const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LeadSiteHome-DaesDA5v.js","assets/SearchAutocomplete-Cl4AfQiH.js","assets/CityPagesModule-Cii2Pu1h.js","assets/imageOptimization-rphVJGSj.js","assets/LeadSiteLuxuryHome-CGbhROvc.js","assets/LeadSiteLandRanchHome-IS8Aiui3.js","assets/LeadSiteSearch-Wkz4kH4m.js","assets/SaveSearchButton-BBKtmFuO.js","assets/LeadSiteMap-BYTSKAFa.js","assets/LeadSiteLuxurySearch-DOAWShdx.js","assets/LeadSiteListingDetail-BeLYyT6v.js","assets/SimilarListings-DJSsCtLi.js","assets/LeadSiteLuxuryListingDetail-Cnr4nowm.js","assets/LeadSiteCityPage-CUvZM_Li.js","assets/PostcardManager-CkLKvV8Q.js","assets/usePostcardZones-C1ASOHAe.js","assets/DirectMail-C5ZmPrXe.js","assets/LeadSiteEditor-diR5mQes.js","assets/VideoUrlField-FddRe15g.js","assets/LeadSiteEditor-BzY4kI8E.css","assets/AdminLeadSiteThemes-DivzmJqf.js","assets/EmailCampaignComposer-i4EycNbA.js","assets/EditorModeSelector-DLAAw3wI.js","assets/SharedCampaignTemplates-CNl6Fj4z.js","assets/TemplateEditorDialog-C8S3R7NN.js","assets/AgentTemplates-Cei_4jdh.js","assets/TheLocalMoveHome-C68SePJl.js","assets/tlm-hero-bg-BbD3acLf.js","assets/TheLocalMoveGetStarted-Bj3_dYUl.js"])))=>i.map(i=>d[i]); var Pmt=Object.defineProperty;var oAe=t=>{throw TypeError(t)};var Imt=(t,s,r)=>s in t?Pmt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var Sn=(t,s,r)=>Imt(t,typeof s!="symbol"?s+"":s,r),fxe=(t,s,r)=>s.has(t)||oAe("Cannot "+r);var ds=(t,s,r)=>(fxe(t,s,"read from private field"),r?r.call(t):s.get(t)),Oa=(t,s,r)=>s.has(t)?oAe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),Fn=(t,s,r,n)=>(fxe(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),Pi=(t,s,r)=>(fxe(t,s,"access private method"),r);var H7=(t,s,r,n)=>({set _(a){Fn(t,s,a,r)},get _(){return ds(t,s,n)}});function Lmt(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 Dmt="modulepreload",Rmt=function(t){return"/"+t},lAe={},Ha=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=Rmt(d),d in lAe)return;lAe[d]=!0;const u=d.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const x=document.createElement("link");if(x.rel=u?"stylesheet":Dmt,u||(x.as="script"),x.crossOrigin="",x.href=d,i&&x.setAttribute("nonce",i),document.head.appendChild(x),u)return new Promise((y,_)=>{x.addEventListener("load",y),x.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 md=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function so(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Omt(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 uBe={exports:{}},Ade={},hBe={exports:{}},Hi={};/** * @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 mR=Symbol.for("react.element"),Fmt=Symbol.for("react.portal"),zmt=Symbol.for("react.fragment"),Bmt=Symbol.for("react.strict_mode"),$mt=Symbol.for("react.profiler"),qmt=Symbol.for("react.provider"),Umt=Symbol.for("react.context"),Vmt=Symbol.for("react.forward_ref"),Hmt=Symbol.for("react.suspense"),Gmt=Symbol.for("react.memo"),Wmt=Symbol.for("react.lazy"),cAe=Symbol.iterator;function Kmt(t){return t===null||typeof t!="object"?null:(t=cAe&&t[cAe]||t["@@iterator"],typeof t=="function"?t:null)}var mBe={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},pBe=Object.assign,fBe={};function CA(t,s,r){this.props=t,this.context=s,this.refs=fBe,this.updater=r||mBe}CA.prototype.isReactComponent={};CA.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")};CA.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function xBe(){}xBe.prototype=CA.prototype;function t2e(t,s,r){this.props=t,this.context=s,this.refs=fBe,this.updater=r||mBe}var s2e=t2e.prototype=new xBe;s2e.constructor=t2e;pBe(s2e,CA.prototype);s2e.isPureReactComponent=!0;var dAe=Array.isArray,gBe=Object.prototype.hasOwnProperty,r2e={current:null},yBe={key:!0,ref:!0,__self:!0,__source:!0};function vBe(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)gBe.call(s,n)&&!yBe.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,we=oe[he];if(0>>1;hea(Te,_e))Mea(Fe,Te)?(oe[he]=Fe,oe[Me]=_e,he=Me):(oe[he]=Te,oe[Ue]=_e,he=Ue);else if(Mea(Fe,_e))oe[he]=Fe,oe[Me]=_e,he=Me;else break e}}return pe}function a(oe,pe){var _e=oe.sortIndex-pe.sortIndex;return _e!==0?_e:oe.id-pe.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var l=Date,i=l.now();t.unstable_now=function(){return l.now()-i}}var d=[],u=[],p=1,x=null,y=3,_=!1,b=!1,N=!1,w=typeof setTimeout=="function"?setTimeout:null,k=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 E(oe){for(var pe=r(u);pe!==null;){if(pe.callback===null)n(u);else if(pe.startTime<=oe)n(u),pe.sortIndex=pe.expirationTime,s(d,pe);else break;pe=r(u)}}function L(oe){if(N=!1,E(oe),!b)if(r(d)!==null)b=!0,ie(I);else{var pe=r(u);pe!==null&&ae(L,pe.startTime-oe)}}function I(oe,pe){b=!1,N&&(N=!1,k(q),q=-1),_=!0;var _e=y;try{for(E(pe),x=r(d);x!==null&&(!(x.expirationTime>pe)||oe&&!se());){var he=x.callback;if(typeof he=="function"){x.callback=null,y=x.priorityLevel;var we=he(x.expirationTime<=pe);pe=t.unstable_now(),typeof we=="function"?x.callback=we:x===r(d)&&n(d),E(pe)}else n(d);x=r(d)}if(x!==null)var je=!0;else{var Ue=r(u);Ue!==null&&ae(L,Ue.startTime-pe),je=!1}return je}finally{x=null,y=_e,_=!1}}var O=!1,V=null,q=-1,$=5,U=-1;function se(){return!(t.unstable_now()-U<$)}function Y(){if(V!==null){var oe=t.unstable_now();U=oe;var pe=!0;try{pe=V(!0,oe)}finally{pe?J():(O=!1,V=null)}}else O=!1}var J;if(typeof C=="function")J=function(){C(Y)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,ce=X.port2;X.port1.onmessage=Y,J=function(){ce.postMessage(null)}}else J=function(){w(Y,0)};function ie(oe){V=oe,O||(O=!0,J())}function ae(oe,pe){q=w(function(){oe(t.unstable_now())},pe)}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(oe){oe.callback=null},t.unstable_continueExecution=function(){b||_||(b=!0,ie(I))},t.unstable_forceFrameRate=function(oe){0>oe||125he?(oe.sortIndex=_e,s(u,oe),r(d)===null&&oe===r(u)&&(N?(k(q),q=-1):N=!0,ae(L,_e-he))):(oe.sortIndex=we,s(d,oe),b||_||(b=!0,ie(I))),oe},t.unstable_shouldYield=se,t.unstable_wrapCallback=function(oe){var pe=y;return function(){var _e=y;y=pe;try{return oe.apply(this,arguments)}finally{y=_e}}}})(NBe);jBe.exports=NBe;var apt=jBe.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 ipt=S,ff=apt;function Vr(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"),C0e=Object.prototype.hasOwnProperty,opt=/^[: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]*$/,hAe={},mAe={};function lpt(t){return C0e.call(mAe,t)?!0:C0e.call(hAe,t)?!1:opt.test(t)?mAe[t]=!0:(hAe[t]=!0,!1)}function cpt(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 dpt(t,s,r,n){if(s===null||typeof s>"u"||cpt(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 Dm(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 Dm(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 Dm(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){ph[t]=new Dm(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){ph[t]=new Dm(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 Dm(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){ph[t]=new Dm(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){ph[t]=new Dm(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){ph[t]=new Dm(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){ph[t]=new Dm(t,5,!1,t.toLowerCase(),null,!1,!1)});var i2e=/[\-:]([a-z])/g;function o2e(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(i2e,o2e);ph[s]=new Dm(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(i2e,o2e);ph[s]=new Dm(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(i2e,o2e);ph[s]=new Dm(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){ph[t]=new Dm(t,1,!1,t.toLowerCase(),null,!1,!1)});ph.xlinkHref=new Dm("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){ph[t]=new Dm(t,1,!1,t.toLowerCase(),null,!0,!0)});function l2e(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{yxe=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?wI(t):""}function upt(t){switch(t.tag){case 5:return wI(t.type);case 16:return wI("Lazy");case 13:return wI("Suspense");case 19:return wI("SuspenseList");case 0:case 2:case 15:return t=vxe(t.type,!1),t;case 11:return t=vxe(t.type.render,!1),t;case 1:return t=vxe(t.type,!0),t;default:return""}}function E0e(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 F5:return"Fragment";case O5:return"Portal";case M0e:return"Profiler";case c2e:return"StrictMode";case T0e:return"Suspense";case A0e:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case CBe:return(t.displayName||"Context")+".Consumer";case SBe:return(t._context.displayName||"Context")+".Provider";case d2e:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case u2e:return s=t.displayName||null,s!==null?s:E0e(t.type)||"Memo";case M_:s=t._payload,t=t._init;try{return E0e(t(s))}catch{}}return null}function hpt(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 E0e(s);case 8:return s===c2e?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function qb(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function TBe(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function mpt(t){var s=TBe(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 K7(t){t._valueTracker||(t._valueTracker=mpt(t))}function ABe(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=TBe(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function loe(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 P0e(t,s){var r=s.checked;return Bc({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function fAe(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=qb(s.value!=null?s.value:r),t._wrapperState={initialChecked:n,initialValue:r,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function EBe(t,s){s=s.checked,s!=null&&l2e(t,"checked",s,!1)}function I0e(t,s){EBe(t,s);var r=qb(s.value),n=s.type;if(r!=null)n==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+r):t.value!==""+r&&(t.value=""+r);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}s.hasOwnProperty("value")?L0e(t,s.type,r):s.hasOwnProperty("defaultValue")&&L0e(t,s.type,qb(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function xAe(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 L0e(t,s,r){(s!=="number"||loe(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var jI=Array.isArray;function lM(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=Z7.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function M8(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var qI={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},ppt=["Webkit","ms","Moz","O"];Object.keys(qI).forEach(function(t){ppt.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),qI[s]=qI[t]})});function DBe(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||qI.hasOwnProperty(t)&&qI[t]?(""+s).trim():s+"px"}function RBe(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=DBe(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var fpt=Bc({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 O0e(t,s){if(s){if(fpt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Vr(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Vr(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Vr(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Vr(62))}}function F0e(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 z0e=null;function h2e(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var B0e=null,cM=null,dM=null;function vAe(t){if(t=xR(t)){if(typeof B0e!="function")throw Error(Vr(280));var s=t.stateNode;s&&(s=Dde(s),B0e(t.stateNode,t.type,s))}}function OBe(t){cM?dM?dM.push(t):dM=[t]:cM=t}function FBe(){if(cM){var t=cM,s=dM;if(dM=cM=null,vAe(t),s)for(t=0;t>>=0,t===0?32:31-(Spt(t)/Cpt|0)|0}var Y7=64,X7=4194304;function NI(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 hoe(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=NI(i):(o&=l,o!==0&&(n=NI(o)))}else l=r&~a,l!==0?n=NI(l):o!==0&&(n=NI(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 pR(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Mg(s),t[s]=r}function Ept(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=VI),MAe=" ",TAe=!1;function n$e(t,s){switch(t){case"keyup":return aft.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function a$e(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var z5=!1;function oft(t,s){switch(t){case"compositionend":return a$e(s);case"keypress":return s.which!==32?null:(TAe=!0,MAe);case"textInput":return t=s.data,t===MAe&&TAe?null:t;default:return null}}function lft(t,s){if(z5)return t==="compositionend"||!_2e&&n$e(t,s)?(t=s$e(),L9=g2e=nb=null,z5=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:r,offset:s-t};t=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=IAe(r)}}function c$e(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?c$e(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function d$e(){for(var t=window,s=loe();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=loe(t.document)}return s}function b2e(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 gft(t){var s=d$e(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&c$e(r.ownerDocument.documentElement,r)){if(n!==null&&b2e(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=LAe(r,o);var l=LAe(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,B5=null,G0e=null,GI=null,W0e=!1;function DAe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;W0e||B5==null||B5!==loe(n)||(n=B5,"selectionStart"in n&&b2e(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}),GI&&L8(GI,n)||(GI=n,n=foe(G0e,"onSelect"),0U5||(t.current=J0e[U5],J0e[U5]=null,U5--)}function Sl(t,s){U5++,J0e[U5]=t.current,t.current=s}var Ub={},Fh=iw(Ub),dp=iw(!1),LS=Ub;function gT(t,s){var r=t.type.contextTypes;if(!r)return Ub;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 up(t){return t=t.childContextTypes,t!=null}function goe(){Jl(dp),Jl(Fh)}function qAe(t,s,r){if(Fh.current!==Ub)throw Error(Vr(168));Sl(Fh,s),Sl(dp,r)}function v$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(Vr(108,hpt(t)||"Unknown",a));return Bc({},r,n)}function yoe(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Ub,LS=Fh.current,Sl(Fh,t),Sl(dp,dp.current),!0}function UAe(t,s,r){var n=t.stateNode;if(!n)throw Error(Vr(169));r?(t=v$e(t,s,LS),n.__reactInternalMemoizedMergedChildContext=t,Jl(dp),Jl(Fh),Sl(Fh,t)):Jl(dp),Sl(dp,r)}var kv=null,Rde=!1,Ixe=!1;function _$e(t){kv===null?kv=[t]:kv.push(t)}function Tft(t){Rde=!0,_$e(t)}function ow(){if(!Ixe&&kv!==null){Ixe=!0;var t=0,s=Zo;try{var r=kv;for(Zo=1;t>=l,a-=l,Rv=1<<32-Mg(s)+a|r<q?($=V,V=null):$=V.sibling;var U=y(k,V,E[q],L);if(U===null){V===null&&(V=$);break}t&&V&&U.alternate===null&&s(k,V),C=o(U,C,q),O===null?I=U:O.sibling=U,O=U,V=$}if(q===E.length)return r(k,V),fc&&$2(k,q),I;if(V===null){for(;qq?($=V,V=null):$=V.sibling;var se=y(k,V,U.value,L);if(se===null){V===null&&(V=$);break}t&&V&&se.alternate===null&&s(k,V),C=o(se,C,q),O===null?I=se:O.sibling=se,O=se,V=$}if(U.done)return r(k,V),fc&&$2(k,q),I;if(V===null){for(;!U.done;q++,U=E.next())U=x(k,U.value,L),U!==null&&(C=o(U,C,q),O===null?I=U:O.sibling=U,O=U);return fc&&$2(k,q),I}for(V=n(k,V);!U.done;q++,U=E.next())U=_(V,k,q,U.value,L),U!==null&&(t&&U.alternate!==null&&V.delete(U.key===null?q:U.key),C=o(U,C,q),O===null?I=U:O.sibling=U,O=U);return t&&V.forEach(function(Y){return s(k,Y)}),fc&&$2(k,q),I}function w(k,C,E,L){if(typeof E=="object"&&E!==null&&E.type===F5&&E.key===null&&(E=E.props.children),typeof E=="object"&&E!==null){switch(E.$$typeof){case W7:e:{for(var I=E.key,O=C;O!==null;){if(O.key===I){if(I=E.type,I===F5){if(O.tag===7){r(k,O.sibling),C=a(O,E.props.children),C.return=k,k=C;break e}}else if(O.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===M_&&GAe(I)===O.type){r(k,O.sibling),C=a(O,E.props),C.ref=B6(k,O,E),C.return=k,k=C;break e}r(k,O);break}else s(k,O);O=O.sibling}E.type===F5?(C=z4(E.props.children,k.mode,L,E.key),C.return=k,k=C):(L=q9(E.type,E.key,E.props,null,k.mode,L),L.ref=B6(k,C,E),L.return=k,k=L)}return l(k);case O5:e:{for(O=E.key;C!==null;){if(C.key===O)if(C.tag===4&&C.stateNode.containerInfo===E.containerInfo&&C.stateNode.implementation===E.implementation){r(k,C.sibling),C=a(C,E.children||[]),C.return=k,k=C;break e}else{r(k,C);break}else s(k,C);C=C.sibling}C=$xe(E,k.mode,L),C.return=k,k=C}return l(k);case M_:return O=E._init,w(k,C,O(E._payload),L)}if(jI(E))return b(k,C,E,L);if(D6(E))return N(k,C,E,L);nz(k,E)}return typeof E=="string"&&E!==""||typeof E=="number"?(E=""+E,C!==null&&C.tag===6?(r(k,C.sibling),C=a(C,E),C.return=k,k=C):(r(k,C),C=Bxe(E,k.mode,L),C.return=k,k=C),l(k)):r(k,C)}return w}var vT=N$e(!0),k$e=N$e(!1),boe=iw(null),woe=null,G5=null,k2e=null;function S2e(){k2e=G5=woe=null}function C2e(t){var s=boe.current;Jl(boe),t._currentValue=s}function sve(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 hM(t,s){woe=t,k2e=G5=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(ap=!0),t.firstContext=null)}function Nx(t){var s=t._currentValue;if(k2e!==t)if(t={context:t,memoizedValue:s,next:null},G5===null){if(woe===null)throw Error(Vr(308));G5=t,woe.dependencies={lanes:0,firstContext:t}}else G5=G5.next=t;return s}var d4=null;function M2e(t){d4===null?d4=[t]:d4.push(t)}function S$e(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,M2e(s)):(r.next=a.next,a.next=r),s.interleaved=r,c1(t,n)}function c1(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 T_=!1;function T2e(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function C$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 Vv(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function gb(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,po&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,c1(t,r)}return a=n.interleaved,a===null?(s.next=s,M2e(n)):(s.next=a.next,a.next=s),n.interleaved=s,c1(t,r)}function R9(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,p2e(t,r)}}function WAe(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 joe(t,s,r,n){var a=t.updateQueue;T_=!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 x=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"){x=b.call(_,x,y);break e}x=b;break e;case 3:b.flags=b.flags&-65537|128;case 0:if(b=N.payload,y=typeof b=="function"?b.call(_,x,y):b,y==null)break e;x=Bc({},x,y);break e;case 2:T_=!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=x):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=x),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);OS|=l,t.lanes=l,t.memoizedState=x}}function KAe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=Dxe.transition;Dxe.transition={};try{t(!1),s()}finally{Zo=r,Dxe.transition=n}}function V$e(){return kx().memoizedState}function Ift(t,s,r){var n=vb(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},H$e(t))G$e(s,r);else if(r=S$e(t,s,r,n),r!==null){var a=km();Tg(r,t,n,a),W$e(r,s,n)}}function Lft(t,s,r){var n=vb(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(H$e(t))G$e(s,a);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=s.lastRenderedReducer,o!==null))try{var l=s.lastRenderedState,i=o(l,r);if(a.hasEagerState=!0,a.eagerState=i,Og(i,l)){var d=s.interleaved;d===null?(a.next=a,M2e(s)):(a.next=d.next,d.next=a),s.interleaved=a;return}}catch{}finally{}r=S$e(t,s,a,n),r!==null&&(a=km(),Tg(r,t,n,a),W$e(r,s,n))}}function H$e(t){var s=t.alternate;return t===Fc||s!==null&&s===Fc}function G$e(t,s){WI=koe=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function W$e(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,p2e(t,r)}}var Soe={readContext:Nx,useCallback:jh,useContext:jh,useEffect:jh,useImperativeHandle:jh,useInsertionEffect:jh,useLayoutEffect:jh,useMemo:jh,useReducer:jh,useRef:jh,useState:jh,useDebugValue:jh,useDeferredValue:jh,useTransition:jh,useMutableSource:jh,useSyncExternalStore:jh,useId:jh,unstable_isNewReconciler:!1},Dft={readContext:Nx,useCallback:function(t,s){return Sy().memoizedState=[t,s===void 0?null:s],t},useContext:Nx,useEffect:YAe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,F9(4194308,4,z$e.bind(null,s,t),r)},useLayoutEffect:function(t,s){return F9(4194308,4,t,s)},useInsertionEffect:function(t,s){return F9(4,2,t,s)},useMemo:function(t,s){var r=Sy();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=Sy();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=Ift.bind(null,Fc,t),[n.memoizedState,t]},useRef:function(t){var s=Sy();return t={current:t},s.memoizedState=t},useState:ZAe,useDebugValue:O2e,useDeferredValue:function(t){return Sy().memoizedState=t},useTransition:function(){var t=ZAe(!1),s=t[0];return t=Pft.bind(null,t[1]),Sy().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=Fc,a=Sy();if(fc){if(r===void 0)throw Error(Vr(407));r=r()}else{if(r=s(),Ru===null)throw Error(Vr(349));RS&30||E$e(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,YAe(I$e.bind(null,n,o,t),[t]),n.flags|=2048,q8(9,P$e.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=Sy(),s=Ru.identifierPrefix;if(fc){var r=Ov,n=Rv;r=(n&~(1<<32-Mg(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=B8++,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[Oy]=s,t[O8]=n,rqe(t,s,!1,!1),s.stateNode=t;e:{switch(l=F0e(r,n),r){case"dialog":Vl("cancel",t),Vl("close",t),a=n;break;case"iframe":case"object":case"embed":Vl("load",t),a=n;break;case"video":case"audio":for(a=0;awT&&(s.flags|=128,n=!0,$6(o,!1),s.lanes=4194304)}else{if(!n)if(t=Noe(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),$6(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!fc)return Nh(s),null}else 2*hd()-o.renderingStartTime>wT&&r!==1073741824&&(s.flags|=128,n=!0,$6(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=hd(),s.sibling=null,r=Lc.current,Sl(Lc,n?r&1|2:r&1),s):(Nh(s),null);case 22:case 23:return U2e(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?Gp&1073741824&&(Nh(s),s.subtreeFlags&6&&(s.flags|=8192)):Nh(s),null;case 24:return null;case 25:return null}throw Error(Vr(156,s.tag))}function Uft(t,s){switch(j2e(s),s.tag){case 1:return up(s.type)&&goe(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return _T(),Jl(dp),Jl(Fh),P2e(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return E2e(s),null;case 13:if(Jl(Lc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Vr(340));yT()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return Jl(Lc),null;case 4:return _T(),null;case 10:return C2e(s.type._context),null;case 22:case 23:return U2e(),null;case 24:return null;default:return null}}var iz=!1,Th=!1,Vft=typeof WeakSet=="function"?WeakSet:Set,Zn=null;function W5(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 uve(t,s,r){try{r()}catch(n){Kc(t,s,n)}}var oEe=!1;function Hft(t,s){if(K0e=moe,t=d$e(),b2e(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,x=t,y=null;t:for(;;){for(var _;x!==r||a!==0&&x.nodeType!==3||(i=l+a),x!==o||n!==0&&x.nodeType!==3||(d=l+n),x.nodeType===3&&(l+=x.nodeValue.length),(_=x.firstChild)!==null;)y=x,x=_;for(;;){if(x===t)break t;if(y===r&&++u===a&&(i=l),y===o&&++p===n&&(d=l),(_=x.nextSibling)!==null)break;x=y,y=x.parentNode}x=_}r=i===-1||d===-1?null:{start:i,end:d}}else r=null}r=r||{start:0,end:0}}else r=null;for(Z0e={focusedElem:t,selectionRange:r},moe=!1,Zn=s;Zn!==null;)if(s=Zn,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,Zn=t;else for(;Zn!==null;){s=Zn;try{var b=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(b!==null){var N=b.memoizedProps,w=b.memoizedState,k=s.stateNode,C=k.getSnapshotBeforeUpdate(s.elementType===s.type?N:hg(s.type,N),w);k.__reactInternalSnapshotBeforeUpdate=C}break;case 3:var E=s.stateNode.containerInfo;E.nodeType===1?E.textContent="":E.nodeType===9&&E.documentElement&&E.removeChild(E.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Vr(163))}}catch(L){Kc(s,s.return,L)}if(t=s.sibling,t!==null){t.return=s.return,Zn=t;break}Zn=s.return}return b=oEe,oEe=!1,b}function KI(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&&uve(s,r,o)}a=a.next}while(a!==n)}}function zde(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 hve(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 iqe(t){var s=t.alternate;s!==null&&(t.alternate=null,iqe(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[Oy],delete s[O8],delete s[Q0e],delete s[Cft],delete s[Mft])),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 oqe(t){return t.tag===5||t.tag===3||t.tag===4}function lEe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||oqe(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 mve(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=xoe));else if(n!==4&&(t=t.child,t!==null))for(mve(t,s,r),t=t.sibling;t!==null;)mve(t,s,r),t=t.sibling}function pve(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(pve(t,s,r),t=t.sibling;t!==null;)pve(t,s,r),t=t.sibling}var Qu=null,fg=!1;function u_(t,s,r){for(r=r.child;r!==null;)lqe(t,s,r),r=r.sibling}function lqe(t,s,r){if(Hy&&typeof Hy.onCommitFiberUnmount=="function")try{Hy.onCommitFiberUnmount(Ede,r)}catch{}switch(r.tag){case 5:Th||W5(r,s);case 6:var n=Qu,a=fg;Qu=null,u_(t,s,r),Qu=n,fg=a,Qu!==null&&(fg?(t=Qu,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):Qu.removeChild(r.stateNode));break;case 18:Qu!==null&&(fg?(t=Qu,r=r.stateNode,t.nodeType===8?Pxe(t.parentNode,r):t.nodeType===1&&Pxe(t,r),P8(t)):Pxe(Qu,r.stateNode));break;case 4:n=Qu,a=fg,Qu=r.stateNode.containerInfo,fg=!0,u_(t,s,r),Qu=n,fg=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)&&uve(r,s,l),a=a.next}while(a!==n)}u_(t,s,r);break;case 1:if(!Th&&(W5(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)}u_(t,s,r);break;case 21:u_(t,s,r);break;case 22:r.mode&1?(Th=(n=Th)||r.memoizedState!==null,u_(t,s,r),Th=n):u_(t,s,r);break;default:u_(t,s,r)}}function cEe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new Vft),s.forEach(function(n){var a=ext.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function ag(t,s){var r=s.deletions;if(r!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=hd()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*Wft(n/1960))-n,10t?16:t,ab===null)var n=!1;else{if(t=ab,ab=null,Toe=0,po&6)throw Error(Vr(331));var a=po;for(po|=4,Zn=t.current;Zn!==null;){var o=Zn,l=o.child;if(Zn.flags&16){var i=o.deletions;if(i!==null){for(var d=0;dhd()-$2e?F4(t,0):B2e|=r),hp(t,s)}function xqe(t,s){s===0&&(t.mode&1?(s=X7,X7<<=1,!(X7&130023424)&&(X7=4194304)):s=1);var r=km();t=c1(t,s),t!==null&&(pR(t,s,r),hp(t,r))}function Jft(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),xqe(t,r)}function ext(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(Vr(314))}n!==null&&n.delete(s),xqe(t,r)}var gqe;gqe=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||dp.current)ap=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return ap=!1,$ft(t,s,r);ap=!!(t.flags&131072)}else ap=!1,fc&&s.flags&1048576&&b$e(s,_oe,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;z9(t,s),t=s.pendingProps;var a=gT(s,Fh.current);hM(s,r),a=L2e(null,s,n,t,a,r);var o=D2e();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,up(n)?(o=!0,yoe(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,T2e(s),a.updater=Fde,s.stateNode=a,a._reactInternals=s,nve(s,n,t,r),s=ove(null,s,n,!0,o,r)):(s.tag=0,fc&&o&&w2e(s),mm(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(z9(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=sxt(n),t=hg(n,t),a){case 0:s=ive(null,s,n,t,r);break e;case 1:s=nEe(null,s,n,t,r);break e;case 11:s=sEe(null,s,n,t,r);break e;case 14:s=rEe(null,s,n,hg(n.type,t),r);break e}throw Error(Vr(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:hg(n,a),ive(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:hg(n,a),nEe(t,s,n,a,r);case 3:e:{if(eqe(s),t===null)throw Error(Vr(387));n=s.pendingProps,o=s.memoizedState,a=o.element,C$e(t,s),joe(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=bT(Error(Vr(423)),s),s=aEe(t,s,n,r,a);break e}else if(n!==a){a=bT(Error(Vr(424)),s),s=aEe(t,s,n,r,a);break e}else for(ef=xb(s.stateNode.containerInfo.firstChild),sf=s,fc=!0,_g=null,r=k$e(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(yT(),n===a){s=d1(t,s,r);break e}mm(t,s,n,r)}s=s.child}return s;case 5:return M$e(s),t===null&&tve(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,Y0e(n,a)?l=null:o!==null&&Y0e(n,o)&&(s.flags|=32),J$e(t,s),mm(t,s,l,r),s.child;case 6:return t===null&&tve(s),null;case 13:return tqe(t,s,r);case 4:return A2e(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=vT(s,null,n,r):mm(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:hg(n,a),sEe(t,s,n,a,r);case 7:return mm(t,s,s.pendingProps,r),s.child;case 8:return mm(t,s,s.pendingProps.children,r),s.child;case 12:return mm(t,s,s.pendingProps.children,r),s.child;case 10:e:{if(n=s.type._context,a=s.pendingProps,o=s.memoizedProps,l=a.value,Sl(boe,n._currentValue),n._currentValue=l,o!==null)if(Og(o.value,l)){if(o.children===a.children&&!dp.current){s=d1(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=Vv(-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),sve(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(Vr(341));l.lanes|=r,i=l.alternate,i!==null&&(i.lanes|=r),sve(l,r,s),l=o.sibling}else l=o.child;if(l!==null)l.return=o;else for(l=o;l!==null;){if(l===s){l=null;break}if(o=l.sibling,o!==null){o.return=l.return,l=o;break}l=l.return}o=l}mm(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,hM(s,r),a=Nx(a),n=n(a),s.flags|=1,mm(t,s,n,r),s.child;case 14:return n=s.type,a=hg(n,s.pendingProps),a=hg(n.type,a),rEe(t,s,n,a,r);case 15:return X$e(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:hg(n,a),z9(t,s),s.tag=1,up(n)?(t=!0,yoe(s)):t=!1,hM(s,r),K$e(s,n,a),nve(s,n,a,r),ove(null,s,n,!0,t,r);case 19:return sqe(t,s,r);case 22:return Q$e(t,s,r)}throw Error(Vr(156,s.tag))};function yqe(t,s){return HBe(t,s)}function txt(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 dx(t,s,r,n){return new txt(t,s,r,n)}function H2e(t){return t=t.prototype,!(!t||!t.isReactComponent)}function sxt(t){if(typeof t=="function")return H2e(t)?1:0;if(t!=null){if(t=t.$$typeof,t===d2e)return 11;if(t===u2e)return 14}return 2}function _b(t,s){var r=t.alternate;return r===null?(r=dx(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 q9(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")H2e(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case F5:return z4(r.children,a,o,s);case c2e:l=8,a|=8;break;case M0e:return t=dx(12,r,s,a|2),t.elementType=M0e,t.lanes=o,t;case T0e:return t=dx(13,r,s,a),t.elementType=T0e,t.lanes=o,t;case A0e:return t=dx(19,r,s,a),t.elementType=A0e,t.lanes=o,t;case MBe:return $de(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case SBe:l=10;break e;case CBe:l=9;break e;case d2e:l=11;break e;case u2e:l=14;break e;case M_:l=16,n=null;break e}throw Error(Vr(130,t==null?t:typeof t,""))}return s=dx(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function z4(t,s,r,n){return t=dx(7,t,n,s),t.lanes=r,t}function $de(t,s,r,n){return t=dx(22,t,n,s),t.elementType=MBe,t.lanes=r,t.stateNode={isHidden:!1},t}function Bxe(t,s,r){return t=dx(6,t,null,s),t.lanes=r,t}function $xe(t,s,r){return s=dx(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function rxt(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=bxe(0),this.expirationTimes=bxe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=bxe(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function G2e(t,s,r,n,a,o,l,i,d){return t=new rxt(t,s,r,i,d),s===1?(s=1,o===!0&&(s|=8)):s=0,o=dx(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},T2e(o),t}function nxt(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(wqe)}catch(t){console.error(t)}}wqe(),wBe.exports=bf;var ip=wBe.exports;const Y2e=so(ip);var jqe,gEe=ip;jqe=gEe.createRoot,gEe.hydrateRoot;const cxt=1,dxt=1e6;let qxe=0;function uxt(){return qxe=(qxe+1)%Number.MAX_SAFE_INTEGER,qxe.toString()}const Uxe=new Map,yEe=t=>{if(Uxe.has(t))return;const s=setTimeout(()=>{Uxe.delete(t),XI({type:"REMOVE_TOAST",toastId:t})},dxt);Uxe.set(t,s)},hxt=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,cxt)};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?yEe(r):t.toasts.forEach(n=>{yEe(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)}}},U9=[];let V9={toasts:[]};function XI(t){V9=hxt(V9,t),U9.forEach(s=>{s(V9)})}function gn({...t}){const s=uxt(),r=a=>XI({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>XI({type:"DISMISS_TOAST",toastId:s});return XI({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function wa(){const[t,s]=S.useState(V9);return S.useEffect(()=>(U9.push(s),()=>{const r=U9.indexOf(s);r>-1&&U9.splice(r,1)}),[t]),{...t,toast:gn,dismiss:r=>XI({type:"DISMISS_TOAST",toastId:r})}}function Cr(t,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(t==null||t(a),r===!1||!a.defaultPrevented)return s==null?void 0:s(a)}}function vEe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function u1(...t){return s=>{let r=!1;const n=t.map(a=>{const o=vEe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,d=S.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:d,children:l})};n.displayName=t+"Provider";function a(o){const l=S.useContext(r);if(l)return l;if(s!==void 0)return s;throw new Error(`\`${o}\` must be used within \`${t}\``)}return[n,a]}function $c(t,s=[]){let r=[];function n(o,l){const i=S.createContext(l),d=r.length;r=[...r,l];const u=x=>{var k;const{scope:y,children:_,...b}=x,N=((k=y==null?void 0:y[t])==null?void 0:k[d])||i,w=S.useMemo(()=>b,Object.values(b));return e.jsx(N.Provider,{value:w,children:_})};u.displayName=o+"Provider";function p(x,y){var N;const _=((N=y==null?void 0:y[t])==null?void 0:N[d])||i,b=S.useContext(_);if(b)return b;if(l!==void 0)return l;throw new Error(`\`${x}\` must be used within \`${o}\``)}return[u,p]}const a=()=>{const o=r.map(l=>S.createContext(l));return function(i){const d=(i==null?void 0:i[t])||o;return S.useMemo(()=>({[`__scope${t}`]:{...i,[t]:d}}),[i,d])}};return a.scopeName=t,[n,pxt(a,...s)]}function pxt(...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 x=d(o)[`__scope${u}`];return{...i,...x}},{});return S.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function Vb(t){const s=fxt(t),r=S.forwardRef((n,a)=>{const{children:o,...l}=n,i=S.Children.toArray(o),d=i.find(xxt);if(d){const u=d.props.children,p=i.map(x=>x===d?S.Children.count(u)>1?S.Children.only(null):S.isValidElement(u)?u.props.children:null:x);return e.jsx(s,{...l,ref:a,children:S.isValidElement(u)?S.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var X2e=Vb("Slot");function fxt(t){const s=S.forwardRef((r,n)=>{const{children:a,...o}=r;if(S.isValidElement(a)){const l=yxt(a),i=gxt(o,a.props);return a.type!==S.Fragment&&(i.ref=n?u1(n,l):l),S.cloneElement(a,i)}return S.Children.count(a)>1?S.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var Nqe=Symbol("radix.slottable");function kqe(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=Nqe,s}function xxt(t){return S.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Nqe}function gxt(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 yxt(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 yR(t){const s=t+"CollectionProvider",[r,n]=$c(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=N=>{const{scope:w,children:k}=N,C=ft.useRef(null),E=ft.useRef(new Map).current;return e.jsx(a,{scope:w,itemMap:E,collectionRef:C,children:k})};l.displayName=s;const i=t+"CollectionSlot",d=Vb(i),u=ft.forwardRef((N,w)=>{const{scope:k,children:C}=N,E=o(i,k),L=Aa(w,E.collectionRef);return e.jsx(d,{ref:L,children:C})});u.displayName=i;const p=t+"CollectionItemSlot",x="data-radix-collection-item",y=Vb(p),_=ft.forwardRef((N,w)=>{const{scope:k,children:C,...E}=N,L=ft.useRef(null),I=Aa(w,L),O=o(p,k);return ft.useEffect(()=>(O.itemMap.set(L,{ref:L,...E}),()=>void O.itemMap.delete(L))),e.jsx(y,{[x]:"",ref:I,children:C})});_.displayName=p;function b(N){const w=o(t+"CollectionConsumer",N);return ft.useCallback(()=>{const C=w.collectionRef.current;if(!C)return[];const E=Array.from(C.querySelectorAll(`[${x}]`));return Array.from(w.itemMap.values()).sort((O,V)=>E.indexOf(O.ref.current)-E.indexOf(V.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:l,Slot:u,ItemSlot:_},b,n]}var vxt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Yr=vxt.reduce((t,s)=>{const r=Vb(`Primitive.${s}`),n=S.forwardRef((a,o)=>{const{asChild:l,...i}=a,d=l?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...i,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{});function Q2e(t,s){t&&ip.flushSync(()=>t.dispatchEvent(s))}function ed(t){const s=S.useRef(t);return S.useEffect(()=>{s.current=t}),S.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function _xt(t,s=globalThis==null?void 0:globalThis.document){const r=ed(t);S.useEffect(()=>{const n=a=>{a.key==="Escape"&&r(a)};return s.addEventListener("keydown",n,{capture:!0}),()=>s.removeEventListener("keydown",n,{capture:!0})},[r,s])}var bxt="DismissableLayer",vve="dismissableLayer.update",wxt="dismissableLayer.pointerDownOutside",jxt="dismissableLayer.focusOutside",_Ee,Sqe=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),lw=S.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...d}=t,u=S.useContext(Sqe),[p,x]=S.useState(null),y=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,_]=S.useState({}),b=Aa(s,V=>x(V)),N=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),k=N.indexOf(w),C=p?N.indexOf(p):-1,E=u.layersWithOutsidePointerEventsDisabled.size>0,L=C>=k,I=kxt(V=>{const q=V.target,$=[...u.branches].some(U=>U.contains(q));!L||$||(a==null||a(V),l==null||l(V),V.defaultPrevented||i==null||i())},y),O=Sxt(V=>{const q=V.target;[...u.branches].some(U=>U.contains(q))||(o==null||o(V),l==null||l(V),V.defaultPrevented||i==null||i())},y);return _xt(V=>{C===u.layers.size-1&&(n==null||n(V),!V.defaultPrevented&&i&&(V.preventDefault(),i()))},y),S.useEffect(()=>{if(p)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(_Ee=y.body.style.pointerEvents,y.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),bEe(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(y.body.style.pointerEvents=_Ee)}},[p,y,r,u]),S.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),bEe())},[p,u]),S.useEffect(()=>{const V=()=>_({});return document.addEventListener(vve,V),()=>document.removeEventListener(vve,V)},[]),e.jsx(Yr.div,{...d,ref:b,style:{pointerEvents:E?L?"auto":"none":void 0,...t.style},onFocusCapture:Cr(t.onFocusCapture,O.onFocusCapture),onBlurCapture:Cr(t.onBlurCapture,O.onBlurCapture),onPointerDownCapture:Cr(t.onPointerDownCapture,I.onPointerDownCapture)})});lw.displayName=bxt;var Nxt="DismissableLayerBranch",Cqe=S.forwardRef((t,s)=>{const r=S.useContext(Sqe),n=S.useRef(null),a=Aa(s,n);return S.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),e.jsx(Yr.div,{...t,ref:a})});Cqe.displayName=Nxt;function kxt(t,s=globalThis==null?void 0:globalThis.document){const r=ed(t),n=S.useRef(!1),a=S.useRef(()=>{});return S.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let d=function(){Mqe(wxt,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 Sxt(t,s=globalThis==null?void 0:globalThis.document){const r=ed(t),n=S.useRef(!1);return S.useEffect(()=>{const a=o=>{o.target&&!n.current&&Mqe(jxt,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 bEe(){const t=new CustomEvent(vve);document.dispatchEvent(t)}function Mqe(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?Q2e(a,o):a.dispatchEvent(o)}var Cxt=lw,Mxt=Cqe,rd=globalThis!=null&&globalThis.document?S.useLayoutEffect:()=>{},Txt="Portal",AA=S.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=S.useState(!1);rd(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?Y2e.createPortal(e.jsx(Yr.div,{...n,ref:s}),l):null});AA.displayName=Txt;function Axt(t,s){return S.useReducer((r,n)=>s[r][n]??r,t)}var wd=t=>{const{present:s,children:r}=t,n=Ext(s),a=typeof r=="function"?r({present:n.isPresent}):S.Children.only(r),o=Aa(n.ref,Pxt(a));return typeof r=="function"||n.isPresent?S.cloneElement(a,{ref:o}):null};wd.displayName="Presence";function Ext(t){const[s,r]=S.useState(),n=S.useRef(null),a=S.useRef(t),o=S.useRef("none"),l=t?"mounted":"unmounted",[i,d]=Axt(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return S.useEffect(()=>{const u=cz(n.current);o.current=i==="mounted"?u:"none"},[i]),rd(()=>{const u=n.current,p=a.current;if(p!==t){const y=o.current,_=cz(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,x=_=>{const N=cz(n.current).includes(_.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=cz(n.current))};return s.addEventListener("animationstart",y),s.addEventListener("animationcancel",x),s.addEventListener("animationend",x),()=>{p.clearTimeout(u),s.removeEventListener("animationstart",y),s.removeEventListener("animationcancel",x),s.removeEventListener("animationend",x)}}else d("ANIMATION_END")},[s,d]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:S.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function cz(t){return(t==null?void 0:t.animationName)||"none"}function Pxt(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 Ixt=a2e[" useInsertionEffect ".trim().toString()]||rd;function $u({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=Lxt({defaultProp:s,onChange:r}),i=t!==void 0,d=i?t:a;{const p=S.useRef(t!==void 0);S.useEffect(()=>{const x=p.current;x!==i&&console.warn(`${n} is changing from ${x?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=i},[i,n])}const u=S.useCallback(p=>{var x;if(i){const y=Dxt(p)?p(t):p;y!==t&&((x=l.current)==null||x.call(l,y))}else o(p)},[i,t,o,l]);return[d,u]}function Lxt({defaultProp:t,onChange:s}){const[r,n]=S.useState(t),a=S.useRef(r),o=S.useRef(s);return Ixt(()=>{o.current=s},[s]),S.useEffect(()=>{var l;a.current!==r&&((l=o.current)==null||l.call(o,r),a.current=r)},[r,a]),[r,n,o]}function Dxt(t){return typeof t=="function"}var Tqe=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"}),Rxt="VisuallyHidden",Gde=S.forwardRef((t,s)=>e.jsx(Yr.span,{...t,ref:s,style:{...Tqe,...t.style}}));Gde.displayName=Rxt;var Oxt=Gde,J2e="ToastProvider",[eje,Fxt,zxt]=yR("Toast"),[Aqe,sTs]=$c("Toast",[zxt]),[Bxt,Wde]=Aqe(J2e),Eqe=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,d]=S.useState(null),[u,p]=S.useState(0),x=S.useRef(!1),y=S.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${J2e}\`. Expected non-empty \`string\`.`),e.jsx(eje.Provider,{scope:s,children:e.jsx(Bxt,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:d,onToastAdd:S.useCallback(()=>p(_=>_+1),[]),onToastRemove:S.useCallback(()=>p(_=>_-1),[]),isFocusedToastEscapeKeyDownRef:x,isClosePausedRef:y,children:l})})};Eqe.displayName=J2e;var Pqe="ToastViewport",$xt=["F8"],_ve="toast.viewportPause",bve="toast.viewportResume",Iqe=S.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=$xt,label:a="Notifications ({hotkey})",...o}=t,l=Wde(Pqe,r),i=Fxt(r),d=S.useRef(null),u=S.useRef(null),p=S.useRef(null),x=S.useRef(null),y=Aa(s,x,l.onViewportChange),_=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=l.toastCount>0;S.useEffect(()=>{const w=k=>{var E;n.length!==0&&n.every(L=>k[L]||k.code===L)&&((E=x.current)==null||E.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[n]),S.useEffect(()=>{const w=d.current,k=x.current;if(b&&w&&k){const C=()=>{if(!l.isClosePausedRef.current){const O=new CustomEvent(_ve);k.dispatchEvent(O),l.isClosePausedRef.current=!0}},E=()=>{if(l.isClosePausedRef.current){const O=new CustomEvent(bve);k.dispatchEvent(O),l.isClosePausedRef.current=!1}},L=O=>{!w.contains(O.relatedTarget)&&E()},I=()=>{w.contains(document.activeElement)||E()};return w.addEventListener("focusin",C),w.addEventListener("focusout",L),w.addEventListener("pointermove",C),w.addEventListener("pointerleave",I),window.addEventListener("blur",C),window.addEventListener("focus",E),()=>{w.removeEventListener("focusin",C),w.removeEventListener("focusout",L),w.removeEventListener("pointermove",C),w.removeEventListener("pointerleave",I),window.removeEventListener("blur",C),window.removeEventListener("focus",E)}}},[b,l.isClosePausedRef]);const N=S.useCallback(({tabbingDirection:w})=>{const C=i().map(E=>{const L=E.ref.current,I=[L,...egt(L)];return w==="forwards"?I:I.reverse()});return(w==="forwards"?C.reverse():C).flat()},[i]);return S.useEffect(()=>{const w=x.current;if(w){const k=C=>{var I,O,V;const E=C.altKey||C.ctrlKey||C.metaKey;if(C.key==="Tab"&&!E){const q=document.activeElement,$=C.shiftKey;if(C.target===w&&$){(I=u.current)==null||I.focus();return}const Y=N({tabbingDirection:$?"backwards":"forwards"}),J=Y.findIndex(X=>X===q);Vxe(Y.slice(J+1))?C.preventDefault():$?(O=u.current)==null||O.focus():(V=p.current)==null||V.focus()}};return w.addEventListener("keydown",k),()=>w.removeEventListener("keydown",k)}},[i,N]),e.jsxs(Mxt,{ref:d,role:"region","aria-label":a.replace("{hotkey}",_),tabIndex:-1,style:{pointerEvents:b?void 0:"none"},children:[b&&e.jsx(wve,{ref:u,onFocusFromOutsideViewport:()=>{const w=N({tabbingDirection:"forwards"});Vxe(w)}}),e.jsx(eje.Slot,{scope:r,children:e.jsx(Yr.ol,{tabIndex:-1,...o,ref:y})}),b&&e.jsx(wve,{ref:p,onFocusFromOutsideViewport:()=>{const w=N({tabbingDirection:"backwards"});Vxe(w)}})]})});Iqe.displayName=Pqe;var Lqe="ToastFocusProxy",wve=S.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=Wde(Lqe,r);return e.jsx(Gde,{"aria-hidden":!0,tabIndex:0,...a,ref:s,style:{position:"fixed"},onFocus:l=>{var u;const i=l.relatedTarget;!((u=o.viewport)!=null&&u.contains(i))&&n()}})});wve.displayName=Lqe;var vR="Toast",qxt="toast.swipeStart",Uxt="toast.swipeMove",Vxt="toast.swipeCancel",Hxt="toast.swipeEnd",Dqe=S.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,d]=$u({prop:n,defaultProp:a??!0,onChange:o,caller:vR});return e.jsx(wd,{present:r||i,children:e.jsx(Kxt,{open:i,...l,ref:s,onClose:()=>d(!1),onPause:ed(t.onPause),onResume:ed(t.onResume),onSwipeStart:Cr(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Cr(t.onSwipeMove,u=>{const{x:p,y:x}=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",`${x}px`)}),onSwipeCancel:Cr(t.onSwipeCancel,u=>{u.currentTarget.setAttribute("data-swipe","cancel"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Cr(t.onSwipeEnd,u=>{const{x:p,y:x}=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",`${x}px`),d(!1)})})})});Dqe.displayName=vR;var[Gxt,Wxt]=Aqe(vR,{onClose(){}}),Kxt=S.forwardRef((t,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:o,onClose:l,onEscapeKeyDown:i,onPause:d,onResume:u,onSwipeStart:p,onSwipeMove:x,onSwipeCancel:y,onSwipeEnd:_,...b}=t,N=Wde(vR,r),[w,k]=S.useState(null),C=Aa(s,X=>k(X)),E=S.useRef(null),L=S.useRef(null),I=a||N.duration,O=S.useRef(0),V=S.useRef(I),q=S.useRef(0),{onToastAdd:$,onToastRemove:U}=N,se=ed(()=>{var ce;(w==null?void 0:w.contains(document.activeElement))&&((ce=N.viewport)==null||ce.focus()),l()}),Y=S.useCallback(X=>{!X||X===1/0||(window.clearTimeout(q.current),O.current=new Date().getTime(),q.current=window.setTimeout(se,X))},[se]);S.useEffect(()=>{const X=N.viewport;if(X){const ce=()=>{Y(V.current),u==null||u()},ie=()=>{const ae=new Date().getTime()-O.current;V.current=V.current-ae,window.clearTimeout(q.current),d==null||d()};return X.addEventListener(_ve,ie),X.addEventListener(bve,ce),()=>{X.removeEventListener(_ve,ie),X.removeEventListener(bve,ce)}}},[N.viewport,I,d,u,Y]),S.useEffect(()=>{o&&!N.isClosePausedRef.current&&Y(I)},[o,I,N.isClosePausedRef,Y]),S.useEffect(()=>($(),()=>U()),[$,U]);const J=S.useMemo(()=>w?qqe(w):null,[w]);return N.viewport?e.jsxs(e.Fragment,{children:[J&&e.jsx(Zxt,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:J}),e.jsx(Gxt,{scope:r,onClose:se,children:ip.createPortal(e.jsx(eje.ItemSlot,{scope:r,children:e.jsx(Cxt,{asChild:!0,onEscapeKeyDown:Cr(i,()=>{N.isFocusedToastEscapeKeyDownRef.current||se(),N.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(Yr.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":N.swipeDirection,...b,ref:C,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Cr(t.onKeyDown,X=>{X.key==="Escape"&&(i==null||i(X.nativeEvent),X.nativeEvent.defaultPrevented||(N.isFocusedToastEscapeKeyDownRef.current=!0,se()))}),onPointerDown:Cr(t.onPointerDown,X=>{X.button===0&&(E.current={x:X.clientX,y:X.clientY})}),onPointerMove:Cr(t.onPointerMove,X=>{if(!E.current)return;const ce=X.clientX-E.current.x,ie=X.clientY-E.current.y,ae=!!L.current,oe=["left","right"].includes(N.swipeDirection),pe=["left","up"].includes(N.swipeDirection)?Math.min:Math.max,_e=oe?pe(0,ce):0,he=oe?0:pe(0,ie),we=X.pointerType==="touch"?10:2,je={x:_e,y:he},Ue={originalEvent:X,delta:je};ae?(L.current=je,dz(Uxt,x,Ue,{discrete:!1})):wEe(je,N.swipeDirection,we)?(L.current=je,dz(qxt,p,Ue,{discrete:!1}),X.target.setPointerCapture(X.pointerId)):(Math.abs(ce)>we||Math.abs(ie)>we)&&(E.current=null)}),onPointerUp:Cr(t.onPointerUp,X=>{const ce=L.current,ie=X.target;if(ie.hasPointerCapture(X.pointerId)&&ie.releasePointerCapture(X.pointerId),L.current=null,E.current=null,ce){const ae=X.currentTarget,oe={originalEvent:X,delta:ce};wEe(ce,N.swipeDirection,N.swipeThreshold)?dz(Hxt,_,oe,{discrete:!0}):dz(Vxt,y,oe,{discrete:!0}),ae.addEventListener("click",pe=>pe.preventDefault(),{once:!0})}})})})}),N.viewport)})]}):null}),Zxt=t=>{const{__scopeToast:s,children:r,...n}=t,a=Wde(vR,s),[o,l]=S.useState(!1),[i,d]=S.useState(!1);return Qxt(()=>l(!0)),S.useEffect(()=>{const u=window.setTimeout(()=>d(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(AA,{asChild:!0,children:e.jsx(Gde,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},Yxt="ToastTitle",Rqe=S.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Yr.div,{...n,ref:s})});Rqe.displayName=Yxt;var Xxt="ToastDescription",Oqe=S.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Yr.div,{...n,ref:s})});Oqe.displayName=Xxt;var Fqe="ToastAction",zqe=S.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx($qe,{altText:r,asChild:!0,children:e.jsx(tje,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${Fqe}\`. Expected non-empty \`string\`.`),null)});zqe.displayName=Fqe;var Bqe="ToastClose",tje=S.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=Wxt(Bqe,r);return e.jsx($qe,{asChild:!0,children:e.jsx(Yr.button,{type:"button",...n,ref:s,onClick:Cr(t.onClick,a.onClose)})})});tje.displayName=Bqe;var $qe=S.forwardRef((t,s)=>{const{__scopeToast:r,altText:n,...a}=t;return e.jsx(Yr.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function qqe(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),Jxt(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(...qqe(n))}}),s}function dz(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?Q2e(a,o):a.dispatchEvent(o)}var wEe=(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 Qxt(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 Jxt(t){return t.nodeType===t.ELEMENT_NODE}function egt(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 Vxe(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var tgt=Eqe,Uqe=Iqe,Vqe=Dqe,Hqe=Rqe,Gqe=Oqe,Wqe=zqe,Kqe=tje;function Zqe(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,NEe=_i,gC=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return NEe(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],x=o==null?void 0:o[u];if(p===null)return null;const y=jEe(p)||jEe(x);return a[u][y]}),i=r&&Object.entries(r).reduce((u,p)=>{let[x,y]=p;return y===void 0||(u[x]=y),u},{}),d=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((u,p)=>{let{class:x,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,x,y]:u},[]);return NEe(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 sgt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Yqe=(...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 Xqe=S.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},d)=>S.createElement("svg",{ref:d,...rgt,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:Yqe("lucide",a),...i},[...l.map(([u,p])=>S.createElement(u,p)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z=(t,s)=>{const r=S.forwardRef(({className:n,...a},o)=>S.createElement(Xqe,{ref:o,iconNode:s,className:Yqe(`lucide-${sgt(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 H9=Z("AArrowDown",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 7v9",key:"pknjwm"}],["path",{d:"m14 12 4 4 4-4",key:"buelq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G9=Z("AArrowUp",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 16V7",key:"ty0viw"}],["path",{d:"m14 11 4-4 4 4",key:"1pu57t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W9=Z("ALargeSmall",[["path",{d:"M21 14h-5",key:"1vh23k"}],["path",{d:"M16 16v-3.5a2.5 2.5 0 0 1 5 0V16",key:"1wh10o"}],["path",{d:"M4.5 13h6",key:"dfilno"}],["path",{d:"m3 16 4.5-9 4.5 9",key:"2dxa0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K9=Z("Accessibility",[["circle",{cx:"16",cy:"4",r:"1",key:"1grugj"}],["path",{d:"m18 19 1-7-6 1",key:"r0i19z"}],["path",{d:"m5 8 3-3 5.5 3-2.36 3.5",key:"9ptxx2"}],["path",{d:"M4.24 14.5a5 5 0 0 0 6.88 6",key:"10kmtu"}],["path",{d:"M13.76 17.5a5 5 0 0 0-6.88-6",key:"2qq6rc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ih=Z("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z9=Z("AirVent",[["path",{d:"M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"larmp2"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"M18.3 17.7a2.5 2.5 0 0 1-3.16 3.83 2.53 2.53 0 0 1-1.14-2V12",key:"1bo8pg"}],["path",{d:"M6.6 15.6A2 2 0 1 0 10 17v-5",key:"t9h90c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y9=Z("Airplay",[["path",{d:"M5 17H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-1",key:"ns4c3b"}],["path",{d:"m12 15 5 6H7Z",key:"14qnn2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U2=Z("AlarmClockCheck",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V2=Z("AlarmClockMinus",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"M9 13h6",key:"1uhe8q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X9=Z("AlarmClockOff",[["path",{d:"M6.87 6.87a8 8 0 1 0 11.26 11.26",key:"3on8tj"}],["path",{d:"M19.9 14.25a8 8 0 0 0-9.15-9.15",key:"15ghsc"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.26 18.67 4 21",key:"yzmioq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M4 4 2 6",key:"1ycko6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H2=Z("AlarmClockPlus",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q9=Z("AlarmClock",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M12 9v4l2 2",key:"1c63tq"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J9=Z("AlarmSmoke",[["path",{d:"M11 21c0-2.5 2-2.5 2-5",key:"1sicvv"}],["path",{d:"M16 21c0-2.5 2-2.5 2-5",key:"1o3eny"}],["path",{d:"m19 8-.8 3a1.25 1.25 0 0 1-1.2 1H7a1.25 1.25 0 0 1-1.2-1L5 8",key:"1bvca4"}],["path",{d:"M21 3a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a1 1 0 0 1 1-1z",key:"x3qr1j"}],["path",{d:"M6 21c0-2.5 2-2.5 2-5",key:"i3w1gp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eB=Z("Album",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["polyline",{points:"11 3 11 11 14 8 17 11 17 3",key:"1wcwz3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tB=Z("AlignCenterHorizontal",[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4",key:"11f1s0"}],["path",{d:"M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4",key:"t14dx9"}],["path",{d:"M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1",key:"1w07xs"}],["path",{d:"M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1",key:"1apec2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sB=Z("AlignCenterVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4",key:"14d6g8"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4",key:"1e2lrw"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1",key:"1fkdwx"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1",key:"1euafb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B4=Z("AlignCenter",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rB=Z("AlignEndHorizontal",[["rect",{width:"6",height:"16",x:"4",y:"2",rx:"2",key:"z5wdxg"}],["rect",{width:"6",height:"9",x:"14",y:"9",rx:"2",key:"um7a8w"}],["path",{d:"M22 22H2",key:"19qnx5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nB=Z("AlignEndVertical",[["rect",{width:"16",height:"6",x:"2",y:"4",rx:"2",key:"10wcwx"}],["rect",{width:"9",height:"6",x:"9",y:"14",rx:"2",key:"4p5bwg"}],["path",{d:"M22 22V2",key:"12ipfv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aB=Z("AlignHorizontalDistributeCenter",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iB=Z("AlignHorizontalDistributeEnd",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M10 2v20",key:"uyc634"}],["path",{d:"M20 2v20",key:"1tx262"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oB=Z("AlignHorizontalDistributeStart",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M4 2v20",key:"gtpd5x"}],["path",{d:"M14 2v20",key:"tg6bpw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lB=Z("AlignHorizontalJustifyCenter",[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M12 2v20",key:"t6zp3m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cB=Z("AlignHorizontalJustifyEnd",[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"12",y:"7",rx:"2",key:"1ht384"}],["path",{d:"M22 2v20",key:"40qfg1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dB=Z("AlignHorizontalJustifyStart",[["rect",{width:"6",height:"14",x:"6",y:"5",rx:"2",key:"hsirpf"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M2 2v20",key:"1ivd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uB=Z("AlignHorizontalSpaceAround",[["rect",{width:"6",height:"10",x:"9",y:"7",rx:"2",key:"yn7j0q"}],["path",{d:"M4 22V2",key:"tsjzd3"}],["path",{d:"M20 22V2",key:"1bnhr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hB=Z("AlignHorizontalSpaceBetween",[["rect",{width:"6",height:"14",x:"3",y:"5",rx:"2",key:"j77dae"}],["rect",{width:"6",height:"10",x:"15",y:"7",rx:"2",key:"bq30hj"}],["path",{d:"M3 2v20",key:"1d2pfg"}],["path",{d:"M21 2v20",key:"p059bm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mB=Z("AlignJustify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $4=Z("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q4=Z("AlignRight",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pB=Z("AlignStartHorizontal",[["rect",{width:"6",height:"16",x:"4",y:"6",rx:"2",key:"1n4dg1"}],["rect",{width:"6",height:"9",x:"14",y:"6",rx:"2",key:"17khns"}],["path",{d:"M22 2H2",key:"fhrpnj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fB=Z("AlignStartVertical",[["rect",{width:"9",height:"6",x:"6",y:"14",rx:"2",key:"lpm2y7"}],["rect",{width:"16",height:"6",x:"6",y:"4",rx:"2",key:"rdj6ps"}],["path",{d:"M2 2v20",key:"1ivd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xB=Z("AlignVerticalDistributeCenter",[["path",{d:"M22 17h-3",key:"1lwga1"}],["path",{d:"M22 7h-5",key:"o2endc"}],["path",{d:"M5 17H2",key:"1gx9xc"}],["path",{d:"M7 7H2",key:"6bq26l"}],["rect",{x:"5",y:"14",width:"14",height:"6",rx:"2",key:"1qrzuf"}],["rect",{x:"7",y:"4",width:"10",height:"6",rx:"2",key:"we8e9z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gB=Z("AlignVerticalDistributeEnd",[["rect",{width:"14",height:"6",x:"5",y:"14",rx:"2",key:"jmoj9s"}],["rect",{width:"10",height:"6",x:"7",y:"4",rx:"2",key:"aza5on"}],["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"M2 10h20",key:"1ir3d8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yB=Z("AlignVerticalDistributeStart",[["rect",{width:"14",height:"6",x:"5",y:"14",rx:"2",key:"jmoj9s"}],["rect",{width:"10",height:"6",x:"7",y:"4",rx:"2",key:"aza5on"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M2 4h20",key:"mda7wb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vB=Z("AlignVerticalJustifyCenter",[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _B=Z("AlignVerticalJustifyEnd",[["rect",{width:"14",height:"6",x:"5",y:"12",rx:"2",key:"4l4tp2"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 22h20",key:"272qi7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bB=Z("AlignVerticalJustifyStart",[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"6",rx:"2",key:"13squh"}],["path",{d:"M2 2h20",key:"1ennik"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wB=Z("AlignVerticalSpaceAround",[["rect",{width:"10",height:"6",x:"7",y:"9",rx:"2",key:"b1zbii"}],["path",{d:"M22 20H2",key:"1p1f7z"}],["path",{d:"M22 4H2",key:"1b7qnq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jB=Z("AlignVerticalSpaceBetween",[["rect",{width:"14",height:"6",x:"5",y:"15",rx:"2",key:"1w91an"}],["rect",{width:"10",height:"6",x:"7",y:"3",rx:"2",key:"17wqzy"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M2 3h20",key:"91anmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NB=Z("Ambulance",[["path",{d:"M10 10H6",key:"1bsnug"}],["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.28a1 1 0 0 0-.684-.948l-1.923-.641a1 1 0 0 1-.578-.502l-1.539-3.076A1 1 0 0 0 16.382 8H14",key:"lrkjwd"}],["path",{d:"M8 8v4",key:"1fwk8c"}],["path",{d:"M9 18h6",key:"x1upvd"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kB=Z("Ampersand",[["path",{d:"M17.5 12c0 4.4-3.6 8-8 8A4.5 4.5 0 0 1 5 15.5c0-6 8-4 8-8.5a3 3 0 1 0-6 0c0 3 2.5 8.5 12 13",key:"1o9ehi"}],["path",{d:"M16 12h3",key:"4uvgyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SB=Z("Ampersands",[["path",{d:"M10 17c-5-3-7-7-7-9a2 2 0 0 1 4 0c0 2.5-5 2.5-5 6 0 1.7 1.3 3 3 3 2.8 0 5-2.2 5-5",key:"12lh1k"}],["path",{d:"M22 17c-5-3-7-7-7-9a2 2 0 0 1 4 0c0 2.5-5 2.5-5 6 0 1.7 1.3 3 3 3 2.8 0 5-2.2 5-5",key:"173c68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CB=Z("Amphora",[["path",{d:"M10 2v5.632c0 .424-.272.795-.653.982A6 6 0 0 0 6 14c.006 4 3 7 5 8",key:"1h8rid"}],["path",{d:"M10 5H8a2 2 0 0 0 0 4h.68",key:"3ezsi6"}],["path",{d:"M14 2v5.632c0 .424.272.795.652.982A6 6 0 0 1 18 14c0 4-3 7-5 8",key:"yt6q09"}],["path",{d:"M14 5h2a2 2 0 0 1 0 4h-.68",key:"8f95yk"}],["path",{d:"M18 22H6",key:"mg6kv4"}],["path",{d:"M9 2h6",key:"1jrp98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MB=Z("Anchor",[["path",{d:"M12 22V8",key:"qkxhtm"}],["path",{d:"M5 12H2a10 10 0 0 0 20 0h-3",key:"1hv3nh"}],["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TB=Z("Angry",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["path",{d:"M7.5 8 10 9",key:"olxxln"}],["path",{d:"m14 9 2.5-1",key:"1j6cij"}],["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AB=Z("Annoyed",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 15h8",key:"45n4r"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M14 9h2",key:"116p9w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EB=Z("Antenna",[["path",{d:"M2 12 7 2",key:"117k30"}],["path",{d:"m7 12 5-10",key:"1tvx22"}],["path",{d:"m12 12 5-10",key:"ev1o1a"}],["path",{d:"m17 12 5-10",key:"1e4ti3"}],["path",{d:"M4.5 7h15",key:"vlsxkz"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PB=Z("Anvil",[["path",{d:"M7 10H6a4 4 0 0 1-4-4 1 1 0 0 1 1-1h4",key:"1hjpb6"}],["path",{d:"M7 5a1 1 0 0 1 1-1h13a1 1 0 0 1 1 1 7 7 0 0 1-7 7H8a1 1 0 0 1-1-1z",key:"1qn45f"}],["path",{d:"M9 12v5",key:"3anwtq"}],["path",{d:"M15 12v5",key:"5xh3zn"}],["path",{d:"M5 20a3 3 0 0 1 3-3h8a3 3 0 0 1 3 3 1 1 0 0 1-1 1H6a1 1 0 0 1-1-1",key:"1fi4x8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IB=Z("Aperture",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14.31 8 5.74 9.94",key:"1y6ab4"}],["path",{d:"M9.69 8h11.48",key:"1wxppr"}],["path",{d:"m7.38 12 5.74-9.94",key:"1grp0k"}],["path",{d:"M9.69 16 3.95 6.06",key:"libnyf"}],["path",{d:"M14.31 16H2.83",key:"x5fava"}],["path",{d:"m16.62 12-5.74 9.94",key:"1vwawt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LB=Z("AppWindowMac",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M14 8h.01",key:"1primd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QI=Z("AppWindow",[["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}],["path",{d:"M10 4v4",key:"pp8u80"}],["path",{d:"M2 8h20",key:"d11cs7"}],["path",{d:"M6 4v4",key:"1svtjw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DB=Z("Apple",[["path",{d:"M12 20.94c1.5 0 2.75 1.06 4 1.06 3 0 6-8 6-12.22A4.91 4.91 0 0 0 17 5c-2.22 0-4 1.44-5 2-1-.56-2.78-2-5-2a4.9 4.9 0 0 0-5 4.78C2 14 5 22 8 22c1.25 0 2.5-1.06 4-1.06Z",key:"3s7exb"}],["path",{d:"M10 2c1 .5 2 2 2 5",key:"fcco2y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JI=Z("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RB=Z("ArchiveX",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"m9.5 17 5-5",key:"nakeu6"}],["path",{d:"m9.5 12 5 5",key:"1hccrj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pM=Z("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OB=Z("Armchair",[["path",{d:"M19 9V6a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v3",key:"irtipd"}],["path",{d:"M3 16a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"1qyhux"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FB=Z("ArrowBigDownDash",[["path",{d:"M15 5H9",key:"1tp3ed"}],["path",{d:"M15 9v3h4l-7 7-7-7h4V9z",key:"ncdc4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zB=Z("ArrowBigDown",[["path",{d:"M15 6v6h4l-7 7-7-7h4V6h6z",key:"1thax2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BB=Z("ArrowBigLeftDash",[["path",{d:"M19 15V9",key:"1hci5f"}],["path",{d:"M15 15h-3v4l-7-7 7-7v4h3v6z",key:"16tjna"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $B=Z("ArrowBigLeft",[["path",{d:"M18 15h-6v4l-7-7 7-7v4h6v6z",key:"lbrdak"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qB=Z("ArrowBigRightDash",[["path",{d:"M5 9v6",key:"158jrl"}],["path",{d:"M9 9h3V5l7 7-7 7v-4H9V9z",key:"1sg2xn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UB=Z("ArrowBigRight",[["path",{d:"M6 9h6V5l7 7-7 7v-4H6V9z",key:"7fvt9c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VB=Z("ArrowBigUpDash",[["path",{d:"M9 19h6",key:"456am0"}],["path",{d:"M9 15v-3H5l7-7 7 7h-4v3H9z",key:"1r2uve"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HB=Z("ArrowBigUp",[["path",{d:"M9 18v-6H5l7-7 7 7h-4v6H9z",key:"1x06kx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GB=Z("ArrowDown01",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WB=Z("ArrowDown10",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G2=Z("ArrowDownAZ",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KB=Z("ArrowDownFromLine",[["path",{d:"M19 3H5",key:"1236rx"}],["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m6 15 6 6 6-6",key:"h15q88"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZB=Z("ArrowDownLeft",[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YB=Z("ArrowDownNarrowWide",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h4",key:"6d7r33"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h10",key:"1438ji"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eL=Z("ArrowDownRight",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XB=Z("ArrowDownToDot",[["path",{d:"M12 2v14",key:"jyx4ut"}],["path",{d:"m19 9-7 7-7-7",key:"1oe3oy"}],["circle",{cx:"12",cy:"21",r:"1",key:"o0uj5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QB=Z("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JB=Z("ArrowDownUp",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W2=Z("ArrowDownWideNarrow",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K2=Z("ArrowDownZA",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ph=Z("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e$=Z("ArrowLeftFromLine",[["path",{d:"m9 6-6 6 6 6",key:"7v63n9"}],["path",{d:"M3 12h14",key:"13k4hi"}],["path",{d:"M21 19V5",key:"b4bplr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t$=Z("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s$=Z("ArrowLeftToLine",[["path",{d:"M3 19V5",key:"rwsyhb"}],["path",{d:"m13 6-6 6 6 6",key:"1yhaz7"}],["path",{d:"M7 12h14",key:"uoisry"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fa=Z("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r$=Z("ArrowRightFromLine",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M21 12H7",key:"13ipq5"}],["path",{d:"m15 18 6-6-6-6",key:"6tx3qv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hv=Z("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n$=Z("ArrowRightToLine",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ei=Z("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a$=Z("ArrowUp01",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i$=Z("ArrowUp10",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z2=Z("ArrowUpAZ",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const td=Z("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o$=Z("ArrowUpFromDot",[["path",{d:"m5 9 7-7 7 7",key:"1hw5ic"}],["path",{d:"M12 16V2",key:"ywoabb"}],["circle",{cx:"12",cy:"21",r:"1",key:"o0uj5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l$=Z("ArrowUpFromLine",[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c$=Z("ArrowUpLeft",[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y2=Z("ArrowUpNarrowWide",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tL=Z("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d$=Z("ArrowUpToLine",[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u$=Z("ArrowUpWideNarrow",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h4",key:"1krc32"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X2=Z("ArrowUpZA",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const du=Z("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h$=Z("ArrowsUpFromLine",[["path",{d:"m4 6 3-3 3 3",key:"9aidw8"}],["path",{d:"M7 17V3",key:"19qxw1"}],["path",{d:"m14 6 3-3 3 3",key:"6iy689"}],["path",{d:"M17 17V3",key:"o0fmgi"}],["path",{d:"M4 21h16",key:"1h09gz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m$=Z("Asterisk",[["path",{d:"M12 6v12",key:"1vza4d"}],["path",{d:"M17.196 9 6.804 15",key:"1ah31z"}],["path",{d:"m6.804 9 10.392 6",key:"1b6pxd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p$=Z("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f$=Z("Atom",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z",key:"1l2ple"}],["path",{d:"M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z",key:"1wam0m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x$=Z("AudioLines",[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g$=Z("AudioWaveform",[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ec=Z("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y$=Z("Axe",[["path",{d:"m14 12-8.5 8.5a2.12 2.12 0 1 1-3-3L11 9",key:"csbz4o"}],["path",{d:"M15 13 9 7l4-4 6 6h3a8 8 0 0 1-7 7z",key:"113wfo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q2=Z("Axis3d",[["path",{d:"M4 4v16h16",key:"1s015l"}],["path",{d:"m4 20 7-7",key:"17qe9y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v$=Z("Baby",[["path",{d:"M9 12h.01",key:"157uk2"}],["path",{d:"M15 12h.01",key:"1k8ypt"}],["path",{d:"M10 16c.5.3 1.2.5 2 .5s1.5-.2 2-.5",key:"1u7htd"}],["path",{d:"M19 6.3a9 9 0 0 1 1.8 3.9 2 2 0 0 1 0 3.6 9 9 0 0 1-17.6 0 2 2 0 0 1 0-3.6A9 9 0 0 1 12 3c2 0 3.5 1.1 3.5 2.5s-.9 2.5-2 2.5c-.8 0-1.5-.4-1.5-1",key:"5yv0yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _$=Z("Backpack",[["path",{d:"M4 10a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z",key:"1ol0lm"}],["path",{d:"M8 10h8",key:"c7uz4u"}],["path",{d:"M8 18h8",key:"1no2b1"}],["path",{d:"M8 22v-6a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v6",key:"1fr6do"}],["path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2",key:"donm21"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b$=Z("BadgeAlert",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w$=Z("BadgeCent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M15.4 10a4 4 0 1 0 0 4",key:"2eqtx8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J2=Z("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j$=Z("BadgeDollarSign",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N$=Z("BadgeEuro",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M7 12h5",key:"gblrwe"}],["path",{d:"M15 9.4a4 4 0 1 0 0 5.2",key:"1makmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k$=Z("BadgeHelp",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["line",{x1:"12",x2:"12.01",y1:"17",y2:"17",key:"io3f8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S$=Z("BadgeIndianRupee",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M8 8h8",key:"1bis0t"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m13 17-5-1h1a4 4 0 0 0 0-8",key:"nu2bwa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C$=Z("BadgeInfo",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"16",y2:"12",key:"1y1yb1"}],["line",{x1:"12",x2:"12.01",y1:"8",y2:"8",key:"110wyk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M$=Z("BadgeJapaneseYen",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 8 3 3v7",key:"17yadx"}],["path",{d:"m12 11 3-3",key:"p4cfq1"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M9 16h6",key:"8wimt3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T$=Z("BadgeMinus",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A$=Z("BadgePercent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E$=Z("BadgePlus",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"16",key:"10p56q"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P$=Z("BadgePoundSterling",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M8 12h4",key:"qz6y1c"}],["path",{d:"M10 16V9.5a2.5 2.5 0 0 1 5 0",key:"3mlbjk"}],["path",{d:"M8 16h7",key:"sbedsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I$=Z("BadgeRussianRuble",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9 16h5",key:"1syiyw"}],["path",{d:"M9 12h5a2 2 0 1 0 0-4h-3v9",key:"1ge9c1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L$=Z("BadgeSwissFranc",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M11 17V8h4",key:"1bfq6y"}],["path",{d:"M11 12h3",key:"2eqnfz"}],["path",{d:"M9 16h4",key:"1skf3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D$=Z("BadgeX",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R$=Z("Badge",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O$=Z("BaggageClaim",[["path",{d:"M22 18H6a2 2 0 0 1-2-2V7a2 2 0 0 0-2-2",key:"4irg2o"}],["path",{d:"M17 14V4a2 2 0 0 0-2-2h-1a2 2 0 0 0-2 2v10",key:"14fcyx"}],["rect",{width:"13",height:"8",x:"8",y:"6",rx:"1",key:"o6oiis"}],["circle",{cx:"18",cy:"20",r:"2",key:"t9985n"}],["circle",{cx:"9",cy:"20",r:"2",key:"e5v82j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sL=Z("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F$=Z("Banana",[["path",{d:"M4 13c3.5-2 8-2 10 2a5.5 5.5 0 0 1 8 5",key:"1cscit"}],["path",{d:"M5.15 17.89c5.52-1.52 8.65-6.89 7-12C11.55 4 11.5 2 13 2c3.22 0 5 5.5 5 8 0 6.5-4.2 12-10.49 12C5.11 22 2 22 2 20c0-1.5 1.14-1.55 3.15-2.11Z",key:"1y1nbv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z$=Z("Bandage",[["path",{d:"M10 10.01h.01",key:"1e9xi7"}],["path",{d:"M10 14.01h.01",key:"ac23bv"}],["path",{d:"M14 10.01h.01",key:"2wfrvf"}],["path",{d:"M14 14.01h.01",key:"8tw8yn"}],["path",{d:"M18 6v11.5",key:"dkbidh"}],["path",{d:"M6 6v12",key:"vkc79e"}],["rect",{x:"2",y:"6",width:"20",height:"12",rx:"2",key:"1wpnh2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B$=Z("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $$=Z("Barcode",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M8 5v14",key:"1ybrkv"}],["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"M17 5v14",key:"ycjyhj"}],["path",{d:"M21 5v14",key:"nzette"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q$=Z("Baseline",[["path",{d:"M4 20h16",key:"14thso"}],["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rf=Z("Bath",[["path",{d:"M10 4 8 6",key:"1rru8s"}],["path",{d:"M17 19v2",key:"ts1sot"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M7 19v2",key:"12npes"}],["path",{d:"M9 5 7.621 3.621A2.121 2.121 0 0 0 4 5v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5",key:"14ym8i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U$=Z("BatteryCharging",[["path",{d:"M15 7h1a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-2",key:"1sdynx"}],["path",{d:"M6 7H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h1",key:"1gkd3k"}],["path",{d:"m11 7-3 5h4l-3 5",key:"b4a64w"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V$=Z("BatteryFull",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"13",key:"c6fn6x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H$=Z("BatteryLow",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G$=Z("BatteryMedium",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W$=Z("BatteryWarning",[["path",{d:"M10 17h.01",key:"nbq80n"}],["path",{d:"M10 7v6",key:"nne03l"}],["path",{d:"M14 7h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-2",key:"1x5o8m"}],["path",{d:"M22 11v2",key:"1wo06k"}],["path",{d:"M6 7H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"1mdjgh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K$=Z("Battery",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z$=Z("Beaker",[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y$=Z("BeanOff",[["path",{d:"M9 9c-.64.64-1.521.954-2.402 1.165A6 6 0 0 0 8 22a13.96 13.96 0 0 0 9.9-4.1",key:"bq3udt"}],["path",{d:"M10.75 5.093A6 6 0 0 1 22 8c0 2.411-.61 4.68-1.683 6.66",key:"17ccse"}],["path",{d:"M5.341 10.62a4 4 0 0 0 6.487 1.208M10.62 5.341a4.015 4.015 0 0 1 2.039 2.04",key:"18zqgq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X$=Z("Bean",[["path",{d:"M10.165 6.598C9.954 7.478 9.64 8.36 9 9c-.64.64-1.521.954-2.402 1.165A6 6 0 0 0 8 22c7.732 0 14-6.268 14-14a6 6 0 0 0-11.835-1.402Z",key:"1tvzk7"}],["path",{d:"M5.341 10.62a4 4 0 1 0 5.279-5.28",key:"2cyri2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U4=Z("BedDouble",[["path",{d:"M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8",key:"1k78r4"}],["path",{d:"M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"fb3tl2"}],["path",{d:"M12 4v6",key:"1dcgq2"}],["path",{d:"M2 18h20",key:"ajqnye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q$=Z("BedSingle",[["path",{d:"M3 20v-8a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v8",key:"1wm6mi"}],["path",{d:"M5 10V6a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v4",key:"4k93s5"}],["path",{d:"M3 18h18",key:"1h113x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wy=Z("Bed",[["path",{d:"M2 4v16",key:"vw9hq8"}],["path",{d:"M2 8h18a2 2 0 0 1 2 2v10",key:"1dgv2r"}],["path",{d:"M2 17h20",key:"18nfp3"}],["path",{d:"M6 8v9",key:"1yriud"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J$=Z("Beef",[["circle",{cx:"12.5",cy:"8.5",r:"2.5",key:"9738u8"}],["path",{d:"M12.5 2a6.5 6.5 0 0 0-6.22 4.6c-1.1 3.13-.78 3.9-3.18 6.08A3 3 0 0 0 5 18c4 0 8.4-1.8 11.4-4.3A6.5 6.5 0 0 0 12.5 2Z",key:"o0f6za"}],["path",{d:"m18.5 6 2.19 4.5a6.48 6.48 0 0 1 .31 2 6.49 6.49 0 0 1-2.6 5.2C15.4 20.2 11 22 7 22a3 3 0 0 1-2.68-1.66L2.4 16.5",key:"k7p6i0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eq=Z("BeerOff",[["path",{d:"M13 13v5",key:"igwfh0"}],["path",{d:"M17 11.47V8",key:"16yw0g"}],["path",{d:"M17 11h1a3 3 0 0 1 2.745 4.211",key:"1xbt65"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 8v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-3",key:"c55o3e"}],["path",{d:"M7.536 7.535C6.766 7.649 6.154 8 5.5 8a2.5 2.5 0 0 1-1.768-4.268",key:"1ydug7"}],["path",{d:"M8.727 3.204C9.306 2.767 9.885 2 11 2c1.56 0 2 1.5 3 1.5s1.72-.5 2.5-.5a1 1 0 1 1 0 5c-.78 0-1.5-.5-2.5-.5a3.149 3.149 0 0 0-.842.12",key:"q81o7q"}],["path",{d:"M9 14.6V18",key:"20ek98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tq=Z("Beer",[["path",{d:"M17 11h1a3 3 0 0 1 0 6h-1",key:"1yp76v"}],["path",{d:"M9 12v6",key:"1u1cab"}],["path",{d:"M13 12v6",key:"1sugkk"}],["path",{d:"M14 7.5c-1 0-1.44.5-3 .5s-2-.5-3-.5-1.72.5-2.5.5a2.5 2.5 0 0 1 0-5c.78 0 1.57.5 2.5.5S9.44 2 11 2s2 1.5 3 1.5 1.72-.5 2.5-.5a2.5 2.5 0 0 1 0 5c-.78 0-1.5-.5-2.5-.5Z",key:"1510fo"}],["path",{d:"M5 8v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"19jb7n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sq=Z("BellDot",[["path",{d:"M19.4 14.9C20.2 16.4 21 17 21 17H3s3-2 3-9c0-3.3 2.7-6 6-6 .7 0 1.3.1 1.9.3",key:"xcehk"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["circle",{cx:"18",cy:"8",r:"3",key:"1g0gzu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rq=Z("BellElectric",[["path",{d:"M18.8 4A6.3 8.7 0 0 1 20 9",key:"xve1fh"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["circle",{cx:"9",cy:"9",r:"7",key:"p2h5vp"}],["rect",{width:"10",height:"6",x:"4",y:"16",rx:"2",key:"17f3te"}],["path",{d:"M14 19c3 0 4.6-1.6 4.6-1.6",key:"n7odp6"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nq=Z("BellMinus",[["path",{d:"M18.4 12c.8 3.8 2.6 5 2.6 5H3s3-2 3-9c0-3.3 2.7-6 6-6 1.8 0 3.4.8 4.5 2",key:"eck70s"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M15 8h6",key:"8ybuxh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gv=Z("BellOff",[["path",{d:"M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5",key:"o7mx20"}],["path",{d:"M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7",key:"16f1lm"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aq=Z("BellPlus",[["path",{d:"M19.3 14.8C20.1 16.4 21 17 21 17H3s3-2 3-9c0-3.3 2.7-6 6-6 1 0 1.9.2 2.8.7",key:"guizqy"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M15 8h6",key:"8ybuxh"}],["path",{d:"M18 5v6",key:"g5ayrv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iq=Z("BellRing",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sm=Z("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ej=Z("BetweenHorizontalEnd",[["rect",{width:"13",height:"7",x:"3",y:"3",rx:"1",key:"11xb64"}],["path",{d:"m22 15-3-3 3-3",key:"26chmm"}],["rect",{width:"13",height:"7",x:"3",y:"14",rx:"1",key:"k6ky7n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tj=Z("BetweenHorizontalStart",[["rect",{width:"13",height:"7",x:"8",y:"3",rx:"1",key:"pkso9a"}],["path",{d:"m2 9 3 3-3 3",key:"1agib5"}],["rect",{width:"13",height:"7",x:"8",y:"14",rx:"1",key:"1q5fc1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oq=Z("BetweenVerticalEnd",[["rect",{width:"7",height:"13",x:"3",y:"3",rx:"1",key:"1fdu0f"}],["path",{d:"m9 22 3-3 3 3",key:"17z65a"}],["rect",{width:"7",height:"13",x:"14",y:"3",rx:"1",key:"1squn4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lq=Z("BetweenVerticalStart",[["rect",{width:"7",height:"13",x:"3",y:"8",rx:"1",key:"1fjrkv"}],["path",{d:"m15 2-3 3-3-3",key:"1uh6eb"}],["rect",{width:"7",height:"13",x:"14",y:"8",rx:"1",key:"w3fjg8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cq=Z("BicepsFlexed",[["path",{d:"M12.409 13.017A5 5 0 0 1 22 15c0 3.866-4 7-9 7-4.077 0-8.153-.82-10.371-2.462-.426-.316-.631-.832-.62-1.362C2.118 12.723 2.627 2 10 2a3 3 0 0 1 3 3 2 2 0 0 1-2 2c-1.105 0-1.64-.444-2-1",key:"1pmlyh"}],["path",{d:"M15 14a5 5 0 0 0-7.584 2",key:"5rb254"}],["path",{d:"M9.964 6.825C8.019 7.977 9.5 13 8 15",key:"kbvsx9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dq=Z("Bike",[["circle",{cx:"18.5",cy:"17.5",r:"3.5",key:"15x4ox"}],["circle",{cx:"5.5",cy:"17.5",r:"3.5",key:"1noe27"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["path",{d:"M12 17.5V14l-3-3 4-3 2 3h2",key:"1npguv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uq=Z("Binary",[["rect",{x:"14",y:"14",width:"4",height:"6",rx:"2",key:"p02svl"}],["rect",{x:"6",y:"4",width:"4",height:"6",rx:"2",key:"xm4xkj"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 10h4",key:"ru81e7"}],["path",{d:"M6 14h2v6",key:"16z9wg"}],["path",{d:"M14 4h2v6",key:"1idq9u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hq=Z("Binoculars",[["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M19 7V4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3",key:"3apit1"}],["path",{d:"M20 21a2 2 0 0 0 2-2v-3.851c0-1.39-2-2.962-2-4.829V8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v11a2 2 0 0 0 2 2z",key:"rhpgnw"}],["path",{d:"M 22 16 L 2 16",key:"14lkq7"}],["path",{d:"M4 21a2 2 0 0 1-2-2v-3.851c0-1.39 2-2.962 2-4.829V8a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v11a2 2 0 0 1-2 2z",key:"104b3k"}],["path",{d:"M9 7V4a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v3",key:"14fczp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mq=Z("Biohazard",[["circle",{cx:"12",cy:"11.9",r:"2",key:"e8h31w"}],["path",{d:"M6.7 3.4c-.9 2.5 0 5.2 2.2 6.7C6.5 9 3.7 9.6 2 11.6",key:"17bolr"}],["path",{d:"m8.9 10.1 1.4.8",key:"15ezny"}],["path",{d:"M17.3 3.4c.9 2.5 0 5.2-2.2 6.7 2.4-1.2 5.2-.6 6.9 1.5",key:"wtwa5u"}],["path",{d:"m15.1 10.1-1.4.8",key:"1r0b28"}],["path",{d:"M16.7 20.8c-2.6-.4-4.6-2.6-4.7-5.3-.2 2.6-2.1 4.8-4.7 5.2",key:"m7qszh"}],["path",{d:"M12 13.9v1.6",key:"zfyyim"}],["path",{d:"M13.5 5.4c-1-.2-2-.2-3 0",key:"1bi9q0"}],["path",{d:"M17 16.4c.7-.7 1.2-1.6 1.5-2.5",key:"1rhjqw"}],["path",{d:"M5.5 13.9c.3.9.8 1.8 1.5 2.5",key:"8gsud3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pq=Z("Bird",[["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M3.4 18H12a8 8 0 0 0 8-8V7a4 4 0 0 0-7.28-2.3L2 20",key:"oj1oa8"}],["path",{d:"m20 7 2 .5-2 .5",key:"12nv4d"}],["path",{d:"M10 18v3",key:"1yea0a"}],["path",{d:"M14 17.75V21",key:"1pymcb"}],["path",{d:"M7 18a6 6 0 0 0 3.84-10.61",key:"1npnn0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fq=Z("Bitcoin",[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xq=Z("Blend",[["circle",{cx:"9",cy:"9",r:"7",key:"p2h5vp"}],["circle",{cx:"15",cy:"15",r:"7",key:"19ennj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gq=Z("Blinds",[["path",{d:"M3 3h18",key:"o7r712"}],["path",{d:"M20 7H8",key:"gd2fo2"}],["path",{d:"M20 11H8",key:"1ynp89"}],["path",{d:"M10 19h10",key:"19hjk5"}],["path",{d:"M8 15h12",key:"1yqzne"}],["path",{d:"M4 3v14",key:"fggqzn"}],["circle",{cx:"4",cy:"19",r:"2",key:"p3m9r0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yq=Z("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vq=Z("BluetoothConnected",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}],["line",{x1:"18",x2:"21",y1:"12",y2:"12",key:"1rsjjs"}],["line",{x1:"3",x2:"6",y1:"12",y2:"12",key:"11yl8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _q=Z("BluetoothOff",[["path",{d:"m17 17-5 5V12l-5 5",key:"v5aci6"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M14.5 9.5 17 7l-5-5v4.5",key:"1kddfz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bq=Z("BluetoothSearching",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}],["path",{d:"M20.83 14.83a4 4 0 0 0 0-5.66",key:"k8tn1j"}],["path",{d:"M18 12h.01",key:"yjnet6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wq=Z("Bluetooth",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V4=Z("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jq=Z("Bolt",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nq=Z("Bomb",[["circle",{cx:"11",cy:"13",r:"9",key:"hd149"}],["path",{d:"M14.35 4.65 16.3 2.7a2.41 2.41 0 0 1 3.4 0l1.6 1.6a2.4 2.4 0 0 1 0 3.4l-1.95 1.95",key:"jp4j1b"}],["path",{d:"m22 2-1.5 1.5",key:"ay92ug"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kq=Z("Bone",[["path",{d:"M17 10c.7-.7 1.69 0 2.5 0a2.5 2.5 0 1 0 0-5 .5.5 0 0 1-.5-.5 2.5 2.5 0 1 0-5 0c0 .81.7 1.8 0 2.5l-7 7c-.7.7-1.69 0-2.5 0a2.5 2.5 0 0 0 0 5c.28 0 .5.22.5.5a2.5 2.5 0 1 0 5 0c0-.81-.7-1.8 0-2.5Z",key:"w610uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sq=Z("BookA",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m8 13 4-7 4 7",key:"4rari8"}],["path",{d:"M9.1 11h5.7",key:"1gkovt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cq=Z("BookAudio",[["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8v3",key:"gejaml"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 8v3",key:"1qzp49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mq=Z("BookCheck",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 9.5 2 2 4-4",key:"1dth82"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tq=Z("BookCopy",[["path",{d:"M2 16V4a2 2 0 0 1 2-2h11",key:"spzkk5"}],["path",{d:"M22 18H11a2 2 0 1 0 0 4h10.5a.5.5 0 0 0 .5-.5v-15a.5.5 0 0 0-.5-.5H11a2 2 0 0 0-2 2v12",key:"1wz07i"}],["path",{d:"M5 14H4a2 2 0 1 0 0 4h1",key:"16gqf9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sj=Z("BookDashed",[["path",{d:"M12 17h2",key:"13u4lk"}],["path",{d:"M12 22h2",key:"kn7ki6"}],["path",{d:"M12 2h2",key:"cvn524"}],["path",{d:"M18 22h1a1 1 0 0 0 1-1",key:"w6gbqz"}],["path",{d:"M18 2h1a1 1 0 0 1 1 1v1",key:"1vpra5"}],["path",{d:"M20 15v2h-2",key:"fph276"}],["path",{d:"M20 8v3",key:"deu0bs"}],["path",{d:"M4 11V9",key:"v3xsx8"}],["path",{d:"M4 19.5V15",key:"6gr39e"}],["path",{d:"M4 5v-.5A2.5 2.5 0 0 1 6.5 2H8",key:"wywhs9"}],["path",{d:"M8 22H6.5a1 1 0 0 1 0-5H8",key:"1cu73q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aq=Z("BookDown",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 10 3 3 3-3",key:"zt5b4y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eq=Z("BookHeadphones",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 12v-2a4 4 0 0 1 8 0v2",key:"1vsqkj"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pq=Z("BookHeart",[["path",{d:"M16 8.2A2.22 2.22 0 0 0 13.8 6c-.8 0-1.4.3-1.8.9-.4-.6-1-.9-1.8-.9A2.22 2.22 0 0 0 8 8.2c0 .6.3 1.2.7 1.6A226.652 226.652 0 0 0 12 13a404 404 0 0 0 3.3-3.1 2.413 2.413 0 0 0 .7-1.7",key:"1t75a8"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iq=Z("BookImage",[["path",{d:"m20 13.7-2.1-2.1a2 2 0 0 0-2.8 0L9.7 17",key:"q6ojf0"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"10",cy:"8",r:"2",key:"2qkj4p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lq=Z("BookKey",[["path",{d:"m19 3 1 1",key:"ze14oc"}],["path",{d:"m20 2-4.5 4.5",key:"1sppr8"}],["path",{d:"M20 8v13a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"1ocbpn"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H14",key:"1gfsgw"}],["circle",{cx:"14",cy:"8",r:"2",key:"u49eql"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dq=Z("BookLock",[["path",{d:"M18 6V4a2 2 0 1 0-4 0v2",key:"1aquzs"}],["path",{d:"M20 15v6a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"1rkj32"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H10",key:"18wgow"}],["rect",{x:"12",y:"6",width:"8",height:"5",rx:"1",key:"73l30o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rq=Z("BookMarked",[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oq=Z("BookMinus",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fq=Z("BookOpenCheck",[["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m16 12 2 2 4-4",key:"mdajum"}],["path",{d:"M22 6V4a1 1 0 0 0-1-1h-5a4 4 0 0 0-4 4 4 4 0 0 0-4-4H3a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6a1 1 0 0 0 1-1v-1.3",key:"8arnkb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zq=Z("BookOpenText",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oh=Z("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bq=Z("BookPlus",[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $q=Z("BookText",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 11h8",key:"vwpz6n"}],["path",{d:"M8 7h6",key:"1f0q6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qq=Z("BookType",[["path",{d:"M10 13h4",key:"ytezjc"}],["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8V6H8v2",key:"x8j6u4"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uq=Z("BookUp2",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M18 2h1a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"161d7n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2",key:"1lorq7"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vq=Z("BookUp",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hq=Z("BookUser",[["path",{d:"M15 13a3 3 0 1 0-6 0",key:"10j68g"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gq=Z("BookX",[["path",{d:"m14.5 7-5 5",key:"dy991v"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9.5 7 5 5",key:"s45iea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wq=Z("Book",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kq=Z("BookmarkCheck",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zq=Z("BookmarkMinus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rL=Z("BookmarkPlus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yq=Z("BookmarkX",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fx=Z("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xq=Z("BoomBox",[["path",{d:"M4 9V5a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"vvzvr1"}],["path",{d:"M8 8v1",key:"xcqmfk"}],["path",{d:"M12 8v1",key:"1rj8u4"}],["path",{d:"M16 8v1",key:"1q12zr"}],["rect",{width:"20",height:"12",x:"2",y:"9",rx:"2",key:"igpb89"}],["circle",{cx:"8",cy:"15",r:"2",key:"fa4a8s"}],["circle",{cx:"16",cy:"15",r:"2",key:"14c3ya"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qq=Z("BotMessageSquare",[["path",{d:"M12 6V2H8",key:"1155em"}],["path",{d:"m8 18-4 4V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2Z",key:"w2lp3e"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M9 11v2",key:"1ueba0"}],["path",{d:"M15 11v2",key:"i11awn"}],["path",{d:"M20 12h2",key:"1q8mjw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jq=Z("BotOff",[["path",{d:"M13.67 8H18a2 2 0 0 1 2 2v4.33",key:"7az073"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}],["path",{d:"M8 8H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 1.414-.586",key:"s09a7a"}],["path",{d:"M9 13v2",key:"rq6x2g"}],["path",{d:"M9.67 4H12v2.33",key:"110xot"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fM=Z("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eU=Z("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tU=Z("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rj=Z("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sU=Z("Brackets",[["path",{d:"M16 3h3v18h-3",key:"1yor1f"}],["path",{d:"M8 21H5V3h3",key:"1qrfwo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rU=Z("BrainCircuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nU=Z("BrainCog",[["path",{d:"M12 5a3 3 0 1 0-5.997.142 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588 4 4 0 0 0 7.636 2.106 3.2 3.2 0 0 0 .164-.546c.028-.13.306-.13.335 0a3.2 3.2 0 0 0 .163.546 4 4 0 0 0 7.636-2.106 4 4 0 0 0 .556-6.588 4 4 0 0 0-2.526-5.77A3 3 0 1 0 12 5",key:"1kgmhc"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m15.7 10.4-.9.4",key:"ayzo6p"}],["path",{d:"m9.2 13.2-.9.4",key:"1uzb3g"}],["path",{d:"m13.6 15.7-.4-.9",key:"11ifqf"}],["path",{d:"m10.8 9.2-.4-.9",key:"1pmk2v"}],["path",{d:"m15.7 13.5-.9-.4",key:"7ng02m"}],["path",{d:"m9.2 10.9-.9-.4",key:"1x66zd"}],["path",{d:"m10.5 15.7.4-.9",key:"3js94g"}],["path",{d:"m13.1 9.2.4-.9",key:"18n7mc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nL=Z("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aU=Z("BrickWall",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 9v6",key:"199k2o"}],["path",{d:"M16 15v6",key:"8rj2es"}],["path",{d:"M16 3v6",key:"1j6rpj"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M8 15v6",key:"1stoo3"}],["path",{d:"M8 3v6",key:"vlvjmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iU=Z("BriefcaseBusiness",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M22 13a18.15 18.15 0 0 1-20 0",key:"12hx5q"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oU=Z("BriefcaseConveyorBelt",[["path",{d:"M10 20v2",key:"1n8e1g"}],["path",{d:"M14 20v2",key:"1lq872"}],["path",{d:"M18 20v2",key:"10uadw"}],["path",{d:"M21 20H3",key:"kdqkdp"}],["path",{d:"M6 20v2",key:"a9bc87"}],["path",{d:"M8 16V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v12",key:"17n9tx"}],["rect",{x:"4",y:"6",width:"16",height:"10",rx:"2",key:"1097i5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lU=Z("BriefcaseMedical",[["path",{d:"M12 11v4",key:"a6ujw6"}],["path",{d:"M14 13h-4",key:"1pl8zg"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M18 6v14",key:"1mu4gy"}],["path",{d:"M6 6v14",key:"1s15cj"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ih=Z("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cU=Z("BringToFront",[["rect",{x:"8",y:"8",width:"8",height:"8",rx:"2",key:"yj20xf"}],["path",{d:"M4 10a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2",key:"1ltk23"}],["path",{d:"M14 20a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2",key:"1q24h9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dU=Z("Brush",[["path",{d:"m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08",key:"1styjt"}],["path",{d:"M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z",key:"z0l1mu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uU=Z("BugOff",[["path",{d:"M15 7.13V6a3 3 0 0 0-5.14-2.1L8 2",key:"vl8zik"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M22 13h-4v-2a4 4 0 0 0-4-4h-1.3",key:"1ou0bd"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M7.7 7.7A4 4 0 0 0 6 11v3a6 6 0 0 0 11.13 3.13",key:"1njkjs"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hU=Z("BugPlay",[["path",{d:"M12.765 21.522a.5.5 0 0 1-.765-.424v-8.196a.5.5 0 0 1 .765-.424l5.878 3.674a1 1 0 0 1 0 1.696z",key:"17shqo"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M18 11a4 4 0 0 0-4-4h-4a4 4 0 0 0-4 4v3a6.1 6.1 0 0 0 2 4.5",key:"1tjixy"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mU=Z("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pa=Z("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H4=Z("Building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pU=Z("BusFront",[["path",{d:"M4 6 2 7",key:"1mqr15"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"m22 7-2-1",key:"1umjhc"}],["rect",{width:"16",height:"16",x:"4",y:"3",rx:"2",key:"1wxw4b"}],["path",{d:"M4 11h16",key:"mpoxn0"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M6 19v2",key:"1loha6"}],["path",{d:"M18 21v-2",key:"sqyl04"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fU=Z("Bus",[["path",{d:"M8 6v6",key:"18i7km"}],["path",{d:"M15 6v6",key:"1sg6z9"}],["path",{d:"M2 12h19.6",key:"de5uta"}],["path",{d:"M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3",key:"1wwztk"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}],["path",{d:"M9 18h5",key:"lrx6i"}],["circle",{cx:"16",cy:"18",r:"2",key:"1v4tcr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xU=Z("CableCar",[["path",{d:"M10 3h.01",key:"lbucoy"}],["path",{d:"M14 2h.01",key:"1k8aa1"}],["path",{d:"m2 9 20-5",key:"1kz0j5"}],["path",{d:"M12 12V6.5",key:"1vbrij"}],["rect",{width:"16",height:"10",x:"4",y:"12",rx:"3",key:"if91er"}],["path",{d:"M9 12v5",key:"3anwtq"}],["path",{d:"M15 12v5",key:"5xh3zn"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gU=Z("Cable",[["path",{d:"M17 21v-2a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1",key:"10bnsj"}],["path",{d:"M19 15V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V9",key:"1eqmu1"}],["path",{d:"M21 21v-2h-4",key:"14zm7j"}],["path",{d:"M3 5h4V3",key:"z442eg"}],["path",{d:"M7 5a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1V3",key:"ebdjd7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yU=Z("CakeSlice",[["circle",{cx:"9",cy:"7",r:"2",key:"1305pl"}],["path",{d:"M7.2 7.9 3 11v9c0 .6.4 1 1 1h16c.6 0 1-.4 1-1v-9c0-2-3-6-7-8l-3.6 2.6",key:"xle13f"}],["path",{d:"M16 13H3",key:"1wpj08"}],["path",{d:"M16 17H3",key:"3lvfcd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lh=Z("Cake",[["path",{d:"M20 21v-8a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8",key:"1w3rig"}],["path",{d:"M4 16s.5-1 2-1 2.5 2 4 2 2.5-2 4-2 2.5 2 4 2 2-1 2-1",key:"n2jgmb"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M7 8v3",key:"1qtyvj"}],["path",{d:"M12 8v3",key:"hwp4zt"}],["path",{d:"M17 8v3",key:"1i6e5u"}],["path",{d:"M7 4h.01",key:"1bh4kh"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M17 4h.01",key:"1upcoc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xM=Z("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vU=Z("Calendar1",[["path",{d:"M11 14h1v4",key:"fy54vd"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _U=Z("CalendarArrowDown",[["path",{d:"m14 18 4 4 4-4",key:"1waygx"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M18 14v8",key:"irew45"}],["path",{d:"M21 11.354V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.343",key:"bse4f3"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bU=Z("CalendarArrowUp",[["path",{d:"m14 18 4-4 4 4",key:"ftkppy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M18 22v-8",key:"su0gjh"}],["path",{d:"M21 11.343V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h9",key:"1exg90"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wU=Z("CalendarCheck2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 14V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"bce9hv"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aL=Z("CalendarCheck",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m9 16 2 2 4-4",key:"19s6y9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gM=Z("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jU=Z("CalendarCog",[["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"M21 10.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"11kmuh"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xd=Z("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NU=Z("CalendarFold",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 17V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11Z",key:"kg77oy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M15 22v-4a2 2 0 0 1 2-2h4",key:"1gnbqr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kU=Z("CalendarHeart",[["path",{d:"M3 10h18V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7",key:"136lmk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21.29 14.7a2.43 2.43 0 0 0-2.65-.52c-.3.12-.57.3-.8.53l-.34.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L17.5 22l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1t7hil"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SU=Z("CalendarMinus2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M10 16h4",key:"17e571"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CU=Z("CalendarMinus",[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 15V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1scpom"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iL=Z("CalendarOff",[["path",{d:"M4.2 4.2A2 2 0 0 0 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.82-1.18",key:"16swn3"}],["path",{d:"M21 15.5V6a2 2 0 0 0-2-2H9.5",key:"yhw86o"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h7",key:"1wap6i"}],["path",{d:"M21 10h-5.5",key:"quycpq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MU=Z("CalendarPlus2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M10 16h4",key:"17e571"}],["path",{d:"M12 14v4",key:"1thi36"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bb=Z("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TU=Z("CalendarRange",[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M17 14h-6",key:"bkmgh3"}],["path",{d:"M13 18H7",key:"bb0bb7"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 18h.01",key:"1bdyru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AU=Z("CalendarSearch",[["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 11.75V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.25",key:"1jrsq6"}],["path",{d:"m22 22-1.875-1.875",key:"13zax7"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EU=Z("CalendarSync",[["path",{d:"M11 10v4h4",key:"172dkj"}],["path",{d:"m11 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"vu0qm5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"m21 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"1qgeyt"}],["path",{d:"M21 22v-4h-4",key:"hrummi"}],["path",{d:"M21 8.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h4.3",key:"mctw84"}],["path",{d:"M3 10h4",key:"1el30a"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PU=Z("CalendarX2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m17 22 5-5",key:"1k6ppv"}],["path",{d:"m17 17 5 5",key:"p7ous7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IU=Z("CalendarX",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m14 14-4 4",key:"rymu2i"}],["path",{d:"m10 14 4 4",key:"3sz06r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const on=Z("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LU=Z("CameraOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16",key:"qmtpty"}],["path",{d:"M9.5 4h5L17 7h3a2 2 0 0 1 2 2v7.5",key:"1ufyfc"}],["path",{d:"M14.121 15.121A3 3 0 1 1 9.88 10.88",key:"11zox6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xx=Z("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DU=Z("CandyCane",[["path",{d:"M5.7 21a2 2 0 0 1-3.5-2l8.6-14a6 6 0 0 1 10.4 6 2 2 0 1 1-3.464-2 2 2 0 1 0-3.464-2Z",key:"isaq8g"}],["path",{d:"M17.75 7 15 2.1",key:"12x7e8"}],["path",{d:"M10.9 4.8 13 9",key:"100a87"}],["path",{d:"m7.9 9.7 2 4.4",key:"ntfhaj"}],["path",{d:"M4.9 14.7 7 18.9",key:"1x43jy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RU=Z("CandyOff",[["path",{d:"m8.5 8.5-1 1a4.95 4.95 0 0 0 7 7l1-1",key:"1ff4ui"}],["path",{d:"M11.843 6.187A4.947 4.947 0 0 1 16.5 7.5a4.947 4.947 0 0 1 1.313 4.657",key:"1sbrv4"}],["path",{d:"M14 16.5V14",key:"1maf8j"}],["path",{d:"M14 6.5v1.843",key:"1a6u6t"}],["path",{d:"M10 10v7.5",key:"80pj65"}],["path",{d:"m16 7 1-5 1.367.683A3 3 0 0 0 19.708 3H21v1.292a3 3 0 0 0 .317 1.341L22 7l-5 1",key:"11a9mt"}],["path",{d:"m8 17-1 5-1.367-.683A3 3 0 0 0 4.292 21H3v-1.292a3 3 0 0 0-.317-1.341L2 17l5-1",key:"3mjmon"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OU=Z("Candy",[["path",{d:"m9.5 7.5-2 2a4.95 4.95 0 1 0 7 7l2-2a4.95 4.95 0 1 0-7-7Z",key:"ue6khb"}],["path",{d:"M14 6.5v10",key:"5xnk7c"}],["path",{d:"M10 7.5v10",key:"1uew51"}],["path",{d:"m16 7 1-5 1.37.68A3 3 0 0 0 19.7 3H21v1.3c0 .46.1.92.32 1.33L22 7l-5 1",key:"b9cp6k"}],["path",{d:"m8 17-1 5-1.37-.68A3 3 0 0 0 4.3 21H3v-1.3a3 3 0 0 0-.32-1.33L2 17l5-1",key:"5lney8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FU=Z("Cannabis",[["path",{d:"M12 22v-4",key:"1utk9m"}],["path",{d:"M7 12c-1.5 0-4.5 1.5-5 3 3.5 1.5 6 1 6 1-1.5 1.5-2 3.5-2 5 2.5 0 4.5-1.5 6-3 1.5 1.5 3.5 3 6 3 0-1.5-.5-3.5-2-5 0 0 2.5.5 6-1-.5-1.5-3.5-3-5-3 1.5-1 4-4 4-6-2.5 0-5.5 1.5-7 3 0-2.5-.5-5-2-7-1.5 2-2 4.5-2 7-1.5-1.5-4.5-3-7-3 0 2 2.5 5 4 6",key:"1mezod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zU=Z("CaptionsOff",[["path",{d:"M10.5 5H19a2 2 0 0 1 2 2v8.5",key:"jqtk4d"}],["path",{d:"M17 11h-.5",key:"1961ue"}],["path",{d:"M19 19H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2",key:"1keqsi"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M7 11h4",key:"1o1z6v"}],["path",{d:"M7 15h2.5",key:"1ina1g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nj=Z("Captions",[["rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2",key:"12ruh7"}],["path",{d:"M7 15h4M15 15h2M7 11h2M13 11h4",key:"1ueiar"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BU=Z("CarFront",[["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $U=Z("CarTaxiFront",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qU=Z("Car",[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UU=Z("Caravan",[["path",{d:"M18 19V9a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v8a2 2 0 0 0 2 2h2",key:"19jm3t"}],["path",{d:"M2 9h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2",key:"13hakp"}],["path",{d:"M22 17v1a1 1 0 0 1-1 1H10v-9a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v9",key:"1crci8"}],["circle",{cx:"8",cy:"19",r:"2",key:"t8fc5s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VU=Z("Carrot",[["path",{d:"M2.27 21.7s9.87-3.5 12.73-6.36a4.5 4.5 0 0 0-6.36-6.37C5.77 11.84 2.27 21.7 2.27 21.7zM8.64 14l-2.05-2.04M15.34 15l-2.46-2.46",key:"rfqxbe"}],["path",{d:"M22 9s-1.33-2-3.5-2C16.86 7 15 9 15 9s1.33 2 3.5 2S22 9 22 9z",key:"6b25w4"}],["path",{d:"M15 2s-2 1.33-2 3.5S15 9 15 9s2-1.84 2-3.5C17 3.33 15 2 15 2z",key:"fn65lo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HU=Z("CaseLower",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GU=Z("CaseSensitive",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["circle",{cx:"18",cy:"12",r:"3",key:"1kchzo"}],["path",{d:"M21 9v6",key:"anns31"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WU=Z("CaseUpper",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["path",{d:"M15 11h4.5a2 2 0 0 1 0 4H15V7h4a2 2 0 0 1 0 4",key:"1sqfas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KU=Z("CassetteTape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["circle",{cx:"8",cy:"10",r:"2",key:"1xl4ub"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"10",r:"2",key:"r14t7q"}],["path",{d:"m6 20 .7-2.9A1.4 1.4 0 0 1 8.1 16h7.8a1.4 1.4 0 0 1 1.4 1l.7 3",key:"l01ucn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZU=Z("Cast",[["path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6",key:"3zrzxg"}],["path",{d:"M2 12a9 9 0 0 1 8 8",key:"g6cvee"}],["path",{d:"M2 16a5 5 0 0 1 4 4",key:"1y1dii"}],["line",{x1:"2",x2:"2.01",y1:"20",y2:"20",key:"xu2jvo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YU=Z("Castle",[["path",{d:"M22 20v-9H2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2Z",key:"109fe4"}],["path",{d:"M18 11V4H6v7",key:"mon5oj"}],["path",{d:"M15 22v-4a3 3 0 0 0-3-3a3 3 0 0 0-3 3v4",key:"1k4jtn"}],["path",{d:"M22 11V9",key:"3zbp94"}],["path",{d:"M2 11V9",key:"1x5rnq"}],["path",{d:"M6 4V2",key:"1rsq15"}],["path",{d:"M18 4V2",key:"1jsdo1"}],["path",{d:"M10 4V2",key:"75d9ly"}],["path",{d:"M14 4V2",key:"8nj3z6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XU=Z("Cat",[["path",{d:"M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z",key:"x6xyqk"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M11.25 16.25h1.5L12 17l-.75-.75Z",key:"12kq1m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QU=Z("Cctv",[["path",{d:"M16.75 12h3.632a1 1 0 0 1 .894 1.447l-2.034 4.069a1 1 0 0 1-1.708.134l-2.124-2.97",key:"ir91b5"}],["path",{d:"M17.106 9.053a1 1 0 0 1 .447 1.341l-3.106 6.211a1 1 0 0 1-1.342.447L3.61 12.3a2.92 2.92 0 0 1-1.3-3.91L3.69 5.6a2.92 2.92 0 0 1 3.92-1.3z",key:"jlp8i1"}],["path",{d:"M2 19h3.76a2 2 0 0 0 1.8-1.1L9 15",key:"19bib8"}],["path",{d:"M2 21v-4",key:"l40lih"}],["path",{d:"M7 9h.01",key:"19b3jx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aj=Z("ChartArea",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ij=Z("ChartBarBig",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"7",y:"13",width:"9",height:"4",rx:"1",key:"1iip1u"}],["rect",{x:"7",y:"5",width:"12",height:"4",rx:"1",key:"1anskk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JU=Z("ChartBarDecreasing",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11h8",key:"1feolt"}],["path",{d:"M7 16h3",key:"ur6vzw"}],["path",{d:"M7 6h12",key:"sz5b0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eV=Z("ChartBarIncreasing",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11h8",key:"1feolt"}],["path",{d:"M7 16h12",key:"wsnu98"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tV=Z("ChartBarStacked",[["path",{d:"M11 13v4",key:"vyy2rb"}],["path",{d:"M15 5v4",key:"1gx88a"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"7",y:"13",width:"9",height:"4",rx:"1",key:"1iip1u"}],["rect",{x:"7",y:"5",width:"12",height:"4",rx:"1",key:"1anskk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oj=Z("ChartBar",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16h8",key:"srdodz"}],["path",{d:"M7 11h12",key:"127s9w"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lj=Z("ChartCandlestick",[["path",{d:"M9 5v4",key:"14uxtq"}],["rect",{width:"4",height:"6",x:"7",y:"9",rx:"1",key:"f4fvz0"}],["path",{d:"M9 15v2",key:"r5rk32"}],["path",{d:"M17 3v2",key:"1l2re6"}],["rect",{width:"4",height:"8",x:"15",y:"5",rx:"1",key:"z38je5"}],["path",{d:"M17 13v3",key:"5l0wba"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cj=Z("ChartColumnBig",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sV=Z("ChartColumnDecreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17v-3",key:"1sqioe"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17V5",key:"1wzmnc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dj=Z("ChartColumnIncreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17V5",key:"sfb6ij"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rV=Z("ChartColumnStacked",[["path",{d:"M11 13H7",key:"t0o9gq"}],["path",{d:"M19 9h-4",key:"rera1j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const to=Z("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nV=Z("ChartGantt",[["path",{d:"M10 6h8",key:"zvc2xc"}],["path",{d:"M12 16h6",key:"yi5mkt"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 11h7",key:"wz2hg0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uj=Z("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aV=Z("ChartNetwork",[["path",{d:"m13.11 7.664 1.78 2.672",key:"go2gg9"}],["path",{d:"m14.162 12.788-3.324 1.424",key:"11x848"}],["path",{d:"m20 4-6.06 1.515",key:"1wxxh7"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["circle",{cx:"12",cy:"6",r:"2",key:"1jj5th"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}],["circle",{cx:"9",cy:"15",r:"2",key:"lf2ghp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iV=Z("ChartNoAxesColumnDecreasing",[["path",{d:"M12 20V10",key:"g8npz5"}],["path",{d:"M18 20v-4",key:"8uic4z"}],["path",{d:"M6 20V4",key:"1w1bmo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hj=Z("ChartNoAxesColumnIncreasing",[["line",{x1:"12",x2:"12",y1:"20",y2:"10",key:"1vz5eb"}],["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["line",{x1:"6",x2:"6",y1:"20",y2:"16",key:"hq0ia6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mj=Z("ChartNoAxesColumn",[["line",{x1:"18",x2:"18",y1:"20",y2:"10",key:"1xfpm4"}],["line",{x1:"12",x2:"12",y1:"20",y2:"4",key:"be30l9"}],["line",{x1:"6",x2:"6",y1:"20",y2:"14",key:"1r4le6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oV=Z("ChartNoAxesCombined",[["path",{d:"M12 16v5",key:"zza2cw"}],["path",{d:"M16 14v7",key:"1g90b9"}],["path",{d:"M20 10v11",key:"1iqoj0"}],["path",{d:"m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15",key:"1fw8x9"}],["path",{d:"M4 18v3",key:"1yp0dc"}],["path",{d:"M8 14v7",key:"n3cwzv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pj=Z("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fj=Z("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xj=Z("ChartScatter",[["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["circle",{cx:"18.5",cy:"5.5",r:".5",fill:"currentColor",key:"lysivs"}],["circle",{cx:"11.5",cy:"11.5",r:".5",fill:"currentColor",key:"byv1b8"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["circle",{cx:"17.5",cy:"14.5",r:".5",fill:"currentColor",key:"1gjh6j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lV=Z("ChartSpline",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16c.5-2 1.5-7 4-7 2 0 2 3 4 3 2.5 0 4.5-5 5-7",key:"lw07rv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oL=Z("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jn=Z("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cV=Z("ChefHat",[["path",{d:"M17 21a1 1 0 0 0 1-1v-5.35c0-.457.316-.844.727-1.041a4 4 0 0 0-2.134-7.589 5 5 0 0 0-9.186 0 4 4 0 0 0-2.134 7.588c.411.198.727.585.727 1.041V20a1 1 0 0 0 1 1Z",key:"1qvrer"}],["path",{d:"M6 17h12",key:"1jwigz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dV=Z("Cherry",[["path",{d:"M2 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z",key:"cvxqlc"}],["path",{d:"M12 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z",key:"1ostrc"}],["path",{d:"M7 14c3.22-2.91 4.29-8.75 5-12 1.66 2.38 4.94 9 5 12",key:"hqx58h"}],["path",{d:"M22 9c-4.29 0-7.14-2.33-10-7 5.71 0 10 4.67 10 7Z",key:"eykp1o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oi=Z("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uV=Z("ChevronFirst",[["path",{d:"m17 18-6-6 6-6",key:"1yerx2"}],["path",{d:"M7 6v12",key:"1p53r6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hV=Z("ChevronLast",[["path",{d:"m7 18 6-6-6-6",key:"lwmzdw"}],["path",{d:"M17 6v12",key:"1o0aio"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xl=Z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sa=Z("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nf=Z("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mV=Z("ChevronsDownUp",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pV=Z("ChevronsDown",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fV=Z("ChevronsLeftRightEllipsis",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xV=Z("ChevronsLeftRight",[["path",{d:"m9 7-5 5 5 5",key:"j5w590"}],["path",{d:"m15 7 5 5-5 5",key:"1bl6da"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gV=Z("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yV=Z("ChevronsRightLeft",[["path",{d:"m20 17-5-5 5-5",key:"30x0n2"}],["path",{d:"m4 17 5-5-5-5",key:"16spf4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vV=Z("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gx=Z("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _V=Z("ChevronsUp",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bV=Z("Chrome",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["line",{x1:"21.17",x2:"12",y1:"8",y2:"8",key:"a0cw5f"}],["line",{x1:"3.95",x2:"8.54",y1:"6.06",y2:"14",key:"1kftof"}],["line",{x1:"10.88",x2:"15.46",y1:"21.94",y2:"14",key:"1ymyh8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wV=Z("Church",[["path",{d:"M10 9h4",key:"u4k05v"}],["path",{d:"M12 7v5",key:"ma6bk"}],["path",{d:"M14 22v-4a2 2 0 0 0-4 0v4",key:"1pdhuj"}],["path",{d:"M18 22V5.618a1 1 0 0 0-.553-.894l-4.553-2.277a2 2 0 0 0-1.788 0L6.553 4.724A1 1 0 0 0 6 5.618V22",key:"1rkokr"}],["path",{d:"m18 7 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9.618a1 1 0 0 1 .553-.894L6 7",key:"1w6esw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jV=Z("CigaretteOff",[["path",{d:"M12 12H3a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h13",key:"1gdiyg"}],["path",{d:"M18 8c0-2.5-2-2.5-2-5",key:"1il607"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M21 12a1 1 0 0 1 1 1v2a1 1 0 0 1-.5.866",key:"166zjj"}],["path",{d:"M22 8c0-2.5-2-2.5-2-5",key:"1gah44"}],["path",{d:"M7 12v4",key:"jqww69"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NV=Z("Cigarette",[["path",{d:"M17 12H3a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h14",key:"1mb5g1"}],["path",{d:"M18 8c0-2.5-2-2.5-2-5",key:"1il607"}],["path",{d:"M21 16a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"1yl5r7"}],["path",{d:"M22 8c0-2.5-2-2.5-2-5",key:"1gah44"}],["path",{d:"M7 12v4",key:"jqww69"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lo=Z("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gj=Z("CircleArrowDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yj=Z("CircleArrowLeft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"m12 8-4 4 4 4",key:"15vm53"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vj=Z("CircleArrowOutDownLeft",[["path",{d:"M2 12a10 10 0 1 1 10 10",key:"1yn6ov"}],["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"M8 22H2v-6",key:"sulq54"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _j=Z("CircleArrowOutDownRight",[["path",{d:"M12 22a10 10 0 1 1 10-10",key:"130bv5"}],["path",{d:"M22 22 12 12",key:"131aw7"}],["path",{d:"M22 16v6h-6",key:"1gvm70"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bj=Z("CircleArrowOutUpLeft",[["path",{d:"M2 8V2h6",key:"hiwtdz"}],["path",{d:"m2 2 10 10",key:"1oh8rs"}],["path",{d:"M12 2A10 10 0 1 1 2 12",key:"rrk4fa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wj=Z("CircleArrowOutUpRight",[["path",{d:"M22 12A10 10 0 1 1 12 2",key:"1fm58d"}],["path",{d:"M22 2 12 12",key:"yg2myt"}],["path",{d:"M16 2h6v6",key:"zan5cs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jj=Z("CircleArrowRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nj=Z("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ti=Z("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qn=Z("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kj=Z("CircleChevronDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sj=Z("CircleChevronLeft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14 16-4-4 4-4",key:"ojs7w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cj=Z("CircleChevronRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mj=Z("CircleChevronUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m8 14 4-4 4 4",key:"fy2ptz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kV=Z("CircleDashed",[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tj=Z("CircleDivide",[["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}],["line",{x1:"12",x2:"12",y1:"16",y2:"16",key:"aqc6ln"}],["line",{x1:"12",x2:"12",y1:"8",y2:"8",key:"1mkcni"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SV=Z("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CV=Z("CircleDotDashed",[["path",{d:"M10.1 2.18a9.93 9.93 0 0 1 3.8 0",key:"1qdqn0"}],["path",{d:"M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7",key:"1bq7p6"}],["path",{d:"M21.82 10.1a9.93 9.93 0 0 1 0 3.8",key:"1rlaqf"}],["path",{d:"M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69",key:"1xk03u"}],["path",{d:"M13.9 21.82a9.94 9.94 0 0 1-3.8 0",key:"l7re25"}],["path",{d:"M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7",key:"1v18p6"}],["path",{d:"M2.18 13.9a9.93 9.93 0 0 1 0-3.8",key:"xdo6bj"}],["path",{d:"M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69",key:"1jjmaz"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MV=Z("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TV=Z("CircleEllipsis",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AV=Z("CircleEqual",[["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EV=Z("CircleFadingArrowUp",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PV=Z("CircleFadingPlus",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aj=Z("CircleGauge",[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sv=Z("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ej=Z("CircleMinus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IV=Z("CircleOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.35 2.69A10 10 0 0 1 21.3 15.65",key:"1pfsoa"}],["path",{d:"M19.08 19.08A10 10 0 1 1 4.92 4.92",key:"1ablyi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pj=Z("CircleParkingOff",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m5 5 14 14",key:"11anup"}],["path",{d:"M13 13a3 3 0 1 0 0-6H9v2",key:"uoagbd"}],["path",{d:"M9 17v-2.34",key:"a9qo08"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ij=Z("CircleParking",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lj=Z("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dj=Z("CirclePercent",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sp=Z("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rj=Z("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oj=Z("CirclePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fj=Z("CircleSlash2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LV=Z("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zj=Z("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bj=Z("CircleUserRound",[["path",{d:"M18 20a6 6 0 0 0-12 0",key:"1qehca"}],["circle",{cx:"12",cy:"10",r:"4",key:"1h16sb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $j=Z("CircleUser",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zl=Z("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sd=Z("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DV=Z("CircuitBoard",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M11 9h4a2 2 0 0 0 2-2V3",key:"1ve2rv"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"M7 21v-4a2 2 0 0 1 2-2h4",key:"1fwkro"}],["circle",{cx:"15",cy:"15",r:"2",key:"3i40o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RV=Z("Citrus",[["path",{d:"M21.66 17.67a1.08 1.08 0 0 1-.04 1.6A12 12 0 0 1 4.73 2.38a1.1 1.1 0 0 1 1.61-.04z",key:"4ite01"}],["path",{d:"M19.65 15.66A8 8 0 0 1 8.35 4.34",key:"1gxipu"}],["path",{d:"m14 10-5.5 5.5",key:"92pfem"}],["path",{d:"M14 17.85V10H6.15",key:"xqmtsk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OV=Z("Clapperboard",[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yM=Z("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FV=Z("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wb=Z("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zV=Z("ClipboardMinus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BV=Z("ClipboardPaste",[["path",{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",key:"1pp7kr"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",key:"2ik1ml"}],["path",{d:"m17 10 4 4-4 4",key:"vp2hj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qj=Z("ClipboardPenLine",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.5",key:"1but9f"}],["path",{d:"M16 4h2a2 2 0 0 1 1.73 1",key:"1p8n7l"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uj=Z("ClipboardPen",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-5.5",key:"cereej"}],["path",{d:"M4 13.5V6a2 2 0 0 1 2-2h2",key:"5ua5vh"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $V=Z("ClipboardPlus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}],["path",{d:"M12 17v-6",key:"1y8rbf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qV=Z("ClipboardType",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 12v-1h6v1",key:"iehl6m"}],["path",{d:"M11 17h2",key:"12w5me"}],["path",{d:"M12 11v6",key:"1bwqyc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UV=Z("ClipboardX",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m15 11-6 6",key:"1toa9n"}],["path",{d:"m9 11 6 6",key:"wlibny"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VV=Z("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HV=Z("Clock1",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 14.5 8",key:"12zbmj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GV=Z("Clock10",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 10",key:"atfzqc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WV=Z("Clock11",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 8",key:"l5bg6f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KV=Z("Clock12",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12",key:"1fub01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZV=Z("Clock2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 10",key:"1g230d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YV=Z("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XV=Z("Clock4",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QV=Z("Clock5",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 14.5 16",key:"1pcbox"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JV=Z("Clock6",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 12 16.5",key:"hb2qv6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eH=Z("Clock7",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 16",key:"ka3394"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tH=Z("Clock8",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 14",key:"tmc9b4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sH=Z("Clock9",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 7.5 12",key:"1k60p0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rH=Z("ClockAlert",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["path",{d:"M16 21.16a10 10 0 1 1 5-13.516",key:"cxo92l"}],["path",{d:"M20 11.5v6",key:"2ei3xq"}],["path",{d:"M20 21.5h.01",key:"1r2dzp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nH=Z("ClockArrowDown",[["path",{d:"M12.338 21.994A10 10 0 1 1 21.925 13.227",key:"1i7shu"}],["path",{d:"M12 6v6l2 1",key:"19cm8n"}],["path",{d:"m14 18 4 4 4-4",key:"1waygx"}],["path",{d:"M18 14v8",key:"irew45"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aH=Z("ClockArrowUp",[["path",{d:"M13.228 21.925A10 10 0 1 1 21.994 12.338",key:"1fzlyi"}],["path",{d:"M12 6v6l1.562.781",key:"1ujuk9"}],["path",{d:"m14 18 4-4 4 4",key:"ftkppy"}],["path",{d:"M18 22v-8",key:"su0gjh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ln=Z("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iH=Z("CloudAlert",[["path",{d:"M12 12v4",key:"tww15h"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M17 18h.5a1 1 0 0 0 0-9h-1.79A7 7 0 1 0 7 17.708",key:"xsb5ju"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oH=Z("CloudCog",[["circle",{cx:"12",cy:"17",r:"3",key:"1spfwm"}],["path",{d:"M4.2 15.1A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2",key:"zaobp"}],["path",{d:"m15.7 18.4-.9-.3",key:"4qxpbn"}],["path",{d:"m9.2 15.9-.9-.3",key:"17q7o2"}],["path",{d:"m10.6 20.7.3-.9",key:"1pf4s2"}],["path",{d:"m13.1 14.2.3-.9",key:"1mnuqm"}],["path",{d:"m13.6 20.7-.4-1",key:"1jpd1m"}],["path",{d:"m10.8 14.3-.4-1",key:"17ugyy"}],["path",{d:"m8.3 18.6 1-.4",key:"s42vdx"}],["path",{d:"m14.7 15.8 1-.4",key:"2wizun"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vj=Z("CloudDownload",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lH=Z("CloudDrizzle",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 19v1",key:"1dk2by"}],["path",{d:"M8 14v1",key:"84yxot"}],["path",{d:"M16 19v1",key:"v220m7"}],["path",{d:"M16 14v1",key:"g12gj6"}],["path",{d:"M12 21v1",key:"q8vafk"}],["path",{d:"M12 16v1",key:"1mx6rx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cH=Z("CloudFog",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 17H7",key:"pygtm1"}],["path",{d:"M17 21H9",key:"1u2q02"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dH=Z("CloudHail",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v2",key:"a1is7l"}],["path",{d:"M8 14v2",key:"1e9m6t"}],["path",{d:"M16 20h.01",key:"xwek51"}],["path",{d:"M8 20h.01",key:"1vjney"}],["path",{d:"M12 16v2",key:"z66u1j"}],["path",{d:"M12 22h.01",key:"1urd7a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uH=Z("CloudLightning",[["path",{d:"M6 16.326A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 .5 8.973",key:"1cez44"}],["path",{d:"m13 12-3 5h4l-3 5",key:"1t22er"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hH=Z("CloudMoonRain",[["path",{d:"M10.188 8.5A6 6 0 0 1 16 4a1 1 0 0 0 6 6 6 6 0 0 1-3 5.197",key:"erj67n"}],["path",{d:"M11 20v2",key:"174qtz"}],["path",{d:"M3 20a5 5 0 1 1 8.9-4H13a3 3 0 0 1 2 5.24",key:"1qmrp3"}],["path",{d:"M7 19v2",key:"12npes"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mH=Z("CloudMoon",[["path",{d:"M10.188 8.5A6 6 0 0 1 16 4a1 1 0 0 0 6 6 6 6 0 0 1-3 5.197",key:"erj67n"}],["path",{d:"M13 16a3 3 0 1 1 0 6H7a5 5 0 1 1 4.9-6Z",key:"p44pc9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pH=Z("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fH=Z("CloudRainWind",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m9.2 22 3-7",key:"sb5f6j"}],["path",{d:"m9 13-3 7",key:"500co5"}],["path",{d:"m17 13-3 7",key:"8t2fiy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xH=Z("CloudRain",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v6",key:"1j4efv"}],["path",{d:"M8 14v6",key:"17c4r9"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gH=Z("CloudSnow",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M8 19h.01",key:"puxtts"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M12 21h.01",key:"h35vbk"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M16 19h.01",key:"1vcnzz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yH=Z("CloudSunRain",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M3 20a5 5 0 1 1 8.9-4H13a3 3 0 0 1 2 5.24",key:"1qmrp3"}],["path",{d:"M11 20v2",key:"174qtz"}],["path",{d:"M7 19v2",key:"12npes"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vH=Z("CloudSun",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z",key:"s09mg5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hj=Z("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _H=Z("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bH=Z("Cloudy",[["path",{d:"M17.5 21H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"gqqjvc"}],["path",{d:"M22 10a3 3 0 0 0-3-3h-2.207a5.502 5.502 0 0 0-10.702.5",key:"1p2s76"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fv=Z("Clover",[["path",{d:"M16.17 7.83 2 22",key:"t58vo8"}],["path",{d:"M4.02 12a2.827 2.827 0 1 1 3.81-4.17A2.827 2.827 0 1 1 12 4.02a2.827 2.827 0 1 1 4.17 3.81A2.827 2.827 0 1 1 19.98 12a2.827 2.827 0 1 1-3.81 4.17A2.827 2.827 0 1 1 12 19.98a2.827 2.827 0 1 1-4.17-3.81A1 1 0 1 1 4 12",key:"17k36q"}],["path",{d:"m7.83 7.83 8.34 8.34",key:"1d7sxk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wH=Z("Club",[["path",{d:"M17.28 9.05a5.5 5.5 0 1 0-10.56 0A5.5 5.5 0 1 0 12 17.66a5.5 5.5 0 1 0 5.28-8.6Z",key:"27yuqz"}],["path",{d:"M12 17.66L12 22",key:"ogfahf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gj=Z("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G4=Z("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jH=Z("Codepen",[["polygon",{points:"12 2 22 8.5 22 15.5 12 22 2 15.5 2 8.5 12 2",key:"srzb37"}],["line",{x1:"12",x2:"12",y1:"22",y2:"15.5",key:"1t73f2"}],["polyline",{points:"22 8.5 12 15.5 2 8.5",key:"ajlxae"}],["polyline",{points:"2 15.5 12 8.5 22 15.5",key:"susrui"}],["line",{x1:"12",x2:"12",y1:"2",y2:"8.5",key:"2cldga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NH=Z("Codesandbox",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}],["polyline",{points:"7.5 4.21 12 6.81 16.5 4.21",key:"fabo96"}],["polyline",{points:"7.5 19.79 7.5 14.6 3 12",key:"z377f1"}],["polyline",{points:"21 12 16.5 14.6 16.5 19.79",key:"9nrev1"}],["polyline",{points:"3.27 6.96 12 12.01 20.73 6.96",key:"1180pa"}],["line",{x1:"12",x2:"12",y1:"22.08",y2:"12",key:"3z3uq6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W4=Z("Coffee",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kH=Z("Cog",[["path",{d:"M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",key:"sobvz5"}],["path",{d:"M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",key:"11i496"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lL=Z("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wj=Z("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kj=Z("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SH=Z("Columns4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7.5 3v18",key:"w0wo6v"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M16.5 3v18",key:"10tjh1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CH=Z("Combine",[["path",{d:"M10 18H5a3 3 0 0 1-3-3v-1",key:"ru65g8"}],["path",{d:"M14 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"e30een"}],["path",{d:"M20 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"2ahx8o"}],["path",{d:"m7 21 3-3-3-3",key:"127cv2"}],["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MH=Z("Command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vM=Z("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TH=Z("Component",[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AH=Z("Computer",[["rect",{width:"14",height:"8",x:"5",y:"2",rx:"2",key:"wc9tft"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h2",key:"rwmk9e"}],["path",{d:"M12 18h6",key:"aqd8w3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EH=Z("ConciergeBell",[["path",{d:"M3 20a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1Z",key:"1pvr1r"}],["path",{d:"M20 16a8 8 0 1 0-16 0",key:"1pa543"}],["path",{d:"M12 4v4",key:"1bq03y"}],["path",{d:"M10 4h4",key:"1xpv9s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PH=Z("Cone",[["path",{d:"m20.9 18.55-8-15.98a1 1 0 0 0-1.8 0l-8 15.98",key:"53pte7"}],["ellipse",{cx:"12",cy:"19",rx:"9",ry:"3",key:"1ji25f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IH=Z("Construction",[["rect",{x:"2",y:"6",width:"20",height:"8",rx:"1",key:"1estib"}],["path",{d:"M17 14v7",key:"7m2elx"}],["path",{d:"M7 14v7",key:"1cm7wv"}],["path",{d:"M17 3v3",key:"1v4jwn"}],["path",{d:"M7 3v3",key:"7o6guu"}],["path",{d:"M10 14 2.3 6.3",key:"1023jk"}],["path",{d:"m14 6 7.7 7.7",key:"1s8pl2"}],["path",{d:"m8 6 8 8",key:"hl96qh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zj=Z("ContactRound",[["path",{d:"M16 2v2",key:"scm5qe"}],["path",{d:"M17.915 22a6 6 0 0 0-12 0",key:"suqz9p"}],["path",{d:"M8 2v2",key:"pbkmx"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K4=Z("Contact",[["path",{d:"M16 2v2",key:"scm5qe"}],["path",{d:"M7 22v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2",key:"1waht3"}],["path",{d:"M8 2v2",key:"pbkmx"}],["circle",{cx:"12",cy:"11",r:"3",key:"itu57m"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LH=Z("Container",[["path",{d:"M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z",key:"1t2lqe"}],["path",{d:"M10 21.9V14L2.1 9.1",key:"o7czzq"}],["path",{d:"m10 14 11.9-6.9",key:"zm5e20"}],["path",{d:"M14 19.8v-8.1",key:"159ecu"}],["path",{d:"M18 17.5V9.4",key:"11uown"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DH=Z("Contrast",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 18a6 6 0 0 0 0-12v12z",key:"j4l70d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RH=Z("Cookie",[["path",{d:"M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5",key:"laymnq"}],["path",{d:"M8.5 8.5v.01",key:"ue8clq"}],["path",{d:"M16 15.5v.01",key:"14dtrp"}],["path",{d:"M12 12v.01",key:"u5ubse"}],["path",{d:"M11 17v.01",key:"1hyl5a"}],["path",{d:"M7 14v.01",key:"uct60s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OH=Z("CookingPot",[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M20 12v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8",key:"u0tga0"}],["path",{d:"m4 8 16-4",key:"16g0ng"}],["path",{d:"m8.86 6.78-.45-1.81a2 2 0 0 1 1.45-2.43l1.94-.48a2 2 0 0 1 2.43 1.46l.45 1.8",key:"12cejc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FH=Z("CopyCheck",[["path",{d:"m12 15 2 2 4-4",key:"2c609p"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zH=Z("CopyMinus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BH=Z("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $H=Z("CopySlash",[["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qH=Z("CopyX",[["line",{x1:"12",x2:"18",y1:"12",y2:"18",key:"1rg63v"}],["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ya=Z("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UH=Z("Copyleft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.17 14.83a4 4 0 1 0 0-5.66",key:"1sveal"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VH=Z("Copyright",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M14.83 14.83a4 4 0 1 1 0-5.66",key:"1i56pz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HH=Z("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GH=Z("CornerDownRight",[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WH=Z("CornerLeftDown",[["polyline",{points:"14 15 9 20 4 15",key:"nkc4i"}],["path",{d:"M20 4h-7a4 4 0 0 0-4 4v12",key:"nbpdq2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KH=Z("CornerLeftUp",[["polyline",{points:"14 9 9 4 4 9",key:"m9oyvo"}],["path",{d:"M20 20h-7a4 4 0 0 1-4-4V4",key:"1blwi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZH=Z("CornerRightDown",[["polyline",{points:"10 15 15 20 20 15",key:"axus6l"}],["path",{d:"M4 4h7a4 4 0 0 1 4 4v12",key:"wcbgct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YH=Z("CornerRightUp",[["polyline",{points:"10 9 15 4 20 9",key:"1lr6px"}],["path",{d:"M4 20h7a4 4 0 0 0 4-4V4",key:"1plgdj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XH=Z("CornerUpLeft",[["polyline",{points:"9 14 4 9 9 4",key:"881910"}],["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QH=Z("CornerUpRight",[["polyline",{points:"15 14 20 9 15 4",key:"1tbx3s"}],["path",{d:"M4 20v-7a4 4 0 0 1 4-4h12",key:"1lu4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JH=Z("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eG=Z("CreativeCommons",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M10 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1ss3eq"}],["path",{d:"M17 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1od56t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yx=Z("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tG=Z("Croissant",[["path",{d:"m4.6 13.11 5.79-3.21c1.89-1.05 4.79 1.78 3.71 3.71l-3.22 5.81C8.8 23.16.79 15.23 4.6 13.11Z",key:"1ozxlb"}],["path",{d:"m10.5 9.5-1-2.29C9.2 6.48 8.8 6 8 6H4.5C2.79 6 2 6.5 2 8.5a7.71 7.71 0 0 0 2 4.83",key:"ffuyb5"}],["path",{d:"M8 6c0-1.55.24-4-2-4-2 0-2.5 2.17-2.5 4",key:"osnpzi"}],["path",{d:"m14.5 13.5 2.29 1c.73.3 1.21.7 1.21 1.5v3.5c0 1.71-.5 2.5-2.5 2.5a7.71 7.71 0 0 1-4.83-2",key:"1vubaw"}],["path",{d:"M18 16c1.55 0 4-.24 4 2 0 2-2.17 2.5-4 2.5",key:"wxr772"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sG=Z("Crop",[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rG=Z("Cross",[["path",{d:"M4 9a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h4a1 1 0 0 1 1 1v4a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-4a1 1 0 0 1 1-1h4a2 2 0 0 0 2-2v-2a2 2 0 0 0-2-2h-4a1 1 0 0 1-1-1V4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4a1 1 0 0 1-1 1z",key:"1xbrqy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nG=Z("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cm=Z("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aG=Z("Cuboid",[["path",{d:"m21.12 6.4-6.05-4.06a2 2 0 0 0-2.17-.05L2.95 8.41a2 2 0 0 0-.95 1.7v5.82a2 2 0 0 0 .88 1.66l6.05 4.07a2 2 0 0 0 2.17.05l9.95-6.12a2 2 0 0 0 .95-1.7V8.06a2 2 0 0 0-.88-1.66Z",key:"1u2ovd"}],["path",{d:"M10 22v-8L2.25 9.15",key:"11pn4q"}],["path",{d:"m10 14 11.77-6.87",key:"1kt1wh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iG=Z("CupSoda",[["path",{d:"m6 8 1.75 12.28a2 2 0 0 0 2 1.72h4.54a2 2 0 0 0 2-1.72L18 8",key:"8166m8"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"yjz344"}],["path",{d:"m12 8 1-6h2",key:"3ybfa4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oG=Z("Currency",[["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}],["line",{x1:"3",x2:"6",y1:"3",y2:"6",key:"1jkytn"}],["line",{x1:"21",x2:"18",y1:"3",y2:"6",key:"14zfjt"}],["line",{x1:"3",x2:"6",y1:"21",y2:"18",key:"iusuec"}],["line",{x1:"21",x2:"18",y1:"21",y2:"18",key:"yj2dd7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lG=Z("Cylinder",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cG=Z("Dam",[["path",{d:"M11 11.31c1.17.56 1.54 1.69 3.5 1.69 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"157kva"}],["path",{d:"M11.75 18c.35.5 1.45 1 2.75 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"d7q6m6"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M7 3a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1L10 4a1 1 0 0 0-1-1z",key:"pr6s65"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dG=Z("DatabaseBackup",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 12a9 3 0 0 0 5 2.69",key:"1ui2ym"}],["path",{d:"M21 9.3V5",key:"6k6cib"}],["path",{d:"M3 5v14a9 3 0 0 0 6.47 2.88",key:"i62tjy"}],["path",{d:"M12 12v4h4",key:"1bxaet"}],["path",{d:"M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16",key:"1f4ei9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uG=Z("DatabaseZap",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 15 21.84",key:"14ibmq"}],["path",{d:"M21 5V8",key:"1marbg"}],["path",{d:"M21 12L18 17H22L19 22",key:"zafso"}],["path",{d:"M3 12A9 3 0 0 0 14.59 14.87",key:"1y4wr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cL=Z("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hG=Z("Delete",[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mG=Z("Dessert",[["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["path",{d:"M10.2 3.2C5.5 4 2 8.1 2 13a2 2 0 0 0 4 0v-1a2 2 0 0 1 4 0v4a2 2 0 0 0 4 0v-4a2 2 0 0 1 4 0v1a2 2 0 0 0 4 0c0-4.9-3.5-9-8.2-9.8",key:"lfo06j"}],["path",{d:"M3.2 14.8a9 9 0 0 0 17.6 0",key:"12xarc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pG=Z("Diameter",[["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["circle",{cx:"5",cy:"5",r:"2",key:"1gwv83"}],["path",{d:"M6.48 3.66a10 10 0 0 1 13.86 13.86",key:"xr8kdq"}],["path",{d:"m6.41 6.41 11.18 11.18",key:"uhpjw7"}],["path",{d:"M3.66 6.48a10 10 0 0 0 13.86 13.86",key:"cldpwv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fG=Z("DiamondMinus",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yj=Z("DiamondPercent",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0Z",key:"1tpxz2"}],["path",{d:"M9.2 9.2h.01",key:"1b7bvt"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"M14.7 14.8h.01",key:"17nsh4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xG=Z("DiamondPlus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gG=Z("Diamond",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yG=Z("Dice1",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vG=Z("Dice2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M9 15h.01",key:"fzyn71"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _G=Z("Dice3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bG=Z("Dice4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wG=Z("Dice5",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jG=Z("Dice6",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NG=Z("Dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kG=Z("Diff",[["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SG=Z("Disc2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CG=Z("Disc3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M6 12c0-1.7.7-3.2 1.8-4.2",key:"oqkarx"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M18 12c0 1.7-.7 3.2-1.8 4.2",key:"1eah9h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MG=Z("DiscAlbum",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"5",key:"nd82uf"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TG=Z("Disc",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AG=Z("Divide",[["circle",{cx:"12",cy:"6",r:"1",key:"1bh7o1"}],["line",{x1:"5",x2:"19",y1:"12",y2:"12",key:"13b5wn"}],["circle",{cx:"12",cy:"18",r:"1",key:"lqb9t5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EG=Z("DnaOff",[["path",{d:"M15 2c-1.35 1.5-2.092 3-2.5 4.5L14 8",key:"1bivrr"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c3.333-3 6.667-3 10-3",key:"nxix30"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M22 9c-1.5 1.35-3 2.092-4.5 2.5l-1-1",key:"18cutr"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.35-1.5 2.092-3 2.5-4.5L10 16",key:"rlvei3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PG=Z("Dna",[["path",{d:"m10 16 1.5 1.5",key:"11lckj"}],["path",{d:"m14 8-1.5-1.5",key:"1ohn8i"}],["path",{d:"M15 2c-1.798 1.998-2.518 3.995-2.807 5.993",key:"80uv8i"}],["path",{d:"m16.5 10.5 1 1",key:"696xn5"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c6.667-6 13.333 0 20-6",key:"1pyr53"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.798-1.998 2.518-3.995 2.807-5.993",key:"q3hbxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IG=Z("Dock",[["path",{d:"M2 8h20",key:"d11cs7"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 16h12",key:"u522kt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LG=Z("Dog",[["path",{d:"M11.25 16.25h1.5L12 17z",key:"w7jh35"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309",key:"u7s9ue"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235A7.497 7.497 0 0 1 14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5",key:"v8hric"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yc=Z("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DG=Z("Donut",[["path",{d:"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3",key:"19sr3x"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RG=Z("DoorClosed",[["path",{d:"M18 20V6a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v14",key:"36qu9e"}],["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"M14 12v.01",key:"xfcn54"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wv=Z("DoorOpen",[["path",{d:"M13 4h3a2 2 0 0 1 2 2v14",key:"hrm0s9"}],["path",{d:"M2 20h3",key:"1gaodv"}],["path",{d:"M13 20h9",key:"s90cdi"}],["path",{d:"M10 12v.01",key:"vx6srw"}],["path",{d:"M13 4.562v16.157a1 1 0 0 1-1.242.97L5 20V5.562a2 2 0 0 1 1.515-1.94l4-1A2 2 0 0 1 13 4.561Z",key:"199qr4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OG=Z("Dot",[["circle",{cx:"12.1",cy:"12.1",r:"1",key:"18d7e5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xa=Z("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FG=Z("DraftingCompass",[["path",{d:"m12.99 6.74 1.93 3.44",key:"iwagvd"}],["path",{d:"M19.136 12a10 10 0 0 1-14.271 0",key:"ppmlo4"}],["path",{d:"m21 21-2.16-3.84",key:"vylbct"}],["path",{d:"m3 21 8.02-14.26",key:"1ssaw4"}],["circle",{cx:"12",cy:"5",r:"2",key:"f1ur92"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zG=Z("Drama",[["path",{d:"M10 11h.01",key:"d2at3l"}],["path",{d:"M14 6h.01",key:"k028ub"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6.5 13.1h.01",key:"1748ia"}],["path",{d:"M22 5c0 9-4 12-6 12s-6-3-6-12c0-2 2-3 6-3s6 1 6 3",key:"172yzv"}],["path",{d:"M17.4 9.9c-.8.8-2 .8-2.8 0",key:"1obv0w"}],["path",{d:"M10.1 7.1C9 7.2 7.7 7.7 6 8.6c-3.5 2-4.7 3.9-3.7 5.6 4.5 7.8 9.5 8.4 11.2 7.4.9-.5 1.9-2.1 1.9-4.7",key:"rqjl8i"}],["path",{d:"M9.1 16.5c.3-1.1 1.4-1.7 2.4-1.4",key:"1mr6wy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BG=Z("Dribbble",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M19.13 5.09C15.22 9.14 10 10.44 2.25 10.94",key:"hpej1"}],["path",{d:"M21.75 12.84c-6.62-1.41-12.14 1-16.38 6.32",key:"1tr44o"}],["path",{d:"M8.56 2.75c4.37 6 6 9.42 8 17.72",key:"kbh691"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $G=Z("Drill",[["path",{d:"M10 18a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H5a3 3 0 0 1-3-3 1 1 0 0 1 1-1z",key:"ioqxb1"}],["path",{d:"M13 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1l-.81 3.242a1 1 0 0 1-.97.758H8",key:"1rs59n"}],["path",{d:"M14 4h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-3",key:"105ega"}],["path",{d:"M18 6h4",key:"66u95g"}],["path",{d:"m5 10-2 8",key:"xt2lic"}],["path",{d:"m7 18 2-8",key:"1bzku2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qG=Z("Droplet",[["path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z",key:"c7niix"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ag=Z("Droplets",[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UG=Z("Drum",[["path",{d:"m2 2 8 8",key:"1v6059"}],["path",{d:"m22 2-8 8",key:"173r8a"}],["ellipse",{cx:"12",cy:"9",rx:"10",ry:"5",key:"liohsx"}],["path",{d:"M7 13.4v7.9",key:"1yi6u9"}],["path",{d:"M12 14v8",key:"1tn2tj"}],["path",{d:"M17 13.4v7.9",key:"eqz2v3"}],["path",{d:"M2 9v8a10 5 0 0 0 20 0V9",key:"1750ul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VG=Z("Drumstick",[["path",{d:"M15.4 15.63a7.875 6 135 1 1 6.23-6.23 4.5 3.43 135 0 0-6.23 6.23",key:"1dtqwm"}],["path",{d:"m8.29 12.71-2.6 2.6a2.5 2.5 0 1 0-1.65 4.65A2.5 2.5 0 1 0 8.7 18.3l2.59-2.59",key:"1oq1fw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HG=Z("Dumbbell",[["path",{d:"M14.4 14.4 9.6 9.6",key:"ic80wn"}],["path",{d:"M18.657 21.485a2 2 0 1 1-2.829-2.828l-1.767 1.768a2 2 0 1 1-2.829-2.829l6.364-6.364a2 2 0 1 1 2.829 2.829l-1.768 1.767a2 2 0 1 1 2.828 2.829z",key:"nnl7wr"}],["path",{d:"m21.5 21.5-1.4-1.4",key:"1f1ice"}],["path",{d:"M3.9 3.9 2.5 2.5",key:"1evmna"}],["path",{d:"M6.404 12.768a2 2 0 1 1-2.829-2.829l1.768-1.767a2 2 0 1 1-2.828-2.829l2.828-2.828a2 2 0 1 1 2.829 2.828l1.767-1.768a2 2 0 1 1 2.829 2.829z",key:"yhosts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GG=Z("EarOff",[["path",{d:"M6 18.5a3.5 3.5 0 1 0 7 0c0-1.57.92-2.52 2.04-3.46",key:"1qngmn"}],["path",{d:"M6 8.5c0-.75.13-1.47.36-2.14",key:"b06bma"}],["path",{d:"M8.8 3.15A6.5 6.5 0 0 1 19 8.5c0 1.63-.44 2.81-1.09 3.76",key:"g10hsz"}],["path",{d:"M12.5 6A2.5 2.5 0 0 1 15 8.5M10 13a2 2 0 0 0 1.82-1.18",key:"ygzou7"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WG=Z("Ear",[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KG=Z("EarthLock",[["path",{d:"M7 3.34V5a3 3 0 0 0 3 3",key:"w732o8"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"f02343"}],["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M12 2a10 10 0 1 0 9.54 13",key:"zjsr6q"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xj=Z("Earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZG=Z("Eclipse",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a7 7 0 1 0 10 10",key:"1yuj32"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YG=Z("EggFried",[["circle",{cx:"11.5",cy:"12.5",r:"3.5",key:"1cl1mi"}],["path",{d:"M3 8c0-3.5 2.5-6 6.5-6 5 0 4.83 3 7.5 5s5 2 5 6c0 4.5-2.5 6.5-7 6.5-2.5 0-2.5 2.5-6 2.5s-7-2-7-5.5c0-3 1.5-3 1.5-5C3.5 10 3 9 3 8Z",key:"165ef9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XG=Z("EggOff",[["path",{d:"M6.399 6.399C5.362 8.157 4.65 10.189 4.5 12c-.37 4.43 1.27 9.95 7.5 10 3.256-.026 5.259-1.547 6.375-3.625",key:"6et380"}],["path",{d:"M19.532 13.875A14.07 14.07 0 0 0 19.5 12c-.36-4.34-3.95-9.96-7.5-10-1.04.012-2.082.502-3.046 1.297",key:"gcdc3f"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _M=Z("Egg",[["path",{d:"M12 22c6.23-.05 7.87-5.57 7.5-10-.36-4.34-3.95-9.96-7.5-10-3.55.04-7.14 5.66-7.5 10-.37 4.43 1.27 9.95 7.5 10z",key:"1c39pg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ax=Z("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ix=Z("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QG=Z("EqualApproximately",[["path",{d:"M5 15a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"yrdkhy"}],["path",{d:"M5 9a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"gzkvyz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JG=Z("EqualNot",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}],["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eW=Z("Equal",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tW=Z("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sW=Z("EthernetPort",[["path",{d:"m15 20 3-3h2a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h2l3 3z",key:"rbahqx"}],["path",{d:"M6 8v1",key:"1636ez"}],["path",{d:"M10 8v1",key:"1talb4"}],["path",{d:"M14 8v1",key:"1rsfgr"}],["path",{d:"M18 8v1",key:"gnkwox"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rW=Z("Euro",[["path",{d:"M4 10h12",key:"1y6xl8"}],["path",{d:"M4 14h9",key:"1loblj"}],["path",{d:"M19 6a7.7 7.7 0 0 0-5.2-2A7.9 7.9 0 0 0 6 12c0 4.4 3.5 8 7.8 8 2 0 3.8-.8 5.2-2",key:"1j6lzo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nW=Z("Expand",[["path",{d:"m21 21-6-6m6 6v-4.8m0 4.8h-4.8",key:"1c15vz"}],["path",{d:"M3 16.2V21m0 0h4.8M3 21l6-6",key:"1fsnz2"}],["path",{d:"M21 7.8V3m0 0h-4.8M21 3l-6 6",key:"hawz9i"}],["path",{d:"M3 7.8V3m0 0h4.8M3 3l6 6",key:"u9ee12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kr=Z("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aW=Z("EyeClosed",[["path",{d:"m15 18-.722-3.25",key:"1j64jw"}],["path",{d:"M2 8a10.645 10.645 0 0 0 20 0",key:"1e7gxb"}],["path",{d:"m20 15-1.726-2.05",key:"1cnuld"}],["path",{d:"m4 15 1.726-2.05",key:"1dsqqd"}],["path",{d:"m9 18 .722-3.25",key:"ypw2yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mp=Z("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wn=Z("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uu=Z("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iW=Z("Factory",[["path",{d:"M2 20a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8l-7 5V8l-7 5V4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"159hny"}],["path",{d:"M17 18h1",key:"uldtlt"}],["path",{d:"M12 18h1",key:"s9uhes"}],["path",{d:"M7 18h1",key:"1neino"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oW=Z("Fan",[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lW=Z("FastForward",[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cW=Z("Feather",[["path",{d:"M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z",key:"18jl4k"}],["path",{d:"M16 8 2 22",key:"vp34q"}],["path",{d:"M17.5 15H9",key:"1oz8nu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dW=Z("Fence",[["path",{d:"M4 3 2 5v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"1n2rgs"}],["path",{d:"M6 8h4",key:"utf9t1"}],["path",{d:"M6 18h4",key:"12yh4b"}],["path",{d:"m12 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"3ha7mj"}],["path",{d:"M14 8h4",key:"1r8wg2"}],["path",{d:"M14 18h4",key:"1t3kbu"}],["path",{d:"m20 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"dfd4e2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uW=Z("FerrisWheel",[["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m6.8 15-3.5 2",key:"hjy98k"}],["path",{d:"m20.7 7-3.5 2",key:"f08gto"}],["path",{d:"M6.8 9 3.3 7",key:"1aevh4"}],["path",{d:"m20.7 17-3.5-2",key:"1liqo3"}],["path",{d:"m9 22 3-8 3 8",key:"wees03"}],["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M18 18.7a9 9 0 1 0-12 0",key:"dhzg4g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hW=Z("Figma",[["path",{d:"M5 5.5A3.5 3.5 0 0 1 8.5 2H12v7H8.5A3.5 3.5 0 0 1 5 5.5z",key:"1340ok"}],["path",{d:"M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2z",key:"1hz3m3"}],["path",{d:"M12 12.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 1 1-7 0z",key:"1oz8n2"}],["path",{d:"M5 19.5A3.5 3.5 0 0 1 8.5 16H12v3.5a3.5 3.5 0 1 1-7 0z",key:"1ff65i"}],["path",{d:"M5 12.5A3.5 3.5 0 0 1 8.5 9H12v7H8.5A3.5 3.5 0 0 1 5 12.5z",key:"pdip6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mW=Z("FileArchive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pW=Z("FileAudio2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"3",cy:"17",r:"1",key:"vo6nti"}],["path",{d:"M2 17v-3a4 4 0 0 1 8 0v3",key:"1ggdre"}],["circle",{cx:"9",cy:"17",r:"1",key:"bc1fq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fW=Z("FileAudio",[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qj=Z("FileAxis3d",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 18 4-4",key:"12zab0"}],["path",{d:"M8 10v8h8",key:"tlaukw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xW=Z("FileBadge2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14 12.5 1 5.5-3-1-3 1 1-5.5",key:"14xlky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gW=Z("FileBadge",[["path",{d:"M12 22h6a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"12ixgl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M5 17a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",key:"u0c8gj"}],["path",{d:"M7 16.5 8 22l-3-1-3 1 1-5.5",key:"5gm2nr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yW=Z("FileBox",[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"16lz6z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z",key:"99pj1s"}],["path",{d:"M7 17v5",key:"1yj1jh"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jj=Z("FileChartColumnIncreasing",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M12 18v-4",key:"q1q25u"}],["path",{d:"M16 18v-6",key:"15y0np"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eN=Z("FileChartColumn",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-1",key:"zg0ygc"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"M16 18v-3",key:"j5jt4h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tN=Z("FileChartLine",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m16 13-3.5 3.5-2-2L8 17",key:"zz7yod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sN=Z("FileChartPie",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3.5",key:"13ddob"}],["path",{d:"M4.017 11.512a6 6 0 1 0 8.466 8.475",key:"s6vs5t"}],["path",{d:"M9 16a1 1 0 0 1-1-1v-4c0-.552.45-1.008.995-.917a6 6 0 0 1 4.922 4.922c.091.544-.365.995-.917.995z",key:"1dl6s6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vW=Z("FileCheck2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _W=Z("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bW=Z("FileClock",[["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"37hlfg"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}],["path",{d:"M9.5 17.5 8 16.25V14",key:"1o80t2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wW=Z("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jW=Z("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rN=Z("FileCog",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3.2 12.9-.9-.4",key:"1i3dj5"}],["path",{d:"m3.2 15.1-.9.4",key:"1fvgj0"}],["path",{d:"M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5",key:"1yo3oz"}],["path",{d:"m4.9 11.2-.4-.9",key:"otmhb9"}],["path",{d:"m4.9 16.8-.4.9",key:"1b8z07"}],["path",{d:"m7.5 10.3-.4.9",key:"11k65u"}],["path",{d:"m7.5 17.7-.4-.9",key:"431x55"}],["path",{d:"m9.7 12.5-.9.4",key:"87sjan"}],["path",{d:"m9.7 15.5-.9-.4",key:"khqm91"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NW=Z("FileDiff",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kW=Z("FileDigit",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"4",height:"6",x:"2",y:"12",rx:"2",key:"jm304g"}],["path",{d:"M10 12h2v6",key:"12zw74"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z4=Z("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SW=Z("FileHeart",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10.29 10.7a2.43 2.43 0 0 0-2.66-.52c-.29.12-.56.3-.78.53l-.35.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L6.5 18l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1c1fso"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jb=Z("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CW=Z("FileInput",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MW=Z("FileJson2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"fq0c9t"}],["path",{d:"M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"4gibmv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TW=Z("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AW=Z("FileKey2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v6",key:"rc0qvx"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"m10 10-4.5 4.5",key:"7fwrp6"}],["path",{d:"m9 11 1 1",key:"wa6s5q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EW=Z("FileKey",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["circle",{cx:"10",cy:"16",r:"2",key:"4ckbqe"}],["path",{d:"m16 10-4.5 4.5",key:"7p3ebg"}],["path",{d:"m15 11 1 1",key:"1bsyx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PW=Z("FileLock2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v1",key:"jmtmu2"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"5",x:"2",y:"13",rx:"1",key:"10y5wo"}],["path",{d:"M8 13v-2a2 2 0 1 0-4 0v2",key:"1pdxzg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IW=Z("FileLock",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["rect",{width:"8",height:"6",x:"8",y:"12",rx:"1",key:"3yr8at"}],["path",{d:"M10 12v-2a2 2 0 1 1 4 0v2",key:"j4i8d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LW=Z("FileMinus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DW=Z("FileMinus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RW=Z("FileMusic",[["path",{d:"M10.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v8.4",key:"1d3kfm"}],["path",{d:"M8 18v-7.7L16 9v7",key:"1oie6o"}],["circle",{cx:"14",cy:"16",r:"2",key:"1bzzi3"}],["circle",{cx:"6",cy:"18",r:"2",key:"1fncim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OW=Z("FileOutput",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nN=Z("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aN=Z("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FW=Z("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zW=Z("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BW=Z("FileQuestion",[["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $W=Z("FileScan",[["path",{d:"M20 10V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h4",key:"1rdf37"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M16 14a2 2 0 0 0-2 2",key:"ceaadl"}],["path",{d:"M20 14a2 2 0 0 1 2 2",key:"1ny6zw"}],["path",{d:"M20 22a2 2 0 0 0 2-2",key:"1l9q4k"}],["path",{d:"M16 22a2 2 0 0 1-2-2",key:"1wqh5n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qW=Z("FileSearch2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UW=Z("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VW=Z("FileSliders",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M10 11v2",key:"1s651w"}],["path",{d:"M8 17h8",key:"wh5c61"}],["path",{d:"M14 16v2",key:"12fp5e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kv=Z("FileSpreadsheet",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dL=Z("FileStack",[["path",{d:"M21 7h-3a2 2 0 0 1-2-2V2",key:"9rb54x"}],["path",{d:"M21 6v6.5c0 .8-.7 1.5-1.5 1.5h-7c-.8 0-1.5-.7-1.5-1.5v-9c0-.8.7-1.5 1.5-1.5H17Z",key:"1059l0"}],["path",{d:"M7 8v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H15",key:"16874u"}],["path",{d:"M3 12v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H11",key:"k2ox98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HW=Z("FileSymlink",[["path",{d:"m10 18 3-3-3-3",key:"18f6ys"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 11V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"50q2rw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GW=Z("FileTerminal",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fn=Z("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WW=Z("FileType2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 13v-1h6v1",key:"1dh9dg"}],["path",{d:"M5 12v6",key:"150t9c"}],["path",{d:"M4 18h2",key:"1xrofg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KW=Z("FileType",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZW=Z("FileUp",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YW=Z("FileUser",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 18a3 3 0 1 0-6 0",key:"16awa0"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XW=Z("FileVideo2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"6",x:"2",y:"12",rx:"1",key:"1a6c1e"}],["path",{d:"m10 15.5 4 2.5v-6l-4 2.5",key:"t7cp39"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QW=Z("FileVideo",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m10 11 5 3-5 3v-6Z",key:"7ntvm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JW=Z("FileVolume2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M11.5 13.5a2.5 2.5 0 0 1 0 3",key:"1fccat"}],["path",{d:"M15 12a5 5 0 0 1 0 6",key:"ps46cm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eK=Z("FileVolume",[["path",{d:"M11 11a5 5 0 0 1 0 6",key:"193qb2"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 6.765V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-.93-.23",key:"ifyjnl"}],["path",{d:"M7 10.51a.5.5 0 0 0-.826-.38l-1.893 1.628A1 1 0 0 1 3.63 12H2.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h1.129a1 1 0 0 1 .652.242l1.893 1.63a.5.5 0 0 0 .826-.38z",key:"mk8rxu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tK=Z("FileWarning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sK=Z("FileX2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 12.5-5 5",key:"b853mi"}],["path",{d:"m3 12.5 5 5",key:"1qls4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rK=Z("FileX",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bM=Z("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nK=Z("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tu=Z("Film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aK=Z("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eg=Z("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iK=Z("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oK=Z("FireExtinguisher",[["path",{d:"M15 6.5V3a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3.5",key:"sqyvz"}],["path",{d:"M9 18h8",key:"i7pszb"}],["path",{d:"M18 3h-3",key:"7idoqj"}],["path",{d:"M11 3a6 6 0 0 0-6 6v11",key:"1v5je3"}],["path",{d:"M5 13h4",key:"svpcxo"}],["path",{d:"M17 10a4 4 0 0 0-8 0v10a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2Z",key:"vsjego"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lK=Z("FishOff",[["path",{d:"M18 12.47v.03m0-.5v.47m-.475 5.056A6.744 6.744 0 0 1 15 18c-3.56 0-7.56-2.53-8.5-6 .348-1.28 1.114-2.433 2.121-3.38m3.444-2.088A8.802 8.802 0 0 1 15 6c3.56 0 6.06 2.54 7 6-.309 1.14-.786 2.177-1.413 3.058",key:"1j1hse"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33m7.48-4.372A9.77 9.77 0 0 1 16 6.07m0 11.86a9.77 9.77 0 0 1-1.728-3.618",key:"1q46z8"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98M8.53 3h5.27a2 2 0 0 1 1.98 1.67l.23 1.4M2 2l20 20",key:"1407gh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cK=Z("FishSymbol",[["path",{d:"M2 16s9-15 20-4C11 23 2 8 2 8",key:"h4oh4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dK=Z("Fish",[["path",{d:"M6.5 12c.94-3.46 4.94-6 8.5-6 3.56 0 6.06 2.54 7 6-.94 3.47-3.44 6-7 6s-7.56-2.53-8.5-6Z",key:"15baut"}],["path",{d:"M18 12v.5",key:"18hhni"}],["path",{d:"M16 17.93a9.77 9.77 0 0 1 0-11.86",key:"16dt7o"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33",key:"l9di03"}],["path",{d:"M10.46 7.26C10.2 5.88 9.17 4.24 8 3h5.8a2 2 0 0 1 1.98 1.67l.23 1.4",key:"1kjonw"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98",key:"1zlm23"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uK=Z("FlagOff",[["path",{d:"M8 2c3 0 5 2 8 2s4-1 4-1v11",key:"9rwyz9"}],["path",{d:"M4 22V4",key:"1plyxx"}],["path",{d:"M4 15s1-1 4-1 5 2 8 2",key:"1myooe"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hK=Z("FlagTriangleLeft",[["path",{d:"M17 22V2L7 7l10 5",key:"1rmf0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mK=Z("FlagTriangleRight",[["path",{d:"M7 22V2l10 5-10 5",key:"17n18y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zv=Z("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pK=Z("FlameKindling",[["path",{d:"M12 2c1 3 2.5 3.5 3.5 4.5A5 5 0 0 1 17 10a5 5 0 1 1-10 0c0-.3 0-.6.1-.9a2 2 0 1 0 3.3-2C8 4.5 11 2 12 2Z",key:"1ir223"}],["path",{d:"m5 22 14-4",key:"1brv4h"}],["path",{d:"m5 18 14 4",key:"lgyyje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ch=Z("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fK=Z("FlashlightOff",[["path",{d:"M16 16v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4",key:"1r120k"}],["path",{d:"M7 2h11v4c0 2-2 2-2 4v1",key:"dz1920"}],["line",{x1:"11",x2:"18",y1:"6",y2:"6",key:"bi1vpe"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xK=Z("Flashlight",[["path",{d:"M18 6c0 2-2 2-2 4v10a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4V2h12z",key:"1orkel"}],["line",{x1:"6",x2:"18",y1:"6",y2:"6",key:"1z11jq"}],["line",{x1:"12",x2:"12",y1:"12",y2:"12",key:"1f4yc1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gK=Z("FlaskConicalOff",[["path",{d:"M10 10 4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-1.272-2.542",key:"59ek9y"}],["path",{d:"M10 2v2.343",key:"15t272"}],["path",{d:"M14 2v6.343",key:"sxr80q"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h9",key:"t5njau"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nb=Z("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yK=Z("FlaskRound",[["path",{d:"M10 2v7.31",key:"5d1hyh"}],["path",{d:"M14 9.3V1.99",key:"14k4l0"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14 9.3a6.5 6.5 0 1 1-4 0",key:"1r8fvy"}],["path",{d:"M5.52 16h12.96",key:"46hh1i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vK=Z("FlipHorizontal2",[["path",{d:"m3 7 5 5-5 5V7",key:"couhi7"}],["path",{d:"m21 7-5 5 5 5V7",key:"6ouia7"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uL=Z("FlipHorizontal",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h3",key:"1i73f7"}],["path",{d:"M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3",key:"saxlbk"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _K=Z("FlipVertical2",[["path",{d:"m17 3-5 5-5-5h10",key:"1ftt6x"}],["path",{d:"m17 21-5-5-5 5h10",key:"1m0wmu"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bK=Z("FlipVertical",[["path",{d:"M21 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v3",key:"14bfxa"}],["path",{d:"M21 16v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-3",key:"14rx03"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kg=Z("Flower2",[["path",{d:"M12 5a3 3 0 1 1 3 3m-3-3a3 3 0 1 0-3 3m3-3v1M9 8a3 3 0 1 0 3 3M9 8h1m5 0a3 3 0 1 1-3 3m3-3h-1m-2 3v-1",key:"3pnvol"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M12 10v12",key:"6ubwww"}],["path",{d:"M12 22c4.2 0 7-1.667 7-5-4.2 0-7 1.667-7 5Z",key:"9hd38g"}],["path",{d:"M12 22c-4.2 0-7-1.667-7-5 4.2 0 7 1.667 7 5Z",key:"ufn41s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wK=Z("Flower",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 16.5A4.5 4.5 0 1 1 7.5 12 4.5 4.5 0 1 1 12 7.5a4.5 4.5 0 1 1 4.5 4.5 4.5 4.5 0 1 1-4.5 4.5",key:"14wa3c"}],["path",{d:"M12 7.5V9",key:"1oy5b0"}],["path",{d:"M7.5 12H9",key:"eltsq1"}],["path",{d:"M16.5 12H15",key:"vk5kw4"}],["path",{d:"M12 16.5V15",key:"k7eayi"}],["path",{d:"m8 8 1.88 1.88",key:"nxy4qf"}],["path",{d:"M14.12 9.88 16 8",key:"1lst6k"}],["path",{d:"m8 16 1.88-1.88",key:"h2eex1"}],["path",{d:"M14.12 14.12 16 16",key:"uqkrx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jK=Z("Focus",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NK=Z("FoldHorizontal",[["path",{d:"M2 12h6",key:"1wqiqv"}],["path",{d:"M22 12h-6",key:"1eg9hc"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 9-3 3 3 3",key:"12ol22"}],["path",{d:"m5 15 3-3-3-3",key:"1kdhjc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kK=Z("FoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SK=Z("FolderArchive",[["circle",{cx:"15",cy:"19",r:"2",key:"u2pros"}],["path",{d:"M20.9 19.8A2 2 0 0 0 22 18V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h5.1",key:"1jj40k"}],["path",{d:"M15 11v-1",key:"cntcp"}],["path",{d:"M15 17v-2",key:"1279jj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CK=Z("FolderCheck",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MK=Z("FolderClock",[["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"M7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2",key:"1urifu"}],["path",{d:"M16 14v2l1 1",key:"xth2jh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TK=Z("FolderClosed",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M2 10h20",key:"1ir3d8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AK=Z("FolderCode",[["path",{d:"M10 10.5 8 13l2 2.5",key:"m4t9c1"}],["path",{d:"m14 10.5 2 2.5-2 2.5",key:"14w2eb"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z",key:"1u1bxd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iN=Z("FolderCog",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"M10.3 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v3.3",key:"1k8050"}],["path",{d:"m21.7 19.4-.9-.3",key:"1qgwi9"}],["path",{d:"m15.2 16.9-.9-.3",key:"1t7mvx"}],["path",{d:"m16.6 21.7.3-.9",key:"1j67ps"}],["path",{d:"m19.1 15.2.3-.9",key:"18r7jp"}],["path",{d:"m19.6 21.7-.4-1",key:"z2vh2"}],["path",{d:"m16.8 15.3-.4-1",key:"1ei7r6"}],["path",{d:"m14.3 19.6 1-.4",key:"11sv9r"}],["path",{d:"m20.7 16.8 1-.4",key:"19m87a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EK=Z("FolderDot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"1",key:"49l61u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PK=Z("FolderDown",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m15 13-3 3-3-3",key:"6j2sf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IK=Z("FolderGit2",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["path",{d:"M18 19c-2.8 0-5-2.2-5-5v8",key:"pkpw2h"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LK=Z("FolderGit",[["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M14 13h3",key:"1dgedf"}],["path",{d:"M7 13h3",key:"1pygq7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DK=Z("FolderHeart",[["path",{d:"M11 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v1.5",key:"6hud8k"}],["path",{d:"M13.9 17.45c-1.2-1.2-1.14-2.8-.2-3.73a2.43 2.43 0 0 1 3.44 0l.36.34.34-.34a2.43 2.43 0 0 1 3.45-.01c.95.95 1 2.53-.2 3.74L17.5 21Z",key:"wpff58"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RK=Z("FolderInput",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OK=Z("FolderKanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FK=Z("FolderKey",[["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2",key:"3hgo9p"}],["path",{d:"m22 14-4.5 4.5",key:"1ef6z8"}],["path",{d:"m21 15 1 1",key:"1ejcpy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zK=Z("FolderLock",[["rect",{width:"8",height:"5",x:"14",y:"17",rx:"1",key:"19aais"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5",key:"1w6v7t"}],["path",{d:"M20 17v-2a2 2 0 1 0-4 0v2",key:"pwaxnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BK=Z("FolderMinus",[["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $K=Z("FolderOpenDot",[["path",{d:"m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2",key:"1nmvlm"}],["circle",{cx:"14",cy:"15",r:"1",key:"1gm4qj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mm=Z("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qK=Z("FolderOutput",[["path",{d:"M2 7.5V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-1.5",key:"1yk7aj"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m5 10-3 3 3 3",key:"1r8ie0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oN=Z("FolderPen",[["path",{d:"M2 11.5V5a2 2 0 0 1 2-2h3.9c.7 0 1.3.3 1.7.9l.8 1.2c.4.6 1 .9 1.7.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-9.5",key:"a8xqs0"}],["path",{d:"M11.378 13.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1saktj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UK=Z("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VK=Z("FolderRoot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M12 15v5",key:"11xva1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HK=Z("FolderSearch2",[["circle",{cx:"11.5",cy:"12.5",r:"2.5",key:"1ea5ju"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M13.3 14.3 15 16",key:"1y4v1n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GK=Z("FolderSearch",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WK=Z("FolderSymlink",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"x1c07l"}],["path",{d:"m8 16 3-3-3-3",key:"rlqrt1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KK=Z("FolderSync",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5",key:"1dkoa9"}],["path",{d:"M12 10v4h4",key:"1czhmt"}],["path",{d:"m12 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"lvuxfi"}],["path",{d:"M22 22v-4h-4",key:"1ewp4q"}],["path",{d:"m22 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"14ync0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZK=Z("FolderTree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YK=Z("FolderUp",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m9 13 3-3 3 3",key:"1pxg3c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XK=Z("FolderX",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9.5 10.5 5 5",key:"ra9qjz"}],["path",{d:"m14.5 10.5-5 5",key:"l2rkpq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QK=Z("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JK=Z("Folders",[["path",{d:"M20 17a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.9a2 2 0 0 1-1.69-.9l-.81-1.2a2 2 0 0 0-1.67-.9H8a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2Z",key:"4u7rpt"}],["path",{d:"M2 8v11a2 2 0 0 0 2 2h14",key:"1eicx1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eZ=Z("Footprints",[["path",{d:"M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z",key:"1dudjm"}],["path",{d:"M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z",key:"l2t8xc"}],["path",{d:"M16 17h4",key:"1dejxt"}],["path",{d:"M4 13h4",key:"1bwh8b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tZ=Z("Forklift",[["path",{d:"M12 12H5a2 2 0 0 0-2 2v5",key:"7zsz91"}],["circle",{cx:"13",cy:"19",r:"2",key:"wjnkru"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M8 19h3m5-17v17h6M6 12V7c0-1.1.9-2 2-2h3l5 5",key:"13bk1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sZ=Z("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rZ=Z("Frame",[["line",{x1:"22",x2:"2",y1:"6",y2:"6",key:"15w7dq"}],["line",{x1:"22",x2:"2",y1:"18",y2:"18",key:"1ip48p"}],["line",{x1:"6",x2:"6",y1:"2",y2:"22",key:"a2lnyx"}],["line",{x1:"18",x2:"18",y1:"2",y2:"22",key:"8vb6jd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nZ=Z("Framer",[["path",{d:"M5 16V9h14V2H5l14 14h-7m-7 0 7 7v-7m-7 0h7",key:"1a2nng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aZ=Z("Frown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iZ=Z("Fuel",[["line",{x1:"3",x2:"15",y1:"22",y2:"22",key:"xegly4"}],["line",{x1:"4",x2:"14",y1:"9",y2:"9",key:"xcnuvu"}],["path",{d:"M14 22V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v18",key:"16j0yd"}],["path",{d:"M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 2 2a2 2 0 0 0 2-2V9.83a2 2 0 0 0-.59-1.42L18 5",key:"7cu91f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oZ=Z("Fullscreen",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lZ=Z("GalleryHorizontalEnd",[["path",{d:"M2 7v10",key:"a2pl2d"}],["path",{d:"M6 5v14",key:"1kq3d7"}],["rect",{width:"12",height:"18",x:"10",y:"3",rx:"2",key:"13i7bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cZ=Z("GalleryHorizontal",[["path",{d:"M2 3v18",key:"pzttux"}],["rect",{width:"12",height:"18",x:"6",y:"3",rx:"2",key:"btr8bg"}],["path",{d:"M22 3v18",key:"6jf3v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dZ=Z("GalleryThumbnails",[["rect",{width:"18",height:"14",x:"3",y:"3",rx:"2",key:"74y24f"}],["path",{d:"M4 21h1",key:"16zlid"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M19 21h1",key:"edywat"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uZ=Z("GalleryVerticalEnd",[["path",{d:"M7 2h10",key:"nczekb"}],["path",{d:"M5 6h14",key:"u2x4p"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hZ=Z("GalleryVertical",[["path",{d:"M3 2h18",key:"15qxfx"}],["rect",{width:"18",height:"12",x:"3",y:"6",rx:"2",key:"1439r6"}],["path",{d:"M3 22h18",key:"8prr45"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mZ=Z("Gamepad2",[["line",{x1:"6",x2:"10",y1:"11",y2:"11",key:"1gktln"}],["line",{x1:"8",x2:"8",y1:"9",y2:"13",key:"qnk9ow"}],["line",{x1:"15",x2:"15.01",y1:"12",y2:"12",key:"krot7o"}],["line",{x1:"18",x2:"18.01",y1:"10",y2:"10",key:"1lcuu1"}],["path",{d:"M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z",key:"mfqc10"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pZ=Z("Gamepad",[["line",{x1:"6",x2:"10",y1:"12",y2:"12",key:"161bw2"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"15",x2:"15.01",y1:"13",y2:"13",key:"dqpgro"}],["line",{x1:"18",x2:"18.01",y1:"11",y2:"11",key:"meh2c"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fZ=Z("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xZ=Z("Gavel",[["path",{d:"m14.5 12.5-8 8a2.119 2.119 0 1 1-3-3l8-8",key:"15492f"}],["path",{d:"m16 16 6-6",key:"vzrcl6"}],["path",{d:"m8 8 6-6",key:"18bi4p"}],["path",{d:"m9 7 8 8",key:"5jnvq1"}],["path",{d:"m21 11-8-8",key:"z4y7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gZ=Z("Gem",[["path",{d:"M6 3h12l4 6-10 13L2 9Z",key:"1pcd5k"}],["path",{d:"M11 3 8 9l4 13 4-13-3-6",key:"1fcu3u"}],["path",{d:"M2 9h20",key:"16fsjt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y4=Z("Ghost",[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ui=Z("Gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yZ=Z("GitBranchPlus",[["path",{d:"M6 3v12",key:"qpgusn"}],["path",{d:"M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"1d02ji"}],["path",{d:"M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"chk6ph"}],["path",{d:"M15 6a9 9 0 0 0-9 9",key:"or332x"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vZ=Z("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lN=Z("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Z=Z("GitCommitVertical",[["path",{d:"M12 3v6",key:"1holv5"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 15v6",key:"a9ows0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bZ=Z("GitCompareArrows",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wZ=Z("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jZ=Z("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NZ=Z("GitGraph",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kZ=Z("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SZ=Z("GitPullRequestArrow",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v12",key:"ih889a"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CZ=Z("GitPullRequestClosed",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 9v12",key:"1sc30k"}],["path",{d:"m21 3-6 6",key:"16nqsk"}],["path",{d:"m21 9-6-6",key:"9j17rh"}],["path",{d:"M18 11.5V15",key:"65xf6f"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MZ=Z("GitPullRequestCreateArrow",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v12",key:"ih889a"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v3",key:"1rbwk6"}],["path",{d:"M19 15v6",key:"10aioa"}],["path",{d:"M22 18h-6",key:"1d5gi5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TZ=Z("GitPullRequestCreate",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 9v12",key:"1sc30k"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v3",key:"1jb6z3"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AZ=Z("GitPullRequestDraft",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M18 6V5",key:"1oao2s"}],["path",{d:"M18 11v-1",key:"11c8tz"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EZ=Z("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PZ=Z("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IZ=Z("Gitlab",[["path",{d:"m22 13.29-3.33-10a.42.42 0 0 0-.14-.18.38.38 0 0 0-.22-.11.39.39 0 0 0-.23.07.42.42 0 0 0-.14.18l-2.26 6.67H8.32L6.1 3.26a.42.42 0 0 0-.1-.18.38.38 0 0 0-.26-.08.39.39 0 0 0-.23.07.42.42 0 0 0-.14.18L2 13.29a.74.74 0 0 0 .27.83L12 21l9.69-6.88a.71.71 0 0 0 .31-.83Z",key:"148pdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LZ=Z("GlassWater",[["path",{d:"M5.116 4.104A1 1 0 0 1 6.11 3h11.78a1 1 0 0 1 .994 1.105L17.19 20.21A2 2 0 0 1 15.2 22H8.8a2 2 0 0 1-2-1.79z",key:"p55z4y"}],["path",{d:"M6 12a5 5 0 0 1 6 0 5 5 0 0 0 6 0",key:"mjntcy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DZ=Z("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RZ=Z("GlobeLock",[["path",{d:"M15.686 15A14.5 14.5 0 0 1 12 22a14.5 14.5 0 0 1 0-20 10 10 0 1 0 9.542 13",key:"qkt0x6"}],["path",{d:"M2 12h8.5",key:"ovaggd"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gd=Z("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OZ=Z("Goal",[["path",{d:"M12 13V2l8 4-8 4",key:"5wlwwj"}],["path",{d:"M20.561 10.222a9 9 0 1 1-12.55-5.29",key:"1c0wjv"}],["path",{d:"M8.002 9.997a5 5 0 1 0 8.9 2.02",key:"gb1g7m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FZ=Z("Grab",[["path",{d:"M18 11.5V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1.4",key:"edstyy"}],["path",{d:"M14 10V8a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"19wdwo"}],["path",{d:"M10 9.9V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"1lugqo"}],["path",{d:"M6 14a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1hbeus"}],["path",{d:"M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-4a8 8 0 0 1-8-8 2 2 0 1 1 4 0",key:"1etffm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lh=Z("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zZ=Z("Grape",[["path",{d:"M22 5V2l-5.89 5.89",key:"1eenpo"}],["circle",{cx:"16.6",cy:"15.89",r:"3",key:"xjtalx"}],["circle",{cx:"8.11",cy:"7.4",r:"3",key:"u2fv6i"}],["circle",{cx:"12.35",cy:"11.65",r:"3",key:"i6i8g7"}],["circle",{cx:"13.91",cy:"5.85",r:"3",key:"6ye0dv"}],["circle",{cx:"18.15",cy:"10.09",r:"3",key:"snx9no"}],["circle",{cx:"6.56",cy:"13.2",r:"3",key:"17x4xg"}],["circle",{cx:"10.8",cy:"17.44",r:"3",key:"1hogw9"}],["circle",{cx:"5",cy:"19",r:"3",key:"1sn6vo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BZ=Z("Grid2x2Check",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cN=Z("Grid2x2Plus",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 22v-6",key:"qhmiwi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Z=Z("Grid2x2X",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"m16 16 5 5",key:"8tpb07"}],["path",{d:"m16 21 5-5",key:"193jll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dN=Z("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yf=Z("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qZ=Z("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hu=Z("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UZ=Z("Grip",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VZ=Z("Group",[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2",key:"adw53z"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2",key:"an4l38"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2",key:"144t0e"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2",key:"rtnfgi"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1",key:"1eyiv7"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1",key:"1qlmkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HZ=Z("Guitar",[["path",{d:"m11.9 12.1 4.514-4.514",key:"109xqo"}],["path",{d:"M20.1 2.3a1 1 0 0 0-1.4 0l-1.114 1.114A2 2 0 0 0 17 4.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 17.828 7h1.344a2 2 0 0 0 1.414-.586L21.7 5.3a1 1 0 0 0 0-1.4z",key:"txyc8t"}],["path",{d:"m6 16 2 2",key:"16qmzd"}],["path",{d:"M8.2 9.9C8.7 8.8 9.8 8 11 8c2.8 0 5 2.2 5 5 0 1.2-.8 2.3-1.9 2.8l-.9.4A2 2 0 0 0 12 18a4 4 0 0 1-4 4c-3.3 0-6-2.7-6-6a4 4 0 0 1 4-4 2 2 0 0 0 1.8-1.2z",key:"1u8q3z"}],["circle",{cx:"11.5",cy:"12.5",r:".5",fill:"currentColor",key:"16onso"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GZ=Z("Ham",[["path",{d:"M13.144 21.144A7.274 10.445 45 1 0 2.856 10.856",key:"1k1t7q"}],["path",{d:"M13.144 21.144A7.274 4.365 45 0 0 2.856 10.856a7.274 4.365 45 0 0 10.288 10.288",key:"153t1g"}],["path",{d:"M16.565 10.435 18.6 8.4a2.501 2.501 0 1 0 1.65-4.65 2.5 2.5 0 1 0-4.66 1.66l-2.024 2.025",key:"gzrt0n"}],["path",{d:"m8.5 16.5-1-1",key:"otr954"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WZ=Z("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KZ=Z("HandCoins",[["path",{d:"M11 15h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 17",key:"geh8rc"}],["path",{d:"m7 21 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"1fto5m"}],["path",{d:"m2 16 6 6",key:"1pfhp9"}],["circle",{cx:"16",cy:"9",r:"2.9",key:"1n0dlu"}],["circle",{cx:"6",cy:"5",r:"3",key:"151irh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZZ=Z("HandHeart",[["path",{d:"M11 14h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 16",key:"1ifwr1"}],["path",{d:"m7 20 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"17abbs"}],["path",{d:"m2 15 6 6",key:"10dquu"}],["path",{d:"M19.5 8.5c.7-.7 1.5-1.6 1.5-2.7A2.73 2.73 0 0 0 16 4a2.78 2.78 0 0 0-5 1.8c0 1.2.8 2 1.5 2.8L16 12Z",key:"1h3036"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uN=Z("HandHelping",[["path",{d:"M11 12h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 14",key:"1j4xps"}],["path",{d:"m7 18 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"uospg8"}],["path",{d:"m2 13 6 6",key:"16e5sb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YZ=Z("HandMetal",[["path",{d:"M18 12.5V10a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1.4",key:"wc6myp"}],["path",{d:"M14 11V9a2 2 0 1 0-4 0v2",key:"94qvcw"}],["path",{d:"M10 10.5V5a2 2 0 1 0-4 0v9",key:"m1ah89"}],["path",{d:"m7 15-1.76-1.76a2 2 0 0 0-2.83 2.82l3.6 3.6C7.5 21.14 9.2 22 12 22h2a8 8 0 0 0 8-8V7a2 2 0 1 0-4 0v5",key:"t1skq1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XZ=Z("HandPlatter",[["path",{d:"M12 3V2",key:"ar7q03"}],["path",{d:"m15.4 17.4 3.2-2.8a2 2 0 1 1 2.8 2.9l-3.6 3.3c-.7.8-1.7 1.2-2.8 1.2h-4c-1.1 0-2.1-.4-2.8-1.2l-1.302-1.464A1 1 0 0 0 6.151 19H5",key:"n2g93r"}],["path",{d:"M2 14h12a2 2 0 0 1 0 4h-2",key:"1o2jem"}],["path",{d:"M4 10h16",key:"img6z1"}],["path",{d:"M5 10a7 7 0 0 1 14 0",key:"1ega1o"}],["path",{d:"M5 14v6a1 1 0 0 1-1 1H2",key:"1hescx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hL=Z("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mL=Z("Handshake",[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QZ=Z("HardDriveDownload",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JZ=Z("HardDriveUpload",[["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M12 2v8",key:"1q4o3n"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pL=Z("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eY=Z("HardHat",[["path",{d:"M10 10V5a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v5",key:"1p9q5i"}],["path",{d:"M14 6a6 6 0 0 1 6 6v3",key:"1hnv84"}],["path",{d:"M4 15v-3a6 6 0 0 1 6-6",key:"9ciidu"}],["rect",{x:"2",y:"15",width:"20",height:"4",rx:"1",key:"g3x8cw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X4=Z("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tY=Z("Haze",[["path",{d:"m5.2 6.2 1.4 1.4",key:"17imol"}],["path",{d:"M2 13h2",key:"13gyu8"}],["path",{d:"M20 13h2",key:"16rner"}],["path",{d:"m17.4 7.6 1.4-1.4",key:"t4xlah"}],["path",{d:"M22 17H2",key:"1gtaj3"}],["path",{d:"M22 21H2",key:"1gy6en"}],["path",{d:"M16 13a4 4 0 0 0-8 0",key:"1dyczq"}],["path",{d:"M12 5V2.5",key:"1vytko"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sY=Z("HdmiPort",[["path",{d:"M22 9a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v4a1 1 0 0 0 1 1h1l2 2h12l2-2h1a1 1 0 0 0 1-1Z",key:"2128wb"}],["path",{d:"M7.5 12h9",key:"1t0ckc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wM=Z("Heading1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jM=Z("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fL=Z("Heading3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rY=Z("Heading4",[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nY=Z("Heading5",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aY=Z("Heading6",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iY=Z("Heading",[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oY=Z("HeadphoneOff",[["path",{d:"M21 14h-1.343",key:"1jdnxi"}],["path",{d:"M9.128 3.47A9 9 0 0 1 21 12v3.343",key:"6kipu2"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.414 20.414A2 2 0 0 1 19 21h-1a2 2 0 0 1-2-2v-3",key:"9x50f4"}],["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 2.636-6.364",key:"1bkxnm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lY=Z("Headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cY=Z("Headset",[["path",{d:"M3 11h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5Zm0 0a9 9 0 1 1 18 0m0 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3Z",key:"12oyoe"}],["path",{d:"M21 16v2a4 4 0 0 1-4 4h-5",key:"1x7m43"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dY=Z("HeartCrack",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"m12 13-1-1 2-2-3-3 2-2",key:"xjdxli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uY=Z("HeartHandshake",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M12 5 9.04 7.96a2.17 2.17 0 0 0 0 3.08c.82.82 2.13.85 3 .07l2.07-1.9a2.82 2.82 0 0 1 3.79 0l2.96 2.66",key:"4oyue0"}],["path",{d:"m18 15-2-2",key:"60u0ii"}],["path",{d:"m15 18-2-2",key:"6p76be"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hY=Z("HeartOff",[["line",{x1:"2",y1:"2",x2:"22",y2:"22",key:"1w4vcy"}],["path",{d:"M16.5 16.5 12 21l-7-7c-1.5-1.45-3-3.2-3-5.5a5.5 5.5 0 0 1 2.14-4.35",key:"3mpagl"}],["path",{d:"M8.76 3.1c1.15.22 2.13.78 3.24 1.9 1.5-1.5 2.74-2 4.5-2A5.5 5.5 0 0 1 22 8.5c0 2.12-1.3 3.78-2.67 5.17",key:"1gh3v3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mY=Z("HeartPulse",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"1uw2ng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Za=Z("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pY=Z("Heater",[["path",{d:"M11 8c2-3-2-3 0-6",key:"1ldv5m"}],["path",{d:"M15.5 8c2-3-2-3 0-6",key:"1otqoz"}],["path",{d:"M6 10h.01",key:"1lbq93"}],["path",{d:"M6 14h.01",key:"zudwn7"}],["path",{d:"M10 16v-4",key:"1c25yv"}],["path",{d:"M14 16v-4",key:"1dkbt8"}],["path",{d:"M18 16v-4",key:"1yg9me"}],["path",{d:"M20 6a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h3",key:"1ubg90"}],["path",{d:"M5 20v2",key:"1abpe8"}],["path",{d:"M19 20v2",key:"kqn6ft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fY=Z("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xY=Z("Highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NM=Z("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gY=Z("HopOff",[["path",{d:"M10.82 16.12c1.69.6 3.91.79 5.18.85.28.01.53-.09.7-.27",key:"qyzcap"}],["path",{d:"M11.14 20.57c.52.24 2.44 1.12 4.08 1.37.46.06.86-.25.9-.71.12-1.52-.3-3.43-.5-4.28",key:"y078lb"}],["path",{d:"M16.13 21.05c1.65.63 3.68.84 4.87.91a.9.9 0 0 0 .7-.26",key:"1utre3"}],["path",{d:"M17.99 5.52a20.83 20.83 0 0 1 3.15 4.5.8.8 0 0 1-.68 1.13c-1.17.1-2.5.02-3.9-.25",key:"17o9hm"}],["path",{d:"M20.57 11.14c.24.52 1.12 2.44 1.37 4.08.04.3-.08.59-.31.75",key:"1d1n4p"}],["path",{d:"M4.93 4.93a10 10 0 0 0-.67 13.4c.35.43.96.4 1.17-.12.69-1.71 1.07-5.07 1.07-6.71 1.34.45 3.1.9 4.88.62a.85.85 0 0 0 .48-.24",key:"9uv3tt"}],["path",{d:"M5.52 17.99c1.05.95 2.91 2.42 4.5 3.15a.8.8 0 0 0 1.13-.68c.2-2.34-.33-5.3-1.57-8.28",key:"1292wz"}],["path",{d:"M8.35 2.68a10 10 0 0 1 9.98 1.58c.43.35.4.96-.12 1.17-1.5.6-4.3.98-6.07 1.05",key:"7ozu9p"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yY=Z("Hop",[["path",{d:"M10.82 16.12c1.69.6 3.91.79 5.18.85.55.03 1-.42.97-.97-.06-1.27-.26-3.5-.85-5.18",key:"18lxf1"}],["path",{d:"M11.5 6.5c1.64 0 5-.38 6.71-1.07.52-.2.55-.82.12-1.17A10 10 0 0 0 4.26 18.33c.35.43.96.4 1.17-.12.69-1.71 1.07-5.07 1.07-6.71 1.34.45 3.1.9 4.88.62a.88.88 0 0 0 .73-.74c.3-2.14-.15-3.5-.61-4.88",key:"vtfxrw"}],["path",{d:"M15.62 16.95c.2.85.62 2.76.5 4.28a.77.77 0 0 1-.9.7 16.64 16.64 0 0 1-4.08-1.36",key:"13hl71"}],["path",{d:"M16.13 21.05c1.65.63 3.68.84 4.87.91a.9.9 0 0 0 .96-.96 17.68 17.68 0 0 0-.9-4.87",key:"1sl8oj"}],["path",{d:"M16.94 15.62c.86.2 2.77.62 4.29.5a.77.77 0 0 0 .7-.9 16.64 16.64 0 0 0-1.36-4.08",key:"19c6kt"}],["path",{d:"M17.99 5.52a20.82 20.82 0 0 1 3.15 4.5.8.8 0 0 1-.68 1.13c-2.33.2-5.3-.32-8.27-1.57",key:"85ghs3"}],["path",{d:"M4.93 4.93 3 3a.7.7 0 0 1 0-1",key:"x087yj"}],["path",{d:"M9.58 12.18c1.24 2.98 1.77 5.95 1.57 8.28a.8.8 0 0 1-1.13.68 20.82 20.82 0 0 1-4.5-3.15",key:"11xdqo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vY=Z("Hospital",[["path",{d:"M12 6v4",key:"16clxf"}],["path",{d:"M14 14h-4",key:"esezmu"}],["path",{d:"M14 18h-4",key:"16mqa2"}],["path",{d:"M14 8h-4",key:"z8ypaz"}],["path",{d:"M18 12h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2",key:"b1k337"}],["path",{d:"M18 22V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v18",key:"16g51d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Y=Z("Hotel",[["path",{d:"M10 22v-6.57",key:"1wmca3"}],["path",{d:"M12 11h.01",key:"z322tv"}],["path",{d:"M12 7h.01",key:"1ivr5q"}],["path",{d:"M14 15.43V22",key:"1q2vjd"}],["path",{d:"M15 16a5 5 0 0 0-6 0",key:"o9wqvi"}],["path",{d:"M16 11h.01",key:"xkw8gn"}],["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 7h.01",key:"1vti4s"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bY=Z("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wY=Z("HousePlug",[["path",{d:"M10 12V8.964",key:"1vll13"}],["path",{d:"M14 12V8.964",key:"1x3qvg"}],["path",{d:"M15 12a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-2a1 1 0 0 1 1-1z",key:"ppykja"}],["path",{d:"M8.5 21H5a2 2 0 0 1-2-2v-9a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2h-5a2 2 0 0 1-2-2v-2",key:"1gvg2z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jY=Z("HousePlus",[["path",{d:"M13.22 2.416a2 2 0 0 0-2.511.057l-7 5.999A2 2 0 0 0 3 10v9a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7.354",key:"5phn05"}],["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"M18 3v6",key:"x1uolp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mn=Z("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hN=Z("IceCreamBowl",[["path",{d:"M12 17c5 0 8-2.69 8-6H4c0 3.31 3 6 8 6m-4 4h8m-4-3v3M5.14 11a3.5 3.5 0 1 1 6.71 0",key:"1uxfcu"}],["path",{d:"M12.14 11a3.5 3.5 0 1 1 6.71 0",key:"4k3m1s"}],["path",{d:"M15.5 6.5a3.5 3.5 0 1 0-7 0",key:"zmuahr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mN=Z("IceCreamCone",[["path",{d:"m7 11 4.08 10.35a1 1 0 0 0 1.84 0L17 11",key:"1v6356"}],["path",{d:"M17 7A5 5 0 0 0 7 7",key:"151p3v"}],["path",{d:"M17 7a2 2 0 0 1 0 4H7a2 2 0 0 1 0-4",key:"1sdaij"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NY=Z("IdCard",[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kY=Z("ImageDown",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19 3 3v-5.5",key:"9ldu5r"}],["path",{d:"m17 22 3-3",key:"1nkfve"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SY=Z("ImageMinus",[["path",{d:"M21 9v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"m87ecr"}],["line",{x1:"16",x2:"22",y1:"5",y2:"5",key:"ez7e4s"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CY=Z("ImageOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MY=Z("ImagePlay",[["path",{d:"m11 16-5 5",key:"j5f7ct"}],["path",{d:"M11 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6.5",key:"7s81lt"}],["path",{d:"M15.765 22a.5.5 0 0 1-.765-.424V13.38a.5.5 0 0 1 .765-.424l5.878 3.674a1 1 0 0 1 0 1.696z",key:"1omb6s"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yv=Z("ImagePlus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TY=Z("ImageUp",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19.5 3-3 3 3",key:"9vmjn0"}],["path",{d:"M17 22v-5.5",key:"1aa6fl"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AY=Z("ImageUpscale",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M17 21h2a2 2 0 0 0 2-2",key:"130fy9"}],["path",{d:"M21 12v3",key:"1wzk3p"}],["path",{d:"m21 3-5 5",key:"1g5oa7"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2",key:"kk3yz1"}],["path",{d:"m5 21 4.144-4.144a1.21 1.21 0 0 1 1.712 0L13 19",key:"fyekpt"}],["path",{d:"M9 3h3",key:"d52fa"}],["rect",{x:"3",y:"11",width:"10",height:"10",rx:"1",key:"1wpmix"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wo=Z("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EY=Z("Images",[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PY=Z("Import",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IY=Z("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pN=Z("IndentDecrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m7 8-4 4 4 4",key:"o5hrat"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fN=Z("IndentIncrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m3 8 4 4-4 4",key:"1a3j6y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LY=Z("IndianRupee",[["path",{d:"M6 3h12",key:"ggurg9"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"m6 13 8.5 8",key:"u1kupk"}],["path",{d:"M6 13h3",key:"wdp6ag"}],["path",{d:"M9 13c6.667 0 6.667-10 0-10",key:"1nkvk2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DY=Z("Infinity",[["path",{d:"M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z",key:"1z0uae"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q4=Z("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RY=Z("InspectionPanel",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7h.01",key:"7u93v4"}],["path",{d:"M17 7h.01",key:"14a9sn"}],["path",{d:"M7 17h.01",key:"19xn7k"}],["path",{d:"M17 17h.01",key:"1sd3ek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mu=Z("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J4=Z("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OY=Z("IterationCcw",[["path",{d:"M20 10c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8h8",key:"4znkd0"}],["polyline",{points:"16 14 20 18 16 22",key:"11njsm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FY=Z("IterationCw",[["path",{d:"M4 10c0-4.4 3.6-8 8-8s8 3.6 8 8-3.6 8-8 8H4",key:"tuf4su"}],["polyline",{points:"8 22 4 18 8 14",key:"evkj9s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zY=Z("JapaneseYen",[["path",{d:"M12 9.5V21m0-11.5L6 3m6 6.5L18 3",key:"2ej80x"}],["path",{d:"M6 15h12",key:"1hwgt5"}],["path",{d:"M6 11h12",key:"wf4gp6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BY=Z("Joystick",[["path",{d:"M21 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-2Z",key:"jg2n2t"}],["path",{d:"M6 15v-2",key:"gd6mvg"}],["path",{d:"M12 15V9",key:"8c7uyn"}],["circle",{cx:"12",cy:"6",r:"3",key:"1gm2ql"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ky=Z("Kanban",[["path",{d:"M6 5v11",key:"mdvv1e"}],["path",{d:"M12 5v6",key:"14ar3b"}],["path",{d:"M18 5v14",key:"7ji314"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eS=Z("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Y=Z("KeySquare",[["path",{d:"M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z",key:"165ttr"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814",key:"1ubxi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pp=Z("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qY=Z("KeyboardMusic",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h4",key:"utf9t1"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M6 12v4",key:"dy92yo"}],["path",{d:"M10 12v4",key:"1fxnav"}],["path",{d:"M14 12v4",key:"1hft58"}],["path",{d:"M18 12v4",key:"tjjnbz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UY=Z("KeyboardOff",[["path",{d:"M 20 4 A2 2 0 0 1 22 6",key:"1g1fkt"}],["path",{d:"M 22 6 L 22 16.41",key:"1qjg3w"}],["path",{d:"M 7 16 L 16 16",key:"n0yqwb"}],["path",{d:"M 9.69 4 L 20 4",key:"kbpcgx"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20 20H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2",key:"s23sx2"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M8 12h.01",key:"czm47f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VY=Z("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HY=Z("LampCeiling",[["path",{d:"M12 2v5",key:"nd4vlx"}],["path",{d:"M6 7h12l4 9H2l4-9Z",key:"123d64"}],["path",{d:"M9.17 16a3 3 0 1 0 5.66 0",key:"1061mw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GY=Z("LampDesk",[["path",{d:"m14 5-3 3 2 7 8-8-7-2Z",key:"1b0msb"}],["path",{d:"m14 5-3 3-3-3 3-3 3 3Z",key:"1uemms"}],["path",{d:"M9.5 6.5 4 12l3 6",key:"1bx08v"}],["path",{d:"M3 22v-2c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v2H3Z",key:"wap775"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WY=Z("LampFloor",[["path",{d:"M9 2h6l3 7H6l3-7Z",key:"wcx6mj"}],["path",{d:"M12 9v13",key:"3n1su1"}],["path",{d:"M9 22h6",key:"1rlq3v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KY=Z("LampWallDown",[["path",{d:"M11 13h6l3 7H8l3-7Z",key:"9n3qlo"}],["path",{d:"M14 13V8a2 2 0 0 0-2-2H8",key:"1hu4hb"}],["path",{d:"M4 9h2a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H4v6Z",key:"s053bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZY=Z("LampWallUp",[["path",{d:"M11 4h6l3 7H8l3-7Z",key:"11x1ee"}],["path",{d:"M14 11v5a2 2 0 0 1-2 2H8",key:"eutp5o"}],["path",{d:"M4 15h2a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2H4v-6Z",key:"1iuthr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YY=Z("Lamp",[["path",{d:"M8 2h8l4 10H4L8 2Z",key:"9dma5w"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M8 22v-2c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v2H8Z",key:"mwf4oh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XY=Z("LandPlot",[["path",{d:"m12 8 6-3-6-3v10",key:"mvpnpy"}],["path",{d:"m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12",key:"ek95tt"}],["path",{d:"m6.49 12.85 11.02 6.3",key:"1kt42w"}],["path",{d:"M17.51 12.85 6.5 19.15",key:"v55bdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QY=Z("Landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JY=Z("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eX=Z("LaptopMinimalCheck",[["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}],["rect",{x:"3",y:"4",width:"18",height:"12",rx:"2",key:"8ur36m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xN=Z("LaptopMinimal",[["rect",{width:"18",height:"12",x:"3",y:"4",rx:"2",ry:"2",key:"1qhy41"}],["line",{x1:"2",x2:"22",y1:"20",y2:"20",key:"ni3hll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tX=Z("Laptop",[["path",{d:"M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16",key:"tarvll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sX=Z("LassoSelect",[["path",{d:"M7 22a5 5 0 0 1-2-4",key:"umushi"}],["path",{d:"M7 16.93c.96.43 1.96.74 2.99.91",key:"ybbtv3"}],["path",{d:"M3.34 14A6.8 6.8 0 0 1 2 10c0-4.42 4.48-8 10-8s10 3.58 10 8a7.19 7.19 0 0 1-.33 2",key:"gt5e1w"}],["path",{d:"M5 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z",key:"bq3ynw"}],["path",{d:"M14.33 22h-.09a.35.35 0 0 1-.24-.32v-10a.34.34 0 0 1 .33-.34c.08 0 .15.03.21.08l7.34 6a.33.33 0 0 1-.21.59h-4.49l-2.57 3.85a.35.35 0 0 1-.28.14z",key:"72q637"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rX=Z("Lasso",[["path",{d:"M7 22a5 5 0 0 1-2-4",key:"umushi"}],["path",{d:"M3.3 14A6.8 6.8 0 0 1 2 10c0-4.4 4.5-8 10-8s10 3.6 10 8-4.5 8-10 8a12 12 0 0 1-5-1",key:"146dds"}],["path",{d:"M5 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z",key:"bq3ynw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nX=Z("Laugh",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12Z",key:"b2q4dd"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aX=Z("Layers2",[["path",{d:"m16.02 12 5.48 3.13a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74L7.98 12",key:"1cuww1"}],["path",{d:"M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74Z",key:"pdlvxu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iX=Z("Layers3",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m6.08 9.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1e5n1m"}],["path",{d:"m6.08 14.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1iwflc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oX=Z("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tS=Z("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fp=Z("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lX=Z("LayoutList",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cX=Z("LayoutPanelLeft",[["rect",{width:"7",height:"18",x:"3",y:"3",rx:"1",key:"2obqm"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dX=Z("LayoutPanelTop",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sS=Z("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uX=Z("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hX=Z("LeafyGreen",[["path",{d:"M2 22c1.25-.987 2.27-1.975 3.9-2.2a5.56 5.56 0 0 1 3.8 1.5 4 4 0 0 0 6.187-2.353 3.5 3.5 0 0 0 3.69-5.116A3.5 3.5 0 0 0 20.95 8 3.5 3.5 0 1 0 16 3.05a3.5 3.5 0 0 0-5.831 1.373 3.5 3.5 0 0 0-5.116 3.69 4 4 0 0 0-2.348 6.155C3.499 15.42 4.409 16.712 4.2 18.1 3.926 19.743 3.014 20.732 2 22",key:"1134nt"}],["path",{d:"M2 22 17 7",key:"1q7jp2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mX=Z("Lectern",[["path",{d:"M16 12h3a2 2 0 0 0 1.902-1.38l1.056-3.333A1 1 0 0 0 21 6H3a1 1 0 0 0-.958 1.287l1.056 3.334A2 2 0 0 0 5 12h3",key:"13jjxg"}],["path",{d:"M18 6V3a1 1 0 0 0-1-1h-3",key:"1550fe"}],["rect",{width:"8",height:"12",x:"8",y:"10",rx:"1",key:"qmu8b6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pX=Z("LetterText",[["path",{d:"M15 12h6",key:"upa0zy"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"m3 13 3.553-7.724a.5.5 0 0 1 .894 0L11 13",key:"blevx4"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M4 11h6",key:"olkgv1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fX=Z("LibraryBig",[["rect",{width:"8",height:"18",x:"3",y:"3",rx:"1",key:"oynpb5"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M20.4 18.9c.2.5-.1 1.1-.6 1.3l-1.9.7c-.5.2-1.1-.1-1.3-.6L11.1 5.1c-.2-.5.1-1.1.6-1.3l1.9-.7c.5-.2 1.1.1 1.3.6Z",key:"1qboyk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kM=Z("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SM=Z("LifeBuoy",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xX=Z("Ligature",[["path",{d:"M8 20V8c0-2.2 1.8-4 4-4 1.5 0 2.8.8 3.5 2",key:"1rtphz"}],["path",{d:"M6 12h4",key:"a4o3ry"}],["path",{d:"M14 12h2v8",key:"c1fccl"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 20h4",key:"lzx1xo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gX=Z("LightbulbOff",[["path",{d:"M16.8 11.2c.8-.9 1.2-2 1.2-3.2a6 6 0 0 0-9.3-5",key:"1fkcox"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M6.3 6.3a4.67 4.67 0 0 0 1.2 5.2c.7.7 1.3 1.5 1.5 2.5",key:"10m8kw"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kb=Z("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yX=Z("Link2Off",[["path",{d:"M9 17H7A5 5 0 0 1 7 7",key:"10o201"}],["path",{d:"M15 7h2a5 5 0 0 1 4 8",key:"1d3206"}],["line",{x1:"8",x2:"12",y1:"12",y2:"12",key:"rvw6j4"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Do=Z("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fo=Z("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xp=Z("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vX=Z("ListCheck",[["path",{d:"M11 18H3",key:"n3j2dh"}],["path",{d:"m15 18 2 2 4-4",key:"1szwhi"}],["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _X=Z("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bX=Z("ListCollapse",[["path",{d:"m3 10 2.5-2.5L3 5",key:"i6eama"}],["path",{d:"m3 19 2.5-2.5L3 14",key:"w2gmor"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wX=Z("ListEnd",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M10 18H3",key:"13769t"}],["path",{d:"M21 6v10a2 2 0 0 1-2 2h-5",key:"ilrcs8"}],["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jX=Z("ListFilter",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NX=Z("ListMinus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kX=Z("ListMusic",[["path",{d:"M21 15V6",key:"h1cx4g"}],["path",{d:"M18.5 18a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z",key:"8saifv"}],["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zy=Z("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SX=Z("ListPlus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CX=Z("ListRestart",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M7 12H3",key:"13ou7f"}],["path",{d:"M7 18H3",key:"1sijw9"}],["path",{d:"M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14",key:"qth677"}],["path",{d:"M11 10v4h4",key:"172dkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MX=Z("ListStart",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M10 6H3",key:"lf8lx7"}],["path",{d:"M21 18V8a2 2 0 0 0-2-2h-5",key:"1hghli"}],["path",{d:"m16 8-2-2 2-2",key:"160uvd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TX=Z("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AX=Z("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EX=Z("ListVideo",[["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}],["path",{d:"m16 12 5 3-5 3v-6Z",key:"zpskkp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PX=Z("ListX",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dh=Z("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _s=Z("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IX=Z("LoaderPinwheel",[["path",{d:"M22 12a1 1 0 0 1-10 0 1 1 0 0 0-10 0",key:"1lzz15"}],["path",{d:"M7 20.7a1 1 0 1 1 5-8.7 1 1 0 1 0 5-8.6",key:"1gnrpi"}],["path",{d:"M7 3.3a1 1 0 1 1 5 8.6 1 1 0 1 0 5 8.6",key:"u9yy5q"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LX=Z("Loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DX=Z("LocateFixed",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RX=Z("LocateOff",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["path",{d:"M7.11 7.11C5.83 8.39 5 10.1 5 12c0 3.87 3.13 7 7 7 1.9 0 3.61-.83 4.89-2.11",key:"1oh7ia"}],["path",{d:"M18.71 13.96c.19-.63.29-1.29.29-1.96 0-3.87-3.13-7-7-7-.67 0-1.33.1-1.96.29",key:"3qdecy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CM=Z("Locate",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gN=Z("LockKeyholeOpen",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}],["path",{d:"M7 10V7a5 5 0 0 1 9.33-2.5",key:"car5b7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OX=Z("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yN=Z("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yd=Z("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rS=Z("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MM=Z("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FX=Z("Logs",[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zX=Z("Lollipop",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M11 11a2 2 0 0 0 4 0 4 4 0 0 0-8 0 6 6 0 0 0 12 0",key:"107gwy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BX=Z("Luggage",[["path",{d:"M6 20a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2",key:"1m57jg"}],["path",{d:"M8 18V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v14",key:"1l99gc"}],["path",{d:"M10 20h4",key:"ni2waw"}],["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $X=Z("Magnet",[["path",{d:"m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15",key:"1i3lhw"}],["path",{d:"m5 8 4 4",key:"j6kj7e"}],["path",{d:"m12 15 4 4",key:"lnac28"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qX=Z("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UX=Z("MailMinus",[["path",{d:"M22 15V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"fuxbkv"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M16 19h6",key:"xwg31i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VX=Z("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xL=Z("MailPlus",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M16 19h6",key:"xwg31i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HX=Z("MailQuestion",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 15.28c.2-.4.5-.8.9-1a2.1 2.1 0 0 1 2.6.4c.3.4.5.8.5 1.3 0 1.3-2 2-2 2",key:"7z9rxb"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GX=Z("MailSearch",[["path",{d:"M22 12.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h7.5",key:"w80f2v"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",key:"8lzu5m"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m22 22-1.5-1.5",key:"1x83k4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WX=Z("MailWarning",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M20 14v4",key:"1hm744"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gL=Z("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rr=Z("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KX=Z("Mailbox",[["path",{d:"M22 17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9.5C2 7 4 5 6.5 5H18c2.2 0 4 1.8 4 4v8Z",key:"1lbycx"}],["polyline",{points:"15,9 18,9 18,11",key:"1pm9c0"}],["path",{d:"M6.5 5C9 5 11 7 11 9.5V17a2 2 0 0 1-2 2",key:"15i455"}],["line",{x1:"6",x2:"7",y1:"10",y2:"10",key:"1e2scm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZX=Z("Mails",[["rect",{width:"16",height:"13",x:"6",y:"4",rx:"2",key:"1drq3f"}],["path",{d:"m22 7-7.1 3.78c-.57.3-1.23.3-1.8 0L6 7",key:"xn252p"}],["path",{d:"M2 8v11c0 1.1.9 2 2 2h14",key:"n13cji"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YX=Z("MapPinCheckInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XX=Z("MapPinCheck",[["path",{d:"M19.43 12.935c.357-.967.57-1.955.57-2.935a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32.197 32.197 0 0 0 .813-.728",key:"1dq61d"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"m16 18 2 2 4-4",key:"1mkfmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QX=Z("MapPinHouse",[["path",{d:"M15 22a1 1 0 0 1-1-1v-4a1 1 0 0 1 .445-.832l3-2a1 1 0 0 1 1.11 0l3 2A1 1 0 0 1 22 17v4a1 1 0 0 1-1 1z",key:"1p1rcz"}],["path",{d:"M18 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 .601.2",key:"mcbcs9"}],["path",{d:"M18 22v-3",key:"1t1ugv"}],["circle",{cx:"10",cy:"10",r:"3",key:"1ns7v1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JX=Z("MapPinMinusInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eQ=Z("MapPinMinus",[["path",{d:"M18.977 14C19.6 12.701 20 11.343 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32 32 0 0 0 .824-.738",key:"11uxia"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M16 18h6",key:"987eiv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tQ=Z("MapPinOff",[["path",{d:"M12.75 7.09a3 3 0 0 1 2.16 2.16",key:"1d4wjd"}],["path",{d:"M17.072 17.072c-1.634 2.17-3.527 3.912-4.471 4.727a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 1.432-4.568",key:"12yil7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.475 2.818A8 8 0 0 1 20 10c0 1.183-.31 2.377-.81 3.533",key:"lhrkcz"}],["path",{d:"M9.13 9.13a3 3 0 0 0 3.74 3.74",key:"13wojd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sQ=Z("MapPinPlusInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rQ=Z("MapPinPlus",[["path",{d:"M19.914 11.105A7.298 7.298 0 0 0 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32 32 0 0 0 .824-.738",key:"fcdtly"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M16 18h6",key:"987eiv"}],["path",{d:"M19 15v6",key:"10aioa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nQ=Z("MapPinXInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aQ=Z("MapPinX",[["path",{d:"M19.752 11.901A7.78 7.78 0 0 0 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 19 19 0 0 0 .09-.077",key:"y0ewhp"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"m21.5 15.5-5 5",key:"11iqnx"}],["path",{d:"m21.5 20.5-5-5",key:"1bylgx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Da=Z("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iQ=Z("MapPinned",[["path",{d:"M18 8c0 3.613-3.869 7.429-5.393 8.795a1 1 0 0 1-1.214 0C9.87 15.429 6 11.613 6 8a6 6 0 0 1 12 0",key:"11u0oz"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M8.714 14h-3.71a1 1 0 0 0-.948.683l-2.004 6A1 1 0 0 0 3 22h18a1 1 0 0 0 .948-1.316l-2-6a1 1 0 0 0-.949-.684h-3.712",key:"q8zwxj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nS=Z("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oQ=Z("Martini",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M12 11v11",key:"ur9y6a"}],["path",{d:"m19 3-7 8-7-8Z",key:"1sgpiw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lQ=Z("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yL=Z("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xv=Z("Medal",[["path",{d:"M7.21 15 2.66 7.14a2 2 0 0 1 .13-2.2L4.4 2.8A2 2 0 0 1 6 2h12a2 2 0 0 1 1.6.8l1.6 2.14a2 2 0 0 1 .14 2.2L16.79 15",key:"143lza"}],["path",{d:"M11 12 5.12 2.2",key:"qhuxz6"}],["path",{d:"m13 12 5.88-9.8",key:"hbye0f"}],["path",{d:"M8 7h8",key:"i86dvs"}],["circle",{cx:"12",cy:"17",r:"5",key:"qbz8iq"}],["path",{d:"M12 18v-2h-.5",key:"fawc4q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cQ=Z("MegaphoneOff",[["path",{d:"M9.26 9.26 3 11v3l14.14 3.14",key:"3429n"}],["path",{d:"M21 15.34V6l-7.31 2.03",key:"4o1dh8"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dh=Z("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dQ=Z("Meh",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"8",x2:"16",y1:"15",y2:"15",key:"1xb1d9"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uQ=Z("MemoryStick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aS=Z("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hQ=Z("Merge",[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mQ=Z("MessageCircleCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22z",key:"k85zhp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pQ=Z("MessageCircleDashed",[["path",{d:"M13.5 3.1c-.5 0-1-.1-1.5-.1s-1 .1-1.5.1",key:"16ll65"}],["path",{d:"M19.3 6.8a10.45 10.45 0 0 0-2.1-2.1",key:"1nq77a"}],["path",{d:"M20.9 13.5c.1-.5.1-1 .1-1.5s-.1-1-.1-1.5",key:"1sf7wn"}],["path",{d:"M17.2 19.3a10.45 10.45 0 0 0 2.1-2.1",key:"x1hs5g"}],["path",{d:"M10.5 20.9c.5.1 1 .1 1.5.1s1-.1 1.5-.1",key:"19m18z"}],["path",{d:"M3.5 17.5 2 22l4.5-1.5",key:"1f36qi"}],["path",{d:"M3.1 10.5c0 .5-.1 1-.1 1.5s.1 1 .1 1.5",key:"1vz3ju"}],["path",{d:"M6.8 4.7a10.45 10.45 0 0 0-2.1 2.1",key:"19f9do"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TM=Z("MessageCircleHeart",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M15.8 9.2a2.5 2.5 0 0 0-3.5 0l-.3.4-.35-.3a2.42 2.42 0 1 0-3.2 3.6l3.6 3.5 3.6-3.5c1.2-1.2 1.1-2.7.2-3.7",key:"43lnbm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fQ=Z("MessageCircleMore",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xQ=Z("MessageCircleOff",[["path",{d:"M20.5 14.9A9 9 0 0 0 9.1 3.5",key:"1iebmn"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.6 5.6C3 8.3 2.2 12.5 4 16l-2 6 6-2c3.4 1.8 7.6 1.1 10.3-1.7",key:"1ov8ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gQ=Z("MessageCirclePlus",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vL=Z("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yQ=Z("MessageCircleReply",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}],["path",{d:"M7 12h7a2 2 0 0 1 2 2v1",key:"1gheu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vQ=Z("MessageCircleWarning",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Q=Z("MessageCircleX",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vc=Z("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bQ=Z("MessageSquareCode",[["path",{d:"M10 7.5 8 10l2 2.5",key:"xb17xw"}],["path",{d:"m14 7.5 2 2.5-2 2.5",key:"5rap1v"}],["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wQ=Z("MessageSquareDashed",[["path",{d:"M10 17H7l-4 4v-7",key:"1r71xu"}],["path",{d:"M14 17h1",key:"nufu4t"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 14v1a2 2 0 0 1-2 2",key:"29akq3"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M9 3h1",key:"1yesri"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jQ=Z("MessageSquareDiff",[["path",{d:"m5 19-2 2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2",key:"1xuzuj"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NQ=Z("MessageSquareDot",[["path",{d:"M11.7 3H5a2 2 0 0 0-2 2v16l4-4h12a2 2 0 0 0 2-2v-2.7",key:"uodpkb"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kQ=Z("MessageSquareHeart",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M14.8 7.5a1.84 1.84 0 0 0-2.6 0l-.2.3-.3-.3a1.84 1.84 0 1 0-2.4 2.8L12 13l2.7-2.7c.9-.9.8-2.1.1-2.8",key:"1blaws"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SQ=Z("MessageSquareLock",[["path",{d:"M19 15v-2a2 2 0 1 0-4 0v2",key:"h3d1vz"}],["path",{d:"M9 17H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v3.5",key:"xsnnhn"}],["rect",{x:"13",y:"15",width:"8",height:"5",rx:"1",key:"1ccwuk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _L=Z("MessageSquareMore",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CQ=Z("MessageSquareOff",[["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M3.6 3.6c-.4.3-.6.8-.6 1.4v16l4-4h10",key:"pwpm4a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AM=Z("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bL=Z("MessageSquareQuote",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 12a2 2 0 0 0 2-2V8H8",key:"1jfesj"}],["path",{d:"M14 12a2 2 0 0 0 2-2V8h-2",key:"1dq9mh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MQ=Z("MessageSquareReply",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m10 7-3 3 3 3",key:"1eugdv"}],["path",{d:"M17 13v-1a2 2 0 0 0-2-2H7",key:"ernfh3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TQ=Z("MessageSquareShare",[["path",{d:"M21 12v3a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h7",key:"tqtdkg"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"m16 8 5-5",key:"15mbrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AQ=Z("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EQ=Z("MessageSquareWarning",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v2",key:"stiyo7"}],["path",{d:"M12 13h.01",key:"y0uutt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PQ=Z("MessageSquareX",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ki=Z("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IQ=Z("MessagesSquare",[["path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z",key:"p1xzt8"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1",key:"1cx29u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LQ=Z("MicOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vN=Z("MicVocal",[["path",{d:"m11 7.601-5.994 8.19a1 1 0 0 0 .1 1.298l.817.818a1 1 0 0 0 1.314.087L15.09 12",key:"80a601"}],["path",{d:"M16.5 21.174C15.5 20.5 14.372 20 13 20c-2.058 0-3.928 2.356-6 2-2.072-.356-2.775-3.369-1.5-4.5",key:"j0ngtp"}],["circle",{cx:"16",cy:"7",r:"5",key:"d08jfb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wL=Z("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DQ=Z("Microchip",[["path",{d:"M18 12h2",key:"quuxs7"}],["path",{d:"M18 16h2",key:"zsn3lv"}],["path",{d:"M18 20h2",key:"9x5y9y"}],["path",{d:"M18 4h2",key:"1luxfb"}],["path",{d:"M18 8h2",key:"nxqzg"}],["path",{d:"M4 12h2",key:"1ltxp0"}],["path",{d:"M4 16h2",key:"8a5zha"}],["path",{d:"M4 20h2",key:"27dk57"}],["path",{d:"M4 4h2",key:"10groj"}],["path",{d:"M4 8h2",key:"18vq6w"}],["path",{d:"M8 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-1.5c-.276 0-.494.227-.562.495a2 2 0 0 1-3.876 0C9.994 2.227 9.776 2 9.5 2z",key:"1681fp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RQ=Z("Microscope",[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OQ=Z("Microwave",[["rect",{width:"20",height:"15",x:"2",y:"4",rx:"2",key:"2no95f"}],["rect",{width:"8",height:"7",x:"6",y:"8",rx:"1",key:"zh9wx"}],["path",{d:"M18 8v7",key:"o5zi4n"}],["path",{d:"M6 19v2",key:"1loha6"}],["path",{d:"M18 19v2",key:"1dawf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FQ=Z("Milestone",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}],["path",{d:"M4 6a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h13a2 2 0 0 0 1.152-.365l3.424-2.317a1 1 0 0 0 0-1.635l-3.424-2.318A2 2 0 0 0 17 6z",key:"1btarq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zQ=Z("MilkOff",[["path",{d:"M8 2h8",key:"1ssgc1"}],["path",{d:"M9 2v1.343M15 2v2.789a4 4 0 0 0 .672 2.219l.656.984a4 4 0 0 1 .672 2.22v1.131M7.8 7.8l-.128.192A4 4 0 0 0 7 10.212V20a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-3",key:"y0ejgx"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.472 6.472 0 0 0 3.435.435",key:"iaxqsy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BQ=Z("Milk",[["path",{d:"M8 2h8",key:"1ssgc1"}],["path",{d:"M9 2v2.789a4 4 0 0 1-.672 2.219l-.656.984A4 4 0 0 0 7 10.212V20a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-9.789a4 4 0 0 0-.672-2.219l-.656-.984A4 4 0 0 1 15 4.788V2",key:"qtp12x"}],["path",{d:"M7 15a6.472 6.472 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"ygeh44"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Q=Z("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qQ=Z("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yy=Z("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UQ=Z("MonitorCheck",[["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VQ=Z("MonitorCog",[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m15.2 4.9-.9-.4",key:"12wd2u"}],["path",{d:"m15.2 7.1-.9.4",key:"1r2vl7"}],["path",{d:"m16.9 3.2-.4-.9",key:"3zbo91"}],["path",{d:"m16.9 8.8-.4.9",key:"1qr2dn"}],["path",{d:"m19.5 2.3-.4.9",key:"1rjrkq"}],["path",{d:"m19.5 9.7-.4-.9",key:"heryx5"}],["path",{d:"m21.7 4.5-.9.4",key:"17fqt1"}],["path",{d:"m21.7 7.5-.9-.4",key:"14zyni"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HQ=Z("MonitorDot",[["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M22 12v3a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9",key:"1fet9y"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GQ=Z("MonitorDown",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"m15 10-3 3-3-3",key:"lzhmyn"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WQ=Z("MonitorOff",[["path",{d:"M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2",key:"k0q8oc"}],["path",{d:"M22 15V5a2 2 0 0 0-2-2H9",key:"cp1ac0"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KQ=Z("MonitorPause",[["path",{d:"M10 13V7",key:"1u13u9"}],["path",{d:"M14 13V7",key:"1vj9om"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZQ=Z("MonitorPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YQ=Z("MonitorSmartphone",[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XQ=Z("MonitorSpeaker",[["path",{d:"M5.5 20H8",key:"1k40s5"}],["path",{d:"M17 9h.01",key:"1j24nn"}],["rect",{width:"10",height:"16",x:"12",y:"4",rx:"2",key:"ixliua"}],["path",{d:"M8 6H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h4",key:"1mp6e1"}],["circle",{cx:"17",cy:"15",r:"1",key:"tqvash"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QQ=Z("MonitorStop",[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}],["rect",{x:"9",y:"7",width:"6",height:"6",rx:"1",key:"5m2oou"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iS=Z("MonitorUp",[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JQ=Z("MonitorX",[["path",{d:"m14.5 12.5-5-5",key:"1jahn5"}],["path",{d:"m9.5 12.5 5-5",key:"1k2t7b"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oS=Z("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eJ=Z("MoonStar",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9",key:"4ay0iu"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tJ=Z("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sJ=Z("MountainSnow",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}],["path",{d:"M4.14 15.08c2.62-1.57 5.24-1.43 7.86.42 2.74 1.94 5.49 2 8.23.19",key:"1pvmmp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rJ=Z("Mountain",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nJ=Z("MouseOff",[["path",{d:"M12 6v.343",key:"1gyhex"}],["path",{d:"M18.218 18.218A7 7 0 0 1 5 15V9a7 7 0 0 1 .782-3.218",key:"ukzz01"}],["path",{d:"M19 13.343V9A7 7 0 0 0 8.56 2.902",key:"104jy9"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aJ=Z("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iJ=Z("MousePointerBan",[["path",{d:"M2.034 2.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.944L8.204 7.545a1 1 0 0 0-.66.66l-1.066 3.443a.5.5 0 0 1-.944.033z",key:"11pp1i"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"m11.8 11.8 8.4 8.4",key:"oogvdj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tm=Z("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nu=Z("MousePointer",[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oJ=Z("Mouse",[["rect",{x:"5",y:"2",width:"14",height:"20",rx:"7",key:"11ol66"}],["path",{d:"M12 6v4",key:"16clxf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _N=Z("Move3d",[["path",{d:"M5 3v16h16",key:"1mqmf9"}],["path",{d:"m5 19 6-6",key:"jh6hbb"}],["path",{d:"m2 6 3-3 3 3",key:"tkyvxa"}],["path",{d:"m18 16 3 3-3 3",key:"1d4glt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lJ=Z("MoveDiagonal2",[["path",{d:"M19 13v6h-6",key:"1hxl6d"}],["path",{d:"M5 11V5h6",key:"12e2xe"}],["path",{d:"m5 5 14 14",key:"11anup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cJ=Z("MoveDiagonal",[["path",{d:"M11 19H5v-6",key:"8awifj"}],["path",{d:"M13 5h6v6",key:"7voy1q"}],["path",{d:"M19 5 5 19",key:"wwaj1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dJ=Z("MoveDownLeft",[["path",{d:"M11 19H5V13",key:"1akmht"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uJ=Z("MoveDownRight",[["path",{d:"M19 13V19H13",key:"10vkzq"}],["path",{d:"M5 5L19 19",key:"5zm2fv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hJ=Z("MoveDown",[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mJ=Z("MoveHorizontal",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pJ=Z("MoveLeft",[["path",{d:"M6 8L2 12L6 16",key:"kyvwex"}],["path",{d:"M2 12H22",key:"1m8cig"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fJ=Z("MoveRight",[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xJ=Z("MoveUpLeft",[["path",{d:"M5 11V5H11",key:"3q78g9"}],["path",{d:"M5 5L19 19",key:"5zm2fv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gJ=Z("MoveUpRight",[["path",{d:"M13 5H19V11",key:"1n1gyv"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yJ=Z("MoveUp",[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vJ=Z("MoveVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _J=Z("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bJ=Z("Music2",[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wJ=Z("Music3",[["circle",{cx:"12",cy:"18",r:"4",key:"m3r9ws"}],["path",{d:"M16 18V2",key:"40x2m5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jJ=Z("Music4",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["path",{d:"m9 9 12-2",key:"1e64n2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NJ=Z("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kJ=Z("Navigation2Off",[["path",{d:"M9.31 9.31 5 21l7-4 7 4-1.17-3.17",key:"qoq2o2"}],["path",{d:"M14.53 8.88 12 2l-1.17 3.17",key:"k3sjzy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SJ=Z("Navigation2",[["polygon",{points:"12 2 19 21 12 17 5 21 12 2",key:"x8c0qg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CJ=Z("NavigationOff",[["path",{d:"M8.43 8.43 3 11l8 2 2 8 2.57-5.43",key:"1vdtb7"}],["path",{d:"M17.39 11.73 22 2l-9.73 4.61",key:"tya3r6"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jL=Z("Navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MJ=Z("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qv=Z("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TJ=Z("Nfc",[["path",{d:"M6 8.32a7.43 7.43 0 0 1 0 7.36",key:"9iaqei"}],["path",{d:"M9.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"1yha7l"}],["path",{d:"M12.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"4iu2gk"}],["path",{d:"M16.37 2a20.16 20.16 0 0 1 0 20",key:"sap9u2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AJ=Z("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EJ=Z("NotebookTabs",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M15 2v20",key:"dcj49h"}],["path",{d:"M15 7h5",key:"1xj5lc"}],["path",{d:"M15 12h5",key:"w5shd9"}],["path",{d:"M15 17h5",key:"1qaofu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PJ=Z("NotebookText",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M9.5 8h5",key:"11mslq"}],["path",{d:"M9.5 12H16",key:"ktog6x"}],["path",{d:"M9.5 16H14",key:"p1seyn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IJ=Z("Notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LJ=Z("NotepadTextDashed",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v2",key:"j91f56"}],["path",{d:"M20 12v2",key:"w8o0tu"}],["path",{d:"M20 18v2a2 2 0 0 1-2 2h-1",key:"1c9ggx"}],["path",{d:"M13 22h-2",key:"191ugt"}],["path",{d:"M7 22H6a2 2 0 0 1-2-2v-2",key:"1rt9px"}],["path",{d:"M4 14v-2",key:"1v0sqh"}],["path",{d:"M4 8V6a2 2 0 0 1 2-2h2",key:"1mwabg"}],["path",{d:"M8 10h6",key:"3oa6kw"}],["path",{d:"M8 14h8",key:"1fgep2"}],["path",{d:"M8 18h5",key:"17enja"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DJ=Z("NotepadText",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"16",height:"18",x:"4",y:"4",rx:"2",key:"1u9h20"}],["path",{d:"M8 10h6",key:"3oa6kw"}],["path",{d:"M8 14h8",key:"1fgep2"}],["path",{d:"M8 18h5",key:"17enja"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RJ=Z("NutOff",[["path",{d:"M12 4V2",key:"1k5q1u"}],["path",{d:"M5 10v4a7.004 7.004 0 0 0 5.277 6.787c.412.104.802.292 1.102.592L12 22l.621-.621c.3-.3.69-.488 1.102-.592a7.01 7.01 0 0 0 4.125-2.939",key:"1xcvy9"}],["path",{d:"M19 10v3.343",key:"163tfc"}],["path",{d:"M12 12c-1.349-.573-1.905-1.005-2.5-2-.546.902-1.048 1.353-2.5 2-1.018-.644-1.46-1.08-2-2-1.028.71-1.69.918-3 1 1.081-1.048 1.757-2.03 2-3 .194-.776.84-1.551 1.79-2.21m11.654 5.997c.887-.457 1.28-.891 1.556-1.787 1.032.916 1.683 1.157 3 1-1.297-1.036-1.758-2.03-2-3-.5-2-4-4-8-4-.74 0-1.461.068-2.15.192",key:"17914v"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OJ=Z("Nut",[["path",{d:"M12 4V2",key:"1k5q1u"}],["path",{d:"M5 10v4a7.004 7.004 0 0 0 5.277 6.787c.412.104.802.292 1.102.592L12 22l.621-.621c.3-.3.69-.488 1.102-.592A7.003 7.003 0 0 0 19 14v-4",key:"1tgyif"}],["path",{d:"M12 4C8 4 4.5 6 4 8c-.243.97-.919 1.952-2 3 1.31-.082 1.972-.29 3-1 .54.92.982 1.356 2 2 1.452-.647 1.954-1.098 2.5-2 .595.995 1.151 1.427 2.5 2 1.31-.621 1.862-1.058 2.5-2 .629.977 1.162 1.423 2.5 2 1.209-.548 1.68-.967 2-2 1.032.916 1.683 1.157 3 1-1.297-1.036-1.758-2.03-2-3-.5-2-4-4-8-4Z",key:"tnsqj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cv=Z("OctagonAlert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FJ=Z("OctagonMinus",[["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bN=Z("OctagonPause",[["path",{d:"M10 15V9",key:"1lckn7"}],["path",{d:"M14 15V9",key:"1muqhk"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wN=Z("OctagonX",[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zJ=Z("Octagon",[["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BJ=Z("Omega",[["path",{d:"M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21",key:"1x94xo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $J=Z("Option",[["path",{d:"M3 3h6l6 18h6",key:"ph9rgk"}],["path",{d:"M14 3h7",key:"16f0ms"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qJ=Z("Orbit",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M10.4 21.9a10 10 0 0 0 9.941-15.416",key:"eohfx2"}],["path",{d:"M13.5 2.1a10 10 0 0 0-9.841 15.416",key:"19pvbm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UJ=Z("Origami",[["path",{d:"M12 12V4a1 1 0 0 1 1-1h6.297a1 1 0 0 1 .651 1.759l-4.696 4.025",key:"1bx4vc"}],["path",{d:"m12 21-7.414-7.414A2 2 0 0 1 4 12.172V6.415a1.002 1.002 0 0 1 1.707-.707L20 20.009",key:"1h3km6"}],["path",{d:"m12.214 3.381 8.414 14.966a1 1 0 0 1-.167 1.199l-1.168 1.163a1 1 0 0 1-.706.291H6.351a1 1 0 0 1-.625-.219L3.25 18.8a1 1 0 0 1 .631-1.781l4.165.027",key:"1hj4wg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VJ=Z("Package2",[["path",{d:"M3 9h18v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9Z",key:"1ront0"}],["path",{d:"m3 9 2.45-4.9A2 2 0 0 1 7.24 3h9.52a2 2 0 0 1 1.8 1.1L21 9",key:"19h2x1"}],["path",{d:"M12 3v6",key:"1holv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HJ=Z("PackageCheck",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GJ=Z("PackageMinus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WJ=Z("PackageOpen",[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KJ=Z("PackagePlus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZJ=Z("PackageSearch",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["circle",{cx:"18.5",cy:"15.5",r:"2.5",key:"b5zd12"}],["path",{d:"M20.27 17.27 22 19",key:"1l4muz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YJ=Z("PackageX",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["path",{d:"m17 13 5 5m-5 0 5-5",key:"im3w4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nl=Z("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XJ=Z("PaintBucket",[["path",{d:"m19 11-8-8-8.6 8.6a2 2 0 0 0 0 2.8l5.2 5.2c.8.8 2 .8 2.8 0L19 11Z",key:"irua1i"}],["path",{d:"m5 2 5 5",key:"1lls2c"}],["path",{d:"M2 13h15",key:"1hkzvu"}],["path",{d:"M22 20a2 2 0 1 1-4 0c0-1.6 1.7-2.4 2-4 .3 1.6 2 2.4 2 4Z",key:"xk76lq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QJ=Z("PaintRoller",[["rect",{width:"16",height:"6",x:"2",y:"2",rx:"2",key:"jcyz7m"}],["path",{d:"M10 16v-2a2 2 0 0 1 2-2h8a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2",key:"1b9h7c"}],["rect",{width:"4",height:"6",x:"8",y:"16",rx:"1",key:"d6e7yl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jN=Z("PaintbrushVertical",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v4",key:"qmzblu"}],["path",{d:"M17 2a1 1 0 0 1 1 1v9H6V3a1 1 0 0 1 1-1z",key:"ycvu00"}],["path",{d:"M6 12a1 1 0 0 0-1 1v1a2 2 0 0 0 2 2h2a1 1 0 0 1 1 1v2.9a2 2 0 1 0 4 0V17a1 1 0 0 1 1-1h2a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1",key:"iw4wnp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JJ=Z("Paintbrush",[["path",{d:"m14.622 17.897-10.68-2.913",key:"vj2p1u"}],["path",{d:"M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z",key:"18tc5c"}],["path",{d:"M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15",key:"ytzfxy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dl=Z("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eee=Z("PanelBottomClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m15 8-3 3-3-3",key:"1oxy1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NN=Z("PanelBottomDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M14 15h1",key:"171nev"}],["path",{d:"M19 15h2",key:"1vnucp"}],["path",{d:"M3 15h2",key:"8bym0q"}],["path",{d:"M9 15h1",key:"1tg3ks"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tee=Z("PanelBottomOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const see=Z("PanelBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kN=Z("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SN=Z("PanelLeftDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 14v1",key:"askpd8"}],["path",{d:"M9 19v2",key:"16tejx"}],["path",{d:"M9 3v2",key:"1noubl"}],["path",{d:"M9 9v1",key:"19ebxg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CN=Z("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MN=Z("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ree=Z("PanelRightClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TN=Z("PanelRightDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 14v1",key:"ilsfch"}],["path",{d:"M15 19v2",key:"1fst2f"}],["path",{d:"M15 3v2",key:"z204g4"}],["path",{d:"M15 9v1",key:"z2a8b1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nee=Z("PanelRightOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aee=Z("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iee=Z("PanelTopClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m9 16 3-3 3 3",key:"1idcnm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AN=Z("PanelTopDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M14 9h1",key:"l0svgy"}],["path",{d:"M19 9h2",key:"te2zfg"}],["path",{d:"M3 9h2",key:"1h4ldw"}],["path",{d:"M9 9h1",key:"15jzuz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oee=Z("PanelTopOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m15 14-3 3-3-3",key:"g215vf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lee=Z("PanelTop",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cee=Z("PanelsLeftBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M9 15h12",key:"5ijen5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dee=Z("PanelsRightBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h12",key:"1wkqb3"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mv=Z("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lS=Z("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uee=Z("Parentheses",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hee=Z("ParkingMeter",[["path",{d:"M11 15h2",key:"199qp6"}],["path",{d:"M12 12v3",key:"158kv8"}],["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15.282 19a1 1 0 0 0 .948-.68l2.37-6.988a7 7 0 1 0-13.2 0l2.37 6.988a1 1 0 0 0 .948.68z",key:"1jofit"}],["path",{d:"M9 9a3 3 0 1 1 6 0",key:"jdoeu8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bd=Z("PartyPopper",[["path",{d:"M5.8 11.3 2 22l10.7-3.79",key:"gwxi1d"}],["path",{d:"M4 3h.01",key:"1vcuye"}],["path",{d:"M22 8h.01",key:"1mrtc2"}],["path",{d:"M15 2h.01",key:"1cjtqr"}],["path",{d:"M22 20h.01",key:"1mrys2"}],["path",{d:"m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10",key:"hbicv8"}],["path",{d:"m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17",key:"1i94pl"}],["path",{d:"m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7",key:"1cofks"}],["path",{d:"M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z",key:"4kbmks"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uh=Z("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mee=Z("PawPrint",[["circle",{cx:"11",cy:"4",r:"2",key:"vol9p0"}],["circle",{cx:"18",cy:"8",r:"2",key:"17gozi"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}],["path",{d:"M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045Q6.52 17.48 4.46 16.84A3.5 3.5 0 0 1 5.5 10Z",key:"1ydw1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pee=Z("PcCase",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",key:"1uq1d7"}],["path",{d:"M15 14h.01",key:"1kp3bh"}],["path",{d:"M9 6h6",key:"dgm16u"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tv=Z("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fee=Z("PenOff",[["path",{d:"m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982",key:"bjo8r8"}],["path",{d:"m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353",key:"16h5ne"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sb=Z("PenTool",[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dy=Z("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xee=Z("PencilLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}],["path",{d:"m15 5 3 3",key:"1w25hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gee=Z("PencilOff",[["path",{d:"m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982",key:"bjo8r8"}],["path",{d:"m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353",key:"16h5ne"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yee=Z("PencilRuler",[["path",{d:"M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13",key:"orapub"}],["path",{d:"m8 6 2-2",key:"115y1s"}],["path",{d:"m18 16 2-2",key:"ee94s4"}],["path",{d:"m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17",key:"cfq27r"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ga=Z("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vee=Z("Pentagon",[["path",{d:"M10.83 2.38a2 2 0 0 1 2.34 0l8 5.74a2 2 0 0 1 .73 2.25l-3.04 9.26a2 2 0 0 1-1.9 1.37H7.04a2 2 0 0 1-1.9-1.37L2.1 10.37a2 2 0 0 1 .73-2.25z",key:"2hea0t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EM=Z("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ee=Z("PersonStanding",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["path",{d:"m9 20 3-6 3 6",key:"se2kox"}],["path",{d:"m6 8 6 2 6-2",key:"4o3us4"}],["path",{d:"M12 10v4",key:"1kjpxc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bee=Z("PhilippinePeso",[["path",{d:"M20 11H4",key:"6ut86h"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"M7 21V4a1 1 0 0 1 1-1h4a1 1 0 0 1 0 12H7",key:"1ana5r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wee=Z("PhoneCall",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}],["path",{d:"M14.05 2a9 9 0 0 1 8 7.94",key:"vmijpz"}],["path",{d:"M14.05 6A5 5 0 0 1 18 10",key:"13nbpp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jee=Z("PhoneForwarded",[["polyline",{points:"18 2 22 6 18 10",key:"6vjanh"}],["line",{x1:"14",x2:"22",y1:"6",y2:"6",key:"1jsywh"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nee=Z("PhoneIncoming",[["polyline",{points:"16 2 16 8 22 8",key:"1ygljm"}],["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kee=Z("PhoneMissed",[["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["line",{x1:"16",x2:"22",y1:"2",y2:"8",key:"13zxdn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const See=Z("PhoneOff",[["path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91",key:"z86iuo"}],["line",{x1:"22",x2:"2",y1:"2",y2:"22",key:"11kh81"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cee=Z("PhoneOutgoing",[["polyline",{points:"22 8 22 2 16 2",key:"1g204g"}],["line",{x1:"16",x2:"22",y1:"8",y2:"2",key:"1ggias"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pn=Z("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mee=Z("Pi",[["line",{x1:"9",x2:"9",y1:"4",y2:"20",key:"ovs5a5"}],["path",{d:"M4 7c0-1.7 1.3-3 3-3h13",key:"10pag4"}],["path",{d:"M18 20c-1.7 0-3-1.3-3-3V4",key:"1gaosr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tee=Z("Piano",[["path",{d:"M18.5 8c-1.4 0-2.6-.8-3.2-2A6.87 6.87 0 0 0 2 9v11a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-8.5C22 9.6 20.4 8 18.5 8",key:"lag0yf"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M6 14v4",key:"9ng0ue"}],["path",{d:"M10 14v4",key:"1v8uk5"}],["path",{d:"M14 14v4",key:"1tqops"}],["path",{d:"M18 14v4",key:"18uqwm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aee=Z("Pickaxe",[["path",{d:"M14.531 12.469 6.619 20.38a1 1 0 1 1-3-3l7.912-7.912",key:"we99rg"}],["path",{d:"M15.686 4.314A12.5 12.5 0 0 0 5.461 2.958 1 1 0 0 0 5.58 4.71a22 22 0 0 1 6.318 3.393",key:"1w6hck"}],["path",{d:"M17.7 3.7a1 1 0 0 0-1.4 0l-4.6 4.6a1 1 0 0 0 0 1.4l2.6 2.6a1 1 0 0 0 1.4 0l4.6-4.6a1 1 0 0 0 0-1.4z",key:"15hgfx"}],["path",{d:"M19.686 8.314a12.501 12.501 0 0 1 1.356 10.225 1 1 0 0 1-1.751-.119 22 22 0 0 0-3.393-6.319",key:"452b4h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eee=Z("PictureInPicture2",[["path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4",key:"daa4of"}],["rect",{width:"10",height:"7",x:"12",y:"13",rx:"2",key:"1nb8gs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pee=Z("PictureInPicture",[["path",{d:"M8 4.5v5H3m-1-6 6 6m13 0v-3c0-1.16-.84-2-2-2h-7m-9 9v2c0 1.05.95 2 2 2h3",key:"bcd8fb"}],["rect",{width:"10",height:"7",x:"12",y:"13.5",ry:"2",key:"136fx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iee=Z("PiggyBank",[["path",{d:"M19 5c-1.5 0-2.8 1.4-3 2-3.5-1.5-11-.3-11 5 0 1.8 0 3 2 4.5V20h4v-2h3v2h4v-4c1-.5 1.7-1 2-2h2v-4h-2c0-1-.5-1.5-1-2V5z",key:"1ivx2i"}],["path",{d:"M2 9v1c0 1.1.9 2 2 2h1",key:"nm575m"}],["path",{d:"M16 11h.01",key:"xkw8gn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lee=Z("PilcrowLeft",[["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"M14 9h-3a3 3 0 0 1 0-6h9",key:"1ulc19"}],["path",{d:"M18 3v11",key:"1phi0r"}],["path",{d:"M22 18H2l4-4",key:"yt65j9"}],["path",{d:"m6 22-4-4",key:"6jgyf5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dee=Z("PilcrowRight",[["path",{d:"M10 3v11",key:"o3l5kj"}],["path",{d:"M10 9H7a1 1 0 0 1 0-6h8",key:"1wb1nc"}],["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"m18 14 4 4H2",key:"4r8io1"}],["path",{d:"m22 18-4 4",key:"1hjjrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ree=Z("Pilcrow",[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oee=Z("PillBottle",[["path",{d:"M18 11h-4a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h4",key:"17ldeb"}],["path",{d:"M6 7v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7",key:"nc37y6"}],["rect",{width:"16",height:"5",x:"4",y:"2",rx:"1",key:"3jeezo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fee=Z("Pill",[["path",{d:"m10.5 20.5 10-10a4.95 4.95 0 1 0-7-7l-10 10a4.95 4.95 0 1 0 7 7Z",key:"wa1lgi"}],["path",{d:"m8.5 8.5 7 7",key:"rvfmvr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NL=Z("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cb=Z("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zee=Z("Pipette",[["path",{d:"m2 22 1-1h3l9-9",key:"1sre89"}],["path",{d:"M3 21v-3l9-9",key:"hpe2y6"}],["path",{d:"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",key:"196du1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bee=Z("Pizza",[["path",{d:"m12 14-1 1",key:"11onhr"}],["path",{d:"m13.75 18.25-1.25 1.42",key:"1yisr3"}],["path",{d:"M17.775 5.654a15.68 15.68 0 0 0-12.121 12.12",key:"1qtqk6"}],["path",{d:"M18.8 9.3a1 1 0 0 0 2.1 7.7",key:"fbbbr2"}],["path",{d:"M21.964 20.732a1 1 0 0 1-1.232 1.232l-18-5a1 1 0 0 1-.695-1.232A19.68 19.68 0 0 1 15.732 2.037a1 1 0 0 1 1.232.695z",key:"1hyfdd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ee=Z("PlaneLanding",[["path",{d:"M2 22h20",key:"272qi7"}],["path",{d:"M3.77 10.77 2 9l2-4.5 1.1.55c.55.28.9.84.9 1.45s.35 1.17.9 1.45L8 8.5l3-6 1.05.53a2 2 0 0 1 1.09 1.52l.72 5.4a2 2 0 0 0 1.09 1.52l4.4 2.2c.42.22.78.55 1.01.96l.6 1.03c.49.88-.06 1.98-1.06 2.1l-1.18.15c-.47.06-.95-.02-1.37-.24L4.29 11.15a2 2 0 0 1-.52-.38Z",key:"1ma21e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qee=Z("PlaneTakeoff",[["path",{d:"M2 22h20",key:"272qi7"}],["path",{d:"M6.36 17.4 4 17l-2-4 1.1-.55a2 2 0 0 1 1.8 0l.17.1a2 2 0 0 0 1.8 0L8 12 5 6l.9-.45a2 2 0 0 1 2.09.2l4.02 3a2 2 0 0 0 2.1.2l4.19-2.06a2.41 2.41 0 0 1 1.73-.17L21 7a1.4 1.4 0 0 1 .87 1.99l-.38.76c-.23.46-.6.84-1.07 1.08L7.58 17.2a2 2 0 0 1-1.22.18Z",key:"fkigj9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uee=Z("Plane",[["path",{d:"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z",key:"1v9wt8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const So=Z("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vee=Z("Plug2",[["path",{d:"M9 2v6",key:"17ngun"}],["path",{d:"M15 2v6",key:"s7yy2p"}],["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M6 11V8h12v3a6 6 0 1 1-12 0Z",key:"wtfw2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EN=Z("PlugZap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kL=Z("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Us=Z("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hee=Z("PocketKnife",[["path",{d:"M3 2v1c0 1 2 1 2 2S3 6 3 7s2 1 2 2-2 1-2 2 2 1 2 2",key:"19w3oe"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M20.83 8.83a4 4 0 0 0-5.66-5.66l-12 12a4 4 0 1 0 5.66 5.66Z",key:"6fykxj"}],["path",{d:"M18 11.66V22a4 4 0 0 0 4-4V6",key:"1utzek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gee=Z("Pocket",[["path",{d:"M4 3h16a2 2 0 0 1 2 2v6a10 10 0 0 1-10 10A10 10 0 0 1 2 11V5a2 2 0 0 1 2-2z",key:"1mz881"}],["polyline",{points:"8 10 12 14 16 10",key:"w4mbv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wee=Z("Podcast",[["path",{d:"M16.85 18.58a9 9 0 1 0-9.7 0",key:"d71mpg"}],["path",{d:"M8 14a5 5 0 1 1 8 0",key:"fc81rn"}],["circle",{cx:"12",cy:"11",r:"1",key:"1gvufo"}],["path",{d:"M13 17a1 1 0 1 0-2 0l.5 4.5a.5.5 0 1 0 1 0Z",key:"za5kbj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kee=Z("PointerOff",[["path",{d:"M10 4.5V4a2 2 0 0 0-2.41-1.957",key:"jsi14n"}],["path",{d:"M13.9 8.4a2 2 0 0 0-1.26-1.295",key:"hirc7f"}],["path",{d:"M21.7 16.2A8 8 0 0 0 22 14v-3a2 2 0 1 0-4 0v-1a2 2 0 0 0-3.63-1.158",key:"1jxb2e"}],["path",{d:"m7 15-1.8-1.8a2 2 0 0 0-2.79 2.86L6 19.7a7.74 7.74 0 0 0 6 2.3h2a8 8 0 0 0 5.657-2.343",key:"10r7hm"}],["path",{d:"M6 6v8",key:"tv5xkp"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zee=Z("Pointer",[["path",{d:"M22 14a8 8 0 0 1-8 8",key:"56vcr3"}],["path",{d:"M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1agjmk"}],["path",{d:"M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1",key:"wdbh2u"}],["path",{d:"M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10",key:"1ibuk9"}],["path",{d:"M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"g6ys72"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yee=Z("Popcorn",[["path",{d:"M18 8a2 2 0 0 0 0-4 2 2 0 0 0-4 0 2 2 0 0 0-4 0 2 2 0 0 0-4 0 2 2 0 0 0 0 4",key:"10td1f"}],["path",{d:"M10 22 9 8",key:"yjptiv"}],["path",{d:"m14 22 1-14",key:"8jwc8b"}],["path",{d:"M20 8c.5 0 .9.4.8 1l-2.6 12c-.1.5-.7 1-1.2 1H7c-.6 0-1.1-.4-1.2-1L3.2 9c-.1-.6.3-1 .8-1Z",key:"1qo33t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xee=Z("Popsicle",[["path",{d:"M18.6 14.4c.8-.8.8-2 0-2.8l-8.1-8.1a4.95 4.95 0 1 0-7.1 7.1l8.1 8.1c.9.7 2.1.7 2.9-.1Z",key:"1o68ps"}],["path",{d:"m22 22-5.5-5.5",key:"17o70y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qee=Z("PoundSterling",[["path",{d:"M18 7c0-5.333-8-5.333-8 0",key:"1prm2n"}],["path",{d:"M10 7v14",key:"18tmcs"}],["path",{d:"M6 21h12",key:"4dkmi1"}],["path",{d:"M6 13h10",key:"ybwr4a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jee=Z("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SL=Z("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pg=Z("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ete=Z("PrinterCheck",[["path",{d:"M13.5 22H7a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v.5",key:"qeb09x"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}],["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v2",key:"1md90i"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CL=Z("Printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tte=Z("Projector",[["path",{d:"M5 7 3 5",key:"1yys58"}],["path",{d:"M9 6V3",key:"1ptz9u"}],["path",{d:"m13 7 2-2",key:"1w3vmq"}],["circle",{cx:"9",cy:"13",r:"3",key:"1mma13"}],["path",{d:"M11.83 12H20a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h2.17",key:"2frwzc"}],["path",{d:"M16 16h2",key:"dnq2od"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ste=Z("Proportions",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M12 9v11",key:"1fnkrn"}],["path",{d:"M2 9h13a2 2 0 0 1 2 2v9",key:"11z3ex"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rte=Z("Puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nte=Z("Pyramid",[["path",{d:"M2.5 16.88a1 1 0 0 1-.32-1.43l9-13.02a1 1 0 0 1 1.64 0l9 13.01a1 1 0 0 1-.32 1.44l-8.51 4.86a2 2 0 0 1-1.98 0Z",key:"aenxs0"}],["path",{d:"M12 2v20",key:"t6zp3m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xy=Z("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cS=Z("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ate=Z("Rabbit",[["path",{d:"M13 16a3 3 0 0 1 2.24 5",key:"1epib5"}],["path",{d:"M18 12h.01",key:"yjnet6"}],["path",{d:"M18 21h-8a4 4 0 0 1-4-4 7 7 0 0 1 7-7h.2L9.6 6.4a1 1 0 1 1 2.8-2.8L15.8 7h.2c3.3 0 6 2.7 6 6v1a2 2 0 0 1-2 2h-1a3 3 0 0 0-3 3",key:"ue9ozu"}],["path",{d:"M20 8.54V4a2 2 0 1 0-4 0v3",key:"49iql8"}],["path",{d:"M7.612 12.524a3 3 0 1 0-1.6 4.3",key:"1e33i0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ite=Z("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ote=Z("Radiation",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7.5 4.2c-.3-.5-.9-.7-1.3-.4C3.9 5.5 2.3 8.1 2 11c-.1.5.4 1 1 1h5c0-1.5.8-2.8 2-3.4-1.1-1.9-2-3.5-2.5-4.4z",key:"wy49g3"}],["path",{d:"M21 12c.6 0 1-.4 1-1-.3-2.9-1.8-5.5-4.1-7.1-.4-.3-1.1-.2-1.3.3-.6.9-1.5 2.5-2.6 4.3 1.2.7 2 2 2 3.5h5z",key:"vklnvr"}],["path",{d:"M7.5 19.8c-.3.5-.1 1.1.4 1.3 2.6 1.2 5.6 1.2 8.2 0 .5-.2.7-.8.4-1.3-.5-.9-1.4-2.5-2.5-4.3-1.2.7-2.8.7-4 0-1.1 1.8-2 3.4-2.5 4.3z",key:"wkdf1o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lte=Z("Radical",[["path",{d:"M3 12h3.28a1 1 0 0 1 .948.684l2.298 7.934a.5.5 0 0 0 .96-.044L13.82 4.771A1 1 0 0 1 14.792 4H21",key:"1mqj8i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cte=Z("RadioReceiver",[["path",{d:"M5 16v2",key:"g5qcv5"}],["path",{d:"M19 16v2",key:"1gbaio"}],["rect",{width:"20",height:"8",x:"2",y:"8",rx:"2",key:"vjsjur"}],["path",{d:"M18 12h.01",key:"yjnet6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dte=Z("RadioTower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jv=Z("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ute=Z("Radius",[["path",{d:"M20.34 17.52a10 10 0 1 0-2.82 2.82",key:"fydyku"}],["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["path",{d:"m13.41 13.41 4.18 4.18",key:"1gqbwc"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hte=Z("RailSymbol",[["path",{d:"M5 15h14",key:"m0yey3"}],["path",{d:"M5 9h14",key:"7tsvo6"}],["path",{d:"m14 20-5-5 6-6-5-5",key:"1jo42i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mte=Z("Rainbow",[["path",{d:"M22 17a10 10 0 0 0-20 0",key:"ozegv"}],["path",{d:"M6 17a6 6 0 0 1 12 0",key:"5giftw"}],["path",{d:"M10 17a2 2 0 0 1 4 0",key:"gnsikk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pte=Z("Rat",[["path",{d:"M17 5c0-1.7-1.3-3-3-3s-3 1.3-3 3c0 .8.3 1.5.8 2H11c-3.9 0-7 3.1-7 7c0 2.2 1.8 4 4 4",key:"1wq71c"}],["path",{d:"M16.8 3.9c.3-.3.6-.5 1-.7 1.5-.6 3.3.1 3.9 1.6.6 1.5-.1 3.3-1.6 3.9l1.6 2.8c.2.3.2.7.2 1-.2.8-.9 1.2-1.7 1.1 0 0-1.6-.3-2.7-.6H17c-1.7 0-3 1.3-3 3",key:"1crdmb"}],["path",{d:"M13.2 18a3 3 0 0 0-2.2-5",key:"1ol3lk"}],["path",{d:"M13 22H4a2 2 0 0 1 0-4h12",key:"bt3f23"}],["path",{d:"M16 9h.01",key:"1bdo4e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fte=Z("Ratio",[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xte=Z("ReceiptCent",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M12 6.5v11",key:"ecfhkf"}],["path",{d:"M15 9.4a4 4 0 1 0 0 5.2",key:"1makmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gte=Z("ReceiptEuro",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 12h5",key:"1g6qi8"}],["path",{d:"M16 9.5a4 4 0 1 0 0 5.2",key:"b2px4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yte=Z("ReceiptIndianRupee",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 7h8",key:"i86dvs"}],["path",{d:"M12 17.5 8 15h1a4 4 0 0 0 0-8",key:"grpkl4"}],["path",{d:"M8 11h8",key:"vwpz6n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vte=Z("ReceiptJapaneseYen",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"m12 10 3-3",key:"1mc12w"}],["path",{d:"m9 7 3 3v7.5",key:"39i0xv"}],["path",{d:"M9 11h6",key:"1fldmi"}],["path",{d:"M9 15h6",key:"cctwl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _te=Z("ReceiptPoundSterling",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 13h5",key:"1k9z8w"}],["path",{d:"M10 17V9.5a2.5 2.5 0 0 1 5 0",key:"1dzgp0"}],["path",{d:"M8 17h7",key:"8mjdqu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bte=Z("ReceiptRussianRuble",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 15h5",key:"vxg57a"}],["path",{d:"M8 11h5a2 2 0 1 0 0-4h-3v10",key:"1usi5u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wte=Z("ReceiptSwissFranc",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M10 17V7h5",key:"k7jq18"}],["path",{d:"M10 11h4",key:"1i0mka"}],["path",{d:"M8 15h5",key:"vxg57a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jte=Z("ReceiptText",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M13 16H8",key:"wsln4y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nte=Z("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PN=Z("RectangleEllipsis",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kte=Z("RectangleHorizontal",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ste=Z("RectangleVertical",[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cte=Z("Recycle",[["path",{d:"M7 19H4.815a1.83 1.83 0 0 1-1.57-.881 1.785 1.785 0 0 1-.004-1.784L7.196 9.5",key:"x6z5xu"}],["path",{d:"M11 19h8.203a1.83 1.83 0 0 0 1.556-.89 1.784 1.784 0 0 0 0-1.775l-1.226-2.12",key:"1x4zh5"}],["path",{d:"m14 16-3 3 3 3",key:"f6jyew"}],["path",{d:"M8.293 13.596 7.196 9.5 3.1 10.598",key:"wf1obh"}],["path",{d:"m9.344 5.811 1.093-1.892A1.83 1.83 0 0 1 11.985 3a1.784 1.784 0 0 1 1.546.888l3.943 6.843",key:"9tzpgr"}],["path",{d:"m13.378 9.633 4.096 1.098 1.097-4.096",key:"1oe83g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mte=Z("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tte=Z("RedoDot",[["circle",{cx:"12",cy:"17",r:"1",key:"1ixnty"}],["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dS=Z("Redo",[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ate=Z("RefreshCcwDot",[["path",{d:"M3 2v6h6",key:"18ldww"}],["path",{d:"M21 12A9 9 0 0 0 6 5.3L3 8",key:"1pbrqz"}],["path",{d:"M21 22v-6h-6",key:"usdfbe"}],["path",{d:"M3 12a9 9 0 0 0 15 6.7l3-2.7",key:"1hosoe"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PM=Z("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ete=Z("RefreshCwOff",[["path",{d:"M21 8L18.74 5.74A9.75 9.75 0 0 0 12 3C11 3 10.03 3.16 9.13 3.47",key:"1krf6h"}],["path",{d:"M8 16H3v5",key:"1cv678"}],["path",{d:"M3 12C3 9.51 4 7.26 5.64 5.64",key:"ruvoct"}],["path",{d:"m3 16 2.26 2.26A9.75 9.75 0 0 0 12 21c2.49 0 4.74-1 6.36-2.64",key:"19q130"}],["path",{d:"M21 12c0 1-.16 1.97-.47 2.87",key:"4w8emr"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oo=Z("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pte=Z("Refrigerator",[["path",{d:"M5 6a4 4 0 0 1 4-4h6a4 4 0 0 1 4 4v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6Z",key:"fpq118"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M15 7v6",key:"1nx30x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ite=Z("Regex",[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lte=Z("RemoveFormatting",[["path",{d:"M4 7V4h16v3",key:"9msm58"}],["path",{d:"M5 20h6",key:"1h6pxn"}],["path",{d:"M13 4 8 20",key:"kqq6aj"}],["path",{d:"m15 15 5 5",key:"me55sn"}],["path",{d:"m20 15-5 5",key:"11p7ol"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dte=Z("Repeat1",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}],["path",{d:"M11 10h1v4",key:"70cz1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rte=Z("Repeat2",[["path",{d:"m2 9 3-3 3 3",key:"1ltn5i"}],["path",{d:"M13 18H7a2 2 0 0 1-2-2V6",key:"1r6tfw"}],["path",{d:"m22 15-3 3-3-3",key:"4rnwn2"}],["path",{d:"M11 6h6a2 2 0 0 1 2 2v10",key:"2f72bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ML=Z("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ote=Z("ReplaceAll",[["path",{d:"M14 14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"1yyzbs"}],["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"zfj4xr"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a 3 3 0 0 1 3-3h1",key:"1ageje"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fte=Z("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zte=Z("ReplyAll",[["polyline",{points:"7 17 2 12 7 7",key:"t83bqg"}],["polyline",{points:"12 17 7 12 12 7",key:"1g4ajm"}],["path",{d:"M22 18v-2a4 4 0 0 0-4-4H7",key:"1fcyog"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TL=Z("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bte=Z("Rewind",[["polygon",{points:"11 19 2 12 11 5 11 19",key:"14yba5"}],["polygon",{points:"22 19 13 12 22 5 22 19",key:"1pi1cj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $te=Z("Ribbon",[["path",{d:"M12 11.22C11 9.997 10 9 10 8a2 2 0 0 1 4 0c0 1-.998 2.002-2.01 3.22",key:"1rnhq3"}],["path",{d:"m12 18 2.57-3.5",key:"116vt7"}],["path",{d:"M6.243 9.016a7 7 0 0 1 11.507-.009",key:"10dq0b"}],["path",{d:"M9.35 14.53 12 11.22",key:"tdsyp2"}],["path",{d:"M9.35 14.53C7.728 12.246 6 10.221 6 7a6 5 0 0 1 12 0c-.005 3.22-1.778 5.235-3.43 7.5l3.557 4.527a1 1 0 0 1-.203 1.43l-1.894 1.36a1 1 0 0 1-1.384-.215L12 18l-2.679 3.593a1 1 0 0 1-1.39.213l-1.865-1.353a1 1 0 0 1-.203-1.422z",key:"nmifey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qy=Z("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qte=Z("RockingChair",[["polyline",{points:"3.5 2 6.5 12.5 18 12.5",key:"y3iy52"}],["line",{x1:"9.5",x2:"5.5",y1:"12.5",y2:"20",key:"19vg5i"}],["line",{x1:"15",x2:"18.5",y1:"12.5",y2:"20",key:"1inpmv"}],["path",{d:"M2.75 18a13 13 0 0 0 18.5 0",key:"1nquas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ute=Z("RollerCoaster",[["path",{d:"M6 19V5",key:"1r845m"}],["path",{d:"M10 19V6.8",key:"9j2tfs"}],["path",{d:"M14 19v-7.8",key:"10s8qv"}],["path",{d:"M18 5v4",key:"1tajlv"}],["path",{d:"M18 19v-6",key:"ielfq3"}],["path",{d:"M22 19V9",key:"158nzp"}],["path",{d:"M2 19V9a4 4 0 0 1 4-4c2 0 4 1.33 6 4s4 4 6 4a4 4 0 1 0-3-6.65",key:"1930oh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IN=Z("Rotate3d",[["path",{d:"M16.466 7.5C15.643 4.237 13.952 2 12 2 9.239 2 7 6.477 7 12s2.239 10 5 10c.342 0 .677-.069 1-.2",key:"10n0gc"}],["path",{d:"m15.194 13.707 3.814 1.86-1.86 3.814",key:"16shm9"}],["path",{d:"M19 15.57c-1.804.885-4.274 1.43-7 1.43-5.523 0-10-2.239-10-5s4.477-5 10-5c4.838 0 8.873 1.718 9.8 4",key:"1lxi77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vte=Z("RotateCcwSquare",[["path",{d:"M20 9V7a2 2 0 0 0-2-2h-6",key:"19z8uc"}],["path",{d:"m15 2-3 3 3 3",key:"177bxs"}],["path",{d:"M20 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2",key:"d36hnl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jy=Z("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hte=Z("RotateCwSquare",[["path",{d:"M12 5H6a2 2 0 0 0-2 2v3",key:"l96uqu"}],["path",{d:"m9 8 3-3-3-3",key:"1gzgc3"}],["path",{d:"M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2",key:"1w2k5h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AL=Z("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gte=Z("RouteOff",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5c.4 0 .9-.1 1.3-.2",key:"1effex"}],["path",{d:"M5.2 5.2A3.5 3.53 0 0 0 6.5 12H12",key:"k9y2ds"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M21 15.3a3.5 3.5 0 0 0-3.3-3.3",key:"11nlu2"}],["path",{d:"M15 5h-4.3",key:"6537je"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wte=Z("Route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kte=Z("Router",[["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6.01 18H6",key:"19vcac"}],["path",{d:"M10.01 18H10",key:"uamcmx"}],["path",{d:"M15 10v4",key:"qjz1xs"}],["path",{d:"M17.84 7.17a4 4 0 0 0-5.66 0",key:"1rif40"}],["path",{d:"M20.66 4.34a8 8 0 0 0-11.31 0",key:"6a5xfq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LN=Z("Rows2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DN=Z("Rows3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zte=Z("Rows4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 7.5H3",key:"1hm9pq"}],["path",{d:"M21 12H3",key:"2avoz0"}],["path",{d:"M21 16.5H3",key:"n7jzkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yte=Z("Rss",[["path",{d:"M4 11a9 9 0 0 1 9 9",key:"pv89mb"}],["path",{d:"M4 4a16 16 0 0 1 16 16",key:"k0647b"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uS=Z("Ruler",[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xte=Z("RussianRuble",[["path",{d:"M6 11h8a4 4 0 0 0 0-8H9v18",key:"18ai8t"}],["path",{d:"M6 15h8",key:"1y8f6l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qte=Z("Sailboat",[["path",{d:"M22 18H2a4 4 0 0 0 4 4h12a4 4 0 0 0 4-4Z",key:"1404fh"}],["path",{d:"M21 14 10 2 3 14h18Z",key:"1nzg7v"}],["path",{d:"M10 2v16",key:"1labyt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jte=Z("Salad",[["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 21a9 9 0 0 0 9-9H3a9 9 0 0 0 9 9Z",key:"4rw317"}],["path",{d:"M11.38 12a2.4 2.4 0 0 1-.4-4.77 2.4 2.4 0 0 1 3.2-2.77 2.4 2.4 0 0 1 3.47-.63 2.4 2.4 0 0 1 3.37 3.37 2.4 2.4 0 0 1-1.1 3.7 2.51 2.51 0 0 1 .03 1.1",key:"10xrj0"}],["path",{d:"m13 12 4-4",key:"1hckqy"}],["path",{d:"M10.9 7.25A3.99 3.99 0 0 0 4 10c0 .73.2 1.41.54 2",key:"1p4srx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ese=Z("Sandwich",[["path",{d:"m2.37 11.223 8.372-6.777a2 2 0 0 1 2.516 0l8.371 6.777",key:"f1wd0e"}],["path",{d:"M21 15a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-5.25",key:"1pfu07"}],["path",{d:"M3 15a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h9",key:"1oq9qw"}],["path",{d:"m6.67 15 6.13 4.6a2 2 0 0 0 2.8-.4l3.15-4.2",key:"1fnwu5"}],["rect",{width:"20",height:"4",x:"2",y:"11",rx:"1",key:"itshg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tse=Z("SatelliteDish",[["path",{d:"M4 10a7.31 7.31 0 0 0 10 10Z",key:"1fzpp3"}],["path",{d:"m9 15 3-3",key:"88sc13"}],["path",{d:"M17 13a6 6 0 0 0-6-6",key:"15cc6u"}],["path",{d:"M21 13A10 10 0 0 0 11 3",key:"11nf8s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sse=Z("Satellite",[["path",{d:"M13 7 9 3 5 7l4 4",key:"vyckw6"}],["path",{d:"m17 11 4 4-4 4-4-4",key:"rchckc"}],["path",{d:"m8 12 4 4 6-6-4-4Z",key:"1sshf7"}],["path",{d:"m16 8 3-3",key:"x428zp"}],["path",{d:"M9 21a6 6 0 0 0-6-6",key:"1iajcf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rse=Z("SaveAll",[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nse=Z("SaveOff",[["path",{d:"M13 13H8a1 1 0 0 0-1 1v7",key:"h8g396"}],["path",{d:"M14 8h1",key:"1lfen6"}],["path",{d:"M17 21v-4",key:"1yknxs"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.41 20.41A2 2 0 0 1 19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 .59-1.41",key:"1t4vdl"}],["path",{d:"M29.5 11.5s5 5 4 5",key:"zzn4i6"}],["path",{d:"M9 3h6.2a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V15",key:"24cby9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _c=Z("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RN=Z("Scale3d",[["path",{d:"M5 7v11a1 1 0 0 0 1 1h11",key:"13dt1j"}],["path",{d:"M5.293 18.707 11 13",key:"ezgbsx"}],["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["circle",{cx:"5",cy:"5",r:"2",key:"1gwv83"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EL=Z("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ase=Z("Scaling",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M14 15H9v-5",key:"pi4jk9"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M21 3 9 15",key:"15kdhq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ise=Z("ScanBarcode",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 7v10",key:"23sfjj"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M17 7v10",key:"578dap"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ose=Z("ScanEye",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lse=Z("ScanFace",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 9h.01",key:"x1ddxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cse=Z("ScanLine",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dse=Z("ScanQrCode",[["path",{d:"M17 12v4a1 1 0 0 1-1 1h-4",key:"uk4fdo"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M17 8V7",key:"q2g9wo"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M7 17h.01",key:"19xn7k"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{x:"7",y:"7",width:"5",height:"5",rx:"1",key:"m9kyts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const use=Z("ScanSearch",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hse=Z("ScanText",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 8h8",key:"1jbsf9"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h6",key:"1vyc9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mse=Z("Scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pse=Z("School",[["path",{d:"M14 22v-4a2 2 0 1 0-4 0v4",key:"hhkicm"}],["path",{d:"m18 10 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-7.382a1 1 0 0 1 .553-.894L6 10",key:"1xqip1"}],["path",{d:"M18 5v17",key:"1sw6gf"}],["path",{d:"m4 6 7.106-3.553a2 2 0 0 1 1.788 0L20 6",key:"9d2mlk"}],["path",{d:"M6 5v17",key:"1xfsm0"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fse=Z("ScissorsLineDashed",[["path",{d:"M5.42 9.42 8 12",key:"12pkuq"}],["circle",{cx:"4",cy:"8",r:"2",key:"107mxr"}],["path",{d:"m14 6-8.58 8.58",key:"gvzu5l"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"M10.8 14.8 14 18",key:"ax7m9r"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xse=Z("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gse=Z("ScreenShareOff",[["path",{d:"M13 3H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-3",key:"i8wdob"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yse=Z("ScreenShare",[["path",{d:"M13 3H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-3",key:"i8wdob"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m17 8 5-5",key:"fqif7o"}],["path",{d:"M17 3h5v5",key:"1o3tu8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vse=Z("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _se=Z("Scroll",[["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bse=Z("SearchCheck",[["path",{d:"m8 11 2 2 4-4",key:"1sed1v"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wse=Z("SearchCode",[["path",{d:"m13 13.5 2-2.5-2-2.5",key:"1rvxrh"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M9 8.5 7 11l2 2.5",key:"6ffwbx"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jse=Z("SearchSlash",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PL=Z("SearchX",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const an=Z("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nse=Z("Section",[["path",{d:"M16 5a4 3 0 0 0-8 0c0 4 8 3 8 7a4 3 0 0 1-8 0",key:"vqan6v"}],["path",{d:"M8 19a4 3 0 0 0 8 0c0-4-8-3-8-7a4 3 0 0 1 8 0",key:"wdjd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ON=Z("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kse=Z("SendToBack",[["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}],["path",{d:"M7 14v1a2 2 0 0 0 2 2h1",key:"pao6x6"}],["path",{d:"M14 7h1a2 2 0 0 1 2 2v1",key:"19tdru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const An=Z("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sse=Z("SeparatorHorizontal",[["line",{x1:"3",x2:"21",y1:"12",y2:"12",key:"10d38w"}],["polyline",{points:"8 8 12 4 16 8",key:"zo8t4w"}],["polyline",{points:"16 16 12 20 8 16",key:"1oyrid"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cse=Z("SeparatorVertical",[["line",{x1:"12",x2:"12",y1:"3",y2:"21",key:"1efggb"}],["polyline",{points:"8 8 4 12 8 16",key:"bnfmv4"}],["polyline",{points:"16 16 20 12 16 8",key:"u90052"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mse=Z("ServerCog",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m15.7 13.4-.9-.3",key:"1jwmzr"}],["path",{d:"m9.2 10.9-.9-.3",key:"qapnim"}],["path",{d:"m10.6 15.7.3-.9",key:"quwk0k"}],["path",{d:"m13.6 15.7-.4-1",key:"cb9xp7"}],["path",{d:"m10.8 9.3-.4-1",key:"1uaiz5"}],["path",{d:"m8.3 13.6 1-.4",key:"s6srou"}],["path",{d:"m14.7 10.8 1-.4",key:"4d31cq"}],["path",{d:"m13.4 8.3-.3.9",key:"1bm987"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tse=Z("ServerCrash",[["path",{d:"M6 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-2",key:"4b9dqc"}],["path",{d:"M6 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-2",key:"22nnkd"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m13 6-4 6h6l-4 6",key:"14hqih"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ase=Z("ServerOff",[["path",{d:"M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5",key:"bt2siv"}],["path",{d:"M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z",key:"1hjrv1"}],["path",{d:"M22 17v-1a2 2 0 0 0-2-2h-1",key:"1iynyr"}],["path",{d:"M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z",key:"161ggg"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ese=Z("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IL=Z("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ko=Z("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pse=Z("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vd=Z("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LL=Z("Share",[["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["polyline",{points:"16 6 12 2 8 6",key:"m901s6"}],["line",{x1:"12",x2:"12",y1:"2",y2:"15",key:"1p0rca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ise=Z("Sheet",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lse=Z("Shell",[["path",{d:"M14 11a2 2 0 1 1-4 0 4 4 0 0 1 8 0 6 6 0 0 1-12 0 8 8 0 0 1 16 0 10 10 0 1 1-20 0 11.93 11.93 0 0 1 2.42-7.22 2 2 0 1 1 3.16 2.44",key:"1cn552"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dse=Z("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rse=Z("ShieldBan",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m4.243 5.21 14.39 12.472",key:"1c9a7c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hS=Z("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ose=Z("ShieldEllipsis",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fse=Z("ShieldHalf",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 22V2",key:"zs6s6o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zse=Z("ShieldMinus",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9 12h6",key:"1c52cq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mS=Z("ShieldOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bse=Z("ShieldPlus",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M12 9v6",key:"199k2o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $se=Z("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FN=Z("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ou=Z("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qse=Z("ShipWheel",[["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}],["path",{d:"M12 2v7.5",key:"1e5rl5"}],["path",{d:"m19 5-5.23 5.23",key:"1ezxxf"}],["path",{d:"M22 12h-7.5",key:"le1719"}],["path",{d:"m19 19-5.23-5.23",key:"p3fmgn"}],["path",{d:"M12 14.5V22",key:"dgcmos"}],["path",{d:"M10.23 13.77 5 19",key:"qwopd4"}],["path",{d:"M9.5 12H2",key:"r7bup8"}],["path",{d:"M10.23 10.23 5 5",key:"k2y7lj"}],["circle",{cx:"12",cy:"12",r:"2.5",key:"ix0uyj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Use=Z("Ship",[["path",{d:"M12 10.189V14",key:"1p8cqu"}],["path",{d:"M12 2v3",key:"qbqxhf"}],["path",{d:"M19 13V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6",key:"qpkstq"}],["path",{d:"M19.38 20A11.6 11.6 0 0 0 21 14l-8.188-3.639a2 2 0 0 0-1.624 0L3 14a11.6 11.6 0 0 0 2.81 7.76",key:"7tigtc"}],["path",{d:"M2 21c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1s1.2 1 2.5 1c2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"1924j5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vse=Z("Shirt",[["path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z",key:"1wgbhj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e0=Z("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hse=Z("ShoppingBasket",[["path",{d:"m15 11-1 9",key:"5wnq3a"}],["path",{d:"m19 11-4-7",key:"cnml18"}],["path",{d:"M2 11h20",key:"3eubbj"}],["path",{d:"m3.5 11 1.6 7.4a2 2 0 0 0 2 1.6h9.8a2 2 0 0 0 2-1.6l1.7-7.4",key:"yiazzp"}],["path",{d:"M4.5 15.5h15",key:"13mye1"}],["path",{d:"m5 11 4-7",key:"116ra9"}],["path",{d:"m9 11 1 9",key:"1ojof7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const op=Z("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gse=Z("Shovel",[["path",{d:"M2 22v-5l5-5 5 5-5 5z",key:"1fh25c"}],["path",{d:"M9.5 14.5 16 8",key:"1smz5x"}],["path",{d:"m17 2 5 5-.5.5a3.53 3.53 0 0 1-5 0s0 0 0 0a3.53 3.53 0 0 1 0-5L17 2",key:"1q8uv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wse=Z("ShowerHead",[["path",{d:"m4 4 2.5 2.5",key:"uv2vmf"}],["path",{d:"M13.5 6.5a4.95 4.95 0 0 0-7 7",key:"frdkwv"}],["path",{d:"M15 5 5 15",key:"1ag8rq"}],["path",{d:"M14 17v.01",key:"eokfpp"}],["path",{d:"M10 16v.01",key:"14uyyl"}],["path",{d:"M13 13v.01",key:"1v1k97"}],["path",{d:"M16 10v.01",key:"5169yg"}],["path",{d:"M11 20v.01",key:"cj92p8"}],["path",{d:"M17 14v.01",key:"11cswd"}],["path",{d:"M20 11v.01",key:"19e0od"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kse=Z("Shrink",[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zse=Z("Shrub",[["path",{d:"M12 22v-7l-2-2",key:"eqv9mc"}],["path",{d:"M17 8v.8A6 6 0 0 1 13.8 20H10A6.5 6.5 0 0 1 7 8a5 5 0 0 1 10 0Z",key:"ubcgy"}],["path",{d:"m14 14-2 2",key:"847xa2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pS=Z("Shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yse=Z("Sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xse=Z("SignalHigh",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qse=Z("SignalLow",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jse=Z("SignalMedium",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ere=Z("SignalZero",[["path",{d:"M2 20h.01",key:"4haj6o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tre=Z("Signal",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sre=Z("Signature",[["path",{d:"m21 17-2.156-1.868A.5.5 0 0 0 18 15.5v.5a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1c0-2.545-3.991-3.97-8.5-4a1 1 0 0 0 0 5c4.153 0 4.745-11.295 5.708-13.5a2.5 2.5 0 1 1 3.31 3.284",key:"y32ogt"}],["path",{d:"M3 21h18",key:"itz85i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rre=Z("SignpostBig",[["path",{d:"M10 9H4L2 7l2-2h6",key:"1hq7x2"}],["path",{d:"M14 5h6l2 2-2 2h-6",key:"bv62ej"}],["path",{d:"M10 22V4a2 2 0 1 1 4 0v18",key:"eqpcf2"}],["path",{d:"M8 22h8",key:"rmew8v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nre=Z("Signpost",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}],["path",{d:"M18 6a2 2 0 0 1 1.387.56l2.307 2.22a1 1 0 0 1 0 1.44l-2.307 2.22A2 2 0 0 1 18 13H6a2 2 0 0 1-1.387-.56l-2.306-2.22a1 1 0 0 1 0-1.44l2.306-2.22A2 2 0 0 1 6 6z",key:"gqqp9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const are=Z("Siren",[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ire=Z("SkipBack",[["polygon",{points:"19 20 9 12 19 4 19 20",key:"o2sva"}],["line",{x1:"5",x2:"5",y1:"19",y2:"5",key:"1ocqjk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ore=Z("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lre=Z("Skull",[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cre=Z("Slack",[["rect",{width:"3",height:"8",x:"13",y:"2",rx:"1.5",key:"diqz80"}],["path",{d:"M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5",key:"183iwg"}],["rect",{width:"3",height:"8",x:"8",y:"14",rx:"1.5",key:"hqg7r1"}],["path",{d:"M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5",key:"76g71w"}],["rect",{width:"8",height:"3",x:"14",y:"13",rx:"1.5",key:"1kmz0a"}],["path",{d:"M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5",key:"jc4sz0"}],["rect",{width:"8",height:"3",x:"2",y:"8",rx:"1.5",key:"1omvl4"}],["path",{d:"M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5",key:"16f3cl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dre=Z("Slash",[["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ure=Z("Slice",[["path",{d:"M11 16.586V19a1 1 0 0 1-1 1H2L18.37 3.63a1 1 0 1 1 3 3l-9.663 9.663a1 1 0 0 1-1.414 0L8 14",key:"1sllp5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fS=Z("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zN=Z("SlidersVertical",[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hre=Z("SmartphoneCharging",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12.667 8 10 12h4l-2.667 4",key:"h9lk2d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mre=Z("SmartphoneNfc",[["rect",{width:"7",height:"12",x:"2",y:"6",rx:"1",key:"5nje8w"}],["path",{d:"M13 8.32a7.43 7.43 0 0 1 0 7.36",key:"1g306n"}],["path",{d:"M16.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"uqvjvo"}],["path",{d:"M19.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"ujntz3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t0=Z("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pre=Z("SmilePlus",[["path",{d:"M22 11v1a10 10 0 1 1-9-10",key:"ew0xw9"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}],["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fre=Z("Smile",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xre=Z("Snail",[["path",{d:"M2 13a6 6 0 1 0 12 0 4 4 0 1 0-8 0 2 2 0 0 0 4 0",key:"hneq2s"}],["circle",{cx:"10",cy:"13",r:"8",key:"194lz3"}],["path",{d:"M2 21h12c4.4 0 8-3.6 8-8V7a2 2 0 1 0-4 0v6",key:"ixqyt7"}],["path",{d:"M18 3 19.1 5.2",key:"9tjm43"}],["path",{d:"M22 3 20.9 5.2",key:"j3odrs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zv=Z("Snowflake",[["line",{x1:"2",x2:"22",y1:"12",y2:"12",key:"1dnqot"}],["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"m20 16-4-4 4-4",key:"rquw4f"}],["path",{d:"m4 8 4 4-4 4",key:"12s3z9"}],["path",{d:"m16 4-4 4-4-4",key:"1tumq1"}],["path",{d:"m8 20 4-4 4 4",key:"9p200w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gre=Z("Sofa",[["path",{d:"M20 9V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v3",key:"1dgpiv"}],["path",{d:"M2 16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"xacw8m"}],["path",{d:"M4 18v2",key:"jwo5n2"}],["path",{d:"M20 18v2",key:"1ar1qi"}],["path",{d:"M12 4v9",key:"oqhhn3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yre=Z("Soup",[["path",{d:"M12 21a9 9 0 0 0 9-9H3a9 9 0 0 0 9 9Z",key:"4rw317"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M19.5 12 22 6",key:"shfsr5"}],["path",{d:"M16.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.73 1.62",key:"rpc6vp"}],["path",{d:"M11.25 3c.27.1.8.53.74 1.36-.05.83-.93 1.2-.98 2.02-.06.78.33 1.24.72 1.62",key:"1lf63m"}],["path",{d:"M6.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.74 1.62",key:"97tijn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vre=Z("Space",[["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _re=Z("Spade",[["path",{d:"M5 9c-1.5 1.5-3 3.2-3 5.5A5.5 5.5 0 0 0 7.5 20c1.8 0 3-.5 4.5-2 1.5 1.5 2.7 2 4.5 2a5.5 5.5 0 0 0 5.5-5.5c0-2.3-1.5-4-3-5.5l-7-7-7 7Z",key:"40bo9n"}],["path",{d:"M12 18v4",key:"jadmvz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bre=Z("Sparkle",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $r=Z("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wre=Z("Speaker",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["circle",{cx:"12",cy:"14",r:"4",key:"1jruaj"}],["path",{d:"M12 14h.01",key:"1etili"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jre=Z("Speech",[["path",{d:"M8.8 20v-4.1l1.9.2a2.3 2.3 0 0 0 2.164-2.1V8.3A5.37 5.37 0 0 0 2 8.25c0 2.8.656 3.054 1 4.55a5.77 5.77 0 0 1 .029 2.758L2 20",key:"11atix"}],["path",{d:"M19.8 17.8a7.5 7.5 0 0 0 .003-10.603",key:"yol142"}],["path",{d:"M17 15a3.5 3.5 0 0 0-.025-4.975",key:"ssbmkc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nre=Z("SpellCheck2",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M4 21c1.1 0 1.1-1 2.3-1s1.1 1 2.3 1c1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1",key:"8mdmtu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kre=Z("SpellCheck",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sre=Z("Spline",[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cre=Z("Split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mre=Z("SprayCan",[["path",{d:"M3 3h.01",key:"159qn6"}],["path",{d:"M7 5h.01",key:"1hq22a"}],["path",{d:"M11 7h.01",key:"1osv80"}],["path",{d:"M3 7h.01",key:"1xzrh3"}],["path",{d:"M7 9h.01",key:"19b3jx"}],["path",{d:"M3 11h.01",key:"1eifu7"}],["rect",{width:"4",height:"4",x:"15",y:"5",key:"mri9e4"}],["path",{d:"m19 9 2 2v10c0 .6-.4 1-1 1h-6c-.6 0-1-.4-1-1V11l2-2",key:"aib6hk"}],["path",{d:"m13 14 8-2",key:"1d7bmk"}],["path",{d:"m13 19 8-2",key:"1y2vml"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xS=Z("Sprout",[["path",{d:"M7 20h10",key:"e6iznv"}],["path",{d:"M10 20c5.5-2.5.8-6.4 3-10",key:"161w41"}],["path",{d:"M9.5 9.4c1.1.8 1.8 2.2 2.3 3.7-2 .4-3.5.4-4.8-.3-1.2-.6-2.3-1.9-3-4.2 2.8-.5 4.4 0 5.5.8z",key:"9gtqwd"}],["path",{d:"M14.1 6a7 7 0 0 0-1.1 4c1.9-.1 3.3-.6 4.3-1.4 1-1 1.6-2.3 1.7-4.6-2.7.1-4 1-4.9 2z",key:"bkxnd2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BN=Z("SquareActivity",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $N=Z("SquareArrowDownLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 8-8 8",key:"166keh"}],["path",{d:"M16 16H8V8",key:"1w2ppm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qN=Z("SquareArrowDownRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"M16 8v8H8",key:"1lbpgo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UN=Z("SquareArrowDown",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VN=Z("SquareArrowLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m12 8-4 4 4 4",key:"15vm53"}],["path",{d:"M16 12H8",key:"1fr5h0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HN=Z("SquareArrowOutDownLeft",[["path",{d:"M13 21h6a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v6",key:"14qz4y"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GN=Z("SquareArrowOutDownRight",[["path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"14rsvq"}],["path",{d:"m21 21-9-9",key:"1et2py"}],["path",{d:"M21 15v6h-6",key:"1jko0i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WN=Z("SquareArrowOutUpLeft",[["path",{d:"M13 3h6a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-6",key:"14mv1t"}],["path",{d:"m3 3 9 9",key:"rks13r"}],["path",{d:"M3 9V3h6",key:"ira0h2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KN=Z("SquareArrowOutUpRight",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZN=Z("SquareArrowRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YN=Z("SquareArrowUpLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8h8",key:"19xb1h"}],["path",{d:"M16 16 8 8",key:"1qdy8n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XN=Z("SquareArrowUpRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 8h8v8",key:"b65dnt"}],["path",{d:"m8 16 8-8",key:"13b9ih"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QN=Z("SquareArrowUp",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JN=Z("SquareAsterisk",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8.5 14 7-4",key:"12hpby"}],["path",{d:"m8.5 10 7 4",key:"wwy2dy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ek=Z("SquareBottomDashedScissors",[["path",{d:"M4 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2",key:"1vzg26"}],["path",{d:"M10 22H8",key:"euku7a"}],["path",{d:"M16 22h-2",key:"18d249"}],["circle",{cx:"8",cy:"8",r:"2",key:"14cg06"}],["path",{d:"M9.414 9.414 12 12",key:"qz4lzr"}],["path",{d:"M14.8 14.8 18 18",key:"11flf1"}],["circle",{cx:"8",cy:"16",r:"2",key:"1acxsx"}],["path",{d:"m18 6-8.586 8.586",key:"11kzk1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ny=Z("SquareChartGantt",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 8h7",key:"kbo1nt"}],["path",{d:"M8 12h6",key:"ikassy"}],["path",{d:"M11 16h5",key:"oq65wt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Av=Z("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tk=Z("SquareCheck",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sk=Z("SquareChevronDown",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rk=Z("SquareChevronLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m14 16-4-4 4-4",key:"ojs7w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nk=Z("SquareChevronRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ak=Z("SquareChevronUp",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m8 14 4-4 4 4",key:"fy2ptz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ik=Z("SquareCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tre=Z("SquareDashedBottomCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Are=Z("SquareDashedBottom",[["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 21h1",key:"v9vybs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ok=Z("SquareDashedKanban",[["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M21 14v1",key:"169vum"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M3 9v1",key:"1r0deq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lk=Z("SquareDashedMousePointer",[["path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z",key:"xwnzip"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h2",key:"1qve2z"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v2",key:"p14lih"}],["path",{d:"M3 14v1",key:"vnatye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ck=Z("SquareDashed",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dk=Z("SquareDivide",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}],["line",{x1:"12",x2:"12",y1:"16",y2:"16",key:"aqc6ln"}],["line",{x1:"12",x2:"12",y1:"8",y2:"8",key:"1mkcni"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uk=Z("SquareDot",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hk=Z("SquareEqual",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mk=Z("SquareFunction",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3",key:"m1af9g"}],["path",{d:"M9 11.2h5.7",key:"3zgcl2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pk=Z("SquareKanban",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fk=Z("SquareLibrary",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7v10",key:"d5nglc"}],["path",{d:"M11 7v10",key:"pptsnr"}],["path",{d:"m15 7 2 10",key:"1m7qm5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xk=Z("SquareM",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8l4 4 4-4v8",key:"141u4e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gk=Z("SquareMenu",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 8h10",key:"1jw688"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yk=Z("SquareMinus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vk=Z("SquareMousePointer",[["path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z",key:"xwnzip"}],["path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"14rsvq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _k=Z("SquareParkingOff",[["path",{d:"M3.6 3.6A2 2 0 0 1 5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-.59 1.41",key:"9l1ft6"}],["path",{d:"M3 8.7V19a2 2 0 0 0 2 2h10.3",key:"17knke"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M13 13a3 3 0 1 0 0-6H9v2",key:"uoagbd"}],["path",{d:"M9 17v-2.3",key:"1jxgo2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bk=Z("SquareParking",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gc=Z("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wk=Z("SquarePercent",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jk=Z("SquarePi",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7h10",key:"udp07y"}],["path",{d:"M10 7v10",key:"i1d9ee"}],["path",{d:"M16 17a2 2 0 0 1-2-2V7",key:"ftwdc7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nk=Z("SquarePilcrow",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 12H9.5a2.5 2.5 0 0 1 0-5H17",key:"1l9586"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M16 7v10",key:"lavkr4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kk=Z("SquarePlay",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 8 6 4-6 4Z",key:"f1r3lt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sk=Z("SquarePlus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ck=Z("SquarePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ere=Z("SquareRadical",[["path",{d:"M7 12h2l2 5 2-10h4",key:"1fxv6h"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mk=Z("SquareScissors",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"2",key:"1btzen"}],["circle",{cx:"8",cy:"8",r:"2",key:"14cg06"}],["path",{d:"M9.414 9.414 12 12",key:"qz4lzr"}],["path",{d:"M14.8 14.8 18 18",key:"11flf1"}],["circle",{cx:"8",cy:"16",r:"2",key:"1acxsx"}],["path",{d:"m18 6-8.586 8.586",key:"11kzk1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tk=Z("SquareSigma",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M16 8.9V7H8l4 5-4 5h8v-1.9",key:"9nih0i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ak=Z("SquareSlash",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ek=Z("SquareSplitHorizontal",[["path",{d:"M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3",key:"lubmu8"}],["path",{d:"M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3",key:"1ag34g"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pk=Z("SquareSplitVertical",[["path",{d:"M5 8V5c0-1 1-2 2-2h10c1 0 2 1 2 2v3",key:"1pi83i"}],["path",{d:"M19 16v3c0 1-1 2-2 2H7c-1 0-2-1-2-2v-3",key:"ido5k7"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pre=Z("SquareSquare",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ire=Z("SquareStack",[["path",{d:"M4 10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"4i38lg"}],["path",{d:"M10 16c-1.1 0-2-.9-2-2v-4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"mlte4a"}],["rect",{width:"8",height:"8",x:"14",y:"14",rx:"2",key:"1fa9i4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ik=Z("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lk=Z("SquareUserRound",[["path",{d:"M18 21a6 6 0 0 0-12 0",key:"kaz2du"}],["circle",{cx:"12",cy:"11",r:"4",key:"1gt34v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dk=Z("SquareUser",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 21v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2",key:"1m6ac2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rk=Z("SquareX",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s0=Z("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lre=Z("Squircle",[["path",{d:"M12 3c7.2 0 9 1.8 9 9s-1.8 9-9 9-9-1.8-9-9 1.8-9 9-9",key:"garfkc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dre=Z("Squirrel",[["path",{d:"M15.236 22a3 3 0 0 0-2.2-5",key:"21bitc"}],["path",{d:"M16 20a3 3 0 0 1 3-3h1a2 2 0 0 0 2-2v-2a4 4 0 0 0-4-4V4",key:"oh0fg0"}],["path",{d:"M18 13h.01",key:"9veqaj"}],["path",{d:"M18 6a4 4 0 0 0-4 4 7 7 0 0 0-7 7c0-5 4-5 4-10.5a4.5 4.5 0 1 0-9 0 2.5 2.5 0 0 0 5 0C7 10 3 11 3 17c0 2.8 2.2 5 5 5h10",key:"980v8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rre=Z("Stamp",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M19.27 13.73A2.5 2.5 0 0 0 17.5 13h-11A2.5 2.5 0 0 0 4 15.5V17a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-1.5c0-.66-.26-1.3-.73-1.77Z",key:"1sy9ra"}],["path",{d:"M14 13V8.5C14 7 15 7 15 5a3 3 0 0 0-3-3c-1.66 0-3 1-3 3s1 2 1 3.5V13",key:"cnxgux"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ore=Z("StarHalf",[["path",{d:"M12 18.338a2.1 2.1 0 0 0-.987.244L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.12 2.12 0 0 0 1.597-1.16l2.309-4.679A.53.53 0 0 1 12 2",key:"2ksp49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fre=Z("StarOff",[["path",{d:"M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43",key:"16m0ql"}],["path",{d:"M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91",key:"1vt8nq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hn=Z("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zre=Z("StepBack",[["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["polygon",{points:"14,20 4,12 14,4",key:"ypakod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bre=Z("StepForward",[["line",{x1:"6",x2:"6",y1:"4",y2:"20",key:"fy8qot"}],["polygon",{points:"10,4 20,12 10,20",key:"1mc1pf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $re=Z("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qre=Z("Sticker",[["path",{d:"M15.5 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2V8.5L15.5 3Z",key:"1wis1t"}],["path",{d:"M14 3v4a2 2 0 0 0 2 2h4",key:"36rjfy"}],["path",{d:"M8 13h.01",key:"1sbv64"}],["path",{d:"M16 13h.01",key:"wip0gl"}],["path",{d:"M10 16s.8 1 2 1c1.3 0 2-1 2-1",key:"1vvgv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ure=Z("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vre=Z("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hre=Z("StretchHorizontal",[["rect",{width:"20",height:"6",x:"2",y:"4",rx:"2",key:"qdearl"}],["rect",{width:"20",height:"6",x:"2",y:"14",rx:"2",key:"1xrn6j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gre=Z("StretchVertical",[["rect",{width:"6",height:"20",x:"4",y:"2",rx:"2",key:"19qu7m"}],["rect",{width:"6",height:"20",x:"14",y:"2",rx:"2",key:"24v0nk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DL=Z("Strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wre=Z("Subscript",[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kre=Z("SunDim",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M20 12h.01",key:"1ykeid"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M4 12h.01",key:"158zrr"}],["path",{d:"M17.657 6.343h.01",key:"31pqzk"}],["path",{d:"M17.657 17.657h.01",key:"jehnf4"}],["path",{d:"M6.343 17.657h.01",key:"gdk6ow"}],["path",{d:"M6.343 6.343h.01",key:"1uurf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zre=Z("SunMedium",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 3v1",key:"1asbbs"}],["path",{d:"M12 20v1",key:"1wcdkc"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M20 12h1",key:"1vloll"}],["path",{d:"m18.364 5.636-.707.707",key:"1hakh0"}],["path",{d:"m6.343 17.657-.707.707",key:"18m9nf"}],["path",{d:"m5.636 5.636.707.707",key:"1xv1c5"}],["path",{d:"m17.657 17.657.707.707",key:"vl76zb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yre=Z("SunMoon",[["path",{d:"M12 8a2.83 2.83 0 0 0 4 4 4 4 0 1 1-4-4",key:"1fu5g2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.9 4.9 1.4 1.4",key:"b9915j"}],["path",{d:"m17.7 17.7 1.4 1.4",key:"qc3ed3"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.3 17.7-1.4 1.4",key:"5gca6"}],["path",{d:"m19.1 4.9-1.4 1.4",key:"wpu9u6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xre=Z("SunSnow",[["path",{d:"M10 9a3 3 0 1 0 0 6",key:"6zmtdl"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M14 21V3",key:"1llu3z"}],["path",{d:"M10 4V3",key:"pkzwkn"}],["path",{d:"M10 21v-1",key:"1u8rkd"}],["path",{d:"m3.64 18.36.7-.7",key:"105rm9"}],["path",{d:"m4.34 6.34-.7-.7",key:"d3unjp"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 4-3 3",key:"15jcng"}],["path",{d:"m14 17 3 3",key:"6tlq38"}],["path",{d:"m21 15-3-3 3-3",key:"1nlnje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e1=Z("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qre=Z("Sunrise",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jre=Z("Sunset",[["path",{d:"M12 10V2",key:"16sf7g"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ene=Z("Superscript",[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tne=Z("SwatchBook",[["path",{d:"M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z",key:"1ldrpk"}],["path",{d:"M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7",key:"11i5po"}],["path",{d:"M 7 17h.01",key:"1euzgo"}],["path",{d:"m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8",key:"o2gii7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sne=Z("SwissFranc",[["path",{d:"M10 21V3h8",key:"br2l0g"}],["path",{d:"M6 16h9",key:"2py0wn"}],["path",{d:"M10 9.5h7",key:"13dmhz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rne=Z("SwitchCamera",[["path",{d:"M11 19H4a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5",key:"mtk2lu"}],["path",{d:"M13 5h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-5",key:"120jsl"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m18 22-3-3 3-3",key:"kgdoj7"}],["path",{d:"m6 2 3 3-3 3",key:"1fnbkv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nne=Z("Sword",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ane=Z("Swords",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ine=Z("Syringe",[["path",{d:"m18 2 4 4",key:"22kx64"}],["path",{d:"m17 7 3-3",key:"1w1zoj"}],["path",{d:"M19 9 8.7 19.3c-1 1-2.5 1-3.4 0l-.6-.6c-1-1-1-2.5 0-3.4L15 5",key:"1exhtz"}],["path",{d:"m9 11 4 4",key:"rovt3i"}],["path",{d:"m5 19-3 3",key:"59f2uf"}],["path",{d:"m14 4 6 6",key:"yqp9t2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IM=Z("Table2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const one=Z("TableCellsMerge",[["path",{d:"M12 21v-6",key:"lihzve"}],["path",{d:"M12 9V3",key:"da5inc"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lne=Z("TableCellsSplit",[["path",{d:"M12 15V9",key:"8c7uyn"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cne=Z("TableColumnsSplit",[["path",{d:"M14 14v2",key:"w2a1xv"}],["path",{d:"M14 20v2",key:"1lq872"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M14 8v2",key:"i67w9a"}],["path",{d:"M2 15h8",key:"82wtch"}],["path",{d:"M2 3h6a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H2",key:"up0l64"}],["path",{d:"M2 9h8",key:"yelfik"}],["path",{d:"M22 15h-4",key:"1es58f"}],["path",{d:"M22 3h-2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h2",key:"pdjoqf"}],["path",{d:"M22 9h-4",key:"1luja7"}],["path",{d:"M5 3v18",key:"14hmio"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dne=Z("TableOfContents",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M21 12h.01",key:"msek7k"}],["path",{d:"M21 18h.01",key:"1e8rq1"}],["path",{d:"M21 6h.01",key:"1koanj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const une=Z("TableProperties",[["path",{d:"M15 3v18",key:"14nvp0"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hne=Z("TableRowsSplit",[["path",{d:"M14 10h2",key:"1lstlu"}],["path",{d:"M15 22v-8",key:"1fwwgm"}],["path",{d:"M15 2v4",key:"1044rn"}],["path",{d:"M2 10h2",key:"1r8dkt"}],["path",{d:"M20 10h2",key:"1ug425"}],["path",{d:"M3 19h18",key:"awlh7x"}],["path",{d:"M3 22v-6a2 2 135 0 1 2-2h14a2 2 45 0 1 2 2v6",key:"ibqhof"}],["path",{d:"M3 2v2a2 2 45 0 0 2 2h14a2 2 135 0 0 2-2V2",key:"1uenja"}],["path",{d:"M8 10h2",key:"66od0"}],["path",{d:"M9 22v-8",key:"fmnu31"}],["path",{d:"M9 2v4",key:"j1yeou"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LM=Z("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mne=Z("TabletSmartphone",[["rect",{width:"10",height:"14",x:"3",y:"8",rx:"2",key:"1vrsiq"}],["path",{d:"M5 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2h-2.4",key:"1j4zmg"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pne=Z("Tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fne=Z("Tablets",[["circle",{cx:"7",cy:"7",r:"5",key:"x29byf"}],["circle",{cx:"17",cy:"17",r:"5",key:"1op1d2"}],["path",{d:"M12 17h10",key:"ls21zv"}],["path",{d:"m3.46 10.54 7.08-7.08",key:"1rehiu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hh=Z("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xne=Z("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gne=Z("Tally1",[["path",{d:"M4 4v16",key:"6qkkli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yne=Z("Tally2",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vne=Z("Tally3",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ne=Z("Tally4",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}],["path",{d:"M19 4v16",key:"8ij5ei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bne=Z("Tally5",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}],["path",{d:"M19 4v16",key:"8ij5ei"}],["path",{d:"M22 6 2 18",key:"h9moai"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wne=Z("Tangent",[["circle",{cx:"17",cy:"4",r:"2",key:"y5j2s2"}],["path",{d:"M15.59 5.41 5.41 15.59",key:"l0vprr"}],["circle",{cx:"4",cy:"17",r:"2",key:"9p4efm"}],["path",{d:"M12 22s-4-9-1.5-11.5S22 12 22 12",key:"1twk4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rh=Z("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jne=Z("Telescope",[["path",{d:"m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44",key:"k4qptu"}],["path",{d:"m13.56 11.747 4.332-.924",key:"19l80z"}],["path",{d:"m16 21-3.105-6.21",key:"7oh9d"}],["path",{d:"M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z",key:"m7xp4m"}],["path",{d:"m6.158 8.633 1.114 4.456",key:"74o979"}],["path",{d:"m8 21 3.105-6.21",key:"1fvxut"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nne=Z("TentTree",[["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}],["path",{d:"m14 5 3-3 3 3",key:"1sorif"}],["path",{d:"m14 10 3-3 3 3",key:"1jyi9h"}],["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M17 14H7l-5 8h20Z",key:"13ar7p"}],["path",{d:"M8 14v8",key:"1ghmqk"}],["path",{d:"m9 14 5 8",key:"13pgi6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kne=Z("Tent",[["path",{d:"M3.5 21 14 3",key:"1szst5"}],["path",{d:"M20.5 21 10 3",key:"1310c3"}],["path",{d:"M15.5 21 12 15l-3.5 6",key:"1ddtfw"}],["path",{d:"M2 21h20",key:"1nyx9w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sne=Z("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ok=Z("TestTubeDiagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cne=Z("TestTube",[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mne=Z("TestTubes",[["path",{d:"M9 2v17.5A2.5 2.5 0 0 1 6.5 22A2.5 2.5 0 0 1 4 19.5V2",key:"1hjrqt"}],["path",{d:"M20 2v17.5a2.5 2.5 0 0 1-2.5 2.5a2.5 2.5 0 0 1-2.5-2.5V2",key:"16lc8n"}],["path",{d:"M3 2h7",key:"7s29d5"}],["path",{d:"M14 2h7",key:"7sicin"}],["path",{d:"M9 16H4",key:"1bfye3"}],["path",{d:"M20 16h-5",key:"ddnjpe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tne=Z("TextCursorInput",[["path",{d:"M5 4h1a3 3 0 0 1 3 3 3 3 0 0 1 3-3h1",key:"18xjzo"}],["path",{d:"M13 20h-1a3 3 0 0 1-3-3 3 3 0 0 1-3 3H5",key:"fj48gi"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M9 7v10",key:"1vc8ob"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ane=Z("TextCursor",[["path",{d:"M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1",key:"uvaxm9"}],["path",{d:"M7 22h1a4 4 0 0 0 4-4v-1",key:"11xy8d"}],["path",{d:"M7 2h1a4 4 0 0 1 4 4v1",key:"1uw06m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ene=Z("TextQuote",[["path",{d:"M17 6H3",key:"16j9eg"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 18H8",key:"1wfozv"}],["path",{d:"M3 12v6",key:"fv4c87"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pne=Z("TextSearch",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fk=Z("TextSelect",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}],["line",{x1:"7",x2:"15",y1:"8",y2:"8",key:"1758g8"}],["line",{x1:"7",x2:"17",y1:"12",y2:"12",key:"197423"}],["line",{x1:"7",x2:"13",y1:"16",y2:"16",key:"37cgm6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ine=Z("Text",[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lne=Z("Theater",[["path",{d:"M2 10s3-3 3-8",key:"3xiif0"}],["path",{d:"M22 10s-3-3-3-8",key:"ioaa5q"}],["path",{d:"M10 2c0 4.4-3.6 8-8 8",key:"16fkpi"}],["path",{d:"M14 2c0 4.4 3.6 8 8 8",key:"b9eulq"}],["path",{d:"M2 10s2 2 2 5",key:"1au1lb"}],["path",{d:"M22 10s-2 2-2 5",key:"qi2y5e"}],["path",{d:"M8 15h8",key:"45n4r"}],["path",{d:"M2 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1",key:"1vsc2m"}],["path",{d:"M14 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1",key:"hrha4u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dne=Z("ThermometerSnowflake",[["path",{d:"M2 12h10",key:"19562f"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"m3 9 3 3-3 3",key:"1sas0l"}],["path",{d:"M12 6 9 9 6 6",key:"pfrgxu"}],["path",{d:"m6 18 3-3 1.5 1.5",key:"1e277p"}],["path",{d:"M20 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"iof6y5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rne=Z("ThermometerSun",[["path",{d:"M12 9a4 4 0 0 0-2 7.5",key:"1jvsq6"}],["path",{d:"M12 3v2",key:"1w22ol"}],["path",{d:"m6.6 18.4-1.4 1.4",key:"w2yidj"}],["path",{d:"M20 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"iof6y5"}],["path",{d:"M4 13H2",key:"118le4"}],["path",{d:"M6.34 7.34 4.93 5.93",key:"1brd51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const One=Z("Thermometer",[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RL=Z("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fu=Z("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fne=Z("TicketCheck",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zne=Z("TicketMinus",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M9 12h6",key:"1c52cq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bne=Z("TicketPercent",[["path",{d:"M2 9a3 3 0 1 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 1 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"1l48ns"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ne=Z("TicketPlus",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M12 9v6",key:"199k2o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qne=Z("TicketSlash",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Une=Z("TicketX",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OL=Z("Ticket",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vne=Z("TicketsPlane",[["path",{d:"M10.5 17h1.227a2 2 0 0 0 1.345-.52L18 12",key:"16muxl"}],["path",{d:"m12 13.5 3.75.5",key:"1i9qhk"}],["path",{d:"m4.5 8 10.58-5.06a1 1 0 0 1 1.342.488L18.5 8",key:"12lg5p"}],["path",{d:"M6 10V8",key:"1y41hn"}],["path",{d:"M6 14v1",key:"cao2tf"}],["path",{d:"M6 19v2",key:"1loha6"}],["rect",{x:"2",y:"8",width:"20",height:"13",rx:"2",key:"p3bz5l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hne=Z("Tickets",[["path",{d:"m4.5 8 10.58-5.06a1 1 0 0 1 1.342.488L18.5 8",key:"12lg5p"}],["path",{d:"M6 10V8",key:"1y41hn"}],["path",{d:"M6 14v1",key:"cao2tf"}],["path",{d:"M6 19v2",key:"1loha6"}],["rect",{x:"2",y:"8",width:"20",height:"13",rx:"2",key:"p3bz5l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gne=Z("TimerOff",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7",key:"10he05"}],["path",{d:"M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2",key:"15f7sh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M12 12v-2",key:"fwoke6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wne=Z("TimerReset",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M12 14v-4",key:"1evpnu"}],["path",{d:"M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6",key:"1ts96g"}],["path",{d:"M9 17H4v5",key:"8t5av"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kne=Z("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zne=Z("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yne=Z("ToggleRight",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xne=Z("Toilet",[["path",{d:"M7 12h13a1 1 0 0 1 1 1 5 5 0 0 1-5 5h-.598a.5.5 0 0 0-.424.765l1.544 2.47a.5.5 0 0 1-.424.765H5.402a.5.5 0 0 1-.424-.765L7 18",key:"kc4kqr"}],["path",{d:"M8 18a5 5 0 0 1-5-5V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8",key:"1tqs57"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qne=Z("Tornado",[["path",{d:"M21 4H3",key:"1hwok0"}],["path",{d:"M18 8H6",key:"41n648"}],["path",{d:"M19 12H9",key:"1g4lpz"}],["path",{d:"M16 16h-6",key:"1j5d54"}],["path",{d:"M11 20H9",key:"39obr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jne=Z("Torus",[["ellipse",{cx:"12",cy:"11",rx:"3",ry:"2",key:"1b2qxu"}],["ellipse",{cx:"12",cy:"12.5",rx:"10",ry:"8.5",key:"h8emeu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eae=Z("TouchpadOff",[["path",{d:"M4 4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16",key:"lnt0bk"}],["path",{d:"M2 14h12",key:"d8icqz"}],["path",{d:"M22 14h-2",key:"jrx26d"}],["path",{d:"M12 20v-6",key:"1rm09r"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M22 16V6a2 2 0 0 0-2-2H10",key:"11y8e4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tae=Z("Touchpad",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M12 20v-6",key:"1rm09r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sae=Z("TowerControl",[["path",{d:"M18.2 12.27 20 6H4l1.8 6.27a1 1 0 0 0 .95.73h10.5a1 1 0 0 0 .96-.73Z",key:"1pledb"}],["path",{d:"M8 13v9",key:"hmv0ci"}],["path",{d:"M16 22v-9",key:"ylnf1u"}],["path",{d:"m9 6 1 7",key:"dpdgam"}],["path",{d:"m15 6-1 7",key:"ls7zgu"}],["path",{d:"M12 6V2",key:"1pj48d"}],["path",{d:"M13 2h-2",key:"mj6ths"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rae=Z("ToyBrick",[["rect",{width:"18",height:"12",x:"3",y:"8",rx:"1",key:"158fvp"}],["path",{d:"M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3",key:"s0042v"}],["path",{d:"M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3",key:"9wmeh2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nae=Z("Tractor",[["path",{d:"m10 11 11 .9a1 1 0 0 1 .8 1.1l-.665 4.158a1 1 0 0 1-.988.842H20",key:"she1j9"}],["path",{d:"M16 18h-5",key:"bq60fd"}],["path",{d:"M18 5a1 1 0 0 0-1 1v5.573",key:"1kv8ia"}],["path",{d:"M3 4h8.129a1 1 0 0 1 .99.863L13 11.246",key:"1q1ert"}],["path",{d:"M4 11V4",key:"9ft8pt"}],["path",{d:"M7 15h.01",key:"k5ht0j"}],["path",{d:"M8 10.1V4",key:"1jgyzo"}],["circle",{cx:"18",cy:"18",r:"2",key:"1emm8v"}],["circle",{cx:"7",cy:"15",r:"5",key:"ddtuc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aae=Z("TrafficCone",[["path",{d:"M9.3 6.2a4.55 4.55 0 0 0 5.4 0",key:"flyxqv"}],["path",{d:"M7.9 10.7c.9.8 2.4 1.3 4.1 1.3s3.2-.5 4.1-1.3",key:"1nlxxg"}],["path",{d:"M13.9 3.5a1.93 1.93 0 0 0-3.8-.1l-3 10c-.1.2-.1.4-.1.6 0 1.7 2.2 3 5 3s5-1.3 5-3c0-.2 0-.4-.1-.5Z",key:"vz7x1l"}],["path",{d:"m7.5 12.2-4.7 2.7c-.5.3-.8.7-.8 1.1s.3.8.8 1.1l7.6 4.5c.9.5 2.1.5 3 0l7.6-4.5c.7-.3 1-.7 1-1.1s-.3-.8-.8-1.1l-4.7-2.8",key:"1xfzlw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iae=Z("TrainFrontTunnel",[["path",{d:"M2 22V12a10 10 0 1 1 20 0v10",key:"o0fyp0"}],["path",{d:"M15 6.8v1.4a3 2.8 0 1 1-6 0V6.8",key:"m8q3n9"}],["path",{d:"M10 15h.01",key:"44in9x"}],["path",{d:"M14 15h.01",key:"5mohn5"}],["path",{d:"M10 19a4 4 0 0 1-4-4v-3a6 6 0 1 1 12 0v3a4 4 0 0 1-4 4Z",key:"hckbmu"}],["path",{d:"m9 19-2 3",key:"iij7hm"}],["path",{d:"m15 19 2 3",key:"npx8sa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oae=Z("TrainFront",[["path",{d:"M8 3.1V7a4 4 0 0 0 8 0V3.1",key:"1v71zp"}],["path",{d:"m9 15-1-1",key:"1yrq24"}],["path",{d:"m15 15 1-1",key:"1t0d6s"}],["path",{d:"M9 19c-2.8 0-5-2.2-5-5v-4a8 8 0 0 1 16 0v4c0 2.8-2.2 5-5 5Z",key:"1p0hjs"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m16 19 2 3",key:"xo31yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lae=Z("TrainTrack",[["path",{d:"M2 17 17 2",key:"18b09t"}],["path",{d:"m2 14 8 8",key:"1gv9hu"}],["path",{d:"m5 11 8 8",key:"189pqp"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"m11 5 8 8",key:"ummqn6"}],["path",{d:"m14 2 8 8",key:"1vk7dn"}],["path",{d:"M7 22 22 7",key:"15mb1i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zk=Z("TramFront",[["rect",{width:"16",height:"16",x:"4",y:"3",rx:"2",key:"1wxw4b"}],["path",{d:"M4 11h16",key:"mpoxn0"}],["path",{d:"M12 3v8",key:"1h2ygw"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m18 22-2-3",key:"1p0ohu"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M16 15h.01",key:"rnfrdf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gr=Z("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cae=Z("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dae=Z("TreeDeciduous",[["path",{d:"M8 19a4 4 0 0 1-2.24-7.32A3.5 3.5 0 0 1 9 6.03V6a3 3 0 1 1 6 0v.04a3.5 3.5 0 0 1 3.24 5.65A4 4 0 0 1 16 19Z",key:"oadzkq"}],["path",{d:"M12 19v3",key:"npa21l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bk=Z("TreePalm",[["path",{d:"M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4",key:"foxbe7"}],["path",{d:"M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3",key:"18arnh"}],["path",{d:"M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35",key:"ywahnh"}],["path",{d:"M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14",key:"ft0feo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mb=Z("TreePine",[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uae=Z("Trees",[["path",{d:"M10 10v.2A3 3 0 0 1 8.9 16H5a3 3 0 0 1-1-5.8V10a3 3 0 0 1 6 0Z",key:"1l6gj6"}],["path",{d:"M7 16v6",key:"1a82de"}],["path",{d:"M13 19v3",key:"13sx9i"}],["path",{d:"M12 19h8.3a1 1 0 0 0 .7-1.7L18 14h.3a1 1 0 0 0 .7-1.7L16 9h.2a1 1 0 0 0 .8-1.7L13 3l-1.4 1.5",key:"1sj9kv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hae=Z("Trello",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["rect",{width:"3",height:"9",x:"7",y:"7",key:"14n3xi"}],["rect",{width:"3",height:"5",x:"14",y:"7",key:"s4azjd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gS=Z("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mae=Z("TrendingUpDown",[["path",{d:"M14.828 14.828 21 21",key:"ar5fw7"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"m21 3-9 9-4-4-6 6",key:"1h02xo"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yo=Z("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qc=Z("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pae=Z("TriangleRight",[["path",{d:"M22 18a2 2 0 0 1-2 2H3c-1.1 0-1.3-.6-.4-1.3L20.4 4.3c.9-.7 1.6-.4 1.6.7Z",key:"183wce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fae=Z("Triangle",[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vi=Z("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FL=Z("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xae=Z("Turtle",[["path",{d:"m12 10 2 4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a8 8 0 1 0-16 0v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3l2-4h4Z",key:"1lbbv7"}],["path",{d:"M4.82 7.9 8 10",key:"m9wose"}],["path",{d:"M15.18 7.9 12 10",key:"p8dp2u"}],["path",{d:"M16.93 10H20a2 2 0 0 1 0 4H2",key:"12nsm7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gae=Z("TvMinimalPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $k=Z("TvMinimal",[["path",{d:"M7 21h10",key:"1b0cd5"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yae=Z("Tv",[["rect",{width:"20",height:"15",x:"2",y:"7",rx:"2",ry:"2",key:"10ag99"}],["polyline",{points:"17 2 12 7 7 2",key:"11pgbg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vae=Z("Twitch",[["path",{d:"M21 2H3v16h5v4l4-4h5l4-4V2zm-10 9V7m5 4V7",key:"c0yzno"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ae=Z("Twitter",[["path",{d:"M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z",key:"pff0z6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bae=Z("TypeOutline",[["path",{d:"M14 16.5a.5.5 0 0 0 .5.5h.5a2 2 0 0 1 0 4H9a2 2 0 0 1 0-4h.5a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5V8a2 2 0 0 1-4 0V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3a2 2 0 0 1-4 0v-.5a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5Z",key:"1reda3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wae=Z("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jae=Z("UmbrellaOff",[["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"M15.5 21a1.85 1.85 0 0 1-3.5-1v-8H2a10 10 0 0 1 3.428-6.575",key:"eki10q"}],["path",{d:"M17.5 12H22A10 10 0 0 0 9.004 3.455",key:"n2ayka"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nae=Z("Umbrella",[["path",{d:"M22 12a10.06 10.06 1 0 0-20 0Z",key:"1teyop"}],["path",{d:"M12 12v8a2 2 0 0 0 4 0",key:"ulpmoc"}],["path",{d:"M12 2v1",key:"11qlp1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zL=Z("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kae=Z("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sae=Z("UndoDot",[["path",{d:"M21 17a9 9 0 0 0-15-6.7L3 13",key:"8mp6z9"}],["path",{d:"M3 7v6h6",key:"1v2h90"}],["circle",{cx:"12",cy:"17",r:"1",key:"1ixnty"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yS=Z("Undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cae=Z("UnfoldHorizontal",[["path",{d:"M16 12h6",key:"15xry1"}],["path",{d:"M8 12H2",key:"1jqql6"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 15 3-3-3-3",key:"wjy7rq"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mae=Z("UnfoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tae=Z("Ungroup",[["rect",{width:"8",height:"6",x:"5",y:"4",rx:"1",key:"nzclkv"}],["rect",{width:"8",height:"6",x:"11",y:"14",rx:"1",key:"4tytwb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qk=Z("University",[["circle",{cx:"12",cy:"10",r:"1",key:"1gnqs8"}],["path",{d:"M22 20V8h-4l-6-4-6 4H2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"1qj5sn"}],["path",{d:"M6 17v.01",key:"roodi6"}],["path",{d:"M6 13v.01",key:"67c122"}],["path",{d:"M18 17v.01",key:"12ktxm"}],["path",{d:"M18 13v.01",key:"tn1rt1"}],["path",{d:"M14 22v-5a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"11g7fi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aae=Z("Unlink2",[["path",{d:"M15 7h2a5 5 0 0 1 0 10h-2m-6 0H7A5 5 0 0 1 7 7h2",key:"1re2ne"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vS=Z("Unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eae=Z("Unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $a=Z("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pae=Z("Usb",[["circle",{cx:"10",cy:"7",r:"1",key:"dypaad"}],["circle",{cx:"4",cy:"20",r:"1",key:"22iqad"}],["path",{d:"M4.7 19.3 19 5",key:"1enqfc"}],["path",{d:"m21 3-3 1 2 2Z",key:"d3ov82"}],["path",{d:"M9.26 7.68 5 12l2 5",key:"1esawj"}],["path",{d:"m10 14 5 2 3.5-3.5",key:"v8oal5"}],["path",{d:"m18 12 1-1 1 1-1 1Z",key:"1bh22v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tb=Z("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BL=Z("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $L=Z("UserMinus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iae=Z("UserPen",[["path",{d:"M11.5 15H7a4 4 0 0 0-4 4v2",key:"15lzij"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const al=Z("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uk=Z("UserRoundCheck",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vk=Z("UserRoundCog",[["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hk=Z("UserRoundMinus",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 19h-6",key:"vcuq98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lae=Z("UserRoundPen",[["path",{d:"M2 21a8 8 0 0 1 10.821-7.487",key:"1c8h7z"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gk=Z("UserRoundPlus",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M22 19h-6",key:"vcuq98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dae=Z("UserRoundSearch",[["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m22 22-1.9-1.9",key:"1e5ubv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wk=Z("UserRoundX",[["path",{d:"M2 21a8 8 0 0 1 11.873-7",key:"74fkxq"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m17 17 5 5",key:"p7ous7"}],["path",{d:"m22 17-5 5",key:"gqnmv0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kk=Z("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rae=Z("UserSearch",[["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}],["path",{d:"M10.3 15H7a4 4 0 0 0-4 4v2",key:"3bnktk"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oae=Z("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ti=Z("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zk=Z("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lr=Z("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yk=Z("UtensilsCrossed",[["path",{d:"m16 2-2.3 2.3a3 3 0 0 0 0 4.2l1.8 1.8a3 3 0 0 0 4.2 0L22 8",key:"n7qcjb"}],["path",{d:"M15 15 3.3 3.3a4.2 4.2 0 0 0 0 6l7.3 7.3c.7.7 2 .7 2.8 0L15 15Zm0 0 7 7",key:"d0u48b"}],["path",{d:"m2.1 21.8 6.4-6.3",key:"yn04lh"}],["path",{d:"m19 5-7 7",key:"194lzd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xk=Z("Utensils",[["path",{d:"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2",key:"cjf0a3"}],["path",{d:"M7 2v20",key:"1473qp"}],["path",{d:"M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7",key:"j28e5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fae=Z("UtilityPole",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M3 3v2",key:"9imdir"}],["path",{d:"M7 3v2",key:"n0os7"}],["path",{d:"M17 3v2",key:"1l2re6"}],["path",{d:"M21 3v2",key:"1duuac"}],["path",{d:"m19 5-7 7-7-7",key:"133zxf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DM=Z("Variable",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zae=Z("Vault",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["path",{d:"m7.9 7.9 2.7 2.7",key:"hpeyl3"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}],["path",{d:"m13.4 10.6 2.7-2.7",key:"264c1n"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["path",{d:"m7.9 16.1 2.7-2.7",key:"p81g5e"}],["circle",{cx:"16.5",cy:"16.5",r:".5",fill:"currentColor",key:"fubopw"}],["path",{d:"m13.4 13.4 2.7 2.7",key:"abhel3"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bae=Z("Vegan",[["path",{d:"M16 8q6 0 6-6-6 0-6 6",key:"qsyyc4"}],["path",{d:"M17.41 3.59a10 10 0 1 0 3 3",key:"41m9h7"}],["path",{d:"M2 2a26.6 26.6 0 0 1 10 20c.9-6.82 1.5-9.5 4-14",key:"qiv7li"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ae=Z("VenetianMask",[["path",{d:"M18 11c-1.5 0-2.5.5-3 2",key:"1fod00"}],["path",{d:"M4 6a2 2 0 0 0-2 2v4a5 5 0 0 0 5 5 8 8 0 0 1 5 2 8 8 0 0 1 5-2 5 5 0 0 0 5-5V8a2 2 0 0 0-2-2h-3a8 8 0 0 0-5 2 8 8 0 0 0-5-2z",key:"d70hit"}],["path",{d:"M6 11c1.5 0 2.5.5 3 2",key:"136fht"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qae=Z("VibrateOff",[["path",{d:"m2 8 2 2-2 2 2 2-2 2",key:"sv1b1"}],["path",{d:"m22 8-2 2 2 2-2 2 2 2",key:"101i4y"}],["path",{d:"M8 8v10c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2",key:"1hbad5"}],["path",{d:"M16 10.34V6c0-.55-.45-1-1-1h-4.34",key:"1x5tf0"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uae=Z("Vibrate",[["path",{d:"m2 8 2 2-2 2 2 2-2 2",key:"sv1b1"}],["path",{d:"m22 8-2 2 2 2-2 2 2 2",key:"101i4y"}],["rect",{width:"8",height:"14",x:"8",y:"5",rx:"1",key:"1oyrl4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vae=Z("VideoOff",[["path",{d:"M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196",key:"w8jjjt"}],["path",{d:"M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"1xawa7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tn=Z("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hae=Z("Videotape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 8h20",key:"d11cs7"}],["circle",{cx:"8",cy:"14",r:"2",key:"1k2qr5"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"14",r:"2",key:"14k7lr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gae=Z("View",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wae=Z("Voicemail",[["circle",{cx:"6",cy:"12",r:"4",key:"1ehtga"}],["circle",{cx:"18",cy:"12",r:"4",key:"4vafl8"}],["line",{x1:"6",x2:"18",y1:"16",y2:"16",key:"pmt8us"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kae=Z("Volleyball",[["path",{d:"M11.1 7.1a16.55 16.55 0 0 1 10.9 4",key:"2880wi"}],["path",{d:"M12 12a12.6 12.6 0 0 1-8.7 5",key:"113sja"}],["path",{d:"M16.8 13.6a16.55 16.55 0 0 1-9 7.5",key:"1qmsgl"}],["path",{d:"M20.7 17a12.8 12.8 0 0 0-8.7-5 13.3 13.3 0 0 1 0-10",key:"1bmeqp"}],["path",{d:"M6.3 3.8a16.55 16.55 0 0 0 1.9 11.5",key:"iekzv9"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zae=Z("Volume1",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yae=Z("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xae=Z("VolumeOff",[["path",{d:"M16 9a5 5 0 0 1 .95 2.293",key:"1fgyg8"}],["path",{d:"M19.364 5.636a9 9 0 0 1 1.889 9.96",key:"l3zxae"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m7 7-.587.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298V11",key:"1gbwow"}],["path",{d:"M9.828 4.172A.686.686 0 0 1 11 4.657v.686",key:"s2je0y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qae=Z("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jae=Z("Volume",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eie=Z("Vote",[["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}],["path",{d:"M5 7c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v12H5V7Z",key:"1ezoue"}],["path",{d:"M22 19H2",key:"nuriw5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tie=Z("WalletCards",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2",key:"4125el"}],["path",{d:"M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21",key:"1dpki6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qk=Z("WalletMinimal",[["path",{d:"M17 14h.01",key:"7oqj8z"}],["path",{d:"M7 7h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14",key:"u1rqew"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qL=Z("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sie=Z("Wallpaper",[["circle",{cx:"8",cy:"9",r:"2",key:"gjzl9d"}],["path",{d:"m9 17 6.1-6.1a2 2 0 0 1 2.81.01L22 15V5a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"69xh40"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ev=Z("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rie=Z("Wand",[["path",{d:"M15 4V2",key:"z1p9b7"}],["path",{d:"M15 16v-2",key:"px0unx"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M17.8 11.8 19 13",key:"yihg8r"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M17.8 6.2 19 5",key:"fd4us0"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M12.2 6.2 11 5",key:"i3da3b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nie=Z("Warehouse",[["path",{d:"M22 8.35V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8.35A2 2 0 0 1 3.26 6.5l8-3.2a2 2 0 0 1 1.48 0l8 3.2A2 2 0 0 1 22 8.35Z",key:"gksnxg"}],["path",{d:"M6 18h12",key:"9pbo8z"}],["path",{d:"M6 14h12",key:"4cwo0f"}],["rect",{width:"12",height:"12",x:"6",y:"10",key:"apd30q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aie=Z("WashingMachine",[["path",{d:"M3 6h3",key:"155dbl"}],["path",{d:"M17 6h.01",key:"e2y6kg"}],["rect",{width:"18",height:"20",x:"3",y:"2",rx:"2",key:"od3kk9"}],["circle",{cx:"12",cy:"13",r:"5",key:"nlbqau"}],["path",{d:"M12 18a2.5 2.5 0 0 0 0-5 2.5 2.5 0 0 1 0-5",key:"17lach"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iie=Z("Watch",[["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["polyline",{points:"12 10 12 12 13 13",key:"19dquz"}],["path",{d:"m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05",key:"18k57s"}],["path",{d:"m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05",key:"16ny36"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oie=Z("Waves",[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lie=Z("Waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cie=Z("Webcam",[["circle",{cx:"12",cy:"10",r:"8",key:"1gshiw"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 22h10",key:"10w4w3"}],["path",{d:"M12 22v-4",key:"1utk9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const die=Z("WebhookOff",[["path",{d:"M17 17h-5c-1.09-.02-1.94.92-2.5 1.9A3 3 0 1 1 2.57 15",key:"1tvl6x"}],["path",{d:"M9 3.4a4 4 0 0 1 6.52.66",key:"q04jfq"}],["path",{d:"m6 17 3.1-5.8a2.5 2.5 0 0 0 .057-2.05",key:"azowf0"}],["path",{d:"M20.3 20.3a4 4 0 0 1-2.3.7",key:"5joiws"}],["path",{d:"M18.6 13a4 4 0 0 1 3.357 3.414",key:"cangb8"}],["path",{d:"m12 6 .6 1",key:"tpjl1n"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uie=Z("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hie=Z("Weight",[["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}],["path",{d:"M6.5 8a2 2 0 0 0-1.905 1.46L2.1 18.5A2 2 0 0 0 4 21h16a2 2 0 0 0 1.925-2.54L19.4 9.5A2 2 0 0 0 17.48 8Z",key:"56o5sh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mie=Z("WheatOff",[["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"m16 8-1.17 1.17",key:"1qqm82"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"m8 8-.53.53a3.5 3.5 0 0 0 0 4.94L9 15l1.53-1.53c.55-.55.88-1.25.98-1.97",key:"4wz8re"}],["path",{d:"M10.91 5.26c.15-.26.34-.51.56-.73L13 3l1.53 1.53a3.5 3.5 0 0 1 .28 4.62",key:"rves66"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"m16 16-.53.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.49 3.49 0 0 1 1.97-.98",key:"ak46r"}],["path",{d:"M18.74 13.09c.26-.15.51-.34.73-.56L21 11l-1.53-1.53a3.5 3.5 0 0 0-4.62-.28",key:"1tw520"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pie=Z("Wheat",[["path",{d:"M2 22 16 8",key:"60hf96"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"M7.47 8.53 9 7l1.53 1.53a3.5 3.5 0 0 1 0 4.94L9 15l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1sdzmb"}],["path",{d:"M11.47 4.53 13 3l1.53 1.53a3.5 3.5 0 0 1 0 4.94L13 11l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"eoatbi"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"M15.47 13.47 17 15l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"2m8kc5"}],["path",{d:"M19.47 9.47 21 11l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L13 11l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"vex3ng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fie=Z("WholeWord",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xie=Z("WifiHigh",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gie=Z("WifiLow",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yie=Z("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vie=Z("WifiZero",[["path",{d:"M12 20h.01",key:"zekei9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ie=Z("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bie=Z("WindArrowDown",[["path",{d:"M10 2v8",key:"d4bbey"}],["path",{d:"M12.8 21.6A2 2 0 1 0 14 18H2",key:"19kp1d"}],["path",{d:"M17.5 10a2.5 2.5 0 1 1 2 4H2",key:"19kpjc"}],["path",{d:"m6 6 4 4 4-4",key:"k13n16"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wie=Z("Wind",[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jie=Z("WineOff",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h3m7 0h-1.343",key:"v48bem"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M7.307 7.307A12.33 12.33 0 0 0 7 10a5 5 0 0 0 7.391 4.391M8.638 2.981C8.75 2.668 8.872 2.34 9 2h6c1.5 4 2 6 2 8 0 .407-.05.809-.145 1.198",key:"1ymjlu"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nie=Z("Wine",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M12 15a5 5 0 0 0 5-5c0-2-.5-4-2-8H9c-1.5 4-2 6-2 8a5 5 0 0 0 5 5Z",key:"10ffi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kie=Z("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sie=Z("Worm",[["path",{d:"m19 12-1.5 3",key:"9bcu4o"}],["path",{d:"M19.63 18.81 22 20",key:"121v98"}],["path",{d:"M6.47 8.23a1.68 1.68 0 0 1 2.44 1.93l-.64 2.08a6.76 6.76 0 0 0 10.16 7.67l.42-.27a1 1 0 1 0-2.73-4.21l-.42.27a1.76 1.76 0 0 1-2.63-1.99l.64-2.08A6.66 6.66 0 0 0 3.94 3.9l-.7.4a1 1 0 1 0 2.55 4.34z",key:"1tij6q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cie=Z("WrapText",[["line",{x1:"3",x2:"21",y1:"6",y2:"6",key:"4m8b97"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["polyline",{points:"16 16 14 18 16 20",key:"1jznyi"}],["line",{x1:"3",x2:"10",y1:"18",y2:"18",key:"1h33wv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ig=Z("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sr=Z("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mie=Z("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tie=Z("ZapOff",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oh=Z("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ab=Z("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RM=Z("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ngt=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:H9,AArrowUp:G9,ALargeSmall:W9,Accessibility:K9,Activity:ih,AirVent:Z9,Airplay:Y9,AlarmClock:Q9,AlarmClockCheck:U2,AlarmClockMinus:V2,AlarmClockOff:X9,AlarmClockPlus:H2,AlarmSmoke:J9,Album:eB,AlignCenter:B4,AlignCenterHorizontal:tB,AlignCenterVertical:sB,AlignEndHorizontal:rB,AlignEndVertical:nB,AlignHorizontalDistributeCenter:aB,AlignHorizontalDistributeEnd:iB,AlignHorizontalDistributeStart:oB,AlignHorizontalJustifyCenter:lB,AlignHorizontalJustifyEnd:cB,AlignHorizontalJustifyStart:dB,AlignHorizontalSpaceAround:uB,AlignHorizontalSpaceBetween:hB,AlignJustify:mB,AlignLeft:$4,AlignRight:q4,AlignStartHorizontal:pB,AlignStartVertical:fB,AlignVerticalDistributeCenter:xB,AlignVerticalDistributeEnd:gB,AlignVerticalDistributeStart:yB,AlignVerticalJustifyCenter:vB,AlignVerticalJustifyEnd:_B,AlignVerticalJustifyStart:bB,AlignVerticalSpaceAround:wB,AlignVerticalSpaceBetween:jB,Ambulance:NB,Ampersand:kB,Ampersands:SB,Amphora:CB,Anchor:MB,Angry:TB,Annoyed:AB,Antenna:EB,Anvil:PB,Aperture:IB,AppWindow:QI,AppWindowMac:LB,Apple:DB,Archive:pM,ArchiveRestore:JI,ArchiveX:RB,Armchair:OB,ArrowBigDown:zB,ArrowBigDownDash:FB,ArrowBigLeft:$B,ArrowBigLeftDash:BB,ArrowBigRight:UB,ArrowBigRightDash:qB,ArrowBigUp:HB,ArrowBigUpDash:VB,ArrowDown:Ph,ArrowDown01:GB,ArrowDown10:WB,ArrowDownAZ:G2,ArrowDownFromLine:KB,ArrowDownLeft:ZB,ArrowDownNarrowWide:YB,ArrowDownRight:eL,ArrowDownToDot:XB,ArrowDownToLine:QB,ArrowDownUp:JB,ArrowDownWideNarrow:W2,ArrowDownZA:K2,ArrowLeft:Fa,ArrowLeftFromLine:e$,ArrowLeftRight:t$,ArrowLeftToLine:s$,ArrowRight:ei,ArrowRightFromLine:r$,ArrowRightLeft:Hv,ArrowRightToLine:n$,ArrowUp:du,ArrowUp01:a$,ArrowUp10:i$,ArrowUpAZ:Z2,ArrowUpDown:td,ArrowUpFromDot:o$,ArrowUpFromLine:l$,ArrowUpLeft:c$,ArrowUpNarrowWide:Y2,ArrowUpRight:tL,ArrowUpToLine:d$,ArrowUpWideNarrow:u$,ArrowUpZA:X2,ArrowsUpFromLine:h$,Asterisk:m$,AtSign:p$,Atom:f$,AudioLines:x$,AudioWaveform:g$,Award:ec,Axe:y$,Axis3d:Q2,Baby:v$,Backpack:_$,Badge:R$,BadgeAlert:b$,BadgeCent:w$,BadgeCheck:J2,BadgeDollarSign:j$,BadgeEuro:N$,BadgeHelp:k$,BadgeIndianRupee:S$,BadgeInfo:C$,BadgeJapaneseYen:M$,BadgeMinus:T$,BadgePercent:A$,BadgePlus:E$,BadgePoundSterling:P$,BadgeRussianRuble:I$,BadgeSwissFranc:L$,BadgeX:D$,BaggageClaim:O$,Ban:sL,Banana:F$,Bandage:z$,Banknote:B$,Barcode:$$,Baseline:q$,Bath:rf,Battery:K$,BatteryCharging:U$,BatteryFull:V$,BatteryLow:H$,BatteryMedium:G$,BatteryWarning:W$,Beaker:Z$,Bean:X$,BeanOff:Y$,Bed:Wy,BedDouble:U4,BedSingle:Q$,Beef:J$,Beer:tq,BeerOff:eq,Bell:Sm,BellDot:sq,BellElectric:rq,BellMinus:nq,BellOff:Gv,BellPlus:aq,BellRing:iq,BetweenHorizontalEnd:ej,BetweenHorizontalStart:tj,BetweenVerticalEnd:oq,BetweenVerticalStart:lq,BicepsFlexed:cq,Bike:dq,Binary:uq,Binoculars:hq,Biohazard:mq,Bird:pq,Bitcoin:fq,Blend:xq,Blinds:gq,Blocks:yq,Bluetooth:wq,BluetoothConnected:vq,BluetoothOff:_q,BluetoothSearching:bq,Bold:V4,Bolt:jq,Bomb:Nq,Bone:kq,Book:Wq,BookA:Sq,BookAudio:Cq,BookCheck:Mq,BookCopy:Tq,BookDashed:sj,BookDown:Aq,BookHeadphones:Eq,BookHeart:Pq,BookImage:Iq,BookKey:Lq,BookLock:Dq,BookMarked:Rq,BookMinus:Oq,BookOpen:oh,BookOpenCheck:Fq,BookOpenText:zq,BookPlus:Bq,BookText:$q,BookType:qq,BookUp:Vq,BookUp2:Uq,BookUser:Hq,BookX:Gq,Bookmark:fx,BookmarkCheck:Kq,BookmarkMinus:Zq,BookmarkPlus:rL,BookmarkX:Yq,BoomBox:Xq,Bot:fM,BotMessageSquare:Qq,BotOff:Jq,Box:eU,Boxes:tU,Braces:rj,Brackets:sU,Brain:nL,BrainCircuit:rU,BrainCog:nU,BrickWall:aU,Briefcase:Ih,BriefcaseBusiness:iU,BriefcaseConveyorBelt:oU,BriefcaseMedical:lU,BringToFront:cU,Brush:dU,Bug:mU,BugOff:uU,BugPlay:hU,Building:H4,Building2:pa,Bus:fU,BusFront:pU,Cable:gU,CableCar:xU,Cake:lh,CakeSlice:yU,Calculator:xM,Calendar:on,Calendar1:vU,CalendarArrowDown:_U,CalendarArrowUp:bU,CalendarCheck:aL,CalendarCheck2:wU,CalendarClock:gM,CalendarCog:jU,CalendarDays:xd,CalendarFold:NU,CalendarHeart:kU,CalendarMinus:CU,CalendarMinus2:SU,CalendarOff:iL,CalendarPlus:bb,CalendarPlus2:MU,CalendarRange:TU,CalendarSearch:AU,CalendarSync:EU,CalendarX:IU,CalendarX2:PU,Camera:xx,CameraOff:LU,Candy:OU,CandyCane:DU,CandyOff:RU,Cannabis:FU,Captions:nj,CaptionsOff:zU,Car:qU,CarFront:BU,CarTaxiFront:$U,Caravan:UU,Carrot:VU,CaseLower:HU,CaseSensitive:GU,CaseUpper:WU,CassetteTape:KU,Cast:ZU,Castle:YU,Cat:XU,Cctv:QU,ChartArea:aj,ChartBar:oj,ChartBarBig:ij,ChartBarDecreasing:JU,ChartBarIncreasing:eV,ChartBarStacked:tV,ChartCandlestick:lj,ChartColumn:to,ChartColumnBig:cj,ChartColumnDecreasing:sV,ChartColumnIncreasing:dj,ChartColumnStacked:rV,ChartGantt:nV,ChartLine:uj,ChartNetwork:aV,ChartNoAxesColumn:mj,ChartNoAxesColumnDecreasing:iV,ChartNoAxesColumnIncreasing:hj,ChartNoAxesCombined:oV,ChartNoAxesGantt:pj,ChartPie:fj,ChartScatter:xj,ChartSpline:lV,Check:Jn,CheckCheck:oL,ChefHat:cV,Cherry:dV,ChevronDown:Oi,ChevronFirst:uV,ChevronLast:hV,ChevronLeft:xl,ChevronRight:Sa,ChevronUp:nf,ChevronsDown:pV,ChevronsDownUp:mV,ChevronsLeft:gV,ChevronsLeftRight:xV,ChevronsLeftRightEllipsis:fV,ChevronsRight:vV,ChevronsRightLeft:yV,ChevronsUp:_V,ChevronsUpDown:gx,Chrome:bV,Church:wV,Cigarette:NV,CigaretteOff:jV,Circle:sd,CircleAlert:Lo,CircleArrowDown:gj,CircleArrowLeft:yj,CircleArrowOutDownLeft:vj,CircleArrowOutDownRight:_j,CircleArrowOutUpLeft:bj,CircleArrowOutUpRight:wj,CircleArrowRight:jj,CircleArrowUp:Nj,CircleCheck:Qn,CircleCheckBig:ti,CircleChevronDown:kj,CircleChevronLeft:Sj,CircleChevronRight:Cj,CircleChevronUp:Mj,CircleDashed:kV,CircleDivide:Tj,CircleDollarSign:SV,CircleDot:MV,CircleDotDashed:CV,CircleEllipsis:TV,CircleEqual:AV,CircleFadingArrowUp:EV,CircleFadingPlus:PV,CircleGauge:Aj,CircleHelp:Sv,CircleMinus:Ej,CircleOff:IV,CircleParking:Ij,CircleParkingOff:Pj,CirclePause:Lj,CirclePercent:Dj,CirclePlay:sp,CirclePlus:Rj,CirclePower:Oj,CircleSlash:LV,CircleSlash2:Fj,CircleStop:zj,CircleUser:$j,CircleUserRound:Bj,CircleX:Zl,CircuitBoard:DV,Citrus:RV,Clapperboard:OV,Clipboard:VV,ClipboardCheck:yM,ClipboardCopy:FV,ClipboardList:wb,ClipboardMinus:zV,ClipboardPaste:BV,ClipboardPen:Uj,ClipboardPenLine:qj,ClipboardPlus:$V,ClipboardType:qV,ClipboardX:UV,Clock:ln,Clock1:HV,Clock10:GV,Clock11:WV,Clock12:KV,Clock2:ZV,Clock3:YV,Clock4:XV,Clock5:QV,Clock6:JV,Clock7:eH,Clock8:tH,Clock9:sH,ClockAlert:rH,ClockArrowDown:nH,ClockArrowUp:aH,Cloud:_H,CloudAlert:iH,CloudCog:oH,CloudDownload:Vj,CloudDrizzle:lH,CloudFog:cH,CloudHail:dH,CloudLightning:uH,CloudMoon:mH,CloudMoonRain:hH,CloudOff:pH,CloudRain:xH,CloudRainWind:fH,CloudSnow:gH,CloudSun:vH,CloudSunRain:yH,CloudUpload:Hj,Cloudy:bH,Clover:Fv,Club:wH,Code:G4,CodeXml:Gj,Codepen:jH,Codesandbox:NH,Coffee:W4,Cog:kH,Coins:lL,Columns2:Wj,Columns3:Kj,Columns4:SH,Combine:CH,Command:MH,Compass:vM,Component:TH,Computer:AH,ConciergeBell:EH,Cone:PH,Construction:IH,Contact:K4,ContactRound:Zj,Container:LH,Contrast:DH,Cookie:RH,CookingPot:OH,Copy:Ya,CopyCheck:FH,CopyMinus:zH,CopyPlus:BH,CopySlash:$H,CopyX:qH,Copyleft:UH,Copyright:VH,CornerDownLeft:HH,CornerDownRight:GH,CornerLeftDown:WH,CornerLeftUp:KH,CornerRightDown:ZH,CornerRightUp:YH,CornerUpLeft:XH,CornerUpRight:QH,Cpu:JH,CreativeCommons:eG,CreditCard:yx,Croissant:tG,Crop:sG,Cross:rG,Crosshair:nG,Crown:Cm,Cuboid:aG,CupSoda:iG,Currency:oG,Cylinder:lG,Dam:cG,Database:cL,DatabaseBackup:dG,DatabaseZap:uG,Delete:hG,Dessert:mG,Diameter:pG,Diamond:gG,DiamondMinus:fG,DiamondPercent:Yj,DiamondPlus:xG,Dice1:yG,Dice2:vG,Dice3:_G,Dice4:bG,Dice5:wG,Dice6:jG,Dices:NG,Diff:kG,Disc:TG,Disc2:SG,Disc3:CG,DiscAlbum:MG,Divide:AG,Dna:PG,DnaOff:EG,Dock:IG,Dog:LG,DollarSign:yc,Donut:DG,DoorClosed:RG,DoorOpen:Wv,Dot:OG,Download:Xa,DraftingCompass:FG,Drama:zG,Dribbble:BG,Drill:$G,Droplet:qG,Droplets:Ag,Drum:UG,Drumstick:VG,Dumbbell:HG,Ear:WG,EarOff:GG,Earth:Xj,EarthLock:KG,Eclipse:ZG,Egg:_M,EggFried:YG,EggOff:XG,Ellipsis:ix,EllipsisVertical:ax,Equal:eW,EqualApproximately:QG,EqualNot:JG,Eraser:tW,EthernetPort:sW,Euro:rW,Expand:nW,ExternalLink:Kr,Eye:wn,EyeClosed:aW,EyeOff:mp,Facebook:uu,Factory:iW,Fan:oW,FastForward:lW,Feather:cW,Fence:dW,FerrisWheel:uW,Figma:hW,File:bM,FileArchive:mW,FileAudio:fW,FileAudio2:pW,FileAxis3d:Qj,FileBadge:gW,FileBadge2:xW,FileBox:yW,FileChartColumn:eN,FileChartColumnIncreasing:Jj,FileChartLine:tN,FileChartPie:sN,FileCheck:_W,FileCheck2:vW,FileClock:bW,FileCode:jW,FileCode2:wW,FileCog:rN,FileDiff:NW,FileDigit:kW,FileDown:Z4,FileHeart:SW,FileImage:jb,FileInput:CW,FileJson:TW,FileJson2:MW,FileKey:EW,FileKey2:AW,FileLock:IW,FileLock2:PW,FileMinus:DW,FileMinus2:LW,FileMusic:RW,FileOutput:OW,FilePen:aN,FilePenLine:nN,FilePlus:zW,FilePlus2:FW,FileQuestion:BW,FileScan:$W,FileSearch:UW,FileSearch2:qW,FileSliders:VW,FileSpreadsheet:Kv,FileStack:dL,FileSymlink:HW,FileTerminal:GW,FileText:fn,FileType:KW,FileType2:WW,FileUp:ZW,FileUser:YW,FileVideo:QW,FileVideo2:XW,FileVolume:eK,FileVolume2:JW,FileWarning:tK,FileX:rK,FileX2:sK,Files:nK,Film:tu,Filter:Eg,FilterX:aK,Fingerprint:iK,FireExtinguisher:oK,Fish:dK,FishOff:lK,FishSymbol:cK,Flag:Zv,FlagOff:uK,FlagTriangleLeft:hK,FlagTriangleRight:mK,Flame:ch,FlameKindling:pK,Flashlight:xK,FlashlightOff:fK,FlaskConical:Nb,FlaskConicalOff:gK,FlaskRound:yK,FlipHorizontal:uL,FlipHorizontal2:vK,FlipVertical:bK,FlipVertical2:_K,Flower:wK,Flower2:kg,Focus:jK,FoldHorizontal:NK,FoldVertical:kK,Folder:QK,FolderArchive:SK,FolderCheck:CK,FolderClock:MK,FolderClosed:TK,FolderCode:AK,FolderCog:iN,FolderDot:EK,FolderDown:PK,FolderGit:LK,FolderGit2:IK,FolderHeart:DK,FolderInput:RK,FolderKanban:OK,FolderKey:FK,FolderLock:zK,FolderMinus:BK,FolderOpen:Mm,FolderOpenDot:$K,FolderOutput:qK,FolderPen:oN,FolderPlus:UK,FolderRoot:VK,FolderSearch:GK,FolderSearch2:HK,FolderSymlink:WK,FolderSync:KK,FolderTree:ZK,FolderUp:YK,FolderX:XK,Folders:JK,Footprints:eZ,Forklift:tZ,Forward:sZ,Frame:rZ,Framer:nZ,Frown:aZ,Fuel:iZ,Fullscreen:oZ,GalleryHorizontal:cZ,GalleryHorizontalEnd:lZ,GalleryThumbnails:dZ,GalleryVertical:hZ,GalleryVerticalEnd:uZ,Gamepad:pZ,Gamepad2:mZ,Gauge:fZ,Gavel:xZ,Gem:gZ,Ghost:Y4,Gift:Ui,GitBranch:vZ,GitBranchPlus:yZ,GitCommitHorizontal:lN,GitCommitVertical:_Z,GitCompare:wZ,GitCompareArrows:bZ,GitFork:jZ,GitGraph:NZ,GitMerge:kZ,GitPullRequest:EZ,GitPullRequestArrow:SZ,GitPullRequestClosed:CZ,GitPullRequestCreate:TZ,GitPullRequestCreateArrow:MZ,GitPullRequestDraft:AZ,Github:PZ,Gitlab:IZ,GlassWater:LZ,Glasses:DZ,Globe:gd,GlobeLock:RZ,Goal:OZ,Grab:FZ,GraduationCap:Lh,Grape:zZ,Grid2x2:dN,Grid2x2Check:BZ,Grid2x2Plus:cN,Grid2x2X:$Z,Grid3x3:Yf,Grip:UZ,GripHorizontal:qZ,GripVertical:hu,Group:VZ,Guitar:HZ,Ham:GZ,Hammer:WZ,Hand:hL,HandCoins:KZ,HandHeart:ZZ,HandHelping:uN,HandMetal:YZ,HandPlatter:XZ,Handshake:mL,HardDrive:pL,HardDriveDownload:QZ,HardDriveUpload:JZ,HardHat:eY,Hash:X4,Haze:tY,HdmiPort:sY,Heading:iY,Heading1:wM,Heading2:jM,Heading3:fL,Heading4:rY,Heading5:nY,Heading6:aY,HeadphoneOff:oY,Headphones:lY,Headset:cY,Heart:Za,HeartCrack:dY,HeartHandshake:uY,HeartOff:hY,HeartPulse:mY,Heater:pY,Hexagon:fY,Highlighter:xY,History:NM,Hop:yY,HopOff:gY,Hospital:vY,Hotel:_Y,Hourglass:bY,House:Mn,HousePlug:wY,HousePlus:jY,IceCreamBowl:hN,IceCreamCone:mN,IdCard:NY,Image:Wo,ImageDown:kY,ImageMinus:SY,ImageOff:CY,ImagePlay:MY,ImagePlus:Yv,ImageUp:TY,ImageUpscale:AY,Images:EY,Import:PY,Inbox:IY,IndentDecrease:pN,IndentIncrease:fN,IndianRupee:LY,Infinity:DY,Info:Q4,InspectionPanel:RY,Instagram:mu,Italic:J4,IterationCcw:OY,IterationCw:FY,JapaneseYen:zY,Joystick:BY,Kanban:Ky,Key:pp,KeyRound:eS,KeySquare:$Y,Keyboard:VY,KeyboardMusic:qY,KeyboardOff:UY,Lamp:YY,LampCeiling:HY,LampDesk:GY,LampFloor:WY,LampWallDown:KY,LampWallUp:ZY,LandPlot:XY,Landmark:QY,Languages:JY,Laptop:tX,LaptopMinimal:xN,LaptopMinimalCheck:eX,Lasso:rX,LassoSelect:sX,Laugh:nX,Layers:oX,Layers2:aX,Layers3:iX,LayoutDashboard:tS,LayoutGrid:fp,LayoutList:lX,LayoutPanelLeft:cX,LayoutPanelTop:dX,LayoutTemplate:sS,Leaf:uX,LeafyGreen:hX,Lectern:mX,LetterText:pX,Library:kM,LibraryBig:fX,LifeBuoy:SM,Ligature:xX,Lightbulb:kb,LightbulbOff:gX,Link:fo,Link2:Do,Link2Off:yX,Linkedin:xp,List:Dh,ListCheck:vX,ListChecks:_X,ListCollapse:bX,ListEnd:wX,ListFilter:jX,ListMinus:NX,ListMusic:kX,ListOrdered:Zy,ListPlus:SX,ListRestart:CX,ListStart:MX,ListTodo:TX,ListTree:AX,ListVideo:EX,ListX:PX,Loader:LX,LoaderCircle:_s,LoaderPinwheel:IX,Locate:CM,LocateFixed:DX,LocateOff:RX,Lock:yd,LockKeyhole:OX,LockKeyholeOpen:gN,LockOpen:yN,LogIn:rS,LogOut:MM,Logs:FX,Lollipop:zX,Luggage:BX,Magnet:$X,Mail:rr,MailCheck:qX,MailMinus:UX,MailOpen:VX,MailPlus:xL,MailQuestion:HX,MailSearch:GX,MailWarning:WX,MailX:gL,Mailbox:KX,Mails:ZX,Map:nS,MapPin:Da,MapPinCheck:XX,MapPinCheckInside:YX,MapPinHouse:QX,MapPinMinus:eQ,MapPinMinusInside:JX,MapPinOff:tQ,MapPinPlus:rQ,MapPinPlusInside:sQ,MapPinX:aQ,MapPinXInside:nQ,MapPinned:iQ,Martini:oQ,Maximize:yL,Maximize2:lQ,Medal:Xv,Megaphone:dh,MegaphoneOff:cQ,Meh:dQ,MemoryStick:uQ,Menu:aS,Merge:hQ,MessageCircle:vc,MessageCircleCode:mQ,MessageCircleDashed:pQ,MessageCircleHeart:TM,MessageCircleMore:fQ,MessageCircleOff:xQ,MessageCirclePlus:gQ,MessageCircleQuestion:vL,MessageCircleReply:yQ,MessageCircleWarning:vQ,MessageCircleX:_Q,MessageSquare:ki,MessageSquareCode:bQ,MessageSquareDashed:wQ,MessageSquareDiff:jQ,MessageSquareDot:NQ,MessageSquareHeart:kQ,MessageSquareLock:SQ,MessageSquareMore:_L,MessageSquareOff:CQ,MessageSquarePlus:AM,MessageSquareQuote:bL,MessageSquareReply:MQ,MessageSquareShare:TQ,MessageSquareText:AQ,MessageSquareWarning:EQ,MessageSquareX:PQ,MessagesSquare:IQ,Mic:wL,MicOff:LQ,MicVocal:vN,Microchip:DQ,Microscope:RQ,Microwave:OQ,Milestone:FQ,Milk:BQ,MilkOff:zQ,Minimize:qQ,Minimize2:$Q,Minus:Yy,Monitor:oS,MonitorCheck:UQ,MonitorCog:VQ,MonitorDot:HQ,MonitorDown:GQ,MonitorOff:WQ,MonitorPause:KQ,MonitorPlay:ZQ,MonitorSmartphone:YQ,MonitorSpeaker:XQ,MonitorStop:QQ,MonitorUp:iS,MonitorX:JQ,Moon:tJ,MoonStar:eJ,Mountain:rJ,MountainSnow:sJ,Mouse:oJ,MouseOff:nJ,MousePointer:nu,MousePointer2:aJ,MousePointerBan:iJ,MousePointerClick:Tm,Move:_J,Move3d:_N,MoveDiagonal:cJ,MoveDiagonal2:lJ,MoveDown:hJ,MoveDownLeft:dJ,MoveDownRight:uJ,MoveHorizontal:mJ,MoveLeft:pJ,MoveRight:fJ,MoveUp:yJ,MoveUpLeft:xJ,MoveUpRight:gJ,MoveVertical:vJ,Music:NJ,Music2:bJ,Music3:wJ,Music4:jJ,Navigation:jL,Navigation2:SJ,Navigation2Off:kJ,NavigationOff:CJ,Network:MJ,Newspaper:Qv,Nfc:TJ,Notebook:IJ,NotebookPen:AJ,NotebookTabs:EJ,NotebookText:PJ,NotepadText:DJ,NotepadTextDashed:LJ,Nut:OJ,NutOff:RJ,Octagon:zJ,OctagonAlert:Cv,OctagonMinus:FJ,OctagonPause:bN,OctagonX:wN,Omega:BJ,Option:$J,Orbit:qJ,Origami:UJ,Package:nl,Package2:VJ,PackageCheck:HJ,PackageMinus:GJ,PackageOpen:WJ,PackagePlus:KJ,PackageSearch:ZJ,PackageX:YJ,PaintBucket:XJ,PaintRoller:QJ,Paintbrush:JJ,PaintbrushVertical:jN,Palette:Dl,PanelBottom:see,PanelBottomClose:eee,PanelBottomDashed:NN,PanelBottomOpen:tee,PanelLeft:MN,PanelLeftClose:kN,PanelLeftDashed:SN,PanelLeftOpen:CN,PanelRight:aee,PanelRightClose:ree,PanelRightDashed:TN,PanelRightOpen:nee,PanelTop:lee,PanelTopClose:iee,PanelTopDashed:AN,PanelTopOpen:oee,PanelsLeftBottom:cee,PanelsRightBottom:dee,PanelsTopLeft:Mv,Paperclip:lS,Parentheses:uee,ParkingMeter:hee,PartyPopper:Bd,Pause:uh,PawPrint:mee,PcCase:pee,Pen:Dy,PenLine:Tv,PenOff:fee,PenTool:Sb,Pencil:ga,PencilLine:xee,PencilOff:gee,PencilRuler:yee,Pentagon:vee,Percent:EM,PersonStanding:_ee,PhilippinePeso:bee,Phone:Pn,PhoneCall:wee,PhoneForwarded:jee,PhoneIncoming:Nee,PhoneMissed:kee,PhoneOff:See,PhoneOutgoing:Cee,Pi:Mee,Piano:Tee,Pickaxe:Aee,PictureInPicture:Pee,PictureInPicture2:Eee,PiggyBank:Iee,Pilcrow:Ree,PilcrowLeft:Lee,PilcrowRight:Dee,Pill:Fee,PillBottle:Oee,Pin:Cb,PinOff:NL,Pipette:zee,Pizza:Bee,Plane:Uee,PlaneLanding:$ee,PlaneTakeoff:qee,Play:So,Plug:kL,Plug2:Vee,PlugZap:EN,Plus:Us,Pocket:Gee,PocketKnife:Hee,Podcast:Wee,Pointer:Zee,PointerOff:Kee,Popcorn:Yee,Popsicle:Xee,PoundSterling:Qee,Power:SL,PowerOff:Jee,Presentation:Pg,Printer:CL,PrinterCheck:ete,Projector:tte,Proportions:ste,Puzzle:rte,Pyramid:nte,QrCode:Xy,Quote:cS,Rabbit:ate,Radar:ite,Radiation:ote,Radical:lte,Radio:Jv,RadioReceiver:cte,RadioTower:dte,Radius:ute,RailSymbol:hte,Rainbow:mte,Rat:pte,Ratio:fte,Receipt:Nte,ReceiptCent:xte,ReceiptEuro:gte,ReceiptIndianRupee:yte,ReceiptJapaneseYen:vte,ReceiptPoundSterling:_te,ReceiptRussianRuble:bte,ReceiptSwissFranc:wte,ReceiptText:jte,RectangleEllipsis:PN,RectangleHorizontal:kte,RectangleVertical:Ste,Recycle:Cte,Redo:dS,Redo2:Mte,RedoDot:Tte,RefreshCcw:PM,RefreshCcwDot:Ate,RefreshCw:oo,RefreshCwOff:Ete,Refrigerator:Pte,Regex:Ite,RemoveFormatting:Lte,Repeat:ML,Repeat1:Dte,Repeat2:Rte,Replace:Fte,ReplaceAll:Ote,Reply:TL,ReplyAll:zte,Rewind:Bte,Ribbon:$te,Rocket:Qy,RockingChair:qte,RollerCoaster:Ute,Rotate3d:IN,RotateCcw:Jy,RotateCcwSquare:Vte,RotateCw:AL,RotateCwSquare:Hte,Route:Wte,RouteOff:Gte,Router:Kte,Rows2:LN,Rows3:DN,Rows4:Zte,Rss:Yte,Ruler:uS,RussianRuble:Xte,Sailboat:Qte,Salad:Jte,Sandwich:ese,Satellite:sse,SatelliteDish:tse,Save:_c,SaveAll:rse,SaveOff:nse,Scale:EL,Scale3d:RN,Scaling:ase,Scan:mse,ScanBarcode:ise,ScanEye:ose,ScanFace:lse,ScanLine:cse,ScanQrCode:dse,ScanSearch:use,ScanText:hse,School:pse,Scissors:xse,ScissorsLineDashed:fse,ScreenShare:yse,ScreenShareOff:gse,Scroll:_se,ScrollText:vse,Search:an,SearchCheck:bse,SearchCode:wse,SearchSlash:jse,SearchX:PL,Section:Nse,Send:An,SendHorizontal:ON,SendToBack:kse,SeparatorHorizontal:Sse,SeparatorVertical:Cse,Server:Ese,ServerCog:Mse,ServerCrash:Tse,ServerOff:Ase,Settings:ko,Settings2:IL,Shapes:Pse,Share:LL,Share2:vd,Sheet:Ise,Shell:Lse,Shield:Ou,ShieldAlert:Dse,ShieldBan:Rse,ShieldCheck:hS,ShieldEllipsis:Ose,ShieldHalf:Fse,ShieldMinus:zse,ShieldOff:mS,ShieldPlus:Bse,ShieldQuestion:$se,ShieldX:FN,Ship:Use,ShipWheel:qse,Shirt:Vse,ShoppingBag:e0,ShoppingBasket:Hse,ShoppingCart:op,Shovel:Gse,ShowerHead:Wse,Shrink:Kse,Shrub:Zse,Shuffle:pS,Sigma:Yse,Signal:tre,SignalHigh:Xse,SignalLow:Qse,SignalMedium:Jse,SignalZero:ere,Signature:sre,Signpost:nre,SignpostBig:rre,Siren:are,SkipBack:ire,SkipForward:ore,Skull:lre,Slack:cre,Slash:dre,Slice:ure,SlidersHorizontal:fS,SlidersVertical:zN,Smartphone:t0,SmartphoneCharging:hre,SmartphoneNfc:mre,Smile:fre,SmilePlus:pre,Snail:xre,Snowflake:zv,Sofa:gre,Soup:yre,Space:vre,Spade:_re,Sparkle:bre,Sparkles:$r,Speaker:wre,Speech:jre,SpellCheck:kre,SpellCheck2:Nre,Spline:Sre,Split:Cre,SprayCan:Mre,Sprout:xS,Square:s0,SquareActivity:BN,SquareArrowDown:UN,SquareArrowDownLeft:$N,SquareArrowDownRight:qN,SquareArrowLeft:VN,SquareArrowOutDownLeft:HN,SquareArrowOutDownRight:GN,SquareArrowOutUpLeft:WN,SquareArrowOutUpRight:KN,SquareArrowRight:ZN,SquareArrowUp:QN,SquareArrowUpLeft:YN,SquareArrowUpRight:XN,SquareAsterisk:JN,SquareBottomDashedScissors:ek,SquareChartGantt:Ny,SquareCheck:tk,SquareCheckBig:Av,SquareChevronDown:sk,SquareChevronLeft:rk,SquareChevronRight:nk,SquareChevronUp:ak,SquareCode:ik,SquareDashed:ck,SquareDashedBottom:Are,SquareDashedBottomCode:Tre,SquareDashedKanban:ok,SquareDashedMousePointer:lk,SquareDivide:dk,SquareDot:uk,SquareEqual:hk,SquareFunction:mk,SquareKanban:pk,SquareLibrary:fk,SquareM:xk,SquareMenu:gk,SquareMinus:yk,SquareMousePointer:vk,SquareParking:bk,SquareParkingOff:_k,SquarePen:Gc,SquarePercent:wk,SquarePi:jk,SquarePilcrow:Nk,SquarePlay:kk,SquarePlus:Sk,SquarePower:Ck,SquareRadical:Ere,SquareScissors:Mk,SquareSigma:Tk,SquareSlash:Ak,SquareSplitHorizontal:Ek,SquareSplitVertical:Pk,SquareSquare:Pre,SquareStack:Ire,SquareTerminal:Ik,SquareUser:Dk,SquareUserRound:Lk,SquareX:Rk,Squircle:Lre,Squirrel:Dre,Stamp:Rre,Star:Hn,StarHalf:Ore,StarOff:Fre,StepBack:zre,StepForward:Bre,Stethoscope:$re,Sticker:qre,StickyNote:Ure,Store:Vre,StretchHorizontal:Hre,StretchVertical:Gre,Strikethrough:DL,Subscript:Wre,Sun:e1,SunDim:Kre,SunMedium:Zre,SunMoon:Yre,SunSnow:Xre,Sunrise:Qre,Sunset:Jre,Superscript:ene,SwatchBook:tne,SwissFranc:sne,SwitchCamera:rne,Sword:nne,Swords:ane,Syringe:ine,Table:LM,Table2:IM,TableCellsMerge:one,TableCellsSplit:lne,TableColumnsSplit:cne,TableOfContents:dne,TableProperties:une,TableRowsSplit:hne,Tablet:pne,TabletSmartphone:mne,Tablets:fne,Tag:hh,Tags:xne,Tally1:gne,Tally2:yne,Tally3:vne,Tally4:_ne,Tally5:bne,Tangent:wne,Target:Rh,Telescope:jne,Tent:kne,TentTree:Nne,Terminal:Sne,TestTube:Cne,TestTubeDiagonal:Ok,TestTubes:Mne,Text:Ine,TextCursor:Ane,TextCursorInput:Tne,TextQuote:Ene,TextSearch:Pne,TextSelect:Fk,Theater:Lne,Thermometer:One,ThermometerSnowflake:Dne,ThermometerSun:Rne,ThumbsDown:RL,ThumbsUp:Fu,Ticket:OL,TicketCheck:Fne,TicketMinus:zne,TicketPercent:Bne,TicketPlus:$ne,TicketSlash:qne,TicketX:Une,Tickets:Hne,TicketsPlane:Vne,Timer:Kne,TimerOff:Gne,TimerReset:Wne,ToggleLeft:Zne,ToggleRight:Yne,Toilet:Xne,Tornado:Qne,Torus:Jne,Touchpad:tae,TouchpadOff:eae,TowerControl:sae,ToyBrick:rae,Tractor:nae,TrafficCone:aae,TrainFront:oae,TrainFrontTunnel:iae,TrainTrack:lae,TramFront:zk,Trash:cae,Trash2:gr,TreeDeciduous:dae,TreePalm:Bk,TreePine:Mb,Trees:uae,Trello:hae,TrendingDown:gS,TrendingUp:Yo,TrendingUpDown:mae,Triangle:fae,TriangleAlert:Qc,TriangleRight:pae,Trophy:Vi,Truck:FL,Turtle:xae,Tv:yae,TvMinimal:$k,TvMinimalPlay:gae,Twitch:vae,Twitter:_ae,Type:wae,TypeOutline:bae,Umbrella:Nae,UmbrellaOff:jae,Underline:zL,Undo:yS,Undo2:kae,UndoDot:Sae,UnfoldHorizontal:Cae,UnfoldVertical:Mae,Ungroup:Tae,University:qk,Unlink:vS,Unlink2:Aae,Unplug:Eae,Upload:$a,Usb:Pae,User:Ti,UserCheck:Tb,UserCog:BL,UserMinus:$L,UserPen:Iae,UserPlus:al,UserRound:Kk,UserRoundCheck:Uk,UserRoundCog:Vk,UserRoundMinus:Hk,UserRoundPen:Lae,UserRoundPlus:Gk,UserRoundSearch:Dae,UserRoundX:Wk,UserSearch:Rae,UserX:Oae,Users:lr,UsersRound:Zk,Utensils:Xk,UtensilsCrossed:Yk,UtilityPole:Fae,Variable:DM,Vault:zae,Vegan:Bae,VenetianMask:$ae,Vibrate:Uae,VibrateOff:qae,Video:Tn,VideoOff:Vae,Videotape:Hae,View:Gae,Voicemail:Wae,Volleyball:Kae,Volume:Jae,Volume1:Zae,Volume2:Yae,VolumeOff:Xae,VolumeX:Qae,Vote:eie,Wallet:qL,WalletCards:tie,WalletMinimal:Qk,Wallpaper:sie,Wand:rie,WandSparkles:Ev,Warehouse:nie,WashingMachine:aie,Watch:iie,Waves:oie,Waypoints:lie,Webcam:cie,Webhook:uie,WebhookOff:die,Weight:hie,Wheat:pie,WheatOff:mie,WholeWord:fie,Wifi:_ie,WifiHigh:xie,WifiLow:gie,WifiOff:yie,WifiZero:vie,Wind:wie,WindArrowDown:bie,Wine:Nie,WineOff:jie,Workflow:kie,Worm:Sie,WrapText:Cie,Wrench:Ig,X:Sr,Youtube:Mie,Zap:Oh,ZapOff:Tie,ZoomIn:Ab,ZoomOut:RM},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 sje=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:H9,AArrowDownIcon:H9,AArrowUp:G9,AArrowUpIcon:G9,ALargeSmall:W9,ALargeSmallIcon:W9,Accessibility:K9,AccessibilityIcon:K9,Activity:ih,ActivityIcon:ih,ActivitySquare:BN,ActivitySquareIcon:BN,AirVent:Z9,AirVentIcon:Z9,Airplay:Y9,AirplayIcon:Y9,AlarmCheck:U2,AlarmCheckIcon:U2,AlarmClock:Q9,AlarmClockCheck:U2,AlarmClockCheckIcon:U2,AlarmClockIcon:Q9,AlarmClockMinus:V2,AlarmClockMinusIcon:V2,AlarmClockOff:X9,AlarmClockOffIcon:X9,AlarmClockPlus:H2,AlarmClockPlusIcon:H2,AlarmMinus:V2,AlarmMinusIcon:V2,AlarmPlus:H2,AlarmPlusIcon:H2,AlarmSmoke:J9,AlarmSmokeIcon:J9,Album:eB,AlbumIcon:eB,AlertCircle:Lo,AlertCircleIcon:Lo,AlertOctagon:Cv,AlertOctagonIcon:Cv,AlertTriangle:Qc,AlertTriangleIcon:Qc,AlignCenter:B4,AlignCenterHorizontal:tB,AlignCenterHorizontalIcon:tB,AlignCenterIcon:B4,AlignCenterVertical:sB,AlignCenterVerticalIcon:sB,AlignEndHorizontal:rB,AlignEndHorizontalIcon:rB,AlignEndVertical:nB,AlignEndVerticalIcon:nB,AlignHorizontalDistributeCenter:aB,AlignHorizontalDistributeCenterIcon:aB,AlignHorizontalDistributeEnd:iB,AlignHorizontalDistributeEndIcon:iB,AlignHorizontalDistributeStart:oB,AlignHorizontalDistributeStartIcon:oB,AlignHorizontalJustifyCenter:lB,AlignHorizontalJustifyCenterIcon:lB,AlignHorizontalJustifyEnd:cB,AlignHorizontalJustifyEndIcon:cB,AlignHorizontalJustifyStart:dB,AlignHorizontalJustifyStartIcon:dB,AlignHorizontalSpaceAround:uB,AlignHorizontalSpaceAroundIcon:uB,AlignHorizontalSpaceBetween:hB,AlignHorizontalSpaceBetweenIcon:hB,AlignJustify:mB,AlignJustifyIcon:mB,AlignLeft:$4,AlignLeftIcon:$4,AlignRight:q4,AlignRightIcon:q4,AlignStartHorizontal:pB,AlignStartHorizontalIcon:pB,AlignStartVertical:fB,AlignStartVerticalIcon:fB,AlignVerticalDistributeCenter:xB,AlignVerticalDistributeCenterIcon:xB,AlignVerticalDistributeEnd:gB,AlignVerticalDistributeEndIcon:gB,AlignVerticalDistributeStart:yB,AlignVerticalDistributeStartIcon:yB,AlignVerticalJustifyCenter:vB,AlignVerticalJustifyCenterIcon:vB,AlignVerticalJustifyEnd:_B,AlignVerticalJustifyEndIcon:_B,AlignVerticalJustifyStart:bB,AlignVerticalJustifyStartIcon:bB,AlignVerticalSpaceAround:wB,AlignVerticalSpaceAroundIcon:wB,AlignVerticalSpaceBetween:jB,AlignVerticalSpaceBetweenIcon:jB,Ambulance:NB,AmbulanceIcon:NB,Ampersand:kB,AmpersandIcon:kB,Ampersands:SB,AmpersandsIcon:SB,Amphora:CB,AmphoraIcon:CB,Anchor:MB,AnchorIcon:MB,Angry:TB,AngryIcon:TB,Annoyed:AB,AnnoyedIcon:AB,Antenna:EB,AntennaIcon:EB,Anvil:PB,AnvilIcon:PB,Aperture:IB,ApertureIcon:IB,AppWindow:QI,AppWindowIcon:QI,AppWindowMac:LB,AppWindowMacIcon:LB,Apple:DB,AppleIcon:DB,Archive:pM,ArchiveIcon:pM,ArchiveRestore:JI,ArchiveRestoreIcon:JI,ArchiveX:RB,ArchiveXIcon:RB,AreaChart:aj,AreaChartIcon:aj,Armchair:OB,ArmchairIcon:OB,ArrowBigDown:zB,ArrowBigDownDash:FB,ArrowBigDownDashIcon:FB,ArrowBigDownIcon:zB,ArrowBigLeft:$B,ArrowBigLeftDash:BB,ArrowBigLeftDashIcon:BB,ArrowBigLeftIcon:$B,ArrowBigRight:UB,ArrowBigRightDash:qB,ArrowBigRightDashIcon:qB,ArrowBigRightIcon:UB,ArrowBigUp:HB,ArrowBigUpDash:VB,ArrowBigUpDashIcon:VB,ArrowBigUpIcon:HB,ArrowDown:Ph,ArrowDown01:GB,ArrowDown01Icon:GB,ArrowDown10:WB,ArrowDown10Icon:WB,ArrowDownAZ:G2,ArrowDownAZIcon:G2,ArrowDownAz:G2,ArrowDownAzIcon:G2,ArrowDownCircle:gj,ArrowDownCircleIcon:gj,ArrowDownFromLine:KB,ArrowDownFromLineIcon:KB,ArrowDownIcon:Ph,ArrowDownLeft:ZB,ArrowDownLeftFromCircle:vj,ArrowDownLeftFromCircleIcon:vj,ArrowDownLeftFromSquare:HN,ArrowDownLeftFromSquareIcon:HN,ArrowDownLeftIcon:ZB,ArrowDownLeftSquare:$N,ArrowDownLeftSquareIcon:$N,ArrowDownNarrowWide:YB,ArrowDownNarrowWideIcon:YB,ArrowDownRight:eL,ArrowDownRightFromCircle:_j,ArrowDownRightFromCircleIcon:_j,ArrowDownRightFromSquare:GN,ArrowDownRightFromSquareIcon:GN,ArrowDownRightIcon:eL,ArrowDownRightSquare:qN,ArrowDownRightSquareIcon:qN,ArrowDownSquare:UN,ArrowDownSquareIcon:UN,ArrowDownToDot:XB,ArrowDownToDotIcon:XB,ArrowDownToLine:QB,ArrowDownToLineIcon:QB,ArrowDownUp:JB,ArrowDownUpIcon:JB,ArrowDownWideNarrow:W2,ArrowDownWideNarrowIcon:W2,ArrowDownZA:K2,ArrowDownZAIcon:K2,ArrowDownZa:K2,ArrowDownZaIcon:K2,ArrowLeft:Fa,ArrowLeftCircle:yj,ArrowLeftCircleIcon:yj,ArrowLeftFromLine:e$,ArrowLeftFromLineIcon:e$,ArrowLeftIcon:Fa,ArrowLeftRight:t$,ArrowLeftRightIcon:t$,ArrowLeftSquare:VN,ArrowLeftSquareIcon:VN,ArrowLeftToLine:s$,ArrowLeftToLineIcon:s$,ArrowRight:ei,ArrowRightCircle:jj,ArrowRightCircleIcon:jj,ArrowRightFromLine:r$,ArrowRightFromLineIcon:r$,ArrowRightIcon:ei,ArrowRightLeft:Hv,ArrowRightLeftIcon:Hv,ArrowRightSquare:ZN,ArrowRightSquareIcon:ZN,ArrowRightToLine:n$,ArrowRightToLineIcon:n$,ArrowUp:du,ArrowUp01:a$,ArrowUp01Icon:a$,ArrowUp10:i$,ArrowUp10Icon:i$,ArrowUpAZ:Z2,ArrowUpAZIcon:Z2,ArrowUpAz:Z2,ArrowUpAzIcon:Z2,ArrowUpCircle:Nj,ArrowUpCircleIcon:Nj,ArrowUpDown:td,ArrowUpDownIcon:td,ArrowUpFromDot:o$,ArrowUpFromDotIcon:o$,ArrowUpFromLine:l$,ArrowUpFromLineIcon:l$,ArrowUpIcon:du,ArrowUpLeft:c$,ArrowUpLeftFromCircle:bj,ArrowUpLeftFromCircleIcon:bj,ArrowUpLeftFromSquare:WN,ArrowUpLeftFromSquareIcon:WN,ArrowUpLeftIcon:c$,ArrowUpLeftSquare:YN,ArrowUpLeftSquareIcon:YN,ArrowUpNarrowWide:Y2,ArrowUpNarrowWideIcon:Y2,ArrowUpRight:tL,ArrowUpRightFromCircle:wj,ArrowUpRightFromCircleIcon:wj,ArrowUpRightFromSquare:KN,ArrowUpRightFromSquareIcon:KN,ArrowUpRightIcon:tL,ArrowUpRightSquare:XN,ArrowUpRightSquareIcon:XN,ArrowUpSquare:QN,ArrowUpSquareIcon:QN,ArrowUpToLine:d$,ArrowUpToLineIcon:d$,ArrowUpWideNarrow:u$,ArrowUpWideNarrowIcon:u$,ArrowUpZA:X2,ArrowUpZAIcon:X2,ArrowUpZa:X2,ArrowUpZaIcon:X2,ArrowsUpFromLine:h$,ArrowsUpFromLineIcon:h$,Asterisk:m$,AsteriskIcon:m$,AsteriskSquare:JN,AsteriskSquareIcon:JN,AtSign:p$,AtSignIcon:p$,Atom:f$,AtomIcon:f$,AudioLines:x$,AudioLinesIcon:x$,AudioWaveform:g$,AudioWaveformIcon:g$,Award:ec,AwardIcon:ec,Axe:y$,AxeIcon:y$,Axis3D:Q2,Axis3DIcon:Q2,Axis3d:Q2,Axis3dIcon:Q2,Baby:v$,BabyIcon:v$,Backpack:_$,BackpackIcon:_$,Badge:R$,BadgeAlert:b$,BadgeAlertIcon:b$,BadgeCent:w$,BadgeCentIcon:w$,BadgeCheck:J2,BadgeCheckIcon:J2,BadgeDollarSign:j$,BadgeDollarSignIcon:j$,BadgeEuro:N$,BadgeEuroIcon:N$,BadgeHelp:k$,BadgeHelpIcon:k$,BadgeIcon:R$,BadgeIndianRupee:S$,BadgeIndianRupeeIcon:S$,BadgeInfo:C$,BadgeInfoIcon:C$,BadgeJapaneseYen:M$,BadgeJapaneseYenIcon:M$,BadgeMinus:T$,BadgeMinusIcon:T$,BadgePercent:A$,BadgePercentIcon:A$,BadgePlus:E$,BadgePlusIcon:E$,BadgePoundSterling:P$,BadgePoundSterlingIcon:P$,BadgeRussianRuble:I$,BadgeRussianRubleIcon:I$,BadgeSwissFranc:L$,BadgeSwissFrancIcon:L$,BadgeX:D$,BadgeXIcon:D$,BaggageClaim:O$,BaggageClaimIcon:O$,Ban:sL,BanIcon:sL,Banana:F$,BananaIcon:F$,Bandage:z$,BandageIcon:z$,Banknote:B$,BanknoteIcon:B$,BarChart:hj,BarChart2:mj,BarChart2Icon:mj,BarChart3:to,BarChart3Icon:to,BarChart4:dj,BarChart4Icon:dj,BarChartBig:cj,BarChartBigIcon:cj,BarChartHorizontal:oj,BarChartHorizontalBig:ij,BarChartHorizontalBigIcon:ij,BarChartHorizontalIcon:oj,BarChartIcon:hj,Barcode:$$,BarcodeIcon:$$,Baseline:q$,BaselineIcon:q$,Bath:rf,BathIcon:rf,Battery:K$,BatteryCharging:U$,BatteryChargingIcon:U$,BatteryFull:V$,BatteryFullIcon:V$,BatteryIcon:K$,BatteryLow:H$,BatteryLowIcon:H$,BatteryMedium:G$,BatteryMediumIcon:G$,BatteryWarning:W$,BatteryWarningIcon:W$,Beaker:Z$,BeakerIcon:Z$,Bean:X$,BeanIcon:X$,BeanOff:Y$,BeanOffIcon:Y$,Bed:Wy,BedDouble:U4,BedDoubleIcon:U4,BedIcon:Wy,BedSingle:Q$,BedSingleIcon:Q$,Beef:J$,BeefIcon:J$,Beer:tq,BeerIcon:tq,BeerOff:eq,BeerOffIcon:eq,Bell:Sm,BellDot:sq,BellDotIcon:sq,BellElectric:rq,BellElectricIcon:rq,BellIcon:Sm,BellMinus:nq,BellMinusIcon:nq,BellOff:Gv,BellOffIcon:Gv,BellPlus:aq,BellPlusIcon:aq,BellRing:iq,BellRingIcon:iq,BetweenHorizonalEnd:ej,BetweenHorizonalEndIcon:ej,BetweenHorizonalStart:tj,BetweenHorizonalStartIcon:tj,BetweenHorizontalEnd:ej,BetweenHorizontalEndIcon:ej,BetweenHorizontalStart:tj,BetweenHorizontalStartIcon:tj,BetweenVerticalEnd:oq,BetweenVerticalEndIcon:oq,BetweenVerticalStart:lq,BetweenVerticalStartIcon:lq,BicepsFlexed:cq,BicepsFlexedIcon:cq,Bike:dq,BikeIcon:dq,Binary:uq,BinaryIcon:uq,Binoculars:hq,BinocularsIcon:hq,Biohazard:mq,BiohazardIcon:mq,Bird:pq,BirdIcon:pq,Bitcoin:fq,BitcoinIcon:fq,Blend:xq,BlendIcon:xq,Blinds:gq,BlindsIcon:gq,Blocks:yq,BlocksIcon:yq,Bluetooth:wq,BluetoothConnected:vq,BluetoothConnectedIcon:vq,BluetoothIcon:wq,BluetoothOff:_q,BluetoothOffIcon:_q,BluetoothSearching:bq,BluetoothSearchingIcon:bq,Bold:V4,BoldIcon:V4,Bolt:jq,BoltIcon:jq,Bomb:Nq,BombIcon:Nq,Bone:kq,BoneIcon:kq,Book:Wq,BookA:Sq,BookAIcon:Sq,BookAudio:Cq,BookAudioIcon:Cq,BookCheck:Mq,BookCheckIcon:Mq,BookCopy:Tq,BookCopyIcon:Tq,BookDashed:sj,BookDashedIcon:sj,BookDown:Aq,BookDownIcon:Aq,BookHeadphones:Eq,BookHeadphonesIcon:Eq,BookHeart:Pq,BookHeartIcon:Pq,BookIcon:Wq,BookImage:Iq,BookImageIcon:Iq,BookKey:Lq,BookKeyIcon:Lq,BookLock:Dq,BookLockIcon:Dq,BookMarked:Rq,BookMarkedIcon:Rq,BookMinus:Oq,BookMinusIcon:Oq,BookOpen:oh,BookOpenCheck:Fq,BookOpenCheckIcon:Fq,BookOpenIcon:oh,BookOpenText:zq,BookOpenTextIcon:zq,BookPlus:Bq,BookPlusIcon:Bq,BookTemplate:sj,BookTemplateIcon:sj,BookText:$q,BookTextIcon:$q,BookType:qq,BookTypeIcon:qq,BookUp:Vq,BookUp2:Uq,BookUp2Icon:Uq,BookUpIcon:Vq,BookUser:Hq,BookUserIcon:Hq,BookX:Gq,BookXIcon:Gq,Bookmark:fx,BookmarkCheck:Kq,BookmarkCheckIcon:Kq,BookmarkIcon:fx,BookmarkMinus:Zq,BookmarkMinusIcon:Zq,BookmarkPlus:rL,BookmarkPlusIcon:rL,BookmarkX:Yq,BookmarkXIcon:Yq,BoomBox:Xq,BoomBoxIcon:Xq,Bot:fM,BotIcon:fM,BotMessageSquare:Qq,BotMessageSquareIcon:Qq,BotOff:Jq,BotOffIcon:Jq,Box:eU,BoxIcon:eU,BoxSelect:ck,BoxSelectIcon:ck,Boxes:tU,BoxesIcon:tU,Braces:rj,BracesIcon:rj,Brackets:sU,BracketsIcon:sU,Brain:nL,BrainCircuit:rU,BrainCircuitIcon:rU,BrainCog:nU,BrainCogIcon:nU,BrainIcon:nL,BrickWall:aU,BrickWallIcon:aU,Briefcase:Ih,BriefcaseBusiness:iU,BriefcaseBusinessIcon:iU,BriefcaseConveyorBelt:oU,BriefcaseConveyorBeltIcon:oU,BriefcaseIcon:Ih,BriefcaseMedical:lU,BriefcaseMedicalIcon:lU,BringToFront:cU,BringToFrontIcon:cU,Brush:dU,BrushIcon:dU,Bug:mU,BugIcon:mU,BugOff:uU,BugOffIcon:uU,BugPlay:hU,BugPlayIcon:hU,Building:H4,Building2:pa,Building2Icon:pa,BuildingIcon:H4,Bus:fU,BusFront:pU,BusFrontIcon:pU,BusIcon:fU,Cable:gU,CableCar:xU,CableCarIcon:xU,CableIcon:gU,Cake:lh,CakeIcon:lh,CakeSlice:yU,CakeSliceIcon:yU,Calculator:xM,CalculatorIcon:xM,Calendar:on,Calendar1:vU,Calendar1Icon:vU,CalendarArrowDown:_U,CalendarArrowDownIcon:_U,CalendarArrowUp:bU,CalendarArrowUpIcon:bU,CalendarCheck:aL,CalendarCheck2:wU,CalendarCheck2Icon:wU,CalendarCheckIcon:aL,CalendarClock:gM,CalendarClockIcon:gM,CalendarCog:jU,CalendarCogIcon:jU,CalendarDays:xd,CalendarDaysIcon:xd,CalendarFold:NU,CalendarFoldIcon:NU,CalendarHeart:kU,CalendarHeartIcon:kU,CalendarIcon:on,CalendarMinus:CU,CalendarMinus2:SU,CalendarMinus2Icon:SU,CalendarMinusIcon:CU,CalendarOff:iL,CalendarOffIcon:iL,CalendarPlus:bb,CalendarPlus2:MU,CalendarPlus2Icon:MU,CalendarPlusIcon:bb,CalendarRange:TU,CalendarRangeIcon:TU,CalendarSearch:AU,CalendarSearchIcon:AU,CalendarSync:EU,CalendarSyncIcon:EU,CalendarX:IU,CalendarX2:PU,CalendarX2Icon:PU,CalendarXIcon:IU,Camera:xx,CameraIcon:xx,CameraOff:LU,CameraOffIcon:LU,CandlestickChart:lj,CandlestickChartIcon:lj,Candy:OU,CandyCane:DU,CandyCaneIcon:DU,CandyIcon:OU,CandyOff:RU,CandyOffIcon:RU,Cannabis:FU,CannabisIcon:FU,Captions:nj,CaptionsIcon:nj,CaptionsOff:zU,CaptionsOffIcon:zU,Car:qU,CarFront:BU,CarFrontIcon:BU,CarIcon:qU,CarTaxiFront:$U,CarTaxiFrontIcon:$U,Caravan:UU,CaravanIcon:UU,Carrot:VU,CarrotIcon:VU,CaseLower:HU,CaseLowerIcon:HU,CaseSensitive:GU,CaseSensitiveIcon:GU,CaseUpper:WU,CaseUpperIcon:WU,CassetteTape:KU,CassetteTapeIcon:KU,Cast:ZU,CastIcon:ZU,Castle:YU,CastleIcon:YU,Cat:XU,CatIcon:XU,Cctv:QU,CctvIcon:QU,ChartArea:aj,ChartAreaIcon:aj,ChartBar:oj,ChartBarBig:ij,ChartBarBigIcon:ij,ChartBarDecreasing:JU,ChartBarDecreasingIcon:JU,ChartBarIcon:oj,ChartBarIncreasing:eV,ChartBarIncreasingIcon:eV,ChartBarStacked:tV,ChartBarStackedIcon:tV,ChartCandlestick:lj,ChartCandlestickIcon:lj,ChartColumn:to,ChartColumnBig:cj,ChartColumnBigIcon:cj,ChartColumnDecreasing:sV,ChartColumnDecreasingIcon:sV,ChartColumnIcon:to,ChartColumnIncreasing:dj,ChartColumnIncreasingIcon:dj,ChartColumnStacked:rV,ChartColumnStackedIcon:rV,ChartGantt:nV,ChartGanttIcon:nV,ChartLine:uj,ChartLineIcon:uj,ChartNetwork:aV,ChartNetworkIcon:aV,ChartNoAxesColumn:mj,ChartNoAxesColumnDecreasing:iV,ChartNoAxesColumnDecreasingIcon:iV,ChartNoAxesColumnIcon:mj,ChartNoAxesColumnIncreasing:hj,ChartNoAxesColumnIncreasingIcon:hj,ChartNoAxesCombined:oV,ChartNoAxesCombinedIcon:oV,ChartNoAxesGantt:pj,ChartNoAxesGanttIcon:pj,ChartPie:fj,ChartPieIcon:fj,ChartScatter:xj,ChartScatterIcon:xj,ChartSpline:lV,ChartSplineIcon:lV,Check:Jn,CheckCheck:oL,CheckCheckIcon:oL,CheckCircle:ti,CheckCircle2:Qn,CheckCircle2Icon:Qn,CheckCircleIcon:ti,CheckIcon:Jn,CheckSquare:Av,CheckSquare2:tk,CheckSquare2Icon:tk,CheckSquareIcon:Av,ChefHat:cV,ChefHatIcon:cV,Cherry:dV,CherryIcon:dV,ChevronDown:Oi,ChevronDownCircle:kj,ChevronDownCircleIcon:kj,ChevronDownIcon:Oi,ChevronDownSquare:sk,ChevronDownSquareIcon:sk,ChevronFirst:uV,ChevronFirstIcon:uV,ChevronLast:hV,ChevronLastIcon:hV,ChevronLeft:xl,ChevronLeftCircle:Sj,ChevronLeftCircleIcon:Sj,ChevronLeftIcon:xl,ChevronLeftSquare:rk,ChevronLeftSquareIcon:rk,ChevronRight:Sa,ChevronRightCircle:Cj,ChevronRightCircleIcon:Cj,ChevronRightIcon:Sa,ChevronRightSquare:nk,ChevronRightSquareIcon:nk,ChevronUp:nf,ChevronUpCircle:Mj,ChevronUpCircleIcon:Mj,ChevronUpIcon:nf,ChevronUpSquare:ak,ChevronUpSquareIcon:ak,ChevronsDown:pV,ChevronsDownIcon:pV,ChevronsDownUp:mV,ChevronsDownUpIcon:mV,ChevronsLeft:gV,ChevronsLeftIcon:gV,ChevronsLeftRight:xV,ChevronsLeftRightEllipsis:fV,ChevronsLeftRightEllipsisIcon:fV,ChevronsLeftRightIcon:xV,ChevronsRight:vV,ChevronsRightIcon:vV,ChevronsRightLeft:yV,ChevronsRightLeftIcon:yV,ChevronsUp:_V,ChevronsUpDown:gx,ChevronsUpDownIcon:gx,ChevronsUpIcon:_V,Chrome:bV,ChromeIcon:bV,Church:wV,ChurchIcon:wV,Cigarette:NV,CigaretteIcon:NV,CigaretteOff:jV,CigaretteOffIcon:jV,Circle:sd,CircleAlert:Lo,CircleAlertIcon:Lo,CircleArrowDown:gj,CircleArrowDownIcon:gj,CircleArrowLeft:yj,CircleArrowLeftIcon:yj,CircleArrowOutDownLeft:vj,CircleArrowOutDownLeftIcon:vj,CircleArrowOutDownRight:_j,CircleArrowOutDownRightIcon:_j,CircleArrowOutUpLeft:bj,CircleArrowOutUpLeftIcon:bj,CircleArrowOutUpRight:wj,CircleArrowOutUpRightIcon:wj,CircleArrowRight:jj,CircleArrowRightIcon:jj,CircleArrowUp:Nj,CircleArrowUpIcon:Nj,CircleCheck:Qn,CircleCheckBig:ti,CircleCheckBigIcon:ti,CircleCheckIcon:Qn,CircleChevronDown:kj,CircleChevronDownIcon:kj,CircleChevronLeft:Sj,CircleChevronLeftIcon:Sj,CircleChevronRight:Cj,CircleChevronRightIcon:Cj,CircleChevronUp:Mj,CircleChevronUpIcon:Mj,CircleDashed:kV,CircleDashedIcon:kV,CircleDivide:Tj,CircleDivideIcon:Tj,CircleDollarSign:SV,CircleDollarSignIcon:SV,CircleDot:MV,CircleDotDashed:CV,CircleDotDashedIcon:CV,CircleDotIcon:MV,CircleEllipsis:TV,CircleEllipsisIcon:TV,CircleEqual:AV,CircleEqualIcon:AV,CircleFadingArrowUp:EV,CircleFadingArrowUpIcon:EV,CircleFadingPlus:PV,CircleFadingPlusIcon:PV,CircleGauge:Aj,CircleGaugeIcon:Aj,CircleHelp:Sv,CircleHelpIcon:Sv,CircleIcon:sd,CircleMinus:Ej,CircleMinusIcon:Ej,CircleOff:IV,CircleOffIcon:IV,CircleParking:Ij,CircleParkingIcon:Ij,CircleParkingOff:Pj,CircleParkingOffIcon:Pj,CirclePause:Lj,CirclePauseIcon:Lj,CirclePercent:Dj,CirclePercentIcon:Dj,CirclePlay:sp,CirclePlayIcon:sp,CirclePlus:Rj,CirclePlusIcon:Rj,CirclePower:Oj,CirclePowerIcon:Oj,CircleSlash:LV,CircleSlash2:Fj,CircleSlash2Icon:Fj,CircleSlashIcon:LV,CircleSlashed:Fj,CircleSlashedIcon:Fj,CircleStop:zj,CircleStopIcon:zj,CircleUser:$j,CircleUserIcon:$j,CircleUserRound:Bj,CircleUserRoundIcon:Bj,CircleX:Zl,CircleXIcon:Zl,CircuitBoard:DV,CircuitBoardIcon:DV,Citrus:RV,CitrusIcon:RV,Clapperboard:OV,ClapperboardIcon:OV,Clipboard:VV,ClipboardCheck:yM,ClipboardCheckIcon:yM,ClipboardCopy:FV,ClipboardCopyIcon:FV,ClipboardEdit:Uj,ClipboardEditIcon:Uj,ClipboardIcon:VV,ClipboardList:wb,ClipboardListIcon:wb,ClipboardMinus:zV,ClipboardMinusIcon:zV,ClipboardPaste:BV,ClipboardPasteIcon:BV,ClipboardPen:Uj,ClipboardPenIcon:Uj,ClipboardPenLine:qj,ClipboardPenLineIcon:qj,ClipboardPlus:$V,ClipboardPlusIcon:$V,ClipboardSignature:qj,ClipboardSignatureIcon:qj,ClipboardType:qV,ClipboardTypeIcon:qV,ClipboardX:UV,ClipboardXIcon:UV,Clock:ln,Clock1:HV,Clock10:GV,Clock10Icon:GV,Clock11:WV,Clock11Icon:WV,Clock12:KV,Clock12Icon:KV,Clock1Icon:HV,Clock2:ZV,Clock2Icon:ZV,Clock3:YV,Clock3Icon:YV,Clock4:XV,Clock4Icon:XV,Clock5:QV,Clock5Icon:QV,Clock6:JV,Clock6Icon:JV,Clock7:eH,Clock7Icon:eH,Clock8:tH,Clock8Icon:tH,Clock9:sH,Clock9Icon:sH,ClockAlert:rH,ClockAlertIcon:rH,ClockArrowDown:nH,ClockArrowDownIcon:nH,ClockArrowUp:aH,ClockArrowUpIcon:aH,ClockIcon:ln,Cloud:_H,CloudAlert:iH,CloudAlertIcon:iH,CloudCog:oH,CloudCogIcon:oH,CloudDownload:Vj,CloudDownloadIcon:Vj,CloudDrizzle:lH,CloudDrizzleIcon:lH,CloudFog:cH,CloudFogIcon:cH,CloudHail:dH,CloudHailIcon:dH,CloudIcon:_H,CloudLightning:uH,CloudLightningIcon:uH,CloudMoon:mH,CloudMoonIcon:mH,CloudMoonRain:hH,CloudMoonRainIcon:hH,CloudOff:pH,CloudOffIcon:pH,CloudRain:xH,CloudRainIcon:xH,CloudRainWind:fH,CloudRainWindIcon:fH,CloudSnow:gH,CloudSnowIcon:gH,CloudSun:vH,CloudSunIcon:vH,CloudSunRain:yH,CloudSunRainIcon:yH,CloudUpload:Hj,CloudUploadIcon:Hj,Cloudy:bH,CloudyIcon:bH,Clover:Fv,CloverIcon:Fv,Club:wH,ClubIcon:wH,Code:G4,Code2:Gj,Code2Icon:Gj,CodeIcon:G4,CodeSquare:ik,CodeSquareIcon:ik,CodeXml:Gj,CodeXmlIcon:Gj,Codepen:jH,CodepenIcon:jH,Codesandbox:NH,CodesandboxIcon:NH,Coffee:W4,CoffeeIcon:W4,Cog:kH,CogIcon:kH,Coins:lL,CoinsIcon:lL,Columns:Wj,Columns2:Wj,Columns2Icon:Wj,Columns3:Kj,Columns3Icon:Kj,Columns4:SH,Columns4Icon:SH,ColumnsIcon:Wj,Combine:CH,CombineIcon:CH,Command:MH,CommandIcon:MH,Compass:vM,CompassIcon:vM,Component:TH,ComponentIcon:TH,Computer:AH,ComputerIcon:AH,ConciergeBell:EH,ConciergeBellIcon:EH,Cone:PH,ConeIcon:PH,Construction:IH,ConstructionIcon:IH,Contact:K4,Contact2:Zj,Contact2Icon:Zj,ContactIcon:K4,ContactRound:Zj,ContactRoundIcon:Zj,Container:LH,ContainerIcon:LH,Contrast:DH,ContrastIcon:DH,Cookie:RH,CookieIcon:RH,CookingPot:OH,CookingPotIcon:OH,Copy:Ya,CopyCheck:FH,CopyCheckIcon:FH,CopyIcon:Ya,CopyMinus:zH,CopyMinusIcon:zH,CopyPlus:BH,CopyPlusIcon:BH,CopySlash:$H,CopySlashIcon:$H,CopyX:qH,CopyXIcon:qH,Copyleft:UH,CopyleftIcon:UH,Copyright:VH,CopyrightIcon:VH,CornerDownLeft:HH,CornerDownLeftIcon:HH,CornerDownRight:GH,CornerDownRightIcon:GH,CornerLeftDown:WH,CornerLeftDownIcon:WH,CornerLeftUp:KH,CornerLeftUpIcon:KH,CornerRightDown:ZH,CornerRightDownIcon:ZH,CornerRightUp:YH,CornerRightUpIcon:YH,CornerUpLeft:XH,CornerUpLeftIcon:XH,CornerUpRight:QH,CornerUpRightIcon:QH,Cpu:JH,CpuIcon:JH,CreativeCommons:eG,CreativeCommonsIcon:eG,CreditCard:yx,CreditCardIcon:yx,Croissant:tG,CroissantIcon:tG,Crop:sG,CropIcon:sG,Cross:rG,CrossIcon:rG,Crosshair:nG,CrosshairIcon:nG,Crown:Cm,CrownIcon:Cm,Cuboid:aG,CuboidIcon:aG,CupSoda:iG,CupSodaIcon:iG,CurlyBraces:rj,CurlyBracesIcon:rj,Currency:oG,CurrencyIcon:oG,Cylinder:lG,CylinderIcon:lG,Dam:cG,DamIcon:cG,Database:cL,DatabaseBackup:dG,DatabaseBackupIcon:dG,DatabaseIcon:cL,DatabaseZap:uG,DatabaseZapIcon:uG,Delete:hG,DeleteIcon:hG,Dessert:mG,DessertIcon:mG,Diameter:pG,DiameterIcon:pG,Diamond:gG,DiamondIcon:gG,DiamondMinus:fG,DiamondMinusIcon:fG,DiamondPercent:Yj,DiamondPercentIcon:Yj,DiamondPlus:xG,DiamondPlusIcon:xG,Dice1:yG,Dice1Icon:yG,Dice2:vG,Dice2Icon:vG,Dice3:_G,Dice3Icon:_G,Dice4:bG,Dice4Icon:bG,Dice5:wG,Dice5Icon:wG,Dice6:jG,Dice6Icon:jG,Dices:NG,DicesIcon:NG,Diff:kG,DiffIcon:kG,Disc:TG,Disc2:SG,Disc2Icon:SG,Disc3:CG,Disc3Icon:CG,DiscAlbum:MG,DiscAlbumIcon:MG,DiscIcon:TG,Divide:AG,DivideCircle:Tj,DivideCircleIcon:Tj,DivideIcon:AG,DivideSquare:dk,DivideSquareIcon:dk,Dna:PG,DnaIcon:PG,DnaOff:EG,DnaOffIcon:EG,Dock:IG,DockIcon:IG,Dog:LG,DogIcon:LG,DollarSign:yc,DollarSignIcon:yc,Donut:DG,DonutIcon:DG,DoorClosed:RG,DoorClosedIcon:RG,DoorOpen:Wv,DoorOpenIcon:Wv,Dot:OG,DotIcon:OG,DotSquare:uk,DotSquareIcon:uk,Download:Xa,DownloadCloud:Vj,DownloadCloudIcon:Vj,DownloadIcon:Xa,DraftingCompass:FG,DraftingCompassIcon:FG,Drama:zG,DramaIcon:zG,Dribbble:BG,DribbbleIcon:BG,Drill:$G,DrillIcon:$G,Droplet:qG,DropletIcon:qG,Droplets:Ag,DropletsIcon:Ag,Drum:UG,DrumIcon:UG,Drumstick:VG,DrumstickIcon:VG,Dumbbell:HG,DumbbellIcon:HG,Ear:WG,EarIcon:WG,EarOff:GG,EarOffIcon:GG,Earth:Xj,EarthIcon:Xj,EarthLock:KG,EarthLockIcon:KG,Eclipse:ZG,EclipseIcon:ZG,Edit:Gc,Edit2:Dy,Edit2Icon:Dy,Edit3:Tv,Edit3Icon:Tv,EditIcon:Gc,Egg:_M,EggFried:YG,EggFriedIcon:YG,EggIcon:_M,EggOff:XG,EggOffIcon:XG,Ellipsis:ix,EllipsisIcon:ix,EllipsisVertical:ax,EllipsisVerticalIcon:ax,Equal:eW,EqualApproximately:QG,EqualApproximatelyIcon:QG,EqualIcon:eW,EqualNot:JG,EqualNotIcon:JG,EqualSquare:hk,EqualSquareIcon:hk,Eraser:tW,EraserIcon:tW,EthernetPort:sW,EthernetPortIcon:sW,Euro:rW,EuroIcon:rW,Expand:nW,ExpandIcon:nW,ExternalLink:Kr,ExternalLinkIcon:Kr,Eye:wn,EyeClosed:aW,EyeClosedIcon:aW,EyeIcon:wn,EyeOff:mp,EyeOffIcon:mp,Facebook:uu,FacebookIcon:uu,Factory:iW,FactoryIcon:iW,Fan:oW,FanIcon:oW,FastForward:lW,FastForwardIcon:lW,Feather:cW,FeatherIcon:cW,Fence:dW,FenceIcon:dW,FerrisWheel:uW,FerrisWheelIcon:uW,Figma:hW,FigmaIcon:hW,File:bM,FileArchive:mW,FileArchiveIcon:mW,FileAudio:fW,FileAudio2:pW,FileAudio2Icon:pW,FileAudioIcon:fW,FileAxis3D:Qj,FileAxis3DIcon:Qj,FileAxis3d:Qj,FileAxis3dIcon:Qj,FileBadge:gW,FileBadge2:xW,FileBadge2Icon:xW,FileBadgeIcon:gW,FileBarChart:Jj,FileBarChart2:eN,FileBarChart2Icon:eN,FileBarChartIcon:Jj,FileBox:yW,FileBoxIcon:yW,FileChartColumn:eN,FileChartColumnIcon:eN,FileChartColumnIncreasing:Jj,FileChartColumnIncreasingIcon:Jj,FileChartLine:tN,FileChartLineIcon:tN,FileChartPie:sN,FileChartPieIcon:sN,FileCheck:_W,FileCheck2:vW,FileCheck2Icon:vW,FileCheckIcon:_W,FileClock:bW,FileClockIcon:bW,FileCode:jW,FileCode2:wW,FileCode2Icon:wW,FileCodeIcon:jW,FileCog:rN,FileCog2:rN,FileCog2Icon:rN,FileCogIcon:rN,FileDiff:NW,FileDiffIcon:NW,FileDigit:kW,FileDigitIcon:kW,FileDown:Z4,FileDownIcon:Z4,FileEdit:aN,FileEditIcon:aN,FileHeart:SW,FileHeartIcon:SW,FileIcon:bM,FileImage:jb,FileImageIcon:jb,FileInput:CW,FileInputIcon:CW,FileJson:TW,FileJson2:MW,FileJson2Icon:MW,FileJsonIcon:TW,FileKey:EW,FileKey2:AW,FileKey2Icon:AW,FileKeyIcon:EW,FileLineChart:tN,FileLineChartIcon:tN,FileLock:IW,FileLock2:PW,FileLock2Icon:PW,FileLockIcon:IW,FileMinus:DW,FileMinus2:LW,FileMinus2Icon:LW,FileMinusIcon:DW,FileMusic:RW,FileMusicIcon:RW,FileOutput:OW,FileOutputIcon:OW,FilePen:aN,FilePenIcon:aN,FilePenLine:nN,FilePenLineIcon:nN,FilePieChart:sN,FilePieChartIcon:sN,FilePlus:zW,FilePlus2:FW,FilePlus2Icon:FW,FilePlusIcon:zW,FileQuestion:BW,FileQuestionIcon:BW,FileScan:$W,FileScanIcon:$W,FileSearch:UW,FileSearch2:qW,FileSearch2Icon:qW,FileSearchIcon:UW,FileSignature:nN,FileSignatureIcon:nN,FileSliders:VW,FileSlidersIcon:VW,FileSpreadsheet:Kv,FileSpreadsheetIcon:Kv,FileStack:dL,FileStackIcon:dL,FileSymlink:HW,FileSymlinkIcon:HW,FileTerminal:GW,FileTerminalIcon:GW,FileText:fn,FileTextIcon:fn,FileType:KW,FileType2:WW,FileType2Icon:WW,FileTypeIcon:KW,FileUp:ZW,FileUpIcon:ZW,FileUser:YW,FileUserIcon:YW,FileVideo:QW,FileVideo2:XW,FileVideo2Icon:XW,FileVideoIcon:QW,FileVolume:eK,FileVolume2:JW,FileVolume2Icon:JW,FileVolumeIcon:eK,FileWarning:tK,FileWarningIcon:tK,FileX:rK,FileX2:sK,FileX2Icon:sK,FileXIcon:rK,Files:nK,FilesIcon:nK,Film:tu,FilmIcon:tu,Filter:Eg,FilterIcon:Eg,FilterX:aK,FilterXIcon:aK,Fingerprint:iK,FingerprintIcon:iK,FireExtinguisher:oK,FireExtinguisherIcon:oK,Fish:dK,FishIcon:dK,FishOff:lK,FishOffIcon:lK,FishSymbol:cK,FishSymbolIcon:cK,Flag:Zv,FlagIcon:Zv,FlagOff:uK,FlagOffIcon:uK,FlagTriangleLeft:hK,FlagTriangleLeftIcon:hK,FlagTriangleRight:mK,FlagTriangleRightIcon:mK,Flame:ch,FlameIcon:ch,FlameKindling:pK,FlameKindlingIcon:pK,Flashlight:xK,FlashlightIcon:xK,FlashlightOff:fK,FlashlightOffIcon:fK,FlaskConical:Nb,FlaskConicalIcon:Nb,FlaskConicalOff:gK,FlaskConicalOffIcon:gK,FlaskRound:yK,FlaskRoundIcon:yK,FlipHorizontal:uL,FlipHorizontal2:vK,FlipHorizontal2Icon:vK,FlipHorizontalIcon:uL,FlipVertical:bK,FlipVertical2:_K,FlipVertical2Icon:_K,FlipVerticalIcon:bK,Flower:wK,Flower2:kg,Flower2Icon:kg,FlowerIcon:wK,Focus:jK,FocusIcon:jK,FoldHorizontal:NK,FoldHorizontalIcon:NK,FoldVertical:kK,FoldVerticalIcon:kK,Folder:QK,FolderArchive:SK,FolderArchiveIcon:SK,FolderCheck:CK,FolderCheckIcon:CK,FolderClock:MK,FolderClockIcon:MK,FolderClosed:TK,FolderClosedIcon:TK,FolderCode:AK,FolderCodeIcon:AK,FolderCog:iN,FolderCog2:iN,FolderCog2Icon:iN,FolderCogIcon:iN,FolderDot:EK,FolderDotIcon:EK,FolderDown:PK,FolderDownIcon:PK,FolderEdit:oN,FolderEditIcon:oN,FolderGit:LK,FolderGit2:IK,FolderGit2Icon:IK,FolderGitIcon:LK,FolderHeart:DK,FolderHeartIcon:DK,FolderIcon:QK,FolderInput:RK,FolderInputIcon:RK,FolderKanban:OK,FolderKanbanIcon:OK,FolderKey:FK,FolderKeyIcon:FK,FolderLock:zK,FolderLockIcon:zK,FolderMinus:BK,FolderMinusIcon:BK,FolderOpen:Mm,FolderOpenDot:$K,FolderOpenDotIcon:$K,FolderOpenIcon:Mm,FolderOutput:qK,FolderOutputIcon:qK,FolderPen:oN,FolderPenIcon:oN,FolderPlus:UK,FolderPlusIcon:UK,FolderRoot:VK,FolderRootIcon:VK,FolderSearch:GK,FolderSearch2:HK,FolderSearch2Icon:HK,FolderSearchIcon:GK,FolderSymlink:WK,FolderSymlinkIcon:WK,FolderSync:KK,FolderSyncIcon:KK,FolderTree:ZK,FolderTreeIcon:ZK,FolderUp:YK,FolderUpIcon:YK,FolderX:XK,FolderXIcon:XK,Folders:JK,FoldersIcon:JK,Footprints:eZ,FootprintsIcon:eZ,ForkKnife:Xk,ForkKnifeCrossed:Yk,ForkKnifeCrossedIcon:Yk,ForkKnifeIcon:Xk,Forklift:tZ,ForkliftIcon:tZ,FormInput:PN,FormInputIcon:PN,Forward:sZ,ForwardIcon:sZ,Frame:rZ,FrameIcon:rZ,Framer:nZ,FramerIcon:nZ,Frown:aZ,FrownIcon:aZ,Fuel:iZ,FuelIcon:iZ,Fullscreen:oZ,FullscreenIcon:oZ,FunctionSquare:mk,FunctionSquareIcon:mk,GalleryHorizontal:cZ,GalleryHorizontalEnd:lZ,GalleryHorizontalEndIcon:lZ,GalleryHorizontalIcon:cZ,GalleryThumbnails:dZ,GalleryThumbnailsIcon:dZ,GalleryVertical:hZ,GalleryVerticalEnd:uZ,GalleryVerticalEndIcon:uZ,GalleryVerticalIcon:hZ,Gamepad:pZ,Gamepad2:mZ,Gamepad2Icon:mZ,GamepadIcon:pZ,GanttChart:pj,GanttChartIcon:pj,GanttChartSquare:Ny,GanttChartSquareIcon:Ny,Gauge:fZ,GaugeCircle:Aj,GaugeCircleIcon:Aj,GaugeIcon:fZ,Gavel:xZ,GavelIcon:xZ,Gem:gZ,GemIcon:gZ,Ghost:Y4,GhostIcon:Y4,Gift:Ui,GiftIcon:Ui,GitBranch:vZ,GitBranchIcon:vZ,GitBranchPlus:yZ,GitBranchPlusIcon:yZ,GitCommit:lN,GitCommitHorizontal:lN,GitCommitHorizontalIcon:lN,GitCommitIcon:lN,GitCommitVertical:_Z,GitCommitVerticalIcon:_Z,GitCompare:wZ,GitCompareArrows:bZ,GitCompareArrowsIcon:bZ,GitCompareIcon:wZ,GitFork:jZ,GitForkIcon:jZ,GitGraph:NZ,GitGraphIcon:NZ,GitMerge:kZ,GitMergeIcon:kZ,GitPullRequest:EZ,GitPullRequestArrow:SZ,GitPullRequestArrowIcon:SZ,GitPullRequestClosed:CZ,GitPullRequestClosedIcon:CZ,GitPullRequestCreate:TZ,GitPullRequestCreateArrow:MZ,GitPullRequestCreateArrowIcon:MZ,GitPullRequestCreateIcon:TZ,GitPullRequestDraft:AZ,GitPullRequestDraftIcon:AZ,GitPullRequestIcon:EZ,Github:PZ,GithubIcon:PZ,Gitlab:IZ,GitlabIcon:IZ,GlassWater:LZ,GlassWaterIcon:LZ,Glasses:DZ,GlassesIcon:DZ,Globe:gd,Globe2:Xj,Globe2Icon:Xj,GlobeIcon:gd,GlobeLock:RZ,GlobeLockIcon:RZ,Goal:OZ,GoalIcon:OZ,Grab:FZ,GrabIcon:FZ,GraduationCap:Lh,GraduationCapIcon:Lh,Grape:zZ,GrapeIcon:zZ,Grid:Yf,Grid2X2:dN,Grid2X2Icon:dN,Grid2X2Plus:cN,Grid2X2PlusIcon:cN,Grid2x2:dN,Grid2x2Check:BZ,Grid2x2CheckIcon:BZ,Grid2x2Icon:dN,Grid2x2Plus:cN,Grid2x2PlusIcon:cN,Grid2x2X:$Z,Grid2x2XIcon:$Z,Grid3X3:Yf,Grid3X3Icon:Yf,Grid3x3:Yf,Grid3x3Icon:Yf,GridIcon:Yf,Grip:UZ,GripHorizontal:qZ,GripHorizontalIcon:qZ,GripIcon:UZ,GripVertical:hu,GripVerticalIcon:hu,Group:VZ,GroupIcon:VZ,Guitar:HZ,GuitarIcon:HZ,Ham:GZ,HamIcon:GZ,Hammer:WZ,HammerIcon:WZ,Hand:hL,HandCoins:KZ,HandCoinsIcon:KZ,HandHeart:ZZ,HandHeartIcon:ZZ,HandHelping:uN,HandHelpingIcon:uN,HandIcon:hL,HandMetal:YZ,HandMetalIcon:YZ,HandPlatter:XZ,HandPlatterIcon:XZ,Handshake:mL,HandshakeIcon:mL,HardDrive:pL,HardDriveDownload:QZ,HardDriveDownloadIcon:QZ,HardDriveIcon:pL,HardDriveUpload:JZ,HardDriveUploadIcon:JZ,HardHat:eY,HardHatIcon:eY,Hash:X4,HashIcon:X4,Haze:tY,HazeIcon:tY,HdmiPort:sY,HdmiPortIcon:sY,Heading:iY,Heading1:wM,Heading1Icon:wM,Heading2:jM,Heading2Icon:jM,Heading3:fL,Heading3Icon:fL,Heading4:rY,Heading4Icon:rY,Heading5:nY,Heading5Icon:nY,Heading6:aY,Heading6Icon:aY,HeadingIcon:iY,HeadphoneOff:oY,HeadphoneOffIcon:oY,Headphones:lY,HeadphonesIcon:lY,Headset:cY,HeadsetIcon:cY,Heart:Za,HeartCrack:dY,HeartCrackIcon:dY,HeartHandshake:uY,HeartHandshakeIcon:uY,HeartIcon:Za,HeartOff:hY,HeartOffIcon:hY,HeartPulse:mY,HeartPulseIcon:mY,Heater:pY,HeaterIcon:pY,HelpCircle:Sv,HelpCircleIcon:Sv,HelpingHand:uN,HelpingHandIcon:uN,Hexagon:fY,HexagonIcon:fY,Highlighter:xY,HighlighterIcon:xY,History:NM,HistoryIcon:NM,Home:Mn,HomeIcon:Mn,Hop:yY,HopIcon:yY,HopOff:gY,HopOffIcon:gY,Hospital:vY,HospitalIcon:vY,Hotel:_Y,HotelIcon:_Y,Hourglass:bY,HourglassIcon:bY,House:Mn,HouseIcon:Mn,HousePlug:wY,HousePlugIcon:wY,HousePlus:jY,HousePlusIcon:jY,IceCream:mN,IceCream2:hN,IceCream2Icon:hN,IceCreamBowl:hN,IceCreamBowlIcon:hN,IceCreamCone:mN,IceCreamConeIcon:mN,IceCreamIcon:mN,Icon:Xqe,IdCard:NY,IdCardIcon:NY,Image:Wo,ImageDown:kY,ImageDownIcon:kY,ImageIcon:Wo,ImageMinus:SY,ImageMinusIcon:SY,ImageOff:CY,ImageOffIcon:CY,ImagePlay:MY,ImagePlayIcon:MY,ImagePlus:Yv,ImagePlusIcon:Yv,ImageUp:TY,ImageUpIcon:TY,ImageUpscale:AY,ImageUpscaleIcon:AY,Images:EY,ImagesIcon:EY,Import:PY,ImportIcon:PY,Inbox:IY,InboxIcon:IY,Indent:fN,IndentDecrease:pN,IndentDecreaseIcon:pN,IndentIcon:fN,IndentIncrease:fN,IndentIncreaseIcon:fN,IndianRupee:LY,IndianRupeeIcon:LY,Infinity:DY,InfinityIcon:DY,Info:Q4,InfoIcon:Q4,Inspect:vk,InspectIcon:vk,InspectionPanel:RY,InspectionPanelIcon:RY,Instagram:mu,InstagramIcon:mu,Italic:J4,ItalicIcon:J4,IterationCcw:OY,IterationCcwIcon:OY,IterationCw:FY,IterationCwIcon:FY,JapaneseYen:zY,JapaneseYenIcon:zY,Joystick:BY,JoystickIcon:BY,Kanban:Ky,KanbanIcon:Ky,KanbanSquare:pk,KanbanSquareDashed:ok,KanbanSquareDashedIcon:ok,KanbanSquareIcon:pk,Key:pp,KeyIcon:pp,KeyRound:eS,KeyRoundIcon:eS,KeySquare:$Y,KeySquareIcon:$Y,Keyboard:VY,KeyboardIcon:VY,KeyboardMusic:qY,KeyboardMusicIcon:qY,KeyboardOff:UY,KeyboardOffIcon:UY,Lamp:YY,LampCeiling:HY,LampCeilingIcon:HY,LampDesk:GY,LampDeskIcon:GY,LampFloor:WY,LampFloorIcon:WY,LampIcon:YY,LampWallDown:KY,LampWallDownIcon:KY,LampWallUp:ZY,LampWallUpIcon:ZY,LandPlot:XY,LandPlotIcon:XY,Landmark:QY,LandmarkIcon:QY,Languages:JY,LanguagesIcon:JY,Laptop:tX,Laptop2:xN,Laptop2Icon:xN,LaptopIcon:tX,LaptopMinimal:xN,LaptopMinimalCheck:eX,LaptopMinimalCheckIcon:eX,LaptopMinimalIcon:xN,Lasso:rX,LassoIcon:rX,LassoSelect:sX,LassoSelectIcon:sX,Laugh:nX,LaughIcon:nX,Layers:oX,Layers2:aX,Layers2Icon:aX,Layers3:iX,Layers3Icon:iX,LayersIcon:oX,Layout:Mv,LayoutDashboard:tS,LayoutDashboardIcon:tS,LayoutGrid:fp,LayoutGridIcon:fp,LayoutIcon:Mv,LayoutList:lX,LayoutListIcon:lX,LayoutPanelLeft:cX,LayoutPanelLeftIcon:cX,LayoutPanelTop:dX,LayoutPanelTopIcon:dX,LayoutTemplate:sS,LayoutTemplateIcon:sS,Leaf:uX,LeafIcon:uX,LeafyGreen:hX,LeafyGreenIcon:hX,Lectern:mX,LecternIcon:mX,LetterText:pX,LetterTextIcon:pX,Library:kM,LibraryBig:fX,LibraryBigIcon:fX,LibraryIcon:kM,LibrarySquare:fk,LibrarySquareIcon:fk,LifeBuoy:SM,LifeBuoyIcon:SM,Ligature:xX,LigatureIcon:xX,Lightbulb:kb,LightbulbIcon:kb,LightbulbOff:gX,LightbulbOffIcon:gX,LineChart:uj,LineChartIcon:uj,Link:fo,Link2:Do,Link2Icon:Do,Link2Off:yX,Link2OffIcon:yX,LinkIcon:fo,Linkedin:xp,LinkedinIcon:xp,List:Dh,ListCheck:vX,ListCheckIcon:vX,ListChecks:_X,ListChecksIcon:_X,ListCollapse:bX,ListCollapseIcon:bX,ListEnd:wX,ListEndIcon:wX,ListFilter:jX,ListFilterIcon:jX,ListIcon:Dh,ListMinus:NX,ListMinusIcon:NX,ListMusic:kX,ListMusicIcon:kX,ListOrdered:Zy,ListOrderedIcon:Zy,ListPlus:SX,ListPlusIcon:SX,ListRestart:CX,ListRestartIcon:CX,ListStart:MX,ListStartIcon:MX,ListTodo:TX,ListTodoIcon:TX,ListTree:AX,ListTreeIcon:AX,ListVideo:EX,ListVideoIcon:EX,ListX:PX,ListXIcon:PX,Loader:LX,Loader2:_s,Loader2Icon:_s,LoaderCircle:_s,LoaderCircleIcon:_s,LoaderIcon:LX,LoaderPinwheel:IX,LoaderPinwheelIcon:IX,Locate:CM,LocateFixed:DX,LocateFixedIcon:DX,LocateIcon:CM,LocateOff:RX,LocateOffIcon:RX,Lock:yd,LockIcon:yd,LockKeyhole:OX,LockKeyholeIcon:OX,LockKeyholeOpen:gN,LockKeyholeOpenIcon:gN,LockOpen:yN,LockOpenIcon:yN,LogIn:rS,LogInIcon:rS,LogOut:MM,LogOutIcon:MM,Logs:FX,LogsIcon:FX,Lollipop:zX,LollipopIcon:zX,LucideAArrowDown:H9,LucideAArrowUp:G9,LucideALargeSmall:W9,LucideAccessibility:K9,LucideActivity:ih,LucideActivitySquare:BN,LucideAirVent:Z9,LucideAirplay:Y9,LucideAlarmCheck:U2,LucideAlarmClock:Q9,LucideAlarmClockCheck:U2,LucideAlarmClockMinus:V2,LucideAlarmClockOff:X9,LucideAlarmClockPlus:H2,LucideAlarmMinus:V2,LucideAlarmPlus:H2,LucideAlarmSmoke:J9,LucideAlbum:eB,LucideAlertCircle:Lo,LucideAlertOctagon:Cv,LucideAlertTriangle:Qc,LucideAlignCenter:B4,LucideAlignCenterHorizontal:tB,LucideAlignCenterVertical:sB,LucideAlignEndHorizontal:rB,LucideAlignEndVertical:nB,LucideAlignHorizontalDistributeCenter:aB,LucideAlignHorizontalDistributeEnd:iB,LucideAlignHorizontalDistributeStart:oB,LucideAlignHorizontalJustifyCenter:lB,LucideAlignHorizontalJustifyEnd:cB,LucideAlignHorizontalJustifyStart:dB,LucideAlignHorizontalSpaceAround:uB,LucideAlignHorizontalSpaceBetween:hB,LucideAlignJustify:mB,LucideAlignLeft:$4,LucideAlignRight:q4,LucideAlignStartHorizontal:pB,LucideAlignStartVertical:fB,LucideAlignVerticalDistributeCenter:xB,LucideAlignVerticalDistributeEnd:gB,LucideAlignVerticalDistributeStart:yB,LucideAlignVerticalJustifyCenter:vB,LucideAlignVerticalJustifyEnd:_B,LucideAlignVerticalJustifyStart:bB,LucideAlignVerticalSpaceAround:wB,LucideAlignVerticalSpaceBetween:jB,LucideAmbulance:NB,LucideAmpersand:kB,LucideAmpersands:SB,LucideAmphora:CB,LucideAnchor:MB,LucideAngry:TB,LucideAnnoyed:AB,LucideAntenna:EB,LucideAnvil:PB,LucideAperture:IB,LucideAppWindow:QI,LucideAppWindowMac:LB,LucideApple:DB,LucideArchive:pM,LucideArchiveRestore:JI,LucideArchiveX:RB,LucideAreaChart:aj,LucideArmchair:OB,LucideArrowBigDown:zB,LucideArrowBigDownDash:FB,LucideArrowBigLeft:$B,LucideArrowBigLeftDash:BB,LucideArrowBigRight:UB,LucideArrowBigRightDash:qB,LucideArrowBigUp:HB,LucideArrowBigUpDash:VB,LucideArrowDown:Ph,LucideArrowDown01:GB,LucideArrowDown10:WB,LucideArrowDownAZ:G2,LucideArrowDownAz:G2,LucideArrowDownCircle:gj,LucideArrowDownFromLine:KB,LucideArrowDownLeft:ZB,LucideArrowDownLeftFromCircle:vj,LucideArrowDownLeftFromSquare:HN,LucideArrowDownLeftSquare:$N,LucideArrowDownNarrowWide:YB,LucideArrowDownRight:eL,LucideArrowDownRightFromCircle:_j,LucideArrowDownRightFromSquare:GN,LucideArrowDownRightSquare:qN,LucideArrowDownSquare:UN,LucideArrowDownToDot:XB,LucideArrowDownToLine:QB,LucideArrowDownUp:JB,LucideArrowDownWideNarrow:W2,LucideArrowDownZA:K2,LucideArrowDownZa:K2,LucideArrowLeft:Fa,LucideArrowLeftCircle:yj,LucideArrowLeftFromLine:e$,LucideArrowLeftRight:t$,LucideArrowLeftSquare:VN,LucideArrowLeftToLine:s$,LucideArrowRight:ei,LucideArrowRightCircle:jj,LucideArrowRightFromLine:r$,LucideArrowRightLeft:Hv,LucideArrowRightSquare:ZN,LucideArrowRightToLine:n$,LucideArrowUp:du,LucideArrowUp01:a$,LucideArrowUp10:i$,LucideArrowUpAZ:Z2,LucideArrowUpAz:Z2,LucideArrowUpCircle:Nj,LucideArrowUpDown:td,LucideArrowUpFromDot:o$,LucideArrowUpFromLine:l$,LucideArrowUpLeft:c$,LucideArrowUpLeftFromCircle:bj,LucideArrowUpLeftFromSquare:WN,LucideArrowUpLeftSquare:YN,LucideArrowUpNarrowWide:Y2,LucideArrowUpRight:tL,LucideArrowUpRightFromCircle:wj,LucideArrowUpRightFromSquare:KN,LucideArrowUpRightSquare:XN,LucideArrowUpSquare:QN,LucideArrowUpToLine:d$,LucideArrowUpWideNarrow:u$,LucideArrowUpZA:X2,LucideArrowUpZa:X2,LucideArrowsUpFromLine:h$,LucideAsterisk:m$,LucideAsteriskSquare:JN,LucideAtSign:p$,LucideAtom:f$,LucideAudioLines:x$,LucideAudioWaveform:g$,LucideAward:ec,LucideAxe:y$,LucideAxis3D:Q2,LucideAxis3d:Q2,LucideBaby:v$,LucideBackpack:_$,LucideBadge:R$,LucideBadgeAlert:b$,LucideBadgeCent:w$,LucideBadgeCheck:J2,LucideBadgeDollarSign:j$,LucideBadgeEuro:N$,LucideBadgeHelp:k$,LucideBadgeIndianRupee:S$,LucideBadgeInfo:C$,LucideBadgeJapaneseYen:M$,LucideBadgeMinus:T$,LucideBadgePercent:A$,LucideBadgePlus:E$,LucideBadgePoundSterling:P$,LucideBadgeRussianRuble:I$,LucideBadgeSwissFranc:L$,LucideBadgeX:D$,LucideBaggageClaim:O$,LucideBan:sL,LucideBanana:F$,LucideBandage:z$,LucideBanknote:B$,LucideBarChart:hj,LucideBarChart2:mj,LucideBarChart3:to,LucideBarChart4:dj,LucideBarChartBig:cj,LucideBarChartHorizontal:oj,LucideBarChartHorizontalBig:ij,LucideBarcode:$$,LucideBaseline:q$,LucideBath:rf,LucideBattery:K$,LucideBatteryCharging:U$,LucideBatteryFull:V$,LucideBatteryLow:H$,LucideBatteryMedium:G$,LucideBatteryWarning:W$,LucideBeaker:Z$,LucideBean:X$,LucideBeanOff:Y$,LucideBed:Wy,LucideBedDouble:U4,LucideBedSingle:Q$,LucideBeef:J$,LucideBeer:tq,LucideBeerOff:eq,LucideBell:Sm,LucideBellDot:sq,LucideBellElectric:rq,LucideBellMinus:nq,LucideBellOff:Gv,LucideBellPlus:aq,LucideBellRing:iq,LucideBetweenHorizonalEnd:ej,LucideBetweenHorizonalStart:tj,LucideBetweenHorizontalEnd:ej,LucideBetweenHorizontalStart:tj,LucideBetweenVerticalEnd:oq,LucideBetweenVerticalStart:lq,LucideBicepsFlexed:cq,LucideBike:dq,LucideBinary:uq,LucideBinoculars:hq,LucideBiohazard:mq,LucideBird:pq,LucideBitcoin:fq,LucideBlend:xq,LucideBlinds:gq,LucideBlocks:yq,LucideBluetooth:wq,LucideBluetoothConnected:vq,LucideBluetoothOff:_q,LucideBluetoothSearching:bq,LucideBold:V4,LucideBolt:jq,LucideBomb:Nq,LucideBone:kq,LucideBook:Wq,LucideBookA:Sq,LucideBookAudio:Cq,LucideBookCheck:Mq,LucideBookCopy:Tq,LucideBookDashed:sj,LucideBookDown:Aq,LucideBookHeadphones:Eq,LucideBookHeart:Pq,LucideBookImage:Iq,LucideBookKey:Lq,LucideBookLock:Dq,LucideBookMarked:Rq,LucideBookMinus:Oq,LucideBookOpen:oh,LucideBookOpenCheck:Fq,LucideBookOpenText:zq,LucideBookPlus:Bq,LucideBookTemplate:sj,LucideBookText:$q,LucideBookType:qq,LucideBookUp:Vq,LucideBookUp2:Uq,LucideBookUser:Hq,LucideBookX:Gq,LucideBookmark:fx,LucideBookmarkCheck:Kq,LucideBookmarkMinus:Zq,LucideBookmarkPlus:rL,LucideBookmarkX:Yq,LucideBoomBox:Xq,LucideBot:fM,LucideBotMessageSquare:Qq,LucideBotOff:Jq,LucideBox:eU,LucideBoxSelect:ck,LucideBoxes:tU,LucideBraces:rj,LucideBrackets:sU,LucideBrain:nL,LucideBrainCircuit:rU,LucideBrainCog:nU,LucideBrickWall:aU,LucideBriefcase:Ih,LucideBriefcaseBusiness:iU,LucideBriefcaseConveyorBelt:oU,LucideBriefcaseMedical:lU,LucideBringToFront:cU,LucideBrush:dU,LucideBug:mU,LucideBugOff:uU,LucideBugPlay:hU,LucideBuilding:H4,LucideBuilding2:pa,LucideBus:fU,LucideBusFront:pU,LucideCable:gU,LucideCableCar:xU,LucideCake:lh,LucideCakeSlice:yU,LucideCalculator:xM,LucideCalendar:on,LucideCalendar1:vU,LucideCalendarArrowDown:_U,LucideCalendarArrowUp:bU,LucideCalendarCheck:aL,LucideCalendarCheck2:wU,LucideCalendarClock:gM,LucideCalendarCog:jU,LucideCalendarDays:xd,LucideCalendarFold:NU,LucideCalendarHeart:kU,LucideCalendarMinus:CU,LucideCalendarMinus2:SU,LucideCalendarOff:iL,LucideCalendarPlus:bb,LucideCalendarPlus2:MU,LucideCalendarRange:TU,LucideCalendarSearch:AU,LucideCalendarSync:EU,LucideCalendarX:IU,LucideCalendarX2:PU,LucideCamera:xx,LucideCameraOff:LU,LucideCandlestickChart:lj,LucideCandy:OU,LucideCandyCane:DU,LucideCandyOff:RU,LucideCannabis:FU,LucideCaptions:nj,LucideCaptionsOff:zU,LucideCar:qU,LucideCarFront:BU,LucideCarTaxiFront:$U,LucideCaravan:UU,LucideCarrot:VU,LucideCaseLower:HU,LucideCaseSensitive:GU,LucideCaseUpper:WU,LucideCassetteTape:KU,LucideCast:ZU,LucideCastle:YU,LucideCat:XU,LucideCctv:QU,LucideChartArea:aj,LucideChartBar:oj,LucideChartBarBig:ij,LucideChartBarDecreasing:JU,LucideChartBarIncreasing:eV,LucideChartBarStacked:tV,LucideChartCandlestick:lj,LucideChartColumn:to,LucideChartColumnBig:cj,LucideChartColumnDecreasing:sV,LucideChartColumnIncreasing:dj,LucideChartColumnStacked:rV,LucideChartGantt:nV,LucideChartLine:uj,LucideChartNetwork:aV,LucideChartNoAxesColumn:mj,LucideChartNoAxesColumnDecreasing:iV,LucideChartNoAxesColumnIncreasing:hj,LucideChartNoAxesCombined:oV,LucideChartNoAxesGantt:pj,LucideChartPie:fj,LucideChartScatter:xj,LucideChartSpline:lV,LucideCheck:Jn,LucideCheckCheck:oL,LucideCheckCircle:ti,LucideCheckCircle2:Qn,LucideCheckSquare:Av,LucideCheckSquare2:tk,LucideChefHat:cV,LucideCherry:dV,LucideChevronDown:Oi,LucideChevronDownCircle:kj,LucideChevronDownSquare:sk,LucideChevronFirst:uV,LucideChevronLast:hV,LucideChevronLeft:xl,LucideChevronLeftCircle:Sj,LucideChevronLeftSquare:rk,LucideChevronRight:Sa,LucideChevronRightCircle:Cj,LucideChevronRightSquare:nk,LucideChevronUp:nf,LucideChevronUpCircle:Mj,LucideChevronUpSquare:ak,LucideChevronsDown:pV,LucideChevronsDownUp:mV,LucideChevronsLeft:gV,LucideChevronsLeftRight:xV,LucideChevronsLeftRightEllipsis:fV,LucideChevronsRight:vV,LucideChevronsRightLeft:yV,LucideChevronsUp:_V,LucideChevronsUpDown:gx,LucideChrome:bV,LucideChurch:wV,LucideCigarette:NV,LucideCigaretteOff:jV,LucideCircle:sd,LucideCircleAlert:Lo,LucideCircleArrowDown:gj,LucideCircleArrowLeft:yj,LucideCircleArrowOutDownLeft:vj,LucideCircleArrowOutDownRight:_j,LucideCircleArrowOutUpLeft:bj,LucideCircleArrowOutUpRight:wj,LucideCircleArrowRight:jj,LucideCircleArrowUp:Nj,LucideCircleCheck:Qn,LucideCircleCheckBig:ti,LucideCircleChevronDown:kj,LucideCircleChevronLeft:Sj,LucideCircleChevronRight:Cj,LucideCircleChevronUp:Mj,LucideCircleDashed:kV,LucideCircleDivide:Tj,LucideCircleDollarSign:SV,LucideCircleDot:MV,LucideCircleDotDashed:CV,LucideCircleEllipsis:TV,LucideCircleEqual:AV,LucideCircleFadingArrowUp:EV,LucideCircleFadingPlus:PV,LucideCircleGauge:Aj,LucideCircleHelp:Sv,LucideCircleMinus:Ej,LucideCircleOff:IV,LucideCircleParking:Ij,LucideCircleParkingOff:Pj,LucideCirclePause:Lj,LucideCirclePercent:Dj,LucideCirclePlay:sp,LucideCirclePlus:Rj,LucideCirclePower:Oj,LucideCircleSlash:LV,LucideCircleSlash2:Fj,LucideCircleSlashed:Fj,LucideCircleStop:zj,LucideCircleUser:$j,LucideCircleUserRound:Bj,LucideCircleX:Zl,LucideCircuitBoard:DV,LucideCitrus:RV,LucideClapperboard:OV,LucideClipboard:VV,LucideClipboardCheck:yM,LucideClipboardCopy:FV,LucideClipboardEdit:Uj,LucideClipboardList:wb,LucideClipboardMinus:zV,LucideClipboardPaste:BV,LucideClipboardPen:Uj,LucideClipboardPenLine:qj,LucideClipboardPlus:$V,LucideClipboardSignature:qj,LucideClipboardType:qV,LucideClipboardX:UV,LucideClock:ln,LucideClock1:HV,LucideClock10:GV,LucideClock11:WV,LucideClock12:KV,LucideClock2:ZV,LucideClock3:YV,LucideClock4:XV,LucideClock5:QV,LucideClock6:JV,LucideClock7:eH,LucideClock8:tH,LucideClock9:sH,LucideClockAlert:rH,LucideClockArrowDown:nH,LucideClockArrowUp:aH,LucideCloud:_H,LucideCloudAlert:iH,LucideCloudCog:oH,LucideCloudDownload:Vj,LucideCloudDrizzle:lH,LucideCloudFog:cH,LucideCloudHail:dH,LucideCloudLightning:uH,LucideCloudMoon:mH,LucideCloudMoonRain:hH,LucideCloudOff:pH,LucideCloudRain:xH,LucideCloudRainWind:fH,LucideCloudSnow:gH,LucideCloudSun:vH,LucideCloudSunRain:yH,LucideCloudUpload:Hj,LucideCloudy:bH,LucideClover:Fv,LucideClub:wH,LucideCode:G4,LucideCode2:Gj,LucideCodeSquare:ik,LucideCodeXml:Gj,LucideCodepen:jH,LucideCodesandbox:NH,LucideCoffee:W4,LucideCog:kH,LucideCoins:lL,LucideColumns:Wj,LucideColumns2:Wj,LucideColumns3:Kj,LucideColumns4:SH,LucideCombine:CH,LucideCommand:MH,LucideCompass:vM,LucideComponent:TH,LucideComputer:AH,LucideConciergeBell:EH,LucideCone:PH,LucideConstruction:IH,LucideContact:K4,LucideContact2:Zj,LucideContactRound:Zj,LucideContainer:LH,LucideContrast:DH,LucideCookie:RH,LucideCookingPot:OH,LucideCopy:Ya,LucideCopyCheck:FH,LucideCopyMinus:zH,LucideCopyPlus:BH,LucideCopySlash:$H,LucideCopyX:qH,LucideCopyleft:UH,LucideCopyright:VH,LucideCornerDownLeft:HH,LucideCornerDownRight:GH,LucideCornerLeftDown:WH,LucideCornerLeftUp:KH,LucideCornerRightDown:ZH,LucideCornerRightUp:YH,LucideCornerUpLeft:XH,LucideCornerUpRight:QH,LucideCpu:JH,LucideCreativeCommons:eG,LucideCreditCard:yx,LucideCroissant:tG,LucideCrop:sG,LucideCross:rG,LucideCrosshair:nG,LucideCrown:Cm,LucideCuboid:aG,LucideCupSoda:iG,LucideCurlyBraces:rj,LucideCurrency:oG,LucideCylinder:lG,LucideDam:cG,LucideDatabase:cL,LucideDatabaseBackup:dG,LucideDatabaseZap:uG,LucideDelete:hG,LucideDessert:mG,LucideDiameter:pG,LucideDiamond:gG,LucideDiamondMinus:fG,LucideDiamondPercent:Yj,LucideDiamondPlus:xG,LucideDice1:yG,LucideDice2:vG,LucideDice3:_G,LucideDice4:bG,LucideDice5:wG,LucideDice6:jG,LucideDices:NG,LucideDiff:kG,LucideDisc:TG,LucideDisc2:SG,LucideDisc3:CG,LucideDiscAlbum:MG,LucideDivide:AG,LucideDivideCircle:Tj,LucideDivideSquare:dk,LucideDna:PG,LucideDnaOff:EG,LucideDock:IG,LucideDog:LG,LucideDollarSign:yc,LucideDonut:DG,LucideDoorClosed:RG,LucideDoorOpen:Wv,LucideDot:OG,LucideDotSquare:uk,LucideDownload:Xa,LucideDownloadCloud:Vj,LucideDraftingCompass:FG,LucideDrama:zG,LucideDribbble:BG,LucideDrill:$G,LucideDroplet:qG,LucideDroplets:Ag,LucideDrum:UG,LucideDrumstick:VG,LucideDumbbell:HG,LucideEar:WG,LucideEarOff:GG,LucideEarth:Xj,LucideEarthLock:KG,LucideEclipse:ZG,LucideEdit:Gc,LucideEdit2:Dy,LucideEdit3:Tv,LucideEgg:_M,LucideEggFried:YG,LucideEggOff:XG,LucideEllipsis:ix,LucideEllipsisVertical:ax,LucideEqual:eW,LucideEqualApproximately:QG,LucideEqualNot:JG,LucideEqualSquare:hk,LucideEraser:tW,LucideEthernetPort:sW,LucideEuro:rW,LucideExpand:nW,LucideExternalLink:Kr,LucideEye:wn,LucideEyeClosed:aW,LucideEyeOff:mp,LucideFacebook:uu,LucideFactory:iW,LucideFan:oW,LucideFastForward:lW,LucideFeather:cW,LucideFence:dW,LucideFerrisWheel:uW,LucideFigma:hW,LucideFile:bM,LucideFileArchive:mW,LucideFileAudio:fW,LucideFileAudio2:pW,LucideFileAxis3D:Qj,LucideFileAxis3d:Qj,LucideFileBadge:gW,LucideFileBadge2:xW,LucideFileBarChart:Jj,LucideFileBarChart2:eN,LucideFileBox:yW,LucideFileChartColumn:eN,LucideFileChartColumnIncreasing:Jj,LucideFileChartLine:tN,LucideFileChartPie:sN,LucideFileCheck:_W,LucideFileCheck2:vW,LucideFileClock:bW,LucideFileCode:jW,LucideFileCode2:wW,LucideFileCog:rN,LucideFileCog2:rN,LucideFileDiff:NW,LucideFileDigit:kW,LucideFileDown:Z4,LucideFileEdit:aN,LucideFileHeart:SW,LucideFileImage:jb,LucideFileInput:CW,LucideFileJson:TW,LucideFileJson2:MW,LucideFileKey:EW,LucideFileKey2:AW,LucideFileLineChart:tN,LucideFileLock:IW,LucideFileLock2:PW,LucideFileMinus:DW,LucideFileMinus2:LW,LucideFileMusic:RW,LucideFileOutput:OW,LucideFilePen:aN,LucideFilePenLine:nN,LucideFilePieChart:sN,LucideFilePlus:zW,LucideFilePlus2:FW,LucideFileQuestion:BW,LucideFileScan:$W,LucideFileSearch:UW,LucideFileSearch2:qW,LucideFileSignature:nN,LucideFileSliders:VW,LucideFileSpreadsheet:Kv,LucideFileStack:dL,LucideFileSymlink:HW,LucideFileTerminal:GW,LucideFileText:fn,LucideFileType:KW,LucideFileType2:WW,LucideFileUp:ZW,LucideFileUser:YW,LucideFileVideo:QW,LucideFileVideo2:XW,LucideFileVolume:eK,LucideFileVolume2:JW,LucideFileWarning:tK,LucideFileX:rK,LucideFileX2:sK,LucideFiles:nK,LucideFilm:tu,LucideFilter:Eg,LucideFilterX:aK,LucideFingerprint:iK,LucideFireExtinguisher:oK,LucideFish:dK,LucideFishOff:lK,LucideFishSymbol:cK,LucideFlag:Zv,LucideFlagOff:uK,LucideFlagTriangleLeft:hK,LucideFlagTriangleRight:mK,LucideFlame:ch,LucideFlameKindling:pK,LucideFlashlight:xK,LucideFlashlightOff:fK,LucideFlaskConical:Nb,LucideFlaskConicalOff:gK,LucideFlaskRound:yK,LucideFlipHorizontal:uL,LucideFlipHorizontal2:vK,LucideFlipVertical:bK,LucideFlipVertical2:_K,LucideFlower:wK,LucideFlower2:kg,LucideFocus:jK,LucideFoldHorizontal:NK,LucideFoldVertical:kK,LucideFolder:QK,LucideFolderArchive:SK,LucideFolderCheck:CK,LucideFolderClock:MK,LucideFolderClosed:TK,LucideFolderCode:AK,LucideFolderCog:iN,LucideFolderCog2:iN,LucideFolderDot:EK,LucideFolderDown:PK,LucideFolderEdit:oN,LucideFolderGit:LK,LucideFolderGit2:IK,LucideFolderHeart:DK,LucideFolderInput:RK,LucideFolderKanban:OK,LucideFolderKey:FK,LucideFolderLock:zK,LucideFolderMinus:BK,LucideFolderOpen:Mm,LucideFolderOpenDot:$K,LucideFolderOutput:qK,LucideFolderPen:oN,LucideFolderPlus:UK,LucideFolderRoot:VK,LucideFolderSearch:GK,LucideFolderSearch2:HK,LucideFolderSymlink:WK,LucideFolderSync:KK,LucideFolderTree:ZK,LucideFolderUp:YK,LucideFolderX:XK,LucideFolders:JK,LucideFootprints:eZ,LucideForkKnife:Xk,LucideForkKnifeCrossed:Yk,LucideForklift:tZ,LucideFormInput:PN,LucideForward:sZ,LucideFrame:rZ,LucideFramer:nZ,LucideFrown:aZ,LucideFuel:iZ,LucideFullscreen:oZ,LucideFunctionSquare:mk,LucideGalleryHorizontal:cZ,LucideGalleryHorizontalEnd:lZ,LucideGalleryThumbnails:dZ,LucideGalleryVertical:hZ,LucideGalleryVerticalEnd:uZ,LucideGamepad:pZ,LucideGamepad2:mZ,LucideGanttChart:pj,LucideGanttChartSquare:Ny,LucideGauge:fZ,LucideGaugeCircle:Aj,LucideGavel:xZ,LucideGem:gZ,LucideGhost:Y4,LucideGift:Ui,LucideGitBranch:vZ,LucideGitBranchPlus:yZ,LucideGitCommit:lN,LucideGitCommitHorizontal:lN,LucideGitCommitVertical:_Z,LucideGitCompare:wZ,LucideGitCompareArrows:bZ,LucideGitFork:jZ,LucideGitGraph:NZ,LucideGitMerge:kZ,LucideGitPullRequest:EZ,LucideGitPullRequestArrow:SZ,LucideGitPullRequestClosed:CZ,LucideGitPullRequestCreate:TZ,LucideGitPullRequestCreateArrow:MZ,LucideGitPullRequestDraft:AZ,LucideGithub:PZ,LucideGitlab:IZ,LucideGlassWater:LZ,LucideGlasses:DZ,LucideGlobe:gd,LucideGlobe2:Xj,LucideGlobeLock:RZ,LucideGoal:OZ,LucideGrab:FZ,LucideGraduationCap:Lh,LucideGrape:zZ,LucideGrid:Yf,LucideGrid2X2:dN,LucideGrid2X2Plus:cN,LucideGrid2x2:dN,LucideGrid2x2Check:BZ,LucideGrid2x2Plus:cN,LucideGrid2x2X:$Z,LucideGrid3X3:Yf,LucideGrid3x3:Yf,LucideGrip:UZ,LucideGripHorizontal:qZ,LucideGripVertical:hu,LucideGroup:VZ,LucideGuitar:HZ,LucideHam:GZ,LucideHammer:WZ,LucideHand:hL,LucideHandCoins:KZ,LucideHandHeart:ZZ,LucideHandHelping:uN,LucideHandMetal:YZ,LucideHandPlatter:XZ,LucideHandshake:mL,LucideHardDrive:pL,LucideHardDriveDownload:QZ,LucideHardDriveUpload:JZ,LucideHardHat:eY,LucideHash:X4,LucideHaze:tY,LucideHdmiPort:sY,LucideHeading:iY,LucideHeading1:wM,LucideHeading2:jM,LucideHeading3:fL,LucideHeading4:rY,LucideHeading5:nY,LucideHeading6:aY,LucideHeadphoneOff:oY,LucideHeadphones:lY,LucideHeadset:cY,LucideHeart:Za,LucideHeartCrack:dY,LucideHeartHandshake:uY,LucideHeartOff:hY,LucideHeartPulse:mY,LucideHeater:pY,LucideHelpCircle:Sv,LucideHelpingHand:uN,LucideHexagon:fY,LucideHighlighter:xY,LucideHistory:NM,LucideHome:Mn,LucideHop:yY,LucideHopOff:gY,LucideHospital:vY,LucideHotel:_Y,LucideHourglass:bY,LucideHouse:Mn,LucideHousePlug:wY,LucideHousePlus:jY,LucideIceCream:mN,LucideIceCream2:hN,LucideIceCreamBowl:hN,LucideIceCreamCone:mN,LucideIdCard:NY,LucideImage:Wo,LucideImageDown:kY,LucideImageMinus:SY,LucideImageOff:CY,LucideImagePlay:MY,LucideImagePlus:Yv,LucideImageUp:TY,LucideImageUpscale:AY,LucideImages:EY,LucideImport:PY,LucideInbox:IY,LucideIndent:fN,LucideIndentDecrease:pN,LucideIndentIncrease:fN,LucideIndianRupee:LY,LucideInfinity:DY,LucideInfo:Q4,LucideInspect:vk,LucideInspectionPanel:RY,LucideInstagram:mu,LucideItalic:J4,LucideIterationCcw:OY,LucideIterationCw:FY,LucideJapaneseYen:zY,LucideJoystick:BY,LucideKanban:Ky,LucideKanbanSquare:pk,LucideKanbanSquareDashed:ok,LucideKey:pp,LucideKeyRound:eS,LucideKeySquare:$Y,LucideKeyboard:VY,LucideKeyboardMusic:qY,LucideKeyboardOff:UY,LucideLamp:YY,LucideLampCeiling:HY,LucideLampDesk:GY,LucideLampFloor:WY,LucideLampWallDown:KY,LucideLampWallUp:ZY,LucideLandPlot:XY,LucideLandmark:QY,LucideLanguages:JY,LucideLaptop:tX,LucideLaptop2:xN,LucideLaptopMinimal:xN,LucideLaptopMinimalCheck:eX,LucideLasso:rX,LucideLassoSelect:sX,LucideLaugh:nX,LucideLayers:oX,LucideLayers2:aX,LucideLayers3:iX,LucideLayout:Mv,LucideLayoutDashboard:tS,LucideLayoutGrid:fp,LucideLayoutList:lX,LucideLayoutPanelLeft:cX,LucideLayoutPanelTop:dX,LucideLayoutTemplate:sS,LucideLeaf:uX,LucideLeafyGreen:hX,LucideLectern:mX,LucideLetterText:pX,LucideLibrary:kM,LucideLibraryBig:fX,LucideLibrarySquare:fk,LucideLifeBuoy:SM,LucideLigature:xX,LucideLightbulb:kb,LucideLightbulbOff:gX,LucideLineChart:uj,LucideLink:fo,LucideLink2:Do,LucideLink2Off:yX,LucideLinkedin:xp,LucideList:Dh,LucideListCheck:vX,LucideListChecks:_X,LucideListCollapse:bX,LucideListEnd:wX,LucideListFilter:jX,LucideListMinus:NX,LucideListMusic:kX,LucideListOrdered:Zy,LucideListPlus:SX,LucideListRestart:CX,LucideListStart:MX,LucideListTodo:TX,LucideListTree:AX,LucideListVideo:EX,LucideListX:PX,LucideLoader:LX,LucideLoader2:_s,LucideLoaderCircle:_s,LucideLoaderPinwheel:IX,LucideLocate:CM,LucideLocateFixed:DX,LucideLocateOff:RX,LucideLock:yd,LucideLockKeyhole:OX,LucideLockKeyholeOpen:gN,LucideLockOpen:yN,LucideLogIn:rS,LucideLogOut:MM,LucideLogs:FX,LucideLollipop:zX,LucideLuggage:BX,LucideMSquare:xk,LucideMagnet:$X,LucideMail:rr,LucideMailCheck:qX,LucideMailMinus:UX,LucideMailOpen:VX,LucideMailPlus:xL,LucideMailQuestion:HX,LucideMailSearch:GX,LucideMailWarning:WX,LucideMailX:gL,LucideMailbox:KX,LucideMails:ZX,LucideMap:nS,LucideMapPin:Da,LucideMapPinCheck:XX,LucideMapPinCheckInside:YX,LucideMapPinHouse:QX,LucideMapPinMinus:eQ,LucideMapPinMinusInside:JX,LucideMapPinOff:tQ,LucideMapPinPlus:rQ,LucideMapPinPlusInside:sQ,LucideMapPinX:aQ,LucideMapPinXInside:nQ,LucideMapPinned:iQ,LucideMartini:oQ,LucideMaximize:yL,LucideMaximize2:lQ,LucideMedal:Xv,LucideMegaphone:dh,LucideMegaphoneOff:cQ,LucideMeh:dQ,LucideMemoryStick:uQ,LucideMenu:aS,LucideMenuSquare:gk,LucideMerge:hQ,LucideMessageCircle:vc,LucideMessageCircleCode:mQ,LucideMessageCircleDashed:pQ,LucideMessageCircleHeart:TM,LucideMessageCircleMore:fQ,LucideMessageCircleOff:xQ,LucideMessageCirclePlus:gQ,LucideMessageCircleQuestion:vL,LucideMessageCircleReply:yQ,LucideMessageCircleWarning:vQ,LucideMessageCircleX:_Q,LucideMessageSquare:ki,LucideMessageSquareCode:bQ,LucideMessageSquareDashed:wQ,LucideMessageSquareDiff:jQ,LucideMessageSquareDot:NQ,LucideMessageSquareHeart:kQ,LucideMessageSquareLock:SQ,LucideMessageSquareMore:_L,LucideMessageSquareOff:CQ,LucideMessageSquarePlus:AM,LucideMessageSquareQuote:bL,LucideMessageSquareReply:MQ,LucideMessageSquareShare:TQ,LucideMessageSquareText:AQ,LucideMessageSquareWarning:EQ,LucideMessageSquareX:PQ,LucideMessagesSquare:IQ,LucideMic:wL,LucideMic2:vN,LucideMicOff:LQ,LucideMicVocal:vN,LucideMicrochip:DQ,LucideMicroscope:RQ,LucideMicrowave:OQ,LucideMilestone:FQ,LucideMilk:BQ,LucideMilkOff:zQ,LucideMinimize:qQ,LucideMinimize2:$Q,LucideMinus:Yy,LucideMinusCircle:Ej,LucideMinusSquare:yk,LucideMonitor:oS,LucideMonitorCheck:UQ,LucideMonitorCog:VQ,LucideMonitorDot:HQ,LucideMonitorDown:GQ,LucideMonitorOff:WQ,LucideMonitorPause:KQ,LucideMonitorPlay:ZQ,LucideMonitorSmartphone:YQ,LucideMonitorSpeaker:XQ,LucideMonitorStop:QQ,LucideMonitorUp:iS,LucideMonitorX:JQ,LucideMoon:tJ,LucideMoonStar:eJ,LucideMoreHorizontal:ix,LucideMoreVertical:ax,LucideMountain:rJ,LucideMountainSnow:sJ,LucideMouse:oJ,LucideMouseOff:nJ,LucideMousePointer:nu,LucideMousePointer2:aJ,LucideMousePointerBan:iJ,LucideMousePointerClick:Tm,LucideMousePointerSquareDashed:lk,LucideMove:_J,LucideMove3D:_N,LucideMove3d:_N,LucideMoveDiagonal:cJ,LucideMoveDiagonal2:lJ,LucideMoveDown:hJ,LucideMoveDownLeft:dJ,LucideMoveDownRight:uJ,LucideMoveHorizontal:mJ,LucideMoveLeft:pJ,LucideMoveRight:fJ,LucideMoveUp:yJ,LucideMoveUpLeft:xJ,LucideMoveUpRight:gJ,LucideMoveVertical:vJ,LucideMusic:NJ,LucideMusic2:bJ,LucideMusic3:wJ,LucideMusic4:jJ,LucideNavigation:jL,LucideNavigation2:SJ,LucideNavigation2Off:kJ,LucideNavigationOff:CJ,LucideNetwork:MJ,LucideNewspaper:Qv,LucideNfc:TJ,LucideNotebook:IJ,LucideNotebookPen:AJ,LucideNotebookTabs:EJ,LucideNotebookText:PJ,LucideNotepadText:DJ,LucideNotepadTextDashed:LJ,LucideNut:OJ,LucideNutOff:RJ,LucideOctagon:zJ,LucideOctagonAlert:Cv,LucideOctagonMinus:FJ,LucideOctagonPause:bN,LucideOctagonX:wN,LucideOmega:BJ,LucideOption:$J,LucideOrbit:qJ,LucideOrigami:UJ,LucideOutdent:pN,LucidePackage:nl,LucidePackage2:VJ,LucidePackageCheck:HJ,LucidePackageMinus:GJ,LucidePackageOpen:WJ,LucidePackagePlus:KJ,LucidePackageSearch:ZJ,LucidePackageX:YJ,LucidePaintBucket:XJ,LucidePaintRoller:QJ,LucidePaintbrush:JJ,LucidePaintbrush2:jN,LucidePaintbrushVertical:jN,LucidePalette:Dl,LucidePalmtree:Bk,LucidePanelBottom:see,LucidePanelBottomClose:eee,LucidePanelBottomDashed:NN,LucidePanelBottomInactive:NN,LucidePanelBottomOpen:tee,LucidePanelLeft:MN,LucidePanelLeftClose:kN,LucidePanelLeftDashed:SN,LucidePanelLeftInactive:SN,LucidePanelLeftOpen:CN,LucidePanelRight:aee,LucidePanelRightClose:ree,LucidePanelRightDashed:TN,LucidePanelRightInactive:TN,LucidePanelRightOpen:nee,LucidePanelTop:lee,LucidePanelTopClose:iee,LucidePanelTopDashed:AN,LucidePanelTopInactive:AN,LucidePanelTopOpen:oee,LucidePanelsLeftBottom:cee,LucidePanelsLeftRight:Kj,LucidePanelsRightBottom:dee,LucidePanelsTopBottom:DN,LucidePanelsTopLeft:Mv,LucidePaperclip:lS,LucideParentheses:uee,LucideParkingCircle:Ij,LucideParkingCircleOff:Pj,LucideParkingMeter:hee,LucideParkingSquare:bk,LucideParkingSquareOff:_k,LucidePartyPopper:Bd,LucidePause:uh,LucidePauseCircle:Lj,LucidePauseOctagon:bN,LucidePawPrint:mee,LucidePcCase:pee,LucidePen:Dy,LucidePenBox:Gc,LucidePenLine:Tv,LucidePenOff:fee,LucidePenSquare:Gc,LucidePenTool:Sb,LucidePencil:ga,LucidePencilLine:xee,LucidePencilOff:gee,LucidePencilRuler:yee,LucidePentagon:vee,LucidePercent:EM,LucidePercentCircle:Dj,LucidePercentDiamond:Yj,LucidePercentSquare:wk,LucidePersonStanding:_ee,LucidePhilippinePeso:bee,LucidePhone:Pn,LucidePhoneCall:wee,LucidePhoneForwarded:jee,LucidePhoneIncoming:Nee,LucidePhoneMissed:kee,LucidePhoneOff:See,LucidePhoneOutgoing:Cee,LucidePi:Mee,LucidePiSquare:jk,LucidePiano:Tee,LucidePickaxe:Aee,LucidePictureInPicture:Pee,LucidePictureInPicture2:Eee,LucidePieChart:fj,LucidePiggyBank:Iee,LucidePilcrow:Ree,LucidePilcrowLeft:Lee,LucidePilcrowRight:Dee,LucidePilcrowSquare:Nk,LucidePill:Fee,LucidePillBottle:Oee,LucidePin:Cb,LucidePinOff:NL,LucidePipette:zee,LucidePizza:Bee,LucidePlane:Uee,LucidePlaneLanding:$ee,LucidePlaneTakeoff:qee,LucidePlay:So,LucidePlayCircle:sp,LucidePlaySquare:kk,LucidePlug:kL,LucidePlug2:Vee,LucidePlugZap:EN,LucidePlugZap2:EN,LucidePlus:Us,LucidePlusCircle:Rj,LucidePlusSquare:Sk,LucidePocket:Gee,LucidePocketKnife:Hee,LucidePodcast:Wee,LucidePointer:Zee,LucidePointerOff:Kee,LucidePopcorn:Yee,LucidePopsicle:Xee,LucidePoundSterling:Qee,LucidePower:SL,LucidePowerCircle:Oj,LucidePowerOff:Jee,LucidePowerSquare:Ck,LucidePresentation:Pg,LucidePrinter:CL,LucidePrinterCheck:ete,LucideProjector:tte,LucideProportions:ste,LucidePuzzle:rte,LucidePyramid:nte,LucideQrCode:Xy,LucideQuote:cS,LucideRabbit:ate,LucideRadar:ite,LucideRadiation:ote,LucideRadical:lte,LucideRadio:Jv,LucideRadioReceiver:cte,LucideRadioTower:dte,LucideRadius:ute,LucideRailSymbol:hte,LucideRainbow:mte,LucideRat:pte,LucideRatio:fte,LucideReceipt:Nte,LucideReceiptCent:xte,LucideReceiptEuro:gte,LucideReceiptIndianRupee:yte,LucideReceiptJapaneseYen:vte,LucideReceiptPoundSterling:_te,LucideReceiptRussianRuble:bte,LucideReceiptSwissFranc:wte,LucideReceiptText:jte,LucideRectangleEllipsis:PN,LucideRectangleHorizontal:kte,LucideRectangleVertical:Ste,LucideRecycle:Cte,LucideRedo:dS,LucideRedo2:Mte,LucideRedoDot:Tte,LucideRefreshCcw:PM,LucideRefreshCcwDot:Ate,LucideRefreshCw:oo,LucideRefreshCwOff:Ete,LucideRefrigerator:Pte,LucideRegex:Ite,LucideRemoveFormatting:Lte,LucideRepeat:ML,LucideRepeat1:Dte,LucideRepeat2:Rte,LucideReplace:Fte,LucideReplaceAll:Ote,LucideReply:TL,LucideReplyAll:zte,LucideRewind:Bte,LucideRibbon:$te,LucideRocket:Qy,LucideRockingChair:qte,LucideRollerCoaster:Ute,LucideRotate3D:IN,LucideRotate3d:IN,LucideRotateCcw:Jy,LucideRotateCcwSquare:Vte,LucideRotateCw:AL,LucideRotateCwSquare:Hte,LucideRoute:Wte,LucideRouteOff:Gte,LucideRouter:Kte,LucideRows:LN,LucideRows2:LN,LucideRows3:DN,LucideRows4:Zte,LucideRss:Yte,LucideRuler:uS,LucideRussianRuble:Xte,LucideSailboat:Qte,LucideSalad:Jte,LucideSandwich:ese,LucideSatellite:sse,LucideSatelliteDish:tse,LucideSave:_c,LucideSaveAll:rse,LucideSaveOff:nse,LucideScale:EL,LucideScale3D:RN,LucideScale3d:RN,LucideScaling:ase,LucideScan:mse,LucideScanBarcode:ise,LucideScanEye:ose,LucideScanFace:lse,LucideScanLine:cse,LucideScanQrCode:dse,LucideScanSearch:use,LucideScanText:hse,LucideScatterChart:xj,LucideSchool:pse,LucideSchool2:qk,LucideScissors:xse,LucideScissorsLineDashed:fse,LucideScissorsSquare:Mk,LucideScissorsSquareDashedBottom:ek,LucideScreenShare:yse,LucideScreenShareOff:gse,LucideScroll:_se,LucideScrollText:vse,LucideSearch:an,LucideSearchCheck:bse,LucideSearchCode:wse,LucideSearchSlash:jse,LucideSearchX:PL,LucideSection:Nse,LucideSend:An,LucideSendHorizonal:ON,LucideSendHorizontal:ON,LucideSendToBack:kse,LucideSeparatorHorizontal:Sse,LucideSeparatorVertical:Cse,LucideServer:Ese,LucideServerCog:Mse,LucideServerCrash:Tse,LucideServerOff:Ase,LucideSettings:ko,LucideSettings2:IL,LucideShapes:Pse,LucideShare:LL,LucideShare2:vd,LucideSheet:Ise,LucideShell:Lse,LucideShield:Ou,LucideShieldAlert:Dse,LucideShieldBan:Rse,LucideShieldCheck:hS,LucideShieldClose:FN,LucideShieldEllipsis:Ose,LucideShieldHalf:Fse,LucideShieldMinus:zse,LucideShieldOff:mS,LucideShieldPlus:Bse,LucideShieldQuestion:$se,LucideShieldX:FN,LucideShip:Use,LucideShipWheel:qse,LucideShirt:Vse,LucideShoppingBag:e0,LucideShoppingBasket:Hse,LucideShoppingCart:op,LucideShovel:Gse,LucideShowerHead:Wse,LucideShrink:Kse,LucideShrub:Zse,LucideShuffle:pS,LucideSidebar:MN,LucideSidebarClose:kN,LucideSidebarOpen:CN,LucideSigma:Yse,LucideSigmaSquare:Tk,LucideSignal:tre,LucideSignalHigh:Xse,LucideSignalLow:Qse,LucideSignalMedium:Jse,LucideSignalZero:ere,LucideSignature:sre,LucideSignpost:nre,LucideSignpostBig:rre,LucideSiren:are,LucideSkipBack:ire,LucideSkipForward:ore,LucideSkull:lre,LucideSlack:cre,LucideSlash:dre,LucideSlashSquare:Ak,LucideSlice:ure,LucideSliders:zN,LucideSlidersHorizontal:fS,LucideSlidersVertical:zN,LucideSmartphone:t0,LucideSmartphoneCharging:hre,LucideSmartphoneNfc:mre,LucideSmile:fre,LucideSmilePlus:pre,LucideSnail:xre,LucideSnowflake:zv,LucideSofa:gre,LucideSortAsc:Y2,LucideSortDesc:W2,LucideSoup:yre,LucideSpace:vre,LucideSpade:_re,LucideSparkle:bre,LucideSparkles:$r,LucideSpeaker:wre,LucideSpeech:jre,LucideSpellCheck:kre,LucideSpellCheck2:Nre,LucideSpline:Sre,LucideSplit:Cre,LucideSplitSquareHorizontal:Ek,LucideSplitSquareVertical:Pk,LucideSprayCan:Mre,LucideSprout:xS,LucideSquare:s0,LucideSquareActivity:BN,LucideSquareArrowDown:UN,LucideSquareArrowDownLeft:$N,LucideSquareArrowDownRight:qN,LucideSquareArrowLeft:VN,LucideSquareArrowOutDownLeft:HN,LucideSquareArrowOutDownRight:GN,LucideSquareArrowOutUpLeft:WN,LucideSquareArrowOutUpRight:KN,LucideSquareArrowRight:ZN,LucideSquareArrowUp:QN,LucideSquareArrowUpLeft:YN,LucideSquareArrowUpRight:XN,LucideSquareAsterisk:JN,LucideSquareBottomDashedScissors:ek,LucideSquareChartGantt:Ny,LucideSquareCheck:tk,LucideSquareCheckBig:Av,LucideSquareChevronDown:sk,LucideSquareChevronLeft:rk,LucideSquareChevronRight:nk,LucideSquareChevronUp:ak,LucideSquareCode:ik,LucideSquareDashed:ck,LucideSquareDashedBottom:Are,LucideSquareDashedBottomCode:Tre,LucideSquareDashedKanban:ok,LucideSquareDashedMousePointer:lk,LucideSquareDivide:dk,LucideSquareDot:uk,LucideSquareEqual:hk,LucideSquareFunction:mk,LucideSquareGanttChart:Ny,LucideSquareKanban:pk,LucideSquareLibrary:fk,LucideSquareM:xk,LucideSquareMenu:gk,LucideSquareMinus:yk,LucideSquareMousePointer:vk,LucideSquareParking:bk,LucideSquareParkingOff:_k,LucideSquarePen:Gc,LucideSquarePercent:wk,LucideSquarePi:jk,LucideSquarePilcrow:Nk,LucideSquarePlay:kk,LucideSquarePlus:Sk,LucideSquarePower:Ck,LucideSquareRadical:Ere,LucideSquareScissors:Mk,LucideSquareSigma:Tk,LucideSquareSlash:Ak,LucideSquareSplitHorizontal:Ek,LucideSquareSplitVertical:Pk,LucideSquareSquare:Pre,LucideSquareStack:Ire,LucideSquareTerminal:Ik,LucideSquareUser:Dk,LucideSquareUserRound:Lk,LucideSquareX:Rk,LucideSquircle:Lre,LucideSquirrel:Dre,LucideStamp:Rre,LucideStar:Hn,LucideStarHalf:Ore,LucideStarOff:Fre,LucideStars:$r,LucideStepBack:zre,LucideStepForward:Bre,LucideStethoscope:$re,LucideSticker:qre,LucideStickyNote:Ure,LucideStopCircle:zj,LucideStore:Vre,LucideStretchHorizontal:Hre,LucideStretchVertical:Gre,LucideStrikethrough:DL,LucideSubscript:Wre,LucideSubtitles:nj,LucideSun:e1,LucideSunDim:Kre,LucideSunMedium:Zre,LucideSunMoon:Yre,LucideSunSnow:Xre,LucideSunrise:Qre,LucideSunset:Jre,LucideSuperscript:ene,LucideSwatchBook:tne,LucideSwissFranc:sne,LucideSwitchCamera:rne,LucideSword:nne,LucideSwords:ane,LucideSyringe:ine,LucideTable:LM,LucideTable2:IM,LucideTableCellsMerge:one,LucideTableCellsSplit:lne,LucideTableColumnsSplit:cne,LucideTableOfContents:dne,LucideTableProperties:une,LucideTableRowsSplit:hne,LucideTablet:pne,LucideTabletSmartphone:mne,LucideTablets:fne,LucideTag:hh,LucideTags:xne,LucideTally1:gne,LucideTally2:yne,LucideTally3:vne,LucideTally4:_ne,LucideTally5:bne,LucideTangent:wne,LucideTarget:Rh,LucideTelescope:jne,LucideTent:kne,LucideTentTree:Nne,LucideTerminal:Sne,LucideTerminalSquare:Ik,LucideTestTube:Cne,LucideTestTube2:Ok,LucideTestTubeDiagonal:Ok,LucideTestTubes:Mne,LucideText:Ine,LucideTextCursor:Ane,LucideTextCursorInput:Tne,LucideTextQuote:Ene,LucideTextSearch:Pne,LucideTextSelect:Fk,LucideTextSelection:Fk,LucideTheater:Lne,LucideThermometer:One,LucideThermometerSnowflake:Dne,LucideThermometerSun:Rne,LucideThumbsDown:RL,LucideThumbsUp:Fu,LucideTicket:OL,LucideTicketCheck:Fne,LucideTicketMinus:zne,LucideTicketPercent:Bne,LucideTicketPlus:$ne,LucideTicketSlash:qne,LucideTicketX:Une,LucideTickets:Hne,LucideTicketsPlane:Vne,LucideTimer:Kne,LucideTimerOff:Gne,LucideTimerReset:Wne,LucideToggleLeft:Zne,LucideToggleRight:Yne,LucideToilet:Xne,LucideTornado:Qne,LucideTorus:Jne,LucideTouchpad:tae,LucideTouchpadOff:eae,LucideTowerControl:sae,LucideToyBrick:rae,LucideTractor:nae,LucideTrafficCone:aae,LucideTrain:zk,LucideTrainFront:oae,LucideTrainFrontTunnel:iae,LucideTrainTrack:lae,LucideTramFront:zk,LucideTrash:cae,LucideTrash2:gr,LucideTreeDeciduous:dae,LucideTreePalm:Bk,LucideTreePine:Mb,LucideTrees:uae,LucideTrello:hae,LucideTrendingDown:gS,LucideTrendingUp:Yo,LucideTrendingUpDown:mae,LucideTriangle:fae,LucideTriangleAlert:Qc,LucideTriangleRight:pae,LucideTrophy:Vi,LucideTruck:FL,LucideTurtle:xae,LucideTv:yae,LucideTv2:$k,LucideTvMinimal:$k,LucideTvMinimalPlay:gae,LucideTwitch:vae,LucideTwitter:_ae,LucideType:wae,LucideTypeOutline:bae,LucideUmbrella:Nae,LucideUmbrellaOff:jae,LucideUnderline:zL,LucideUndo:yS,LucideUndo2:kae,LucideUndoDot:Sae,LucideUnfoldHorizontal:Cae,LucideUnfoldVertical:Mae,LucideUngroup:Tae,LucideUniversity:qk,LucideUnlink:vS,LucideUnlink2:Aae,LucideUnlock:yN,LucideUnlockKeyhole:gN,LucideUnplug:Eae,LucideUpload:$a,LucideUploadCloud:Hj,LucideUsb:Pae,LucideUser:Ti,LucideUser2:Kk,LucideUserCheck:Tb,LucideUserCheck2:Uk,LucideUserCircle:$j,LucideUserCircle2:Bj,LucideUserCog:BL,LucideUserCog2:Vk,LucideUserMinus:$L,LucideUserMinus2:Hk,LucideUserPen:Iae,LucideUserPlus:al,LucideUserPlus2:Gk,LucideUserRound:Kk,LucideUserRoundCheck:Uk,LucideUserRoundCog:Vk,LucideUserRoundMinus:Hk,LucideUserRoundPen:Lae,LucideUserRoundPlus:Gk,LucideUserRoundSearch:Dae,LucideUserRoundX:Wk,LucideUserSearch:Rae,LucideUserSquare:Dk,LucideUserSquare2:Lk,LucideUserX:Oae,LucideUserX2:Wk,LucideUsers:lr,LucideUsers2:Zk,LucideUsersRound:Zk,LucideUtensils:Xk,LucideUtensilsCrossed:Yk,LucideUtilityPole:Fae,LucideVariable:DM,LucideVault:zae,LucideVegan:Bae,LucideVenetianMask:$ae,LucideVerified:J2,LucideVibrate:Uae,LucideVibrateOff:qae,LucideVideo:Tn,LucideVideoOff:Vae,LucideVideotape:Hae,LucideView:Gae,LucideVoicemail:Wae,LucideVolleyball:Kae,LucideVolume:Jae,LucideVolume1:Zae,LucideVolume2:Yae,LucideVolumeOff:Xae,LucideVolumeX:Qae,LucideVote:eie,LucideWallet:qL,LucideWallet2:Qk,LucideWalletCards:tie,LucideWalletMinimal:Qk,LucideWallpaper:sie,LucideWand:rie,LucideWand2:Ev,LucideWandSparkles:Ev,LucideWarehouse:nie,LucideWashingMachine:aie,LucideWatch:iie,LucideWaves:oie,LucideWaypoints:lie,LucideWebcam:cie,LucideWebhook:uie,LucideWebhookOff:die,LucideWeight:hie,LucideWheat:pie,LucideWheatOff:mie,LucideWholeWord:fie,LucideWifi:_ie,LucideWifiHigh:xie,LucideWifiLow:gie,LucideWifiOff:yie,LucideWifiZero:vie,LucideWind:wie,LucideWindArrowDown:bie,LucideWine:Nie,LucideWineOff:jie,LucideWorkflow:kie,LucideWorm:Sie,LucideWrapText:Cie,LucideWrench:Ig,LucideX:Sr,LucideXCircle:Zl,LucideXOctagon:wN,LucideXSquare:Rk,LucideYoutube:Mie,LucideZap:Oh,LucideZapOff:Tie,LucideZoomIn:Ab,LucideZoomOut:RM,Luggage:BX,LuggageIcon:BX,MSquare:xk,MSquareIcon:xk,Magnet:$X,MagnetIcon:$X,Mail:rr,MailCheck:qX,MailCheckIcon:qX,MailIcon:rr,MailMinus:UX,MailMinusIcon:UX,MailOpen:VX,MailOpenIcon:VX,MailPlus:xL,MailPlusIcon:xL,MailQuestion:HX,MailQuestionIcon:HX,MailSearch:GX,MailSearchIcon:GX,MailWarning:WX,MailWarningIcon:WX,MailX:gL,MailXIcon:gL,Mailbox:KX,MailboxIcon:KX,Mails:ZX,MailsIcon:ZX,Map:nS,MapIcon:nS,MapPin:Da,MapPinCheck:XX,MapPinCheckIcon:XX,MapPinCheckInside:YX,MapPinCheckInsideIcon:YX,MapPinHouse:QX,MapPinHouseIcon:QX,MapPinIcon:Da,MapPinMinus:eQ,MapPinMinusIcon:eQ,MapPinMinusInside:JX,MapPinMinusInsideIcon:JX,MapPinOff:tQ,MapPinOffIcon:tQ,MapPinPlus:rQ,MapPinPlusIcon:rQ,MapPinPlusInside:sQ,MapPinPlusInsideIcon:sQ,MapPinX:aQ,MapPinXIcon:aQ,MapPinXInside:nQ,MapPinXInsideIcon:nQ,MapPinned:iQ,MapPinnedIcon:iQ,Martini:oQ,MartiniIcon:oQ,Maximize:yL,Maximize2:lQ,Maximize2Icon:lQ,MaximizeIcon:yL,Medal:Xv,MedalIcon:Xv,Megaphone:dh,MegaphoneIcon:dh,MegaphoneOff:cQ,MegaphoneOffIcon:cQ,Meh:dQ,MehIcon:dQ,MemoryStick:uQ,MemoryStickIcon:uQ,Menu:aS,MenuIcon:aS,MenuSquare:gk,MenuSquareIcon:gk,Merge:hQ,MergeIcon:hQ,MessageCircle:vc,MessageCircleCode:mQ,MessageCircleCodeIcon:mQ,MessageCircleDashed:pQ,MessageCircleDashedIcon:pQ,MessageCircleHeart:TM,MessageCircleHeartIcon:TM,MessageCircleIcon:vc,MessageCircleMore:fQ,MessageCircleMoreIcon:fQ,MessageCircleOff:xQ,MessageCircleOffIcon:xQ,MessageCirclePlus:gQ,MessageCirclePlusIcon:gQ,MessageCircleQuestion:vL,MessageCircleQuestionIcon:vL,MessageCircleReply:yQ,MessageCircleReplyIcon:yQ,MessageCircleWarning:vQ,MessageCircleWarningIcon:vQ,MessageCircleX:_Q,MessageCircleXIcon:_Q,MessageSquare:ki,MessageSquareCode:bQ,MessageSquareCodeIcon:bQ,MessageSquareDashed:wQ,MessageSquareDashedIcon:wQ,MessageSquareDiff:jQ,MessageSquareDiffIcon:jQ,MessageSquareDot:NQ,MessageSquareDotIcon:NQ,MessageSquareHeart:kQ,MessageSquareHeartIcon:kQ,MessageSquareIcon:ki,MessageSquareLock:SQ,MessageSquareLockIcon:SQ,MessageSquareMore:_L,MessageSquareMoreIcon:_L,MessageSquareOff:CQ,MessageSquareOffIcon:CQ,MessageSquarePlus:AM,MessageSquarePlusIcon:AM,MessageSquareQuote:bL,MessageSquareQuoteIcon:bL,MessageSquareReply:MQ,MessageSquareReplyIcon:MQ,MessageSquareShare:TQ,MessageSquareShareIcon:TQ,MessageSquareText:AQ,MessageSquareTextIcon:AQ,MessageSquareWarning:EQ,MessageSquareWarningIcon:EQ,MessageSquareX:PQ,MessageSquareXIcon:PQ,MessagesSquare:IQ,MessagesSquareIcon:IQ,Mic:wL,Mic2:vN,Mic2Icon:vN,MicIcon:wL,MicOff:LQ,MicOffIcon:LQ,MicVocal:vN,MicVocalIcon:vN,Microchip:DQ,MicrochipIcon:DQ,Microscope:RQ,MicroscopeIcon:RQ,Microwave:OQ,MicrowaveIcon:OQ,Milestone:FQ,MilestoneIcon:FQ,Milk:BQ,MilkIcon:BQ,MilkOff:zQ,MilkOffIcon:zQ,Minimize:qQ,Minimize2:$Q,Minimize2Icon:$Q,MinimizeIcon:qQ,Minus:Yy,MinusCircle:Ej,MinusCircleIcon:Ej,MinusIcon:Yy,MinusSquare:yk,MinusSquareIcon:yk,Monitor:oS,MonitorCheck:UQ,MonitorCheckIcon:UQ,MonitorCog:VQ,MonitorCogIcon:VQ,MonitorDot:HQ,MonitorDotIcon:HQ,MonitorDown:GQ,MonitorDownIcon:GQ,MonitorIcon:oS,MonitorOff:WQ,MonitorOffIcon:WQ,MonitorPause:KQ,MonitorPauseIcon:KQ,MonitorPlay:ZQ,MonitorPlayIcon:ZQ,MonitorSmartphone:YQ,MonitorSmartphoneIcon:YQ,MonitorSpeaker:XQ,MonitorSpeakerIcon:XQ,MonitorStop:QQ,MonitorStopIcon:QQ,MonitorUp:iS,MonitorUpIcon:iS,MonitorX:JQ,MonitorXIcon:JQ,Moon:tJ,MoonIcon:tJ,MoonStar:eJ,MoonStarIcon:eJ,MoreHorizontal:ix,MoreHorizontalIcon:ix,MoreVertical:ax,MoreVerticalIcon:ax,Mountain:rJ,MountainIcon:rJ,MountainSnow:sJ,MountainSnowIcon:sJ,Mouse:oJ,MouseIcon:oJ,MouseOff:nJ,MouseOffIcon:nJ,MousePointer:nu,MousePointer2:aJ,MousePointer2Icon:aJ,MousePointerBan:iJ,MousePointerBanIcon:iJ,MousePointerClick:Tm,MousePointerClickIcon:Tm,MousePointerIcon:nu,MousePointerSquareDashed:lk,MousePointerSquareDashedIcon:lk,Move:_J,Move3D:_N,Move3DIcon:_N,Move3d:_N,Move3dIcon:_N,MoveDiagonal:cJ,MoveDiagonal2:lJ,MoveDiagonal2Icon:lJ,MoveDiagonalIcon:cJ,MoveDown:hJ,MoveDownIcon:hJ,MoveDownLeft:dJ,MoveDownLeftIcon:dJ,MoveDownRight:uJ,MoveDownRightIcon:uJ,MoveHorizontal:mJ,MoveHorizontalIcon:mJ,MoveIcon:_J,MoveLeft:pJ,MoveLeftIcon:pJ,MoveRight:fJ,MoveRightIcon:fJ,MoveUp:yJ,MoveUpIcon:yJ,MoveUpLeft:xJ,MoveUpLeftIcon:xJ,MoveUpRight:gJ,MoveUpRightIcon:gJ,MoveVertical:vJ,MoveVerticalIcon:vJ,Music:NJ,Music2:bJ,Music2Icon:bJ,Music3:wJ,Music3Icon:wJ,Music4:jJ,Music4Icon:jJ,MusicIcon:NJ,Navigation:jL,Navigation2:SJ,Navigation2Icon:SJ,Navigation2Off:kJ,Navigation2OffIcon:kJ,NavigationIcon:jL,NavigationOff:CJ,NavigationOffIcon:CJ,Network:MJ,NetworkIcon:MJ,Newspaper:Qv,NewspaperIcon:Qv,Nfc:TJ,NfcIcon:TJ,Notebook:IJ,NotebookIcon:IJ,NotebookPen:AJ,NotebookPenIcon:AJ,NotebookTabs:EJ,NotebookTabsIcon:EJ,NotebookText:PJ,NotebookTextIcon:PJ,NotepadText:DJ,NotepadTextDashed:LJ,NotepadTextDashedIcon:LJ,NotepadTextIcon:DJ,Nut:OJ,NutIcon:OJ,NutOff:RJ,NutOffIcon:RJ,Octagon:zJ,OctagonAlert:Cv,OctagonAlertIcon:Cv,OctagonIcon:zJ,OctagonMinus:FJ,OctagonMinusIcon:FJ,OctagonPause:bN,OctagonPauseIcon:bN,OctagonX:wN,OctagonXIcon:wN,Omega:BJ,OmegaIcon:BJ,Option:$J,OptionIcon:$J,Orbit:qJ,OrbitIcon:qJ,Origami:UJ,OrigamiIcon:UJ,Outdent:pN,OutdentIcon:pN,Package:nl,Package2:VJ,Package2Icon:VJ,PackageCheck:HJ,PackageCheckIcon:HJ,PackageIcon:nl,PackageMinus:GJ,PackageMinusIcon:GJ,PackageOpen:WJ,PackageOpenIcon:WJ,PackagePlus:KJ,PackagePlusIcon:KJ,PackageSearch:ZJ,PackageSearchIcon:ZJ,PackageX:YJ,PackageXIcon:YJ,PaintBucket:XJ,PaintBucketIcon:XJ,PaintRoller:QJ,PaintRollerIcon:QJ,Paintbrush:JJ,Paintbrush2:jN,Paintbrush2Icon:jN,PaintbrushIcon:JJ,PaintbrushVertical:jN,PaintbrushVerticalIcon:jN,Palette:Dl,PaletteIcon:Dl,Palmtree:Bk,PalmtreeIcon:Bk,PanelBottom:see,PanelBottomClose:eee,PanelBottomCloseIcon:eee,PanelBottomDashed:NN,PanelBottomDashedIcon:NN,PanelBottomIcon:see,PanelBottomInactive:NN,PanelBottomInactiveIcon:NN,PanelBottomOpen:tee,PanelBottomOpenIcon:tee,PanelLeft:MN,PanelLeftClose:kN,PanelLeftCloseIcon:kN,PanelLeftDashed:SN,PanelLeftDashedIcon:SN,PanelLeftIcon:MN,PanelLeftInactive:SN,PanelLeftInactiveIcon:SN,PanelLeftOpen:CN,PanelLeftOpenIcon:CN,PanelRight:aee,PanelRightClose:ree,PanelRightCloseIcon:ree,PanelRightDashed:TN,PanelRightDashedIcon:TN,PanelRightIcon:aee,PanelRightInactive:TN,PanelRightInactiveIcon:TN,PanelRightOpen:nee,PanelRightOpenIcon:nee,PanelTop:lee,PanelTopClose:iee,PanelTopCloseIcon:iee,PanelTopDashed:AN,PanelTopDashedIcon:AN,PanelTopIcon:lee,PanelTopInactive:AN,PanelTopInactiveIcon:AN,PanelTopOpen:oee,PanelTopOpenIcon:oee,PanelsLeftBottom:cee,PanelsLeftBottomIcon:cee,PanelsLeftRight:Kj,PanelsLeftRightIcon:Kj,PanelsRightBottom:dee,PanelsRightBottomIcon:dee,PanelsTopBottom:DN,PanelsTopBottomIcon:DN,PanelsTopLeft:Mv,PanelsTopLeftIcon:Mv,Paperclip:lS,PaperclipIcon:lS,Parentheses:uee,ParenthesesIcon:uee,ParkingCircle:Ij,ParkingCircleIcon:Ij,ParkingCircleOff:Pj,ParkingCircleOffIcon:Pj,ParkingMeter:hee,ParkingMeterIcon:hee,ParkingSquare:bk,ParkingSquareIcon:bk,ParkingSquareOff:_k,ParkingSquareOffIcon:_k,PartyPopper:Bd,PartyPopperIcon:Bd,Pause:uh,PauseCircle:Lj,PauseCircleIcon:Lj,PauseIcon:uh,PauseOctagon:bN,PauseOctagonIcon:bN,PawPrint:mee,PawPrintIcon:mee,PcCase:pee,PcCaseIcon:pee,Pen:Dy,PenBox:Gc,PenBoxIcon:Gc,PenIcon:Dy,PenLine:Tv,PenLineIcon:Tv,PenOff:fee,PenOffIcon:fee,PenSquare:Gc,PenSquareIcon:Gc,PenTool:Sb,PenToolIcon:Sb,Pencil:ga,PencilIcon:ga,PencilLine:xee,PencilLineIcon:xee,PencilOff:gee,PencilOffIcon:gee,PencilRuler:yee,PencilRulerIcon:yee,Pentagon:vee,PentagonIcon:vee,Percent:EM,PercentCircle:Dj,PercentCircleIcon:Dj,PercentDiamond:Yj,PercentDiamondIcon:Yj,PercentIcon:EM,PercentSquare:wk,PercentSquareIcon:wk,PersonStanding:_ee,PersonStandingIcon:_ee,PhilippinePeso:bee,PhilippinePesoIcon:bee,Phone:Pn,PhoneCall:wee,PhoneCallIcon:wee,PhoneForwarded:jee,PhoneForwardedIcon:jee,PhoneIcon:Pn,PhoneIncoming:Nee,PhoneIncomingIcon:Nee,PhoneMissed:kee,PhoneMissedIcon:kee,PhoneOff:See,PhoneOffIcon:See,PhoneOutgoing:Cee,PhoneOutgoingIcon:Cee,Pi:Mee,PiIcon:Mee,PiSquare:jk,PiSquareIcon:jk,Piano:Tee,PianoIcon:Tee,Pickaxe:Aee,PickaxeIcon:Aee,PictureInPicture:Pee,PictureInPicture2:Eee,PictureInPicture2Icon:Eee,PictureInPictureIcon:Pee,PieChart:fj,PieChartIcon:fj,PiggyBank:Iee,PiggyBankIcon:Iee,Pilcrow:Ree,PilcrowIcon:Ree,PilcrowLeft:Lee,PilcrowLeftIcon:Lee,PilcrowRight:Dee,PilcrowRightIcon:Dee,PilcrowSquare:Nk,PilcrowSquareIcon:Nk,Pill:Fee,PillBottle:Oee,PillBottleIcon:Oee,PillIcon:Fee,Pin:Cb,PinIcon:Cb,PinOff:NL,PinOffIcon:NL,Pipette:zee,PipetteIcon:zee,Pizza:Bee,PizzaIcon:Bee,Plane:Uee,PlaneIcon:Uee,PlaneLanding:$ee,PlaneLandingIcon:$ee,PlaneTakeoff:qee,PlaneTakeoffIcon:qee,Play:So,PlayCircle:sp,PlayCircleIcon:sp,PlayIcon:So,PlaySquare:kk,PlaySquareIcon:kk,Plug:kL,Plug2:Vee,Plug2Icon:Vee,PlugIcon:kL,PlugZap:EN,PlugZap2:EN,PlugZap2Icon:EN,PlugZapIcon:EN,Plus:Us,PlusCircle:Rj,PlusCircleIcon:Rj,PlusIcon:Us,PlusSquare:Sk,PlusSquareIcon:Sk,Pocket:Gee,PocketIcon:Gee,PocketKnife:Hee,PocketKnifeIcon:Hee,Podcast:Wee,PodcastIcon:Wee,Pointer:Zee,PointerIcon:Zee,PointerOff:Kee,PointerOffIcon:Kee,Popcorn:Yee,PopcornIcon:Yee,Popsicle:Xee,PopsicleIcon:Xee,PoundSterling:Qee,PoundSterlingIcon:Qee,Power:SL,PowerCircle:Oj,PowerCircleIcon:Oj,PowerIcon:SL,PowerOff:Jee,PowerOffIcon:Jee,PowerSquare:Ck,PowerSquareIcon:Ck,Presentation:Pg,PresentationIcon:Pg,Printer:CL,PrinterCheck:ete,PrinterCheckIcon:ete,PrinterIcon:CL,Projector:tte,ProjectorIcon:tte,Proportions:ste,ProportionsIcon:ste,Puzzle:rte,PuzzleIcon:rte,Pyramid:nte,PyramidIcon:nte,QrCode:Xy,QrCodeIcon:Xy,Quote:cS,QuoteIcon:cS,Rabbit:ate,RabbitIcon:ate,Radar:ite,RadarIcon:ite,Radiation:ote,RadiationIcon:ote,Radical:lte,RadicalIcon:lte,Radio:Jv,RadioIcon:Jv,RadioReceiver:cte,RadioReceiverIcon:cte,RadioTower:dte,RadioTowerIcon:dte,Radius:ute,RadiusIcon:ute,RailSymbol:hte,RailSymbolIcon:hte,Rainbow:mte,RainbowIcon:mte,Rat:pte,RatIcon:pte,Ratio:fte,RatioIcon:fte,Receipt:Nte,ReceiptCent:xte,ReceiptCentIcon:xte,ReceiptEuro:gte,ReceiptEuroIcon:gte,ReceiptIcon:Nte,ReceiptIndianRupee:yte,ReceiptIndianRupeeIcon:yte,ReceiptJapaneseYen:vte,ReceiptJapaneseYenIcon:vte,ReceiptPoundSterling:_te,ReceiptPoundSterlingIcon:_te,ReceiptRussianRuble:bte,ReceiptRussianRubleIcon:bte,ReceiptSwissFranc:wte,ReceiptSwissFrancIcon:wte,ReceiptText:jte,ReceiptTextIcon:jte,RectangleEllipsis:PN,RectangleEllipsisIcon:PN,RectangleHorizontal:kte,RectangleHorizontalIcon:kte,RectangleVertical:Ste,RectangleVerticalIcon:Ste,Recycle:Cte,RecycleIcon:Cte,Redo:dS,Redo2:Mte,Redo2Icon:Mte,RedoDot:Tte,RedoDotIcon:Tte,RedoIcon:dS,RefreshCcw:PM,RefreshCcwDot:Ate,RefreshCcwDotIcon:Ate,RefreshCcwIcon:PM,RefreshCw:oo,RefreshCwIcon:oo,RefreshCwOff:Ete,RefreshCwOffIcon:Ete,Refrigerator:Pte,RefrigeratorIcon:Pte,Regex:Ite,RegexIcon:Ite,RemoveFormatting:Lte,RemoveFormattingIcon:Lte,Repeat:ML,Repeat1:Dte,Repeat1Icon:Dte,Repeat2:Rte,Repeat2Icon:Rte,RepeatIcon:ML,Replace:Fte,ReplaceAll:Ote,ReplaceAllIcon:Ote,ReplaceIcon:Fte,Reply:TL,ReplyAll:zte,ReplyAllIcon:zte,ReplyIcon:TL,Rewind:Bte,RewindIcon:Bte,Ribbon:$te,RibbonIcon:$te,Rocket:Qy,RocketIcon:Qy,RockingChair:qte,RockingChairIcon:qte,RollerCoaster:Ute,RollerCoasterIcon:Ute,Rotate3D:IN,Rotate3DIcon:IN,Rotate3d:IN,Rotate3dIcon:IN,RotateCcw:Jy,RotateCcwIcon:Jy,RotateCcwSquare:Vte,RotateCcwSquareIcon:Vte,RotateCw:AL,RotateCwIcon:AL,RotateCwSquare:Hte,RotateCwSquareIcon:Hte,Route:Wte,RouteIcon:Wte,RouteOff:Gte,RouteOffIcon:Gte,Router:Kte,RouterIcon:Kte,Rows:LN,Rows2:LN,Rows2Icon:LN,Rows3:DN,Rows3Icon:DN,Rows4:Zte,Rows4Icon:Zte,RowsIcon:LN,Rss:Yte,RssIcon:Yte,Ruler:uS,RulerIcon:uS,RussianRuble:Xte,RussianRubleIcon:Xte,Sailboat:Qte,SailboatIcon:Qte,Salad:Jte,SaladIcon:Jte,Sandwich:ese,SandwichIcon:ese,Satellite:sse,SatelliteDish:tse,SatelliteDishIcon:tse,SatelliteIcon:sse,Save:_c,SaveAll:rse,SaveAllIcon:rse,SaveIcon:_c,SaveOff:nse,SaveOffIcon:nse,Scale:EL,Scale3D:RN,Scale3DIcon:RN,Scale3d:RN,Scale3dIcon:RN,ScaleIcon:EL,Scaling:ase,ScalingIcon:ase,Scan:mse,ScanBarcode:ise,ScanBarcodeIcon:ise,ScanEye:ose,ScanEyeIcon:ose,ScanFace:lse,ScanFaceIcon:lse,ScanIcon:mse,ScanLine:cse,ScanLineIcon:cse,ScanQrCode:dse,ScanQrCodeIcon:dse,ScanSearch:use,ScanSearchIcon:use,ScanText:hse,ScanTextIcon:hse,ScatterChart:xj,ScatterChartIcon:xj,School:pse,School2:qk,School2Icon:qk,SchoolIcon:pse,Scissors:xse,ScissorsIcon:xse,ScissorsLineDashed:fse,ScissorsLineDashedIcon:fse,ScissorsSquare:Mk,ScissorsSquareDashedBottom:ek,ScissorsSquareDashedBottomIcon:ek,ScissorsSquareIcon:Mk,ScreenShare:yse,ScreenShareIcon:yse,ScreenShareOff:gse,ScreenShareOffIcon:gse,Scroll:_se,ScrollIcon:_se,ScrollText:vse,ScrollTextIcon:vse,Search:an,SearchCheck:bse,SearchCheckIcon:bse,SearchCode:wse,SearchCodeIcon:wse,SearchIcon:an,SearchSlash:jse,SearchSlashIcon:jse,SearchX:PL,SearchXIcon:PL,Section:Nse,SectionIcon:Nse,Send:An,SendHorizonal:ON,SendHorizonalIcon:ON,SendHorizontal:ON,SendHorizontalIcon:ON,SendIcon:An,SendToBack:kse,SendToBackIcon:kse,SeparatorHorizontal:Sse,SeparatorHorizontalIcon:Sse,SeparatorVertical:Cse,SeparatorVerticalIcon:Cse,Server:Ese,ServerCog:Mse,ServerCogIcon:Mse,ServerCrash:Tse,ServerCrashIcon:Tse,ServerIcon:Ese,ServerOff:Ase,ServerOffIcon:Ase,Settings:ko,Settings2:IL,Settings2Icon:IL,SettingsIcon:ko,Shapes:Pse,ShapesIcon:Pse,Share:LL,Share2:vd,Share2Icon:vd,ShareIcon:LL,Sheet:Ise,SheetIcon:Ise,Shell:Lse,ShellIcon:Lse,Shield:Ou,ShieldAlert:Dse,ShieldAlertIcon:Dse,ShieldBan:Rse,ShieldBanIcon:Rse,ShieldCheck:hS,ShieldCheckIcon:hS,ShieldClose:FN,ShieldCloseIcon:FN,ShieldEllipsis:Ose,ShieldEllipsisIcon:Ose,ShieldHalf:Fse,ShieldHalfIcon:Fse,ShieldIcon:Ou,ShieldMinus:zse,ShieldMinusIcon:zse,ShieldOff:mS,ShieldOffIcon:mS,ShieldPlus:Bse,ShieldPlusIcon:Bse,ShieldQuestion:$se,ShieldQuestionIcon:$se,ShieldX:FN,ShieldXIcon:FN,Ship:Use,ShipIcon:Use,ShipWheel:qse,ShipWheelIcon:qse,Shirt:Vse,ShirtIcon:Vse,ShoppingBag:e0,ShoppingBagIcon:e0,ShoppingBasket:Hse,ShoppingBasketIcon:Hse,ShoppingCart:op,ShoppingCartIcon:op,Shovel:Gse,ShovelIcon:Gse,ShowerHead:Wse,ShowerHeadIcon:Wse,Shrink:Kse,ShrinkIcon:Kse,Shrub:Zse,ShrubIcon:Zse,Shuffle:pS,ShuffleIcon:pS,Sidebar:MN,SidebarClose:kN,SidebarCloseIcon:kN,SidebarIcon:MN,SidebarOpen:CN,SidebarOpenIcon:CN,Sigma:Yse,SigmaIcon:Yse,SigmaSquare:Tk,SigmaSquareIcon:Tk,Signal:tre,SignalHigh:Xse,SignalHighIcon:Xse,SignalIcon:tre,SignalLow:Qse,SignalLowIcon:Qse,SignalMedium:Jse,SignalMediumIcon:Jse,SignalZero:ere,SignalZeroIcon:ere,Signature:sre,SignatureIcon:sre,Signpost:nre,SignpostBig:rre,SignpostBigIcon:rre,SignpostIcon:nre,Siren:are,SirenIcon:are,SkipBack:ire,SkipBackIcon:ire,SkipForward:ore,SkipForwardIcon:ore,Skull:lre,SkullIcon:lre,Slack:cre,SlackIcon:cre,Slash:dre,SlashIcon:dre,SlashSquare:Ak,SlashSquareIcon:Ak,Slice:ure,SliceIcon:ure,Sliders:zN,SlidersHorizontal:fS,SlidersHorizontalIcon:fS,SlidersIcon:zN,SlidersVertical:zN,SlidersVerticalIcon:zN,Smartphone:t0,SmartphoneCharging:hre,SmartphoneChargingIcon:hre,SmartphoneIcon:t0,SmartphoneNfc:mre,SmartphoneNfcIcon:mre,Smile:fre,SmileIcon:fre,SmilePlus:pre,SmilePlusIcon:pre,Snail:xre,SnailIcon:xre,Snowflake:zv,SnowflakeIcon:zv,Sofa:gre,SofaIcon:gre,SortAsc:Y2,SortAscIcon:Y2,SortDesc:W2,SortDescIcon:W2,Soup:yre,SoupIcon:yre,Space:vre,SpaceIcon:vre,Spade:_re,SpadeIcon:_re,Sparkle:bre,SparkleIcon:bre,Sparkles:$r,SparklesIcon:$r,Speaker:wre,SpeakerIcon:wre,Speech:jre,SpeechIcon:jre,SpellCheck:kre,SpellCheck2:Nre,SpellCheck2Icon:Nre,SpellCheckIcon:kre,Spline:Sre,SplineIcon:Sre,Split:Cre,SplitIcon:Cre,SplitSquareHorizontal:Ek,SplitSquareHorizontalIcon:Ek,SplitSquareVertical:Pk,SplitSquareVerticalIcon:Pk,SprayCan:Mre,SprayCanIcon:Mre,Sprout:xS,SproutIcon:xS,Square:s0,SquareActivity:BN,SquareActivityIcon:BN,SquareArrowDown:UN,SquareArrowDownIcon:UN,SquareArrowDownLeft:$N,SquareArrowDownLeftIcon:$N,SquareArrowDownRight:qN,SquareArrowDownRightIcon:qN,SquareArrowLeft:VN,SquareArrowLeftIcon:VN,SquareArrowOutDownLeft:HN,SquareArrowOutDownLeftIcon:HN,SquareArrowOutDownRight:GN,SquareArrowOutDownRightIcon:GN,SquareArrowOutUpLeft:WN,SquareArrowOutUpLeftIcon:WN,SquareArrowOutUpRight:KN,SquareArrowOutUpRightIcon:KN,SquareArrowRight:ZN,SquareArrowRightIcon:ZN,SquareArrowUp:QN,SquareArrowUpIcon:QN,SquareArrowUpLeft:YN,SquareArrowUpLeftIcon:YN,SquareArrowUpRight:XN,SquareArrowUpRightIcon:XN,SquareAsterisk:JN,SquareAsteriskIcon:JN,SquareBottomDashedScissors:ek,SquareBottomDashedScissorsIcon:ek,SquareChartGantt:Ny,SquareChartGanttIcon:Ny,SquareCheck:tk,SquareCheckBig:Av,SquareCheckBigIcon:Av,SquareCheckIcon:tk,SquareChevronDown:sk,SquareChevronDownIcon:sk,SquareChevronLeft:rk,SquareChevronLeftIcon:rk,SquareChevronRight:nk,SquareChevronRightIcon:nk,SquareChevronUp:ak,SquareChevronUpIcon:ak,SquareCode:ik,SquareCodeIcon:ik,SquareDashed:ck,SquareDashedBottom:Are,SquareDashedBottomCode:Tre,SquareDashedBottomCodeIcon:Tre,SquareDashedBottomIcon:Are,SquareDashedIcon:ck,SquareDashedKanban:ok,SquareDashedKanbanIcon:ok,SquareDashedMousePointer:lk,SquareDashedMousePointerIcon:lk,SquareDivide:dk,SquareDivideIcon:dk,SquareDot:uk,SquareDotIcon:uk,SquareEqual:hk,SquareEqualIcon:hk,SquareFunction:mk,SquareFunctionIcon:mk,SquareGanttChart:Ny,SquareGanttChartIcon:Ny,SquareIcon:s0,SquareKanban:pk,SquareKanbanIcon:pk,SquareLibrary:fk,SquareLibraryIcon:fk,SquareM:xk,SquareMIcon:xk,SquareMenu:gk,SquareMenuIcon:gk,SquareMinus:yk,SquareMinusIcon:yk,SquareMousePointer:vk,SquareMousePointerIcon:vk,SquareParking:bk,SquareParkingIcon:bk,SquareParkingOff:_k,SquareParkingOffIcon:_k,SquarePen:Gc,SquarePenIcon:Gc,SquarePercent:wk,SquarePercentIcon:wk,SquarePi:jk,SquarePiIcon:jk,SquarePilcrow:Nk,SquarePilcrowIcon:Nk,SquarePlay:kk,SquarePlayIcon:kk,SquarePlus:Sk,SquarePlusIcon:Sk,SquarePower:Ck,SquarePowerIcon:Ck,SquareRadical:Ere,SquareRadicalIcon:Ere,SquareScissors:Mk,SquareScissorsIcon:Mk,SquareSigma:Tk,SquareSigmaIcon:Tk,SquareSlash:Ak,SquareSlashIcon:Ak,SquareSplitHorizontal:Ek,SquareSplitHorizontalIcon:Ek,SquareSplitVertical:Pk,SquareSplitVerticalIcon:Pk,SquareSquare:Pre,SquareSquareIcon:Pre,SquareStack:Ire,SquareStackIcon:Ire,SquareTerminal:Ik,SquareTerminalIcon:Ik,SquareUser:Dk,SquareUserIcon:Dk,SquareUserRound:Lk,SquareUserRoundIcon:Lk,SquareX:Rk,SquareXIcon:Rk,Squircle:Lre,SquircleIcon:Lre,Squirrel:Dre,SquirrelIcon:Dre,Stamp:Rre,StampIcon:Rre,Star:Hn,StarHalf:Ore,StarHalfIcon:Ore,StarIcon:Hn,StarOff:Fre,StarOffIcon:Fre,Stars:$r,StarsIcon:$r,StepBack:zre,StepBackIcon:zre,StepForward:Bre,StepForwardIcon:Bre,Stethoscope:$re,StethoscopeIcon:$re,Sticker:qre,StickerIcon:qre,StickyNote:Ure,StickyNoteIcon:Ure,StopCircle:zj,StopCircleIcon:zj,Store:Vre,StoreIcon:Vre,StretchHorizontal:Hre,StretchHorizontalIcon:Hre,StretchVertical:Gre,StretchVerticalIcon:Gre,Strikethrough:DL,StrikethroughIcon:DL,Subscript:Wre,SubscriptIcon:Wre,Subtitles:nj,SubtitlesIcon:nj,Sun:e1,SunDim:Kre,SunDimIcon:Kre,SunIcon:e1,SunMedium:Zre,SunMediumIcon:Zre,SunMoon:Yre,SunMoonIcon:Yre,SunSnow:Xre,SunSnowIcon:Xre,Sunrise:Qre,SunriseIcon:Qre,Sunset:Jre,SunsetIcon:Jre,Superscript:ene,SuperscriptIcon:ene,SwatchBook:tne,SwatchBookIcon:tne,SwissFranc:sne,SwissFrancIcon:sne,SwitchCamera:rne,SwitchCameraIcon:rne,Sword:nne,SwordIcon:nne,Swords:ane,SwordsIcon:ane,Syringe:ine,SyringeIcon:ine,Table:LM,Table2:IM,Table2Icon:IM,TableCellsMerge:one,TableCellsMergeIcon:one,TableCellsSplit:lne,TableCellsSplitIcon:lne,TableColumnsSplit:cne,TableColumnsSplitIcon:cne,TableIcon:LM,TableOfContents:dne,TableOfContentsIcon:dne,TableProperties:une,TablePropertiesIcon:une,TableRowsSplit:hne,TableRowsSplitIcon:hne,Tablet:pne,TabletIcon:pne,TabletSmartphone:mne,TabletSmartphoneIcon:mne,Tablets:fne,TabletsIcon:fne,Tag:hh,TagIcon:hh,Tags:xne,TagsIcon:xne,Tally1:gne,Tally1Icon:gne,Tally2:yne,Tally2Icon:yne,Tally3:vne,Tally3Icon:vne,Tally4:_ne,Tally4Icon:_ne,Tally5:bne,Tally5Icon:bne,Tangent:wne,TangentIcon:wne,Target:Rh,TargetIcon:Rh,Telescope:jne,TelescopeIcon:jne,Tent:kne,TentIcon:kne,TentTree:Nne,TentTreeIcon:Nne,Terminal:Sne,TerminalIcon:Sne,TerminalSquare:Ik,TerminalSquareIcon:Ik,TestTube:Cne,TestTube2:Ok,TestTube2Icon:Ok,TestTubeDiagonal:Ok,TestTubeDiagonalIcon:Ok,TestTubeIcon:Cne,TestTubes:Mne,TestTubesIcon:Mne,Text:Ine,TextCursor:Ane,TextCursorIcon:Ane,TextCursorInput:Tne,TextCursorInputIcon:Tne,TextIcon:Ine,TextQuote:Ene,TextQuoteIcon:Ene,TextSearch:Pne,TextSearchIcon:Pne,TextSelect:Fk,TextSelectIcon:Fk,TextSelection:Fk,TextSelectionIcon:Fk,Theater:Lne,TheaterIcon:Lne,Thermometer:One,ThermometerIcon:One,ThermometerSnowflake:Dne,ThermometerSnowflakeIcon:Dne,ThermometerSun:Rne,ThermometerSunIcon:Rne,ThumbsDown:RL,ThumbsDownIcon:RL,ThumbsUp:Fu,ThumbsUpIcon:Fu,Ticket:OL,TicketCheck:Fne,TicketCheckIcon:Fne,TicketIcon:OL,TicketMinus:zne,TicketMinusIcon:zne,TicketPercent:Bne,TicketPercentIcon:Bne,TicketPlus:$ne,TicketPlusIcon:$ne,TicketSlash:qne,TicketSlashIcon:qne,TicketX:Une,TicketXIcon:Une,Tickets:Hne,TicketsIcon:Hne,TicketsPlane:Vne,TicketsPlaneIcon:Vne,Timer:Kne,TimerIcon:Kne,TimerOff:Gne,TimerOffIcon:Gne,TimerReset:Wne,TimerResetIcon:Wne,ToggleLeft:Zne,ToggleLeftIcon:Zne,ToggleRight:Yne,ToggleRightIcon:Yne,Toilet:Xne,ToiletIcon:Xne,Tornado:Qne,TornadoIcon:Qne,Torus:Jne,TorusIcon:Jne,Touchpad:tae,TouchpadIcon:tae,TouchpadOff:eae,TouchpadOffIcon:eae,TowerControl:sae,TowerControlIcon:sae,ToyBrick:rae,ToyBrickIcon:rae,Tractor:nae,TractorIcon:nae,TrafficCone:aae,TrafficConeIcon:aae,Train:zk,TrainFront:oae,TrainFrontIcon:oae,TrainFrontTunnel:iae,TrainFrontTunnelIcon:iae,TrainIcon:zk,TrainTrack:lae,TrainTrackIcon:lae,TramFront:zk,TramFrontIcon:zk,Trash:cae,Trash2:gr,Trash2Icon:gr,TrashIcon:cae,TreeDeciduous:dae,TreeDeciduousIcon:dae,TreePalm:Bk,TreePalmIcon:Bk,TreePine:Mb,TreePineIcon:Mb,Trees:uae,TreesIcon:uae,Trello:hae,TrelloIcon:hae,TrendingDown:gS,TrendingDownIcon:gS,TrendingUp:Yo,TrendingUpDown:mae,TrendingUpDownIcon:mae,TrendingUpIcon:Yo,Triangle:fae,TriangleAlert:Qc,TriangleAlertIcon:Qc,TriangleIcon:fae,TriangleRight:pae,TriangleRightIcon:pae,Trophy:Vi,TrophyIcon:Vi,Truck:FL,TruckIcon:FL,Turtle:xae,TurtleIcon:xae,Tv:yae,Tv2:$k,Tv2Icon:$k,TvIcon:yae,TvMinimal:$k,TvMinimalIcon:$k,TvMinimalPlay:gae,TvMinimalPlayIcon:gae,Twitch:vae,TwitchIcon:vae,Twitter:_ae,TwitterIcon:_ae,Type:wae,TypeIcon:wae,TypeOutline:bae,TypeOutlineIcon:bae,Umbrella:Nae,UmbrellaIcon:Nae,UmbrellaOff:jae,UmbrellaOffIcon:jae,Underline:zL,UnderlineIcon:zL,Undo:yS,Undo2:kae,Undo2Icon:kae,UndoDot:Sae,UndoDotIcon:Sae,UndoIcon:yS,UnfoldHorizontal:Cae,UnfoldHorizontalIcon:Cae,UnfoldVertical:Mae,UnfoldVerticalIcon:Mae,Ungroup:Tae,UngroupIcon:Tae,University:qk,UniversityIcon:qk,Unlink:vS,Unlink2:Aae,Unlink2Icon:Aae,UnlinkIcon:vS,Unlock:yN,UnlockIcon:yN,UnlockKeyhole:gN,UnlockKeyholeIcon:gN,Unplug:Eae,UnplugIcon:Eae,Upload:$a,UploadCloud:Hj,UploadCloudIcon:Hj,UploadIcon:$a,Usb:Pae,UsbIcon:Pae,User:Ti,User2:Kk,User2Icon:Kk,UserCheck:Tb,UserCheck2:Uk,UserCheck2Icon:Uk,UserCheckIcon:Tb,UserCircle:$j,UserCircle2:Bj,UserCircle2Icon:Bj,UserCircleIcon:$j,UserCog:BL,UserCog2:Vk,UserCog2Icon:Vk,UserCogIcon:BL,UserIcon:Ti,UserMinus:$L,UserMinus2:Hk,UserMinus2Icon:Hk,UserMinusIcon:$L,UserPen:Iae,UserPenIcon:Iae,UserPlus:al,UserPlus2:Gk,UserPlus2Icon:Gk,UserPlusIcon:al,UserRound:Kk,UserRoundCheck:Uk,UserRoundCheckIcon:Uk,UserRoundCog:Vk,UserRoundCogIcon:Vk,UserRoundIcon:Kk,UserRoundMinus:Hk,UserRoundMinusIcon:Hk,UserRoundPen:Lae,UserRoundPenIcon:Lae,UserRoundPlus:Gk,UserRoundPlusIcon:Gk,UserRoundSearch:Dae,UserRoundSearchIcon:Dae,UserRoundX:Wk,UserRoundXIcon:Wk,UserSearch:Rae,UserSearchIcon:Rae,UserSquare:Dk,UserSquare2:Lk,UserSquare2Icon:Lk,UserSquareIcon:Dk,UserX:Oae,UserX2:Wk,UserX2Icon:Wk,UserXIcon:Oae,Users:lr,Users2:Zk,Users2Icon:Zk,UsersIcon:lr,UsersRound:Zk,UsersRoundIcon:Zk,Utensils:Xk,UtensilsCrossed:Yk,UtensilsCrossedIcon:Yk,UtensilsIcon:Xk,UtilityPole:Fae,UtilityPoleIcon:Fae,Variable:DM,VariableIcon:DM,Vault:zae,VaultIcon:zae,Vegan:Bae,VeganIcon:Bae,VenetianMask:$ae,VenetianMaskIcon:$ae,Verified:J2,VerifiedIcon:J2,Vibrate:Uae,VibrateIcon:Uae,VibrateOff:qae,VibrateOffIcon:qae,Video:Tn,VideoIcon:Tn,VideoOff:Vae,VideoOffIcon:Vae,Videotape:Hae,VideotapeIcon:Hae,View:Gae,ViewIcon:Gae,Voicemail:Wae,VoicemailIcon:Wae,Volleyball:Kae,VolleyballIcon:Kae,Volume:Jae,Volume1:Zae,Volume1Icon:Zae,Volume2:Yae,Volume2Icon:Yae,VolumeIcon:Jae,VolumeOff:Xae,VolumeOffIcon:Xae,VolumeX:Qae,VolumeXIcon:Qae,Vote:eie,VoteIcon:eie,Wallet:qL,Wallet2:Qk,Wallet2Icon:Qk,WalletCards:tie,WalletCardsIcon:tie,WalletIcon:qL,WalletMinimal:Qk,WalletMinimalIcon:Qk,Wallpaper:sie,WallpaperIcon:sie,Wand:rie,Wand2:Ev,Wand2Icon:Ev,WandIcon:rie,WandSparkles:Ev,WandSparklesIcon:Ev,Warehouse:nie,WarehouseIcon:nie,WashingMachine:aie,WashingMachineIcon:aie,Watch:iie,WatchIcon:iie,Waves:oie,WavesIcon:oie,Waypoints:lie,WaypointsIcon:lie,Webcam:cie,WebcamIcon:cie,Webhook:uie,WebhookIcon:uie,WebhookOff:die,WebhookOffIcon:die,Weight:hie,WeightIcon:hie,Wheat:pie,WheatIcon:pie,WheatOff:mie,WheatOffIcon:mie,WholeWord:fie,WholeWordIcon:fie,Wifi:_ie,WifiHigh:xie,WifiHighIcon:xie,WifiIcon:_ie,WifiLow:gie,WifiLowIcon:gie,WifiOff:yie,WifiOffIcon:yie,WifiZero:vie,WifiZeroIcon:vie,Wind:wie,WindArrowDown:bie,WindArrowDownIcon:bie,WindIcon:wie,Wine:Nie,WineIcon:Nie,WineOff:jie,WineOffIcon:jie,Workflow:kie,WorkflowIcon:kie,Worm:Sie,WormIcon:Sie,WrapText:Cie,WrapTextIcon:Cie,Wrench:Ig,WrenchIcon:Ig,X:Sr,XCircle:Zl,XCircleIcon:Zl,XIcon:Sr,XOctagon:wN,XOctagonIcon:wN,XSquare:Rk,XSquareIcon:Rk,Youtube:Mie,YoutubeIcon:Mie,Zap:Oh,ZapIcon:Oh,ZapOff:Tie,ZapOffIcon:Tie,ZoomIn:Ab,ZoomInIcon:Ab,ZoomOut:RM,ZoomOutIcon:RM,createLucideIcon:Z,icons:ngt},Symbol.toStringTag,{value:"Module"})),rje="-",agt=t=>{const s=ogt(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split(rje);return i[0]===""&&i.length!==1&&i.shift(),Qqe(i,s)||igt(l)},getConflictingClassGroupIds:(l,i)=>{const d=r[l]||[];return i&&n[l]?[...d,...n[l]]:d}}},Qqe=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?Qqe(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join(rje);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},kEe=/^\[(.+)\]$/,igt=t=>{if(kEe.test(t)){const s=kEe.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},ogt=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return cgt(Object.entries(t.classGroups),r).forEach(([o,l])=>{jve(l,n,o,s)}),n},jve=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:SEe(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(lgt(a)){jve(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{jve(l,SEe(s,o),r,n)})})},SEe=(t,s)=>{let r=t;return s.split(rje).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},lgt=t=>t.isThemeGetter,cgt=(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,dgt=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)}}},Jqe="!",ugt=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,x;for(let w=0;wp?x-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},mgt=t=>({cache:dgt(t.cacheSize),parseClassName:ugt(t),...agt(t)}),pgt=/\s+/,fgt=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(pgt);let i="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{modifiers:p,hasImportantModifier:x,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(":"),k=x?w+Jqe:w,C=k+N;if(o.includes(C))continue;o.push(C);const E=a(N,b);for(let L=0;L0?" "+i:i)}return i};function xgt(){let t=0,s,r,n="";for(;t{if(typeof t=="string")return t;let s,r="";for(let n=0;nx(p),t());return r=mgt(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=fgt(d,r);return a(d,p),p}return function(){return o(xgt.apply(null,arguments))}}const ql=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},tUe=/^\[(?:([a-z-]+):)?(.+)\]$/i,ygt=/^\d+\/\d+$/,vgt=new Set(["px","full","screen"]),_gt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,bgt=/\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$/,wgt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,jgt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ngt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,dv=t=>OM(t)||vgt.has(t)||ygt.test(t),h_=t=>EA(t,"length",Pgt),OM=t=>!!t&&!Number.isNaN(Number(t)),Hxe=t=>EA(t,"number",OM),U6=t=>!!t&&Number.isInteger(Number(t)),kgt=t=>t.endsWith("%")&&OM(t.slice(0,-1)),Ci=t=>tUe.test(t),m_=t=>_gt.test(t),Sgt=new Set(["length","size","percentage"]),Cgt=t=>EA(t,Sgt,sUe),Mgt=t=>EA(t,"position",sUe),Tgt=new Set(["image","url"]),Agt=t=>EA(t,Tgt,Lgt),Egt=t=>EA(t,"",Igt),V6=()=>!0,EA=(t,s,r)=>{const n=tUe.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},Pgt=t=>bgt.test(t)&&!wgt.test(t),sUe=()=>!1,Igt=t=>jgt.test(t),Lgt=t=>Ngt.test(t),Dgt=()=>{const t=ql("colors"),s=ql("spacing"),r=ql("blur"),n=ql("brightness"),a=ql("borderColor"),o=ql("borderRadius"),l=ql("borderSpacing"),i=ql("borderWidth"),d=ql("contrast"),u=ql("grayscale"),p=ql("hueRotate"),x=ql("invert"),y=ql("gap"),_=ql("gradientColorStops"),b=ql("gradientColorStopPositions"),N=ql("inset"),w=ql("margin"),k=ql("opacity"),C=ql("padding"),E=ql("saturate"),L=ql("scale"),I=ql("sepia"),O=ql("skew"),V=ql("space"),q=ql("translate"),$=()=>["auto","contain","none"],U=()=>["auto","hidden","clip","visible","scroll"],se=()=>["auto",Ci,s],Y=()=>[Ci,s],J=()=>["",dv,h_],X=()=>["auto",OM,Ci],ce=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ie=()=>["solid","dashed","dotted","double","none"],ae=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],oe=()=>["start","end","center","between","around","evenly","stretch"],pe=()=>["","0",Ci],_e=()=>["auto","avoid","all","avoid-page","page","left","right","column"],he=()=>[OM,Ci];return{cacheSize:500,separator:":",theme:{colors:[V6],spacing:[dv,h_],blur:["none","",m_,Ci],brightness:he(),borderColor:[t],borderRadius:["none","","full",m_,Ci],borderSpacing:Y(),borderWidth:J(),contrast:he(),grayscale:pe(),hueRotate:he(),invert:pe(),gap:Y(),gradientColorStops:[t],gradientColorStopPositions:[kgt,h_],inset:se(),margin:se(),opacity:he(),padding:Y(),saturate:he(),scale:he(),sepia:pe(),skew:he(),space:Y(),translate:Y()},classGroups:{aspect:[{aspect:["auto","square","video",Ci]}],container:["container"],columns:[{columns:[m_]}],"break-after":[{"break-after":_e()}],"break-before":[{"break-before":_e()}],"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(),Ci]}],overflow:[{overflow:U()}],"overflow-x":[{"overflow-x":U()}],"overflow-y":[{"overflow-y":U()}],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",U6,Ci]}],basis:[{basis:se()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Ci]}],grow:[{grow:pe()}],shrink:[{shrink:pe()}],order:[{order:["first","last","none",U6,Ci]}],"grid-cols":[{"grid-cols":[V6]}],"col-start-end":[{col:["auto",{span:["full",U6,Ci]},Ci]}],"col-start":[{"col-start":X()}],"col-end":[{"col-end":X()}],"grid-rows":[{"grid-rows":[V6]}],"row-start-end":[{row:["auto",{span:[U6,Ci]},Ci]}],"row-start":[{"row-start":X()}],"row-end":[{"row-end":X()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Ci]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Ci]}],gap:[{gap:[y]}],"gap-x":[{"gap-x":[y]}],"gap-y":[{"gap-y":[y]}],"justify-content":[{justify:["normal",...oe()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...oe(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...oe(),"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":[V]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[V]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Ci,s]}],"min-w":[{"min-w":[Ci,s,"min","max","fit"]}],"max-w":[{"max-w":[Ci,s,"none","full","min","max","fit","prose",{screen:[m_]},m_]}],h:[{h:[Ci,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Ci,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Ci,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Ci,s,"auto","min","max","fit"]}],"font-size":[{text:["base",m_,h_]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Hxe]}],"font-family":[{font:[V6]}],"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",Ci]}],"line-clamp":[{"line-clamp":["none",OM,Hxe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",dv,Ci]}],"list-image":[{"list-image":["none",Ci]}],"list-style-type":[{list:["none","disc","decimal",Ci]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",dv,h_]}],"underline-offset":[{"underline-offset":["auto",dv,Ci]}],"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:Y()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ci]}],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",Ci]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ce(),Mgt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Cgt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Agt]}],"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":[k]}],"border-style":[{border:[...ie(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[k]}],"divide-style":[{divide:ie()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...ie()]}],"outline-offset":[{"outline-offset":[dv,Ci]}],"outline-w":[{outline:[dv,h_]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[dv,h_]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",m_,Egt]}],"shadow-color":[{shadow:[V6]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...ae(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ae()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",m_,Ci]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[x]}],saturate:[{saturate:[E]}],sepia:[{sepia:[I]}],"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":[x]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[E]}],"backdrop-sepia":[{"backdrop-sepia":[I]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[l]}],"border-spacing-x":[{"border-spacing-x":[l]}],"border-spacing-y":[{"border-spacing-y":[l]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Ci]}],duration:[{duration:he()}],ease:[{ease:["linear","in","out","in-out",Ci]}],delay:[{delay:he()}],animate:[{animate:["none","spin","ping","pulse","bounce",Ci]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[L]}],"scale-x":[{"scale-x":[L]}],"scale-y":[{"scale-y":[L]}],rotate:[{rotate:[U6,Ci]}],"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",Ci]}],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",Ci]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Y()}],"scroll-mx":[{"scroll-mx":Y()}],"scroll-my":[{"scroll-my":Y()}],"scroll-ms":[{"scroll-ms":Y()}],"scroll-me":[{"scroll-me":Y()}],"scroll-mt":[{"scroll-mt":Y()}],"scroll-mr":[{"scroll-mr":Y()}],"scroll-mb":[{"scroll-mb":Y()}],"scroll-ml":[{"scroll-ml":Y()}],"scroll-p":[{"scroll-p":Y()}],"scroll-px":[{"scroll-px":Y()}],"scroll-py":[{"scroll-py":Y()}],"scroll-ps":[{"scroll-ps":Y()}],"scroll-pe":[{"scroll-pe":Y()}],"scroll-pt":[{"scroll-pt":Y()}],"scroll-pr":[{"scroll-pr":Y()}],"scroll-pb":[{"scroll-pb":Y()}],"scroll-pl":[{"scroll-pl":Y()}],"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",Ci]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[dv,h_,Hxe]}],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"]}}},Rgt=ggt(Dgt);function Rt(...t){return Rgt(_i(t))}function kl(t,s=!1){return s&&t>=1e6?`$${(t/1e6).toFixed(1)}M`:s&&t>=1e3?`$${(t/1e3).toFixed(0)}K`:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(t)}function CEe(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function Kde(t){return t?t.replace(/<[^>]*>/g,""):""}const Ogt=tgt,rUe=S.forwardRef(({className:t,...s},r)=>e.jsx(Uqe,{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}));rUe.displayName=Uqe.displayName;const Fgt=gC("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"}}),nUe=S.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(Vqe,{ref:n,className:Rt(Fgt({variant:s}),t),...r}));nUe.displayName=Vqe.displayName;const zgt=S.forwardRef(({className:t,...s},r)=>e.jsx(Wqe,{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}));zgt.displayName=Wqe.displayName;const aUe=S.forwardRef(({className:t,...s},r)=>e.jsx(Kqe,{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"})}));aUe.displayName=Kqe.displayName;const iUe=S.forwardRef(({className:t,...s},r)=>e.jsx(Hqe,{ref:r,className:Rt("text-sm font-semibold",t),...s}));iUe.displayName=Hqe.displayName;const oUe=S.forwardRef(({className:t,...s},r)=>e.jsx(Gqe,{ref:r,className:Rt("text-sm opacity-90",t),...s}));oUe.displayName=Gqe.displayName;function Bgt(){const{toasts:t}=wa();return e.jsxs(Ogt,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(nUe,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(iUe,{children:r}),n&&e.jsx(oUe,{children:n})]}),a,e.jsx(aUe,{})]},s)}),e.jsx(rUe,{})]})}var MEe=["light","dark"],$gt="(prefers-color-scheme: dark)",qgt=S.createContext(void 0),Ugt={setTheme:t=>{},themes:[]},Vgt=()=>{var t;return(t=S.useContext(qgt))!=null?t:Ugt};S.memo(({forcedTheme:t,storageKey:s,attribute:r,enableSystem:n,enableColorScheme:a,defaultTheme:o,value:l,attrs:i,nonce:d})=>{let u=o==="system",p=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(b=>`'${b}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,x=a?MEe.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 k=l?l[b]:b,C=N?b+"|| ''":`'${k}'`,E="";return a&&w&&!N&&MEe.includes(b)&&(E+=`d.style.colorScheme = '${b}';`),r==="class"?N||k?E+=`c.add(${C})`:E+="null":k&&(E+=`d[s](n,${C})`),E},_=t?`!function(){${p}${y(t)}}()`:n?`!function(){try{${p}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${$gt}',m=window.matchMedia(t);if(m.media!==t||m.matches){${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)+"}"}${x}}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)};}${x}}catch(t){}}();`;return S.createElement("script",{nonce:d,dangerouslySetInnerHTML:{__html:_}})});var Hgt=t=>{switch(t){case"success":return Kgt;case"info":return Ygt;case"warning":return Zgt;case"error":return Xgt;default:return null}},Ggt=Array(12).fill(0),Wgt=({visible:t,className:s})=>ft.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},ft.createElement("div",{className:"sonner-spinner"},Ggt.map((r,n)=>ft.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),Kgt=ft.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ft.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Zgt=ft.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ft.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"})),Ygt=ft.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ft.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"})),Xgt=ft.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ft.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Qgt=ft.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"},ft.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ft.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Jgt=()=>{let[t,s]=ft.useState(document.hidden);return ft.useEffect(()=>{let r=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},Nve=1,eyt=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:Nve++,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],ft.isValidElement(u))o=!1,this.create({id:n,type:"default",message:u});else if(syt(u)&&!u.ok){o=!1;let p=typeof r.error=="function"?await r.error(`HTTP error! status: ${u.status}`):r.error,x=typeof r.description=="function"?await r.description(`HTTP error! status: ${u.status}`):r.description;this.create({id:n,type:"error",message:p,description:x})}else if(r.success!==void 0){o=!1;let p=typeof r.success=="function"?await r.success(u):r.success,x=typeof r.description=="function"?await r.description(u):r.description;this.create({id:n,type:"success",message:p,description:x})}}).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,x=typeof r.description=="function"?await r.description(u):r.description;this.create({id:n,type:"error",message:p,description:x})}}).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)||Nve++;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}},Jm=new eyt,tyt=(t,s)=>{let r=(s==null?void 0:s.id)||Nve++;return Jm.addToast({title:t,...s,id:r}),r},syt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",ryt=tyt,nyt=()=>Jm.toasts,ayt=()=>Jm.getActiveToasts(),me=Object.assign(ryt,{success:Jm.success,info:Jm.info,warning:Jm.warning,error:Jm.error,custom:Jm.custom,message:Jm.message,promise:Jm.promise,dismiss:Jm.dismiss,loading:Jm.loading},{getHistory:nyt,getToasts:ayt});function iyt(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))}iyt(`: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 uz(t){return t.label!==void 0}var oyt=3,lyt="32px",cyt="16px",TEe=4e3,dyt=356,uyt=14,hyt=20,myt=200;function ig(...t){return t.filter(Boolean).join(" ")}function pyt(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var fyt=t=>{var s,r,n,a,o,l,i,d,u,p,x;let{invert:y,toast:_,unstyled:b,interacting:N,setHeights:w,visibleToasts:k,heights:C,index:E,toasts:L,expanded:I,removeToast:O,defaultRichColors:V,closeButton:q,style:$,cancelButtonStyle:U,actionButtonStyle:se,className:Y="",descriptionClassName:J="",duration:X,position:ce,gap:ie,loadingIcon:ae,expandByDefault:oe,classNames:pe,icons:_e,closeButtonAriaLabel:he="Close toast",pauseWhenPageIsHidden:we}=t,[je,Ue]=ft.useState(null),[Te,Me]=ft.useState(null),[Fe,Le]=ft.useState(!1),[Ne,qe]=ft.useState(!1),[ze,ve]=ft.useState(!1),[dt,fe]=ft.useState(!1),[Ve,Je]=ft.useState(!1),[at,Ae]=ft.useState(0),[Ye,We]=ft.useState(0),ot=ft.useRef(_.duration||X||TEe),Ge=ft.useRef(null),et=ft.useRef(null),ht=E===0,xt=E+1<=k,Ke=_.type,Ze=_.dismissible!==!1,Et=_.className||"",$t=_.descriptionClassName||"",Yt=ft.useMemo(()=>C.findIndex(cr=>cr.toastId===_.id)||0,[C,_.id]),Ps=ft.useMemo(()=>{var cr;return(cr=_.closeButton)!=null?cr:q},[_.closeButton,q]),zs=ft.useMemo(()=>_.duration||X||TEe,[_.duration,X]),Zs=ft.useRef(0),Dr=ft.useRef(0),zt=ft.useRef(0),$s=ft.useRef(null),[kr,Xs]=ce.split("-"),ir=ft.useMemo(()=>C.reduce((cr,cn,rn)=>rn>=Yt?cr:cr+cn.height,0),[C,Yt]),Or=Jgt(),Vn=_.invert||y,Qr=Ke==="loading";Dr.current=ft.useMemo(()=>Yt*ie+ir,[Yt,ir]),ft.useEffect(()=>{ot.current=zs},[zs]),ft.useEffect(()=>{Le(!0)},[]),ft.useEffect(()=>{let cr=et.current;if(cr){let cn=cr.getBoundingClientRect().height;return We(cn),w(rn=>[{toastId:_.id,height:cn,position:_.position},...rn]),()=>w(rn=>rn.filter(jn=>jn.toastId!==_.id))}},[w,_.id]),ft.useLayoutEffect(()=>{if(!Fe)return;let cr=et.current,cn=cr.style.height;cr.style.height="auto";let rn=cr.getBoundingClientRect().height;cr.style.height=cn,We(rn),w(jn=>jn.find(ni=>ni.toastId===_.id)?jn.map(ni=>ni.toastId===_.id?{...ni,height:rn}:ni):[{toastId:_.id,height:rn,position:_.position},...jn])},[Fe,_.title,_.description,w,_.id]);let Gr=ft.useCallback(()=>{qe(!0),Ae(Dr.current),w(cr=>cr.filter(cn=>cn.toastId!==_.id)),setTimeout(()=>{O(_)},myt)},[_,O,w,Dr]);ft.useEffect(()=>{if(_.promise&&Ke==="loading"||_.duration===1/0||_.type==="loading")return;let cr;return I||N||we&&Or?(()=>{if(zt.current{var cn;(cn=_.onAutoClose)==null||cn.call(_,_),Gr()},ot.current)),()=>clearTimeout(cr)},[I,N,_,Ke,we,Or,Gr]),ft.useEffect(()=>{_.delete&&Gr()},[Gr,_.delete]);function tr(){var cr,cn,rn;return _e!=null&&_e.loading?ft.createElement("div",{className:ig(pe==null?void 0:pe.loader,(cr=_==null?void 0:_.classNames)==null?void 0:cr.loader,"sonner-loader"),"data-visible":Ke==="loading"},_e.loading):ae?ft.createElement("div",{className:ig(pe==null?void 0:pe.loader,(cn=_==null?void 0:_.classNames)==null?void 0:cn.loader,"sonner-loader"),"data-visible":Ke==="loading"},ae):ft.createElement(Wgt,{className:ig(pe==null?void 0:pe.loader,(rn=_==null?void 0:_.classNames)==null?void 0:rn.loader),visible:Ke==="loading"})}return ft.createElement("li",{tabIndex:0,ref:et,className:ig(Y,Et,pe==null?void 0:pe.toast,(s=_==null?void 0:_.classNames)==null?void 0:s.toast,pe==null?void 0:pe.default,pe==null?void 0:pe[Ke],(r=_==null?void 0:_.classNames)==null?void 0:r[Ke]),"data-sonner-toast":"","data-rich-colors":(n=_.richColors)!=null?n:V,"data-styled":!(_.jsx||_.unstyled||b),"data-mounted":Fe,"data-promise":!!_.promise,"data-swiped":Ve,"data-removed":Ne,"data-visible":xt,"data-y-position":kr,"data-x-position":Xs,"data-index":E,"data-front":ht,"data-swiping":ze,"data-dismissible":Ze,"data-type":Ke,"data-invert":Vn,"data-swipe-out":dt,"data-swipe-direction":Te,"data-expanded":!!(I||oe&&Fe),style:{"--index":E,"--toasts-before":E,"--z-index":L.length-E,"--offset":`${Ne?at:Dr.current}px`,"--initial-height":oe?"auto":`${Ye}px`,...$,..._.style},onDragEnd:()=>{ve(!1),Ue(null),$s.current=null},onPointerDown:cr=>{Qr||!Ze||(Ge.current=new Date,Ae(Dr.current),cr.target.setPointerCapture(cr.pointerId),cr.target.tagName!=="BUTTON"&&(ve(!0),$s.current={x:cr.clientX,y:cr.clientY}))},onPointerUp:()=>{var cr,cn,rn,jn;if(dt||!Ze)return;$s.current=null;let ni=Number(((cr=et.current)==null?void 0:cr.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),rs=Number(((cn=et.current)==null?void 0:cn.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Bn=new Date().getTime()-((rn=Ge.current)==null?void 0:rn.getTime()),mn=je==="x"?ni:rs,Fr=Math.abs(mn)/Bn;if(Math.abs(mn)>=hyt||Fr>.11){Ae(Dr.current),(jn=_.onDismiss)==null||jn.call(_,_),Me(je==="x"?ni>0?"right":"left":rs>0?"down":"up"),Gr(),fe(!0),Je(!1);return}ve(!1),Ue(null)},onPointerMove:cr=>{var cn,rn,jn,ni;if(!$s.current||!Ze||((cn=window.getSelection())==null?void 0:cn.toString().length)>0)return;let rs=cr.clientY-$s.current.y,Bn=cr.clientX-$s.current.x,mn=(rn=t.swipeDirections)!=null?rn:pyt(ce);!je&&(Math.abs(Bn)>1||Math.abs(rs)>1)&&Ue(Math.abs(Bn)>Math.abs(rs)?"x":"y");let Fr={x:0,y:0};je==="y"?(mn.includes("top")||mn.includes("bottom"))&&(mn.includes("top")&&rs<0||mn.includes("bottom")&&rs>0)&&(Fr.y=rs):je==="x"&&(mn.includes("left")||mn.includes("right"))&&(mn.includes("left")&&Bn<0||mn.includes("right")&&Bn>0)&&(Fr.x=Bn),(Math.abs(Fr.x)>0||Math.abs(Fr.y)>0)&&Je(!0),(jn=et.current)==null||jn.style.setProperty("--swipe-amount-x",`${Fr.x}px`),(ni=et.current)==null||ni.style.setProperty("--swipe-amount-y",`${Fr.y}px`)}},Ps&&!_.jsx?ft.createElement("button",{"aria-label":he,"data-disabled":Qr,"data-close-button":!0,onClick:Qr||!Ze?()=>{}:()=>{var cr;Gr(),(cr=_.onDismiss)==null||cr.call(_,_)},className:ig(pe==null?void 0:pe.closeButton,(a=_==null?void 0:_.classNames)==null?void 0:a.closeButton)},(o=_e==null?void 0:_e.close)!=null?o:Qgt):null,_.jsx||S.isValidElement(_.title)?_.jsx?_.jsx:typeof _.title=="function"?_.title():_.title:ft.createElement(ft.Fragment,null,Ke||_.icon||_.promise?ft.createElement("div",{"data-icon":"",className:ig(pe==null?void 0:pe.icon,(l=_==null?void 0:_.classNames)==null?void 0:l.icon)},_.promise||_.type==="loading"&&!_.icon?_.icon||tr():null,_.type!=="loading"?_.icon||(_e==null?void 0:_e[Ke])||Hgt(Ke):null):null,ft.createElement("div",{"data-content":"",className:ig(pe==null?void 0:pe.content,(i=_==null?void 0:_.classNames)==null?void 0:i.content)},ft.createElement("div",{"data-title":"",className:ig(pe==null?void 0:pe.title,(d=_==null?void 0:_.classNames)==null?void 0:d.title)},typeof _.title=="function"?_.title():_.title),_.description?ft.createElement("div",{"data-description":"",className:ig(J,$t,pe==null?void 0:pe.description,(u=_==null?void 0:_.classNames)==null?void 0:u.description)},typeof _.description=="function"?_.description():_.description):null),S.isValidElement(_.cancel)?_.cancel:_.cancel&&uz(_.cancel)?ft.createElement("button",{"data-button":!0,"data-cancel":!0,style:_.cancelButtonStyle||U,onClick:cr=>{var cn,rn;uz(_.cancel)&&Ze&&((rn=(cn=_.cancel).onClick)==null||rn.call(cn,cr),Gr())},className:ig(pe==null?void 0:pe.cancelButton,(p=_==null?void 0:_.classNames)==null?void 0:p.cancelButton)},_.cancel.label):null,S.isValidElement(_.action)?_.action:_.action&&uz(_.action)?ft.createElement("button",{"data-button":!0,"data-action":!0,style:_.actionButtonStyle||se,onClick:cr=>{var cn,rn;uz(_.action)&&((rn=(cn=_.action).onClick)==null||rn.call(cn,cr),!cr.defaultPrevented&&Gr())},className:ig(pe==null?void 0:pe.actionButton,(x=_==null?void 0:_.classNames)==null?void 0:x.actionButton)},_.action.label):null))};function AEe(){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 xyt(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?cyt:lyt;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 gyt=S.forwardRef(function(t,s){let{invert:r,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:l,className:i,offset:d,mobileOffset:u,theme:p="light",richColors:x,duration:y,style:_,visibleToasts:b=oyt,toastOptions:N,dir:w=AEe(),gap:k=uyt,loadingIcon:C,icons:E,containerAriaLabel:L="Notifications",pauseWhenPageIsHidden:I}=t,[O,V]=ft.useState([]),q=ft.useMemo(()=>Array.from(new Set([n].concat(O.filter(we=>we.position).map(we=>we.position)))),[O,n]),[$,U]=ft.useState([]),[se,Y]=ft.useState(!1),[J,X]=ft.useState(!1),[ce,ie]=ft.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),ae=ft.useRef(null),oe=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),pe=ft.useRef(null),_e=ft.useRef(!1),he=ft.useCallback(we=>{V(je=>{var Ue;return(Ue=je.find(Te=>Te.id===we.id))!=null&&Ue.delete||Jm.dismiss(we.id),je.filter(({id:Te})=>Te!==we.id)})},[]);return ft.useEffect(()=>Jm.subscribe(we=>{if(we.dismiss){V(je=>je.map(Ue=>Ue.id===we.id?{...Ue,delete:!0}:Ue));return}setTimeout(()=>{Y2e.flushSync(()=>{V(je=>{let Ue=je.findIndex(Te=>Te.id===we.id);return Ue!==-1?[...je.slice(0,Ue),{...je[Ue],...we},...je.slice(Ue+1)]:[we,...je]})})})}),[]),ft.useEffect(()=>{if(p!=="system"){ie(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ie("dark"):ie("light")),typeof window>"u")return;let we=window.matchMedia("(prefers-color-scheme: dark)");try{we.addEventListener("change",({matches:je})=>{ie(je?"dark":"light")})}catch{we.addListener(({matches:Ue})=>{try{ie(Ue?"dark":"light")}catch(Te){console.error(Te)}})}},[p]),ft.useEffect(()=>{O.length<=1&&Y(!1)},[O]),ft.useEffect(()=>{let we=je=>{var Ue,Te;a.every(Me=>je[Me]||je.code===Me)&&(Y(!0),(Ue=ae.current)==null||Ue.focus()),je.code==="Escape"&&(document.activeElement===ae.current||(Te=ae.current)!=null&&Te.contains(document.activeElement))&&Y(!1)};return document.addEventListener("keydown",we),()=>document.removeEventListener("keydown",we)},[a]),ft.useEffect(()=>{if(ae.current)return()=>{pe.current&&(pe.current.focus({preventScroll:!0}),pe.current=null,_e.current=!1)}},[ae.current]),ft.createElement("section",{ref:s,"aria-label":`${L} ${oe}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},q.map((we,je)=>{var Ue;let[Te,Me]=we.split("-");return O.length?ft.createElement("ol",{key:we,dir:w==="auto"?AEe():w,tabIndex:-1,ref:ae,className:i,"data-sonner-toaster":!0,"data-theme":ce,"data-y-position":Te,"data-lifted":se&&O.length>1&&!o,"data-x-position":Me,style:{"--front-toast-height":`${((Ue=$[0])==null?void 0:Ue.height)||0}px`,"--width":`${dyt}px`,"--gap":`${k}px`,..._,...xyt(d,u)},onBlur:Fe=>{_e.current&&!Fe.currentTarget.contains(Fe.relatedTarget)&&(_e.current=!1,pe.current&&(pe.current.focus({preventScroll:!0}),pe.current=null))},onFocus:Fe=>{Fe.target instanceof HTMLElement&&Fe.target.dataset.dismissible==="false"||_e.current||(_e.current=!0,pe.current=Fe.relatedTarget)},onMouseEnter:()=>Y(!0),onMouseMove:()=>Y(!0),onMouseLeave:()=>{J||Y(!1)},onDragEnd:()=>Y(!1),onPointerDown:Fe=>{Fe.target instanceof HTMLElement&&Fe.target.dataset.dismissible==="false"||X(!0)},onPointerUp:()=>X(!1)},O.filter(Fe=>!Fe.position&&je===0||Fe.position===we).map((Fe,Le)=>{var Ne,qe;return ft.createElement(fyt,{key:Fe.id,icons:E,index:Le,toast:Fe,defaultRichColors:x,duration:(Ne=N==null?void 0:N.duration)!=null?Ne:y,className:N==null?void 0:N.className,descriptionClassName:N==null?void 0:N.descriptionClassName,invert:r,visibleToasts:b,closeButton:(qe=N==null?void 0:N.closeButton)!=null?qe: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(ze=>ze.position==Fe.position),heights:$.filter(ze=>ze.position==Fe.position),setHeights:U,expandByDefault:o,gap:k,loadingIcon:C,expanded:se,pauseWhenPageIsHidden:I,swipeDirections:t.swipeDirections})})):null}))});const yyt=({...t})=>{const{theme:s="system"}=Vgt();return e.jsx(gyt,{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 vyt=a2e[" useId ".trim().toString()]||(()=>{}),_yt=0;function pu(t){const[s,r]=S.useState(vyt());return rd(()=>{r(n=>n??String(_yt++))},[t]),s?`radix-${s}`:""}const byt=["top","right","bottom","left"],Hb=Math.min,Zp=Math.max,Poe=Math.round,hz=Math.floor,Gb=t=>({x:t,y:t}),wyt={left:"right",right:"left",bottom:"top",top:"bottom"},jyt={start:"end",end:"start"};function kve(t,s,r){return Zp(t,Hb(s,r))}function h1(t,s){return typeof t=="function"?t(s):t}function m1(t){return t.split("-")[0]}function PA(t){return t.split("-")[1]}function nje(t){return t==="x"?"y":"x"}function aje(t){return t==="y"?"height":"width"}function Wb(t){return["top","bottom"].includes(m1(t))?"y":"x"}function ije(t){return nje(Wb(t))}function Nyt(t,s,r){r===void 0&&(r=!1);const n=PA(t),a=ije(t),o=aje(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=Ioe(l)),[l,Ioe(l)]}function kyt(t){const s=Ioe(t);return[Sve(t),s,Sve(s)]}function Sve(t){return t.replace(/start|end/g,s=>jyt[s])}function Syt(t,s,r){const n=["left","right"],a=["right","left"],o=["top","bottom"],l=["bottom","top"];switch(t){case"top":case"bottom":return r?s?a:n:s?n:a;case"left":case"right":return s?o:l;default:return[]}}function Cyt(t,s,r,n){const a=PA(t);let o=Syt(m1(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(Sve)))),o}function Ioe(t){return t.replace(/left|right|bottom|top/g,s=>wyt[s])}function Myt(t){return{top:0,right:0,bottom:0,left:0,...t}}function lUe(t){return typeof t!="number"?Myt(t):{top:t,right:t,bottom:t,left:t}}function Loe(t){const{x:s,y:r,width:n,height:a}=t;return{width:n,height:a,top:r,left:s,right:s+n,bottom:r+a,x:s,y:r}}function EEe(t,s,r){let{reference:n,floating:a}=t;const o=Wb(s),l=ije(s),i=aje(l),d=m1(s),u=o==="y",p=n.x+n.width/2-a.width/2,x=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:x};break;case"left":_={x:n.x-a.width,y:x};break;default:_={x:n.x,y:n.y}}switch(PA(s)){case"start":_[l]-=y*(r&&u?-1:1);break;case"end":_[l]+=y*(r&&u?-1:1);break}return _}const Tyt=async(t,s,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:o=[],platform:l}=r,i=o.filter(Boolean),d=await(l.isRTL==null?void 0:l.isRTL(s));let u=await l.getElementRects({reference:t,floating:s,strategy:a}),{x:p,y:x}=EEe(u,n,d),y=n,_={},b=0;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}=h1(t,s)||{};if(u==null)return{};const x=lUe(p),y={x:r,y:n},_=ije(a),b=aje(_),N=await l.getDimensions(u),w=_==="y",k=w?"top":"left",C=w?"bottom":"right",E=w?"clientHeight":"clientWidth",L=o.reference[b]+o.reference[_]-y[_]-o.floating[b],I=y[_]-o.reference[_],O=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let V=O?O[E]:0;(!V||!await(l.isElement==null?void 0:l.isElement(O)))&&(V=i.floating[E]||o.floating[b]);const q=L/2-I/2,$=V/2-N[b]/2-1,U=Hb(x[k],$),se=Hb(x[C],$),Y=U,J=V-N[b]-se,X=V/2-N[b]/2+q,ce=kve(Y,X,J),ie=!d.arrow&&PA(a)!=null&&X!==ce&&o.reference[b]/2-(XX<=0)){var se,Y;const X=(((se=o.flip)==null?void 0:se.index)||0)+1,ce=V[X];if(ce)return{data:{index:X,overflows:U},reset:{placement:ce}};let ie=(Y=U.filter(ae=>ae.overflows[0]<=0).sort((ae,oe)=>ae.overflows[1]-oe.overflows[1])[0])==null?void 0:Y.placement;if(!ie)switch(_){case"bestFit":{var J;const ae=(J=U.filter(oe=>{if(O){const pe=Wb(oe.placement);return pe===C||pe==="y"}return!0}).map(oe=>[oe.placement,oe.overflows.filter(pe=>pe>0).reduce((pe,_e)=>pe+_e,0)]).sort((oe,pe)=>oe[1]-pe[1])[0])==null?void 0:J[0];ae&&(ie=ae);break}case"initialPlacement":ie=i;break}if(a!==ie)return{reset:{placement:ie}}}return{}}}};function PEe(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function IEe(t){return byt.some(s=>t[s]>=0)}const Pyt=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=h1(t,s);switch(n){case"referenceHidden":{const o=await V8(s,{...a,elementContext:"reference"}),l=PEe(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:IEe(l)}}}case"escaped":{const o=await V8(s,{...a,altBoundary:!0}),l=PEe(o,r.floating);return{data:{escapedOffsets:l,escaped:IEe(l)}}}default:return{}}}}};async function Iyt(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=m1(r),i=PA(r),d=Wb(r)==="y",u=["left","top"].includes(l)?-1:1,p=o&&d?-1:1,x=h1(s,t);let{mainAxis:y,crossAxis:_,alignmentAxis:b}=typeof x=="number"?{mainAxis:x,crossAxis:0,alignmentAxis:null}:{mainAxis:x.mainAxis||0,crossAxis:x.crossAxis||0,alignmentAxis:x.alignmentAxis};return i&&typeof b=="number"&&(_=i==="end"?b*-1:b),d?{x:_*p,y:y*u}:{x:y*u,y:_*p}}const Lyt=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 Iyt(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}}}}},Dyt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:r,y:n,placement:a}=s,{mainAxis:o=!0,crossAxis:l=!1,limiter:i={fn:w=>{let{x:k,y:C}=w;return{x:k,y:C}}},...d}=h1(t,s),u={x:r,y:n},p=await V8(s,d),x=Wb(m1(a)),y=nje(x);let _=u[y],b=u[x];if(o){const w=y==="y"?"top":"left",k=y==="y"?"bottom":"right",C=_+p[w],E=_-p[k];_=kve(C,_,E)}if(l){const w=x==="y"?"top":"left",k=x==="y"?"bottom":"right",C=b+p[w],E=b-p[k];b=kve(C,b,E)}const N=i.fn({...s,[y]:_,[x]:b});return{...N,data:{x:N.x-r,y:N.y-n,enabled:{[y]:o,[x]:l}}}}}},Ryt=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}=h1(t,s),p={x:r,y:n},x=Wb(a),y=nje(x);let _=p[y],b=p[x];const N=h1(i,s),w=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:0,crossAxis:0,...N};if(d){const E=y==="y"?"height":"width",L=o.reference[y]-o.floating[E]+w.mainAxis,I=o.reference[y]+o.reference[E]-w.mainAxis;_I&&(_=I)}if(u){var k,C;const E=y==="y"?"width":"height",L=["top","left"].includes(m1(a)),I=o.reference[x]-o.floating[E]+(L&&((k=l.offset)==null?void 0:k[x])||0)+(L?0:w.crossAxis),O=o.reference[x]+o.reference[E]+(L?0:((C=l.offset)==null?void 0:C[x])||0)-(L?w.crossAxis:0);bO&&(b=O)}return{[y]:_,[x]:b}}}},Oyt=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}=h1(t,s),p=await V8(s,u),x=m1(a),y=PA(a),_=Wb(a)==="y",{width:b,height:N}=o.floating;let w,k;x==="top"||x==="bottom"?(w=x,k=y===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(k=x,w=y==="end"?"top":"bottom");const C=N-p.top-p.bottom,E=b-p.left-p.right,L=Hb(N-p[w],C),I=Hb(b-p[k],E),O=!s.middlewareData.shift;let V=L,q=I;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&(q=E),(n=s.middlewareData.shift)!=null&&n.enabled.y&&(V=C),O&&!y){const U=Zp(p.left,0),se=Zp(p.right,0),Y=Zp(p.top,0),J=Zp(p.bottom,0);_?q=b-2*(U!==0||se!==0?U+se:Zp(p.left,p.right)):V=N-2*(Y!==0||J!==0?Y+J:Zp(p.top,p.bottom))}await d({...s,availableWidth:q,availableHeight:V});const $=await l.getDimensions(i.floating);return b!==$.width||N!==$.height?{reset:{rects:!0}}:{}}}};function Zde(){return typeof window<"u"}function IA(t){return cUe(t)?(t.nodeName||"").toLowerCase():"#document"}function af(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 Zde()?t instanceof Node||t instanceof af(t).Node:!1}function Fg(t){return Zde()?t instanceof Element||t instanceof af(t).Element:!1}function d0(t){return Zde()?t instanceof HTMLElement||t instanceof af(t).HTMLElement:!1}function LEe(t){return!Zde()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof af(t).ShadowRoot}function _R(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=zg(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!["inline","contents"].includes(a)}function Fyt(t){return["table","td","th"].includes(IA(t))}function Yde(t){return[":popover-open",":modal"].some(s=>{try{return t.matches(s)}catch{return!1}})}function oje(t){const s=lje(),r=Fg(t)?zg(t):t;return r.transform!=="none"||r.perspective!=="none"||(r.containerType?r.containerType!=="normal":!1)||!s&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!s&&(r.filter?r.filter!=="none":!1)||["transform","perspective","filter"].some(n=>(r.willChange||"").includes(n))||["paint","layout","strict","content"].some(n=>(r.contain||"").includes(n))}function zyt(t){let s=Kb(t);for(;d0(s)&&!jT(s);){if(oje(s))return s;if(Yde(s))return null;s=Kb(s)}return null}function lje(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function jT(t){return["html","body","#document"].includes(IA(t))}function zg(t){return af(t).getComputedStyle(t)}function Xde(t){return Fg(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Kb(t){if(IA(t)==="html")return t;const s=t.assignedSlot||t.parentNode||LEe(t)&&t.host||v0(t);return LEe(s)?s.host:s}function dUe(t){const s=Kb(t);return jT(s)?t.ownerDocument?t.ownerDocument.body:t.body:d0(s)&&_R(s)?s:dUe(s)}function H8(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=dUe(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=af(a);if(o){const i=Cve(l);return s.concat(l,l.visualViewport||[],_R(a)?a:[],i&&r?H8(i):[])}return s.concat(a,H8(a,[],r))}function Cve(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function uUe(t){const s=zg(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=d0(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=Poe(r)!==o||Poe(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function cje(t){return Fg(t)?t:t.contextElement}function FM(t){const s=cje(t);if(!d0(s))return Gb(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=uUe(s);let l=(o?Poe(r.width):r.width)/n,i=(o?Poe(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const Byt=Gb(0);function hUe(t){const s=af(t);return!lje()||!s.visualViewport?Byt:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function $yt(t,s,r){return s===void 0&&(s=!1),!r||s&&r!==af(t)?!1:s}function zS(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=cje(t);let l=Gb(1);s&&(n?Fg(n)&&(l=FM(n)):l=FM(t));const i=$yt(o,r,n)?hUe(o):Gb(0);let d=(a.left+i.x)/l.x,u=(a.top+i.y)/l.y,p=a.width/l.x,x=a.height/l.y;if(o){const y=af(o),_=n&&Fg(n)?af(n):n;let b=y,N=Cve(b);for(;N&&n&&_!==b;){const w=FM(N),k=N.getBoundingClientRect(),C=zg(N),E=k.left+(N.clientLeft+parseFloat(C.paddingLeft))*w.x,L=k.top+(N.clientTop+parseFloat(C.paddingTop))*w.y;d*=w.x,u*=w.y,p*=w.x,x*=w.y,d+=E,u+=L,b=af(N),N=Cve(b)}}return Loe({width:p,height:x,x:d,y:u})}function qyt(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=v0(n),i=s?Yde(s.floating):!1;if(n===l||i&&o)return r;let d={scrollLeft:0,scrollTop:0},u=Gb(1);const p=Gb(0),x=d0(n);if((x||!x&&!o)&&((IA(n)!=="body"||_R(l))&&(d=Xde(n)),d0(n))){const y=zS(n);u=FM(n),p.x=y.x+n.clientLeft,p.y=y.y+n.clientTop}return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-d.scrollLeft*u.x+p.x,y:r.y*u.y-d.scrollTop*u.y+p.y}}function Uyt(t){return Array.from(t.getClientRects())}function Mve(t,s){const r=Xde(t).scrollLeft;return s?s.left+r:zS(v0(t)).left+r}function Vyt(t){const s=v0(t),r=Xde(t),n=t.ownerDocument.body,a=Zp(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=Zp(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+Mve(t);const i=-r.scrollTop;return zg(n).direction==="rtl"&&(l+=Zp(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function Hyt(t,s){const r=af(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 u=lje();(!u||u&&s==="fixed")&&(i=a.offsetLeft,d=a.offsetTop)}return{width:o,height:l,x:i,y:d}}function Gyt(t,s){const r=zS(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=d0(t)?FM(t):Gb(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 DEe(t,s,r){let n;if(s==="viewport")n=Hyt(t,r);else if(s==="document")n=Vyt(v0(t));else if(Fg(s))n=Gyt(s,r);else{const a=hUe(t);n={...s,x:s.x-a.x,y:s.y-a.y}}return Loe(n)}function mUe(t,s){const r=Kb(t);return r===s||!Fg(r)||jT(r)?!1:zg(r).position==="fixed"||mUe(r,s)}function Wyt(t,s){const r=s.get(t);if(r)return r;let n=H8(t,[],!1).filter(i=>Fg(i)&&IA(i)!=="body"),a=null;const o=zg(t).position==="fixed";let l=o?Kb(t):t;for(;Fg(l)&&!jT(l);){const i=zg(l),d=oje(l);!d&&i.position==="fixed"&&(a=null),(o?!d&&!a:!d&&i.position==="static"&&!!a&&["absolute","fixed"].includes(a.position)||_R(l)&&!d&&mUe(t,l))?n=n.filter(p=>p!==l):a=i,l=Kb(l)}return s.set(t,n),n}function Kyt(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?Yde(s)?[]:Wyt(s,this._c):[].concat(r),n],i=l[0],d=l.reduce((u,p)=>{const x=DEe(s,p,a);return u.top=Zp(x.top,u.top),u.right=Hb(x.right,u.right),u.bottom=Hb(x.bottom,u.bottom),u.left=Zp(x.left,u.left),u},DEe(s,i,a));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function Zyt(t){const{width:s,height:r}=uUe(t);return{width:s,height:r}}function Yyt(t,s,r){const n=d0(s),a=v0(s),o=r==="fixed",l=zS(t,!0,o,s);let i={scrollLeft:0,scrollTop:0};const d=Gb(0);if(n||!n&&!o)if((IA(s)!=="body"||_R(a))&&(i=Xde(s)),n){const _=zS(s,!0,o,s);d.x=_.x+s.clientLeft,d.y=_.y+s.clientTop}else a&&(d.x=Mve(a));let u=0,p=0;if(a&&!n&&!o){const _=a.getBoundingClientRect();p=_.top+i.scrollTop,u=_.left+i.scrollLeft-Mve(a,_)}const x=l.left+i.scrollLeft-d.x-u,y=l.top+i.scrollTop-d.y-p;return{x,y,width:l.width,height:l.height}}function Gxe(t){return zg(t).position==="static"}function REe(t,s){if(!d0(t)||zg(t).position==="fixed")return null;if(s)return s(t);let r=t.offsetParent;return v0(t)===r&&(r=r.ownerDocument.body),r}function pUe(t,s){const r=af(t);if(Yde(t))return r;if(!d0(t)){let a=Kb(t);for(;a&&!jT(a);){if(Fg(a)&&!Gxe(a))return a;a=Kb(a)}return r}let n=REe(t,s);for(;n&&Fyt(n)&&Gxe(n);)n=REe(n,s);return n&&jT(n)&&Gxe(n)&&!oje(n)?r:n||zyt(t)||r}const Xyt=async function(t){const s=this.getOffsetParent||pUe,r=this.getDimensions,n=await r(t.floating);return{reference:Yyt(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Qyt(t){return zg(t).direction==="rtl"}const Jyt={convertOffsetParentRelativeRectToViewportRelativeRect:qyt,getDocumentElement:v0,getClippingRect:Kyt,getOffsetParent:pUe,getElementRects:Xyt,getClientRects:Uyt,getDimensions:Zyt,getScale:FM,isElement:Fg,isRTL:Qyt};function e0t(t,s){let r=null,n;const a=v0(t);function o(){var i;clearTimeout(n),(i=r)==null||i.disconnect(),r=null}function l(i,d){i===void 0&&(i=!1),d===void 0&&(d=1),o();const{left:u,top:p,width:x,height:y}=t.getBoundingClientRect();if(i||s(),!x||!y)return;const _=hz(p),b=hz(a.clientWidth-(u+x)),N=hz(a.clientHeight-(p+y)),w=hz(u),C={rootMargin:-_+"px "+-b+"px "+-N+"px "+-w+"px",threshold:Zp(0,Hb(1,d))||1};let E=!0;function L(I){const O=I[0].intersectionRatio;if(O!==d){if(!E)return l();O?l(!1,O):n=setTimeout(()=>{l(!1,1e-7)},1e3)}E=!1}try{r=new IntersectionObserver(L,{...C,root:a.ownerDocument})}catch{r=new IntersectionObserver(L,C)}r.observe(t)}return l(!0),o}function t0t(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=cje(t),p=a||o?[...u?H8(u):[],...H8(s)]:[];p.forEach(k=>{a&&k.addEventListener("scroll",r,{passive:!0}),o&&k.addEventListener("resize",r)});const x=u&&i?e0t(u,r):null;let y=-1,_=null;l&&(_=new ResizeObserver(k=>{let[C]=k;C&&C.target===u&&_&&(_.unobserve(s),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var E;(E=_)==null||E.observe(s)})),r()}),u&&!d&&_.observe(u),_.observe(s));let b,N=d?zS(t):null;d&&w();function w(){const k=zS(t);N&&(k.x!==N.x||k.y!==N.y||k.width!==N.width||k.height!==N.height)&&r(),N=k,b=requestAnimationFrame(w)}return r(),()=>{var k;p.forEach(C=>{a&&C.removeEventListener("scroll",r),o&&C.removeEventListener("resize",r)}),x==null||x(),(k=_)==null||k.disconnect(),_=null,d&&cancelAnimationFrame(b)}}const s0t=Lyt,r0t=Dyt,n0t=Eyt,a0t=Oyt,i0t=Pyt,OEe=Ayt,o0t=Ryt,l0t=(t,s,r)=>{const n=new Map,a={platform:Jyt,...r},o={...a.platform,_c:n};return Tyt(t,s,{...a,platform:o})};var Aie=typeof document<"u"?S.useLayoutEffect:S.useEffect;function Doe(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(!Doe(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)&&!Doe(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function fUe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function FEe(t,s){const r=fUe(t);return Math.round(s*r)/r}function Wxe(t){const s=S.useRef(t);return Aie(()=>{s.current=t}),s}function c0t(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,x]=S.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[y,_]=S.useState(n);Doe(y,n)||_(n);const[b,N]=S.useState(null),[w,k]=S.useState(null),C=S.useCallback(oe=>{oe!==O.current&&(O.current=oe,N(oe))},[]),E=S.useCallback(oe=>{oe!==V.current&&(V.current=oe,k(oe))},[]),L=o||b,I=l||w,O=S.useRef(null),V=S.useRef(null),q=S.useRef(p),$=d!=null,U=Wxe(d),se=Wxe(a),Y=Wxe(u),J=S.useCallback(()=>{if(!O.current||!V.current)return;const oe={placement:s,strategy:r,middleware:y};se.current&&(oe.platform=se.current),l0t(O.current,V.current,oe).then(pe=>{const _e={...pe,isPositioned:Y.current!==!1};X.current&&!Doe(q.current,_e)&&(q.current=_e,ip.flushSync(()=>{x(_e)}))})},[y,s,r,se,Y]);Aie(()=>{u===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,x(oe=>({...oe,isPositioned:!1})))},[u]);const X=S.useRef(!1);Aie(()=>(X.current=!0,()=>{X.current=!1}),[]),Aie(()=>{if(L&&(O.current=L),I&&(V.current=I),L&&I){if(U.current)return U.current(L,I,J);J()}},[L,I,J,U,$]);const ce=S.useMemo(()=>({reference:O,floating:V,setReference:C,setFloating:E}),[C,E]),ie=S.useMemo(()=>({reference:L,floating:I}),[L,I]),ae=S.useMemo(()=>{const oe={position:r,left:0,top:0};if(!ie.floating)return oe;const pe=FEe(ie.floating,p.x),_e=FEe(ie.floating,p.y);return i?{...oe,transform:"translate("+pe+"px, "+_e+"px)",...fUe(ie.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:pe,top:_e}},[r,i,ie.floating,p.x,p.y]);return S.useMemo(()=>({...p,update:J,refs:ce,elements:ie,floatingStyles:ae}),[p,J,ce,ie,ae])}const d0t=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?OEe({element:n.current,padding:a}).fn(r):{}:n?OEe({element:n,padding:a}).fn(r):{}}}},u0t=(t,s)=>({...s0t(t),options:[t,s]}),h0t=(t,s)=>({...r0t(t),options:[t,s]}),m0t=(t,s)=>({...o0t(t),options:[t,s]}),p0t=(t,s)=>({...n0t(t),options:[t,s]}),f0t=(t,s)=>({...a0t(t),options:[t,s]}),x0t=(t,s)=>({...i0t(t),options:[t,s]}),g0t=(t,s)=>({...d0t(t),options:[t,s]});var y0t="Arrow",xUe=S.forwardRef((t,s)=>{const{children:r,width:n=10,height:a=5,...o}=t;return e.jsx(Yr.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"})})});xUe.displayName=y0t;var v0t=xUe;function bR(t){const[s,r]=S.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 dje="Popper",[gUe,_0]=$c(dje),[_0t,yUe]=gUe(dje),vUe=t=>{const{__scopePopper:s,children:r}=t,[n,a]=S.useState(null);return e.jsx(_0t,{scope:s,anchor:n,onAnchorChange:a,children:r})};vUe.displayName=dje;var _Ue="PopperAnchor",bUe=S.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=yUe(_Ue,r),l=S.useRef(null),i=Aa(s,l);return S.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:e.jsx(Yr.div,{...a,ref:i})});bUe.displayName=_Ue;var uje="PopperContent",[b0t,w0t]=gUe(uje),wUe=S.forwardRef((t,s)=>{var Fe,Le,Ne,qe,ze,ve;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:x="partial",hideWhenDetached:y=!1,updatePositionStrategy:_="optimized",onPlaced:b,...N}=t,w=yUe(uje,r),[k,C]=S.useState(null),E=Aa(s,dt=>C(dt)),[L,I]=S.useState(null),O=bR(L),V=(O==null?void 0:O.width)??0,q=(O==null?void 0:O.height)??0,$=n+(o!=="center"?"-"+o:""),U=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},se=Array.isArray(u)?u:[u],Y=se.length>0,J={padding:U,boundary:se.filter(N0t),altBoundary:Y},{refs:X,floatingStyles:ce,placement:ie,isPositioned:ae,middlewareData:oe}=c0t({strategy:"fixed",placement:$,whileElementsMounted:(...dt)=>t0t(...dt,{animationFrame:_==="always"}),elements:{reference:w.anchor},middleware:[u0t({mainAxis:a+q,alignmentAxis:l}),d&&h0t({mainAxis:!0,crossAxis:!1,limiter:x==="partial"?m0t():void 0,...J}),d&&p0t({...J}),f0t({...J,apply:({elements:dt,rects:fe,availableWidth:Ve,availableHeight:Je})=>{const{width:at,height:Ae}=fe.reference,Ye=dt.floating.style;Ye.setProperty("--radix-popper-available-width",`${Ve}px`),Ye.setProperty("--radix-popper-available-height",`${Je}px`),Ye.setProperty("--radix-popper-anchor-width",`${at}px`),Ye.setProperty("--radix-popper-anchor-height",`${Ae}px`)}}),L&&g0t({element:L,padding:i}),k0t({arrowWidth:V,arrowHeight:q}),y&&x0t({strategy:"referenceHidden",...J})]}),[pe,_e]=kUe(ie),he=ed(b);rd(()=>{ae&&(he==null||he())},[ae,he]);const we=(Fe=oe.arrow)==null?void 0:Fe.x,je=(Le=oe.arrow)==null?void 0:Le.y,Ue=((Ne=oe.arrow)==null?void 0:Ne.centerOffset)!==0,[Te,Me]=S.useState();return rd(()=>{k&&Me(window.getComputedStyle(k).zIndex)},[k]),e.jsx("div",{ref:X.setFloating,"data-radix-popper-content-wrapper":"",style:{...ce,transform:ae?ce.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Te,"--radix-popper-transform-origin":[(qe=oe.transformOrigin)==null?void 0:qe.x,(ze=oe.transformOrigin)==null?void 0:ze.y].join(" "),...((ve=oe.hide)==null?void 0:ve.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(b0t,{scope:r,placedSide:pe,onArrowChange:I,arrowX:we,arrowY:je,shouldHideArrow:Ue,children:e.jsx(Yr.div,{"data-side":pe,"data-align":_e,...N,ref:E,style:{...N.style,animation:ae?void 0:"none"}})})})});wUe.displayName=uje;var jUe="PopperArrow",j0t={top:"bottom",right:"left",bottom:"top",left:"right"},NUe=S.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=w0t(jUe,n),l=j0t[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(v0t,{...a,ref:r,style:{...a.style,display:"block"}})})});NUe.displayName=jUe;function N0t(t){return t!==null}var k0t=t=>({name:"transformOrigin",options:t,fn(s){var w,k,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]=kUe(r),x={start:"0%",center:"50%",end:"100%"}[p],y=(((k=a.arrow)==null?void 0:k.x)??0)+i/2,_=(((C=a.arrow)==null?void 0:C.y)??0)+d/2;let b="",N="";return u==="bottom"?(b=l?x:`${y}px`,N=`${-d}px`):u==="top"?(b=l?x:`${y}px`,N=`${n.floating.height+d}px`):u==="right"?(b=`${-d}px`,N=l?x:`${_}px`):u==="left"&&(b=`${n.floating.width+d}px`,N=l?x:`${_}px`),{data:{x:b,y:N}}}});function kUe(t){const[s,r="center"]=t.split("-");return[s,r]}var wR=vUe,LA=bUe,jR=wUe,NR=NUe,[Qde,nTs]=$c("Tooltip",[_0]),Jde=_0(),SUe="TooltipProvider",S0t=700,Tve="tooltip.open",[C0t,hje]=Qde(SUe),CUe=t=>{const{__scopeTooltip:s,delayDuration:r=S0t,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=S.useRef(!0),i=S.useRef(!1),d=S.useRef(0);return S.useEffect(()=>{const u=d.current;return()=>window.clearTimeout(u)},[]),e.jsx(C0t,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:S.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:S.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:S.useCallback(u=>{i.current=u},[]),disableHoverableContent:a,children:o})};CUe.displayName=SUe;var G8="Tooltip",[M0t,eue]=Qde(G8),MUe=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,d=hje(G8,t.__scopeTooltip),u=Jde(s),[p,x]=S.useState(null),y=pu(),_=S.useRef(0),b=l??d.disableHoverableContent,N=i??d.delayDuration,w=S.useRef(!1),[k,C]=$u({prop:n,defaultProp:a??!1,onChange:V=>{V?(d.onOpen(),document.dispatchEvent(new CustomEvent(Tve))):d.onClose(),o==null||o(V)},caller:G8}),E=S.useMemo(()=>k?w.current?"delayed-open":"instant-open":"closed",[k]),L=S.useCallback(()=>{window.clearTimeout(_.current),_.current=0,w.current=!1,C(!0)},[C]),I=S.useCallback(()=>{window.clearTimeout(_.current),_.current=0,C(!1)},[C]),O=S.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{w.current=!0,C(!0),_.current=0},N)},[N,C]);return S.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),e.jsx(wR,{...u,children:e.jsx(M0t,{scope:s,contentId:y,open:k,stateAttribute:E,trigger:p,onTriggerChange:x,onTriggerEnter:S.useCallback(()=>{d.isOpenDelayedRef.current?O():L()},[d.isOpenDelayedRef,O,L]),onTriggerLeave:S.useCallback(()=>{b?I():(window.clearTimeout(_.current),_.current=0)},[I,b]),onOpen:L,onClose:I,disableHoverableContent:b,children:r})})};MUe.displayName=G8;var Ave="TooltipTrigger",TUe=S.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=eue(Ave,r),o=hje(Ave,r),l=Jde(r),i=S.useRef(null),d=Aa(s,i,a.onTriggerChange),u=S.useRef(!1),p=S.useRef(!1),x=S.useCallback(()=>u.current=!1,[]);return S.useEffect(()=>()=>document.removeEventListener("pointerup",x),[x]),e.jsx(LA,{asChild:!0,...l,children:e.jsx(Yr.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:d,onPointerMove:Cr(t.onPointerMove,y=>{y.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Cr(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Cr(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",x,{once:!0})}),onFocus:Cr(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Cr(t.onBlur,a.onClose),onClick:Cr(t.onClick,a.onClose)})})});TUe.displayName=Ave;var T0t="TooltipPortal",[aTs,A0t]=Qde(T0t,{forceMount:void 0}),NT="TooltipContent",AUe=S.forwardRef((t,s)=>{const r=A0t(NT,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=eue(NT,t.__scopeTooltip);return e.jsx(wd,{present:n||l.open,children:l.disableHoverableContent?e.jsx(EUe,{side:a,...o,ref:s}):e.jsx(E0t,{side:a,...o,ref:s})})}),E0t=S.forwardRef((t,s)=>{const r=eue(NT,t.__scopeTooltip),n=hje(NT,t.__scopeTooltip),a=S.useRef(null),o=Aa(s,a),[l,i]=S.useState(null),{trigger:d,onClose:u}=r,p=a.current,{onPointerInTransitChange:x}=n,y=S.useCallback(()=>{i(null),x(!1)},[x]),_=S.useCallback((b,N)=>{const w=b.currentTarget,k={x:b.clientX,y:b.clientY},C=R0t(k,w.getBoundingClientRect()),E=O0t(k,C),L=F0t(N.getBoundingClientRect()),I=B0t([...E,...L]);i(I),x(!0)},[x]);return S.useEffect(()=>()=>y(),[y]),S.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]),S.useEffect(()=>{if(l){const b=N=>{const w=N.target,k={x:N.clientX,y:N.clientY},C=(d==null?void 0:d.contains(w))||(p==null?void 0:p.contains(w)),E=!z0t(k,l);C?y():E&&(y(),u())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[d,p,l,u,y]),e.jsx(EUe,{...t,ref:o})}),[P0t,I0t]=Qde(G8,{isInside:!1}),L0t=kqe("TooltipContent"),EUe=S.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,d=eue(NT,r),u=Jde(r),{onClose:p}=d;return S.useEffect(()=>(document.addEventListener(Tve,p),()=>document.removeEventListener(Tve,p)),[p]),S.useEffect(()=>{if(d.trigger){const x=y=>{const _=y.target;_!=null&&_.contains(d.trigger)&&p()};return window.addEventListener("scroll",x,{capture:!0}),()=>window.removeEventListener("scroll",x,{capture:!0})}},[d.trigger,p]),e.jsx(lw,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:x=>x.preventDefault(),onDismiss:p,children:e.jsxs(jR,{"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(L0t,{children:n}),e.jsx(P0t,{scope:r,isInside:!0,children:e.jsx(Oxt,{id:d.contentId,role:"tooltip",children:a||n})})]})})});AUe.displayName=NT;var PUe="TooltipArrow",D0t=S.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=Jde(r);return I0t(PUe,r).isInside?null:e.jsx(NR,{...a,...n,ref:s})});D0t.displayName=PUe;function R0t(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 O0t(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 F0t(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 z0t(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=y>n&&r<(x-u)*(n-p)/(y-p)+u&&(a=!a)}return a}function B0t(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),$0t(s)}function $0t(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 q0t=CUe,U0t=MUe,V0t=TUe,IUe=AUe;const N1=q0t,Yl=U0t,Xl=V0t,Cl=S.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(IUe,{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}));Cl.displayName=IUe.displayName;var DA=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(){}},BS=typeof window>"u"||"Deno"in globalThis;function pm(){}function H0t(t,s){return typeof t=="function"?t(s):t}function Eve(t){return typeof t=="number"&&t>=0&&t!==1/0}function LUe(t,s){return Math.max(t+(s||0)-Date.now(),0)}function Eb(t,s){return typeof t=="function"?t(s):t}function Jf(t,s){return typeof t=="function"?t(s):t}function zEe(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==mje(l,s.options))return!1}else if(!W8(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 BEe(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if($S(s.options.mutationKey)!==$S(o))return!1}else if(!W8(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function mje(t,s){return((s==null?void 0:s.queryKeyHashFn)||$S)(t)}function $S(t){return JSON.stringify(t,(s,r)=>Pve(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function W8(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>W8(t[r],s[r])):!1}function DUe(t,s){if(t===s)return t;const r=$Ee(t)&&$Ee(s);if(r||Pve(t)&&Pve(s)){const n=r?t:Object.keys(t),a=n.length,o=r?s:Object.keys(s),l=o.length,i=r?[]:{},d=new Set(n);let u=0;for(let p=0;p{setTimeout(s,t)})}function Ive(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?DUe(t,s):s}function W0t(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function K0t(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var pje=Symbol();function RUe(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===pje?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function OUe(t,s){return typeof t=="function"?t(...s):!!t}var M4,K_,nT,eBe,Z0t=(eBe=class extends DA{constructor(){super();Oa(this,M4);Oa(this,K_);Oa(this,nT);Fn(this,nT,s=>{if(!BS&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){ds(this,K_)||this.setEventListener(ds(this,nT))}onUnsubscribe(){var s;this.hasListeners()||((s=ds(this,K_))==null||s.call(this),Fn(this,K_,void 0))}setEventListener(s){var r;Fn(this,nT,s),(r=ds(this,K_))==null||r.call(this),Fn(this,K_,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){ds(this,M4)!==s&&(Fn(this,M4,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof ds(this,M4)=="boolean"?ds(this,M4):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},M4=new WeakMap,K_=new WeakMap,nT=new WeakMap,eBe),fje=new Z0t,aT,Z_,iT,tBe,Y0t=(tBe=class extends DA{constructor(){super();Oa(this,aT,!0);Oa(this,Z_);Oa(this,iT);Fn(this,iT,s=>{if(!BS&&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(){ds(this,Z_)||this.setEventListener(ds(this,iT))}onUnsubscribe(){var s;this.hasListeners()||((s=ds(this,Z_))==null||s.call(this),Fn(this,Z_,void 0))}setEventListener(s){var r;Fn(this,iT,s),(r=ds(this,Z_))==null||r.call(this),Fn(this,Z_,s(this.setOnline.bind(this)))}setOnline(s){ds(this,aT)!==s&&(Fn(this,aT,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return ds(this,aT)}},aT=new WeakMap,Z_=new WeakMap,iT=new WeakMap,tBe),Ooe=new Y0t;function Lve(){let t,s;const r=new Promise((a,o)=>{t=a,s=o});r.status="pending",r.catch(()=>{});function n(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{n({status:"fulfilled",value:a}),t(a)},r.reject=a=>{n({status:"rejected",reason:a}),s(a)},r}function X0t(t){return Math.min(1e3*2**t,3e4)}function FUe(t){return(t??"online")==="online"?Ooe.isOnline():!0}var zUe=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function Kxe(t){return t instanceof zUe}function BUe(t){let s=!1,r=0,n=!1,a;const o=Lve(),l=N=>{var w;n||(y(new zUe(N)),(w=t.abort)==null||w.call(t))},i=()=>{s=!0},d=()=>{s=!1},u=()=>fje.isFocused()&&(t.networkMode==="always"||Ooe.isOnline())&&t.canRun(),p=()=>FUe(t.networkMode)&&t.canRun(),x=N=>{var w;n||(n=!0,(w=t.onSuccess)==null||w.call(t,N),a==null||a(),o.resolve(N))},y=N=>{var w;n||(n=!0,(w=t.onError)==null||w.call(t,N),a==null||a(),o.reject(N))},_=()=>new Promise(N=>{var w;a=k=>{(n||u())&&N(k)},(w=t.onPause)==null||w.call(t)}).then(()=>{var N;a=void 0,n||(N=t.onContinue)==null||N.call(t)}),b=()=>{if(n)return;let N;const w=r===0?t.initialPromise:void 0;try{N=w??t.fn()}catch(k){N=Promise.reject(k)}Promise.resolve(N).then(x).catch(k=>{var O;if(n)return;const C=t.retry??(BS?0:3),E=t.retryDelay??X0t,L=typeof E=="function"?E(r,k):E,I=C===!0||typeof C=="number"&&ru()?void 0:_()).then(()=>{s?y(k):b()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:d,canStart:p,start:()=>(p()?b():_().then(b),o)}}var Q0t=t=>setTimeout(t,0);function J0t(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=Q0t;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=J0t(),T4,sBe,$Ue=(sBe=class{constructor(){Oa(this,T4)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Eve(this.gcTime)&&Fn(this,T4,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(BS?1/0:5*60*1e3))}clearGcTimeout(){ds(this,T4)&&(clearTimeout(ds(this,T4)),Fn(this,T4,void 0))}},T4=new WeakMap,sBe),oT,A4,Qf,E4,kh,cR,P4,mg,yv,rBe,evt=(rBe=class extends $Ue{constructor(s){super();Oa(this,mg);Oa(this,oT);Oa(this,A4);Oa(this,Qf);Oa(this,E4);Oa(this,kh);Oa(this,cR);Oa(this,P4);Fn(this,P4,!1),Fn(this,cR,s.defaultOptions),this.setOptions(s.options),this.observers=[],Fn(this,E4,s.client),Fn(this,Qf,ds(this,E4).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,Fn(this,oT,tvt(this.options)),this.state=s.state??ds(this,oT),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=ds(this,kh))==null?void 0:s.promise}setOptions(s){this.options={...ds(this,cR),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&ds(this,Qf).remove(this)}setData(s,r){const n=Ive(this.state.data,s,this.options);return Pi(this,mg,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){Pi(this,mg,yv).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=ds(this,kh))==null?void 0:n.promise;return(a=ds(this,kh))==null||a.cancel(s),r?r.then(pm).catch(pm):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ds(this,oT))}isActive(){return this.observers.some(s=>Jf(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===pje||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>Eb(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:!LUe(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=ds(this,kh))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=ds(this,kh))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),ds(this,Qf).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(ds(this,kh)&&(ds(this,P4)?ds(this,kh).cancel({revert:!0}):ds(this,kh).cancelRetry()),this.scheduleGc()),ds(this,Qf).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Pi(this,mg,yv).call(this,{type:"invalidate"})}fetch(s,r){var u,p,x;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(ds(this,kh))return ds(this,kh).continueRetry(),ds(this,kh).promise}if(s&&this.setOptions(s),!this.options.queryFn){const y=this.observers.find(_=>_.options.queryFn);y&&this.setOptions(y.options)}const n=new AbortController,a=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(Fn(this,P4,!0),n.signal)})},o=()=>{const y=RUe(this.options,r),b=(()=>{const N={client:ds(this,E4),queryKey:this.queryKey,meta:this.meta};return a(N),N})();return Fn(this,P4,!1),this.options.persister?this.options.persister(y,b,this):y(b)},i=(()=>{const y={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:ds(this,E4),state:this.state,fetchFn:o};return a(y),y})();(u=this.options.behavior)==null||u.onFetch(i,this),Fn(this,A4,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=i.fetchOptions)==null?void 0:p.meta))&&Pi(this,mg,yv).call(this,{type:"fetch",meta:(x=i.fetchOptions)==null?void 0:x.meta});const d=y=>{var _,b,N,w;Kxe(y)&&y.silent||Pi(this,mg,yv).call(this,{type:"error",error:y}),Kxe(y)||((b=(_=ds(this,Qf).config).onError)==null||b.call(_,y,this),(w=(N=ds(this,Qf).config).onSettled)==null||w.call(N,this.state.data,y,this)),this.scheduleGc()};return Fn(this,kh,BUe({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:y=>{var _,b,N,w;if(y===void 0){d(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(y)}catch(k){d(k);return}(b=(_=ds(this,Qf).config).onSuccess)==null||b.call(_,y,this),(w=(N=ds(this,Qf).config).onSettled)==null||w.call(N,y,this.state.error,this),this.scheduleGc()},onError:d,onFail:(y,_)=>{Pi(this,mg,yv).call(this,{type:"failed",failureCount:y,error:_})},onPause:()=>{Pi(this,mg,yv).call(this,{type:"pause"})},onContinue:()=>{Pi(this,mg,yv).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),ds(this,kh).start()}},oT=new WeakMap,A4=new WeakMap,Qf=new WeakMap,E4=new WeakMap,kh=new WeakMap,cR=new WeakMap,P4=new WeakMap,mg=new WeakSet,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,...qUe(n.data,this.options),fetchMeta:s.meta??null};case"success":return Fn(this,A4,void 0),{...n,data:s.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:s.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!s.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const a=s.error;return Kxe(a)&&a.revert&&ds(this,A4)?{...ds(this,A4),fetchStatus:"idle"}:{...n,error:a,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...s.state}}};this.state=r(this.state),ru.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),ds(this,Qf).notify({query:this,type:"updated",action:s})})},rBe);function qUe(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:FUe(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function tvt(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 Py,nBe,svt=(nBe=class extends DA{constructor(s={}){super();Oa(this,Py);this.config=s,Fn(this,Py,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??mje(a,r);let l=this.get(o);return l||(l=new evt({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){ds(this,Py).has(s.queryHash)||(ds(this,Py).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=ds(this,Py).get(s.queryHash);r&&(s.destroy(),r===s&&ds(this,Py).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){ru.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return ds(this,Py).get(s)}getAll(){return[...ds(this,Py).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>zEe(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>zEe(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()})})}},Py=new WeakMap,nBe),Iy,um,I4,Ly,__,aBe,rvt=(aBe=class extends $Ue{constructor(s){super();Oa(this,Ly);Oa(this,Iy);Oa(this,um);Oa(this,I4);this.mutationId=s.mutationId,Fn(this,um,s.mutationCache),Fn(this,Iy,[]),this.state=s.state||UUe(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){ds(this,Iy).includes(s)||(ds(this,Iy).push(s),this.clearGcTimeout(),ds(this,um).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){Fn(this,Iy,ds(this,Iy).filter(r=>r!==s)),this.scheduleGc(),ds(this,um).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){ds(this,Iy).length||(this.state.status==="pending"?this.scheduleGc():ds(this,um).remove(this))}continue(){var s;return((s=ds(this,I4))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,i,d,u,p,x,y,_,b,N,w,k,C,E,L,I,O,V,q;const r=()=>{Pi(this,Ly,__).call(this,{type:"continue"})};Fn(this,I4,BUe({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:($,U)=>{Pi(this,Ly,__).call(this,{type:"failed",failureCount:$,error:U})},onPause:()=>{Pi(this,Ly,__).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>ds(this,um).canRun(this)}));const n=this.state.status==="pending",a=!ds(this,I4).canStart();try{if(n)r();else{Pi(this,Ly,__).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=ds(this,um).config).onMutate)==null?void 0:l.call(o,s,this));const U=await((d=(i=this.options).onMutate)==null?void 0:d.call(i,s));U!==this.state.context&&Pi(this,Ly,__).call(this,{type:"pending",context:U,variables:s,isPaused:a})}const $=await ds(this,I4).start();return await((p=(u=ds(this,um).config).onSuccess)==null?void 0:p.call(u,$,s,this.state.context,this)),await((y=(x=this.options).onSuccess)==null?void 0:y.call(x,$,s,this.state.context)),await((b=(_=ds(this,um).config).onSettled)==null?void 0:b.call(_,$,null,this.state.variables,this.state.context,this)),await((w=(N=this.options).onSettled)==null?void 0:w.call(N,$,null,s,this.state.context)),Pi(this,Ly,__).call(this,{type:"success",data:$}),$}catch($){try{throw await((C=(k=ds(this,um).config).onError)==null?void 0:C.call(k,$,s,this.state.context,this)),await((L=(E=this.options).onError)==null?void 0:L.call(E,$,s,this.state.context)),await((O=(I=ds(this,um).config).onSettled)==null?void 0:O.call(I,void 0,$,this.state.variables,this.state.context,this)),await((q=(V=this.options).onSettled)==null?void 0:q.call(V,void 0,$,s,this.state.context)),$}finally{Pi(this,Ly,__).call(this,{type:"error",error:$})}}finally{ds(this,um).runNext(this)}}},Iy=new WeakMap,um=new WeakMap,I4=new WeakMap,Ly=new WeakSet,__=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(()=>{ds(this,Iy).forEach(n=>{n.onMutationUpdate(s)}),ds(this,um).notify({mutation:this,type:"updated",action:s})})},aBe);function UUe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Pv,pg,dR,iBe,nvt=(iBe=class extends DA{constructor(s={}){super();Oa(this,Pv);Oa(this,pg);Oa(this,dR);this.config=s,Fn(this,Pv,new Set),Fn(this,pg,new Map),Fn(this,dR,0)}build(s,r,n){const a=new rvt({mutationCache:this,mutationId:++H7(this,dR)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){ds(this,Pv).add(s);const r=mz(s);if(typeof r=="string"){const n=ds(this,pg).get(r);n?n.push(s):ds(this,pg).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(ds(this,Pv).delete(s)){const r=mz(s);if(typeof r=="string"){const n=ds(this,pg).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&ds(this,pg).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=mz(s);if(typeof r=="string"){const n=ds(this,pg).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=mz(s);if(typeof r=="string"){const a=(n=ds(this,pg).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(()=>{ds(this,Pv).forEach(s=>{this.notify({type:"removed",mutation:s})}),ds(this,Pv).clear(),ds(this,pg).clear()})}getAll(){return Array.from(ds(this,Pv))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>BEe(r,n))}findAll(s={}){return this.getAll().filter(r=>BEe(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(pm))))}},Pv=new WeakMap,pg=new WeakMap,dR=new WeakMap,iBe);function mz(t){var s;return(s=t.options.scope)==null?void 0:s.id}function Foe(t){return{onFetch:(s,r)=>{var p,x,y,_,b;const n=s.options,a=(y=(x=(p=s.fetchOptions)==null?void 0:p.meta)==null?void 0:x.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=E=>{Object.defineProperty(E,"signal",{enumerable:!0,get:()=>(s.signal.aborted?N=!0:s.signal.addEventListener("abort",()=>{N=!0}),s.signal)})},k=RUe(s.options,s.fetchOptions),C=async(E,L,I)=>{if(N)return Promise.reject();if(L==null&&E.pages.length)return Promise.resolve(E);const V=(()=>{const se={client:s.client,queryKey:s.queryKey,pageParam:L,direction:I?"backward":"forward",meta:s.options.meta};return w(se),se})(),q=await k(V),{maxPages:$}=s.options,U=I?K0t:W0t;return{pages:U(E.pages,q,$),pageParams:U(E.pageParams,L,$)}};if(a&&o.length){const E=a==="backward",L=E?VUe:Dve,I={pages:o,pageParams:l},O=L(n,I);i=await C(I,O,E)}else{const E=t??o.length;do{const L=d===0?l[0]??n.initialPageParam:Dve(n,i);if(d>0&&L==null)break;i=await C(i,L),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 Dve(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 VUe(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 avt(t,s){return s?Dve(t,s)!=null:!1}function ivt(t,s){return!s||!t.getPreviousPageParam?!1:VUe(t,s)!=null}var Hc,Y_,X_,lT,cT,Q_,dT,uT,oBe,ovt=(oBe=class{constructor(t={}){Oa(this,Hc);Oa(this,Y_);Oa(this,X_);Oa(this,lT);Oa(this,cT);Oa(this,Q_);Oa(this,dT);Oa(this,uT);Fn(this,Hc,t.queryCache||new svt),Fn(this,Y_,t.mutationCache||new nvt),Fn(this,X_,t.defaultOptions||{}),Fn(this,lT,new Map),Fn(this,cT,new Map),Fn(this,Q_,0)}mount(){H7(this,Q_)._++,ds(this,Q_)===1&&(Fn(this,dT,fje.subscribe(async t=>{t&&(await this.resumePausedMutations(),ds(this,Hc).onFocus())})),Fn(this,uT,Ooe.subscribe(async t=>{t&&(await this.resumePausedMutations(),ds(this,Hc).onOnline())})))}unmount(){var t,s;H7(this,Q_)._--,ds(this,Q_)===0&&((t=ds(this,dT))==null||t.call(this),Fn(this,dT,void 0),(s=ds(this,uT))==null||s.call(this),Fn(this,uT,void 0))}isFetching(t){return ds(this,Hc).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return ds(this,Y_).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=ds(this,Hc).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=ds(this,Hc).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(Eb(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return ds(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=ds(this,Hc).get(n.queryHash),o=a==null?void 0:a.state.data,l=H0t(s,o);if(l!==void 0)return ds(this,Hc).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return ru.batch(()=>ds(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=ds(this,Hc).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=ds(this,Hc);ru.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=ds(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(()=>ds(this,Hc).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(pm).catch(pm)}invalidateQueries(t,s={}){return ru.batch(()=>(ds(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(()=>ds(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(pm)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(pm)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=ds(this,Hc).build(this,s);return r.isStaleByTime(Eb(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(pm).catch(pm)}fetchInfiniteQuery(t){return t.behavior=Foe(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(pm).catch(pm)}ensureInfiniteQueryData(t){return t.behavior=Foe(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Ooe.isOnline()?ds(this,Y_).resumePausedMutations():Promise.resolve()}getQueryCache(){return ds(this,Hc)}getMutationCache(){return ds(this,Y_)}getDefaultOptions(){return ds(this,X_)}setDefaultOptions(t){Fn(this,X_,t)}setQueryDefaults(t,s){ds(this,lT).set($S(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...ds(this,lT).values()],r={};return s.forEach(n=>{W8(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){ds(this,cT).set($S(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...ds(this,cT).values()],r={};return s.forEach(n=>{W8(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...ds(this,X_).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=mje(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===pje&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...ds(this,X_).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){ds(this,Hc).clear(),ds(this,Y_).clear()}},Hc=new WeakMap,Y_=new WeakMap,X_=new WeakMap,lT=new WeakMap,cT=new WeakMap,Q_=new WeakMap,dT=new WeakMap,uT=new WeakMap,oBe),Ym,Ji,uR,hm,L4,hT,J_,eb,hR,mT,pT,D4,R4,tb,fT,qo,SI,Rve,Ove,Fve,zve,Bve,$ve,qve,GUe,lBe,HUe=(lBe=class extends DA{constructor(s,r){super();Oa(this,qo);Oa(this,Ym);Oa(this,Ji);Oa(this,uR);Oa(this,hm);Oa(this,L4);Oa(this,hT);Oa(this,J_);Oa(this,eb);Oa(this,hR);Oa(this,mT);Oa(this,pT);Oa(this,D4);Oa(this,R4);Oa(this,tb);Oa(this,fT,new Set);this.options=r,Fn(this,Ym,s),Fn(this,eb,null),Fn(this,J_,Lve()),this.options.experimental_prefetchInRender||ds(this,J_).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(ds(this,Ji).addObserver(this),UEe(ds(this,Ji),this.options)?Pi(this,qo,SI).call(this):this.updateResult(),Pi(this,qo,zve).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Uve(ds(this,Ji),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Uve(ds(this,Ji),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Pi(this,qo,Bve).call(this),Pi(this,qo,$ve).call(this),ds(this,Ji).removeObserver(this)}setOptions(s){const r=this.options,n=ds(this,Ji);if(this.options=ds(this,Ym).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Jf(this.options.enabled,ds(this,Ji))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Pi(this,qo,qve).call(this),ds(this,Ji).setOptions(this.options),r._defaulted&&!Roe(this.options,r)&&ds(this,Ym).getQueryCache().notify({type:"observerOptionsUpdated",query:ds(this,Ji),observer:this});const a=this.hasListeners();a&&VEe(ds(this,Ji),n,this.options,r)&&Pi(this,qo,SI).call(this),this.updateResult(),a&&(ds(this,Ji)!==n||Jf(this.options.enabled,ds(this,Ji))!==Jf(r.enabled,ds(this,Ji))||Eb(this.options.staleTime,ds(this,Ji))!==Eb(r.staleTime,ds(this,Ji)))&&Pi(this,qo,Rve).call(this);const o=Pi(this,qo,Ove).call(this);a&&(ds(this,Ji)!==n||Jf(this.options.enabled,ds(this,Ji))!==Jf(r.enabled,ds(this,Ji))||o!==ds(this,tb))&&Pi(this,qo,Fve).call(this,o)}getOptimisticResult(s){const r=ds(this,Ym).getQueryCache().build(ds(this,Ym),s),n=this.createResult(r,s);return cvt(this,n)&&(Fn(this,hm,n),Fn(this,hT,this.options),Fn(this,L4,ds(this,Ji).state)),n}getCurrentResult(){return ds(this,hm)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){ds(this,fT).add(s)}getCurrentQuery(){return ds(this,Ji)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=ds(this,Ym).defaultQueryOptions(s),n=ds(this,Ym).getQueryCache().build(ds(this,Ym),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return Pi(this,qo,SI).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),ds(this,hm)))}createResult(s,r){var $;const n=ds(this,Ji),a=this.options,o=ds(this,hm),l=ds(this,L4),i=ds(this,hT),u=s!==n?s.state:ds(this,uR),{state:p}=s;let x={...p},y=!1,_;if(r._optimisticResults){const U=this.hasListeners(),se=!U&&UEe(s,r),Y=U&&VEe(s,n,r,a);(se||Y)&&(x={...x,...qUe(p.data,s.options)}),r._optimisticResults==="isRestoring"&&(x.fetchStatus="idle")}let{error:b,errorUpdatedAt:N,status:w}=x;_=x.data;let k=!1;if(r.placeholderData!==void 0&&_===void 0&&w==="pending"){let U;o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(U=o.data,k=!0):U=typeof r.placeholderData=="function"?r.placeholderData(($=ds(this,pT))==null?void 0:$.state.data,ds(this,pT)):r.placeholderData,U!==void 0&&(w="success",_=Ive(o==null?void 0:o.data,U,r),y=!0)}if(r.select&&_!==void 0&&!k)if(o&&_===(l==null?void 0:l.data)&&r.select===ds(this,hR))_=ds(this,mT);else try{Fn(this,hR,r.select),_=r.select(_),_=Ive(o==null?void 0:o.data,_,r),Fn(this,mT,_),Fn(this,eb,null)}catch(U){Fn(this,eb,U)}ds(this,eb)&&(b=ds(this,eb),_=ds(this,mT),N=Date.now(),w="error");const C=x.fetchStatus==="fetching",E=w==="pending",L=w==="error",I=E&&C,O=_!==void 0,q={status:w,fetchStatus:x.fetchStatus,isPending:E,isSuccess:w==="success",isError:L,isInitialLoading:I,isLoading:I,data:_,dataUpdatedAt:x.dataUpdatedAt,error:b,errorUpdatedAt:N,failureCount:x.fetchFailureCount,failureReason:x.fetchFailureReason,errorUpdateCount:x.errorUpdateCount,isFetched:x.dataUpdateCount>0||x.errorUpdateCount>0,isFetchedAfterMount:x.dataUpdateCount>u.dataUpdateCount||x.errorUpdateCount>u.errorUpdateCount,isFetching:C,isRefetching:C&&!E,isLoadingError:L&&!O,isPaused:x.fetchStatus==="paused",isPlaceholderData:y,isRefetchError:L&&O,isStale:xje(s,r),refetch:this.refetch,promise:ds(this,J_),isEnabled:Jf(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const U=J=>{q.status==="error"?J.reject(q.error):q.data!==void 0&&J.resolve(q.data)},se=()=>{const J=Fn(this,J_,q.promise=Lve());U(J)},Y=ds(this,J_);switch(Y.status){case"pending":s.queryHash===n.queryHash&&U(Y);break;case"fulfilled":(q.status==="error"||q.data!==Y.value)&&se();break;case"rejected":(q.status!=="error"||q.error!==Y.reason)&&se();break}}return q}updateResult(){const s=ds(this,hm),r=this.createResult(ds(this,Ji),this.options);if(Fn(this,L4,ds(this,Ji).state),Fn(this,hT,this.options),ds(this,L4).data!==void 0&&Fn(this,pT,ds(this,Ji)),Roe(r,s))return;Fn(this,hm,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!ds(this,fT).size)return!0;const l=new Set(o??ds(this,fT));return this.options.throwOnError&&l.add("error"),Object.keys(ds(this,hm)).some(i=>{const d=i;return ds(this,hm)[d]!==s[d]&&l.has(d)})};Pi(this,qo,GUe).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Pi(this,qo,zve).call(this)}},Ym=new WeakMap,Ji=new WeakMap,uR=new WeakMap,hm=new WeakMap,L4=new WeakMap,hT=new WeakMap,J_=new WeakMap,eb=new WeakMap,hR=new WeakMap,mT=new WeakMap,pT=new WeakMap,D4=new WeakMap,R4=new WeakMap,tb=new WeakMap,fT=new WeakMap,qo=new WeakSet,SI=function(s){Pi(this,qo,qve).call(this);let r=ds(this,Ji).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(pm)),r},Rve=function(){Pi(this,qo,Bve).call(this);const s=Eb(this.options.staleTime,ds(this,Ji));if(BS||ds(this,hm).isStale||!Eve(s))return;const n=LUe(ds(this,hm).dataUpdatedAt,s)+1;Fn(this,D4,setTimeout(()=>{ds(this,hm).isStale||this.updateResult()},n))},Ove=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ds(this,Ji)):this.options.refetchInterval)??!1},Fve=function(s){Pi(this,qo,$ve).call(this),Fn(this,tb,s),!(BS||Jf(this.options.enabled,ds(this,Ji))===!1||!Eve(ds(this,tb))||ds(this,tb)===0)&&Fn(this,R4,setInterval(()=>{(this.options.refetchIntervalInBackground||fje.isFocused())&&Pi(this,qo,SI).call(this)},ds(this,tb)))},zve=function(){Pi(this,qo,Rve).call(this),Pi(this,qo,Fve).call(this,Pi(this,qo,Ove).call(this))},Bve=function(){ds(this,D4)&&(clearTimeout(ds(this,D4)),Fn(this,D4,void 0))},$ve=function(){ds(this,R4)&&(clearInterval(ds(this,R4)),Fn(this,R4,void 0))},qve=function(){const s=ds(this,Ym).getQueryCache().build(ds(this,Ym),this.options);if(s===ds(this,Ji))return;const r=ds(this,Ji);Fn(this,Ji,s),Fn(this,uR,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},GUe=function(s){ru.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(ds(this,hm))}),ds(this,Ym).getQueryCache().notify({query:ds(this,Ji),type:"observerResultsUpdated"})})},lBe);function lvt(t,s){return Jf(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function UEe(t,s){return lvt(t,s)||t.state.data!==void 0&&Uve(t,s,s.refetchOnMount)}function Uve(t,s,r){if(Jf(s.enabled,t)!==!1&&Eb(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&xje(t,s)}return!1}function VEe(t,s,r,n){return(t!==s||Jf(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&xje(t,r)}function xje(t,s){return Jf(s.enabled,t)!==!1&&t.isStaleByTime(Eb(s.staleTime,t))}function cvt(t,s){return!Roe(t.getCurrentResult(),s)}var dvt=class extends HUe{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:Foe()})}getOptimisticResult(t){return t.behavior=Foe(),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",x=l&&d==="backward",y=a&&d==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:avt(s,r.data),hasPreviousPage:ivt(s,r.data),isFetchNextPageError:u,isFetchingNextPage:p,isFetchPreviousPageError:x,isFetchingPreviousPage:y,isRefetchError:i&&!u&&!x,isRefetching:o&&!p&&!y}}},sb,rb,Xm,Iv,i1,Eie,Vve,cBe,uvt=(cBe=class extends DA{constructor(r,n){super();Oa(this,i1);Oa(this,sb);Oa(this,rb);Oa(this,Xm);Oa(this,Iv);Fn(this,sb,r),this.setOptions(n),this.bindMethods(),Pi(this,i1,Eie).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=ds(this,sb).defaultMutationOptions(r),Roe(this.options,n)||ds(this,sb).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ds(this,Xm),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&$S(n.mutationKey)!==$S(this.options.mutationKey)?this.reset():((a=ds(this,Xm))==null?void 0:a.state.status)==="pending"&&ds(this,Xm).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=ds(this,Xm))==null||r.removeObserver(this)}onMutationUpdate(r){Pi(this,i1,Eie).call(this),Pi(this,i1,Vve).call(this,r)}getCurrentResult(){return ds(this,rb)}reset(){var r;(r=ds(this,Xm))==null||r.removeObserver(this),Fn(this,Xm,void 0),Pi(this,i1,Eie).call(this),Pi(this,i1,Vve).call(this)}mutate(r,n){var a;return Fn(this,Iv,n),(a=ds(this,Xm))==null||a.removeObserver(this),Fn(this,Xm,ds(this,sb).getMutationCache().build(ds(this,sb),this.options)),ds(this,Xm).addObserver(this),ds(this,Xm).execute(r)}},sb=new WeakMap,rb=new WeakMap,Xm=new WeakMap,Iv=new WeakMap,i1=new WeakSet,Eie=function(){var n;const r=((n=ds(this,Xm))==null?void 0:n.state)??UUe();Fn(this,rb,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},Vve=function(r){ru.batch(()=>{var n,a,o,l,i,d,u,p;if(ds(this,Iv)&&this.hasListeners()){const x=ds(this,rb).variables,y=ds(this,rb).context;(r==null?void 0:r.type)==="success"?((a=(n=ds(this,Iv)).onSuccess)==null||a.call(n,r.data,x,y),(l=(o=ds(this,Iv)).onSettled)==null||l.call(o,r.data,null,x,y)):(r==null?void 0:r.type)==="error"&&((d=(i=ds(this,Iv)).onError)==null||d.call(i,r.error,x,y),(p=(u=ds(this,Iv)).onSettled)==null||p.call(u,void 0,r.error,x,y))}this.listeners.forEach(x=>{x(ds(this,rb))})})},cBe),WUe=S.createContext(void 0),Jt=t=>{const s=S.useContext(WUe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},hvt=({client:t,children:s})=>(S.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(WUe.Provider,{value:t,children:s})),KUe=S.createContext(!1),mvt=()=>S.useContext(KUe);KUe.Provider;function pvt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var fvt=S.createContext(pvt()),xvt=()=>S.useContext(fvt),gvt=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},yvt=t=>{S.useEffect(()=>{t.clearReset()},[t])},vvt=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||OUe(r,[t.error,n])),_vt=t=>{if(t.suspense){const s=n=>n==="static"?n:Math.max(n??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...n)=>s(r(...n)):s(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},bvt=(t,s)=>t.isLoading&&t.isFetching&&!s,wvt=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,HEe=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function ZUe(t,s,r){var x,y,_,b,N;const n=mvt(),a=xvt(),o=Jt(),l=o.defaultQueryOptions(t);(y=(x=o.getDefaultOptions().queries)==null?void 0:x._experimental_beforeQuery)==null||y.call(x,l),l._optimisticResults=n?"isRestoring":"optimistic",_vt(l),gvt(l,a),yvt(a);const i=!o.getQueryCache().get(l.queryHash),[d]=S.useState(()=>new s(o,l)),u=d.getOptimisticResult(l),p=!n&&t.subscribed!==!1;if(S.useSyncExternalStore(S.useCallback(w=>{const k=p?d.subscribe(ru.batchCalls(w)):pm;return d.updateResult(),k},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),S.useEffect(()=>{d.setOptions(l)},[l,d]),wvt(l,u))throw HEe(l,d,a);if(vvt({result:u,errorResetBoundary:a,throwOnError:l.throwOnError,query:o.getQueryCache().get(l.queryHash),suspense:l.suspense}))throw u.error;if((b=(_=o.getDefaultOptions().queries)==null?void 0:_._experimental_afterQuery)==null||b.call(_,l,u),l.experimental_prefetchInRender&&!BS&&bvt(u,n)){const w=i?HEe(l,d,a):(N=o.getQueryCache().get(l.queryHash))==null?void 0:N.promise;w==null||w.catch(pm).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?u:d.trackResult(u)}function gt(t,s){return ZUe(t,HUe)}function It(t,s){const r=Jt(),[n]=S.useState(()=>new uvt(r,t));S.useEffect(()=>{n.setOptions(t)},[n,t]);const a=S.useSyncExternalStore(S.useCallback(l=>n.subscribe(ru.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=S.useCallback((l,i)=>{n.mutate(l,i).catch(pm)},[n]);if(a.error&&OUe(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function jvt(t,s){return ZUe(t,dvt)}/** * @remix-run/router v1.23.0 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function K8(){return K8=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function YUe(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function kvt(){return Math.random().toString(36).substr(2,8)}function WEe(t,s){return{usr:t.state,key:t.key,idx:s}}function Hve(t,s,r,n){return r===void 0&&(r=null),K8({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?RA(s):s,{state:r,key:s&&s.key||n||kvt()})}function zoe(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 RA(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 Svt(t,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=ib.Pop,d=null,u=p();u==null&&(u=0,l.replaceState(K8({},l.state,{idx:u}),""));function p(){return(l.state||{idx:null}).idx}function x(){i=ib.Pop;let w=p(),k=w==null?null:w-u;u=w,d&&d({action:i,location:N.location,delta:k})}function y(w,k){i=ib.Push;let C=Hve(N.location,w,k);u=p()+1;let E=WEe(C,u),L=N.createHref(C);try{l.pushState(E,"",L)}catch(I){if(I instanceof DOMException&&I.name==="DataCloneError")throw I;a.location.assign(L)}o&&d&&d({action:i,location:N.location,delta:1})}function _(w,k){i=ib.Replace;let C=Hve(N.location,w,k);u=p();let E=WEe(C,u),L=N.createHref(C);l.replaceState(E,"",L),o&&d&&d({action:i,location:N.location,delta:0})}function b(w){let k=a.location.origin!=="null"?a.location.origin:a.location.href,C=typeof w=="string"?w:zoe(w);return C=C.replace(/ $/,"%20"),_d(k,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,k)}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(GEe,x),d=w,()=>{a.removeEventListener(GEe,x),d=null}},createHref(w){return s(a,w)},createURL:b,encodeLocation(w){let k=b(w);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:y,replace:_,go(w){return l.go(w)}};return N}var KEe;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(KEe||(KEe={}));function Cvt(t,s,r){return r===void 0&&(r="/"),Mvt(t,s,r,!1)}function Mvt(t,s,r,n){let a=typeof s=="string"?RA(s):s,o=gje(a.pathname||"/",r);if(o==null)return null;let l=XUe(t);Tvt(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=Pb([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+'".')),XUe(o.children,s,p,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:Rvt(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 QUe(o.path))a(o,l,d)}),s}function QUe(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=QUe(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 Tvt(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:Ovt(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const Avt=/^:[\w-]+$/,Evt=3,Pvt=2,Ivt=1,Lvt=10,Dvt=-2,ZEe=t=>t==="*";function Rvt(t,s){let r=t.split("/"),n=r.length;return r.some(ZEe)&&(n+=Dvt),s&&(n+=Pvt),r.filter(a=>!ZEe(a)).reduce((a,o)=>a+(Avt.test(o)?Evt:o===""?Ivt:Lvt),n)}function Ovt(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 Fvt(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[x]||"";l=o.slice(0,o.length-N.length).replace(/(.)\/+$/,"$1")}const b=i[x];return _&&!b?u[y]=void 0:u[y]=(b||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:l,pattern:t}}function zvt(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),YUe(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 Bvt(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return YUe(!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 gje(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let r=s.endsWith("/")?s.length-1:s.length,n=t.charAt(r);return n&&n!=="/"?null:t.slice(r)||"/"}function $vt(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?RA(t):t;return{pathname:r?r.startsWith("/")?r:qvt(r,s):s,search:Hvt(n),hash:Gvt(a)}}function qvt(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 Zxe(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 Uvt(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function yje(t,s){let r=Uvt(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function vje(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=RA(t):(a=K8({},t),_d(!a.pathname||!a.pathname.includes("?"),Zxe("?","pathname","search",a)),_d(!a.pathname||!a.pathname.includes("#"),Zxe("#","pathname","hash",a)),_d(!a.search||!a.search.includes("#"),Zxe("#","search","hash",a)));let o=t===""||a.pathname==="",l=o?"/":a.pathname,i;if(l==null)i=r;else{let x=s.length-1;if(!n&&l.startsWith("..")){let y=l.split("/");for(;y[0]==="..";)y.shift(),x-=1;a.pathname=y.join("/")}i=x>=0?s[x]:"/"}let d=$vt(a,i),u=l&&l!=="/"&&l.endsWith("/"),p=(o||l===".")&&r.endsWith("/");return!d.pathname.endsWith("/")&&(u||p)&&(d.pathname+="/"),d}const Pb=t=>t.join("/").replace(/\/\/+/g,"/"),Vvt=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Hvt=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Gvt=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function Wvt(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const JUe=["post","put","patch","delete"];new Set(JUe);const Kvt=["get",...JUe];new Set(Kvt);/** * React Router v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Z8(){return Z8=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),S.useCallback(function(u,p){if(p===void 0&&(p={}),!i.current)return;if(typeof u=="number"){n.go(u);return}let x=vje(u,JSON.parse(l),o,p.relative==="path");t==null&&s!=="/"&&(x.pathname=x.pathname==="/"?s:Pb([s,x.pathname])),(p.replace?n.replace:n.push)(x,p.state,p)},[s,n,l,o,t])}const Qvt=S.createContext(null);function Jvt(t){let s=S.useContext(b0).outlet;return s&&S.createElement(Qvt.Provider,{value:t},s)}function co(){let{matches:t}=S.useContext(b0),s=t[t.length-1];return s?s.params:{}}function sVe(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=S.useContext(cw),{matches:a}=S.useContext(b0),{pathname:o}=Ol(),l=JSON.stringify(yje(a,n.v7_relativeSplatPath));return S.useMemo(()=>vje(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function e1t(t,s){return t1t(t,s)}function t1t(t,s,r,n){OA()||_d(!1);let{navigator:a}=S.useContext(cw),{matches:o}=S.useContext(b0),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let d=l?l.pathnameBase:"/";l&&l.route;let u=Ol(),p;if(s){var x;let w=typeof s=="string"?RA(s):s;d==="/"||(x=w.pathname)!=null&&x.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=Cvt(t,{pathname:_}),N=i1t(b&&b.map(w=>Object.assign({},w,{params:Object.assign({},i,w.params),pathname:Pb([d,a.encodeLocation?a.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?d:Pb([d,a.encodeLocation?a.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),o,r,n);return s&&N?S.createElement(tue.Provider,{value:{location:Z8({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:ib.Pop}},N):N}function s1t(){let t=d1t(),s=Wvt(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},s),r?S.createElement("pre",{style:a},r):null,null)}const r1t=S.createElement(s1t,null);class n1t extends S.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,r){return r.location!==s.location||r.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:r.error,location:r.location,revalidation:s.revalidation||r.revalidation}}componentDidCatch(s,r){console.error("React Router caught the following error during render",s,r)}render(){return this.state.error!==void 0?S.createElement(b0.Provider,{value:this.props.routeContext},S.createElement(eVe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function a1t(t){let{routeContext:s,match:r,children:n}=t,a=S.useContext(_je);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),S.createElement(b0.Provider,{value:s},n)}function i1t(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(x=>x.route.id&&(i==null?void 0:i[x.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,x,y)=>{let _,b=!1,N=null,w=null;r&&(_=i&&x.route.id?i[x.route.id]:void 0,N=x.route.errorElement||r1t,d&&(u<0&&y===0?(b=!0,w=null):u===y&&(b=!0,w=x.route.hydrateFallbackElement||null)));let k=s.concat(l.slice(0,y+1)),C=()=>{let E;return _?E=N:b?E=w:x.route.Component?E=S.createElement(x.route.Component,null):x.route.element?E=x.route.element:E=p,S.createElement(a1t,{match:x,routeContext:{outlet:p,matches:k,isDataRoute:r!=null},children:E})};return r&&(x.route.ErrorBoundary||x.route.errorElement||y===0)?S.createElement(n1t,{location:r.location,revalidation:r.revalidation,component:N,error:_,children:C(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):C()},null)}var rVe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(rVe||{}),Boe=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}(Boe||{});function o1t(t){let s=S.useContext(_je);return s||_d(!1),s}function l1t(t){let s=S.useContext(Zvt);return s||_d(!1),s}function c1t(t){let s=S.useContext(b0);return s||_d(!1),s}function nVe(t){let s=c1t(),r=s.matches[s.matches.length-1];return r.route.id||_d(!1),r.route.id}function d1t(){var t;let s=S.useContext(eVe),r=l1t(Boe.UseRouteError),n=nVe(Boe.UseRouteError);return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function u1t(){let{router:t}=o1t(rVe.UseNavigateStable),s=nVe(Boe.UseNavigateStable),r=S.useRef(!1);return tVe(()=>{r.current=!0}),S.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,Z8({fromRouteId:s},o)))},[t,s])}function h1t(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Yxe(t){let{to:s,replace:r,state:n,relative:a}=t;OA()||_d(!1);let{future:o,static:l}=S.useContext(cw),{matches:i}=S.useContext(b0),{pathname:d}=Ol(),u=_r(),p=vje(s,yje(i,o.v7_relativeSplatPath),d,a==="path"),x=JSON.stringify(p);return S.useEffect(()=>u(JSON.parse(x),{replace:r,state:n,relative:a}),[u,x,a,r,n]),null}function m1t(t){return Jvt(t.context)}function ys(t){_d(!1)}function p1t(t){let{basename:s="/",children:r=null,location:n,navigationType:a=ib.Pop,navigator:o,static:l=!1,future:i}=t;OA()&&_d(!1);let d=s.replace(/^\/*/,"/"),u=S.useMemo(()=>({basename:d,navigator:o,static:l,future:Z8({v7_relativeSplatPath:!1},i)}),[d,i,o,l]);typeof n=="string"&&(n=RA(n));let{pathname:p="/",search:x="",hash:y="",state:_=null,key:b="default"}=n,N=S.useMemo(()=>{let w=gje(p,d);return w==null?null:{location:{pathname:w,search:x,hash:y,state:_,key:b},navigationType:a}},[d,p,x,y,_,b,a]);return N==null?null:S.createElement(cw.Provider,{value:u},S.createElement(tue.Provider,{children:r,value:N}))}function $oe(t){let{children:s,location:r}=t;return e1t(Gve(s),r)}new Promise(()=>{});function Gve(t,s){s===void 0&&(s=[]);let r=[];return S.Children.forEach(t,(n,a)=>{if(!S.isValidElement(n))return;let o=[...s,a];if(n.type===S.Fragment){r.push.apply(r,Gve(n.props.children,o));return}n.type!==ys&&_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=Gve(n.props.children,o)),r.push(l)}),r}/** * React Router DOM v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Wve(){return Wve=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function x1t(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function g1t(t,s){return t.button===0&&(!s||s==="_self")&&!x1t(t)}function Kve(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 y1t(t,s){let r=Kve(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const v1t=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],_1t="6";try{window.__reactRouterVersion=_1t}catch{}const b1t="startTransition",XEe=a2e[b1t];function w1t(t){let{basename:s,children:r,future:n,window:a}=t,o=S.useRef();o.current==null&&(o.current=Nvt({window:a,v5Compat:!0}));let l=o.current,[i,d]=S.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},p=S.useCallback(x=>{u&&XEe?XEe(()=>d(x)):d(x)},[d,u]);return S.useLayoutEffect(()=>l.listen(p),[l,p]),S.useEffect(()=>h1t(n),[n]),S.createElement(p1t,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const j1t=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",N1t=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ha=S.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:d,to:u,preventScrollReset:p,viewTransition:x}=s,y=f1t(s,v1t),{basename:_}=S.useContext(cw),b,N=!1;if(typeof u=="string"&&N1t.test(u)&&(b=u,j1t))try{let E=new URL(window.location.href),L=u.startsWith("//")?new URL(E.protocol+u):new URL(u),I=gje(L.pathname,_);L.origin===E.origin&&I!=null?u=I+L.search+L.hash:N=!0}catch{}let w=Yvt(u,{relative:a}),k=k1t(u,{replace:l,state:i,target:d,preventScrollReset:p,relative:a,viewTransition:x});function C(E){n&&n(E),E.defaultPrevented||k(E)}return S.createElement("a",Wve({},y,{href:b||w,onClick:N||o?n:C,ref:r,target:d}))});var QEe;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(QEe||(QEe={}));var JEe;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(JEe||(JEe={}));function k1t(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,d=_r(),u=Ol(),p=sVe(t,{relative:l});return S.useCallback(x=>{if(g1t(x,r)){x.preventDefault();let y=n!==void 0?n:zoe(u)===zoe(p);d(t,{replace:y,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[u,d,p,n,a,r,t,o,l,i])}function Nc(t){let s=S.useRef(Kve(t)),r=S.useRef(!1),n=Ol(),a=S.useMemo(()=>y1t(n.search,r.current?null:s.current),[n.search]),o=_r(),l=S.useCallback((i,d)=>{const u=Kve(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,d)},[o,a]);return[a,l]}var S1t=typeof Element<"u",C1t=typeof Map=="function",M1t=typeof Set=="function",T1t=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function Pie(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(!Pie(t[n],s[n]))return!1;return!0}var o;if(C1t&&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(!Pie(n.value[1],s.get(n.value[0])))return!1;return!0}if(M1t&&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(T1t&&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(S1t&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!Pie(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var A1t=function(s,r){try{return Pie(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 E1t=so(A1t);var P1t=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}},I1t=P1t;const ePe=so(I1t);var L1t=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))(aVe||{}),Xxe={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"]}},tPe=Object.values(aVe),bje={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},R1t=Object.entries(bje).reduce((t,[s,r])=>(t[r]=s,t),{}),Sg="data-rh",zM={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},BM=(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},O1t=t=>{let s=BM(t,"title");const r=BM(t,zM.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=BM(t,zM.DEFAULT_TITLE);return s||n||void 0},F1t=t=>BM(t,zM.ON_CHANGE_CLIENT_STATE)||(()=>{}),Qxe=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),z1t=(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),H6=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&B1t(`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:z1t(["href"],t),bodyAttributes:Qxe("bodyAttributes",t),defer:BM(t,zM.DEFER),encode:BM(t,zM.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:Qxe("htmlAttributes",t),linkTags:H6("link",["rel","href"],t),metaTags:H6("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:H6("noscript",["innerHTML"],t),onChangeClientState:F1t(t),scriptTags:H6("script",["src","innerHTML"],t),styleTags:H6("style",["cssText"],t),title:O1t(t),titleAttributes:Qxe("titleAttributes",t),prioritizeSeoTags:$1t(t,zM.PRIORITIZE_SEO_TAGS)}),iVe=t=>Array.isArray(t)?t.join(""):t,U1t=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(U1t(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},sPe=(t,s)=>({...t,[s]:void 0}),V1t=["noscript","script","style"],Zve=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),oVe=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),H1t=(t,s,r,n)=>{const a=oVe(r),o=iVe(s);return a?`<${t} ${Sg}="true" ${a}>${Zve(o,n)}`:`<${t} ${Sg}="true">${Zve(o,n)}`},G1t=(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 x=typeof o[p]>"u"?p:`${p}="${Zve(o[p],r)}"`;return u?`${u} ${x}`:x},""),i=o.innerHTML||o.cssText||"",d=V1t.indexOf(t)===-1;return`${n}<${t} ${Sg}="true" ${l}${d?"/>":`>${i}`}`},""),lVe=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=bje[n];return r[a||n]=t[n],r},s),W1t=(t,s,r)=>{const n={key:s,[Sg]:!0},a=lVe(r,n);return[ft.createElement("title",a,s)]},Iie=(t,s)=>s.map((r,n)=>{const a={key:n,[Sg]:!0};return Object.keys(r).forEach(o=>{const i=bje[o]||o;if(i==="innerHTML"||i==="cssText"){const d=r.innerHTML||r.cssText;a.dangerouslySetInnerHTML={__html:d}}else a[i]=r[o]}),ft.createElement(t,a)}),Xf=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>W1t(t,s.title,s.titleAttributes),toString:()=>H1t(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>lVe(s),toString:()=>oVe(s)};default:return{toComponent:()=>Iie(t,s),toString:()=>G1t(t,s,r)}}},K1t=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=Jxe(t,Xxe.meta),o=Jxe(s,Xxe.link),l=Jxe(r,Xxe.script);return{priorityMethods:{toComponent:()=>[...Iie("meta",a.priority),...Iie("link",o.priority),...Iie("script",l.priority)],toString:()=>`${Xf("meta",a.priority,n)} ${Xf("link",o.priority,n)} ${Xf("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},Z1t=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:x,scriptTags:y}=t,_={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:_,linkTags:p,metaTags:x,scriptTags:y}=K1t(t)),{priority:_,base:Xf("base",s,n),bodyAttributes:Xf("bodyAttributes",r,n),htmlAttributes:Xf("htmlAttributes",a,n),link:Xf("link",p,n),meta:Xf("meta",x,n),noscript:Xf("noscript",o,n),script:Xf("script",y,n),style:Xf("style",l,n),title:Xf("title",{title:i,titleAttributes:d},n)}},Yve=Z1t,pz=[],cVe=!!(typeof window<"u"&&window.document&&window.document.createElement),Xve=class{constructor(t,s){Sn(this,"instances",[]);Sn(this,"canUseDOM",cVe);Sn(this,"context");Sn(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?pz:this.instances,add:t=>{(this.canUseDOM?pz:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?pz:this.instances).indexOf(t);(this.canUseDOM?pz:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=Yve({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},Y1t={},dVe=ft.createContext(Y1t),O4,uVe=(O4=class extends S.Component{constructor(r){super(r);Sn(this,"helmetData");this.helmetData=new Xve(this.props.context||{},O4.canUseDOM)}render(){return ft.createElement(dVe.Provider,{value:this.helmetData.value},this.props.children)}},Sn(O4,"canUseDOM",cVe),O4),r5=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${Sg}]`),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,x=typeof i[p]>"u"?"":i[p];d.setAttribute(u,x)}d.setAttribute(Sg,"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}},Qve=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(Sg),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(Sg):r.getAttribute(Sg)!==l.join(",")&&r.setAttribute(Sg,l.join(","))},X1t=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=iVe(t)),Qve("title",s)},rPe=(t,s)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:d,scriptTags:u,styleTags:p,title:x,titleAttributes:y}=t;Qve("body",n),Qve("html",a),X1t(x,y);const _={baseTag:r5("base",r),linkTags:r5("link",o),metaTags:r5("meta",l),noscriptTags:r5("noscript",i),scriptTags:r5("script",u),styleTags:r5("style",p)},b={},N={};Object.keys(_).forEach(w=>{const{newTags:k,oldTags:C}=_[w];k.length&&(b[w]=k),C.length&&(N[w]=_[w].oldTags)}),s&&s(),d(t,b,N)},G6=null,Q1t=t=>{G6&&cancelAnimationFrame(G6),t.defer?G6=requestAnimationFrame(()=>{rPe(t,()=>{G6=null})}):(rPe(t),G6=null)},J1t=Q1t,nPe=class extends S.Component{constructor(){super(...arguments);Sn(this,"rendered",!1)}shouldComponentUpdate(s){return!D1t(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=q1t(s.get().map(o=>{const l={...o.props};return delete l.context,l}));uVe.canUseDOM?J1t(a):Yve&&(n=Yve(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}},S0e,wc=(S0e=class extends S.Component{shouldComponentUpdate(t){return!E1t(sPe(this.props,"helmetData"),sPe(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 ePe(tPe.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 ${tPe.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),ePe(!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 ft.Children.forEach(t,n=>{if(!n||!n.props)return;const{children:a,...o}=n.props,l=Object.keys(o).reduce((d,u)=>(d[R1t[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 Xve)){const a=n;n=new Xve(a.context,!0),delete r.helmetData}return n?ft.createElement(nPe,{...r,context:n.value}):ft.createElement(dVe.Consumer,null,a=>ft.createElement(nPe,{...r,context:a}))}},Sn(S0e,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),S0e);const e_t=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Ha(async()=>{const{default:n}=await Promise.resolve().then(()=>FA);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class wje extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class t_t extends wje{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class s_t extends wje{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class r_t extends wje{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var Jve;(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"})(Jve||(Jve={}));var n_t=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(x){l(x)}}function d(p){try{u(n.throw(p))}catch(x){l(x)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};class a_t{constructor(s,{headers:r={},customFetch:n,region:a=Jve.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=e_t(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s,r={}){var n;return n_t(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 t_t(b)}),x=p.headers.get("x-relay-error");if(x&&x==="true")throw new s_t(p);if(!p.ok)throw new r_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 rp={},jje={},sue={},kR={},rue={},nue={},i_t=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")},kT=i_t();const o_t=kT.fetch,hVe=kT.fetch.bind(kT),mVe=kT.Headers,l_t=kT.Request,c_t=kT.Response,FA=Object.freeze(Object.defineProperty({__proto__:null,Headers:mVe,Request:l_t,Response:c_t,default:hVe,fetch:o_t},Symbol.toStringTag,{value:"Module"})),d_t=Omt(FA);var aue={};Object.defineProperty(aue,"__esModule",{value:!0});let u_t=class extends Error{constructor(s){super(s.message),this.name="PostgrestError",this.details=s.details,this.hint=s.hint,this.code=s.code}};aue.default=u_t;var pVe=md&&md.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(nue,"__esModule",{value:!0});const h_t=pVe(d_t),m_t=pVe(aue);let p_t=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=h_t.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,x=null,y=o.status,_=o.statusText;if(o.ok){if(this.method!=="HEAD"){const k=await o.text();k===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?p=k:p=JSON.parse(k))}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&&(x=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,x=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 m_t.default(u)}return{error:u,data:p,count:x,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}};nue.default=p_t;var f_t=md&&md.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(rue,"__esModule",{value:!0});const x_t=f_t(nue);let g_t=class extends x_t.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}};rue.default=g_t;var y_t=md&&md.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(kR,"__esModule",{value:!0});const v_t=y_t(rue);let __t=class extends v_t.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}};kR.default=__t;var b_t=md&&md.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(sue,"__esModule",{value:!0});const W6=b_t(kR);let w_t=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 W6.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 W6.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 W6.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 W6.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 W6.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};sue.default=w_t;var iue={},oue={};Object.defineProperty(oue,"__esModule",{value:!0});oue.version=void 0;oue.version="0.0.0-automated";Object.defineProperty(iue,"__esModule",{value:!0});iue.DEFAULT_HEADERS=void 0;const j_t=oue;iue.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${j_t.version}`};var fVe=md&&md.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(jje,"__esModule",{value:!0});const N_t=fVe(sue),k_t=fVe(kR),S_t=iue;let C_t=class xVe{constructor(s,{headers:r={},schema:n,fetch:a}={}){this.url=s,this.headers=Object.assign(Object.assign({},S_t.DEFAULT_HEADERS),r),this.schemaName=n,this.fetch=a}from(s){const r=new URL(`${this.url}/${s}`);return new N_t.default(r,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(s){return new xVe(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,x])=>x!==void 0).map(([p,x])=>[p,Array.isArray(x)?`{${x.join(",")}}`:`${x}`]).forEach(([p,x])=>{i.searchParams.append(p,x)})):(l="POST",d=r);const u=Object.assign({},this.headers);return o&&(u.Prefer=`count=${o}`),new k_t.default({method:l,url:i,headers:u,schema:this.schemaName,body:d,fetch:this.fetch,allowEmpty:!1})}};jje.default=C_t;var zA=md&&md.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(rp,"__esModule",{value:!0});rp.PostgrestError=rp.PostgrestBuilder=rp.PostgrestTransformBuilder=rp.PostgrestFilterBuilder=rp.PostgrestQueryBuilder=rp.PostgrestClient=void 0;const gVe=zA(jje);rp.PostgrestClient=gVe.default;const yVe=zA(sue);rp.PostgrestQueryBuilder=yVe.default;const vVe=zA(kR);rp.PostgrestFilterBuilder=vVe.default;const _Ve=zA(rue);rp.PostgrestTransformBuilder=_Ve.default;const bVe=zA(nue);rp.PostgrestBuilder=bVe.default;const wVe=zA(aue);rp.PostgrestError=wVe.default;var M_t=rp.default={PostgrestClient:gVe.default,PostgrestQueryBuilder:yVe.default,PostgrestFilterBuilder:vVe.default,PostgrestTransformBuilder:_Ve.default,PostgrestBuilder:bVe.default,PostgrestError:wVe.default};const{PostgrestClient:T_t,PostgrestQueryBuilder:hTs,PostgrestFilterBuilder:mTs,PostgrestTransformBuilder:pTs,PostgrestBuilder:fTs,PostgrestError:xTs}=M_t;let e1e;typeof window>"u"?e1e=require("ws"):e1e=window.WebSocket;const A_t=e1e,E_t="2.11.10",P_t={"X-Client-Info":`realtime-js/${E_t}`},I_t="1.0.0",jVe=1e4,L_t=1e3;var $M;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})($M||($M={}));var dm;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(dm||(dm={}));var xg;(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"})(xg||(xg={}));var t1e;(function(t){t.websocket="websocket"})(t1e||(t1e={}));var a4;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(a4||(a4={}));class D_t{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 NVe{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 wl;(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"})(wl||(wl={}));const aPe=(t,s,r={})=>{var n;const a=(n=r.skipTypes)!==null&&n!==void 0?n:[];return Object.keys(s).reduce((o,l)=>(o[l]=R_t(l,t,s,a),o),{})},R_t=(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)?kVe(o,l):s1e(l)},kVe=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return B_t(s,r)}switch(t){case wl.bool:return O_t(s);case wl.float4:case wl.float8:case wl.int2:case wl.int4:case wl.int8:case wl.numeric:case wl.oid:return F_t(s);case wl.json:case wl.jsonb:return z_t(s);case wl.timestamp:return $_t(s);case wl.abstime:case wl.date:case wl.daterange:case wl.int4range:case wl.int8range:case wl.money:case wl.reltime:case wl.text:case wl.time:case wl.timestamptz:case wl.timetz:case wl.tsrange:case wl.tstzrange:return s1e(s);default:return s1e(s)}},s1e=t=>t,O_t=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},F_t=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},z_t=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},B_t=(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=>kVe(s,i))}return t},$_t=t=>typeof t=="string"?t.replace(" ","T"):t,SVe=t=>{let s=t;return s=s.replace(/^ws/i,"http"),s=s.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),s.replace(/\/+$/,"")};class ege{constructor(s,r,n={},a=jVe){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 iPe;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(iPe||(iPe={}));class UL{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=UL.syncState(this.state,a,o,l),this.pendingDiffs.forEach(d=>{this.state=UL.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=UL.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 x=o[u];if(x){const y=p.map(w=>w.presence_ref),_=x.map(w=>w.presence_ref),b=p.filter(w=>_.indexOf(w.presence_ref)<0),N=x.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 x=s[i].map(_=>_.presence_ref),y=p.filter(_=>x.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(x=>x.presence_ref);u=u.filter(x=>p.indexOf(x.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 oPe;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(oPe||(oPe={}));var lPe;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(lPe||(lPe={}));var wv;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(wv||(wv={}));class Nje{constructor(s,r={config:{}},n){this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=dm.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 ege(this,xg.join,this.params,this.timeout),this.rejoinTimer=new NVe(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=dm.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=dm.closed,this.socket._remove(this)}),this._onError(a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=dm.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=dm.errored,this.rejoinTimer.scheduleTimeout())}),this._on(xg.reply,{},(a,o)=>{this._trigger(this._replyEventName(o),a)}),this.presence=new UL(this),this.broadcastEndpointURL=SVe(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 x;if(this.socket.setAuth(),p===void 0){s==null||s(wv.SUBSCRIBED);return}else{const y=this.bindings.postgres_changes,_=(x=y==null?void 0:y.length)!==null&&x!==void 0?x:0,b=[];for(let N=0;N<_;N++){const w=y[N],{filter:{event:k,schema:C,table:E,filter:L}}=w,I=p&&p[N];if(I&&I.event===k&&I.schema===C&&I.table===E&&I.filter===L)b.push(Object.assign(Object.assign({},w),{id:I.id}));else{this.unsubscribe(),this.state=dm.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=dm.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=dm.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(xg.close,"leave",this._joinRef())};return this.joinPush.destroy(),new Promise(n=>{const a=new ege(this,xg.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 ege(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}=xg;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,k,C,E;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in _){const L=_.id,I=(b=_.filter)===null||b===void 0?void 0:b.event;return L&&((N=r.ids)===null||N===void 0?void 0:N.includes(L))&&(I==="*"||(I==null?void 0:I.toLocaleLowerCase())===((w=r.data)===null||w===void 0?void 0:w.type.toLocaleLowerCase()))}else{const L=(C=(k=_==null?void 0:_.filter)===null||k===void 0?void 0:k.event)===null||C===void 0?void 0:C.toLocaleLowerCase();return L==="*"||L===((E=r==null?void 0:r.event)===null||E===void 0?void 0:E.toLocaleLowerCase())}else return _.type.toLocaleLowerCase()===l}).map(_=>{if(typeof y=="object"&&"ids"in y){const b=y.data,{schema:N,table:w,commit_timestamp:k,type:C,errors:E}=b;y=Object.assign(Object.assign({},{schema:N,table:w,commit_timestamp:k,eventType:C,new:{},old:{},errors:E}),this._getPayloadRecords(b))}_.callback(y,n)})}_isClosed(){return this.state===dm.closed}_isJoined(){return this.state===dm.joined}_isJoining(){return this.state===dm.joining}_isLeaving(){return this.state===dm.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&&Nje.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(xg.close,{},s)}_onError(s){this._on(xg.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=dm.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=aPe(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=aPe(s.columns,s.old_record)),r}}const cPe=()=>{},q_t=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class U_t{constructor(s,r){var n;this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers=P_t,this.params={},this.timeout=jVe,this.heartbeatIntervalMs=25e3,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=cPe,this.ref=0,this.logger=cPe,this.conn=null,this.sendBuffer=[],this.serializer=new D_t,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._resolveFetch=o=>{let l;return o?l=o:typeof fetch>"u"?l=(...i)=>Ha(async()=>{const{default:d}=await Promise.resolve().then(()=>FA);return{default:d}},void 0).then(({default:d})=>d(...i)):l=fetch,(...i)=>l(...i)},this.endPoint=`${s}/${t1e.websocket}`,this.httpEndpoint=SVe(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 NVe(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=A_t),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 V_t(this.endpointURL(),void 0,{close:()=>{this.conn=null}})}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:I_t}))}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 $M.connecting:return a4.Connecting;case $M.open:return a4.Open;case $M.closing:return a4.Closing;default:return a4.Closed}}isConnected(){return this.connectionState()===a4.Open}channel(s,r={config:{}}){const n=`realtime:${s}`,a=this.getChannels().find(o=>o.topic===n);if(a)return a;{const o=new Nje(`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(xg.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(L_t,"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(xg.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([q_t],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}}class V_t{constructor(s,r,n){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=$M.connecting,this.send=()=>{},this.url=null,this.url=s,this.close=n.close}}class kje extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function Au(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class H_t extends kje{constructor(s,r){super(s),this.name="StorageApiError",this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class r1e extends kje{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}var G_t=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(x){l(x)}}function d(p){try{u(n.throw(p))}catch(x){l(x)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};const CVe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Ha(async()=>{const{default:n}=await Promise.resolve().then(()=>FA);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},W_t=()=>G_t(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Ha(()=>Promise.resolve().then(()=>FA),void 0)).Response:Response}),n1e=t=>{if(Array.isArray(t))return t.map(r=>n1e(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]=n1e(n)}),s};var yC=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(x){l(x)}}function d(p){try{u(n.throw(p))}catch(x){l(x)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};const tge=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),K_t=(t,s,r)=>yC(void 0,void 0,void 0,function*(){const n=yield W_t();t instanceof n&&!(r!=null&&r.noResolveJson)?t.json().then(a=>{s(new H_t(tge(a),t.status||500))}).catch(a=>{s(new r1e(tge(a),a))}):s(new r1e(tge(t),t))}),Z_t=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"?a:(a.headers=Object.assign({"Content-Type":"application/json"},s==null?void 0:s.headers),n&&(a.body=JSON.stringify(n)),Object.assign(Object.assign({},a),r))};function SR(t,s,r,n,a,o){return yC(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,Z_t(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=>K_t(d,i,n))})})}function qoe(t,s,r,n){return yC(this,void 0,void 0,function*(){return SR(t,"GET",s,r,n)})}function A_(t,s,r,n,a){return yC(this,void 0,void 0,function*(){return SR(t,"POST",s,n,a,r)})}function Y_t(t,s,r,n,a){return yC(this,void 0,void 0,function*(){return SR(t,"PUT",s,n,a,r)})}function X_t(t,s,r,n){return yC(this,void 0,void 0,function*(){return SR(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function MVe(t,s,r,n,a){return yC(this,void 0,void 0,function*(){return SR(t,"DELETE",s,n,a,r)})}var Km=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(x){l(x)}}function d(p){try{u(n.throw(p))}catch(x){l(x)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};const Q_t={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},dPe={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class J_t{constructor(s,r={},n,a){this.url=s,this.headers=r,this.bucketId=n,this.fetch=CVe(a)}uploadOrUpdate(s,r,n,a){return Km(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},dPe),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),x=yield this.fetch(`${this.url}/object/${p}`,Object.assign({method:s,body:o,headers:i},l!=null&&l.duplex?{duplex:l.duplex}:{})),y=yield x.json();return x.ok?{data:{path:u,id:y.Id,fullPath:y.Key},error:null}:{data:null,error:y}}catch(o){if(Au(o))return{data:null,error:o};throw o}})}upload(s,r,n){return Km(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return Km(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:dPe.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 x=yield this.fetch(i.toString(),{method:"PUT",body:d,headers:p}),y=yield x.json();return x.ok?{data:{path:o,fullPath:y.Key},error:null}:{data:null,error:y}}catch(d){if(Au(d))return{data:null,error:d};throw d}})}createSignedUploadUrl(s,r){return Km(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 A_(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 kje("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(Au(n))return{data:null,error:n};throw n}})}update(s,r,n){return Km(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return Km(this,void 0,void 0,function*(){try{return{data:yield A_(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(Au(a))return{data:null,error:a};throw a}})}copy(s,r,n){return Km(this,void 0,void 0,function*(){try{return{data:{path:(yield A_(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(Au(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return Km(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield A_(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(Au(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return Km(this,void 0,void 0,function*(){try{const a=yield A_(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(Au(a))return{data:null,error:a};throw a}})}download(s,r){return Km(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 qoe(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(i){if(Au(i))return{data:null,error:i};throw i}})}info(s){return Km(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield qoe(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:n1e(n),error:null}}catch(n){if(Au(n))return{data:null,error:n};throw n}})}exists(s){return Km(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield X_t(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(Au(n)&&n instanceof r1e){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 Km(this,void 0,void 0,function*(){try{return{data:yield MVe(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(Au(r))return{data:null,error:r};throw r}})}list(s,r,n){return Km(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},Q_t),r),{prefix:s||""});return{data:yield A_(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(Au(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 ebt="2.7.1",tbt={"X-Client-Info":`storage-js/${ebt}`};var n5=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(x){l(x)}}function d(p){try{u(n.throw(p))}catch(x){l(x)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};class sbt{constructor(s,r={},n){this.url=s,this.headers=Object.assign(Object.assign({},tbt),r),this.fetch=CVe(n)}listBuckets(){return n5(this,void 0,void 0,function*(){try{return{data:yield qoe(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(s){if(Au(s))return{data:null,error:s};throw s}})}getBucket(s){return n5(this,void 0,void 0,function*(){try{return{data:yield qoe(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(Au(r))return{data:null,error:r};throw r}})}createBucket(s,r={public:!1}){return n5(this,void 0,void 0,function*(){try{return{data:yield A_(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(Au(n))return{data:null,error:n};throw n}})}updateBucket(s,r){return n5(this,void 0,void 0,function*(){try{return{data:yield Y_t(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(Au(n))return{data:null,error:n};throw n}})}emptyBucket(s){return n5(this,void 0,void 0,function*(){try{return{data:yield A_(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(Au(r))return{data:null,error:r};throw r}})}deleteBucket(s){return n5(this,void 0,void 0,function*(){try{return{data:yield MVe(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(Au(r))return{data:null,error:r};throw r}})}}class rbt extends sbt{constructor(s,r={},n){super(s,r,n)}from(s){return new J_t(this.url,this.headers,s,this.fetch)}}const nbt="2.49.10";let CI="";typeof Deno<"u"?CI="deno":typeof document<"u"?CI="web":typeof navigator<"u"&&navigator.product==="ReactNative"?CI="react-native":CI="node";const abt={"X-Client-Info":`supabase-js-${CI}/${nbt}`},ibt={headers:abt},obt={schema:"public"},lbt={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},cbt={};var dbt=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(x){l(x)}}function d(p){try{u(n.throw(p))}catch(x){l(x)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};const ubt=t=>{let s;return t?s=t:typeof fetch>"u"?s=hVe:s=fetch,(...r)=>s(...r)},hbt=()=>typeof Headers>"u"?mVe:Headers,mbt=(t,s,r)=>{const n=ubt(r),a=hbt();return(o,l)=>dbt(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 pbt=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(x){l(x)}}function d(p){try{u(n.throw(p))}catch(x){l(x)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};function fbt(t){return t.endsWith("/")?t:t+"/"}function xbt(t,s){var r,n;const{db:a,auth:o,realtime:l,global:i}=t,{db:d,auth:u,realtime:p,global:x}=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({},x),i),{headers:Object.assign(Object.assign({},(r=x==null?void 0:x.headers)!==null&&r!==void 0?r:{}),(n=i==null?void 0:i.headers)!==null&&n!==void 0?n:{})}),accessToken:()=>pbt(this,void 0,void 0,function*(){return""})};return t.accessToken?y.accessToken=t.accessToken:delete y.accessToken,y}const TVe="2.69.1",C5=30*1e3,a1e=3,sge=a1e*C5,gbt="http://localhost:9999",ybt="supabase.auth.token",vbt={"X-Client-Info":`gotrue-js/${TVe}`},i1e="X-Supabase-Api-Version",AVe={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},_bt=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,bbt=6e5;class Sje extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Mi(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class wbt extends Sje{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function jbt(t){return Mi(t)&&t.name==="AuthApiError"}class EVe extends Sje{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class dw extends Sje{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class b_ extends dw{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Nbt(t){return Mi(t)&&t.name==="AuthSessionMissingError"}class rge extends dw{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class fz extends dw{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class xz extends dw{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 kbt(t){return Mi(t)&&t.name==="AuthImplicitGrantRedirectError"}class uPe extends dw{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 o1e extends dw{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function nge(t){return Mi(t)&&t.name==="AuthRetryableFetchError"}class hPe extends dw{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class VL extends dw{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const mPe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),pPe=` \r=`.split(""),Sbt=(()=>{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=>{Tbt(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 Mbt(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}Cbt(n,s)}}function Tbt(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 Abt(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function Pbt(t){return Math.round(Date.now()/1e3)+t}function Ibt(){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 ky=()=>typeof window<"u"&&typeof document<"u",I2={tested:!1,writable:!1},HL=()=>{if(!ky())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(I2.tested)return I2.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),I2.tested=!0,I2.writable=!0}catch{I2.tested=!0,I2.writable=!1}return I2.writable};function Lbt(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 IVe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Ha(async()=>{const{default:n}=await Promise.resolve().then(()=>FA);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Dbt=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",LVe=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},gz=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},yz=async(t,s)=>{await t.removeItem(s)};class lue{constructor(){this.promise=new lue.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}lue.promiseConstructor=Promise;function age(t){const s=t.split(".");if(s.length!==3)throw new VL("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function Obt(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 Fbt(t){return("0"+t.toString(16)).substr(-2)}function zbt(){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,Fbt).join("")}async function Bbt(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 $bt(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 Bbt(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function a5(t,s,r=!1){const n=zbt();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await LVe(t,`${s}-code-verifier`,a);const o=await $bt(n);return[o,n===o?"plain":"s256"]}const qbt=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function Ubt(t){const s=t.headers.get(i1e);if(!s||!s.match(qbt))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function Vbt(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 Hbt(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 Gbt=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),Wbt=[502,503,504];async function xPe(t){var s;if(!Dbt(t))throw new o1e(Jk(t),0);if(Wbt.includes(t.status))throw new o1e(Jk(t),t.status);let r;try{r=await t.json()}catch(o){throw new EVe(Jk(o),o)}let n;const a=Ubt(t);if(a&&a.getTime()>=AVe["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 hPe(Jk(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new b_}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 hPe(Jk(r),t.status,r.weak_password.reasons);throw new wbt(Jk(r),t.status||500,n)}const Kbt=(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 Wi(t,s,r,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[i1e]||(o[i1e]=AVe["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 Zbt(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 Zbt(t,s,r,n,a,o){const l=Kbt(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(d){throw console.error(d),new o1e(Jk(d),0)}if(i.ok||await xPe(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(d){await xPe(d)}}function w_(t){var s;let r=null;Jbt(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=Pbt(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function gPe(t){const s=w_(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 q_(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function Ybt(t){return{data:t,error:null}}function Xbt(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=Gbt(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 Qbt(t){return t}function Jbt(t){return t.access_token&&t.refresh_token&&t.expires_in}var ewt=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({},x),u),error:null}}catch(u){if(Mi(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){try{return await Wi(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:q_})}catch(r){if(Mi(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){try{return await Wi(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:q_})}catch(n){if(Mi(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){try{return await Wi(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:q_})}catch(n){if(Mi(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){try{const{data:r,error:n}=await Wi(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(Mi(r))return{data:null,error:r};throw r}}async _deleteFactor(s){try{return{data:await Wi(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(Mi(r))return{data:null,error:r};throw r}}}const swt={getItem:t=>HL()?globalThis.localStorage.getItem(t):null,setItem:(t,s)=>{HL()&&globalThis.localStorage.setItem(t,s)},removeItem:t=>{HL()&&globalThis.localStorage.removeItem(t)}};function yPe(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}function rwt(){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 i5={debug:!!(globalThis&&HL()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class DVe extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class nwt extends DVe{}async function awt(t,s,r){i5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),i5.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){i5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{i5.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw i5.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new nwt(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(i5.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()}}))}rwt();const iwt={url:gbt,storageKey:ybt,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:vbt,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function vPe(t,s,r){return await r()}class Y8{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=Y8.nextInstanceID,Y8.nextInstanceID+=1,this.instanceID>0&&ky()&&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({},iwt),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 twt({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=IVe(a.fetch),this.lock=a.lock||vPe,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:ky()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=awt:this.lock=vPe,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:HL()?this.storage=swt:(this.memoryStorage={},this.storage=yPe(this.memoryStorage)):(this.memoryStorage={},this.storage=yPe(this.memoryStorage)),ky()&&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} (${TVe}) ${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=Lbt(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),ky()&&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),kbt(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 Mi(r)?{error:r}:{error:new EVe("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const o=await Wi(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:w_}),{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(Mi(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:x,options:y}=s;let _=null,b=null;this.flowType==="pkce"&&([_,b]=await a5(this.storage,this.storageKey)),o=await Wi(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:y==null?void 0:y.emailRedirectTo,body:{email:p,password:x,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:w_})}else if("phone"in s){const{phone:p,password:x,options:y}=s;o=await Wi(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:p,password:x,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:w_})}else throw new fz("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(Mi(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 Wi(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:gPe})}else if("phone"in s){const{phone:o,password:l,options:i}=s;r=await Wi(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:gPe})}else throw new fz("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 rge}:(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(Mi(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 gz(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:o,error:l}=await Wi(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:w_});if(await yz(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new rge}:(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(Mi(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 Wi(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:w_}),{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 rge}:(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",d.session)),{data:d,error:u})}catch(r){if(Mi(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 a5(this.storage,this.storageKey));const{error:x}=await Wi(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:x}}if("phone"in s){const{phone:i,options:d}=s,{data:u,error:p}=await Wi(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 fz("You must provide either an email or phone number.")}catch(i){if(Mi(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 Wi(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:w_});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(Mi(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 a5(this.storage,this.storageKey)),await Wi(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:Ybt})}catch(o){if(Mi(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 b_;const{error:a}=await Wi(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(Mi(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 Wi(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 Wi(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 fz("You must provide either an email or phone number and a type")}catch(r){if(Mi(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 gz(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 Wi(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:q_}):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 b_}:await Wi(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:q_})})}catch(r){if(Mi(r))return Nbt(r)&&(await this._removeSession(),await yz(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 b_;const l=a.session;let i=null,d=null;this.flowType==="pkce"&&s.email!=null&&([i,d]=await a5(this.storage,this.storageKey));const{data:u,error:p}=await Wi(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:q_});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(Mi(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 b_;const r=Date.now()/1e3;let n=r,a=!0,o=null;const{payload:l}=age(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(Mi(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 b_;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(Mi(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!ky())throw new xz("No browser detected.");if(s.error||s.error_description||s.error_code)throw new xz(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 uPe("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new xz("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 uPe("No code detected.");const{data:C,error:E}=await this._exchangeCodeForSession(s.code);if(E)throw E;const L=new URL(window.location.href);return L.searchParams.delete("code"),window.history.replaceState(window.history.state,"",L.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 xz("No session defined in URL");const p=Math.round(Date.now()/1e3),x=parseInt(i);let y=p+x;d&&(y=parseInt(d));const _=y-p;_*1e3<=C5&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${_}s, should have been closer to ${x}s`);const b=y-x;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 k={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:x,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:k,redirectType:s.type},error:null}}catch(n){if(Mi(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 gz(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&&!(jbt(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await yz(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=Ibt(),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 a5(this.storage,this.storageKey,!0));try{return await Wi(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(Mi(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(Mi(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:x,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 Wi(this.fetch,"GET",_,{headers:this.headers,jwt:(p=(u=x.session)===null||u===void 0?void 0:u.access_token)!==null&&p!==void 0?p:void 0})});if(a)throw a;return ky()&&!(!((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(Mi(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 Wi(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(Mi(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 Obt(async a=>(a>0&&await Rbt(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await Wi(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:w_})),(a,o)=>{const l=200*Math.pow(2,a);return o&&nge(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(),C5);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)/C5);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${C5}ms, refresh threshold is ${a1e} ticks`),a<=a1e&&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 DVe)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!ky()||!(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 a5(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 Wi(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(Mi(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 Wi(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(Mi(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 Wi(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(Mi(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 Wi(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(Mi(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}=age(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(x=>x.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+bbt>Date.now()))return n;const{data:a,error:o}=await Wi(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 VL("JWKS is empty");if(this.jwks=a,this.jwks_cached_at=Date.now(),n=a.keys.find(l=>l.kid===s),!n)throw new VL("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}}=age(n);if(Vbt(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=Hbt(a.alg),p=await this.fetchJwk(a.kid,r),x=await crypto.subtle.importKey("jwk",p,u,!0,["verify"]);if(!await crypto.subtle.verify(u,x,l,Ebt(`${i}.${d}`)))throw new VL("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(Mi(n))return{data:null,error:n};throw n}}}Y8.nextInstanceID=0;const owt=Y8;class lwt extends owt{constructor(s){super(s)}}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(x){l(x)}}function d(p){try{u(n.throw(p))}catch(x){l(x)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};class dwt{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=fbt(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:obt,realtime:cbt,auth:Object.assign(Object.assign({},lbt),{storageKey:u}),global:ibt},x=xbt(n??{},p);this.storageKey=(a=x.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(o=x.global.headers)!==null&&o!==void 0?o:{},x.accessToken?(this.accessToken=x.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=x.auth)!==null&&l!==void 0?l:{},this.headers,x.global.fetch),this.fetch=mbt(r,this._getAccessToken.bind(this),x.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},x.realtime)),this.rest=new T_t(new URL("rest/v1",d).href,{headers:this.headers,schema:x.db.schema,fetch:this.fetch}),x.accessToken||this._listenForAuthEvents()}get functions(){return new a_t(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}get storage(){return new rbt(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 cwt(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 x={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new lwt({url:this.authUrl.href,headers:Object.assign(Object.assign({},x),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 U_t(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 uwt=(t,s,r)=>new dwt(t,s,r),hwt="https://relzejiswnotikjgvjhz.supabase.co",mwt="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",G=uwt(hwt,mwt,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),RVe=S.createContext(void 0),pwt=({children:t})=>{const[s,r]=S.useState(null),[n,a]=S.useState(null),[o,l]=S.useState(!0),[i,d]=S.useState(!0),[u,p]=S.useState(!1),[x,y]=S.useState(!1),[_,b]=S.useState(null),[N,w]=S.useState([]),[k,C]=S.useState(null),E=S.useRef(null),L=S.useRef(!1),I=S.useRef(!1),O=_r(),V=()=>{p(!1),y(!1),b(null),w([]),C(null),E.current=null,L.current=!1},q=async Y=>{if(!(L.current&&E.current===Y)&&!I.current){I.current=!0,d(!0);try{console.log("Checking roles via RPC for user:",Y);const[{data:J,error:X},{data:ce,error:ie}]=await Promise.all([G.rpc("has_role",{_user_id:Y,_role:"admin"}),G.rpc("has_role",{_user_id:Y,_role:"brokerage_manager"})]);if(X||ie)console.error("Role RPC errors:",{isAdminError:X,isBrokerError:ie}),p(!1),y(!1);else{const pe=!!J,_e=!!ce;console.log("RPC roles result:",{adminValue:pe,brokerValue:_e}),p(pe),y(_e)}const{data:ae,error:oe}=await G.from("profiles").select("brokerage_id").eq("id",Y).single();if(b(!oe&&ae?ae.brokerage_id:null),ce){console.log("Fetching managed brokerages for user:",Y);const{data:pe,error:_e}=await G.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",Y);if(console.log("Managed brokerage assignments result:",{assignments:pe,assignmentsError:_e}),_e||!pe){console.error("Error fetching managed brokerage assignments:",_e),w([]);return}const he=Array.from(new Set(pe.map(Te=>Te.brokerage_id).filter(Boolean)));if(he.length===0){w([]);return}const{data:we,error:je}=await G.from("brokerages").select("id, name").in("id",he);if(console.log("Managed brokerages details result:",{brokeragesData:we,brokeragesError:je}),je||!we){console.error("Error fetching managed brokerages details:",je),w([]);return}const Ue=we.map(Te=>({id:Te.id,name:Te.name})).sort((Te,Me)=>he.indexOf(Te.id)-he.indexOf(Me.id));console.log("Parsed managed brokerages:",Ue),w(Ue),Ue.length>0&&C(Te=>Te??Ue[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),w([]);E.current=Y,L.current=!0}catch(J){console.error("Unexpected error in checkRoles:",J),V()}finally{I.current=!1,d(!1)}}};S.useEffect(()=>{let Y=!0,J=!1;const X=()=>{!Y||J||(J=!0,l(!1))},{data:{subscription:ce}}=G.auth.onAuthStateChange((oe,pe)=>{console.log("Auth event:",oe),Y&&(a(pe),r((pe==null?void 0:pe.user)??null),X(),oe==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{O("/profile?reset=true")},100)),pe!=null&&pe.user?(!L.current||E.current!==pe.user.id)&&setTimeout(()=>{q(pe.user.id)},0):(V(),d(!1)))}),ie=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),X()},4e3);return(async()=>{try{const{data:{session:oe}}=await G.auth.getSession();if(!Y)return;a(oe),r((oe==null?void 0:oe.user)??null),oe!=null&&oe.user?await q(oe.user.id):V()}catch(oe){console.error("Error restoring auth session:",oe),Y&&(a(null),r(null),V())}finally{X()}})(),()=>{Y=!1,window.clearTimeout(ie),ce.unsubscribe()}},[]);const $=async(Y,J)=>{const{error:X}=await G.auth.signInWithPassword({email:Y,password:J});if(X)throw me.error(X.message),X;me.success("Welcome back!");const ce=sessionStorage.getItem("redirectAfterLogin")||"/dashboard";sessionStorage.removeItem("redirectAfterLogin"),O(ce)},U=async(Y,J,X)=>{const ce=`${window.location.origin}/dashboard`,{error:ie}=await G.auth.signUp({email:Y,password:J,options:{emailRedirectTo:ce,data:{name:X}}});if(ie)throw me.error(ie.message),ie;me.success("Account created! Welcome to LevelUp."),O("/dashboard")},se=async()=>{try{const{data:{session:Y}}=await G.auth.getSession();if(Y){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(Y){console.error("Unexpected sign out error:",Y),O("/auth")}};return e.jsx(RVe.Provider,{value:{user:s,session:n,loading:o,rolesLoading:i,signIn:$,signUp:U,signOut:se,isAdmin:u,isBrokerageManager:x,brokerageId:_,managedBrokerages:N,selectedBrokerageId:k,setSelectedBrokerageId:C},children:t})},Fs=()=>{const t=S.useContext(RVe);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},OVe=S.createContext(void 0),L2="levelup_admin_session",p_="levelup_impersonation",ige="levelup_impersonation_return",fwt=({children:t})=>{const[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState(!1);S.useEffect(()=>{const u=sessionStorage.getItem(p_);if(u)try{const p=JSON.parse(u);r(!0),a(p)}catch{sessionStorage.removeItem(p_)}},[]);const i=async(u,p)=>{l(!0);try{const{data:{session:x}}=await G.auth.getSession();if(!x)return me.error("No active session found"),!1;const y={access_token:x.access_token,refresh_token:x.refresh_token};sessionStorage.setItem(L2,JSON.stringify(y)),p&&sessionStorage.setItem(ige,p);const _=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x.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(p_,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(L2),sessionStorage.removeItem(p_),new Error("Failed to establish impersonation session")}else{const w=b.type||"recovery",{error:k}=await G.auth.verifyOtp({token_hash:b.token_hash,type:w});if(k)throw console.error("Verify OTP error:",k),sessionStorage.removeItem(L2),sessionStorage.removeItem(p_),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(x){return console.error("Impersonation error:",x),me.error(x.message||"Failed to impersonate user"),sessionStorage.removeItem(L2),sessionStorage.removeItem(p_),!1}finally{l(!1)}},d=async()=>{l(!0);try{const u=sessionStorage.getItem(L2);if(!u){await G.auth.signOut(),window.location.href="/auth";return}const p=JSON.parse(u);await G.auth.signOut();const{error:x}=await G.auth.setSession({access_token:p.access_token,refresh_token:p.refresh_token});if(sessionStorage.removeItem(L2),sessionStorage.removeItem(p_),x){console.error("Failed to restore admin session:",x),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(ige)||"/admin/members";sessionStorage.removeItem(ige),window.location.href=y}catch(u){console.error("Stop impersonation error:",u),me.error("Failed to restore admin session"),sessionStorage.removeItem(L2),sessionStorage.removeItem(p_),window.location.href="/auth"}finally{l(!1)}};return e.jsx(OVe.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:d,isLoading:o},children:t})},cue=()=>{const t=S.useContext(OVe);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},X8=gC("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-full px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),K=S.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?X2e:"button";return e.jsx(l,{className:Rt(X8({variant:s,size:r,className:t})),ref:o,...a})});K.displayName="Button";const xwt=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=cue();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(_s,{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"})]})})]})})},FVe=S.createContext(void 0),o5="levelup_acting_as",vz="levelup_acting_as_self",gwt=({children:t})=>{const{user:s}=Fs(),[r,n]=S.useState(!1),[a,o]=S.useState([]),[l,i]=S.useState(null),[d,u]=S.useState({}),[p,x]=S.useState(!0),[y,_]=S.useState(()=>sessionStorage.getItem(vz)==="true");S.useEffect(()=>{if(!(s!=null&&s.id)){n(!1),o([]),i(null),u({}),x(!1);return}(async()=>{x(!0);try{const{data:E}=await G.rpc("has_role",{_user_id:s.id,_role:"assistant"});if(!E){n(!1),o([]),i(null),u({}),x(!1);return}n(!0);const{data:L,error:I}=await G.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",s.id);if(I||!L||L.length===0){o([]),x(!1);return}const O=L.map($=>$.agent_id),{data:V}=await G.from("profiles").select("id, name, email, avatar_url").in("id",O),q=(V||[]).map($=>({id:$.id,name:$.name||$.email||"Unknown",email:$.email||"",avatar_url:$.avatar_url}));if(o(q),sessionStorage.getItem(vz)==="true")_(!0),i(null),u({});else{const $=sessionStorage.getItem(o5);if($){const U=q.find(se=>se.id===$);if(U){i(U);const se=L.find(Y=>Y.agent_id===$);u((se==null?void 0:se.permissions)||{})}else if(q.length>0){i(q[0]);const se=L.find(Y=>Y.agent_id===q[0].id);u((se==null?void 0:se.permissions)||{}),sessionStorage.setItem(o5,q[0].id)}}else if(q.length>0){i(q[0]);const U=L.find(se=>se.agent_id===q[0].id);u((U==null?void 0:U.permissions)||{}),sessionStorage.setItem(o5,q[0].id)}}}catch(E){console.error("Error loading assistant data:",E)}finally{x(!1)}})()},[s==null?void 0:s.id]);const b=C=>{i(C),_(!1),sessionStorage.removeItem(vz),C?(sessionStorage.setItem(o5,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:E})=>{u((E==null?void 0:E.permissions)||{})})):(sessionStorage.removeItem(o5),u({}))},N=()=>{_(!0),i(null),u({}),sessionStorage.setItem(vz,"true"),sessionStorage.removeItem(o5)},w=C=>!r||y?!0:d[C]===!0,k=r&&l&&!y?l.id:(s==null?void 0:s.id)||null;return e.jsx(FVe.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:b,effectiveUserId:k,permissions:d,hasPermission:w,isLoading:p,isActingAsSelf:y,setActingAsSelf:N},children:t})},Cje=()=>{const t=S.useContext(FVe);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},ja=()=>{const{effectiveUserId:t}=Cje();return t};var zVe={exports:{}},BVe={};/** * @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 ST=S;function ywt(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var vwt=typeof Object.is=="function"?Object.is:ywt,_wt=ST.useState,bwt=ST.useEffect,wwt=ST.useLayoutEffect,jwt=ST.useDebugValue;function Nwt(t,s){var r=s(),n=_wt({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return wwt(function(){a.value=r,a.getSnapshot=s,oge(a)&&o({inst:a})},[t,r,s]),bwt(function(){return oge(a)&&o({inst:a}),t(function(){oge(a)&&o({inst:a})})},[t]),jwt(r),r}function oge(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!vwt(t,r)}catch{return!0}}function kwt(t,s){return s()}var Swt=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?kwt:Nwt;BVe.useSyncExternalStore=ST.useSyncExternalStore!==void 0?ST.useSyncExternalStore:Swt;zVe.exports=BVe;var Cwt=zVe.exports;function Mwt(){return Cwt.useSyncExternalStore(Twt,()=>!0,()=>!1)}function Twt(){return()=>{}}var Mje="Avatar",[Awt,gTs]=$c(Mje),[Ewt,$Ve]=Awt(Mje),qVe=S.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=S.useState("idle");return e.jsx(Ewt,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(Yr.span,{...n,ref:s})})});qVe.displayName=Mje;var UVe="AvatarImage",VVe=S.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=$Ve(UVe,r),i=Pwt(n,o),d=ed(u=>{a(u),l.onImageLoadingStatusChange(u)});return rd(()=>{i!=="idle"&&d(i)},[i,d]),i==="loaded"?e.jsx(Yr.img,{...o,ref:s,src:n}):null});VVe.displayName=UVe;var HVe="AvatarFallback",GVe=S.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=$Ve(HVe,r),[l,i]=S.useState(n===void 0);return S.useEffect(()=>{if(n!==void 0){const d=window.setTimeout(()=>i(!0),n);return()=>window.clearTimeout(d)}},[n]),l&&o.imageLoadingStatus!=="loaded"?e.jsx(Yr.span,{...a,ref:s}):null});GVe.displayName=HVe;function _Pe(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Pwt(t,{referrerPolicy:s,crossOrigin:r}){const n=Mwt(),a=S.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=S.useState(()=>_Pe(o,t));return rd(()=>{i(_Pe(o,t))},[o,t]),rd(()=>{const d=x=>()=>{i(x)};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 WVe=qVe,KVe=VVe,ZVe=GVe;const vn=S.forwardRef(({className:t,...s},r)=>e.jsx(WVe,{ref:r,className:Rt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));vn.displayName=WVe.displayName;const Ta=S.forwardRef(({className:t,...s},r)=>e.jsx(KVe,{ref:r,className:Rt("aspect-square h-full w-full",t),...s}));Ta.displayName=KVe.displayName;const _n=S.forwardRef(({className:t,...s},r)=>e.jsx(ZVe,{ref:r,className:Rt("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));_n.displayName=ZVe.displayName;const Iwt=gC("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 Qe({className:t,variant:s,...r}){return e.jsx("div",{className:Rt(Iwt({variant:s}),t),...r})}var Lwt=S.createContext(void 0);function uw(t){const s=S.useContext(Lwt);return t||s||"ltr"}var lge=0;function due(){S.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??bPe()),document.body.insertAdjacentElement("beforeend",t[1]??bPe()),lge++,()=>{lge===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),lge--}},[])}function bPe(){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 cge="focusScope.autoFocusOnMount",dge="focusScope.autoFocusOnUnmount",wPe={bubbles:!1,cancelable:!0},Dwt="FocusScope",CR=S.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,d]=S.useState(null),u=ed(a),p=ed(o),x=S.useRef(null),y=Aa(s,N=>d(N)),_=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(n){let N=function(E){if(_.paused||!i)return;const L=E.target;i.contains(L)?x.current=L:j_(x.current,{select:!0})},w=function(E){if(_.paused||!i)return;const L=E.relatedTarget;L!==null&&(i.contains(L)||j_(x.current,{select:!0}))},k=function(E){if(document.activeElement===document.body)for(const I of E)I.removedNodes.length>0&&j_(i)};document.addEventListener("focusin",N),document.addEventListener("focusout",w);const C=new MutationObserver(k);return i&&C.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",N),document.removeEventListener("focusout",w),C.disconnect()}}},[n,i,_.paused]),S.useEffect(()=>{if(i){NPe.add(_);const N=document.activeElement;if(!i.contains(N)){const k=new CustomEvent(cge,wPe);i.addEventListener(cge,u),i.dispatchEvent(k),k.defaultPrevented||(Rwt($wt(YVe(i)),{select:!0}),document.activeElement===N&&j_(i))}return()=>{i.removeEventListener(cge,u),setTimeout(()=>{const k=new CustomEvent(dge,wPe);i.addEventListener(dge,p),i.dispatchEvent(k),k.defaultPrevented||j_(N??document.body,{select:!0}),i.removeEventListener(dge,p),NPe.remove(_)},0)}}},[i,u,p,_]);const b=S.useCallback(N=>{if(!r&&!n||_.paused)return;const w=N.key==="Tab"&&!N.altKey&&!N.ctrlKey&&!N.metaKey,k=document.activeElement;if(w&&k){const C=N.currentTarget,[E,L]=Owt(C);E&&L?!N.shiftKey&&k===L?(N.preventDefault(),r&&j_(E,{select:!0})):N.shiftKey&&k===E&&(N.preventDefault(),r&&j_(L,{select:!0})):k===C&&N.preventDefault()}},[r,n,_.paused]);return e.jsx(Yr.div,{tabIndex:-1,...l,ref:y,onKeyDown:b})});CR.displayName=Dwt;function Rwt(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(j_(n,{select:s}),document.activeElement!==r)return}function Owt(t){const s=YVe(t),r=jPe(s,t),n=jPe(s.reverse(),t);return[r,n]}function YVe(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 jPe(t,s){for(const r of t)if(!Fwt(r,{upTo:s}))return r}function Fwt(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 zwt(t){return t instanceof HTMLInputElement&&"select"in t}function j_(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&zwt(t)&&s&&t.select()}}var NPe=Bwt();function Bwt(){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 $wt(t){return t.filter(s=>s.tagName!=="A")}var uge="rovingFocusGroup.onEntryFocus",qwt={bubbles:!1,cancelable:!0},MR="RovingFocusGroup",[l1e,XVe,Uwt]=yR(MR),[Vwt,hw]=$c(MR,[Uwt]),[Hwt,Gwt]=Vwt(MR),QVe=S.forwardRef((t,s)=>e.jsx(l1e.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(l1e.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Wwt,{...t,ref:s})})}));QVe.displayName=MR;var Wwt=S.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...x}=t,y=S.useRef(null),_=Aa(s,y),b=uw(o),[N,w]=$u({prop:l,defaultProp:i??null,onChange:d,caller:MR}),[k,C]=S.useState(!1),E=ed(u),L=XVe(r),I=S.useRef(!1),[O,V]=S.useState(0);return S.useEffect(()=>{const q=y.current;if(q)return q.addEventListener(uge,E),()=>q.removeEventListener(uge,E)},[E]),e.jsx(Hwt,{scope:r,orientation:n,dir:b,loop:a,currentTabStopId:N,onItemFocus:S.useCallback(q=>w(q),[w]),onItemShiftTab:S.useCallback(()=>C(!0),[]),onFocusableItemAdd:S.useCallback(()=>V(q=>q+1),[]),onFocusableItemRemove:S.useCallback(()=>V(q=>q-1),[]),children:e.jsx(Yr.div,{tabIndex:k||O===0?-1:0,"data-orientation":n,...x,ref:_,style:{outline:"none",...t.style},onMouseDown:Cr(t.onMouseDown,()=>{I.current=!0}),onFocus:Cr(t.onFocus,q=>{const $=!I.current;if(q.target===q.currentTarget&&$&&!k){const U=new CustomEvent(uge,qwt);if(q.currentTarget.dispatchEvent(U),!U.defaultPrevented){const se=L().filter(ie=>ie.focusable),Y=se.find(ie=>ie.active),J=se.find(ie=>ie.id===N),ce=[Y,J,...se].filter(Boolean).map(ie=>ie.ref.current);tHe(ce,p)}}I.current=!1}),onBlur:Cr(t.onBlur,()=>C(!1))})})}),JVe="RovingFocusGroupItem",eHe=S.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,d=pu(),u=o||d,p=Gwt(JVe,r),x=p.currentTabStopId===u,y=XVe(r),{onFocusableItemAdd:_,onFocusableItemRemove:b,currentTabStopId:N}=p;return S.useEffect(()=>{if(n)return _(),()=>b()},[n,_,b]),e.jsx(l1e.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:e.jsx(Yr.span,{tabIndex:x?0:-1,"data-orientation":p.orientation,...i,ref:s,onMouseDown:Cr(t.onMouseDown,w=>{n?p.onItemFocus(u):w.preventDefault()}),onFocus:Cr(t.onFocus,()=>p.onItemFocus(u)),onKeyDown:Cr(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const k=Ywt(w,p.orientation,p.dir);if(k!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let E=y().filter(L=>L.focusable).map(L=>L.ref.current);if(k==="last")E.reverse();else if(k==="prev"||k==="next"){k==="prev"&&E.reverse();const L=E.indexOf(w.currentTarget);E=p.loop?Xwt(E,L+1):E.slice(L+1)}setTimeout(()=>tHe(E))}}),children:typeof l=="function"?l({isCurrentTabStop:x,hasTabStop:N!=null}):l})})});eHe.displayName=JVe;var Kwt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Zwt(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Ywt(t,s,r){const n=Zwt(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return Kwt[n]}function tHe(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function Xwt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var uue=QVe,hue=eHe,Qwt=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},l5=new WeakMap,_z=new WeakMap,bz={},hge=0,sHe=function(t){return t&&(t.host||sHe(t.parentNode))},Jwt=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=sHe(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})},e2t=function(t,s,r,n){var a=Jwt(s,Array.isArray(t)?t:[t]);bz[r]||(bz[r]=new WeakMap);var o=bz[r],l=[],i=new Set,d=new Set(a),u=function(x){!x||i.has(x)||(i.add(x),u(x.parentNode))};a.forEach(u);var p=function(x){!x||d.has(x)||Array.prototype.forEach.call(x.children,function(y){if(i.has(y))p(y);else try{var _=y.getAttribute(n),b=_!==null&&_!=="false",N=(l5.get(y)||0)+1,w=(o.get(y)||0)+1;l5.set(y,N),o.set(y,w),l.push(y),N===1&&b&&_z.set(y,!0),w===1&&y.setAttribute(r,"true"),b||y.setAttribute(n,"true")}catch(k){console.error("aria-hidden: cannot operate on ",y,k)}})};return p(s),i.clear(),hge++,function(){l.forEach(function(x){var y=l5.get(x)-1,_=o.get(x)-1;l5.set(x,y),o.set(x,_),y||(_z.has(x)||x.removeAttribute(n),_z.delete(x)),_||x.removeAttribute(r)}),hge--,hge||(l5=new WeakMap,l5=new WeakMap,_z=new WeakMap,bz={})}},mue=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=Qwt(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),e2t(n,a,r,"aria-hidden")):function(){return null}},Fy=function(){return Fy=Object.assign||function(s){for(var r,n=1,a=arguments.length;n"u")return g2t;var s=y2t(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])}},_2t=iHe(),qM="data-scroll-locked",b2t=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(s2t,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(qM,`] { 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(Lie,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(Die,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(Lie," .").concat(Lie,` { right: 0 `).concat(n,`; } .`).concat(Die," .").concat(Die,` { margin-right: 0 `).concat(n,`; } body[`).concat(qM,`] { `).concat(r2t,": ").concat(i,`px; } `)},CPe=function(){var t=parseInt(document.body.getAttribute(qM)||"0",10);return isFinite(t)?t:0},w2t=function(){S.useEffect(function(){return document.body.setAttribute(qM,(CPe()+1).toString()),function(){var t=CPe()-1;t<=0?document.body.removeAttribute(qM):document.body.setAttribute(qM,t.toString())}},[])},j2t=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;w2t();var o=S.useMemo(function(){return v2t(a)},[a]);return S.createElement(_2t,{styles:b2t(o,!s,a,r?"":"!important")})},c1e=!1;if(typeof window<"u")try{var wz=Object.defineProperty({},"passive",{get:function(){return c1e=!0,!0}});window.addEventListener("test",wz,wz),window.removeEventListener("test",wz,wz)}catch{c1e=!1}var c5=c1e?{passive:!1}:!1,N2t=function(t){return t.tagName==="TEXTAREA"},oHe=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!N2t(t)&&r[s]==="visible")},k2t=function(t){return oHe(t,"overflowY")},S2t=function(t){return oHe(t,"overflowX")},MPe=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=lHe(t,n);if(a){var o=cHe(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},C2t=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},M2t=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},lHe=function(t,s){return t==="v"?k2t(s):S2t(s)},cHe=function(t,s){return t==="v"?C2t(s):M2t(s)},T2t=function(t,s){return t==="h"&&s==="rtl"?-1:1},A2t=function(t,s,r,n,a){var o=T2t(t,window.getComputedStyle(s).direction),l=o*n,i=r.target,d=s.contains(i),u=!1,p=l>0,x=0,y=0;do{if(!i)break;var _=cHe(t,i),b=_[0],N=_[1],w=_[2],k=N-w-o*b;(b||k)&&lHe(t,i)&&(x+=k,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(x)<1||!a)||!p&&(Math.abs(y)<1||!a))&&(u=!0),u},jz=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},TPe=function(t){return[t.deltaX,t.deltaY]},APe=function(t){return t&&"current"in t?t.current:t},E2t=function(t,s){return t[0]===s[0]&&t[1]===s[1]},P2t=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},I2t=0,d5=[];function L2t(t){var s=S.useRef([]),r=S.useRef([0,0]),n=S.useRef(),a=S.useState(I2t++)[0],o=S.useState(iHe)[0],l=S.useRef(t);S.useEffect(function(){l.current=t},[t]),S.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var N=t2t([t.lockRef.current],(t.shards||[]).map(APe),!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=S.useCallback(function(N,w){if("touches"in N&&N.touches.length===2||N.type==="wheel"&&N.ctrlKey)return!l.current.allowPinchZoom;var k=jz(N),C=r.current,E="deltaX"in N?N.deltaX:C[0]-k[0],L="deltaY"in N?N.deltaY:C[1]-k[1],I,O=N.target,V=Math.abs(E)>Math.abs(L)?"h":"v";if("touches"in N&&V==="h"&&O.type==="range")return!1;var q=MPe(V,O);if(!q)return!0;if(q?I=V:(I=V==="v"?"h":"v",q=MPe(V,O)),!q)return!1;if(!n.current&&"changedTouches"in N&&(E||L)&&(n.current=I),!I)return!0;var $=n.current||I;return A2t($,w,N,$==="h"?E:L,!0)},[]),d=S.useCallback(function(N){var w=N;if(!(!d5.length||d5[d5.length-1]!==o)){var k="deltaY"in w?TPe(w):jz(w),C=s.current.filter(function(I){return I.name===w.type&&(I.target===w.target||w.target===I.shadowParent)&&E2t(I.delta,k)})[0];if(C&&C.should){w.cancelable&&w.preventDefault();return}if(!C){var E=(l.current.shards||[]).map(APe).filter(Boolean).filter(function(I){return I.contains(w.target)}),L=E.length>0?i(w,E[0]):!l.current.noIsolation;L&&w.cancelable&&w.preventDefault()}}},[]),u=S.useCallback(function(N,w,k,C){var E={name:N,delta:w,target:k,should:C,shadowParent:D2t(k)};s.current.push(E),setTimeout(function(){s.current=s.current.filter(function(L){return L!==E})},1)},[]),p=S.useCallback(function(N){r.current=jz(N),n.current=void 0},[]),x=S.useCallback(function(N){u(N.type,TPe(N),N.target,i(N,t.lockRef.current))},[]),y=S.useCallback(function(N){u(N.type,jz(N),N.target,i(N,t.lockRef.current))},[]);S.useEffect(function(){return d5.push(o),t.setCallbacks({onScrollCapture:x,onWheelCapture:x,onTouchMoveCapture:y}),document.addEventListener("wheel",d,c5),document.addEventListener("touchmove",d,c5),document.addEventListener("touchstart",p,c5),function(){d5=d5.filter(function(N){return N!==o}),document.removeEventListener("wheel",d,c5),document.removeEventListener("touchmove",d,c5),document.removeEventListener("touchstart",p,c5)}},[]);var _=t.removeScrollBar,b=t.inert;return S.createElement(S.Fragment,null,b?S.createElement(o,{styles:P2t(a)}):null,_?S.createElement(j2t,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function D2t(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const R2t=d2t(aHe,L2t);var TR=S.forwardRef(function(t,s){return S.createElement(pue,Fy({},t,{ref:s,sideCar:R2t}))});TR.classNames=pue.classNames;var d1e=["Enter"," "],O2t=["ArrowDown","PageUp","Home"],dHe=["ArrowUp","PageDown","End"],F2t=[...O2t,...dHe],z2t={ltr:[...d1e,"ArrowRight"],rtl:[...d1e,"ArrowLeft"]},B2t={ltr:["ArrowLeft"],rtl:["ArrowRight"]},AR="Menu",[Q8,$2t,q2t]=yR(AR),[vC,uHe]=$c(AR,[q2t,_0,hw]),fue=_0(),hHe=hw(),[U2t,_C]=vC(AR),[V2t,ER]=vC(AR),mHe=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=fue(s),[d,u]=S.useState(null),p=S.useRef(!1),x=ed(o),y=uw(a);return S.useEffect(()=>{const _=()=>{p.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>p.current=!1;return document.addEventListener("keydown",_,{capture:!0}),()=>{document.removeEventListener("keydown",_,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),e.jsx(wR,{...i,children:e.jsx(U2t,{scope:s,open:r,onOpenChange:x,content:d,onContentChange:u,children:e.jsx(V2t,{scope:s,onClose:S.useCallback(()=>x(!1),[x]),isUsingKeyboardRef:p,dir:y,modal:l,children:n})})})};mHe.displayName=AR;var H2t="MenuAnchor",Tje=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=fue(r);return e.jsx(LA,{...a,...n,ref:s})});Tje.displayName=H2t;var Aje="MenuPortal",[G2t,pHe]=vC(Aje,{forceMount:void 0}),fHe=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=_C(Aje,s);return e.jsx(G2t,{scope:s,forceMount:r,children:e.jsx(wd,{present:r||o.open,children:e.jsx(AA,{asChild:!0,container:a,children:n})})})};fHe.displayName=Aje;var vx="MenuContent",[W2t,Eje]=vC(vx),xHe=S.forwardRef((t,s)=>{const r=pHe(vx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=_C(vx,t.__scopeMenu),l=ER(vx,t.__scopeMenu);return e.jsx(Q8.Provider,{scope:t.__scopeMenu,children:e.jsx(wd,{present:n||o.open,children:e.jsx(Q8.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(K2t,{...a,ref:s}):e.jsx(Z2t,{...a,ref:s})})})})}),K2t=S.forwardRef((t,s)=>{const r=_C(vx,t.__scopeMenu),n=S.useRef(null),a=Aa(s,n);return S.useEffect(()=>{const o=n.current;if(o)return mue(o)},[]),e.jsx(Pje,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Cr(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Z2t=S.forwardRef((t,s)=>{const r=_C(vx,t.__scopeMenu);return e.jsx(Pje,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),Y2t=Vb("MenuContent.ScrollLock"),Pje=S.forwardRef((t,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:i,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:x,onInteractOutside:y,onDismiss:_,disableOutsideScroll:b,...N}=t,w=_C(vx,r),k=ER(vx,r),C=fue(r),E=hHe(r),L=$2t(r),[I,O]=S.useState(null),V=S.useRef(null),q=Aa(s,V,w.onContentChange),$=S.useRef(0),U=S.useRef(""),se=S.useRef(0),Y=S.useRef(null),J=S.useRef("right"),X=S.useRef(0),ce=b?TR:S.Fragment,ie=b?{as:Y2t,allowPinchZoom:!0}:void 0,ae=pe=>{var Fe,Le;const _e=U.current+pe,he=L().filter(Ne=>!Ne.disabled),we=document.activeElement,je=(Fe=he.find(Ne=>Ne.ref.current===we))==null?void 0:Fe.textValue,Ue=he.map(Ne=>Ne.textValue),Te=ljt(Ue,_e,je),Me=(Le=he.find(Ne=>Ne.textValue===Te))==null?void 0:Le.ref.current;(function Ne(qe){U.current=qe,window.clearTimeout($.current),qe!==""&&($.current=window.setTimeout(()=>Ne(""),1e3))})(_e),Me&&setTimeout(()=>Me.focus())};S.useEffect(()=>()=>window.clearTimeout($.current),[]),due();const oe=S.useCallback(pe=>{var he,we;return J.current===((he=Y.current)==null?void 0:he.side)&&djt(pe,(we=Y.current)==null?void 0:we.area)},[]);return e.jsx(W2t,{scope:r,searchRef:U,onItemEnter:S.useCallback(pe=>{oe(pe)&&pe.preventDefault()},[oe]),onItemLeave:S.useCallback(pe=>{var _e;oe(pe)||((_e=V.current)==null||_e.focus(),O(null))},[oe]),onTriggerLeave:S.useCallback(pe=>{oe(pe)&&pe.preventDefault()},[oe]),pointerGraceTimerRef:se,onPointerGraceIntentChange:S.useCallback(pe=>{Y.current=pe},[]),children:e.jsx(ce,{...ie,children:e.jsx(CR,{asChild:!0,trapped:a,onMountAutoFocus:Cr(o,pe=>{var _e;pe.preventDefault(),(_e=V.current)==null||_e.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(lw,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:x,onInteractOutside:y,onDismiss:_,children:e.jsx(uue,{asChild:!0,...E,dir:k.dir,orientation:"vertical",loop:n,currentTabStopId:I,onCurrentTabStopIdChange:O,onEntryFocus:Cr(d,pe=>{k.isUsingKeyboardRef.current||pe.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(jR,{role:"menu","aria-orientation":"vertical","data-state":PHe(w.open),"data-radix-menu-content":"",dir:k.dir,...C,...N,ref:q,style:{outline:"none",...N.style},onKeyDown:Cr(N.onKeyDown,pe=>{const he=pe.target.closest("[data-radix-menu-content]")===pe.currentTarget,we=pe.ctrlKey||pe.altKey||pe.metaKey,je=pe.key.length===1;he&&(pe.key==="Tab"&&pe.preventDefault(),!we&&je&&ae(pe.key));const Ue=V.current;if(pe.target!==Ue||!F2t.includes(pe.key))return;pe.preventDefault();const Me=L().filter(Fe=>!Fe.disabled).map(Fe=>Fe.ref.current);dHe.includes(pe.key)&&Me.reverse(),ijt(Me)}),onBlur:Cr(t.onBlur,pe=>{pe.currentTarget.contains(pe.target)||(window.clearTimeout($.current),U.current="")}),onPointerMove:Cr(t.onPointerMove,J8(pe=>{const _e=pe.target,he=X.current!==pe.clientX;if(pe.currentTarget.contains(_e)&&he){const we=pe.clientX>X.current?"right":"left";J.current=we,X.current=pe.clientX}}))})})})})})})});xHe.displayName=vx;var X2t="MenuGroup",Ije=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Yr.div,{role:"group",...n,ref:s})});Ije.displayName=X2t;var Q2t="MenuLabel",gHe=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Yr.div,{...n,ref:s})});gHe.displayName=Q2t;var Uoe="MenuItem",EPe="menu.itemSelect",xue=S.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=S.useRef(null),l=ER(Uoe,t.__scopeMenu),i=Eje(Uoe,t.__scopeMenu),d=Aa(s,o),u=S.useRef(!1),p=()=>{const x=o.current;if(!r&&x){const y=new CustomEvent(EPe,{bubbles:!0,cancelable:!0});x.addEventListener(EPe,_=>n==null?void 0:n(_),{once:!0}),Q2e(x,y),y.defaultPrevented?u.current=!1:l.onClose()}};return e.jsx(yHe,{...a,ref:d,disabled:r,onClick:Cr(t.onClick,p),onPointerDown:x=>{var y;(y=t.onPointerDown)==null||y.call(t,x),u.current=!0},onPointerUp:Cr(t.onPointerUp,x=>{var y;u.current||(y=x.currentTarget)==null||y.click()}),onKeyDown:Cr(t.onKeyDown,x=>{const y=i.searchRef.current!=="";r||y&&x.key===" "||d1e.includes(x.key)&&(x.currentTarget.click(),x.preventDefault())})})});xue.displayName=Uoe;var yHe=S.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=Eje(Uoe,r),i=hHe(r),d=S.useRef(null),u=Aa(s,d),[p,x]=S.useState(!1),[y,_]=S.useState("");return S.useEffect(()=>{const b=d.current;b&&_((b.textContent??"").trim())},[o.children]),e.jsx(Q8.ItemSlot,{scope:r,disabled:n,textValue:a??y,children:e.jsx(hue,{asChild:!0,...i,focusable:!n,children:e.jsx(Yr.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:u,onPointerMove:Cr(t.onPointerMove,J8(b=>{n?l.onItemLeave(b):(l.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Cr(t.onPointerLeave,J8(b=>l.onItemLeave(b))),onFocus:Cr(t.onFocus,()=>x(!0)),onBlur:Cr(t.onBlur,()=>x(!1))})})})}),J2t="MenuCheckboxItem",vHe=S.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(NHe,{scope:t.__scopeMenu,checked:r,children:e.jsx(xue,{role:"menuitemcheckbox","aria-checked":Voe(r)?"mixed":r,...a,ref:s,"data-state":Dje(r),onSelect:Cr(a.onSelect,()=>n==null?void 0:n(Voe(r)?!0:!r),{checkForDefaultPrevented:!1})})})});vHe.displayName=J2t;var _He="MenuRadioGroup",[ejt,tjt]=vC(_He,{value:void 0,onValueChange:()=>{}}),bHe=S.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=ed(n);return e.jsx(ejt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(Ije,{...a,ref:s})})});bHe.displayName=_He;var wHe="MenuRadioItem",jHe=S.forwardRef((t,s)=>{const{value:r,...n}=t,a=tjt(wHe,t.__scopeMenu),o=r===a.value;return e.jsx(NHe,{scope:t.__scopeMenu,checked:o,children:e.jsx(xue,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":Dje(o),onSelect:Cr(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});jHe.displayName=wHe;var Lje="MenuItemIndicator",[NHe,sjt]=vC(Lje,{checked:!1}),kHe=S.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=sjt(Lje,r);return e.jsx(wd,{present:n||Voe(o.checked)||o.checked===!0,children:e.jsx(Yr.span,{...a,ref:s,"data-state":Dje(o.checked)})})});kHe.displayName=Lje;var rjt="MenuSeparator",SHe=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Yr.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});SHe.displayName=rjt;var njt="MenuArrow",CHe=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=fue(r);return e.jsx(NR,{...a,...n,ref:s})});CHe.displayName=njt;var ajt="MenuSub",[yTs,MHe]=vC(ajt),MI="MenuSubTrigger",THe=S.forwardRef((t,s)=>{const r=_C(MI,t.__scopeMenu),n=ER(MI,t.__scopeMenu),a=MHe(MI,t.__scopeMenu),o=Eje(MI,t.__scopeMenu),l=S.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:d}=o,u={__scopeMenu:t.__scopeMenu},p=S.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return S.useEffect(()=>p,[p]),S.useEffect(()=>{const x=i.current;return()=>{window.clearTimeout(x),d(null)}},[i,d]),e.jsx(Tje,{asChild:!0,...u,children:e.jsx(yHe,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":PHe(r.open),...t,ref:u1(s,a.onTriggerChange),onClick:x=>{var y;(y=t.onClick)==null||y.call(t,x),!(t.disabled||x.defaultPrevented)&&(x.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Cr(t.onPointerMove,J8(x=>{o.onItemEnter(x),!x.defaultPrevented&&!t.disabled&&!r.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),p()},100))})),onPointerLeave:Cr(t.onPointerLeave,J8(x=>{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",k=w?-5:5,C=y[w?"left":"right"],E=y[w?"right":"left"];o.onPointerGraceIntentChange({area:[{x:x.clientX+k,y:x.clientY},{x:C,y:y.top},{x:E,y:y.top},{x:E,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(x),x.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Cr(t.onKeyDown,x=>{var _;const y=o.searchRef.current!=="";t.disabled||y&&x.key===" "||z2t[n.dir].includes(x.key)&&(r.onOpenChange(!0),(_=r.content)==null||_.focus(),x.preventDefault())})})})});THe.displayName=MI;var AHe="MenuSubContent",EHe=S.forwardRef((t,s)=>{const r=pHe(vx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=_C(vx,t.__scopeMenu),l=ER(vx,t.__scopeMenu),i=MHe(AHe,t.__scopeMenu),d=S.useRef(null),u=Aa(s,d);return e.jsx(Q8.Provider,{scope:t.__scopeMenu,children:e.jsx(wd,{present:n||o.open,children:e.jsx(Q8.Slot,{scope:t.__scopeMenu,children:e.jsx(Pje,{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 x;l.isUsingKeyboardRef.current&&((x=d.current)==null||x.focus()),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Cr(t.onFocusOutside,p=>{p.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Cr(t.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:Cr(t.onKeyDown,p=>{var _;const x=p.currentTarget.contains(p.target),y=B2t[l.dir].includes(p.key);x&&y&&(o.onOpenChange(!1),(_=i.trigger)==null||_.focus(),p.preventDefault())})})})})})});EHe.displayName=AHe;function PHe(t){return t?"open":"closed"}function Voe(t){return t==="indeterminate"}function Dje(t){return Voe(t)?"indeterminate":t?"checked":"unchecked"}function ijt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function ojt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function ljt(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=ojt(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 cjt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=y>n&&r<(x-u)*(n-p)/(y-p)+u&&(a=!a)}return a}function djt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return cjt(r,s)}function J8(t){return s=>s.pointerType==="mouse"?t(s):void 0}var ujt=mHe,hjt=Tje,mjt=fHe,pjt=xHe,fjt=Ije,xjt=gHe,gjt=xue,yjt=vHe,vjt=bHe,_jt=jHe,bjt=kHe,wjt=SHe,jjt=CHe,Njt=THe,kjt=EHe,gue="DropdownMenu",[Sjt,vTs]=$c(gue,[uHe]),Rm=uHe(),[Cjt,IHe]=Sjt(gue),LHe=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,d=Rm(s),u=S.useRef(null),[p,x]=$u({prop:a,defaultProp:o??!1,onChange:l,caller:gue});return e.jsx(Cjt,{scope:s,triggerId:pu(),triggerRef:u,contentId:pu(),open:p,onOpenChange:x,onOpenToggle:S.useCallback(()=>x(y=>!y),[x]),modal:i,children:e.jsx(ujt,{...d,open:p,onOpenChange:x,dir:n,modal:i,children:r})})};LHe.displayName=gue;var DHe="DropdownMenuTrigger",RHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=IHe(DHe,r),l=Rm(r);return e.jsx(hjt,{asChild:!0,...l,children:e.jsx(Yr.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:u1(s,o.triggerRef),onPointerDown:Cr(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:Cr(t.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});RHe.displayName=DHe;var Mjt="DropdownMenuPortal",OHe=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Rm(s);return e.jsx(mjt,{...n,...r})};OHe.displayName=Mjt;var FHe="DropdownMenuContent",zHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=IHe(FHe,r),o=Rm(r),l=S.useRef(!1);return e.jsx(pjt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:Cr(t.onCloseAutoFocus,i=>{var d;l.current||(d=a.triggerRef.current)==null||d.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:Cr(t.onInteractOutside,i=>{const d=i.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,p=d.button===2||u;(!a.modal||p)&&(l.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});zHe.displayName=FHe;var Tjt="DropdownMenuGroup",Ajt=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(fjt,{...a,...n,ref:s})});Ajt.displayName=Tjt;var Ejt="DropdownMenuLabel",BHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(xjt,{...a,...n,ref:s})});BHe.displayName=Ejt;var Pjt="DropdownMenuItem",$He=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(gjt,{...a,...n,ref:s})});$He.displayName=Pjt;var Ijt="DropdownMenuCheckboxItem",qHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(yjt,{...a,...n,ref:s})});qHe.displayName=Ijt;var Ljt="DropdownMenuRadioGroup",Djt=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(vjt,{...a,...n,ref:s})});Djt.displayName=Ljt;var Rjt="DropdownMenuRadioItem",UHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(_jt,{...a,...n,ref:s})});UHe.displayName=Rjt;var Ojt="DropdownMenuItemIndicator",VHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(bjt,{...a,...n,ref:s})});VHe.displayName=Ojt;var Fjt="DropdownMenuSeparator",HHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(wjt,{...a,...n,ref:s})});HHe.displayName=Fjt;var zjt="DropdownMenuArrow",Bjt=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(jjt,{...a,...n,ref:s})});Bjt.displayName=zjt;var $jt="DropdownMenuSubTrigger",GHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Njt,{...a,...n,ref:s})});GHe.displayName=$jt;var qjt="DropdownMenuSubContent",WHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(kjt,{...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)"}})});WHe.displayName=qjt;var Ujt=LHe,Vjt=RHe,Hjt=OHe,KHe=zHe,ZHe=BHe,YHe=$He,XHe=qHe,QHe=UHe,JHe=VHe,eGe=HHe,tGe=GHe,sGe=WHe;const Ud=Ujt,Vd=Vjt,Gjt=S.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(tGe,{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(Sa,{className:"ml-auto h-4 w-4"})]}));Gjt.displayName=tGe.displayName;const Wjt=S.forwardRef(({className:t,...s},r)=>e.jsx(sGe,{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}));Wjt.displayName=sGe.displayName;const jd=S.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(Hjt,{children:e.jsx(KHe,{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=KHe.displayName;const va=S.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(YHe,{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}));va.displayName=YHe.displayName;const Kjt=S.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(XHe,{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(JHe,{children:e.jsx(Jn,{className:"h-4 w-4"})})}),s]}));Kjt.displayName=XHe.displayName;const Zjt=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(QHe,{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(JHe,{children:e.jsx(sd,{className:"h-2 w-2 fill-current"})})}),s]}));Zjt.displayName=QHe.displayName;const u1e=S.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(ZHe,{ref:n,className:Rt("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));u1e.displayName=ZHe.displayName;const Zb=S.forwardRef(({className:t,...s},r)=>e.jsx(eGe,{ref:r,className:Rt("-mx-1 my-1 h-px bg-muted",t),...s}));Zb.displayName=eGe.displayName;const Yjt=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:a,setActingAsSelf:o}=Cje();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(Ti,{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(lr,{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(Ti,{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(Ta,{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(Oi,{className:"h-3 w-3"})]})}),e.jsxs(jd,{align:"start",className:"z-[2147483647]",children:[e.jsxs(va,{onClick:o,className:"gap-2",children:[e.jsx(Ti,{className:"h-4 w-4"}),e.jsx("span",{children:"My Account"}),a&&e.jsx(Qe,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),e.jsx(Zb,{}),r.map(i=>e.jsxs(va,{onClick:()=>n(i),className:"gap-2",children:[e.jsxs(vn,{className:"h-6 w-6",children:[e.jsx(Ta,{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(Qe,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},i.id))]})]})]}),e.jsx(Qe,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:a?"Personal Mode":"Assistant Mode"})]})})},ar=({children:t,requireAdmin:s=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:a,rolesLoading:o,isAdmin:l,isBrokerageManager:i}=Fs(),d=Ol();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(Yxe,{to:"/auth",replace:!0})}return s&&!l?e.jsx(Yxe,{to:"/dashboard",replace:!0}):r&&!i&&!l?e.jsx(Yxe,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t})};var Rje={};(function t(s,r,n,a){var o=!!(s.Worker&&s.Blob&&s.Promise&&s.OffscreenCanvas&&s.OffscreenCanvasRenderingContext2D&&s.HTMLCanvasElement&&s.HTMLCanvasElement.prototype.transferControlToOffscreen&&s.URL&&s.URL.createObjectURL),l=typeof Path2D=="function"&&typeof DOMMatrix=="function",i=function(){if(!s.OffscreenCanvas)return!1;try{var _e=new OffscreenCanvas(1,1),he=_e.getContext("2d");he.fillRect(0,0,1,1);var we=_e.transferToImageBitmap();he.createPattern(we,"no-repeat")}catch{return!1}return!0}();function d(){}function u(_e){var he=r.exports.Promise,we=he!==void 0?he:s.Promise;return typeof we=="function"?new we(_e):(_e(d,d),null)}var p=function(_e,he){return{transform:function(we){if(_e)return we;if(he.has(we))return he.get(we);var je=new OffscreenCanvas(we.width,we.height),Ue=je.getContext("2d");return Ue.drawImage(we,0,0),he.set(we,je),je},clear:function(){he.clear()}}}(i,new Map),x=function(){var _e=Math.floor(16.666666666666668),he,we,je={},Ue=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(he=function(Te){var Me=Math.random();return je[Me]=requestAnimationFrame(function Fe(Le){Ue===Le||Ue+_e-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 Qjt(){const t=Jt();return It({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 Jjt(){const t=Jt(),{user:s}=Fs();return It({mutationFn:async r=>{const{error:n}=await G.from("celebration_queue").insert({user_id:r.user_id,celebration_type:r.celebration_type,title:r.title,message:r.message||null,points_amount:r.points_amount||null,created_by:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}var yue="Dialog",[rGe,nGe]=$c(yue),[eNt,Vg]=rGe(yue),aGe=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=S.useRef(null),d=S.useRef(null),[u,p]=$u({prop:n,defaultProp:a??!1,onChange:o,caller:yue});return e.jsx(eNt,{scope:s,triggerRef:i,contentRef:d,contentId:pu(),titleId:pu(),descriptionId:pu(),open:u,onOpenChange:p,onOpenToggle:S.useCallback(()=>p(x=>!x),[p]),modal:l,children:r})};aGe.displayName=yue;var iGe="DialogTrigger",oGe=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Vg(iGe,r),o=Aa(s,a.triggerRef);return e.jsx(Yr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":zje(a.open),...n,ref:o,onClick:Cr(t.onClick,a.onOpenToggle)})});oGe.displayName=iGe;var Oje="DialogPortal",[tNt,lGe]=rGe(Oje,{forceMount:void 0}),cGe=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=Vg(Oje,s);return e.jsx(tNt,{scope:s,forceMount:r,children:S.Children.map(n,l=>e.jsx(wd,{present:r||o.open,children:e.jsx(AA,{asChild:!0,container:a,children:l})}))})};cGe.displayName=Oje;var Hoe="DialogOverlay",dGe=S.forwardRef((t,s)=>{const r=lGe(Hoe,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=Vg(Hoe,t.__scopeDialog);return o.modal?e.jsx(wd,{present:n||o.open,children:e.jsx(rNt,{...a,ref:s})}):null});dGe.displayName=Hoe;var sNt=Vb("DialogOverlay.RemoveScroll"),rNt=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Vg(Hoe,r);return e.jsx(TR,{as:sNt,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(Yr.div,{"data-state":zje(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),qS="DialogContent",uGe=S.forwardRef((t,s)=>{const r=lGe(qS,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=Vg(qS,t.__scopeDialog);return e.jsx(wd,{present:n||o.open,children:o.modal?e.jsx(nNt,{...a,ref:s}):e.jsx(aNt,{...a,ref:s})})});uGe.displayName=qS;var nNt=S.forwardRef((t,s)=>{const r=Vg(qS,t.__scopeDialog),n=S.useRef(null),a=Aa(s,r.contentRef,n);return S.useEffect(()=>{const o=n.current;if(o)return mue(o)},[]),e.jsx(hGe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Cr(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Cr(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:Cr(t.onFocusOutside,o=>o.preventDefault())})}),aNt=S.forwardRef((t,s)=>{const r=Vg(qS,t.__scopeDialog),n=S.useRef(!1),a=S.useRef(!1);return e.jsx(hGe,{...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()}})}),hGe=S.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=Vg(qS,r),d=S.useRef(null),u=Aa(s,d);return due(),e.jsxs(e.Fragment,{children:[e.jsx(CR,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(lw,{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(oNt,{titleId:i.titleId}),e.jsx(cNt,{contentRef:d,descriptionId:i.descriptionId})]})]})}),Fje="DialogTitle",mGe=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Vg(Fje,r);return e.jsx(Yr.h2,{id:a.titleId,...n,ref:s})});mGe.displayName=Fje;var pGe="DialogDescription",fGe=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Vg(pGe,r);return e.jsx(Yr.p,{id:a.descriptionId,...n,ref:s})});fGe.displayName=pGe;var xGe="DialogClose",gGe=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Vg(xGe,r);return e.jsx(Yr.button,{type:"button",...n,ref:s,onClick:Cr(t.onClick,()=>a.onOpenChange(!1))})});gGe.displayName=xGe;function zje(t){return t?"open":"closed"}var yGe="DialogTitleWarning",[iNt,vGe]=mxt(yGe,{contentName:qS,titleName:Fje,docsSlug:"dialog"}),oNt=({titleId:t})=>{const s=vGe(yGe),r=`\`${s.contentName}\` requires a \`${s.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${s.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${s.docsSlug}`;return S.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},lNt="DialogDescriptionWarning",cNt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${vGe(lNt).contentName}}.`;return S.useEffect(()=>{var o;const a=(o=t.current)==null?void 0:o.getAttribute("aria-describedby");s&&a&&(document.getElementById(s)||console.warn(n))},[n,t,s]),null},vue=aGe,Bje=oGe,_ue=cGe,BA=dGe,$A=uGe,PR=mGe,IR=fGe,LR=gGe;const fs=vue,pi=Bje,dNt=_ue,_Ts=LR,_Ge=S.forwardRef(({className:t,...s},r)=>e.jsx(BA,{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}));_Ge.displayName=BA.displayName;const ms=S.forwardRef(({className:t,children:s,overlayClassName:r,...n},a)=>e.jsxs(dNt,{children:[e.jsx(_Ge,{className:r}),e.jsxs($A,{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(LR,{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=$A.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 En=({className:t,...s})=>e.jsx("div",{className:Rt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});En.displayName="DialogFooter";const bs=S.forwardRef(({className:t,...s},r)=>e.jsx(PR,{ref:r,className:Rt("text-lg font-semibold leading-none tracking-tight",t),...s}));bs.displayName=PR.displayName;const Ir=S.forwardRef(({className:t,...s},r)=>e.jsx(IR,{ref:r,className:Rt("text-sm text-muted-foreground",t),...s}));Ir.displayName=IR.displayName;const uNt={points_earned:Vi,listing_created:Mn,deal_closed:yc,custom:Hn},IPe={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"},LPe=()=>{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 hNt(){const{user:t}=Fs(),s=Jt(),{data:r}=Xjt(),n=Qjt(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=S.useCallback(()=>{const _=Date.now()+3e3,b={startVelocity:30,spread:360,ticks:60,zIndex:9999},N=(k,C)=>Math.random()*(C-k)+k,w=setInterval(()=>{const k=_-Date.now();if(k<=0){clearInterval(w);return}const C=50*(k/3e3);PPe({...b,particleCount:C,origin:{x:N(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),PPe({...b,particleCount:C,origin:{x:N(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);S.useEffect(()=>{LPe()||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(LPe()||!a)return null;const p=uNt[a.celebration_type]||Hn,x=IPe[a.celebration_type]||IPe.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 ${x} 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 ${x} 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($r,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx($r,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx($r,{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 bGe="/assets/levelup-logo-horizontal-DEFNc0ms.png",$je="/assets/levelup-logo-white-C2RAgAoG.png",mNt="/assets/listings-hero-BI9Ki9Dq.jpg",De=S.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}));De.displayName="Input";var wGe={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(md,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(f,c){var h=c[0],g=c[1],j=c[2],T=c[3],P=h*T-j*g;return P?(f[0]=T*(P=1/P),f[1]=-g*P,f[2]=-j*P,f[3]=h*P,f):null}function x(){var f=new u(9);return u!=Float32Array&&(f[1]=0,f[2]=0,f[3]=0,f[5]=0,f[6]=0,f[7]=0),f[0]=1,f[4]=1,f[8]=1,f}function y(f,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 f[0]=P*Q-R*H,f[1]=j*H-g*Q,f[2]=g*R-j*P,f[3]=R*F-T*Q,f[4]=h*Q-j*F,f[5]=j*T-h*R,f[6]=T*H-P*F,f[7]=g*F-h*H,f[8]=h*P-g*T,f}function _(f,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],te=c[8],re=h[0],le=h[1],ue=h[2],ge=h[3],ke=h[4],Ee=h[5],He=h[6],$e=h[7],rt=h[8];return f[0]=re*g+le*P+ue*H,f[1]=re*j+le*R+ue*Q,f[2]=re*T+le*F+ue*te,f[3]=ge*g+ke*P+Ee*H,f[4]=ge*j+ke*R+Ee*Q,f[5]=ge*T+ke*F+Ee*te,f[6]=He*g+$e*P+rt*H,f[7]=He*j+$e*R+rt*Q,f[8]=He*T+$e*F+rt*te,f}function b(){var f=new u(16);return u!=Float32Array&&(f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[11]=0,f[12]=0,f[13]=0,f[14]=0),f[0]=1,f[5]=1,f[10]=1,f[15]=1,f}function N(f){var c=new u(16);return c[0]=f[0],c[1]=f[1],c[2]=f[2],c[3]=f[3],c[4]=f[4],c[5]=f[5],c[6]=f[6],c[7]=f[7],c[8]=f[8],c[9]=f[9],c[10]=f[10],c[11]=f[11],c[12]=f[12],c[13]=f[13],c[14]=f[14],c[15]=f[15],c}function w(f){return f[0]=1,f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=1,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[10]=1,f[11]=0,f[12]=0,f[13]=0,f[14]=0,f[15]=1,f}function k(f,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],te=c[9],re=c[10],le=c[11],ue=c[12],ge=c[13],ke=c[14],Ee=c[15],He=h*R-g*P,$e=h*F-j*P,rt=h*H-T*P,it=g*F-j*R,lt=g*H-T*R,Pt=j*H-T*F,jt=Q*ge-te*ue,At=Q*ke-re*ue,St=Q*Ee-le*ue,Ct=te*ke-re*ge,ss=te*Ee-le*ge,is=re*Ee-le*ke,us=He*is-$e*ss+rt*Ct+it*St-lt*At+Pt*jt;return us?(f[0]=(R*is-F*ss+H*Ct)*(us=1/us),f[1]=(j*ss-g*is-T*Ct)*us,f[2]=(ge*Pt-ke*lt+Ee*it)*us,f[3]=(re*lt-te*Pt-le*it)*us,f[4]=(F*St-P*is-H*At)*us,f[5]=(h*is-j*St+T*At)*us,f[6]=(ke*rt-ue*Pt-Ee*$e)*us,f[7]=(Q*Pt-re*rt+le*$e)*us,f[8]=(P*ss-R*St+H*jt)*us,f[9]=(g*St-h*ss-T*jt)*us,f[10]=(ue*lt-ge*rt+Ee*He)*us,f[11]=(te*rt-Q*lt-le*He)*us,f[12]=(R*At-P*Ct-F*jt)*us,f[13]=(h*Ct-g*At+j*jt)*us,f[14]=(ge*$e-ue*it-ke*He)*us,f[15]=(Q*it-te*$e+re*He)*us,f):null}function C(f,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],te=c[8],re=c[9],le=c[10],ue=c[11],ge=c[12],ke=c[13],Ee=c[14],He=c[15],$e=h[0],rt=h[1],it=h[2],lt=h[3];return f[0]=$e*g+rt*R+it*te+lt*ge,f[1]=$e*j+rt*F+it*re+lt*ke,f[2]=$e*T+rt*H+it*le+lt*Ee,f[3]=$e*P+rt*Q+it*ue+lt*He,f[4]=($e=h[4])*g+(rt=h[5])*R+(it=h[6])*te+(lt=h[7])*ge,f[5]=$e*j+rt*F+it*re+lt*ke,f[6]=$e*T+rt*H+it*le+lt*Ee,f[7]=$e*P+rt*Q+it*ue+lt*He,f[8]=($e=h[8])*g+(rt=h[9])*R+(it=h[10])*te+(lt=h[11])*ge,f[9]=$e*j+rt*F+it*re+lt*ke,f[10]=$e*T+rt*H+it*le+lt*Ee,f[11]=$e*P+rt*Q+it*ue+lt*He,f[12]=($e=h[12])*g+(rt=h[13])*R+(it=h[14])*te+(lt=h[15])*ge,f[13]=$e*j+rt*F+it*re+lt*ke,f[14]=$e*T+rt*H+it*le+lt*Ee,f[15]=$e*P+rt*Q+it*ue+lt*He,f}function E(f,c,h){var g,j,T,P,R,F,H,Q,te,re,le,ue,ge=h[0],ke=h[1],Ee=h[2];return c===f?(f[12]=c[0]*ge+c[4]*ke+c[8]*Ee+c[12],f[13]=c[1]*ge+c[5]*ke+c[9]*Ee+c[13],f[14]=c[2]*ge+c[6]*ke+c[10]*Ee+c[14],f[15]=c[3]*ge+c[7]*ke+c[11]*Ee+c[15]):(j=c[1],T=c[2],P=c[3],R=c[4],F=c[5],H=c[6],Q=c[7],te=c[8],re=c[9],le=c[10],ue=c[11],f[0]=g=c[0],f[1]=j,f[2]=T,f[3]=P,f[4]=R,f[5]=F,f[6]=H,f[7]=Q,f[8]=te,f[9]=re,f[10]=le,f[11]=ue,f[12]=g*ge+R*ke+te*Ee+c[12],f[13]=j*ge+F*ke+re*Ee+c[13],f[14]=T*ge+H*ke+le*Ee+c[14],f[15]=P*ge+Q*ke+ue*Ee+c[15]),f}function L(f,c,h){var g=h[0],j=h[1],T=h[2];return f[0]=c[0]*g,f[1]=c[1]*g,f[2]=c[2]*g,f[3]=c[3]*g,f[4]=c[4]*j,f[5]=c[5]*j,f[6]=c[6]*j,f[7]=c[7]*j,f[8]=c[8]*T,f[9]=c[9]*T,f[10]=c[10]*T,f[11]=c[11]*T,f[12]=c[12],f[13]=c[13],f[14]=c[14],f[15]=c[15],f}function I(f,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],te=c[10],re=c[11];return c!==f&&(f[0]=c[0],f[1]=c[1],f[2]=c[2],f[3]=c[3],f[12]=c[12],f[13]=c[13],f[14]=c[14],f[15]=c[15]),f[4]=T*j+H*g,f[5]=P*j+Q*g,f[6]=R*j+te*g,f[7]=F*j+re*g,f[8]=H*j-T*g,f[9]=Q*j-P*g,f[10]=te*j-R*g,f[11]=re*j-F*g,f}function O(f,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],te=c[10],re=c[11];return c!==f&&(f[4]=c[4],f[5]=c[5],f[6]=c[6],f[7]=c[7],f[12]=c[12],f[13]=c[13],f[14]=c[14],f[15]=c[15]),f[0]=T*j-H*g,f[1]=P*j-Q*g,f[2]=R*j-te*g,f[3]=F*j-re*g,f[8]=T*g+H*j,f[9]=P*g+Q*j,f[10]=R*g+te*j,f[11]=F*g+re*j,f}function V(f,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],te=c[6],re=c[7];return c!==f&&(f[8]=c[8],f[9]=c[9],f[10]=c[10],f[11]=c[11],f[12]=c[12],f[13]=c[13],f[14]=c[14],f[15]=c[15]),f[0]=T*j+H*g,f[1]=P*j+Q*g,f[2]=R*j+te*g,f[3]=F*j+re*g,f[4]=H*j-T*g,f[5]=Q*j-P*g,f[6]=te*j-R*g,f[7]=re*j-F*g,f}function q(f,c){return f[0]=c[0],f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=c[1],f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[10]=c[2],f[11]=0,f[12]=0,f[13]=0,f[14]=0,f[15]=1,f}function $(f,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)),f[0]=c[0]*T,f[1]=c[1]*T,f[2]=c[2]*T,f}function qe(f,c){return f[0]*c[0]+f[1]*c[1]+f[2]*c[2]}function ze(f,c,h){var g=c[0],j=c[1],T=c[2],P=h[0],R=h[1],F=h[2];return f[0]=j*F-T*R,f[1]=T*P-g*F,f[2]=g*R-j*P,f}function ve(f,c,h,g){var j=c[0],T=c[1],P=c[2];return f[0]=j+g*(h[0]-j),f[1]=T+g*(h[1]-T),f[2]=P+g*(h[2]-P),f}function dt(f,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 f[0]=(h[0]*g+h[4]*j+h[8]*T+h[12])/(P=P||1),f[1]=(h[1]*g+h[5]*j+h[9]*T+h[13])/P,f[2]=(h[2]*g+h[6]*j+h[10]*T+h[14])/P,f}function fe(f,c,h){var g=c[0],j=c[1],T=c[2];return f[0]=g*h[0]+j*h[3]+T*h[6],f[1]=g*h[1]+j*h[4]+T*h[7],f[2]=g*h[2]+j*h[5]+T*h[8],f}function Ve(f,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,te=T*R-g*H,re=g*F-j*R;return f[0]=R+P*(Q+=Q)+j*(re+=re)-T*(te+=te),f[1]=F+P*te+T*Q-g*re,f[2]=H+P*re+g*te-j*Q,f}function Je(f){return f[0]=0,f[1]=0,f[2]=0,f}function at(f,c){return f[0]===c[0]&&f[1]===c[1]&&f[2]===c[2]}var Ae=pe,Ye=_e,We=ce;function ot(){var f=new u(4);return u!=Float32Array&&(f[0]=0,f[1]=0,f[2]=0,f[3]=0),f}function Ge(f,c,h){return f[0]=c[0]*h,f[1]=c[1]*h,f[2]=c[2]*h,f[3]=c[3]*h,f}function et(f,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)),f[0]=h*P,f[1]=g*P,f[2]=j*P,f[3]=T*P,f}function ht(f,c){return f[0]*c[0]+f[1]*c[1]+f[2]*c[2]+f[3]*c[3]}function xt(f,c,h){var g=c[0],j=c[1],T=c[2],P=c[3];return f[0]=h[0]*g+h[4]*j+h[8]*T+h[12]*P,f[1]=h[1]*g+h[5]*j+h[9]*T+h[13]*P,f[2]=h[2]*g+h[6]*j+h[10]*T+h[14]*P,f[3]=h[3]*g+h[7]*j+h[11]*T+h[15]*P,f}function Ke(){var f=new u(4);return u!=Float32Array&&(f[0]=0,f[1]=0,f[2]=0),f[3]=1,f}function Ze(f){return f[0]=0,f[1]=0,f[2]=0,f[3]=1,f}function Et(f,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 f[0]=g*F+P*R,f[1]=j*F+T*R,f[2]=T*F-j*R,f[3]=P*F-g*R,f}function $t(f,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 f[0]=g*F-T*R,f[1]=j*F+P*R,f[2]=T*F+g*R,f[3]=P*F-j*R,f}J(),ot();var Yt,Ps,zs,Zs=et,Dr=(Yt=J(),Ps=ie(1,0,0),zs=ie(0,1,0),function(f,c,h){var g=qe(c,h);return g<-.999999?(ze(Yt,Ps,c),We(Yt)<1e-6&&ze(Yt,zs,c),Ne(Yt,Yt),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)}(f,Yt,Math.PI),f):g>.999999?(f[0]=0,f[1]=0,f[2]=0,f[3]=1,f):(ze(Yt,c,h),f[0]=Yt[0],f[1]=Yt[1],f[2]=Yt[2],f[3]=1+g,Zs(f,f))});function zt(){var f=new u(2);return u!=Float32Array&&(f[0]=0,f[1]=0),f}function $s(f,c){var h=new u(2);return h[0]=f,h[1]=c,h}function kr(f,c,h){return f[0]=c,f[1]=h,f}function Xs(f,c,h){return f[0]=c[0]+h[0],f[1]=c[1]+h[1],f}function ir(f,c,h){return f[0]=c[0]-h[0],f[1]=c[1]-h[1],f}function Or(f,c,h){return f[0]=c[0]*h,f[1]=c[1]*h,f}function Vn(f){var c=f[0],h=f[1];return Math.sqrt(c*c+h*h)}function Qr(f,c){var h=c[0],g=c[1],j=h*h+g*g;return j>0&&(j=1/Math.sqrt(j)),f[0]=c[0]*j,f[1]=c[1]*j,f}function Gr(f,c){return f[0]*c[0]+f[1]*c[1]}Ke(),Ke(),x();var tr,cr,cn=ir;function rn(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}zt();var jn=function(){if(cr)return tr;function f(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 cr=1,tr=f,f.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))}},tr}(),ni=rn(jn);function rs(f,c){this.x=f,this.y=c}function Bn(f,c){if(Array.isArray(f)){if(!Array.isArray(c)||f.length!==c.length)return!1;for(let h=0;h=1)return 1;const c=f*f,h=c*f;return 4*(f<.5?h:3*(f-c)+h-.75)}function qt(f,c,h,g){const j=new ni(f,c,h,g);return function(T){return j.solve(T)}}const Se=qt(.25,.1,.25,1);function Oe(f,c,h){return Math.min(h,Math.max(c,f))}function Xe(f,c,h){return(h=Oe((h-f)/(c-f),0,1))*h*(3-2*h)}function _t(f,c,h){const g=h-c,j=((f-c)%g+g)%g+c;return j===c?h:j}function bt(f,c,h){if(!f.length)return h(null,[]);let g=f.length;const j=new Array(f.length);let T=null;f.forEach((P,R)=>{c(P,(F,H)=>{F&&(T=F),j[R]=H,--g===0&&h(T,j)})})}let Mt=1;function Ht(){return Mt++}function Vt(f){return f<=1?1:Math.pow(2,Math.ceil(Math.log2(f)))}function Xt(f,c){f.forEach(h=>{c[h]&&(c[h]=c[h].bind(c))})}function Ts(f,c,h){const g={};for(const j in f)g[j]=c.call(this,f[j],j,f);return g}function xs(f,c,h){const g={};for(const j in f)c.call(this,f[j],j,f)&&(g[j]=f[j]);return g}function or(f){return Array.isArray(f)?f.map(or):typeof f=="object"&&f?Ts(f,or):f}function Lr(f,c){for(let h=0;h=0)return!0;return!1}const Hr={};function Rr(f){Hr[f]||(typeof console<"u"&&console.warn(f),Hr[f]=!0)}function dn(f,c,h){return(h.y-f.y)*(c.x-f.x)>(c.y-f.y)*(h.x-f.x)}function Gn(f){let c=0;for(let h,g,j=0,T=f.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 _o,Zi=null;function ai(f,c){return[f[4*c],f[4*c+1],f[4*c+2],f[4*c+3]]}function Fi(f,c,h,g){for(;c>1;f[j]>1;f[j]<=g?c=j+1:h=j}return c}function di(f){return f>0?1/(1.001-f):1+f}function zi(f){return f>0?1-1/(1.001-f):-f}function Yi(f,c,h){return(f-c.min)*(h.max-h.min)/(c.max-c.min)+h.min}const ua={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!ua.API_URL)return null;try{const f=new URL(ua.API_URL);return f.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":f.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(ua.DRACO_URL,ua.API_URL).href}function sc(){if(typeof WebAssembly!="object")throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL(function(){if(_o===void 0){if(typeof WebAssembly!="object")return!1;const f=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]);_o=WebAssembly.validate(f)}return _o}()?ua.MESHOPT_SIMD_URL:ua.MESHOPT_URL,ua.API_URL).href}function rc(){return new URL(ua.BUILDING_GEN_URL,ua.API_URL).href}function _u(f){return ua.API_URL_REGEX.test(f)}function bu(f){return ua.API_SPRITE_REGEX.test(f)}let Om,Nd,wu,Fm,Hu,zm;function kd(){return Om==null&&(Om=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Om}const Sd={now:()=>Fm!==void 0?Fm:performance.now(),setNow(f){Fm=f},restoreNow(){Fm=void 0},frame(f){const c=requestAnimationFrame(f);return{cancel:()=>cancelAnimationFrame(c)}},getImageData(f,c=0){const{width:h,height:g}=f;Hu||(Hu=document.createElement("canvas"));const j=Hu.getContext("2d",{willReadFrequently:!0});if(!j)throw new Error("failed to create canvas 2d context");return(h>Hu.width||g>Hu.height)&&(Hu.width=h,Hu.height=g),j.clearRect(-c,-c,h+2*c,g+2*c),j.drawImage(f,0,0,h,g),j.getImageData(-c,-c,h+2*c,g+2*c)},resolveURL:f=>(Nd||(Nd=document.createElement("a")),Nd.href=f,Nd.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(wu==null&&(wu=window.matchMedia("(prefers-reduced-motion: reduce)")),wu.matches)},hasCanvasFingerprintNoise(){if(zm!==void 0)return zm;if(!kd())return zm=!1,!1;const f=new OffscreenCanvas(85,1),c=f.getContext("2d",{willReadFrequently:!0});let h=0;for(let j=0;j0?`?${T}`:""}`}const xh="mapbox-tiles";let kp=500,Sp=50;const Mw=["language","worldview","jobid"];let Kh;function Sf(){try{return caches}catch{}}function zx(){const f=Sf();f&&Kh==null&&(Kh=f.open(xh))}let Cd=1/0;const Bx={supported:!1,testSupport:function(f){!Tw&&Hd&&(gh?Cf(f):Cp=f)}};let Cp,Hd,Tw=!1,gh=!1;const Xg=typeof self<"u"?self:{};function Cf(f){const c=f.createTexture();f.bindTexture(f.TEXTURE_2D,c);try{if(f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,Hd),f.isContextLost())return;Bx.supported=!0}catch{}f.deleteTexture(c),Tw=!0}Xg.document&&(Hd=Xg.document.createElement("img"),Hd.onload=function(){Cp&&Cf(Cp),Cp=null,gh=!0},Hd.onerror=function(){Tw=!0,Cp=null},Hd.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const I0={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(I0);class Aw extends Error{constructor(c,h,g){h===401&&_u(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 A1(f){return typeof f=="object"&&f!==null&&"status"in f&&f.status===404}const Ca=da()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Qg=function(f,c){return/^file:/.test(h=f.url)||/^file:/.test(Ca())&&!/^\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(),te=H.join(": ");R.append(Q,te)}),j(null,P,R)}else j(new Aw(T.statusText,T.status,g.url))},T.send(g.body),{cancel:()=>T.abort()}}(f,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:Ca(),referrerPolicy:g.referrerPolicy,signal:T.signal});let R=!1,F=!1;const H=(Q=P.url).indexOf("sku=")>0&&_u(Q);var Q;g.type==="json"&&P.headers.set("Accept","application/json");const te=(le,ue,ge)=>{if(F)return;if(le&&le.message!=="SecurityError"&&Rr(le.toString()),ue&&ge)return re(ue);const ke=Date.now();fetch(P).then(Ee=>{if(Ee.ok){const He=H?Ee.clone():null;return re(Ee,He,ke)}return j(new Aw(Ee.statusText,Ee.status,g.url))}).catch(Ee=>{Ee.name!=="AbortError"&&j(new Error(`${Ee.message} ${g.url}`))})},re=(le,ue,ge)=>{(g.type==="arrayBuffer"?le.arrayBuffer():g.type==="json"?le.json():le.text()).then(ke=>{F||(ue&&ge&&function(Ee,He,$e){if(zx(),Kh==null)return;const rt=Mo(He.headers.get("cache-control")||"");if(rt["no-store"])return;const it={status:He.status,statusText:He.statusText,headers:new Headers};He.headers.forEach((St,Ct)=>it.headers.set(Ct,St)),rt["max-age"]&&it.headers.set("Expires",new Date($e+1e3*rt["max-age"]).toUTCString());const lt=it.headers.get("expires");if(!lt||new Date(lt).getTime()-$e<42e4)return;let Pt=Cw(Ee.url,{persistentParams:Mw});if(He.status===206){const St=Ee.headers.get("Range");if(!St)return;it.status=200,Pt=P0(Pt,{range:St})}const jt=new Response((At=He.status)!==200&&At!==404&&[101,103,204,205,304].includes(At)?null:He.body,it);var At;zx(),Kh!=null&&Kh.then(St=>St.put(Pt,jt)).catch(St=>Rr(St.message))}(P,ue,ge),R=!0,j(null,ke,le.headers))}).catch(ke=>{F||j(new Error(ke.message))})};return H?function(le,ue){if(zx(),Kh==null)return ue(null);Kh.then(ge=>{let ke=Cw(le.url,{persistentParams:Mw});const Ee=le.headers.get("Range");Ee&&(ke=P0(ke,{range:Ee})),ge.match(ke).then(He=>{const $e=function(rt){if(!rt)return!1;const it=new Date(rt.headers.get("expires")||0),lt=Mo(rt.headers.get("cache-control")||"");return Number(it)>Date.now()&&!lt["no-cache"]}(He);ge.delete(ke).catch(ue),$e&&ge.put(ke,He.clone()).catch(ue),ue(null,He,$e)}).catch(ue)}).catch(ue)}(P,te):te(null,null),{cancel:()=>{F=!0,R||T.abort()}}}(f,c);var h},Jg=function(f,c){return Qg(Object.assign(f,{type:"arrayBuffer"}),c)};function IE(f){const c=document.createElement("a");return c.href=f,c.protocol===location.protocol&&c.host===location.host}let $x,Mf;$x=[],Mf=0;const ey=function(f,c){if(Bx.supported&&(f.headers||(f.headers={}),f.headers.accept="image/webp,*/*"),Mf>=ua.MAX_PARALLEL_IMAGE_REQUESTS){const T={requestParameters:f,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return $x.push(T),T}Mf++;let h=!1;const g=()=>{if(!h)for(h=!0,Mf--;$x.length&&Mf{g(),T?c(T):P&&function(F,H){const Q=new Blob([new Uint8Array(F)],{type:"image/png"});createImageBitmap(Q).then(te=>{H(null,te)}).catch(te=>{H(new Error(`Could not load image because of ${te.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(P,(F,H)=>c(F,H,R))});return{cancel:()=>{j.cancel(),g()}}};var L0,E1,PC,Tf={exports:{}},IC={exports:{}},kt={exports:{}},Ds=function(){if(PC)return Tf.exports;PC=1;var f=(L0||(L0=1,IC.exports=function(h,g){var j,T,P,R,F,H,Q,te;for(T=h.length-(j=3&h.length),P=g,F=3432918353,H=461845907,te=0;te>>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(te+2))<<16;case 2:Q^=(255&h.charCodeAt(te+1))<<8;case 1:P^=Q=(65535&(Q=(Q=(65535&(Q^=255&h.charCodeAt(te)))*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}),IC.exports),c=(E1||(E1=1,kt.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}),kt.exports);return Tf.exports=f,Tf.exports.murmur3=f,Tf.exports.murmur2=c,Tf.exports}(),nr=rn(Ds);class Jr{constructor(c,...h){Object.assign(this,h[0]||{}),this.type=c}}class pn extends Jr{constructor(c,h={}){super("error",Object.assign({error:c},h))}}function oa(f,c,h){h[f]&&h[f].indexOf(c)!==-1||(h[f]=h[f]||[],h[f].push(c))}function xa(f,c,h){if(h&&h[f]){const g=h[f].indexOf(c);g!==-1&&h[f].splice(g,1)}}class Ai{on(c,h){return this._listeners=this._listeners||{},oa(c,h,this._listeners),this}off(c,h){return xa(c,h,this._listeners),xa(c,h,this._oneTimeListeners),this}once(c,h){return h?(this._oneTimeListeners=this._oneTimeListeners||{},oa(c,h,this._oneTimeListeners),this):new Promise(g=>{this.once(c,g)})}fire(c,h){const g=typeof c=="string"?new Jr(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)xa(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 pn&&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 kc{constructor(c){typeof c=="string"?this.name=c:(this.name=c.name,this.iconsetId=c.iconsetId)}static from(c){return new kc(c)}static toString(c){return c.iconsetId?`${c.name}${c.iconsetId}`:c.name}static parse(c){const[h,g]=c.split("");return new kc({name:h,iconsetId:g})}static isEqual(c,h){return c.name===h.name&&c.iconsetId===h.iconsetId}toString(){return kc.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var Bm,Zh={},D0=function(){if(Bm)return Zh;Bm=1;var f={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{Zh.parseCSSColor=function(T){var P,R=T.replace(/ /g,"").toLowerCase();if(R in f)return f[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),te=R.substr(F+1,H-(F+1)).split(","),re=1;switch(Q){case"rgba":if(te.length!==4)return null;re=g(te.pop());case"rgb":return te.length!==3?null:[h(te[0]),h(te[1]),h(te[2]),re];case"hsla":if(te.length!==4)return null;re=g(te.pop());case"hsl":if(te.length!==3)return null;var le=(parseFloat(te[0])%360+360)%360/360,ue=g(te[1]),ge=g(te[2]),ke=ge<=.5?ge*(ue+1):ge+ue-ge*ue,Ee=2*ge-ke;return[c(255*j(Ee,ke,le+1/3)),c(255*j(Ee,ke,le)),c(255*j(Ee,ke,le-1/3)),re];default:return null}}return null}}catch{}return Zh}();class Ea{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 Ea)return c;if(typeof c!="string")return;const h=D0.parseCSSColor(c);return h?new Ea(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 LC(c,h,g,j,T)}toPremultipliedRenderColor(c){const{r:h,g,b:j,a:T}=this;return new P1(c,h*T,g*T,j*T,T)}clone(){return new Ea(this.r,this.g,this.b,this.a)}}class LE{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),te=Math.floor(j),re=Math.ceil(h),le=Math.ceil(g),ue=Math.ceil(j),ge=h-H,ke=g-Q,Ee=j-te,He=c.image.data,$e=4*(H+Q*F+te*R),rt=4*(H+Q*F+ue*R),it=4*(H+le*F+te*R),lt=4*(H+le*F+ue*R),Pt=4*(re+Q*F+te*R),jt=4*(re+Q*F+ue*R),At=4*(re+le*F+te*R),St=4*(re+le*F+ue*R);this.r=sn(sn(sn(He[$e],He[rt],Ee),sn(He[it],He[lt],Ee),ke),sn(sn(He[Pt],He[jt],Ee),sn(He[At],He[St],Ee),ke),ge)/255*(this.premultiplied?T:1),this.g=sn(sn(sn(He[$e+1],He[rt+1],Ee),sn(He[it+1],He[lt+1],Ee),ke),sn(sn(He[Pt+1],He[jt+1],Ee),sn(He[At+1],He[St+1],Ee),ke),ge)/255*(this.premultiplied?T:1),this.b=sn(sn(sn(He[$e+2],He[rt+2],Ee),sn(He[it+2],He[lt+2],Ee),ke),sn(sn(He[Pt+2],He[jt+2],Ee),sn(He[At+2],He[St+2],Ee),ke),ge)/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,te=.5*(F+H);if(Q===0)return[0,0,100*te,j];const re=te>.5?Q/(2-H-F):Q/(H+F);let le;switch(H){case T:le=60*((P-R)/Q+(Psn(g,c[j],h))}Ea.black=new Ea(0,0,0,1),Ea.white=new Ea(1,1,1,1),Ea.transparent=new Ea(0,0,0,0),Ea.red=new Ea(1,0,0,1),Ea.blue=new Ea(0,0,1,1);var DC=Object.freeze({__proto__:null,array:Mp,color:function(f,c,h){return new Ea(sn(f.r,c.r,h),sn(f.g,c.g,h),sn(f.b,c.b,h),sn(f.a,c.a,h))},number:sn});class $m extends Error{constructor(c,h){super(h),this.message=h,this.key=c}}class R0{constructor(c,h=[]){this.parent=c,this.bindings={};for(const[g,j]of h)this.bindings[g]=j}concat(c){return new R0(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 qx={kind:"null"},Pr={kind:"number"},si={kind:"string"},ii={kind:"boolean"},ju={kind:"color"},ty={kind:"object"},oi={kind:"value"},O0={kind:"collator"},Ew={kind:"formatted"},Pw={kind:"resolvedImage"};function Gd(f,c){return{kind:"array",itemType:f,N:c}}function yl(f){if(f.kind==="array"){const c=yl(f.itemType);return typeof f.N=="number"?`array<${c}, ${f.N}>`:f.itemType.kind==="value"?"array":`array<${c}>`}return f.kind}const rpe=[qx,Pr,si,ii,ju,Ew,ty,Gd(oi),Pw];function Iw(f,c){if(c.kind==="error")return null;if(f.kind==="array"){if(c.kind==="array"&&(c.N===0&&c.itemType.kind==="value"||!Iw(f.itemType,c.itemType))&&(typeof f.N!="number"||f.N===c.N))return null}else{if(f.kind===c.kind)return null;if(f.kind==="value"){for(const h of rpe)if(!Iw(h,c))return null}}return`Expected ${yl(f)} but found ${yl(c)} instead.`}function DE(f,c){return c.some(h=>h.kind===f.kind)}function I1(f,c){return c.some(h=>h==="null"?f===null:h==="array"?Array.isArray(f):h==="object"?f&&!Array.isArray(f)&&typeof f=="object":h===typeof f)}function Ux(f,c){return f.kind==="array"&&c.kind==="array"?f.N===c.N&&Ux(f.itemType,c.itemType):f.kind===c.kind}class RE{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 Lw{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 Md{constructor(c){this.sections=c}static fromString(c){return new Md([new Lw(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 Md?c:Md.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 qm{constructor(c,h={}){this.id=kc.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 qm(h,{params:g,sx:j,sy:T}):null}scaleSelf(c,h=c){return this.sx*=c,this.sy*=h,this}}class Gu{constructor(c,h,g,j,T=!1){this.primaryId=kc.from(c),this.primaryOptions=h,g&&(this.secondaryId=kc.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 qm(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new qm(this.secondaryId,this.secondaryOptions):null}static from(c){return typeof c=="string"?Gu.build({name:c}):c}static build(c,h,g,j){return!c||typeof c=="object"&&!("name"in c)?null:new Gu(c,g,h,j)}}function MO(f,c,h,g){return typeof f=="number"&&f>=0&&f<=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 [${[f,c,h,g].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof g=="number"?[f,c,h,g]:[f,c,h]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function L1(f){if(f===null||typeof f=="string"||typeof f=="boolean"||typeof f=="number"||f instanceof Ea||f instanceof RE||f instanceof Md||f instanceof Gu)return!0;if(Array.isArray(f)){for(const c of f)if(!L1(c))return!1;return!0}if(typeof f=="object"){for(const c in f)if(!L1(f[c]))return!1;return!0}return!1}function Oo(f){if(f===null)return qx;if(typeof f=="string")return si;if(typeof f=="boolean")return ii;if(typeof f=="number")return Pr;if(f instanceof Ea)return ju;if(f instanceof RE)return O0;if(f instanceof Md)return Ew;if(f instanceof Gu)return Pw;if(Array.isArray(f)){const c=f.length;let h;for(const g of f){const j=Oo(g);if(h){if(h===j)continue;h=oi;break}h=j}return Gd(h||oi,c)}return ty}function tn(f){const c=typeof f;return f===null?"":c==="string"||c==="number"||c==="boolean"?String(f):f instanceof Md||f instanceof Gu||f instanceof Ea?f.toString():JSON.stringify(f)}class Nr{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(!L1(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 Nr(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 Ea?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Md?this.value.serialize():this.value}}class il{constructor(c){this.name="ExpressionEvaluationError",this.message=c}toJSON(){return this.message}}const nn={string:si,number:Pr,boolean:ii,object:ty};class Yh{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 nn)||H==="object")return h.error('The item type argument of "array" must be one of string, number, boolean',1);R=nn[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=Gd(R,F)}else g=nn[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 F0{constructor(c){this.type=Ew,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",Pr),!F))return null;let H=null;if(R["text-font"]&&(H=h.parseObjectValue(R["text-font"],P,"text-font",Gd(si)),!H))return null;let Q=null;if(R["text-color"]&&(Q=h.parseObjectValue(R["text-color"],P,"text-color",ju),!Q))return null;const te=j[j.length-1];te.scale=F,te.font=H,te.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 F0(j)}evaluate(c){return new Md(this.sections.map(h=>{const g=h.content.evaluate(c);return Ux(Oo(g),Pw)?new Lw("",g,null,null,null):new Lw(tn(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=Pw,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(gkc.isEqual(P,T)),j.available){const P=j.getSecondary()?j.getSecondary().id:null;P&&(j.available=c.availableImages.some(R=>kc.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 Dw(f){return OC(f)?"string":Rw(f)?"number":Ow(f)?"boolean":Array.isArray(f)?"array":f===null?"null":RC(f)?"object":typeof f}function RC(f){return f!=null&&!Array.isArray(f)&&typeof f!="function"&&!(f instanceof String||f instanceof Number||f instanceof Boolean)&&typeof f=="object"}function OC(f){return typeof f=="string"||f instanceof String}function Rw(f){return typeof f=="number"||f instanceof Number}function Ow(f){return typeof f=="boolean"||f instanceof Boolean}const npe={"to-boolean":ii,"to-color":ju,"to-number":Pr,"to-string":si};class Tp{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=qx;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=Gd(h.expectedType.itemType,P)}else{if(!(P>0&&L1(c[1][0])))return null;T=Gd(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.`:MO(h[0],h[1],h[2],h[3]),!g))return new Ea(h[0]/255,h[1]/255,h[2]/255,h[3])}throw new il(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 il(`Could not convert ${JSON.stringify(h)} to number.`)}return this.type.kind==="formatted"?Md.fromString(tn(this.args[0].evaluate(c))):this.type.kind==="resolvedImage"?Gu.build(tn(this.args[0].evaluate(c))):this.type.kind==="array"?this.args.map(h=>h.evaluate(c)):tn(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 F0([{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 z0=["Unknown","Point","LineString","Polygon"];class Fw{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"?z0[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]=Ea.parse(c)),h}getConfig(c){return this.options?this.options.get(c):null}}class nc{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=nc.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=nc.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,te]of P){if(Array.isArray(Q)&&Q.length!==c.length-1)continue;R.push(Q),H++,F=new HC(h.registry,h.path,null,h.scope,void 0,h._scope,h.options,h.iconImageUseTheme);const re=[];let le=!1;for(let ue=1;uere)).map(sy).join(" | "),te=[];for(let re=1;reh;){if(g-h>600){const F=g-h+1,H=c-h+1,Q=Math.log(F),te=.5*Math.exp(2*Q/3),re=.5*Math.sqrt(Q*te*(F-te)/F)*(H-F/2<0?-1:1);TO(f,c,Math.max(h,Math.floor(c-H*te/F+re)),Math.min(g,Math.floor(c+(F-H)*te/F+re)),j)}const T=f[c];let P=h,R=g;for(zw(f,h,c),j(f[g],T)>0&&zw(f,h,g);P0;)R--}j(f[h],T)===0?zw(f,h,R):(R++,zw(f,R,g)),R<=c&&(h=R+1),c<=R&&(g=R-1)}}function zw(f,c,h){const g=f[c];f[c]=f[h],f[h]=g}function zC(f,c){return fc?1:0}function AO(f){let c=0;for(let h,g,j=0,T=f.length,P=T-1;j=c[2]||f[1]<=c[1]||f[3]>=c[3])}function ape(f,c,h){const g=f[0]-c[0],j=f[1]-c[1],T=f[0]-h[0],P=f[1]-h[1];return g*P-T*j===0&&g*T<=0&&j*P<=0}function OE(f,c,h){return c[1]>f[1]!=h[1]>f[1]&&f[0]<(h[0]-c[0])*(f[1]-c[1])/(h[1]-c[1])+c[0]}function D1(f,c,h=!1){let g=!1;for(let j=0,T=c.length;j0&&R<0||P<0&&R>0}function $w(f,c,h,g){return(j=[g[0]-h[0],g[1]-h[1]])[0]*(T=[c[0]-f[0],c[1]-f[1]])[1]-j[1]*T[0]!==0&&!(!EO(f,c,h,g)||!EO(h,g,f,c));var j,T}function FE(f){const c=new rs(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),h=new rs(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const g of f[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=f[0]-h[0]>j?-g:h[0]-f[0]>j?g:0;T===0&&(T=f[0]-h[2]>j?-g:h[2]-f[0]>j?g:0),f[0]+=T}Ap(c,f)}function $E(f,c,h,g){const j=Math.pow(2,g.z)*ry,T=[g.x*ry,g.y*ry],P=[];if(!f)return P;for(const R of f)for(const F of R){const H=[F.x+T[0],F.y+T[1]];Um(H,c,h,j),P.push(H)}return P}function qE(f,c,h,g){const j=Math.pow(2,g.z)*ry,T=[g.x*ry,g.y*ry],P=[];if(!f)return P;for(const F of f){const H=[];for(const Q of F){const te=[Q.x+T[0],Q.y+T[1]];Ap(c,te),H.push(te)}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)Um(H,c,h,j)}var R;return P}class ny{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(L1(c[1])){const g=c[1];if(g.type==="FeatureCollection")for(let j=0;jh)return $C(T,P,(h-(g-R))/R)}return c[c.length-1]}pointToSegmentDistance(c,h,g){let[j,T]=h,P=Xh(g[0]-j)*this.kx,R=(g[1]-T)*this.ky;if(P!==0||R!==0){const F=(Xh(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=Xh(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]):le>0&&(H+=te/this.kx*le,Q+=re/this.ky*le)),te=Xh(h[0]-H)*this.kx,re=(h[1]-Q)*this.ky;const ue=te*te+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;!HE(g[R],P[0])&&R<=F&&P.push(g[R]);for(let H=R+1;H<=F;H++)P.push(g[H]);return HE(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($C(R,F,(c-(j-H))/H)),j>=h)return T.push($C(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 Xh(c[0]-h[0])>=0&&Xh(c[0]-h[2])<=0&&c[1]>=h[1]&&c[1]<=h[3]}}function HE(f,c){return f[0]===c[0]&&f[1]===c[1]}function $C(f,c,h){const g=Xh(c[0]-f[0]);return[f[0]+g*h,f[1]+(c[1]-f[1])*h]}function Xh(f){for(;f<-180;)f+=360;for(;f>180;)f-=360;return f}class Uw{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 IO(f,c){return c.dist-f.dist}function LO(f){const c=[1/0,1/0,-1/0,-1/0];if(c.length!==f.length)return!1;for(let h=0;h=f[0]&&f[1]f[1])return[null,null];const h=$0(f);if(c){if(h===2)return[f,null];const g=Math.floor(h/2);return[[f[0],f[0]+g],[f[0]+g,f[1]]]}{if(h===1)return[f,null];const g=Math.floor(h/2)-1;return[[f[0],f[0]+g],[f[0]+g+1,f[1]]]}}function ay(f,c){const h=[1/0,1/0,-1/0,-1/0];if(!Ep(c,f.length))return h;for(let g=c[0];g<=c[1];++g)Ap(h,f[g]);return h}function Vw(f){const c=[1/0,1/0,-1/0,-1/0];for(let h=0;hc[2]&&(g=f[0]-c[2]),f[1]>c[3]&&(j=f[1]-c[3]),f[3]=g)return g;if(Bw(j,T)){if(zO(f,c))return 0}else if(zO(c,f))return 0;let P=g;for(const R of f)for(let F=0,H=R.length,Q=H-1;F=T)continue;const Q=H.range1;if($0(Q)<=R){if(!Ep(Q,f.length))return NaN;if(c){const te=ro(f,Q,h,g);if((T=Math.min(T,te))===0)return T}else for(let te=Q[0];te<=Q[1];++te){const re=dpe(f[te],h,g);if((T=Math.min(T,re))===0)return T}}else{const te=F1(Q,c);if(te[0]!==null){const re=z1(ay(f,te[0]),F,g);re=P)continue;const te=Q.range1,re=Q.range2;if($0(te)<=F&&$0(re)<=H){if(!Ep(te,f.length)||!Ep(re,h.length))return NaN;if(c&&g?P=Math.min(P,cpe(f,te,h,re,j)):c||g?c&&!g?P=Math.min(P,OO(h,re,f,te,j)):!c&&g&&(P=Math.min(P,OO(f,te,h,re,j))):P=Math.min(P,FO(f,te,h,re,j)),P===0)return P}else{const le=F1(te,c),ue=F1(re,g);qC(R,P,j,f,h,le[0],ue[0]),qC(R,P,j,f,h,le[0],ue[1]),qC(R,P,j,f,h,le[1],ue[0]),qC(R,P,j,f,h,le[1],ue[1])}}return P}function WE(f,c,h,g,j=1/0){let T=j;const P=ay(f,[0,f.length-1]);for(const R of h)if(!(T!==1/0&&z1(P,ay(R,[0,R.length-1]),g)>=T)&&(T=Math.min(T,BO(f,c,R,!0,g,T)),T===0))return T;return T}function UC(f,c,h,g,j=1/0){let T=j;const P=ay(f,[0,f.length-1]);for(const R of h){if(T!==1/0&&z1(P,Vw(R),g)>=T)continue;const F=hpe(f,c,R,g,T);if(isNaN(F))return F;if((T=Math.min(T,F))===0)return T}return T}function KE(f){return f==="Point"||f==="MultiPoint"||f==="LineString"||f==="MultiLineString"||f==="Polygon"||f==="MultiPolygon"}class q0{constructor(c,h){this.type=Pr,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(L1(c[1])){const g=c[1];if(g.type==="FeatureCollection"){for(let j=0;j{c&&!U0(h)&&(c=!1)}),c}function B1(f){if(f instanceof nc&&f.name==="feature-state")return!1;let c=!0;return f.eachChild(h=>{c&&!B1(h)&&(c=!1)}),c}function Af(f,c){if(f instanceof nc&&c.indexOf(f.name)>=0)return!1;let h=!0;return f.eachChild(g=>{h&&!Af(g,c)&&(h=!1)}),h}function $O(f,c,h){return[f,c,h].filter(Boolean).join("")}function ZE(f,c){switch(f){case"string":return tn(c);case"number":return+c;case"boolean":return!!c;case"color":return Ea.parse(c);case"formatted":return Md.fromString(tn(c));case"resolvedImage":return Gu.build(tn(c))}return c}function qO(f,c,h,g){return g!==void 0&&(f=g*Math.round(f/g)),c!==void 0&&fh&&(f=h),f}class $1{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 Nr))return h.error("Key name of 'config' expression must be a string literal.");let T,P=!0;const R=tn(j.value);if(c.length>=3){const F=h.parse(c[2],2);if(!(F instanceof Nr))return h.error("Scope of 'config' expression must be a string literal.");T=tn(F.value)}if(h.options){const F=$O(R,T,h._scope),H=h.options.get(F);H&&(P=U0(H.value||H.default))}return new $1(g,R,T,P)}evaluate(c){const h=$O(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 te=Q;if(T){const re=c.scope;c.scope=(re||"").split("").slice(1).join(""),te=T.evaluate(c),c.scope=re}return j&&(te=ZE(j,te)),te===void 0||R===void 0&&F===void 0&&H===void 0||(typeof te=="number"?te=qO(te,R,F,H):Array.isArray(te)&&(te=te.map(re=>typeof re=="number"?qO(re,R,F,H):re))),T!==void 0&&te!==void 0&&P&&!P.includes(te)&&(te=Q,j&&(te=ZE(j,te))),(j&&j!==this.type||te!==void 0&&!Ux(Oo(te),this.type))&&(te=ZE(this.type.kind,te)),te}eachChild(){}outputDefined(){return!1}serialize(){const c=["config",this.key];return this.scope&&c.concat(this.scope),c}}class VC{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 VC(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 HC{constructor(c,h=[],g,j=new R0,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 Yh(T,[j]):P==="coerce"?new Tp(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 Nr)&&T.type.kind!=="resolvedImage"&&YE(T)){const P=new Fw(this._scope,this.options,this.iconImageUseTheme);try{T=new Nr(T.type,T.evaluate(P))}catch(R){return this.error(R.message),null}}return T}return Tp.parse(["to-array",c],this)}return this.error(c===void 0?"'undefined' value invalid. Use null instead.":typeof c=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof c} instead.`)}concat(c,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 HC(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 $m(g,c))}checkSubtype(c,h){const g=Iw(c,h);return g&&this.error(g),g}}function YE(f){if(f instanceof VC)return YE(f.boundExpression);if(f instanceof nc&&f.name==="error"||f instanceof FC||f instanceof ny||f instanceof q0||f instanceof $1)return!1;const c=f instanceof Tp||f instanceof Yh;let h=!0;return f.eachChild(g=>{h=c?h&&YE(g):h&&g instanceof Nr}),!!h&&U0(f)&&Af(f,["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 GC(f,c){const h=f.length-1;let g,j,T=0,P=h,R=0;for(;T<=P;)if(R=Math.floor((T+P)/2),g=f[R],j=f[R+1],g<=c){if(R===h||cc))throw new il("Input is not a number.");P=R-1}return 0}class Hw{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,Pr);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 te=h.parse(F,Q,T);if(!te)return null;T=T||te.type,j.push([R,te])}return new Hw(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[GC(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 UO=.95047,VO=1.08883,HO=4/29,q1=6/29,GO=3*q1*q1,mpe=q1*q1*q1,ppe=Math.PI/180,fpe=180/Math.PI;function XE(f){return f>mpe?Math.pow(f,1/3):f/GO+HO}function QE(f){return f>q1?f*f*f:GO*(f-HO)}function Gw(f){return 255*(f<=.0031308?12.92*f:1.055*Math.pow(f,1/2.4)-.055)}function U1(f){return(f/=255)<=.04045?f/12.92:Math.pow((f+.055)/1.055,2.4)}function JE(f){const c=U1(f.r),h=U1(f.g),g=U1(f.b),j=XE((.4124564*c+.3575761*h+.1804375*g)/UO),T=XE((.2126729*c+.7151522*h+.072175*g)/1);return{l:116*T-16,a:500*(j-T),b:200*(T-XE((.0193339*c+.119192*h+.9503041*g)/VO)),alpha:f.a}}function WO(f){let c=(f.l+16)/116,h=isNaN(f.a)?c:c+f.a/500,g=isNaN(f.b)?c:c-f.b/200;return c=1*QE(c),h=UO*QE(h),g=VO*QE(g),new Ea(Gw(3.2404542*h-1.5371385*c-.4985314*g),Gw(-.969266*h+1.8760108*c+.041556*g),Gw(.0556434*h-.2040259*c+1.0572252*g),f.alpha)}function xpe(f,c,h){const g=c-f;return f+h*(g>180||g<-180?g-360*Math.round(g/360):g)}const Ww={forward:JE,reverse:WO,interpolate:function(f,c,h){return{l:sn(f.l,c.l,h),a:sn(f.a,c.a,h),b:sn(f.b,c.b,h),alpha:sn(f.alpha,c.alpha,h)}}},V1={forward:function(f){const{l:c,a:h,b:g}=JE(f),j=Math.atan2(g,h)*fpe;return{h:j<0?j+360:j,c:Math.sqrt(h*h+g*g),l:c,alpha:f.a}},reverse:function(f){const c=f.h*ppe,h=f.c;return WO({l:f.l,a:Math.cos(c)*h,b:Math.sin(c)*h,alpha:f.alpha})},interpolate:function(f,c,h){return{h:xpe(f.h,c.h,h),c:sn(f.c,c.c,h),l:sn(f.l,c.l,h),alpha:sn(f.alpha,c.alpha,h)}}};var eP=Object.freeze({__proto__:null,hcl:V1,lab:Ww});class Td{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=WC(h,c.base,g,j);else if(c.name==="linear")T=WC(h,1,g,j);else if(c.name==="cubic-bezier"){const P=c.controlPoints;T=new ni(P[0],P[1],P[2],P[3]).solve(WC(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,Pr),!T)return null;const R=[];let F=null;g==="interpolate-hcl"||g==="interpolate-lab"?F=ju: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(te,le,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 Td(F,g,j,T,R):h.error(`Type ${yl(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=GC(h,j),R=Td.interpolationFactor(this.interpolation,j,h[P],h[P+1]),F=g[P].evaluate(c),H=g[P+1].evaluate(c);return this.operator==="interpolate"?DC[this.type.kind.toLowerCase()](F,H,R):this.operator==="interpolate-hcl"?V1.reverse(V1.interpolate(V1.forward(F),V1.forward(H),R)):Ww.reverse(Ww.interpolate(Ww.forward(F),Ww.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;gIw(j,R.type));return new Kw(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 Gu&&!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 KC{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 il("Array index out of bounds: index exceeds array size");if(h!==Math.floor(h))throw new il("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 Yw{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,Pr),j=h.parse(c[2],2,Gd(h.expectedType||oi));return g&&j?new Yw(j.type.itemType,g,j):null}evaluate(c){const h=this.index.evaluate(c),g=this.input.evaluate(c);if(h<0)throw new il(`Array index out of bounds: ${h} < 0.`);if(h>g.length-1)throw new il(`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 il(`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 Xw{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?DE(g.type,[ii,si,Pr,qx,oi])?new Xw(g,j):(h.error(`Expected first argument to be of type boolean, string, number or null, but found ${yl(g.type)} instead`),null):null}evaluate(c){const h=this.needle.evaluate(c),g=this.haystack.evaluate(c);if(g==null)return!1;if(!I1(h,["boolean","string","number","null"]))throw new il(`Expected first argument to be of type boolean, string, number or null, but found ${yl(Oo(h))} instead.`);if(!I1(g,["string","array"]))throw new il(`Expected second argument to be of type array or string, but found ${yl(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 ZC{constructor(c,h,g){this.type=Pr,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(!DE(g.type,[ii,si,Pr,qx,oi]))return h.error(`Expected first argument to be of type boolean, string, number or null, but found ${yl(g.type)} instead`),null;if(c.length===4){const T=h.parse(c[3],3,Pr);return T?new ZC(g,j,T):null}return new ZC(g,j)}evaluate(c){const h=this.needle.evaluate(c),g=this.haystack.evaluate(c);if(!I1(h,["boolean","string","number","null"]))throw new il(`Expected first argument to be of type boolean, string, number or null, but found ${yl(Oo(h))} instead.`);if(!I1(g,["string","array"]))throw new il(`Expected second argument to be of type array or string, but found ${yl(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 tP{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 le=h.parse(te,H,j);if(!le)return null;j=j||le.type,P.push(le)}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 tP(g,j,R,T,P,F):null}evaluate(c){const h=this.input.evaluate(c);return(Ux(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 YC{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 Qw{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,Pr);if(!g||!j)return null;if(!DE(g.type,[Gd(oi),si,oi]))return h.error(`Expected first argument to be of type array or string, but found ${yl(g.type)} instead`),null;if(c.length===4){const T=h.parse(c[3],3,Pr);return T?new Qw(g.type,g,j,T):null}return new Qw(g.type,g,j)}evaluate(c){const h=this.input.evaluate(c),g=this.beginIndex.evaluate(c);if(!I1(h,["string","array"]))throw new il(`Expected first argument to be of type array or string, but found ${yl(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 sP{constructor(c,h){this.type=Gd(si),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,si),j=h.parse(c[2],2,si);return g&&j?new sP(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 KO(f,c){return f==="=="||f==="!="?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 ZO(f,c,h,g){return g.compare(c,h)===0}function V0(f,c,h){const g=f!=="=="&&f!=="!=";return class jGe{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(!KO(R,F.type))return P.concat(1).error(`"${R}" comparisons are not supported for type '${yl(F.type)}'.`);let H=P.parse(T[2],2,oi);if(!H)return null;if(!KO(R,H.type))return P.concat(2).error(`"${R}" comparisons are not supported for type '${yl(H.type)}'.`);if(F.type.kind!==H.type.kind&&F.type.kind!=="value"&&H.type.kind!=="value")return P.error(`Cannot compare types '${yl(F.type)}' and '${yl(H.type)}'.`);g&&(F.type.kind==="value"&&H.type.kind!=="value"?F=new Yh(H.type,[F]):F.type.kind!=="value"&&H.type.kind==="value"&&(H=new Yh(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,O0),!Q)return null}return new jGe(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 il(`Expected arguments for "${f}" 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=[f];return this.eachChild(P=>{T.push(P.serialize())}),T}}}const YO=V0("==",function(f,c,h){return c===h},ZO),XC=V0("!=",function(f,c,h){return c!==h},function(f,c,h,g){return!ZO(0,c,h,g)}),gpe=V0("<",function(f,c,h){return c",function(f,c,h){return c>h},function(f,c,h,g){return g.compare(c,h)>0}),ype=V0("<=",function(f,c,h){return c<=h},function(f,c,h,g){return g.compare(c,h)<=0}),vpe=V0(">=",function(f,c,h){return c>=h},function(f,c,h,g){return g.compare(c,h)>=0});class QC{constructor(c,h,g,j,T,P){this.type=si,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,Pr);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",si),!T))return null;let P=null;if(j.currency&&(P=h.parseObjectValue(j.currency,2,"currency",si),!P))return null;let R=null;if(j.unit&&(R=h.parseObjectValue(j.unit,2,"unit",si),!R))return null;let F=null;if(j["min-fraction-digits"]&&(F=h.parseObjectValue(j["min-fraction-digits"],2,"min-fraction-digits",Pr),!F))return null;let H=null;return j["max-fraction-digits"]&&(H=h.parseObjectValue(j["max-fraction-digits"],2,"max-fraction-digits",Pr),!H)?null:new QC(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 JC{constructor(c){this.type=Pr,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 ${yl(g.type)} instead.`),null):new JC(g):null}evaluate(c){const h=this.input.evaluate(c);if(typeof h=="string"||Array.isArray(h))return h.length;throw new il(`Expected value to be of type string or array, but found ${yl(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 QO(f){return function(){f=1831565813+(f|=0)|0;let c=Math.imul(f^f>>>15,1|f);return c=c+Math.imul(c^c>>>7,61|c)^c,((c^c>>>14)>>>0)/4294967296}}const H1={"==":YO,"!=":XC,">":XO,"<":gpe,">=":vpe,"<=":ype,array:Yh,at:Zw,"at-interpolated":Yw,boolean:Yh,case:YC,coalesce:Kw,collator:FC,format:F0,image:Wr,in:Xw,"index-of":ZC,interpolate:Td,"interpolate-hcl":Td,"interpolate-lab":Td,length:JC,let:KC,literal:Nr,match:tP,number:Yh,"number-format":QC,object:Yh,slice:Qw,step:Hw,string:Yh,"to-boolean":Tp,"to-color":Tp,"to-number":Tp,"to-string":Tp,var:VC,within:ny,distance:q0,config:$1,split:sP};function JO(f,[c,h,g,j]){c=c.evaluate(f),h=h.evaluate(f),g=g.evaluate(f);const T=j?j.evaluate(f):1,P=MO(c,h,g,T);if(P)throw new il(P);return new Ea(c/255,h/255,g/255,T)}function eF(f,[c,h,g,j]){c=c.evaluate(f),h=h.evaluate(f),g=g.evaluate(f);const T=j?j.evaluate(f):1,P=function(H,Q,te,re){return typeof H=="number"&&H>=0&&H<=360?typeof Q=="number"&&Q>=0&&Q<=100&&typeof te=="number"&&te>=0&&te<=100?re===void 0||typeof re=="number"&&re>=0&&re<=1?null:`Invalid hsla value [${[H,Q,te,re].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof re=="number"?[H,Q,te,re]:[H,Q,te]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof re=="number"?[H,Q,te,re]:[H,Q,te]).join(", ")}]: 'h' must be between 0 and 360.`}(c,h,g,T);if(P)throw new il(P);const R=`hsla(${c}, ${h}%, ${g}%, ${T})`,F=Ea.parse(R);if(!F)throw new il(`Failed to parse HSLA color: ${R}`);return F}function Jw(f,c){return f in c}function e3(f,c){const h=c[f];return h===void 0?null:h}function iy(f){return{type:f}}function t3(f){if(f instanceof $1)return new Set([f.key]);let c=new Set;return f.eachChild(h=>{c=new Set([...c,...t3(h)])}),c}function s3(f){if(f instanceof nc&&f.name==="is-active-floor")return!0;let c=!1;return f.eachChild(h=>{!c&&s3(h)&&(c=!0)}),c}function tF(f){return{result:"success",value:f}}function oy(f){return{result:"error",value:f}}function e2(f,c){return!!f&&!!f.parameters&&f.parameters.indexOf(c)>-1}function r3(f){return f["property-type"]==="data-driven"}function sF(f){return e2(f.expression,"measure-light")}function rP(f){return e2(f.expression,"zoom")}function n3(f){return!!f.expression&&f.expression.interpolated}function nP(f){return typeof f=="object"&&f!==null&&!Array.isArray(f)}function rF(f){return f}function nF(f,c){const h=c.type==="color",g=f.stops&&typeof f.stops[0][0]=="object",j=g||!(g||f.property!==void 0),T=f.type||(n3(c)?"exponential":"interval");if(h&&((f=Object.assign({},f)).stops&&(f.stops=f.stops.map(H=>[H[0],Ea.parse(H[1])])),f.default=Ea.parse(f.default?f.default:c.default)),f.colorSpace&&f.colorSpace!=="rgb"&&!eP[f.colorSpace])throw new Error(`Unknown color space: ${f.colorSpace}`);let P,R,F;if(T==="exponential")P=aF;else if(T==="interval")P=bpe;else if(T==="categorical"){P=_pe,R=Object.create(null);for(const H of f.stops)R[H[0]]=H[1];F=typeof f.stops[0][0]}else{if(T!=="identity")throw new Error(`Unknown function type "${T}"`);P=iF}if(g){const H={},Q=[];for(let le=0;lele[0]),evaluate:({zoom:le},ue)=>aF({stops:te,base:f.base},c,le).evaluate(le,ue)}}if(j){const H=T==="exponential"?{name:"exponential",base:f.base!==void 0?f.base:1}:null;return{kind:"camera",interpolationType:H,interpolationFactor:Td.interpolationFactor.bind(void 0,H),zoomStops:f.stops.map(Q=>Q[0]),evaluate:({zoom:Q})=>P(f,c,Q,R,F)}}return{kind:"source",evaluate(H,Q){const te=Q&&Q.properties?Q.properties[f.property]:void 0;return te===void 0?Ef(f.default,c.default):P(f,c,te,R,F)}}}function Ef(f,c,h){return f!==void 0?f:c!==void 0?c:h!==void 0?h:void 0}function _pe(f,c,h,g,j){return Ef(typeof h===j?g[h]:void 0,f.default,c.default)}function bpe(f,c,h){if(!Rw(h))return Ef(f.default,c.default);const g=f.stops.length;if(g===1||h<=f.stops[0][0])return f.stops[0][1];if(h>=f.stops[g-1][0])return f.stops[g-1][1];const j=GC(f.stops.map(T=>T[0]),h);return f.stops[j][1]}function aF(f,c,h){const g=f.base!==void 0?f.base:1;if(!Rw(h))return Ef(f.default,c.default);const j=f.stops.length;if(j===1||h<=f.stops[0][0])return f.stops[0][1];if(h>=f.stops[j-1][0])return f.stops[j-1][1];const T=GC(f.stops.map(Q=>Q[0]),h),P=function(Q,te,re,le){const ue=le-re,ge=Q-re;return ue===0?0:te===1?ge/ue:(Math.pow(te,ge)-1)/(Math.pow(te,ue)-1)}(h,g,f.stops[T][0],f.stops[T+1][0]),R=f.stops[T][1],F=f.stops[T+1][1];let H=DC[c.type]||rF;if(f.colorSpace&&f.colorSpace!=="rgb"){const Q=eP[f.colorSpace];H=(te,re)=>Q.reverse(Q.interpolate(Q.forward(te),Q.forward(re),P))}return typeof R.evaluate=="function"?{evaluate(...Q){const te=R.evaluate.apply(void 0,Q),re=F.evaluate.apply(void 0,Q);if(te!==void 0&&re!==void 0)return H(te,re,P)}}:H(R,F,P)}function iF(f,c,h){return c.type==="color"?h=Ea.parse(h):c.type==="formatted"?h=Md.fromString(h.toString()):c.type==="resolvedImage"?h=Gu.build(h.toString()):Dw(h)===c.type||c.type==="enum"&&c.values[h]||(h=void 0),Ef(h,f.default,c.default)}nc.register(H1,{error:[{kind:"error"},[si],(f,[c])=>{throw new il(c.evaluate(f))}],typeof:[si,[oi],(f,[c])=>yl(Oo(c.evaluate(f)))],"to-rgba":[Gd(Pr,4),[ju],(f,[c])=>c.evaluate(f).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Gd(Pr,4),[ju],(f,[c])=>c.evaluate(f).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[ju,[Pr,Pr,Pr],JO],rgba:[ju,[Pr,Pr,Pr,Pr],JO],hsl:[ju,[Pr,Pr,Pr],eF],hsla:[ju,[Pr,Pr,Pr,Pr],eF],has:{type:ii,overloads:[[[si],(f,[c])=>Jw(c.evaluate(f),f.properties())],[[si,ty],(f,[c,h])=>Jw(c.evaluate(f),h.evaluate(f))]]},get:{type:oi,overloads:[[[si],(f,[c])=>e3(c.evaluate(f),f.properties())],[[si,ty],(f,[c,h])=>e3(c.evaluate(f),h.evaluate(f))]]},"feature-state":[oi,[si],(f,[c])=>e3(c.evaluate(f),f.featureState||{})],properties:[ty,[],f=>f.properties()],"geometry-type":[si,[],f=>f.geometryType()],worldview:[si,[],f=>f.globals.worldview||""],"is-active-floor":[ii,iy(si),(f,c)=>{if(!(f.globals&&f.globals.activeFloors&&f.globals.activeFloors.size>0))return!1;if(c.length===0)return!0;const h=f.globals.activeFloors;return c.some(g=>{const j=g.evaluate(f);return h.has(j)})}],id:[oi,[],f=>f.id()],zoom:[Pr,[],f=>f.globals.zoom],pitch:[Pr,[],f=>f.globals.pitch||0],"distance-from-center":[Pr,[],f=>f.distanceFromCenter()],"measure-light":[Pr,[si],(f,[c])=>f.measureLight(c.evaluate(f))],"heatmap-density":[Pr,[],f=>f.globals.heatmapDensity||0],"line-progress":[Pr,[],f=>f.globals.lineProgress||0],"raster-value":[Pr,[],f=>f.globals.rasterValue||0],"raster-particle-speed":[Pr,[],f=>f.globals.rasterParticleSpeed||0],"sky-radial-progress":[Pr,[],f=>f.globals.skyRadialProgress||0],accumulated:[oi,[],f=>f.globals.accumulated===void 0?null:f.globals.accumulated],"+":[Pr,iy(Pr),(f,c)=>{let h=0;for(const g of c)h+=g.evaluate(f);return h}],"*":[Pr,iy(Pr),(f,c)=>{let h=1;for(const g of c)h*=g.evaluate(f);return h}],"-":{type:Pr,overloads:[[[Pr,Pr],(f,[c,h])=>c.evaluate(f)-h.evaluate(f)],[[Pr],(f,[c])=>-c.evaluate(f)]]},"/":[Pr,[Pr,Pr],(f,[c,h])=>c.evaluate(f)/h.evaluate(f)],"%":[Pr,[Pr,Pr],(f,[c,h])=>c.evaluate(f)%h.evaluate(f)],ln2:[Pr,[],()=>Math.LN2],pi:[Pr,[],()=>Math.PI],e:[Pr,[],()=>Math.E],"^":[Pr,[Pr,Pr],(f,[c,h])=>Math.pow(c.evaluate(f),h.evaluate(f))],sqrt:[Pr,[Pr],(f,[c])=>Math.sqrt(c.evaluate(f))],log10:[Pr,[Pr],(f,[c])=>Math.log(c.evaluate(f))/Math.LN10],ln:[Pr,[Pr],(f,[c])=>Math.log(c.evaluate(f))],log2:[Pr,[Pr],(f,[c])=>Math.log2(c.evaluate(f))],sin:[Pr,[Pr],(f,[c])=>Math.sin(c.evaluate(f))],cos:[Pr,[Pr],(f,[c])=>Math.cos(c.evaluate(f))],tan:[Pr,[Pr],(f,[c])=>Math.tan(c.evaluate(f))],asin:[Pr,[Pr],(f,[c])=>Math.asin(c.evaluate(f))],acos:[Pr,[Pr],(f,[c])=>Math.acos(c.evaluate(f))],atan:[Pr,[Pr],(f,[c])=>Math.atan(c.evaluate(f))],min:[Pr,iy(Pr),(f,c)=>Math.min(...c.map(h=>h.evaluate(f)))],max:[Pr,iy(Pr),(f,c)=>Math.max(...c.map(h=>h.evaluate(f)))],abs:[Pr,[Pr],(f,[c])=>Math.abs(c.evaluate(f))],round:[Pr,[Pr],(f,[c])=>{const h=c.evaluate(f);return h<0?-Math.round(-h):Math.round(h)}],floor:[Pr,[Pr],(f,[c])=>Math.floor(c.evaluate(f))],ceil:[Pr,[Pr],(f,[c])=>Math.ceil(c.evaluate(f))],"filter-==":[ii,[si,oi],(f,[c,h])=>f.properties()[c.value]===h.value],"filter-id-==":[ii,[oi],(f,[c])=>f.id()===c.value],"filter-type-==":[ii,[si],(f,[c])=>f.geometryType()===c.value],"filter-<":[ii,[si,oi],(f,[c,h])=>{const g=f.properties()[c.value],j=h.value;return typeof g==typeof j&&g{const h=f.id(),g=c.value;return typeof h==typeof g&&h":[ii,[si,oi],(f,[c,h])=>{const g=f.properties()[c.value],j=h.value;return typeof g==typeof j&&g>j}],"filter-id->":[ii,[oi],(f,[c])=>{const h=f.id(),g=c.value;return typeof h==typeof g&&h>g}],"filter-<=":[ii,[si,oi],(f,[c,h])=>{const g=f.properties()[c.value],j=h.value;return typeof g==typeof j&&g<=j}],"filter-id-<=":[ii,[oi],(f,[c])=>{const h=f.id(),g=c.value;return typeof h==typeof g&&h<=g}],"filter->=":[ii,[si,oi],(f,[c,h])=>{const g=f.properties()[c.value],j=h.value;return typeof g==typeof j&&g>=j}],"filter-id->=":[ii,[oi],(f,[c])=>{const h=f.id(),g=c.value;return typeof h==typeof g&&h>=g}],"filter-has":[ii,[oi],(f,[c])=>c.value in f.properties()],"filter-has-id":[ii,[],f=>f.id()!==null&&f.id()!==void 0],"filter-type-in":[ii,[Gd(si)],(f,[c])=>c.value.indexOf(f.geometryType())>=0],"filter-id-in":[ii,[Gd(oi)],(f,[c])=>c.value.indexOf(f.id())>=0],"filter-in-small":[ii,[si,Gd(oi)],(f,[c,h])=>h.value.indexOf(f.properties()[c.value])>=0],"filter-in-large":[ii,[si,Gd(oi)],(f,[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}(f.properties()[c.value],h.value,0,h.value.length-1)],all:{type:ii,overloads:[[[ii,ii],(f,[c,h])=>c.evaluate(f)&&h.evaluate(f)],[iy(ii),(f,c)=>{for(const h of c)if(!h.evaluate(f))return!1;return!0}]]},any:{type:ii,overloads:[[[ii,ii],(f,[c,h])=>c.evaluate(f)||h.evaluate(f)],[iy(ii),(f,c)=>{for(const h of c)if(h.evaluate(f))return!0;return!1}]]},"!":[ii,[ii],(f,[c])=>!c.evaluate(f)],"is-supported-script":[ii,[si],(f,[c])=>{const h=f.globals&&f.globals.isSupportedScript;return!h||h(c.evaluate(f))}],upcase:[si,[si],(f,[c])=>c.evaluate(f).toUpperCase()],downcase:[si,[si],(f,[c])=>c.evaluate(f).toLowerCase()],concat:[si,iy(oi),(f,c)=>c.map(h=>tn(h.evaluate(f))).join("")],"resolved-locale":[si,[O0],(f,[c])=>c.evaluate(f).resolvedLocale()],random:[Pr,[Pr,Pr,oi],(f,c)=>{const[h,g,j]=c.map(P=>P.evaluate(f));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(te)).join(", ")}, but found ${JSON.stringify(Q)} instead.`);return Q}catch(Q){const te=Q;return this._warningHistory[te.message]||(this._warningHistory[te.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${te.message}`)),this._defaultValue}}}function t2(f){return Array.isArray(f)&&f.length>0&&typeof f[0]=="string"&&f[0]in H1}function ly(f,c,h,g,j){const T=new HC(H1,[],c?function(R){const F={color:ju,string:si,number:Pr,enum:si,boolean:ii,formatted:Ew,resolvedImage:Pw};return R.type==="array"?Gd(F[R.value]||oi,R.length):F[R.type]}(c):void 0,void 0,void 0,h,g,j),P=T.parse(f,void 0,void 0,void 0,c&&c.type==="string"?{typeAnnotation:"coerce"}:void 0);return P?tF(new a3(P,c,h,g,j)):oy(T.errors)}class G1{constructor(c,h,g,j){this.kind=c,this._styleExpression=h,this.isLightConstant=g,this.isLineProgressConstant=j,this.isStateDependent=c!=="constant"&&!B1(h.expression),this.configDependencies=t3(h.expression),this.isIndoorDependent=s3(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 H0{constructor(c,h,g,j,T,P){this.kind=c,this.zoomStops=g,this._styleExpression=h,this.isStateDependent=c!=="camera"&&!B1(h.expression),this.isIndoorDependent=s3(h.expression),this.isLightConstant=T,this.isLineProgressConstant=P,this.configDependencies=t3(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?Td.interpolationFactor(this.interpolationType,c,h,g):0}}function aP(f,c,h,g,j){if((f=ly(f,c,h,g,j)).result==="error")return f;const T=f.value.expression,P=U0(T);if(!P&&!r3(c))return oy([new $m("","data expressions not supported")]);const R=Af(T,["zoom","pitch","distance-from-center"]);if(!R&&!rP(c))return oy([new $m("","zoom expressions not supported")]);const F=Af(T,["measure-light"]);if(!F&&!sF(c))return oy([new $m("","measure-light expression not supported")]);const H=Af(T,["line-progress"]);if(!H&&!function(re){return e2(re.expression,"line-progress")}(c))return oy([new $m("","line-progress expression not supported")]);const Q=c.expression&&c.expression.relaxZoomRestriction,te=Pp(T);return te||R||Q?te instanceof $m?oy([te]):te instanceof Td&&!n3(c)?oy([new $m("",'"interpolate" expressions cannot be used with this property')]):tF(te?new H0(P&&H?"camera":"composite",f.value,te.labels,te instanceof Td?te.interpolation:void 0,F,H):new G1(P&&H?"constant":"source",f.value,F,H)):oy([new $m("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class i3{constructor(c,h){this._parameters=c,this._specification=h,Object.assign(this,nF(this._parameters,this._specification))}static deserialize(c){return new i3(c._parameters,c._specification)}static serialize(c){return{_parameters:c._parameters,_specification:c._specification}}}function Pp(f){let c=null;if(f instanceof KC)c=Pp(f.result);else if(f instanceof Kw){for(const h of f.args)if(c=Pp(h),c)break}else(f instanceof Hw||f instanceof Td)&&f.input instanceof nc&&f.input.name==="zoom"&&(c=f);return c instanceof $m||f.eachChild(h=>{const g=Pp(h);g instanceof $m?c=g:c&&g&&c!==g&&(c=new $m("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),c}var iP,oF,s2=function(){if(oF)return iP;oF=1,iP=c;var f=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[ge+0]&&T>=re[ge+1])?(F[ue]=!0,R.push(te[ue])):F[ue]=!1}}},c.prototype._forEachCell=function(h,g,j,T,P,R,F,H){for(var Q=this._convertToCellCoord(h),te=this._convertToCellCoord(g),re=this._convertToCellCoord(j),le=this._convertToCellCoord(T),ue=Q;ue<=re;ue++)for(var ge=te;ge<=le;ge++){var ke=this.d*ge+ue;if((!H||H(this._convertFromCellCoord(ue),this._convertFromCellCoord(ge),this._convertFromCellCoord(ue+1),this._convertFromCellCoord(ge+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=f+this.cells.length+1+1,j=0,T=0;T=0||(j[T]=Hx(f[T],c)));f instanceof Error&&(j.message=f.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 f)}function cy(f){if(f==null||typeof f=="boolean"||typeof f=="number"||typeof f=="string"||f instanceof Boolean||f instanceof Number||f instanceof String||f instanceof Date||f instanceof RegExp||r2(f)||f instanceof ImageBitmap||ArrayBuffer.isView(f)||f instanceof ImageData)return f;if(Array.isArray(f))return f.map(cy);if(typeof f=="object"){const c=f.$name||"Object";if(c==="Map"){const j=f.entries||[],T=new Map;for(let P=0;Pf>=1536&&f<=1791,o3=f=>f>=1872&&f<=1919,l3=f=>f>=2208&&f<=2303,c3=f=>f>=11904&&f<=12031,Gx=f=>f>=12032&&f<=12255,oP=f=>f>=12272&&f<=12287,n2=f=>f>=12288&&f<=12351,a2=f=>f>=12352&&f<=12447,W0=f=>f>=12448&&f<=12543,lP=f=>f>=12544&&f<=12591,d3=f=>f>=12704&&f<=12735,Pf=f=>f>=12736&&f<=12783,cF=f=>f>=12784&&f<=12799,dF=f=>f>=12800&&f<=13055,uF=f=>f>=13056&&f<=13311,cP=f=>f>=13312&&f<=19903,u3=f=>f>=19968&&f<=40959,i2=f=>f>=40960&&f<=42127,dP=f=>f>=42128&&f<=42191,uP=f=>f>=44032&&f<=55215,h3=f=>f>=63744&&f<=64255,hP=f=>f>=64336&&f<=65023,hF=f=>f>=65040&&f<=65055,mP=f=>f>=65072&&f<=65103,mF=f=>f>=65104&&f<=65135,pP=f=>f>=65136&&f<=65279,fP=f=>f>=65280&&f<=65519;function xP(f){for(const c of f)if(gP(c.charCodeAt(0)))return!0;return!1}function wpe(f){for(const c of f)if(!jpe(c.charCodeAt(0)))return!1;return!0}function jpe(f){return!(lF(f)||o3(f)||l3(f)||hP(f)||pP(f))}function Npe(f){return!(f<11904||!(d3(f)||lP(f)||mP(f)||h3(f)||uF(f)||c3(f)||Pf(f)||n2(f)||cP(f)||u3(f)||dF(f)||fP(f)||a2(f)||oP(f)||Gx(f)||cF(f)||W0(f)||hF(f)||dP(f)||i2(f)))}function gP(f){return!(f!==746&&f!==747&&(f<4352||!(d3(f)||lP(f)||mP(f)&&!(f>=65097&&f<=65103)||h3(f)||uF(f)||c3(f)||Pf(f)||!(!n2(f)||f>=12296&&f<=12305||f>=12308&&f<=12319||f===12336)||cP(f)||u3(f)||dF(f)||(c=>c>=12592&&c<=12687)(f)||(c=>c>=43360&&c<=43391)(f)||(c=>c>=55216&&c<=55295)(f)||(c=>c>=4352&&c<=4607)(f)||uP(f)||a2(f)||oP(f)||(c=>c>=12688&&c<=12703)(f)||Gx(f)||cF(f)||W0(f)&&f!==12540||!(!fP(f)||f===65288||f===65289||f===65293||f>=65306&&f<=65310||f===65339||f===65341||f===65343||f>=65371&&f<=65503||f===65507||f>=65512&&f<=65519)||!(!mF(f)||f>=65112&&f<=65118||f>=65123&&f<=65126)||(c=>c>=5120&&c<=5759)(f)||(c=>c>=6320&&c<=6399)(f)||hF(f)||(c=>c>=19904&&c<=19967)(f)||i2(f)||dP(f))))}function pF(f){return f===12312||f===12313||f===12316||f===12540||f===12448}function K0(f){return!(gP(f)||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)||n2(c)||W0(c)||(h=>h>=57344&&h<=63743)(c)||mP(c)||mF(c)||fP(c)||c===8734||c===8756||c===8757||c>=9984&&c<=10087||c>=10102&&c<=10131||c===65532||c===65533)}(f))}function fF(f){return lF(f)||o3(f)||l3(f)||hP(f)||pP(f)}function yP(f){return f>=1424&&f<=2303||hP(f)||pP(f)}function m3(f,c){return!(!c&&yP(f)||f>=2304&&f<=3583||f>=3840&&f<=4255||(h=>h>=6016&&h<=6143)(f))}function kpe(f){for(const c of f)if(yP(c.charCodeAt(0)))return!0;return!1}const yh={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let If=null,Wd=yh.unavailable,Qh=null;const xF=function(f){f&&typeof f=="string"&&f.indexOf("NetworkError")>-1&&(Wd=yh.error),If&&If(f)};function vP(){_P.fire(new Jr("pluginStateChange",{pluginStatus:Wd,pluginURL:Qh}))}const _P=new Ai,bP=function(){return Wd},gF=function(){if(Wd!==yh.deferred||!Qh)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Wd=yh.loading,vP(),Qh&&Jg({url:Qh},f=>{f?xF(f):(Wd=yh.loaded,vP())})},Wx={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Wd===yh.loaded||Wx.applyArabicShaping!=null,isLoading:()=>Wd===yh.loading,setState(f){Wd=f.pluginStatus,Qh=f.pluginURL},isParsing:()=>Wd===yh.parsing,isParsed:()=>Wd===yh.parsed,getPluginURL:()=>Qh},yF=function(){Wx.isLoading()||Wx.isLoaded()||bP()!=="deferred"||gF()};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(!m3(j.charCodeAt(0),g))return!1;return!0}(c,Wx.isLoaded())}}class K1{constructor(c,h,g,j,T){this.property=c,this.value=h,this.expression=function(P,R,F,H,Q){if(nP(P))return new i3(P,R);if(t2(P)||Array.isArray(P)&&P.length>0){const te=aP(P,R,F,H,Q);if(te.result==="error")throw new Error(te.value.map(re=>`${re.key}: ${re.message}`).join(", "));return te.value}{let te=P;return typeof P=="string"&&R.type==="color"&&(te=Ea.parse(P)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>te}}}(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 p3{constructor(c,h,g,j){this.property=c,this.value=new K1(c,void 0,h,g,j)}transitioned(c,h){return new Z1(this.property,this.value,h,Object.assign({},c.transition,this.transition),c.now)}untransitioned(){return new Z1(this.property,this.value,null,{},0)}}class f3{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 or(this._values[c].value.value)}setValue(c,h){this._values.hasOwnProperty(c)||(this._values[c]=new p3(this._values[c].property,this._scope,this._options,this._iconImageUseTheme)),this._values[c].value=new K1(this._values[c].property,h===null?void 0:or(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 or(this._values[c].transition)}setTransition(c,h){this._values.hasOwnProperty(c)||(this._values[c]=new p3(this._values[c].property)),this._values[c].transition=or(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 wP(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 wP(this._properties);for(const h of Object.keys(this._values))c._values[h]=this._values[h].untransitioned();return c}isIndoorDependent(){return this._isIndoorDependent}}class Z1{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 vF(f){return f instanceof Number||f instanceof String||f instanceof Boolean?f.valueOf():f}function x3(f){if(Array.isArray(f))return f.map(x3);if(f instanceof Object&&!(f instanceof Number||f instanceof String||f instanceof Boolean)){const c={};for(const h in f)c[h]=x3(f[h]);return c}return vF(f)}function NP(f){if(f===!0||f===!1)return!0;if(!Array.isArray(f)||f.length===0)return!1;switch(f[0]){case"has":return f.length>=2&&f[1]!=="$id"&&f[1]!=="$type";case"in":return f.length>=3&&(typeof f[1]!="string"||Array.isArray(f[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return f.length!==3||Array.isArray(f[1])||Array.isArray(f[2]);case"any":case"all":for(const c of f.slice(1))if(!NP(c)&&typeof c!="boolean")return!1;return!0;default:return!0}}function g3(f,c="",h=null,g="fill"){if(f==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};NP(f)||(f=y3(f));const j=f;let T=!0;try{T=function(Q){if(!X1(Q))return Q;let te=x3(Q);return bF(te),te=_F(te),te}(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=Gt[`filter_${g}`];const Q=ly(T,R,c,h);if(Q.result==="error")throw new Error(Q.value.map(te=>`${te.key}: ${te.message}`).join(", "));P=(te,re,le)=>Q.value.evaluate(te,re,{},le)}let F=null,H=null;if(T!==j){const Q=ly(j,R,c,h);if(Q.result==="error")throw new Error(Q.value.map(te=>`${te.key}: ${te.message}`).join(", "));F=(te,re,le,ue,ge)=>Q.value.evaluate(te,re,{},le,void 0,void 0,ue,ge),H=!U0(Q.value.expression)}return{filter:P,dynamicFilter:F||void 0,needGeometry:jF(T),needFeature:!!H}}function _F(f){if(!Array.isArray(f))return f;const c=function(h){if(wF.has(h[0])){for(let g=1;g_F(h))}function bF(f){let c=!1;const h=[];if(f[0]==="case"){for(let g=1;g",">=","<","<=","to-boolean"]);function Spe(f,c){return fc?1:0}function jF(f){if(!Array.isArray(f))return!1;if(f[0]==="within"||f[0]==="distance")return!0;for(let c=1;c"||c==="<="||c===">="?v3(f[1],f[2],c):c==="any"?(h=f.slice(1),["any"].concat(h.map(y3))):c==="all"?["all"].concat(f.slice(1).map(y3)):c==="none"?["all"].concat(f.slice(1).map(y3).map(o2)):c==="in"?kP(f[1],f.slice(2)):c==="!in"?o2(kP(f[1],f.slice(2))):c==="has"?Zx(f[1]):c!=="!has"||o2(Zx(f[1]));var h}function v3(f,c,h){switch(f){case"$type":return[`filter-type-${h}`,c];case"$id":return[`filter-id-${h}`,c];default:return[`filter-${h}`,f,c]}}function kP(f,c){if(c.length===0)return!1;switch(f){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",f,["literal",c.sort(Spe)]]:["filter-in-small",f,["literal",c]]}}function Zx(f){switch(f){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",f]}}function o2(f){return["!",f]}const l2="";function Y0(f,c){return c?`${f}${l2}${c}`:f}function NF(f){const c=f.indexOf(l2);return c>=0?f.slice(c+1):""}let kF;const SP=()=>kF||(kF=new Xi({"icon-size":new Vs(Gt.layout_symbol["icon-size"]),"icon-image":new Vs(Gt.layout_symbol["icon-image"]),"icon-rotate":new Vs(Gt.layout_symbol["icon-rotate"]),"icon-offset":new Vs(Gt.layout_symbol["icon-offset"]),"text-size":new Vs(Gt.layout_symbol["text-size"]),"text-rotate":new Vs(Gt.layout_symbol["text-rotate"]),"text-offset":new Vs(Gt.layout_symbol["text-offset"])}));let CP;const MP=()=>CP||(CP=new Xi({"icon-opacity":new Vs(Gt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Vs(Gt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Vs(Gt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Vs(Gt.paint_symbol["text-emissive-strength"]),"icon-color":new Vs(Gt.paint_symbol["icon-color"]),"icon-halo-color":new Vs(Gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Vs(Gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Vs(Gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Vs(Gt.paint_symbol["icon-translate"]),"text-opacity":new Vs(Gt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Vs(Gt.paint_symbol["text-occlusion-opacity"]),"text-color":new Vs(Gt.paint_symbol["text-color"],{runtimeType:ju,getOverride:f=>f.textColor,hasOverride:f=>!!f.textColor}),"text-halo-color":new Vs(Gt.paint_symbol["text-halo-color"]),"text-halo-width":new Vs(Gt.paint_symbol["text-halo-width"]),"text-halo-blur":new Vs(Gt.paint_symbol["text-halo-blur"]),"text-translate":new Vs(Gt.paint_symbol["text-translate"]),"symbol-z-offset":new Vs(Gt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"})}));class Cpe{constructor(c,h,g,j,T,P){this._conditionSpec=c,this._propertiesSpec=g;const R=ly(c,Gt.appearance.condition);if(R.result==="success"&&(this.condition=R.value),this.name=h,g){this.layoutProperties=new Kx(SP()),this.unevaluatedLayout=new jP(SP(),j,T,P),this.paintProperties=new Kx(MP()),this.unevaluatedPaint=new jP(MP(),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 TP="-transition",Mpe=new Set(["fill","line","background","hillshade","raster"]);class Kd extends Ai{constructor(c,h,g,j,T,P){if(super(),this.id=c.id,this.fqid=Y0(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=ly(this.filter,Gt[`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 jP(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 f3(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 Kx(h.paint)}}}onAdd(c){}onRemove(c){}isDraped(c){return!this.is3D(!0)&&Mpe.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 Cpe(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(TP)?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(TP)){const te=c.slice(0,-11);return j[te]&&g.setTransition(te,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())),xs(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 Z0&&r3(h.property.specification)&&(h.value.kind==="source"||h.value.kind==="composite")&&h.value.isStateDependent)return!0}for(const c of this.appearances)if(!B1(c.condition.expression))return!0;return!1}compileFilter(c){this._filterCompiled||(this._featureFilter=g3(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 _3={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class c2{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 Tpe=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=Tpe),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 la(f,c=1){let h=0,g=0;return{members:f.map(j=>{const T=_3[j.type].BYTES_PER_ELEMENT,P=h=SF(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:SF(h,Math.max(g,c)),alignment:c}}function SF(f,c){return Math.ceil(f/c)*c}class vh 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}}vh.prototype.bytesPerElement=4,xr(vh,"StructArrayLayout2i4");class Lf 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}}Lf.prototype.bytesPerElement=6,xr(Lf,"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,xr(id,"StructArrayLayout2i2ui8");class Jh 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}}Jh.prototype.bytesPerElement=4,xr(Jh,"StructArrayLayout1f4");class AP 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}}AP.prototype.bytesPerElement=8,xr(AP,"StructArrayLayout2i1f8");class EP 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}}EP.prototype.bytesPerElement=8,xr(EP,"StructArrayLayout3i8");class PP 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}}PP.prototype.bytesPerElement=8,xr(PP,"StructArrayLayout4i8");class IP 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}}IP.prototype.bytesPerElement=10,xr(IP,"StructArrayLayout5i10");class d2 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,te=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[te+2]=F,c}}d2.prototype.bytesPerElement=12,xr(d2,"StructArrayLayout2i4ub1f12");class Vm 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}}Vm.prototype.bytesPerElement=12,xr(Vm,"StructArrayLayout3f12");class Df 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}}Df.prototype.bytesPerElement=12,xr(Df,"StructArrayLayout4ui1f12");class Q1 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}}Q1.prototype.bytesPerElement=8,xr(Q1,"StructArrayLayout4ui8");class b3 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}}b3.prototype.bytesPerElement=12,xr(b3,"StructArrayLayout6i12");class LP 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,te,re){const le=this.length;return this.resize(le+1),this.emplace(le,c,h,g,j,T,P,R,F,H,Q,te,re)}emplace(c,h,g,j,T,P,R,F,H,Q,te,re,le){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]=te,this.int16[ue+10]=re,this.int16[ue+11]=le,c}}LP.prototype.bytesPerElement=24,xr(LP,"StructArrayLayout4i4ui4i24");class DP 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}}DP.prototype.bytesPerElement=20,xr(DP,"StructArrayLayout3i3f20");class Yx 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}}Yx.prototype.bytesPerElement=16,xr(Yx,"StructArrayLayout4f16");class u2 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}}u2.prototype.bytesPerElement=4,xr(u2,"StructArrayLayout1ul4");class Hm 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}}Hm.prototype.bytesPerElement=4,xr(Hm,"StructArrayLayout2ui4");class w3 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,te,re,le){const ue=this.length;return this.resize(ue+1),this.emplace(ue,c,h,g,j,T,P,R,F,H,Q,te,re,le)}emplace(c,h,g,j,T,P,R,F,H,Q,te,re,le,ue){const ge=20*c,ke=10*c;return this.int16[ge+0]=h,this.int16[ge+1]=g,this.int16[ge+2]=j,this.int16[ge+3]=T,this.int16[ge+4]=P,this.float32[ke+3]=R,this.float32[ke+4]=F,this.float32[ke+5]=H,this.float32[ke+6]=Q,this.int16[ge+14]=te,this.uint32[ke+8]=re,this.uint16[ge+18]=le,this.uint16[ge+19]=ue,c}}w3.prototype.bytesPerElement=40,xr(w3,"StructArrayLayout5i4f1i1ul2ui40");class h2 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}}h2.prototype.bytesPerElement=16,xr(h2,"StructArrayLayout3i2i2i16");class RP 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}}RP.prototype.bytesPerElement=16,xr(RP,"StructArrayLayout2f1f2i16");class m2 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}}m2.prototype.bytesPerElement=20,xr(m2,"StructArrayLayout2ub4f20");class To 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}}To.prototype.bytesPerElement=6,xr(To,"StructArrayLayout3ui6");class j3 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,te,re,le,ue,ge,ke,Ee,He,$e,rt,it){const lt=this.length;return this.resize(lt+1),this.emplace(lt,c,h,g,j,T,P,R,F,H,Q,te,re,le,ue,ge,ke,Ee,He,$e,rt,it)}emplace(c,h,g,j,T,P,R,F,H,Q,te,re,le,ue,ge,ke,Ee,He,$e,rt,it,lt){const Pt=30*c,jt=15*c,At=60*c;return this.int16[Pt+0]=h,this.int16[Pt+1]=g,this.int16[Pt+2]=j,this.float32[jt+2]=T,this.float32[jt+3]=P,this.uint16[Pt+8]=R,this.uint16[Pt+9]=F,this.uint32[jt+5]=H,this.uint32[jt+6]=Q,this.uint32[jt+7]=te,this.uint16[Pt+16]=re,this.uint16[Pt+17]=le,this.uint16[Pt+18]=ue,this.float32[jt+10]=ge,this.float32[jt+11]=ke,this.uint8[At+48]=Ee,this.uint8[At+49]=He,this.uint8[At+50]=$e,this.uint32[jt+13]=rt,this.int16[Pt+28]=it,this.uint8[At+58]=lt,c}}j3.prototype.bytesPerElement=60,xr(j3,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class OP 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,te,re,le,ue,ge,ke,Ee,He,$e,rt,it,lt,Pt,jt,At,St,Ct,ss,is,us,vs,hs,Is){const es=this.length;return this.resize(es+1),this.emplace(es,c,h,g,j,T,P,R,F,H,Q,te,re,le,ue,ge,ke,Ee,He,$e,rt,it,lt,Pt,jt,At,St,Ct,ss,is,us,vs,hs,Is)}emplace(c,h,g,j,T,P,R,F,H,Q,te,re,le,ue,ge,ke,Ee,He,$e,rt,it,lt,Pt,jt,At,St,Ct,ss,is,us,vs,hs,Is,es){const gs=20*c,Ss=40*c,Ls=80*c;return this.float32[gs+0]=h,this.float32[gs+1]=g,this.int16[Ss+4]=j,this.int16[Ss+5]=T,this.int16[Ss+6]=P,this.int16[Ss+7]=R,this.int16[Ss+8]=F,this.int16[Ss+9]=H,this.int16[Ss+10]=Q,this.int16[Ss+11]=te,this.int16[Ss+12]=re,this.uint16[Ss+13]=le,this.uint16[Ss+14]=ue,this.uint16[Ss+15]=ge,this.uint16[Ss+16]=ke,this.uint16[Ss+17]=Ee,this.uint16[Ss+18]=He,this.uint16[Ss+19]=$e,this.uint16[Ss+20]=rt,this.uint16[Ss+21]=it,this.uint16[Ss+22]=lt,this.uint16[Ss+23]=Pt,this.uint16[Ss+24]=jt,this.uint16[Ss+25]=At,this.uint16[Ss+26]=St,this.uint16[Ss+27]=Ct,this.uint32[gs+14]=ss,this.float32[gs+15]=is,this.float32[gs+16]=us,this.float32[gs+17]=vs,this.float32[gs+18]=hs,this.uint8[Ls+76]=Is,this.uint16[Ss+39]=es,c}}OP.prototype.bytesPerElement=80,xr(OP,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class N3 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}}N3.prototype.bytesPerElement=24,xr(N3,"StructArrayLayout6f24");class X0 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}}X0.prototype.bytesPerElement=20,xr(X0,"StructArrayLayout5f20");class p2 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}}p2.prototype.bytesPerElement=28,xr(p2,"StructArrayLayout7f28");class FP 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,te){const re=this.length;return this.resize(re+1),this.emplace(re,c,h,g,j,T,P,R,F,H,Q,te)}emplace(c,h,g,j,T,P,R,F,H,Q,te,re){const le=11*c;return this.float32[le+0]=h,this.float32[le+1]=g,this.float32[le+2]=j,this.float32[le+3]=T,this.float32[le+4]=P,this.float32[le+5]=R,this.float32[le+6]=F,this.float32[le+7]=H,this.float32[le+8]=Q,this.float32[le+9]=te,this.float32[le+10]=re,c}}FP.prototype.bytesPerElement=44,xr(FP,"StructArrayLayout11f44");class zP 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 te=9*c;return this.float32[te+0]=h,this.float32[te+1]=g,this.float32[te+2]=j,this.float32[te+3]=T,this.float32[te+4]=P,this.float32[te+5]=R,this.float32[te+6]=F,this.float32[te+7]=H,this.float32[te+8]=Q,c}}zP.prototype.bytesPerElement=36,xr(zP,"StructArrayLayout9f36");class Q0 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}}Q0.prototype.bytesPerElement=8,xr(Q0,"StructArrayLayout2f8");class BP 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}}BP.prototype.bytesPerElement=12,xr(BP,"StructArrayLayout1ul3ui12");class J0 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}}J0.prototype.bytesPerElement=2,xr(J0,"StructArrayLayout1ui2");class $P 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,te,re,le,ue,ge,ke){const Ee=this.length;return this.resize(Ee+1),this.emplace(Ee,c,h,g,j,T,P,R,F,H,Q,te,re,le,ue,ge,ke)}emplace(c,h,g,j,T,P,R,F,H,Q,te,re,le,ue,ge,ke,Ee){const He=16*c;return this.float32[He+0]=h,this.float32[He+1]=g,this.float32[He+2]=j,this.float32[He+3]=T,this.float32[He+4]=P,this.float32[He+5]=R,this.float32[He+6]=F,this.float32[He+7]=H,this.float32[He+8]=Q,this.float32[He+9]=te,this.float32[He+10]=re,this.float32[He+11]=le,this.float32[He+12]=ue,this.float32[He+13]=ge,this.float32[He+14]=ke,this.float32[He+15]=Ee,c}}$P.prototype.bytesPerElement=64,xr($P,"StructArrayLayout16f64");class k3 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}}k3.prototype.bytesPerElement=20,xr(k3,"StructArrayLayout4ui3f20");class S3 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}}S3.prototype.bytesPerElement=2,xr(S3,"StructArrayLayout1i2");class C3 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}}C3.prototype.bytesPerElement=1,xr(C3,"StructArrayLayout1ub1");class CF extends c2{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]}}CF.prototype.size=40;class qP extends w3{get(c){return new CF(this,c)}}xr(qP,"CollisionBoxArray");class MF extends c2{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}}MF.prototype.size=60;class TF extends j3{get(c){return new MF(this,c)}}xr(TF,"PlacedSymbolArray");class f2 extends c2{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]}}f2.prototype.size=80;class AF extends OP{get(c){return new f2(this,c)}}xr(AF,"SymbolInstanceArray");class EF extends Jh{getoffsetX(c){return this.float32[1*c+0]}}xr(EF,"GlyphOffsetArray");class x2 extends vh{getx(c){return this.int16[2*c+0]}gety(c){return this.int16[2*c+1]}}xr(x2,"SymbolLineVertexArray");class PF extends c2{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]}}PF.prototype.size=12;class UP extends BP{get(c){return new PF(this,c)}}xr(UP,"FeatureIndexArray");class IF extends Hm{geta_centroid_pos0(c){return this.uint16[2*c+0]}geta_centroid_pos1(c){return this.uint16[2*c+1]}}xr(IF,"FillExtrusionCentroidArray");class VP extends c2{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]}}VP.prototype.size=6;class HP extends Lf{get(c){return new VP(this,c)}}xr(HP,"FillExtrusionWallArray");const LF=la([{name:"a_pos",components:2,type:"Int16"}],4),Ape=la([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),Epe=la([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class bi{constructor(c=[]){this.segments=c}_prepareSegment(c,h,g,j,T){let P=this.segments[this.segments.length-1];return c>bi.MAX_VERTEX_ARRAY_LENGTH&&Rr(`Max vertices per segment is ${bi.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${c}`),(!P||P.vertexLength+c>bi.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 bi([{vertexOffset:c,primitiveOffset:h,vertexLength:g,primitiveLength:j,vaos:{},sortKey:0}])}}function M3(f,c){return 256*(f=Oe(Math.floor(f),0,255))+Oe(Math.floor(c),0,255)}bi.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,xr(bi,"SegmentVector");const Ppe=la([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Ipe=la([{name:"a_pattern_b",components:4,type:"Uint16"}]),Lpe=la([{name:"a_dash",components:4,type:"Uint16"}]);class g2{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(c,h,g,j){this.ids.push(GP(c)),this.positions.push(h,g,j)}eachPosition(c,h){const g=GP(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 y2(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 g2;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 GP(f){const c=+f;return Number.isSafeInteger(c)?c:nr(String(f))}function y2(f,c,h,g){for(;h>1];let T=h-1,P=g+1;for(;;){do T++;while(f[T]j);if(T>=P)break;em(f,T,P),em(c,3*T,3*P),em(c,3*T+1,3*P+1),em(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 Ea?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 Rpe(c):new vl(c)}}class ee{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 Dpe(c):new vl(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,te=B(this.lutExpression,h,{},j,T,P,R,F);this.paintVertexArray.resize(c),this._setPaintValue(H,c,Q,te?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),te=B(this.lutExpression,h,{},j,T,P,R,F),re=this.paintVertexArray.length;this.paintVertexArray.resize(c),this._setPaintValue(re,c,H,Q,te?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),te=B(this.lutExpression,g,j,T,void 0,R,void 0,F);this._setPaintValue(c,h,H,Q,te?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 Z0&&r3(R.property.specification)))continue;const F=Ie(P,c.type),H=R.value,Q=R.property.specification.type,te=!!R.property.useIntegerZoom,re=P==="line-dasharray"||P.endsWith("pattern"),le=T.paint.get(`${P}-use-theme`),ue=P==="line-dasharray"&&T.layout.get("line-cap").value.kind!=="constant"||le&&le.value.kind!=="constant";if(H.kind!=="constant"||ue)if(H.kind==="source"||ue||re){const ge=ct(P,Q,"source");this.binders[P]=re?new be(H,F,Q,ge,c.id):new ne(H,F,Q,ge),j.push(`/a_${P}`)}else{const ge=ct(P,Q,"composite");this.binders[P]=new de(H,F,Q,te,h,ge),j.push(`/z_${P}`)}else this.binders[P]=re?new ee(H.value,F):new W(H.value,F,Q,h),j.push(`/u_${P}`);le&&(this.binders[P].lutExpression=le.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 be)&&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 ee&&j.setConstantPatternPositions(c,h)}}getPatternTransitionVertexBuffer(c){const h=this.binders[c];return h instanceof be?h.paintTransitionVertexBuffer:null}updatePaintArrays(c,h,g,j,T,P,R,F,H,Q){let te=!1;const re=Object.keys(c),le=re.length!==0&&!F,ue=le?re:h.uniqueIds;this.context.lut=T.lut;for(const ge in this.binders){const ke=this.binders[ge];if(ke.context=this.context,(ke instanceof ne||ke instanceof de||ke instanceof be)&&ke.expression&&ke.expression.kind&&ke.expression.kind!=="constant"&&(ke.expression.isStateDependent===!0||ke.expression.isLightConstant===!1)){const Ee=T.paint.get(ge);ke.expression=Ee.value;for(const He of ue){const $e=c[He.toString()];h.eachPosition(He,(rt,it,lt)=>{const Pt=j.feature(rt);ke.updatePaintArray(it,lt,Pt,$e,P,R,H,Q)})}if(!le)for(const He of g.uniqueIds){const $e=c[He.toString()];g.eachPosition(He,(rt,it,lt)=>{const Pt=j.feature(rt);ke.updatePaintArray(it,lt,Pt,$e,P,R,H,Q)})}te=!0}}return te}defines(){const c=[];for(const h in this.binders){const g=this.binders[h];(g instanceof W||g instanceof ee)&&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 ee||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 be)&&h.paintVertexBuffer&&this._buffers.push(h.paintVertexBuffer),h instanceof be&&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 be)&&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 be)&&h.destroy()}}}class Ce{constructor(c,h,g=()=>!0){this.programConfigurations={};for(const j of c)this.programConfigurations[j.id]=new ye(j,h,g);this.needsUpload=!1,this._featureMap=new g2,this._featureMapWithoutIds=new g2,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 Be={"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 Ie(f,c){return Be[f]||[f.replace(`${c}-`,"").replace(/-/g,"_")]}const st={"line-pattern":{source:Df,composite:Df},"fill-pattern":{source:Df,composite:Df},"fill-extrusion-pattern":{source:Df,composite:Df},"line-dasharray":{source:Q1,composite:Q1}},tt={color:{source:Q0,composite:Yx},number:{source:Jh,composite:Q0}};function ct(f,c,h){const g=st[f];return g&&g[h]||tt[c][h]}xr(W,"ConstantBinder"),xr(ee,"PatternConstantBinder"),xr(ne,"SourceExpressionBinder"),xr(be,"PatternCompositeBinder"),xr(de,"CompositeExpressionBinder"),xr(ye,"ProgramConfiguration",{omit:["_buffers"]}),xr(Ce,"ProgramConfigurationSet");const mt=sr/Math.PI/2,nt=64,Ft=[nt,32,16],wt=-mt,Dt=mt;function pt(f,c,h,g=mt){return h=Kt(h),[f*Math.sin(h)*g,-c*g,f*Math.cos(h)*g]}function yt(f,c,h){return pt(Math.cos(Kt(f)),Math.sin(Kt(f)),c,h)}const Tt=63710088e-1,Wt=2*Math.PI*Tt;class Bt{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 Bt(_t(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 yt(this.lat,this.lng,mt+c*mt/Tt)}static convert(c){if(c instanceof Bt)return c;if(Array.isArray(c)&&(c.length===2||c.length===3))return new Bt(Number(c[0]),Number(c[1]));if(!Array.isArray(c)&&typeof c=="object"&&c!==null)return new Bt(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 Bt?new Bt(c.lng,c.lat):Bt.convert(c),this}setSouthWest(c){return this._sw=c instanceof Bt?new Bt(c.lng,c.lat):Bt.convert(c),this}extend(c){const h=this._sw,g=this._ne;let j,T;if(c instanceof Bt)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(Bt.convert(c)):typeof c=="object"&&c!==null&&c.hasOwnProperty("lat")&&(c.hasOwnProperty("lon")||c.hasOwnProperty("lng"))?this.extend(Bt.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 Bt(j.lng,j.lat),this._ne=new Bt(T.lng,T.lat)),this}getCenter(){return new Bt((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 Bt(this.getWest(),this.getNorth())}getSouthEast(){return new Bt(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}=Bt.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 Qt(f){return Wt*Math.cos(f*Math.PI/180)}function ws(f){return(180+f)/360}function As(f){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+f*Math.PI/360)))/360}function Zt(f,c){return f/Qt(c)}function Ut(f){return 360*f-180}function ts(f){return 360/Math.PI*Math.atan(Math.exp((180-360*f)*Math.PI/180))-90}function as(f,c){return f*Qt(ts(c))}const cs=85.051129;function Qs(f){return Math.cos(Kt(Oe(f,-85.051129,cs)))}function Hs(f,c){const h=Oe(c,0,25.5),g=Math.pow(2,h);return Qs(f)*Wt/(512*g)}function Gs(f){return 1/Math.cos(f*Math.PI/180)}function Cs(f,c=0){const h=Math.exp(Math.PI*(1-(f.y+c/sr)/(1<=F?(Ar(f,c,h,H,Q,T,te,R,F),Ar(f,H,Q,g,j,te,P,R,F)):f.push(P)}function mr(f,c,h){let g=f[0],j=g.x,T=g.y;c(g);const P=[g];for(let R=1;Rf.x+1||gf.y+1)&&Rr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),f}function qr(f,c,h){const g=f.loadGeometry(),j=f.extent,T=sr/j;if(c&&h&&h.projection.isReprojectedInTileSpace){const P=1<{const le=Ut((c.x+re.x/j)/P),ue=ts((c.y+re.y/j)/P),ge=Q.project(le,ue);re.x=(ge.x*R-F)*j,re.y=(ge.y*R-H)*j};for(let re=0;re=j||ue.y<0||ue.y>=j||(te(ue),le.push(ue));g[re]=le}}for(const P of g)for(const R of P)$n(R,T);return g}function qn(f,c){return{type:f.type,id:f.id,properties:f.properties,geometry:c?qr(f):[]}}class hn{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(Pa,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 rs(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 le=H(re);Q=re.length===1?{type:"Point",coordinates:le[0]}:{type:"MultiPoint",coordinates:le}}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 ge=ue.length;if(ge<=1)return[ue];const ke=[];let Ee,He;for(let $e=0;$e=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 hn(this._pbf,h,this.extent,this._keys,this._values)}}function wi(f,c,h){f===15?c.version=h.readVarint():f===1?c.name=h.readString():f===5?c.extent=h.readVarint():f===2?c._features.push(h.pos):f===3?c._keys.push(h.readString()):f===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 za{constructor(c,h){this.layers=c.readFields(Rn,{},h)}}function Rn(f,c,h){if(f===3){const g=new Gi(h,h.readVarint()+h.pos);g.length&&(c[g.name]=g)}}const On="3d_elevation_id",ji="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 Ba{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 bn=new Ba((f,c,h)=>f.reset(c).require(On,g=>{h.id=g}).optional("fixed_height_relative",g=>{h.constantHeight=g},mi.decodeRelativeHeight).geometry(g=>{h.bounds=g},FE).success(),(f,c,h)=>f.reset(c).require(On,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()),Bi=new Ba((f,c,h)=>f.reset(c).require(On,g=>{h.id=g}).optional("fixed_height",g=>{h.constantHeight=g},mi.decodeMetricHeight).geometry(g=>{h.bounds=g},FE).success(),(f,c,h)=>f.reset(c).require(On,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 $s(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"?Bi:void 0:bn}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 _l(f,c){for(const h of f.projections){const g=ol(c,f.points[0],h.axis);if(h.projection[1]g[1])return 0}return 1}function Sc(f,c){let h=0;const g=[0,0,0,0];for(let j=0;j=0&&h++;return h}class _h{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=Qa.fromPoints(this.points),this.projections=[],this.frustumEdges=[Ae([],this.points[2],this.points[3]),Ae([],this.points[0],this.points[3]),Ae([],this.points[4],this.points[0]),Ae([],this.points[5],this.points[1]),Ae([],this.points[6],this.points[2]),Ae([],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:ol(this.points,this.points[0],j)}),this.projections.push({axis:T,projection:ol(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=xt([],H,c),te=1/Q[3]/h*T;return(re=Q)[0]=(le=Q)[0]*(ue=[te,te,j?1/Q[3]:te,te])[0],re[1]=le[1]*ue[1],re[2]=le[2]*ue[2],re[3]=le[3]*ue[3],re;var re,le,ue}),R=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(H=>{const Q=Ne([],ze([],Ae([],P[H[0]],P[H[1]]),Ae([],P[H[2]],P[H[1]]))),te=-qe(Q,P[H[1]]);return Q.concat(te)}),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(qe([h[0],h[1],h[2]],c)+g<0)return!1}return!0}}class Qa{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 Qa(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])]}}xr(Qa,"Aabb");class tm{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 rs(Math.trunc(c.position[0]+g*T),Math.trunc(c.position[1]+j*T)),new rs(Math.trunc(c.position[0]-g*T),Math.trunc(c.position[1]-j*T))]}next(){this.index++}valid(){return this.index{return R.a0?je(F,F,1/H):ae(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,te]=this._tmpVec2;kr(te,c.x,c.y);const re=new Uo(te,null);for(let le=0;le0?Gr(F,R)/rt:0,lt=Oe(it,0,1),Pt=Math.abs((it-lt)*this.edgeProps[le].len);ir(H,te,ke),kr(Q,ge[1],-ge[0]);const jt=Pt+Math.abs(Gr(H,Q));jt=0;--P){const R=this.edges[P].a,F=this.edges[P].b,{position:H,height:Q,extent:te}=this.vertices[R],{position:re,height:le,extent:ue}=this.vertices[F],ge=this.vertexProps[R].dir,ke=this.vertexProps[F].dir;if(ae(h,H[0]/c,H[1]/c,Q),ae(g,re[0]/c,re[1]/c,le),ae(j,ge[1],-ge[0],0),je(j,j,te),ae(T,ke[1],-ke[0],0),je(T,T,ue),this.distSqLines(ie(h[0]+.5*j[0],h[1]+.5*j[1],h[2]+.5*j[2]),ie(g[0]-.5*T[0],g[1]-.5*T[1],g[2]-.5*T[2]),ie(h[0]-.5*j[0],h[1]-.5*j[1],h[2]-.5*j[2]),ie(g[0]+.5*T[0],g[1]+.5*T[1],g[2]+.5*T[2]))<=.0025000000000000005)continue;const Ee=this.vertices.length,He=Xs(zt(),H,re);this.vertices.push({position:Or(He,He,.5),height:.5*(Q+le),extent:.5*(te+ue)});const $e=Xs(zt(),ge,ke);this.vertexProps.push({dir:Qr($e,$e)}),this.edges.splice(P,1),this.edgeProps.splice(P,1),this.edges.push({a:R,b:Ee}),this.edges.push({a:Ee,b:F});const rt=ir(zt(),this.vertices[Ee].position,H),it=Vn(rt),lt={vec:rt,dir:Or(zt(),rt,1/it),len:it};this.edgeProps.push(lt),this.edgeProps.push(lt)}}distSqLines(c,h,g,j){const T=pe(J(),h,c),P=pe(J(),j,g),R=pe(J(),c,g),F=qe(T,T),H=qe(T,P),Q=qe(T,R),te=qe(P,P),re=qe(P,R),le=F*te-H*H;if(le===0)return Me(ve(T,g,j,qe(R,P)/qe(P,P)),c);const ue=(F*re-H*Q)/le;return Me(ve(T,c,h,(H*re-Q*te)/le),ve(P,g,j,ue))}}class Si{static parseFrom(c,h){const g=mi.parse(c);if(!g)return[];let{vertices:j,features:T}=g;const P=1/Cs(h);T.sort((Q,te)=>Q.id-te.id),j.sort((Q,te)=>Q.id-te.id||Q.idx-te.idx),j=j.filter((Q,te,re)=>te===re.findIndex(le=>le.id===Q.id&&le.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 sm(Q.id,Q.bounds,Q.constantHeight));continue}for(;F!==H&&j[F].idj.id===g)}}class Ei{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*Xe(0,h,c>=0?c:Math.abs(.5*c))}}xr(sm,"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 vh,this.indexArray=new To,this.segments=new bi,this.programConfigurations=new Ce(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 Jh),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:te,sourceLayerIndex:re}of c){const le=this.layers[0]._featureFilter.needGeometry,ue=qn(H,le);if(!this.layers[0]._featureFilter.filter(new Ga(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),ue,g))continue;const ge=R?R.evaluate(ue,{},g):void 0,ke={id:Q,properties:H.properties,type:H.type,sourceLayerIndex:re,index:te,geometry:le?ue.geometry:qr(H,g,j),patterns:{},sortKey:ge};P.push(ke)}R&&P.sort((H,Q)=>H.sortKey-Q.sortKey);let F=null;j.projection.name==="globe"&&(this.globeExtVertexArray=new b3,F=j.projection);for(const H of P){const{geometry:Q,index:te,sourceLayerIndex:re}=H,le=c[te].feature;this.addFeature(H,Q,te,h.availableImages,g,F,h.brightness,h.elevationFeatures),h.featureIndex.insert(le,Q,te,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,LF.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,Epe.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,Ape.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=Si.getElevationFeature(c,F));for(const Q of h)for(const te of Q){const re=te.x,le=te.y;if(re<0||re>=sr||le<0||le>=sr)continue;if(P){const ke=P.projectTilePoint(re,le,T),Ee=P.upVector(T,re,le);this.addGlobeExtVertex(ke,Ee),this.addGlobeExtVertex(ke,Ee),this.addGlobeExtVertex(ke,Ee),this.addGlobeExtVertex(ke,Ee)}const ue=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,c.sortKey),ge=ue.vertexLength;if(this.addCircleVertex(re,le,-1,-1),this.addCircleVertex(re,le,1,-1),this.addCircleVertex(re,le,1,1),this.addCircleVertex(re,le,-1,1),this.elevationMode!=="none"){const ke=H?H.pointElevation(new rs(re,le)):0;this.hasElevation=this.hasElevation||ke!==0;for(let Ee=0;Ee<4;Ee++)this.elevatedLayoutVertexArray.emplaceBack(ke)}this.indexArray.emplaceBack(ge,ge+1,ge+2),this.indexArray.emplaceBack(ge,ge+2,ge+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(f,c){for(let h=0;h1){if(dy(f,c))return!0;for(let g=0;g1?h:h.sub(c)._mult(j)._add(c))}function e_(f,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 Wu(f,c){let h=!1;for(let g=0,j=f.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 uy(f,c,h,g,j){for(const P of f)if(c<=P.x&&h<=P.y&&g>=P.x&&j>=P.y)return!0;const T=[new rs(c,h),new rs(c,j),new rs(g,j),new rs(g,h)];if(f.length>2){for(const P of T)if(Wu(f,P))return!0}for(let P=0;Pj.x&&c.x>j.x||f.yj.y&&c.y>j.y)return!1;const T=dn(f,c,h[0]);return T!==dn(f,c,h[1])||T!==dn(f,c,h[2])||T!==dn(f,c,h[3])}function my(f,c,h,g,j,T){let P=c.y-f.y,R=f.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-f.x)*P+(h.y-f.y)*R-T<0||(g.x-f.x)*P+(g.y-f.y)*R-T<0||(j.x-f.x)*P+(j.y-f.y)*R-T<0)}function A3(f,c,h,g,j,T,P){return!(my(f,c,g,j,T,P)||my(c,h,g,j,T,P)||my(h,f,g,j,T,P)||my(g,j,f,c,h,P)||my(j,T,f,c,h,P)||my(T,g,f,c,h,P))}function t_(f,c,h){const g=c.paint.get(f).value;return g.kind==="constant"?g.value:h.programConfigurations.get(c.id).getMaxValue(f)}function DF(f){return Math.sqrt(f[0]*f[0]+f[1]*f[1])}function ZCe(f,c,h,g,j){if(!c[0]&&!c[1])return f;const T=rs.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),te=H*(.5-(P+1)/F);return`${Q},${te},${Q+H/F},${te+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 Nu(c,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Nu(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 E3(this.wrap*+h,c,this.canonical.z,this.canonical.x,this.canonical.y);{const g=this.canonical.z-c;return E3(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 Nu(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 Nu(h,this.wrap,h,g,j),new Nu(h,this.wrap,h,g+1,j),new Nu(h,this.wrap,h,g,j+1),new Nu(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=f.canonical.x-1,h=f.wrap;return c<0&&(c=(1<{let c=f.canonical.x+1,h=f.wrap;return c===1<new Nu(f.overscaledZ,f.wrap,f.canonical.z,f.canonical.x,(f.canonical.y===0?1<new Nu(f.overscaledZ,f.wrap,f.canonical.z,f.canonical.x,f.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)}(f.a[c],f.b[c],f.angle,Oe(h,0,1))+f.center[c]}function py(f){if(f.z<=1)return Dct[f.z+2*f.y+f.x];const c=Fpe(FF(f));return Qa.fromPoints(c)}function sv(f,c,h){return je(f,f,1-h),Ue(f,f,c,h)}function s3e(f,c){const h=rv(c.zoom);if(h===0)return py(f);const g=FF(f),j=Fpe(g),T=ws(g.getWest())*c.worldSize,P=ws(g.getEast())*c.worldSize,R=As(g.getNorth())*c.worldSize,F=As(g.getSouth())*c.worldSize,H=[T,R,0],Q=[P,R,0],te=[T,F,0],re=[P,F,0],le=k([],c.globeMatrix);return dt(H,H,le),dt(Q,Q,le),dt(te,te,le),dt(re,re,le),j[0]=sv(j[0],te,h),j[1]=sv(j[1],re,h),j[2]=sv(j[2],Q,h),j[3]=sv(j[3],H,h),Qa.fromPoints(j)}function r3e(f,c,h){for(const g of f)dt(g,g,c),je(g,g,h)}function n3e(f,c,h,g){const j=c/f.worldSize,T=f.globeMatrix;if(h.z<=1){const At=py(h).getCorners();return r3e(At,T,j),Qa.fromPoints(At)}const P=FF(h,g),R=Fpe(P,mt+OF(f._tileCoverLift));r3e(R,T,j);const F=Number.MAX_VALUE,H=[-F,-F,-F],Q=[F,F,F];if(P.contains(f.center)){for(const Ct of R)he(Q,Q,Ct),we(H,H,Ct);H[2]=0;const At=f.point,St=[At.x*j,At.y*j,0];return he(Q,Q,St),we(H,H,St),new Qa(Q,H)}if(f._tileCoverLift>0){for(const At of R)he(Q,Q,At),we(H,H,At);return new Qa(Q,H)}const te=[T[12]*j,T[13]*j,T[14]*j],re=P.getCenter(),le=Oe(f.center.lat,-85.051129,cs),ue=Oe(re.lat,-85.051129,cs),ge=ws(f.center.lng),ke=As(le);let Ee=ge-ws(re.lng);const He=ke-As(ue);Ee>.5?Ee-=1:Ee<-.5&&(Ee+=1);let $e=0;Math.abs(Ee)>Math.abs(He)?$e=Ee>=0?1:3:($e=He>=0?0:2,Ue(te,te,[T[4]*j,T[5]*j,T[6]*j],-Math.sin(Kt(He>=0?P.getSouth():P.getNorth()))*mt));const rt=R[$e],it=R[($e+1)%4],lt=new Rct(rt,it,te),Pt=[Ope(lt,0)||rt[0],Ope(lt,1)||rt[1],Ope(lt,2)||rt[2]],jt=rv(f.zoom);if(jt>0){const At=function({x:Ct,y:ss,z:is},us,vs,hs,Is){const es=1/(1<.5?pr=-1:er<-.5&&(pr=1),gs=((gs+pr)*us-(hs*=us))*vs+hs,Ss=((Ss+pr)*us-hs)*vs+hs,Ls=(Ls*us-(Is*=us))*vs+Is,Ws=(Ws*us-Is)*vs+Is,[[gs,Ws,0],[Ss,Ws,0],[Ss,Ls,0],[gs,Ls,0]]}(h,c,f._pixelsPerMercatorPixel,ge,ke);for(let Ct=0;CtMath.PI/2*1.01}const c3e=Kt(85),Oct=Math.cos(c3e),Fct=Math.sin(c3e),zct=b(),d3e=f=>{const c=[];return f.paint.get("circle-pitch-alignment")==="map"&&c.push("PITCH_WITH_MAP"),f.paint.get("circle-pitch-scale")==="map"&&c.push("SCALE_WITH_MAP"),c};function u3e(f,c,h,g,j,T,P,R,F){if(T&&f.queryGeometry.isAboveHorizon)return!1;T&&(F*=f.pixelToTileUnitsFactor);const H=f.tileID.canonical,Q=h.projection.upVectorScale(H,h.center.lat,h.worldSize).metersToTile;for(const te of c)for(const re of te){const le=re.add(R),ue=j&&h.elevation?h.elevation.exaggeration()*j.getElevationAt(le.x,le.y,!0):0,ge=h.projection.projectTilePoint(le.x,le.y,H);if(ue>0){const $e=h.projection.upVector(H,le.x,le.y);ge.x+=$e[0]*Q*ue,ge.y+=$e[1]*Q*ue,ge.z+=$e[2]*Q*ue}const ke=T?le:Bct(ge.x,ge.y,ge.z,g),Ee=T?f.tilespaceRays.map($e=>qct($e,ue)):f.queryGeometry.screenGeometry,He=xt([],[ge.x,ge.y,ge.z,1],g);if(!P&&T?F*=He[3]/h.cameraToCenterDistance:P&&!T&&(F*=h.cameraToCenterDistance/He[3]),T){const $e=ts((re.y/sr+H.y)/(1<f.width||j.height>f.height||h.x>f.width-j.width||h.y>f.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=f.data,H=c.data,Q=T===4&&R;for(let te=0;te{c[f.evaluationKey]=F;const H=f.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(f.clips)for(let P=0,R=0;P80*h){R=f[0],F=f[1];let Q=R,te=F;for(let re=h;reQ&&(Q=le),ue>te&&(te=ue)}H=Math.max(Q-R,te-F),H=H!==0?32767/H:0}return XP(T,P,h,R,F,H,0),P}function b3e(f,c,h,g,j){let T;if(j===function(P,R,F,H){let Q=0;for(let te=R,re=F-H;te0)for(let P=c;P=c;P-=g)T=k3e(P/g|0,f[P],f[P+1],T);return T&&I3(T,T.next)&&(e6(T),T=T.next),T}function w2(f,c){if(!f)return f;c||(c=f);let h,g=f;do if(h=!1,g.steiner||!I3(g,g.next)&&Cc(g.prev,g,g.next)!==0)g=g.next;else{if(e6(g),g=c=g.prev,g===g.next)break;h=!0}while(h||g!==c);return c}function XP(f,c,h,g,j,T,P){if(!f)return;!P&&T&&function(F,H,Q,te){let re=F;do re.z===0&&(re.z=Upe(re.x,re.y,H,Q,te)),re.prevZ=re.prev,re.nextZ=re.next,re=re.next;while(re!==F);re.prevZ.nextZ=null,re.prevZ=null,function(le){let ue,ge=1;do{let ke,Ee=le;le=null;let He=null;for(ue=0;Ee;){ue++;let $e=Ee,rt=0;for(let lt=0;lt0||it>0&&$e;)rt!==0&&(it===0||!$e||Ee.z<=$e.z)?(ke=Ee,Ee=Ee.nextZ,rt--):(ke=$e,$e=$e.nextZ,it--),He?He.nextZ=ke:le=ke,ke.prevZ=He,He=ke;Ee=$e}He.nextZ=null,ge*=2}while(ue>1)}(re)}(f,g,j,T);let R=f;for(;f.prev!==f.next;){const F=f.prev,H=f.next;if(T?Kct(f,g,j,T):Wct(f))c.push(F.i,f.i,H.i),e6(f),f=H.next,R=H.next;else if((f=H)===R){P?P===1?XP(f=Zct(w2(f),c),c,h,g,j,T,2):P===2&&Yct(f,c,h,g,j,T):XP(w2(f),c,h,g,j,T,1);break}}}function Wct(f){const c=f.prev,h=f,g=f.next;if(Cc(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),te=Math.min(R,F,H),re=Math.max(j,T,P),le=Math.max(R,F,H);let ue=g.next;for(;ue!==c;){if(ue.x>=Q&&ue.x<=re&&ue.y>=te&&ue.y<=le&&QP(j,R,T,F,P,H,ue.x,ue.y)&&Cc(ue.prev,ue,ue.next)>=0)return!1;ue=ue.next}return!0}function Kct(f,c,h,g){const j=f.prev,T=f,P=f.next;if(Cc(j,T,P)>=0)return!1;const R=j.x,F=T.x,H=P.x,Q=j.y,te=T.y,re=P.y,le=Math.min(R,F,H),ue=Math.min(Q,te,re),ge=Math.max(R,F,H),ke=Math.max(Q,te,re),Ee=Upe(le,ue,c,h,g),He=Upe(ge,ke,c,h,g);let $e=f.prevZ,rt=f.nextZ;for(;$e&&$e.z>=Ee&&rt&&rt.z<=He;){if($e.x>=le&&$e.x<=ge&&$e.y>=ue&&$e.y<=ke&&$e!==j&&$e!==P&&QP(R,Q,F,te,H,re,$e.x,$e.y)&&Cc($e.prev,$e,$e.next)>=0||($e=$e.prevZ,rt.x>=le&&rt.x<=ge&&rt.y>=ue&&rt.y<=ke&&rt!==j&&rt!==P&&QP(R,Q,F,te,H,re,rt.x,rt.y)&&Cc(rt.prev,rt,rt.next)>=0))return!1;rt=rt.nextZ}for(;$e&&$e.z>=Ee;){if($e.x>=le&&$e.x<=ge&&$e.y>=ue&&$e.y<=ke&&$e!==j&&$e!==P&&QP(R,Q,F,te,H,re,$e.x,$e.y)&&Cc($e.prev,$e,$e.next)>=0)return!1;$e=$e.prevZ}for(;rt&&rt.z<=He;){if(rt.x>=le&&rt.x<=ge&&rt.y>=ue&&rt.y<=ke&&rt!==j&&rt!==P&&QP(R,Q,F,te,H,re,rt.x,rt.y)&&Cc(rt.prev,rt,rt.next)>=0)return!1;rt=rt.nextZ}return!0}function Zct(f,c){let h=f;do{const g=h.prev,j=h.next.next;!I3(g,j)&&j3e(g,h,h.next,j)&&JP(g,j)&&JP(j,g)&&(c.push(g.i,h.i,j.i),e6(h),e6(h.next),h=f=j),h=h.next}while(h!==f);return w2(h)}function Yct(f,c,h,g,j,T){let P=f;do{let R=P.next.next;for(;R!==P.prev;){if(P.i!==R.i&&tdt(P,R)){let F=N3e(P,R);return P=w2(P,P.next),F=w2(F,F.next),XP(P,c,h,g,j,T,0),void XP(F,c,h,g,j,T,0)}R=R.next}P=P.next}while(P!==f)}function Xct(f,c){let h=f.x-c.x;return h===0&&(h=f.y-c.y,h===0)&&(h=(f.next.y-f.y)/(f.next.x-f.x)-(c.next.y-c.y)/(c.next.x-c.x)),h}function Qct(f,c){const h=function(j,T){let P=T;const R=j.x,F=j.y;let H,Q=-1/0;if(I3(j,P))return P;do{if(I3(j,P.next))return P.next;if(F<=P.y&&F>=P.next.y&&P.next.y!==P.y){const ge=P.x+(F-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(ge<=R&&ge>Q&&(Q=ge,H=P.x=P.x&&P.x>=re&&R!==P.x&&w3e(FH.x||P.x===H.x&&Jct(H,P)))&&(H=P,ue=ge)}P=P.next}while(P!==te);return H}(f,c);if(!h)return c;const g=N3e(h,f);return w2(g,g.next),w2(h,h.next)}function Jct(f,c){return Cc(f.prev,f,c.prev)<0&&Cc(c.next,f,f.next)<0}function Upe(f,c,h,g,j){return(f=1431655765&((f=858993459&((f=252645135&((f=16711935&((f=(f-h)*j|0)|f<<8))|f<<4))|f<<2))|f<<1))|(c=1431655765&((c=858993459&((c=252645135&((c=16711935&((c=(c-g)*j|0)|c<<8))|c<<4))|c<<2))|c<<1))<<1}function edt(f){let c=f,h=f;do(c.x=(f-P)*(T-R)&&(f-P)*(g-R)>=(h-P)*(c-R)&&(h-P)*(T-R)>=(j-P)*(g-R)}function QP(f,c,h,g,j,T,P,R){return!(f===P&&c===R)&&w3e(f,c,h,g,j,T,P,R)}function tdt(f,c){return f.next.i!==c.i&&f.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&&j3e(j,j.next,h,g))return!0;j=j.next}while(j!==h);return!1}(f,c)&&(JP(f,c)&&JP(c,f)&&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}(f,c)&&(Cc(f.prev,f,c.prev)||Cc(f,c.prev,c))||I3(f,c)&&Cc(f.prev,f,f.next)>0&&Cc(c.prev,c,c.next)>0)}function Cc(f,c,h){return(c.y-f.y)*(h.x-c.x)-(c.x-f.x)*(h.y-c.y)}function I3(f,c){return f.x===c.x&&f.y===c.y}function j3e(f,c,h,g){const j=$F(Cc(f,c,h)),T=$F(Cc(f,c,g)),P=$F(Cc(h,g,f)),R=$F(Cc(h,g,c));return j!==T&&P!==R||!(j!==0||!BF(f,h,c))||!(T!==0||!BF(f,g,c))||!(P!==0||!BF(h,f,g))||!(R!==0||!BF(h,c,g))}function BF(f,c,h){return c.x<=Math.max(f.x,h.x)&&c.x>=Math.min(f.x,h.x)&&c.y<=Math.max(f.y,h.y)&&c.y>=Math.min(f.y,h.y)}function $F(f){return f>0?1:f<0?-1:0}function JP(f,c){return Cc(f.prev,f,f.next)<0?Cc(f,c,f.next)>=0&&Cc(f,f.prev,c)>=0:Cc(f,c,f.prev)<0||Cc(f,f.next,c)<0}function N3e(f,c){const h=Vpe(f.i,f.x,f.y),g=Vpe(c.i,c.x,c.y),j=f.next,T=c.prev;return f.next=c,c.prev=f,h.next=j,j.prev=h,g.next=h,h.prev=g,T.next=g,g.prev=T,g}function k3e(f,c,h,g){const j=Vpe(f,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 e6(f){f.next.prev=f.prev,f.prev.next=f.next,f.prevZ&&(f.prevZ.nextZ=f.nextZ),f.nextZ&&(f.nextZ.prevZ=f.prevZ)}function Vpe(f,c,h){return{i:f,x:c,y:h,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function t6(f,c){const h=f.length;if(h<=1)return[f];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 nv;let h=[];for(const F of c)h.push(...F.portals);if(h.length===0)return new nv;for(const F of h){const H=F.va,Q=F.vb;(nv.isOnBorder(H.x,Q.x)||nv.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 nv;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 Ce(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&&te.x<=T.max.x&&te.y>=T.min.y&&te.y<=T.max.y||re.x>=T.min.x&&re.x<=T.max.x&&re.y>=T.min.y&&re.y<=T.max.y||hy(te,re,R))||this.isOnBorder(te.x,re.x)||this.isOnBorder(te.y,re.y))continue;const le=rm.computeEdgeHash(this.unevalVertices[H],this.unevalVertices[Q]);let ue,ge=this.vertexHashLookup.get(rm.computePosHash(te));ge!=null?ue=ge.next:(ge=this.vertexHashLookup.get(rm.computePosHash(re)),ue=ge!=null?ge.prev:le),this.unevalEdges.push({polygonIdx:c,a:H,b:Q,hash:le,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=rm.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 rdt(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(c.portals,this.unevalEdges);const T=h(),P=h(),R=h(),F=(re,le)=>{re.sort((ge,ke)=>ge.type===le&&ke.type!==le?-1:ge.type!==le&&ke.type===le?1:0);const ue=re.findIndex(ge=>ge.type!==le);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(),te=h();if(this.unevalEdges.length>0){const re=this.unevalEdges.splice(H),le=F(re,"tunnel")+H;this.unevalEdges.push(...re),this.constructTunnelStructures(j,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:H},{min:H,max:le})}g(Q),j.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),g(te),j.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),g(P),j.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),g(T),this.maskSegments=bi.simpleSegment(0,te.primitiveOffset,0,te.primitiveLength),this.depthSegments=bi.simpleSegment(0,P.primitiveOffset,0,P.primitiveLength),this.renderableBridgeSegments=bi.simpleSegment(0,R.primitiveOffset,0,R.primitiveLength),this.renderableTunnelSegments=bi.simpleSegment(0,Q.primitiveOffset,0,Q.primitiveLength),this.shadowCasterSegments=bi.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,Hct.members),this.vertexBufferNormal=c.createVertexBuffer(this.vertexNormals,Gct.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;Hae(vs,h[hs].x,h[hs].y,g[hs]*F),te=J(),re=J(),le=J(),ue=J(),ge=J(),ke=(vs,hs)=>{const Is=R.get(rm.computePosHash(h[hs])),es=Is.from,gs=Is.to;if(!es||!gs)return;Q(te,es),Q(re,hs),Q(le,gs),Je(ue),at(te,re)||(Ae(ge,re,te),Ne(ue,ge)),at(le,re)||(Ae(ge,le,re),oe(ue,ue,Ne(ge,ge)));const Ss=We(ue);return Ss>0?je(vs,ue,1/Ss):void 0};let Ee=Number.POSITIVE_INFINITY;this.sortSubarray(j,T.min,T.max,(vs,hs)=>vs.featureInfo.featureIndex-hs.featureInfo.featureIndex);const He=J(),$e=J(),rt=J(),it=J(),lt=J(),Pt=J(),jt=J(),At=J(),St=J(),Ct=[J(),J(),J(),J()],ss=[J(),J(),J(),J()],is=[{coord:new rs(0,0),height:0},{coord:new rs(0,0),height:0}],us=(vs,hs)=>vs>hs;for(let vs=T.min;vsEe.featureInfo.featureIndex-He.featureInfo.featureIndex;this.sortSubarray(j,T.min,T.max,F),this.sortSubarray(j,P.min,P.max,F);const H=Ee=>Ne(Ee,Ee),Q=[{coord:new rs(0,0),height:0},{coord:new rs(0,0),height:0}],te=(Ee,He)=>EeR.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(rm.computePosHash(c))<<32n|BigInt(rm.computePosHash(h))}static computePosHash(c){return((65535&c.x)<<16|65535&c.y)>>>0}}function ndt(f,c){return f>c?1:f0))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&&Zpe(c,h,0,j-1,this._compare),this._root=Kpe(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 Wpe(g,T).load(c,h,j)}}function Kpe(f,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:f};return R.left=Kpe(R,c,h,g,P),R.right=Kpe(R,c,h,P+1,j),R}return null}function Zpe(f,c,h,g,j){if(h>=g)return;const T=f[h+g>>1];let P=h-1,R=g+1;for(;;){do P++;while(j(f[P],T)<0);do R--;while(j(f[R],T)>0);if(P>=R)break;let F=f[P];f[P]=f[R],f[R]=F,F=c[P],c[P]=c[R],c[R]=F}Zpe(f,c,h,R,j),Zpe(f,c,R+1,g,j)}const C3e=11102230246251565e-32,wh=134217729,adt=(3+8*C3e)*C3e;function Ype(f,c,h,g,j){let T,P,R,F,H=c[0],Q=g[0],te=0,re=0;Q>H==Q>-H?(T=H,H=c[++te]):(T=Q,Q=g[++re]);let le=0;if(teH==Q>-H?(P=H+T,R=T-(P-H),H=c[++te]):(P=Q+T,R=T-(P-Q),Q=g[++re]),T=P,R!==0&&(j[le++]=R);teH==Q>-H?(P=T+H,F=P-T,R=T-(P-F)+(H-F),H=c[++te]):(P=T+Q,F=P-T,R=T-(P-F)+(Q-F),Q=g[++re]),T=P,R!==0&&(j[le++]=R);for(;te0:(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 D3(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 fy(f,c){return f[0]===c[0]&&f[1]===c[1]}function Xpe(f,c,h){const g=function(j,T,P,R,F,H){const Q=(T-H)*(P-F),te=(j-F)*(R-H),re=Q-te;if(Q===0||te===0||Q>0!=te>0)return re;const le=Math.abs(Q+te);return Math.abs(re)>=33306690738754716e-32*le?re:-function(ue,ge,ke,Ee,He,$e,rt){let it,lt,Pt,jt,At,St,Ct,ss,is,us,vs,hs,Is,es,gs,Ss,Ls,Ws;const pr=ue-He,er=ke-He,Js=ge-$e,Ks=Ee-$e;es=pr*Ks,St=wh*pr,Ct=St-(St-pr),ss=pr-Ct,St=wh*Ks,is=St-(St-Ks),us=Ks-is,gs=ss*us-(es-Ct*is-ss*is-Ct*us),Ss=Js*er,St=wh*Js,Ct=St-(St-Js),ss=Js-Ct,St=wh*er,is=St-(St-er),us=er-is,Ls=ss*us-(Ss-Ct*is-ss*is-Ct*us),vs=gs-Ls,At=gs-vs,L3[0]=gs-(vs+At)+(At-Ls),hs=es+vs,At=hs-es,Is=es-(hs-At)+(vs-At),vs=Is-Ss,At=Is-vs,L3[1]=Is-(vs+At)+(At-Ss),Ws=hs+vs,At=Ws-hs,L3[2]=hs-(Ws-At)+(vs-At),L3[3]=Ws;let dr=function(Na,kn){let Ma=kn[0];for(let Un=1;Un<4;Un++)Ma+=kn[Un];return Ma}(0,L3),wr=22204460492503146e-32*rt;if(dr>=wr||-dr>=wr||(At=ue-pr,it=ue-(pr+At)+(At-He),At=ke-er,Pt=ke-(er+At)+(At-He),At=ge-Js,lt=ge-(Js+At)+(At-$e),At=Ee-Ks,jt=Ee-(Ks+At)+(At-$e),it===0&<===0&&Pt===0&&jt===0)||(wr=11093356479670487e-47*rt+adt*Math.abs(dr),dr+=pr*jt+Ks*it-(Js*Pt+er*lt),dr>=wr||-dr>=wr))return dr;es=it*Ks,St=wh*it,Ct=St-(St-it),ss=it-Ct,St=wh*Ks,is=St-(St-Ks),us=Ks-is,gs=ss*us-(es-Ct*is-ss*is-Ct*us),Ss=lt*er,St=wh*lt,Ct=St-(St-lt),ss=lt-Ct,St=wh*er,is=St-(St-er),us=er-is,Ls=ss*us-(Ss-Ct*is-ss*is-Ct*us),vs=gs-Ls,At=gs-vs,nm[0]=gs-(vs+At)+(At-Ls),hs=es+vs,At=hs-es,Is=es-(hs-At)+(vs-At),vs=Is-Ss,At=Is-vs,nm[1]=Is-(vs+At)+(At-Ss),Ws=hs+vs,At=Ws-hs,nm[2]=hs-(Ws-At)+(vs-At),nm[3]=Ws;const Br=Ype(4,L3,4,nm,M3e);es=pr*jt,St=wh*pr,Ct=St-(St-pr),ss=pr-Ct,St=wh*jt,is=St-(St-jt),us=jt-is,gs=ss*us-(es-Ct*is-ss*is-Ct*us),Ss=Js*Pt,St=wh*Js,Ct=St-(St-Js),ss=Js-Ct,St=wh*Pt,is=St-(St-Pt),us=Pt-is,Ls=ss*us-(Ss-Ct*is-ss*is-Ct*us),vs=gs-Ls,At=gs-vs,nm[0]=gs-(vs+At)+(At-Ls),hs=es+vs,At=hs-es,Is=es-(hs-At)+(vs-At),vs=Is-Ss,At=Is-vs,nm[1]=Is-(vs+At)+(At-Ss),Ws=hs+vs,At=Ws-hs,nm[2]=hs-(Ws-At)+(vs-At),nm[3]=Ws;const Tr=Ype(Br,M3e,4,nm,T3e);es=it*jt,St=wh*it,Ct=St-(St-it),ss=it-Ct,St=wh*jt,is=St-(St-jt),us=jt-is,gs=ss*us-(es-Ct*is-ss*is-Ct*us),Ss=lt*Pt,St=wh*lt,Ct=St-(St-lt),ss=lt-Ct,St=wh*Pt,is=St-(St-Pt),us=Pt-is,Ls=ss*us-(Ss-Ct*is-ss*is-Ct*us),vs=gs-Ls,At=gs-vs,nm[0]=gs-(vs+At)+(At-Ls),hs=es+vs,At=hs-es,Is=es-(hs-At)+(vs-At),vs=Is-Ss,At=Is-vs,nm[1]=Is-(vs+At)+(At-Ss),Ws=hs+vs,At=Ws-hs,nm[2]=hs-(Ws-At)+(vs-At),nm[3]=Ws;const Nn=Ype(Tr,T3e,4,nm,A3e);return A3e[Nn-1]}(j,T,P,R,F,H,le)}(f[0],f[1],c[0],c[1],h[0],h[1]);return g>0?-1:g<0?1:0}function r_(f,c){const h=f.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:Xpe(P,j.otherEvent.point,T.otherEvent.point)!==0?j.isBelow(T.otherEvent.point)?-1:1:!j.isSubject&&T.isSubject?1:-1}(f,c,h)}function n_(f,c,h){const g=new D3(c,!1,f,f.isSubject),j=new D3(c,!0,f.otherEvent,f.isSubject);return fy(f.point,f.otherEvent.point)&&console.warn("what is that, a collapsed segment?",f),g.contourId=j.contourId=f.contourId,r_(j,f.otherEvent)>0&&(f.otherEvent.left=!0,j.left=!1),f.otherEvent.otherEvent=j,f.otherEvent=g,h.push(j),h.push(g),h}function qF(f,c){return f[0]*c[1]-f[1]*c[0]}function Qpe(f,c){return f[0]*c[0]+f[1]*c[1]}function Jpe(f,c,h){const g=function(F,H,Q,te){const re=[H[0]-F[0],H[1]-F[1]],le=[te[0]-Q[0],te[1]-Q[1]];function ue(Pt,jt,At){return[Pt[0]+jt*At[0],Pt[1]+jt*At[1]]}const ge=[Q[0]-F[0],Q[1]-F[1]];let ke=qF(re,le),Ee=ke*ke;const He=Qpe(re,re);if(Ee>0){const Pt=qF(ge,le)/ke;if(Pt<0||Pt>1)return null;const jt=qF(ge,re)/ke;return jt<0||jt>1?null:Pt===0||Pt===1?[ue(F,Pt,re)]:jt===0||jt===1?[ue(Q,jt,le)]:[ue(F,Pt,re)]}if(ke=qF(ge,re),Ee=ke*ke,Ee>0)return null;const $e=Qpe(re,ge)/He,rt=$e+Qpe(re,le)/He,it=Math.min($e,rt),lt=Math.max($e,rt);return it<=1&<>=0?it===1?[ue(F,it>0?it:0,re)]:lt===0?[ue(F,lt<1?lt:1,re)]:[ue(F,it>0?it:0,re),ue(F,lt<1?lt:1,re)]:null}(f.point,f.otherEvent.point,c.point,c.otherEvent.point),j=g?g.length:0;if(j===0||j===1&&(fy(f.point,c.point)||fy(f.otherEvent.point,c.otherEvent.point))||j===2&&f.isSubject===c.isSubject)return 0;if(j===1)return!fy(f.point,g[0])&&!fy(f.otherEvent.point,g[0])&&n_(f,g[0],h),!fy(c.point,g[0])&&!fy(c.otherEvent.point,g[0])&&n_(c,g[0],h),1;const T=[];let P=!1,R=!1;return fy(f.point,c.point)?P=!0:r_(f,c)===1?T.push(c,f):T.push(f,c),fy(f.otherEvent.point,c.otherEvent.point)?R=!0:r_(f.otherEvent,c.otherEvent)===1?T.push(c.otherEvent,f.otherEvent):T.push(f.otherEvent,c.otherEvent),P&&R||P?(c.type=1,f.type=c.inOut===f.inOut?2:3,P&&!R&&n_(T[1].otherEvent,T[0].point,h),2):R?(n_(T[0],T[1].point,h),3):T[0]!==T[3].otherEvent?(n_(T[0],T[1].point,h),n_(T[1],T[2].point,h),3):(n_(T[0],T[1].point,h),n_(T[3].otherEvent,T[2].point,h),3)}function idt(f,c){if(f===c)return 0;if(Xpe(f.point,f.otherEvent.point,c.point)!==0||Xpe(f.point,f.otherEvent.point,c.otherEvent.point)!==0)return fy(f.point,c.point)?f.isBelow(c.otherEvent.point)?-1:1:f.point[0]===c.point[0]?f.point[1](c.contourId??0)?1:-1}return r_(f,c)===1?1:-1}class odt{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return this.holeOf==null}}function ldt(f,c,h,g){let j,T=f+1,P=c[f].point;const R=c.length;for(Tg;)T--;return T}function cdt(f,c,h){const g=new odt;if(f.prevInResult!=null){const j=f.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 P3e=Math.max,I3e=Math.min;let UF=0;function L3e(f,c,h,g,j,T){let P,R,F,H,Q,te;for(P=0,R=f.length-1;P0?te.left=!0:Q.left=!0;const re=F[0],le=F[1];j[0]=I3e(j[0],re),j[1]=I3e(j[1],le),j[2]=P3e(j[2],re),j[3]=P3e(j[3],le),g.push(Q),g.push(te)}}const VF=[];function D3e(f,c,h){let g=f,j=c;typeof f[0][0][0]=="number"&&(g=[f]),typeof c[0][0][0]=="number"&&(j=[c]);let T=function(re,le,ue){let ge=null;return re.length*le.length===0&&(ue===0?ge=VF:ue===2?ge=re:(ue===1||ue===3)&&(ge=re.length===0?le:re)),ge}(g,j,h);if(T)return T===VF?null:T;const P=[1/0,1/0,-1/0,-1/0],R=[1/0,1/0,-1/0,-1/0],F=function(re,le,ue,ge,ke){const Ee=new Uw(void 0,r_);let He,$e,rt,it,lt,Pt;for(rt=0,it=re.length;rtge[2]||ge[0]>ue[2]||ue[1]>ge[3]||ge[1]>ue[3])&&(ke===0?Ee=VF:ke===2?Ee=re:(ke===1||ke===3)&&(Ee=re.concat(le))),Ee}(g,j,P,R,h),T)return T===VF?null:T;const H=function(re,le,ue,ge,ke,Ee){const He=new Wpe(idt),$e=[],rt=Math.min(ge[2],ke[2]);let it,lt,Pt;for(;re.length!==0;){let jt=re.pop();if($e.push(jt),Ee===0&&jt.point[0]>rt||Ee===2&&jt.point[0]>ge[2])break;if(jt.left){lt=it=He.insert(jt),Pt=He.minNode(),it=it!==Pt?He.prev(it):null,lt=He.next(lt);const At=it?it.key:null;let St;if(r6(jt,At,Ee),lt&&Jpe(jt,lt.key,re)===2&&(r6(jt,At,Ee),r6(lt.key,jt,Ee)),it&&Jpe(it.key,jt,re)===2){let Ct=it;Ct=Ct!==Pt?He.prev(Ct):null,St=Ct?Ct.key:null,r6(At,St,Ee),r6(jt,At,Ee)}}else jt=jt.otherEvent,lt=it=He.find(jt),it&<&&(it=it!==Pt?He.prev(it):null,lt=He.next(lt),He.remove(jt),lt&&it&&Jpe(it.key,lt.key,re))}return $e}(F,0,0,P,R,h),Q=function(re){let le,ue;const ge=function(He){let $e,rt,it,lt,Pt;const jt=[];for(rt=0,it=He.length;rt{ke[Pt]=!0,Pt=ge.length)&&ge[it];);Ee.push($e)}return Ee}(H),te=[];for(let re=0;re{P.push(new rs(te,F+(te-R)/(H-R)*(Q-F)))}:(P,R,F,H,Q,te)=>{P.push(new rs(R+(te-F)/(Q-F)*(H-R),te))};for(const P of f){const R=[];for(const F of P){if(F.length<=2)continue;const H=[];for(let re=0;rec&&T(H,le,ue,ge,ke,c):Ee>h?He=c&&T(H,le,ue,ge,ke,c),He>h&&Ee<=h&&T(H,le,ue,ge,ke,h)}let Q=F[F.length-1];const te=g===0?Q.x:Q.y;te>=c&&te<=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 ddt(f,c){const h=D3e(efe(f),efe([c]),0);return h==null?[]:R3e(h)}function udt(f,c,h=0){let j=efe(f,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,te=R.y*65536;const re=Q-F,le=te-H,ue=Math.hypot(re,le);if(ue===0)continue;F-=re*h,H-=le*h,Q+=re*h,te+=le*h;const ge=Math.trunc(le/ue*3),ke=-Math.trunc(re/ue*3);T.push([[[F,H],[Q,te],[Q+ge,te+ke],[F+ge,H+ke],[F,H]]])}return T.length>0&&(j=D3e(j,T,2)),R3e(j,1/65536,128)}function efe(f,c=1){return[f.map(h=>h.map(g=>[g.x*c,g.y*c]))]}function R3e(f,c=1,h){return f.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 rs(F*c,H*c)._round()});return T>0&&P.reverse(),P}))}class tfe{constructor(c,h){this.layoutVertexArray=new vh,this.indexArray=new To,this.lineIndexArray=new Hm,this.triangleSegments=new bi,this.lineSegments=new bi,this.programConfigurations=new Ce(c.layers,{zoom:c.zoom,lut:c.lut}),this.uploaded=!1,h&&(this.elevatedLayoutVertexArray=new Jh)}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,Uct.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,Vct.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 GF{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 tfe(c,!1),this.elevationBufferData=new tfe(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=Hpe("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 te=this.layers[0]._featureFilter.needGeometry,re=qn(R,te);if(!this.layers[0]._featureFilter.filter(new Ga(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),re,g))continue;const le=T?T.evaluate(re,{},g,h.availableImages):void 0,ue={id:F,properties:R.properties,type:R.type,sourceLayerIndex:Q,index:H,geometry:te?re.geometry:qr(R,g,j),patterns:{},sortKey:le};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 te=Gpe("fill",this.layers,R,this.zoom,this.pixelRatio,h);this.patternFeatures.push(te)}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=t6(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=Si.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 rm(H.elevationTileID,this.layers,this.zoom,this.lut));const te=H.elevationFeature.isTunnel();let re=0;c.properties.hasOwnProperty(ji)&&(re=+c.properties[ji]),this.elevatedStructures.addPortalCandidates(H.elevationFeature.id,H.polygons,te,H.elevationFeature,re)}H.elevationFeature.constantHeight==null&&(H.polygons=this.prepareElevatedPolygons(H.polygons,H.elevationFeature,H.elevationTileID));const Q=new Ei(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 te=g.elevationSampler.pointElevation(F,g.elevation,g.bias);h.elevatedLayoutVertexArray.emplaceBack(te),Q.push(te),j=Math.min(j,te),T=Math.max(T,te)}};for(const F of c){let H=0;for(const $e of F)H+=$e.length;const Q=h.triangleSegments.prepareSegment(H,h.layoutVertexArray,h.indexArray),te=Q.vertexLength,re=[],le=[],ue=[],ge=[],ke=[],Ee=h.layoutVertexArray.length;for(const $e of F){if($e.length===0)continue;$e!==F[0]&&le.push(re.length/2);const rt=h.lineSegments.prepareSegment($e.length,h.layoutVertexArray,h.lineIndexArray),it=rt.vertexLength;g&&ke.push(h.layoutVertexArray.length-Ee),R($e[0],ue,ge),h.layoutVertexArray.emplaceBack($e[0].x,$e[0].y),h.lineIndexArray.emplaceBack(it+$e.length-1,it),re.push($e[0].x),re.push($e[0].y);for(let lt=1;lt<$e.length;lt++)R($e[lt],ue,ge),h.layoutVertexArray.emplaceBack($e[lt].x,$e[lt].y),h.lineIndexArray.emplaceBack(it+lt-1,it+lt),re.push($e[lt].x),re.push($e[lt].y);rt.vertexLength+=$e.length,rt.primitiveLength+=$e.length}const He=P3(re,le);for(let $e=0;$e0&&g&&this.elevationMode==="hd-road-base"){const $e=g.elevation.isTunnel(),rt=g.elevation.safeArea,it=this.elevatedStructures.addVertices(ue,ge);this.elevatedStructures.addTriangles(He,it,$e);const lt=ke.length;if(lt>0){for(let Pt=0;Pt=g&&le.max.x<=T&&le.min.y>=j&&le.max.y<=P?F:H).push(re)}if(F.length===c.length)return c;const Q=[new rs(g,j),new rs(T,j),new rs(T,P),new rs(g,P),new rs(g,j)],te=F;for(const re of H)te.push(...ddt(re,Q));return te}}let O3e,F3e,z3e,B3e;xr(GF,"FillBucket",{omit:["layers","patternFeatures"]}),xr(tfe,"FillBufferData"),xr(rm,"ElevatedStructures");class WF{constructor(c,h,g,j){if(this.triangleCount=h.length/3,this.min=new rs(0,0),this.max=new rs(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||c.length===0)return;const[T,P]=[c[0].clone(),c[0].clone()];for(let te=1;tete.cellIdx-re.cellIdx||te.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=xy(c.x-this.min.x,this.xScale,this.cellsX),j=xy(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=xy(c.x-this.min.x,this.xScale,this.cellsX),T=xy(h.x-this.min.x,this.xScale,this.cellsX),P=xy(c.y-this.min.y,this.yScale,this.cellsY),R=xy(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 te=0;teh.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,te=qn(P,Q);if(!this.layers[0]._featureFilter.filter(new Ga(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),te,g))continue;const re={id:R,properties:P.properties,type:P.type,sourceLayerIndex:H,index:F,geometry:Q?te.geometry:qr(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 t6(h,2)){const H=[],Q=[],te=[],re=new rs(1/0,1/0),le=new rs(-1/0,-1/0);for(const ke of F)if(ke.length!==0){ke!==F[0]&&te.push(Q.length/2);for(let Ee=0;Eec.max.x||f.max.xc.max.y||f.max.ynew rs((F.x+T.x*sr)*R-P.x*sr,(F.y+T.y*sr)*R-P.y*sr))}return rfe(h,j,f.indices,0,f.indices.length,0,0)}function G3e(f,c,h,g){const j=Math.pow(2,g.z-h.z);return new rs((f+h.x*sr)*j-g.x*sr,(c+h.y*sr)*j-g.y*sr)}function W3e(f,c){const h=[];c.grid.queryPoint(f,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 afe=hn.types,wdt=["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"],jdt=["fill-extrusion-flood-light-ground-radius"],Ndt=Math.pow(2,13),kdt=Math.pow(2,15)-1,XF=new rs(0,1),av=2147483648,QF=1073741824;function a6(f,c,h,g,j,T,P,R){f.emplaceBack((c<<1)+P,(h<<1)+T,(Math.floor(g*Ndt)<<1)+j,Math.round(R))}function i6(f,c,h){f.emplaceBack(c.x*sr,c.y*sr,h?1:0)}function JF(f,c,h,g,j,T){f.emplaceBack(c.x,c.y,(h.x<<1)+g,(h.y<<1)+j,T)}function o6(f,c,h){f.emplaceBack(c.x,c.y,c.z,h[0]*16384,h[1]*16384,h[2]*16384)}class Z3e{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class ife{constructor(){this.centroidXY=new rs(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new rs(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new rs(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new rs(0,0)}span(){return new rs(this.max.x-this.min.x,this.max.y-this.min.y)}}class ofe{constructor(){this.acc=new rs(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,sn(h.y,c.y,(0-h.x)/(c.x-h.x))),h.x>sr!=c.x>sr&&this.addBorderIntersection(1,sn(h.y,c.y,(sr-h.x)/(c.x-h.x))),h.y<0!=c.y<0&&this.addBorderIntersection(2,sn(h.x,c.x,(0-h.y)/(c.y-h.y))),h.y>sr!=c.y>sr&&this.addBorderIntersection(3,sn(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 rs(0,0):new rs(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((c,h)=>c+ +(h[0]!==Number.MAX_VALUE),0):0}}function Y3e(f,c){const h=f.add(c)._unit(),g=Oe(f.x*h.x+f.y*h.y,-1,1);var j,T,P;return P=Math.acos(g),Math.min(4,Math.max(-4,Math.tan(P)))/4*kdt*((j=f).x*(T=c).y-j.y*T.x<0?-1:1)}const Sdt=[f=>f.x<0,f=>f.x>sr,f=>f.y<0,f=>f.y>sr];function Cdt(f,c,h,g){const j=[4];if(g===0)return j;h._mult(g);const T=f.sub(h),P=c.sub(h),R=[f,c,T,P];for(let F=0;F<4;F++)for(const H of R)if(Sdt[F](H)){j.push(F);break}return j}class lfe{constructor(c){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new IP,this.indexArray=new To,this.programConfigurations=new Ce(c.layers,{zoom:c.zoom,lut:c.lut},h=>jdt.includes(h)),this._segments=new bi,this.hiddenByLandmarkVertexArray=new C3,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new bi}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=Y3e(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 bi);const te={vertexOffset:T.vertexOffset,primitiveOffset:T.primitiveOffset+R,vertexLength:T.vertexLength,primitiveLength:H};Q.get().push(te)}R+=H}for(let F=0;F0?this.hiddenByLandmarkVertexBuffer=c.createVertexBuffer(this.hiddenByLandmarkVertexArray,gdt.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 e7{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 To,this.footprintVertices=new vh,this.footprintSegments=[],this.layoutVertexArray=new PP,this.centroidVertexArray=new IF,this.wallVertexArray=new HP,this.indexArray=new To,this.programConfigurations=new Ce(c.layers,{zoom:c.zoom,lut:c.lut},h=>wdt.includes(h)),this.segments=new bi,this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.groundEffect=new lfe(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=Hpe("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=Cs(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 te={id:P,sourceLayerIndex:F,index:R,geometry:H?Q.geometry:qr(T,g,j),properties:T.properties,type:T.type,patterns:{}},re=this.layoutVertexArray.length,le=afe[te.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:T.id,feature:Gpe("fill-extrusion",this.layers,te,this.zoom,this.pixelRatio,h)});else if(this.wallMode)for(const ue of te.geometry)for(const ge of K3e(ue,le))this.addFeature(T.id,te,[ge],R,g,{},h.availableImages,j,h.brightness);else this.addFeature(T.id,te,te.geometry,R,g,{},h.availableImages,j,h.brightness);h.featureIndex.insert(T,te.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=afe[F.type]==="Polygon",{geometry:Q}=F;if(this.wallMode)for(const te of Q)for(const re of K3e(te,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,vdt),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.wallVertexBuffer=c.createVertexBuffer(this.wallVertexArray,xdt.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=c.createVertexBuffer(this.layoutVertexExtArray,ydt.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,fdt.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,te=[new rs(0,0),new rs(sr,sr)],re=F.projection,le=re.name==="globe",ue=this.wallMode||afe[h.type]==="Polygon",ge=new ofe;ge.centroidDataIndex=this.centroidData.length;const ke=new ife;ke.buildingId=c,h.properties&&h.properties.hasOwnProperty("building_id")&&(ke.buildingId=Number(h.properties.building_id)),ge.buildingId=ke.buildingId;const Ee=this.layers[0].paint.get("fill-extrusion-base").evaluate(h,{},T)<=0,He=this.layers[0].paint.get("fill-extrusion-height").evaluate(h,{},T);let $e;if(ke.height=He,ke.vertexArrayOffset=this.layoutVertexArray.length,ke.groundVertexArrayOffset=this.groundEffect.vertexArray.length,le&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new b3),this.wallMode){if(le)return void Rr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(g.length!==1)return;$e=function(St){const Ct=St[0].x===St[St.length-1].x&&St[0].y===St[St.length-1].y;(function(Js){let Ks=0;const dr=Js.length;for(let wr=0;wr=0})(St)||(St=St.reverse());const is={geometry:[],joinNormals:[],indices:[]},us=[],vs=[],hs=[];let Is=St.length;for(;Is>=2&&St[Is-1].equals(St[Is-2]);)Is--;if(Is<(Ct?3:2))return is;let es,gs,Ss,Ls,Ws,pr=0;for(;pr0;let Tr="miter";const Nn=2;Tr==="miter"&&wr>Nn&&(Tr="bevel"),Tr==="bevel"&&(wr>100&&(Tr="flipbevel"),wr{const Wa=new rs(kn.x,kn.y),La=new rs(kn.x,kn.y);Wa.x+=Ma.x*ho,Wa.y+=Ma.y*ho,La.x-=Ma.x*Math.max(Un,1),La.y-=Ma.y*Math.max(Un,1),hs.push(Ma),us.push(Wa),vs.push(La)};if(Tr==="miter")Ks._mult(wr),Na(es,Ks,0,0);else if(Tr==="flipbevel")Ks=Ws.mult(-1),Na(es,Ks,0,0),Na(es,Ks.mult(-1),0,0);else{const kn=-Math.sqrt(wr*wr-1),Ma=Br?kn:0,Un=Br?0:kn;gs&&Na(es,Ls,Ma,Un),Ss&&Na(es,Ws,Ma,Un)}}is.geometry=[...us,...vs.reverse(),us[0]],is.joinNormals=[...hs,...hs.reverse(),hs[hs.length-1]];const er=is.geometry.length-1;for(let Js=0;JsSt<(Ct.length-1)/2||St===Ct.length-1,it=this.wallMode?[g]:t6(g,500);for(let St=it.length-1;St>=0;St--){const Ct=it[St];(Ct.length===0||Tdt(Ct[0]))&&it.splice(St,1)}let lt;if(le)lt=r5e(it,te,T);else{lt=[];for(const St of it)lt.push({polygon:St,bounds:te})}const Pt=ue?this.edgeRadius:0,jt=Pt>0&&this.zoom<17,At=(St,Ct)=>{if(St.length===0)return!1;const ss=St[St.length-1];return Ct.x===ss.x&&Ct.y===ss.y};for(const{polygon:St,bounds:Ct}of lt){let ss=0,is=0;for(const Is of St)ue&&!Is[0].equals(Is[Is.length-1])&&Is.push(Is[0]),is+=ue?Is.length-1:Is.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 vs={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},hs=new Z3e;if(hs.vertexOffset=this.footprintVertices.length,hs.indexOffset=3*this.footprintIndices.length,hs.ringIndices=[],ue){const Is=[],es=[];ss=us.vertexLength;for(let Ss=0;Ss4&&e5e(es[es.length-2],es[0],es[1]),Ss=Pt?Mdt(es[es.length-2],es[0],es[1],Pt):0;const Ls=[];let Ws,pr,er;pr=es[1].sub(es[0])._perp()._unit();let Js=!0;for(let Ks=1,dr=0;Ks0?1:0,Ma=wr.dist(Br);if(dr+Ma>32768&&(dr=0),Pt){er=Tr.sub(Br)._perp()._unit();let La=Q3e(wr,Br,Tr,X3e(pr,er),Pt);isNaN(La)&&(La=0);const Ni=Br.sub(wr)._unit();wr=wr.add(Ni.mult(Ss))._round(),Br=Br.add(Ni.mult(-La))._round(),Ss=La,pr=er,Ee&&this.zoom>=17&&(At(Ls,wr)||Ls.push(wr),At(Ls,Br)||Ls.push(Br))}const Un=us.vertexLength,ho=es.length>4&&e5e(wr,Br,Tr);let Wa=t5e(dr,gs,Js);if(a6(this.layoutVertexArray,wr.x,wr.y,Na,kn,0,0,Wa),a6(this.layoutVertexArray,wr.x,wr.y,Na,kn,0,1,Wa),this.wallMode){const La=rt(Ks-1,es),Ni=$e.joinNormals[Ks-1];i6(this.wallVertexArray,Ni,La),i6(this.wallVertexArray,Ni,La)}if(dr+=Ma,Wa=t5e(dr,ho,!Js),gs=ho,a6(this.layoutVertexArray,Br.x,Br.y,Na,kn,0,0,Wa),a6(this.layoutVertexArray,Br.x,Br.y,Na,kn,0,1,Wa),this.wallMode){const La=rt(Ks,es),Ni=$e.joinNormals[Ks];i6(this.wallVertexArray,Ni,La),i6(this.wallVertexArray,Ni,La)}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,Pt){const La=ss+(Ks===1?es.length-2:Ks-2),Ni=Ks===1?ss:La+1;if(this.indexArray.emplaceBack(Un+1,La,Un+3),this.indexArray.emplaceBack(La,Ni,Un+3),us.primitiveLength+=2,Ws===void 0&&(Ws=Un),!cfe(Tr,es[Ks],Ct)){const no=Ks===es.length-1?Ws:us.vertexLength;this.indexArray.emplaceBack(Un+2,Un+3,no),this.indexArray.emplaceBack(Un+3,no+1,no),this.indexArray.emplaceBack(Un+3,Ni,no+1),us.primitiveLength+=3}Js=!Js}if(le){const La=this.layoutVertexExtArray,Ni=re.projectTilePoint(wr.x,wr.y,T),no=re.projectTilePoint(Br.x,Br.y,T),ic=re.upVector(T,wr.x,wr.y),ao=re.upVector(T,Br.x,Br.y);o6(La,Ni,ic),o6(La,Ni,ic),o6(La,no,ao),o6(La,no,ao)}}ue&&(ss+=es.length-1),Ee&&Pt&&this.zoom>=17&&(Ls.length!==0&&At(Ls,Ls[0])&&Ls.pop(),this.groundEffect.addData(Ls,Ct,Q,Pt>0))}this.footprintSegments.push(hs),vs.triangleCount=this.indexArray.length-vs.triangleArrayOffset,this.polygonSegments.push(vs),++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=ge.borders?XF:this.encodeCentroid(ge,ke),h.properties&&h.properties.hasOwnProperty("building_id")){const St=ke.buildingId;let Ct=this.buildingGroups.get(St);Ct||(Ct={accX:0,accY:0,accCount:0,mergedMin:new rs(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new rs(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(St,Ct)),Ct.accX+=ge.acc.x,Ct.accY+=ge.acc.y,Ct.accCount+=ge.accCount,Ct.mergedMin.x=Math.min(Ct.mergedMin.x,ke.min.x),Ct.mergedMin.y=Math.min(Ct.mergedMin.y,ke.min.y),Ct.mergedMax.x=Math.max(Ct.mergedMax.x,ke.max.x),Ct.mergedMax.y=Math.max(Ct.mergedMax.y,ke.max.y),Ct.partIndices.push(this.centroidData.length)}if(this.centroidData.push(ke),ge.borders){this.featuresOnBorder.push(ge);const St=this.featuresOnBorder.length-1;for(let Ct=0;Ctthis.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 te=0;teR.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:le,min:te,max:re}),F=H;for(let ue=F;ue[ge[0]*(1-Ee[0])+ke[0]*Ee[0],ge[1]*(1-Ee[1])+ke[1]*Ee[1]],le=[],ue=[];for(const ge of this.triangleSubSegments){le[0]=ge.min.x/sr,le[1]=ge.min.y/sr,ue[0]=ge.max.x/sr,ue[1]=ge.max.y/sr;const ke=re(Q,te,le),Ee=re(Q,te,ue);if(new Qa([ke[0],ke[1],T],[Ee[0],Ee[1],P]).intersectsPrecise(g)===0){H&&(j.segments.push(H),H=void 0);continue}const He=ge.segment;H&&H.vertexOffset!==He.vertexOffset&&(j.segments.push(H),H=void 0),H?(H.vertexLength+=He.vertexLength,H.primitiveLength+=He.primitiveLength):H={vertexOffset:He.vertexOffset,primitiveLength:He.primitiveLength,vertexLength:He.vertexLength,primitiveOffset:He.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 rs(Oe(g.x,1,8191)<<3|T,Oe(g.y,1,8191)<<3|P)}encodeBorderCentroid(c){if(!c.borders)return new rs(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 rs(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 rs((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&=av,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 rs(Oe(h.groupCentroidPos.x,1,8191)<<3|j,Oe(h.groupCentroidPos.y,1,8191)<<3|T)}else h.centroidXY=new rs(0,0);this.writeCentroidToBuffer(h)}writeCentroidToBuffer(c){this.groundEffect.updateHiddenByLandmark(c);const h=c.vertexArrayOffset,g=c.vertexCount+c.vertexArrayOffset,j=-1073741824&c.flags?XF: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!==YF.None?-1073741824:av);else for(const F of this.centroidData)if(!(F.flags&av||F.flags&QF||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!=le>h&&c<(this.footprintVertices.int16[2*(Q+P.vertexOffset)+0]-te)*(h-re)/(le-re)+te&&(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&av)}: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&av));if(g!==Number.NEGATIVE_INFINITY)return{height:g,hidden:j};this.partLookup[T]=void 0}}function X3e(f,c){const h=f.add(c)._unit();return f.x*h.x+f.y*h.y}function Mdt(f,c,h,g){const j=c.sub(f)._perp()._unit(),T=h.sub(c)._perp()._unit();return Q3e(f,c,h,X3e(j,T),g)}function Q3e(f,c,h,g,j){const T=Math.sqrt(1-g*g);return Math.min(f.dist(c)/3,c.dist(h)/3,j*T/g)}function cfe(f,c,h){return f.xh[1].x&&c.x>h[1].x||f.yh[1].y&&c.y>h[1].y}function J3e(f,c){return f.xc[1].x||f.yc[1].y}function Tdt(f){return f.every(c=>c.x<=0)||f.every(c=>c.x>=sr)||f.every(c=>c.y<=0)||f.every(c=>c.y>=sr)}function e5e(f,c,h){if(f.x<0||f.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=f.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 t5e(f,c,h){const g=c?2|f:-3&f;return h?1|g:-2&g}function s5e(){const f=Math.PI/32,c=Math.tan(f),h=Tt;return h*Math.sqrt(1+2*c*c)-h}function r5e(f,c,h){const g=1<{for(const jt of lt)ue.push({polygon:jt,bounds:Pt})},ke=Math.ceil(Math.log2(Q)),Ee=Math.ceil(Math.log2(te)),He=ke-Ee,$e=[];for(let lt=0;lt0?0:1);for(let lt=0;ltPt+1?it.push({polygons:us,bounds:hs,depth:Pt+1}):ge(us,hs)}if(vs.length){const hs=[new rs(jt===0?is:At.x,jt===1?is:At.y),St];$e.length>Pt+1?it.push({polygons:vs,bounds:hs,depth:Pt+1}):ge(vs,hs)}}return ue}(f,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 te=ts((h.y+H/sr)/g);return(As(.5*(ts((h.y+Q/sr)/g)+te))*g-h.y)*sr}})}function Adt(f,c,h,g,j,T){const P=Math.pow(2,g.z-j.z);for(let R=0;R=F[P]&&(R=c,F=f),R[P]j&&o5e(R,F,P,j),R[P]T&&o5e(F,R,P,T)}}function t7(f,c,h,g,j,T){const P=[];for(let R=0;R=g&&ue.x>=g||(le.x>=g?le=new rs(g,le.y+(g-le.x)/(ue.x-le.x)*(ue.y-le.y))._round():ue.x>=g&&(ue=new rs(g,le.y+(g-le.x)/(ue.x-le.x)*(ue.y-le.y))._round()),le.y>=j&&ue.y>=j||(le.y>=j?le=new rs(le.x+(j-le.y)/(ue.y-le.y)*(ue.x-le.x),j)._round():ue.y>=j&&(ue=new rs(le.x+(j-le.y)/(ue.y-le.y)*(ue.x-le.x),j)._round()),H&&le.equals(H[H.length-1])||(H=[le],P.push(H),T&&T.push({progress:{min:ke+c5e(Ee,He,le)*ge,max:1},parentIndex:R,prevPoint:Ee,nextPoint:He})),H.push(ue),T&&(T[T.length-1].progress.max=ke+c5e(Ee,He,ue)*ge,T[T.length-1].nextPoint=He)))))}if(T&&te>0)for(let re=Q;reH.t-Q.t);let P=0,R=0,F=[];for(g.push(F);P!==f.length;){if(R===T.length){for(;P!==f.length;)F.length!==0&&F[F.length-1].equals(f[P])||F.push(f[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(f[P])||F.push(f[P]),P++)}}function c5e(f,c,h){return f.x!==c.x?(h.x-f.x)/(c.x-f.x):f.y!==c.y?(h.y-f.y)/(c.y-f.y):0}function l6(f,c){return f.x*c.x+f.y*c.y}function d5e(f,c){if(f.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]=vs,is[2]=hs,is[3]=1},ss=s5e();le>0&&(le+=ss),ue+=ss;for(const is of re){const us=[],vs=[];for(const hs of is){const Is=hs.x+ge.x,es=hs.y+ge.y,gs=te.projection.projectTilePoint(Is,es,it),Ss=te.projection.upVector(it,hs.x,hs.y);let Ls=le,Ws=ue;if(Ee){const pr=m5e(Is,es,le,ue,Ee,He,$e,rt);Ls+=pr.base,Ws+=pr.top}le!==0?Ct(At,gs.x+Ss[0]*jt*Ls,gs.y+Ss[1]*jt*Ls,gs.z+Ss[2]*jt*Ls):Ct(At,gs.x,gs.y,gs.z),Ct(St,gs.x+Ss[0]*jt*Ws,gs.y+Ss[1]*jt*Ws,gs.z+Ss[2]*jt*Ws),dt(At,At,ke),dt(St,St,ke),us.push(new j2(At[0],At[1],At[2])),vs.push(new j2(St[0],St[1],St[2]))}lt.push(us),Pt.push(vs)}return[lt,Pt]}(f,c,h,g,j,T,P,R,F,H,Q):P?function(te,re,le,ue,ge,ke,Ee,He,$e){const rt=[],it=[],lt=[0,0,0,1];for(const Pt of te){const jt=[],At=[];for(const St of Pt){const Ct=St.x+ue.x,ss=St.y+ue.y,is=m5e(Ct,ss,re,le,ke,Ee,He,$e);lt[0]=Ct,lt[1]=ss,lt[2]=is.base,lt[3]=1,xt(lt,lt,ge),lt[3]=Math.max(lt[3],1e-5);const us=new j2(lt[0]/lt[3],lt[1]/lt[3],lt[2]/lt[3]);lt[0]=Ct,lt[1]=ss,lt[2]=is.top,lt[3]=1,xt(lt,lt,ge),lt[3]=Math.max(lt[3],1e-5);const vs=new j2(lt[0]/lt[3],lt[1]/lt[3],lt[2]/lt[3]);jt.push(us),At.push(vs)}rt.push(jt),it.push(At)}return[rt,it]}(c,h,g,j,T,P,R,F,H):function(te,re,le,ue,ge){const ke=[],Ee=[],He=ge[8]*re,$e=ge[9]*re,rt=ge[10]*re,it=ge[11]*re,lt=ge[8]*le,Pt=ge[9]*le,jt=ge[10]*le,At=ge[11]*le;for(const St of te){const Ct=[],ss=[];for(const is of St){const us=is.x+ue.x,vs=is.y+ue.y,hs=ge[0]*us+ge[4]*vs+ge[12],Is=ge[1]*us+ge[5]*vs+ge[13],es=ge[2]*us+ge[6]*vs+ge[14],gs=ge[3]*us+ge[7]*vs+ge[15],Ss=hs+He,Ls=Is+$e,Ws=es+rt,pr=Math.max(gs+it,1e-5),er=hs+lt,Js=Is+Pt,Ks=es+jt,dr=Math.max(gs+At,1e-5);Ct.push(new j2(Ss/pr,Ls/pr,Ws/pr)),ss.push(new j2(er/dr,Js/dr,Ks/dr))}ke.push(Ct),Ee.push(ss)}return[ke,Ee]}(c,h,g,j,T)}function m5e(f,c,h,g,j,T,P,R){const F=P*j.getElevationAt(f,c,!0,!0),H=T[0]!==0,Q=H?T[1]===0?P*(T[0]/7-450):P*function(te,re,le){const ue=Math.floor(re[0]/8),ge=Math.floor(re[1]/8),ke=10*(re[0]-8*ue),Ee=10*(re[1]-8*ge),He=te.getElevationAt(ue,ge,!0,!0),$e=te.getMeterToDEM(le),rt=Math.floor(.5*(ke*$e-1)),it=Math.floor(.5*(Ee*$e-1)),lt=te.tileCoordToPixel(ue,ge),Pt=2*rt+1,jt=2*it+1,At=function(vs,hs,Is,es,gs){return[vs.getElevationAtPixel(hs,Is,!0),vs.getElevationAtPixel(hs+gs,Is,!0),vs.getElevationAtPixel(hs,Is+gs,!0),vs.getElevationAtPixel(hs+es,Is+gs,!0)]}(te,lt.x-rt,lt.y-it,Pt,jt),St=Math.abs(At[0]-At[1]),Ct=Math.abs(At[2]-At[3]),ss=Math.abs(At[0]-At[2])+Math.abs(At[1]-At[3]),is=Math.min(.25,.5*$e*(St+Ct)/Pt),us=Math.min(.25,.5*$e*ss/jt);return He+Math.max(is*ke,us*Ee)}(j,T,R):F;return{base:F+(h===0?-1:h),top:H?Math.max(Q+g,F+h+2):F+g}}const dfe=4096;class Pdt{constructor(c){this.module=c,this.memoryStack=this.module.malloc(dfe),this.memoryStackNextFree=this.memoryStack}createIntArray(c){const h=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>dfe?-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>dfe?-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=le[ue++]>>2;if(ue++,j.json=JSON.parse(j5e.decode(le.subarray(ue,ue+ke))),ue+=ke,ue>>0,Math.ceil(1.2*rt)),lt=Math.ceil((it-rt)/65536);try{return ge.grow(lt),ke(),!0}catch{return!1}},b:Ee}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(le,He):le.then($e=>$e.arrayBuffer()).then($e=>WebAssembly.instantiate($e,He))).then($e=>{const{Rb:rt,Qb:it,P:lt,T:Pt,X:jt,Ja:At,La:St,Qa:Ct,Va:ss,Wa:is,eb:us,jb:vs,f:hs,e:Is,yb:es,zb:gs,Ab:Ss,Bb:Ls,Db:Ws,Gb:pr}=$e.instance.exports;ge=Is;const er=(()=>{let Js=0,Ks=0,dr=0,wr=0;return Br=>{dr&&(rt(wr),rt(Js),Ks+=dr,dr=Js=0),Js||(Ks+=128,Js=it(Ks));const Tr=Br.length+7&-8;let Nn=Js;Tr>=Ks&&(dr=Tr,Nn=wr=it(Tr));for(let Na=0;Na{Qx=le,c6=void 0}))}()),re&&Q.push(function(){if(ufe)return;const le=function(ue){let ge;const ke=WebAssembly.instantiateStreaming(ue,{}).then($e=>{ge=$e.instance,ge.exports.__wasm_call_ctors()}),Ee={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},He={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:ke,supported:!0,decodeGltfBuffer($e,rt,it,lt,Pt,jt){(function(At,St,Ct,ss,is,us,vs){const hs=At.exports.sbrk,Is=ss+3&-4,es=hs(Is*is),gs=hs(us.length),Ss=new Uint8Array(At.exports.memory.buffer);Ss.set(us,gs);const Ls=St(es,ss,is,gs,us.length);if(Ls===0&&vs&&vs(es,Is,is),Ct.set(Ss.subarray(es,es+ss*is)),hs(es-hs(0)),Ls!==0)throw new Error(`Malformed buffer data: ${Ls}`)})(ge,ge.exports[He[Pt]],$e,rt,it,lt,ge.exports[Ee[jt]])}}}(fetch(sc()));return le.ready.then(()=>{ufe=le})}()),P)for(let le=0;le{const R=Qg(g,(F,H)=>{F?P(F):T(H)});j&&j.addEventListener("abort",()=>{R.cancel(),P(new DOMException("Aborted","AbortError"))},{once:!0})})}({url:f,type:"arrayBuffer"},c);return S5e(h,0,f,c)}function mfe(f){switch(f){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 pfe(f){switch(f){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 gy{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 te=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&&(te?P.texSubImage2D(P.TEXTURE_2D,0,R,F,mfe(this.format),pfe(this.format),c):"data"in c&&c.data&&P.texSubImage2D(P.TEXTURE_2D,0,R,F,g,j,mfe(this.format),pfe(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 u6{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 zdt=la([{name:"a_pos_3f",components:3,type:"Float32"}]),Bdt=la([{name:"a_color_3f",components:3,type:"Float32"}]),$dt=la([{name:"a_color_4f",components:4,type:"Float32"}]),qdt=la([{name:"a_uv_2f",components:2,type:"Float32"}]),Udt=la([{name:"a_normal_3f",components:3,type:"Float32"}]),Vdt=la([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Hdt=la([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function M5e(f,c){const h=a7(f.projection,f.zoom,f.width,f.height),g=function(T,P,R,F,H){const Q=new Bt(R.lng-180*a_,R.lat),te=new Bt(R.lng+180*a_,R.lat),re=T.project(Q.lng,Q.lat),le=T.project(te.lng,te.lat),ue=-Math.atan2(le.y-re.y,le.x-re.x),ge=br.fromLngLat(R);ge.y=Oe(ge.y,-1+a_,1-a_);const ke=ge.toLngLat(),Ee=T.project(ke.lng,ke.lat),He=br.fromLngLat(ke);He.x+=a_;const $e=He.toLngLat(),rt=T.project($e.lng,$e.lat),it=A5e(rt.x-Ee.x,rt.y-Ee.y,ue),lt=br.fromLngLat(ke);lt.y+=a_;const Pt=lt.toLngLat(),jt=T.project(Pt.lng,Pt.lat),At=A5e(jt.x-Ee.x,jt.y-Ee.y,ue),St=Math.abs(it.x)/Math.abs(At.y),Ct=w([]);V(Ct,Ct,-ue*(1-(H?0:F)));const ss=w([]);return L(ss,ss,[1,1-(1-St)*F,1]),ss[4]=-At.x/At.y*F,V(ss,ss,ue),C(ss,Ct,ss),ss}(f.projection,0,f.center,h,c),j=T5e(f);return L(g,g,[j,j,1]),g}function T5e(f){const c=f.projection,h=a7(f.projection,f.zoom,f.width,f.height),g=ffe(c,f.center),j=ffe(c,Bt.convert(c.center));return Math.pow(2,g*h+(1-h)*j)}function a7(f,c,h,g,j=1/0){const T=f.range;if(!T)return 0;const P=Math.min(j,Math.max(h,g)),R=Math.log2(P/1024);return Xe(T[0]+R,T[1]+R,c)}const a_=1/4e4;function ffe(f,c){const h=Oe(c.lat,-85.051129,cs),g=new Bt(c.lng-180*a_,h),j=new Bt(c.lng+180*a_,h),T=f.project(g.lng,h),P=f.project(j.lng,h),R=br.fromLngLat(g),F=br.fromLngLat(j),H=P.x-T.x,Q=P.y-T.y,te=F.x-R.x,re=F.y-R.y,le=Math.sqrt((te*te+re*re)/(H*H+Q*Q));return Math.log2(le)}function A5e(f,c,h){const g=Math.cos(h),j=Math.sin(h);return{x:f*g-c*j,y:f*j+c*g}}function E5e(f,c,h){w(f),V(f,f,Kt(c[2])),I(f,f,Kt(c[0])),O(f,f,Kt(c[1])),L(f,f,h),C(f,f,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function i7(f,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 Ze(f);const Q=ze([],F,H);Ne(Q,Q),pe(H,g,c),F[2]=(T-j)*R,H[2]=(P-j)*R;const te=F;return ze(te,F,H),Ne(te,te),Dr(f,Q,te)}function o7(f,c,h=!1){const g=rv(c.zoom),j=function(T,P,R){const F=P.worldSize,H=[T[12],T[13],T[14]],Q=ts(H[1]/F),te=Ut(H[0]/F),re=w([]),le=Zt(1,Q)*F,ue=Zt(1,0)*F*Hs(Q,P.zoom),ge=1/Bpe(F);let ke=ue*ge;if(R){const rt=a7(P.projection,P.zoom,P.width,P.height,1024);ke=ge*P.projection.pixelSpaceConversion(P.center.lat,F,rt)}const Ee=yt(Q,te);oe(Ee,Ee,je([],Ne([],Ee),le*ke*H[2]));const He=function(rt){const it=[rt[0],rt[1],rt[2]];let lt=[0,1,0];const Pt=ze([],lt,it);return ze(lt,it,Pt),Fe(lt)===0&&(lt=[0,1,0],ze(Pt,it,lt)),Ne(Pt,Pt),Ne(lt,lt),Ne(it,it),[Pt[0],Pt[1],Pt[2],0,lt[0],lt[1],lt[2],0,it[0],it[1],it[2],0,rt[0],rt[1],rt[2],1]}(Ee);L(re,re,[ke,ke,ke*le]),E(re,re,[-H[0],-H[1],-H[2]]);const $e=C([],P.globeMatrix,He);return C($e,$e,re),C($e,$e,T),$e}(f,c,h);if(g>0){const T=function(P,R){const F=R.worldSize,H=Zt(1,0)*F*Hs(R.center.lat,R.zoom)/Bpe(F),Q=Zt(1,R.center.lat)*F,te=w([]);O(te,te,Kt(R.center.lng)),I(te,te,Kt(R.center.lat)),E(te,te,[0,0,mt]),L(te,te,[H,H,H*Q]);const re=R.point;return E(te,te,[-re.x,-re.y,0]),C(te,te,P),C(te,R.globeMatrix,te)}(f,c);return function(P,R,F){const H=(ue,ge,ke)=>{const Ee=ce(ue),He=ce(ge),$e=sv(ue,ge,ke);return je($e,$e,1/ce($e)*sn(Ee,He,ke))},Q=H([P[0],P[1],P[2]],[R[0],R[1],R[2]],F),te=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),le=sv([P[12],P[13],P[14]],[R[12],R[13],R[14]],F);return[Q[0],Q[1],Q[2],0,te[0],te[1],te[2],0,re[0],re[1],re[2],0,le[0],le[1],le[2],1]}(j,T,g)}return j}function xfe(f,c,h,g){const j=Qa.projectAabbCorners(g,h);let T=Number.MAX_VALUE;for(let R=0;R0||ke===0&&ue[0]*ge[0]+ue[1]*ge[1]>=0&&ue[0]*ue[0]+ue[1]*ue[1]>ge[0]*ge[0]+ge[1]*ge[1])&&(Q=le)}te=Q}while(te!==H);return F.length>0&&F.push(F[0]),F}(j);if(Fo(f,P))return T}const N2=64,O3={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function l7(f,c,h,g,j,T,P,R,F,H=!1){const Q=h.zoom,te=h.project(g),re=Hs(g.lat,Q),le=1/re;w(f),E(f,f,[te.x+P[0]*le,te.y+P[1]*le,P[2]]);let ue=1,ge=1;const ke=h.worldSize;if(H){if(h.projection.name==="mercator"){let rt=0;h.elevation&&(rt=h.elevation.getAtPointOrZero(new br(te.x/ke,te.y/ke),0));const it=xt([],[te.x,te.y,rt,1],h.projMatrix)[3]/h.cameraToCenterDistance;ue=it,ge=it*Hs(h.center.lat,Q)}else if(h.projection.name==="globe"){const rt=o7(f,h),it=[0,0,0,1];xt(it,it,C([],h.projMatrix,rt));const lt=it[3]/h.cameraToCenterDistance,Pt=rv(Q),jt=h.projection.pixelsPerMeter(g.lat,ke)*Hs(g.lat,Q),At=h.projection.pixelsPerMeter(h.center.lat,ke)*Hs(h.center.lat,Q);ue=lt/sn(jt,Qs(h.center.lat),Pt),ge=lt*re/jt,ue*=At,ge*=At}}else ue=le;L(f,f,[ue,ue,ge]);const Ee=[...f],He=c.orientation,$e=[];if(E5e($e,[He[0]+(j?j[0]:0),He[1]+(j?j[1]:0),He[2]+(j?j[2]:0)],T),C(f,Ee,$e),R&&h.elevation){let rt=0;const it=[];if(F&&h.elevation){rt=function(Pt,jt,At,St,Ct){const ss=jt.elevation;if(!ss)return 0;const is=Qa.projectAabbCorners(At,St),us=Zt(1,Ct.lat)*jt.worldSize,vs=function(Ks,dr){const wr=[0,0,1],Br=[{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 Tr of Br){const Nn=Ks[Tr.corners[0]],Na=Ks[Tr.corners[1]],kn=Ks[Tr.corners[2]],Ma=[Na[0]-Nn[0],Na[1]-Nn[1],dr*(Na[2]-Nn[2])],Un=ze(Ma,Ma,[kn[0]-Nn[0],kn[1]-Nn[1],dr*(kn[2]-Nn[2])]);Ne(Un,Un),Tr.dotProductWithUp=qe(Un,wr)}return Br.sort((Tr,Nn)=>Tr.dotProductWithUp-Nn.dotProductWithUp),Br[0].corners}(is,us),hs=is[vs[0]],Is=is[vs[1]],es=is[vs[2]],gs=is[vs[3]],Ss=ss.getAtPointOrZero(new br(hs[0]/jt.worldSize,hs[1]/jt.worldSize),0),Ls=ss.getAtPointOrZero(new br(Is[0]/jt.worldSize,Is[1]/jt.worldSize),0),Ws=ss.getAtPointOrZero(new br(es[0]/jt.worldSize,es[1]/jt.worldSize),0),pr=ss.getAtPointOrZero(new br(gs[0]/jt.worldSize,gs[1]/jt.worldSize),0),er=(Ss+pr)/2,Js=(Ls+Ws)/2;return er>Js?Ls=c.gl.NEAREST_MIPMAP_NEAREST}),f.uploaded=!0,f.image=null)}function Gdt(f,c,h){f.indexBuffer=c.createIndexBuffer(f.indexArray,!1,!0),f.vertexBuffer=c.createVertexBuffer(f.vertexArray,zdt.members,!1,!0),f.normalArray&&(f.normalBuffer=c.createVertexBuffer(f.normalArray,Udt.members,!1,!0)),f.texcoordArray&&(f.texcoordBuffer=c.createVertexBuffer(f.texcoordArray,qdt.members,!1,!0)),f.colorArray&&(f.colorBuffer=c.createVertexBuffer(f.colorArray,(f.colorArray.bytesPerElement===12?Bdt:$dt).members,!1,!0)),f.featureArray&&(f.pbrBuffer=c.createVertexBuffer(f.featureArray,Hdt.members,!0)),f.segments=bi.simpleSegment(0,0,f.vertexArray.length,f.indexArray.length);const g=f.material;g.pbrMetallicRoughness.baseColorTexture&&h6(g.pbrMetallicRoughness.baseColorTexture,c),g.pbrMetallicRoughness.metallicRoughnessTexture&&h6(g.pbrMetallicRoughness.metallicRoughnessTexture,c),g.normalTexture&&h6(g.normalTexture,c),g.occlusionTexture&&h6(g.occlusionTexture,c,h),g.emissionTexture&&h6(g.emissionTexture,c)}function gfe(f,c,h){if(f.meshes)for(const g of f.meshes)Gdt(g,c,h);if(f.children)for(const g of f.children)gfe(g,c,h)}function c7(f){if(f.meshes)for(const c of f.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(f.children)for(const c of f.children)c7(c)}function Wdt(f){f.pbrMetallicRoughness.baseColorTexture&&f.pbrMetallicRoughness.baseColorTexture.gfxTexture&&f.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),f.pbrMetallicRoughness.metallicRoughnessTexture&&f.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&f.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),f.normalTexture&&f.normalTexture.gfxTexture&&f.normalTexture.gfxTexture.destroy(),f.emissionTexture&&f.emissionTexture.gfxTexture&&f.emissionTexture.gfxTexture.destroy(),f.occlusionTexture&&f.occlusionTexture.gfxTexture&&f.occlusionTexture.gfxTexture.destroy()}function yfe(f){if(f.meshes)for(const c of f.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&&Wdt(c.material));if(f.footprintDebugMesh&&(f.footprintDebugMesh.vertexBuffer.destroy(),f.footprintDebugMesh.indexBuffer.destroy(),f.footprintDebugMesh.segments.destroy()),f.children)for(const c of f.children)yfe(c)}function k2(f,c){const h=f.json.bufferViews[c.bufferView],g=r7[c.componentType];return new g(f.buffers[h.buffer],(c.byteOffset||0)+(h.byteOffset||0),c.count*(h.byteStride&&h.byteStride!==d6[c.type]*g.BYTES_PER_ELEMENT?h.byteStride/g.BYTES_PER_ELEMENT:d6[c.type]))}function vfe(f,c,h,g){const j=r7[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=f.json.bufferViews[c.bufferView],R=P.byteStride?P.byteStride/j.BYTES_PER_ELEMENT:d6[c.type],F=h.float32,H=F.length/h.capacity;for(let Q=0,te=0;Q0){for(let ke=0;ke0){T.texcoordArray=new Q0;const re=c.json.accessors[j.TEXCOORD_0];T.texcoordArray.resize(re.count);const le=k2(c,re);vfe(c,re,T.texcoordArray,le)}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=k2(c,re))}j._FEATURE_RGBA4444!==void 0&&(T.featureData=new Uint32Array(k2(c,c.json.accessors[j._FEATURE_RGBA4444]).buffer));const te=f.material;return T.material=function(re,le){const{emissiveFactor:ue=[0,0,0],alphaMode:ge="OPAQUE",alphaCutoff:ke=.5,normalTexture:Ee,occlusionTexture:He,emissiveTexture:$e,doubleSided:rt,name:it}=re,{baseColorFactor:lt=[1,1,1,1],metallicFactor:Pt=1,roughnessFactor:jt=1,baseColorTexture:At,metallicRoughnessTexture:St}=re.pbrMetallicRoughness||{},Ct=He?le[He.index]:void 0;if(He&&He.extensions&&He.extensions.KHR_texture_transform&&Ct){const ss=He.extensions.KHR_texture_transform;Ct.offsetScale=[ss.offset[0],ss.offset[1],ss.scale[0],ss.scale[1]]}return{name:it,pbrMetallicRoughness:{baseColorFactor:new Ea(...lt),metallicFactor:Pt,roughnessFactor:jt,baseColorTexture:At?le[At.index]:void 0,metallicRoughnessTexture:St?le[St.index]:void 0},doubleSided:rt,emissiveFactor:new Ea(...ue),alphaMode:ge,alphaCutoff:ke,normalTexture:Ee?le[Ee.index]:void 0,occlusionTexture:Ct,emissionTexture:$e?le[$e.index]:void 0,defined:re.defined===void 0}}(te!==void 0?c.json.materials[te]:{defined:!1},h),T}function I5e(f,c,h){const{matrix:g,rotation:j,translation:T,scale:P,mesh:R,extras:F,children:H,name:Q}=f,te={};if(te.name=Q,te.localMatrix=g||function(re,le,ue,ge){var ke=le[0],Ee=le[1],He=le[2],$e=le[3],rt=ke+ke,it=Ee+Ee,lt=He+He,Pt=ke*rt,jt=ke*it,At=ke*lt,St=Ee*it,Ct=Ee*lt,ss=He*lt,is=$e*rt,us=$e*it,vs=$e*lt,hs=ge[0],Is=ge[1],es=ge[2];return re[0]=(1-(St+ss))*hs,re[1]=(jt+vs)*hs,re[2]=(At-us)*hs,re[3]=0,re[4]=(jt-vs)*Is,re[5]=(1-(Pt+ss))*Is,re[6]=(Ct+is)*Is,re[7]=0,re[8]=(At+us)*es,re[9]=(Ct-is)*es,re[10]=(1-(Pt+St))*es,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]),te.globalMatrix=N(te.localMatrix),R!==void 0){te.meshes=h[R];const re=te.anchor=[0,0];for(const le of te.meshes){const{min:ue,max:ge}=le.aabb;re[0]+=ue[0]+ge[0],re[1]+=ue[1]+ge[1]}re[0]=Math.floor(re[0]/te.meshes.length/2),re[1]=Math.floor(re[1]/te.meshes.length/2)}if(F&&(F.id&&(te.id=F.id),F.lights&&(te.lights=function(re){if(!re.length)return[];const le=function(He){const $e=atob(He),rt=new Uint8Array($e.length);for(let it=0;it<$e.length;it++)rt[it]=$e.codePointAt(it);return rt}(re),ue=[],ge=le.length/24,ke=new Uint16Array(le.buffer),Ee=new Float32Array(le.buffer);for(let He=0;He1&&g[g.length-1].equals(g[0])&&g.pop();let j=0;for(let P=0;P0&&g.reverse();const T=P3(g.flatMap(P=>[P.x,P.y]),[]);return T.length===0?null:{vertices:g,indices:T}}function Xdt(f,c){const h=[],g=[];let j=0;const T=[];for(const P of f){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 _fe(f){const c=function(F,H){const Q=[],te=WebGL2RenderingContext;if(F.json.textures)for(const re of F.json.textures){const le={magFilter:te.LINEAR,minFilter:te.NEAREST,wrapS:te.REPEAT,wrapT:te.REPEAT};re.sampler!==void 0&&Object.assign(le,F.json.samplers[re.sampler]),Q.push({image:H[re.source],sampler:le,uploaded:!1})}return Q}(f,f.images),h=function(F,H){const Q=[];for(const te of F.json.meshes){const re=[];for(const le of te.primitives)re.push(Kdt(le,F,H));Q.push(re)}return Q}(f,c),{scenes:g,scene:j,nodes:T}=f.json,P=g?g[j||0].nodes:[...T.keys()],R=[];for(const F of P)R.push(I5e(T[F],f,h));return function(F,H,Q){const te={},re=new Set;for(let le=0;le0){const le=Array.from(re.values()).sort((ue,ge)=>ue-ge);for(let ue=le.length-1;ue>=0;ue--)F.splice(le[ue],1)}}(R,P,f.json.nodes),R}function Qdt(f){f.heightmap=new Float32Array(4096),f.heightmap.fill(-1);const c=f.vertexArray.float32,h=f.aabb.min[0]-1,g=f.aabb.min[1]-1,j=N2/(f.aabb.max[0]-h+2),T=N2/(f.aabb.max[1]-g+2);for(let P=0;Pf.heightmap[H*N2+F]&&(f.heightmap[H*N2+F]=R)}}function L5e(f,c,h,g,j){h.reserve(h.length+4*f.length),g.reserve(g.length+10*f.length),j.reserve(j.length+10*f.length);let T=g.length;for(const P of f){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),te=Ue([],P.pos,F,Q/2),re=Ue([],P.pos,F,-Q/2),le=[te[0],te[1],te[2]+P.height],ue=[re[0],re[1],re[2]+P.height],ge=Ue([],P.normal,F,H);je(ge,ge,R);const ke=Ue([],P.normal,F,-H);je(ke,ke,R),oe(ge,te,ge),oe(ke,re,ke),te[2]+=.1,re[2]+=.1,g.emplaceBack(ge[0],ge[1],ge[2]),g.emplaceBack(ke[0],ke[1],ke[2]),g.emplaceBack(te[0],te[1],te[2]),g.emplaceBack(re[0],re[1],re[2]),g.emplaceBack(le[0],le[1],le[2]),g.emplaceBack(ue[0],ue[1],ue[2]),g.emplaceBack(te[0],te[1],te[2]),g.emplaceBack(re[0],re[1],re[2]),g.emplaceBack(ge[0],ge[1],ge[2]),g.emplaceBack(ke[0],ke[1],ke[2]);const Ee=Q/R/2;j.emplaceBack(-Ee-H,-1,Ee,.8),j.emplaceBack(Ee+H,-1,Ee,.8),j.emplaceBack(-Ee,0,Ee,1.3),j.emplaceBack(Ee,0,Ee,1.3),j.emplaceBack(Ee+H,-.8,Ee,.7),j.emplaceBack(Ee+H,-.8,Ee,.7),j.emplaceBack(0,0,Ee,1.3),j.emplaceBack(0,0,Ee,1.3),j.emplaceBack(Ee+H,-1.2,Ee,.8),j.emplaceBack(Ee+H,-1.2,Ee,.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 Jdt(f,c){const h={};h.indexArray=new To,h.vertexArray=new Vm,h.colorArray=new Yx,L5e(f,c,h.indexArray,h.vertexArray,h.colorArray);const g={defined:!0};g.emissiveFactor=Ea.black;const j={};return j.baseColorFactor=Ea.white,g.pbrMetallicRoughness=j,h.material=g,h.aabb=new Qa([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),h}const D5e=la([{name:"a_pos_3f",components:3,type:"Float32"}]),eut=la([{name:"a_normal_3",components:3,type:"Int16"}]),tut=la([{name:"a_centroid_3",components:3,type:"Int16"}]),R5e=la([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),sut=la([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),rut=la([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),nut=la([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),aut=la([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),iut=la([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),O5e=hn.types,d7=32767;function out(f,c){const h=sr+c;for(const g of f)for(const j of g)if(j.x<-c||j.x>h||j.y<-c||j.y>h)return!1;return!0}function lut(f){switch(f){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: ${f}`)}}class bfe{constructor(){this.layoutVertexArray=new Vm,this.layoutAttenuationArray=new Yx,this.layoutColorArray=new Hm,this.indexArray=new To,this.indexArrayForConflation=new To,this.segmentsBucket=new bi}}class wfe{constructor(c){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new bi,this.entranceBloom=new bfe;const h=66560;this.layoutVertexArray=new Vm,this.layoutVertexArray.reserve(h),this.layoutNormalArray=new Lf,this.layoutNormalArray.reserve(h),this.layoutCentroidArray=new Lf,this.layoutCentroidArray.reserve(h),this.layoutColorArray=new Hm,this.layoutColorArray.reserve(h),this.layoutFloodLightDataArray=new S3,this.layoutFloodLightDataArray.reserve(h),this.layoutAOArray=new C3,this.layoutAOArray.reserve(h),this.indexArray=new To,this.indexArray.reserve(66560),this.indexArrayForConflation=new To,this.segmentsBucket=new bi,this.entranceBloom=new bfe,c&&(this.layoutFacadePaintArray=new Hm,this.layoutFacadeDataArray=new Q1,this.layoutFacadeVerticalRangeArray=new Hm)}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 F5e{constructor(c){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Q0,this.footprintsIndices=new J0,this.footprintsMin=new rs(1/0,1/0),this.footprintsMax=new rs(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new wfe(!1),this.buildingWithFacade=new wfe(!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 Ce(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 lfe(c),this.groundEffect.groundRadiusArray=new Jh,this.hasAppearances=null}updateFootprints(c,h){const g=new WF([],[],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(s7!=null||p5e!=null)return null;if(R3!=null)return R3;const c=fetch(rc());return R3=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=()=>{},te={a:{a:H,f:function(re){const le=g.length,ue=Math.max(re>>>0,Math.ceil(1.2*le)),ge=Math.ceil((ue-le)/65536);try{return R.grow(ge),F(),!0}catch{return!1}},g:H,b:Q,c:Q,d:Q,e:Q}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(h,te):h.then(re=>re.arrayBuffer()).then(re=>WebAssembly.instantiate(re,te))).then(re=>{const le=re.instance.exports;return(0,le.g)(),R=le.f,F(),new Pdt({setStyle:le.h,setAOOptions:le.i,setMetricOptions:le.j,setStructuralOptions:le.k,setFacadeOptions:le.l,setFauxFacadeOptions:le.m,setFacadeClassifierOptions:le.n,addFeature:le.o,addFacade:le.p,generateMesh:le.q,getLastError:le.r,getOuterRingLength:le.s,getMeshCount:le.t,getPositionsPtr:le.u,getPositionsLength:le.v,getNormalsPtr:le.w,getNormalsLength:le.x,getAOPtr:le.y,getAOLength:le.z,getUVPtr:le.A,getUVLength:le.B,getFauxFacadePtr:le.C,getFauxFacadeLength:le.D,getIndicesPtr:le.E,getIndicesLength:le.F,getBuildingPart:le.G,getRingCount:le.H,getRingPtr:le.I,getRingLength:le.J,malloc:le.K,free:le.L,heapU8:g,heap16:j,heap32:T,heapF32:P})})}(c).then(h=>(R3=null,s7=h,s7)).catch(h=>{Rr("Could not load building-gen"),R3=null,p5e=h instanceof Error?h:new Error("Unknown error")}),R3}()}populate(c,h,g,j){const T=Idt();if(!T)return;const P=Cs(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:Ee}of c){if(O5e[Ee.type]!=="LineString"){R.set(Ee.id,Ee.properties.source_id);continue}const He=this.layers[0]._featureFilter.needGeometry;if(He&&!this.layers[0]._featureFilter.filter(new Ga(this.zoom),Ee,g))continue;const $e=qn(Ee,He);if(!He&&!this.layers[0]._featureFilter.filter(new Ga(this.zoom),$e,g))continue;const rt=He?$e.geometry:qr(Ee,g,j),it=[];for(const At of rt)for(const St of At)it.push(St.x),it.push(St.y);const lt={coordinates:it,crossPerc:Ee.properties.cross_perc,distanceToRoad:Ee.properties.distance_to_road,entrances:Ee.properties.entrances,sourceId:0},Pt=Ee.properties.source_id;let jt=F.get(Pt);jt||(jt=[],F.set(Pt,jt)),jt.push(lt),++H}this.maxHeight=0;const Q=new Array,te=new Set,re=Ee=>{Ee!=null&&te.add(Ee)},le=(Ee,He)=>{Ee!=null&&Q.push({buildingId:Ee,footprintIndex:He})},ue=64*(c.length-H),ge=ue/2;this.buildingWithFacade.reserve(ue,ge,!0),this.buildingWithoutFacade.reserve(2*ue,2*ge,!1),this.footprintsIndices.reserve(16*(c.length-H)),this.footprintsVertices.reserve(8*(c.length-H));for(const{feature:Ee,id:He,index:$e,sourceLayerIndex:rt}of c){if(O5e[Ee.type]==="LineString")continue;const it=this.layers[0]._featureFilter.needGeometry;if(it&&!this.layers[0]._featureFilter.filter(new Ga(this.zoom),Ee,g))continue;let lt=null;if(Ee.properties&&Ee.properties.hasOwnProperty("building_id")&&(lt=Number(Ee.properties.building_id),te.has(lt)))continue;const Pt=qn(Ee,it);if(!it&&!this.layers[0]._featureFilter.filter(new Ga(this.zoom),Pt,g))continue;const jt=it?Pt.geometry:qr(Ee,g,j),At=t6(jt,500);let St=!1;for(const Xn of At)if(Xn.length!==1){St=!0;break}if(St){re(lt);continue}if(!out(jt,163)){re(lt);continue}const Ct=this.layers[0],ss=lut(Ct.layout.get("building-roof-shape").evaluate(Ee,{},g)),is=Ct.layout.get("building-base").evaluate(Ee,{},g),us=Ct.layout.get("building-height").evaluate(Ee,{},g),vs=Ct.layout.get("building-flood-light-ground-radius").evaluate(Ee,{},g),hs=Ct.paint.get("building-ambient-occlusion-intensity"),Is=vs/this.tileToMeter;Ee.properties["building-part"]="roof";const es=Ct.paint.get("building-color").evaluate(Ee,{},this.canonical).toPremultipliedRenderColor(this.lut),gs=Ct.paint.get("building-emissive-strength").evaluate(Ee,{},this.canonical);Ee.properties["building-part"]="wall";const Ss=Ct.paint.get("building-color").evaluate(Ee,{},this.canonical).toPremultipliedRenderColor(this.lut),Ls=Ct.paint.get("building-emissive-strength").evaluate(Ee,{},this.canonical);Ee.properties["building-part"]="window";const Ws=Ct.paint.get("building-color").evaluate(Ee,{},this.canonical).toPremultipliedRenderColor(this.lut),pr=Ct.paint.get("building-emissive-strength").evaluate(Ee,{},this.canonical);Ee.properties["building-part"]="door";const er=Ct.paint.get("building-color").evaluate(Ee,{},this.canonical).toPremultipliedRenderColor(this.lut),Js=Ct.paint.get("building-emissive-strength").evaluate(Ee,{},this.canonical);let Ks=Ct.layout.get("building-flood-light-wall-radius").evaluate(Ee,{},g);Ks=Oe(Ks,0,2048);const dr=Ks/2048*d7,wr=R.get(He),Br=F.get(wr)||[],Tr=Br.length!==0&&Ct.layout.get("building-facade").evaluate(Ee,{},g);T.setFacadeOptions(4,!0),T.setFauxFacadeOptions(Tr,!1,1);let Nn=0,Na=0,kn=0,Ma=0,Un=0,ho=0,Wa=0,La=0,Ni=0,no=0,ic=0;if(Tr){let Xn=Math.round(Ct.layout.get("building-facade-floors").evaluate(Ee,{},g));if(is===0){Xn=Math.max(1,Xn-(Br.length>0?1:0));let Po=4;if(us>100){const Bl=[10,13,15];Po=Bl[Ee.id?Ee.id%Bl.length:0]}else us<=10&&(Po=3);T.setFacadeOptions(Po,!0),Un=(us<15?1.3:1.61803)*Po/P}else Un=is/P;ho=us/P,Un=Math.min(Un,ho),kn=Ct.layout.get("building-facade-unit-width").evaluate(Ee,{},g)/P,Ma=(ho-Un)/Xn,T.setFauxFacadeOptions(!0,!0,kn);const Ac=Ct.layout.get("building-facade-window").evaluate(Ee,{},g);Nn=Ac[0],Na=Ac[1],Wa=Math.floor(65535*Math.min(1,Un/sr)),La=Math.floor(65535*Math.min(1,ho/sr)),Ni=Math.floor(255*Nn)<<8|Math.floor(255*Na),no=Math.floor(65535*Math.min(1,kn/sr)),ic=Math.floor(65535*Math.min(1,Ma/sr))}const ao=Array(At.length),Ao={x:1/0,y:1/0},el={x:-1/0,y:-1/0},Eo={x:0,y:0};let ld=0;for(let Xn=0;Xn0){const Po=[],Bl=Array(Ac.length+1);Bl[0]=0;for(let Rp=0;Rpsr||Ao.y<0||el.y>sr)&&this.featuresOnBorder.push({featureId:Ee.id,footprintIndex:this.footprints.length});{const Xn=P3(cv,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+Xn.length),this.footprintsIndices.uint16.set(Xn,Y3),this.buildingIds.add(lt??Ee.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,Lp.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,Lp.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Dp.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Dp.y);const Ac={footprintVertexOffset:lv,footprintVertexLength:this.footprintsVertices.length-lv,footprintIndexOffset:Y3,footprintIndexLength:this.footprintsIndices.length-Y3,min:Lp,max:Dp,hiddenFlags:0,indicesOffset:z7,indicesLength:hxe,bloomIndicesOffset:cd,bloomIndicesLength:mo,groundEffectVertexOffset:P2,groundEffectVertexLength:X3,hasFauxFacade:Tr,height:Z3,promoteId:He,feature:Pt,parts:Mc,buildingBloom:Su},Po=this.footprints.length;Ee.id!==void 0&&this.featureFootprintLookup.set(Ee.id,Po),le(lt,Po),this.footprints.push(Ac)}this.programConfigurations.populatePaintArrays(Wn.layoutVertexArray.length,Ee,$e,{},h.availableImages,g,h.brightness),this.groundEffect.addPaintPropertiesData(Ee,$e,{},h.availableImages,g,h.brightness),h.featureIndex.insert(Ee,jt,$e,rt,this.index,Zd)}Q.forEach(({buildingId:Ee,footprintIndex:He})=>{te.has(Ee)&&(this.footprints[He].hiddenFlags|=4)});const ke=new Set;this.buildingIds.forEach((Ee,He,$e)=>{te.has(Ee)||ke.add(Ee)}),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,D5e.members),g.layoutNormalBuffer=c.createVertexBuffer(g.layoutNormalArray,eut.members),g.layoutCentroidBuffer=c.createVertexBuffer(g.layoutCentroidArray,tut.members),g.layoutFloodLightDataBuffer=c.createVertexBuffer(g.layoutFloodLightDataArray,iut.members),g.layoutFacadeDataArray&&g.layoutFacadeDataArray.length&&(g.layoutFacadeDataBuffer=c.createVertexBuffer(g.layoutFacadeDataArray,rut.members)),g.layoutFacadeVerticalRangeArray&&g.layoutFacadeVerticalRangeArray.length&&(g.layoutFacadeVerticalRangeBuffer=c.createVertexBuffer(g.layoutFacadeVerticalRangeArray,nut.members)),g.entranceBloom.layoutVertexArray.length&&(g.entranceBloom.layoutVertexBuffer=c.createVertexBuffer(g.entranceBloom.layoutVertexArray,D5e.members),g.entranceBloom.layoutAttenuationBuffer=c.createVertexBuffer(g.entranceBloom.layoutAttenuationArray,aut.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,R5e.members,!0),g.layoutFacadePaintArray&&(g.layoutFacadePaintBuffer?g.layoutFacadePaintBuffer.updateData(g.layoutFacadePaintArray):g.layoutFacadePaintBuffer=c.createVertexBuffer(g.layoutFacadePaintArray,sut.members,!0)),g.entranceBloom.layoutColorBuffer?g.entranceBloom.layoutColorBuffer.updateData(g.entranceBloom.layoutColorArray):g.entranceBloom.layoutColorBuffer=c.createVertexBuffer(g.entranceBloom.layoutColorArray,R5e.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 te=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 le=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),ge=j.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Ee of j.parts){let He,$e=R;Ee.part===1?($e=R,He=F):Ee.part===0?($e=H,He=Q):Ee.part===2?($e=te,He=re):Ee.part===3&&($e=le,He=ue),He=Oe(He,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||cut(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 cut(f,c,h){for(let g=0;g1&&(F=c[++R]);const Q=Math.abs(H-F.left),te=Math.abs(H-F.right),re=Math.min(Q,te);let le;const ue=T/g*(j+1);if(F.isDash){const ge=j-Math.abs(ue);le=Math.sqrt(re*re+ge*ge)}else le=j-Math.sqrt(re*re+ue*ue);this.image.data[P+H]=Math.max(0,Math.min(255,le+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),te=Math.min(H,Q);this.image.data[T+F]=Math.max(0,Math.min(255,(R.isDash?te:-te)+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 Rr("LineAtlas out of space"),null;c.length===0&&c.push(1);let R=0;for(let te=0;teh.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 d2,this.layoutVertexArray2=new Vm,this.patternVertexArray=new Vm,this.indexArray=new To,this.programConfigurations=new Ce(c.layers,{zoom:c.zoom,lut:c.lut}),this.segments=new bi,this.maxLineLength=0,this.zOffsetVertexArray=new Vm,this.elevationGroundScaleVertexArray=new Jh,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=Hpe("line",this.layers,this.pixelRatio,h);const T=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Cs(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"),le=re.isConstant()&&!re.constantOr(0);this.elevationType=P!=="sea"&&P!=="ground"&&le?"none":"offset",this.elevationType==="offset"&&P==="none"&&Rr(`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:le,index:ue,sourceLayerIndex:ge}of c){const ke=this.layers[0]._featureFilter.needGeometry,Ee=qn(re,ke);if(!this.layers[0]._featureFilter.filter(new Ga(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),Ee,g))continue;const He=T?T.evaluate(Ee,{},g):void 0,$e={id:le,properties:re.properties,type:re.type,sourceLayerIndex:ge,index:ue,geometry:ke?Ee.geometry:qr(re,g,j),patterns:{},sortKey:He};F.push($e)}T&&F.sort((re,le)=>re.sortKey-le.sortKey);const{lineAtlas:H,featureIndex:Q}=h,te=this.addConstantDashes(H);for(const re of F){const{geometry:le,index:ue,sourceLayerIndex:ge}=re;if(te&&this.addFeatureDashes(re,H),this.hasPattern){const ke=Gpe("line",this.layers,re,this.zoom,this.pixelRatio,h);this.patternFeatures.push(ke)}else this.addFeature(re,le,ue,g,H.positions,h.availableImages,h.brightness,h.elevationFeatures);Q.insert(c[ue].feature,le,ue,ge,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,xut)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=c.createVertexBuffer(this.patternVertexArray,yut)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,hut.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=c.createVertexBuffer(this.elevationGroundScaleVertexArray,mut.members,!0)),this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,put),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,{}),te=H.get("line-cap").evaluate(c,{}),re=H.get("line-miter-limit"),le=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 ge=this.layers[0].paint.get("line-width").value;if(ge.kind!=="constant"&&ge.isLineProgressConstant===!1&&(this.variableWidthValue=ge),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,te,re,le)){const[Ee,He]=this.clipRuntimeLinesToTile(h,1);for(let $e=0;$e0?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 t7(c,-h,-h,sr+h,sr+h)}clipRuntimeLinesToTile(c,h){const g=[];return[t7(c,-h,-h,sr+h,sr+h,g),g]}addElevatedRoadFeature(c,h,g,j,T,P,R,F){const H=[],Q=Si.getElevationFeature(c,j);if(Q){const te=this.clipLinesToTile(h,1),re=this.prepareElevatedLines(te,Q,g);for(const le of re)H.push({geometry:le,elevation:Q,elevationTileID:g,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(H.length===0)return!1;for(const te of H){const re=this.layoutVertexArray.length;this.addLine(te.geometry,c,g,T,P,R,F);const le=new Ei(g,te.elevationTileID);if(te.elevation)for(let ue=re;ue>1,this.layoutVertexArray.int16[6*ue+1]>>1),ke=le.pointElevation(ge,te.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/Cs(g);for(const P of c)Edt(P,new tm(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},St=1;if(F){const is=this.lineClips.end-this.lineClips.start;At=function(us,vs,hs){return{min:Yi(us.min,vs,hs),max:Yi(us.max,vs,hs)}}(F.progress,{min:0,max:1},At),is>0&&(St=(At.max-At.min)/is)}const Ct=+h.properties.mapbox_clip_feature_len,ss=+h.properties.mapbox_clip_seg_len;if(Number.isNaN(Ct)||Number.isNaN(ss)){for(let us=0;us=2&&c[ue-1].equals(c[ue-2]);)ue--;let ge=0;for(;ge0,gs=this.overscaling<=16?122880/(512*this.overscaling):0;if(St&&Ct==="round"){if(vsP&&(Ct="bevel"),Ct==="bevel"&&(vs>2&&(Ct="flipbevel"),vs2*gs){const Ws=Ee.sub(Ee.sub(He)._mult(gs/Ss)._round());this.updateDistance(He,Ws),this.addCurrentVertex(Ws,rt,0,0,ke,jt),He=Ws}this.updateDistance(He,Ee),is._mult(vs),this.addCurrentVertex(Ee,is,0,0,ke,jt);const Ls=Ee.dist($e);if(Ls>2*gs){const Ws=Ee.add($e.sub(Ee)._mult(gs/Ls)._round());this.updateDistance(Ee,Ws),this.addCurrentVertex(Ws,it,0,0,ke,jt),Ee=Ws}}else is._mult(vs),this.addCurrentVertex(Ee,is,0,0,ke,jt);else if(Ct==="flipbevel"){if(vs>100)is=it.mult(-1);else{const Ss=vs*rt.add(it).mag()/rt.sub(it).mag();is._perp()._mult(Ss*(es?-1:1))}this.addCurrentVertex(Ee,is,0,0,ke,jt),this.addCurrentVertex(Ee,is.mult(-1),0,0,ke,jt)}else if(Ct==="bevel"||Ct==="fakeround"){const Ss=Ee.dist(He);let Ls=1;if(this.elevationType==="offset"&&Ct==="bevel"&&this.currentLineJoinType!=="round"&&!this.patternJoinNone&&jt!=null&&He&&$e){const dr=4*gs;Ss1){this.lineSoFar=c.w;const ge=(h.x-c.x)/te,ke=(h.y-c.y)/te,Ee=(h.z-c.z)/te,He=(h.w-c.w)/te,$e=h.x-c.x,rt=h.y-c.y,it=Math.sqrt($e*$e+rt*rt);if(it===0)return;const lt=-rt/it,Pt=$e/it,jt=lt,At=Pt,St=-lt,Ct=-Pt;for(let ss=1;ss=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 te=H?H.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(te)}}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 jfe(f,c,h){return f.xh||f.yh}let q5e,U5e;function V5e(f,c,h){return c*(sr/(f.tileSize*Math.pow(2,h-f.tileID.overscaledZ)))}xr(u7,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const H5e=(f,c,h)=>(1-h)*f+h*c;function G5e(f,c){return 1/V5e(f,1,c.tileZoom)}function W5e(f,c,h,g){return f.translatePosMatrix(g||c.tileID.projMatrix,c,h.paint.get("line-translate"),h.paint.get("line-translate-anchor"))}const K5e=f=>{const c=[];Z5e(f)&&c.push("RENDER_LINE_DASH"),f.paint.get("line-gradient")&&c.push("RENDER_LINE_GRADIENT"),f.paint.get("line-blend-mode")==="multiply"&&c.push("LINE_BLEND_MULTIPLY");const h=f.paint.get("line-trim-offset");h[0]===0&&h[1]===0||c.push("RENDER_LINE_TRIM_OFFSET"),f.paint.get("line-border-width").constantOr(1)!==0&&c.push("RENDER_LINE_BORDER");const g=f.layout.get("line-join").constantOr("miter")==="none",j=!!f.paint.get("line-pattern").constantOr(1);return g&&j&&c.push("LINE_JOIN_NONE"),c};function Z5e(f){const c=f.paint.get("line-dasharray").value;return c.kind!=="constant"||c.value}let Nfe;const Y5e=()=>Nfe||(Nfe={layout:q5e||(q5e=new Xi({"line-cap":new Vs(Gt.layout_line["line-cap"]),"line-join":new Vs(Gt.layout_line["line-join"]),"line-miter-limit":new Ys(Gt.layout_line["line-miter-limit"]),"line-round-limit":new Ys(Gt.layout_line["line-round-limit"]),"line-sort-key":new Vs(Gt.layout_line["line-sort-key"]),"line-z-offset":new Vs(Gt.layout_line["line-z-offset"]),"line-elevation-reference":new Ys(Gt.layout_line["line-elevation-reference"]),"line-cross-slope":new Ys(Gt.layout_line["line-cross-slope"]),visibility:new Ys(Gt.layout_line.visibility),"line-width-unit":new Ys(Gt.layout_line["line-width-unit"]),"line-elevation-ground-scale":new Vs(Gt.layout_line["line-elevation-ground-scale"])})),paint:U5e||(U5e=new Xi({"line-opacity":new Vs(Gt.paint_line["line-opacity"]),"line-color":new Vs(Gt.paint_line["line-color"]),"line-translate":new Ys(Gt.paint_line["line-translate"]),"line-translate-anchor":new Ys(Gt.paint_line["line-translate-anchor"]),"line-width":new Vs(Gt.paint_line["line-width"]),"line-gap-width":new Vs(Gt.paint_line["line-gap-width"]),"line-offset":new Vs(Gt.paint_line["line-offset"]),"line-blur":new Vs(Gt.paint_line["line-blur"]),"line-dasharray":new Vs(Gt.paint_line["line-dasharray"]),"line-pattern":new Vs(Gt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Ys(Gt.paint_line["line-pattern-cross-fade"]),"line-gradient":new Y1(Gt.paint_line["line-gradient"]),"line-trim-offset":new Ys(Gt.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ys(Gt.paint_line["line-trim-fade-range"]),"line-trim-color":new Ys(Gt.paint_line["line-trim-color"]),"line-emissive-strength":new Vs(Gt.paint_line["line-emissive-strength"]),"line-border-width":new Vs(Gt.paint_line["line-border-width"]),"line-border-color":new Vs(Gt.paint_line["line-border-color"]),"line-occlusion-opacity":new Ys(Gt.paint_line["line-occlusion-opacity"]),"line-blend-mode":new Ys(Gt.paint_line["line-blend-mode"]),"line-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"})}))},Nfe);class wut extends Vs{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 m6;function X5e(f,c){return c>0?c+2*f:f}const jut=la([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Nut=la([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),kut=la([{name:"a_projected_pos",components:4,type:"Float32"}],4);la([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Sut=la([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Cut=la([{name:"a_feature_index",components:1,type:"Float32"}],4),Mut=la([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),Tut=la([{name:"a_texb",components:2,type:"Uint16"}]),Aut=la([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Eut=la([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);la([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Q5e=la([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Put=la([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);la([{name:"triangle",components:3,type:"Uint16"}]),la([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),la([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}]),la([{type:"Float32",name:"offsetX"}]),la([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const kfe=class Rie{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(Rie.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,Rie.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)}}};kfe.HEADER_DWORDS=12,kfe.HEADER_BYTES=48;let Sfe=kfe;function Cfe(f,c,h,g){return[M3(255*f,255*c),M3(255*h,255*g)]}function J5e(f,c,h,g,j,T,P,R){return!!f&&(f.kind==="constant"?f.value==="none":f.kind==="composite"||f.kind==="source"?f.evaluate({zoom:0,brightness:T,worldview:R},c,h,j,g,P)==="none":typeof f=="string"&&f==="none")}xr(Sfe,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});class Mfe{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:te}=h[F],re=c.get(H),le=!(!re||typeof re.isConstant!="function"||re.isConstant()),ue=this._appearancesHavePaintProperties(H),ge=le||ue,ke=!(!re||!re.value||re.value.kind!=="composite"),Ee=this.layer._transitionablePaint._values[H],He=!ge&&(Ee&&Ee.value&&Ee.value.expression&&Ee.value.expression.kind)==="camera";ge?(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){Rr(`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 Sfe(R,re,this.uboSizeDwords),this.ubos[re].writeHeader(H)),this.ubos[re].writeDataDrivenBlock(Q,le,H);const ge={batchIndex:re,localFeatureIndex:le,vtFeatureIndex:h,featureId:F};return this.allFeatures.push(ge),F!=null&&(this.featureVertexRangesFromId.has(F)||this.featureVertexRangesFromId.set(F,[]),this.featureVertexRangesFromId.get(F).push(ge)),le}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 te=P[H]||{};for(const re of Q){if(!g)continue;const le=g.feature(re.vtFeatureIndex);if(!le)continue;const ue={type:le.type,id:H,properties:le.properties||{},geometry:[]},ge=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(re.vtFeatureIndex):void 0,ke=this.evaluateAllProperties(ue,te,j,T,R,void 0,ge);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]||{},te={type:H.type,id:F.featureId,properties:H.properties||{},geometry:[]},re=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(F.vtFeatureIndex):void 0,le=this.evaluateAllProperties(te,Q,g,j,P,void 0,re);this.ubos[F.batchIndex]&&this.ubos[F.batchIndex].writeDataDrivenBlock(le,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 te=this.evaluateAllProperties(h,g,j,T,P,void 0,R);this.ubos[Q.batchIndex]&&(this.ubos[Q.batchIndex].writeDataDrivenBlock(te,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 le=P[re],ue=T.get(le.name);if(!ue)return[0,0,0,1];const ge=le.useThemeName?T.get(le.useThemeName):void 0,ke=J5e(ge&&typeof ge!="string"?ge.value:void 0,F,{},[],void 0,h,void 0,this.worldview)?null:this.lut;let Ee;Ee=g&&g.cameraMask&1<{const ue=T.get(P[re].name);if(!ue)return le;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()),Wx.applyArabicShaping&&(j=Wx.applyArabicShaping(j)),j}(g.text,c,h)}),f}const p6={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Lut(f){return f==="︶"||f==="﹈"||f==="︸"||f==="﹄"||f==="﹂"||f==="︾"||f==="︼"||f==="︺"||f==="︘"||f==="﹀"||f==="︐"||f==="︓"||f==="︔"||f==="`"||f===" ̄"||f==="︑"||f==="︒"}function Dut(f){return f==="︵"||f==="﹇"||f==="︷"||f==="﹃"||f==="﹁"||f==="︽"||f==="︻"||f==="︹"||f==="︗"||f==="︿"}const Tfe=4294967296,eMe=1/Tfe,tMe=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let h7=class{constructor(f=new Uint8Array(16)){this.buf=ArrayBuffer.isView(f)?f:new Uint8Array(f),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(f,c,h=this.length){for(;this.pos>3,T=this.pos;this.type=7&g,f(j,c,this),this.pos===T&&this.skip(g)}return c}readMessage(f,c){return this.readFields(f,c,this.readVarint()+this.pos)}readFixed32(){const f=this.dataView.getUint32(this.pos,!0);return this.pos+=4,f}readSFixed32(){const f=this.dataView.getInt32(this.pos,!0);return this.pos+=4,f}readFixed64(){const f=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Tfe;return this.pos+=8,f}readSFixed64(){const f=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Tfe;return this.pos+=8,f}readFloat(){const f=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,f}readDouble(){const f=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,f}readVarint(f){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 F3(j,F,T);throw new Error("Expected varint not more than 10 bytes")}(h,f,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const f=this.readVarint();return f%2==1?(f+1)/-2:f/2}readBoolean(){return!!this.readVarint()}readString(){const f=this.readVarint()+this.pos,c=this.pos;return this.pos=f,f-c>=12&&tMe?tMe.decode(this.buf.subarray(c,f)):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&&(te=R):re===2?(F=h[P+1],(192&F)==128&&(te=(31&R)<<6|63&F,te<=127&&(te=null))):re===3?(F=h[P+1],H=h[P+2],(192&F)==128&&(192&H)==128&&(te=(15&R)<<12|(63&F)<<6|63&H,(te<=2047||te>=55296&&te<=57343)&&(te=null))):re===4&&(F=h[P+1],H=h[P+2],Q=h[P+3],(192&F)==128&&(192&H)==128&&(192&Q)==128&&(te=(15&R)<<18|(63&F)<<12|(63&H)<<6|63&Q,(te<=65535||te>=1114112)&&(te=null))),te===null?(te=65533,re=1):te>65535&&(te-=65536,T+=String.fromCharCode(te>>>10&1023|55296),te=56320|1023&te),T+=String.fromCharCode(te),P+=re}return T}(this.buf,c,f)}readBytes(){const f=this.readVarint()+this.pos,c=this.buf.subarray(this.pos,f);return this.pos=f,c}readPackedVarint(f=[],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(f,c){this.writeVarint(f<<3|c)}realloc(f){let c=this.length||16;for(;c268435455||f<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)}(f,this):(this.realloc(4),this.buf[this.pos++]=127&f|(f>127?128:0),f<=127||(this.buf[this.pos++]=127&(f>>>=7)|(f>127?128:0),f<=127||(this.buf[this.pos++]=127&(f>>>=7)|(f>127?128:0),f<=127||(this.buf[this.pos++]=f>>>7&127))))}writeSVarint(f){this.writeVarint(f<0?2*-f-1:2*f)}writeBoolean(f){this.writeVarint(+f)}writeString(f){f=String(f),this.realloc(4*f.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,f,this.pos);const h=this.pos-c;h>=128&&sMe(c,h,this),this.pos=c-1,this.writeVarint(h),this.pos+=h}writeFloat(f){this.realloc(4),this.dataView.setFloat32(this.pos,f,!0),this.pos+=4}writeDouble(f){this.realloc(8),this.dataView.setFloat64(this.pos,f,!0),this.pos+=8}writeBytes(f){const c=f.length;this.writeVarint(c),this.realloc(c);for(let h=0;h=128&&sMe(h,g,this),this.pos=h-1,this.writeVarint(g),this.pos+=g}writeMessage(f,c,h){this.writeTag(f,2),this.writeRawMessage(c,h)}writePackedVarint(f,c){c.length&&this.writeMessage(f,Rut,c)}writePackedSVarint(f,c){c.length&&this.writeMessage(f,Out,c)}writePackedBoolean(f,c){c.length&&this.writeMessage(f,But,c)}writePackedFloat(f,c){c.length&&this.writeMessage(f,Fut,c)}writePackedDouble(f,c){c.length&&this.writeMessage(f,zut,c)}writePackedFixed32(f,c){c.length&&this.writeMessage(f,$ut,c)}writePackedSFixed32(f,c){c.length&&this.writeMessage(f,qut,c)}writePackedFixed64(f,c){c.length&&this.writeMessage(f,Uut,c)}writePackedSFixed64(f,c){c.length&&this.writeMessage(f,Vut,c)}writeBytesField(f,c){this.writeTag(f,2),this.writeBytes(c)}writeFixed32Field(f,c){this.writeTag(f,5),this.writeFixed32(c)}writeSFixed32Field(f,c){this.writeTag(f,5),this.writeSFixed32(c)}writeFixed64Field(f,c){this.writeTag(f,1),this.writeFixed64(c)}writeSFixed64Field(f,c){this.writeTag(f,1),this.writeSFixed64(c)}writeVarintField(f,c){this.writeTag(f,0),this.writeVarint(c)}writeSVarintField(f,c){this.writeTag(f,0),this.writeSVarint(c)}writeStringField(f,c){this.writeTag(f,2),this.writeString(c)}writeFloatField(f,c){this.writeTag(f,5),this.writeFloat(c)}writeDoubleField(f,c){this.writeTag(f,1),this.writeDouble(c)}writeBooleanField(f,c){this.writeVarintField(f,+c)}};function F3(f,c,h){return h?4294967296*c+(f>>>0):4294967296*(c>>>0)+(f>>>0)}function sMe(f,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>=f;j--)h.buf[j+g]=h.buf[j]}function Rut(f,c){for(let h=0;h=0&&g>=c&&m7[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 z3;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(f6.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 Afe(f,c,h,g,j,T,P,R,F,H,Q,te,re,le,ue,ge=1,ke=1){const Ee=z3.fromFeature(f,j,ge,ke);te===am.vertical&&Ee.verticalizePunctuation(re);let He=[];const $e=function(jt,At,St,Ct,ss,is,us=1){if(!jt)return[];const vs=[],hs=function(gs,Ss,Ls,Ws,pr,er,Js=1){let Ks=0;for(let dr=0;dr=0;let es=0;for(let gs=0;gs0&&Zd>Un&&(Un=Zd)}else{const Mc=St[no.fontStack];if(!Mc)continue;Mc[ao]&&(Eo=Mc[ao]);const Su=At[no.fontStack];if(!Su)continue;const cd=Su.glyphs[ao];if(!cd)continue;if(el=cd.metrics,oc=ao!==8203?ac:0,Js){const mo=Su.ascender!==void 0?Math.abs(Su.ascender):0,Zd=Su.descender!==void 0?Math.abs(Su.descender):0,Tc=(mo+Zd)*Ao;ho-h/2;){if(P--,P<0)return!1;R-=f[P].dist(T),T=f[P]}R+=f[P].dist(f[P+1]),P++;const F=[];let H=0;for(;Rg;)H-=F.shift().angleDelta;if(H>j)return!1;P++,R+=Q.dist(te)}return!0}function hMe(f){let c=0;for(let h=0;hH){const ue=(H-F)/le,ge=sn(te.x,re.x,ue),ke=sn(te.y,re.y,ue),Ee=new ov(ge,ke,0,re.angleTo(te),Q);return!P||uMe(f,Ee,R,P,c)?Ee:void 0}F+=le}}function Xut(f,c,h,g,j,T,P,R,F){const H=mMe(g,T,P),Q=pMe(g,j),te=Q*P,re=f[0].x===0||f[0].x===F||f[0].y===0||f[0].y===F;return c-te=0&&rt=0&&it=0&&re+H<=Q){const lt=new ov(rt,it,0,He,ue);g&&!uMe(f,lt,T,g,j)||le.push(lt)}}te+=Ee}return R||le.length||P||(le=fMe(f,te/2,h,g,j,T,P,!0,F)),le}function xMe(f){let c=0,h=0;for(const P of f)c+=P.w*P.h,h=Math.max(h,P.w);f.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 f)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:f.versionc.version?1:f.sxc.sx?1:f.syc.sy?1:0}function Dfe(f){let c=0;for(let h=0;h0,gMe(c,g,this.iconDescriptors,T),gMe(h,g,this.patternDescriptors,T),this.iconDescriptors.sort(f7),this.patternDescriptors.sort(f7);let P=0;const R=j?j.data:"";R&&(P=Jx(P,Dfe(R))),P=Jx(P,1);for(const F of this.iconDescriptors)P=Jx(P,Dfe(F.id)),P=Jx(P,F.version),P=Jx(P,F.sx),P=Jx(P,F.sy);P=Jx(P,1);for(const F of this.patternDescriptors)P=Jx(P,Dfe(F.id)),P=Jx(P,F.version),P=Jx(P,F.sx),P=Jx(P,F.sy);this.hash=P}subsetOf(c){return this.isSubsetArray(this.iconDescriptors,c.iconDescriptors,f7)&&this.isSubsetArray(this.patternDescriptors,c.patternDescriptors,f7)}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 yMe{constructor(c){this.sourceAtlasHash=c}}class vMe{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?Ffe(c,H):c,te=F?Ffe(h,H):h;this.addImages(Q,T,1,R),this.addImages(te,P,2,R);const{w:re,h:le}=xMe(R),ue=new Ed({width:re||1,height:le||1});for(const[ge,ke]of Q.entries()){const Ee=T.get(ge).paddedRect;Ed.copy(ke.data,ue,{x:0,y:0},{x:Ee.x+1,y:Ee.y+1},ke.data,null,ke.sdf)}for(const[ge,ke]of te.entries()){const Ee=P.get(ge),He=Ee.paddedRect;let $e=Ee.padding;const rt=He.x+$e,it=He.y+$e,lt=ke.data.width,Pt=ke.data.height;$e=$e>1?$e-1:$e,Ed.copy(ke.data,ue,{x:0,y:0},{x:rt,y:it},ke.data,g),Ed.copy(ke.data,ue,{x:0,y:Pt-$e},{x:rt,y:it-$e},{width:lt,height:$e},g),Ed.copy(ke.data,ue,{x:0,y:0},{x:rt,y:it+Pt},{width:lt,height:$e},g),Ed.copy(ke.data,ue,{x:lt-$e,y:0},{x:rt-$e,y:it},{width:$e,height:Pt},g),Ed.copy(ke.data,ue,{x:0,y:0},{x:rt+lt,y:it},{width:$e,height:Pt},g),Ed.copy(ke.data,ue,{x:lt-$e,y:Pt-$e},{x:rt-$e,y:it-$e},{width:$e,height:$e},g),Ed.copy(ke.data,ue,{x:0,y:Pt-$e},{x:rt+lt,y:it-$e},{width:$e,height:$e},g),Ed.copy(ke.data,ue,{x:0,y:0},{x:rt+lt,y:it+Pt},{width:$e,height:$e},g),Ed.copy(ke.data,ue,{x:lt-$e,y:0},{x:rt-$e,y:it+Pt},{width:$e,height:$e},g)}this.lut=g,this.image=ue,this.iconPositions=T,this.patternPositions=P,F&&(this.contentDescriptor=new Rfe(Q,te,j,g,H))}addImages(c,h,g,j){for(const[T,P]of c.entries()){const{bin:R,imagePosition:F,imageVariant:H}=Ofe(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=qm.parse(P);if(kc.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=qm.parse(P);if(kc.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 Ed(F);Ed.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})}}xr(x6,"ImagePosition"),xr(vMe,"ImageAtlas",{omit:["lut"]}),xr(yMe,"ImageAtlasReference");class g6{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 g6.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,te)=>{if(!R.callbackCalled&&(Q&&!R.firstError&&(R.firstError=Q),te&&(P[H]=te),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 le=this._composeGlyphs(re);T(null,le)}};for(let H=0;H{F(H,Q,te)})}_loadFont(c,h,g,j,T){const P=`${c}:${h}`;if(this.cachedRanges.has(P)){const F=this.cachedRanges.get(P);return void Sd.frame(()=>T(null,F))}const R=this.pendingRequests.get(P);R?R.push(T):(this.pendingRequests.set(P,[T]),g6.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 te of Q)te(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}}}g6.loadGlyphRange=function(f,c,h,g,j){const T=256*c,P=T+255,R=g.transformRequest(g.normalizeGlyphsURL(h).replace("{fontstack}",f).replace("{range}",`${T}-${P}`),I0.Glyphs);Jg(R,(F,H)=>{if(F)j(F);else if(H){const Q={},te=function(re){return new h7(re).readFields(Hut,{})}(H);for(const re of te.glyphs)Q[re.id]=re;j(null,{glyphs:Q,ascender:te.ascender,descender:te.descender})}})};const y6=1e20;function _Me(f,c,h,g,j,T,P,R,F){for(let H=c;H-1);F++,T[F]=R,P[F]=H,P[F+1]=y6}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||ua.GLYPHS_URL;for(const T in c)for(const P of c[T])g.push({stack:T,id:P});bt(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 Rr("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 te=F.requests[Q];te||(te=F.requests[Q]=[],this.glyphLoader.loadGlyphRange(T,Q,j,this.requestManager,(re,le)=>{if(le){F.ascender=le.ascender,F.descender=le.descender;for(const ue in le.glyphs)this._doesCharSupportLocalGlyph(+ue)||(F.glyphs[+ue]=le.glyphs[+ue]);F.ranges[Q]=!0}for(const ue of te)ue(re,le);delete F.requests[Q]})),te.push((re,le)=>{re?R(re):le&&R(null,{stack:T,id:P,glyph:le.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!==zfe.none&&(this.localGlyphMode===zfe.all?!!this.localFontFamily:!!this.localFontFamily&&(u3(c)||uP(c)||a2(c)||W0(c)||n2(c)||cP(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 x7.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:te,glyphHeight:re,glyphLeft:le,glyphTop:ue,glyphAdvance:ge}=T.draw(R);return this.localGlyphs[P][g]={id:g,bitmap:new s_({width:H,height:Q},F),metrics:{width:te/2,height:re/2,left:le/2,top:ue/2-27,advance:ge/2,localGlyph:!0}}}}function wMe(f,c){return f+c[1]-c[0]}function Bfe(f,c,h,g,j=1){const T=[],P=f.imagePrimary,R=P.pixelRatio,F=P.paddedRect.w-2,H=P.paddedRect.h-2,Q=(f.right-f.left)*j,te=(f.bottom-f.top)*j,re=P.stretchX||[[0,F]],le=P.stretchY||[[0,H]],ue=re.reduce(wMe,0),ge=le.reduce(wMe,0),ke=F-ue,Ee=H-ge;let He=0,$e=ue,rt=0,it=ge,lt=0,Pt=ke,jt=0,At=Ee;if(P.content&&g){const Ct=P.content;He=g7(re,0,Ct[0]),rt=g7(le,0,Ct[1]),$e=g7(re,Ct[0],Ct[2]),it=g7(le,Ct[1],Ct[3]),lt=Ct[0]-He,jt=Ct[1]-rt,Pt=Ct[2]-Ct[0]-$e,At=Ct[3]-Ct[1]-it}const St=(Ct,ss,is,us)=>{const vs=y7(Ct.stretch-He,$e,Q,f.left*j),hs=v7(Ct.fixed-lt,Pt,Ct.stretch,ue),Is=y7(ss.stretch-rt,it,te,f.top*j),es=v7(ss.fixed-jt,At,ss.stretch,ge),gs=y7(is.stretch-He,$e,Q,f.left*j),Ss=v7(is.fixed-lt,Pt,is.stretch,ue),Ls=y7(us.stretch-rt,it,te,f.top*j),Ws=v7(us.fixed-jt,At,us.stretch,ge),pr=new rs(vs,Is),er=new rs(gs,Is),Js=new rs(gs,Ls),Ks=new rs(vs,Ls),dr=new rs(hs/R,es/R),wr=new rs(Ss/R,Ws/R),Br=c*Math.PI/180;if(Br){const Un=Math.sin(Br),ho=Math.cos(Br),Wa=[ho,-Un,Un,ho];pr._matMult(Wa),er._matMult(Wa),Ks._matMult(Wa),Js._matMult(Wa)}const Tr=Ct.stretch+Ct.fixed,Nn=is.stretch+is.fixed,Na=ss.stretch+ss.fixed,kn=us.stretch+us.fixed,Ma=f.imageSecondary;return{tl:pr,tr:er,bl:Ks,br:Js,texPrimary:{x:P.paddedRect.x+1+Tr,y:P.paddedRect.y+1+Na,w:Nn-Tr,h:kn-Na},texSecondary:Ma?{x:Ma.paddedRect.x+1+Tr,y:Ma.paddedRect.y+1+Na,w:Nn-Tr,h:kn-Na}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:dr,pixelOffsetBR:wr,minFontScaleX:Pt/R/Q,minFontScaleY:At/R/te,isSDF:h}};if(P.stretchX||P.stretchY){const Ct=jMe(re,ke,ue),ss=jMe(le,Ee,ge);for(let is=0;is0?[He,-$e]:rt<0?[-He,$e]:He===0?[$e,He]:[$e,-He]}(h);let le=Math.abs(c.top-c.bottom);for(const Ee of c.positionedLines)le-=Ee.lineOffset;const ue=c.positionedLines.length,ge=le/ue;let ke=c.top-h[1];for(let Ee=0;EeT)&&(T=ue.x),(!le||ue.y>P)&&(P=ue.y)}const F=Math.min(T-g,P-j);let H=F/2;const Q=new Uw([],tht);if(F===0)return new rs(g,j);for(let le=g;lete.d||!te.d)&&(te=le,h&&console.log("found best %d after %d probes",Math.round(1e4*le.d)/1e4,re)),le.max-te.d<=c||(H=le.h/2,Q.push(new $3(le.p.x-H,le.p.y-H,H,f)),Q.push(new $3(le.p.x+H,le.p.y-H,H,f)),Q.push(new $3(le.p.x-H,le.p.y+H,H,f)),Q.push(new $3(le.p.x+H,le.p.y+H,H,f)),re+=4)}return h&&(console.log(`num probes: ${re}`),console.log(`best distance: ${te.d}`)),te.p}function tht(f,c){return c.max-f.max}x7.TinySDF=class{constructor({fontSize:f=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=f+4*c,H=this._createCanvas(F),Q=this.ctx=H.getContext("2d",{willReadFrequently:!0});Q.font=`${P} ${T} ${f}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(f){const c=document.createElement("canvas");return c.width=c.height=f,c}draw(f){const{width:c,actualBoundingBoxAscent:h,actualBoundingBoxDescent:g,actualBoundingBoxLeft:j,actualBoundingBoxRight:T}=this.ctx.measureText(f),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,te=Math.max(H*Q,0),re=new Uint8ClampedArray(te),le={data:re,width:H,height:Q,glyphWidth:R,glyphHeight:F,glyphTop:P,glyphLeft:0,glyphAdvance:c};if(R===0||F===0)return le;const{ctx:ue,buffer:ge,gridInner:ke,gridOuter:Ee}=this;this.lang&&(ue.lang=this.lang),ue.clearRect(ge,ge,R,F),ue.fillText(f,ge,ge+P);const He=ue.getImageData(ge,ge,R,F);Ee.fill(y6,0,te),ke.fill(0,0,te);for(let $e=0;$e0?Pt*Pt:0,ke[lt]=Pt<0?Pt*Pt:0}}_Me(Ee,0,0,H,Q,H,this.f,this.v,this.z),_Me(ke,ge,ge,R,F,H,this.f,this.v,this.z);for(let $e=0;$eT.y!=ge.y>T.y&&T.x<(ge.x-ue.x)*(T.y-ue.y)/(ge.y-ue.y)+ue.x&&(R=!R),F=Math.min(F,Rf(T,ue,ge))}}return(R?1:-1)*Math.sqrt(F)}(this.p,j),this.max=this.d+this.h*Math.SQRT2}}const sht=Object.keys,$fe=Number.POSITIVE_INFINITY,rht=Math.sqrt(2);function i_(f,c,h,g,j,T){const P=Pfe(f)&&f.collisionPadding?f.collisionPadding:[0,0,0,0],R={top:f.top-P[1],bottom:f.bottom+P[3],left:f.left-P[0],right:f.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 te=Kt(H),re=new rs(Q?Q[0]:0,Q?Q[1]:0),le=new rs(F.left,F.top),ue=new rs(F.right,F.top),ge=new rs(F.left,F.bottom),ke=new rs(F.right,F.bottom);le._rotateAround(te,re),ue._rotateAround(te,re),ge._rotateAround(te,re),ke._rotateAround(te,re),F.left=Math.min(le.x,ue.x,ge.x,ke.x),F.right=Math.max(le.x,ue.x,ge.x,ke.x),F.top=Math.min(le.y,ue.y,ge.y,ke.y),F.bottom=Math.max(le.y,ue.y,ge.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 SMe(f,[c,h]){let g=0,j=0;if(h===$fe){c<0&&(c=0);const T=c/rht;switch(f){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(f){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),f){case"top-right":case"top-left":case"top":j=h-7;break;case"bottom-right":case"bottom-left":case"bottom":j=7-h}switch(f){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 nht(f,c,h,g,j,T,P,R,F,H,Q,te,re,le,ue){const ge=f.layers[0],ke=ge.appearances;if(ke.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Ee={iconBBox:null,iconVerticalBBox:null},He={textBBox:null,textVerticalBBox:null},{baseIconRotate:$e,baseTextRotate:rt,iconScaleFactor:it}=function(Pt,jt,At){const St=Pt.get("icon-rotate").evaluate(jt,{},At),Ct=Pt.get("text-rotate").evaluate(jt,{},At),[ss,is]=Pt.get("icon-size-scale-range");return{baseIconRotate:St,baseTextRotate:Ct,iconScaleFactor:Oe(1,ss,is)}}(g,j,T);c&&(Ee.iconBBox=i_(c,Ee.iconBBox,$e),h)&&(Ee.iconVerticalBBox=i_(h,Ee.iconVerticalBBox,$e+90));const lt=b7(te.horizontal);lt&&(He.textBBox=i_(lt,He.textBBox,rt,1,le)),te.vertical&&(He.textVerticalBBox=i_(te.vertical,He.textVerticalBBox,rt+90,1,le));for(const Pt of ke)Pt.hasIconLayoutProperties()&&aht(Ee,f,ge,Pt,j,T,R,$e,P,F,c,H,it,Q,ue),Pt.hasTextLayoutProperties()&&iht(He,ge,Pt,j,T,le,rt,re,lt,te.vertical);return{iconBBox:Ee.iconBBox,iconVerticalBBox:Ee.iconVerticalBBox,textBBox:He.textBBox,textVerticalBBox:He.textVerticalBBox}}function aht(f,c,h,g,j,T,P,R,F,H,Q,te,re,le,ue){const{appearanceIconOffset:ge,appearanceIconRotate:ke,appearanceIconSize:Ee}=CMe(g,h,j,T,P,R,F,H.iconScaleFactor);let He=null,$e=null,rt=null;g.hasLayoutProperty("icon-image")?rt=function(lt,Pt,jt,At,St,Ct,ss,is){let us=null;const vs=Pt.getAppearanceValueAndResolveTokens(jt,"icon-image",At,St,is);if(vs){const hs=lt.getResolvedImageFromTokens(vs),Is=jt.hasLayoutProperty("icon-size")?jt.getUnevaluatedLayoutProperty("icon-size"):Pt._unevaluatedLayout._values["icon-size"],es=v6(hs,S2(lt.zoom,Is,lt.worldview,is),Is,St,lt.zoom,At,lt.pixelRatio,ss,lt.worldview,is);us=Ct.get(es.iconPrimary.toString())}return us}(c,h,g,j,T,te,re,ue):Q&&(rt=Q.imagePrimary),rt&&(He=p7(rt,null,ge,le),c.allowVerticalPlacement&&($e=p7(rt,null,ge,le)));const it=F>0?Ee/F:1;He&&(f.iconBBox=i_(He,f.iconBBox,ke,it!==1?it:void 0)),$e&&(f.iconVerticalBBox=i_($e,f.iconVerticalBBox,ke+90,it!==1?it:void 0))}function CMe(f,c,h,g,j,T,P,R){const F=f.hasLayoutProperty("icon-offset")?c.getAppearanceValueAndResolveTokens(f,"icon-offset",h,g,[]):null,H=F&&Array.isArray(F)?F:j,Q=f.hasLayoutProperty("icon-rotate")?c.getAppearanceValueAndResolveTokens(f,"icon-rotate",h,g,[]):null,te=typeof Q=="number"?Q:T,re=f.hasLayoutProperty("icon-size")?c.getAppearanceValueAndResolveTokens(f,"icon-size",h,g,[]):null;return{appearanceIconOffset:H,appearanceIconRotate:te,appearanceIconSize:typeof re=="number"?re*R:P}}function iht(f,c,h,g,j,T,P,R,F,H){const{appearanceTextOffset:Q,appearanceTextRotate:te,appearanceTextSize:re}=MMe(h,c,g,j,T,P,R),le=re/R,ue=[(Q[0]-T[0])*le,(Q[1]-T[1])*le],ge=ue[0]!==0||ue[1]!==0;F&&(f.textBBox=i_(F,f.textBBox,te,le,Q,ge?ue:void 0)),H&&(f.textVerticalBBox=i_(H,f.textVerticalBBox,te+90,le,Q,ge?ue:void 0))}function MMe(f,c,h,g,j,T,P){const R=f.hasLayoutProperty("text-offset")?c.getAppearanceValueAndResolveTokens(f,"text-offset",h,g,[]):null,F=R&&Array.isArray(R)?[R[0]*ac,R[1]*ac]:j,H=f.hasLayoutProperty("text-rotate")?c.getAppearanceValueAndResolveTokens(f,"text-rotate",h,g,[]):null,Q=typeof H=="number"?H:T,te=f.hasLayoutProperty("text-size")?c.getAppearanceValueAndResolveTokens(f,"text-size",h,g,[]):null;return{appearanceTextOffset:F,appearanceTextRotate:Q,appearanceTextSize:typeof te=="number"?te:P}}function _7(f,c,h,g,j,T,P,R,F){if(!c||!c.usvg)return;const H=dMe(g),Q=dMe(j),te=T!=="both"&&T!=="width"||!lMe(g)?1:Q.width/H.width,re=T!=="both"&&T!=="height"||!cMe(g)?1:Q.height/H.height;h.scaleSelf(te,re);const le=h.toString();P.set(le,h),R.set(le,c);const{imagePosition:ue}=Ofe(le,c,1);F.set(le,ue)}function TMe(f,c,h,g,j,T,P,R,F,H){if(!f)return;const Q=function(te,re,le,ue,ge,ke,Ee){if(te.kind==="camera")return te.maxSize;if(te.kind==="composite"){const He=re.possiblyEvaluate(new Ga(te.maxZoom,{worldview:ke}),le,Ee).evaluate(ge,{},le,Ee),$e=re.possiblyEvaluate(new Ga(te.minZoom,{worldview:ke}),le,Ee).evaluate(ge,{},le,Ee);return Math.max(He,$e)}return re.possiblyEvaluate(new Ga(ue,{worldview:ke}),le,Ee).evaluate(ge,{},le,Ee)}(c,h,g,j,T,F,H);return f.scaleSelf(Q*R*P)}function v6(f,c,h,g,j,T,P,R,F,H){return{iconPrimary:TMe(f.getPrimary(),c,h,g,j,T,P,R,F,H),iconSecondary:TMe(f.getSecondary(),c,h,g,j,T,P,R,F,H)}}function oht(f,c,h){if(!c)return;const g=h.get(f.toString()),j=h.get(c.toString());g&&j&&(g.paddedRect.w===j.paddedRect.w&&g.paddedRect.h===j.paddedRect.h||Rr(`Mismatch in icon variant sizes: ${f.toString()} and ${c.toString()}`),g.usvg!==j.usvg&&Rr(`Mismatch in icon variant image types: ${f.id} and ${c.id}`))}function AMe(f,c,h,g){if(!f)return;const j=c.get(h.toString());if(j&&(f.imagePrimary=j),g){const T=c.get(g.toString());f.imageSecondary=T}}function lht(f,c){for(const h in f.horizontal)EMe(f.horizontal[h],c);EMe(f.vertical,c)}function EMe(f,c){if(f){for(const h of f.positionedLines)for(const g of h.positionedGlyphs)if(g.image!==null){const j=g.image.toString();g.rect=c.get(j).paddedRect}}}function qfe(f){switch(f){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function cht(f,c,h,g,j,T,P,R,F){const H=b7(T.horizontal)||T.vertical,Q=h.get("icon-text-fit-padding").evaluate(g,{},j);let te,re=c;return c&&F!=="none"&&(f.allowVerticalPlacement&&T.vertical&&(te=Ife(c,T.vertical,F,Q,R,P)),H&&(re=Ife(c,H,F,Q,R,P))),{defaultShapedIcon:re,verticallyShapedIcon:te}}function PMe(f,c){return f*c/24}function dht(f,c,h,g,j,T,P,R,F,H,Q,te,re,le,ue,ge,ke,Ee,He,$e,rt,it,lt,Pt){let jt=P.textMaxSize.evaluate(c,{},re);jt===void 0?jt=R*P.textScaleFactor:jt*=P.textScaleFactor;const At=f.layers[0].layout,St=PMe(R,P.textScaleFactor),Ct=b7(h.horizontal)||h.vertical,ss=f.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),is=f.getAppearanceFeatureData(c.index);(ke!=="none"||ss)&&is&&(is.textShaping=Ct,is.iconTextFitPadding=At.get("icon-text-fit-padding").evaluate(c,{},re),is.fontScale=St,is.textScaleFactor=P.textScaleFactor);const us=le.name==="globe",vs=f.tilePixelRatio*jt/24,hs=(Ws=f.overscaling,f.zoom>18&&Ws>2&&(Ws>>=1),Math.max(sr/(512*Ws),1)*At.get("symbol-spacing")),Is=At.get("text-padding")*f.tilePixelRatio,es=At.get("icon-padding")*f.tilePixelRatio,gs=Kt(At.get("text-max-angle")),Ss=At.get("icon-rotation-alignment")==="map"&&$e!=="point",Ls=hs/2;var Ws;f.hasAnyIconTextFit===!1&&ke!=="none"&&(f.hasAnyIconTextFit=!0);const pr=c.properties?+c.properties[On]:null,er=pr&&f.elevationFeatureIdToIndex?f.elevationFeatureIdToIndex.get(pr):65535,Js=(Ks,dr,wr)=>{if(dr.x<0||dr.x>=sr||dr.y<0||dr.y>=sr)return;let Br=null;if(us){const{x:Tr,y:Nn,z:Na}=le.projectTilePoint(dr.x,dr.y,wr);Br={anchor:new ov(Tr,Nn,Na,0,void 0),up:le.upVector(wr,dr.x,dr.y)}}(function(Tr,Nn,Na,kn,Ma,Un,ho,Wa,La,Ni,no,ic,ao,Ao,el,Eo,ld,oc,Wn,ku,zo,Mc,Su,cd,mo,Zd,Tc,z7,Z3,Ku,hxe,Y3){const lv=Tr.addToLineVertexArray(Nn,kn);let cv,Lp,Dp,P2,X3,Xn,Ac,Po=0,Bl=0,Rp=0,im=0,om=-1,lm=-1;const zf={};let B7=nr("");const rg=Na?Na.anchor:Nn,Q3=z7!=="none";let J3=0,bl=0;if(La._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Bo=La.layout.get("text-offset").evaluate(zo,{},mo);J3=Bo[0]*ac,bl=Bo[1]*ac}else J3=La.layout.get("text-radial-offset").evaluate(zo,{},mo)*ac,bl=$fe;if(Tr.allowVerticalPlacement&&Ma.vertical){const Bo=Ma.vertical;if(el)Xn=Hfe(Bo),Wa&&(Ac=Hfe(Wa));else{const Cu=La.layout.get("text-rotate").evaluate(zo,{},mo)+90;Dp=w7(Ni,rg,Nn,no,ic,ao,Bo,Ao,Cu,Eo,Y3),Wa&&(P2=w7(Ni,rg,Nn,no,ic,ao,Wa,oc,Cu,null,hxe))}}if(Un){const Bo=La.layout.get("icon-rotate").evaluate(zo,{},mo),Cu=Bfe(Un,Bo,Su,Q3,Mc.iconScaleFactor),Zu=Wa?Bfe(Wa,Bo,Su,Q3,Mc.iconScaleFactor):void 0;Lp=w7(Ni,rg,Nn,no,ic,ao,Un,oc,Bo,null,Ku);const $f=function(ng,L6,e5,kmt,Smt,JTe,eAe,Cmt,eTs,pxe){const tAe=ng.layers[0],sAe=tAe.appearances;let t5=L6.length;if(e5&&(t5=Math.max(t5,e5.length)),sAe.length===0)return t5;const[Mmt,Tmt]=kmt.get("icon-size-scale-range"),Amt=Oe(1,Mmt,Tmt);for(const V7 of sAe)if(V7.hasLayoutProperty("icon-image")){const rAe=tAe.getAppearanceValueAndResolveTokens(V7,"icon-image",JTe,eAe,pxe);if(rAe){const nAe=ng.getResolvedImageFromTokens(rAe);if(nAe){const aAe=V7.hasLayoutProperty("icon-size")?V7.getUnevaluatedLayoutProperty("icon-size"):Smt._values["icon-size"],Emt=v6(nAe,S2(ng.zoom,aAe,ng.worldview,pxe),aAe,eAe,ng.zoom,JTe,ng.pixelRatio,Amt,ng.worldview,pxe),iAe=Cmt.get(Emt.iconPrimary.toString());iAe&&(t5=Math.max(t5,Qut(iAe)))}}}return t5}(Tr,Cu,Zu,La.layout,La._unevaluatedLayout,zo,mo,Tr.iconAtlasPositions,0,cd);Po=4*$f;const $7=La.layout.get("icon-size").evaluate(zo,{},mo,cd),q7=Mc.compositeIconSizes?Mc.compositeIconSizes[0].evaluate(zo,{},mo,cd):0,mxe=Mc.compositeIconSizes?Mc.compositeIconSizes[1].evaluate(zo,{},mo,cd):0,U7=Vfe(Tr.layerIds[0],Tr.iconSizeData,$7,Mc.iconScaleFactor,q7,mxe);Tr.addSymbols(Tr.icon,Cu,U7,ku,Wn,zo,void 0,Na,Nn,lv.lineStartIndex,lv.lineLength,-1,cd,mo,Zd,Tc,Tr.symbolInstances.length,$f),om=Tr.icon.placedSymbolArray.length-1,Zu&&(Bl=4*$f,Tr.addSymbols(Tr.icon,Zu,U7,ku,Wn,zo,am.vertical,Na,Nn,lv.lineStartIndex,lv.lineLength,-1,cd,mo,Zd,Tc,Tr.symbolInstances.length,$f),lm=Tr.icon.placedSymbolArray.length-1)}for(const Bo in Ma.horizontal){const Cu=Bo,Zu=Ma.horizontal[Cu];cv||(B7=nr(Zu.text),el?X3=Hfe(Zu):cv=w7(Ni,rg,Nn,no,ic,ao,Zu,Ao,La.layout.get("text-rotate").evaluate(zo,{},mo),Eo,Y3));const $f=Zu.positionedLines.length===1;if(Rp+=IMe(Tr,Na,Nn,Zu,ho,La,el,zo,Eo,lv,Ma.vertical?am.horizontal:am.horizontalOnly,$f?sht(Ma.horizontal):[Cu],zf,om,Mc,cd,mo,Tr.symbolInstances.length,Zd),$f)break}Ma.vertical&&(im+=IMe(Tr,Na,Nn,Ma.vertical,ho,La,el,zo,Eo,lv,am.vertical,["vertical"],zf,lm,Mc,cd,mo,Tr.symbolInstances.length,Zd));let ll=-1;const $l=(Bo,Cu)=>Bo?Math.max(Bo,Cu):Cu;ll=$l(X3,ll),ll=$l(Xn,ll),ll=$l(Ac,ll);const Bf=ll>-1?1:0;Tr.glyphOffsetArray.length>=65535&&Rr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),zo.sortKey!==void 0&&Tr.addToSortKeyRanges(Tr.symbolInstances.length,zo.sortKey),Tr.symbolInstances.emplaceBack(Nn.x,Nn.y,rg.x,rg.y,rg.z,zf.right>=0?zf.right:-1,zf.center>=0?zf.center:-1,zf.left>=0?zf.left:-1,zf.vertical>=0?zf.vertical:-1,om,lm,B7,cv!==void 0?cv:Tr.collisionBoxArray.length,cv!==void 0?cv+1:Tr.collisionBoxArray.length,Dp!==void 0?Dp:Tr.collisionBoxArray.length,Dp!==void 0?Dp+1:Tr.collisionBoxArray.length,Lp!==void 0?Lp:Tr.collisionBoxArray.length,Lp!==void 0?Lp+1:Tr.collisionBoxArray.length,P2||Tr.collisionBoxArray.length,P2?P2+1:Tr.collisionBoxArray.length,no,Rp,im,Po,Bl,Bf,0,J3,bl,ll,0,Q3?1:0,Z3)})(f,dr,Br,Ks,h,g,T,j,f.layers[0],f.collisionBoxArray,c.index,c.sourceLayerIndex,f.index,Is,He,H,0,es,Ss,Ee,c,P,Q,te,re,ue,ge,ke,er,rt,it,lt)};if($e==="line")for(const Ks of t7(c.geometry,0,0,sr,sr)){const dr=Xut(Ks,hs,gs,h.vertical||Ct,g,24,vs,f.overscaling,sr);for(const wr of dr)Ct&&uht(f,Ct.text,Ls,wr)||Js(Ks,wr,re)}else if($e==="line-center"){for(const Ks of c.geometry)if(Ks.length>1){const dr=Yut(Ks,gs,h.vertical||Ct,g,24,vs);dr&&Js(Ks,dr,re)}}else if(c.type==="Polygon")for(const Ks of t6(c.geometry,0)){const dr=eht(Ks,16);Js(Ks[0],new ov(dr.x,dr.y,0,0,void 0),re)}else if(c.type==="LineString")for(const Ks of c.geometry)Js(Ks,new ov(Ks[0].x,Ks[0].y,0,0,void 0),re);else if(c.type==="Point")for(const Ks of c.geometry)for(const dr of Ks)Js([dr],new ov(dr.x,dr.y,0,0,void 0),re)}const Ufe=255,C2=Ufe*iv;function IMe(f,c,h,g,j,T,P,R,F,H,Q,te,re,le,ue,ge,ke,Ee,He){const $e=kMe(0,g,F,T,P,R,j,f.allowVerticalPlacement,void 0,ue.textScaleFactor),rt=T.layout.get("text-size").evaluate(R,{},ke),it=ue.compositeTextSizes?ue.compositeTextSizes[0].evaluate(R,{},ke):0,lt=ue.compositeTextSizes?ue.compositeTextSizes[1].evaluate(R,{},ke):0,Pt=Vfe(f.layerIds[0],f.textSizeData,rt,ue.textScaleFactor,it,lt);f.addSymbols(f.text,$e,Pt,F,P,R,Q,c,h,H.lineStartIndex,H.lineLength,le,ge,ke,He,!1,Ee,$e.length);for(const jt of te)re[jt]=f.text.placedSymbolArray.length-1;return 4*$e.length}function Vfe(f,c,h,g,j,T){const P=c;let R=null;return P.kind==="source"?(R=[iv*h*g],R[0]>C2&&Rr(`${f}: Value for "text-size" is >= ${Ufe}. Reduce your "text-size".`)):P.kind==="composite"&&(R=[iv*j*g,iv*T*g],(R[0]>C2||R[1]>C2)&&Rr(`${f}: Value for "text-size" is >= ${Ufe}. Reduce your "text-size".`)),R}function b7(f){for(const c in f)return f[c];return null}function w7(f,c,h,g,j,T,P,R,F,H,Q){let te,re,le,ue;if(te=Q?Q.top:P.top,re=Q?Q.bottom:P.bottom,le=Q?Q.left:P.left,ue=Q?Q.right:P.right,Pfe(P)&&P.collisionPadding){const ge=P.collisionPadding;le-=ge[0],te-=ge[1],ue+=ge[2],re+=ge[3]}if(F){const ge=new rs(le,te),ke=new rs(ue,te),Ee=new rs(le,re),He=new rs(ue,re),$e=Kt(F);let rt=new rs(0,0);H&&(rt=new rs(H[0],H[1])),ge._rotateAround($e,rt),ke._rotateAround($e,rt),Ee._rotateAround($e,rt),He._rotateAround($e,rt),le=Math.min(ge.x,ke.x,Ee.x,He.x),ue=Math.max(ge.x,ke.x,Ee.x,He.x),te=Math.min(ge.y,ke.y,Ee.y,He.y),re=Math.max(ge.y,ke.y,Ee.y,He.y)}return f.emplaceBack(c.x,c.y,c.z,h.x,h.y,le,te,ue,re,R,g,j,T),f.length-1}function Hfe(f){Pfe(f)&&f.collisionPadding&&(f.top-=f.collisionPadding[1],f.bottom+=f.collisionPadding[3]);const c=f.bottom-f.top;return c>0?Math.max(10,c):null}function uht(f,c,h,g){const j=f.compareText;if(c in j){const T=j[c];for(let P=T.length-1;P>=0;P--)if(g.dist(T[P])$e&&(rt(lt,us,jt,At,ss,is),rt(us,Pt,ss,is,St,Ct))}rt(te,re,g,T,j,T),rt(re,le,j,T,j,P),rt(le,ue,j,P,g,P),rt(ue,te,g,P,g,T),ge-=$e,ke-=$e,Ee+=$e,He+=$e;const it=1/Math.max(Ee-ge,He-ke);return{scale:it,x:ge*it,y:ke*it,x2:Ee*it,y2:He*it,projection:c}}function DMe(f,{x:c,y:h},g=0){return new rs(((c-g)*f.scale-f.x)*sr,(h*f.scale-f.y)*sr)}const hht=w(new Float32Array(16));class o_{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 Bt(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 LMe(c,c.pixelsPerMeter)}pointCoordinate(c,h,g,j){const T=c.horizonLineFromTop(!1),P=new rs(h,Math.max(T,g));return c.rayIntersectionCoordinate(c.pointRayIntersection(P,j))}pointCoordinate3D(c,h,g){const j=new rs(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<-q3+g&&(h=-q3+g):h>q3-g&&(h=q3-g);const P=T/Math.pow(N7(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=Oe(jr(F/g)+this.center[0],-180,180),Q=Oe(jr(2*Math.atan(Math.pow(j/R,1/g))-q3),-85.051129,cs);return new Bt(H,this.southernCenter?-Q:Q)}}class RMe extends o_{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:ws(c),y:As(h),z:0}}unproject(c,h){const g=Ut(c),j=ts(h);return new Bt(g,j)}}const OMe=Kt(cs);class ght extends o_{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=Oe(g-T,-OMe,OMe)}while(Math.abs(T)>1e-6&&--j>0);P=g*g;const R=Oe(jr(c/(.8707+P*(P*(P*P*P*(.003971-.001529*P)-.013791)-.131979))),-180,180),F=jr(g);return new Bt(R,F)}}const FMe=Kt(cs);class yht extends o_{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),te=2*Q*H,re=Q*Q,le=H*H,ue=Math.cos(g/2),ge=Math.sin(g/2),ke=2*ue*ge,Ee=ge*ge,He=1-le*ue*ue,$e=He?1/He:0,rt=He?Math.acos(H*ue)*Math.sqrt(1/He):0,it=.5*(2*rt*H*ge+2*g/Math.PI)-c,lt=.5*(rt*Q+j)-h,Pt=.5*$e*(le*Ee+rt*H*ue*re)+1/Math.PI,jt=$e*(ke*te/4-rt*Q*ge),At=.125*$e*(te*ge-rt*Q*le*ke),St=.5*$e*(re*ue+rt*Ee*H)+.5,Ct=jt*At-St*Pt;R=(lt*jt-it*St)/Ct,F=(it*At-lt*Pt)/Ct,g=Oe(g-R,-Math.PI,Math.PI),j=Oe(j-F,-FMe,FMe)}while((Math.abs(R)>P||Math.abs(F)>P)&&--T>0);return new Bt(jr(g),jr(j))}}class zMe extends o_{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=Oe(jr((c-.5)/g)/j,-180,180),R=Math.asin(Oe(T*j,-1,1)),F=Oe(jr(R),-85.051129,cs);return new Bt(P,F)}}class vht extends RMe{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=KP(c,h,g);return dt(j,j,ZP(py(g))),{x:j[0],y:j[1],z:j[2]}}locationPoint(c,h,g){const j=yt(h.lat,h.lng),T=Ne([],j),P=g?c._centerAltitude+g:c.elevation?c.elevation.getAtPointOrZero(c.locationCoordinate(h),c._centerAltitude):c._centerAltitude;Ue(j,j,T,Zt(1,0)*sr*P);const R=w(new Float64Array(16));return C(R,c.pixelMatrix,c.globeMatrix),dt(j,j,R),new rs(j[0],j[1])}pixelsPerMeter(c,h){return Zt(1,0)*h}pixelSpaceConversion(c,h,g){const j=Zt(1,c)*h,T=sn(Zt(1,45)*h,j,g);return this.pixelsPerMeter(c,h)/T}createTileMatrix(c,h,g){const j=zpe(py(g.canonical));return C(new Float64Array(16),c.globeMatrix,j)}createInversionMatrix(c,h){const{center:g}=c,j=ZP(py(h));return O(j,j,Kt(g.lng)),I(j,j,Kt(g.lat)),L(j,j,[c._pixelsPerMercatorPixel,c._pixelsPerMercatorPixel,1]),Float32Array.from(j)}pointCoordinate(c,h,g,j){return t3e(c,h,g,!0)||new br(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!t3e(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=oe([],je([],H,-P),[0,0,R]),te=j.worldSize/(2*Math.PI),re=[0,0,-te],le=j.width/j.height,ue=Math.tan(j.fovAboveCenter),ge=je([],F.up(),ue),ke=je([],F.right(),ue*le),Ee=Ne([],oe([],oe([],H,ge),ke)),He=[];let $e;if(new sa(Q,Ee).closestPointOnSphere(re,te,He)){const rt=oe([],He,re),it=Ae([],rt,Q);$e=Math.cos(j.fovAboveCenter)*ce(it)}else{const rt=Ae([],Q,re),it=Ae([],re,Q);Ne(it,it);const lt=ce(rt)-te;$e=Math.sqrt(lt*(lt+2*te));const Pt=Math.acos($e/(te+lt))-Math.acos(qe(H,it));$e*=Math.cos(Pt)}return 1.01*$e}(c,this.pixelsPerMeter(c.center.lat,c.worldSize)),g=rv(c.zoom);if(g>0){const j=LMe(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 sn(h,j+T*(1-Math.cos(P)),Math.pow(g,10))}return h}upVector(c,h,g){return KP(h,g,c,1)}upVectorScale(c){return{metersToTile:OF(zF(py(c)))}}}function BMe(f){const c=f.parallels,h=!!c&&Math.abs(c[0]+c[1])<.01;switch(f.name){case"mercator":return new RMe(f);case"equirectangular":return new fht(f);case"naturalEarth":return new ght(f);case"equalEarth":return new pht(f);case"winkelTripel":return new yht(f);case"albers":return h?new zMe(f):new mht(f);case"lambertConformalConic":return h?new zMe(f):new xht(f);case"globe":return new vht(f)}throw new Error(`Invalid projection name: ${f.name}`)}class _ht{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:!U0(P),stateDependent:!B1(P),zoomDependent:!Af(P,["zoom"]),pitchDependent:!Af(P,["pitch"]),brightnessDependent:!Af(P,["brightness","measure-light"]),worldviewDependent:!Af(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 bi(R))}return h&&(this.cachedBatchIndices=j,this.cachedBatchSegments=T),{batchIndices:j,batchSegments:T}}snapshotSymbolVertexData(c,h){const g=c*V3;return this.layoutVertexArray.uint16.slice(g,g+h*V3)}restoreSymbolVertexData(c,h){this.layoutVertexArray.uint16.set(h,c*V3)}updateSymbolVertexData(c,h,g,j,T,P,R,F,H,Q,te,re,le){const ue=this.layoutVertexArray.uint16,ge=c*V3;ue[ge]=h,ue[ge+1]=g,ue[ge+2]=j,ue[ge+3]=T,ue[ge+4]=P,ue[ge+5]=R,ue[ge+6]=F,ue[ge+7]=H,ue[ge+8]=Q,ue[ge+9]=te,ue[ge+10]=re,ue[ge+11]=le}upload(c,h,g,j,T,P){this.isEmpty()||(g&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,jut.members,!!P),this.indexBuffer=c.createIndexBuffer(this.indexArray,h),this.dynamicLayoutVertexBuffer=c.createVertexBuffer(this.dynamicLayoutVertexArray,kut.members,!0),this.opacityVertexBuffer=c.createVertexBuffer(this.opacityVertexArray,wht,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=c.createVertexBuffer(this.iconTransitioningVertexArray,Tut.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,Nut.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||T)&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,Sut.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=c.createVertexBuffer(this.orientationVertexArray,Mut.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray&&this.featureIdArray.length>0&&(this.featureIdBuffer=c.createVertexBuffer(this.featureIdArray,Cut.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())}}xr(Gfe,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class Wfe{constructor(c,h,g){this.layoutVertexArray=new c,this.layoutAttributes=h,this.indexArray=new g,this.segments=new bi,this.collisionVertexArray=new m2,this.collisionVertexArrayExt=new Yx}upload(c){this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=c.createVertexBuffer(this.collisionVertexArray,Aut.members,!0),this.collisionVertexBufferExt=c.createVertexBuffer(this.collisionVertexArrayExt,Eut.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}xr(Wfe,"CollisionBuffers");class eg{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=S2(this.zoom,h["text-size"],this.worldview,c.availableImages),this.iconSizeData=S2(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=>am[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 Gfe(new Ce(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("text")||c.startsWith("symbol"))),this.icon=new Gfe(new Ce(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("icon")||c.startsWith("symbol"))),this.disableSymbolUBO||(this.text.uboBinder=new Mfe(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new Mfe(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords)),this.glyphOffsetArray=new EF,this.lineVertexArray=new x2,this.symbolInstances=new AF}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=p6[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=S2(this.zoom,H,this.worldview,T),te=B3(Q,h);if(Q.kind!=="constant"&&Q.kind!=="camera"||(F=te.uSize),Q.kind==="composite"){const{minZoom:re,maxZoom:le}=Q,ue=H.possiblyEvaluate(new Ga(re,{worldview:this.worldview}),j),ge=H.possiblyEvaluate(new Ga(le,{worldview:this.worldview}),j),ke=ue.evaluate(g,{},j,T);F=ke+(ge.evaluate(g,{},j,T)-ke)*te.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!ZF(this.activeReplacements,g)&&(this.activeReplacements=g,!0)}getResolvedImageFromTokens(c){return typeof c=="string"?Gu.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"),[te,re]=P.get("icon-size-scale-range"),le=Oe(h.scaleFactor||1,te,re),[ue,ge]=P.get("text-size-scale-range"),ke=Oe(h.scaleFactor||1,ue,ge),Ee=(H.value.kind!=="constant"||H.value.value instanceof Md&&!H.value.value.isEmpty()||H.value.value.toString().length>0)&&(F.value.kind!=="constant"||F.value.value.length>0),He=Q.value.kind!=="constant"||!!Q.value.value||Object.keys(Q.parameters).length>0,$e=this.hasAnyAppearanceLayoutProperty("icon-image"),rt=P.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!Ee&&!He&&!$e)return;const it=h.iconDependencies,lt=h.glyphDependencies,Pt=h.availableImages,jt=new Ga(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),At=St=>{const Ct=St.id.toString();it.has(Ct)?it.get(Ct).push(St):it.set(Ct,[St])};for(const St of c){const{feature:Ct,id:ss,index:is,sourceLayerIndex:us}=St,vs=T._featureFilter.needGeometry,hs=qn(Ct,vs);if(!T._featureFilter.filter(jt,hs,g))continue;if(vs||(hs.geometry=qr(Ct,g,j)),R&&Ct.type!==1&&g.z<=5){const er=hs.geometry,Js=.98078528056,Ks=(dr,wr)=>qe(KP(dr.x,dr.y,g,1),KP(wr.x,wr.y,g,1)){if(!er.getLayoutProperty("icon-image"))return;const Js=this.getCombinedIconPrimary(er,gs,hs,g,Pt,Ws,le);Js&&At(Js)}),Is){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(am.vertical)>=0;for(const Ks of Is.sections)if(Ks.image){const dr=Ks.image.getPrimary().scaleSelf(this.pixelRatio*ke),wr=dr.id.toString(),Br=it.get(wr)||[];Br.push(dr),it.set(wr,Br)}else{const dr=xP(Is.toString()),wr=Ks.fontStack||er,Br=lt[wr]=lt[wr]||{};this.calculateGlyphDependencies(Ks.text,Br,Js,this.allowVerticalPlacement,dr)}}}if(P.get("symbol-placement")==="line"&&(this.features=function(St){const Ct={},ss={},is=[];let us=0;function vs(gs){is.push(St[gs]),us++}function hs(gs,Ss,Ls){const Ws=ss[gs];return delete ss[gs],ss[Ss]=Ws,is[Ws].geometry[0].pop(),is[Ws].geometry[0]=is[Ws].geometry[0].concat(Ls[0]),Ws}function Is(gs,Ss,Ls){const Ws=Ct[Ss];return delete Ct[Ss],Ct[gs]=Ws,is[Ws].geometry[0].shift(),is[Ws].geometry[0]=Ls[0].concat(is[Ws].geometry[0]),Ws}function es(gs,Ss,Ls){const Ws=Ls?Ss[0][Ss[0].length-1]:Ss[0][0];return`${gs}:${Ws.x}:${Ws.y}`}for(let gs=0;gsgs.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 St of h.elevationFeatures)this.elevationFeatureIdToIndex.set(St.id,this.elevationFeatures.length),this.elevationFeatures.push(St)}}else P.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((St,Ct)=>St.sortKey-Ct.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=v6(F,S2(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:te,featureState:re,layoutIconOffset:le,layoutIconSize:ue,layoutIconRotate:ge}=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 Ee=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},te);if(!Ee)return{vertexOffsetDelta:0,hasChanges:!1};const He=Ee.toString(),$e=this.iconAtlasPositions&&this.iconAtlasPositions.get(He);if($e){const{appearanceIconOffset:rt,appearanceIconRotate:it}=CMe(ke,Q,j,R,le,ge,ue,te);let lt=p7($e,void 0,rt,Q.layout.get("icon-anchor").evaluate(j,re,R));const Pt=$e.sdf,jt=Q.layout.get("icon-text-fit").constantOr("none");jt!=="none"&&h.textShaping&&h.iconTextFitPadding&&h.fontScale&&(lt=Ife(lt,h.textShaping,jt,h.iconTextFitPadding,rt,h.fontScale));const At=this.calculateEffectiveAppearanceIconSize(ke,H.zoom,j,R,F,te,ue),St=0,Ct=1+(Math.min(C2,Math.round(At*iv))<<1),ss=Bfe(lt,it,Pt,jt!=="none",te);h.isUsingAppearanceIconVertexData||(h.isUsingAppearanceIconVertexData=!0,h.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(T,c.numIconVertices));const is=Math.floor(c.numIconVertices/4),us=Math.min(ss.length,is);let vs=T;for(let Is=0;Is0||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:lt,appearanceTextRotate:Pt,appearanceTextSize:jt}=MMe(it,F,j,R,re,ue,le);h.fontScale=PMe(jt,h.textScaleFactor);const At=it.getUnevaluatedLayoutProperty("text-size");let St=this.textSizeData,Ct=Ee,ss=He;it.hasLayoutProperty("text-size")&&(St=S2(this.zoom,At,this.worldview,$e),Ct=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,ss=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0);const is=h.textShaping.bottom-re[1],us=h.textShaping.left-re[0],vs=h.textShaping.right-re[0];h.textShaping.top=lt[1]+(h.textShaping.top-re[1]),h.textShaping.bottom=lt[1]+is,h.textShaping.left=lt[0]+us,h.textShaping.right=lt[0]+vs;const hs=kMe(0,h.textShaping,lt,F,!1,j,Q,this.allowVerticalPlacement,Pt),Is=jt&&St.kind==="composite"?At.possiblyEvaluate(new Ga(Ct,{}),R).evaluate(j,te,R):ge,es=jt&&St.kind==="composite"?At.possiblyEvaluate(new Ga(ss,{}),R).evaluate(j,te,R):ke,gs=Vfe(it.name,St,jt,H,Is,es),Ss=Array.isArray(gs)?gs[1]:jt,Ls=0,Ws=1+(Math.min(C2,Math.round(Ss*iv))<<1);h.isUsingAppearanceTextVertexData||(h.isUsingAppearanceTextVertexData=!0,h.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(T,c.numHorizontalGlyphVertices+c.numVerticalGlyphVertices));for(let pr=0;pr0){const H=new Set(Object.keys(c).map(Q=>{const te=Number(Q);return!isNaN(te)&&Number.isSafeInteger(te)&&String(te)===Q?te: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=Cs(c),j=1/g;let T=!1,P=!1;for(let R=0;R0||re>0,ke=le>0,Ee=this.elevationFeatures[F.elevationFeatureIndex];if(Ee){const He=new rs(F.tileAnchorX,F.tileAnchorY),$e=.075+Ee.pointElevation(He);F.zOffset!==$e&&(h=!0,F.zOffset=$e),$e!==0&&(this.hasAnyZOffset=!0);const rt=Ee.computeSlopeNormal(He,j),it=Dr(Ke(),ie(0,0,1),rt);Ve(H,H,it),Ve(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||ge,P=P||ke)}if(ge&&(k7(this.text.orientationVertexArray,te,H,Q),k7(this.text.orientationVertexArray,re,H,Q)),ke){const{placedIconSymbolIndex:He,verticalPlacedIconSymbolIndex:$e}=F;He>=0&&k7(this.icon.orientationVertexArray,le,H,Q),$e>=0&&k7(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)),te){const{placedIconSymbolIndex:re,verticalPlacedIconSymbolIndex:le}=P;re>=0&&h(this.icon.zOffsetVertexArray,H,Q),le>=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 te=this.layers[0],re=te.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===te.appearancesVersion||(this.featureAppearances=new _ht(te.appearances,te.appearancesVersion));const le=this.featureAppearances.update(j,P);if(le.kind==="no-changes")return R;let ue=1,ge=0,ke=!1,Ee=!1;if(H){const[lt,Pt]=re.get("icon-size-scale-range");ue=Oe(1,lt,Pt)}let He=1,$e=0,rt=!1;if(Q){const[lt,Pt]=re.get("text-size-scale-range");He=Oe(1,lt,Pt)}const it=new Map;if(T&&g)for(const lt of g){const Pt=T.getImage(lt,te.scope);if(Pt){const jt=new qm(lt.toString());it.set(jt.toString(),Pt)}}for(let lt=0;ltvs.isActive({globals:j,feature:Ct,canonical:c,featureState:St})):-1;ss=us>=0?us:-1}const is=jt.activeAppearanceIndex!==ss;if(Q){const us=re.get("text-size"),vs=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,hs=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0,Is={canonical:c,layer:te,featureState:St,availableImages:g,textScaleFactor:He,imageMap:it,layoutTextOffset:re.get("text-offset").evaluate(Ct,St,c).map(gs=>gs*ac),layoutTextSize:us.evaluate(Ct,St,c),layoutTextRotate:re.get("text-rotate").evaluate(Ct,St,c),layoutMinZoomSize:us.evaluate(Ct,{zoom:vs},c),layoutMaxZoomSize:us.evaluate(Ct,{zoom:hs},c),layoutTextSizeMinZoom:vs,layoutTextSizeMaxZoom:hs},es=this.updateSymbolInstanceTextVertices(Pt,jt,ss,Ct,$e,Is);$e+=es.vertexOffsetDelta,rt=rt||es.hasChanges}if(H){const us={canonical:c,layer:te,featureState:St,availableImages:g,globalProperties:j,iconScaleFactor:ue,layoutIconOffset:re.get("icon-offset").evaluate(Ct,St,c),layoutIconSize:re.get("icon-size").evaluate(Ct,St,c,g),layoutIconRotate:re.get("icon-rotate").evaluate(Ct,St,c)},vs=this.updateSymbolInstanceIconVertices(Pt,jt,ss,Ct,ge,us);ge+=vs.vertexOffsetDelta,ke=ke||vs.hasChanges}if(is){const us=Pt.featureIndex,vs=j?j.brightness:null,hs=St||{},Is=ss>=0?te.appearances[ss]:null;this.text.uboBinder&&(this.text.uboBinder.layer=te,Ee=this.text.uboBinder.updateFeaturePaintForAppearance(us,Ct,hs,c,g,vs,Is)||Ee),this.icon.uboBinder&&(this.icon.uboBinder.layer=te,Ee=this.icon.uboBinder.updateFeaturePaintForAppearance(us,Ct,hs,c,g,vs,Is)||Ee)}jt.activeAppearanceIndex=ss}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:Ee}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=BMe(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,te,re,le,ue,ge,ke,Ee,He){const $e=c.indexArray,rt=c.layoutVertexArray,it=c.globeExtVertexArray,lt=He,Pt=c.uboBinder?c.uboBinder.getCurrentBatchIndex():void 0,jt=c.segments.prepareSegment(4*lt,rt,$e,this.canOverlap?P.sortKey:void 0,Pt),At=this.glyphOffsetArray.length,St=jt.vertexLength,Ct=this.allowVerticalPlacement&&R===am.vertical?Math.PI/2:0,ss=P.text&&P.text.sections;let is=rt.length,us=-1;for(let Is=0;Is=0)){const Is=4*vs;for(let es=0;es=0?h.rightJustifiedTextSymbolIndex:h.centerJustifiedTextSymbolIndex>=0?h.centerJustifiedTextSymbolIndex:h.leftJustifiedTextSymbolIndex>=0?h.leftJustifiedTextSymbolIndex:h.verticalPlacedTextSymbolIndex>=0?h.verticalPlacedTextSymbolIndex:j),P=Lfe(this.textSizeData,c,T)/ac;return this.tilePixelRatio*P}getSymbolInstanceIconSize(c,h,g){const j=this.icon.placedSymbolArray.get(g),T=Lfe(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:te,verticalPlacedTextSymbolIndex:re}=F;H>=0&&this.addIndicesForPlacedSymbol(this.text,H),Q>=0&&Q!==H&&this.addIndicesForPlacedSymbol(this.text,Q),te>=0&&te!==Q&&te!==H&&this.addIndicesForPlacedSymbol(this.text,te),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 f?String(f[g]):"")}let qMe,UMe,Kfe;xr(eg,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),eg.addDynamicAttributes=U3;class VMe{constructor(c){this.type=c.property.overrides?c.property.overrides.runtimeType:qx,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}}xr(VMe,"FormatSectionOverride",{omit:["defaultValue"]});const Zfe=()=>Kfe||(Kfe={layout:qMe||(qMe=new Xi({"symbol-placement":new Ys(Gt.layout_symbol["symbol-placement"]),"symbol-spacing":new Ys(Gt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ys(Gt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Vs(Gt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ys(Gt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ys(Gt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Ys(Gt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Ys(Gt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ys(Gt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ys(Gt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ys(Gt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Vs(Gt.layout_symbol["icon-size"]),"icon-size-scale-range":new Ys(Gt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Vs(Gt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Vs(Gt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Vs(Gt.layout_symbol["icon-image"]),"icon-image-use-theme":new Ys({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new Vs(Gt.layout_symbol["icon-rotate"]),"icon-padding":new Ys(Gt.layout_symbol["icon-padding"]),"icon-keep-upright":new Ys(Gt.layout_symbol["icon-keep-upright"]),"icon-offset":new Vs(Gt.layout_symbol["icon-offset"]),"icon-anchor":new Vs(Gt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ys(Gt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ys(Gt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ys(Gt.layout_symbol["text-rotation-alignment"]),"text-field":new Vs(Gt.layout_symbol["text-field"]),"text-font":new Vs(Gt.layout_symbol["text-font"]),"text-size":new Vs(Gt.layout_symbol["text-size"]),"text-size-scale-range":new Ys(Gt.layout_symbol["text-size-scale-range"]),"text-max-width":new Vs(Gt.layout_symbol["text-max-width"]),"text-line-height":new Vs(Gt.layout_symbol["text-line-height"]),"text-letter-spacing":new Vs(Gt.layout_symbol["text-letter-spacing"]),"text-justify":new Vs(Gt.layout_symbol["text-justify"]),"text-radial-offset":new Vs(Gt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ys(Gt.layout_symbol["text-variable-anchor"]),"text-anchor":new Vs(Gt.layout_symbol["text-anchor"]),"text-max-angle":new Ys(Gt.layout_symbol["text-max-angle"]),"text-writing-mode":new Ys(Gt.layout_symbol["text-writing-mode"]),"text-rotate":new Vs(Gt.layout_symbol["text-rotate"]),"text-padding":new Ys(Gt.layout_symbol["text-padding"]),"text-keep-upright":new Ys(Gt.layout_symbol["text-keep-upright"]),"text-transform":new Vs(Gt.layout_symbol["text-transform"]),"text-offset":new Vs(Gt.layout_symbol["text-offset"]),"text-allow-overlap":new Ys(Gt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ys(Gt.layout_symbol["text-ignore-placement"]),"text-optional":new Ys(Gt.layout_symbol["text-optional"]),visibility:new Ys(Gt.layout_symbol.visibility)})),paint:UMe||(UMe=new Xi({"icon-opacity":new Vs(Gt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Vs(Gt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Vs(Gt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Vs(Gt.paint_symbol["text-emissive-strength"]),"icon-color":new Vs(Gt.paint_symbol["icon-color"]),"icon-halo-color":new Vs(Gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Vs(Gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Vs(Gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Ys(Gt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ys(Gt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Ys(Gt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Vs(Gt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Vs(Gt.paint_symbol["text-occlusion-opacity"]),"text-color":new Vs(Gt.paint_symbol["text-color"],{runtimeType:ju,getOverride:f=>f.textColor,hasOverride:f=>!!f.textColor}),"text-halo-color":new Vs(Gt.paint_symbol["text-halo-color"]),"text-halo-width":new Vs(Gt.paint_symbol["text-halo-width"]),"text-halo-blur":new Vs(Gt.paint_symbol["text-halo-blur"]),"text-translate":new Ys(Gt.paint_symbol["text-translate"]),"text-translate-anchor":new Ys(Gt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ys(Gt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ys(Gt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ys(Gt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ys(Gt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Vs(Gt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"})}))},Kfe);class S7 extends Kd{constructor(c,h,g,j){super(c,Zfe(),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=zi(T),P=di(P);const H=b(),Q=T/3,te=1-2*Q,re=[te,Q,Q,0,Q,te,Q,0,Q,Q,te,0,0,0,0,1],le=.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,le,le,le,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()||t2(P.value)||!T?T:$Me(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()||t2(F.value)||!R||typeof R!="string"?R:$Me(g.properties,R)}createBucket(c){return new eg(c)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const c of Zfe().paint.overridableProperties){if(!S7.hasPaintOverride(this.layout,c))continue;const h=this.paint.get(c),g=new VMe(h),j=new a3(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 G1("source",j):new H0("composite",j,h.value.zoomStops,h.value.interpolationType),this.paint._values[c]=new Z0(h.property,T,h.parameters)}}_handleOverridablePaintPropertyUpdate(c,h,g){return!(!this.layout||h.isDataDriven()||g.isDataDriven())&&S7.hasPaintOverride(this.layout,c)}static hasPaintOverride(c,h){const g=c.get("text-field"),j=Zfe().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 Md)P(g.value.value.sections);else if(g.value.kind==="source"){const R=H=>{T||(H instanceof Nr&&Oo(H.value)===Ew?P(H.value.sections):H instanceof F0?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 ye(this,{zoom:h,lut:g}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let HMe,GMe,WMe,KMe;var C7=la([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);function M7(f,c,h,g,j,T,P,R){const F=[f,c,1,h,g,1,j,T,1],H=[P,R,1],Q=y([],F),[te,re,le]=fe(H,H,Q);return _(F,F,[te,0,0,0,re,0,0,0,le])}function ZMe(f,c,h,g,j,T,P,R){const F=function(H,Q,te,re,le,ue,ge,ke){const Ee=M7(0,0,1,0,1,1,0,1),He=M7(H,Q,te,re,le,ue,ge,ke);return _(He,He,y([],Ee))}(f,c,h,g,j,T,P,R);return[F[2]/F[8]/sr,F[5]/F[8]/sr]}function T7(f){return[f[0],Math.min(Math.max(f[1],-85.051129),cs)]}class YMe extends Ai{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 Jr("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return c&&(this.coordinates=c),this._loaded=!0,void this._finishLoading();this._imageRequest=ey(this.map._requestManager.transformRequest(this.url,I0.Image),(g,j)=>{this._imageRequest=null,this._loaded=!0,g?this.fire(new pn(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 u6(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 Jr("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 u6||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]cs?this.onNorthPole=!0:j<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const T=c.map(br.fromLngLat);this.tileID=function(P){let R=1/0,F=1/0,H=-1/0,Q=-1/0;for(const ge of P)R=Math.min(R,ge.x),F=Math.min(F,ge.y),H=Math.max(H,ge.x),Q=Math.max(Q,ge.y);const te=Math.max(H-R,Q-F),re=Math.max(0,Math.floor(-Math.log2(te))),le=Math.pow(2,re);let ue=Math.floor((R+H)/2*le);return ue>1&&(ue-=1),new b2(re,ue,Math.floor((F+Q)/2*le))}(T),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Jr("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof u6||(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 Ee=this.tiles[ke];Ee.state!=="loaded"&&(Ee.state="loaded",Ee.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const h=M2(new b2(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 Ee=ke[1].x-ke[0].x,He=ke[1].y-ke[0].y,$e=ke[2].x-ke[1].x,rt=ke[2].y-ke[1].y,it=ke[3].x-ke[2].x,lt=ke[3].y-ke[2].y,Pt=ke[0].x-ke[3].x,jt=ke[0].y-ke[3].y,At=Ee*rt-$e*He,St=$e*lt-it*rt,Ct=it*jt-Pt*lt,ss=Pt*He-Ee*jt;return At>0&&St>0&&Ct>0&&ss>0||At<0&&St<0&&Ct<0&&ss<0}(g))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const j=M2(this.tileID,this.map.transform.projection),[T,P,R,F]=this.coordinates.map(ke=>{const Ee=j.projection.project(ke[0],ke[1]);return DMe(j,Ee)._round()});this.perspectiveTransform=ZMe(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,C7.members),this.boundsSegments=bi.simpleSegment(0,0,4,2);const Q=[],te=function(ke){return[T7(ke[0]),T7(ke[1]),T7(ke[2]),T7(ke[3])]}(this.coordinates),[re,le,ue,ge]=function(ke){let Ee=ke[0][0],He=Ee,$e=ke[0][1],rt=$e;for(let it=1;itHe&&(He=ke[it][0]),ke[it][1]<$e?$e=ke[it][1]:ke[it][1]>rt&&(rt=ke[it][1]);return[Ee,$e,He-Ee,rt-$e]}(te);{const ke=new id,[Ee,He,$e,rt]=function(hs){let Is=hs[0].x,es=Is,gs=hs[0].y,Ss=gs;for(let Ls=1;Lses&&(es=hs[Ls].x),hs[Ls].ySs&&(Ss=hs[Ls].y);return[Is,gs,es-Is,Ss-gs]}(g),it=hs=>[(hs.x-Ee)/$e,(hs.y-He)/rt],[lt,Pt,jt,At]=g.map(it),St=function(hs,Is,es,gs,Ss,Ls,Ws,pr){const er=M7(0,0,1,0,1,1,0,1);return _(er,er,y([],M7(hs,Is,es,gs,Ss,Ls,Ws,pr)))}(lt[0],lt[1],Pt[0],Pt[1],jt[0],jt[1],At[0],At[1]);this.elevatedGlobePerspectiveTransform=ZMe(lt[0],lt[1],Pt[0],Pt[1],jt[0],jt[1],At[0],At[1]);const Ct=(hs,Is)=>{Q.push(hs.lng);const es=Math.round((hs.lng-re)/ue*sr),gs=Math.round((hs.lat-le)/ge*sr),Ss=it(Is),Ls=fe([],[Ss[0],Ss[1],1],St),Ws=Math.round(Ls[0]/Ls[2]*sr),pr=Math.round(Ls[1]/Ls[2]*sr);ke.emplaceBack(es,gs,Ws,pr)},ss=g[3].x-g[0].x,is=g[3].y-g[0].y,us=g[2].x-g[1].x,vs=g[2].y-g[1].y;for(let hs=0;hs<65;hs++){const Is=hs/64,es=[g[0].x+Is*ss,g[0].y+Is*is],gs=[g[1].x+Is*us,g[1].y+Is*vs],Ss=gs[0]-es[0],Ls=gs[1]-es[1];for(let Ws=0;Ws<65;Ws++){const pr=Ws/64,er={x:es[0]+Ss*pr,y:es[1]+Ls*pr};Ct(h.projection.unproject(er.x,er.y),er)}}this.elevatedGlobeVertexBuffer=c.createVertexBuffer(ke,C7.members)}{this.maxLongitudeTriangleSize=0;let ke=[],Ee=new To;const He=($e,rt,it)=>{Ee.emplaceBack($e,rt,it);const lt=Q[$e],Pt=Q[rt],jt=Q[it],At=Math.min(Math.min(lt,Pt),jt),St=Math.max(Math.max(lt,Pt),jt)-At;St>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=St),ke.push(At+St/2)};for(let $e=0;$e<64;$e++)for(let rt=0;rt<64;rt++){const it=65*$e+rt,lt=it+1,Pt=it+65,jt=Pt+1;He(it,Pt,lt),He(lt,Pt,jt)}[ke,Ee]=function($e,rt){const it=Array.from({length:$e.length},(jt,At)=>At);it.sort((jt,At)=>$e[jt]-$e[At]);const lt=[],Pt=new To;for(let jt=0;jt{P.segments.push({vertexOffset:0,primitiveOffset:te,vertexLength:h.segments[0].vertexLength,primitiveLength:re,sortKey:void 0,vaos:{}})},F=.51*this.maxLongitudeTriangleSize;if(Math.abs(g[0]-j)<=F){const te=Qo(g,0,g.length,j+F);return te===g.length||R(te,Fi(g,te+1,g.length,j+360-F)-te),P}j0}}let QMe,JMe,eTe,tTe,sTe,rTe,nTe;class aTe extends Kd{constructor(c,h,g,j){super(c,{layout:QMe||(QMe=new Xi({visibility:new Ys(Gt["layout_raster-particle"].visibility)})),paint:JMe||(JMe=new Xi({"raster-particle-array-band":new Ys(Gt["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new Ys(Gt["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new Y1(Gt["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new Ys(Gt["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new Ys(Gt["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new Ys(Gt["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new Ys(Gt["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new Ys(Gt["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"})}))},h,g,j),this._updateColorRamp(),this.lastInvalidatedAt=Sd.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=YP({expression:c,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:h}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=Sd.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class kht extends Kd{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 Xfe(f,c,h){const g=[0,0,1],j=Ze([]);return $t(j,j,h?-Kt(f)+Math.PI:Kt(f)),Et(j,j,-Kt(c)),Ve(g,g,j),Ne(g,g)}class A7{constructor(c,h,g,j){this.message=(c?`${c}: `:"")+g,j&&(this.identifier=j),h!=null&&h.__line__&&(this.line=h.__line__)}}function Qfe(f,c){const h=f.indexOf("://")===-1;try{return new URL(f,h&&c?"http://example.com":void 0),!0}catch{return!1}}class iTe{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 oTe{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new $P,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 rs(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 Jfe{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=Cs(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 te=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 le={id:te,sourceLayerIndex:Q,index:H,geometry:T?re.geometry:qr(R,g,j),properties:R.properties,type:R.type,patterns:{}},ue=this.addFeature(le,le.geometry,re,P,g);ue&&h.featureIndex.insert(R,le.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);at(j.rotation,F)&&at(j.scale,H)&&at(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(ZF(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 te=Q.instancedDataOffset,re=Q.instancedDataCount;for(let le=0;lesr;ge=ke?ge-sr:ge;const Ee=Math.floor(ge),He=Math.floor(H.float32[ue+1]);let $e=!1;for(const rt of this.activeReplacements)if(!q3e(rt,g,YF.Model,j)&&!(rt.min.x>Ee||Ee>rt.max.x||rt.min.y>He||He>rt.max.y)&&($e=W3e(G3e(Ee,He,c.canonical,rt.footprintTileId.canonical),rt.footprint),$e))break;H.float32[ue]=$e?ge+sr:ge,P=P||$e!==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,Vdt.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 Rr(`modelId is not evaluated for layer ${P.id} and it is not going to get rendered.`),H;(Qfe(H,!1)||this.styleDefinedModelURLs[H]!==void 0)&&(this.modelUris.includes(H)||this.modelUris.push(H)),this.instancesPerModel[H]||(this.instancesPerModel[H]=new oTe);const Q=this.instancesPerModel[H],te=Q.instancedDataArray,re=new iTe(g,te.length);let le;j&&(le=Si.getElevationFeature(c,j));for(const ue of h)for(const ge of ue){if(ge.x<0||ge.x>=sr||ge.y<0||ge.y>=sr)continue;if(this.lookupDim!==0&&F){const Ee=(this.lookupDim-1)/sr,He=this.lookupDim*(ge.y*Ee|0)+ge.x*Ee|0;if(this.lookup){if(this.lookup[He]!==0)continue;this.lookup[He]=1}}this.instanceCount++;const ke=te.length;if(te.resize(ke+1),j){Q.instancesRoadElevation||(Q.instancesRoadElevation=[]);const Ee=le?le.pointElevation(new rs(ge.x,ge.y)):0;Q.instancesRoadElevation.push(Ee)}Q.instancesEvaluatedElevation.push(0),te.float32[16*ke]=ge.x,te.float32[16*ke+1]=ge.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),te=Object.assign({},T.paint.get("model-color").evaluate(P,h,R));te.a=T.paint.get("model-color-mix-intensity").evaluate(P,h,R);const re=[];this.maxVerticalOffset0?Math.sqrt(le):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])),E5e(re,F,H);const ge=Math.round(100*te.a)+te.b/1.05;for(let ke=0;ke10?this.tileToMeter:Cs(R,it)),$e[He+4]=Q[0],$e[He+5]=Q[1],$e[He+6]=Q[2]+(g.instancesRoadElevation?g.instancesRoadElevation[Ee]:0)+rt,$e[He+7]=re[0],$e[He+8]=re[1],$e[He+9]=re[2],$e[He+10]=re[4],$e[He+11]=re[5],$e[He+12]=re[6],$e[He+13]=re[8],$e[He+14]=re[9],$e[He+15]=re[10],g.instancesEvaluatedElevation[Ee]=Q[2]}}}xr(Jfe,"ModelBucket",{omit:["layers"]}),xr(oTe,"PerModelAttributes"),xr(iTe,"ModelFeature");class H3{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|=O3.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,j&&(this.modelTraits|=O3.HasMapboxMeshFeatures),T&&(this.modelTraits|=O3.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 uTe(H)),cTe(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(!Bn(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):gfe(j,c,!0)}for(const g of h)c7(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||C6(g.paint.get("model-color").value,P)||C6(g.paint.get("model-color-mix-intensity").value,P)||C6(g.paint.get("model-roughness").value,P)||C6(g.paint.get("model-emissive-strength").value,P)||C6(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(Bn(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 te=0;te=lt)continue;const Is=exe[hs],es=Math.abs(Is);es>Ct&&(St=Is,Ct=es,ss=vs,is=us)}if(Ct>.1){const us=1-(lt+.5*Math.abs(ss*is))/ue;let vs=h._dem.get(jt,Pt)+St*us;const hs=h._dem.get(jt+ss,Pt+is),Is=h._dem.get(jt-ss,Pt-is,!0);(vs-hs)*(vs-Is)>0&&(vs=(hs+Is)/2),exe[At]=h._dem.set(jt,Pt,vs),T2[At]=lt}}}}}R&&(h._demTile.needsDEMTextureUpload=!0,h._dem._timestamp=Sd.now())}setFilter(c){this.filter=c?g3(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)c7(h.node),yfe(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]};k(T,P.node.globalMatrix),j[0]=c,j[1]=h,dt(j,j,T);const H=(j[0]-R.aabb.min[0])/(R.aabb.max[0]-R.aabb.min[0])*N2|0,Q=Math.min(63,(j[1]-R.aabb.min[1])/(R.aabb.max[1]-R.aabb.min[1])*N2|0)*N2+Math.min(63,H),te=R.heightmap[Q];if(!(te<0&&P.node.footprint))return P.hiddenByReplacement?void 0:{height:te,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};if(P.node.footprint.grid.query(new rs(c,h),new rs(c,h),g),g.length>0)return{height:void 0,maxHeight:P.feature.properties.height,hidden:P.hiddenByReplacement,verticalScale:P.evaluatedScale[2]}}}}function C6(f,c){return f instanceof G1&&!f.isLightConstant&&c}function Sht(f,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=sn(F,255*h[0],h[3]),H=sn(H,255*h[1],h[3]),Q=sn(Q,255*h[2],h[3]));const te=F<<8|H,re=Q<<8|Math.floor(255*g[3]),le=function(lt){const Pt=Oe(lt,0,2);return Math.min(Math.round(.5*Pt*255),255)}(g[2])<<8|15*g[0]<<4|15*g[1],ue=Oe(j[0],0,1),ge=Oe(j[1],0,1),ke=Oe(j[2],0,1),Ee=Oe(j[3],0,1);let He,$e,rt,it;if(ue!==ge&&P!==T&&ge!==ue){const lt=P-T;$e=1/(lt*(ge-ue)),rt=-(T+lt*ue)/(lt*(ge-ue));const Pt=Oe(j[4],-1,1);it=Math.pow(10,Pt),He=255*ke<<8|255*Ee}else He=65535,$e=0,rt=1,it=1;if(f.emplaceBack(te,re,le,He,$e,rt,it),R){const lt=R.length;R.clear();for(let Pt=0;Pt>16&65535,Q=T?F>>16&65535:65535&F,te=(15&Q)<8?15&Q:0,re=f.evaluatedRMEA[te],le=f.evaluatedColor[te],ue=f.emissionHeightBasedParams[te];let ge;if(R&&te===2&&g.lights&&(ge=new k3,ge.resize(10*g.lights.length)),Sht(P.featureArray,H,le,re,ue,P.aabb.min[2],P.aabb.max[2],ge),ge&&R){R=!1;const ke=g.meshes[g.lightMeshIndex];ke.featureArray=ge,ke.featureArray._trim()}}P.featureArray._trim(),j++}}xr(E7,"Tiled3dModelBucket",{omit:["layers"]}),xr(uTe,"Tiled3dModelFeature");const Mht=["id","tile","layer","source","sourceLayer","state"];class A2{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 A2(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 Mht)this[h]!==void 0&&(c[h]=this[h]);return c}}class E2 extends Ai{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 C5e(this.map._requestManager.transformRequest(c,I0.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=_fe(j),R=T.modelSpec,F=new P5e(c,R.uri,R.position,R.orientation,P);E2.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 pn(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 Bt(j.position[0],j.position[1]):new Bt(0,0),P.orientation=j.orientation!=null?j.orientation:[0,0,0],E2.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 Jr("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new Jr("data",{dataType:"source",sourceDataType:"metadata"}))}static applyModelSpecification(c,h){h.nodeOverrides&&E2.convertNodeOverrides(c,h.nodeOverrides),h.materialOverrides&&E2.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 Ea(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=Y0(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 txe(f,c,h,g){const j=1<F>=it.vertexArrayOffset&&Frt.polygon).flat());const ke=le?R:null,[Ee,He]=h5e(T,g,te,Q,H,P,ke,re,ue,T.center.lat,f.tileID.canonical),$e=f.queryGeometry;return u5e(Ee,He,$e.isPointQuery()?$e.screenBounds:$e.screenGeometry)}},building:class extends Kd{constructor(f,c,h,g){super(f,{layout:z5e||(z5e=new Xi({visibility:new Ys(Gt.layout_building.visibility),"building-facade":new Vs(Gt.layout_building["building-facade"]),"building-facade-floors":new Vs(Gt.layout_building["building-facade-floors"]),"building-facade-unit-width":new Vs(Gt.layout_building["building-facade-unit-width"]),"building-facade-window":new Vs(Gt.layout_building["building-facade-window"]),"building-roof-shape":new Vs(Gt.layout_building["building-roof-shape"]),"building-height":new Vs(Gt.layout_building["building-height"]),"building-base":new Vs(Gt.layout_building["building-base"]),"building-flood-light-wall-radius":new Vs(Gt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new Vs(Gt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new Vs(Gt.layout_building["building-flip-roof-orientation"])})),paint:B5e||(B5e=new Xi({"building-opacity":new Ys(Gt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Ys(Gt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Ys(Gt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Ys(Gt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Ys(Gt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Ys(Gt.paint_building["building-vertical-scale"]),"building-cast-shadows":new Ys(Gt.paint_building["building-cast-shadows"]),"building-color":new Vs(Gt.paint_building["building-color"]),"building-emissive-strength":new Vs(Gt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Ys(Gt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Ys(Gt.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new Ys(Gt.paint_building["building-front-cutoff"]),"building-flood-light-color":new Ys(Gt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Ys(Gt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Ys(Gt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"})}))},c,h,g),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(f){return new F5e(f)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(f){return!0}queryRadius(f){return 0}queryIntersectsFeature(f,c,h,g,j,T,P,R,F,H){let Q=this.layout.get("building-height").evaluate(c,h);const te=this.layout.get("building-base").evaluate(c,h),re=f.tile.getBucket(this).getFootprint(c);if(re){if(re.hiddenFlags!==0)return!1;Q=re.height}const[le,ue]=h5e(T,g,te,Q,new rs(0,0),P,null,[0,0],1,T.center.lat,f.tileID.canonical),ge=f.queryGeometry;return u5e(le,ue,ge.isPointQuery()?ge.screenBounds:ge.screenGeometry)}},line:class extends Kd{constructor(f,c,h,g){const j=Y5e();super(f,j,c,h,g),j.layout&&(this.layout=new Kx(j.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(f){if(f==="line-gradient"){const c=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=c._styleExpression&&c._styleExpression.expression instanceof Hw,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(f,c){super.recalculate(f,c),this.paint._values["line-floorwidth"]=(()=>{if(m6)return m6;const h=Y5e();return m6=new wut(h.paint.properties["line-width"].specification),m6.useIntegerZoom=!0,m6})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,f)}createBucket(f){return new u7(f)}getProgramIds(){const f=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return this.paint.get("line-blend-mode")!=="default"&&f.push("lineBlendComposite"),f}getDefaultProgramParams(f,c,h){if(f==="lineBlendComposite")return{};const g=K5e(this);return{config:new ye(this,{zoom:c,lut:h}),defines:g,overrideFog:!1}}queryRadius(f){const c=f,h=X5e(t_("line-width",this,c),t_("line-gap-width",this,c)),g=t_("line-offset",this,c);return h/2+Math.abs(g)+DF(this.paint.get("line-translate"))}queryIntersectsFeature(f,c,h,g,j,T){if(f.queryGeometry.isAboveHorizon)return!1;const P=ZCe(f.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),T.angle,f.pixelToTileUnitsFactor),R=f.pixelToTileUnitsFactor/2*X5e(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 te=[],re=new rs(0,0);for(let le=0;le=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 hTe{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 za(new h7(this.rawTileData)).layers,this.sourceLayerCoder=new hTe(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,te=this.grid.query(Q.min.x,Q.min.y,Q.max.x,Q.max.y,(ge,ke,Ee,He)=>uy(g.bufferedTilespaceGeometry,ge-H,ke-H,Ee+H,He+H));te.sort(Pht);let re=null;j.elevation&&te.length>0&&(re=H3.create(j.elevation,this.tileID));const le={};let ue;for(let ge=0;ge(He||(He=qr($e,this.tileID.canonical,T)),rt.queryIntersectsFeature(g,$e,it,He,this.z,j,P,re,lt,h.scope)))}return le}loadMatchingFeature(c,h,g,j,T,P){const{featureIndex:R,bucketIndex:F,sourceLayerIndex:H,layoutVertexArrayOffset:Q}=h,te=this.bucketLayerIDs[F],re=g.layers,le=Object.keys(re);if(le.length&&!Lr(le,te))return;const ue=g.sourceCache,ge=this.sourceLayerCoder.decode(H),ke=this.vtLayers[ge].feature(R),Ee=this.getId(ke,ge);for(let He=0;He`${R.key}: ${R.message}`).join(", ");return void Rr(`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 pTe(f,c,h,g,j){return Ts(f,(T,P)=>{const R=c instanceof Kx?c.get(P):null;return R&&R.evaluate?R.evaluate(h,g,void 0,j):R})}function Pht(f,c){return c-f}function fTe(f,c){const h={};if(!c)return h;for(const g of f){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}xr(mTe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Of=32,yy=33,l_=new Uint16Array(8184);for(let f=0;f<2046;f++){let c=f+2,h=0,g=0,j=0,T=0,P=0,R=0;for(1&c?j=T=P=Of:h=g=R=Of;(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*f;l_[F+0]=h,l_[F+1]=g,l_[F+2]=j,l_[F+3]=T}const vy=new Uint16Array(2178),c_=new Uint8Array(1089),P7=new Uint16Array(1089);function xTe(f){return f===0?-.03125:f===32?.03125:0}const gTe={Other:0,Symbol:1,FillExtrusion:2},yTe={type:2,extent:sr,loadGeometry:()=>[[new rs(0,0),new rs(8193,0),new rs(8193,8193),new rs(0,8193),new rs(0,0)]]};class Iht{constructor(){this.tasks={},this.taskQueue=[],Xt(["process"],this),this.invoker=new Eht(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===gTe.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,(f>>8&255)/255,(255&f)/255,1)}function Hht(f,c,h){f===1?(c.rgb_color=D7(h.readVarint()),c.paint="rgb_color"):f===2?(c.linear_gradient_idx=h.readVarint(),c.paint="linear_gradient_idx"):f===3?(c.radial_gradient_idx=h.readVarint(),c.paint="radial_gradient_idx"):f===5?h.readPackedFloat(c.dasharray):f===6?c.dashoffset=h.readFloat():f===7?c.miterlimit=h.readFloat():f===8?c.opacity=h.readVarint():f===9?c.width=h.readFloat():f===10?c.linecap=h.readVarint():f===11&&(c.linejoin=h.readVarint())}function Ght(f,c,h){f===1?c.transform=L7(h,h.readVarint()+h.pos):f===2?c.spread_method=h.readVarint():f===3?c.stops.push(bTe(h,h.readVarint()+h.pos)):f===4?c.x1=h.readFloat():f===5?c.y1=h.readFloat():f===6?c.x2=h.readFloat():f===7&&(c.y2=h.readFloat())}function bTe(f,c){return f.readFields(Wht,{offset:0,opacity:255,rgb_color:sxe},c)}function Wht(f,c,h){f===1?c.offset=h.readFloat():f===2?c.opacity=h.readVarint():f===3&&(c.rgb_color=D7(h.readVarint()))}function Kht(f,c,h){f===1?c.transform=L7(h,h.readVarint()+h.pos):f===2?c.spread_method=h.readVarint():f===3?c.stops.push(bTe(h,h.readVarint()+h.pos)):f===4?c.cx=h.readFloat():f===5?c.cy=h.readFloat():f===6?c.r=h.readFloat():f===7?c.fx=h.readFloat():f===8?c.fy=h.readFloat():f===9&&(c.fr=h.readFloat())}function Zht(f,c,h){f===1?c.transform=L7(h,h.readVarint()+h.pos):f===2?c.clip_path_idx=h.readVarint():f===3&&c.children.push(I7(h,h.readVarint()+h.pos))}function Yht(f,c,h){f===1?c.left=c.top=h.readFloat():f===2?c.width=c.height=h.readFloat():f===3?c.top=h.readFloat():f===4?c.height=h.readFloat():f===5?c.mask_type=h.readVarint():f===6?c.mask_idx=h.readVarint():f===7&&c.children.push(I7(h,h.readVarint()+h.pos))}class Xht{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 Ea(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 G3(f,c=255,h){const g=c/255,j=f.toString(),T=h.has(j)?h.get(j).clone():f.clone();return T.a*=g,T.toString()}function M6(f,c){if(!kd()){const h=document.createElement("canvas");return h.width=f,h.height=c,h}return new OffscreenCanvas(f,c)}let rxe,T6=null;function nxe(f,c,h,g,j){for(const T of g.children)wTe(f,c,h,T,j)}function wTe(f,c,h,g,j){g.group?(f.save(),function(T,P,R,F,H){const Q=F.mask_idx!=null?R.masks[F.mask_idx]:null,te=F.clip_path_idx!=null?R.clip_paths[F.clip_path_idx]:null;if(F.transform&&(P=W3(F.transform).preMultiplySelf(P)),!function(ue,ge,ke){return ue.opacity!==255||ge||ke}(F,te!=null,Q!=null))return void nxe(T,P,R,F,H);const re=M6(T.canvas.width,T.canvas.height),le=re.getContext("2d");nxe(le,P,R,F,H),te&&TTe(le,P,R,te),Q&&ATe(le,P,R,Q,H),T.globalAlpha=F.opacity/255,T.drawImage(re,0,0)}(f,c,h,g.group,j),f.restore()):g.path&&(f.save(),function(T,P,R,F,H){T.setTransform(P),F.paint_order===1?(jTe(T,R,F,H),kTe(T,R,F,H)):(kTe(T,R,F,H),jTe(T,R,F,H))}(f,c,h,g.path,j),f.restore())}function jTe(f,c,h,g){const j=h.fill;if(!j)return;const T=j.opacity/255;switch(f.save(),f.beginPath(),ETe(h,f),j.paint){case"rgb_color":f.fillStyle=G3(j.rgb_color,j.opacity,g);break;case"linear_gradient_idx":{const P=c.linear_gradients[j.linear_gradient_idx];P.transform&&f.setTransform(W3(P.transform).preMultiplySelf(f.getTransform())),f.fillStyle=STe(f,P,T,g);break}case"radial_gradient_idx":{const P=c.radial_gradients[j.radial_gradient_idx];P.transform&&f.setTransform(W3(P.transform).preMultiplySelf(f.getTransform())),f.fillStyle=CTe(f,P,T,g)}}f.fill(NTe(h)),f.restore()}function NTe(f){return f.rule===1?"nonzero":f.rule===2?"evenodd":void 0}function kTe(f,c,h,g){const j=h.stroke;if(!j)return;const T=PTe(h);f.lineWidth=j.width,f.miterLimit=j.miterlimit,f.setLineDash(j.dasharray),f.lineDashOffset=j.dashoffset;const P=j.opacity/255;switch(j.paint){case"rgb_color":f.strokeStyle=G3(j.rgb_color,j.opacity,g);break;case"linear_gradient_idx":f.strokeStyle=STe(f,c.linear_gradients[j.linear_gradient_idx],P,g,!0);break;case"radial_gradient_idx":f.strokeStyle=CTe(f,c.radial_gradients[j.radial_gradient_idx],P,g,!0)}switch(j.linejoin){case 2:case 1:f.lineJoin="miter";break;case 3:f.lineJoin="round";break;case 4:f.lineJoin="bevel"}switch(j.linecap){case 1:f.lineCap="butt";break;case 2:f.lineCap="round";break;case 3:f.lineCap="square"}f.stroke(T)}function STe(f,c,h,g,j=!1){if(c.stops.length===1){const re=c.stops[0];return G3(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=W3(c.transform);H=re.transformPoint(H),Q=re.transformPoint(Q)}const te=f.createLinearGradient(H.x,H.y,Q.x,Q.y);for(const re of c.stops)te.addColorStop(re.offset,G3(re.rgb_color,re.opacity*h,g));return te}function CTe(f,c,h,g,j=!1){if(c.stops.length===1){const Ee=c.stops[0];return G3(Ee.rgb_color,Ee.opacity*h,g)}const T=W3(c.transform),{fx:P,fy:R,fr:F,cx:H,cy:Q,r:te}=c;let re=new DOMPoint(P,R),le=new DOMPoint(H,Q),ue=F,ge=te;if(j){re=T.transformPoint(re),le=T.transformPoint(le);const Ee=(T.a+T.d)/2;ue=F*Ee,ge=c.r*Ee}const ke=f.createRadialGradient(re.x,re.y,ue,le.x,le.y,ge);for(const Ee of c.stops)ke.addColorStop(Ee.offset,G3(Ee.rgb_color,Ee.opacity*h,g));return ke}function MTe(f,c,h,g){const j=g.transform?W3(g.transform).preMultiplySelf(c):c,T=M6(f.canvas.width,f.canvas.height),P=T.getContext("2d");for(const F of g.children)if(F.group)MTe(P,j,h,F.group);else if(F.path){const H=F.path,Q=new Path2D;Q.addPath(PTe(H),j),P.fill(Q,NTe(H))}const R=g.clip_path_idx!=null?h.clip_paths[g.clip_path_idx]:null;R&&TTe(P,j,h,R),f.globalCompositeOperation="source-over",f.drawImage(T,0,0)}function TTe(f,c,h,g){const j=M6(f.canvas.width,f.canvas.height);MTe(j.getContext("2d"),c,h,g),f.globalCompositeOperation="destination-in",f.drawImage(j,0,0)}function ATe(f,c,h,g,j){if(g.children.length===0)return;const T=g.mask_idx!=null?h.masks[g.mask_idx]:null;T&&ATe(f,c,h,T,j);const P=f.canvas.width,R=f.canvas.height,F=M6(P,R),H=F.getContext("2d"),Q=g.width,te=g.height,re=g.left,le=g.top,ue=new Path2D,ge=new Path2D;ge.rect(re,le,Q,te),ue.addPath(ge,c),H.clip(ue);for(const He of g.children)wTe(H,c,h,He,j);const ke=H.getImageData(0,0,P,R),Ee=ke.data;if(g.mask_type===1)for(let He=0;Hec[P])return null}else{const R=1/g[P];let F=(f[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 DTe(f,c,h,g,j,T,P,R,F,H,Q){const te=g-f,re=j-c,le=T-h,ue=P-f,ge=R-c,ke=F-h,Ee=Q[1]*ke-Q[2]*ge,He=Q[2]*ue-Q[0]*ke,$e=Q[0]*ge-Q[1]*ue,rt=te*Ee+re*He+le*$e;if(Math.abs(rt)<1e-15)return null;const it=1/rt,lt=H[0]-f,Pt=H[1]-c,jt=H[2]-h,At=(lt*Ee+Pt*He+jt*$e)*it;if(At<0||At>1)return null;const St=Pt*le-jt*re,Ct=jt*te-lt*le,ss=lt*re-Pt*te,is=(Q[0]*St+Q[1]*Ct+Q[2]*ss)*it;return is<0||At+is>1?null:(ue*St+ge*Ct+ke*ss)*it}function RTe(f,c,h){return(f-c)/(h-c)}function OTe(f,c,h,g,j,T,P,R,F){const H=1<{const He=ke?1:0,$e=(le+1)*ge-He,rt=ue*ge,it=(ue+1)*ge-He;Ee[0]=le*ge,Ee[1]=rt,Ee[2]=$e,Ee[3]=it};let te=new ITe(F);const re=[];for(let le=0;le=1;F/=2){const le=R[R.length-1];te=new ITe(F);for(let ue=0;ue0;){const{idx:ue,t:ge,nodex:ke,nodey:Ee,depth:He}=le.pop();if(this.leaves[ue]){OTe(ke,Ee,He,c,h,g,j,te,re);const rt=1<=hs[2])return ge}continue}let $e=0;for(let rt=0;rt=H[Q[jt]]&&(Q.splice(jt,0,rt),Pt=!0);Pt||(Q[$e]=rt),$e++}}for(let rt=0;rt<$e;rt++){const it=Q[rt];le.push({idx:this.childOffsets[ue]+it,t:H[it],nodex:(ke<<1)+this._siblingOffset[it][0],nodey:(Ee<<1)+this._siblingOffset[it][1],depth:He+1})}}return null}_addNode(c,h,g){return this.minimums.push(c),this.maximums.push(h),this.leaves.push(g),this.childOffsets.push(0),this.nodeCount++}_construct(c,h,g,j,T){if(c[j].isLeaf(h,g)===1)return;this.childOffsets[T]||(this.childOffsets[T]=this.nodeCount);const P=j-1,R=c[P];let F=0,H=0;for(let Q=0;Q=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=O7.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 _3e({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&f[c]);return f}function umt(f,c){switch(c){case"uint32":return f;case"uint16":for(let h=0;h>4|(61440&g)>>8|(240&j)<<4|61440&j,f[h+1]=15&g|(3840&g)>>4|(15&j)<<8|(3840&j)<<4}return f;case"uint8":for(let h=0;h>6|(192&j)>>4|(192&T)>>2|192&P,f[h+1]=(48&g)>>4|(48&j)>>2|48&T|(48&P)<<2,f[h+2]=(12&g)>>2|12&j|(12&T)<<2|(12&P)<<4,f[h+3]=3&g|(3&j)<<2|(3&T)<<4|(3&P)<<6}return f;default:throw new Error(`Invalid pixel format, "${c}"`)}}xr(O7,"DEMData"),xr(FTe,"DemMinMaxQuadTree",{omit:["dem"]});var Ip=Uint8Array,A6=Uint16Array,hmt=Int32Array,BTe=new Ip([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]),$Te=new Ip([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]),mmt=new Ip([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qTe=function(f,c){for(var h=new A6(31),g=0;g<31;++g)h[g]=c+=1<>1|(21845&zl)<<1;HTe[zl]=((65280&(K3=(61680&(K3=(52428&K3)>>2|(13107&K3)<<2))>>4|(3855&K3)<<4))>>8|(255&K3)<<8)>>1}var E6=function(f,c,h){for(var g=f.length,j=0,T=new A6(c);j>F]=H;return P},P6=new Ip(288);for(zl=0;zl<144;++zl)P6[zl]=8;for(zl=144;zl<256;++zl)P6[zl]=9;for(zl=256;zl<280;++zl)P6[zl]=7;for(zl=280;zl<288;++zl)P6[zl]=8;var GTe=new Ip(32);for(zl=0;zl<32;++zl)GTe[zl]=5;var xmt=E6(P6,9),gmt=E6(GTe,5),ixe=function(f){for(var c=f[0],h=1;hc&&(c=f[h]);return c},tg=function(f,c,h){var g=c/8|0;return(f[g]|f[g+1]<<8)>>(7&c)&h},oxe=function(f,c){var h=c/8|0;return(f[h]|f[h+1]<<8|f[h+2]<<16)>>(7&c)},ymt=function(f){return(f+7)/8|0},vmt=["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"],sg=function(f,c,h){var g=new Error(c||vmt[f]);if(g.code=f,Error.captureStackTrace&&Error.captureStackTrace(g,sg),!h)throw g;return g},_mt=new Ip(0),bmt=typeof TextDecoder<"u"&&new TextDecoder;try{bmt.decode(_mt,{stream:!0})}catch{}const wmt={gzip_data:"gzip"};class Ff extends Error{constructor(c){super(c),this.name="MRTError"}}const jmt={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},WTe={uint32:1,uint16:2,uint8:4},Nmt={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let lxe;class F7{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 Ff(`Layer '${c}' not found`);return h}getHeaderLength(c){const h=new Uint8Array(c),g=new DataView(c);if(h[0]!==13)throw new Ff("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 lxe(h.subarray(0,g)).readFields(tmt,{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 Ff(`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 KTe(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 ZTe(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 KTe{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 Ff(`Cannot parse raster layer encoded with MRT version ${c}`);this.name=h,this.units=g,this.tileSize=j,this.buffer=P,this.pixelFormat=jmt[T],this.dataIndex=R,this.bandShape=[j+2*P,j+2*P,WTe[this.pixelFormat]],this._decodedBlocks=new R7(F?F.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return WTe[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 Ff(`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 Ff(`Band not found: ${JSON.stringify(c)}`);const j=this._decodedBlocks.get(h.toString());if(!j)throw new Ff(`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}}}F7.setPbf=function(f){lxe=f};class ZTe{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)}}F7.performDecoding=function(f,c){const h=new Uint8Array(f);return Promise.all(c.tasks.map(g=>{const{layerName:j,firstByte:T,lastByte:P,pixelFormat:R,blockShape:F,blockIndex:H,filters:Q,codec:te}=g,re=h.subarray(T,P+1),le=new Uint32Array(F[0]*F[1]*F[2]);let ue;if(te!=="gzip_data")throw new Ff(`Unhandled codec: ${te}`);return ue=function(ge,ke){if(!globalThis.DecompressionStream&&ke==="gzip_data")return Promise.resolve((it=function(jt){jt[0]==31&&jt[1]==139&&jt[2]==8||sg(6,"invalid gzip data");var At=jt[3],St=10;4&At&&(St+=2+(jt[10]|jt[11]<<8));for(var Ct=(At>>3&1)+(At>>4&1);Ct>0;Ct-=!jt[St++]);return St+(2&At)}(Ee=ge),it+8>Ee.length&&sg(6,"invalid gzip data"),function(jt,At,St,Ct){var ss=jt.length;if(!ss||At.f&&!At.l)return St||new Ip(0);var is=!St,us=is||At.i!=2,vs=At.i;is&&(St=new Ip(3*ss));var hs=function(mo){var Zd=St.length;if(mo>Zd){var Tc=new Ip(Math.max(2*Zd,mo));Tc.set(St),St=Tc}},Is=At.f||0,es=At.p||0,gs=At.b||0,Ss=At.l,Ls=At.d,Ws=At.m,pr=At.n,er=8*ss;do{if(!Ss){Is=tg(jt,es,1);var Js=tg(jt,es+1,3);if(es+=3,!Js){var Ks=jt[(Wa=ymt(es)+4)-4]|jt[Wa-3]<<8,dr=Wa+Ks;if(dr>ss){vs&&sg(0);break}us&&hs(gs+Ks),St.set(jt.subarray(Wa,dr),gs),At.b=gs+=Ks,At.p=es=8*dr,At.f=Is;continue}if(Js==1)Ss=xmt,Ls=gmt,Ws=9,pr=5;else if(Js==2){var wr=tg(jt,es,31)+257,Br=tg(jt,es+10,15)+4,Tr=wr+tg(jt,es+5,31)+1;es+=14;for(var Nn=new Ip(Tr),Na=new Ip(19),kn=0;kn>4)<16)Nn[kn++]=Wa;else{var Ni=0,no=0;for(Wa==16?(no=3+tg(jt,es,3),es+=2,Ni=Nn[kn-1]):Wa==17?(no=3+tg(jt,es,7),es+=3):Wa==18&&(no=11+tg(jt,es,127),es+=7);no--;)Nn[kn++]=Ni}}var ic=Nn.subarray(0,wr),ao=Nn.subarray(wr);Ws=ixe(ic),pr=ixe(ao),Ss=E6(ic,Ws),Ls=E6(ao,pr)}else sg(1);if(es>er){vs&&sg(0);break}}us&&hs(gs+131072);for(var Ao=(1<>4;if((es+=15&Ni)>er){vs&&sg(0);break}if(Ni||sg(2),ld<256)St[gs++]=ld;else{if(ld==256){Eo=es,Ss=null;break}var oc=ld-254;ld>264&&(oc=tg(jt,es,(1<<(zo=BTe[kn=ld-257]))-1)+VTe[kn],es+=zo);var Wn=Ls[oxe(jt,es)&el],ku=Wn>>4;if(Wn||sg(3),es+=15&Wn,ao=fmt[ku],ku>3){var zo=$Te[ku];ao+=oxe(jt,es)&(1<er){vs&&sg(0);break}us&&hs(gs+131072);var Mc=gs+oc;if(gsmo.length)&&(Tc=mo.length),new Ip(mo.subarray(0,Tc))}(St,0,gs):St.subarray(0,gs)}(Ee.subarray(it,-8),{i:2},new Ip((($e=Ee)[(rt=$e.length)-4]|$e[rt-3]<<8|$e[rt-2]<<16|$e[rt-1]<<24)>>>0),He)));var Ee,He,$e,rt,it;const lt=wmt[ke];if(!lt)throw new Error(`Unhandled codec: ${ke}`);const Pt=new globalThis.DecompressionStream(lt);return new Response(new Blob([ge]).stream().pipeThrough(Pt)).arrayBuffer().then(jt=>new Uint8Array(jt))}(re,te).then(ge=>(function(ke,Ee){ke.readFields(omt,Ee)}(new lxe(ge),le),new Nmt[R](le.buffer))),ue.then(ge=>{for(let ke=Q.length-1;ke>=0;ke--)switch(Q[ke]){case"delta_filter":cmt(ge,F);break;case"zigzag_filter":dmt(ge);break;case"bitshuffle_filter":umt(ge,R);break;default:throw new Ff(`Unhandled filter "${Q[ke]}"`)}return{layerName:j,blockIndex:H,data:ge}}).catch(ge=>{throw ge})}))},xr(ZTe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),xr(F7,"MapboxRasterTile"),xr(KTe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const YTe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class cxe{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=YTe[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 cxe(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=YTe.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 dxe(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,te=F.pop()||0,re=F.pop()||0;if(te-re<=R){for(let ke=re;ke<=te;ke++){const Ee=P[2*ke],He=P[2*ke+1];Ee>=c&&Ee<=g&&He>=h&&He<=j&&H.push(T[ke])}continue}const le=re+te>>1,ue=P[2*le],ge=P[2*le+1];ue>=c&&ue<=g&&ge>=h&&ge<=j&&H.push(T[le]),(Q===0?c<=ue:h<=ge)&&(F.push(re),F.push(le-1),F.push(1-Q)),(Q===0?g>=ue:j>=ge)&&(F.push(le+1),F.push(te),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,te=R.pop()||0,re=R.pop()||0;if(te-re<=P){for(let ke=re;ke<=te;ke++)QTe(T[2*ke],T[2*ke+1],c,h)<=H&&F.push(j[ke]);continue}const le=re+te>>1,ue=T[2*le],ge=T[2*le+1];QTe(ue,ge,c,h)<=H&&F.push(j[le]),(Q===0?c-g<=ue:h-g<=ge)&&(R.push(re),R.push(le-1),R.push(1-Q)),(Q===0?c+g>=ue:h+g>=ge)&&(R.push(le+1),R.push(te),R.push(1-Q))}return F}}function dxe(f,c,h,g,j,T){if(j-g<=h)return;const P=g+j>>1;XTe(f,c,P,g,j,T),dxe(f,c,h,g,P-1,1-T),dxe(f,c,h,P+1,j,1-T)}function XTe(f,c,h,g,j,T){for(;j>g;){if(j-g>600){const H=j-g+1,Q=h-g+1,te=Math.log(H),re=.5*Math.exp(2*te/3),le=.5*Math.sqrt(te*re*(H-re)/H)*(Q-H/2<0?-1:1);XTe(f,c,h,Math.max(g,Math.floor(h-Q*re/H+le)),Math.min(j,Math.floor(h+(H-Q)*re/H+le)),T)}const P=c[2*h+T];let R=g,F=j;for(I6(f,c,g,h),c[2*j+T]>P&&I6(f,c,g,j);RP;)F--}c[2*g+T]===P?I6(f,c,g,F):(F++,I6(f,c,F,j)),F<=h&&(g=F+1),h<=F&&(j=F-1)}}function I6(f,c,h,g){uxe(f,h,g),uxe(c,2*h,2*g),uxe(c,2*h+1,2*g+1)}function uxe(f,c,h){const g=f[c];f[c]=f[h],f[h]=g}function QTe(f,c,h,g){const j=f-h,T=c-g;return j*j+T*T}i.$=B1,i.A=class{constructor(f,c,h){this.target=f,this.parent=c,this.mapId=h,this.callbacks={},this.cancelCallbacks={},Xt(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new Iht}send(f,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:f,hasCallback:!!h,targetMapId:g,mustQueue:j,sourceMapId:this.mapId,data:Hx(c,R)},R),{cancel:()=>{h&&delete this.callbacks[P],this.target.postMessage({id:P,type:"",targetMapId:g,sourceMapId:this.mapId})}}}receive(f){const c=f.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||da(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(f,c){if(delete this.cancelCallbacks[f],c.type===""){const h=this.callbacks[f];delete this.callbacks[f],h&&(c.error?h(cy(c.error)):h(null,cy(c.data)))}else{const h=new Set,g=c.hasCallback?(T,P)=>{this.target.postMessage({id:f,type:"",sourceMapId:this.mapId,error:T?Hx(T):null,data:Hx(P,h)},h)}:()=>{},j=cy(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=pn,i.C=Jr,i.D=qm,i.E=Ai,i.F=Y0,i.G=2,i.H=x6,i.I=kc,i.J=xMe,i.K=RC,i.L=vF,i.M=Dw,i.N=Rw,i.O=n3,i.P=rs,i.Q=r3,i.R=I0,i.S=rP,i.T=gy,i.U=t2,i.V=A7,i.W=x3,i.X=ly,i.Y=aP,i.Z=Af,i._=U0,i.a=function(f){return ua.API_CDN_URL_REGEX.test(f)},i.a$=h7,i.a0=nc,i.a1=Ow,i.a2=OC,i.a3=D0,i.a4=NP,i.a5=class extends A7{},i.a6=nP,i.a7=sF,i.a8=Gt,i.a9=function(f){const c=f.value;return c?OC(c)?Qfe(c,!0)?[]:[new A7(f.key,c,`invalid url "${c}"`)]:[new A7(f.key,c,`string expected, "${Dw(c)}" found`)]:[]},i.aA=V5e,i.aB=function(f){let c=1/0,h=1/0,g=-1/0,j=-1/0;for(const T of f)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 rs(c,h),max:new rs(g,j)}},i.aC=Oe,i.aD=C,i.aE=xt,i.aF=mt,i.aG=Wu,i.aH=ws,i.aI=mr,i.aJ=function(f,c){const h={};for(let g=0;g=0?c.slice(h+1):""}catch{return""}},i.aN=class{constructor(f){this.entries={},this.scheduler=f}request(f,c,h,g){const j=this.entries[f]=this.entries[f]||{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[f],3e3)})),()=>{j.result||(j.callbacks=j.callbacks.filter(T=>T!==g),j.callbacks.length||(j.cancel(),delete this.entries[f]))}}},i.aO=function(f,c,h){const g=JSON.stringify(f.request);return f.data&&(this.deduped.entries[g]={result:[null,f.data]}),this.deduped.request(g,{type:"parseTile",renderSourceType:f.renderSourceType,zoom:f.tileZoom},j=>{const T=Jg(f.request,(P,R,F)=>{P?A1(P)?j(null,null):j(P):R&&j(null,{rawData:R,vectorTile:h?void 0:new za(new h7(R)),responseHeaders:new Map(F.entries())})});return()=>{T.cancel(),j(null,null)}},c)},i.aP=function(f){return f?{cacheControl:f.get("cache-control"),expires:f.get("expires")}:{cacheControl:void 0,expires:void 0}},i.aQ=function(f){Cd++,Cd>Sp&&(f.getActor().send("enforceCacheSizeLimit",kp),Cd=0)},i.aR=Nu,i.aS=XMe,i.aT=aTe,i.aU=Bt,i.aV=YMe,i.aW=function(f,c){const h=document.createElement("video");h.muted=!0,h.onloadstart=function(){c(null,h)};for(let g=0;g{}}},i.aX=u6,i.aY=E2,i.aZ=Xt,i.a_=F7,i.aa=f3,i.ab=Xi,i.ac=Ys,i.ad=class{constructor(f){this.specification=f}possiblyEvaluate(f,c){return ta(f.expression.evaluate(c))}interpolate(f,c,h){return{x:sn(f.x,c.x,h),y:sn(f.y,c.y,h),z:sn(f.z,c.z,h),azimuthal:sn(f.azimuthal,c.azimuthal,h),polar:sn(f.polar,c.polar,h)}}},i.ae=Ga,i.af=H0,i.ag=br,i.ah=dt,i.ai=ce,i.aj=Xe,i.ak=Kx,i.al=rv,i.am=sn,i.an=sr,i.ao=Mp,i.ap=Kt,i.aq=Ea,i.ar=class{constructor(f){this.specification=f}possiblyEvaluate(f,c){return function([h,g]){const j=ta([1,h,g]);return{x:j.x,y:j.y,z:j.z}}(f.expression.evaluate(c))}interpolate(f,c,h){return{x:sn(f.x,c.x,h),y:sn(f.y,c.y,h),z:sn(f.z,c.z,h)}}},i.as=function(f,c,h=0,g=!0){const j=new rs(h,h),T=f.sub(j),P=c.add(j),R=[T,new rs(P.x,T.y),P,new rs(T.x,P.y)];return g&&R.push(T.clone()),R},i.at=function(f,c){const h=[];for(let g=0;gthis.buckets[te].layers.some(re=>P.has(re.fqid))),F=Object.keys(this.buckets).some(te=>this.buckets[te].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 f=0;for(const c in this.buckets){const h=this.buckets[c];h.evaluateQueryRenderedFeaturePadding&&(f=Math.max(f,h.evaluateQueryRenderedFeaturePadding()))}return f}queryRenderedFeatures(f,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 te=q([],[.5*H.width,.5*-H.height,1]);return E(te,te,[1,-1,0]),C(te,te,H.calculateProjMatrix(Q.toUnwrapped())),Float32Array.from(te)}(j,this.tileID);return this.latestFeatureIndex.query(f,{tilespaceGeometry:c,pixelPosMatrix:F,transform:g,availableImages:h,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:R,scope:P})}querySourceFeatures(f,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=g3(c&&c.filter),{z:R,x:F,y:H}=this.tileID.canonical,Q={z:R,x:F,y:H};for(let te=0;teh)g=!1;else if(c)if(this.expirationTimeh.appearances&&h.appearances.length>0))return!0;return!1}updateBuckets(f,c,h,g,j,T){if(!this.latestFeatureIndex||!f.style)return;const P=T||f.style.listImages(),R=f.style.getBrightness(),F=j||new Set;for(const H in this.buckets){if(!f.style.hasLayer(H))continue;const Q=this.buckets[H],te=Q.layers[0],re=te.sourceLayer||"_geojsonTileLayer",le=f.style.getLayerSourceCache(te),ue=Q.layers.some(it=>F.has(it.fqid)),ge=(g||ue)&&Q instanceof eg?f.style.getOwnLayer(H):void 0;let ke=h&&h[re]||{};le&&!h&&(ke=le._state.getState(re,void 0));const Ee=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},He=Object.keys(ke).length>0&&!c;Q.hasAppearances=Q.layers.some(it=>it.appearances&&it.appearances.length>0);const $e=He?Q.stateDependentLayers:Q.layers;if(He&&Q.stateDependentLayers.length!==0||c||ue||g){const it=this.latestFeatureIndex.loadVTLayers()[re];if(Q.update(ke,it,P,Ee,$e,c,R,this.tileID.canonical),(g||ue)&&!c&&Q instanceof eg&&ge&&ge.type==="symbol"){const lt=Q;lt.text&<.text.uboBinder&<.text.uboBinder.updateDynamicExpressions(ge,it,this.tileID.canonical,P,ke,R),lt.icon&<.icon.uboBinder&<.icon.uboBinder.updateDynamicExpressions(ge,it,this.tileID.canonical,P,ke,R)}if(Q instanceof eg){const lt=Q,Pt=f.context;lt.text&<.text.uboBinder&<.text.uboBinder.upload(Pt),lt.icon&<.icon.uboBinder&<.icon.uboBinder.upload(Pt)}}if(He&&Q.stateDependentLayers.length!==0||c||Q.hasAppearances){const it={zoom:f.transform.zoom,pitch:f.transform.pitch,brightness:f.style.getBrightness()||0,worldview:f.worldview},lt=Q.updateAppearances(this.tileID.canonical,ke,P,it,f.imageManager,He&&Q.stateDependentLayers.length!==0);if(lt&<.hasUboChanges){const Pt=f.context;Q instanceof eg&&Q.text&&Q.text.uboBinder&&Q.text.uboBinder.upload(Pt),Q instanceof eg&&Q.icon&&Q.icon.uboBinder&&Q.icon.uboBinder.upload(Pt)}}(Q instanceof u7||Q instanceof GF)&&f._terrain&&f._terrain.enabled&&le&&Q.uploadPending()&&f._terrain._clearRenderCacheForTile(le.id,this.tileID);const rt=f&&f.style&&f.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;ge--){const ke=4*ge,Ee=l_[ke+0],He=l_[ke+1],$e=l_[ke+2],rt=l_[ke+3],it=Ee+$e>>1,lt=He+rt>>1,Pt=it+lt-He,jt=lt+Ee-it,At=He*yy+Ee,St=rt*yy+$e,Ct=lt*yy+it,ss=Math.hypot((vy[2*At+0]+vy[2*St+0])/2-vy[2*Ct+0],(vy[2*At+1]+vy[2*St+1])/2-vy[2*Ct+1])>=16;c_[Ct]=c_[Ct]||(ss?1:0),ge<1022&&(c_[Ct]=c_[Ct]||c_[(He+jt>>1)*yy+(Ee+Pt>>1)]||c_[(rt+jt>>1)*yy+($e+Pt>>1)])}const Q=new id,te=new To;let re=0;function le(ge,ke){const Ee=ke*yy+ge;return P7[Ee]===0&&(Q.emplaceBack(vy[2*Ee+0],vy[2*Ee+1],ge*sr/Of,ke*sr/Of),P7[Ee]=++re),P7[Ee]-1}function ue(ge,ke,Ee,He,$e,rt){const it=ge+Ee>>1,lt=ke+He>>1;if(Math.abs(ge-$e)+Math.abs(ke-rt)>1&&c_[lt*yy+it])ue($e,rt,ge,ke,it,lt),ue(Ee,He,$e,rt,it,lt);else{const Pt=le(ge,ke),jt=le(Ee,He),At=le($e,rt);te.emplaceBack(Pt,jt,At)}}return ue(0,0,Of,Of,Of,0),ue(Of,Of,0,0,0,Of),{vertices:Q,indices:te}}(this.tileID.canonical,c);g=T.vertices,j=T.indices}else{g=new id,j=new To;for(const{x:P,y:R}of h)g.emplaceBack(P,R,0,0);const T=P3(g.int16.subarray(0,4*g.length),void 0,4);for(let P=0;P0&&(P=k(new Float64Array(16),c.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(f,g,c,j,P,T),this._makeGlobeTileDebugTextBuffer(f,g,c,j,P,T)}_globePoint(f,c,h,g,j,T,P){let R=KP(f,c,h);if(T){const F=1<.5?re=-1:te<-.5&&(re=1);let le=(f/sr+h.x)/F+re,ue=(c/sr+h.y)/F;le=(le-H)*g._pixelsPerMercatorPixel+H,ue=(ue-Q)*g._pixelsPerMercatorPixel+Q;const ge=[le*g.worldSize,ue*g.worldSize,0];dt(ge,ge,T),R=sv(R,ge,P)}return dt(R,R,j)}_makeGlobeTileDebugBorderBuffer(f,c,h,g,j,T){const P=new vh,R=new J0,F=new Lf,H=(te,re,le,ue,ge)=>{const ke=(le-te)/(ge-1),Ee=(ue-re)/(ge-1),He=P.length;for(let $e=0;$eH*te+re;for(let te=0;te1)return!1;const h=c.getSource().maxzoom,g=1<1)return c;const j=g.getSource().maxzoom,T=1<{const R=this.getAtTileOffset(f,j,T,P),F=g.upVector(f.canonical,j.x,j.y);return je(F,F,R*g.upVectorScale(f.canonical,c,h).metersToTile),F}}getForTilePoints(f,c,h,g){if(this.isUsingMockSource())return!1;const j=H3.create(this,f,g);return!!j&&(c.forEach(T=>{T[2]=this.exaggeration()*j.getElevationAt(T[0],T[1],h)}),!0)}getMinMaxForTile(f){if(this.isUsingMockSource())return null;const c=this.findDEMTileFor(f);if(!c||!c.dem)return null;const h=c.dem.tree,g=c.tileID,j=1<0&&(g+=(f[j]-0)*(f[j]-0)),c[j]<0&&(g+=(0-c[j])*(0-c[j]));return g},i.cL=function(f){return f*f*f*f*f},i.cM=Qt,i.cN=45,i.cO=T3,i.cP=function(f,c,h){const g=Math.sqrt(f*f+c*c+h*h),j=g>0?Math.acos(h/g)*Fr:0;let T=f!==0||c!==0?Math.atan2(-c,-f)*Fr+90:0;return T<0&&(T+=360),[g,T,j]},i.cQ=ie,i.cR=ta,i.cS=Cs,i.cT=oe,i.cU=Qa,i.cV=pe,i.cW=function(f){return[Math.pow(f[0],1/2.2),Math.pow(f[1],1/2.2),Math.pow(f[2],1/2.2)]},i.cX=C5e,i.cY=_fe,i.cZ=P5e,i.c_=Qfe,i.ca=2,i.cb=7,i.cc=6,i.cd=ve,i.ce=J,i.cf=X,i.cg=0,i.ch=1,i.ci=4,i.cj=5,i.ck=E3,i.cl=_h,i.cm=T5e,i.cn=b2,i.co=n3e,i.cp=function(f,c,h,g,j,T,P,R,F){if(F.name==="globe")return n3e(f,c,new b2(h,g,j),!1);const H=M2({z:h,x:g,y:j},F);return new Qa([(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(f,c,h){return f[0]=Math.min(c[0],h[0]),f[1]=Math.min(c[1],h[1]),f[2]=Math.min(c[2],h[2]),f[3]=Math.min(c[3],h[3]),f},i.cr=function(f,c,h){return f[0]=Math.max(c[0],h[0]),f[1]=Math.max(c[1],h[1]),f[2]=Math.max(c[2],h[2]),f[3]=Math.max(c[3],h[3]),f},i.cs=function(f){const c=Math.round((f+45+360)%360/90)%4;return zr[c]},i.ct=cs,i.cu=Ge,i.cv=6,i.cw=function(f){const c=w(new Float64Array(16));C(c,f.pixelMatrix,f.globeMatrix);const h=[0,wt,0],g=[0,Dt,0];return dt(h,h,c),dt(g,g,c),[h[0]>0&&h[0]<=f.width&&h[1]>0&&h[1]<=f.height&&!$pe(f,new Bt(f.center.lat,90)),g[0]>0&&g[0]<=f.width&&g[1]>0&&g[1]<=f.height&&!$pe(f,new Bt(f.center.lat,-90))]},i.cx=function(f,c){const{scale:h}=f.tileTransform,g=h*sr/(f.tileSize*Math.pow(2,c.zoom-f.tileID.overscaledZ+f.tileID.canonical.z));return function(j,T,P){var R=T[1],F=T[2],H=T[3],Q=P[0],te=P[1];return j[0]=T[0]*Q,j[1]=R*Q,j[2]=F*te,j[3]=H*te,j}(new Float32Array(4),c.inverseAdjustmentMatrix,[g,g])},i.cy=a7,i.cz=Y,i.d=function(f){return ua.API_TILEJSON_REGEX.test(f)},i.d$=Ict,i.d0=uo,i.d1=class{static calculate(f,c,h){const g=new Set,j=new Map,T=new Set,P=new Set;for(const F of Object.values(f))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 te=H===c,re=Q.connections&&c&&Q.connections.has(c);(te||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=x7,i.d3=zfe,i.d4=Ca,i.d5=function(){return{API_URL:ua.API_URL,DRACO_URL:ua.DRACO_URL,MESHOPT_URL:ua.MESHOPT_URL,MESHOPT_SIMD_URL:ua.MESHOPT_SIMD_URL,BUILDING_GEN_URL:ua.BUILDING_GEN_URL}},i.d6=xF,i.d7=Cw,i.d8=nr,i.d9=or,i.dA=OF,i.dB=vh,i.dC=To,i.dD=function(f,c){return[Math.pow(f[0],2.2)*c,Math.pow(f[1],2.2)*c,Math.pow(f[2],2.2)*c]},i.dE=x,i.dF=function(f,c){var h=Math.sin(c),g=Math.cos(c);return f[0]=g,f[1]=h,f[2]=0,f[3]=-h,f[4]=g,f[5]=0,f[6]=0,f[7]=0,f[8]=1,f},i.dG=fe,i.dH=i3e,i.dI=di,i.dJ=zi,i.dK=Yfe,i.dL=function(f,c){const h=[0,0,0];return dt(h,h,ZP(py(c.canonical))),dt(h,h,f),h},i.dM=f=>({u_matrix:new m(f),u_texsize:new Wm(f),u_pixels_to_tile_units:new D(f),u_device_pixel_ratio:new vl(f),u_width_scale:new vl(f),u_floor_width_scale:new vl(f),u_image:new v2(f),u_units_to_pixels:new Wm(f),u_tile_units_to_pixels:new vl(f),u_alpha_discard_threshold:new vl(f),u_trim_offset:new Wm(f),u_trim_fade_range:new Wm(f),u_trim_gradient_mix_range:new Wm(f),u_trim_color:new T3(f),u_zbias_factor:new vl(f),u_tile_to_meter:new vl(f),u_ground_shadow_factor:new _2(f),u_pattern_transition:new vl(f)}),i.dN=f=>({u_matrix:new m(f),u_pixels_to_tile_units:new D(f),u_device_pixel_ratio:new vl(f),u_width_scale:new vl(f),u_floor_width_scale:new vl(f),u_units_to_pixels:new Wm(f),u_dash_image:new v2(f),u_gradient_image:new v2(f),u_image_height:new vl(f),u_texsize:new Wm(f),u_tile_units_to_pixels:new vl(f),u_alpha_discard_threshold:new vl(f),u_trim_offset:new Wm(f),u_trim_fade_range:new Wm(f),u_trim_gradient_mix_range:new Wm(f),u_trim_color:new T3(f),u_zbias_factor:new vl(f),u_tile_to_meter:new vl(f),u_ground_shadow_factor:new _2(f)}),i.dO=f=>({u_camera_to_center_distance:new vl(f),u_extrude_scale:new D(f),u_device_pixel_ratio:new vl(f),u_matrix:new m(f),u_inv_rot_matrix:new m(f),u_merc_center:new Wm(f),u_tile_id:new _2(f),u_zoom_transition:new vl(f),u_up_dir:new _2(f),u_emissive_strength:new vl(f)}),i.dP=RP,i.dQ=Put,i.dR=class{constructor(f,c,h,g){this.context=f,this.format=g,this.size=h,this.texture=f.gl.createTexture();const[j,T,P]=this.size,{gl:R}=f;R.bindTexture(R.TEXTURE_3D,this.texture),f.pixelStoreUnpackFlipY.set(!1),f.pixelStoreUnpack.set(1),f.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in c&&c.data&&R.texImage3D(R.TEXTURE_3D,0,this.format,j,T,P,0,mfe(this.format),pfe(this.format),c.data)}bind(f,c){const{context:h}=this,{gl:g}=h;g.bindTexture(g.TEXTURE_3D,this.texture),f!==this.minFilter&&(g.texParameteri(g.TEXTURE_3D,g.TEXTURE_MAG_FILTER,f),g.texParameteri(g.TEXTURE_3D,g.TEXTURE_MIN_FILTER,f),this.minFilter=f),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:f}=this.context;f.deleteTexture(this.texture),this.texture=null}},i.dS=d3e,i.dT=(f,c,h,g,j,T)=>{const P=f.transform,R=P.projection.name==="globe";let F;if(T.paint.get("circle-pitch-alignment")==="map")if(R){const Q=i3e(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:f.transform.getCameraToCenterDistance(P.projection),u_matrix:f.translatePosMatrix(c.projMatrix,h,T.paint.get("circle-translate"),T.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Sd.devicePixelRatio,u_extrude_scale:F,u_inv_rot_matrix:zct,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=f.transform,te=Q.pitch<15?H5e(.07,.7,Oe((14-Q.zoom)/5,0,1)):.07,re=h.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:W5e(f,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:G5e(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:te,u_tile_to_meter:Cs(c.tileID.canonical,0),u_ground_shadow_factor:F,u_pattern_transition:H}},i.dX=(f,c,h,g,j,T,P,R,F,H)=>{const Q=f.transform,te=Q.calculatePixelsToTileUnitsMatrix(c),re=h.paint.get("line-trim-color-use-theme").constantOr("default")==="none",le=Q.pitch<15?H5e(.07,.7,Oe((14-Q.zoom)/5,0,1)):.07;return{u_matrix:W5e(f,c,h,g),u_pixels_to_tile_units:te,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:Z5e(h)&&c.lineAtlasTexture?c.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:G5e(c,f.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:le,u_tile_to_meter:Cs(c.tileID.canonical,0),u_ground_shadow_factor:H}},i.dY=Vt,i.dZ=YP,i.d_=as,i.da=function(f){const c=f.indexOf(l2);return c>=0?f.slice(0,c):f},i.db=function(f){return f.indexOf(l2)>=0},i.dc=function(f){const c=f.lastIndexOf(l2);return c>=0?f.slice(c+1):""},i.dd=function(f){const c=[],h=f.id;return h===void 0&&c.push({message:`layers.${h}: missing required property "id"`}),f.render===void 0&&c.push({message:`layers.${h}: missing required method "render"`}),f.renderingMode&&f.renderingMode!=="2d"&&f.renderingMode!=="3d"&&c.push({message:`layers.${h}: property "renderingMode" must be either "2d" or "3d"`}),c},i.de=function(f,c,h,g){return f.type==="custom"?new kht(f,c):new Aht[f.type](f,c,h,g)},i.df=xs,i.dg=g3,i.dh=NF,i.di=class extends A2{constructor(f,c){super(f._vectorTileFeature,f._z,f._x,f._y,f.id),f.state&&(this.state=Object.assign({},f.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=f.source,this.sourceLayer=f.sourceLayer,this.layer=f.layer)}toJSON(){const f=super.toJSON();return f.target=this.target,f.namespace=this.namespace,f}},i.dj=_P,i.dk=function(f){return f({pluginStatus:Wd,pluginURL:Qh}),_P.on("pluginStateChange",f),f},i.dl=Rpe,i.dm=class extends Gm{constructor(f){super(f),this.current=v}set(f,c,h){if(this.fetchUniformLocation(f,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=fa,i.dp=function(f,c,h){const g=rv(h.zoom),j=f.style.map._antialias,T=f.terrain&&f.terrain.exaggeration()>0;return g===0&&!j&&!T},i.dq=function(f){const c=f.pixelsPerMeter,h=c/Zt(1,f.center.lat),g=w(new Float64Array(16));return E(g,g,[f.point.x,f.point.y,0]),L(g,g,[h,h,c]),Float32Array.from(g)},i.dr=FF,i.ds=function(f){const c=80.051129;f=Oe(f,-80.051129,c)/c*90;const h=Math.pow(Math.abs(Math.sin(Kt(f))),3);return Math.round(h*(Ft.length-1))},i.dt=function(f,c,h,g){const j=c.getNorth(),T=c.getSouth(),P=c.getWest(),R=c.getEast(),F=1<0){const ue=180/g;_(le,le,[ue/H+1,0,0,0,ue/Q+1,0,-.5*ue/te,.5*ue/re,1])}return le[2]=F,le[5]=f.x,le[8]=f.y,le},i.du=ZP,i.dv=py,i.dw=function(f,c,h){const g=w(new Float64Array(16)),j=(c/(1<0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(f,c=!1){const h=V3e(new rs(0,0),new rs(sr,sr),f),g=[];if(c&&!sfe(h,this._globalClipBounds))return g;for(const j of this._activeRegions){if(j.hiddenByOverlap||!sfe(h,j))continue;const T=bdt(j.min,j.max,f);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(f){this._setSources(f.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(f){const c=f.getFootprints();if(c.length===0)return;const h=f.getOrder(),g=f.getClipMask(),j=f.getClipScope();for(const T of c){if(!T.footprint)continue;const P=V3e(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(f.getSourceId())}_computeReplacement(){this._activeRegions.sort((c,h)=>c.priority-h.priority||KF(c.min,h.min)||KF(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 f=this._activeRegions.length!==this._prevRegions.length;if(!f){let c=0;for(;!f&&c!==this._activeRegions.length;){const h=this._activeRegions[c],g=this._prevRegions[c];f=h.priority!==g.priority||!U3e(h,g)||h.order!==g.order||h.clipMask!==g.clipMask||!Bn(h.clipScope,g.clipScope),this._activeRegions[c].hiddenByOverlap=g.hiddenByOverlap,++c}}if(f){++this._updateTime;for(const h of this._activeRegions)h.order!==n6&&(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(f[c]);this._computeReplacement()}},i.eH=id,i.eI=C7,i.eJ=J0,i.eK=n6,i.eL=class{constructor(f){this._createGrid(f),this._createPoles(f)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const f of this._poleSegments)f.destroy();for(const f of this._gridSegments)f.withSkirts.destroy(),f.withoutSkirts.destroy()}_fillGridMeshWithLods(f,c){const h=new vh,g=new To,j=[],T=f+1+2,P=c[0]+1,R=c[0]+1+(1+c.length),F=(H,Q,te)=>{let re=H===T-1?H-2:H===0?H:H-1;return re+=te?24575:0,[re,Q]};for(let H=0;H>>=0,f=Math.imul(2747636419^f,2654435769)>>>0,f=Math.imul(f^f>>>16,2654435769)>>>0,(f=Math.imul(f^f>>>16,2654435769)>>>0)/4294967296},i.ec=s3e,i.ed=zpe,i.ee=Vm,i.ef=O,i.eg=function(f,c){return f[0]=c[0],f[1]=c[1],f[2]=c[2],f[3]=c[4],f[4]=c[5],f[5]=c[6],f[6]=c[8],f[7]=c[9],f[8]=c[10],f},i.eh=X0,i.ei=p2,i.ej=function(f,c,h,g,j){return Oe((f-c)/(h-c)*(j-g)+g,g,j)},i.ek=$t,i.el=function(f,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],te=Q*P-R*H,re=-Q*T+R*F,le=H*T-P*F,ue=h*te+g*re+j*le;return ue?(f[0]=te*(ue=1/ue),f[1]=(-Q*g+j*H)*ue,f[2]=(R*g-j*P)*ue,f[3]=re*ue,f[4]=(Q*h-j*F)*ue,f[5]=(-R*h+j*T)*ue,f[6]=le*ue,f[7]=(-H*h+g*F)*ue,f[8]=(P*h-g*T)*ue,f):null},i.em=QO,i.en=2,i.eo=Le,i.ep=Ke,i.eq=U,i.er=function(f,c){var h=new u(3);U(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,te=c[6]*T,re=c[8]*g,le=c[9]*j,ue=c[10]*T,ge=P+Q+ue,ke=0;return ge>0?(ke=2*Math.sqrt(ge+1),f[3]=.25*ke,f[0]=(te-le)/ke,f[1]=(re-F)/ke,f[2]=(R-H)/ke):P>Q&&P>ue?(ke=2*Math.sqrt(1+P-Q-ue),f[3]=(te-le)/ke,f[0]=.25*ke,f[1]=(R+H)/ke,f[2]=(re+F)/ke):Q>ue?(ke=2*Math.sqrt(1+Q-P-ue),f[3]=(re-F)/ke,f[0]=(R+H)/ke,f[1]=.25*ke,f[2]=(te+le)/ke):(ke=2*Math.sqrt(1+ue-P-Q),f[3]=(R-H)/ke,f[0]=(re+F)/ke,f[1]=(te+le)/ke,f[2]=.25*ke),f},i.es=function(f,c){var h=2*Math.acos(c[3]),g=Math.sin(h/2);return g>d?(f[0]=c[0]/g,f[1]=c[1]/g,f[2]=c[2]/g):(f[0]=1,f[1]=0,f[2]=0),h},i.et=txe,i.eu=l7,i.ev=o7,i.ew=[1,1,1],i.ex=H3,i.ey=function(f,c,h,g){var j=c[0],T=c[1],P=c[2],R=c[3];return f[0]=j+g*(h[0]-j),f[1]=T+g*(h[1]-T),f[2]=P+g*(h[2]-P),f[3]=R+g*(h[3]-R),f},i.ez=O3,i.f=_u,i.f0=l3e,i.f1=function(f){const c=[0,0,0],h=w(new Float64Array(16));return C(h,f.pixelMatrix,f.globeMatrix),dt(c,c,h),new rs(c[0],c[1])},i.f2=bP,i.f3=function(f,c,h=!1){if(Wd===yh.deferred||Wd===yh.loading||Wd===yh.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Qh=Sd.resolveURL(f),Wd=yh.deferred,If=c,vP(),h||gF()},i.f4=rc,i.f5=sc,i.f6=Jo,i.f7=function(f){const c=Sf();if(!c)return;const h=c.delete(xh);f&&h.then(()=>f()).catch(f)},i.f8=xr,i.f9=s_,i.fA=hn,i.fB=function(f){let c=0;if(new Uint32Array(f,0,1)[0]!==w5e){const h=new Uint32Array(f,0,7),[,,g,j,T,P]=h;c=h.byteLength+j+T+P+T,(g!==f.byteLength||c>=f.byteLength)&&Rr("Invalid b3dm header information.")}return S5e(f,c)},i.fC=function(f,c){const h=_fe(f);for(const g of h){for(const j of g.meshes)Qdt(j);g.lights&&(g.lightMeshIndex=g.meshes.length,g.meshes.push(Jdt(g.lights,c)))}return h},i.fD=E7,i.fE=da,i.fF=Wx,i.fG=yh,i.fH=function(f){zx(),Kh!=null&&Kh.then(c=>{c.keys().then(h=>{for(let g=0;gRr(j.message))}).catch(h=>Rr(h.message))}).catch(c=>Rr(c.message))},i.fa=2,i.fb=Vx,i.fc=M2,i.fd=qP,i.fe=hTe,i.ff=mTe,i.fg=$5e,i.fh=On,i.fi="hd_road_elevation",i.fj=Si,i.fk=Ts,i.fl=GF,i.fm=nv,i.fn=Ofe,i.fo=1,i.fp=eg,i.fq=function(f,c,h,g,j,T,P,R=1,F,H,Q,te){f.createArrays(),f.tilePixelRatio=sr/(512*f.overscaling),f.compareText={},f.iconsNeedLinear=!1;const re=f.layers[0].layout,le=f.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[ge,ke]=ue.textSizeScaleRange,[Ee,He]=ue.iconSizeScaleRange;ue.textScaleFactor=Oe(ue.scaleFactor,ge,ke),ue.iconScaleFactor=Oe(ue.scaleFactor,Ee,He);const $e=le["text-size"],rt=le["icon-size"];if(f.textSizeData.kind==="composite"){const{minZoom:St,maxZoom:Ct}=f.textSizeData;ue.compositeTextSizes=[$e.possiblyEvaluate(new Ga(St,{worldview:Q}),T),$e.possiblyEvaluate(new Ga(Ct,{worldview:Q}),T)]}if(f.iconSizeData.kind==="composite"){const{minZoom:St,maxZoom:Ct}=f.iconSizeData;ue.compositeIconSizes=[rt.possiblyEvaluate(new Ga(St,{worldview:Q}),T,te),rt.possiblyEvaluate(new Ga(Ct,{worldview:Q}),T,te)]}ue.layoutTextSize=$e.possiblyEvaluate(new Ga(P+1,{worldview:Q}),T),ue.layoutIconSize=rt.possiblyEvaluate(new Ga(P+1,{worldview:Q}),T,te),ue.textMaxSize=$e.possiblyEvaluate(new Ga(18,{worldview:Q}),T);const it=re.get("symbol-placement"),lt=re.get("text-rotation-alignment")==="map"&&it!=="point",Pt=re.get("text-size");let jt=!1;const At=[];for(const St of f.features){const Ct=re.get("text-font").evaluate(St,{},T).join(","),ss=Pt.evaluate(St,{},T)*ue.textScaleFactor,is=ue.layoutTextSize.evaluate(St,{},T)*ue.textScaleFactor,us=ue.layoutIconSize.evaluate(St,{},T,te)*ue.iconScaleFactor,vs={horizontal:{},vertical:void 0},hs=St.text;let Is,es=[0,0];if(hs){const Un=hs.toString(),ho=re.get("text-letter-spacing").evaluate(St,{},T)*ac,Wa=re.get("text-line-height").evaluate(St,{},T)*ac,La=wpe(Un)?ho:0,Ni=re.get("text-anchor").evaluate(St,{},T),no=re.get("text-variable-anchor");if(!no){const Eo=re.get("text-radial-offset").evaluate(St,{},T);if(Eo)es=SMe(Ni,[Eo*ac,$fe]);else{const ld=re.get("text-offset").evaluate(St,{},T);es=[ld[0]*ac,ld[1]*ac]}}let ic=lt?"center":re.get("text-justify").evaluate(St,{},T);const ao=it==="point",Ao=ao?re.get("text-max-width").evaluate(St,{},T)*ac:1/0,el=Eo=>{f.allowVerticalPlacement&&xP(Un)&&(vs.vertical=Afe(hs,c,h,j,Ct,Ao,Wa,Ni,Eo,La,es,am.vertical,!0,is,ss,F,ue.textScaleFactor))};if(!lt&&no){const Eo=ic==="auto"?no.map(oc=>qfe(oc)):[ic];let ld=!1;for(let oc=0;oc=0||!xP(Un)){const Eo=Afe(hs,c,h,j,Ct,Ao,Wa,Ni,ic,La,es,am.horizontal,!1,is,ss,F,ue.textScaleFactor);Eo&&(vs.horizontal[ic]=Eo)}el(ao?"left":ic)}}let gs,Ss,Ls,Ws,pr,er,Js=!1;const Ks=re.get("icon-text-fit").evaluate(St,{},T);if(St.icon&&St.icon.hasPrimary()){const Un=v6(St.icon,f.iconSizeData,le["icon-size"],T,f.zoom,St,F,ue.iconScaleFactor,Q,te);gs=Un.iconPrimary,Ls=Un.iconSecondary;const ho=gs.toString();if(Ss=g.get(ho),Ss&&(pr=re.get("icon-offset").evaluate(St,{},T),er=re.get("icon-anchor").evaluate(St,{},T),Is=p7(j.get(ho),Ls?j.get(Ls.toString()):void 0,pr,er),Js=Ss.sdf,f.sdfIcons===void 0?f.sdfIcons=Ss.sdf:f.sdfIcons!==Ss.sdf&&Rr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Ss.pixelRatio!==f.pixelRatio||re.get("icon-rotate").constantOr(1)!==0)&&(f.iconsNeedLinear=!0)),Ls){const Wa=Ls.toString();Ws=g.get(Wa)}}jt=jt||!(!St.icon||!St.icon.hasSecondary());const dr=b7(vs.horizontal)||vs.vertical;f.iconsInText||(f.iconsInText=!!dr&&dr.iconsInText);const wr=is*ue.textScaleFactor/ac,{defaultShapedIcon:Br,verticallyShapedIcon:Tr}=cht(f,Is,re,St,T,vs,wr,pr,Ks);Ks!=="none"&&Is&&(lMe(Is)||cMe(Is))&&(_7(0,Ss,gs,Is,Br,Ks,H,g,j),_7(0,Ws,Ls,Is,Br,Ks,H,g,j),Tr&&(_7(0,Ss,gs,Is,Tr,Ks,H,g,j),_7(0,Ws,Ls,Is,Tr,Ks,H,g,j))),Is=Br;const{iconBBox:Nn,iconVerticalBBox:Na,textBBox:kn,textVerticalBBox:Ma}=nht(f,Is,Tr,re,St,T,us,pr,ue,j,er,vs,is,es,te);At.push({feature:St,shapedTextOrientations:vs,shapedText:dr,shapedIcon:Is,iconPrimary:gs,iconSecondary:Ls,iconOffset:pr,iconAnchor:er,verticallyShapedIcon:Tr,layoutTextSize:is,layoutIconSize:us,textOffset:es,isSDFIcon:Js,iconTextFit:Ks,iconCollisionBounds:Nn,iconVerticalCollisionBounds:Na,textCollisionBounds:kn,textVerticalCollisionBounds:Ma})}return{featureData:At,sizes:ue,hasAnySecondaryIcon:jt,textAlongLine:lt,symbolPlacement:it}},i.fr=Ffe,i.fs=Rfe,i.ft=yMe,i.fu=vMe,i.fv=function(f,c,h,g,j,T,P,R,F,H){f.iconAtlasPositions=H.iconPositions;const{featureData:Q,hasAnySecondaryIcon:te,sizes:re,textAlongLine:le,symbolPlacement:ue}=c;for(const ge of Q){const{shapedIcon:ke,verticallyShapedIcon:Ee,feature:He,shapedTextOrientations:$e,shapedText:rt,layoutTextSize:it,textOffset:lt,isSDFIcon:Pt,iconPrimary:jt,iconSecondary:At,iconTextFit:St,iconOffset:Ct,iconCollisionBounds:ss,iconVerticalCollisionBounds:is,textCollisionBounds:us}=ge;AMe(ke,H.iconPositions,jt,At),AMe(Ee,H.iconPositions,jt,At),lht($e,H.iconPositions),oht(jt,At,H.iconPositions),(rt||ke)&&dht(f,He,$e,ke,Ee,F,re,it,0,lt,Pt,g,j,P,R,te,St,Ct,le,ue,ss,is,us)}h&&f.generateCollisionDebugBuffers(T,f.collisionBoxArray,re.textScaleFactor)},i.fw=u7,i.fx=za,i.fy=function(f){return f<=1?1:Math.pow(2,Math.floor(Math.log2(f)))},i.fz=O7,i.g=ua,i.h=function(f,c){return Qg(Object.assign(f,{method:"GET"}),c)},i.i=function(f){return ua.API_STYLE_REGEX.test(f)&&!bu(f)},i.j=function(f){return btoa(encodeURIComponent(f).replace(/%([0-9A-F]{2})/g,(c,h)=>String.fromCharCode(+("0x"+h))))},i.k=Bx,i.l=function(f){return decodeURIComponent(atob(f).split("").map(c=>"%"+("00"+c.charCodeAt(0).toString(16)).slice(-2)).join(""))},i.m=function(f,c){return Qg(Object.assign(f,{type:"json"}),c)},i.n=ey,i.o=Sd,i.p=function(f,c){return Qg(Object.assign(f,{method:"POST"}),c)},i.q=Ed,i.r=Ht,i.s=function(f){try{const c=self[f];return c.setItem("_mapbox_test_",1),c.removeItem("_mapbox_test_"),!0}catch{return!1}},i.t=bt,i.u=function(){return function f(c){return c?(c^Math.random()*(16>>c/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,f)}()},i.v=function(f){return!!f&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(f)},i.w=Rr,i.x=class{constructor(f){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(f&&f.maxTextureMemoryMB?f.maxTextureMemoryMB:256)*1024,this.finalizationRegistry=new FinalizationRegistry(c=>{this.cache.delete(c),this.clearExpiredTextures()})}calculateTextureMemory(f){return f.image?Math.ceil(f.image.width*f.image.height*4*(f.patternPositions.size>0?1.33:1)):0}evictTexture(f){const c=this.textures.get(f);if(c){const h=this.calculateTextureMemory(f);c.destroy(),this.textures.delete(f),this.textureAccessTimes.delete(f),this.textureMemoryUsed-=h}}evictTexturesIfNeeded(f){for(;this.textureMemoryUsed+f>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[or.id]),Ht=Mt[0];if(Ht.visibility==="none")continue;const Vt=Ht.source||"";let Xt=this.familiesBySource[Vt];Xt||(Xt=this.familiesBySource[Vt]=Object.create(null));const Ts=Ht.sourceLayer||"_geojsonTileLayer";let xs=Xt[Ts];xs||(xs=Xt[Ts]=[]),xs.push(Mt)}}}const b=1*d.fa;class N{constructor(Se){const Oe={},Xe=[];for(const Ht in Se){const Vt=Se[Ht],Xt=Oe[Ht]={};for(const Ts in Vt.glyphs){const xs=Vt.glyphs[+Ts];if(!xs||xs.bitmap.width===0||xs.bitmap.height===0)continue;const or=xs.metrics.localGlyph?b:1,Lr={x:0,y:0,w:xs.bitmap.width+2*or,h:xs.bitmap.height+2*or};Xe.push(Lr),Xt[Ts]=Lr}}const{w:_t,h:bt}=d.J(Xe),Mt=new d.f9({width:_t||1,height:bt||1});for(const Ht in Se){const Vt=Se[Ht];for(const Xt in Vt.glyphs){const Ts=Vt.glyphs[+Xt];if(!Ts||Ts.bitmap.width===0||Ts.bitmap.height===0)continue;const xs=Oe[Ht][Xt],or=Ts.metrics.localGlyph?b:1;d.f9.copy(Ts.bitmap,Mt,{x:0,y:0},{x:xs.x+or,y:xs.y+or},Ts.bitmap)}}this.image=Mt,this.positions=Oe}}function w(qt,Se,Oe){qt[Se]?Oe&&(qt[Se].center=Oe):qt[Se]={floorIds:new Set,center:Oe||[0,0],floors:{}}}function k(qt,Se,Oe,Xe){for(const _t of Se)w(qt,_t),qt[_t].floors[Oe]=Xe,qt[_t].floorIds.add(Oe)}function C(qt){return{id:qt.properties.id.toString(),center:[qt.properties.center_lon||0,qt.properties.center_lat||0]}}function E(qt,Se){const Oe=qt.properties.id.toString(),Xe=!!qt.properties.is_default&&qt.properties.is_default,_t=qt.properties.connected_floor_ids?new Set(qt.properties.connected_floor_ids.toString().split(";")):new Set,bt=qt.properties.conflicted_floor_ids?new Set(qt.properties.conflicted_floor_ids.toString().split(";")):new Set,Mt=qt.properties.structure_ids?new Set(qt.properties.structure_ids.toString().split(";")):new Set,Ht=qt.properties.name.toString(),Vt=qt.properties.z_index,Xt=function(Ts,xs){const or=Ts.loadGeometry();if(!or||or.length===0)return;const Lr=or.map(Hr=>Hr.map(Rr=>d.fb(Rr,xs,Ts.extent)));return Lr.length===0?void 0:{type:"Polygon",coordinates:[Lr[0]]}}(qt,Se);return{id:Oe,isDefault:Xe,connections:_t,conflicts:bt,buildings:Mt,name:Ht,zIndex:Vt,geometry:Xt}}function L(qt,Se){return Se.every(Oe=>qt.properties&&qt.properties[Oe]!=null)}function I(qt){return L(qt,["type","id","name"])&&qt.properties.type==="structure"}function O(qt){return L(qt,["type","id","name","z_index"])&&qt.properties.type==="floor"}d.f8(N,"GlyphAtlas");class V{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,Oe,Xe,_t,bt,Mt){this.status="parsing",this.data=Se,this.collisionBoxArray=new d.fd;const Ht=new d.fe(Object.keys(Se.layers).sort()),Vt=new d.ff(this.tileID,this.promoteId);Vt.bucketLayerIDs=[];const Xt={},Ts=new d.fg(256,256),xs={featureIndex:Vt,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Ts,availableImages:Xe,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};this.indoor&&(xs.activeFloors=function(Rr,dn,Gn,ta){const da=dn.indoorState.activeFloorsVisible;if(!dn.sourceLayers)return da?dn.indoorState.activeFloors:void 0;const Mo=function(ai,Fi){if(!ai)return d.w("No source layers defined in indoor specification"),Fi;if(ai.size===0)return Fi;const Qo=ai.difference(Fi);for(const di of Qo)d.w(`Missing source layer required in indoor specification: ${di}`);return Fi.intersection(Fi)}(dn.sourceLayers,new Set(Object.keys(Rr.layers))),_o=dn.indoorState,Zi=function(ai,Fi,Qo,di,zi){const Yi={};for(const ua of Fi){const Jo=ai.layers[ua];if(Jo)for(let sc=0;sc=di.maxzoom||di.visibility==="none")continue;q(Qo,this.zoom,xs.brightness,Xe,this.worldview,xs.activeFloors);const zi=Xt[di.id]=di.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:_o,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:_t,worldview:this.worldview,localizable:ai,availableImages:Xe,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});Vt.bucketLayerIDs.push(Qo.map(ua=>d.F(ua.id,ua.scope)));let Yi=zi.prepare?zi.prepare():null;Yi!=null?(Yi=Yi.then(()=>zi.populate(Zi,xs,this.tileID.canonical,this.tileTransform)),or.push(Yi)):zi.populate(Zi,xs,this.tileID.canonical,this.tileTransform)}}const Hr=()=>{Ts.trim();const Rr=!(!xs.elevationFeatures||!xs.elevationFeatures.some(di=>di.heightRange.min<0));let dn,Gn,ta,da,Mo,_o,Zi;const ai={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},Fi=()=>{if(dn)return this.status="done",Mt(dn);if(this.extraShadowCaster)this.status="done",Mt(null,{buckets:Object.values(Xt).filter(di=>!di.isEmpty()),featureIndex:Vt,collisionBoxArray:null,hasTunnelGeometry:Rr,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:xs.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Gn&&ta&&da&&Zi){const zi=new N(Gn),Yi=new Map;for(const[sc,rc]of ta.entries()){const{imagePosition:_u}=d.fn(sc,rc,d.fo);Yi.set(sc,_u)}const ua={};for(const sc in Xt){const rc=Xt[sc];rc instanceof d.fp&&(q(rc.layers,this.zoom,xs.brightness,Xe,this.worldview,xs.activeFloors),ua[sc]=d.fq(rc,Gn,zi.positions,ta,Yi,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,Mo,this.worldview,Xe))}const Jo={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(bt,ta,Mo,()=>{Jo.iconsPending=!1,Qo(ua,zi,Jo,void 0,Zi)}),this.rasterizeIfNeeded(bt,da,_o,()=>{Jo.patternsPending=!1,Qo(ua,zi,Jo,void 0,Zi)})}},Qo=(di,zi,Yi,ua,Jo)=>{if(Yi.iconsPending||Yi.patternsPending)return;const sc=ta.size>0||da.size>0,rc=Object.keys(di).length>0;if(!sc&&!rc)return this.status="done",void Mt(null,{buckets:Object.values(Xt).filter(bu=>!bu.isEmpty()),featureIndex:Vt,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:Rr,glyphAtlasImage:zi.image,lineAtlas:Ts,imageAtlas:null,brightness:xs.brightness});const _u=(bu,Om)=>{for(const Nd in Xt){const wu=Xt[Nd];if(Nd in di)d.fv(wu,di[Nd],this.showCollisionBoxes,Xe,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,ta,Om);else if(wu.hasPattern&&(wu instanceof d.fw||wu instanceof d.fl||wu instanceof d.e0)){q(wu.layers,this.zoom,xs.brightness,Xe,this.worldview,xs.activeFloors);const Fm=Object.fromEntries(Om.patternPositions);wu.addFeatures(xs,this.tileID.canonical,Fm,Xe,this.tileTransform,this.brightness)}}this.status="done",Mt(null,{buckets:Object.values(Xt).filter(Nd=>!Nd.isEmpty()),featureIndex:Vt,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:Rr,glyphAtlasImage:zi.image,lineAtlas:Ts,imageAtlas:bu,brightness:xs.brightness})};if(sc){const bu=new Map,Om=d.fr(ta,bu),Nd=d.fr(da,bu),wu=new d.fs(Om,Nd,Jo,this.lut,bu);bt.send("checkAtlasCache",{descriptor:wu,scope:this.scope},(Fm,Hu)=>{let zm,kd;if(Fm&&d.w(`[Worker] Error checking atlas cache: ${Fm.message}`),Hu)zm=new d.ft(Hu.sourceHash),kd=Hu;else{const Sd=new d.fu(ta,da,this.lut,Jo);zm=Sd,kd=Sd}_u(zm,kd)})}else _u(null,{iconPositions:new Map,patternPositions:new Map})};if(!this.extraShadowCaster){const di=d.fk(xs.glyphDependencies,ua=>Object.keys(ua).map(Number));Object.keys(di).length?bt.send("getGlyphs",{uid:this.uid,stacks:di},(ua,Jo)=>{dn||(dn=ua,Gn=Jo,Fi())},void 0,!1,ai):Gn={},Zi=new Map;const zi=Array.from(xs.iconDependencies.keys()).map(ua=>d.I.parse(ua));zi.length?bt.send("getImages",{images:zi,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(ua,Jo)=>{if(!dn){dn=ua,ta=new Map,Mo=this.updateImageMapAndGetImageTaskQueue(ta,Jo.images,xs.iconDependencies);for(const[sc,rc]of Jo.versions.entries())Zi.set(sc,rc);Fi()}},void 0,!1,ai):(ta=new Map,Mo=new Map);const Yi=Array.from(xs.patternDependencies.keys()).map(ua=>d.I.parse(ua));Yi.length?bt.send("getImages",{images:Yi,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(ua,Jo)=>{if(!dn){dn=ua,da=new Map,_o=this.updateImageMapAndGetImageTaskQueue(da,Jo.images,xs.patternDependencies);for(const[sc,rc]of Jo.versions.entries())Zi.set(sc,rc);Fi()}},void 0,!1,ai):(da=new Map,_o=new Map)}if(xs.elevationFeatures&&xs.elevationFeatures.length>0){const di=[];for(const Yi of Object.values(Xt))if(Yi instanceof d.fl){const ua=Yi.getUnevaluatedPortalGraph();ua&&di.push(ua)}const zi=d.fm.evaluate(di);for(const Yi of Object.values(Xt))if(Yi instanceof d.fl){const ua=Se.layers[Ht.decode(Yi.sourceLayerIndex)];Yi.setEvaluatedPortalGraph(zi,ua,this.tileID.canonical,xs.availableImages,xs.brightness)}}Fi()};or.length>0?Promise.allSettled(or).then(Hr).catch(Mt):Hr()}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,Oe,Xe,_t){Array.from(Oe.values()).some(bt=>bt.usvg)?this.rasterize(Se,Oe,Xe,_t):_t()}updateImageMapAndGetImageTaskQueue(Se,Oe,Xe){const _t=new Map;for(const bt of Oe.keys()){const Mt=Xe.get(bt)||[];for(const Ht of Mt){const Vt=Ht.toString(),Xt=Oe.get(Ht.id.toString());Xt.usvg?_t.has(Vt)||(_t.set(Vt,Ht),Se.set(Vt,Object.assign({},Xt))):Se.set(Vt,Xt)}}return _t}rasterize(Se,Oe,Xe,_t){this.rasterizeTask=Se.send("rasterizeImages",{scope:this.scope,tasks:Xe},(bt,Mt)=>{if(!bt)for(const[Ht,Vt]of Mt.entries()){const Xt=Object.assign(Oe.get(Ht),{data:Vt});Oe.set(Ht,Xt)}_t()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function q(qt,Se,Oe,Xe,_t,bt){const Mt=new d.ae(Se,{brightness:Oe,worldview:_t,activeFloors:bt});for(const Ht of qt)Ht.recalculate(Mt,Xe)}class $ extends d.E{constructor({actor:Se,layerIndex:Oe,availableImages:Xe,availableModels:_t,isSpriteLoaded:bt,tileProvider:Mt,brightness:Ht,maxUniformBufferBindings:Vt,maxUniformBlockSizeDwords:Xt,disableSymbolUBO:Ts}){super(),this.actor=Se,this.layerIndex=Oe,this.availableImages=Xe,this.availableModels=_t,this.loadVectorData=d.aO,this.tileProvider=Mt,this.loading={},this.loaded={},this.deduped=new d.aN(Se.scheduler),this.isSpriteLoaded=bt,this.scheduler=Se.scheduler,this.brightness=Ht,this.maxUniformBufferBindings=Vt,this.maxUniformBlockSizeDwords=Xt,this.disableSymbolUBO=Ts}loadTileData(Se,Oe){if(!this.tileProvider)return this.loadVectorData(Se,Oe);const Xe=new AbortController,{z:_t,x:bt,y:Mt}=Se.tileID.canonical;return this.tileProvider.loadTile({z:_t,x:bt,y:Mt},{request:Se.request,signal:Xe.signal}).then(Ht=>{if(Xe.signal.aborted)return;if(Ht==null){const Xt=new Error("Tile not found");return Xt.status=404,Oe(Xt)}if(Ht.data===null)return Oe(null,null);const Vt=new Map;Ht.expires&&Vt.set("expires",Ht.expires),Ht.cacheControl&&Vt.set("cache-control",Ht.cacheControl),Oe(null,{rawData:Ht.data,responseHeaders:Vt})}).catch(Ht=>{Xe.signal.aborted||Oe(Ht instanceof Error?Ht:new Error(String(Ht)))}),()=>Xe.abort()}loadTile(Se,Oe){const Xe=Se.uid,_t=Se&&Se.request,bt=_t&&_t.collectResourceTiming,Mt=this.loading[Xe]=new V(Se);Mt.maxUniformBufferBindings=this.maxUniformBufferBindings,Mt.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords,Mt.disableSymbolUBO=this.disableSymbolUBO,Mt.abort=this.loadTileData(Se,(Ht,Vt)=>{const Xt=!this.loading[Xe];if(delete this.loading[Xe],Mt.cancelRasterize(),Xt||Ht||!Vt)return Mt.status="done",Xt||(this.loaded[Xe]=Mt),Oe(Ht);const Ts=Vt.rawData,xs={},or=d.aP(Vt.responseHeaders);or&&or.expires&&(xs.expires=or.expires),or&&or.cacheControl&&(xs.cacheControl=or.cacheControl),Mt.vectorTile=Vt.vectorTile||new d.fx(new d.a$(Ts));const Lr=()=>{Mt.parse(Mt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(Hr,Rr)=>{if(Hr||!Rr)return Oe(Hr);const dn={};if(bt){const Gn=u(_t);Gn.length>0&&(dn.resourceTiming=JSON.parse(JSON.stringify(Gn)))}Oe(null,Object.assign({rawTileData:Ts.slice(0),responseHeaders:Vt.responseHeaders},Rr,xs,dn))})};this.isSpriteLoaded?Lr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Lr,{type:"parseTile",renderSourceType:Se.renderSourceType,zoom:Se.tileZoom}):Lr()}),this.loaded=this.loaded||{},this.loaded[Xe]=Mt})}reloadTile(Se,Oe){const Xe=this.loaded,_t=Se.uid;if(Xe&&Xe[_t]){const bt=Xe[_t];bt.updateParameters(Se);const Mt=(Ht,Vt)=>{const Xt=bt.reloadCallback;Xt&&(delete bt.reloadCallback,bt.parse(bt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Xt)),Oe(Ht,Vt)};bt.status==="parsing"?bt.reloadCallback=Mt:bt.status==="done"&&(bt.vectorTile?bt.parse(bt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Mt):Mt())}else Oe(null,void 0)}abortTile(Se,Oe){const Xe=Se.uid,_t=this.loading[Xe];_t&&(_t.abort&&_t.abort(),delete this.loading[Xe]),Oe()}removeTile(Se,Oe){const Xe=this.loaded,_t=Se.uid;Xe&&Xe[_t]&&delete Xe[_t],Oe()}}class U{constructor(Se){this.loading={}}loadTile(Se,Oe){const Xe=Se.uid,{cancel:_t}=d.b1(Se.request,(bt,Mt,Ht)=>{const Vt=!this.loading[Xe];if(delete this.loading[Xe],Vt||bt||!Mt)return Oe(bt);this.decodeTile(Xe,Mt,Se.encoding).then(Xt=>{const{expires:Ts,cacheControl:xs}=d.aP(Ht);Oe(null,Object.assign(Xt,{expires:Ts,cacheControl:xs}))}).catch(Xt=>Oe(Xt))});this.loading[Xe]={cancel:_t}}async decodeTile(Se,Oe,Xe){const _t=await createImageBitmap(new Blob([new Uint8Array(Oe)],{type:"image/png"})),bt=1-(_t.width-d.fy(_t.width))/2,Mt=bt<1,Ht=this.getImageData(_t,bt);return _t.close(),{dem:new d.fz(Se,Ht,Xe,Mt),borderReady:Mt}}reloadTile(Se,Oe){Oe(null,null)}abortTile(Se,Oe){const Xe=Se.uid,_t=this.loading[Xe];_t&&(_t.cancel(),delete this.loading[Xe]),Oe()}removeTile(Se,Oe){Oe()}getImageData(Se,Oe){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 Xe=this.offscreenCanvasContext.getImageData(-Oe,-Oe,Se.width+2*Oe,Se.height+2*Oe);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Xe}}d.a_.setPbf(d.a$);class se{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,Oe){const Xe=this._mrt;this.status="parsing",this._entireBuffer=Se;try{Xe.parseHeader(Se),this._isHeaderLoaded=!0;const _t=[];for(const bt in Xe.layers){const Mt=Xe.getLayer(bt),Ht=Mt.getDataRange(Mt.getBandList()),Vt=Xe.createDecodingTask(Ht),Xt=Se.slice(Ht.firstByte,Ht.lastByte+1),Ts=d.a_.performDecoding(Xt,Vt).then(xs=>Vt.complete(null,xs)).catch(xs=>Vt.complete(xs,null));_t.push(Ts)}Promise.allSettled(_t).then(()=>Oe(null,Xe)).catch(bt=>Oe(bt))}catch(_t){Oe(_t)}}}class Y{constructor({actor:Se}){this.actor=Se,this.loading={},this.loaded={}}loadTile(Se,Oe){const Xe=Se.uid,_t=Se.request,bt=this.loading[Xe]=new se(Se),{cancel:Mt}=d.b1(_t,(Ht,Vt,Xt)=>{const Ts=!this.loading[Xe];if(delete this.loading[Xe],Ts||Ht||!Vt)return bt.status="done",Ts||(this.loaded[Xe]=bt),Oe(Ht);bt.parse(Vt,(xs,or)=>{if(xs||!or)return Oe(xs);Oe(null,or,Xt)}),this.loaded[Xe]=bt});bt.abort=Mt}reloadTile(Se,Oe){Oe(null,void 0)}abortTile(Se,Oe){const Xe=Se.uid,_t=this.loading[Xe];_t&&(_t.abort&&_t.abort(),delete this.loading[Xe]),Oe()}removeTile(Se,Oe){const Xe=Se.uid;this.loaded[Xe]&&delete this.loaded[Xe],Oe()}decodeRasterArray(Se,Oe){d.a_.performDecoding(Se.buffer,Se.task).then(Xe=>Oe(null,Xe)).catch(Xe=>Oe(Xe))}}const J=d.fA.prototype.toGeoJSON;class X{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 Oe of this._feature.geometry)Se.push([new d.P(Oe[0],Oe[1])]);return Se}{const Se=[];for(const Oe of this._feature.geometry){const Xe=[];for(const _t of Oe)Xe.push(new d.P(_t[0],_t[1]));Se.push(Xe)}return Se}}toGeoJSON(Se,Oe,Xe){return J.call(this,Se,Oe,Xe)}}class ce{constructor(Se,Oe){this.name=Se,this.extent=d.an,this.length=Oe.length,this._jsonFeatures=Oe}feature(Se){return new X(this._jsonFeatures[Se])}}class ie{constructor(Se){this.layers={},this.extent=d.an;for(const Oe of Object.keys(Se))this.layers[Oe]=new ce(Oe,Se[Oe])}}const ae=64/4096;class oe{constructor(){this.features=new Map}clear(){this.features.clear()}load(Se=[],Oe){for(const Xe of Se){const _t=Xe.id;if(_t==null)continue;let bt=this.features.get(_t);bt&&this.updateCache(bt,Oe),Xe.geometry?(bt=_e(Xe),this.updateCache(bt,Oe),this.features.set(_t,bt)):this.features.delete(_t),this.updateCache(bt,Oe)}}updateCache(Se,Oe){for(const{canonical:Xe,uid:_t}of Object.values(Oe)){const{z:bt,x:Mt,y:Ht}=Xe;pe(Se,Math.pow(2,bt),Mt,Ht)&&delete Oe[_t]}}getTile(Se,Oe,Xe){const _t=Math.pow(2,Se),bt=[];for(const Mt of this.features.values())pe(Mt,_t,Oe,Xe)&&bt.push(Ue(Mt,_t,Oe,Xe));return{features:bt}}getFeatures(){return[...this.features.values()]}}function pe({minX:qt,minY:Se,maxX:Oe,maxY:Xe},_t,bt,Mt){return qt<(bt+1+ae)/_t&&Se<(Mt+1+ae)/_t&&Oe>(bt-ae)/_t&&Xe>(Mt-ae)/_t}function _e(qt){const{id:Se,geometry:Oe,properties:Xe}=qt;if(!Oe)return;if(Oe.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:_t,coordinates:bt}=Oe,Mt={id:Se,type:1,geometry:[],tags:Xe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Ht=Mt.geometry;if(_t==="Point")he(bt,Ht,Mt);else if(_t==="MultiPoint")for(const Vt of bt)he(Vt,Ht,Mt);else if(_t==="LineString")Mt.type=2,we(bt,Ht,Mt);else if(_t==="MultiLineString")Mt.type=2,je(bt,Ht,Mt);else if(_t==="Polygon")Mt.type=3,je(bt,Ht,Mt,!0);else{if(_t!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Mt.type=3;for(const Vt of bt)je(Vt,Ht,Mt,!0)}return Mt}function he([qt,Se],Oe,Xe){const _t=d.aH(qt);let bt=d.aL(Se);bt=bt<0?0:bt>1?1:bt,Oe.push(_t,bt),Xe.minX=Math.min(Xe.minX,_t),Xe.minY=Math.min(Xe.minY,bt),Xe.maxX=Math.max(Xe.maxX,_t),Xe.maxY=Math.max(Xe.maxY,bt)}function we(qt,Se,Oe,Xe=!1,_t=!1){const bt=[];for(const Mt of qt)he(Mt,bt,Oe);Se.push(bt),Xe&&function(Mt,Ht){let Vt=0;for(let Xt=0,Ts=Mt.length,xs=Ts-2;Xt0===Ht)for(let Xt=0,Ts=Mt.length;Xt=Mt&&xs>=Mt||(Xt>=Mt?(Ts+=Math.round(Hr*((Mt-Xt)/Lr)),Xt=Mt):xs>=Mt&&(or=Ts+Math.round(Hr*((Mt-Xt)/Lr)),xs=Mt),Ts>=Mt&&or>=Mt||(Ts>=Mt?(Xt+=Math.round(Lr*((Mt-Ts)/Hr)),Ts=Mt):or>=Mt&&(xs=Xt+Math.round(Lr*((Mt-Ts)/Hr)),or=Mt),Ht&&Xt===Ht[Ht.length-1][0]&&Ts===Ht[Ht.length-1][1]||(Ht=[[Xt,Ts]],_t.push(Ht)),Ht.push([xs,or])))))}}function Me(qt,Se,Oe,Xe,_t){const bt=(Oe-ae)/Se,Mt=(Xe-ae)/Se,Ht=(Oe+1+ae)/Se,Vt=(Xe+1+ae)/Se;function Xt(or,Lr){let Hr=0;return orHt&&(Hr|=2),LrVt&&(Hr|=8),Hr}let Ts=[];for(let or=1;or<=8;or*=2){let Lr=qt[qt.length-2],Hr=qt[qt.length-1],Rr=!(Xt(Lr,Hr)&or);for(let dn=0;dn>31}function ve(qt,Se){const{geometry:Oe,type:Xe}=qt;let _t=0,bt=0;if(Xe===1){Se.writeVarint(qe(1,Oe.length));for(const Mt of Oe){const Ht=Mt[0]-_t,Vt=Mt[1]-bt;Se.writeVarint(ze(Ht)),Se.writeVarint(ze(Vt)),_t+=Ht,bt+=Vt}}else for(const Mt of Oe){if(Mt.length===0)continue;Se.writeVarint(qe(1,1));const Ht=Mt.length-(Xe===3?1:0);for(let Vt=0;Vtqt},Ve=Math.fround||(Je=new Float32Array(1),qt=>(Je[0]=+qt,Je[0]));var Je;class at{constructor(Se){this.options=Object.assign(Object.create(fe),Se),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(Se){const{log:Oe,minZoom:Xe,maxZoom:_t}=this.options;Oe&&console.time("total time");const bt=`prepare ${Se.length} points`;Oe&&console.time(bt),this.points=Se;const Mt=[];for(let Vt=0;Vt=Xe;Vt--){const Xt=+Date.now();Ht=this.trees[Vt]=this._createTree(this._cluster(Ht,Vt)),Oe&&console.log("z%d: %d clusters in %dms",Vt,Ht.numItems,+Date.now()-Xt)}return Oe&&console.timeEnd("total time"),this}getClusters(Se,Oe){let Xe=((Se[0]+180)%360+360)%360-180;const _t=Math.max(-90,Math.min(90,Se[1]));let bt=Se[2]===180?180:((Se[2]+180)%360+360)%360-180;const Mt=Math.max(-90,Math.min(90,Se[3]));if(Se[2]-Se[0]>=360)Xe=-180,bt=180;else if(Xe>bt){const xs=this.getClusters([Xe,_t,180,Mt],Oe),or=this.getClusters([-180,_t,bt,Mt],Oe);return xs.concat(or)}const Ht=this.trees[this._limitZoom(Oe)],Vt=Ht.range(We(Xe),ot(Mt),We(bt),ot(_t)),Xt=Ht.data,Ts=[];for(const xs of Vt){const or=this.stride*xs;Ts.push(Xt[or+5]>1?Ae(Xt,or,this.clusterProps):this.points[Xt[or+3]])}return Ts}getChildren(Se){const Oe=this._getOriginId(Se),Xe=this._getOriginZoom(Se),_t="No cluster with the specified id.",bt=this.trees[Xe];if(!bt)throw new Error(_t);const Mt=bt.data;if(Oe*this.stride>=Mt.length)throw new Error(_t);const Ht=this.options.radius/(this.options.extent*Math.pow(2,Xe-1)),Vt=bt.within(Mt[Oe*this.stride],Mt[Oe*this.stride+1],Ht),Xt=[];for(const Ts of Vt){const xs=Ts*this.stride;Mt[xs+4]===Se&&Xt.push(Mt[xs+5]>1?Ae(Mt,xs,this.clusterProps):this.points[Mt[xs+3]])}if(Xt.length===0)throw new Error(_t);return Xt}getLeaves(Se,Oe,Xe){const _t=[];return this._appendLeaves(_t,Se,Oe=Oe||10,Xe=Xe||0,0),_t}getTile(Se,Oe,Xe){const _t=this.trees[this._limitZoom(Se)],bt=Math.pow(2,Se),{extent:Mt,radius:Ht}=this.options,Vt=Ht/Mt,Xt=(Xe-Vt)/bt,Ts=(Xe+1+Vt)/bt,xs={features:[]};return this._addTileFeatures(_t.range((Oe-Vt)/bt,Xt,(Oe+1+Vt)/bt,Ts),_t.data,Oe,Xe,bt,xs),Oe===0&&this._addTileFeatures(_t.range(1-Vt/bt,Xt,1,Ts),_t.data,bt,Xe,bt,xs),Oe===bt-1&&this._addTileFeatures(_t.range(0,Xt,Vt/bt,Ts),_t.data,-1,Xe,bt,xs),xs.features.length?xs:null}getClusterExpansionZoom(Se){let Oe=this._getOriginZoom(Se)-1;for(;Oe<=this.options.maxZoom;){const Xe=this.getChildren(Se);if(Oe++,Xe.length!==1)break;Se=Xe[0].properties.cluster_id}return Oe}_appendLeaves(Se,Oe,Xe,_t,bt){const Mt=this.getChildren(Oe);for(const Ht of Mt){const Vt=Ht.properties;if(Vt&&Vt.cluster?bt+Vt.point_count<=_t?bt+=Vt.point_count:bt=this._appendLeaves(Se,Vt.cluster_id,Xe,_t,bt):bt<_t?bt++:Se.push(Ht),Se.length===Xe)break}return bt}_createTree(Se){const Oe=new d.bI(Se.length/this.stride|0,this.options.nodeSize,Float32Array);for(let Xe=0;Xe1;let Ts,xs,or;if(Xt)Ts=Ye(Oe,Vt,this.clusterProps),xs=Oe[Vt],or=Oe[Vt+1];else{const Rr=this.points[Oe[Vt+3]];Ts=Rr.properties;const[dn,Gn]=Rr.geometry.coordinates;xs=We(dn),or=ot(Gn)}const Lr={type:1,geometry:[[Math.round(this.options.extent*(xs*bt-Xe)),Math.round(this.options.extent*(or*bt-_t))]],tags:Ts};let Hr;Hr=Xt||this.options.generateId?Oe[Vt+3]:this.points[Oe[Vt+3]].id,Hr!==void 0&&(Lr.id=Hr),Mt.features.push(Lr)}}_limitZoom(Se){return Math.max(this.options.minZoom,Math.min(Math.floor(+Se),this.options.maxZoom+1))}_cluster(Se,Oe){const{radius:Xe,extent:_t,reduce:bt,minPoints:Mt}=this.options,Ht=Xe/(_t*Math.pow(2,Oe)),Vt=Se.data,Xt=[],Ts=this.stride;for(let xs=0;xsOe&&(dn+=Vt[ta+5])}if(dn>Rr&&dn>=Mt){let Gn,ta=or*Rr,da=Lr*Rr,Mo=-1;const _o=(xs/Ts<<5)+(Oe+1)+this.points.length;for(const Zi of Hr){const ai=Zi*Ts;if(Vt[ai+2]<=Oe)continue;Vt[ai+2]=Oe;const Fi=Vt[ai+5];ta+=Vt[ai]*Fi,da+=Vt[ai+1]*Fi,Vt[ai+4]=_o,bt&&(Gn||(Gn=this._map(Vt,xs,!0),Mo=this.clusterProps.length,this.clusterProps.push(Gn)),bt(Gn,this._map(Vt,ai)))}Vt[xs+4]=_o,Xt.push(ta/dn,da/dn,1/0,_o,-1,dn),bt&&Xt.push(Mo)}else{for(let Gn=0;Gn1)for(const Gn of Hr){const ta=Gn*Ts;if(!(Vt[ta+2]<=Oe)){Vt[ta+2]=Oe;for(let da=0;da>5}_getOriginZoom(Se){return(Se-this.points.length)%32}_map(Se,Oe,Xe){if(Se[Oe+5]>1){const Mt=this.clusterProps[Se[Oe+6]];return Xe?Object.assign({},Mt):Mt}const _t=this.points[Se[Oe+3]].properties,bt=this.options.map(_t);return Xe&&bt===_t?Object.assign({},bt):bt}}function Ae(qt,Se,Oe){return{type:"Feature",id:qt[Se+3],properties:Ye(qt,Se,Oe),geometry:{type:"Point",coordinates:[(Xe=qt[Se],360*(Xe-.5)),Ge(qt[Se+1])]}};var Xe}function Ye(qt,Se,Oe){const Xe=qt[Se+5],_t=Xe>=1e4?`${Math.round(Xe/1e3)}k`:Xe>=1e3?Math.round(Xe/100)/10+"k":Xe,bt=qt[Se+6],Mt=bt===-1?{}:Object.assign({},Oe[bt]);return Object.assign(Mt,{cluster:!0,cluster_id:qt[Se+3],point_count:Xe,point_count_abbreviated:_t})}function We(qt){return qt/360+.5}function ot(qt){const Se=Math.sin(qt*Math.PI/180),Oe=.5-.25*Math.log((1+Se)/(1-Se))/Math.PI;return Oe<0?0:Oe>1?1:Oe}function Ge(qt){const Se=(180-360*qt)*Math.PI/180;return 360*Math.atan(Math.exp(Se))/Math.PI-90}function et(qt,Se,Oe,Xe){let _t=Xe;const bt=Se+(Oe-Se>>1);let Mt,Ht=Oe-Se;const Vt=qt[Se],Xt=qt[Se+1],Ts=qt[Oe],xs=qt[Oe+1];for(let or=Se+3;or_t)Mt=or,_t=Lr;else if(Lr===_t){const Hr=Math.abs(or-bt);HrXe&&(Mt-Se>3&&et(qt,Se,Mt,Xe),qt[Mt+2]=_t,Oe-Mt>3&&et(qt,Mt,Oe,Xe))}function ht(qt,Se,Oe,Xe,_t,bt){let Mt=_t-Oe,Ht=bt-Xe;if(Mt!==0||Ht!==0){const Vt=((qt-Oe)*Mt+(Se-Xe)*Ht)/(Mt*Mt+Ht*Ht);Vt>1?(Oe=_t,Xe=bt):Vt>0&&(Oe+=Mt*Vt,Xe+=Ht*Vt)}return Mt=qt-Oe,Ht=Se-Xe,Mt*Mt+Ht*Ht}function xt(qt,Se,Oe,Xe){const _t={id:qt??null,type:Se,geometry:Oe,tags:Xe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(Se==="Point"||Se==="MultiPoint"||Se==="LineString")Ke(_t,Oe);else if(Se==="Polygon")Ke(_t,Oe[0]);else if(Se==="MultiLineString")for(const bt of Oe)Ke(_t,bt);else if(Se==="MultiPolygon")for(const bt of Oe)Ke(_t,bt[0]);return _t}function Ke(qt,Se){for(let Oe=0;Oe0&&(Mt+=Xe?(_t*Ts-Xt*bt)/2:Math.sqrt(Math.pow(Xt-_t,2)+Math.pow(Ts-bt,2))),_t=Xt,bt=Ts}const Ht=Se.length-3;Se[2]=1,et(Se,0,Ht,Oe),Se[Ht+2]=1,Se.size=Math.abs(Mt),Se.start=0,Se.end=Se.size}function Yt(qt,Se,Oe,Xe){for(let _t=0;_t1?1:Oe}function Zs(qt,Se,Oe,Xe,_t,bt,Mt,Ht){if(Xe/=Se,bt>=(Oe/=Se)&&Mt=Xe)return null;const Vt=[];for(const Xt of qt){const Ts=Xt.geometry;let xs=Xt.type;const or=_t===0?Xt.minX:Xt.minY,Lr=_t===0?Xt.maxX:Xt.maxY;if(or>=Oe&&Lr=Xe)continue;let Hr=[];if(xs==="Point"||xs==="MultiPoint")Dr(Ts,Hr,Oe,Xe,_t);else if(xs==="LineString")zt(Ts,Hr,Oe,Xe,_t,!1,Ht.lineMetrics);else if(xs==="MultiLineString")kr(Ts,Hr,Oe,Xe,_t,!1);else if(xs==="Polygon")kr(Ts,Hr,Oe,Xe,_t,!0);else if(xs==="MultiPolygon")for(const Rr of Ts){const dn=[];kr(Rr,dn,Oe,Xe,_t,!0),dn.length&&Hr.push(dn)}if(Hr.length){if(Ht.lineMetrics&&xs==="LineString"){for(const Rr of Hr)Vt.push(xt(Xt.id,xs,Rr,Xt.tags));continue}xs!=="LineString"&&xs!=="MultiLineString"||(Hr.length===1?(xs="LineString",Hr=Hr[0]):xs="MultiLineString"),xs!=="Point"&&xs!=="MultiPoint"||(xs=Hr.length===3?"Point":"MultiPoint"),Vt.push(xt(Xt.id,xs,Hr,Xt.tags))}}return Vt.length?Vt:null}function Dr(qt,Se,Oe,Xe,_t){for(let bt=0;bt=Oe&&Mt<=Xe&&Xs(Se,qt[bt],qt[bt+1],qt[bt+2])}}function zt(qt,Se,Oe,Xe,_t,bt,Mt){let Ht=$s(qt);const Vt=_t===0?ir:Or;let Xt,Ts,xs=qt.start;for(let dn=0;dnOe&&(Ts=Vt(Ht,Gn,ta,Mo,_o,Oe),Mt&&(Ht.start=xs+Xt*Ts)):Zi>Xe?ai=Oe&&(Ts=Vt(Ht,Gn,ta,Mo,_o,Oe),Fi=!0),ai>Xe&&Zi<=Xe&&(Ts=Vt(Ht,Gn,ta,Mo,_o,Xe),Fi=!0),!bt&&Fi&&(Mt&&(Ht.end=xs+Xt*Ts),Se.push(Ht),Ht=$s(qt)),Mt&&(xs+=Xt)}let or=qt.length-3;const Lr=qt[or],Hr=qt[or+1],Rr=_t===0?Lr:Hr;Rr>=Oe&&Rr<=Xe&&Xs(Ht,Lr,Hr,qt[or+2]),or=Ht.length-3,bt&&or>=3&&(Ht[or]!==Ht[0]||Ht[or+1]!==Ht[1])&&Xs(Ht,Ht[0],Ht[1],Ht[2]),Ht.length&&Se.push(Ht)}function $s(qt){const Se=[];return Se.size=qt.size,Se.start=qt.start,Se.end=qt.end,Se}function kr(qt,Se,Oe,Xe,_t,bt){for(const Mt of qt)zt(Mt,Se,Oe,Xe,_t,bt,!1)}function Xs(qt,Se,Oe,Xe){qt.push(Se,Oe,Xe)}function ir(qt,Se,Oe,Xe,_t,bt){const Mt=(bt-Se)/(Xe-Se);return Xs(qt,bt,Oe+(_t-Oe)*Mt,1),Mt}function Or(qt,Se,Oe,Xe,_t,bt){const Mt=(bt-Oe)/(_t-Oe);return Xs(qt,Se+(Xe-Se)*Mt,bt,1),Mt}function Vn(qt,Se){const Oe=[];for(let Xe=0;Xe0&&Se.size<(_t?Mt:Xe))return void(Oe.numPoints+=Se.length/3);const Ht=[];for(let Vt=0;VtMt)&&(Oe.numSimplified++,Ht.push(Se[Vt],Se[Vt+1])),Oe.numPoints++;_t&&function(Vt,Xt){let Ts=0;for(let xs=0,or=Vt.length,Lr=or-2;xs0===Xt)for(let xs=0,or=Vt.length;xs24)throw new Error("maxZoom should be in the 0-24 range");if(Oe.promoteId&&Oe.generateId)throw new Error("promoteId and generateId cannot be used together.");let _t=function(bt,Mt){const Ht=[];if(bt.type==="FeatureCollection")for(let Vt=0;Vt1&&console.time("creation"),Lr=this.tiles[or]=cr(Se,Oe,Xe,_t,Xt),this.tileCoords.push({z:Oe,x:Xe,y:_t}),Ts)){Ts>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",Oe,Xe,_t,Lr.numFeatures,Lr.numPoints,Lr.numSimplified),console.timeEnd("creation"));const Fi=`z${Oe}`;this.stats[Fi]=(this.stats[Fi]||0)+1,this.total++}if(Lr.source=Se,bt==null){if(Oe===Xt.indexMaxZoom||Lr.numPoints<=Xt.indexMaxPoints)continue}else{if(Oe===Xt.maxZoom||Oe===bt)continue;if(bt!=null){const Fi=bt-Oe;if(Xe!==Mt>>Fi||_t!==Ht>>Fi)continue}}if(Lr.source=null,Se.length===0)continue;Ts>1&&console.time("clipping");const Hr=.5*Xt.buffer/Xt.extent,Rr=.5-Hr,dn=.5+Hr,Gn=1+Hr;let ta=null,da=null,Mo=null,_o=null,Zi=Zs(Se,xs,Xe-Hr,Xe+dn,0,Lr.minX,Lr.maxX,Xt),ai=Zs(Se,xs,Xe+Rr,Xe+Gn,0,Lr.minX,Lr.maxX,Xt);Se=null,Zi&&(ta=Zs(Zi,xs,_t-Hr,_t+dn,1,Lr.minY,Lr.maxY,Xt),da=Zs(Zi,xs,_t+Rr,_t+Gn,1,Lr.minY,Lr.maxY,Xt),Zi=null),ai&&(Mo=Zs(ai,xs,_t-Hr,_t+dn,1,Lr.minY,Lr.maxY,Xt),_o=Zs(ai,xs,_t+Rr,_t+Gn,1,Lr.minY,Lr.maxY,Xt),ai=null),Ts>1&&console.timeEnd("clipping"),Vt.push(ta||[],Oe+1,2*Xe,2*_t),Vt.push(da||[],Oe+1,2*Xe,2*_t+1),Vt.push(Mo||[],Oe+1,2*Xe+1,2*_t),Vt.push(_o||[],Oe+1,2*Xe+1,2*_t+1)}}getTile(Se,Oe,Xe){Se=+Se,Oe=+Oe,Xe=+Xe;const _t=this.options,{extent:bt,debug:Mt}=_t;if(Se<0||Se>24)return null;const Ht=1<1&&console.log("drilling down to z%d-%d-%d",Se,Oe,Xe);let Xt,Ts=Se,xs=Oe,or=Xe;for(;!Xt&&Ts>0;)Ts--,xs>>=1,or>>=1,Xt=this.tiles[rs(Ts,xs,or)];return Xt&&Xt.source?(Mt>1&&(console.log("found parent tile z%d-%d-%d",Ts,xs,or),console.time("drilling down")),this.splitTile(Xt.source,Ts,xs,or,Se,Oe,Xe),Mt>1&&console.timeEnd("drilling down"),this.tiles[Vt]?Gr(this.tiles[Vt],bt):null):null}}function rs(qt,Se,Oe){return 32*((1<Xt.tags&&"3d_elevation_id"in Xt.tags&&"source"in Xt.tags&&Xt.tags.source==="elevation",bt=Xe.features.filter(Xt=>_t(Xt));let Mt={_geojsonTileLayer:Xe.features};bt.length>0&&(Mt={_geojsonTileLayer:Xe.features.filter(Xt=>!_t(Xt)),hd_road_elevation:bt});const Ht=new ie(Mt),Vt=function(Xt){const Ts=new d.a$;for(const xs of Object.keys(Xt))Ts.writeMessage(3,Fe,{name:xs,features:Xt[xs]});return Ts.finish()}(Mt).buffer;Se(null,{vectorTile:Ht,rawData:Vt})}class mn extends ${constructor(Se){super(Se),this.loadVectorData=Bn,this._dynamicIndex=new oe}loadData(Se,Oe){const Xe=Se&&Se.request,_t=Xe&&Xe.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(Se,(bt,Mt)=>{if(bt||!Mt)return Oe(bt);if(typeof Mt!="object")return Oe(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(Xt=>`${Xt.key}: ${Xt.message}`).join(", "));Mt.features=Mt.features.filter(Xt=>Vt.value.evaluate({zoom:0},Xt))}Se.dynamic?(Mt.type==="Feature"&&(Mt={type:"FeatureCollection",features:[Mt]}),Se.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Mt.features,this.loaded),Se.cluster&&(Mt.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=Se.cluster?new at(function({superclusterOptions:Vt,clusterProperties:Xt}){if(!Xt||!Vt)return Vt;const Ts={},xs={},or={accumulated:null,zoom:0},Lr={properties:null},Hr=Object.keys(Xt);for(const Rr of Hr){const[dn,Gn]=Xt[Rr],ta=d.X(Gn),da=d.X(typeof dn=="string"?[dn,["accumulated"],["get",Rr]]:dn);Ts[Rr]=ta.value,xs[Rr]=da.value}return Vt.map=Rr=>{Lr.properties=Rr;const dn={};for(const Gn of Hr)dn[Gn]=Ts[Gn].evaluate(or,Lr);return dn},Vt.reduce=(Rr,dn)=>{Lr.properties=dn;for(const Gn of Hr)or.accumulated=Rr[Gn],Rr[Gn]=xs[Gn].evaluate(or,Lr)},Vt}(Se)).load(Mt.features):Se.dynamic?this._dynamicIndex:function(Vt,Xt){return new ni(Vt,Xt)}(Mt,Se.geojsonVtOptions)}catch(Vt){return Oe(Vt)}const Ht={};if(_t){const Vt=u(Xe);Vt&&(Ht.resourceTiming={},Ht.resourceTiming[Se.source]=JSON.parse(JSON.stringify(Vt)))}Oe(null,Ht)}})}reloadTile(Se,Oe){const Xe=this.loaded;return Xe&&Xe[Se.uid]?Se.partial?Oe(null,void 0):super.reloadTile(Se,Oe):this.loadTile(Se,Oe)}loadGeoJSON(Se,Oe){if(Se.request)d.m(Se.request,Oe);else{if(typeof Se.data!="string")return Oe(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return Oe(null,JSON.parse(Se.data))}catch{return Oe(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(Se,Oe){try{Oe(null,this._geoJSONIndex.getClusterExpansionZoom(Se.clusterId))}catch(Xe){Oe(Xe)}}getClusterChildren(Se,Oe){try{Oe(null,this._geoJSONIndex.getChildren(Se.clusterId))}catch(Xe){Oe(Xe)}}getClusterLeaves(Se,Oe){try{Oe(null,this._geoJSONIndex.getLeaves(Se.clusterId,Se.limit,Se.offset))}catch(Xe){Oe(Xe)}}}class Fr{constructor(Se,Oe,Xe){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=Oe,this.worldview=Xe}parse(Se,Oe,Xe,_t){this.status="parsing";const bt=new d.aR(Xe.tileID.overscaledZ,Xe.tileID.wrap,Xe.tileID.canonical.z,Xe.tileID.canonical.x,Xe.tileID.canonical.y),Mt=[],Ht=Oe.familiesBySource[Xe.source],Vt=new d.ff(bt,Xe.promoteId);Vt.bucketLayerIDs=[],Vt.is3DTile=!0,d.fB(Se).then(Xt=>{const Ts=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Xt.json.asset.extras&&Xt.json.asset.extras.MAPBOX_mesh_features,xs=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("EXT_meshopt_compression"),or=new d.ae(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Lr in Ht)for(const Hr of Ht[Lr]){const Rr=Hr[0];Vt.bucketLayerIDs.push(Hr.map(ta=>d.F(ta.id,ta.scope))),Rr.recalculate(or,[]);const dn=d.fC(Xt,1/d.cS(Xe.tileID.canonical)),Gn=new d.fD(Hr,dn,bt,Ts,xs,this.brightness,Vt,this.worldview);Ts||(Gn.needsUpload=!0),Mt.push(Gn),Gn.evaluate(Rr)}this.status="done",_t(null,{buckets:Mt,featureIndex:Vt,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Xt=>_t(new Error(Xt.message)))}}class Kt{constructor({actor:Se,layerIndex:Oe,availableImages:Xe,availableModels:_t,brightness:bt,worldview:Mt}){this.actor=Se,this.layerIndex=Oe,this.availableImages=Xe,this.availableModels=_t,this.brightness=bt,this.loading={},this.loaded={},this.worldview=Mt}loadTile(Se,Oe){const Xe=Se.uid,_t=this.loading[Xe]=new Fr(Se,this.brightness,this.worldview);d.b1(Se.request,(bt,Mt)=>{const Ht=!this.loading[Xe];return delete this.loading[Xe],Ht||bt?(_t.status="done",Ht||(this.loaded[Xe]=_t),Oe(bt)):Mt&&Mt.byteLength!==0?void _t.parse(Mt,this.layerIndex,Se,(Vt,Xt)=>{_t.status="done",this.loaded=this.loaded||{},this.loaded[Xe]=_t,Vt||!Xt?Oe(Vt):Oe(null,Xt)}):(_t.status="done",this.loaded[Xe]=_t,Oe())})}reloadTile(Se,Oe){const Xe=this.loaded,_t=Se.uid;if(Xe&&Xe[_t]){const bt=Xe[_t];bt.projection=Se.projection,bt.brightness=Se.brightness;const Mt=(Ht,Vt)=>{bt.reloadCallback&&(delete bt.reloadCallback,this.loadTile(Se,Oe)),Oe(Ht,Vt)};bt.status==="parsing"?bt.reloadCallback=Mt:bt.status==="done"&&this.loadTile(Se,Oe)}}abortTile(Se,Oe){const Xe=Se.uid;this.loading[Xe]&&delete this.loading[Xe],Oe()}removeTile(Se,Oe){const Xe=this.loaded,_t=Se.uid;Xe&&Xe[_t]&&delete Xe[_t],Oe()}}const jr=new Map,zr=new Map;class fa{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:mn,"raster-dem":U,"raster-array":Y,"batched-model":Kt},this.workerSources={},this.self.registerWorkerSource=(Oe,Xe)=>{if(this.workerSourceTypes[Oe])throw new Error(`Worker source with name "${Oe}" already registered.`);this.workerSourceTypes[Oe]=Xe},this.self.registerRTLTextPlugin=Oe=>{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=Oe.applyArabicShaping,d.fF.processBidirectionalText=Oe.processBidirectionalText,d.fF.processStyledBidirectionalText=Oe.processStyledBidirectionalText;for(const Xe of this.rtlPluginParsingListeners)Xe(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(Se,Oe,Xe){delete this.layerIndexes[Se],delete this.availableImages[Se],delete this.availableModels[Se],delete this.workerSources[Se],Xe()}checkIfReady(Se,Oe,Xe){Xe()}setReferrer(Se,Oe){this.referrer=Oe}spriteLoaded(Se,Oe){this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={});const{scope:Xe,isLoaded:_t}=Oe;if(this.isSpriteLoaded[Se][Xe]=_t,this.workerSources[Se]&&this.workerSources[Se][Xe])for(const bt in this.workerSources[Se][Xe]){const Mt=this.workerSources[Se][Xe][bt];for(const Ht in Mt){const Vt=Mt[Ht];Vt instanceof $&&(Vt.isSpriteLoaded=_t,Vt.fire(new d.C("isSpriteLoaded")))}}}setImages(Se,Oe,Xe){this.availableImages[Se]||(this.availableImages[Se]={});const{scope:_t,images:bt}=Oe;if(this.availableImages[Se][_t]=bt,this.workerSources[Se]&&this.workerSources[Se][_t]){for(const Mt in this.workerSources[Se][_t]){const Ht=this.workerSources[Se][_t][Mt];for(const Vt in Ht)Ht[Vt].availableImages=bt}Xe()}else Xe()}setModels(Se,{scope:Oe,models:Xe},_t){if(this.availableModels[Se]||(this.availableModels[Se]={}),this.availableModels[Se][Oe]=Xe,this.workerSources[Se]&&this.workerSources[Se][Oe]){for(const bt in this.workerSources[Se][Oe]){const Mt=this.workerSources[Se][Oe][bt];for(const Ht in Mt)Mt[Ht].availableModels=Xe}_t()}else _t()}setProjection(Se,Oe){this.projections[Se]=d.c0(Oe)}setBrightness(Se,Oe,Xe){this.brightness=Oe,Xe()}setContextParams(Se,Oe,Xe){this.maxUniformBufferBindings=Oe.maxBindingPoints,this.maxUniformBlockSizeDwords=Oe.maxUniformBlockSizeDwords,this.disableSymbolUBO=Oe.disableSymbolUBO,Xe()}setWorldview(Se,Oe,Xe){this.worldview=Oe,Xe()}setLayers(Se,Oe,Xe){this.getLayerIndex(Se,Oe.scope).replace(Oe.layers,Oe.options),Xe()}updateLayers(Se,Oe,Xe){this.getLayerIndex(Se,Oe.scope).update(Oe.layers,Oe.removedIds,Oe.options),Xe()}loadTile(Se,Oe,Xe){Oe.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,Oe).loadTile(Oe,Xe)}decodeRasterArray(Se,Oe,Xe){this.getWorkerSource(Se,Oe).decodeRasterArray(Oe,Xe)}reloadTile(Se,Oe,Xe){Oe.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,Oe).reloadTile(Oe,Xe)}abortTile(Se,Oe,Xe){this.getWorkerSource(Se,Oe).abortTile(Oe,Xe)}removeTile(Se,Oe,Xe){this.getWorkerSource(Se,Oe).removeTile(Oe,Xe)}removeSource(Se,Oe,Xe){if(!(this.workerSources[Se]&&this.workerSources[Se][Oe.scope]&&this.workerSources[Se][Oe.scope][Oe.type]&&this.workerSources[Se][Oe.scope][Oe.type][Oe.source]))return;const _t=this.workerSources[Se][Oe.scope][Oe.type][Oe.source];delete this.workerSources[Se][Oe.scope][Oe.type][Oe.source],_t.removeSource!==void 0?_t.removeSource(Oe,Xe):Xe()}loadTileProvider(Se,Oe,Xe){(async function(_t,bt){const Mt=zr.get(_t);if(Mt)return Mt;const Ht=jr.get(_t);if(Ht!==void 0)return Ht;const Vt=import(bt).then(Xt=>{const Ts=Xt.default;if(typeof Ts!="function")throw new Error(`TileProvider "${_t}" module must default-export a class`);if(typeof Ts.prototype.loadTile!="function")throw new Error(`TileProvider "${_t}" class must have a loadTile method`);return zr.set(_t,Ts),Ts}).finally(()=>{jr.delete(_t)});return jr.set(_t,Vt),Vt})(Oe.name,Oe.url).then(_t=>{const bt=new _t(Oe.options);return this.getWorkerSource(Se,{type:Oe.type,source:Oe.source,scope:Oe.scope},bt),bt.load&&Oe.request?bt.load({request:Oe.request}):null}).then(_t=>Xe(null,_t)).catch(_t=>Xe(_t instanceof Error?_t:new Error(typeof _t=="string"?_t:"Unknown error")))}loadWorkerSource(Se,Oe,Xe){try{this.self.importScripts(Oe.url),Xe()}catch(_t){Xe(_t)}}syncRTLPluginState(Se,Oe,Xe){if(d.fF.isParsed())Xe(null,!0);else if(d.fF.isParsing())this.rtlPluginParsingListeners.push(Xe);else try{d.fF.setState(Oe);const _t=d.fF.getPluginURL();!d.fF.isLoaded()||d.fF.isParsed()||d.fF.isParsing()||_t==null||(d.fF.setState({pluginStatus:d.fG.parsing,pluginURL:d.fF.getPluginURL()}),this.self.importScripts(_t),d.fF.isParsed()?Xe(null,!0):this.rtlPluginParsingListeners.push(Xe))}catch(_t){Xe(_t)}}setConfig(Se,Oe){Object.assign(d.g,Oe)}getAvailableImages(Se,Oe){this.availableImages[Se]||(this.availableImages[Se]={});let Xe=this.availableImages[Se][Oe];return Xe||(Xe=[]),Xe}getAvailableModels(Se,Oe){this.availableModels[Se]||(this.availableModels[Se]={});let Xe=this.availableModels[Se][Oe];return Xe||(Xe={}),Xe}getLayerIndex(Se,Oe){this.layerIndexes[Se]||(this.layerIndexes[Se]={});let Xe=this.layerIndexes[Se][Oe];return Xe||(Xe=this.layerIndexes[Se][Oe]=new _,Xe.scope=Oe),Xe}getWorkerSource(Se,Oe,Xe){const{type:_t,source:bt,scope:Mt}=Oe,Ht=this.workerSources;if(Ht[Se]||(Ht[Se]={}),Ht[Se][Mt]||(Ht[Se][Mt]={}),Ht[Se][Mt][_t]||(Ht[Se][Mt][_t]={}),this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={}),!Ht[Se][Mt][_t][bt]){const Vt={send:(Ts,xs,or,Lr,Hr,Rr)=>this.actor.send(Ts,xs,or,Se,Hr,Rr),scheduler:this.actor.scheduler},Xt=this.workerSourceTypes[_t];if(!Xt)throw new Error(`Unknown worker source type "${_t}".`);Ht[Se][Mt][_t][bt]=new Xt({actor:Vt,layerIndex:this.getLayerIndex(Se,Mt),availableImages:this.getAvailableImages(Se,Mt),availableModels:this.getAvailableModels(Se,Mt),isSpriteLoaded:this.isSpriteLoaded[Se][Mt],tileProvider:Xe,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO})}return Ht[Se][Mt][_t][bt]}rasterizeImagesWorker(Se,Oe,Xe){const _t=new Map;for(const[bt,{image:Mt,imageVariant:Ht}]of Oe.tasks.entries()){const Vt=this.imageRasterizer.rasterize(Ht,Mt,Oe.scope,Se);_t.set(bt,Vt)}Xe(void 0,_t)}removeRasterizedImages(Se,Oe,Xe){this.imageRasterizer.removeImagesFromCacheByIds(Oe.imageIds,Oe.scope,Se),Xe()}enforceCacheSizeLimit(Se,Oe){d.fH(Oe)}getWorkerPerformanceMetrics(Se,Oe,Xe){Xe(void 0,void 0)}}return d.fE(self)&&(self.worker=new fa(self)),fa}),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 x(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(A){return!m(A)}function m(A){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var z,B,W=new Blob([""],{type:"text/javascript"}),ee=URL.createObjectURL(W);try{B=new Worker(ee),z=!0}catch{z=!1}return B&&B.terminate(),URL.revokeObjectURL(ee),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=A&&A.failIfMajorPerformanceCaveat]===void 0&&(v[D]=function(z){var B,W=function(ee){var ne=document.createElement("canvas"),de=Object.create(M.webGLContextAttributes);return de.failIfMajorPerformanceCaveat=ee,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 A=document.createElement(M);return m!=null&&(A.className=m),v&&v.appendChild(A),A}function w(M,m,v){const A=document.createElementNS("http://www.w3.org/2000/svg",M);for(const D of Object.keys(m))A.setAttributeNS(null,D,String(m[D]));return v&&v.appendChild(A),A}const k=typeof document<"u"?document.documentElement&&document.documentElement.style:null,C=k&&k.userSelect!==void 0?"userSelect":"WebkitUserSelect";let E;function L(){k&&C&&(E=k[C],k[C]="none")}function I(){k&&C&&(k[C]=E)}function O(M){M.preventDefault(),M.stopPropagation(),window.removeEventListener("click",O,!0)}function V(){window.addEventListener("click",O,!0),window.setTimeout(()=>{window.removeEventListener("click",O,!0)},0)}function q(M,m){const v=M.getBoundingClientRect();return se(M,v,m)}function $(M,m){const v=M.getBoundingClientRect(),A=[];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 A=ie(m);return A.params.push(`sdk=js-${d}`),A.path=`/styles/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||v)}normalizeGlyphsURL(m,v){if(!i.e(m))return m;const A=ie(m);return A.path=`/fonts/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||v)}normalizeModelURL(m,v){if(!i.e(m))return m;const A=ie(m);return A.path=`/models/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||v)}normalizeSourceURL(m,v,A,D){if(!i.e(m))return m;const z=ie(m);return z.path=`/v4/${z.authority}.json`,z.params.push("secure"),A&&z.params.push(`language=${A}`),D&&z.params.push(`worldview=${D}`),this._makeAPIURL(z,this._customAccessToken||v)}normalizeIconsetURL(m,v){const A=ie(m);return i.e(m)?(A.path=`/styles/v1${A.path}/iconset.pbf`,this._makeAPIURL(A,this._customAccessToken||v)):ae(A)}normalizeSpriteURL(m,v,A,D){const z=ie(m);return i.e(m)?(z.path=`/styles/v1${z.path}/sprite${v}${A}`,this._makeAPIURL(z,this._customAccessToken||D)):(z.path+=`${v}${A}`,ae(z))}normalizeTileURL(m,v,A){if(this._isSkuTokenExpired()&&this._createSkuToken(),m&&!i.e(m))return m;const D=ie(m);D.path=D.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${v||A&&D.authority!=="raster"&&A===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 ee=W.match(/^access_token=(.*)$/);if(ee)return ee[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 A=ie(m);if(!A.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!A.path.match(/\.[\w]+$/))return m;let D="mapbox://";A.path.match(/^\/raster\/v1\//)?D+=`raster/${A.path.replace(`/${i.g.RASTER_URL_PREFIX}/`,"")}`:A.path.match(/^\/rasterarrays\/v1\//)?D+=`rasterarrays/${A.path.replace(`/${i.g.RASTERARRAYS_URL_PREFIX}/`,"")}`:D+=`tiles/${A.path.replace(`/${i.g.TILE_URL_VERSION}/`,"")}`;let z=A.params;return v&&(z=z.filter(B=>!B.match(/^access_token=/))),z.length&&(D+=`?${z.join("&")}`),D}canonicalizeTileset(m,v){const A=!!v&&i.e(v),D=[];for(const z of m.tiles||[])i.f(z)?D.push(this.canonicalizeTileURL(z,A)):D.push(z);return D}_makeAPIURL(m,v){const A="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",D=ie(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 ae(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. ${A}`);if(v[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${A}`)}return m.params=m.params.filter(z=>z.indexOf("access_token")===-1),m.params.push(`access_token=${v||""}`),ae(m)}}const ce=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ie(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 ae(M){const m=M.params.length?`?${M.params.join("&")}`:"";return`${M.protocol}://${M.authority}${M.path}${m}`}const oe="mapbox.eventData";function pe(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 _e(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=pe(i.g.ACCESS_TOKEN);let A="";return A=v&&v.u?i.j(v.u):i.g.ACCESS_TOKEN||"",m?`${oe}.${m}:${A}`:`${oe}:${A}`}fetchEventData(){const m=i.s("localStorage"),v=this.getStorageKey(),A=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(A);B&&(this.anonId=B);const W=localStorage.getItem(D);W&&(this.anonIdTimestamp=Number(W));const ee=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,A,D){if(!i.g.EVENTS_URL)return;const z=ie(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,ee={url:ae(z),headers:{"Content-Type":"text/plain"},body:JSON.stringify([W])};this.pendingRequest=i.p(ee,ne=>{this.pendingRequest=null,A(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(!_e(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:A}=this.queue.shift();this.postEvent(v,A,()=>{},m)}}const je=new class extends he{constructor(M){super("appUserTurnstile"),this._customAccessToken=M}postTurnstileEvent(M,m){_e(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=pe(i.g.ACCESS_TOKEN),v=m?m.u:i.g.ACCESS_TOKEN;let A=v!==this.eventData.tokenU;i.v(this.anonId)||(this.refreshUUID(),A=!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;A=A||W>=1||W<-1||z.getDate()!==B.getDate()}else A=!0;A?this.postEvent(D,{sdkIdentifier:"mapbox-gl-js",sdkVersion:d,skuId:Y,"enabled.telemetry":!1,userId:this.anonId},z=>{z||(this.eventData.lastSuccess=D,this.eventData.tokenU=v)},M):this.processRequests()}},Ue=je.postTurnstileEvent.bind(je),Te=new class extends he{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(M,m,v,A){this.skuToken=m,this.errorCb=A,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:Y,skuToken:this.skuToken,userId:this.anonId},A=>{A?this.errorCb(A):m&&(this.success[m]=!0)},M))}remove(){this.errorCb=null}},Me=Te.postMapLoadEvent.bind(Te),Fe=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:A,importedStyles:D}=m;if(!_e(M))return;const z=this.getMapInstanceId(v),B={mapInstanceId:z,eventId:this.getEventId(z),style:A};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)}},Le=Fe.postStyleLoadEvent.bind(Fe),Ne=new we({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),qe=Ne.postMetricsEvent.bind(Ne),ze=new we({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),ve=ze.postMetricsEvent.bind(ze),dt=new class extends he{constructor(){super("gljs.performance")}postPerformanceEvent(M,m){_e(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(),A=function(D){const z=performance.getEntriesByType("resource"),B=performance.getEntriesByType("mark"),W=function(Ce){const Be={};if(Ce){for(const Ie in Ce)if(Ie!=="other")for(const st of Ce[Ie]){const tt=`${Ie}ResolveRangeMin`,ct=`${Ie}ResolveRangeMax`,mt=`${Ie}RequestCount`,nt=`${Ie}RequestCachedCount`;Be[tt]=Math.min(Be[tt]||1/0,st.startTime),Be[ct]=Math.max(Be[ct]||-1/0,st.responseEnd);const Ft=wt=>{Be[wt]===void 0&&(Be[wt]=0),++Be[wt]};st.transferSize!==void 0&&st.transferSize===0&&Ft(nt),Ft(mt)}}return Be}(function(Ce,Be){const Ie={};if(Ce)for(const st of Ce){const tt=Be(st);Ie[tt]===void 0&&(Ie[tt]=[]),Ie[tt].push(st)}return Ie}(z,x)),ee=window.devicePixelRatio,ne=navigator.connection||navigator.mozConnection||navigator.webkitConnection,de=ne?ne.effectiveType:void 0,be={counters:[],metadata:[],attributes:[]},ye=(Ce,Be,Ie)=>{Ie!=null&&Ce.push({name:Be,value:Ie.toString()})};for(const Ce in W)ye(be.counters,Ce,W[Ce]);if(D.interactionRange[0]!==1/0&&D.interactionRange[1]!==-1/0&&(ye(be.counters,"interactionRangeMin",D.interactionRange[0]),ye(be.counters,"interactionRangeMax",D.interactionRange[1])),B)for(const Ce of Object.values(u)){const Be=B.find(Ie=>Ie.name===Ce);Be&&ye(be.counters,Ce,Be.startTime)}return ye(be.counters,"visibilityHidden",D.visibilityHidden),ye(be.attributes,"style",function(Ce){if(Ce)for(const Be of Ce){const Ie=Be.name.split("?")[0];if(i.i(Ie)){const st=Ie.split("/").slice(-2);if(st.length===2)return`mapbox://styles/${st[0]}/${st[1]}`}}}(z)),ye(be.attributes,"terrainEnabled",D.terrainEnabled?"true":"false"),ye(be.attributes,"fogEnabled",D.fogEnabled?"true":"false"),ye(be.attributes,"projection",D.projection),ye(be.attributes,"zoom",D.zoom),ye(be.metadata,"devicePixelRatio",ee),ye(be.metadata,"connectionEffectiveType",de),ye(be.metadata,"navigatorUserAgent",navigator.userAgent),ye(be.metadata,"screenWidth",window.screen.width),ye(be.metadata,"screenHeight",window.screen.height),ye(be.metadata,"windowWidth",window.innerWidth),ye(be.metadata,"windowHeight",window.innerHeight),ye(be.metadata,"mapWidth",D.width/ee),ye(be.metadata,"mapHeight",D.height/ee),ye(be.metadata,"webglRenderer",D.renderer),ye(be.metadata,"webglVendor",D.vendor),ye(be.metadata,"sdkVersion",d),ye(be.metadata,"sdkIdentifier","mapbox-gl-js"),be}(v);for(const D of A.metadata);for(const D of A.counters);for(const D of A.attributes);this.postEvent(m,A,()=>{},M)}},fe=dt.postPerformanceEvent.bind(dt),Ve=new class extends he{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(M,m,v,A){if(!i.g.API_URL||!i.g.SESSION_PATH)return;const D=ie(i.g.API_URL+i.g.SESSION_PATH);D.params.push(`sku=${m||""}`),D.params.push(`access_token=${A||i.g.ACCESS_TOKEN||""}`);const z={url:ae(D),headers:{"Content-Type":"text/plain"}};this.pendingRequest=i.h(z,B=>{this.pendingRequest=null,v(B),this.saveEventData(),this.processRequests(A)})}getSessionAPI(M,m,v,A){this.skuToken=m,this.errorCb=A,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,A=>{A?this.errorCb(A):m&&(this.success[m]=!0)},M)}remove(){this.errorCb=null}},Je=Ve.getSessionAPI.bind(Ve),at=new Set;function Ae(M,m){m?at.add(M):at.delete(M)}class Ye{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 We(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 Ge(M){return ot.workerClass!=null?new ot.workerClass:new self.Worker(ot.workerUrl,Object.assign({name:M},ot.workerParams))}const et="mapboxgl_preloaded_worker_pool";class ht{constructor(m){this.active={},this.name=m}acquire(m,v=ht.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{v.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[et]}numActive(){return Object.keys(this.active).length}}ht.workerCount=2;class xt{constructor(m,v,A="Worker",D=ht.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,A){i.t(this.actors,(D,z)=>{D.send(m,v,z)},A=A||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,Ze;function Et(){return Ke||(Ke=new ht),Ke}xt.Actor=i.A;class $t 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 xt((Ze||(Ze=new ht("ImageRasterizer")),Ze),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 A of v.values())A.hasPendingRequests()&&m.push(A);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:A,callback:D}of this.requestors)this._notify(A,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,A){if(this._validate(m,A)){this.images.get(v).set(m.toString(),A);const D=this.imageVersions.get(v),z=D.get(m.toString())||0;D.set(m.toString(),z+1)}}_validate(m,v){let A=!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`))),A=!1),this._validateStretch(v.stretchY,v.data&&v.data.height)||(this.fire(new i.B(new Error(`Image "${m.name}" has invalid "stretchY" value`))),A=!1),this._validateContent(v.content,v)||(this.fire(new i.B(new Error(`Image "${m.name}" has invalid "content" value`))),A=!1),A}_validateStretch(m,v){if(!m)return!0;let A=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,A){const D=[],z=[],B=this.imageProviders.get(v);for(const de of m){if(!de.iconsetId){D.push(de);continue}const be=B.get(de.iconsetId);be&&(this.getImage(de,v)?z.push(de):be.addPendingRequest(de))}if(D.length===0)return void this._notify(z,v,A);let W=!0;const ee=!!this.loaded.get(v),ne=this.images.get(v);if(!ee)for(const de of D)ne.has(de.toString())||(W=!1);ee||W?this._notify(D,v,A):this.requestors.push({ids:D,scope:v,callback:A})}rasterizeImages(m,v){const A=new Map,{tasks:D,scope:z}=m;for(const[B,W]of D.entries()){const ee=this.getImage(W.id,z);ee&&A.set(B,{image:ee,imageVariant:W})}this._rasterizeImages(z,A,v)}_rasterizeImages(m,v,A){if(i.y())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:v,scope:m},A);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));A(void 0,D)}}getUpdatedImages(m){return this.updatedImages.get(m)||new Set}_notify(m,v,A){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 ee={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(ee,{width:W.icon.usvg_tree.width,height:W.icon.usvg_tree.height}),z.set(i.I.toString(B),ee)}A(null,{images:z,versions:this.getImageVersions(v)})}getPixelSize(m){const{width:v,height:A}=this.atlasImage.get(m);return{width:v,height:A}}getPattern(m,v,A){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 ee=this.getPatternInFlightId(D,v);if(this.patternsInFlight.has(ee))return null;this.patternsInFlight.add(ee);const ne=new i.D(m).scaleSelf(i.o.devicePixelRatio),de=new Map([[ne.toString(),{image:W,imageVariant:ne}]]);return this._rasterizeImages(v,de,(be,ye)=>this.storePatternImage(ne,v,W,A,ye)),null}this.storePattern(m,v,W)}return this._updatePatternAtlas(v,A),z.get(D).position}getPatternInFlightId(m,v){return i.F(m,v)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(m,v,A,D,z){const B=m.toString(),W=z?z.get(B):void 0;W&&(A.data=W,this.storePattern(m.id,v,A),this._updatePatternAtlas(v,D),this.patternsInFlight.delete(this.getPatternInFlightId(m.id.toString(),v)))}storePattern(m,v,A){const D={w:A.data.width+2*i.G,h:A.data.height+2*i.G,x:0,y:0},z=new i.H(D,A,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 A=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),A.RGBA8),this.atlasTexture.set(v,D)),D.bind(A.LINEAR,A.CLAMP_TO_EDGE)}_updatePatternAtlas(m,v){const A=this.patterns.get(m),D=Array.from(A.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 ee=this.images.get(m);for(const[ne,{bin:de,position:be}]of A.entries()){let ye=be.padding;const Ce=de.x+ye,Be=de.y+ye,Ie=ee.get(ne).data,st=Ie.width,tt=Ie.height;ye=ye>1?ye-1:ye,i.q.copy(Ie,W,{x:0,y:0},{x:Ce,y:Be},{width:st,height:tt},v),i.q.copy(Ie,W,{x:0,y:tt-ye},{x:Ce,y:Be-ye},{width:st,height:ye},v),i.q.copy(Ie,W,{x:0,y:0},{x:Ce,y:Be+tt},{width:st,height:ye},v),i.q.copy(Ie,W,{x:st-ye,y:0},{x:Ce-ye,y:Be},{width:ye,height:tt},v),i.q.copy(Ie,W,{x:0,y:0},{x:Ce+st,y:Be},{width:ye,height:tt},v),i.q.copy(Ie,W,{x:st-ye,y:tt-ye},{x:Ce-ye,y:Be-ye},{width:ye,height:ye},v),i.q.copy(Ie,W,{x:0,y:tt-ye},{x:Ce+st,y:Be-ye},{width:ye,height:ye},v),i.q.copy(Ie,W,{x:0,y:0},{x:Ce+st,y:Be+tt},{width:ye,height:ye},v),i.q.copy(Ie,W,{x:st-ye,y:0},{x:Ce-ye,y:Be+tt},{width:ye,height:ye},v)}this.dirty=!0}beginFrame(){for(const m of this.images.keys())this.callbackDispatchedThisFrame.set(m,new Set)}dispatchRenderCallbacks(m,v){const A=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=A.get(D.toString());We(z)&&this.updateImage(D,v,z)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function Yt(M){const m=M.value,v=M.valueSpec,A=M.style,D=M.styleSpec,z=M.key,B=M.arrayElementValidator||mn;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 zs(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 A=M.valueSpec,D=i.L(v.type);let z,B,W,ee={};const ne=D!=="categorical"&&v.property===void 0,de=!ne,be=function(Ie){const st=Ie.stops;return Array.isArray(st)&&Array.isArray(st[0])&&i.K(st[0][0])}(v),ye=Fr({key:M.key,value:M.value,valueSpec:M.styleSpec.function,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{stops:function(Ie){if(D==="identity")return[new i.V(Ie.key,Ie.value,'identity function may not have a "stops" property')];let st=[];const tt=Ie.value;return st=st.concat(Yt({key:Ie.key,value:tt,valueSpec:Ie.valueSpec,style:Ie.style,styleSpec:Ie.styleSpec,arrayElementValidator:Ce})),Array.isArray(tt)&&tt.length===0&&st.push(new i.V(Ie.key,tt,"array must have at least one stop")),st},default:function(Ie){return mn({key:Ie.key,value:Ie.value,valueSpec:A,style:Ie.style,styleSpec:Ie.styleSpec})}}});return D==="identity"&&ne&&ye.push(new i.V(M.key,M.value,'missing required property "property"')),D==="identity"||v.stops||ye.push(new i.V(M.key,M.value,'missing required property "stops"')),D==="exponential"&&A.expression&&!i.O(A)&&ye.push(new i.V(M.key,M.value,"exponential functions not supported")),M.styleSpec.$version>=8&&(de&&!i.Q(A)?ye.push(new i.V(M.key,M.value,"property functions not supported")):ne&&!i.S(A)&&ye.push(new i.V(M.key,M.value,"zoom functions not supported"))),D!=="categorical"&&!be||v.property!==void 0||ye.push(new i.V(M.key,M.value,'"property" property is required')),ye;function Ce(Ie){let st=[];const tt=Ie.value,ct=Ie.key;if(!Array.isArray(tt))return[new i.V(ct,tt,`array expected, ${i.M(tt)} found`)];if(tt.length!==2)return[new i.V(ct,tt,`array length 2 expected, length ${tt.length} found`)];if(be){if(!i.K(tt[0]))return[new i.V(ct,tt,`object expected, ${i.M(tt[0])} found`)];const mt=tt[0];if(mt.zoom===void 0)return[new i.V(ct,tt,"object stop key must have zoom")];if(mt.value===void 0)return[new i.V(ct,tt,"object stop key must have value")];const nt=i.L(mt.zoom);if(typeof nt!="number")return[new i.V(ct,mt.zoom,"stop zoom values must be numbers")];if(W&&W>nt)return[new i.V(ct,mt.zoom,"stop zoom values must appear in ascending order")];nt!==W&&(W=nt,B=void 0,ee={}),st=st.concat(Fr({key:`${ct}[0]`,value:tt[0],valueSpec:{zoom:{}},style:Ie.style,styleSpec:Ie.styleSpec,objectElementValidators:{zoom:Ps,value:Be}}))}else st=st.concat(Be({key:`${ct}[0]`,value:tt[0],style:Ie.style,styleSpec:Ie.styleSpec},tt));return i.U(i.W(tt[1]))?st.concat([new i.V(`${ct}[1]`,tt[1],"expressions are not allowed in function stops.")]):st.concat(mn({key:`${ct}[1]`,value:tt[1],valueSpec:A,style:Ie.style,styleSpec:Ie.styleSpec}))}function Be(Ie,st){const tt=i.M(Ie.value),ct=i.L(Ie.value),mt=Ie.value!==null?Ie.value:st;if(z){if(tt!==z)return[new i.V(Ie.key,mt,`${tt} stop domain type must match previous stop domain type ${z}`)]}else z=tt;if(tt!=="number"&&tt!=="string"&&tt!=="boolean"&&typeof ct!="number"&&typeof ct!="string"&&typeof ct!="boolean")return[new i.V(Ie.key,mt,"stop domain value must be a number, string, or boolean")];if(tt!=="number"&&D!=="categorical"){let nt=`number expected, ${tt} found`;return i.Q(A)&&D===void 0&&(nt+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(Ie.key,mt,nt)]}return D!=="categorical"||tt!=="number"||typeof ct=="number"&&isFinite(ct)&&Math.floor(ct)===ct?D!=="categorical"&&tt==="number"&&typeof ct=="number"&&typeof B=="number"&&B!==void 0&&ctnew i.V(`${M.key}${A.key}`,M.value,A.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 Dr(v,M);if(M.expressionContext==="appearance")return zt(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 Dr(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 A=[];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=>{A.push(...Dr(D,m))}),A)}function zt(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 A=[];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=>{A.push(...zt(D,m))}),A)}function $s(M){const m=M.key,v=M.value,A=M.valueSpec,D=[];return Array.isArray(A.values)?A.values.indexOf(i.L(v))===-1&&D.push(new i.V(m,v,`expected one of [${A.values.join(", ")}], ${JSON.stringify(v)} found`)):Object.keys(A.values).indexOf(i.L(v))===-1&&D.push(new i.V(m,v,`expected one of [${Object.keys(A.values).join(", ")}], ${JSON.stringify(v)} found`)),D}function kr(M){return i.a4(i.W(M.value))?Zs(Object.assign({},M,{expressionContext:"filter",valueSpec:M.styleSpec[`filter_${M.layerType||"fill"}`]})):Xs(M)}function Xs(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 A=M.styleSpec;let D=$s({key:`${v}[0]`,value:m[0],valueSpec:A.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(A,v[ne],`"${ne}" is prohibited for ref layers`))}),D.layers.forEach(ne=>{i.L(ne.id)===W&&(ee=ne)}),ee?ee.ref?m.push(new i.V(A,v.ref,"ref cannot reference another ref layer")):B=i.L(ee.type):typeof W=="string"&&m.push(new i.V(A,v.ref,`ref layer "${W}" not found`))}else if(B!=="background"&&B!=="sky"&&B!=="slot")if(v.source)if(i.a2(v.source)){const ee=D.sources&&D.sources[v.source],ne=ee&&i.L(ee.type);ee?ne==="vector"&&B==="raster"?m.push(new i.V(A,v.source,`layer "${v.id}" requires a raster source`)):ne==="raster"&&B!=="raster"?m.push(new i.V(A,v.source,`layer "${v.id}" requires a vector source`)):ne!=="vector"||v["source-layer"]?ne==="raster-dem"&&B!=="hillshade"?m.push(new i.V(A,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"&&!ee.lineMetrics?m.push(new i.V(A,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(A,v.source,`layer "${v.id}" requires a 'raster-array' source.`)):m.push(new i.V(A,v.source,"raster-array source can only be used with layer type 'raster'.")):m.push(new i.V(A,v,`layer "${v.id}" must specify a "source-layer"`)):m.push(new i.V(A,v.source,`source "${v.source}" not found`))}else m.push(new i.V(`${A}.source`,v.source,'"source" must be a string'));else m.push(new i.V(A,v,'missing required property "source"'));return m=m.concat(Fr({key:A,value:v,valueSpec:z.layer,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{"*":()=>[],type:()=>mn({key:`${A}.type`,value:v.type,valueSpec:z.layer.type,style:M.style,styleSpec:M.styleSpec,object:v,objectKey:"type"}),filter:ee=>kr(Object.assign({layerType:B},ee)),layout:ee=>Fr({layer:v,key:ee.key,value:ee.value,valueSpec:{},style:ee.style,styleSpec:ee.styleSpec,objectElementValidators:{"*":ne=>Vn(Object.assign({layerType:B},ne))}}),paint:ee=>Fr({layer:v,key:ee.key,value:ee.value,valueSpec:{},style:ee.style,styleSpec:ee.styleSpec,objectElementValidators:{"*":ne=>Or(Object.assign({layerType:B,layer:v},ne))}}),appearances(ee){const ne=Yt({key:ee.key,value:ee.value,valueSpec:ee.valueSpec,style:ee.style,styleSpec:ee.styleSpec,arrayElementValidator:ye=>function(Ce){const{key:Be,layer:Ie,layerType:st}=Ce,tt=i.L(Ce.value),ct=i.L(tt.name),mt=i.L(tt.condition),nt=Fr({key:Be,value:tt,valueSpec:Ce.styleSpec.appearance,style:Ce.style,styleSpec:Ce.styleSpec,objectElementValidators:{condition:Ft=>function(wt){const Dt=[];return Dt.push(...Zs({key:wt.key,value:wt.object.condition,valueSpec:i.a8.appearance.condition,expressionContext:"appearance"})),Dt}(Object.assign({layer:Ie,layerType:st},Ft)),properties:Ft=>function(wt){const Dt=[],{styleSpec:pt,layer:yt,layerType:Tt}=wt,Wt=pt[`paint_${Tt}`],Bt=pt[`layout_${Tt}`],ns=wt.object[wt.objectKey];for(const Qt in ns){const ws=Qt in Wt?"paint":Qt in Bt?"layout":void 0;if(!ws){Dt.push(new i.V(wt.key,Qt,`unknown property "${Qt}" for layer type "${Tt}"`));continue}const As=Object.assign({},wt,{key:`${wt.key}.${Qt}`,object:ns,objectKey:Qt,layer:yt,layerType:Tt,value:ns[Qt],valueSpec:ws==="paint"?Wt[Qt]:Bt[Qt]});Dt.push(...ir(As,ws))}return Dt}(Object.assign({layer:Ie,layerType:st},Ft))}});return ct!=="hidden"&&mt===void 0&&nt.push(new i.V(Ce.key,"name",'Appearance with name different than "hidden" must have a condition')),nt}(Object.assign({layerType:B,layer:v},ye))}),de=Array.isArray(ee.value)?ee.value:[],be=new Set;return de.forEach((ye,Ce)=>{const Be=i.L(ye.name);if(Be)if(be.has(Be)){const Ie=i.L(v.id);ne.push(new i.V(ee.key,Be,`Duplicated appearance name "${Be}" for layer "${Ie}"`))}else be.add(Be)}),ne}}})),m}function Gr({key:M,value:m}){return i.a2(m)?[]:[new i.V(M,m,`string expected, ${i.M(m)} found`)]}const tr={promoteId:function M({key:m,value:v}){if(i.a2(v))return Gr({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 A=[];for(const D in v)A.push(...M({key:`${m}.${D}`,value:v[D]}));return A}};function cr(M){const m=M.value,v=M.key,A=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(Fr({key:v,value:m,valueSpec:A[`source_${z.replace("-","_")}`],style:M.style,styleSpec:A,objectElementValidators:tr})),B;case"geojson":if(B=Fr({key:v,value:m,valueSpec:A.source_geojson,style:D,styleSpec:A,objectElementValidators:tr}),"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 ee=m.clusterProperties[W];if(!Array.isArray(ee))return[new i.V(`${v}.clusterProperties.${W}`,ee,"array expected")];const[ne,de]=ee,be=typeof ne=="string"?[ne,["accumulated"],["get",W]]:ne;B.push(...Zs({key:`${v}.${W}.map`,value:de,expressionContext:"cluster-map"})),B.push(...Zs({key:`${v}.${W}.reduce`,value:be,expressionContext:"cluster-reduce"}))}}return B;case"video":return Fr({key:v,value:m,valueSpec:A.source_video,style:D,styleSpec:A});case"image":return Fr({key:v,value:m,valueSpec:A.source_image,style:D,styleSpec:A});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 $s({key:`${v}.type`,value:m.type,valueSpec:{values:cn(A)}})}}function cn(M){return M.source.reduce((m,v)=>{const A=M[v];return A.type.type==="enum"&&(m=m.concat(Object.keys(A.type.values||{}))),m},[])}function rn(M){const m=M.value,v=M.styleSpec,A=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$/),ee=B.match(/^(.*)-use-theme$/);z=z.concat(ee&&A[ee[1]]?mn({key:B,value:m[B],valueSpec:{type:"string"},style:D,styleSpec:v}):W&&A[W[1]]&&A[W[1]].transition?mn({key:B,value:m[B],valueSpec:v.transition,style:D,styleSpec:v}):A[B]?mn({key:B,value:m[B],valueSpec:A[B],style:D,styleSpec:v}):[new i.V(B,m[B],`unknown property "${B}"`)])}return z}function jn(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 A=[];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 A=A.concat([new i.V(v,m,`missing property "${de}"`)]),A;if(!i.a2(m.type))return A=A.concat([new i.V(`${v}.type`,m.type,"string expected")]),A;if(W)for(let de=0;de[],array:Yt,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:Ps,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:$s,filter:kr,function:zs,layer:Qr,object:Fr,source:cr,model:i.a9,light:rn,"light-3d":jn,terrain:ni,fog:rs,string:Gr,formatted:function(M){return Gr(M).length===0?[]:Zs(M)},resolvedImage:function(M){return Gr(M).length===0?[]:Zs(M)},projection:function(M){const m=M.value,v=M.styleSpec,A=v.projection,D=M.style;if(i.K(m)){let z=[];for(const B in m)z=z.concat(mn({key:B,value:m[B],valueSpec:A[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:A}=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=Fr(Object.assign({},M,{value:z,valueSpec:A.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(jr(D,A,{key:`${M.key}.data`}))),B},iconset:function(M){const m=M.value,v=M.key,A=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(Fr({key:v,value:m,valueSpec:A[`iconset_${z}`],style:D,styleSpec:A})),function(W,ee){return!(W!=="source"||!ee.source)}(z,m)){const W=D.sources&&D.sources[m.source],ee=W&&i.L(W.type);W?ee!=="raster-array"&&B.push(new i.V(v,m.source,`iconset cannot be used with a source of type ${String(ee)}, 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 mn(M,m=!1){const v=M.value,A=M.valueSpec,D=M.styleSpec;if(A.expression){if(i.a6(i.L(v)))return zs(M);if(i.U(i.W(v)))return Zs(M)}if(A.type&&Bn[A.type]){const z=Bn[A.type](M);return m===!0&&z.length>0&&Array.isArray(M.value)?Zs(M):z}return Fr(Object.assign({},M,{valueSpec:A.type?D[A.type]:A}))}function Fr(M){const m=M.key,v=M.value,A=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 ee in v){const ne=ee.split(".")[0];let de;D[ne]?de=D[ne]:A[ne]?de=mn:D["*"]?de=D["*"]:A["*"]&&(de=mn),de?W=W.concat(de({key:(m&&`${m}.`)+ee,value:v[ee],valueSpec:A[ne]||A["*"],style:z,styleSpec:B,object:v,objectKey:ee},v)):W.push(new i.a5(m,v[ee],`unknown property "${ee}"`))}for(const ee in A){if(D[ee])continue;const ne=A[ee];ne.required&&ne.default===void 0&&v[ee]===void 0&&W.push(new i.V(m,v,`missing required property "${ee}"`))}return W}function Kt({key:M,value:m}){const v=Gr({key:M,value:m});if(v.length)return v;const A=m;return A.indexOf("{fontstack}")===-1&&v.push(new i.V(M,m,'"glyphs" url must include a "{fontstack}" token')),A.indexOf("{range}")===-1&&v.push(new i.V(M,m,'"glyphs" url must include a "{range}" token')),v}function jr(M,m=i.a8,v={}){return Fr({key:v.key||"",value:M,valueSpec:Object.assign(m.$root,{"*":{type:"*"}}),styleSpec:m,style:M,objectElementValidators:{glyphs:Kt}})}function zr(M,m=i.a8){return xs(jr(M,m))}const fa=M=>xs(cr(M)),qt=M=>xs(rn(M)),Se=M=>xs(jn(M)),Oe=M=>xs(ni(M)),Xe=M=>xs(rs(M)),_t=M=>xs(function(m){const v=m.value,A=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 ee=W.match(/^(.*)-transition$/);B=B.concat(ee&&z[ee[1]]&&z[ee[1]].transition?mn({key:W,value:v[W],valueSpec:D.transition,style:A,styleSpec:D}):z[W]?mn({key:W,value:v[W],valueSpec:z[W],style:A,styleSpec:D}):[new i.a5(W,v[W],`unknown property "${W}"`)])}return B}(M)),bt=M=>xs(function(m){const v=m.value,A=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 ee=W.match(/^(.*)-transition$/);B=B.concat(ee&&z[ee[1]]&&z[ee[1]].transition?mn({key:W,value:v[W],valueSpec:D.transition,style:A,styleSpec:D}):z[W]?mn({key:W,value:v[W],valueSpec:z[W],style:A,styleSpec:D}):[new i.a5(W,v[W],`unknown property "${W}"`)])}return B}(M)),Mt=M=>xs(Qr(M)),Ht=M=>xs(kr(M)),Vt=M=>xs(Or(M)),Xt=M=>xs(Vn(M)),Ts=M=>xs(i.a9(M));function xs(M){return M.slice().sort((m,v)=>m.line&&v.line?m.line-v.line:0)}function or(M,m){let v=!1;if(m&&m.length)for(const A of m)A instanceof i.a5?i.w(A.message):(M.fire(new i.B(new Error(A.message))),v=!0);return v}const Lr=i.a8.light;let Hr;class Rr extends i.E{constructor(m,v="flat"){super(),this._transitionable=new i.aa(Hr||(Hr=new i.ab({anchor:new i.ac(Lr.anchor),position:new i.ad(Lr.position),color:new i.ac(Lr.color),intensity:new i.ac(Lr.intensity)}))),this.setLight(m,v),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(m,v,A={}){this._validate(qt,m,A)||(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,A){return(!A||A.validate!==!1)&&or(this,m.call(zr,Object.assign({value:v,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}}const dn=i.a8.terrain;let Gn=class extends i.E{constructor(M,m,v,A,D){super(),this.scope=v,this._transitionable=new i.aa(new i.ab({source:new i.ac(dn.source),exaggeration:new i.ac(dn.exaggeration)}),v,A),this._transitionable.setTransitionOrValue(M,A),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,A=-1,D=1;for(const z of m.zoomStops)D=m.evaluate(new i.ae(z,{worldview:this.worldview})),D>.01?(v=z,A=-1):A=z;return D<.01&&v>0&&A>v?[v,A]: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 ta=.05;function da(M,m,v,A){const D=i.aj(45,65,v),[z,B]=Mo(M,A);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 Mo(M,m){const v=.5/Math.tan(.5*m);return[M.range[0]+v,M.range[1]+v]}function _o(M,m,v,A,D){const z=i.ah([],[m,v,A],D.mercatorFogMatrix);return da(M,i.ai(z),D.pitch,D._fov)}function Zi(M,m,v,A,D,z,B){const W=[[v,A,0],[D,A,0],[D,z,0],[v,z,0]];let ee=Number.MAX_VALUE,ne=-Number.MAX_VALUE;for(const de of W){const be=i.ah([],de,m),ye=i.ai(be);ee=Math.min(ee,ye),ne=Math.max(ne,ye)}return[da(M,ee,B.pitch,B._fov),da(M,ne,B.pitch,B._fov)]}const ai=i.a8.fog;class Fi extends i.E{constructor(m,v,A,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,A,new Map(D)),this.set(m,D),this._transitioning=this._transitionable.untransitioned(),this._transform=v,this.properties=new i.ak(z),this.scope=A}get state(){const m=this._transform,v=m.projection.name==="globe",A=i.al(m.zoom),D=this.properties.get("range"),z=[.5,3];return{range:v?[i.am(z[0],D[0],A),i.am(z[1],D[1],A)]:D,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(m,v,A={}){if(this._validate(Xe,m,A))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(A,D,z){const B=i.ag.fromLngLat(D),W=z.elevation?z.elevation.getAtPointOrZero(B):0;return _o(A,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 Zi(this.state,v,0,0,i.an,i.an,this._transform)}getOpacityForBounds(m,v,A,D,z){return this._transform.projection.supportsFog?Zi(this.state,m,v,A,D,z,this._transform):[1,1]}getFovAdjustedRange(m){return this._transform.projection.supportsFog?Mo(this.state,m):[0,1]}isVisibleOnFrustum(m){if(!this._transform.projection.supportsFog)return!1;const v=[4,5,6,7];for(const A of v){const D=m.points[A];let z;if(D[2]>=0)z=D;else{const B=m.points[A-4];z=i.ao(B,D,B[2]/(B[2]-D[2]))}if(_o(this.state,z[0],z[1],0,this._transform)>=ta)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,A){return(!A||A.validate!==!1)&&or(this,m.call(zr,Object.assign({value:v,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}}let Qo,di,zi,Yi=class extends i.E{constructor(M,m,v,A){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(A)),this.set(M,A),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"),A=i.ap(v[0]),D=-Math.max(i.ap(v[1]),.01),z=[Math.cos(A)*Math.cos(D),Math.sin(A)*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(_t,M,v))return;const A=Object.assign({},M),D=i.a8.snow;for(const z of Object.keys(D))A[z]===void 0&&(A[z]=D[z].default);this._options=A,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)&&or(this,M.call(zr,Object.assign({value:m,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}},ua=class extends i.E{constructor(M,m,v,A){super();const D=di||(di=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(A)),this.set(M,A),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"),A=i.ap(v[0]),D=-Math.max(i.ap(v[1]),.01),z=[Math.cos(A)*Math.cos(D),Math.sin(A)*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(bt,M,v))return;const A=Object.assign({},M),D=i.a8.rain;for(const z of Object.keys(D))A[z]===void 0&&(A[z]=D[z].default);this._options=A,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)&&or(this,M.call(zr,Object.assign({value:m,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}};class Jo extends i.E{constructor(m,v,A,D){super(),this.scope=A,this._options=m,this.properties=new i.ak(v),this._transitionable=new i.aa(v,A,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 sc=()=>zi||(zi=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 rc;const _u=()=>rc||(rc=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 bu{constructor(m,v,A){this.screenBounds=m,this.cameraPoint=A.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=v,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,A)}static createFromScreenPoints(m,v){let A,D;if(m instanceof i.P||typeof m[0]=="number"){const z=i.P.convert(m);A=[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);A=[z,B],D=i.as(z,B).every(ee=>v.isPointAboveHorizon(ee))&&v.isPointAboveHorizon(W)}return new bu(A,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],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.as(v,A,0,!1);return this.cameraPoint.y>A.y&&(this.cameraPoint.x>v.x&&this.cameraPoint.x=A.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],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.as(v,A,m),z=this.cameraPoint.clone(),B=+(z.x>v.x)+ +(z.x>A.x);switch(3*(+(z.y>v.y)+ +(z.y>A.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,A,D=0){const z=Math.max(m.queryPadding,m.evaluateQueryRenderedFeaturePadding())/v._pixelsPerMercatorPixel+1,B=A?this._bufferedCameraMercator(z,v):this._bufferedScreenMercator(z,v);let W=m.tileID.wrap+(B.unwrapped?D:0);const ee=B.polygon.map(st=>i.au(m.tileTransform,st,W));if(!i.av(ee,0,0,i.an,i.an))return;W=m.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const ne=this.screenGeometryMercator.polygon.map(st=>i.aw(m.tileTransform,st,W)),de=ne.map(st=>new i.P(st[0],st[1])),be=v.getFreeCameraOptions().position||new i.ag(0,0,0),ye=i.aw(m.tileTransform,be,W),Ce=ne.map(st=>{const tt=i.ax(st,st,ye);return i.ay(tt,tt),new i.az(ye,tt)}),Be=i.aA(m,1,v.zoom)*v._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:de,tilespaceRays:Ce,bufferedTilespaceGeometry:ee,bufferedTilespaceBounds:(Ie=i.aB(ee),Ie.min.x=i.aC(Ie.min.x,0,i.an),Ie.min.y=i.aC(Ie.min.y,0,i.an),Ie.max.x=i.aC(Ie.max.x,0,i.an),Ie.max.y=i.aC(Ie.max.y,0,i.an),Ie),tile:m,tileID:m.tileID,pixelToTileUnitsFactor:Be};var Ie}_bufferedScreenMercator(m,v){const A=wu(m);if(this._screenRaycastCache[A])return this._screenRaycastCache[A];{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[A]=D,D}}_bufferedCameraMercator(m,v){const A=wu(m);if(this._cameraRaycastCache[A])return this._cameraRaycastCache[A];{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[A]=D,D}}_projectAndResample(m,v){const A=function(z,B){const W=i.aD([],B.pixelMatrix,B.globeMatrix),ee=[0,-i.aF,0,1],ne=[0,i.aF,0,1],de=[0,0,0,1];i.aE(ee,ee,W),i.aE(ne,ne,W),i.aE(de,de,W);const be=new i.P(ee[0]/ee[3],ee[1]/ee[3]),ye=new i.P(ne[0]/ne[3],ne[1]/ne[3]),Ce=i.aG(z,be)&&ee[3]1?Om(z.slice(0,st),B):[],mt=stnew i.P(Nd(Dt.x),Dt.y)),mt=mt.map(Dt=>new i.P(Nd(Dt.x),Dt.y));const nt=[...ct];nt.length===0&&nt.push(mt[mt.length-1]);const Ft=i.am(nt[nt.length-1].y,(mt.length===0?ct[0]:mt[0]).y,tt);let wt;return wt=Ce?[new i.P(0,Ft),new i.P(0,0),new i.P(1,0),new i.P(1,Ft)]:[new i.P(1,Ft),new i.P(1,1),new i.P(0,1),new i.P(0,Ft)],nt.push(...wt),mt.length===0?nt.push(ct[0]):nt.push(...mt),{polygon:nt.map(Dt=>new i.ag(Dt.x,Dt.y)),unwrapped:!1}}(m,v);if(A)return A;const D=function(z,B){let W=!1,ee=-1/0,ne=0;for(let be=0;beee&&(ee=z[be].x,ne=be);for(let be=0;be.5&&(Ce.x{be.x-=1}),{polygon:z,unwrapped:W}}(Om(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 Om(M,m){return i.aI(M,v=>{const A=m.pointCoordinate3D(v);v.x=A.x,v.y=A.y},1/256)}function Nd(M){return M<0?1+M%1:M%1}function wu(M){return 100*M|0}function Fm(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 A=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&&(A.tiles=m.tiles),A.tiles=v.canonicalizeTileset(A,M.url),A}function Hu(M,m,v,A,D){const z=function(W,ee){if(W)return D(W);if(ee){M.url&&ee.tiles&&M.tiles&&delete M.tiles;const ne=Fm(M,ee,m);if(ne instanceof Error)return D(ne);D(null,ne)}},B=function(W,ee,ne){if(!W)return null;if(!ee&&!ne)return W;ne=ne||W.worldview_default;const de=Object.values(W.language||{});if(de.length===0)return null;const be=Object.values(W.worldview||{});if(be.length===0)return null;const ye=de.every(Be=>Be===ee),Ce=be.every(Be=>Be===ne);return ye&&Ce?W:ee in(W.language_options||{})||ne in(W.worldview_options||{})?null:W.language_options&&W.worldview_options?W:null}(M.data,v,A);return B?i.o.frame(()=>z(null,B)):M.url?i.m(m.transformRequest(m.normalizeSourceURL(M.url,null,v,A),i.R.Source),z):i.o.frame(()=>{const{data:W,...ee}=M;z(null,ee)})}function zm(M,m){const v=Math.pow(2,m.z),A=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>=A&&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}`),A&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${A}`),this.fire(new i.B(B))):W&&(this._setTileJSON(W),Ue(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 ee=i.g.TILE_PROVIDER_URLS[W];if(!ee)return null;let ne;try{ne=new URL(ee,i.g.API_URL).href}catch{return i.w(`TileProvider "${W}" has an invalid URL: "${ee}"`),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):Hu(this._options,this.map._requestManager,v,A,D)}_loadWithProvider(m,v){this.provider=m.name;const A=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(A.signal.aborted)return;if(B)return void v(B);const ee=W?W.find(ne=>ne!=null):null;if(ee){const ne=Fm(this._options,ee,this.map._requestManager);ne instanceof Error?v(ne):v(null,ne)}else v(null,{tiles:this._options.tiles})}),{cancel:()=>{A.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=kd.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 A=m.tileID.canonical.url(this.tiles,this.scheme),D=this.map._requestManager.normalizeTileURL(A),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,ee={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(A)&&(ee.localizableLayerIds=this.localizableLayerIds),ee.request.collectResourceTiming=this._collectResourceTiming,m.actor&&m.state!=="expired")m.state==="loading"?m.reloadCallback=v:m.request=m.actor.send("reloadTile",ee,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",ee,ne.bind(this),void 0,!0);else{const de=i.aO.call({deduped:this._deduped},ee,(be,ye)=>{if(be||!ye)ne.call(this,be);else{const Ce=i.aP(ye.responseHeaders);ee.data={rawData:ye.rawData.slice(0),expires:Ce.expires,cacheControl:Ce.cacheControl},m.actor&&m.actor.send("loadTile",ee,ne.bind(this),void 0,!0)}},!0);m.request={cancel:de}}function ne(de,be){return delete m.request,m.aborted?v(null):de?v(de):(be&&be.resourceTiming&&(m.resourceTiming=be.resourceTiming),this.map._refreshExpiredTiles&&be&&m.setExpiryData(be),m.loadVectorData(be,this.map.painter),i.aQ(this.dispatcher),v(null,be),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 P0 extends i.E{constructor(m,v,A,D){super(),this.id=m,this.dispatcher=A,this.setEventedParent(D),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Object.assign({type:"raster"},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=Hu(this._options,this.map._requestManager,null,v,(A,D)=>{this._tileJSONRequest=null,this._loaded=!0,A?this.fire(new i.B(A)):D&&(Object.assign(this,D),D.raster_layers&&(this.rasterLayers=D.raster_layers,this.rasterLayerIds=this.rasterLayers.map(z=>z.id)),this.tileBounds=kd.fromTileJSON(D),Ue(D.tiles),this.fire(new i.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.C("data",{dataType:"source",sourceDataType:"content"}))),m&&m(A)})}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 A=i.o.devicePixelRatio>=2,D=this.map._requestManager.normalizeTileURL(m.tileID.canonical.url(this.tiles,this.scheme),A,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 ee=i.aP(W);this.map._refreshExpiredTiles&&m.setExpiryData(ee),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 Cw([M,m],v,A,{scaled:D=!0}={}){const{tileSize:z,buffer:B}=A,{x:W,y:ee,z:ne}=v;if(!isFinite(W)||!isFinite(ee)||!isFinite(ne))throw new Error("Invalid MRT header");const de=2**ne,be=de*i.aH(M),ye=de*i.aL(m);return function([Ce,Be],Ie,{scaled:st=!0}={}){if(!Ie)throw new Error("bandView is undefined");const{data:tt,tileSize:ct,buffer:mt,offset:nt,scale:Ft,dimension:wt}=Ie;if(Ce<-mt||Ce>ct+mt||Be<-mt||Be>ct+mt)throw new Error(`Point (${Ce}, ${Be}) out of bounds for tileSize=${ct}, buffer=${mt}`);const Dt=(Be+mt)*(ct+2*mt)+(Ce+mt);if(new Uint32Array(tt.buffer)[Dt]===4294967295)return null;let pt=[];pt=st?[]:new Ie.data.constructor(wt);for(let yt=0;yt{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&&ee){const de=i.aP(ne);m.setExpiryData(de)}if(this.partial&&m.state!=="expired")m.state="empty";else if(!this.partial){if(!ee)return v(null);m.state="loaded",m._isHeaderLoaded=!0,m._mrt=ee}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 A=m.texturePerLayer;if(m.flushAllQueues(),A.size){m.destroy(!1);for(const D of A.values())this.map.painter.saveTileTexture(D)}else m.destroy()}prepareTile(m,v,A,D){m._isHeaderLoaded&&(m.state!=="empty"&&(m.state="reloading"),m.fetchBandForRender(v,A,D,(z,B)=>{z?(m.state="errored",this.fire(new i.B(z))):B&&(m._isHeaderLoaded=!0,m.setTexturePerLayer(A,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),A=v&&v.fields,D=A&&A.bands&&A.bands;return D?D[0]:0}getTextureDescriptor(m,v,A){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)&&!A)return;const W=m.textureDescriptorPerLayer.get(v.id);return Object.assign({},W,{texture:m.texturePerLayer.get(v.id)})}getImages(m,v){const A=new Map;for(const D of m)for(const z of v){const[B,W]=z.split("/"),ee=D.getLayer(B);if(!ee||!ee.hasBand(W)||!ee.hasDataForBand(W))continue;const{bytes:ne,tileSize:de,buffer:be}=ee.getBandView(W),ye=de+2*be,Ce={data:new i.q({width:ye,height:ye},ne),pixelRatio:2,sdf:!1,usvg:!1,version:0};A.set(z,Ce)}return A}queryRasterArrayValueByBandId(m,v,A){const D=v._mrt;return new Promise(z=>{const B={},W=new Set;for(const[ee,ne]of Object.entries(D.layers)){if(A.layerName&&ee!==A.layerName)continue;const de={};B[ee]=de;for(const{bands:be}of ne.dataIndex)for(const ye of be)A.bands&&!A.bands.includes(ye)||(W.add(i.F(ee,ye)),v.fetchBand(ee,null,ye,Ce=>{i.o.frame(()=>{de[ye]=Ce?null:Cw([m.lng,m.lat],D,ne.getBandView(ye)),W.delete(i.F(ee,ye)),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 A=this.map._requestManager.normalizeTileURL(m.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),D=this.map._requestManager.transformRequest(A,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(ee=>ee(z,null)),void delete this._loadTilePending[m.uid];if(!B)return this._loadTilePending[m.uid].forEach(ee=>ee(null,null)),void delete this._loadTilePending[m.uid];if(this.map._refreshExpiredTiles&&B){const ee=i.aP(W);m.setExpiryData(ee)}m._mrt=B,m._isHeaderLoaded=!0,m.state="loaded",this._loadTilePending[m.uid].forEach(ee=>ee(null,B)),this._loadTileLoaded[m.uid]=!0,delete this._loadTilePending[m.uid]},void 0,!0)}queryRasterArrayValueByAllBands(m,v,A){return new Promise((D,z)=>{this._loadTileForQuery(v,(B,W)=>{B?z(B):D(W?this.queryRasterArrayValueByBandId(m,v,A):null)})})}queryRasterArrayValue(m,v){const A=i.aU.convert(m),D=this.findLoadedParent(A);return D&&D._mrt?v.bands||!this.partial?this.queryRasterArrayValueByBandId(A,D,v):this.queryRasterArrayValueByAllBands(A,D,v):Promise.resolve(null)}findLoadedParent(m){const v=i.ag.fromLngLat(m,this.map.transform.tileSize),A=this.maxzoom+1,D=1<0&&(W[new i.aR(M.overscaledZ,D,m.z,A,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,A)this.fire(new i.B(A));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 A=this.map.style?this.map.style.getLut(this.scope):null,D=A?{image:A.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,ee)=>z&&!ee?(M.state="loaded",m(null)):(delete M.request,M.destroy(!1),M.aborted?m(null):W?m(W):(M.loadVectorData(ee,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,A){super(M,m,v,A),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,A){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(A)}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=Hu(this._options,this.map._requestManager,m,v,(A,D)=>{this._tileJSONRequest=null,this._loaded=!0,A?(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(A))):D&&(Object.assign(this,D),D.bounds&&(this.tileBounds=new kd(D.bounds,this.minzoom,this.maxzoom)),Ue(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(A)})}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)),A={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",A,D.bind(this))}else M.actor=this.dispatcher.getActor(),M.request=M.actor.send("loadTile",A,D.bind(this),void 0,!0);function D(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,A){super(M,m,v,A),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,A){super(),this.id=M,this.type="custom",this._dataType="raster",this._dispatcher=v,this._implementation=m,this.setEventedParent(A),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new i.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 kd(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:A}=M.canonical;return this._implementation.hasTile({x:m,y:v,z:A})}return!this.tileBounds||this.tileBounds.contains(M.canonical)}loadTile(M,m){const{x:v,y:A,z:D}=M.tileID.canonical,z=new AbortController,B=Promise.resolve(this._implementation.loadTile({x:v,y:A,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(ee){return ee instanceof ImageData||ee instanceof HTMLCanvasElement||ee instanceof ImageBitmap||ee 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:A,z:D}=M.tileID.canonical;this._implementation.unloadTile({x:v,y:A,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"}))}}},Sp=function(M,m,v,A){const D=new kp[m.type](M,m,v,A);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 Mw(M,m,v=""){return`${v}:${m.id||""}:${m.layer.id}:${function(A){if("layerId"in A)return`layer:${A.layerId}`;{const{featuresetId:D,importId:z}=A;return`featureset:${D}${z?`:import:${z}`:""}`}}(M.target)}`}function Kh(M,m,v,A=""){if(M.uniqueFeatureID){const D=Mw(M,m,A);if(v.has(D))return!0;v.add(D)}return!1}function Sf(M,m,v,A,D=!1,z=void 0){const B=m.sourceCache.transform,W=m.sourceCache.tilesIn(M,m.has3DLayers,D);W.sort(Bx);const ee=[];for(const ne of W){const de=ne.tile.queryRenderedFeatures(m,ne,v,A,B,D,z);Object.keys(de).length&&ee.push({wrappedTileID:ne.tile.tileID.wrapped().key,queryResults:de})}for(const ne in m.layers){const de=m.layers[ne];if(de.styleLayer){const be=de.styleLayer.queryRenderedFeatures(M,m.sourceCache,A);Object.keys(be).length&&ee.push({wrappedTileID:0,queryResults:be})}}return ee.length===0?{}:function(ne){const de={},be={};for(const ye of ne){const Ce=ye.queryResults,Be=ye.wrappedTileID,Ie=be[Be]=be[Be]||{};for(const st in Ce){const tt=Ce[st],ct=Ie[st]=Ie[st]||{},mt=de[st]=de[st]||[];for(const nt of tt)ct[nt.featureIndex]||(ct[nt.featureIndex]=!0,mt.push(nt))}}return de}(ee)}function zx(M,m,v,A,D,z){const B={},W=A.queryRenderedSymbols(M),ee=[];for(const ne of Object.keys(W).map(Number))ee.push(D[ne]);ee.sort(Bx);for(const ne of ee){const de=ne.featureIndex.lookupSymbolFeatures(W[ne.bucketInstanceId],ne.bucketIndex,ne.sourceLayerIndex,m,v,z);for(const be in de){const ye=B[be]=B[be]||[],Ce=de[be];Ce.sort((Be,Ie)=>{const st=ne.featureSortOrder;if(st){const tt=st.indexOf(Be.featureIndex);return st.indexOf(Ie.featureIndex)-tt}return Ie.featureIndex-Be.featureIndex});for(const Be of Ce)ye.push(Be)}}return B}function Cd(M,m){const v=M.getRenderableIds().map(z=>M.getTileByID(z)),A=[],D={};for(let z=0;z{if(z)v(z);else try{const ee=A.getHeaderLength(B);if(ee>m)return void(this.request=this.fetchHeader(ee,v));A.parseHeader(B),this._isHeaderLoaded=!0;let ne=0;for(const de of Object.values(A.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(ee){v(ee)}}),this.request}fetchBandForRender(m,v,A,D){this.fetchBand(m,v,A,z=>{if(z)return void D(z);this.updateTextureDescriptor(m,v,A);const B=this.textureDescriptorPerLayer.get(v);D(null,B?B.img:null)})}fetchBand(m,v,A,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 ee;const ne=i.F(String(A),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 be=(Ie,st)=>{ee.complete(Ie,st),Ie?D(Ie):(de.forEach(tt=>tt(null,st)),this._taskQueue.delete(ne))},ye=(Ie,st)=>{if(Ie)return D(Ie);const tt=W.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:st,task:ee},be,void 0,!0);if(v!==null){const ct=this._workQueuePerLayer.get(v)||[];ct.push(()=>{tt&&tt.cancel(),ee.cancel()}),this._workQueuePerLayer.has(v)||this._workQueuePerLayer.set(v,ct)}};let Ce;try{Ce=B.getLayer(m)}catch(Ie){if(this.state==="reloading")return;throw Ie}if(!Ce)return void D(new Error(`Unknown sourceLayer "${m}"`));if(Ce.hasDataForBand(A))return de.forEach(Ie=>Ie(null,null)),void this._taskQueue.delete(ne);const Be=Ce.getDataRange([A]);if(ee=B.createDecodingTask(Be),!ee||ee.tasks.length)if(v!==null&&this.flushQueues(v),this.entireBuffer)ye(null,this.entireBuffer.slice(Be.firstByte,Be.lastByte+1));else{const Ie=Object.assign({},this.requestParams,{headers:{Range:`bytes=${Be.firstByte}-${Be.lastByte}`}}),st=i.b1(Ie,ye);if(v!==null){const tt=this._fetchQueuePerLayer.get(v)||[];tt.push(()=>{st.cancel(),ee.cancel()}),this._fetchQueuePerLayer.has(v)||this._fetchQueuePerLayer.set(v,tt)}}}updateNeeded(m,v){return(!this.textureDescriptorPerLayer.get(m)||this.textureDescriptorPerLayer.get(m).band!==v||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(m,v,A){if(!this._mrt)return;const D=this._mrt.getLayer(m);if(!D||!D.hasBand(A)||!D.hasDataForBand(A))return;const{bytes:z,tileSize:B,buffer:W,offset:ee,scale:ne}=D.getBandView(A),de=B+2*W,be=new i.q({width:de,height:de},z),ye=this.texturePerLayer.get(v);ye&&ye instanceof i.T&&ye.update(be,{premultiply:!1}),this.textureDescriptorPerLayer.set(v,{layer:m,band:A,img:be,buffer:W,offset:ee,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 Hd{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,A){const D=m.wrapped().key;this.data[D]===void 0&&(this.data[D]=[]);const z={value:v,timeout:void 0};if(A!==void 0&&(z.timeout=setTimeout(()=>{this.remove(m,z)},A)),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 A=m.wrapped().key,D=v===void 0?0:this.data[A].indexOf(v),z=this.data[A][D];return this.data[A].splice(D,1),z.timeout&&clearTimeout(z.timeout),this.data[A].length===0&&delete this.data[A],this.onRemove(z.value),this.order.splice(this.order.indexOf(A),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 A in this.data)for(const D of this.data[A])m(D.value)||v.push(D);for(const A of v)this.remove(A.value.tileID,A)}}class Tw{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(m,v,A){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],A),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])A[z]||(this.deletedStates[m][D][z]=null)}else for(const z in A)this.deletedStates[m]&&this.deletedStates[m][D]&&this.deletedStates[m][D][z]===null&&delete this.deletedStates[m][D][z]}removeFeatureState(m,v,A){if(this.deletedStates[m]===null)return;const D=String(v);if(this.deletedStates[m]=this.deletedStates[m]||{},A&&v!==void 0)this.deletedStates[m][D]!==null&&(this.deletedStates[m][D]=this.deletedStates[m][D]||{},this.deletedStates[m][D][A]=null);else if(v!==void 0)if(this.stateChanges[m]&&this.stateChanges[m][D])for(A in this.deletedStates[m][D]={},this.stateChanges[m][D])this.deletedStates[m][D][A]=null;else this.deletedStates[m][D]=null;else this.deletedStates[m]=null}getState(m,v){const A=this.state[m]||{},D=this.stateChanges[m]||{},z=this.deletedStates[m];if(z===null)return{};if(v!==void 0){const W=String(v),ee=Object.assign({},A[W],D[W]);if(z){const ne=z[v];if(ne===null)return{};for(const de in ne)delete ee[de]}return ee}const B=Object.assign({},A,D);if(z)for(const W in z)delete B[W];return B}initializeTileState(m,v){m.refreshFeatureState(v)}coalesceChanges(m,v){const A={};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];A[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]}A[D]=A[D]||{},Object.assign(A[D],z)}if(this.stateChanges={},this.deletedStates={},Object.keys(A).length!==0)for(const D in m)m[D].refreshFeatureState(v,A)}}class gh extends i.E{constructor(m,v,A){super(),this.id=m,this._renderSourceType=A,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 Hd(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 Tw,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 A=this._tiles[v];A.upload(m,this.map?this.map.painter:void 0),A.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(m=>m.tileID).sort(Xg).map(m=>m.key)}getRenderableIds(m,v){const A=[];for(const D in this._tiles)this._isIdRenderable(+D,m,v)&&A.push(this._tiles[D]);return m?A.sort((D,z)=>{const B=D.tileID,W=z.tileID,ee=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-ee.y||ne.x-ee.x}).map(D=>D.tileID.key):A.map(D=>D.tileID).sort(Xg).map(D=>D.key)}hasRenderableParent(m){const v=this.findLoadedParent(m,0);return!!v&&this._isIdRenderable(v.tileID.key)}_isIdRenderable(m,v,A){return this._tiles[m]&&this._tiles[m].hasData()&&!this._coveredTiles[m]&&(v||!this._tiles[m].holdingForFade())&&(A||!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 A=this._tiles[m];A&&(A.state!=="loading"&&(A.state=v),this._loadTile(A,this._tileLoaded.bind(this,A,m,v)))}_tileLoaded(m,v,A,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(),A==="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+ee)===1?B+=ee:Math.abs(B-ee)===1&&(B-=ee)),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,A,D){for(const z in this._tiles){let B=this._tiles[z];if(D[z]||!B.hasData()||B.tileID.overscaledZ<=v||B.tileID.overscaledZ>A)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 ee=W;for(;ee.overscaledZ>v;)if(ee=ee.scaledTo(ee.overscaledZ-1),m[ee.key]){D[W.key]=W;break}}}findLoadedParent(m,v){if(m.key in this._loadedParentTiles){const A=this._loadedParentTiles[m.key];return A&&A.tileID.overscaledZ>=v?A:null}for(let A=m.overscaledZ-1;A>=v;A--){const D=m.scaledTo(A),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 A=Math.ceil(m.width/v)+1,D=Math.ceil(m.height/v)+1,z=Math.floor(A*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 A={};for(const D in this._tiles){const z=this._tiles[D];z.tileID=z.tileID.unwrapTo(z.tileID.wrap+v),A[z.tileID.key]=z}this._tiles=A;for(const D in this._timers)clearTimeout(this._timers[D]),delete this._timers[D];for(const D in this._tiles)this._setTileReloadTimer(+D,this._tiles[D])}}update(m,v,A,D,z){if(this.transform=m,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!A)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,ee=this._source.maxzoom;this._maxzoomOverride!==null&&(ee=Math.min(ee,this._maxzoomOverride));const ne=this.map&&this.map.painter?this.map.painter._terrain:null;if(ne&&ne.sourceCache===this&&ne.attenuationRange()){const Ce=ne.attenuationRange()[0],Be=Math.floor(Ce)-Math.log2(ne.getDemUpscale());ee>Be&&(ee=Be)}const de=this._maxzoomOverride===null&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)W=m.getVisibleUnwrappedCoordinates(this._source.tileID).map(Ce=>new i.aR(Ce.canonical.z,Ce.wrap,Ce.canonical.z,Ce.canonical.x,Ce.canonical.y));else if(this.tileCoverLift!==0){const Ce=m.clone();Ce.tileCoverLift=this.tileCoverLift,W=Ce.coveringTiles({tileSize:v||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:ee,roundZoom:this._source.roundZoom&&!A,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:ee,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:de,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:B}),this._source.hasTile){const Ce=this._source.hasTile.bind(this._source);W=W.filter(Be=>Ce(Be))}}else W=[];if(W.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!this._supportsFading){const Ce=m.coveringZoomLevel({tileSize:v||this._source.tileSize,roundZoom:this._source.roundZoom&&!A}),Be=Math.min(Ce,ee);if(B){const Ie=m.extendTileCover(W,Be);for(const st of Ie)W.push(st)}else if(z){const Ie=this.transform.getFrustum(Be),st=m.extendTileCoverToNearPlane(W,Ie,Be);for(const tt of st)W.push(tt);if(Be>=18&&this._hasTunnelGeometry()){const tt=m.extendTileCoverForTunnels(W,Ie,Be,20);for(const ct of tt)W.push(ct)}}else if(this.castsShadows&&D){const Ie=m.extendTileCover(W,Be,D,16);for(const st of Ie)this._shadowCasterTiles[st.key]=!0,W.push(st)}}const be=this._updateRetainedTiles(W);if(this._supportsFading&&W.length!==0){const Ce={},Be={},Ie=i.o.now(),st=Object.keys(be);for(const ct of st){const mt=be[ct],nt=this._tiles[ct];if(!nt||nt.fadeEndTime!==void 0&&nt.fadeEndTime<=Ie)continue;const Ft=this.findLoadedParent(mt,Math.max(mt.overscaledZ-gh.maxOverzooming,this._source.minzoom));Ft&&(this._addTile(Ft.tileID),Ce[Ft.tileID.key]=Ft.tileID),Be[ct]=mt}const tt=W[W.length-1].overscaledZ;for(const ct in this._tiles){const mt=this._tiles[ct];if(be[ct]||!mt.hasData())continue;let nt=mt.tileID;for(;nt.overscaledZ>tt;){nt=nt.scaledTo(nt.overscaledZ-1);const Ft=this._tiles[nt.key];if(Ft&&Ft.hasData()&&Be[nt.key]){be[ct]=mt.tileID;break}}}for(const ct in Ce)be[ct]||(this._coveredTiles[ct]=!0,be[ct]=Ce[ct])}for(const Ce in be)this._tiles[Ce].clearFadeHold();const ye=i.b3(this._tiles,be);for(const Ce of ye){const Be=this._tiles[Ce];Be.hasSymbolBuckets&&!Be.holdingForFade()?Be.setHoldDuration(this.map._fadeDuration):Be.hasSymbolBuckets&&!Be.symbolFadeFinished()||this._removeTile(+Ce)}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 A={},D=m.reduce((ne,de)=>Math.min(ne,de.overscaledZ),1/0),z=m[0].overscaledZ,B=Math.max(z-gh.maxOverzooming,this._source.minzoom),W=Math.max(z+gh.maxUnderzooming,this._source.minzoom),ee={};for(const ne of m){const de=this._addTile(ne);v[ne.key]=ne,de.hasData()||D=this._source.maxzoom){const ye=ne.children(this._source.maxzoom)[0],Ce=this.getTile(ye);if(Ce&&Ce.hasData()){v[ye.key]=ye;continue}}else{const ye=ne.children(this._source.maxzoom);if(v[ye[0].key]&&v[ye[1].key]&&v[ye[2].key]&&v[ye[3].key])continue}let be=de.wasRequested();for(let ye=ne.overscaledZ-1;ye>=B;--ye){const Ce=ne.scaledTo(ye);if(A[Ce.key]||(A[Ce.key]=!0,de=this.getTile(Ce),!de&&be&&(de=this._addTile(Ce)),de&&(v[Ce.key]=Ce,be=de.wasRequested(),de.hasData())))break}}return v}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const m in this._tiles){const v=[];let A,D=this._tiles[m].tileID;for(;D.overscaledZ>0;){if(D.key in this._loadedParentTiles){A=this._loadedParentTiles[D.key];break}v.push(D.key);const z=D.scaledTo(D.overscaledZ-1);if(A=this._getLoadedTile(z),A)break;D=z}for(const z of v)this._loadedParentTiles[z]=A}}_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 A=!!v;if(!A){const D=this.map?this.map.painter:null,z=this._source.tileSize*m.overscaleFactor();v=this._source.type==="raster-array"?new Cp(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,A||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 A=v.getExpiryTimeout();A&&(this._timers[m]=setTimeout(()=>{this._reloadTile(m,"expired"),delete this._timers[m]},A))}_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,A){const D=[],z=this.transform;if(!z)return D;const B=z.projection.name==="globe",W=i.aH(z.center.lng);for(const ee in this._tiles){const ne=this._tiles[ee];if(A&&ne.clearQueryDebugViz(),ne.holdingForFade())continue;let de;if(B){const be=ne.tileID.canonical;if(be.z===0){const ye=[Math.abs(i.aC(W,...Cf(be,-1))-W),Math.abs(i.aC(W,...Cf(be,1))-W)];de=[0,2*ye.indexOf(Math.min(...ye))-1]}else{const ye=[Math.abs(i.aC(W,...Cf(be,-1))-W),Math.abs(i.aC(W,...Cf(be,0))-W),Math.abs(i.aC(W,...Cf(be,1))-W)];de=[ye.indexOf(Math.min(...ye))-1]}}else de=[0];for(const be of de){const ye=m.containsTile(ne,z,v,be);ye&&D.push(ye)}}return D}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(m){return this._getRenderableCoordinates(m)}_getRenderableCoordinates(m,v){const A=this.getRenderableIds(m,v).map(z=>this._tiles[z].tileID),D=this.transform.projection.name==="globe";for(const z of A)z.projMatrix=this.transform.calculateProjMatrix(z.toUnwrapped()),z.expandedProjMatrix=D?this.transform.calculateProjMatrix(z.toUnwrapped(),!1,!0):z.projMatrix;return A}sortCoordinatesByDistance(m){const v=m.slice(),A=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 A=this._tiles[v];if(A.fadeEndTime!==void 0&&A.fadeEndTime>=m)return!0}}return!1}setFeatureState(m,v,A){this._state.updateState(m=m||"_geojsonTileLayer",v,A)}removeFeatureState(m,v,A){this._state.removeFeatureState(m=m||"_geojsonTileLayer",v,A)}getFeatureState(m,v){return this._state.getState(m=m||"_geojsonTileLayer",v)}setDependencies(m,v,A){const D=this._tiles[m];D&&D.setDependencies(v,A)}reloadTilesForDependencies(m,v){for(const A in this._tiles)this._tiles[A].hasDependency(m,v)&&this._reloadTile(+A,"reloading");this._cache.filter(A=>!A.hasDependency(m,v))}_preloadTiles(m,v){if(!this._sourceLoaded){const ee=()=>{this._sourceLoaded&&(this._source.off("data",ee),this._preloadTiles(m,v))};return void this._source.on("data",ee)}const A=new Map,D=Array.isArray(m)?m:[m],z=this.map.painter.terrain,B=this.usedForTerrain&&z?z.getScaledDemTileSize():this._source.tileSize;for(const ee of D){const ne=ee.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)A.set(de.key,de);this.usedForTerrain&&ee.updateElevation(!1)}const W=Array.from(A.values());i.t(W,(ee,ne)=>{const de=new i.b0(ee,this._source.tileSize*ee.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(de,be=>{this._source.type==="raster-dem"&&de.dem&&this._backfillDEM(de),ne(be,de)})},v)}}function Xg(M,m){const v=Math.abs(2*M.wrap)-+(M.wrap<0),A=Math.abs(2*m.wrap)-+(m.wrap<0);return M.overscaledZ-m.overscaledZ||A-v||m.canonical.y-M.canonical.y||m.canonical.x-M.canonical.x}function Cf(M,m){const v=1<0:A.type==="building"?D=!A.isHidden(m)&&A.paint.get("building-opacity")>0:A.type==="model"&&(D=!A.isHidden(m)&&A.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 ee=B?B.getTile(v):null;if(!ee&&B)for(const ne in B._tiles){const de=B._tiles[ne];if(v.canonical.isChildOf(de.tileID.canonical)){ee=de;break}}this.currentBuildingBuckets.push({bucket:ee?ee.getBucket(z):null,tileID:ee?ee.tileID:v,verticalScale:W})}m.hasAnyZOffset=!1;let A=!1;for(let D=0;D{A in m&&(v[A]=m[A])}),v}function A1(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-ee).add(this.points[v].mult(ee))}}class kt{constructor(m,v,A){const D=this.boxCells=[],z=this.circleCells=[];this.xCellCount=Math.ceil(m/A),this.yCellCount=Math.ceil(v/A);for(let B=0;Bthis.width||D<0||v>this.height)return!z&&[];const W=[];if(m<=0&&v<=0&&this.width<=A&&this.height<=D){if(z)return!0;for(let ee=0;ee0:W}_queryCircle(m,v,A,D,z){const B=m-A,W=m+A,ee=v-A,ne=v+A;if(W<0||B>this.width||ne<0||ee>this.height)return!D&&[];const de=[];return this._forEachCell(B,ee,W,ne,this._queryCellCircle,de,{hitTest:D,circle:{x:m,y:v,radius:A},seenUids:{box:{},circle:{}}},z),D?de.length>0:de}query(m,v,A,D,z){return this._query(m,v,A,D,!1,z)}hitTest(m,v,A,D,z){return this._query(m,v,A,D,!0,z)}hitTestCircle(m,v,A,D){return this._queryCircle(m,v,A,!0,D)}_queryCell(m,v,A,D,z,B,W,ee){const ne=W.seenUids,de=this.boxCells[z];if(de!==null){const ye=this.bboxes;for(const Ce of de)if(!ne.box[Ce]){ne.box[Ce]=!0;const Be=4*Ce;if(m<=ye[Be+2]&&v<=ye[Be+3]&&A>=ye[Be+0]&&D>=ye[Be+1]&&(!ee||ee(this.boxKeys[Ce]))){if(W.hitTest)return B.push(!0),!0;B.push({key:this.boxKeys[Ce],x1:ye[Be],y1:ye[Be+1],x2:ye[Be+2],y2:ye[Be+3]})}}}const be=this.circleCells[z];if(be!==null){const ye=this.circles;for(const Ce of be)if(!ne.circle[Ce]){ne.circle[Ce]=!0;const Be=3*Ce;if(this._circleAndRectCollide(ye[Be],ye[Be+1],ye[Be+2],m,v,A,D)&&(!ee||ee(this.circleKeys[Ce]))){if(W.hitTest)return B.push(!0),!0;{const Ie=ye[Be],st=ye[Be+1],tt=ye[Be+2];B.push({key:this.circleKeys[Ce],x1:Ie-tt,y1:st-tt,x2:Ie+tt,y2:st+tt})}}}}}_queryCellCircle(m,v,A,D,z,B,W,ee){const ne=W.circle,de=W.seenUids,be=this.boxCells[z];if(be!==null){const Ce=this.bboxes;for(const Be of be)if(!de.box[Be]){de.box[Be]=!0;const Ie=4*Be;if(this._circleAndRectCollide(ne.x,ne.y,ne.radius,Ce[Ie+0],Ce[Ie+1],Ce[Ie+2],Ce[Ie+3])&&(!ee||ee(this.boxKeys[Be])))return B.push(!0),!0}}const ye=this.circleCells[z];if(ye!==null){const Ce=this.circles;for(const Be of ye)if(!de.circle[Be]){de.circle[Be]=!0;const Ie=3*Be;if(this._circlesCollide(Ce[Ie],Ce[Ie+1],Ce[Ie+2],ne.x,ne.y,ne.radius)&&(!ee||ee(this.circleKeys[Be])))return B.push(!0),!0}}}_forEachCell(m,v,A,D,z,B,W,ee){const ne=this._convertToXCellCoord(m),de=this._convertToYCellCoord(v),be=this._convertToXCellCoord(A),ye=this._convertToYCellCoord(D);for(let Ce=ne;Ce<=be;Ce++)for(let Be=de;Be<=ye;Be++)if(z.call(this,m,v,A,D,this.xCellCount*Be+Ce,B,W,ee))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,A,D,z,B){const W=D-m,ee=z-v,ne=A+B;return ne*ne>W*W+ee*ee}_circleAndRectCollide(m,v,A,D,z,B,W){const ee=(B-D)/2,ne=Math.abs(m-(D+ee));if(ne>ee+A)return!1;const de=(W-z)/2,be=Math.abs(v-(z+de));if(be>de+A)return!1;if(ne<=ee||be<=de)return!0;const ye=ne-ee,Ce=be-de;return ye*ye+Ce*Ce<=A*A}}const Ds=Math.tan(85*Math.PI/180);function nr(M,m,v,A,D,z,B){const W=i.bb();if(v)if(z.name==="globe"){const ee=i.bc(D,m);i.aD(W,W,ee)}else{const ee=i.bd([],B);W[0]=ee[0],W[1]=ee[1],W[4]=ee[2],W[5]=ee[3],A||i.ba(W,W,D.angle)}else i.aD(W,D.labelPlaneMatrix,M);return W}function Jr(M,m,v,A,D,z,B){const W=nr(M,m,v,A,D,z,B);return z.name==="globe"&&v||(W[2]=W[6]=W[10]=W[14]=0),W}function pn(M,m,v,A,D,z,B){if(v){if(z.name==="globe"){const W=nr(M,m,v,A,D,z,B);return i.b7(W,W),i.aD(W,M,W),W}{const W=i.b8(M),ee=i.b9([]);return ee[0]=B[0],ee[1]=B[1],ee[4]=B[2],ee[5]=B[3],i.aD(W,W,ee),A||i.ba(W,W,-D.angle),W}}return D.glCoordMatrix}function oa(M,m,v,A){const D=[M,m,v,1];v?i.aE(D,D,A):sn(D,D,A);const z=D[3];return D[0]/=z,D[1]/=z,D[2]/=z,D}function xa(M,m){return Math.min(.5+M/m*.5,1.5)}function Ai(M,m){const v=M[0]/M[3],A=M[1]/M[3];return v>=-m[0]&&v<=m[0]&&A>=-m[1]&&A<=m[1]}function kc(M,m,v,A,D,z,B,W,ee,ne,de=1){const be=v.transform,ye=A?M.textSizeData:M.iconSizeData,Ce=i.bj(ye,v.transform.zoom,de),Be=be.projection.name==="globe",Ie=[256/v.width*2+1,256/v.height*2+1],st=A?M.text.dynamicLayoutVertexArray:M.icon.dynamicLayoutVertexArray;st.clear();let tt=null;Be&&(tt=A?M.text.globeExtVertexArray:M.icon.globeExtVertexArray);const ct=M.lineVertexArray,mt=A?M.text.placedSymbolArray:M.icon.placedSymbolArray,nt=v.transform.width/v.transform.height;let Ft,wt=!1;for(let Dt=0;DtMath.abs(v)?{useVertical:!0}:M===i.bk.vertical?A>0?{needsFlipping:!0}:null:m!==0&&function(D,z){return D===0||Math.abs(z/D)>Ds}(v,A)?m===1?{needsFlipping:!0}:null:v<0?{needsFlipping:!0}:null}function D0(M,m,v,A,D,z,B,W,ee,ne,de,be,ye,Ce,Be,Ie,st,tt,ct,mt){const nt=m/24,Ft=M.lineOffsetX*nt,wt=M.lineOffsetY*nt,{lineStartIndex:Dt,glyphStartIndex:pt,numGlyphs:yt,segment:Tt,writingMode:Wt,flipState:Bt}=M,ns=Dt+M.lineLength,Qt=ws=>{if(de){const[ts,as,cs]=ws.up,Qs=ne.length;i.bm(de,Qs+0,ts,as,cs),i.bm(de,Qs+1,ts,as,cs),i.bm(de,Qs+2,ts,as,cs),i.bm(de,Qs+3,ts,as,cs)}const[As,Zt,Ut]=ws.point;i.bn(ne,As,Zt,Ut,ws.angle)};if(yt>1){const ws=Bm(nt,W,Ft,wt,v,be,ye,M,ee,z,Ce,Ie,!1,st,tt,ct,mt);if(!ws)return{notEnoughRoom:!0};if(A&&!v){let[As,Zt,Ut]=ws.first.point,[ts,as,cs]=ws.last.point;[As,Zt]=oa(As,Zt,Ut,B),[ts,as]=oa(ts,as,cs,B);const Qs=Zh(Wt,Bt,(ts-As)*Be,as-Zt);if(M.flipState=Qs&&Qs.needsFlipping?1:2,Qs)return Qs}Qt(ws.first);for(let As=pt+1;As0?ts:LE(ye,Ut,As,1,D,void 0,st,tt.canonical),cs=Zh(Wt,Bt,(as[0]-As[0])*Be,as[1]-As[1]);if(M.flipState=cs&&cs.needsFlipping?1:2,cs)return cs}const ws=LC(nt*W.getoffsetX(pt),Ft,wt,v,be,ye,Tt,Dt,ns,ee,z,Ce,Ie,!1,!1,st,tt,ct,mt);if(!ws)return{notEnoughRoom:!0};Qt(ws)}return{}}function Ea(M,m,v,A,D){const{x:z,y:B,z:W}=A.projectTilePoint(M.x,M.y,m);if(!D)return oa(z,B,W,v);const[ee,ne,de]=D.getElevation(M,D.elevation,D.elevationFeature);return oa(z+ee,B+ne,W+de,v)}function LE(M,m,v,A,D,z,B,W){const ee=Ea(M.sub(m)._unit()._add(M),W,D,B,z);return i.ax(ee,v,ee),i.ay(ee,ee),i.bg(ee,v,ee,A)}function LC(M,m,v,A,D,z,B,W,ee,ne,de,be,ye,Ce,Be,Ie,st,tt,ct){const mt=A?M-m:M+m;let nt=mt>0?1:-1,Ft=0;A&&(nt*=-1,Ft=Math.PI),nt<0&&(Ft+=Math.PI);let wt=W+B+(nt>0?0:1)|0,Dt=D,pt=D,yt=0,Tt=0;const Wt=Math.abs(mt),Bt=[],ns=[];let Qt=z,ws=Qt,As=i.be([]);const Zt=()=>LE(ws,Qt,pt,Wt-yt+1,de,ye,Ie,st.canonical);for(;yt+Tt<=Wt;){if(wt+=nt,wt=ee)return null;if(pt=Dt,ws=Qt,Bt.push(pt),Ce&&ns.push(ws),Qt=new i.P(ne.getx(wt),ne.gety(wt)),Dt=be[wt],!Dt){const Ar=Ea(Qt,st.canonical,de,Ie,ye);Dt=Ar[3]>0?be[wt]=Ar:Zt()}yt+=Tt;const Cs=i.ax([],Dt,pt),br=i.bf(pt,Dt);if(v&&br>0&&Tt>0&&i.bi(As,Cs)/(Tt*br)0,mt),Dt=ne*wt.perspectiveRatio,pt=(A.x1*v+W.x-A.padding)*Dt+wt.point.x,yt=(A.y1*v+W.y-A.padding)*Dt+wt.point.y,Tt=(A.x2*v+W.x+A.padding)*Dt+wt.point.x,Wt=(A.y2*v+W.y+A.padding)*Dt+wt.point.y,Bt=wt.perspectiveRatio<=.55||wt.occluded;return!this.isInsideGrid(pt,yt,Tt,Wt)||!ee&&this.grid.hitTest(pt,yt,Tt,Wt,be)||Bt?{box:[],offscreen:!1,occluded:wt.occluded}:{box:[pt,yt,Tt,Wt],offscreen:this.isOffscreen(pt,yt,Tt,Wt),occluded:!1}}placeCollisionCircles(m,v,A,D,z,B,W,ee,ne,de,be,ye,Ce,Be,Ie,st){const tt=[],ct=this.transform.elevation,mt=m.getProjection(),nt=m.elevationType==="road",Ft=!!ct||nt,wt=i.bu.getAtTileOffsetFunc(st,this.transform.center.lat,this.transform.worldSize,mt),Dt=new i.P(A.tileAnchorX,A.tileAnchorY),pt=new i.P(A.tileAnchorX,A.tileAnchorY);let{x:yt,y:Tt,z:Wt}=mt.projectTilePoint(pt.x,pt.y,st.canonical),Bt=null;if(Ft){const br=nt?m.getElevationFeatureForText(D):null;Bt={getElevation:wt,elevation:ct,elevationFeature:br};const[Ar,mr,yr]=wt(Dt,ct,br);yt+=Ar,Tt+=mr,Wt+=yr}const ns=mt.name==="globe",Qt=this.projectAndGetPerspectiveRatio(ee,yt,Tt,Wt,st,ns||!!ct||this.transform.pitch>0,mt),{perspectiveRatio:ws}=Qt,As=(ye?W/ws:W*ws)/i.by,Zt=oa(yt,Tt,Wt,ne),Ut=A.lineOffsetX*As,ts=A.lineOffsetY*As,as=i.ap(m.layers[0].layout.get("text-max-angle")),cs=Math.cos(as),Qs=Qt.signedDistanceFromCamera>0?Bm(As,B,Ut,ts,nt&&A.flipState===1,Zt,pt,A,z,ne,{},Ft&&!ye?Bt:null,ye&&Ft,mt,st,ye,cs):null;let Hs=!1,Gs=!1,Cs=!0;if(Qs&&!Qt.occluded){const br=.5*Be*ws+Ie,Ar=new i.P(-100,-100),mr=new i.P(this.screenRightBoundary,this.screenBottomBoundary),yr=new IC,{first:Zr,last:xn}=Qs,un=Zr.path.length;let $n=[];for(let hn=un-1;hn>=1;hn--)$n.push(Zr.path[hn]);for(let hn=1;hn(Ft&&!ns&&(hi=wt(Gihn[3]<=0)&&($n=[]));let qn=[];if($n.length>0){let hn=1/0,Pa=-1/0,hi=1/0,Gi=-1/0;for(const wi of $n)hn=Math.min(hn,wi[0]),hi=Math.min(hi,wi[1]),Pa=Math.max(Pa,wi[0]),Gi=Math.max(Gi,wi[1]);Pa>=Ar.x&&hn<=mr.x&&Gi>=Ar.y&&hi<=mr.y&&(qn=[$n.map(wi=>new i.P(wi[0],wi[1]))],(hnmr.x||himr.y)&&(qn=i.bv(qn,Ar.x,Ar.y,mr.x,mr.y)))}for(const hn of qn){yr.reset(hn,.25*br);let Pa=0;Pa=yr.length<=.5*br?1:Math.ceil(yr.paddedLength/qr)+1;for(let hi=0;hi0?(i.aE(ee,ee,m),this.fogState&&z&&W.name!=="globe"&&(ne=function(ye,Ce,Be,Ie,st,tt){const ct=tt.calculateFogTileMatrix(st),mt=[Ce,Be,Ie];return i.ah(mt,mt,ct),da(ye,i.ai(mt),tt.pitch,tt._fov)}(this.fogState,v,A,D,z.toUnwrapped(),this.transform)>.9)):sn(ee,ee,m);const de=ee[3];return{point:new i.P((ee[0]/de+1)/2*this.transform.width+Mp,(-ee[1]/de+1)/2*this.transform.height+Mp),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(W)/de*.5,1.5),signedDistanceFromCamera:de,occluded:B&&ee[2]>de||ne}}isOffscreen(m,v,A,D){return A=this.screenRightBoundary||Dthis.screenBottomBoundary}isInsideGrid(m,v,A,D){return A>=0&&m=0&&vA.collisionGroupID===v}}return this.collisionGroups[m]}}function ju(M,m,v,A,D){const{horizontalAlign:z,verticalAlign:B}=i.bF(M),W=-(z-.5)*m,ee=-(B-.5)*v,ne=i.bG(M,A);return new i.P(W+ne[0]*D,ee+ne[1]*D)}function ty(M,m,v,A,D){const z=new i.P(M,m);return v&&z._rotate(A?D:-D),z}class oi{constructor(m,v,A,D,z,B){this.transform=m.clone(),this.projection=m.projection.name,this.collisionIndex=new DC(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(A),this.collisionCircleArrays={},this.prevPlacement=D,D&&(D.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(m,v,A,D,z=1){const B=A.getBucket(v),W=A.latestFeatureIndex;if(!B||!W||v.fqid!==B.layerIds[0])return;const ee=B.layers[0].layout,ne=B.layers[0].paint,de=A.collisionBoxArray,be=Math.pow(2,this.transform.zoom-A.tileID.overscaledZ),ye=A.tileSize/i.an,Ce=A.tileID.toUnwrapped();this.transform.setProjection(B.projection);const Be=(Ie=A.tileID,st=B.getProjection(),tt=this.transform,st.name===this.projection?tt.calculateProjMatrix(Ie.toUnwrapped()):E1(tt,st,Ie));var Ie,st,tt;const ct=ee.get("text-pitch-alignment")==="map",mt=ee.get("text-rotation-alignment")==="map";v.compileFilter(v.options);const nt=v.dynamicFilter(),Ft=v.dynamicFilterNeedsFeature(),wt=v.dynamicFilterNeedsGeometry(),Dt=this.transform.calculatePixelsToTileUnitsMatrix(A),pt=Jr(Be,A.tileID.canonical,ct,mt,this.transform,B.getProjection(),Dt);let yt=null;const Tt=B.getProjection().createInversionMatrix(this.transform,A.tileID.canonical);if(ct){const ts=pn(Be,A.tileID.canonical,ct,mt,this.transform,B.getProjection(),Dt);yt=i.aD([],this.transform.labelPlaneMatrix,ts)}let Wt=null;nt&&A.latestFeatureIndex&&(Wt={unwrappedTileID:Ce,dynamicFilter:nt,dynamicFilterNeedsFeature:Ft,needGeometry:wt}),this.retainedQueryData[B.bucketInstanceId]=new si(B.bucketInstanceId,W,B.sourceLayerIndex,B.index,A.tileID);const[Bt,ns]=B.layers[0].layout.get("text-size-scale-range"),Qt=i.aC(z,Bt,ns),[ws,As]=ee.get("icon-size-scale-range"),Zt=i.aC(z,ws,As),Ut={bucket:B,layout:ee,paint:ne,posMatrix:Be,invMatrix:Tt,mercatorCenter:[i.aH(this.transform.center.lng),i.aL(this.transform.center.lat)],textLabelPlaneMatrix:pt,labelToScreenMatrix:yt,clippingData:Wt,scale:be,textPixelRatio:ye,holdingForFade:A.holdingForFade(),collisionBoxArray:de,partiallyEvaluatedTextSize:i.bj(B.textSizeData,this.transform.zoom,Qt),partiallyEvaluatedIconSize:i.bj(B.iconSizeData,this.transform.zoom,Zt),collisionGroup:this.collisionGroups.get(B.sourceID),latestFeatureIndex:A.latestFeatureIndex};if(D)for(const ts of B.sortKeyRanges){const{sortKey:as,symbolInstanceStart:cs,symbolInstanceEnd:Qs}=ts;m.push({sortKey:as,symbolInstanceStart:cs,symbolInstanceEnd:Qs,parameters:Ut})}else m.push({symbolInstanceStart:0,symbolInstanceEnd:B.symbolInstances.length,parameters:Ut})}attemptAnchorPlacement(m,v,A,D,z,B,W,ee,ne,de,be,ye,Ce,Be,Ie,st,tt,ct,mt,nt,Ft){const{textOffset0:wt,textOffset1:Dt,crossTileID:pt}=Ie,yt=[wt,Dt],Tt=ju(m,B,W,yt,ee),Wt=this.collisionIndex.placeCollisionBox(tt,ee,v,A,D,z,ty(Tt.x,Tt.y,ne,de,this.transform.angle),Be,be,ye,Ce.predicate);if(mt){const Bt=tt.getSymbolInstanceIconSize(Ft,this.transform.zoom,Ie.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(tt,Bt,mt,A,D,z,ty(Tt.x,Tt.y,ne,de,this.transform.angle),Be,be,ye,Ce.predicate).box.length===0)return}if(Wt.box.length>0){let Bt;return this.prevPlacement&&this.prevPlacement.variableOffsets[pt]&&this.prevPlacement.placements[pt]&&this.prevPlacement.placements[pt].text&&(Bt=this.prevPlacement.variableOffsets[pt].anchor),this.variableOffsets[pt]={textOffset:yt,width:B,height:W,anchor:m,textScale:ee,prevAnchor:Bt},this.markUsedJustification(tt,m,Ie,ct),tt.allowVerticalPlacement&&(this.markUsedOrientation(tt,ct,Ie),this.placedOrientations[pt]=ct),{shift:Tt,placedGlyphBoxes:Wt}}}placeLayerBucketPart(m,v,A,D,z=1){const{bucket:B,layout:W,paint:ee,posMatrix:ne,textLabelPlaneMatrix:de,labelToScreenMatrix:be,clippingData:ye,textPixelRatio:Ce,mercatorCenter:Be,invMatrix:Ie,holdingForFade:st,collisionBoxArray:tt,partiallyEvaluatedTextSize:ct,partiallyEvaluatedIconSize:mt,collisionGroup:nt,latestFeatureIndex:Ft}=m.parameters,wt=W.get("text-optional"),Dt=W.get("icon-optional"),pt=W.get("text-allow-overlap"),yt=W.get("icon-allow-overlap"),Tt=W.get("text-rotation-alignment")==="map",Wt=W.get("icon-rotation-alignment")==="map",Bt=W.get("text-pitch-alignment")==="map",ns=ee.get("symbol-z-offset"),Qt=W.get("symbol-elevation-reference")==="sea",ws=W.get("symbol-placement"),[As,Zt]=W.get("text-size-scale-range"),[Ut,ts]=W.get("icon-size-scale-range"),as=i.aC(z,As,Zt),cs=i.aC(z,Ut,ts),Qs=W.get("text-variable-anchor"),Hs=Tt&&ws!=="point",Gs=Wt&&ws!=="point",Cs=Qs&&B.hasTextData(),br=B.hasIconTextFit()&&Cs&&B.hasIconData();this.transform.setProjection(B.projection);const Ar=Cs||Hs,mr=Gs||br;let yr=pt&&(yt||!B.hasIconData()||Dt),Zr=yt&&(pt||!B.hasTextData()||wt);const xn=!ns.isConstant();!B.collisionArrays&&tt&&B.deserializeCollisionBoxes(tt),A&&D&&B.updateCollisionDebugBuffers(this.transform.zoom,tt,as,cs);const un=(qr,qn,hn)=>{const{crossTileID:Pa,numVerticalGlyphVertices:hi}=qr;let Gi=null;if(ye&&ye.dynamicFilterNeedsFeature||xn){const Si=this.retainedQueryData[B.bucketInstanceId],Ei=Ft.loadFeature({featureIndex:qr.featureIndex,bucketIndex:Si.bucketIndex,sourceLayerIndex:Si.sourceLayerIndex,layoutVertexArrayOffset:0}),li=Ei.properties?Ei.properties.worldview:null;if(B.localizable&&B.worldview&&typeof li=="string")if(li==="all")Ei.properties.$localized=!0;else{if(!li.split(",").includes(B.worldview))return;Ei.properties.$localized=!0,Ei.properties.worldview=B.worldview}Gi=ye&&ye.needGeometry?i.bD(Ei,!0):Ei}if(ye&&!(0,ye.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:B.worldview},Gi,this.retainedQueryData[B.bucketInstanceId].tileID.canonical,new i.P(qr.tileAnchorX,qr.tileAnchorY),this.transform.calculateDistanceTileData(ye.unwrappedTileID)))return this.placements[Pa]=new qx(!1,!1,!1,!0),void v.add(Pa);const wi=ns.evaluate(Gi,{});if((qr.zOffset||0)+(wi||0)>0&&this.frontCutoffStart>0){const Si=2*this.frontCutoffStart-1,Ei=[qr.tileAnchorX,qr.tileAnchorY,0,1],li=i.aE(i.bE(),Ei,ne);if(li[1]/li[3]{Si.tileID=this.retainedQueryData[B.bucketInstanceId].tileID;const Ei=this.transform.elevation;Si.elevation=Qt?wi:wi+i.bu.getAtTileOffset(Si.tileID,new i.P(Si.tileAnchorX,Si.tileAnchorY),Ei,_l),Si.elevation+=qr.zOffset},_h=hn.textBox;if(_h){Sc(_h);const Si=li=>{let Fo=i.bk.horizontal;if(B.allowVerticalPlacement&&!li&&this.prevPlacement){const Ad=this.prevPlacement.placedOrientations[Pa];Ad&&(this.placedOrientations[Pa]=Ad,Fo=Ad,this.markUsedOrientation(B,Fo,qr))}return Fo},Ei=(li,Fo)=>{if(B.allowVerticalPlacement&&hi>0&&hn.verticalTextBox){for(const Ad of B.writingModes)if(Ad===i.bk.vertical?(bn=Fo(),Bi=bn):bn=li(),bn&&bn.box&&bn.box.length)break}else bn=li()};if(Qs){let li=Qs;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Pa]){const uo=this.prevPlacement.variableOffsets[Pa];li.indexOf(uo.anchor)>0&&(li=li.filter(bh=>bh!==uo.anchor),li.unshift(uo.anchor))}const Fo=(uo,bh,dy)=>{const ev=B.getSymbolInstanceTextSize(ct,qr,this.transform.zoom,qn),tv=(uo.x2-uo.x1)*ev+2*uo.padding,J1=(uo.y2-uo.y1)*ev+2*uo.padding,Xx=qr.hasIconTextFit&&!yt?bh:null;Xx&&Sc(Xx);let Rf={box:[],offscreen:!1,occluded:!1};const e_=pt?2*li.length:li.length;for(let Wu=0;Wu=li.length,qr,qn,B,dy,Xx,ct,mt);if(uy&&(Rf=uy.placedGlyphBoxes,Rf&&Rf.box&&Rf.box.length)){za=!0,Ba=uy.shift;break}}return Rf};Ei(()=>Fo(_h,hn.iconBox,i.bk.horizontal),()=>{const uo=hn.verticalTextBox;return uo&&Sc(uo),B.allowVerticalPlacement&&!(bn&&bn.box&&bn.box.length)&&hi>0&&uo?Fo(uo,hn.verticalIconBox,i.bk.vertical):{box:null,offscreen:null,occluded:null}}),bn&&(za=bn.box,On=bn.offscreen,ji=bn.occluded);const Ad=Si(!(!bn||!bn.box));if(!za&&this.prevPlacement){const uo=this.prevPlacement.variableOffsets[Pa];uo&&(this.variableOffsets[Pa]=uo,this.markUsedJustification(B,uo.anchor,qr,Ad))}}else{const li=(Fo,Ad)=>{const uo=B.getSymbolInstanceTextSize(ct,qr,this.transform.zoom,qn),bh=this.collisionIndex.placeCollisionBox(B,uo,Fo,Be,Ie,Ar,new i.P(0,0),pt,Ce,ne,nt.predicate);return bh&&bh.box&&bh.box.length&&(this.markUsedOrientation(B,Ad,qr),this.placedOrientations[Pa]=Ad),bh};Ei(()=>li(_h,i.bk.horizontal),()=>{const Fo=hn.verticalTextBox;return B.allowVerticalPlacement&&hi>0&&Fo?(Sc(Fo),li(Fo,i.bk.vertical)):{box:null,offscreen:null,occluded:null}}),Si(!!(bn&&bn.box&&bn.box.length))}}if(mi=bn,za=mi&&mi.box&&mi.box.length>0,On=mi&&mi.offscreen,ji=mi&&mi.occluded,qr.useRuntimeCollisionCircles){const Si=qr.centerJustifiedTextSymbolIndex>=0?qr.centerJustifiedTextSymbolIndex:qr.verticalPlacedTextSymbolIndex,Ei=B.text.placedSymbolArray.get(Si),li=i.bl(B.textSizeData,ct,Ei),Fo=W.get("text-padding");Uo=this.collisionIndex.placeCollisionCircles(B,pt,Ei,Si,B.lineVertexArray,B.glyphOffsetArray,li,ne,de,be,A,Bt,nt.predicate,qr.collisionCircleDiameter*li/i.by,Fo,this.retainedQueryData[B.bucketInstanceId].tileID),za=pt||Uo.circles.length>0&&!Uo.collisionDetected,On=On&&Uo.offscreen,ji=Uo.occluded}if(hn.iconFeatureIndex&&(od=hn.iconFeatureIndex),hn.iconBox){const Si=Ei=>{Sc(Ei);const li=qr.hasIconTextFit&&Ba?ty(Ba.x,Ba.y,Tt,Bt,this.transform.angle):new i.P(0,0),Fo=B.getSymbolInstanceIconSize(mt,this.transform.zoom,qr.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(B,Fo,Ei,Be,Ie,mr,li,yt,Ce,ne,nt.predicate)};Bi&&Bi.box&&Bi.box.length&&hn.verticalIconBox?(sa=Si(hn.verticalIconBox),Rn=sa.box.length>0):(sa=Si(hn.iconBox),Rn=sa.box.length>0),On=On&&sa.offscreen,Qi=sa.occluded}const Qa=wt||qr.numHorizontalGlyphVertices===0&&hi===0,tm=Dt||qr.numIconVertices===0;if(Qa||tm?tm?Qa||(Rn=Rn&&za):za=Rn&&za:Rn=za=Rn&&za,za&&mi&&mi.box&&this.collisionIndex.insertCollisionBox(mi.box,W.get("text-ignore-placement"),B.bucketInstanceId,Bi&&Bi.box&&ol?ol:vi,nt.ID),Rn&&sa&&this.collisionIndex.insertCollisionBox(sa.box,W.get("icon-ignore-placement"),B.bucketInstanceId,od,nt.ID),Uo&&(za&&this.collisionIndex.insertCollisionCircles(Uo.circles,W.get("text-ignore-placement"),B.bucketInstanceId,vi,nt.ID),A)){const Si=B.bucketInstanceId;let Ei=this.collisionCircleArrays[Si];Ei===void 0&&(Ei=this.collisionCircleArrays[Si]=new Pr);for(let li=0;li=0;--qn){const hn=qr[qn];un(B.symbolInstances.get(hn),hn,B.collisionArrays[hn])}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 qr=B.getSortedIndexesByZOffset();for(let qn=0;qn=0&&(m.text.placedSymbolArray.get(z).crossTileID=be>=0&&z!==be?0:ne),B>=0&&(m.text.placedSymbolArray.get(B).crossTileID=be>=0&&B!==be?0:ne),W>=0&&(m.text.placedSymbolArray.get(W).crossTileID=be>=0&&W!==be?0:ne),ee>=0&&(m.text.placedSymbolArray.get(ee).crossTileID=be>=0&&ee!==be?0:ne)}markUsedOrientation(m,v,A){const D=v===i.bk.horizontal||v===i.bk.horizontalOnly?v:0,z=v===i.bk.vertical?v:0,{leftJustifiedTextSymbolIndex:B,centerJustifiedTextSymbolIndex:W,rightJustifiedTextSymbolIndex:ee,verticalPlacedTextSymbolIndex:ne}=A,de=m.text.placedSymbolArray;B>=0&&(de.get(B).placedOrientation=D),W>=0&&(de.get(W).placedOrientation=D),ee>=0&&(de.get(ee).placedOrientation=D),ne>=0&&(de.get(ne).placedOrientation=z)}commit(m){this.commitTime=m,this.zoomAtLastRecencyCheck=this.transform.zoom;const v=this.prevPlacement;let A=!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 ee in this.placements){const ne=this.placements[ee],de=z[ee];de?(this.opacities[ee]=new R0(de,D,ne.text,ne.icon,null,ne.clipped),A=A||ne.text!==de.text.placed||ne.icon!==de.icon.placed):(this.opacities[ee]=new R0(null,D,ne.text,ne.icon,ne.skipFade,ne.clipped),A=A||ne.text||ne.icon)}for(const ee in z){const ne=z[ee];if(!this.opacities[ee]){const de=new R0(ne,D,!1,!1);de.isHidden()||(this.opacities[ee]=de,A=A||ne.text.placed||ne.icon.placed)}}for(const ee in B)this.variableOffsets[ee]||!this.opacities[ee]||this.opacities[ee].isHidden()||(this.variableOffsets[ee]=B[ee]);for(const ee in W)this.placedOrientations[ee]||!this.opacities[ee]||this.opacities[ee].isHidden()||(this.placedOrientations[ee]=W[ee]);A?this.lastPlacementChangeTime=m:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=v?v.lastPlacementChangeTime:m)}updateLayerOpacities(m,v,A,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,A,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,A,D,z,B,W,ee){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,be=!!m.layers[0].dynamicFilter(),ye=new R0(null,0,!1,!1,!0),Ce=ne.get("text-allow-overlap"),Be=ne.get("icon-allow-overlap"),Ie=ne.get("text-variable-anchor"),st=ne.get("text-rotation-alignment")==="map",tt=ne.get("text-pitch-alignment")==="map",ct=de.get("symbol-z-offset"),mt=ne.get("symbol-elevation-reference")==="sea",nt=!ct.isConstant(),Ft=new R0(null,0,Ce&&(Be||!m.hasIconData()||ne.get("icon-optional")),Be&&(Ce||!m.hasTextData()||ne.get("text-optional")),!0);!m.collisionArrays&&D&&(m.hasIconCollisionBoxData()||m.hasTextCollisionBoxData())&&m.deserializeCollisionBoxes(D);const wt=(pt,yt,Tt)=>{for(let Wt=0;Wt0||Wt>0,Qs=ns>0,Hs=this.placedOrientations[Bt],Gs=Hs===i.bk.vertical,Cs=Hs===i.bk.horizontal||Hs===i.bk.horizontalOnly;!cs&&!Qs||as.isHidden()||Dt++;let br=!1;if((cs||Qs)&&B)for(const Ar of m.activeReplacements){if(i.bz(Ar,z,i.bA.Symbol,ee)||Ar.min.x>Qt||Qt>Ar.max.x||Ar.min.y>ws||ws>Ar.max.y)continue;const mr=i.bB(Qt,ws,W.canonical,Ar.footprintTileId.canonical);if(br=i.bC(mr,Ar.footprint),br)break}if(br&&this.collisionIndex.markSymbolAsClipped(m.bucketInstanceId,yt.featureIndex),cs){const Ar=br?Ux:I1(as.text);wt(m.text,Tt,Gs?Ux:Ar),wt(m.text,Wt,Cs?Ux:Ar);const mr=as.text.isHidden(),{leftJustifiedTextSymbolIndex:yr,centerJustifiedTextSymbolIndex:Zr,rightJustifiedTextSymbolIndex:xn,verticalPlacedTextSymbolIndex:un}=yt,$n=m.text.placedSymbolArray,qr=mr||Gs?1:0;yr>=0&&($n.get(yr).hidden=qr),Zr>=0&&($n.get(Zr).hidden=qr),xn>=0&&($n.get(xn).hidden=qr),un>=0&&($n.get(un).hidden=mr||Cs?1:0);const qn=this.variableOffsets[Bt];qn&&this.markUsedJustification(m,qn.anchor,yt,Hs);const hn=this.placedOrientations[Bt];hn&&(this.markUsedJustification(m,"left",yt,hn),this.markUsedOrientation(m,hn,yt))}if(Qs){const Ar=br?Ux:I1(as.icon),{placedIconSymbolIndex:mr,verticalPlacedIconSymbolIndex:yr}=yt,Zr=m.icon.placedSymbolArray,xn=as.icon.isHidden()?1:0;mr>=0&&(wt(m.icon,ns,Gs?Ux:Ar),Zr.get(mr).hidden=xn),yr>=0&&(wt(m.icon,yt.numVerticalIconVertices,Cs?Ux:Ar),Zr.get(yr).hidden=xn)}if(m.hasIconCollisionBoxData()||m.hasTextCollisionBoxData()){const Ar=m.collisionArrays[pt];if(Ar){let mr=new i.P(0,0),yr=!0;if(Ar.textBox||Ar.verticalTextBox){if(Ie){const xn=this.variableOffsets[Bt];xn?(mr=ju(xn.anchor,xn.width,xn.height,xn.textOffset,xn.textScale),st&&mr._rotate(tt?this.transform.angle:-this.transform.angle)):yr=!1}be&&(yr=!as.clipped),Ar.textBox&&O0(m.textCollisionBox.collisionVertexArray,as.text.placed,!yr||Gs,Ut,mt,mr.x,mr.y),Ar.verticalTextBox&&O0(m.textCollisionBox.collisionVertexArray,as.text.placed,!yr||Cs,Ut,mt,mr.x,mr.y)}const Zr=yr&&!!(!Cs&&Ar.verticalIconBox);Ar.iconBox&&O0(m.iconCollisionBox.collisionVertexArray,as.icon.placed,Zr,Ut,mt,yt.hasIconTextFit?mr.x:0,yt.hasIconTextFit?mr.y:0),Ar.verticalIconBox&&O0(m.iconCollisionBox.collisionVertexArray,as.icon.placed,!Zr,Ut,mt,yt.hasIconTextFit?mr.x:0,yt.hasIconTextFit?mr.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 O0(M,m,v,A,D,z,B){M.emplaceBack(m?1:0,v?1:0,z||0,B||0,A,D?1:0),M.emplaceBack(m?1:0,v?1:0,z||0,B||0,A,D?1:0),M.emplaceBack(m?1:0,v?1:0,z||0,B||0,A,D?1:0),M.emplaceBack(m?1:0,v?1:0,z||0,B||0,A,D?1:0)}const Ew=Math.pow(2,25),Pw=Math.pow(2,24),Gd=Math.pow(2,17),yl=Math.pow(2,16),rpe=Math.pow(2,9),Iw=Math.pow(2,8),DE=Math.pow(2,1);function I1(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*Ew+m*Pw+v*Gd+m*yl+v*rpe+m*Iw+v*DE+m}const Ux=0;class RE{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,A,D,z,B){const W=this._bucketParts;for(;this._currentTileIndexee.sortKey-ne.sortKey));this._currentPartIndex{const ee=i.o.now()-B;return!this.isFullPlacementRequested()&&this._fadeDuration!==0&&ee>2};for(;this._currentPlacementIndex>=0;){const ee=v[m[this._currentPlacementIndex]],ne=this.placement.collisionIndex.transform.zoom;if(ee.type==="symbol"&&ee.visibility!=="none"&&(!ee.minzoom||ee.minzoom<=ne)&&(!ee.maxzoom||ee.maxzoom>ne)){const de=ee,be=de.layout.get("symbol-z-elevate"),ye=de.layout.get("symbol-sort-key").constantOr(1)!==void 0,Ce=de.layout.get("symbol-z-order"),Be=Ce==="viewport-y"||Ce==="auto"&&!(Ce!=="viewport-y"&&ye),Ie=de.layout.get("text-allow-overlap")||de.layout.get("icon-allow-overlap")||de.layout.get("text-ignore-placement")||de.layout.get("icon-ignore-placement"),st=Be&&Ie,tt=this._inProgressLayer=this._inProgressLayer||new RE(de),ct=i.F(ee.source,ee.scope);if(tt.continuePlacement(be||st?D[ct]:A[ct],this.placement,this._showCollisionBoxes,ee,W,z))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._forceFullPlacement=!1,this._done=!0}commit(m){return this.placement.commit(m),this.placement}}const Md=512/i.an/2;class qm{constructor(m,v,A){this.tileID=m,this.bucketInstanceId=A,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;Bst-tt);for(const st of Ie){const tt=this.crossTileIDs[st];if(this.keys[st]===de&&!A.has(tt)){A.add(tt),ne.crossTileID=tt;break}}}}}class Gu{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class MO{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(m){const v=Math.round((m-this.lng)/360);if(v!==0)for(const A in this.indexes){const D=this.indexes[A],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[A]=z}this.lng=m}addBucket(m,v,A){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 ee=B[W];ee.tileID.isChildOf(m)&&ee.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[A]=!0});for(const A in this.layerIndexes)v[A]||delete this.layerIndexes[A]}}const Oo=771;class tn{constructor(m,v,A,D){this.blendFunction=m,this.blendColor=v.toNonPremultipliedRenderColor(null),this.mask=A,this.blendEquation=D}}tn.Replace=[1,0,1,0],tn.disabled=new tn(tn.Replace,i.aq.transparent,[!1,!1,!1,!1]),tn.unblended=new tn(tn.Replace,i.aq.transparent,[!0,!0,!0,!0]),tn.alphaBlended=new tn([1,Oo,1,Oo],i.aq.transparent,[!0,!0,!0,!0]),tn.alphaBlendedNonPremultiplied=new tn([770,Oo,770,Oo],i.aq.transparent,[!0,!0,!0,!0]),tn.multiply=new tn([774,0,774,0],i.aq.transparent,[!0,!0,!0,!0]),tn.multiplyAccumulateAlpha=new tn([774,0,1,Oo],i.aq.transparent,[!0,!0,!0,!0]),tn.additive=new tn([1,1,1,1],i.aq.transparent,[!0,!0,!0,!0]);class Nr{constructor(m,v,A){this.func=m,this.mask=v,this.range=A}}Nr.ReadOnly=!1,Nr.ReadWrite=!0,Nr.disabled=new Nr(519,Nr.ReadOnly,[0,1]);const il=7680;class nn{constructor(m,v,A,D,z,B){this.test=m,this.ref=v,this.mask=A,this.fail=D,this.depthFail=z,this.pass=B}}nn.disabled=new nn({func:519,mask:0},0,0,il,il,il);const Yh=1029,F0=2305;class Wr{constructor(m,v,A){this.enable=m,this.mode=v,this.frontFace=A}}function Dw(M,m){const v=i.bO(M,3);i.bR(M,m),i.bW(M,3,v)}function RC(M,m){const v=i.bL([]);return i.bM(v,v,-m),i.bN(v,v,-M),v}function OC(M,m){const v=[M[0],M[1],0],A=[m[0],m[1],0];if(i.ai(v)>=1e-15){const B=i.ay([],v);i.bJ(A,B,i.bi(A,B)),m[0]=A[0],m[1]=A[1]}const D=i.bh([],m,M);if(i.bK(D)<1e-15)return null;const z=Math.atan2(-D[1],D[0]);return RC(Math.atan2(Math.sqrt(M[0]*M[0]+M[1]*M[1]),-M[2]),z)}Wr.disabled=new Wr(!1,Yh,F0),Wr.backCCW=new Wr(!0,Yh,F0),Wr.backCW=new Wr(!0,Yh,2304),Wr.frontCW=new Wr(!0,1028,2304),Wr.frontCCW=new Wr(!0,1028,F0);class Rw{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,A){if(this.orientation=null,!this.position)return;const D=this.position,z=A||(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=OC(W,v)}setPitchBearing(m,v){this.orientation=RC(i.ap(m),i.ap(-v))}}class Ow{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&&Dw(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=RC(m,v),Dw(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 A=new Float64Array(16);return i.b7(A,this.getWorldToCamera(m,v)),A}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(m,v,A){const D=this.position;i.bJ(D,D,-m);const z=new Float64Array(16);return i.bP(z,[A,A,A]),i.bx(z,z,D),z[10]*=v,z}getWorldToCamera(m,v){const A=new Float64Array(16),D=new Float64Array(4),z=this.position;return i.bQ(D,this._orientation),i.bJ(z,z,-m),i.bR(A,D),i.bx(A,A,z),A[1]*=-1,A[5]*=-1,A[9]*=-1,A[13]*=-1,A[8]*=v,A[9]*=v,A[10]*=v,A[11]*=v,A}getCameraToClipPerspective(m,v,A,D){const z=new Float64Array(16);return i.bS(z,m,v,A,D),z}getCameraToClipOrthographic(m,v,A,D,z,B){const W=new Float64Array(16);return i.bT(W,m,v,A,D,z,B),W}getDistanceToElevation(m,v=!1){const A=m===0?0:i.bU(m,v?i.bV(this.position[1]):this.position[1]),D=this.forward();return(A-this.position[2])/D[2]}clone(){return new Ow([...this.position],[...this.orientation])}}const npe=(M,m)=>({u_matrix:M,u_ground_shadow_factor:m});class Tp{constructor(m=0,v=0,A=0,D=0){if(isNaN(m)||m<0||isNaN(v)||v<0||isNaN(A)||A<0||isNaN(D)||D<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=m,this.bottom=v,this.left=A,this.right=D}interpolate(m,v,A){return v.top!=null&&m.top!=null&&(this.top=i.am(m.top,v.top,A)),v.bottom!=null&&m.bottom!=null&&(this.bottom=i.am(m.bottom,v.bottom,A)),v.left!=null&&m.left!=null&&(this.left=i.am(m.left,v.left,A)),v.right!=null&&m.right!=null&&(this.right=i.am(m.right,v.right,A)),this}getCenter(m,v){const A=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(A,D)}equals(m){return this.top===m.top&&this.bottom===m.bottom&&this.left===m.left&&this.right===m.right}clone(){return new Tp(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const z0=15;class Fw{constructor(m,v,A,D,z,B,W){this.tileSize=512,this._renderWorldCopies=z===void 0||z,this._minZoom=m||0,this._maxZoom=v||22,this._minPitch=A??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 Tp,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new Ow,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 Fw(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 A=this._elevation;v||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&A.exaggeration()&&this._centerAltitudeValidForExaggeration!==A.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*A.exaggeration(),this._centerAltitudeValidForExaggeration=A.exaggeration()):(this._centerAltitude=m||0,this._centerAltitudeValidForExaggeration=A.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]],A=this.horizonLineFromTop();let D=0,z=0;for(let B=0;B{const st=i.ck(ye,be,Ce,Be,Ie);ee.has(st)||(z.push(new i.aR(be,ye,Ce,Be,Ie)),ee.add(st))};for(let be=0;beye.canonical.z)continue;const Ce=ye.canonical,Be=ye.overscaledZ,Ie=ye.wrap,st=1<0,mt=Ce.y+10,Ft=ye.wrap-(ct?0:1),wt=ye.wrap+(tt?0:1),Dt=ct?Ce.x-1:st-1,pt=tt?Ce.x+1:0;if(B)A[0]<0?(ne(Be,wt,Ce.z,pt,Ce.y),A[1]<0&&mt&&(ne(Be,Ie,Ce.z,Ce.x,Ce.y+1),ne(Be,wt,Ce.z,pt,Ce.y+1)),A[1]>0&&nt&&(ne(Be,Ie,Ce.z,Ce.x,Ce.y-1),ne(Be,wt,Ce.z,pt,Ce.y-1))):A[0]>0?(ne(Be,Ft,Ce.z,Dt,Ce.y),A[1]<0&&mt&&(ne(Be,Ie,Ce.z,Ce.x,Ce.y+1),ne(Be,Ft,Ce.z,Dt,Ce.y+1)),A[1]>0&&nt&&(ne(Be,Ie,Ce.z,Ce.x,Ce.y-1),ne(Be,Ft,Ce.z,Dt,Ce.y-1))):A[1]<0&&mt?ne(Be,Ie,Ce.z,Ce.x,Ce.y+1):nt&&ne(Be,Ie,Ce.z,Ce.x,Ce.y-1);else{const yt=ye.visibleQuadrants;1&yt&&(ne(Be,Ft,Ce.z,Dt,Ce.y),nt&&(ne(Be,Ie,Ce.z,Ce.x,Ce.y-1),ne(Be,Ft,Ce.z,Dt,Ce.y-1))),2&yt&&(ne(Be,wt,Ce.z,pt,Ce.y),nt&&(ne(Be,Ie,Ce.z,Ce.x,Ce.y-1),ne(Be,wt,Ce.z,pt,Ce.y-1))),4&yt&&(ne(Be,Ft,Ce.z,Dt,Ce.y),mt&&(ne(Be,Ie,Ce.z,Ce.x,Ce.y+1),ne(Be,Ft,Ce.z,Dt,Ce.y+1))),8&yt&&(ne(Be,wt,Ce.z,pt,Ce.y),mt&&(ne(Be,Ie,Ce.z,Ce.x,Ce.y+1),ne(Be,wt,Ce.z,pt,Ce.y+1)))}}const de=[];for(const be of z)z.some(ye=>be.isChildOf(ye))||de.push(be);if(z=de.filter(be=>!m.some(ye=>!!(be.overscaledZ{const tt=st.canonical.x+.5-Ce[0],ct=st.canonical.y+.5-Ce[1];return tt*tt+ct*ct{const Dt=i.ck(mt,ct,nt,Ft,wt);z.has(Dt)||(D.push(new i.aR(ct,mt,nt,Ft,wt)),z.add(Dt))},W=m.reduce((ct,mt)=>Math.max(ct,mt.overscaledZ),A),ee=1<{const nt=Math.floor(ct[0]),Ft=Math.floor(ct[1]),wt=(ct[0]-nt)*i.an,Dt=(ct[1]-Ft)*i.an,pt=Math.floor(mt[0]),yt=Math.floor(mt[1]),Tt=(mt[0]-pt)*i.an,Wt=(mt[1]-yt)*i.an;for(let Bt=-1;Bt<=1;Bt++){const ns=nt+Bt;if(!(ns<0||ns>=ee)){de.x=wt-Bt*i.an,be.x=Tt-(ns-pt)*i.an;for(let Qt=-1;Qt<=1;Qt++){const ws=Ft+Qt;de.y=Dt-Qt*i.an,be.y=Wt-(ws-yt)*i.an,i.cI(de,be,ne)&&B(W,0,A,ns,ws)}}}},Ce=v.points,Be=Ce[i.c9],Ie=Ce[i.ca],st=this._projectToGround(Be,Ce[i.cb]),tt=this._projectToGround(Ie,Ce[i.cc]);return ye(Be,st),ye(Ie,tt),D}_projectToGround(m,v){return i.cd(i.ce(),m,v,m[2]/(m[2]-v[2]))}_projectToZ(m,v,A){const D=m[2]-v[2];return Math.abs(D)<1e-6?i.cf(m):i.cd(i.ce(),m,v,(m[2]-A)/D)}extendTileCoverForTunnels(m,v,A,D){if(A<18)return[];const z=v.points,B=z[i.cg],W=z[i.ch],ee=z[i.ci],ne=z[i.cj];if(ee[2]>=0&&ne[2]>=0||B[2]<=0||W[2]<=0)return[];const de=ee[2]<0?this._projectToZ(B,ee,0):ee,be=ne[2]<0?this._projectToZ(W,ne,0):ne,ye=-D,Ce=ee[2]3&&(Ie.length=3),Ie}_findExtensionTilesInQuad(m,v,A,D){const z=[],B=new Set;for(const pt of m)B.add(pt.key);const W=m.reduce((pt,yt)=>Math.max(pt,yt.overscaledZ),v),ee=1<{const Tt=pt.canonical.x+.5-wt,Wt=pt.canonical.y+.5-Dt,Bt=yt.canonical.x+.5-wt,ns=yt.canonical.y+.5-Dt;return Tt*Tt+Wt*Wt-(Bt*Bt+ns*ns)||pt.canonical.x-yt.canonical.x||pt.canonical.y-yt.canonical.y}),z}coveringTiles(m){let v=this.coveringZoomLevel(m);const A=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),ee=this.center.lat,ne=1<{const as=new i.ag(Ut.x+25e-6,Ut.y,Ut.z),cs=new i.ag(Ut.x,Ut.y+25e-6,Ut.z),Qs=Ut.toLngLat(),Hs=as.toLngLat(),Gs=cs.toLngLat(),Cs=this.locationCoordinate(Qs),br=this.locationCoordinate(Hs),Ar=this.locationCoordinate(Gs),mr=Math.hypot(br.x-Cs.x,br.y-Cs.y),yr=Math.hypot(Ar.x-Cs.x,Ar.y-Cs.y);return Math.sqrt(mr*yr)*Dt/25e-6},yt=Ut=>{const ts=Ft,as=wt;return{aabb:i.cp(this,ne,0,0,0,Ut,as,ts,this.projection),zoom:0,x:0,y:0,minZ:as,maxZ:ts,wrap:Ut,fullyVisible:!1}},Tt=[];let Wt=[];const Bt=v,ns=m.reparseOverscaled?A:v,Qt=(st-this._centerAltitude)*Ie,ws=Ut=>{if(!this._elevation||!Ut.tileID||!B)return;const ts=this._elevation.getMinMaxForTile(Ut.tileID),as=Ut.aabb;ts?(as.min[2]=ts.min,as.max[2]=ts.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))},As=(Ut,ts)=>{if(.707*ts{if(Ut.zoom=.9)return!0}else if(z&&(cs=Ut.aabb.distanceZ(tt)*Ie),this.projection.isReprojectedInTileSpace&&A<=5){const yr=Math.pow(2,Ut.zoom),Zr=pt(new i.ag((Ut.x+.5)/yr,(Ut.y+.5)/yr));Qs=Zr>.85?1:Zr}if(!B&&!be){const yr=Math.sqrt(ts*ts+as*as+cs*cs);let Zr=(1<0;){const Ut=Tt.pop(),ts=Ut.x,as=Ut.y;let cs=Ut.fullyVisible;const Qs=()=>this.projection.name==="globe"&&(Ut.y===0||Ut.y===(1<Hs)continue;let Gs=0;if(!cs){let mr=ct?Ut.aabb.intersectsPrecise(Ce):Ut.aabb.intersectsPreciseFlat(Ce);if(mr===0&&Qs()){const yr=new i.cn(Ut.zoom,ts,as);mr=i.co(this,ne,yr,!0).intersectsPrecise(Ce)}if(mr===0)continue;if(m.calculateQuadrantVisibility)if(Ce.containsPoint(Ut.aabb.center))Gs=15;else for(let yr=0;yr<4;yr++)Ut.aabb.quadrant(yr).intersects(Ce)!==0&&(Gs|=1<>1),br={aabb:B?Ut.aabb.quadrant(Hs):i.cp(this,ne,Ut.zoom+1,Gs,Cs,Ut.wrap,Ut.minZ,Ut.maxZ,this.projection),zoom:Ut.zoom+1,x:Gs,y:Cs,wrap:Ut.wrap,fullyVisible:cs,tileID:void 0,shouldSplit:void 0,minZ:Ut.minZ,maxZ:Ut.maxZ};z&&!be&&(br.tileID=new i.aR(Ut.zoom+1===Bt?ns:Ut.zoom+1,Ut.wrap,Ut.zoom+1,Gs,Cs),ws(br)),Tt.push(br)}}if(this.fogCullDistSq){const Ut=this.fogCullDistSq,ts=this.horizonLineFromTop();Wt=Wt.filter(as=>{const cs=[0,0,0,1],Qs=[i.an,i.an,0,1],Hs=this.calculateFogTileMatrix(as.tileID.toUnwrapped());i.aE(cs,cs,Hs),i.aE(Qs,Qs,Hs);const Gs=i.cq([],cs,Qs),Cs=i.cr([],cs,Qs),br=i.cK(Gs,Cs);if(br===0)return!0;let Ar=!1;const mr=this._elevation;if(mr&&br>Ut&&ts!==0){const yr=this.calculateProjMatrix(as.tileID.toUnwrapped());let Zr;m.isTerrainDEM||(Zr=mr.getMinMaxForTile(as.tileID)),Zr||(Zr={min:wt,max:Ft});const xn=i.cs(this.rotation),un=[xn[0]*i.an,xn[1]*i.an,Zr.max];i.ah(un,un,yr),Ar=(1-un[1])*this.height*.5Ut.distanceSq-ts.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),A=this.projection.project(m.lng,v);return new i.P(A.x*this.worldSize,A.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 A,D;const z=this.centerPoint;if(this.projection.name==="globe"){const W=this.worldSize;A=(v.x-z.x)/W,D=(v.y-z.y)/W}else{const W=this.pointCoordinate(v),ee=this.pointCoordinate(z);A=W.x-ee.x,D=W.y-ee.y}const B=this.locationCoordinate(m);this.setLocation(new i.ag(B.x-A,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 A=v?i.bU(v,m.lat):void 0,D=this.projection.project(m.lng,m.lat);return new i.ag(D.x,D.y,A)}coordinateLocation(m){return this.projection.unproject(m.x,m.y)}pointRayIntersection(m,v){const A=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],ee=z[2];return{p0:D,p1:z,t:W===ee?0:(A-W)/(ee-W)}}screenPointToMercatorRay(m){const v=[m.x,m.y,0,1],A=[m.x,m.y,1,1];return i.aE(v,v,this.pixelMatrixInverse),i.aE(A,A,this.pixelMatrixInverse),i.cu(v,v,1/v[3]),i.cu(A,A,1/A[3]),v[2]=i.bU(v[2],this._center.lat)*this.worldSize,A[2]=i.bU(A[2],this._center.lat)*this.worldSize,i.cu(v,v,1/this.worldSize),i.cu(A,A,1/this.worldSize),new i.az([v[0],v[1],v[2]],i.ay([],i.ax([],A,v)))}rayIntersectionCoordinate(m){const{p0:v,p1:A,t:D}=m,z=i.bU(v[2],this._center.lat),B=i.bU(A[2],this._center.lat);return new i.ag(i.am(v[0],A[0],D)/this.worldSize,i.am(v[1],A[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 A=this.projection.pointCoordinate3D(this,m.x,m.y);if(A)return new i.ag(A[0],A[1],A[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 ee=0;ee<10&&z-D>B;ee++){W.y=i.am(D,z,.66);const ne=this.projection.pointCoordinate3D(this,W.x,W.y);ne?(z=W.y,A=ne):D=W.y}return A?new i.ag(A[0],A[1],A[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 A=v&&this.elevation?this.elevation.getAtPointOrZero(m,this._centerAltitude):this._centerAltitude,D=[m.x*this.worldSize,m.y*this.worldSize,A+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,A=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,A)),ee=this.pointLocation3D(new i.P(v,A));let ne=Math.min(z.lng,B.lng,W.lng,ee.lng),de=Math.max(z.lng,B.lng,W.lng,ee.lng),be=Math.min(z.lat,B.lat,W.lat,ee.lat),ye=Math.max(z.lat,B.lat,W.lat,ee.lat);const Ce=Math.pow(2,-this.zoom)/16*270,Be=this.projection.name==="globe"?1:4,Ie=(st,tt,ct,mt,nt)=>{const Ft=(st+ct)/2,wt=(tt+mt)/2,Dt=new i.P(Ft,wt),{lng:pt,lat:yt}=this.pointLocation3D(Dt),Tt=Math.max(0,ne-pt,be-yt,pt-de,yt-ye);ne=Math.min(ne,pt),de=Math.max(de,pt),be=Math.min(be,yt),ye=Math.max(ye,yt),(ntCe)&&(Ie(st,tt,Ft,wt,nt+1),Ie(Ft,wt,ct,mt,nt+1))};if(Ie(v,m,D,m,1),Ie(D,m,D,A,1),Ie(D,A,v,A,1),Ie(v,A,v,m,1),this.projection.name==="globe"){const[st,tt]=i.cw(this);st?(ye=90,de=180,ne=-180):tt&&(be=-90,de=180,ne=-180)}return new i.aK(new i.aU(ne,be),new i.aU(de,ye))}_getBoundsRectangular(m,v){const{top:A,left:D}=this._edgeInsets,z=this.height-this._edgeInsets.bottom,B=this.width-this._edgeInsets.right,W=new i.P(D,A),ee=new i.P(B,A),ne=new i.P(B,z),de=new i.P(D,z);let be=this.pointCoordinate(W,m),ye=this.pointCoordinate(ee,m);const Ce=this.pointCoordinate(ne,v),Be=this.pointCoordinate(de,v),Ie=(st,tt)=>(tt.y-st.y)/(tt.x-st.x);return be.y>1&&ye.y>=0?be=new i.ag((1-Be.y)/Ie(Be,be)+Be.x,1):be.y<0&&ye.y<=1&&(be=new i.ag(-Be.y/Ie(Be,be)+Be.x,0)),ye.y>1&&be.y>=0?ye=new i.ag((1-Ce.y)/Ie(Ce,ye)+Ce.x,1):ye.y<0&&be.y<=1&&(ye=new i.ag(-Ce.y/Ie(Ce,ye)+Ce.x,0)),new i.aK().extend(this.coordinateLocation(be)).extend(this.coordinateLocation(ye)).extend(this.coordinateLocation(Be)).extend(this.coordinateLocation(Ce))}_getBoundsRectangularTerrain(){const m=this.elevation;if(!m.visibleDemTiles.length||m.isUsingMockSource())return this._getBoundsRectangular(0,0);const v=m.visibleDemTiles.reduce((A,D)=>{if(D.dem){const z=D.dem.tree;A.min=Math.min(A.min,z.minimums[0]),A.max=Math.max(A.max,z.maximums[0])}return A},{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,A=this.height/2-v*(1-this._horizonShift);return m?Math.max(0,A):A}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.maxLngbe&&(W=be-ne),be-deCe&&(B=Ce-ee),Ce-ye{for(let Zt=0;Zt<16;Zt++)ns[Zt]=i.am(Qt[Zt],ws[Zt],As)})(W,W,ee,i.cL(this.pitch>=z0?1:this.pitch/z0))}else W=ee;const ne=i.cz([],ee,B);let de=i.cz([],W,B);if(this.projection.isReprojectedInTileSpace){const yt=this.locationCoordinate(this.center),Tt=i.b9([]);i.bx(Tt,Tt,[yt.x*this.worldSize,yt.y*this.worldSize,0]),i.aD(Tt,Tt,i.cA(this)),i.bx(Tt,Tt,[-yt.x*this.worldSize,-yt.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 yt=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);yt[8]=2*-m.x/this.width,yt[9]=2*m.y/this.height,this.expandedFarZProjMatrix=i.cz([],yt,B)}else this.expandedFarZProjMatrix=this.projMatrix;const be=i.b7([],W);this.frustumCorners=i.cD.fromInvProjectionMatrix(be,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!v);const ye=new Float32Array(16);i.b9(ye),i.cC(ye,ye,[1,-1,1]),i.cE(ye,ye,this._pitch),i.ba(ye,ye,this.angle);const Ce=i.bS(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=i.b8(Ce);const Be=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;Ce[8]=2*-m.x/this.width,Ce[9]=2*(m.y+Be)/this.height,this.skyboxMatrix=i.aD(ye,Ce,ye);const Ie=this.point,st=Ie.x,tt=Ie.y,ct=this.width%2/2,mt=this.height%2/2,nt=Math.cos(this.angle),Ft=Math.sin(this.angle),wt=st-Math.round(st)+nt*ct+Ft*mt,Dt=tt-Math.round(tt)+nt*mt+Ft*ct,pt=new Float64Array(de);if(i.bx(pt,pt,[wt>.5?wt-1:wt,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 yt=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.ah(yt,yt,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,A=this._camera.position,D=1/this.height/this._pixelsPerMercatorPixel,z=[m,m,v];i.bJ(z,z,D),i.bJ(A,A,-1),i.cG(A,A,z);const B=i.bb();i.bx(B,B,A),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,A=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-A[0]*z,D.y/this.worldSize-A[1]*z,m/this.worldSize*this._centerAltitude-A[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),A=this._camera.position[2],D=m[2];let z=1;this.projection.wrap&&(this.center=this.center.wrap()),D>0&&(z=Math.min((v-A)/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:A,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(A),B),ee=this._zoomFromMercatorZ(W);i.bg(m,m,v,W),this._pitch=i.aC(A,i.ap(this.minPitch),i.ap(this.maxPitch)),this.angle=i.bs(D,-Math.PI,Math.PI),this._setZoom(i.aC(ee,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,A=i.cv,D=0,z=1/0;for(;A-v>1e-6&&A>v;){const B=v+.5*(A-v),W=this.tileSize*Math.pow(2,B),ee=this.getCameraToCenterDistance(this.projection,B,W),ne=this.scaleZoom(ee/(Math.max(0,m)*this.tileSize)),de=Math.abs(B-ne);dene||ye.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 A=i.ai(i.ax([],this._camera.position,m)),D=this._zoomFromMercatorZ(A)+v;return A-this._mercatorZfromZoom(D)}getCameraPoint(){if(this.projection.name==="globe"){const m=function([v,A,D],z){const B=[v,A,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,A=this.worldSize){const D=i.cy(m,v,this.width,this.height,1024),z=m.pixelSpaceConversion(this.center.lat,A,D);let B=.5/Math.tan(.5*this._fov)*this.height*z;return this.isOrthographic&&(B=i.am(1,B,i.cL(this.pitch>=z0?1:this.pitch/z0))),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 nc=(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,A=v.pitch,D=v.isLODDisabled(!1)?60:30;if(A0,uniformValues:{u_cutoff_params:[v._nearZ,v._farZ,(de-v._nearZ)/z,(de-ye-v._nearZ)/z]}}},sy=2048;class FC{constructor(m,v){this.aabb=m,this.lastCascade=v}}class TO{add(m,v){const A=this.receivers[m.key];A!==void 0?(A.aabb.min[0]=Math.min(A.aabb.min[0],v.min[0]),A.aabb.min[1]=Math.min(A.aabb.min[1],v.min[1]),A.aabb.min[2]=Math.min(A.aabb.min[2],v.min[2]),A.aabb.max[0]=Math.max(A.aabb.max[0],v.max[0]),A.aabb.max[1]=Math.max(A.aabb.max[1],v.max[1]),A.aabb.max[2]=Math.max(A.aabb.max[2],v.max[2])):this.receivers[m.key]=new FC(v,null)}clear(){this.receivers={}}get(m){return this.receivers[m.key]}computeRequiredCascades(m,v,A){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 ee=W.aabb.getCorners();for(let ne=0;ne1||ye[1]<-1||ye[1]>1){de=!1;break}}if(W.lastCascade=ne,z=Math.max(z,ne),de)break}}return z+1}}class zw{constructor(m){this.painter=m,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new TO,this._depthMode=new Nr(m.context.gl.LEQUAL,Nr.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 A=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 tt of A.style.order){const ct=A.style._mergedLayers[tt];ct.hasShadowPass()&&!ct.isHidden(m.zoom)&&(B=W),!z||z!==tt&&z!==ct.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 ee=A.context,ne=sy,de=sy;if(this._cascades.length===0||sy!==this._cascades[0].texture.size[0]){this._cascades=[];for(let tt=0;tt<2;++tt){const ct=ee.gl,mt=ee.createFramebuffer(ne,de,0,"texture"),nt=new i.T(ee,{width:ne,height:de,data:null},ct.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=AO(v);let be=0;if(m.elevation){const tt=m.elevation,ct=[1e4,-1e4];tt.visibleDemTiles.filter(mt=>mt.dem).forEach(mt=>{const nt=mt.dem.tree;ct[0]=Math.min(ct[0],nt.minimums[0]),ct[1]=Math.max(ct[1],nt.maximums[0])}),ct[0]!==1e4&&(be=(ct[1]-ct[0])*tt.exaggeration())}const ye=1.5*m.cameraToCenterDistance,Ce=3*ye,Be=new Float64Array(16);for(let tt=0;tt=0)return{};const z=function(ee,ne,de){const be=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=[zC(z[1],z[0],z[4]),zC(z[2],z[1],z[5]),zC(z[3],z[2],z[6]),zC(z[0],z[3],z[7])],W}addShadowReceiver(m,v,A){this._receivers.add(m,i.cU.fromTileIdAndHeight(m,v,A))}getMaxCascadeForTile(m){const v=this._receivers.get(m);return v&&v.lastCascade?v.lastCascade:0}}function zC(M,m,v){const A=i.ax([],v,m),D=i.ax([],M,m),z=i.bh([],A,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 AO(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 A=i.cR([v[0],v[1],v[2]]);return i.cQ(A.x,A.y,A.z)}function Ap(M,m,v){const A=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],ee=v.properties.get("color-use-theme")==="none",ne=v.properties.get("color"),de=v.properties.get("intensity"),be=Math.max(i.bi([0,0,1],W),0),ye=[0,0,0];i.bJ(ye,ne.toPremultipliedRenderColor(ee?null:M.getLut(m.scope)).toArray01Linear().slice(0,3),de);const Ce=[0,0,0];return i.bJ(Ce,D.toPremultipliedRenderColor(A?null:M.getLut(v.scope)).toArray01Linear().slice(0,3),be*z),i.cW([ye[0]>0?ye[0]/(ye[0]+Ce[0]):0,ye[1]>0?ye[1]/(ye[1]+Ce[1]):0,ye[2]>0?ye[2]/(ye[2]+Ce[2]):0])}function Bw(M,m,v,A,D,z){const B=M.zoom,W=M.scale,ee=M.worldSize,ne=1/ee,de=M.aspect,be=Math.sqrt(1+de*de)*Math.tan(.5*M.fovX),ye=be*be,Ce=A-v,Be=A+v;let Ie,st;ye>Ce/Be?(Ie=A,st=A*be):(Ie=.5*Be*(1+ye),st=.5*Math.sqrt(Ce*Ce+2*(A*A+v*v)*ye+Be*Be*ye*ye));const tt=M.projection.pixelsPerMeter(M.center.lat,ee),ct=M._camera.getCameraToWorldMercator(),mt=[0,0,-Ie*ne];i.ah(mt,mt,ct);let nt=st*ne;const Ft=function(cs){return cs[0]/=W,cs[1]/=W,cs[2]=i.bU(cs[2],M._center.lat),cs},wt=M._edgeInsets;if(!(wt.left===0&&wt.top===0&&wt.right===0&&wt.bottom===0||wt.left===wt.right&&wt.top===wt.bottom)){const cs=M._camera.getWorldToCamera(M.worldSize,M.projection.zAxisUnit==="meters"?tt:1),Qs=M._camera.getCameraToClipPerspective(M._fov,M.width/M.height,v,A);Qs[8]=2*-M.centerOffset.x/M.width,Qs[9]=2*M.centerOffset.y/M.height;const Hs=new Float64Array(16);i.cz(Hs,Qs,cs);const Gs=new Float64Array(16);i.b7(Gs,Hs);const Cs=i.cl.fromInvProjectionMatrix(Gs,ee,B,!0);for(const br of Cs.points){const Ar=Ft(br);nt=Math.max(nt,i.bK(i.cV([],mt,Ar)))}}nt*=D/(D-1);const Dt=Math.acos(m[2]),pt=Math.atan2(-m[0],-m[1]),yt=new Ow;yt.position=mt,yt.setPitchBearing(Dt,pt);const Tt=yt.getWorldToCamera(ee,tt),Wt=nt*ee,Bt=Math.min(M._mercatorZfromZoom(17)*ee*-2,-2*Wt),ns=yt.getCameraToClipOrthographic(-Wt,Wt,-Wt,Wt,Bt,(Wt+z*tt)/m[2]),Qt=new Float64Array(16);i.aD(Qt,ns,Tt);const ws=i.cQ(Math.floor(1e6*mt[0])/1e6*ee,Math.floor(1e6*mt[1])/1e6*ee,0),As=.5*D,Zt=[0,0,0];i.ah(Zt,ws,Qt),i.bJ(Zt,Zt,As);const Ut=[Math.floor(Zt[0]),Math.floor(Zt[1]),Math.floor(Zt[2])],ts=[0,0,0];i.ax(ts,Zt,Ut),i.bJ(ts,ts,-1/As);const as=new Float64Array(16);return i.b9(as),i.bx(as,as,ts),i.aD(Qt,as,Qt),[Qt,Wt]}class ape 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(A=>{const D=i.cY(A),z=new i.cZ(m,v,void 0,void 0,D);return z.computeBoundsAndApplyParent(),z}).catch(A=>{if(A&&A.status===404)return null;this.fire(new i.B(new Error(`Could not load model ${m} from ${v}: ${A.message}`)))})}load(m,v,A={forceReload:!1}){this.models[v]||(this.models[v]={});const D=Object.keys(m),z=[],B=[];for(const W of D){const ee=m[W];this.hasURLBeenRequested(ee)&&!A.forceReload||(this.modelByURL[ee]={modelId:W,scope:v},z.push(this.loadModel(W,ee)),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 ee=0;ee{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,A={exactIdMatch:!1}){return!!(A.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,A){this.models[A]||(this.models[A]={}),this.modelUris[A]||(this.modelUris[A]={});const D=this.requestManager.normalizeModelURL(v);if((this.hasModel(m,A,{exactIdMatch:!0})||this.hasModelBeenAdded(m,A))&&this.modelUris[A][m]===D)this.models[A][m].numReferences++;else if(this.hasURLBeenRequested(D)){const{scope:z,modelId:B}=this.modelByURL[D];this.models[z][B].numReferences++}else this.modelUris[A][m]=D,this.load({[m]:this.modelUris[A][m]},A)}addModelURLs(m,v){this.models[v]||(this.models[v]={}),this.modelUris[v]||(this.modelUris[v]={});const A=this.modelUris[v];for(const D in m)A[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 A={};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)?A[D]=this.modelUris[v][D]:!this.hasURLBeenRequested(D)&&i.c_(D,!1)&&(this.modelUris[v][D]=this.requestManager.normalizeModelURL(D),A[D]=this.modelUris[v][D]);this.load(A,v)}hasURLBeenRequested(m){return this.modelByURL[m]!==void 0}removeModel(m,v,A=!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];A||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 A=this.models[m][v].model;delete this.models[m][v],A&&A.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 A in this.models[v])this.models[v][A].model&&this.models[v][A].model.upload(m.context)}}const OE=i.a8.colorTheme,D1=new i.ab({data:new i.ac(OE.data)});function EO(M){if(!M.metadata||!M.metadata.content_area)return;const m=i.o.devicePixelRatio,{left:v,top:A,width:D,height:z}=M.metadata.content_area,B=v*m,W=A*m;return[B,W,B+D*m,W+z*m]}function $w(M){if(M)return M.map(([m,v])=>[m*i.o.devicePixelRatio,v*i.o.devicePixelRatio])}class FE{constructor(m,v,A){this.id=m,this.scope=v,this.sourceCache=A,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 A=this.sourceCache.getSource();if(!(A instanceof xh))return m;const D=v.map(B=>this.sourceCache.getTile(B)),z=A.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 ry{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16}findClosestBuilding(m,v,A,D,z){if(Aee*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 A=m.lat-v.center[1],D=m.lng-v.center[0];return A*A+D*D}_isBuildingVisible(m,v,A){if(!A)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,A))return!0}else if(B.type==="MultiPolygon"){const W=this._convertMultiPolygonToPoints(B.coordinates);if(i.d0(A,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(A=>new i.P(A[0],A[1])))}}class ipe 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 ry,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[A,D]of Object.entries(m.buildings))if(this._buildings[A])for(const z of D.floorIds)this._buildings[A].floorIds.add(z),this._buildings[A].floors[z]?this._mergeFloors(this._buildings[A].floors[z],D.floors[z]):(this._buildings[A].floors[z]=D.floors[z],v=!0);else this._buildings[A]=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,A=v&&m?m[v]:void 0;if(!A)return{selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let D=null;for(const B of A.floorIds)if(this._activeFloors&&this._activeFloors.has(B)){D=B;break}const z=Array.from(A.floorIds).map(B=>({id:B,name:A.floors[B].name,zIndex:A.floors[B].zIndex})).sort((B,W)=>W.zIndex-B.zIndex).filter((B,W,ee)=>W===0||B.zIndex!==ee[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 A=this._closestBuildingId;this._closestBuildingId=v,this._onBuildingTransition(A,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,A){if(v===A)return!0;if(!v||!A||v.size!==A.size)return!1;for(const D of v)if(!A.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,A=m.height;return[m.pointLocation(new i.P(0,0)),m.pointLocation(new i.P(v,0)),m.pointLocation(new i.P(v,A)),m.pointLocation(new i.P(0,A))].map(D=>new i.P(D.lng,D.lat))}}const B0=(M,m)=>or(M,m&&m.filter(v=>v.identifier!=="source.canvas")),ope=i.aJ(Ca,["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"]),PO=i.aJ(Ca,["setCenter","setZoom","setBearing","setPitch"]),zE=new Set(["background","sky","slot","custom"]),BC={version:8,layers:[],sources:{}},BE={duration:300,delay:0};class Um 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({},BE),this._buildingIndex=new I0(this),this.crossTileSymbolIndex=new L1,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 Ye,this._hasDataDrivenEmissive=!1,this.indoorManager=new ipe(this),this.dispatcher=v.dispatcher?v.dispatcher:new xt(Et(),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 $t(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 ape(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 A=this;this._rtlTextPluginCallback=Um.registerForPluginStateChange(D=>{A.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(z,B)=>{if(i.d6(z),B&&B.every(W=>W))for(const W in A._sourceCaches){const ee=A._sourceCaches[W],ne=ee.getSource().type;ne!=="vector"&&ne!=="geojson"||ee.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,A){this.globalId=this._getGlobalId(m);const D=(z,B)=>{try{B(null,this.setState(z,A))}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,ee)=>{W?this.fire(new i.B(W)):ee&&D(ee,v)})}else typeof m=="object"&&D(m,v)}loadURL(m,v={}){this.fire(new i.C("dataloading",{dataType:"style"}));const A=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,A);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,A)})}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(BC,!1)}_loadImports(m,v,A){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 ee=z.data||this.importsCache.get(z.url);ee?(z.data?(B.fire(new i.C("dataloading",{dataType:"style"})),B.globalId=B._getGlobalId(ee),queueMicrotask(()=>B._load(ee,v))):B.loadJSON(ee,{validate:v}),this._isInternalStyle(ee)&&(B.globalId=null)):z.url?B.loadURL(z.url,{validate:v}):B.loadEmpty();const ne={style:B,id:z.id,config:z.config};if(A){const de=this.fragments.findIndex(({id:be})=>be===A);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 A of m.fragments)A.style.globalId&&v.add(A.style.globalId),this.getImportGlobalIds(A.style,v);return[...v.values()]}_createFragmentStyle(m){const v=this.scope?i.F(m.id,this.scope):m.id;let A;const D=this._initialConfig&&this._initialConfig[v];(m.config||D)&&(A=Object.assign({},m.config,D));const z=new Um(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:A,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({},BC,{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&&B0(this,zr(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 A=()=>{if(m.iconsets)for(const ee in m.iconsets)this.addIconset(ee,m.iconsets[ee]);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=A1(this.stylesheet.layers);if(this._order=z.map(ee=>ee.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 ee=this.stylesheet.lights[0];this.light=new Rr(ee.properties,ee.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Rr(this.stylesheet.light)),this._layers={};for(const ee of z){const ne=i.de(ee,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),be=!!this.directionalLight&&this.directionalLight.shadowsEnabled();de&&ne.canCastShadows()&&be&&(de.castsShadows=!0)}if(this.glyphManager.url){const ee=new Set;for(const ne in this._layers){const de=this._layers[ne];if(de.type==="symbol"&&de.layout){const be=de.layout.get("text-font");be&&be.value&&be.value.kind==="constant"&&ee.add(be.value.value.join(","))}}for(const ne of ee)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(ee=>{this.fire(new i.B(new Error("Failed to load imports",ee))),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(()=>{A()}).catch(B=>{i.w(`Couldn't load color theme from the stylesheet: ${B}`),A()})}else this._styleColorTheme.lut=null,A()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(m=>m.style.hasAppearances())}mergeAll(){let m,v,A,D,z,B,W,ee,ne,de;const be={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(ye=>{if(ye.stylesheet){if(ye.light!=null&&(m=ye.light),ye.stylesheet.lights)for(const Ce of ye.stylesheet.lights)Ce.type==="ambient"&&ye.ambientLight!=null&&(v=ye.ambientLight),Ce.type==="directional"&&ye.directionalLight!=null&&(A=ye.directionalLight);D=this._prioritizeTerrain(D,ye.terrain,ye.stylesheet.terrain),ye.stylesheet.fog&&ye.fog!=null&&(z=ye.fog),ye.stylesheet.snow&&ye.snow!=null&&(B=ye.snow),ye.stylesheet.rain&&ye.rain!=null&&(W=ye.rain),ye.stylesheet.camera!=null&&(de=ye.stylesheet.camera),ye.stylesheet.projection!=null&&(ee=ye.stylesheet.projection),ye.stylesheet.transition!=null&&(ne=ye.stylesheet.transition),be[ye.scope]=ye._styleColorTheme}}),this.light=m,this.ambientLight=v,this.directionalLight=A,this.fog=z,this.snow=B,this.rain=W,this._styleColorThemeForScope=be,D===null?delete this.terrain:this.terrain=D,this.camera=de||{"camera-projection":"perspective"},this.projection=ee||{name:"mercator"},this.transition=Object.assign({},BE,ne),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(m){const v=A=>{for(const D of A.fragments)v(D.style);m(A)};v(this)}_prioritizeTerrain(m,v,A){const D=m&&m.drapeRenderMode===0;return A===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={},A={},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);A[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=A,this._mergedFillExtrusionSourceCaches=D}mergeIndoor(){this.forEachFragmentStyle(m=>{if(m.stylesheet&&m.stylesheet.indoor)for(const v of Object.values(m.stylesheet.indoor)){const A=v,D=i.F(A.sourceId,m.scope);this._mergedIndoor[D]=new Set(A.sourceLayers||[])}})}mergeLayers(){const m={},v=[],A={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(B=>{for(const W of B._order){const ee=B._layers[W];if(ee.type==="slot"){const ne=i.da(W);if(m[ne])continue;m[ne]=[]}ee.slot&&m[ee.slot]?m[ee.slot].push(ee):v.push(ee)}}),this._mergedOrder=[];let D=-1;const z=(B=[])=>{for(const W of B)if(W.type==="slot"){const ee=i.da(W.id);m[ee]&&z(m[ee]),this._mergedSlots.push(ee)}else{const ee=i.F(W.id,W.scope);this._mergedOrder.push(ee),A[ee]=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[ee])}this._mergedLayers=A,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,A,D){const z=Object.assign({},A);for(const W of Object.keys(OE))z[W]===void 0&&(z[W]=OE[W].default);const B=new i.aa(D1,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((A,D)=>{const z="data:image/png;base64,";if(!m||m.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void A();let B=m;B.startsWith(z)||(B=z+B);const W=i.I.from("mapbox-reserved-lut"),ee=new Image;ee.src=B,ee.onerror=()=>{this._styleColorTheme.lutLoading=!1,D(new Error("Failed to load image data"))},ee.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==v)return void A();this._styleColorTheme.lutLoading=!1;const{width:ne,height:de,data:be}=i.o.getImageData(ee);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},be),pixelRatio:1,sdf:!1,usvg:!1,version:0});const ye=this.imageManager.getImage(W,this.scope);ye?(this._styleColorTheme.lut={image:ye.data,data:m},A()):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,A,D){let z,B,W;const ee=i.o.devicePixelRatio>1?"@2x":"";let ne=i.m(A.transformRequest(A.normalizeSpriteURL(v,ee,".json"),i.R.SpriteJSON),(ye,Ce)=>{ne=null,W||(W=ye,z=Ce,be())}),de=i.n(A.transformRequest(A.normalizeSpriteURL(v,ee,".png"),i.R.SpriteImage),(ye,Ce)=>{de=null,W||(W=ye,B=Ce,be())});function be(){if(W)D(W);else if(z&&B){const ye=i.o.getImageData(B),Ce={};for(const Be in z){const{width:Ie,height:st,x:tt,y:ct,sdf:mt,pixelRatio:nt,stretchX:Ft,stretchY:wt,content:Dt}=z[Be],pt=new i.q({width:Ie,height:st});i.q.copy(ye,pt,{x:tt,y:ct},{x:0,y:0},{width:Ie,height:st},null),Ce[Be]={data:pt,pixelRatio:nt!==void 0?nt:1,sdf:mt!==void 0&&mt,stretchX:Ft,stretchY:wt,content:Dt,usvg:!1,version:0}}D(null,Ce)}}return{cancel(){ne&&(ne.cancel(),ne=null),de&&(de.cancel(),de=null)}}}(m,this.map._requestManager,(v,A)=>{if(this._spriteRequest=null,v)this.fire(new i.B(v));else if(A){const D=new Map;for(const z in A)D.set(i.I.from(z),A[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 A=this.getOwnSourceCache(v.source);if(!A)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=A.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 FE(m,this.scope,A);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 A,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 ee in B)W.set(i.I.from(ee),B[ee]);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((A=this.map._requestManager).transformRequest(A.normalizeIconsetURL(m),i.R.Iconset),(z,B)=>{if(z)return void D(z);const W={},ee=i.c$(new i.a$(B));for(const ne of ee.icons){const de={version:1,pixelRatio:i.o.devicePixelRatio,content:EO(ne),stretchX:ne.metadata?$w(ne.metadata.stretch_x_areas):void 0,stretchY:ne.metadata?$w(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 A=m.sourceLayer;A&&(v.type==="geojson"||v.vectorLayerIds&&v.vectorLayerIds.indexOf(A)===-1)&&this.fire(new i.B(new Error(`Source layer "${A}" 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 A=this.fragments[v];return A&&A.style&&(m.data=A.style.serialize()),m})}_serializeSources(){const m={};for(const v in this._sourceCaches){const A=this._sourceCaches[v].getSource();m[A.id]||(m[A.id]=A.serialize())}return m}_serializeLayers(m){const v=[];for(const A of m){const D=this._layers[A];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 A=v._transitionablePaint._values["line-emissive-strength"];if(A&&A.value&&A.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(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 A=this.map.painter;if(A)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&&(A.style=this,this.fog&&(A._fogVisible=!0,W.overrideFog=!0,A.getOrCreateProgram(B,W)),A._fogVisible=!1,W.overrideFog=!1,A.getOrCreateProgram(B,W),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(W.overrideRtt=!0,A.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 A=this._changes.isDirty();let D=!1;if(this._changes.isDirty()){const ee=this._changes.getLayerUpdatesByScope();for(const ne in ee){const{updatedIds:de,removedIds:be}=ee[ne];(de||be)&&(this._updateWorkerLayers(ne,de,be),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 ee in this._mergedSourceCaches){const ne=this._mergedSourceCaches[ee];z[ee]=ne.used,ne.used=!1,ne.tileCoverLift=0}const B={};for(const ee of this._mergedOrder){const ne=this._mergedLayers[ee];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 be=ne.layout&&ne.layout.get("source-max-zoom");if(be!=null){const ye=B[de];B[de]=ye==null?be:Math.min(ye,be)}}}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(ne,m)}):this.precompilePrograms(ne,m))}this._shouldPrecompile&&(this._precompileDone=!0);for(const ee in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[ee].setMaxzoomOverride(B[ee]!=null?B[ee]:null);this.terrain&&D&&this.mergeLayers();const W=this.imageManager.getPendingImageProviders();for(const ee of W)ee.sourceCache.used=!0;for(const ee in z){const ne=this._mergedSourceCaches[ee];z[ee]!==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),A&&this.fire(new i.C("data",{dataType:"style"}))}updateImageProviders(){const m=this.imageManager.getPendingImageProviders();for(const v of m){const A=v.resolvePendingRequests(),D=this.getFragmentStyle(v.scope);D&&D.addImages(A)}}_updateTilesForChangedImages(){const m={};for(const v in this._mergedSourceCaches){const A=this._mergedSourceCaches[v].getSource().scope;m[A]=m[A]||this._changes.getUpdatedImages(A),m[A].length!==0&&this._mergedSourceCaches[v].reloadTilesForDependencies(["icons","patterns"],m[A])}for(const v in m)this._changes.resetUpdatedImages(v)}_updateWorkerLayers(m,v,A){const D=this.getFragmentStyle(m);D&&this.dispatcher.broadcast("updateLayers",{layers:v?D._serializeLayers(v):[],scope:m,removedIds:A||[],options:D.options})}setState(m,v){if(this._checkLoaded(),B0(this,zr(m)))return!1;(m=i.d9(m)).layers=A1(m.layers);const A=function(B,W){if(!B)return[{command:Ca.setStyle,args:[W]}];let ee=[];try{if(!i.b6(B.version,W.version))return[{command:Ca.setStyle,args:[W]}];if(i.b6(B.center,W.center)||ee.push({command:Ca.setCenter,args:[W.center]}),i.b6(B.zoom,W.zoom)||ee.push({command:Ca.setZoom,args:[W.zoom]}),i.b6(B.bearing,W.bearing)||ee.push({command:Ca.setBearing,args:[W.bearing]}),i.b6(B.pitch,W.pitch)||ee.push({command:Ca.setPitch,args:[W.pitch]}),i.b6(B.sprite,W.sprite)||ee.push({command:Ca.setSprite,args:[W.sprite]}),i.b6(B.glyphs,W.glyphs)||ee.push({command:Ca.setGlyphs,args:[W.glyphs]}),i.b6(B.imports,W.imports)||function(Ce=[],Be=[],Ie){Be=Be||[];const st=(Ce=Ce||[]).map(ey),tt=Be.map(ey),ct=Ce.reduce(L0,{}),mt=Be.reduce(L0,{}),nt=st.slice();let Ft,wt,Dt,pt;for(Ft=0,wt=0;Ft{Ce.source&&ne[Ce.source]?ee.push({command:Ca.removeLayer,args:[Ce.id]}):be.push(Ce)});let ye=B.terrain;ye&&ne[ye.source]&&(ee.push({command:Ca.setTerrain,args:[void 0]}),ye=void 0),ee=ee.concat(de),i.b6(ye,W.terrain)||ee.push({command:Ca.setTerrain,args:[W.terrain]}),function(Ce,Be,Ie){Be=Be||[];const st=(Ce=Ce||[]).map(ey),tt=Be.map(ey),ct=Ce.reduce(L0,{}),mt=Be.reduce(L0,{}),nt=st.slice(),Ft=Object.create(null);let wt,Dt,pt,yt,Tt,Wt,Bt;for(wt=0,Dt=0;wt!(B.command in PO));if(A.length===0)return!1;const D=A.filter(B=>!(B.command in ope));if(D.length>0)throw new Error(`Unimplemented: ${D.map(B=>B.command).join(", ")}.`);const z=[];return A.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,A]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,A),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,A=!1){this.imageManager.updateImage(m,this.scope,v),A&&(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,A={}){return this._checkLoaded(),this._validate(Ts,`models.${m}`,v,null,A)||(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,A={}){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(fa,`sources.${m}`,v,null,A))return;this.map&&this.map._collectResourceTiming&&(v.collectResourceTiming=!0);const D=Sp(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,ee=i.F(W,this.scope),ne=this._sourceCaches[W]=new gh(ee,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),A.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 A=this.getOwnSourceCaches(m);for(const D of A){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 A=this.getOwnSourceCache(v);A&&m.push(A.getSource())}return m}areTilesLoaded(){const m=this._mergedSourceCaches;for(const v in m){const A=m[v]._tiles;for(const D in A){const z=A[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,sc(),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,_u(),this.scope,this.options)}}const A=Object.assign(v,{worldview:this.map.getWorldview()}),D=new i.ae(this.z||0,A);this.ambientLight&&this.ambientLight.recalculate(D),this.directionalLight&&this.directionalLight.recalculate(D),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const m=this.directionalLight,v=this.ambientLight;if(!m||!v)return;const A=ye=>.2126*(ye[0]<=.03928?ye[0]/12.92:Math.pow((ye[0]+.055)/1.055,2.4))+.7152*(ye[1]<=.03928?ye[1]/12.92:Math.pow((ye[1]+.055)/1.055,2.4))+.0722*(ye[2]<=.03928?ye[2]/12.92:Math.pow((ye[2]+.055)/1.055,2.4)),D=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,ee=A(D)*z*W,ne=v.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),de=v.properties.get("intensity"),be=A(ne)*de;return Number(((ee+be)/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),A=this.fragments.find(({id:z})=>z===v);if(!A)return;const D=i.da(m);return A.style.getFragmentStyle(D)}{const v=this.fragments.find(({id:A})=>A===m);return v?v.style:void 0}}setFeaturesetSelectors(m){if(!m)return;const v=(A,D="")=>`${A}::${D}`;this._featuresetSelectors={};for(const A in m){const D={},z=this._featuresetSelectors[A]=[];for(const B of m[A].selectors){if(B.featureNamespace){const ee=this.getOwnLayer(B.layer);if(!ee){i.w(`Layer is undefined for selector: ${B.layer}`);continue}const ne=v(ee.source,ee.sourceLayer);if(ne in D&&D[ne]!==B.featureNamespace){i.w(`"featureNamespace ${B.featureNamespace} of featureset ${A}'s selector is not associated to the same source, skip this selector`);continue}D[ne]=B.featureNamespace}let W;if(B.properties)for(const ee in B.properties){const ne=i.X(B.properties[ee]);ne.result==="success"&&(W=W||{},W[ee]=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 A=[];for(const D in v.stylesheet.featuresets)A.push({featuresetId:D,importId:v.scope?v.scope:void 0});return A}getFeaturesetLayers(m,v){const A=this.getFragmentStyle(v),D=A.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=A.getOwnLayer(B.layer);W&&z.push(W)}return z}getConfigProperty(m,v){const A=this.getFragmentStyle(m);if(!A)return null;const D=i.F(v,A.scope),z=A.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 A=i.F(m,v);return this._mergedIndoor[A]}setIndoorData(m,v){this.indoorManager.setIndoorData(v)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(m,v,A){const D=this.getFragmentStyle(m);if(!D)return;const z=D.stylesheet.schema;if(!z||!z[v])return;const B=i.X(A);if(B.result!=="success")return void B0(this,B.value);const W=B.value.expression,ee=i.F(v,D.scope),ne=D.options.get(ee);if(!ne)return;let de;const{minValue:be,maxValue:ye,stepValue:Ce,type:Be,values:Ie}=z[v],st=i.X(z[v].default);st.result==="success"&&(de=st.value.expression),de?(this.options.set(ee,Object.assign({},ne,{value:W,default:de,minValue:be,maxValue:ye,stepValue:Ce,type:Be,values:Ie})),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 A=v.stylesheet.schema;if(!A)return null;const D={};for(const z in A){const B=i.F(z,v.scope),W=v.options.get(B),ee=W?W.value||W.default:null;D[z]=ee?ee.serialize():null}return D}setConfig(m,v){const A=this.getFragmentStyle(m);A&&(A.updateConfig(v,A.stylesheet.schema),this.updateConfigDependencies())}getSchema(m){const v=this.getFragmentStyle(m);return v?v.stylesheet.schema:null}setSchema(m,v){const A=this.getFragmentStyle(m);A&&(A.stylesheet.schema=v,A.updateConfig(A._config,v),this.updateConfigDependencies())}updateConfig(m,v){if(this._config=m,m||v)if(v)for(const A in v){let D,z;const B=i.X(v[A].default);if(B.result==="success"&&(D=B.value.expression),m&&m[A]!==void 0){const ye=i.X(m[A]);ye.result==="success"&&(z=ye.value.expression)}const{minValue:W,maxValue:ee,stepValue:ne,type:de,values:be}=v[A];if(D){const ye=i.F(A,this.scope);this.options.set(ye,{default:D,value:z,minValue:W,maxValue:ee,stepValue:ne,type:de,values:be})}else this.fire(new i.B(new Error(`No schema defined for config option "${A}".`)))}else this.fire(new i.B(new Error("Attempting to set config for a style without schema.")))}_updateLayers(m,v=()=>!0){for(const A of m){const D=this.getLayer(A);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 A=v._styleColorTheme.colorThemeOverride?v._styleColorTheme.colorThemeOverride:v._styleColorTheme.colorTheme;if(A){const D=v._evaluateColorThemeData(A);(!v._styleColorTheme.lut&&D!==""||v._styleColorTheme.lut&&D!==v._styleColorTheme.lut.data)&&v.setColorTheme(A)}}),this._changes.setDirty()}addLayer(m,v,A={}){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(B0(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(Mt,`layers.${D}`,m,{arrayIndex:-1},A))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 be=this._order.indexOf(v);if(be===-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=be}this._order.splice(W,0,D),this._handleLayerOrderChange(),this._layers[D]=z;const ee=this.getOwnLayerSourceCache(z),ne=!!this.directionalLight&&this.directionalLight.shadowsEnabled();ee&&z.canCastShadows()&&ne&&(ee.castsShadows=!0);const de=this._changes.getRemovedLayer(z);if(de&&z.source&&ee&&z.type!=="custom"){this._changes.discardLayerRemoval(z);const be=i.F(z.source,z.scope);de.type!==z.type?this._changes.updateSourceCache(be,"clear"):(this._changes.updateSourceCache(be,"reload"),ee.pause())}this._updateLayer(z),z.onAdd&&z.onAdd(this.map),z.scope=this.scope,this.mergeLayers()}moveLayer(m,v){this._checkLoaded();const A=this._checkLayer(m);if(!A||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.`)));A.slot&&A.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 A=this._order.indexOf(m);this._order.splice(A,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,A){this._checkLoaded();const D=this._checkLayer(m);D&&(D.minzoom===v&&D.maxzoom===A||(v!=null&&(D.minzoom=v),A!=null&&(D.maxzoom=A),this._updateLayer(D)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(m,v){this._checkLoaded();const A=this._checkLayer(m);A&&A.slot!==v&&(A.slot=v,this._updateLayer(A))}setFilter(m,v,A={}){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(Ht,`layers.${D.id}.filter`,v,{layerType:D.type},A)||(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,A,D={}){this._checkLoaded();const z=this._checkLayer(m);if(z&&!i.b6(z.getLayoutProperty(v),A)){if(A!=null&&(!D||D.validate!==!1)&&B0(z,Xt.call(zr,{key:`layers.${m}.layout.${v}`,layerType:z.type,objectKey:v,value:A,styleSpec:i.a8,style:{glyphs:!0,sprite:!0}})))return;z.setLayoutProperty(v,A),z.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(z.fqid),z.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(z.fqid),this._updateLayer(z)}}setLayerProperty(m,v,A,D={}){this._checkLoaded();const z=this._checkLayer(m);z&&(v==="appearances"?(z.setAppearances(A),this._updateLayer(z)):z.isPaintProperty(v)?this.setPaintProperty(m,v,A,D):this.setLayoutProperty(m,v,A,D))}getLayoutProperty(m,v){const A=this._checkLayer(m);if(A)return A.getLayoutProperty(v)}setPaintProperty(m,v,A,D={}){this._checkLoaded();const z=this._checkLayer(m);if(!z||i.b6(z.getPaintProperty(v),A)||A!=null&&(!D||D.validate!==!1)&&B0(z,Vt.call(zr,{key:`layers.${m}.paint.${v}`,layerType:z.type,objectKey:v,value:A,styleSpec:i.a8})))return;const B=z.setPaintProperty(v,A);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 A=this._checkLayer(m);if(A)return A.getPaintProperty(v)}setFeatureState(m,v){if(this._checkLoaded(),"target"in m){if("featuresetId"in m.target){const{featuresetId:ee,importId:ne}=m.target,de=this.getFragmentStyle(ne),be=de.getFeaturesetLayers(ee);for(const{source:ye,sourceLayer:Ce}of be)de.setFeatureState({id:m.id,source:ye,sourceLayer:Ce},v)}else if("layerId"in m.target){const{layerId:ee}=m.target,ne=this.getLayer(ee);this.setFeatureState({id:m.id,source:ne.source,sourceLayer:ne.sourceLayer},v)}return}const A=m.source,D=m.sourceLayer,z=this._checkSource(A);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(A);for(const ee of W)ee.setFeatureState(D,m.id,v)}removeFeatureState(m,v){if(this._checkLoaded(),"target"in m){if("featuresetId"in m.target){const{featuresetId:ee,importId:ne}=m.target,de=this.getFragmentStyle(ne),be=de.getFeaturesetLayers(ee);for(const{source:ye,sourceLayer:Ce}of be)de.removeFeatureState({id:m.id,source:ye,sourceLayer:Ce},v)}else if("layerId"in m.target){const{layerId:ee}=m.target,ne=this.getLayer(ee);this.removeFeatureState({id:m.id,source:ne.source,sourceLayer:ne.sourceLayer},v)}return}const A=m.source,D=this._checkSource(A);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(A);for(const ee of W)ee.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,ee=this.getFragmentStyle(W),ne=ee.getFeaturesetLayers(B);for(const{source:de,sourceLayer:be}of ne){const ye=ee.getFeatureState({id:m.id,source:de,sourceLayer:be});if(ye&&!z)z=ye;else if(!i.b6(z,ye))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,A=m.sourceLayer,D=this._checkSource(v);if(D){if(D.type!=="vector"||A)return m.id===void 0&&this.fire(new i.B(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(v)[0].getFeatureState(A,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)},A=>A!==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),A=i.F(m.source,m.scope),D=this._changes.getUpdatedSourceCaches();m.source&&!D[A]&&v&&v.getSource().type!=="raster"&&(this._changes.updateSourceCache(A,"reload"),v.pause()),m.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(m){const v=W=>this._mergedLayers[W].is3D(!!this.terrain),A=this.order,D={},z=[];for(let W=A.length-1;W>=0;W--){const ee=A[W];if(v(ee)){D[ee]=W;for(const ne of m){const de=ne[ee];if(de)for(const be of de)z.push(be)}}}z.sort((W,ee)=>ee.intersectionZ-W.intersectionZ);const B=[];for(let W=A.length-1;W>=0;W--){const ee=A[W];if(v(ee))for(let ne=z.length-1;ne>=0;ne--){const de=z[ne].feature;if(de.layer&&D[de.layer.id]{if(zE.has(de.type))return;const be=this.getOwnLayerSourceCache(de),ye=z[be.id]=z[be.id]||{sourceCache:be,layers:{},has3DLayers:!1};de.is3D(!!this.terrain)&&(ye.has3DLayers=!0),ye.layers[de.fqid]=ye.layers[de.fqid]||{styleLayer:de,targets:[]},ye.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 be=this._layers[de];if(!be)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(be)}}else for(const de in this._layers)B(this._layers[de]);const W=this._queryRenderedFeatures(m,z,A),ee=this._flattenAndSortRenderedFeatures(W),ne=[];for(const de of ee)i.dh(de.layer.id)===this.scope&&ne.push(de);return ne}queryRenderedFeatureset(m,v,A){let D;v&&!Array.isArray(v)&&v.filter&&(this._validate(Ht,"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 be of de)B.push({targetId:z,filter:D,target:be});for(const{style:be}of this.fragments){const ye=be.getFeaturesetDescriptors();for(const Ce of ye)B.push({targetId:z,filter:D,target:Ce})}}const W=this.queryRenderedTargets(m,B,A),ee=[],ne=new Set;for(const de of W)for(const be of de.variants[z])Kh(be,de,ne)||ee.push(new i.di(de,be));return ee}queryRenderedTargets(m,v,A){const D={},z=(W,ee,ne,de)=>{const be=D[ee.id]=D[ee.id]||{sourceCache:ee,layers:{},has3DLayers:!1};if(be.layers[W.fqid]=be.layers[W.fqid]||{styleLayer:W,targets:[]},W.is3D(!!this.terrain)&&(be.has3DLayers=!0),!de)return ne.uniqueFeatureID=!1,void be.layers[W.fqid].targets.push(ne);be.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:ee,importId:ne}=W.target,de=this.getFragmentStyle(ne);if(!de||!de._featuresetSelectors)continue;const be=de._featuresetSelectors[ee];if(!be){this.fire(new i.B(new Error(`The featureset '${ee}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const ye of be){const Ce=de.getOwnLayer(ye.layerId);Ce&&!zE.has(Ce.type)&&z(Ce,de.getOwnLayerSourceCache(Ce),W,ye)}}else if("layerId"in W.target){const{layerId:ee}=W.target,ne=this.getLayer(ee);if(!ne||zE.has(ne.type))continue;z(ne,this.getLayerSourceCache(ne),W)}const B=this._queryRenderedFeatures(m,D,A);return this._flattenAndSortRenderedFeatures(B)}_queryRenderedFeatures(m,v,A){const D=[],z=!!this.map._showQueryGeometry,B=bu.createFromScreenPoints(m,A);for(const W in v){const ee=Sf(B,v[W],this._availableImages,A,z,this.getActualScope());Object.keys(ee).length&&D.push(ee)}if(this.placement)for(const W in v){if(v[W].sourceCache._renderSourceType!==i.b4.Symbol)continue;const ee=zx(B.screenGeometry,v[W],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(ee).length&&D.push(ee)}return D}querySourceFeatures(m,v){const A=v&&v.filter;A&&this._validate(Ht,"querySourceFeatures.filter",A,null,v);let D=[];const z=this.getOwnSourceCaches(m);for(const B of z)D=D.concat(Cd(B,v));return D}addSourceType(m,v,A){return Um.getSourceType(m)?A(new Error(`A source type called "${m}" already exists.`)):(Um.setSourceType(m,v),v.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:m,url:v.workerSourceURL},A):A(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(m,v,A={}){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,A),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 A=m;const D=!("source"in m)||m.source==null;if(v===1){if(this.disableElevatedTerrain)return;if("source"in A&&typeof A.source=="object"){const W="terrain-dem-src";this.addSource(W,A.source),A=i.d9(A),A=Object.assign(A,{source:W})}const z=Object.assign({},A),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(Oe,"terrain",z,B))return}if(!this.terrain||this.terrain.scope!==this.scope&&!D||this.terrain&&v!==this.terrain.drapeRenderMode){if(!A)return;this._createTerrain(A,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))!A.hasOwnProperty(W)&&i.a8.terrain[W].default&&(A[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 ee=this._getTransitionParameters({duration:0});z.updateTransitions(ee),this.fire(new i.C("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(m){const v=this.fog=new Fi(m,this.map.transform,this.scope,this.options);this.stylesheet.fog=v.get();const A=this._getTransitionParameters({duration:0});v.updateTransitions(A)}_createSnow(m){const v=this.snow=new Yi(m,this.map.transform,this.scope,this.options);this.stylesheet.snow=v.get();const A=this._getTransitionParameters({duration:0});v.updateTransitions(A)}_createRain(m){const v=this.rain=new ua(m,this.map.transform,this.scope,this.options);this.stylesheet.rain=v.get();const A=this._getTransitionParameters({duration:0});v.updateTransitions(A)}_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 A=this._getTransitionParameters({duration:0});v.updateTransitions(A)}}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 A=this._getTransitionParameters({duration:0});v.updateTransitions(A)}}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 A=this._getTransitionParameters({duration:0});v.updateTransitions(A)}}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 A=this._evaluateColorThemeData(v);this._loadColorTheme(A).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 A=this.getFragmentStyle(m);A&&(A._styleColorTheme.colorThemeOverride=v,A._reloadColorTheme())}_getTransitionParameters(m){return{now:i.o.now(),transition:Object.assign(this.transition,m)}}updateDrapeFirstLayers(){if(!this.terrain)return;const m=[],v=[];for(const A of this._mergedOrder)this.isLayerDraped(this._mergedLayers[A])?m.push(A):v.push(A);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...m),this._drapedFirstOrder.push(...v)}_createTerrain(m,v){const A=this.terrain=new Gn(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});A.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,A,D,z={}){if(z&&z.validate===!1)return!1;const B=Object.assign({},this.serialize());return B0(this,m.call(zr,Object.assign({key:v,style:B,value:A,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 A of v)A.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 A of v)A.resume(),A.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=AO(this.directionalLight));const A=new Set,D=new Set,z=new Set;for(const B in this._mergedLayers){const W=this._mergedLayers[B];W.type==="building"?A.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],ee=D.has(W._source.id);W._isRasterElevatedOverTerrain=z.has(W._source.id),A.has(W._source.id)&&(W._source.reparseOverscaled=!1),W.update(m,void 0,void 0,v,ee)}}_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 Lw),this.pauseablePlacement.requestFullPlacement()}_setLabelPlacementStale(){this.placement&&this.placement.setStale()}_updatePlacement(m,v,A,D,z){this.pauseablePlacement||(this.pauseablePlacement=new Lw);let B=!1,W=!1;const ee={},ne={};for(const Ie of this._mergedOrder){const st=this._mergedLayers[Ie];if(st.type!=="symbol")continue;const tt=i.F(st.source,st.scope);let ct=ee[tt];if(!ct){const nt=this.getLayerSourceCache(st);if(!nt)continue;const Ft=nt.getRenderableIds(!0).map(wt=>nt.getTileByID(wt));ne[tt]=Ft.slice(),ct=ee[tt]=Ft.sort((wt,Dt)=>Dt.tileID.overscaledZ-wt.tileID.overscaledZ||(wt.tileID.isLessThan(Dt.tileID)?-1:1))}const mt=this.crossTileSymbolIndex.addLayer(st,ct,m.center.lng,m.projection);B=B||mt}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const de=!!(this.placement&&!m.equals(this.placement.transform)),be=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!z||this.placement.lastReplacementSourceUpdateTime!==z.updateTime)),ye=de||be||B,Ce=(ye||this.pauseablePlacement.isStale())&&A===0,Be=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),m.zoom)&&A!==0;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||Ce||Be)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(m,this._mergedOrder,v,A,D,this.placement,this.fog&&m.projection.supportsFog?this.fog.state:null,this._buildingIndex),this.map.painter)){const Ie=this.map.painter.maxFrontCutoffRawStart;if(Ie>0){const st=180*m.pitch/Math.PI;if(st>=15){const tt=Math.min(1,Math.max(0,(st-15)/5)),ct=tt*tt*(3-2*tt);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-ct)+Ie*ct}}}if(this.pauseablePlacement.isDone()?ye&&A!==0&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,ee,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 Ie=0;Iez===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 A.push(m),this._loadImports([m],!0);const D=A.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=A.slice(0,D).concat(m).concat(A.slice(D)),this._loadImports([m],!0,v)}updateImport(m,v){this._checkLoaded();const A=this.stylesheet.imports||[],D=this.getImportIndex(m);return D===-1?this:typeof v=="string"?(this.setImportUrl(m,v),this):(v.url&&v.url!==A[D].url&&this.setImportUrl(m,v.url),i.b6(v.config,A[D].config)||this.setImportConfig(m,v.config,v.data.schema),i.b6(v.data,A[D].data)||this.setImportData(m,v.data),this)}moveImport(m,v){this._checkLoaded();let A=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=A[D],W=this.fragments[D];return A=A.filter(({id:ee})=>ee!==m),this.fragments=this.fragments.filter(({id:ee})=>ee!==m),this.stylesheet.imports=A.slice(0,z).concat(B).concat(A.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 A=this.stylesheet.imports||[],D=this.getImportIndex(m);if(D===-1)return this;A[D].url=v;const z=this.fragments[D];return z.style=this._createFragmentStyle(A[D]),z.style.on("style.import.load",()=>this.mergeAll()),z.style.loadURL(v),this}setImportData(m,v){this._checkLoaded();const A=this.getImportIndex(m),D=this.stylesheet.imports||[];return A===-1?this:v?(this.fragments[A].style.setState(v),this._reloadImports(),this):(delete D[A].data,this.setImportUrl(m,D[A].url))}setImportConfig(m,v,A){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];A&&B.style.stylesheet&&(B.style.stylesheet.schema=A);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||[],A=this.getImportIndex(m);A!==-1&&(v.splice(A,1),this.fragments[A].style._remove(),this.fragments.splice(A,1),this._reloadImports())}getImportIndex(m){const v=(this.stylesheet.imports||[]).findIndex(A=>A.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 A=this._mergedOtherSourceCaches[v];A&&m.push(A.getSource())}return m}getSource(m,v){const A=this.getSourceCache(m,v);return A&&A.getSource()}getLayerSource(m){const v=this.getLayerSourceCache(m);return v&&v.getSource()}getSourceCache(m,v){const A=i.F(m,v);return this._mergedOtherSourceCaches[A]}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 A=m[v];A==="reload"?this.reloadSource(v):A==="clear"&&this.clearSource(v)}}updateLayers(m){const v=this._changes.getUpdatedPaintProperties();for(const A of v){const D=this.getLayer(A);D&&D.updateTransitions(m)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(m){this.stylesheet.glyphs=m,this.glyphManager.setURL(m)}getImages(m,v,A){this.imageManager.getImages(v.images,v.scope,A),this._updateTilesForChangedImages();const D=B=>{if(B){const W=v.images.map(ee=>i.I.toString(ee));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,A){this.imageManager.rasterizeImages(v,A)}checkAtlasCache(m,v,A){const D=this.imageManager.imageAtlasCache.findCachedAtlas(v.descriptor);A(null,D&&D.contentDescriptor?{iconPositions:D.iconPositions,patternPositions:D.patternPositions,sourceHash:D.contentDescriptor.hash}:null)}getGlyphs(m,v,A){this.glyphManager.getGlyphs(v.stacks,A)}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(A=>A.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 A=m.type==="fill-extrusion"&&(m.sourceLayer==="building"||m.sourceLayer==="procedural_buildings"),D=m.type==="building";if(m.is3D(!!this.terrain)){if(A||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)}}Um.getSourceType=function(M){return kp[M]},Um.setSourceType=function(M,m){kp[M]=m},Um.registerForPluginStateChange=i.dk;var $E=` #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`,qE=` #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;}`,ny=` #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`,qw="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;}",UE=` #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`,VE=`#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`,R1=`#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`,O1=`#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`,HE=`#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;}`,$C=`#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`,Xh=`#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 Uw=/#include\s+"([^"]+)"/g,sr=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,IO=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,LO=new Set(["ifdef","ifndef","elif","if","defined"]),$0=new Set;Vx($E,$0),Vx(ny,$0),Vx(qE,$0);const Ep={"_prelude_fog.vertex.glsl":VE,"_prelude_terrain.vertex.glsl":UE,"_prelude_shadow.vertex.glsl":$C,"_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":R1,"_prelude_shadow.fragment.glsl":Xh,"_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":O1,"_prelude_raster_particle.glsl":HE},F1={};ya("",UE),ya(R1,VE),ya(Xh,$C),ya(O1,""),ya(HE,"");const ay=ya(qE,ny),Vw=$E,z1=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",Vw,ay.fragmentSource].join(` `),lpe=["precision highp float;",Vw,ay.vertexSource].join(` `);var DO={background:ya(`#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:ya(`#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:ya(`#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:ya(`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:ya("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),circle:ya(`#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:ya("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:ya(`#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:ya(`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:ya("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:ya("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:ya("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:ya("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:ya(`#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:ya(`#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:ya(`#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:ya(`#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:ya(`#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:ya(`#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:ya(`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:ya(`#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:ya("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:ya(`#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:ya(`#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:ya(`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:ya(`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:ya(`#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:ya(`#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:ya(`#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:ya(`#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:ya(`#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:ya("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:ya("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:ya(`#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:ya(`#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:ya(`#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:ya("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:ya(`#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 }`,qw),skyboxGradient:ya(`#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 }`,qw),skyboxCapture:ya(` 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:ya(`#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:ya(`#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:ya(`#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:ya("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:ya(`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:ya("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:ya("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:ya("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:ya("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 Vx(M,m){const v=M.split(` `);for(let A of v){if(A=A.trimStart(),A[0]!=="#"||!A.includes("if")||A.startsWith("#endif"))continue;const D=A.match(IO);if(D)for(const z of D)LO.has(z)||m.add(z)}}function RO(M){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(M)}function ya(M,m){const v=new Set,A=[],D=[];M=M.replace(Uw,(B,W)=>(D.push(W),"")),m=m.replace(Uw,(B,W)=>(A.push(W),""));let z=new Set($0);Vx(M,z),Vx(m,z);for(const B of[...A,...D])F1[B]||(F1[B]=new Set,Vx(Ep[B],F1[B])),z=new Set([...z,...F1[B]]);return{fragmentSource:M=M.replace(sr,(B,W,ee,ne,de)=>(v.add(de),W==="define"?` #ifndef HAS_UNIFORM_u_${de} ${RO(ne)?"flat ":""}in ${ee} ${ne} ${de}; #else uniform ${ee} ${ne} u_${de}; #endif `:W==="initialize"?` #ifdef HAS_UNIFORM_u_${de} ${ee} ${ne} ${de} = u_${de}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${de} in ${ee} ${ne} ${de}; #endif `:W==="initialize-attribute"?"":void 0)),vertexSource:m=m.replace(sr,(B,W,ee,ne,de)=>{const be=`MATERIAL_ATTRIBUTE_OFFSET_${de}`,ye=ne==="float"?"vec2":ne,Ce=`GET_ATTRIBUTE_${ye}(a_${de}, materialInfo, ${be})`,Be=de.match(/color/)?"color":ye;return W==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${de} in ${ee} ${ne} a_${de}; #endif `:v.has(de)?W==="define"?` #ifndef HAS_UNIFORM_u_${de} uniform lowp float u_${de}_t; #if !defined(${be}) in ${ee} ${ye} a_${de}; #endif ${RO(ne)?"flat ":""}out ${ee} ${ne} ${de}; #else uniform ${ee} ${ne} u_${de}; #endif `:W==="initialize"?Be==="vec4"||Be==="uvec4"?` #ifndef HAS_UNIFORM_u_${de} ${de} = a_${de}; #else ${ee} ${ne} ${de} = u_${de}; #endif `:` #if !defined(HAS_UNIFORM_u_${de}) #ifdef ${be} ${de} = unpack_mix_${Be}(${Ce}, u_${de}_t); #else ${de} = unpack_mix_${Be}(a_${de}, u_${de}_t); #endif #else ${ee} ${ne} ${de} = u_${de}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${de} in ${ee} ${ne} a_${de}; out ${ee} ${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(${be}) in ${ee} ${ye} a_${de}; #endif #else uniform ${ee} ${ne} u_${de}; #endif `:W==="define-instanced"?Be==="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 ${ee} ${ne} u_${de}; #endif `:` #ifdef INSTANCED_ARRAYS in ${ee} ${ye} a_${de}; #else uniform ${ee} ${ne} u_${de}; #endif `:W==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${de} ${ee} ${ne} ${de} = a_${de}; #endif `:Be==="vec4"||Be==="uvec4"?` #ifndef HAS_UNIFORM_u_${de} #ifdef ${be} ${ee} ${ne} ${de} = ${Ce}; #else ${ee} ${ne} ${de} = a_${de}; #endif #else ${ee} ${ne} ${de} = u_${de}; #endif `:` #ifndef HAS_UNIFORM_u_${de} #ifdef ${be} ${ee} ${ne} ${de} = unpack_mix_${Be}(${Ce}, u_${de}_t); #else ${ee} ${ne} ${de} = unpack_mix_${Be}(a_${de}, u_${de}_t); #endif #else ${ee} ${ne} ${de} = u_${de}; #endif `}),usedDefines:z,vertexIncludes:A,fragmentIncludes:D}}class OO{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(m,v,A,D,z,B,W,ee){this.context=m;let ne=this.boundPaintVertexBuffers.length!==D.length;for(let be=0;!ne&&be{const Ft=mt.paint.get("hillshade-shadow-color"),wt=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",yt=mt.paint.get("hillshade-accent-color"),Tt=mt.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Wt=mt.paint.get("hillshade-emissive-strength");let Bt=i.ap(mt.paint.get("hillshade-illumination-direction"));if(mt.paint.get("hillshade-illumination-anchor")==="viewport")Bt-=tt.transform.angle;else if(tt.style&&tt.style.enable3dLights()&&tt.style.directionalLight){const Qt=tt.style.directionalLight.properties.get("direction"),ws=i.cP(Qt.x,Qt.y,Qt.z);Bt=i.ap(ws[1])}const ns=!tt.options.moving;return{u_matrix:nt||tt.transform.calculateProjMatrix(ct.tileID.toUnwrapped(),ns),u_image:0,u_latrange:GE(0,ct.tileID),u_light:[mt.paint.get("hillshade-exaggeration"),Bt],u_shadow:Ft.toPremultipliedRenderColor(wt?null:mt.lut),u_highlight:Dt.toPremultipliedRenderColor(pt?null:mt.lut),u_emissive_strength:Wt,u_accent:yt.toPremultipliedRenderColor(Tt?null:mt.lut)}})(M,v,A,M.terrain?m.projMatrix:null);M.uploadCommonUniforms(W,ye,m.toUnwrapped());const{tileBoundsBuffer:Be,tileBoundsIndexBuffer:Ie,tileBoundsSegments:st}=M.getTileBoundsBuffers(v);ye.draw(M,ee.TRIANGLES,D,z,B,Wr.disabled,Ce,A.id,Be,Ie,st)}function FO(M,m,v){if(!m.needsDEMTextureUpload)return;const A=M.context,D=A.gl;A.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(A,z,D.R32F,{premultiply:!1}),m.needsDEMTextureUpload=!1}function dpe(M,m,v){const A=M.context,D=A.gl;if(!m.dem)return;const z=m.dem;if(A.activeTexture.set(D.TEXTURE1),FO(M,m,z),!m.demTexture)return;m.demTexture.bind(D.NEAREST,D.CLAMP_TO_EDGE);const B=z.dim;A.activeTexture.set(D.TEXTURE0);let W=m.hillshadeFBO;if(!W){const ye=new i.T(A,{width:B,height:B,data:null},D.RGBA8);ye.bind(D.LINEAR,D.CLAMP_TO_EDGE),W=m.hillshadeFBO=A.createFramebuffer(B,B,1,"renderbuffer"),W.colorAttachment0.set(ye.texture)}A.bindFramebuffer.set(W.framebuffer),A.viewport.set([0,0,B,B]);const{tileBoundsBuffer:ee,tileBoundsIndexBuffer:ne,tileBoundsSegments:de}=M.getMercatorTileBoundsBuffers(),be=[];M.linearFloatFilteringSupported()&&be.push("TERRAIN_DEM_FLOAT_FORMAT"),M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&be.push("USE_MRT1"),M.getOrCreateProgram("hillshadePrepare",{defines:be}).draw(M,D.TRIANGLES,Nr.disabled,nn.disabled,tn.unblended,Wr.disabled,((ye,Ce)=>{const Be=Ce.stride,Ie=i.bb();return i.bT(Ie,0,i.an,-i.an,0,0,1),i.bx(Ie,Ie,[0,-i.an,0]),{u_matrix:Ie,u_image:1,u_dimension:[Be,Be],u_zoom:ye.overscaledZ}})(m.tileID,z),v.id,ee,ne,de),m.needsHillshadePrepare=!1}class ro{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 zO extends ro{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 upe extends ro{getDefault(){return 1}set(m){(m!==this.current||this.dirty)&&(this.gl.clearDepth(m),this.current=m,this.dirty=!1)}}class qC extends ro{getDefault(){return 0}set(m){(m!==this.current||this.dirty)&&(this.gl.clearStencil(m),this.current=m,this.dirty=!1)}}class hpe extends ro{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 BO extends ro{getDefault(){return!0}set(m){(m!==this.current||this.dirty)&&(this.gl.depthMask(m),this.current=m,this.dirty=!1)}}class WE extends ro{getDefault(){return 255}set(m){(m!==this.current||this.dirty)&&(this.gl.stencilMask(m),this.current=m,this.dirty=!1)}}class UC extends ro{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 KE extends ro{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 q0 extends ro{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 U0 extends ro{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 B1 extends ro{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 Af extends ro{getDefault(){return this.gl.LESS}set(m){(m!==this.current||this.dirty)&&(this.gl.depthFunc(m),this.current=m,this.dirty=!1)}}class $O extends ro{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 ZE extends ro{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 qO extends ro{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 $1 extends ro{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 VC extends ro{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 HC extends ro{getDefault(){return this.gl.BACK}set(m){(m!==this.current||this.dirty)&&(this.gl.cullFace(m),this.current=m,this.dirty=!1)}}class YE extends ro{getDefault(){return this.gl.CCW}set(m){(m!==this.current||this.dirty)&&(this.gl.frontFace(m),this.current=m,this.dirty=!1)}}let GC=class extends ro{getDefault(){return null}set(M){(M!==this.current||this.dirty)&&(this.gl.useProgram(M),this.current=M,this.dirty=!1)}};class Hw extends ro{getDefault(){return this.gl.TEXTURE0}set(m){(m!==this.current||this.dirty)&&(this.gl.activeTexture(m),this.current=m,this.dirty=!1)}}class UO extends ro{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 VO extends ro{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 HO extends ro{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 q1 extends ro{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 GO extends ro{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 mpe extends ro{getDefault(){return null}set(m){const v=this.gl;v.bindBuffer(v.ELEMENT_ARRAY_BUFFER,m),this.current=m,this.dirty=!1}}class ppe extends ro{getDefault(){return null}set(m){this.gl&&(m!==this.current||this.dirty)&&(this.gl.bindVertexArray(m),this.current=m,this.dirty=!1)}}class fpe extends ro{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 XE extends ro{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 QE extends ro{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 Gw extends ro{constructor(m,v){super(m),this.context=m,this.parent=v}getDefault(){return null}}class U1 extends Gw{constructor(m,v,A=0){super(m,v),this.attachmentPoint=m.gl.COLOR_ATTACHMENT0+A}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 JE extends Gw{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 WO extends Gw{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 xpe extends JE{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const Ww=(M,m,v,A)=>({u_matrix:M,u_image0:0,u_image1:1,u_skirt_height:m,u_ground_shadow_factor:v,u_emissive_texture_available:A}),V1=(M,m,v,A,D,z,B,W,ee,ne,de,be,ye,Ce,Be,Ie,st)=>({u_proj_matrix:Float32Array.from(M),u_globe_matrix:m,u_normalize_matrix:Float32Array.from(A),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:ee,u_frustum_bl:ne,u_globe_pos:de,u_globe_radius:be,u_viewport:ye,u_grid_matrix:st?Float32Array.from(st):new Float32Array(9),u_skirt_height:Ce,u_far_z_cutoff:Be,u_emissive_texture_available:Ie});function eP(M,m){return M!=null&&m!=null&&!(!M.hasData()||!m.hasData())&&M.demTexture!=null&&m.demTexture!=null&&M.tileID.key!==m.tileID.key}const Td=new class{constructor(){this.operations={}}newMorphing(M,m,v,A,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:A,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()}},WC={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Kw(M,m,v){if(m===0)return 0;const A=m<1&&v===514?.25/m:1;return 6*Math.pow(1.5,22-M)*Math.max(m,1)*A}function KC(M,m){const v=1<({u_matrix:M});function Xw(M,m,v,A,D){if(D>0){const z=i.o.now(),B=(z-M.timeAdded)/D,W=m?(z-m.timeAdded)/D:-1,ee=v.getSource(),ne=A.coveringZoomLevel({tileSize:ee.tileSize,roundZoom:ee.roundZoom}),de=!m||Math.abs(m.tileID.overscaledZ-ne)>Math.abs(M.tileID.overscaledZ-ne),be=de&&M.refreshedUponExpiration?1:i.aC(de?B:1-W,0,1);return m?{opacity:1,mix:1-be,isFading:B<1}:{opacity:be,mix:0,isFading:B<1}}return{opacity:1,mix:0,isFading:!1}}class ZC extends gh{constructor(m){const v={type:"raster-dem",maxzoom:Math.ceil(m.transform.maxZoom)},A=Sp("mock-dem",v,m.style.dispatcher,m.style);super("mock-dem",A,null),A.setEventedParent(this),this._sourceLoaded=!0}_loadTile(m,v){m.state="loaded",v(null)}}class tP extends gh{constructor(m){const v=Sp("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,A){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 A=Object.values(v);this.renderCachePool.push(...A),delete this.proxyCachedFBO[m]}}deallocRenderCache(){this.renderCache.forEach(m=>m.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class YC extends i.aR{constructor(m,v,A){super(m.overscaledZ,m.wrap,m.canonical.z,m.canonical.x,m.canonical.y),this.proxyTileKey=v,this.projMatrix=A}}class Qw extends i.bu{constructor(m,v){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=m,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[A,D,z]=function(){const ee=new i.dB,ne=new i.dC,de=131;ee.reserve(17161),ne.reserve(33800);const be=i.an/128,ye=i.an+be/2,Ce=ye+be;for(let Ie=-be;Ieye||Ie<0||Ie>ye?24575:0,ct=i.aC(Math.round(st),0,i.an),mt=i.aC(Math.round(Ie),0,i.an);ee.emplaceBack(ct+tt,mt)}const Be=(Ie,st)=>{const tt=st*de+Ie;ne.emplaceBack(tt+1,tt,tt+de),ne.emplaceBack(tt+de,tt+de+1,tt+1)};for(let Ie=1;Ie<129;Ie++)for(let st=1;st<129;st++)Be(st,Ie);return[0,129].forEach(Ie=>{for(let st=0;st<130;st++)Be(st,Ie),Be(Ie,st)}),[ee,ne,32768]}(),B=m.context;this.gridBuffer=B.createVertexBuffer(A,i.dx.members),this.gridIndexBuffer=B.createIndexBuffer(D),this.gridSegments=i.dy.simpleSegment(0,0,A.length,D.length),this.gridNoSkirtSegments=i.dy.simpleSegment(0,0,A.length,z),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new tP(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 nn({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 ZC(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,A){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,ee=D.get("source"),ne=z?this._mockSourceCache:m.getSourceCache(ee,W);if(!ne)return void i.w(`Couldn't find terrain source "${ee}".`);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 be=this.getScaledDemTileSize();this.sourceCache.update(v,be,!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,A),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,A=m.getFreeCameraOptions().position.z/m.pixelsPerMeter*m.worldSize;this._previousCameraAltitude=A;const D=v!=null?A-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 ee=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),be=de===B.getExaggeration(Math.max(0,ne-.1));if(be&&Math.abs(de-this._exaggeration)<.01)return de;let ye=Math.min(.1,.00375*(this._updateTimestamp-ee));return(be||de<.1||Math.abs(W)<1e-4)&&(ye=Math.min(.2,4*ye)),i.am(this._exaggeration,de,ye)}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,A=this.painter.transform;this._initializing&&(this._initializing=A._centerAltitude===0&&this.getAtPointOrZero(i.ag.fromLngLat(A.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const D=this.proxyCoords=v.getIds().map(ee=>{const ne=v.getTileByID(ee).tileID;return ne.projMatrix=A.calculateProjMatrix(ne.toUnwrapped()),ne});(function(ee,ne){const de=ne.transform.pointCoordinate(ne.transform.getCameraPoint()),be=new i.P(de.x,de.y);ee.sort((ye,Ce)=>{if(Ce.overscaledZ-ye.overscaledZ)return Ce.overscaledZ-ye.overscaledZ;const Be=new i.P(ye.canonical.x+(1<{this.proxyToSource[ee.key]={}}),this.terrainTileForTile={};const B=this._style._mergedSourceCaches;for(const ee in B){const ne=B[ee];if(!ne.used||(ne!==this.sourceCache&&this.resetTileLookupCache(ne.id),this._setupProxiedCoordsForOrtho(ne,m[ee],z),ne.usedForTerrain))continue;const de=m[ee];(ne.getSource().reparseOverscaled||ne._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(de)}this.proxiedCoords[v.id]=D.map(ee=>new YC(ee,ee.key,this.orthoMatrix)),this._assignTerrainTiles(D),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(z),this.renderingToTexture=!1;const W={};this._visibleDemTiles=[];for(const ee of this.proxyCoords){const ne=this.terrainTileForTile[ee.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 A=this._findTileCoveringTileID(v,this.sourceCache);A&&(this.terrainTileForTile[v.key]=A)})}_prepareDEMTextures(){const m=this.painter.context,v=m.gl;for(const A in this.terrainTileForTile){const D=this.terrainTileForTile[A],z=D.dem;!z||D.demTexture&&!D.needsDEMTextureUpload||(m.activeTexture.set(v.TEXTURE1),FO(this.painter,D,z))}}_prepareDemTileUniforms(m,v,A,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 A[`u_dem_tl${W}`]=[z.x*B%1,z.y*B%1],A[`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((A,D)=>{if(!D.dem)return A;const z=D.dem.tree.minimums[0];return z>0&&m++,A+z},0);return m?v/m:0}_updateEmptyDEMTexture(){const m=this.painter.context,v=m.gl;m.activeTexture.set(v.TEXTURE2);const A=this._getLoadedAreaMinimum(),D=new i.dz({width:1,height:1},new Float32Array([A]));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,A){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,ee=null,ne=1;if(A&&A.morphing&&this._useVertexMorphing){const Ce=A.morphing.srcDemTile,Be=A.morphing.dstDemTile;ne=A.morphing.phase,Ce&&Be&&(this._prepareDemTileUniforms(m,Ce,B,"_prev")&&(ee=Ce),this._prepareDemTileUniforms(m,Be,B)&&(W=Be))}const de=Ce=>Ce&&Ce.demTexture&&this.painter.linearFloatFilteringSupported()?z.LINEAR:z.NEAREST;let be=null;var ye;if(this.enabled?ee&&W?(be=W.demTexture,D.activeTexture.set(z.TEXTURE4),ee.demTexture.bind(de(ee),z.CLAMP_TO_EDGE),B.u_dem_lerp=ne):(W=this.terrainTileForTile[m.tileID.key],be=this._prepareDemTileUniforms(m,W,B)?W.demTexture:this.emptyDEMTexture):be=this.emptyDEMTexture,D.activeTexture.set(z.TEXTURE2),be&&(B.u_dem_size=(ye=be).size[0]===1?1:ye.size[0]-2,be.bind(de(W),z.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(A&&A.useDepthForOcclusion,v,B),A&&A.useMeterToDem&&W){const Ce=(1<{if(tt===Qt)return;const ws=[WC[Qt],"PROJECTION_GLOBE_VIEW"];mt&&ws.push("CUSTOM_ANTIALIASING");const As=ne.isTileAffectedByFog(ns);st=ne.getOrCreateProgram("globeRaster",{defines:ws,overrideFog:As}),tt=Qt},Ft=ne.colorModeForRenderPass(),wt=new Nr(Ie.LEQUAL,Nr.ReadWrite,ne.depthRangeFor3D);Td.update(Ce);const Dt=i.dq(ct),pt=[i.aH(ct.center.lng),i.aL(ct.center.lat)],yt=ne.globeSharedBuffers,Tt=[ct.width*i.o.devicePixelRatio,ct.height*i.o.devicePixelRatio],Wt=Float32Array.from(ct.globeMatrix),Bt={useDenormalizedUpVectorScale:!0};{const ns=ne.transform,Qt=Kw(ns.zoom,de.exaggeration(),de.sourceCache._source.tileSize);tt=-1;const ws=Ie.TRIANGLES;for(const As of ye){const Zt=be.getTile(As),Ut=nn.disabled,ts=de.prevTerrainTileForTile[As.key],as=de.terrainTileForTile[As.key];eP(ts,as)&&Td.newMorphing(As.key,ts,as,Ce,250),Zw(ne,Zt.emissiveTexture),Be.activeTexture.set(Ie.TEXTURE0),Zt.texture&&Zt.texture.bind(Ie.LINEAR,Ie.CLAMP_TO_EDGE);const cs=Td.getMorphValuesForProxy(As.key),Qs=cs?1:0;cs&&Object.assign(Bt,{morphing:{srcDemTile:cs.from,dstDemTile:cs.to,phase:i.dn(cs.phase)}});const Hs=i.dr(As.canonical),Gs=i.ds(Hs.getCenter().lat),Cs=i.dt(As.canonical,Hs,Gs,ns.worldSize/ns._pixelsPerMercatorPixel),br=i.du(i.dv(As.canonical)),Ar=ne.emissiveMode==="mrt-fallback"?1:0,mr=V1(ns.expandedFarZProjMatrix,Wt,Dt,br,i.al(ns.zoom),pt,ns.frustumCorners.TL,ns.frustumCorners.TR,ns.frustumCorners.BR,ns.frustumCorners.BL,ns.globeCenterInViewSpace,ns.globeRadius,Tt,Qt,ns._farZ,Ar,Cs);if(nt(As,Qs),st&&(de.setupElevationDraw(Zt,st,Bt),ne.uploadCommonUniforms(Be,st,As.toUnwrapped()),yt)){const[yr,Zr,xn]=yt.getGridBuffers(Gs,Qt!==0);st.draw(ne,ws,wt,Ut,Ft,Wr.backCCW,mr,"globe_raster",yr,Zr,xn)}}}if(yt&&(ne.renderDefaultNorthPole||ne.renderDefaultSouthPole)){const ns=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];mt&&ns.push("CUSTOM_ANTIALIASING"),st=ne.getOrCreateProgram("globeRaster",{defines:ns});for(const Qt of ye){const{x:ws,y:As,z:Zt}=Qt.canonical,Ut=As===0,ts=As===(1<yr.draw(ne,Ie.TRIANGLES,wt,nn.disabled,Ft,Wr.disabled,V1(ct.expandedFarZProjMatrix,Cs,Cs,br,0,pt,ct.frustumCorners.TL,ct.frustumCorners.TR,ct.frustumCorners.BR,ct.frustumCorners.BL,ct.globeCenterInViewSpace,ct.globeRadius,Tt,0,ct._farZ,Ar),"globe_pole_raster",Zr,Qs,Hs);de.setupElevationDraw(Gs,st,Bt),ne.uploadCommonUniforms(Be,st,Qt.toUnwrapped()),Ut&&ne.renderDefaultNorthPole&&mr(st,as),ts&&ne.renderDefaultSouthPole&&(Cs=i.cC(i.bb(),Cs,[1,-1,1]),mr(st,cs))}}}})(D,z,B,W,ee);else{const ne=D.context,de=ne.gl;let be,ye;const Ce=D.shadowRenderer,Be=nc(D,D.longestCutoffRange),Ie=Ft=>{if(ye===Ft)return;const wt=[];wt.push(WC[Ft]),Be.shouldRenderCutoff&&wt.push("RENDER_CUTOFF"),Ce&&(wt.push("RENDER_SHADOWS"),Ce.useNormalOffset&&wt.push("NORMAL_OFFSET")),be=D.getOrCreateProgram("terrainRaster",{defines:wt}),ye=Ft},st=D.colorModeForRenderPass(),tt=new Nr(de.LEQUAL,Nr.ReadWrite,D.depthRangeFor3D);Td.update(ee);const ct=D.transform,mt=Kw(ct.zoom,z.exaggeration(),z.sourceCache._source.tileSize);let nt=[0,0,0];if(Ce){const Ft=D.style.directionalLight,wt=D.style.ambientLight;Ft&&wt&&(nt=Ap(D.style,Ft,wt))}{ye=-1;const Ft=de.TRIANGLES,[wt,Dt]=[z.gridIndexBuffer,z.gridSegments];for(const pt of W){const yt=B.getTile(pt),Tt=nn.disabled,Wt=z.prevTerrainTileForTile[pt.key],Bt=z.terrainTileForTile[pt.key];eP(Wt,Bt)&&Td.newMorphing(pt.key,Wt,Bt,ee,250),Zw(D,yt.emissiveTexture),ne.activeTexture.set(de.TEXTURE0),yt.texture&&yt.texture.bind(de.LINEAR,de.CLAMP_TO_EDGE);const ns=Td.getMorphValuesForProxy(pt.key),Qt=ns?1:0;let ws;ns&&(ws={morphing:{srcDemTile:ns.from,dstDemTile:ns.to,phase:i.dn(ns.phase)}});const As=D.emissiveMode==="mrt-fallback"?1:0,Zt=Ww(pt.projMatrix,KC(pt.canonical,ct.renderWorldCopies)?mt/10:mt,nt,As);if(Ie(Qt),!be)continue;z.setupElevationDraw(yt,be,ws);const Ut=pt.toUnwrapped();Ce&&Ce.setupShadows(Ut,be),D.uploadCommonUniforms(ne,be,Ut,null,Be),be.draw(D,Ft,tt,Tt,st,Wr.backCCW,Zt,"terrain_raster",z.gridBuffer,wt,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,A=this.painter.context,D=this.proxySourceCache,z=this.proxiedCoords[D.id],B=this._drapedRenderBatches.shift(),W=v.style.order,ee=[];this._updateFBOs(v.emissiveMode==="mrt-fallback");let ne=0;for(const de of z){const be=D.getTileByID(de.proxyTileKey),ye=D.proxyCachedFBO[de.key]?D.proxyCachedFBO[de.key][m]:void 0,Ce=ye!==void 0?D.renderCache[ye]:this.pool[ne++],Be=ye!==void 0;if(be.texture=Ce.tex,be.emissiveTexture=Ce.emissiveTex,Be&&!Ce.dirty){ee.push(be.tileID);continue}A.bindFramebuffer.set(Ce.fb.framebuffer);const Ie=A.gl;let st;Ie.drawBuffers(v.emissiveMode==="mrt-fallback"?[Ie.COLOR_ATTACHMENT0,Ie.COLOR_ATTACHMENT1]:[Ie.COLOR_ATTACHMENT0]),this.renderedToTile=!1,Ce.dirty&&(A.clear({color:i.aq.transparent,stencil:0}),Ce.dirty=!1);for(let tt=B.start;tt<=B.end;++tt){const ct=v.style._mergedLayers[W[tt]];if(ct.isHidden(v.transform.zoom))continue;const mt=v.style.getLayerSourceCache(ct),nt=mt?this.proxyToSource[de.key][mt.id]:[de];if(!nt)continue;const Ft=nt;A.viewport.set([0,0,Ce.fb.width,Ce.fb.height]),st!==(mt?mt.id:null)&&(this._setupStencil(Ce,nt,ct,mt),st=mt?mt.id:null),v.renderLayer(v,mt,ct,Ft)}if(Ie.drawBuffers([Ie.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const tt of this._pendingGroundEffectLayers){const ct=v.style._mergedLayers[W[tt]];if(ct.isHidden(v.transform.zoom))continue;const mt=v.style.getLayerSourceCache(ct),nt=mt?this.proxyToSource[de.key][mt.id]:[de];if(!nt)continue;const Ft=nt;A.viewport.set([0,0,Ce.fb.width,Ce.fb.height]),st!==(mt?mt.id:null)&&(this._setupStencil(Ce,nt,ct,mt),st=mt?mt.id:null),v.renderLayer(v,mt,ct,Ft)}this.renderedToTile?(Ce.dirty=!0,ee.push(be.tileID)):Be||--ne,ne===5&&(ne=0,this.renderToBackBuffer(ee))}return this.renderToBackBuffer(ee),this.renderingToTexture=!1,A.bindFramebuffer.set(null),A.viewport.set([0,0,v.width,v.height]),B.end+1}postRender(){}isLayerOrderingCorrect(m){const v=m.order.length;let A=-1,D=v;for(let z=0;zA}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,A){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,A);if(B!=null)return B}return null}_createFBO(){const m=this.painter.context,v=m.gl,A=this.drapeBufferSize;m.activeTexture.set(v.TEXTURE0);const D=new i.T(m,{width:A[0],height:A[1],data:null},v.RGBA8);D.bind(v.LINEAR,v.CLAMP_TO_EDGE);const z=m.createFramebuffer(A[0],A[1],1,null);let B;return z.colorAttachment0.set(D.texture),this._emissiveTexture&&(B=new i.T(m,{width:A[0],height:A[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 xpe(m,z.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=m.createRenderbuffer(m.gl.DEPTH_STENCIL,A[0],A[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 A=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,A.createColorAttachment(D,1),A.colorAttachment1.set(W.texture)}else m.emissiveTex=void 0,A.removeColorAttachment(D,1);m.dirty=!0}_initFBOPool(){for(;this.pool.length{const v=this._style._mergedLayers[m],A=v.isHidden(this.painter.transform.zoom);return v.type==="hillshade"||v.type==="custom"?!A&&v.shouldRedrape():!A&&v.hasTransition()})}_clearLineLayersFromRenderCache(){let m=!1;for(const A of this._style.getSources())if(A instanceof Sd){m=!0;break}if(!m)return;const v={};for(let A=0;Aee>W.end)||i.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=A}_setupRenderCache(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=A[B];if(v.getTileByID(W.key),v.proxyCachedFBO[W.key]!==void 0){const ee=m[W.key],ne=this.proxyToSource[W.key];let de=0;for(const be in ne){const ye=ne[be],Ce=ee[be];if(!Ce||Ce.length!==ye.length||ye.some((Be,Ie)=>Be!==Ce[Ie]||D[be]&&D[be].hasOwnProperty(Be.key))){de=-1;break}++de}for(const be in v.proxyCachedFBO[W.key])v.renderCache[v.proxyCachedFBO[W.key][be]].dirty=de<0||de!==Object.values(ee).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 A){if(v.proxyCachedFBO[W.key])continue;let ee=v.renderCachePool.pop();ee===void 0&&v.renderCache.length<50&&(ee=v.renderCache.length,v.renderCache.push(this._createFBO())),ee!==void 0&&(v.proxyCachedFBO[W.key]={},v.proxyCachedFBO[W.key][B.start]=ee,v.renderCache[ee].dirty=!0)}this._tilesDirty={}}_setupStencil(m,v,A,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(A.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,A.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):nn.disabled}_renderTileClippingMasks(m,v){const A=this.painter,D=this.painter.context,z=D.gl;A._tileClippingMaskIDs={},D.setColorMode(tn.disabled),D.setDepthMode(Nr.disabled);const B=A.getOrCreateProgram("clippingMask");for(const W of m){const ee=A._tileClippingMaskIDs[W.key]=--v;B.draw(A,z.TRIANGLES,Nr.disabled,new nn({func:z.ALWAYS,mask:0},ee,255,z.KEEP,z.KEEP,z.REPLACE),tn.disabled,Wr.disabled,Yw(W.projMatrix),"$clipping",A.tileExtentBuffer,A.quadTriangleIndexBuffer,A.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 A=[m.x,m.y,1,1];i.aE(A,A,v.pixelMatrixInverse),i.cu(A,A,1/A[3]),A[0]/=v.worldSize,A[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([],A.slice(0,3),B);i.ay(W,W);const ee=this.raycast(B,W,this._exaggeration);return ee!==null&&ee?(i.bg(B,B,W,ee),B[3]=B[2],B[2]*=z,B):null}_setupProxiedCoordsForOrtho(m,v,A){if(m.getSource()instanceof i.aV)return this._setupProxiedCoordsForImageSource(m,v,A);this._findCoveringTileCache[m.id]=this._findCoveringTileCache[m.id]||{};const D=this.proxiedCoords[m.id]=[],z=this.proxyCoords;for(let ee=0;eede.overscaledZ-ne.overscaledZ)}_setupProxiedCoordsForImageSource(m,v,A){if(!m.getSource().loaded())return;const D=this.proxiedCoords[m.id]=[],z=this.proxyCoords,B=m.getSource(),W=B.tileID;if(!W)return;const ee=new i.P(W.x,W.y)._div(1<(be.min.x=Math.min(be.min.x,ye.x-ee.x),be.min.y=Math.min(be.min.y,ye.y-ee.y),be.max.x=Math.max(be.max.x,ye.x-ee.x),be.max.y=Math.max(be.max.y,ye.y-ee.y),be),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),de=(be,ye)=>{const Ce=be.wrap+be.canonical.x/(1<st+ne.max.x||Be+Iett+ne.max.y};for(let be=0;beB.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,ee;D=i.bb();const ne=v.tileID.wrap-m.wrap<0?(B=i.an>>z,W=B*((v.tileID.canonical.x<=be){const ye=m.canonical.z-be;v.getSource().reparseOverscaled?(W=Math.max(m.canonical.z+2,v.transform.tileZoom),B=new i.aR(W,m.wrap,be,m.canonical.x>>ye,m.canonical.y>>ye)):ye!==0&&(W=be,B=new i.aR(W,m.wrap,be,m.canonical.x>>ye,m.canonical.y>>ye))}B.key!==m.key&&(ne.push(B.key),A=v.getTile(B))}const de=be=>{ne.forEach(ye=>{D[ye]=be}),ne.length=0};for(W-=1;W>=ee&&(!A||!A.hasData());W--){A&&de(A.tileID.key);const be=B.calculateScaledKey(W);if(A=v.getTileByID(be),A&&A.hasData())break;const ye=D[be];if(ye===null)break;ye===void 0?ne.push(be):A=v.getTileByID(ye)}return de(A?A.tileID.key:null),A&&A.hasData()?A:null}findDEMTileFor(m){return this.enabled?this._findTileCoveringTileID(m,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(m,v){let A=this._tilesDirty[m];A||(A=this._tilesDirty[m]={}),A[v.key]=!0}}function sP(M,m,v){const A=function(W,ee,ne){const de=i.bi(ee,W),be=i.bi(ne,[.2126,.7152,.0722]),ye=(Be,Ie,st)=>(1-st)*Be+st*Ie,Ce=ye(1-.3*Math.min(be,1),1,Math.min(de+1,1));return ye(.92,1,Math.asin(i.aC(ee[2],-1,1))/Math.PI+.5)*Ce}(M,[0,0,1],m),D=[0,0,0];i.bJ(D,v.slice(0,3),A);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 KO=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],ZO=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class V0{static cacheKey(m,v,A,D){const z=[v];D&&z.push(D.cacheKey);for(const B of A)(typeof B=="string"&&B.includes(" ")||m.usedDefines.has(B))&&z.push(B);return z.join("/")}constructor(m,v,A,D,z,B){const W=m.gl;this.program=W.createProgram(),this.configuration=D,this.name=v,this.fixedDefines=[...B];const ee=`#version 300 es ${(D?D.defines():[]).concat(B.map(Ie=>`#define ${Ie}`)).join(` `)}`,ne=[ee,z1];for(const Ie of A.fragmentIncludes)ne.push(Ep[Ie]);ne.push(A.fragmentSource);const de=ne.join(` `),be=[ee,lpe];for(const Ie of A.vertexIncludes)be.push(Ep[Ie]);this.forceManualRenderingForInstanceIDShaders=m.forceManualRenderingForInstanceIDShaders&&A.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&be.push("uniform int u_instanceID;"),be.push(A.vertexSource);let ye=be.join(` `);this.forceManualRenderingForInstanceIDShaders&&(ye=ye.replaceAll("gl_InstanceID","u_instanceID"));const Ce=W.createShader(W.FRAGMENT_SHADER);if(W.isContextLost())return void(this.failedToCreate=!0);W.shaderSource(Ce,de),W.compileShader(Ce),W.attachShader(this.program,Ce);const Be=W.createShader(W.VERTEX_SHADER);W.isContextLost()?this.failedToCreate=!0:(W.shaderSource(Be,ye),W.compileShader(Be),W.attachShader(this.program,Be),this.attributes={},W.linkProgram(this.program),W.deleteShader(Be),W.deleteShader(Ce),this.fixedUniforms=z(m),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=D?D.getUniforms(m):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(Ie=>({u_instanceID:new i.bX(Ie)}))(m)),(B.includes("TERRAIN")||B.includes("ELEVATED")||v.includes("symbol")||v.includes("circle"))&&(this.terrainUniforms=(Ie=>({u_dem:new i.bX(Ie),u_dem_prev:new i.bX(Ie),u_dem_tl:new i.b_(Ie),u_dem_scale:new i.bZ(Ie),u_dem_tl_prev:new i.b_(Ie),u_dem_scale_prev:new i.bZ(Ie),u_dem_size:new i.bZ(Ie),u_dem_lerp:new i.bZ(Ie),u_exaggeration:new i.bZ(Ie),u_depth:new i.bX(Ie),u_depth_size_inv:new i.b_(Ie),u_depth_range_unpack:new i.b_(Ie),u_occluder_half_size:new i.bZ(Ie),u_occlusion_depth_offset:new i.bZ(Ie),u_meter_to_dem:new i.bZ(Ie),u_label_plane_matrix_inv:new i.b$(Ie)}))(m)),B.includes("GLOBE")&&(this.globeUniforms=(Ie=>({u_tile_tl_up:new i.bY(Ie),u_tile_tr_up:new i.bY(Ie),u_tile_br_up:new i.bY(Ie),u_tile_bl_up:new i.bY(Ie),u_tile_up_scale:new i.bZ(Ie)}))(m)),B.includes("FOG")&&(this.fogUniforms=(Ie=>({u_fog_matrix:new i.b$(Ie),u_fog_range:new i.b_(Ie),u_fog_color:new i.cO(Ie),u_fog_horizon_blend:new i.bZ(Ie),u_fog_vertical_limit:new i.b_(Ie),u_fog_temporal_offset:new i.bZ(Ie),u_frustum_tl:new i.bY(Ie),u_frustum_tr:new i.bY(Ie),u_frustum_br:new i.bY(Ie),u_frustum_bl:new i.bY(Ie),u_globe_pos:new i.bY(Ie),u_globe_radius:new i.bZ(Ie),u_globe_transition:new i.bZ(Ie),u_is_globe:new i.bX(Ie),u_viewport:new i.b_(Ie)}))(m)),B.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(Ie=>({u_cutoff_params:new i.cO(Ie)}))(m)),B.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(Ie=>({u_lighting_ambient_color:new i.bY(Ie),u_lighting_directional_dir:new i.bY(Ie),u_lighting_directional_color:new i.bY(Ie),u_ground_radiance:new i.bY(Ie)}))(m)),B.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(Ie=>({u_light_matrix_0:new i.b$(Ie),u_light_matrix_1:new i.b$(Ie),u_fade_range:new i.b_(Ie),u_shadow_normal_offset:new i.bY(Ie),u_shadow_intensity:new i.bZ(Ie),u_shadow_texel_size:new i.bZ(Ie),u_shadow_map_resolution:new i.bZ(Ie),u_shadow_direction:new i.bY(Ie),u_shadow_bias:new i.bY(Ie),u_shadowmap_0:new i.bX(Ie),u_shadowmap_1:new i.bX(Ie)}))(m)))}getAttributeLocation(m,v){let A=this.attributes[v];return A===void 0&&(A=this.attributes[v]=m.getAttribLocation(this.program,v)),A}setTerrainUniformValues(m,v){if(!this.terrainUniforms)return;const A=this.terrainUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)A[D]&&A[D].set(this.program,D,v[D])}}setGlobeUniformValues(m,v){if(!this.globeUniforms)return;const A=this.globeUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)A[D]&&A[D].set(this.program,D,v[D])}}setFogUniformValues(m,v){if(!this.fogUniforms)return;const A=this.fogUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)A[D].set(this.program,D,v[D])}}setCutoffUniformValues(m,v){if(!this.cutoffUniforms)return;const A=this.cutoffUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)A[D].set(this.program,D,v[D])}}setLightsUniformValues(m,v){if(!this.lightsUniforms)return;const A=this.lightsUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)A[D].set(this.program,D,v[D])}}setShadowUniformValues(m,v){if(this.failedToCreate||!this.shadowUniforms)return;const A=this.shadowUniforms;m.program.set(this.program);for(const D in v)A[D].set(this.program,D,v[D])}_drawDebugWireframe(m,v,A,D,z,B,W,ee,ne,de){const be=m.options.wireframe;if(be.terrain===!1&&be.layers2D===!1&&be.layers3D===!1)return;const ye=m.context;if(!(!(!be.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!be.layers2D||m._terrain&&m._terrain.renderingToTexture||!KO.includes(this.name))||!(!be.layers3D||!ZO.includes(this.name))))return;const Ce=ye.gl,Be=m.wireframeDebugCache.getLinesFromTrianglesBuffer(m.frameCounter,z,ye);if(!Be)return;const Ie=[...this.fixedDefines,"DEBUG_WIREFRAME"],st=m.getOrCreateProgram(this.name,{config:this.configuration,defines:Ie});ye.program.set(st.program);const tt=(nt,Ft,wt)=>{if(Ft[nt]&&wt[nt])for(const Dt in Ft[nt])wt[nt][Dt]&&wt[nt][Dt].set(wt.program,Dt,Ft[nt][Dt].current)};ne&&ne.setUniforms(st.program,ye,st.binderUniforms,W,{zoom:ee}),tt("fixedUniforms",this,st),tt("terrainUniforms",this,st),tt("globeUniforms",this,st),tt("fogUniforms",this,st),tt("lightsUniforms",this,st),tt("shadowUniforms",this,st),Be.bind(),ye.setColorMode(new tn([Ce.ONE,Ce.ONE_MINUS_SRC_ALPHA,Ce.ZERO,Ce.ONE],i.aq.transparent,[!0,!0,!0,!1])),ye.setDepthMode(new Nr(v.func===Ce.LESS?Ce.LEQUAL:v.func,Nr.ReadOnly,v.range)),ye.setStencilMode(nn.disabled);const ct=3*B.primitiveLength*2,mt=3*B.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const nt=de||1;for(let Ft=0;Ft1?Ce.drawElementsInstanced(Ce.LINES,ct,Ce.UNSIGNED_SHORT,mt,de):Ce.drawElements(Ce.LINES,ct,Ce.UNSIGNED_SHORT,mt);z.bind(),ye.program.set(this.program),ye.setDepthMode(v),ye.setStencilMode(A),ye.setColorMode(D)}checkUniforms(m,v,A){if(this.fixedDefines.includes(v)){for(const D of Object.keys(A))if(!A[D].initialized)throw new Error(`Program '${this.name}', from draw '${m}': uniform ${D} not set but required by ${v} being defined`)}}draw(m,v,A,D,z,B,W,ee,ne,de,be,ye,Ce,Be,Ie,st){const tt=m.context,ct=tt.gl;if(this.failedToCreate)return;tt.program.set(this.program),tt.setDepthMode(A),tt.setStencilMode(D),tt.setColorMode(z),tt.setCullFace(B);for(const[pt,yt]of this.fixedUniformsEntries)yt.set(this.program,pt,W[pt]);Be&&Be.setUniforms(this.program,tt,this.binderUniforms,ye,{zoom:Ce});const mt={[ct.POINTS]:1,[ct.LINES]:2,[ct.TRIANGLES]:3,[ct.LINE_STRIP]:1}[v];this.checkUniforms(ee,"RENDER_SHADOWS",this.shadowUniforms);const nt=Ie||[],Ft=Be?Be.getPaintVertexBuffers():[],wt=v===ct.TRIANGLES&&de,Dt=st&&st>0?1:void 0;for(const pt of be.get()){const yt=pt.vaos||(pt.vaos={});if((yt[ee]||(yt[ee]=new OO)).bind(tt,this,ne,Ft,de,pt.vertexOffset,nt,Dt),this.forceManualRenderingForInstanceIDShaders){const Tt=st||1;for(let Wt=0;Wt1?ct.drawElementsInstanced(v,pt.primitiveLength*mt,ct.UNSIGNED_SHORT,pt.primitiveOffset*mt*2,st):de?ct.drawElements(v,pt.primitiveLength*mt,ct.UNSIGNED_SHORT,pt.primitiveOffset*mt*2):ct.drawArrays(v,pt.vertexOffset,pt.vertexLength);wt&&this._drawDebugWireframe(m,A,D,z,de,pt,ye,Ce,Be,st)}}}function YO(M,m,v=0){const A=Math.pow(2,m.tileID.overscaledZ),D=m.tileSize*Math.pow(2,M.transform.tileZoom)/A,z=D*(m.tileID.canonical.x+m.tileID.wrap*A),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 XC={terrain:0,flat:1},gpe=i.bb(),XO=(M,m,v,A,D,z,B,W,ee,ne,de,be,ye,Ce,Be,Ie,st,tt,ct=[0,0,1])=>{const mt=m.style.light,nt=mt.properties.get("position"),Ft=[nt.x,nt.y,nt.z],wt=i.dE();mt.properties.get("anchor")==="viewport"&&(i.dF(wt,-m.transform.angle),i.dG(Ft,Ft,wt));const Dt=mt.properties.get("color").toPremultipliedRenderColor(null),pt=m.transform,yt={u_matrix:M,u_lightpos:Ft,u_lightintensity:mt.properties.get("intensity"),u_lightcolor:[Dt.r,Dt.g,Dt.b],u_vertical_gradient:+v,u_opacity:A,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:gpe,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:XC[ne],u_base_type:XC[de],u_ao:D,u_edge_radius:z,u_width_scale:B,u_flood_light_color:Be,u_vertical_scale:Ie,u_flood_light_intensity:st,u_ground_shadow_factor:tt,u_front_cutoff_params:ct};return pt.projection.name==="globe"&&(yt.u_tile_id=[W.canonical.x,W.canonical.y,1<({u_matrix:M,u_edge_radius:m,u_width_scale:v,u_vertical_scale:A,u_height_type:XC[D],u_base_type:XC[z]}),vpe=(M,m,v,A,D,z,B,W,ee,ne,de,be,ye,Ce,Be,Ie,st,tt)=>{const ct=XO(M,m,v,A,D,z,B,W,ne,de,be,ye,Ce,Be,Ie,st,1,[0,0,0]),mt={u_height_factor:-Math.pow(2,W.overscaledZ)/ee.tileSize/8};return Object.assign(ct,YO(m,ee,tt),mt)},QC=(M,m,v)=>({u_matrix:M,u_emissive_strength:m,u_ground_shadow_factor:v}),JC=(M,m,v,A,D,z=0)=>Object.assign(QC(M,m,D),YO(v,A,z)),QO=(M,m,v,A)=>({u_matrix:M,u_world:v,u_emissive_strength:m,u_ground_shadow_factor:A}),H1=(M,m,v,A,D,z,B=0)=>Object.assign(JC(M,m,v,A,z,B),{u_world:D}),JO=(M,m)=>({u_matrix:M,u_depth_bias:m}),eF=(M,m)=>({u_matrix:M,u_ground_shadow_factor:m}),Jw=(M,m,v,A,D)=>({u_matrix:M,u_camera_pos:[m[0],m[1],m[2]],u_depth_bias:v,u_height_scale:A,u_reset_depth:D}),e3=(M,m,v)=>({u_image:M,u_opacity:m,u_blend_mode:v}),iy=(M,m,v,A,D,z,B,W,ee,ne=[0,0,1])=>({u_matrix:M,u_normal_matrix:m,u_opacity:v,u_faux_facade_ao_intensity:A,u_camera_pos:D,u_tile_to_meter:z,u_facade_emissive_chance:B,u_flood_light_color:W,u_flood_light_intensity:ee,u_front_cutoff_params:ne}),t3=M=>({u_matrix:M}),s3=M=>({u_matrix:M}),tF=(M,m,v,A,D,z,B,W)=>{const ee=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]/ee,v.pixelsToGLUnits[1]/ee],u_zoom_transition:A,u_tile_id:B,u_merc_center:D}},oy=(M,m,v,A)=>({u_matrix:M,u_inv_matrix:m,u_camera_to_center_distance:v.getCameraToCenterDistance(A),u_viewport_size:[v.width,v.height]}),e2=(M,m,v=1)=>({u_matrix:M,u_color:m,u_overlay:0,u_overlay_scale:v}),r3=i.bb(),sF=(M,m,v,A,D,z,B)=>{const W=M.transform,ee=W.projection.name==="globe",ne=ee?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:r3,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(ee){de.u_inv_rot_matrix=A,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:A,u_merc_matrix:D,u_grid_matrix:z,u_tl_parent:B,u_scale_parent:de,u_fade_t:be.mix,u_opacity:be.opacity*ye.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:ye.paint.get("raster-brightness-min"),u_brightness_high:ye.paint.get("raster-brightness-max"),u_saturation_factor:i.dJ(ye.paint.get("raster-saturation")),u_contrast_factor:i.dI(ye.paint.get("raster-contrast")),u_spin_weights:nF(ye.paint.get("raster-hue-rotate")),u_perspective_transform:Ce,u_raster_elevation:Be,u_zoom_transition:W,u_merc_center:ee,u_cutoff_params:ne,u_colorization_mix:rP(i.dK,st,ct),u_colorization_offset:n3(i.dK,tt,ct),u_color_ramp:Ie,u_texture_offset:[nt/(mt+2*nt),mt/(mt+2*nt)],u_texture_res:[mt+2*nt,mt+2*nt],u_emissive_strength:Ft,u_zbias_factor:nP(M)});function nF(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 Ef=.05,_pe=(M,m,v,A,D,z,B,W,ee,ne,de,be)=>({u_matrix:M,u_normalize_matrix:m,u_globe_matrix:v,u_merc_matrix:A,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:be,u_zoom_transition:B,u_merc_center:W,u_cutoff_params:ee}),bpe=(M,m,v,A,D,z,B,W,ee,ne)=>({u_particle_texture:M,u_particle_texture_side_len:m,u_tile_offset:v,u_velocity:A,u_color_ramp:z,u_velocity_res:D,u_max_speed:B,u_uv_offset:W,u_data_scale:[255*ee[0],255*ee[1]],u_data_offset:ne,u_particle_pos_scale:1.1,u_particle_pos_offset:[Ef,Ef]}),aF=(M,m,v,A,D,z,B,W,ee,ne)=>({u_particle_texture:M,u_particle_texture_side_len:m,u_velocity:v,u_velocity_res:A,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*ee[0],255*ee[1]],u_data_offset:ne,u_particle_pos_scale:1.1,u_particle_pos_offset:[Ef,Ef]}),iF=i.bb(),a3=(M,m,v,A,D,z,B,W,ee,ne,de,be,ye,Ce,Be,Ie,st,tt,ct,mt,nt,Ft,wt,Dt)=>{const pt=D.transform,yt={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(ct),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:ee?1:0,u_pitch_with_map:+A,u_texsize:de,u_texsize_icon:be,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:iF,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:iF,u_up_vector:[0,-1,0],u_color_adj_mat:Ft,u_icon_transition:wt||0,u_gamma_scale:A?D.transform.getCameraToCenterDistance(ct)*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 ct.name==="globe"&&(yt.u_tile_id=[Ce.canonical.x,Ce.canonical.y,1<({u_matrix:M,u_emissive_strength:m,u_opacity:v,u_color:A}),ly=(M,m,v,A,D,z,B,W,ee)=>Object.assign(function(ne,de,be,ye,Ce,Be){const{width:Ie,height:st}=ye.imageManager.getPixelSize(de),tt=Math.pow(2,Be.tileID.overscaledZ),ct=Be.tileSize*Math.pow(2,ye.transform.tileZoom)/tt,mt=ct*(Be.tileID.canonical.x+Be.tileID.wrap*tt),nt=ct*Be.tileID.canonical.y;return{u_image:0,u_pattern_tl:be.tl,u_pattern_br:be.br,u_texsize:[Ie,st],u_pattern_size:be.displaySize,u_pattern_units_to_pixels:Ce?[ye.transform.width,-1*ye.transform.height]:[1/i.aA(Be,1,ye.transform.tileZoom),1/i.aA(Be,1,ye.transform.tileZoom)],u_pixel_coord_upper:[mt>>16,nt>>16],u_pixel_coord_lower:[65535&mt,65535&nt]}}(0,z,B,A,W,ee),{u_matrix:M,u_emissive_strength:m,u_opacity:v}),G1=new Float32Array(i.b9([])),H0=(M,m,v,A,D,z,B,W,ee,ne,de,be,ye,Ce=[0,0,0],Be,Ie,st)=>{const tt=D.style.light,ct=tt.properties.get("position"),mt=[-ct.x,-ct.y,ct.z],nt=i.dE();tt.properties.get("anchor")==="viewport"&&(i.dF(nt,-D.transform.angle),i.dG(mt,mt,nt));const Ft=de.alphaMode==="MASK",wt=tt.properties.get("color").toNonPremultipliedRenderColor(null),Dt=ye.paint.get("model-ambient-occlusion-intensity"),pt=ye.paint.get("model-color").constantOr(i.aq.white).toNonPremultipliedRenderColor(null);return pt.a=ye.paint.get("model-color-mix-intensity").constantOr(0),st&&(pt.r=st[0],pt.g=st[1],pt.b=st[2],pt.a=st[3]),Ie&&(pt.r=Ie.color.r,pt.g=Ie.color.g,pt.b=Ie.color.b,pt.a=Ie.colorMix,be=Ie.emissionStrength,z*=Ie.opacity),{u_matrix:M,u_lighting_matrix:m,u_normal_matrix:v,u_node_matrix:A||G1,u_lightpos:mt,u_lightintensity:tt.properties.get("intensity"),u_lightcolor:[wt.r,wt.g,wt.b],u_camera_pos:Ce,u_opacity:z,u_baseTextureIsAlpha:0,u_alphaMask:+Ft,u_alphaCutoff:de.alphaCutoff,u_baseColorFactor:B.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:W.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:ee,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:be,u_occlusionTextureTransform:Be||[0,0,0,0]}},aP=(M,m=G1,v=G1)=>({u_matrix:M,u_instance:m,u_node_matrix:v}),i3={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 Pp{constructor(m,v,A,D){this.id=Pp.uniqueIdxCounter,Pp.uniqueIdxCounter++,this.context=m;const z=m.gl;this.buffer=z.createBuffer(),this.dynamicDraw=!!A,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=Pp.uniqueIdxCounter,Pp.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)}}Pp.uniqueIdxCounter=0;const iP={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class oF{constructor(m,v,A,D,z,B){this.length=v.length,this.attributes=A,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 A of this.attributes){const D=v.getAttributeLocation(m,A.name);D!==-1&&m.enableVertexAttribArray(D)}}setVertexAttribPointers(m,v,A){for(const D of this.attributes){const z=v.getAttributeLocation(m,D.name);if(z!==-1){const B=D.offset+this.itemSize*(A||0);D.type==="Float32"?m.vertexAttribPointer(z,D.components,m.FLOAT,!1,this.itemSize,B):m.vertexAttribIPointer(z,D.components,m[iP[D.type]],this.itemSize,B)}}}setVertexAttribDivisor(m,v,A){for(let D=0;D0&&m.vertexAttribDivisor(z,A)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class s2{constructor(m,v,A,D,z){this.context=m,this.width=v,this.height=A;const B=this.framebuffer=m.gl.createFramebuffer();D>0&&(this.colorAttachment0=new U1(m,B,0)),D>1&&(this.colorAttachment1=new U1(m,B,1)),z&&(this.depthAttachmentType=z,this.depthAttachment=z==="renderbuffer"?new JE(m,B):new WO(m,B))}static createWithTexture(m,v,A,D,z){const B=m.gl;if(m.activeTexture.set(B.TEXTURE1),m.viewport.set([0,0,A,D]),v&&v.width===A&&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:A,height:D,data:null},m.extRenderToTextureHalfFloat?m.gl.RGBA16F:m.gl.RGBA8);W.bind(B.LINEAR,B.CLAMP_TO_EDGE);const ee=m.createFramebuffer(A,D,1,null);if(ee.colorAttachment0.set(W.texture),z){const ne=m.createRenderbuffer(B.DEPTH24_STENCIL8,A,D);m.bindFramebuffer.set(ee.framebuffer),B.framebufferRenderbuffer(B.FRAMEBUFFER,B.DEPTH_STENCIL_ATTACHMENT,B.RENDERBUFFER,ne),ee._stencilRbo=ne}return ee}createColorAttachment(m,v){v===0?this.colorAttachment0=new U1(m,this.framebuffer,0):v===1&&(this.colorAttachment1=new U1(m,this.framebuffer,1))}removeColorAttachment(m,v){const A=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&&A.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 W1{constructor(m,v){this.gl=m,this.clearColor=new zO(this),this.clearDepth=new upe(this),this.clearStencil=new qC(this),this.colorMask=new hpe(this),this.depthMask=new BO(this),this.stencilMask=new WE(this),this.stencilFunc=new UC(this),this.stencilOp=new KE(this),this.stencilTest=new q0(this),this.depthRange=new U0(this),this.depthTest=new B1(this),this.depthFunc=new Af(this),this.blend=new $O(this),this.blendFunc=new ZE(this),this.blendColor=new qO(this),this.blendEquation=new $1(this),this.cullFace=new VC(this),this.cullFaceSide=new HC(this),this.frontFace=new YE(this),this.program=new GC(this),this.activeTexture=new Hw(this),this.viewport=new UO(this),this.bindFramebuffer=new VO(this),this.bindRenderbuffer=new HO(this),this.bindTexture=new q1(this),this.bindVertexBuffer=new GO(this),this.bindElementBuffer=new mpe(this),this.bindVertexArrayOES=new ppe(this),this.pixelStoreUnpack=new fpe(this),this.pixelStoreUnpackPremultiplyAlpha=new XE(this),this.pixelStoreUnpackFlipY=new QE(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,A){return new Pp(this,m,v,A)}createVertexBuffer(m,v,A,D,z){return new oF(this,m,v,A,D,z)}createRenderbuffer(m,v,A){const D=this.gl,z=D.createRenderbuffer();return this.bindRenderbuffer.set(z),D.renderbufferStorage(D.RENDERBUFFER,m,v,A),this.bindRenderbuffer.set(null),z}createFramebuffer(m,v,A,D){return new s2(this,m,v,A,D)}clear({color:m,depth:v,stencil:A,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)),A!==void 0&&(B|=z.STENCIL_BUFFER_BIT,this.clearStencil.set(A),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,tn.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 G0;function xr(M,m,v,A,D,z,B){const W=M.context,ee=W.gl,ne=M.transform,de=[i.aH(ne.center.lng),i.aL(ne.center.lat)],be=v.layout.get("symbol-placement"),ye=v.layout.get("text-variable-anchor"),Ce=v.layout.get("icon-rotation-alignment")==="map",Be=v.layout.get("text-rotation-alignment")==="map",Ie=be!=="point",st=[];let tt=0,ct=0;for(let pt=0;pt0){const Ar=i.bb(),mr=Hs;i.cz(Ar,Wt.placementInvProjMatrix,ne.glCoordMatrix),i.cz(Ar,Ar,Wt.placementViewportMatrix),st.push({circleArray:Cs,circleOffset:ct,transform:mr,invTransform:Ar,projection:Wt.getProjection()}),tt+=Cs.length/4,ct=tt}if(!Gs)continue;M.terrain&&M.terrain.setupElevationDraw(Tt,Qs);const br=as?[yt.canonical.x,yt.canonical.y,1<=0&&(Ce[mt.associatedIconIndex]={x:Bt,y:ns,z:Qt,angle:ts})}else P1(wt,be)}if(ne){ye.clear();const ct=M.icon.placedSymbolArray;for(let mt=0;mt{let bn=[0,0,0];if(Ba){const Bi=M.style.directionalLight,mi=M.style.ambientLight;Bi&&mi&&(bn=Ap(M.style,Bi,mi))}return bn},qn=Ba=>{if(M.context.disableSymbolUBO)return;Ba.push("USE_PAINT_PROPERTIES_UBO");const bn=Math.floor(M.context.maxUniformBlockSize/4),Bi=Math.floor(bn/4);Ba.push(`MAX_UBO_SIZE_VEC4 ${Bi}u`)},hn=Ba=>{yt.depthOcclusionForSymbolsAndCircles&&(v.hasOcclusionOpacityProperties||M.terrain)&&(Ba.push("DEPTH_D24"),Ba.push("DEPTH_OCCLUSION"))},Pa=Ba=>{v.lut&&!wt&&(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),Ba.push("APPLY_LUT_ON_GPU"))},hi=()=>{const Ba=Tt&&v.layout.get("symbol-placement")!=="point",bn=[];hn(bn),Pa(bn);const Bi=Ba||xn,mi=Cs.elevationType==="road",Uo=M.shadowRenderer,sa=mi&&Bt&&!!Uo&&Uo.enabled,vi=qr(sa),ol=mi&&Bt&&!M.terrain?Zt:As,od=v.paint.get("icon-image-cross-fade");M.terrainRenderModeElevated()&&Bt&&bn.push("PITCH_WITH_MAP_TERRAIN"),br&&(bn.push("PROJECTION_GLOBE_VIEW"),Bi&&bn.push("PROJECTED_POS_ON_VIEWPORT")),od>0&&Cs.hasAnySecondaryIcon&&bn.push("ICON_TRANSITION"),!Cs.icon.zOffsetVertexBuffer||mi&&M.terrain||bn.push("Z_OFFSET"),tt===0&&ct===0&&mt===0&&nt===1||bn.push("COLOR_ADJUSTMENT"),Cs.sdfIcons&&bn.push("RENDER_SDF"),sa&&bn.push("RENDER_SHADOWS","NORMAL_OFFSET"),mi&&Bt&&!M.terrain&&Cs.icon.orientationVertexBuffer&&bn.push("ELEVATED_ROADS"),qn(bn);const _l=Dt.disableSymbolUBO?Cs.icon.programConfigurations.get(v.id):null,Sc=M.getOrCreateProgram("symbol",{config:_l,defines:bn}),_h=Gs.imageAtlasTexture?Gs.imageAtlasTexture.size:[0,0],Qa=Cs.iconSizeData,tm=i.bj(Qa,yt.zoom),sm=Bt||!yt.isOrthographic,Si=nr(mr,Gs.tileID.canonical,Bt,Tt,yt,Cs.getProjection(),yr),Ei=pn(mr,Gs.tileID.canonical,Bt,Tt,yt,Cs.getProjection(),yr),li=Cs.icon.uboBinder&&Cs.icon.uboBinder.cachedHeader&&256&Cs.icon.uboBinder.cachedHeader.dataDrivenMask?[0,0]:W,Fo=M.translatePosMatrix(Ei,Gs,li,ne,!0),Ad=M.translatePosMatrix(mr,Gs,li,ne),uo=Bi?r2:Si,bh=Tt&&!Bt&&!Ba;let dy=Qs;!as&&!yt.mercatorFromTransition||Tt||(dy=Hx(yt));const ev=br?dy:Qs,tv=v.getColorAdjustmentMatrix(tt,ct,mt,nt),J1=a3(Qa.kind,tm,bh,Bt,M,Ad,uo,Fo,Ft,!1,_h,[0,0],0,Hs,Ar,Ut,un,ev,Cs.getProjection(),vi,$n,tv,od,null),Xx=Gs.imageAtlasTexture?Gs.imageAtlasTexture:null,Rf=v.layout.get("icon-size").constantOr(0)!==1||Cs.iconsNeedLinear,e_=Cs.sdfIcons||M.options.rotating||M.options.zooming||Rf||sm?pt.LINEAR:pt.NEAREST,Wu=Cs.sdfIcons&&v.paint.get("icon-halo-width").constantOr(1)!==0,uy=M.terrain&&Bt&&Ba?i.b7(i.bb(),Si):r2;if(Ba&&Cs.icon){const hy=i.bu.getAtTileOffsetFunc(Hs,yt.center.lat,yt.worldSize,Cs.getProjection()),my=Jr(mr,Gs.tileID.canonical,Bt,Tt,yt,Cs.getProjection(),yr),A3=v.layout.get("icon-size-scale-range"),t_=i.aC(M.scaleFactor,A3[0],A3[1]);kc(Cs,mr,M,!1,my,Ei,Bt,Ie,hy,Hs,t_)}return{program:Sc,buffers:Cs.icon,uniformValues:J1,atlasTexture:Xx,atlasTextureIcon:null,atlasInterpolation:e_,atlasInterpolationIcon:null,isSDF:Cs.sdfIcons,hasHalo:Wu,depthMode:ol,tile:Gs,renderWithShadows:sa,labelPlaneMatrixInv:uy}},Gi=()=>{const Ba=Wt&&v.layout.get("symbol-placement")!=="point",bn=[],Bi=Ba||ts||xn,mi=Cs.elevationType==="road",Uo=M.shadowRenderer,sa=mi&&ns&&!!Uo&&Uo.enabled,vi=qr(sa),ol=mi&&ns&&!M.terrain?Zt:As;M.terrainRenderModeElevated()&&ns&&bn.push("PITCH_WITH_MAP_TERRAIN"),br&&(bn.push("PROJECTION_GLOBE_VIEW"),Bi&&bn.push("PROJECTED_POS_ON_VIEWPORT")),!Cs.text.zOffsetVertexBuffer||mi&&M.terrain||bn.push("Z_OFFSET"),Cs.iconsInText&&bn.push("RENDER_TEXT_AND_SYMBOL"),bn.push("RENDER_SDF"),sa&&bn.push("RENDER_SHADOWS","NORMAL_OFFSET"),mi&&ns&&!M.terrain&&Cs.text.orientationVertexBuffer&&bn.push("ELEVATED_ROADS"),hn(bn),qn(bn);const od=Dt.disableSymbolUBO?Cs.text.programConfigurations.get(v.id):null,_l=M.getOrCreateProgram("symbol",{config:od,defines:bn});let Sc,_h=[0,0],Qa=null;const tm=Cs.textSizeData;Cs.iconsInText&&(_h=Gs.imageAtlasTexture?Gs.imageAtlasTexture.size:[0,0],Qa=Gs.imageAtlasTexture?Gs.imageAtlasTexture:null,Sc=ns||!yt.isOrthographic||M.options.rotating||M.options.zooming||tm.kind==="composite"||tm.kind==="camera"?pt.LINEAR:pt.NEAREST);const sm=Gs.glyphAtlasTexture?Gs.glyphAtlasTexture.size:[0,0],Si=v.layout.get("text-size-scale-range"),Ei=i.aC(M.scaleFactor,Si[0],Si[1]),li=i.bj(tm,yt.zoom,Ei),Fo=nr(mr,Gs.tileID.canonical,ns,Wt,yt,Cs.getProjection(),yr),Ad=pn(mr,Gs.tileID.canonical,ns,Wt,yt,Cs.getProjection(),yr),uo=Cs.text.uboBinder&&Cs.text.uboBinder.cachedHeader&&256&Cs.text.uboBinder.cachedHeader.dataDrivenMask?[0,0]:ee,bh=M.translatePosMatrix(Ad,Gs,uo,de,!0),dy=M.translatePosMatrix(mr,Gs,uo,de),ev=Bi?r2:Fo,tv=Wt&&!ns&&!Ba;let J1=Qs;!as&&!yt.mercatorFromTransition||Wt||(J1=Hx(yt));const Xx=a3(tm.kind,li,tv,ns,M,dy,ev,bh,Ft,!0,sm,_h,0,Hs,Ar,Ut,un,br?J1:Qs,Cs.getProjection(),vi,$n,null,null,Ei),Rf=Gs.glyphAtlasTexture?Gs.glyphAtlasTexture:null,e_=pt.LINEAR,Wu=v.paint.get("text-halo-width").constantOr(1)!==0,uy=M.terrain&&ns&&Ba?i.b7(i.bb(),Fo):r2;if(Ba&&Cs.text){const hy=i.bu.getAtTileOffsetFunc(Hs,yt.center.lat,yt.worldSize,Cs.getProjection()),my=Jr(mr,Gs.tileID.canonical,ns,Wt,yt,Cs.getProjection(),yr);kc(Cs,mr,M,!0,my,Ad,ns,st,hy,Hs,Ei)}return{program:_l,buffers:Cs.text,uniformValues:Xx,atlasTexture:Rf,atlasTextureIcon:Qa,atlasInterpolation:e_,atlasInterpolationIcon:Sc,isSDF:!0,hasHalo:Wu,depthMode:ol,tile:Gs,renderWithShadows:sa,labelPlaneMatrixInv:uy}},wi=Cs.icon.segments.get().length,za=Cs.text.segments.get().length,Rn=wi&&!B.onlyText?hi():null,On=za&&!B.onlyIcons?Gi():null,ji=v.paint.get("icon-opacity").constantOr(1),Qi=v.paint.get("text-opacity").constantOr(1);if(Qt&&Cs.canOverlap){ws=!0;const Ba=ji&&!B.onlyText?Cs.icon.segments.get():[],bn=Qi&&!B.onlyIcons?Cs.text.segments.get():[];for(const Bi of Ba)cs.push({segments:new i.dy([Bi]),sortKey:Bi.sortKey,state:Rn});for(const Bi of bn)cs.push({segments:new i.dy([Bi]),sortKey:Bi.sortKey,state:On})}else B.onlyText||cs.push({segments:ji?Cs.icon.segments:new i.dy([]),sortKey:0,state:Rn}),B.onlyIcons||cs.push({segments:Qi?Cs.text.segments:new i.dy([]),sortKey:0,state:On})}ws&&cs.sort((Hs,Gs)=>Hs.sortKey-Gs.sortKey);for(const Hs of cs){const Gs=Hs.state;if(Gs)if(M.terrain?M.terrain.setupElevationDraw(Gs.tile,Gs.program,{useDepthForOcclusion:yt.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Gs.labelPlaneMatrixInv}):M.setupDepthForOcclusion(yt.depthOcclusionForSymbolsAndCircles,Gs.program),Dt.activeTexture.set(pt.TEXTURE0),Gs.atlasTexture&&Gs.atlasTexture.bind(Gs.atlasInterpolation,pt.CLAMP_TO_EDGE,!0),Gs.atlasTextureIcon&&(Dt.activeTexture.set(pt.TEXTURE1),Gs.atlasTextureIcon&&Gs.atlasTextureIcon.bind(Gs.atlasInterpolationIcon,pt.CLAMP_TO_EDGE,!0)),Gs.renderWithShadows&&M.shadowRenderer.setupShadows(Gs.tile.tileID.toUnwrapped(),Gs.program,"vector-tile"),M.uploadCommonLightUniforms(M.context,Gs.program),Gs.hasHalo){const Cs=Gs.uniformValues;Cs.u_is_halo=1,l3(Gs.buffers,Hs.segments,v,M,Gs.program,Gs.depthMode,D,z,Cs,2),Cs.u_is_halo=0}else{if(Gs.isSDF){const Cs=Gs.uniformValues;Gs.hasHalo&&(Cs.u_is_halo=1,l3(Gs.buffers,Hs.segments,v,M,Gs.program,Gs.depthMode,D,z,Cs,1)),Cs.u_is_halo=0}l3(Gs.buffers,Hs.segments,v,M,Gs.program,Gs.depthMode,D,z,Gs.uniformValues,1)}}}function l3(M,m,v,A,D,z,B,W,ee,ne){const de=A.context,be=de.gl,ye=[M.dynamicLayoutVertexBuffer,M.opacityVertexBuffer,M.iconTransitioningVertexBuffer,M.globeExtVertexBuffer,M.zOffsetVertexBuffer,M.orientationVertexBuffer];M.featureIdBuffer&&ye.push(M.featureIdBuffer);const Ce=M.uboBinder?null:M.programConfigurations.get(v.id);if(M.uboBinder){M.uboBinder.layer=v;const st=A.transform.zoom,tt=A.style.getBrightness?A.style.getBrightness():null,ct=M.uboBinder.getConstantUniformValues(st,tt);ee.u_spp_fill_np_color=ct.fill_np_color,ee.u_spp_halo_np_color=ct.halo_np_color,ee.u_spp_opacity=ct.opacity,ee.u_spp_halo_width=ct.halo_width,ee.u_spp_halo_blur=ct.halo_blur,ee.u_spp_emissive_strength=ct.emissive_strength,ee.u_spp_occlusion_opacity=ct.occlusion_opacity,ee.u_spp_z_offset=ct.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"?A.transform.angle:0;ee.u_spp_translate_rotation=[Math.cos(nt),Math.sin(nt)]}const{batchIndices:Be,batchSegments:Ie}=M.getBatchGrouping(m);for(const st of Be){const tt=Ie.get(st);M.uboBinder&&M.uboBinder.bind(de,D.program,st),D.draw(A,be.TRIANGLES,z,B,W,Wr.disabled,ee,v.id,M.layoutVertexBuffer,M.indexBuffer,tt,v.paint,A.transform.zoom,Ce,ye,ne)}}function c3(M,m,v,A,D,z){const B=v.paint.get("line-width"),W=v.paint.get("line-emissive-strength").isConstant(),ee=v.paint.get("line-emissive-strength").constantOr(0),ne=v.paint.get("line-occlusion-opacity"),de=v.layout.get("line-elevation-reference"),be=v.layout.get("line-width-unit")==="meters",ye=de==="sea",Ce=!(!M.terrain||!M.terrain.enabled),Be=M.context,Ie=Be.gl;if(v.hasElevatedBuckets&&M.transform.projection.name==="globe")return;const st=v.layout.get("line-cross-slope"),tt=st!==void 0,ct=st<1,mt=D||M.colorModeForDrapableLayerRenderPass(W?ee:null),nt=M.terrain&&M.terrain.renderingToTexture||z,Ft=nt?1:i.o.devicePixelRatio,wt=v.paint.get("line-dasharray"),Dt=wt.constantOr(1),pt=v.layout.get("line-cap"),yt=wt.constantOr(null),Tt=pt.constantOr(null),Wt=v.paint.get("line-pattern"),Bt=Wt.constantOr(1),ns=v.paint.get("line-pattern-cross-fade"),Qt=Wt.constantOr(null),ws=v.paint.get("line-opacity").constantOr(1);let As=!Bt&&ws!==1||M.depthOcclusion&&ne>0&&ne<1;const Zt=v.paint.get("line-gradient"),Ut=Bt?"linePattern":"line",ts=i.dU(v);let as;if(nt&&M.terrain&&M.terrain.clipOrMaskOverlapStencilType()&&(As=!1),ne!==0&&M.depthOcclusion){const Cs=v.paint._values["line-opacity"];Cs&&Cs.value&&Cs.value.kind==="constant"?as=Cs.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&&ts.push("VARIABLE_LINE_WIDTH"),nt&&(M.emissiveMode!=="dual-source-blending"||W?M.emissiveMode==="mrt-fallback"&&ts.push("USE_MRT1"):ts.push("DUAL_SOURCE_BLENDING"));const cs={},Qs=(Cs,br,Ar,mr,yr,Zr)=>{for(const xn of Cs){const un=m.getTile(xn);if(Bt&&!un.patternsLoaded())continue;const $n=un.getBucket(v);if(!$n||$n.elevationType!=="none"&&!yr||$n.elevationType==="none"&&yr)continue;M.prepareDrawTile();const qr=[...br],qn=M.shadowRenderer,hn=$n.elevationType==="road"&&!!qn&&qn.enabled;let Pa=[0,0,0];if(hn){const sa=M.style.directionalLight,vi=M.style.ambientLight;sa&&vi&&(Pa=Ap(M.style,sa,vi)),qr.push("RENDER_SHADOWS","NORMAL_OFFSET")}const hi=$n.programConfigurations.get(v.id);let Gi=!1;if(Qt&&un.imageAtlas){const sa=i.dV.from(Qt),vi=sa.getPrimary().scaleSelf(Ft).toString(),ol=un.imageAtlas.patternPositions.get(vi),od=sa.getSecondary(),_l=od?un.imageAtlas.patternPositions.get(od.scaleSelf(Ft).toString()):null;Gi=!!ol&&!!_l,ol&&hi.setConstantPatternPositions(ol,_l)}ns>0&&(Gi||hi.getPatternTransitionVertexBuffer("line-pattern"))&&qr.push("LINE_PATTERN_TRANSITION"),$n.elevationGroundScaleVertexBuffer&&qr.push("ELEVATION_GROUND_SCALE");const wi=M.isTileAffectedByFog(xn),za=M.getOrCreateProgram(Ut,{config:hi,defines:qr,overrideFog:wi});if(!Bt&&yt&&Tt&&un.lineAtlas){const sa=un.lineAtlas.getDash(yt,Tt);sa&&hi.setConstantPatternPositions(sa)}hn&&qn.setupShadows(un.tileID.toUnwrapped(),za,"vector-tile");let[Rn,On]=v.paint.get("line-trim-offset");(Tt==="round"||Tt==="square")&&Rn!==On&&(Rn===0&&(Rn-=1),On===1&&(On+=1));const ji=nt?xn.projMatrix:null,Qi=be?1/$n.tileToMeter/i.aA(un,1,M.transform.zoom):1,Ba=be?1/$n.tileToMeter/i.aA(un,1,Math.floor(M.transform.zoom)):1,bn=Dt?v.paint._values["line-floorwidth"]:null;let Bi;if(bn&&bn.value.kind==="constant"){const sa=$n.zoom;sa in cs||(cs[sa]=Math.max(.01,v.widthExpression().evaluate({zoom:sa}))),Bi=bn.value.value;const vi=Math.floor(M.transform.zoom);bn.value.value=cs[sa]*Math.pow(2,vi-un.tileID.overscaledZ)}const mi=Bt?i.dW(M,un,v,ji,Ft,Qi,Ba,[Rn,On],Pa,ns):i.dX(M,un,v,ji,$n.lineClipsArray.length,Ft,Qi,Ba,[Rn,On],Pa);if(Zt){const sa=$n.gradients[v.id];let vi=sa.texture;if(v.gradientVersion!==sa.version){let ol=256;if(v.stepInterpolant){const od=m.getSource().maxzoom,_l=xn.canonical.z===od?Math.ceil(1<{as!=null&&(as.value=ws*ne),za.draw(M,Ie.TRIANGLES,Ar,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=ws)};if(As&&!yr){const sa=M.stencilModeForClipping(xn).ref;sa===0&&nt&&Be.clear({stencil:0});const vi={func:Ie.EQUAL,mask:255};mi.u_alpha_discard_threshold=.8,Uo(new nn(vi,sa,255,Ie.KEEP,Ie.KEEP,Ie.INVERT)),mi.u_alpha_discard_threshold=0,Uo(new nn(vi,sa,255,Ie.KEEP,Ie.KEEP,Ie.KEEP))}else mi.u_alpha_discard_threshold=As&&yr&&Zr?.8:0,Uo(yr?mr:M.stencilModeForClipping(xn));Bi!==void 0&&(bn.value.value=Bi)}};let Hs=M.depthModeForSublayer(0,Nr.ReadOnly);const Gs=new Nr(M.depthOcclusion?Ie.GREATER:Ie.LEQUAL,Nr.ReadOnly,M.depthRangeFor3D);if(v.hasNonElevatedBuckets){const Cs=!nt&&M.terrain;ne!==0&&Cs?i.w(`Occlusion opacity for layer ${v.id} is supported on terrain only if the layer has line-z-offset enabled.`):Cs?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${v.id}.`):Qs(A,ts,Hs,nn.disabled,!1,!0)}if(v.hasElevatedBuckets){de==="hd-road-markup"?Ce||(Hs=Gs,ts.push("ELEVATED_ROADS")):(ts.push("ELEVATED"),Hs=Gs,tt&&ts.push(ct?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),ye&&ts.push("ELEVATION_REFERENCE_SEA"));const Cs=As?M.stencilModeFor3D():nn.disabled;M.forceTerrainMode=!0,Qs(A,ts,Hs,Cs,!0,!0),As&&Qs(A,ts,Hs,Cs,!0,!1),M.forceTerrainMode=!1}As&&(M.resetStencilClippingMasks(),nt&&Be.clear({stencil:0})),ne===0||M.depthOcclusion||nt||M.layersWithOcclusionOpacity.push(M.currentLayer)}const Gx={additive:{clearColor:new i.aq(0,0,0,0),colorMode:tn.additive,compositeUniformValue:1},multiply:{clearColor:new i.aq(1,1,1,1),colorMode:tn.multiply,compositeUniformValue:0}};function oP(M,m){const v=1<=z0?1:Ce.pitch/z0))),2*Be}(M.transform),ne=M.transform.getFreeCameraOptions().position,de="elevatedStructuresDepthReconstruct",be=M.getOrCreateProgram(de,{defines:["DEPTH_RECONSTRUCTION"]}),ye=M.getOrCreateProgram(de);for(const Ce of A){const Be=m.getTile(Ce),Ie=Be.getBucket(v);if(!Ie)continue;const st=Ie.elevatedStructures;if(!st)continue;const tt=Ie.elevationBufferData.heightRange,ct=oP(Ce.toUnwrapped(),ne),mt=M.translatePosMatrix(Ce.projMatrix,Be,v.paint.get("fill-translate"),v.paint.get("fill-translate-anchor"));let nt,Ft,wt,Dt;if(D==="initialize"){if(!tt||tt.min>=1||st.depthSegments.segments[0].primitiveLength===0)continue;nt=Jw(mt,ct,ee,1,0),Ft=B,wt=st.depthSegments,Dt=be}else if(D==="reset"){if(!tt||tt.min>=0||st.maskSegments.segments[0].primitiveLength===0)continue;nt=Jw(mt,ct,0,0,1),Ft=W,wt=st.maskSegments,Dt=be}else if(D==="geometry"){if(st.depthSegments.segments[0].primitiveLength===0)continue;nt=Jw(mt,ct,ee,1,0),Ft=B,wt=st.depthSegments,Dt=ye}Dt.draw(M,z.TRIANGLES,Ft,nn.disabled,tn.disabled,Wr.disabled,nt,v.id,st.vertexBuffer,st.indexBuffer,wt,v.paint,M.transform.zoom)}}function a2(M,m,v,A){const{painter:D,sourceCache:z,layer:B,coords:W,colorMode:ee,elevationType:ne,terrainEnabled:de,pass:be}=M,ye=D.context.gl,Ce=B.paint.get("fill-pattern"),Be=B.paint.get("fill-pattern-cross-fade"),Ie=Ce.constantOr(null);let st=ne;ne!=="road"||m&&!de||(st="none");const tt=st==="road",ct=M.painter.shadowRenderer,mt=tt&&!!ct&&ct.enabled,nt=new Nr(D.context.gl.LEQUAL,Nr.ReadOnly,D.depthRangeFor3D);let Ft=[0,0,0];if(mt){const yt=D.style.directionalLight,Tt=D.style.ambientLight;yt&&Tt&&(Ft=Ap(D.style,yt,Tt))}const wt=Ce&&Ce.constantOr(1),Dt=D.terrain&&D.terrain.renderingToTexture,pt=(yt,Tt)=>{let Wt,Bt,ns,Qt,ws;Tt?(Wt=wt&&!B.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",ns=ye.LINES):(Wt=wt?"fillPattern":"fill",ns=ye.TRIANGLES);for(const As of W){const Zt=z.getTile(As);if(wt&&!Zt.patternsLoaded())continue;const Ut=Zt.getBucket(B);if(!Ut)continue;const ts=m?Ut.elevationBufferData:Ut.bufferData;if(ts.isEmpty())continue;D.prepareDrawTile();const as=ts.programConfigurations.get(B.id),cs=D.isTileAffectedByFog(As),Qs=[],Hs=[];tt&&(Qs.push("ELEVATED_ROADS"),Hs.push(ts.elevatedLayoutVertexBuffer)),mt&&Qs.push("RENDER_SHADOWS","NORMAL_OFFSET"),Dt&&v&&Qs.push("USE_MRT1"),wt&&(D.context.activeTexture.set(ye.TEXTURE0),Zt.imageAtlasTexture&&Zt.imageAtlasTexture.bind(ye.LINEAR,ye.CLAMP_TO_EDGE),as.updatePaintBuffers());let Gs=!1;if(Ie&&Zt.imageAtlas){const yr=Zt.imageAtlas,Zr=i.dV.from(Ie),xn=Zr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),un=Zr.getSecondary(),$n=yr.patternPositions.get(xn),qr=un?yr.patternPositions.get(un.scaleSelf(i.o.devicePixelRatio).toString()):null;Gs=!!$n&&!!qr,$n&&as.setConstantPatternPositions($n,qr)}Be>0&&(Gs||as.getPatternTransitionVertexBuffer("fill-pattern"))&&Qs.push("FILL_PATTERN_TRANSITION");const Cs=D.getOrCreateProgram(Wt,{config:as,overrideFog:cs,defines:Qs}),br=D.translatePosMatrix(As.projMatrix,Zt,B.paint.get("fill-translate"),B.paint.get("fill-translate-anchor"));mt&&ct.setupShadows(Zt.tileID.toUnwrapped(),Cs,"vector-tile");const Ar=B.paint.get("fill-emissive-strength");if(Tt){Qt=ts.lineIndexBuffer,ws=ts.lineSegments;const yr=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[ye.drawingBufferWidth,ye.drawingBufferHeight];Bt=Wt==="fillOutlinePattern"&&wt?H1(br,Ar,D,Zt,yr,Ft,Be):QO(br,Ar,yr,Ft)}else Qt=ts.indexBuffer,ws=ts.triangleSegments,Bt=wt?JC(br,Ar,D,Zt,Ft,Be):QC(br,Ar,Ft);D.uploadCommonUniforms(D.context,Cs,As.toUnwrapped());let mr=yt;(ne==="road"&&!de||ne==="offset")&&(mr=nt),Cs.draw(D,ns,mr,A||D.stencilModeForClipping(As),ee,Wr.disabled,Bt,B.id,ts.layoutVertexBuffer,Qt,ws,B.paint,D.transform.zoom,as,Hs)}};D.renderPass===be&&pt(D.depthModeForSublayer(1,D.renderPass==="opaque"?Nr.ReadWrite:Nr.ReadOnly),!1),st==="none"&&D.renderPass==="translucent"&&B.paint.get("fill-antialias")&&pt(D.depthModeForSublayer(B.getPaintProperty("fill-outline-color")?2:0,Nr.ReadOnly),!0)}function W0(M,m,v,A,D,z,B,W){v.resetLayerRenderingStats(M);const ee=M.context,ne=ee.gl,de=M.transform,be=v.paint.get("fill-extrusion-pattern"),ye=v.paint.get("fill-extrusion-pattern-cross-fade"),Ce=be.constantOr(null),Be=be.constantOr(1),Ie=v.paint.get("fill-extrusion-opacity"),st=M.style.enable3dLights(),tt=v.paint.get(st&&!Be?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),ct=[v.paint.get("fill-extrusion-ambient-occlusion-intensity"),tt],mt=v.layout.get("fill-extrusion-edge-radius"),nt=mt>0&&!v.paint.get("fill-extrusion-rounded-roof"),Ft=nt?0:mt,wt=de.projection.name==="globe"?i.e1():0,Dt=de.projection.name==="globe",pt=Dt?i.al(de.zoom):0,yt=[i.aH(de.center.lng),i.aL(de.center.lat)],Tt=v.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Wt=v.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Tt?null:v.lut).toArray01().slice(0,3),Bt=v.paint.get("fill-extrusion-flood-light-intensity"),ns=v.paint.get("fill-extrusion-vertical-scale"),Qt=v.paint.get("fill-extrusion-line-width").constantOr(1)!==0,ws=v.paint.get("fill-extrusion-height-alignment"),As=v.paint.get("fill-extrusion-base-alignment"),Zt=nc(M,v.paint.get("fill-extrusion-cutoff-fade-range")),Ut=v.paint.get("fill-extrusion-front-cutoff"),ts=d3(de.pitch,Ut,!!M.terrain),as=ts[2]<1;as&&(M.maxFrontCutoffRawStart=Math.max(M.maxFrontCutoffRawStart,Ut[0]));const cs=[];let Qs;Dt&&cs.push("PROJECTION_GLOBE_VIEW"),ct[0]>0&&cs.push("FAUX_AO"),nt&&cs.push("ZERO_ROOF_RADIUS"),W&&cs.push("HAS_CENTROID"),Bt>0&&cs.push("FLOOD_LIGHT"),Zt.shouldRenderCutoff&&cs.push("RENDER_CUTOFF"),as&&cs.push("RENDER_FRONT_CUTOFF"),Qt&&cs.push("RENDER_WALL_MODE");const Hs=M.renderPass==="shadow",Gs=M.shadowRenderer,Cs=Hs&&!!Gs,br=Hs?Wr.disabled:Wr.backCCW;M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0);let Ar=[0,0,0];if(Gs){const Zr=M.style.directionalLight,xn=M.style.ambientLight;Zr&&xn&&(Ar=Ap(M.style,Zr,xn)),Hs||(cs.push("RENDER_SHADOWS"),Gs.useNormalOffset&&cs.push("NORMAL_OFFSET")),Qs=cs.concat(["SHADOWS_SINGLE_CASCADE"])}const mr=Cs?"fillExtrusionDepth":Be?"fillExtrusionPattern":"fillExtrusion",yr=v.getLayerRenderingStats();for(const Zr of A){const xn=m.getTile(Zr),un=xn.getBucket(v);if(!un||un.projection.name!==de.projection.name)continue;let $n=!1;Gs&&($n=Gs.getMaxCascadeForTile(Zr.toUnwrapped())===0);const qr=M.isTileAffectedByFog(Zr),qn=un.programConfigurations.get(v.id);let hn=!1;if(Ce&&xn.imageAtlas){const On=xn.imageAtlas,ji=i.dV.from(Ce),Qi=ji.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),Ba=ji.getSecondary(),bn=On.patternPositions.get(Qi),Bi=Ba?On.patternPositions.get(Ba.scaleSelf(i.o.devicePixelRatio).toString()):null;hn=!!bn&&!!Bi,bn&&qn.setConstantPatternPositions(bn,Bi)}ye>0&&(hn||qn.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&cs.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Pa=M.getOrCreateProgram(mr,{config:qn,defines:$n?Qs:cs,overrideFog:qr});if(M.terrain&&M.terrain.setupElevationDraw(xn,Pa,{useMeterToDem:!0}),!un.centroidVertexBuffer){const On=Pa.getAttributeLocation(ne,"a_centroid_pos");On!==-1&&ne.vertexAttribI4ui(On,0,0,0,0)}!Hs&&Gs&&Gs.setupShadows(xn.tileID.toUnwrapped(),Pa,"vector-tile"),Be&&(M.context.activeTexture.set(ne.TEXTURE0),xn.imageAtlasTexture&&xn.imageAtlasTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),qn.updatePaintBuffers());const hi=v.paint.get("fill-extrusion-vertical-gradient"),Gi=1/un.tileToMeter;let wi;if(Hs&&Gs){if(u3(xn.tileID,un.maxHeight,M))continue;const On=Gs.calculateShadowPassMatrixFromTile(xn.tileID.toUnwrapped());wi=ype(On,Ft,Gi,ns,ws,As)}else{const On=M.translatePosMatrix(Zr.expandedProjMatrix,xn,v.paint.get("fill-extrusion-translate"),v.paint.get("fill-extrusion-translate-anchor")),ji=de.projection.createInversionMatrix(de,Zr.canonical);wi=Be?vpe(On,M,hi,Ie,ct,Ft,Gi,Zr,xn,wt,ws,As,pt,yt,ji,Wt,ns,ye):XO(On,M,hi,Ie,ct,Ft,Gi,Zr,wt,ws,As,pt,yt,ji,Wt,ns,Bt,Ar,ts)}M.uploadCommonUniforms(ee,Pa,Zr.toUnwrapped(),null,Zt);let za=un.segments;if(de.projection.name==="mercator"&&!Hs&&(za=un.getVisibleSegments(xn.tileID,M.terrain,M.transform.getFrustum(0)),!za.get().length))continue;if(yr)if(Hs)for(const On of za.get())yr.numRenderedVerticesInShadowPass+=On.primitiveLength;else for(const On of za.get())yr.numRenderedVerticesInTransparentPass+=On.primitiveLength;const Rn=[];(M.terrain||W)&&Rn.push(un.centroidVertexBuffer),Dt&&Rn.push(un.layoutVertexExtBuffer),Qt&&Rn.push(un.wallVertexBuffer),Pa.draw(M,ee.gl.TRIANGLES,D,z,B,br,wi,v.id,un.layoutVertexBuffer,un.indexBuffer,za,v.paint,M.transform.zoom,qn,Rn)}M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!1)}class lP{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function d3(M,m,v){if(!(m[2]<1)||v)return[0,0,1];const A=180*M/Math.PI;if(A<15)return[-.5,m[1],m[2]];const D=Math.min(1,Math.max(0,(A-15)/5)),z=D*D*(3-2*D);return[-.5*(1-z)+m[0]*z,m[1],m[2]]}function Pf(M,m,v,A,D,z,B,W,ee,ne,de,be,ye,Ce,Be,Ie,st,tt,ct,mt,nt){const Ft=m.context,wt=Ft.gl,Dt=m.transform,pt=m.transform.zoom,yt=[],Tt=M.translate,Wt=M.translateAnchor,Bt=M.edgeRadius,ns=nc(m,M.cutoffFadeRange);de==="clear"?(yt.push("CLEAR_SUBPASS"),mt&&(yt.push("CLEAR_FROM_TEXTURE"),Ft.activeTexture.set(wt.TEXTURE0),mt.bind(wt.LINEAR,wt.CLAMP_TO_EDGE))):de==="sdf"?yt.push("SDF_SUBPASS"):de==="emissive"&&(yt.push("USE_MRT1"),Ft.activeTexture.set(wt.TEXTURE0),mt.bind(wt.LINEAR,wt.CLAMP_TO_EDGE)),tt&&yt.push("HAS_CENTROID"),ns.shouldRenderCutoff&&yt.push("RENDER_CUTOFF");const Qt=(ws,As,Zt,Ut,ts)=>{let as=yt;As.groundRadiusBuffer!=null&&(as=yt.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const cs=As.programConfigurations.get(A.id),Qs=m.isTileAffectedByFog(ws),Hs=m.getOrCreateProgram("fillExtrusionGroundEffect",{config:cs,defines:as,overrideFog:Qs}),Gs=((br,Ar,mr,yr,Zr,xn,un,$n,qr,qn,hn)=>({u_matrix:Ar,u_opacity:mr,u_ao_pass:yr?1:0,u_meter_to_tile:Zr,u_ao:xn,u_flood_light_intensity:un,u_flood_light_color:$n,u_attenuation:qr,u_edge_radius:qn,u_fb:0,u_fb_size:hn,u_dynamic_offset:1}))(0,Ut,be,ne,ts,[ye,Ce*ts],Be,Ie,st,pt>=17?0:Bt*ts,mt?mt.size[0]:0),Cs=[];tt&&Cs.push(As.hiddenByLandmarkVertexBuffer),As.groundRadiusBuffer!=null&&Cs.push(As.groundRadiusBuffer),m.uploadCommonUniforms(Ft,Hs,ws.toUnwrapped(),null,ns),Hs.draw(m,Ft.gl.TRIANGLES,z,B,W,ee,Gs,A.id,As.vertexBuffer,As.indexBuffer,Zt,A.paint,pt,cs,Cs)};for(const ws of D){const As=v.getTile(ws),Zt=As.getBucket(A);if(!Zt||Zt.projection.name!==Dt.projection.name||!Zt.groundEffect||Zt.groundEffect&&!Zt.groundEffect.hasData())continue;const Ut=Zt.groundEffect,ts=1/Zt.tileToMeter;{const as=m.translatePosMatrix(ws.projMatrix,As,Tt,Wt),cs=Ut.getDefaultSegment();Qt(ws,Ut,cs,as,ts)}if(ct)for(let as=0;as<4;as++){const cs=i.d$[as](ws),Qs=v.getTile(cs);if(!Qs)continue;const Hs=Qs.getBucket(A);if(!Hs||Hs.projection.name!==Dt.projection.name||!Hs.groundEffect||Hs.groundEffect&&!Hs.groundEffect.hasData())continue;const Gs=Hs.groundEffect;let Cs,br;as===0?(Cs=[-i.an,0,0],br=1):as===1?(Cs=[i.an,0,0],br=0):as===2?(Cs=[0,-i.an,0],br=3):(Cs=[0,i.an,0],br=2);const Ar=Gs.regionSegments[br];if(!Ar)continue;const mr=new Float32Array(16);i.bx(mr,ws.projMatrix,Cs),Qt(ws,Gs,Ar,m.translatePosMatrix(mr,As,Tt,Wt),ts)}}}function cF(M,m,v,A,D,z,B){A.centroidVertexArray.length===0&&A.createCentroidsBuffer();const W=z?z.findDEMTileFor(v):null;if(!(W&&W.dem||B))return;z&&W&&W.dem&&A.selfDEMTileTimestamp!==W.dem._timestamp&&(A.borderDoneWithNeighborZ=[-1,-1,-1,-1],A.selfDEMTileTimestamp=W.dem._timestamp);const ee=(tt,ct)=>{(tt.flags|ct.flags)&i.e3?(tt.flags|=i.e3,ct.flags|=i.e3):(tt.flags&=~i.e3,ct.flags&=~i.e3)},ne=tt=>new i.P(Math.ceil((tt+i.e4)*i.e5),0),de=(tt,ct,mt)=>{const nt=Math.ceil((tt+i.e4)*i.e5),Ft=Math.floor(Math.max(0,Math.min(i.an-1,mt))/4);return new i.P(nt,Ft<<5|(3&ct)<<3|7)},be=tt=>{const ct=m.getSource().minzoom,mt=Ft=>{const wt=m.getTileByID(Ft);if(wt&&wt.hasData())return wt.getBucket(D)},nt=[0,-1,1];for(const Ft of nt){if(tt.overscaledZ+Ft(ye[0]=Math.min(tt.min.y,ct.min.y),ye[1]=Math.max(tt.max.y,ct.max.y),ye[2]=i.an-ct.min.x>tt.max.x?ct.min.x-i.an:tt.max.x,ye),Be=(tt,ct)=>(ye[0]=Math.min(tt.min.x,ct.min.x),ye[1]=Math.max(tt.max.x,ct.max.x),ye[2]=i.an-ct.min.y>tt.max.y?ct.min.y-i.an:tt.max.y,ye),Ie=[(tt,ct)=>Ce(tt,ct),(tt,ct)=>Ce(ct,tt),(tt,ct)=>Be(tt,ct),(tt,ct)=>Be(ct,tt)],st=(tt,ct,mt,nt,Ft,wt,Dt)=>{if(!z)return 0;const pt=[[wt?mt:tt,wt?tt:mt,0],[wt?mt:ct,wt?ct:mt,0]],yt=Dt<0?i.an+Dt:Dt,Tt=[wt?yt:(tt+ct)/2,wt?(tt+ct)/2:yt,0];return mt===0&&Dt<0||mt!==0&&Dt>0?z.getForTilePoints(Ft,[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 tt=0;tt<4;tt++){const ct=A.borderFeatureIndices[tt];if(ct.length===0)continue;const mt=i.d$[tt](v),nt=be(mt);if(!(nt&&nt instanceof i.e0))continue;const Ft=z?z.findDEMTileFor(mt):null;if(!(Ft&&Ft.dem||B)||(z&&Ft&&Ft.dem&&A.borderDEMTileTimestamp[tt]!==Ft.dem._timestamp&&(A.borderDoneWithNeighborZ[tt]=-1,A.borderDEMTileTimestamp[tt]=Ft.dem._timestamp),A.borderDoneWithNeighborZ[tt]===nt.canonical.z))continue;nt.centroidVertexArray.length===0&&nt.createCentroidsBuffer();const wt=(tt<2?1:5)-tt,Dt=nt.borderDoneWithNeighborZ[wt]!==A.canonical.z,pt=nt.borderFeatureIndices[wt];let yt=0;if(A.canonical.z!==nt.canonical.z){for(const ns of ct)A.showCentroid(A.featuresOnBorder[ns]);if(Dt)for(const ns of pt)nt.showCentroid(nt.featuresOnBorder[ns]);A.borderDoneWithNeighborZ[tt]=nt.canonical.z,nt.borderDoneWithNeighborZ[wt]=A.canonical.z;continue}const Tt=new Map,Wt=new Set,Bt=new Set;for(let ns=0;ns1||Zt.intersectsCount()>1;{let Hs=0;if(Ft&&Ft.dem&&!Qs){const Gs=Ie[tt](ws,Ut),Cs=tt%2?i.an-1:0;Hs=st(Gs[0],Math.min(i.an-1,Gs[1]),Cs,Ft,mt,tt<2,Gs[2])}ws.centroidXY=de(Hs,tt,cs),Ut.centroidXY=de(Hs,wt,cs)}if(A.writeCentroidToBuffer(ws),nt.writeCentroidToBuffer(Ut),Qt.buildingId!==void 0){for(const Hs of A.centroidData)Hs.buildingId===Qt.buildingId&&Hs!==ws&&(Hs.centroidXY=ws.centroidXY,A.writeCentroidToBuffer(Hs));for(const Hs of nt.centroidData)Hs.buildingId===Qt.buildingId&&Hs!==Ut&&(Hs.centroidXY=Ut.centroidXY,nt.writeCentroidToBuffer(Hs))}}for(const ns of ct){if(Wt.has(ns))continue;const Qt=A.featuresOnBorder[ns],ws=A.centroidData[Qt.centroidDataIndex],As=Qt.borders[tt];let Zt;for(;ytAs[0]+3||Ut[0]>As[0]-3)break;nt.showCentroid(Zt),yt++}if(Zt&&ytAs[1]-3||(ts++,++yt===pt.length))break;Zt=nt.featuresOnBorder[pt[yt]]}for(;Ut=pt.length){A.showCentroid(Qt);continue}Zt=nt.featuresOnBorder[pt[Ut]];let as=!1;if(ts>=1){const Hs=Zt.borders[wt];Math.abs(As[0]-Hs[0])<3&&Math.abs(As[1]-Hs[1])<3&&(ts=1,as=!0,yt=Ut+1)}else if(ts===0){A.showCentroid(Qt);continue}const cs=nt.centroidData[Zt.centroidDataIndex];B&&as&&ee(ws,cs);const Qs=Qt.intersectsCount()>1||Zt.intersectsCount()>1;if(ts>1)yt=Ut,ws.centroidXY=cs.centroidXY=new i.P(0,0);else if(Ft&&Ft.dem&&!Qs){const Hs=Ie[tt](ws,cs),Gs=tt%2?i.an-1:0,Cs=st(Hs[0],Math.min(i.an-1,Hs[1]),Gs,Ft,mt,tt<2,Hs[2]);ws.centroidXY=cs.centroidXY=ne(Cs)}else Qs?ws.centroidXY=cs.centroidXY=new i.P(0,0):(ws.centroidXY=A.encodeBorderCentroid(Qt),cs.centroidXY=nt.encodeBorderCentroid(Zt));A.writeCentroidToBuffer(ws),nt.writeCentroidToBuffer(cs)}else A.showCentroid(Qt)}A.borderDoneWithNeighborZ[tt]=nt.canonical.z,nt.borderDoneWithNeighborZ[wt]=A.canonical.z}(A.needsCentroidUpdate||!A.centroidVertexBuffer&&A.centroidVertexArray.length!==0)&&A.uploadCentroid(M)}const dF=[1,0,0],uF=[0,1,0],cP=[0,0,1];function u3(M,m,v){const A=v.transform,D=v.shadowRenderer;if(!D)return!0;const z=M.toUnwrapped(),B=A.tileSize*D._cascades[v.currentShadowCascade].scale;let W=m;if(A.elevation){const Be=A.elevation.getMinMaxForTile(M);Be&&(W+=Be.max)}const ee=A.scaleZoom(B);W/=i.e2(A.center.lat,ee);const ne=[...D.shadowDirection];ne[2]=-ne[2];const de=D.computeSimplifiedTileShadowVolume(z,W,B,ne);if(!de)return!1;const be=[dF,uF,cP,ne,[ne[0],0,ne[2]],[0,ne[1],ne[2]]],ye=i.cl.fromInvProjectionMatrix(A.invProjMatrix,A.worldSize,ee,A.projection.name!=="globe"),Ce=D.getCurrentCascadeFrustum();return ye.intersectsPrecise(de.vertices,de.planes,be)===0||Ce.intersectsPrecise(de.vertices,de.planes,be)===0}function i2(M){const{painter:m,source:v,layer:A,coords:D}=M;let z=M.defines;const B=m.context,W=m.renderPass==="shadow",ee=m.renderPass==="light-beam",ne=m.shadowRenderer,de=i.e2(m.transform.center.lat,m.transform.zoom),be=nc(m,A.paint.get("building-cutoff-fade-range"));be.shouldRenderCutoff&&(z=z.concat("RENDER_CUTOFF"));const ye=A.paint.get("building-front-cutoff"),Ce=ye[2]<1&&!m.terrain,Be=d3(m.transform.pitch,ye,!!m.terrain);Ce&&(z=z.concat("RENDER_FRONT_CUTOFF"),m.maxFrontCutoffRawStart=Math.max(m.maxFrontCutoffRawStart,ye[0])),M.floodLightIntensity>0&&(z=z.concat("FLOOD_LIGHT"));for(const Ie of D){const st=v.getTile(Ie),tt=st.getBucket(A);if(!tt)continue;ne&&ne.getMaxCascadeForTile(Ie.toUnwrapped())===0&&(z=z.concat("SHADOWS_SINGLE_CASCADE"));const ct=tt.programConfigurations.get(A.id);let mt,nt,Ft,wt=m.translatePosMatrix(Ie.expandedProjMatrix,st,[0,0],"map");if(wt=i.cC(i.bb(),wt,[1,1,M.verticalScale]),W&&ne){if(u3(st.tileID,tt.maxHeight*de,m))continue;let pt=ne.calculateShadowPassMatrixFromTile(st.tileID.toUnwrapped());pt=i.cC(i.bb(),pt,[1,1,M.verticalScale]),Ft=s3(pt),mt=nt=m.getOrCreateProgram("buildingDepth",{config:ct,defines:z,overrideFog:!1})}else if(ee)mt=nt=m.getOrCreateProgram("buildingBloom",{config:ct,defines:z,overrideFog:!1}),Ft=t3(wt);else{const pt=m.transform.calculatePosMatrix(Ie.toUnwrapped(),m.transform.worldSize);i.cC(pt,pt,[1,1,M.verticalScale]);const yt=i.bb();i.cC(yt,pt,[1,-1,1/de]),i.b7(yt,yt),i.e6(yt,yt);const Tt=m.transform.getFreeCameraOptions().position,Wt=1<{if(ee){const Tt=pt.entranceBloom;yt.draw(m,B.gl.TRIANGLES,M.depthMode,nn.disabled,M.blendMode,Wr.disabled,Ft,A.id,Tt.layoutVertexBuffer,Tt.indexBuffer,Tt.segmentsBucket,A.paint,m.transform.zoom,ct,[Tt.layoutAttenuationBuffer,Tt.layoutColorBuffer])}else{const Tt=pt.segmentsBucket;let Wt=[pt.layoutNormalBuffer,pt.layoutCentroidBuffer,pt.layoutColorBuffer,pt.layoutFloodLightDataBuffer];pt.layoutFacadePaintBuffer&&(Wt=Wt.concat([pt.layoutFacadeDataBuffer,pt.layoutFacadeVerticalRangeBuffer,pt.layoutFacadePaintBuffer])),yt.draw(m,B.gl.TRIANGLES,M.depthMode,nn.disabled,M.blendMode,W?Wr.disabled:Wr.backCW,Ft,A.id,pt.layoutVertexBuffer,pt.indexBuffer,Tt,A.paint,m.transform.zoom,ct,Wt)}};m.uploadCommonUniforms(B,nt,Ie.toUnwrapped(),null,be),tt.buildingWithoutFacade&&Dt(tt.buildingWithoutFacade,nt),tt.buildingWithFacade&&(mt!==nt&&m.uploadCommonUniforms(B,mt,Ie.toUnwrapped(),null,be),Dt(tt.buildingWithFacade,mt))}}function dP(M,m,v,A,D,z,B,W,ee,ne,de,be,ye,Ce){const Be=M.context.gl,Ie=M.depthModeForSublayer(1,Nr.ReadOnly,Be.LEQUAL,!0),st=.1*(1-(tt=de))+3*tt;var tt;const ct=M._showOverdrawInspector,mt=be,nt=new lP;ct||Pf(nt,M,m,v,A,Ie,new nn({func:Be.ALWAYS,mask:255},255,255,Be.KEEP,Be.KEEP,Be.REPLACE),new tn([Be.ONE,Be.ONE,Be.ONE,Be.ONE],i.aq.transparent,[!1,!1,!1,!0],Be.MIN),Wr.disabled,D,"sdf",z,B,W,ee,ne,st,mt,!1,void 0);{const Ft=ct?nn.disabled:new nn({func:Be.EQUAL,mask:255},255,255,Be.KEEP,Be.DECR,Be.DECR),wt=ct?M.colorModeForRenderPass():new tn([Be.ONE_MINUS_DST_ALPHA,Be.DST_ALPHA,Be.ONE,Be.ONE],i.aq.transparent,[!0,!0,!0,!0]);Pf(nt,M,m,v,A,Ie,Ft,wt,Wr.disabled,D,"color",z,B,W,ee,ne,st,mt,!1,void 0)}}function uP(M){return[M[0]*i.e7,M[1]*i.e7,M[2]*i.e7,0]}function h3(M,m,v,A,D,z,B,W,ee){const ne=A.getSource(),de=v.globeSharedBuffers;if(!de)return;let be,ye,Ce;if(m&&(be=A.getTile(m)),ne instanceof i.aV?(ye=ne.texture,Ce=i.dw(0,0,v.transform)):be&&m&&(ye=be.texture,Ce=i.dw(m.canonical.z,m.canonical.x,v.transform)),!ye||!Ce)return;M||(Ce=i.cC(i.bb(),Ce,[1,-1,1]));const Be=v.context,Ie=Be.gl,st=D.paint.get("raster-resampling")==="nearest"?Ie.NEAREST:Ie.LINEAR,tt=v.colorModeForDrapableLayerRenderPass(z),ct=B.defines;ct.push("GLOBE_POLES");const mt=new Nr(Ie.LEQUAL,Nr.ReadWrite,v.depthRangeFor3D),nt=Float32Array.from(v.transform.expandedFarZProjMatrix),Ft=Float32Array.from(i.du(i.dv(new i.cn(0,0,0))));v.terrain&&v.terrain.prepareDrawTile(),Be.activeTexture.set(Ie.TEXTURE0),ye.bind(st,Ie.CLAMP_TO_EDGE),Be.activeTexture.set(Ie.TEXTURE1),ye.bind(st,Ie.CLAMP_TO_EDGE),"useMipmap"in ye&&Be.extTextureFilterAnisotropic&&v.transform.pitch>20&&Ie.texParameterf(Ie.TEXTURE_2D,Be.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,Be.extTextureFilterAnisotropicMax);const[wt,Dt,pt,yt]=m?de.getPoleBuffers(m.canonical.z,!1):de.getPoleBuffers(0,!0),Tt=D.paint.get("raster-elevation");let Wt;M?(Wt=wt,v.renderDefaultNorthPole=Tt!==0):(Wt=Dt,v.renderDefaultSouthPole=Tt!==0);const Bt=uP(B.mix),ns=((ws,As,Zt,Ut,ts,as,cs,Qs,Hs,Gs,Cs,br,Ar,mr)=>rF(ws,As,Zt,Ut,new Float32Array(16),new Float32Array(9),[0,0],ts,[0,0],[0,0,0,0],1,{opacity:1,mix:0},cs,[0,0],Hs,2,Cs,br,Ar,1,0,mr))(v,nt,Ft,Ce,i.al(v.transform.zoom),0,D,0,Tt,0,Bt,B.offset,B.range,z),Qt=v.getOrCreateProgram("raster",{defines:ct});v.uploadCommonUniforms(Be,Qt,null),Qt.draw(v,Ie.TRIANGLES,mt,ee,tt,W,ns,D.id,Wt,pt,yt)}function hP(M){if(M.isOrthographic)return[0,0,0,0];const m=M._nearZ,v=M.projection.farthestPixelDistance(M),A=v-m,D=.2*M.height,z=m+D;return[m,v,(z-D-m)/A,(z-m)/A]}function hF(M,m,v,A){if(M)return m instanceof xh&&M instanceof Cp?m.getTextureDescriptor(M,v,!0):{texture:M.texture,mix:uP(A.mix),offset:A.offset,buffer:0,tileSize:1}}var mP=i.e8([{name:"a_index",type:"Int16",components:1}]);class mF{constructor(m,v,A,D){const z={width:A[0],height:A[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 A=this.context.gl,D=v.width*v.height;this.particleTexture0=new i.T(this.context,v,A.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new i.T(this.context,v,A.RGBA8,{premultiply:!1,useMipmap:!1});const z=new i.e9;z.reserve(D);for(let B=0;B0){const Bt=i.ec(v.canonical,ee),ns=i.ed(Bt);ye=i.aD(new Float32Array(16),ee.globeMatrix,ns),i.aD(ye,ee.projMatrix,ye)}const Ce=i.bb();Ce[12]+=2*D/(i.o.devicePixelRatio*ee.width),Ce[13]+=2*z/(i.o.devicePixelRatio*ee.height),i.aD(ye,Ce,ye);const Be=M.getOrCreateProgram("debug",{defines:be}),Ie=m.getTileByID(v.key);M.terrain&&M.terrain.setupElevationDraw(Ie,Be);const st=Nr.disabled,tt=nn.disabled,ct=M.colorModeForRenderPass(),mt="$debug";W.activeTexture.set(ne.TEXTURE0),M.emptyTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),de?Ie._makeGlobeTileDebugBuffers(M.context,ee):Ie._makeDebugTileBoundsBuffers(M.context,ee.projection);const nt=Ie._tileDebugBuffer||M.debugBuffer,Ft=Ie._tileDebugIndexBuffer||M.debugIndexBuffer,wt=Ie._tileDebugSegments||M.debugSegments;if(Be.draw(M,ne.LINE_STRIP,st,tt,ct,Wr.disabled,e2(ye,A.toPremultipliedRenderColor(null)),mt,nt,Ft,wt,null,null,null,[Ie._globeTileDebugBorderBuffer]),B){const Bt=Ie.latestRawTileData,ns=Math.floor((Bt&&Bt.byteLength||0)/1024);let Qt=v.canonical.toString();v.overscaledZ!==v.canonical.z&&(Qt+=` => ${v.overscaledZ}`),Qt+=` ${Ie.state}`,Qt+=` ${ns}kb`,function(ws,As){ws.initDebugOverlayCanvas();const Zt=ws.debugOverlayCanvas,Ut=ws.context.gl,ts=ws.debugOverlayCanvas.getContext("2d");ts.clearRect(0,0,Zt.width,Zt.height),ts.shadowColor="white",ts.shadowBlur=2,ts.lineWidth=1.5,ts.strokeStyle="white",ts.textBaseline="top",ts.font="bold 36px Open Sans, sans-serif",ts.fillText(As,5,5),ts.strokeText(As,5,5),ws.debugOverlayTexture.update(Zt),ws.debugOverlayTexture.bind(Ut.LINEAR,Ut.CLAMP_TO_EDGE)}(M,Qt)}const Dt=m.getTile(v).tileSize,pt=512/Math.min(Dt,512)*(v.overscaledZ/ee.zoom)*.5,yt=Ie._tileDebugTextBuffer||M.debugBuffer,Tt=Ie._tileDebugTextIndexBuffer||M.quadTriangleIndexBuffer,Wt=Ie._tileDebugTextSegments||M.debugSegments;Be.draw(M,ne.TRIANGLES,st,tt,tn.alphaBlended,Wr.disabled,e2(ye,i.aq.transparent.toPremultipliedRenderColor(null),pt),mt,yt,Tt,Wt,null,null,null,[Ie._globeTileDebugTextBuffer])}function fF(M,m,v,A){m3(M,0,m+v/2,M.transform.width,v,A)}function yP(M,m,v,A){m3(M,m-v/2,0,v,M.transform.height,A)}function m3(M,m,v,A,D,z){const B=M.context,W=B.gl;W.enable(W.SCISSOR_TEST),W.scissor(m*i.o.devicePixelRatio,v*i.o.devicePixelRatio,A*i.o.devicePixelRatio,D*i.o.devicePixelRatio),B.clear({color:z}),W.disable(W.SCISSOR_TEST)}const kpe=i.e8([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:yh}=kpe;function If(M,m,v,A){M.emplaceBack(m,v,A)}class Wd{constructor(m){this.vertexArray=new i.ee,this.indices=new i.dC,If(this.vertexArray,-1,-1,1),If(this.vertexArray,1,-1,1),If(this.vertexArray,-1,1,1),If(this.vertexArray,1,1,1),If(this.vertexArray,-1,-1,-1),If(this.vertexArray,1,-1,-1),If(this.vertexArray,-1,1,-1),If(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,yh),this.indexBuffer=m.createIndexBuffer(this.indices),this.segment=i.dy.simpleSegment(0,0,36,12)}}function Qh(M,m,v,A,D,z){const B=M.context.gl,W=m.paint.get("sky-atmosphere-color"),ee=m.paint.get("sky-atmosphere-halo-color"),ne=m.paint.get("sky-atmosphere-sun-intensity"),de=((be,ye,Ce,Be,Ie)=>({u_matrix_3f:be,u_sun_direction:ye,u_sun_intensity:Ce,u_color_tint_r:[Be.r,Be.g,Be.b,Be.a],u_color_tint_m:[Ie.r,Ie.g,Ie.b,Ie.a],u_luminance:5e-5}))(i.eg(i.dE(),A),D,ne,W.toPremultipliedRenderColor(null),ee.toPremultipliedRenderColor(null));B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+z,m.skyboxTexture,0),v.draw(M,B.TRIANGLES,Nr.disabled,nn.disabled,tn.unblended,Wr.frontCW,de,"skyboxCapture",m.skyboxGeometry.vertexBuffer,m.skyboxGeometry.indexBuffer,m.skyboxGeometry.segment)}const xF=i.e8([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class vP{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 A=new i.dC;A.emplaceBack(0,1,2),A.emplaceBack(2,3,0),this.vertexBuffer=m.createVertexBuffer(v,xF.members),this.indexBuffer=m.createIndexBuffer(A),this.segments=i.dy.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const _P=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 bP{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class gF{constructor(m){this.colorModeAlphaBlendedWriteRGB=new tn([1,Oo,1,Oo],i.aq.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new tn([1,0,1,0],i.aq.transparent,[!1,!1,!1,!0]),this.params=new bP,this.updateNeeded=!0}update(m){const v=m.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new vP(v);const A=this.params.sizeRange,D=this.params.intensityRange,z=function(de){const be=i.em(30),ye=[];for(let Ce=0;Ce{const pt=z.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];Dt&&pt.push("ALPHA_PASS");const yt=m.getOrCreateProgram("globeAtmosphere",{defines:pt}),Tt=((Bt,ns,Qt,ws,As,Zt,Ut,ts,as,cs,Qs,Hs)=>({u_frustum_tl:Bt,u_frustum_tr:ns,u_frustum_br:Qt,u_frustum_bl:ws,u_horizon:As,u_transition:Zt,u_fadeout_range:Ut,u_atmosphere_fog_color:ts.toArray01(),u_high_color:as.toArray01(),u_space_color:cs.toArray01(),u_temporal_offset:Qs,u_horizon_angle:Hs}))(z.frustumCorners.TL,z.frustumCorners.TR,z.frustumCorners.BR,z.frustumCorners.BL,z.frustumCorners.horizon,W,st,de,ye,Be,ct,Ft);m.uploadCommonUniforms(A,yt);const Wt=this.atmosphereBuffer;Wt&&yt.draw(m,D.TRIANGLES,B,nn.disabled,Dt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Wr.backCW,Tt,Dt?"atmosphere_glow_alpha":"atmosphere_glow",Wt.vertexBuffer,Wt.indexBuffer,Wt.segments)};wt(!1),wt(!0)}drawStars(m,v){const A=i.aC(v.properties.get("star-intensity"),0,1);if(A===0)return;const D=m.context,z=D.gl,B=m.transform,W=m.getOrCreateProgram("stars"),ee=i.bL([]);i.bN(ee,ee,-B._pitch),i.bM(ee,ee,-B.angle),i.bN(ee,ee,i.ap(B._center.lat)),i.ek(ee,ee,-i.ap(B._center.lng));const ne=i.bR(new Float32Array(16),ee),de=i.aD([],B.starsProjMatrix,ne),be=i.eg([],ne),ye=i.el([],be),Ce=[0,1,0];i.dG(Ce,Ce,ye),i.bJ(Ce,Ce,this.params.sizeMultiplier);const Be=[1,0,0];i.dG(Be,Be,ye),i.bJ(Be,Be,this.params.sizeMultiplier);const Ie=(st=Ce,tt=Be,ct=A,{u_matrix:Float32Array.from(de),u_up:st,u_right:tt,u_intensity_multiplier:ct});var st,tt,ct;m.uploadCommonUniforms(D,W),this.starsVx&&this.starsIdx&&W.draw(m,z.TRIANGLES,Nr.disabled,nn.disabled,this.colorModeAlphaBlendedWriteRGB,Wr.disabled,Ie,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class Wx{constructor(){this.visibleTiles=[]}updateBorders(m,v){const A=[],D=[],z=m._getRenderableCoordinates(!1,!0);for(const ee of z){const ne=m.getTile(ee);if(!ne.hasData())continue;const de=ne.getBucket(v);de&&(de.isEmpty()||(A.push(ee.key),D.push({bucket:de,tileID:ee.canonical})))}let B=A.length!==this.visibleTiles.length;if(!B){A.sort();for(let ee=0;eeee.tileID.z-ne.tileID.z||ee.tileID.x-ne.tileID.x||ee.tileID.y-ne.tileID.y);for(const ee of D){const ne=new Array,de=new Array,be=ee.bucket;for(const ye of be.featuresOnBorder)W.has(ye.featureId)?de.push(ye.footprintIndex):(W.add(ye.featureId),ne.push(ye.footprintIndex));be.updateFootprintHiddenFlags(ne,i.en,!1),be.updateFootprintHiddenFlags(de,i.en,!0)}}}function yF(M,m){const v=[...M],A=m.cameraWorldSizeForFog/m.worldSize,D=i.b9([]);return i.cC(D,D,[A,A,1]),i.aD(v,D,v),i.aD(v,m.worldToFogMatrix,v),v}function Ga(M,m,v,A,D){const z=v.material,B=A.context,{baseColorTexture:W,metallicRoughnessTexture:ee}=z.pbrMetallicRoughness,{normalTexture:ne,occlusionTexture:de,emissionTexture:be}=z;function ye(Be,Ie,st){if(Be&&(M.push(Ie),B.activeTexture.set(B.gl.TEXTURE0+st),Be.gfxTexture)){const{minFilter:tt,magFilter:ct,wrapS:mt,wrapT:nt}=Be.sampler;Be.gfxTexture.bindExtraParam(tt,ct,mt,nt)}}ye(W,"HAS_TEXTURE_u_baseColorTexture",5),ye(ee,"HAS_TEXTURE_u_metallicRoughnessTexture",6),ye(ne,"HAS_TEXTURE_u_normalTexture",7),ye(de,"HAS_TEXTURE_u_occlusionTexture",8),ye(be,"HAS_TEXTURE_u_emissionTexture",9),D&&(D.texture||(D.texture=new i.dR(A.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 Ce=A.shadowRenderer;Ce&&(M.push("RENDER_SHADOWS"),Ce.useNormalOffset&&M.push("NORMAL_OFFSET"))}function K1(M,m,v,A,D,z){const B=M.modelOpacity,W=m.context,ee=new Nr(m.context.gl.LEQUAL,M.isLightMesh?Nr.ReadOnly:Nr.ReadWrite,m.depthRangeFor3D),ne=m.transform,de=M.mesh,be=de.material,ye=be.pbrMetallicRoughness,Ce=m.style.fog;let Be;Be=m.transform.projection.zAxisUnit==="pixels"?[...M.nodeModelMatrix]:i.aD([],A.zScaleMatrix,M.nodeModelMatrix),i.aD(Be,A.negCameraPosMatrix,Be);const Ie=i.b7([],Be);i.e6(Ie,Ie);const st=v.paint.get("model-color-use-theme").constantOr("default")==="none",tt=v.paint.get("model-emissive-strength").constantOr(0),ct=H0(new Float32Array(M.worldViewProjection),new Float32Array(Be),new Float32Array(Ie),null,m,B,ye.baseColorFactor,be.emissiveFactor,ye.metallicFactor,ye.roughnessFactor,be,tt,v,void 0,void 0,M.materialOverride,M.modelColor),mt={defines:[]},nt=[],Ft=m.shadowRenderer;Ft&&(Ft.useNormalOffset=!1),Ga(mt.defines,nt,de,m,st?null:v.lut);let wt=null;if(Ce){const yt=yF(M.nodeModelMatrix,m.transform);if(wt=new Float32Array(yt),ne.projection.name!=="globe"){const Tt=de.aabb.min,Wt=de.aabb.max,[Bt,ns]=Ce.getOpacityForBounds(yt,Tt[0],Tt[1],Wt[0],Wt[1]);mt.overrideFog=Bt>=ta||ns>=ta}}const Dt=nc(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,wt,Dt),m.renderPass!=="shadow"&&Ft&&Ft.setupShadowsFromMatrix(M.nodeModelMatrix,pt),pt.draw(m,W.gl.TRIANGLES,ee,D,z,de.material.doubleSided?Wr.disabled:Wr.backCCW,ct,v.id,de.vertexBuffer,de.indexBuffer,de.segments,v.paint,m.transform.zoom,void 0,nt)}function p3(M,m){return M.style._importedAsBasemap?"basemap":m.scope}function f3(M,m,v,A,D,z,B,W,ee,ne){const de=M.transform,be=!!m.isGeometryBloom&&m.isGeometryBloom;if(be&&M.renderPass==="shadow")return;const ye=de.projection.name==="globe"?i.ev(v,de):[...v];i.aD(ye,ye,m.globalMatrix);const Ce=i.aD([],A,ye);if(m.meshes)for(const Be of m.meshes){const Ie=W.get(Be.material.name);if(Ie&&Ie.opacity<=0)continue;if(Be.material.alphaMode!=="BLEND"){B.push({mesh:Be,depth:0,modelIndex:D,worldViewProjection:Ce,nodeModelMatrix:ye,isLightMesh:be,materialOverride:Ie,modelOpacity:ee,modelColor:ne,node:m,modelMatrix:v});continue}const st=i.ah([],Be.centroid,Ce);!de.isOrthographic&&st[2]<=0||z.push({mesh:Be,depth:st[2],modelIndex:D,worldViewProjection:Ce,nodeModelMatrix:ye,isLightMesh:be,materialOverride:Ie,modelOpacity:ee,modelColor:ne,node:m,modelMatrix:v})}if(m.children)for(const Be of m.children)f3(M,Be,v,A,D,z,B,W,ee,ne)}function Z1(M,m,v,A){const D=v.shadowRenderer;if(!D)return;const z=D.getShadowPassDepthMode(),B=D.calculateShadowPassMatrixFromMatrix(m),W=aP(B);v.getOrCreateProgram("modelDepth").draw(v,v.context.gl.TRIANGLES,z,nn.disabled,tn.disabled,Wr.disabled,W,A.id,M.vertexBuffer,M.indexBuffer,M.segments,A.paint,v.transform.zoom,void 0,void 0)}function wP(M,m,v,A){const D=function(de,be){if(be.footprintDebugMesh)return be.footprintDebugMesh;if(!be.footprint)return null;const ye=de.context,Ce=be.footprint.vertices,Be=be.footprint.indices,Ie=new i.dB;Ie.reserve(Ce.length);for(const Tt of Ce)Ie.emplaceBack(Tt.x,Tt.y);const st=new i.dC;st.reserve(Be.length);for(let Tt=0;Tt0){const ye=z.terrain,Ce=ye.findDEMTileFor(W);Ce&&Ce.dem?ee=i.ex.create(ye,W,Ce):be=0}if(be===0&&(B.terrainElevationMin=0,B.terrainElevationMax=0),be===B.validForExaggeration&&(be===0||ee&&ee._demTile&&ee._demTile.tileID===B.validForDEMTile.id&&ee._dem._timestamp===B.validForDEMTile.timestamp))return!1;for(const ye in B.instancesPerModel){const Ce=B.instancesPerModel[ye];for(let Be=0;Bene&&(ne=Ce.max)}const de=i.aC(A.x,z,B)-A.x,be=i.aC(A.y,W,ee)-A.y,ye=i.bU(ne,m.center.lat)-A.z;return m._zoomFromMercatorZ(Math.sqrt(de*de+be*be+ye*ye))}function Xi(M,m,v,A,D,z,B){const W=M.context,ee=M.renderPass==="shadow",ne=M.shadowRenderer,de=ee&&ne?ne.getShadowPassDepthMode():new Nr(W.gl.LEQUAL,Nr.ReadWrite,M.depthRangeFor3D),be=M.isTileAffectedByFog(z),ye=M.transform.projection.name==="globe";if(v.meshes)for(const Ce of v.meshes){const Be=ye?[]:["MODEL_POSITION_ON_GPU"],Ie=[];let st,tt,ct;const mt=!ye&&A.instancedDataArray.length>20;mt&&Be.push("INSTANCED_ARRAYS");const nt=nc(M,m.paint.get("model-cutoff-fade-range"));if(nt.shouldRenderCutoff&&Be.push("RENDER_CUTOFF"),ee&&ne)st=M.getOrCreateProgram("modelDepth",{defines:Be}),tt=aP(B.shadowTileMatrix,B.shadowTileMatrix,Float32Array.from(v.globalMatrix)),ct=tn.disabled;else{Ga(Be,Ie,Ce,M,m.paint.get("model-color-use-theme").constantOr("default")==="none"?null:m.lut),st=M.getOrCreateProgram("model",{defines:Be,overrideFog:be});const wt=Ce.material,Dt=wt.pbrMetallicRoughness,pt=m.paint.get("model-opacity").constantOr(1),yt=m.paint.get("model-emissive-strength").constantOr(0);tt=H0(z.expandedProjMatrix,Float32Array.from(v.globalMatrix),new Float32Array(16),null,M,pt,Dt.baseColorFactor,wt.emissiveFactor,Dt.metallicFactor,Dt.roughnessFactor,wt,yt,m,D),ne&&(B.shadowUniformsInitialized?st.setShadowUniformValues(W,ne.getShadowUniformValues()):(ne.setupShadows(z.toUnwrapped(),st,"model-tile"),B.shadowUniformsInitialized=!0)),ct=nt.shouldRenderCutoff||pt<1||wt.alphaMode!=="OPAQUE"?tn.alphaBlended:tn.unblended}M.uploadCommonUniforms(W,st,z.toUnwrapped(),null,nt);const Ft=Ce.material.doubleSided?Wr.disabled:Wr.backCCW;if(mt)Ie.push(A.instancedDataBuffer),st.draw(M,W.gl.TRIANGLES,de,nn.disabled,ct,Ft,tt,m.id,Ce.vertexBuffer,Ce.indexBuffer,Ce.segments,m.paint,M.transform.zoom,void 0,Ie,A.instancedDataArray.length);else{const wt=ee?"u_instance":"u_normal_matrix";for(let Dt=0;Dtee[1]?B:ee,z[0]=v.max[0],B=i.aE(i.bE(),z,D),W=B[1]ee[1]?B:ee,z[1]=v.min[1],B=i.aE(i.bE(),z,D),W=B[1]ee[1]?B:ee;const ne=i.aC(A[0],0,1),de=100*m.pixelsPerMeter*i.aC(A[1],0,1),be=i.aC(A[2],0,1),ye=i.ey(i.bE(),W,ee,ne),Ce=Math.tan(.5*m.fovX),Be=-ye[2]*Ce;if(de===0)return ye[1]<-Math.abs(Be)?be:1;const Ie=(-Math.abs(Be)-ye[1])/de,st=(ct,mt,nt)=>(1-nt)*ct+nt*mt,tt=i.aC(st(1,be,Ie),be,1);return st(1,tt,i.aC((m.pitch-20)/20,0,1))}class g3{}class _F{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(m,v,A){{const be=this._storage.get(v.id);if(be)return be.lastUsedFrameIdx=m,be.buf}const D=A.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 ee=new i.eA;for(let be=0;be30&&(A.buf.destroy(),this._storage.delete(v))}destroy(){for(const[m,v]of this._storage)v.buf.destroy(),this._storage.delete(m)}}class bF{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const X1=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 wF{constructor(m){this.revealStart=11,this.revealRange=2}}const Spe=i.e8([{type:"Float32",name:"a_pos_2f",components:2}]);class jF{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(m,v){const A=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,Spe.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,A);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};A.draw(m,m.context.gl.TRIANGLES,Nr.disabled,nn.disabled,tn.alphaBlended,Wr.disabled,B,"vignette",this.vignetteVx,this.vignetteIdx,D)}var z}}class y3{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(m,v){const A=m.getFreeCameraOptions().position,D=A.toAltitude(),z=A.toLngLat(),B=i.ap(z.lng),W=i.ap(z.lat),ee=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 be=-this._offsetYPrev+de,ye=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+ne)*ee,this._accumulatedOffsetY+=be*ee,this._accumulatedElevation+=ye*ee,this._offsetXPrev=ne,this._offsetYPrev=de,this._elevationPrev=D}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function v3(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 kP(M){const m=i.em(1323123451230),v=[];for(let A=0;A Rain"),this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3}update(m){const v=m.context;if(!this.particlesVx){const A=kP(this.particlesCount),D=new i.eE,z=new i.dC;let B=0;const W=i.em(1323123451230);for(let ee=0;eeA)return;const D=Zx(0,1,v.revealStart,v.revealStart+v.revealRange,A);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 ee=this.updateOnRender(m,z.timeFactor),ne=m.context,de=ne.gl,be=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 ye=m.getOrCreateProgram("rainParticle");m.uploadCommonUniforms(ne,ye),ne.activeTexture.set(de.TEXTURE0),this.screenTexture.bind(de.LINEAR,de.CLAMP_TO_EDGE);const Ce=[z.color.r,z.color.g,z.color.b,z.color.a],Be=(Ie,st)=>{const tt=v3(this._movement.getPosition(),Ie),ct=z.dropletSizeX,mt=z.dropletSizeX*z.dropletSizeYScale,nt=m.width/2,Ft=m.height/2,wt=Zx(0,z.screenThinning.start,0,1,z.screenThinning.intensity),Dt=Zx(.001,z.screenThinning.range,0,1,z.screenThinning.intensity),pt=Zx(0,z.screenThinning.particleOffset,0,1,z.screenThinning.intensity),yt=(Tt={modelview:ee.modelviewMatrix,projection:ee.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:tt,velocityConeAperture:z.velocityConeAperture,velocity:z.velocity,boxSize:Ie,rainDropletSize:[ct,mt],distortionStrength:z.distortionStrength,rainDirection:B,color:Ce,screenSize:[be.width,be.height],thinningCenterPos:[nt,Ft],thinningShape:[wt,Dt,Math.pow(10,z.screenThinning.fadePower)],thinningAffectedRatio:z.screenThinning.affectedRatio,thinningParticleOffset:pt,shapeDirectionalPower:z.shapeDirPower,shapeNormalPower:z.shapeNormalPower,mode:st?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 Wt=Math.round(z.intensity*this.particlesCount),Bt=i.dy.simpleSegment(0,0,4*Wt,2*Wt);ye.draw(m,de.TRIANGLES,Nr.disabled,nn.disabled,tn.alphaBlended,Wr.disabled,yt,"rain_particles",this.particlesVx,this.particlesIdx,Bt)};z.distortionStrength>0&&Be(z.boxSize,!0),Be(z.boxSize,!1),this._vignette.draw(m,W)}}const Y0=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 NF extends o2{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 wF("Precipitation > Snow"),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3}update(m){const v=m.context;if(!this.particlesVx){const A=kP(this.particlesCount),D=new i.eF,z=new i.dC;let B=0;const W=i.em(1323123451230);for(let ee=0;eeB)return;const W=Zx(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),A=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 ee=this.updateOnRender(m,v.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const ne=m.context,de=ne.gl,be=m.transform,ye=m.getOrCreateProgram("snowParticle");m.uploadCommonUniforms(ne,ye),((Ce,Be,Ie)=>{const st=v3(this._movement.getPosition(),Ce),tt=be.width/2,ct=be.height/2,mt=Zx(0,Ie.screenThinning.start,0,1,Ie.screenThinning.intensity),nt=Zx(.001,Ie.screenThinning.range,0,1,Ie.screenThinning.intensity),Ft=Zx(0,Ie.screenThinning.particleOffset,0,1,Ie.screenThinning.intensity),wt=(Dt={modelview:ee.modelviewMatrix,projection:ee.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:st,velocityConeAperture:Ie.velocityConeAperture,velocity:Ie.velocity,horizontalOscillationRadius:Ie.horizontalOscillationRadius,horizontalOscillationRate:Ie.horizontalOscillationRate,boxSize:Ce,billboardSize:1*Ie.billboardSize,simpleShapeParameters:[Ie.shapeFadeStart,Ie.shapeFadePower],screenSize:[be.width,be.height],thinningCenterPos:[tt,ct],thinningShape:[mt,nt,Math.pow(10,Ie.screenThinning.fadePower)],thinningAffectedRatio:Ie.screenThinning.affectedRatio,thinningParticleOffset:Ft,color:[Ie.color.r,Ie.color.g,Ie.color.b,Ie.color.a],direction:A},{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(Ie.intensity*this.particlesCount),yt=i.dy.simpleSegment(0,0,4*pt,2*pt);this.particlesVx&&this.particlesIdx&&ye.draw(m,de.TRIANGLES,Nr.disabled,nn.disabled,tn.alphaBlended,Wr.disabled,wt,"snow_particles",this.particlesVx,this.particlesIdx,yt)})(v.boxSize,0,v),this._vignette.draw(m,D)}}const kF={symbol:function(M,m,v,A,D){if(M.renderPass!=="translucent")return;const z=nn.disabled,B=M.colorModeForRenderPass(),W=v.layout.get("text-variable-anchor"),ee=v.layout.get("text-size-scale-range"),ne=i.aC(M.scaleFactor,ee[0],ee[1]);W&&function(ye,Ce,Be,Ie,st,tt,ct,mt){const nt=Ce.transform,Ft=st==="map",wt=tt==="map";for(const Dt of ye){const pt=Ie.getTile(Dt),yt=pt.getBucket(Be);if(!yt||!yt.text||!yt.text.segments.get().length)continue;const Tt=i.bj(yt.textSizeData,nt.zoom,mt),Wt=Tf(Dt,yt.getProjection(),nt),Bt=nt.calculatePixelsToTileUnitsMatrix(pt),ns=nr(Wt,pt.tileID.canonical,wt,Ft,nt,yt.getProjection(),Bt),Qt=yt.hasIconTextFit()&&yt.hasIconData();Tt&&lF(yt,Ft,wt,ct,nt,ns,Dt,Math.pow(2,nt.zoom-pt.tileID.overscaledZ),Tt,Qt)}}(A,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,be=v.paint.get("text-opacity").constantOr(1)!==0;v.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(de||be)?o3(M,m,v,A,z,B):(de&&o3(M,m,v,A,z,B,{onlyIcons:!0}),be&&o3(M,m,v,A,z,B,{onlyText:!0})),m.map.showCollisionBoxes&&(xr(M,m,v,A,v.paint.get("text-translate"),v.paint.get("text-translate-anchor"),!0),xr(M,m,v,A,v.paint.get("icon-translate"),v.paint.get("icon-translate-anchor"),!1))},circle:function(M,m,v,A){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,ee=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,be=M.transform,ye=!(!M.terrain||!M.terrain.enabled),Ce=v.layout.get("circle-elevation-reference"),Be=M.depthModeForSublayer(0,Nr.ReadOnly),Ie=new Nr(M.context.gl.LEQUAL,Nr.ReadOnly,M.depthRangeFor3D),st=Ce==="none"||ye?Be:Ie,tt=nn.disabled,ct=M.colorModeForDrapableLayerRenderPass(ee),mt=be.projection.name==="globe",nt=[i.aH(be.center.lng),i.aL(be.center.lat)],Ft=[];for(let Dt=0;DtDt.sortKey-pt.sortKey);const wt={useDepthForOcclusion:be.depthOcclusionForSymbolsAndCircles};for(const Dt of Ft){const{programConfiguration:pt,program:yt,layoutVertexBuffer:Tt,dynamicBuffers:Wt,indexBuffer:Bt,uniformValues:ns,tile:Qt}=Dt.state,ws=Dt.segments;M.terrain&&M.terrain.setupElevationDraw(Qt,yt,wt),M.uploadCommonUniforms(ne,yt,Qt.tileID.toUnwrapped()),yt.draw(M,de.TRIANGLES,st,tt,ct,Wr.disabled,ns,v.id,Tt,Bt,ws,v.paint,be.zoom,pt,Wt)}},heatmap:function(M,m,v,A){if(v.paint.get("heatmap-opacity")!==0)if(M.renderPass==="offscreen"){const D=M.context,z=D.gl,B=nn.disabled,W=new tn([z.ONE,z.ONE,z.ONE,z.ONE],i.aq.transparent,[!0,!0,!0,!0]),ee=M.transform.projection.name==="globe"?.5:.25;v.heatmapFbo=s2.createWithTexture(D,v.heatmapFbo,M.width*ee,M.height*ee),D.clear({color:i.aq.transparent});const ne=M.transform,de=ne.projection.name==="globe",be=de?["PROJECTION_GLOBE_VIEW"]:[],ye=de?Wr.frontCCW:Wr.disabled,Ce=[i.aH(ne.center.lng),i.aL(ne.center.lat)];for(let Be=0;Be({u_image:0,u_color_ramp:1,u_opacity:be.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,A){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,ee,ne,de,be){if(W.renderPass!=="translucent")return;const ye=W.context,Ce=ye.gl,Be=W.terrain;if(!Be)return;const Ie=ye.bindFramebuffer.current,st=W.emissiveMode==="mrt-fallback";ne.lineBlendDrapeFbo=s2.createWithTexture(ye,ne.lineBlendDrapeFbo,Be.drapeBufferSize[0],Be.drapeBufferSize[1],!0),ne.lineBlendDrapeStencil=ne.lineBlendDrapeFbo._stencilRbo,st&&Ce.drawBuffers([Ce.COLOR_ATTACHMENT0]),ye.clear({color:Gx[be].clearColor,depth:1,stencil:0});const tt=W.currentStencilSource,ct=W._tileClippingMaskIDs,mt=W.nextStencilID;W.currentStencilSource=void 0,W._tileClippingMaskIDs={},W.nextStencilID=1;const nt=W._terrain;W._terrain=null,W._renderTileClippingMasks(ne,ee,de),c3(W,ee,ne,de,Gx[be].colorMode,!0),W._terrain=nt,W.currentStencilSource=tt,W._tileClippingMaskIDs=ct,W.nextStencilID=mt,ye.bindFramebuffer.set(Ie),st&&Ce.drawBuffers([Ce.COLOR_ATTACHMENT0,Ce.COLOR_ATTACHMENT1]);const Ft=Be.drapeBufferSize;ye.viewport.set([0,0,Ft[0],Ft[1]]);const wt=ne.lineBlendDrapeFbo;if(!wt)return;ye.activeTexture.set(Ce.TEXTURE0),Ce.bindTexture(Ce.TEXTURE_2D,wt.colorAttachment0.get());const Dt=be==="additive"?1:ne.paint.get("line-opacity").constantOr(1),pt=ne.paint.get("line-emissive-strength").constantOr(0),yt=be==="additive"?W.colorModeForDrapableLayerRenderPass(pt):Gx[be].colorMode;W.getOrCreateProgram("lineBlendComposite").draw(W,Ce.TRIANGLES,Nr.disabled,nn.disabled,yt,Wr.disabled,e3(0,Dt,Gx[be].compositeUniformValue),ne.id,W.viewportBuffer,W.quadTriangleIndexBuffer,W.viewportSegments,ne.paint,W.transform.zoom)}(M,m,v,A,B):M.renderPass==="offscreen"?void function(W,ee,ne,de,be){const ye=W.context,Ce=Math.ceil(W.width),Be=Math.ceil(W.height);ne.lineBlendFbo=s2.createWithTexture(ye,ne.lineBlendFbo,Ce,Be,!0),ne.lineBlendStencil=ne.lineBlendFbo._stencilRbo,ye.clear({color:Gx[be].clearColor,depth:1,stencil:0});const Ie=W.currentStencilSource,st=W._tileClippingMaskIDs,tt=W.nextStencilID;W.currentStencilSource=void 0,W._tileClippingMaskIDs={},W.nextStencilID=1,W._renderTileClippingMasks(ne,ee,de);const ct=W.renderPass;W.renderPass="translucent",c3(W,ee,ne,de,Gx[be].colorMode),W.renderPass=ct,W.currentStencilSource=Ie,W._tileClippingMaskIDs=st,W.nextStencilID=tt,ye.viewport.set([0,0,W.width,W.height])}(M,m,v,A,B):M.renderPass==="translucent"?void function(W,ee,ne){const de=W.context,be=de.gl,ye=ee.lineBlendFbo;if(!ye)return;de.activeTexture.set(be.TEXTURE0),be.bindTexture(be.TEXTURE_2D,ye.colorAttachment0.get());const Ce=ne==="additive"?1:ee.paint.get("line-opacity").constantOr(1),Be=ne==="additive"?W.colorModeForDrapableLayerRenderPass(ee.paint.get("line-emissive-strength").constantOr(0)):Gx[ne].colorMode;W.getOrCreateProgram("lineBlendComposite").draw(W,be.TRIANGLES,Nr.disabled,nn.disabled,Be,Wr.disabled,e3(0,Ce,Gx[ne].compositeUniformValue),ee.id,W.viewportBuffer,W.quadTriangleIndexBuffer,W.viewportSegments,ee.paint,W.transform.zoom)}(M,v,B):void 0;M.renderPass==="translucent"&&c3(M,m,v,A)},fill:function(M,m,v,A){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),ee=v.paint.get("fill-pattern"),ne=M.opaquePassEnabledForLayer()&&!ee.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 be=!(!M.terrain||!M.terrain.enabled),ye={painter:M,sourceCache:m,layer:v,coords:A,colorMode:W,elevationType:de,terrainEnabled:be,pass:ne};if(M.renderPass==="shadow")return void(M.shadowRenderer&&de==="road"&&!be&&function(Be){const{painter:Ie,sourceCache:st,layer:tt,coords:ct}=Be,mt=Ie.context.gl,nt=Be.painter.shadowRenderer;for(const Ft of ct){const wt=st.getTile(Ft),Dt=wt.getBucket(tt);if(!Dt)continue;const pt=Dt.elevatedStructures;if(!pt||!pt.shadowCasterSegments||pt.shadowCasterSegments.segments[0].primitiveLength===0)continue;Ie.prepareDrawTile();const yt=Dt.bufferData.programConfigurations.get(tt.id),Tt=Ie.isTileAffectedByFog(Ft),Wt=Ie.getOrCreateProgram("elevatedStructuresDepth",{config:yt,overrideFog:Tt}),Bt=nt.calculateShadowPassMatrixFromTile(wt.tileID.toUnwrapped());Ie.uploadCommonUniforms(Ie.context,Wt,Ft.toUnwrapped());const ns=JO(Bt,0);Wt.draw(Ie,mt.TRIANGLES,nt.getShadowPassDepthMode(),nn.disabled,tn.disabled,Wr.disabled,ns,tt.id,pt.vertexBuffer,pt.indexBuffer,pt.shadowCasterSegments,tt.paint,Ie.transform.zoom,yt)}}(ye));const Ce=M.emissiveMode==="mrt-fallback";if(de!=="offset"){if(a2(ye,!1,Ce),de==="road"){const Be=!be&&M.renderPass==="translucent";Be&&n2(M,m,v,A,"geometry"),a2(ye,!0,Ce,nn.disabled),Be&&function(Ie){const{painter:st,sourceCache:tt,layer:ct,coords:mt,colorMode:nt}=Ie,Ft=st.context.gl,wt=Ie.painter.shadowRenderer,Dt=!!wt&&wt.enabled,pt=new Nr(st.context.gl.LEQUAL,Nr.ReadOnly,st.depthRangeFor3D);let yt=[0,0,0];if(Dt){const Wt=st.style.directionalLight,Bt=st.style.ambientLight;Wt&&Bt&&(yt=Ap(st.style,Wt,Bt))}const Tt=Wt=>{for(const Bt of mt){const ns=tt.getTile(Bt),Qt=ns.getBucket(ct);if(!Qt)continue;const ws=Qt.elevatedStructures;if(!ws)continue;let As,Zt;if(Wt?(As=ws.renderableBridgeSegments,Zt=ws.bridgeProgramConfigurations.get(ct.id)):(As=ws.renderableTunnelSegments,Zt=ws.tunnelProgramConfigurations.get(ct.id)),!As||As.segments[0].primitiveLength===0)continue;Zt.updatePaintBuffers(),st.prepareDrawTile();const Ut=st.isTileAffectedByFog(Bt),ts=[];Dt&&ts.push("RENDER_SHADOWS","NORMAL_OFFSET");const as=st.getOrCreateProgram("elevatedStructures",{config:Zt,overrideFog:Ut,defines:ts}),cs=st.translatePosMatrix(Bt.projMatrix,ns,ct.paint.get("fill-translate"),ct.paint.get("fill-translate-anchor"));Dt&&wt.setupShadows(ns.tileID.toUnwrapped(),as,"vector-tile");const Qs=eF(cs,yt);st.uploadCommonUniforms(st.context,as,Bt.toUnwrapped()),as.draw(st,Ft.TRIANGLES,pt,nn.disabled,nt,Wr.backCCW,Qs,ct.id,ws.vertexBuffer,ws.indexBuffer,As,ct.paint,st.transform.zoom,Zt,[ws.vertexBufferNormal])}};Tt(!0),Tt(!1)}(ye)}}else a2(ye,!1,Ce,M.stencilModeFor3D())},"fill-extrusion":function(M,m,v,A){const D=v.paint.get("fill-extrusion-opacity"),z=M.context,B=z.gl,W=M.terrain,ee=W&&W.renderingToTexture;if(D===0)return;const ne=M.emissiveMode==="mrt-fallback",de=M.conflationActive&&M.style.isLayerClipped(v,m.getSource()),be=M.style.order.indexOf(v.fqid);if(de&&function(ye,Ce,Be,Ie,st){for(const tt of Ie){const ct=Ce.getTile(tt).getBucket(Be);ct&&(ct.updateReplacement(tt,ye.replacementSource,st),ct.uploadCentroid(ye.context))}}(M,m,v,A,be),W||de)for(const ye of A){const Ce=m.getTile(ye).getBucket(v);Ce&&cF(M.context,m,ye,Ce,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 ye=M.shadowRenderer.getShadowPassDepthMode();W0(M,m,v,A,ye,nn.disabled,tn.disabled,de)}else if(M.renderPass==="translucent"){const ye=!v.paint.get("fill-extrusion-pattern").constantOr(1),Ce=v.paint.get("fill-extrusion-color").constantOr(i.aq.white);if(!ee&&Ce.a!==0){const Be=new Nr(M.context.gl.LEQUAL,Nr.ReadWrite,M.depthRangeFor3D);D===1&&ye?W0(M,m,v,A,Be,nn.disabled,tn.unblended,de):(W0(M,m,v,A,Be,nn.disabled,tn.disabled,de),W0(M,m,v,A,Be,M.stencilModeFor3D(),M.colorModeForRenderPass(),de),M.resetStencilClippingMasks())}if(M.style.enable3dLights()&&ye&&(!W&&M.transform.projection.name!=="globe"||ee)){const Be=v.paint.get("fill-extrusion-opacity"),Ie=v.paint.get("fill-extrusion-ambient-occlusion-intensity"),st=v.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),tt=v.paint.get("fill-extrusion-flood-light-intensity"),ct=v.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",mt=v.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(ct?null:v.lut).toArray01().slice(0,3),nt=Ie>0&&st>0,Ft=tt>0,wt=(yt,Tt,Wt)=>(1-Wt)*yt+Wt*Tt,Dt=new lP;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=yt=>{const Tt=M.depthModeForSublayer(1,Nr.ReadOnly,B.LEQUAL,!0),Wt=v.paint.get(yt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Bt=wt(.1,3,Wt),ns=M._showOverdrawInspector;if(!ns){const Qt=new nn({func:B.ALWAYS,mask:255},255,255,B.KEEP,B.KEEP,B.REPLACE),ws=new tn([B.ONE,B.ONE,B.ONE,B.ONE],i.aq.transparent,[!1,!1,!1,!0],B.MIN);Pf(Dt,M,m,v,A,Tt,Qt,ws,Wr.disabled,yt,"sdf",Be,Ie,st,tt,mt,Bt,de,!1)}{const Qt=ns?nn.disabled:new nn({func:B.EQUAL,mask:255},255,255,B.KEEP,B.DECR,B.DECR),ws=ns?M.colorModeForRenderPass():new tn([B.ONE_MINUS_DST_ALPHA,B.DST_ALPHA,B.ONE,B.ONE],i.aq.transparent,[!0,!0,!0,!0]);Pf(Dt,M,m,v,A,Tt,Qt,ws,Wr.disabled,yt,"color",Be,Ie,st,tt,mt,Bt,de,!1)}};if(ee){const yt=()=>{const Wt=W.drapeBufferSize[0],Bt=W.drapeBufferSize[1];let ns=W.framebufferCopyTexture;return ns&&(!ns||ns.size[0]===Wt&&ns.size[1]===Bt)||(ns&&ns.destroy(),ns=W.framebufferCopyTexture=new i.T(z,new i.q({width:Wt,height:Bt}),B.RGBA8)),ns.bind(B.LINEAR,B.CLAMP_TO_EDGE),B.copyTexSubImage2D(B.TEXTURE_2D,0,0,0,0,0,Wt,Bt),ns},Tt=(Wt,Bt,ns)=>{const Qt=M.depthModeForSublayer(1,Nr.ReadOnly,B.LEQUAL,!1),ws=v.paint.get(Wt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),As=wt(.1,3,ws);{const Zt=new tn([B.ONE,B.ONE,B.ONE,B.ONE],i.aq.transparent,[!1,!1,!1,!0]);Pf(Dt,M,m,v,A,Qt,nn.disabled,Zt,Wr.disabled,Wt,"clear",Be,Ie,st,tt,mt,As,de,Bt)}{const Zt=new nn({func:B.ALWAYS,mask:255},255,255,B.KEEP,B.KEEP,B.REPLACE),Ut=new tn([B.ONE,B.ONE,B.ONE,B.ONE],i.aq.transparent,[!1,!1,!1,!0],B.MIN);Pf(Dt,M,m,v,A,Qt,Zt,Ut,Wr.disabled,Wt,"sdf",Be,Ie,st,tt,mt,As,de,Bt)}ne&&!Wt&&(ns=yt());{const Zt=Wt?B.ZERO:B.ONE_MINUS_DST_ALPHA,Ut=new nn({func:B.EQUAL,mask:255},255,255,B.KEEP,B.DECR,B.DECR),ts=new tn([Zt,B.DST_ALPHA,B.ONE_MINUS_DST_ALPHA,B.ZERO],i.aq.transparent,[!0,!0,!0,!0]);Pf(Dt,M,m,v,A,Qt,Ut,ts,Wr.disabled,Wt,"color",Be,Ie,st,tt,mt,As,de,Bt)}if(!ne||Wt){const Zt=new tn([B.ONE,B.ONE,B.ONE,Wt?B.ZERO:B.ONE],i.aq.transparent,[!1,!1,!1,!0],Wt?B.FUNC_ADD:B.MAX);Pf(Dt,M,m,v,A,Qt,nn.disabled,Zt,Wr.disabled,Wt,"clear",Be,Ie,st,tt,mt,As,de,Bt,ns)}else{B.drawBuffers([B.NONE,B.COLOR_ATTACHMENT1]);const Zt=new nn({func:B.EQUAL,mask:255},254,255,B.KEEP,B.DECR,B.DECR),Ut=new tn([B.ONE,B.ONE,B.ONE,B.ONE],i.aq.transparent,[!0,!1,!1,!1],B.MAX);Pf(Dt,M,m,v,A,Qt,Zt,Ut,Wr.disabled,Wt,"emissive",Be,Ie,st,tt,mt,As,de,Bt,ns),B.drawBuffers([B.COLOR_ATTACHMENT0])}};if(nt||Ft){let Wt;M.prepareDrawTile(),ne&&!nt||(Wt=yt()),nt&&Tt(!0,!1,Wt),Ft&&Tt(!1,!0,Wt)}}else nt&&pt(!0),Ft&&pt(!1),(nt||Ft)&&M.resetStencilClippingMasks()}}},building:function(M,m,v,A){M.currentLayer0&&z>0,ne=!0;const de=v.paint.get("building-vertical-scale");if(de<=0)return;M.shadowRenderer||(ne=!1);const be=M.conflationActive&&M.style.isLayerClipped(v,m.getSource()),ye=M.style.order.indexOf(v.fqid);if(function(Ce,Be,Ie,st,tt,ct){for(const mt of ct){const nt=Be.getTile(mt).getBucket(Ie);nt&&(tt&&nt.updateReplacement(mt,Ce.replacementSource,st),nt.uploadUpdatedIndexBuffer(Ce.context))}}(M,m,v,ye,be,A),function(Ce,Be,Ie,st){for(const tt of st){const ct=Be.getTile(tt).getBucket(Ie);ct&&ct.needsEvaluation()&&ct.uploadUpdatedColorBuffer(Ce.context)}}(M,m,v,A),v.resetLayerRenderingStats(M),M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0),M.renderPass==="shadow"&&M.shadowRenderer){const Ce=[],Be=M.shadowRenderer.getShadowPassDepthMode();i2({painter:M,source:m,layer:v,coords:A,defines:Ce,blendMode:tn.disabled,depthMode:Be,opacity:W,verticalScale:de,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(M.renderPass==="translucent"){let Ce=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];ne&&(Ce=Ce.concat("RENDER_SHADOWS")),M.shadowRenderer&&M.shadowRenderer.useNormalOffset&&(Ce=Ce.concat("NORMAL_OFFSET"));const Be=v.paint.get("building-facade-emissive-chance"),Ie=v.paint.get("building-ambient-occlusion-intensity"),st=v.paint.get("building-flood-light-intensity"),tt=v.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",ct=v.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(tt?null:v.lut).toArray01().slice(0,3),mt=v.paint.get("building-flood-light-ground-attenuation"),nt=st>0,Ft=new Nr(M.context.gl.LEQUAL,Nr.ReadWrite,M.depthRangeFor3D);W<1&&i2({painter:M,source:m,layer:v,coords:A,defines:Ce,blendMode:tn.disabled,depthMode:Ft,opacity:W,verticalScale:de,facadeEmissiveChance:Be,facadeAOIntensity:Ie,floodLightIntensity:st,floodLightColor:ct,depthOnly:!0});const wt=M.colorModeForRenderPass();i2({painter:M,source:m,layer:v,coords:A,defines:Ce,blendMode:wt,depthMode:Ft,opacity:W,verticalScale:de,facadeEmissiveChance:Be,facadeAOIntensity:Ie,floodLightIntensity:st,floodLightColor:ct});const Dt=v.paint.get("building-front-cutoff");d3(M.transform.pitch,Dt,!!M.terrain),ee&&dP(M,m,v,A,!0,W,D,z,st,ct,B,be),nt&&dP(M,m,v,A,!1,W,D,z,st,ct,mt,be)}else if(M.renderPass==="light-beam"){const Ce=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],Be=new Nr(M.context.gl.LEQUAL,Nr.ReadOnly,M.depthRangeFor3D);i2({painter:M,source:m,layer:v,coords:A,defines:Ce,blendMode:tn.alphaBlended,depthMode:Be,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,A){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?[{},A]:M.stencilConfigForOverlap(A);for(const ee of W){const ne=m.getTile(ee);if(ne.needsHillshadePrepare&&M.renderPass==="offscreen")dpe(M,ne,v);else if(M.renderPass==="translucent"){const de=M.depthModeForSublayer(0,Nr.ReadOnly),be=v.paint.get("hillshade-emissive-strength"),ye=M.colorModeForDrapableLayerRenderPass(be),Ce=z&&M.terrain?M.terrain.stencilModeForRTTOverlap(ee):B[ee.overscaledZ];cpe(M,ee,ne,v,de,Ce,ye)}}D.viewport.set([0,0,M.width,M.height]),M.resetStencilClippingMasks()},raster:function(M,m,v,A,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",ee=v.paint.get("raster-elevation")!==0,ne=ee&&W,de=M.terrain&&M.terrain.exaggeration()>0&&ee&&v.paint.get("raster-elevation-reference")==="ground",be=!W&&de;if(M.renderElevatedRasterBackface&&!ne)return;const ye=M.context,Ce=ye.gl,Be=m.getSource(),Ie=function(yt,Tt,Wt,Bt,ns){const Qt=Tt.paint.get("raster-color"),ws=yt.type==="raster-array",As=[],Zt=Tt.paint.get("raster-resampling"),Ut=Tt.paint.get("raster-color-mix");let ts=Tt.paint.get("raster-color-range");const as=[Ut[0],Ut[1],Ut[2],0],cs=Ut[3];let Qs=Zt==="nearest"?Bt.NEAREST:Bt.LINEAR;if(ws&&(As.push("RASTER_ARRAY"),Qt||As.push("RASTER_COLOR"),Zt==="linear"&&As.push("RASTER_ARRAY_LINEAR"),Qs=Bt.NEAREST,!ts&&yt.rasterLayers)){const Hs=yt.rasterLayers.find(({id:Gs})=>Gs===Tt.sourceLayer);Hs&&Hs.fields&&Hs.fields.range&&(ts=Hs.fields.range)}if(ts=ts||[0,1],Qt){As.push("RASTER_COLOR"),Wt.activeTexture.set(Bt.TEXTURE2),Tt.updateColorRamp(ts);let Hs=Tt.colorRampTexture;Hs||(Hs=Tt.colorRampTexture=new i.T(Wt,Tt.colorRamp,Bt.RGBA8)),Hs.bind(Qs,Bt.CLAMP_TO_EDGE)}return ns&&As.push("USE_MRT1"),{mix:as,range:ts,offset:cs,defines:As,resampling:Qs}}(Be,v,ye,Ce,M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback");if(Be instanceof i.aV&&!A.length&&!W)return;const st=v.paint.get("raster-emissive-strength"),tt=M.colorModeForDrapableLayerRenderPass(st),ct=M.terrain&&M.terrain.renderingToTexture,mt=!M.options.moving,nt=v.paint.get("raster-resampling")==="nearest"?Ce.NEAREST:Ce.LINEAR;if(Be instanceof i.aV&&!A.length&&(Be.onNorthPole||Be.onSouthPole)){const yt=ee?M.stencilModeFor3D():nn.disabled;return void h3(!!Be.onNorthPole,null,M,m,v,st,Ie,Wr.disabled,yt)}if(!A.length)return;const[Ft,wt]=Be instanceof i.aV||ct?[{},A]:M.stencilConfigForOverlap(A),Dt=wt[wt.length-1].overscaledZ;ne&&Ie.defines.push("PROJECTION_GLOBE_VIEW"),ee&&Ie.defines.push("RENDER_CUTOFF","ELEVATED"),de&&Ie.defines.push("ELEVATION_REFERENCE_GROUND");const pt=(yt,Tt,Wt)=>{for(const Bt of yt){const ns=Bt.toUnwrapped(),Qt=m.getTile(Bt);if(ct&&(!Qt||!Qt.hasData()))continue;ye.activeTexture.set(Ce.TEXTURE0);const ws=hF(Qt,Be,v,Ie);if(!ws||!ws.texture)continue;const{texture:As,mix:Zt,offset:Ut,tileSize:ts,buffer:as}=ws;let cs,Qs;ct?(cs=Nr.disabled,Qs=Bt.projMatrix):ee?(cs=new Nr(Ce.LEQUAL,Nr.ReadWrite,M.depthRangeFor3D),Qs=W?Float32Array.from(M.transform.expandedFarZProjMatrix):M.transform.calculateProjMatrix(ns,mt)):(cs=M.depthModeForSublayer(Bt.overscaledZ-Dt,B===1?Nr.ReadWrite:Nr.ReadOnly,Ce.LESS),Qs=M.transform.calculateProjMatrix(ns,mt));const Hs=M.terrain&&ct?M.terrain.stencilModeForRTTOverlap(Bt):Ft[Bt.overscaledZ],Gs=z?0:v.paint.get("raster-fade-duration");Qt.registerFadeDuration(Gs);const Cs=m.findLoadedParent(Bt,0),br=Xw(Qt,Cs,m,M.transform,Gs);let Ar,mr;!br.isFading&&Qt.refreshedUponExpiration&&(Qt.refreshedUponExpiration=!1),M.terrain&&M.terrain.prepareDrawTile(),ye.activeTexture.set(Ce.TEXTURE0),As.bind(nt,Ce.CLAMP_TO_EDGE),ye.activeTexture.set(Ce.TEXTURE1),Cs?(Cs.texture&&Cs.texture.bind(nt,Ce.CLAMP_TO_EDGE),Ar=Math.pow(2,Cs.tileID.overscaledZ-Qt.tileID.overscaledZ),mr=[Qt.tileID.canonical.x*Ar%1,Qt.tileID.canonical.y*Ar%1]):As.bind(nt,Ce.CLAMP_TO_EDGE),"useMipmap"in As&&ye.extTextureFilterAnisotropic&&M.transform.pitch>20&&Ce.texParameterf(Ce.TEXTURE_2D,ye.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,ye.extTextureFilterAnisotropicMax);const yr=M.transform;let Zr;const xn=ee?hP(yr):[0,0,0,0];let un,$n,qr,qn,hn,Pa=0;if(ne&&Be instanceof i.aV&&Be.coordinates.length>3)un=Float32Array.from(i.du(i.dv(new i.cn(0,0,0)))),$n=Float32Array.from(yr.globeMatrix),qr=Float32Array.from(i.dq(yr)),qn=[i.aH(yr.center.lng),i.aL(yr.center.lat)],Zr=Be.elevatedGlobePerspectiveTransform,hn=Be.elevatedGlobeGridMatrix||new Float32Array(9);else if(ne){const za=i.dr(Bt.canonical);Pa=i.ds(za.getCenter().lat),un=Float32Array.from(i.du(i.dv(Bt.canonical))),$n=Float32Array.from(yr.globeMatrix),qr=Float32Array.from(i.dq(yr)),qn=[i.aH(yr.center.lng),i.aL(yr.center.lat)],Zr=[0,0],hn=Float32Array.from(i.dt(Bt.canonical,za,Pa,yr.worldSize/yr._pixelsPerMercatorPixel))}else Zr=Be instanceof i.aV?Be.perspectiveTransform:[0,0],un=new Float32Array(16),$n=new Float32Array(9),qr=new Float32Array(16),qn=[0,0],hn=new Float32Array(9);const hi=rF(M,Qs,un,$n,qr,hn,mr||[0,0],i.al(M.transform.zoom),qn,xn,Ar||1,br,v,Zr,ee?v.paint.get("raster-elevation"):0,2,Zt,Ut,Ie.range,ts,as,st),Gi=M.isTileAffectedByFog(Bt),wi=M.getOrCreateProgram("raster",{defines:Ie.defines,overrideFog:Gi});if(M.uploadCommonUniforms(ye,wi,ns),Be instanceof i.aV){const za=Be.elevatedGlobeVertexBuffer,Rn=Be.elevatedGlobeIndexBuffer;if(ct||!W)Be.boundsBuffer&&Be.boundsSegments&&wi.draw(M,Ce.TRIANGLES,cs,nn.disabled,tt,Wr.disabled,hi,v.id,Be.boundsBuffer,M.quadTriangleIndexBuffer,Be.boundsSegments);else if(za&&Rn){const On=yr.zoom<=i.cJ?Be.elevatedGlobeSegments:Be.getSegmentsForLongitude(yr.center.lng);On&&wi.draw(M,Ce.TRIANGLES,cs,nn.disabled,tt,Tt,hi,v.id,za,Rn,On)}}else if(ne){cs=new Nr(Ce.LEQUAL,Nr.ReadOnly,M.depthRangeFor3D);const za=M.globeSharedBuffers;if(za){de&&(M.terrain.setupElevationDraw(Qt,wi),M.uploadCommonUniforms(ye,wi,Qt.tileID.toUnwrapped()));const[Rn,On,ji]=za.getGridBuffers(Pa,!1),Qi=wi.getAttributeLocation(Ce,"a_texture_pos");Qi!==-1&&Ce.vertexAttribI4ui(Qi,0,0,0,0),wi.draw(M,Ce.TRIANGLES,cs,Wt||Hs,M.colorModeForRenderPass(),Tt,hi,v.id,Rn,On,ji)}}else if(be)cs=new Nr(Ce.LEQUAL,Nr.ReadWrite,M.depthRangeFor3D),M.terrain.setupElevationDraw(Qt,wi),M.uploadCommonUniforms(ye,wi,Qt.tileID.toUnwrapped()),yr.pitch>20&&wi.draw(M,Ce.TRIANGLES,cs,nn.disabled,tn.disabled,Wr.frontCCW,hi,v.id,M.terrain.gridBuffer,M.terrain.gridIndexBuffer,M.terrain.gridSegments),wi.draw(M,Ce.TRIANGLES,cs,Hs,tt,Wr.backCCW,hi,v.id,M.terrain.gridBuffer,M.terrain.gridIndexBuffer,M.terrain.gridSegments);else{const{tileBoundsBuffer:za,tileBoundsIndexBuffer:Rn,tileBoundsSegments:On}=M.getTileBoundsBuffers(Qt);wi.draw(M,Ce.TRIANGLES,cs,Hs,tt,Wr.disabled,hi,v.id,za,Rn,On)}}if(!(Be instanceof i.aV)&&ne)for(const Bt of yt){const ns=Bt.canonical.y===(1<i.d$[as](ns));Zt.push(ns);const Ut=ns.canonical.x,ts=ns.canonical.y;for(const as of Zt){const cs=nt.getTile(Tt?as.wrapped():as);if(!cs)continue;const Qs=cs.rasterParticleState;if(!Qs)continue;const Hs=as.canonical.x+(1<Dt.tileID)),Ce&&(ne.activeTexture.set(de.TEXTURE0),M.imageManager.bind(M.context,v.scope));const wt=[];if(M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&wt.push("USE_MRT1"),ee){const Dt=M.getOrCreateProgram(mt,{overrideFog:!1,overrideRtt:!0,defines:wt}),pt=new Float32Array(i.b9([])),yt=new i.aR(0,0,0,0,0),Tt=Ce?ly(pt,W,B,M,0,v.scope,Be,ee,{tileID:yt,tileSize:ye}):t2(pt,W,B,D.toPremultipliedRenderColor(z?null:v.lut));return void Dt.draw(M,de.TRIANGLES,tt,st,ct,Wr.disabled,Tt,v.id,M.viewportBuffer,M.quadTriangleIndexBuffer,M.viewportSegments)}for(const Dt of Ft){const pt=M.isTileAffectedByFog(Dt),yt=M.getOrCreateProgram(mt,{overrideFog:pt,defines:wt}),Tt=Dt.toUnwrapped(),Wt=A?Dt.projMatrix:M.transform.calculateProjMatrix(Tt);M.prepareDrawTile();const Bt=m?m.getTile(Dt):nt?nt[Dt.key]:new i.b0(Dt,ye,be.zoom,M),ns=Ce?ly(Wt,W,B,M,0,v.scope,Be,ee,{tileID:Dt,tileSize:ye}):t2(Wt,W,B,D.toPremultipliedRenderColor(z?null:v.lut));M.uploadCommonUniforms(ne,yt,Tt);const{tileBoundsBuffer:Qt,tileBoundsIndexBuffer:ws,tileBoundsSegments:As}=M.getTileBoundsBuffers(Bt);yt.draw(M,de.TRIANGLES,tt,st,ct,Wr.disabled,ns,v.id,Qt,ws,As)}},sky:function(M,m,v){const A=M._atmosphere?i.al(M.transform.zoom):1,D=v.paint.get("sky-opacity")*A;if(D===0)return;const z=M.context,B=v.paint.get("sky-type"),W=new Nr(z.gl.LEQUAL,Nr.ReadOnly,[0,1]),ee=M.frameCounter/1e3%1;B==="atmosphere"?M.renderPass==="offscreen"?v.needsSkyboxCapture(M)&&(function(ne,de){const be=ne.context,ye=be.gl;let Ce=de.skyboxFbo;if(!Ce){Ce=de.skyboxFbo=be.createFramebuffer(32,32,1,null),de.skyboxGeometry=new Wd(be),de.skyboxTexture=be.gl.createTexture(),ye.bindTexture(ye.TEXTURE_CUBE_MAP,de.skyboxTexture),ye.texParameteri(ye.TEXTURE_CUBE_MAP,ye.TEXTURE_WRAP_S,ye.CLAMP_TO_EDGE),ye.texParameteri(ye.TEXTURE_CUBE_MAP,ye.TEXTURE_WRAP_T,ye.CLAMP_TO_EDGE),ye.texParameteri(ye.TEXTURE_CUBE_MAP,ye.TEXTURE_MIN_FILTER,ye.LINEAR),ye.texParameteri(ye.TEXTURE_CUBE_MAP,ye.TEXTURE_MAG_FILTER,ye.LINEAR);for(let tt=0;tt<6;++tt)ye.texImage2D(ye.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,ye.RGBA,32,32,0,ye.RGBA,ye.UNSIGNED_BYTE,null)}be.bindFramebuffer.set(Ce.framebuffer),be.viewport.set([0,0,32,32]);const Be=de.getCenter(ne,!0),Ie=ne.getOrCreateProgram("skyboxCapture"),st=new Float64Array(16);i.b9(st),i.ef(st,st,.5*-Math.PI),Qh(ne,de,Ie,st,Be,0),i.b9(st),i.ef(st,st,.5*Math.PI),Qh(ne,de,Ie,st,Be,1),i.b9(st),i.cE(st,st,.5*-Math.PI),Qh(ne,de,Ie,st,Be,2),i.b9(st),i.cE(st,st,.5*Math.PI),Qh(ne,de,Ie,st,Be,3),i.b9(st),Qh(ne,de,Ie,st,Be,4),i.b9(st),i.ef(st,st,Math.PI),Qh(ne,de,Ie,st,Be,5),be.viewport.set([0,0,ne.width,ne.height])}(M,v),v.markSkyboxValid(M)):M.renderPass==="sky"&&function(ne,de,be,ye,Ce){const Be=ne.context,Ie=Be.gl,st=ne.transform,tt=ne.getOrCreateProgram("skybox");Be.activeTexture.set(Ie.TEXTURE0),Ie.bindTexture(Ie.TEXTURE_CUBE_MAP,de.skyboxTexture);const ct=((mt,nt,Ft,wt,Dt)=>({u_matrix:mt,u_sun_direction:nt,u_cubemap:0,u_opacity:wt,u_temporal_offset:Dt}))(st.skyboxMatrix,de.getCenter(ne,!1),0,ye,Ce);ne.uploadCommonUniforms(Be,tt),tt.draw(ne,Ie.TRIANGLES,be,nn.disabled,ne.colorModeForRenderPass(),Wr.backCW,ct,"skybox",de.skyboxGeometry.vertexBuffer,de.skyboxGeometry.indexBuffer,de.skyboxGeometry.segment)}(M,v,W,D,ee):B==="gradient"&&M.renderPass==="sky"&&function(ne,de,be,ye,Ce){const Be=ne.context,Ie=Be.gl,st=ne.transform,tt=ne.getOrCreateProgram("skyboxGradient");de.skyboxGeometry||(de.skyboxGeometry=new Wd(Be)),Be.activeTexture.set(Ie.TEXTURE0);let ct=de.colorRampTexture;ct||(ct=de.colorRampTexture=new i.T(Be,de.colorRamp,Ie.RGBA8)),ct.bind(Ie.LINEAR,Ie.CLAMP_TO_EDGE);const mt=((nt,Ft,wt,Dt,pt)=>({u_matrix:nt,u_color_ramp:0,u_center_direction:Ft,u_radius:i.ap(wt),u_opacity:Dt,u_temporal_offset:pt}))(st.skyboxMatrix,de.getCenter(ne,!1),de.paint.get("sky-gradient-radius"),ye,Ce);ne.uploadCommonUniforms(Be,tt),tt.draw(ne,Ie.TRIANGLES,be,nn.disabled,ne.colorModeForRenderPass(),Wr.backCW,mt,"skyboxGradient",de.skyboxGeometry.vertexBuffer,de.skyboxGeometry.indexBuffer,de.skyboxGeometry.segment)}(M,v,W,D,ee)},custom:function(M,m,v,A){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 ee=A[0].canonical,ne={x:ee.x+A[0].wrap*(z.wrapTileId?0:1<{ne&&(ne.useNormalOffset=!0,de||(ne.enabled=!0))},ye=m.getSource();if(M.renderPass==="light-beam"&&ye.type!=="batched-model")return;if(ye.type==="vector"||ye.type==="geojson")return function(nt,Ft,wt,Dt,pt){const yt=nt.transform,Tt=yt.projection.name==="globe",Wt=yt.getFreeCameraOptions().position;if(!nt.modelManager)return;const Bt=nt.modelManager;wt.modelManager=Bt;const ns=nt.shadowRenderer;if(!wt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const Qt=wt._unevaluatedLayout._values["model-id"],ws=Object.assign({},wt.layout.get("model-id").parameters),As=nt.style.order.indexOf(wt.fqid),Zt=wt.paint.get("model-opacity").constantOr(1);for(const Ut of Dt){const ts=Ft.getTile(Ut).getBucket(wt);if(!ts||ts.projection.name!==yt.projection.name)continue;const as=ts.getModelUris();if(as&&!ts.modelsRequested&&(Bt.addModelsFromBucket(as,pt),ts.modelsRequested=!0),Tt)ws.zoom=Ut.overscaledZ;else{const mr=Y1(Ut,yt);ws.zoom=mr}const cs=Qt.possiblyEvaluate(ws);if(Ys(nt,ts,Ut),Vs.shadowUniformsInitialized=!1,Vs.useSingleShadowCascade=!!ns&&ns.getMaxCascadeForTile(Ut.toUnwrapped())===0,nt.renderPass==="shadow"&&ns){if(nt.currentShadowCascade===1&&ts.isInsideFirstShadowMapFrustum)continue;const mr=yt.calculatePosMatrix(Ut.toUnwrapped(),yt.worldSize);if(Vs.tileMatrix.set(mr),Vs.shadowTileMatrix=Float32Array.from(ns.calculateShadowPassMatrixFromMatrix(mr)),Vs.aabb.min=[0,0,0],Vs.aabb.max[0]=Vs.aabb.max[1]=i.an,Vs.aabb.max[2]=0,vF(ts,Vs,nt,wt.scope))continue}const Qs=1<0&&nt.style.isLayerClipped(wt,Ft.getSource())&&ts.updateReplacement(Ut,nt.replacementSource,As,wt.scope)&&(ts.uploaded=!1,ts.upload(nt.context));let Gs=0;const Cs=new Array,br=new Array,Ar=new Array;for(let mr in ts.instancesPerModel){const yr=ts.instancesPerModel[mr];yr.features.length>0&&!Tt&&(mr=cs.evaluate(yr.features[0].feature,{}));const Zr=Bt.getModel(mr,pt);if(Zr||Bt.hasURLBeenRequested(mr)||ts.modelUris.includes(mr)||(ts.modelUris.push(mr),ts.modelsRequested=!1),Zr&&Zr.uploaded)if(Tt){const xn=i.bJ([],[Wt.x,Wt.y,Wt.z],nt.transform.worldSize);i.eo(xn,xn);for(let un=0;un0&&qn.elevationUpdate(mr.terrain,un,qr,Zr.source),qn.needsReEvaluation(mr,$n,Zr)&&qn.evaluate(Zr))}})(nt,Ft,wt,Dt),function(){const mr=new Map;let yr,Zr,xn;Cs?(yr=Dt.length-1,Zr=-1,xn=-1):(yr=0,Zr=Dt.length,xn=1);const un=new Float64Array(16),$n=i.ce(),qr=new i.P(0,0);for(let qn=yr;qn!==Zr;qn+=xn){const hn=Dt[qn],Pa=Ft.getTile(hn).getBucket(wt);if(!Pa||!Pa.uploaded)continue;let hi=!1;Wt&&(hi=Wt.getMaxCascadeForTile(hn.toUnwrapped())===0);const Gi=yt.calculatePosMatrix(hn.toUnwrapped(),yt.worldSize),wi=Pa.modelTraits;!Qs&&Cs&&(i.b7(un,Gi),i.ah($n,ns,un),qr.x=$n[0],qr.y=$n[1]);const za=[];Pa.setFilter(wt.filter);for(const Rn of Pa.getNodesInfo()){if(Rn.hiddenByReplacement||!Rn.node.meshes)continue;const On=Rn.node;let ji=0;nt.terrain&&On.elevation&&(ji=On.elevation*nt.terrain.exaggeration());const Qi=(()=>{const Sc=Rn.aabb;return cs.min=[...Sc.min],cs.max=[...Sc.max],cs.min[2]+=ji,cs.max[2]+=ji,i.ah(cs.min,cs.min,Gi),i.ah(cs.max,cs.max,Gi),cs})(),Ba=Rn.evaluatedScale;if(Ba[0]<=1&&Ba[1]<=1&&Ba[2]<=1&&Qi.intersects(Hs)===0)continue;if(!Qs&&Cs){const Sc=.16666666666666666;Rn.cameraCollisionOpacity=ns[0]>Qi.min[0]&&ns[0]Qi.min[1]&&ns[1]!Cs||Rn.opacity===1&&On.opacity===1?Rn.depthOn.depth?-1:1);for(const Rn of za){const On=Rn.nodeInfo,ji=On.node;if(nt._debugParams.show3DModelFootprints&&ji.footprint){const sa=ji.id||ji.name||"footprint";mr.has(sa)||mr.set(sa,{node:ji,mvp:Rn.wvpForTile})}let Qi=i.aD([],Zt,Rn.tileModelMatrix);i.aD(Qi,ws,Qi);const Ba=i.b7([],Qi);i.e6(Ba,Ba),i.cC(Ba,Ba,Gt),Qi=i.aD(Qi,Qi,ji.globalMatrix);const bn=nt.renderPass==="light-beam",Bi=wt.paint.get("model-color-use-theme").constantOr("default")==="none",mi=wi&i.ez.HasMapboxMeshFeatures,Uo=mi?0:On.evaluatedRMEA[0][2];for(let sa=0;sa=ta||bh>=ta}}const Qa=vi.material;let tm;Qa.occlusionTexture&&Qa.occlusionTexture.offsetScale&&(tm=Qa.occlusionTexture.offsetScale,_l.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const sm=nt.getOrCreateProgram("model",_l);!Qs&&Wt&&Wt.setupShadowsFromMatrix(Rn.tileModelMatrix,sm,Wt.useNormalOffset),nt.uploadCommonUniforms(pt,sm,null,_h);const Si=Qa.pbrMetallicRoughness;Si.metallicFactor=.9,Si.roughnessFactor=.5;const Ei=H0(new Float32Array(od),new Float32Array(Qi),new Float32Array(Ba),new Float32Array(ji.globalMatrix),nt,Rn.opacity,Si.baseColorFactor,Qa.emissiveFactor,Si.metallicFactor,Si.roughnessFactor,Qa,Uo,wt,[0,0,0],tm);!ol&&(On.hasTranslucentParts||Rn.opacity<1)&&sm.draw(nt,pt.gl.TRIANGLES,ts,nn.disabled,tn.disabled,Wr.backCCW,Ei,wt.id,vi.vertexBuffer,vi.indexBuffer,vi.segments,wt.paint,nt.transform.zoom,void 0,Sc),sm.draw(nt,pt.gl.TRIANGLES,ol?as:ts,nn.disabled,ol||Rn.opacity<1||On.hasTranslucentParts?tn.alphaBlended:tn.unblended,Wr.backCCW,Ei,wt.id,vi.vertexBuffer,vi.indexBuffer,vi.segments,wt.paint,nt.transform.zoom,void 0,Sc)}}}if(nt._debugParams.show3DModelFootprints&&mr.size>0){const qn=Array.from(mr.keys()).sort();for(const hn of qn){const{node:Pa,mvp:hi}=mr.get(hn);wP(nt,0,Pa,hi)}}}()}(M,m,v,A),void be();if(ye.type!=="model")return;const Ce=ye.getModels(),Be=[],Ie=M.transform.getFreeCameraOptions().position,st=i.bJ([],[Ie.x,Ie.y,Ie.z],M.transform.worldSize);i.eo(st,st);const tt=[],ct=[];let mt=0;for(const nt of Ce){const Ft=m.getFeatureState("",nt.id),wt={type:"Unknown",id:nt.id,properties:nt.featureProperties},Dt=v.paint.get("model-rotation").evaluate(wt,Ft),pt=v.paint.get("model-scale").evaluate(wt,Ft),yt=v.paint.get("model-translation").evaluate(wt,Ft),Tt=v.paint.get("model-opacity").evaluate(wt,Ft);jP(v,nt.id,Ft,nt.featureProperties,nt.nodeOverrideNames,nt.nodeOverrides),Z0(v,nt.id,Ft,nt.featureProperties,nt.materialOverrideNames,nt.materialOverrides),nt.nodeOverrides.size>0&&nt.computeBoundsAndApplyParent(),nt.computeModelMatrix(M,Dt,pt,yt,W,B,!1);const Wt=i.b9([]),Bt=i.e2(nt.position.lat,M.transform.zoom),ns=i.bP([],[1,1,1/Bt]);i.bx(Wt,Wt,st),Be.push({zScaleMatrix:ns,negCameraPosMatrix:Wt});for(const Qt of nt.nodes)f3(M,Qt,nt.matrix,M.transform.expandedFarZProjMatrix,mt,tt,ct,nt.materialOverrides,Tt);mt++}if(tt.sort((nt,Ft)=>Ft.depth-nt.depth),M.renderPass!=="shadow"){if(M._debugParams.show3DModelFootprints){const nt=M.transform.projMatrix,Ft=new Map,wt=(pt,yt)=>{if(pt.footprint){const Tt=pt.id||pt.name||"footprint";if(!Ft.has(Tt)){const Wt=i.aD([],nt,yt);Ft.set(Tt,{node:pt,mvp:Wt})}}};for(const pt of ct)wt(pt.node,pt.modelMatrix);for(const pt of tt)wt(pt.node,pt.modelMatrix);const Dt=Array.from(Ft.keys()).sort();for(const pt of Dt){const{node:yt,mvp:Tt}=Ft.get(pt);wP(M,0,yt,Tt)}}Kx(M,v,tt,ct,Be),be()}else{for(const nt of ct)Z1(nt.mesh,nt.nodeModelMatrix,M,v);for(const nt of tt)Z1(nt.mesh,nt.nodeModelMatrix,M,v);be()}}},SP={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 A=m.getVisibleCoordinates();for(const D of A){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 A=m.getSource();if(!A.loaded())return;if(A.type==="vector"||A.type==="geojson")return void(v.modelManager&&v.modelManager.upload(v,p3(v,M)));if(A.type==="batched-model"||A.type!=="model")return;const D=A.getModels();for(const z of D)z.upload(v.context)},raster:function(M,m,v){const A=m.getSource();if(!(A instanceof xh&&A.loaded()))return;const D=M.sourceLayer||A.rasterLayerIds&&A.rasterLayerIds[0];if(!D)return;const z=M.paint.get("raster-array-band")||A.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)&&A.prepareTile(W,D,M.id,z)},"raster-particle":function(M,m,v){const A=m.getSource();if(!(A instanceof xh&&A.loaded()))return;const D=M.sourceLayer||A.rasterLayerIds&&A.rasterLayerIds[0];if(!D)return;const z=M.paint.get("raster-particle-array-band")||A.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)&&A.prepareTile(W,D,M.id,z)}},CP={fill:n2},MP={fill:function(M,m,v,A){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 Nr(D.LEQUAL,Nr.ReadOnly,M.depthRangeFor3D),B=new nn({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),W=M.transform.getFreeCameraOptions().position,ee=M.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const ne of A){const de=m.getTile(ne),be=de.getBucket(v);if(!be)continue;const ye=be.elevatedStructures;if(!ye||ye.depthSegments.segments[0].primitiveLength===0)continue;const Ce=oP(ne.toUnwrapped(),W),Be=M.translatePosMatrix(ne.projMatrix,de,v.paint.get("fill-translate"),v.paint.get("fill-translate-anchor")),Ie=Jw(Be,Ce,0,1,0);ee.draw(M,D.TRIANGLES,z,B,tn.disabled,Wr.disabled,Ie,v.id,ye.vertexBuffer,ye.indexBuffer,ye.depthSegments,v.paint,M.transform.zoom)}}};class Cpe{constructor(m,v,A,D,z){this.context=new W1(m,v),this.transform=A,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this._timeStamp=i.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,show3DModelFootprints:!1,enabledLayers:{}};const B=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const ee of B)this._debugParams.enabledLayers[ee]=!0;for(const ee of B);this.occlusionParams=new bF,this.setup(),this.numSublayers=gh.maxUnderzooming+gh.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 zw(this),this._wireframeDebugCache=new _F,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 A=!!m&&!!m.terrain&&this.transform.projection.supportsTerrain;if(!(A||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Qw(this,m));const D=this._terrain;this.transform.elevation=A?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[A,D]=v.getFovAdjustedRange(this.transform._fov);if(A>D)return void(this.transform.fogCullDistSq=null);const z=A+.78*(D-A);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 Qw(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 A of this.style.order)this.style._mergedLayers[A].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 A=new i.dB;A.emplaceBack(0,0),A.emplaceBack(i.an,0),A.emplaceBack(0,i.an),A.emplaceBack(i.an,i.an),this.debugBuffer=m.createVertexBuffer(A,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 ee=this.context.gl;this.stencilClearMode=new nn({func:ee.ALWAYS,mask:0},0,255,ee.ZERO,ee.ZERO,ee.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,Nr.disabled,this.stencilClearMode,tn.disabled,Wr.disabled,Yw(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(m,v,A){if(!v||this.currentStencilSource===v.id||!m.isTileClipped()||!A||A.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let W=!1;for(const ee of A)if(this._tileClippingMaskIDs[ee.key]===void 0){W=!0;break}if(!W)return}this.currentStencilSource=v.id;const D=this.context,z=D.gl;this.nextStencilID+A.length>256&&this.clearStencil(),D.setColorMode(tn.disabled),D.setDepthMode(Nr.disabled);const B=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const W of A){const ee=v.getTile(W),ne=this._tileClippingMaskIDs[W.key]=this.nextStencilID++,{tileBoundsBuffer:de,tileBoundsIndexBuffer:be,tileBoundsSegments:ye}=this.getTileBoundsBuffers(ee);B.draw(this,z.TRIANGLES,Nr.disabled,new nn({func:z.ALWAYS,mask:0},ne,255,z.KEEP,z.KEEP,z.REPLACE),tn.disabled,Wr.disabled,Yw(W.projMatrix),"$clipping",de,be,ye)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const m=this.nextStencilID++,v=this.context.gl;return new nn({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 nn({func:v.EQUAL,mask:255},this._tileClippingMaskIDs[m.key],0,v.KEEP,v.KEEP,v.REPLACE)}stencilConfigForOverlap(m){const v=this.context.gl,A=m.sort((B,W)=>W.overscaledZ-B.overscaledZ),D=A[A.length-1].overscaledZ,z=A[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 A=i.o.now();this._dt=A-this._timeStamp,this._timeStamp=A,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(),ee=!1,ne=!1,de=null,be=0,ye=!1;for(const Zt of W){const Ut=D[Zt];Ut.visibility!=="none"&&(Ut.type==="circle"?ee=!0:Ut.type==="building"?(de=Ut,++be):Ut.type==="symbol"&&(Ut.hasOcclusionOpacityProperties?ne=!0:ee=!0))}this.updateEmissiveMode();let Ce=W.map(Zt=>D[Zt]);const Be=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 Be){const Ut=Be[Zt];Ut.used&&(Ut.prepare(this.context),Ut.getSource().usedInConflation&&++be)}let Ie=!1;for(const Zt of Ce)Zt.isHidden(this.transform.zoom)||(Zt.type==="clip"&&(Ie=!0),this.prepareLayer(Zt));const st={},tt={},ct={},mt={},nt={};for(const Zt in Be){const Ut=Be[Zt];st[Zt]=Ut.getVisibleCoordinates(),tt[Zt]=st[Zt].slice().reverse(),ct[Zt]=Ut.getVisibleCoordinates(!0).reverse(),mt[Zt]=Ut.getShadowCasterCoordinates(),nt[Zt]=Ut.sortCoordinatesByDistance(st[Zt])}const Ft=Zt=>{const Ut=this.style.getLayerSourceCache(Zt);return Ut&&Ut.used?Ut.getSource():null};if(be||Ie||this._clippingActiveLastFrame){const Zt=[],Ut=[];let ts=0;for(const as of Ce)this.isSourceForClippingOrConflation(as,Ft(as))&&(Zt.push(as),Ut.push(ts)),ts++;if(Zt&&(Ie||Zt.length>1)||this._clippingActiveLastFrame){Ie=!1;const as=[];for(let cs=0;cs0){const as=Ft(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 wt=this.style&&this.style.fog;wt?(this._fogVisible=wt.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=wt.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(ct),this.opaquePassCutoff=0,W=B(),Ce=W.map(Zt=>D[Zt]));const Dt=this._shadowRenderer;if(Dt){Dt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Zt in Be)for(const Ut of st[Zt]){let ts={min:0,max:0};this.terrain&&(ts=this.terrain.getMinMaxForTile(Ut)||ts),Dt.addShadowReceiver(Ut.toUnwrapped(),ts.min,ts.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 gF(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const pt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),yt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(pt&&!this._snow&&(this._snow=new NF(this)),!pt&&this._snow&&(this._snow.destroy(),delete this._snow),yt&&!this._rain&&(this._rain=new l2(this)),!yt&&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 Wx);const Zt=this.style.getLayerSourceCache(de);this.buildingTileBorderManager.updateBorders(Zt,de)}if(!at.has(this.context.gl))return;this.renderPass="offscreen";for(const Zt of Ce){const Ut=m.getLayerSourceCache(Zt);if(!Zt.hasOffscreenPass()||Zt.isHidden(this.transform.zoom))continue;const ts=Ut?tt[Ut.id]:void 0;(Zt.type==="custom"||Zt.type==="raster"||Zt.type==="raster-particle"||Zt.isSky()||ts&&ts.length)&&this.renderLayer(this,Ut,Zt,ts)}this.depthRangeFor3D=[0,1-(Ce.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(),Wt=(()=>{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 ts=Zt.properties.get("color-use-theme")==="none",as=Zt.properties.get("color").toNonPremultipliedRenderColor(ts?null:Ut).toArray01();return new i.aq(...as)}if(Tt){const ts=Zt.properties.get("space-color-use-theme")==="none",as=Zt.properties.get("space-color").toNonPremultipliedRenderColor(ts?null:Ut).toArray01();return new i.aq(...as)}}return i.aq.transparent})();if(this.context.clear({color:Wt,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=Ce[this.currentLayer],Ut=m.getLayerSourceCache(Zt);if(Zt.isSky())continue;const ts=Ut?(Zt.is3D(z)?nt:tt)[Ut.id]:void 0;this._renderTileClippingMasks(Zt,Ut,ts),this.renderLayer(this,Ut,Zt,ts)}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 ts=this.currentLayer;this.depthOcclusion=!0;for(const as of this.layersWithOcclusionOpacity){this.currentLayer=as;const cs=Ce[this.currentLayer],Qs=m.getLayerSourceCache(cs),Hs=Qs?tt[Qs.id]:void 0;this.terrain||this._renderTileClippingMasks(cs,Qs,Qs?st[Qs.id]:void 0),this.renderLayer(this,Qs,cs,Hs)}this.depthOcclusion=!1,this.currentLayer=ts,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;Ce.forEach(Ut=>{const ts=m.getLayerSourceCache(Ut);ts&&!Ut.isHidden(this.transform.zoom)&&ts.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,A){const D=A===void 0?this.terrain&&this.terrain.renderingToTexture:A,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 A=v&&v.defines||[],D=v&&v.config,z=this.currentGlobalDefines(m,v&&v.overrideFog,v&&v.overrideRtt).concat(A),B=V0.cacheKey(DO[m],m,z,D);return this.cache[B]||(this.cache[B]=new V0(this.context,m,DO[m],D,i3[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 A=this.style.directionalLight,D=this.style.ambientLight;if(A&&D){const z=((B,W,ee)=>{const ne=B.properties.get("direction"),de=B.properties.get("color-use-theme")==="none",be=B.properties.get("color").toNonPremultipliedRenderColor(de?null:ee.getLut(B.scope)).toArray01(),ye=B.properties.get("intensity"),Ce=W.properties.get("color-use-theme")==="none",Be=W.properties.get("color").toNonPremultipliedRenderColor(Ce?null:ee.getLut(W.scope)).toArray01(),Ie=W.properties.get("intensity"),st=[ne.x,ne.y,ne.z],tt=i.dD(Be,Ie),ct=i.dD(be,ye);return{u_lighting_ambient_color:tt,u_lighting_directional_dir:st,u_lighting_directional_color:ct,u_ground_radiance:sP(st,ct,tt)}})(A,D,this.style);v.setLightsUniformValues(m,z)}}}uploadCommonUniforms(m,v,A,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),ee=((ne,de,be,ye,Ce,Be,Ie,st,tt,ct,mt,nt)=>{const Ft=ne.transform,wt=de.properties.get("color-use-theme")==="none",Dt=de.properties.get("color").toNonPremultipliedRenderColor(wt?null:ne.style.getLut(de.scope)).toArray01();Dt[3]=ye;const pt=ne.frameCounter/1e3%1,[yt,Tt]=de.properties.get("vertical-range");return{u_fog_matrix:be?Ft.calculateFogTileMatrix(be):nt||ne.identityMat,u_fog_range:de.getFovAdjustedRange(Ft._fov),u_fog_color:Dt,u_fog_horizon_blend:de.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(yt,Tt),Tt],u_fog_temporal_offset:pt,u_frustum_tl:Ce,u_frustum_tr:Be,u_frustum_br:Ie,u_frustum_bl:st,u_globe_pos:tt,u_globe_radius:ct,u_viewport:mt,u_globe_transition:i.al(Ft.zoom),u_is_globe:+(Ft.projection.name==="globe")}})(this,B,A,W,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*i.o.devicePixelRatio,this.transform.height*i.o.devicePixelRatio],D);v.setFogUniformValues(m,ee)}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={},A=this.transform.coveringTiles({tileSize:512});for(const D of A)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]>=ta||v[1]>=ta}setupDepthForOcclusion(m,v,A){const D=this.context,z=D.gl,B=!!A;var W;A||(A={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),D.activeTexture.set(z.TEXTURE3),m&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(z.NEAREST,z.CLAMP_TO_EDGE),A.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],A.u_depth_range_unpack=[2/((W=this.depthRangeFor3D)[1]-W[0]),-1-2*W[0]/(W[1]-W[0])],A.u_occluder_half_size=.5*this.occlusionParams.occluderSize,A.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(z.NEAREST,z.CLAMP_TO_EDGE),D.activeTexture.set(z.TEXTURE0),B||v.setTerrainUniformValues(D,A)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const m=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=m?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function TP(M,m){let v=!1,A=null;const D=()=>{A=null,v&&(M(),A=setTimeout(D,m),v=!1)};return()=>(v=!0,A||D(),A)}class Mpe{constructor(m){this._hashName=m&&encodeURIComponent(m),i.aZ(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=TP(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=Kd(m);if(this._hashName){const A=this._hashName;let D=!1;const z=location.hash.slice(1).split("&").map(B=>{const W=B.split("=")[0];return W===A?(D=!0,`${W}=${v}`):B}).filter(B=>B);return D||z.push(`${A}=${v}`),`#${z.join("&")}`}return`#${v}`}_getCurrentHash(){const m=location.hash.replace("#","");if(this._hashName){let v;return m.split("&").map(A=>A.split("=")).forEach(A=>{A[0]===this._hashName&&(v=A)}),(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(A=>isNaN(Number(A)))){const A=m.dragRotate.isEnabled()&&m.touchZoomRotate.isEnabled()?+(v[3]||0):m.getBearing();return m.jumpTo({center:[+v[2],+v[1]],zoom:+v[0],bearing:A,pitch:+(v[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function Kd(M,m){const v=M.getCenter(),A=Math.round(100*M.getZoom())/100,D=Math.ceil((A*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,ee=M.getBearing(),ne=M.getPitch();let de=m?`/${B}/${W}/${A}`:`${A}/${W}/${B}`;return(ee||ne)&&(de+="/"+Math.round(10*ee)/10),ne&&(de+=`/${Math.round(ne)}`),de}const _3={linearity:.3,easing:i.eN(0,0,.3,1)},c2=Object.assign({deceleration:2500,maxSpeed:1400},_3),Tpe=Object.assign({deceleration:20,maxSpeed:1400},_3),Di=Object.assign({deceleration:1e3,maxSpeed:360},_3),la=Object.assign({deceleration:1e3,maxSpeed:90},_3);class SF{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 A=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,D={};if(v.pan.mag()){const z=Lf(v.pan.mag(),A,Object.assign({},c2,m||{}));D.offset=v.pan.mult(z.amount/v.pan.mag()),D.center=this._map.transform.center,vh(D,z)}if(v.zoom){const z=Lf(v.zoom,A,Tpe);D.zoom=this._map.transform.zoom+z.amount,vh(D,z)}if(v.bearing){const z=Lf(v.bearing,A,Di);D.bearing=this._map.transform.bearing+i.aC(z.amount,-179,179),vh(D,z)}if(v.pitch){const z=Lf(v.pitch,A,la);D.pitch=this._map.transform.pitch+z.amount,vh(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 vh(M,m){(!M.duration||M.durationv.unproject(ee)),W=z.reduce((ee,ne,de,be)=>ee.add(ne.div(be.length)),new i.P(0,0));super(m,{points:z,point:W,lngLats:B,lngLat:v.unproject(W),originalEvent:A}),this._defaultPrevented=!1}}class AP extends i.C{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(m,v){super("wheel",{originalEvent:v}),this._defaultPrevented=!1}}class EP{constructor(m,v){this._map=m,this._clickTolerance=v.clickTolerance}reset(){this._mousedownPos=void 0}wheel(m){return this._firePreventable(new AP(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 Jh(m.type,this._map,m))}touchmove(m){this._map.fire(new Jh(m.type,this._map,m))}touchend(m){this._map.fire(new Jh(m.type,this._map,m))}touchcancel(m){this._map.fire(new Jh(m.type,this._map,m))}_firePreventable(m){if(this._map.fire(m),m.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class PP{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 IP{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&&(L(),this._startPos=this._lastPos=v,this._active=!0)}mousemoveWindow(m,v){if(!this._active)return;const A=v,D=this._startPos,z=this._lastPos;if(!D||!z||z.equals(A)||!this._box&&A.dist(D){this._box&&(this._box.style.transform=`translate(${B}px,${ee}px)`,this._box.style.width=W-B+"px",this._box.style.height=ne-ee+"px")})}mouseupWindow(m,v){if(!this._active)return;const A=this._startPos,D=v;if(A&&m.button===0){if(this.reset(),V(),A.x!==D.x||A.y!==D.y)return this._map.fire(new i.C("boxzoomend",{originalEvent:m})),{cameraAnimation:z=>z.fitScreenCoordinates(A,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),I(),delete this._startPos,delete this._lastPos}_fireEvent(m,v){return this._map.fire(new i.C(m,{originalEvent:v}))}}function d2(M,m){const v={};for(let A=0;Athis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=m.timeStamp),A.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=d2(A,v)))}touchmove(m,v,A){if(this.aborted||!this.centroid)return;const D=d2(A,v);for(const z in this.touches){const B=D[z];(!B||B.dist(this.touches[z])>30)&&(this.aborted=!0)}}touchend(m,v,A){if((!this.centroid||m.timeStamp-this.startTime>500)&&(this.aborted=!0),A.length===0){const D=!this.aborted&&this.centroid;if(this.reset(),D)return D}}}class Df{constructor(m){this.singleTap=new Vm(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,A){this.singleTap.touchstart(m,v,A)}touchmove(m,v,A){this.singleTap.touchmove(m,v,A)}touchend(m,v,A){const D=this.singleTap.touchend(m,v,A);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 Q1{constructor(){this._zoomIn=new Df({numTouches:1,numTaps:2}),this._zoomOut=new Df({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(m,v,A){this._zoomIn.touchstart(m,v,A),this._zoomOut.touchstart(m,v,A)}touchmove(m,v,A){this._zoomIn.touchmove(m,v,A),this._zoomOut.touchmove(m,v,A)}touchend(m,v,A){const D=this._zoomIn.touchend(m,v,A),z=this._zoomOut.touchend(m,v,A);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 b3=0,LP=2,DP={[b3]:1,[LP]:2},Yx={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class u2{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 A=U(m);this._correctButton(m,A)&&(this._lastPoint=v,this._eventButton=A)}mousemoveWindow(m,v){const A=this._lastPoint;if(A){if(m.preventDefault(),this._eventButton!=null&&function(D,z){const B=DP[z];return D.buttons===void 0||(D.buttons&B)!==B}(m,this._eventButton))this.reset();else if(this._moved||!(v.dist(A)0&&(this._active=!0);const D=d2(A,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],be=this._touches[ne];be&&(z._add(de),B._add(de.sub(be)),W++,D[ne]=de)}if(this._touches=D,W{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class m2{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(m){}_move(m,v,A){return{}}touchstart(m,v,A){this._firstTwoTouches||A.length<2||(this._firstTwoTouches=[A[0].identifier,A[1].identifier],this._start([v[0],v[1]]))}touchmove(m,v,A){const D=this._firstTwoTouches;if(!D)return;m.preventDefault();const[z,B]=D,W=To(A,v,z),ee=To(A,v,B);if(!W||!ee)return;const ne=this._aroundCenter?null:W.add(ee).div(2);return this._move([W,ee],ne,m)}touchend(m,v,A){if(!this._firstTwoTouches)return;const[D,z]=this._firstTwoTouches,B=To(A,v,D),W=To(A,v,z);B&&W||(this._active&&V(),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 To(M,m,v){for(let A=0;AMath.abs(M.x)}class FP extends m2{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,p2(m[0].sub(m[1]))&&(this._valid=!1)}_move(m,v,A){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()&&A.touches.length<3||(this._valid=this.gestureBeginsVertically(z,B,A.timeStamp),!this._valid)?void 0:(this._lastPoints=m,this._active=!0,{pitchDelta:(z.y+B.y)/2*-.5})}gestureBeginsVertically(m,v,A){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=A),A-this._firstMove<100&&void 0;const B=m.y>0==v.y>0;return p2(m)&&p2(v)&&B}}const zP={panStep:100,bearingStep:15,pitchStep:10};class Q0{constructor(){const m=zP;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,A=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?A=-1:(m.preventDefault(),z=-1);break;case 39:m.shiftKey?A=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&&(A=0,D=0),{cameraAnimation:W=>{const ee=W.getZoom();W.easeTo({duration:300,easeId:"keyboardHandler",easing:BP,zoom:v?Math.round(ee)+v*(m.shiftKey?2:1):ee,bearing:W.getBearing()+A*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 BP(M){return M*(2-M)}const J0=4.000244140625,$P=1/450;class k3{constructor(m,v){this._map=m,this._el=m.getCanvasContainer(),this._handler=v,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=$P,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 A=i.o.now(),D=A-(this._lastWheelEventTime||0);this._lastWheelEventTime=A,v!==0&&v%J0===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)>J0?this._wheelZoomRate:this._defaultZoomRate;let de=2/(1+Math.exp(-Math.abs(this._delta*ne)));this._delta<0&&de!==0&&(de=1/de);const be=v(),ye=Math.pow(2,be),Ce=typeof this._targetZoom=="number"?m.zoomScale(this._targetZoom):ye;this._targetZoom=Math.min(m.maxZoom,Math.max(m.minZoom,m.scaleZoom(Ce*de))),this._type==="wheel"&&(this._startZoom=be,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const A=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,A,de),ne<1?this._frameId||(this._frameId=!0):W=!0}else B=A,W=!0;this._active=!0,W&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let ee=B-v();return ee*this._lastDelta<0&&(ee=0),{noInertia:!0,needsRenderFrame:!W,zoomDelta:ee,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(m){let v=i.eP;if(this._prevEase){const A=this._prevEase,D=(i.o.now()-A.start)/A.duration,z=A.easing(D+.01)-A.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 S3{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 C3{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(m,v){return m.preventDefault(),{cameraAnimation:A=>{A.easeTo({duration:300,zoom:A.getZoom()+(m.shiftKey?-1:1),around:A.unproject(v)},{originalEvent:m})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class CF{constructor(){this._tap=new Df({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,A){this._swipePoint||(this._tapTime&&m.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?A.length>0&&(this._swipePoint=v[0],this._swipeTouch=A[0].identifier):this._tap.touchstart(m,v,A))}touchmove(m,v,A){if(this._tapTime){if(this._swipePoint){if(A[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,A)}touchend(m,v,A){this._tapTime?this._swipePoint&&A.length===0&&this.reset():this._tap.touchend(m,v,A)&&(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 qP{constructor(m,v,A){this._el=m,this._mousePan=v,this._touchPan=A}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 MF{constructor(m,v,A){this._pitchWithRotate=m.pitchWithRotate,this._mouseRotate=v,this._mousePitch=A}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class TF{constructor(m,v,A,D){this._el=m,this._touchZoom=v,this._touchRotate=A,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 f2=M=>M.zoom||M.drag||M.pitch||M.rotate;class AF extends i.C{}class EF{constructor(){this.constants=[1,1,.01],this.radius=0}setup(m,v){const A=i.ax([],v,m);this.radius=i.ai(A[2]<0?i.eR([],A,this.constants):[A[0],A[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 A=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,A),v),2));v[0]=z[0],v[1]=z[1]}return v}}function x2(M){return M.panDelta&&M.panDelta.mag()||M.zoomDelta||M.bearingDelta||M.pitchDelta}class PF{constructor(m,v){this._map=m,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new SF(m),this._bearingSnap=v.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new EF,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(v),i.aZ(["handleEvent","handleWindowEvent"],this);const A=this._el;this._listeners=[[A,"touchstart",{passive:!0}],[A,"touchmove",{passive:!1}],[A,"touchend",void 0],[A,"touchcancel",void 0],[A,"mousedown",void 0],[A,"mousemove",void 0],[A,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[A,"mouseover",void 0],[A,"mouseout",void 0],[A,"dblclick",void 0],[A,"click",void 0],[A,"keydown",{capture:!1}],[A,"keyup",void 0],[A,"wheel",{passive:!1}],[A,"contextmenu",void 0],[window,"blur",void 0]];for(const[D,z,B]of this._listeners){const W=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(z,W,B)}}destroy(){for(const[m,v,A]of this._listeners){const D=m===document?this.handleWindowEvent:this.handleEvent;m.removeEventListener(v,D,A)}}_addDefaultHandlers(m){const v=this._map,A=v.getCanvasContainer();this._add("mapEvent",new EP(v,m));const D=v.boxZoom=new IP(v,m);this._add("boxZoom",D);const z=new Q1,B=new C3;v.doubleClickZoom=new S3(B,z),this._add("tapZoom",z),this._add("clickZoom",B);const W=new CF;this._add("tapDragZoom",W);const ee=v.touchPitch=new FP(v);this._add("touchPitch",ee);const ne=new w3(m),de=new h2(m);v.dragRotate=new MF(m,ne,de),this._add("mouseRotate",ne,["mousePitch"]),this._add("mousePitch",de,["mouseRotate"]);const be=new Hm(m),ye=new RP(v,m);v.dragPan=new qP(A,be,ye),this._add("mousePan",be),this._add("touchPan",ye,["touchZoom","touchRotate"]);const Ce=new X0,Be=new OP;v.touchZoomRotate=new TF(A,Be,Ce,W),this._add("touchRotate",Ce,["touchPan","touchZoom"]),this._add("touchZoom",Be,["touchPan","touchRotate"]),this._add("blockableMapEvent",new PP(v));const Ie=v.scrollZoom=new k3(v,this);this._add("scrollZoom",Ie,["mousePan"]);const st=v.keyboard=new Q0;this._add("keyboard",st);for(const tt of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])m.interactive&&m[tt]&&v[tt].enable(m[tt])}_add(m,v,A){this._handlers.push({handlerName:m,handler:v,allowed:A}),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!!f2(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(m,v,A){for(const D in m)if(D!==A&&(!v||v.indexOf(D)<0))return!0;return!1}handleWindowEvent(m){this.handleEvent(m,`${m.type}Window`)}_getMapTouches(m){const v=[];for(const A of m)this._el.contains(A.target)&&v.push(A);return v}handleEvent(m,v){this._updatingCamera=!0;const A=m.type==="renderFrame",D=A?void 0:m,z={needsRenderFrame:!1},B={},W={},ee=m.touches?this._getMapTouches(m.touches):void 0,ne=ee?$(this._el,ee):A?void 0:q(this._el,m);for(const{handlerName:ye,handler:Ce,allowed:Be}of this._handlers){if(!Ce.isEnabled())continue;let Ie;this._blockedByActive(W,Be,ye)?Ce.reset():Ce[v||m.type]&&(Ie=Ce[v||m.type](m,ne,ee),this.mergeHandlerResult(z,B,Ie,ye,D),Ie&&Ie.needsRenderFrame&&this._triggerRenderFrame()),(Ie||Ce.isActive())&&(W[ye]=Ce)}const de={};for(const ye in this._previousActiveHandlers)W[ye]||(de[ye]=D);this._previousActiveHandlers=W,(Object.keys(de).length||x2(z))&&(this._changes.push([z,B,de]),this._triggerRenderFrame()),(Object.keys(W).length||x2(z))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:be}=z;be&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],be(this._map))}mergeHandlerResult(m,v,A,D,z){if(!A)return;Object.assign(m,A);const B={handlerName:D,originalEvent:A.originalEvent||z};A.zoomDelta!==void 0&&(v.zoom=B),A.panDelta!==void 0&&(v.drag=B),A.pitchDelta!==void 0&&(v.pitch=B),A.bearingDelta!==void 0&&(v.rotate=B)}_applyChanges(){const m={},v={},A={};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(A,B);this._updateMapTransform(m,v,A),this._changes=[]}_updateMapTransform(m,v,A){const D=this._map,z=D.transform,B=ct=>[ct.x,ct.y,ct.z];if((()=>{const ct=this._eventsInProgress.drag;return ct&&!this._handlersById[ct.handlerName].isActive()})()&&!x2(m)){const ct=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"),ct!==z.zoom&&this._map._update(!0)}if(z._isCameraConstrained&&D._stop(!0),!x2(m))return void this._fireEvents(v,A,!0);let{panDelta:W,zoomDelta:ee,bearingDelta:ne,pitchDelta:de,around:be,aroundCoord:ye,pinchAround:Ce}=m;z._isCameraConstrained&&(ee>0&&(ee=0),z._isCameraConstrained=!1),Ce!==void 0&&(be=Ce),(ee||(ct=>v[ct]&&!this._eventsInProgress[ct])("drag"))&&be&&(this._dragOrigin=B(z.pointCoordinate3D(be)),this._originalZoom=z.zoom,this._trackingEllipsoid.setup(z._camera.position,this._dragOrigin)),z.cameraElevationReference="sea",D._stop(!0),be=be||D.transform.centerPoint,ne&&(z.bearing+=ne),de&&(z.pitch+=de),z._updateCameraState();const Be=[0,0,0];if(W)if(z.projection.name==="mercator"){const ct=this._trackingEllipsoid.projectRay(z.screenPointToMercatorRay(be).dir),mt=this._trackingEllipsoid.projectRay(z.screenPointToMercatorRay(be.sub(W)).dir);Be[0]=mt[0]-ct[0],Be[1]=mt[1]-ct[1]}else{const ct=z.pointCoordinate(be);if(z.projection.name==="globe"){W=W.rotate(-z.angle);const mt=z._pixelsPerMercatorPixel/z.worldSize;Be[0]=-W.x*i.eQ(i.bV(ct.y))*mt,Be[1]=-W.y*i.eQ(z.center.lat)*mt}else{const mt=z.pointCoordinate(be.sub(W));ct&&mt&&(Be[0]=mt.x-ct.x,Be[1]=mt.y-ct.y)}}const Ie=z.zoom,st=[0,0,0];if(ee){const ct=B(ye||z.pointCoordinate3D(be)),mt={dir:i.ay([],i.ax([],ct,z._camera.position))};if(mt.dir[2]<0){const nt=z.zoomDeltaToMovement(ct,ee);i.bJ(st,mt.dir,nt)}}const tt=i.cT(Be,Be,st);z._translateCameraConstrained(tt),ee&&Math.abs(z.zoom-Ie)>1e-4&&z.recenterOnTerrain(),z.cameraElevationReference="ground",this._map._update(),m.noInertia||this._inertia.record(m),this._fireEvents(v,A,!0)}_fireEvents(m,v,A){const D=f2(this._eventsInProgress),z=f2(m),B={};for(const de in m){const{originalEvent:be}=m[de];this._eventsInProgress[de]||(B[`${de}start`]=be),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:be}=m[de];this._fireEvent(de,be)}const W={};let ee;for(const de in this._eventsInProgress){const{handlerName:be,originalEvent:ye}=this._eventsInProgress[de];this._handlersById[be].isActive()||(delete this._eventsInProgress[de],ee=v[be]||ye,W[`${de}end`]=ee)}for(const de in W)this._fireEvent(de,W[de]);const ne=f2(this._eventsInProgress);if(A&&(D||z)&&!ne){this._updatingCamera=!0;const de=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),be=ye=>ye!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new AF("renderFrame",{timeStamp:m})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const UP="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class IF 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,A){return m=i.P.convert(m).mult(-1),this.panTo(this.transform.center,Object.assign({offset:m},v),A)}panTo(m,v,A){return this.easeTo(Object.assign({center:m},v),A)}getZoom(){return this.transform.zoom}setZoom(m,v){return this.jumpTo({zoom:m},v),this}zoomTo(m,v,A){return this.easeTo(Object.assign({zoom:m},v),A)}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,A){return this.easeTo(Object.assign({bearing:m},v),A)}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?A/(2*Math.tan(.5*m.fovX)*m.aspect):D/(2*Math.tan(.5*m.fovY)*m.aspect)}_cameraForBoundsOnGlobe(m,v,A,D,z,B){const W=m.clone(),ee=this._extendCameraOptions(B);W.bearing=D,W.pitch=z;const ne=i.aU.convert(v),de=i.aU.convert(A),be=.5*(ne.lat+de.lat),ye=.5*(ne.lng+de.lng),Ce=i.eT(be,ye),Be=i.ay([],Ce),Ie=i.ay([],i.bh([],Be,[0,1,0])),st=i.bh([],Ie,Be),tt=[Ie[0],Ie[1],Ie[2],0,st[0],st[1],st[2],0,Be[0],Be[1],Be[2],0,0,0,0,1],ct=[Ce,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(be,ne.lng),i.eT(be,de.lng),i.eT(ne.lat,ye),i.eT(de.lat,ye)];let mt=i.cU.fromPoints(ct.map(as=>[i.bi(Ie,as),i.bi(st,as),i.bi(Be,as)]));const nt=i.ah([],mt.center,tt);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 Ft=W.getWorldToCameraMatrix(),wt=i.b7(new Float64Array(16),Ft);mt=i.cU.applyTransform(mt,i.aD([],Ft,tt));const Dt=this._extendAABB(mt,W,ee,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,Ft);const pt=.5*(mt.max[2]-mt.min[2]),yt=this._minimumAABBFrustumDistance(W,mt),Tt=i.bJ([],[0,0,1],pt),Wt=i.cT(Tt,nt,Tt),Bt=yt+(W.pitch===0?0:i.bf(nt,Wt)),ns=W.globeCenterInViewSpace,Qt=i.ax([],nt,[ns[0],ns[1],ns[2]]);i.ay(Qt,Qt),i.bJ(Qt,Qt,Bt);const ws=i.cT([],nt,Qt);i.ah(ws,ws,wt);const As=i.eD/i.aF,Zt=i.ai(ws),Ut=i.bU(Math.max(Zt*As-i.eD,Number.EPSILON),0),ts=Math.min(W.zoomFromMercatorZAdjusted(Ut),ee.maxZoom);return ts>.5*(i.cJ+i.cv)?(W.setProjection({name:"mercator"}),W.zoom=ts,this._cameraForBounds(W,v,A,D,z,B)):{center:W.center,zoom:ts,bearing:D,pitch:z}}_extendAABB(m,v,A,D){const z=.5*((A.padding.left||0)+(A.padding.right||0)),B=.5*((A.padding.top||0)+(A.padding.bottom||0)),W=B,ee=z,ne=z,de=B,be=v.width-(ee+ne),ye=v.height-(W+de),Ce=i.ax([],m.max,m.min),Be=Math.min(be/Ce[0],ye/Ce[1]),Ie=Math.min(v.scaleZoom(v.scale*Be),A.maxZoom);if(isNaN(Ie))return null;const st=v.scale/v.zoomScale(Ie),tt=new i.cU([m.min[0]-ee*st,m.min[1]-de*st,m.min[2]],[m.max[0]+ne*st,m.max[1]+W*st,m.max[2]]),ct=(typeof A.offset.x=="number"&&typeof A.offset.y=="number"?new i.P(A.offset.x,A.offset.y):i.P.convert(A.offset)).rotate(-i.ap(D));return tt.center[0]-=ct.x*st,tt.center[1]+=ct.y*st,tt}queryTerrainElevation(m,v){const A=this.transform.elevation;return A?(v=Object.assign({},{exaggerated:!0},v),A.getAtPoint(i.ag.fromLngLat(m),null,v.exaggerated)):null}_cameraForBounds(m,v,A,D,z,B){if(m.projection.name==="globe")return this._cameraForBoundsOnGlobe(m,v,A,D,z,B);const W=m.clone(),ee=this._extendCameraOptions(B);W.bearing=D,W.pitch=z;const ne=i.aU.convert(v),de=i.aU.convert(A),be=new i.aU(ne.lng,de.lat),ye=new i.aU(de.lng,ne.lat),Ce=W.project(ne),Be=W.project(de),Ie=this.queryTerrainElevation(ne),st=this.queryTerrainElevation(de),tt=this.queryTerrainElevation(be),ct=this.queryTerrainElevation(ye),mt=[[Ce.x,Ce.y,Math.min(Ie||0,st||0,tt||0,ct||0)],[Be.x,Be.y,Math.max(Ie||0,st||0,tt||0,ct||0)]];let nt=i.cU.fromPoints(mt);const Ft=W.getWorldToCameraMatrix(),wt=i.b7(new Float64Array(16),Ft);nt=i.cU.applyTransform(nt,Ft);const Dt=this._extendAABB(nt,W,ee,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],yt=this._minimumAABBFrustumDistance(W,nt),Tt=[0,0,1,0];i.aE(Tt,Tt,Ft),i.eX(Tt,Tt);const Wt=i.bJ([],Tt,yt+pt),Bt=i.cT([],nt.center,Wt);i.ah(nt.center,nt.center,wt),i.ah(Bt,Bt,wt);const ns=W.unproject(new i.P(nt.center[0],nt.center[1])),Qt=i.eY(W.projection,ns),ws=Math.pow(2,Qt),As=Math.min(W._zoomFromMercatorZ(Bt[2]*W.pixelsPerMeter*ws/W.worldSize),ee.maxZoom);return W.mercatorFromTransition&&As<.5*(i.cJ+i.cv)?(W.setProjection({name:"globe"}),W.zoom=As,this._cameraForBounds(W,v,A,D,z,B)):{center:ns,zoom:As,bearing:D,pitch:z}}fitBounds(m,v,A){const D=this.cameraForBounds(m,v);return this._fitInternal(D,v,A)}fitScreenCoordinates(m,v,A,D,z){const B=i.P.convert(m),W=i.P.convert(v),ee=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(ee),be=this.transform.pointLocation3D(ne),ye=this.transform.pointLocation3D(new i.P(ee.x,ne.y)),Ce=this.transform.pointLocation3D(new i.P(ne.x,ee.y)),Be=[Math.min(de.lng,be.lng,ye.lng,Ce.lng),Math.min(de.lat,be.lat,ye.lat,Ce.lat)],Ie=[Math.max(de.lng,be.lng,ye.lng,Ce.lng),Math.max(de.lat,be.lat,ye.lat,Ce.lat)],st=D&&D.pitch?D.pitch:this.getPitch(),tt=this._cameraForBounds(this.transform,Be,Ie,A,st,D);return this._fitInternal(tt,D,z)}_fitInternal(m,v,A){return m?(v=Object.assign(m,v)).linear?this.easeTo(v,A):this.flyTo(v,A):this}jumpTo(m,v){this.stop();const A=m.preloadOnly?this.transform.clone():this.transform;let D=!1,z=!1,B=!1;"zoom"in m&&A.zoom!==+m.zoom&&(D=!0,A.zoom=+m.zoom),m.center!==void 0&&(A.center=i.aU.convert(m.center)),"bearing"in m&&A.bearing!==+m.bearing&&(z=!0,A.bearing=+m.bearing),"pitch"in m&&A.pitch!==+m.pitch&&(B=!0,A.pitch=+m.pitch);const W=typeof m.padding=="number"?this._extendPadding(m.padding):m.padding;if(m.padding!=null&&!A.isPaddingEqual(W))if(m.retainPadding===!1){const ee=A.clone();ee.padding=W,A.setLocationAtPoint(A.center,ee.centerPoint)}else A.padding=W;return m.preloadOnly?(this._preloadTiles(A),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(UP),this.transform.getFreeCameraOptions()}setFreeCameraOptions(m,v){const A=this.transform;if(!A.projection.supportsFreeCamera)return i.w(UP),this;this.stop();const D=A.zoom,z=A.pitch,B=A.bearing;A.setFreeCameraOptions(m);const W=D!==A.zoom,ee=z!==A.pitch,ne=B!==A.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)),ee&&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 A=this.transform,D=this.getZoom(),z=this.getBearing(),B=this.getPitch(),W=this.getPadding(),ee="zoom"in m?+m.zoom:D,ne="bearing"in m?this._normalizeBearing(m.bearing,z):z,de="pitch"in m?+m.pitch:B,be=this._extendPadding(m.padding),ye=i.P.convert(m.offset);let Ce,Be,Ie;if(A.projection.name==="globe"){const Tt=i.ag.fromLngLat(A.center),Wt=ye.rotate(-A.angle);Tt.x+=Wt.x/A.worldSize,Tt.y+=Wt.y/A.worldSize;const Bt=Tt.toLngLat(),ns=i.aU.convert(m.center||Bt);this._normalizeCenter(ns),Ce=A.centerPoint.add(Wt),Be=new i.P(Tt.x,Tt.y).mult(A.worldSize),Ie=new i.P(i.aH(ns.lng),i.aL(ns.lat)).mult(A.worldSize).sub(Be)}else{Ce=A.centerPoint.add(ye);const Tt=A.pointLocation(Ce),Wt=i.aU.convert(m.center||Tt);this._normalizeCenter(Wt),Be=A.project(Tt),Ie=A.project(Wt).sub(Be)}const st=A.zoomScale(ee-D);let tt,ct;m.around&&(tt=i.aU.convert(m.around),ct=A.locationPoint(tt));const mt=this._zooming||ee!==D,nt=this._rotating||z!==ne,Ft=this._pitching||de!==B,wt=!A.isPaddingEqual(be),Dt=m.retainPadding===!1?A.clone():A,pt=Tt=>Wt=>{if(mt&&(Tt.zoom=i.am(D,ee,Wt)),nt&&(Tt.bearing=i.am(z,ne,Wt)),Ft&&(Tt.pitch=i.am(B,de,Wt)),wt&&(Dt.interpolatePadding(W,be,Wt),Ce=Dt.centerPoint.add(ye)),tt)Tt.setLocationAtPoint(tt,ct);else{const Bt=Tt.zoomScale(Tt.zoom-D),ns=ee>D?Math.min(2,st):Math.max(.5,st),Qt=Math.pow(ns,1-Wt),ws=Tt.unproject(Be.add(Ie.mult(Wt*Qt)).mult(Bt));Tt.setLocationAtPoint(Tt.renderWorldCopies?ws.wrap():ws,Ce)}return m.preloadOnly||this._fireMoveEvents(v),Tt};if(m.preloadOnly){const Tt=this._emulate(pt,m.duration,A);return this._preloadTiles(Tt),this}const yt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=mt,this._rotating=nt,this._pitching=Ft,this._padding=wt,this._easeId=m.easeId,this._prepareEase(v,m.noMoveStart,yt),this._ease(pt(A),Tt=>{A.cameraElevationReference==="sea"&&A.recenterOnTerrain(),this._afterEase(v,Tt)},m),this}_prepareEase(m,v,A={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),v||A.moving||this.fire(new i.C("movestart",m)),this._zooming&&!A.zooming&&this.fire(new i.C("zoomstart",m)),this._rotating&&!A.rotating&&this.fire(new i.C("rotatestart",m)),this._pitching&&!A.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 A=this._zooming,D=this._rotating,z=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,A&&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 A=this.transform,D=this.getZoom(),z=this.getBearing(),B=this.getPitch(),W=this.getPadding(),ee="zoom"in m?i.aC(+m.zoom,A.minZoom,A.maxZoom):D,ne="bearing"in m?this._normalizeBearing(m.bearing,z):z,de="pitch"in m?+m.pitch:B,be=this._extendPadding(m.padding),ye=A.zoomScale(ee-D),Ce=i.P.convert(m.offset);let Be=A.centerPoint.add(Ce);const Ie=A.pointLocation(Be),st=i.aU.convert(m.center||Ie);this._normalizeCenter(st);const tt=A.project(Ie),ct=A.project(st).sub(tt);let mt=m.curve;const nt=Math.max(A.width,A.height),Ft=nt/ye,wt=ct.mag();if("minZoom"in m){const as=i.aC(Math.min(m.minZoom,D,ee),A.minZoom,A.maxZoom),cs=nt/A.zoomScale(as-D);mt=Math.sqrt(cs/wt*2)}const Dt=mt*mt;function pt(as){const cs=(Ft*Ft-nt*nt+(as?-1:1)*Dt*Dt*wt*wt)/(2*(as?Ft:nt)*Dt*wt);return Math.log(Math.sqrt(cs*cs+1)-cs)}function yt(as){return(Math.exp(as)-Math.exp(-as))/2}function Tt(as){return(Math.exp(as)+Math.exp(-as))/2}const Wt=pt(0);let Bt=function(as){return Tt(Wt)/Tt(Wt+mt*as)},ns=function(as){return nt*((Tt(Wt)*(yt(cs=Wt+mt*as)/Tt(cs))-yt(Wt))/Dt)/wt;var cs},Qt=(pt(1)-Wt)/mt;if(Math.abs(wt)<1e-6||!isFinite(Qt)){if(Math.abs(nt-Ft)<1e-6)return this.easeTo(m,v);const as=Ftm.maxDuration&&(m.duration=0);const ws=z!==ne,As=de!==B,Zt=!A.isPaddingEqual(be),Ut=m.retainPadding===!1?A.clone():A,ts=as=>cs=>{const Qs=cs*Qt,Hs=1/Bt(Qs);as.zoom=cs===1?ee:D+as.scaleZoom(Hs),ws&&(as.bearing=i.am(z,ne,cs)),As&&(as.pitch=i.am(B,de,cs)),Zt&&(Ut.interpolatePadding(W,be,cs),Be=Ut.centerPoint.add(Ce));const Gs=cs===1?st:as.unproject(tt.add(ct.mult(ns(Qs))).mult(Hs));return as.setLocationAtPoint(as.renderWorldCopies?Gs.wrap():Gs,Be),as._updateCameraOnTerrain(),m.preloadOnly||this._fireMoveEvents(v),as};if(m.preloadOnly){const as=this._emulate(ts,m.duration,A);return this._preloadTiles(as),this}return this._zooming=!0,this._rotating=ws,this._pitching=As,this._padding=Zt,this._prepareEase(v,!1),this._ease(ts(A),()=>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 A=this._onEaseEnd;this._onEaseEnd=void 0,A.call(this,v)}if(!m){const A=this.handlers;A&&A.stop(!1)}return this}_ease(m,v,A){A.animate===!1||A.duration===0?(m(1),v()):(this._easeStart=i.o.now(),this._easeOptions=A,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 A=Math.abs(m-v);return Math.abs(m-360-v)180?-360:A<-180?360:0}_prefersReducedMotion(m){return this._respectPrefersReducedMotion&&i.o.prefersReducedMotion&&!(m&&m.essential)}_emulate(m,v,A){const D=Math.ceil(15*v/1e3),z=[],B=m(A.clone());for(let W=0;W<=D;W++){const ee=B(W/D);z.push(ee.clone())}return z}_preloadTiles(m,v){}}class VP{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,A=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",A);const D=N("span","mapboxgl-ctrl-icon",this._compactButton);return D.setAttribute("aria-hidden","true"),D.setAttribute("title",A),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 A=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 A=m.map(D=>function(z){const B=new DOMParser().parseFromString(z,"text/html");return Array.from(B.body.querySelectorAll("*")).reverse().forEach(W=>{const ee=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(ee));const de=B.createElement("a");de.href=ne,de.textContent=ee,de.rel="noopener nofollow";const be=W.getAttribute("class");be&&(de.className=be),W.replaceWith(de)}),B.body.innerHTML}(D)).join(" | ");A!==this._attribHTML&&(this._attribHTML=A,m.length?(this._innerContainer.innerHTML=A,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class HP{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 A=m[v].getSource();if(A.hasOwnProperty("mapbox_logo")&&!A.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 LF{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,A=v?this._queue.concat(v):this._queue;for(const D of A)if(D.id===m)return void(D.cancelled=!0)}run(m=0){const v=this._currentlyRunning=this._queue;this._queue=[];for(const A of v)if(!A.cancelled&&(A.callback(m),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class Ape{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,A){this._start=this.getValue(v),this._end=m,this._startTime=v,this._endTime=v+A}}const Epe={"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 bi extends i.C{constructor(m,v,A,D){const{point:z,lngLat:B,originalEvent:W,target:ee}=m;super(m.type,{point:z,lngLat:B,originalEvent:W,target:ee}),this.preventDefault=()=>{m.preventDefault()},this.id=v,this.interaction=A,this.feature=D}}class M3{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 A=v.filter;let D=v.type;A&&this.filters.set(m,i.dg(A)),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 A=this.interactionsByType.get(v);return A?A.get(m):void 0}remove(m){const v=this.typeById.get(m);if(!v)return;this.typeById.delete(m),this.filters.delete(m);const A=this.interactionsByType.get(v);A&&(A.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))):A.size===0&&this.map.off(v,this.handleType))}queryTargets(m,v){const A=[];for(const[D,z]of v)z.target&&A.push({targetId:D,target:z.target,filter:this.filters.get(D)});return this.map.style.queryRenderedTargets(m,A,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 A=new Map;for(const[D,{feature:z}]of this.prevHoveredFeatures)this.hoveredFeatures.has(D)||A.set(z.id,z);A.size&&(m.type="mouseleave",this.handleType(m,Array.from(A.values())))}handleOut(m){const v=Array.from(this.hoveredFeatures.values()).map(({feature:A})=>A);v.length&&(m.type="mouseleave",this.handleType(m,v)),this.hoveredFeatures.clear()}handleType(m,v){const A=m.type==="mouseenter";if(A&&!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 ee of v){for(const[ne,de]of D){if(!de.target)continue;const be=ee.variants?ee.variants[ne]:null;if(be){for(const ye of be){if(Kh(ye,ee,W,ne))continue;const Ce=new i.di(ee,ye),Be=Mw(ye,ee,ne);z&&Ce.id!==void 0&&(Ce.state=this.map.getFeatureState(Ce));const Ie=A?this.prevHoveredFeatures.get(Be):null,st=new bi(m,ne,de,Ce),tt=Ie?Ie.stop:de.handler(st);if(A&&this.hoveredFeatures.set(Be,{feature:ee,stop:tt}),tt!==!1){B=!0;break}}if(B)break}}if(B)break}if(!B)for(const[ee,ne]of D){const{handler:de,target:be}=ne;if(!be&&de(new bi(m,ee,ne,null))!==!1)break}}}function Ppe(M,m){if(Array.isArray(M)&&Array.isArray(m)){const v=new Set(M),A=new Set(m);return v.size===A.size&&M.every(D=>A.has(D))}return i.b6(M,m)}const Ipe={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},Lpe={showCompass:!0,showZoom:!0,visualizePitch:!1};class g2{constructor(m,v,A=!1){this._clickTolerance=10,this.element=v,this.mouseRotate=new w3({clickTolerance:m.dragRotate._mouseRotate._clickTolerance}),this.map=m,A&&(this.mousePitch=new h2({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),L()}move(m,v){const A=this.map,D=this.mouseRotate.mousemoveWindow(m,v),z=D&&D.bearingDelta;if(z&&A.setBearing(A.getBearing()+z),this.mousePitch){const B=this.mousePitch.mousemoveWindow(m,v),W=B&&B.pitchDelta;W&&A.setPitch(A.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(){I(),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(A).distSqr(m)180;){const A=v.locationPoint3D(M);if(A.x>=0&&A.y>=0&&A.x<=v.width&&A.y<=v.height)break;M.lng>v.center.lng?M.lng-=360:M.lng+=360}return M}const y2={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%)"},em={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Gm 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:A="center",color:D="#3FB1CE",scale:z=1,draggable:B=!1,clickTolerance:W=0,rotation:ee=em.rotation,rotationAlignment:ne=em.rotationAlignment,pitchAlignment:de=em.pitchAlignment,occludedOpacity:be=em.occludedOpacity,altitude:ye=em.altitude}=m||{};this._anchor=A,this._color=D,this._scale=z,this._draggable=B,this._clickTolerance=W,this._rotation=ee,this._rotationAlignment=ne,this._pitchAlignment=de,this._occludedOpacity=be,this._altitude=ye,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",Ie=>{Ie.preventDefault()}),this._element.addEventListener("mousedown",Ie=>{Ie.preventDefault()});const Ce=this._element.classList;for(const Ie in y2)Ce.remove(`mapboxgl-marker-anchor-${Ie}`);Ce.add(`mapboxgl-marker-anchor-${this._anchor}`);const Be=m&&m.className?m.className.trim().split(/\s+/):[];Ce.add(...Be),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 A=w("radialGradient",{id:"shadowGradient"},w("defs",{},v));w("stop",{offset:"10%","stop-opacity":.4},A),w("stop",{offset:"100%","stop-opacity":.05},A),w("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},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||em.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,A=m.charCode||m.keyCode;v!=="Space"&&v!=="Enter"&&A!==32&&A!==13||this.togglePopup()}_onMapClick(m){const v=m.originalEvent.target,A=this._element;this._popup&&(v===A||A.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 A=m.unproject(v,this._altitude),D=m.getFreeCameraOptions();if(!D.position)return!1;const z=D.position.toLngLat();return z.distanceTo(A)<.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 A=m.unproject(v,this._altitude);let D;m._showingGlobe()&&i.e$(m.transform,this._lngLat)?D=0:(D=1-m._queryFogOpacity(A),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) ${y2[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${v.x}px,${v.y}px) `}_calculateXYTransform(){const m=this._pos,v=this._map,A=this.getPitchAlignment();if(!v||!m||A!=="map")return"";if(!v._showingGlobe()){const ee=v.getPitch();return ee?`rotateX(${ee}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 A=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);A=i.cH(Math.atan2(B.y,B.x))-90}else A=-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),ee=i.cH(Math.atan2(W.y,W.x));A=(ee>90?ee-270:ee+90)*(1-z)}return A+=this._rotation,A?`rotateZ(${A}deg)`:""}_update(m){cancelAnimationFrame(this._updateFrameId);const v=this._map;v&&(v.transform.renderWorldCopies&&(this._lngLat=GP(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 A=this._pointerdownPos,D=this._positionDelta;if(A&&D){if(!this._isDragging){const z=this._clickTolerance||v._clickTolerance;if(m.point.dist(A)M.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(M.minPitch!=null&&M.maxPitch!=null&&M.minPitch>M.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(M.minPitch!=null&&M.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(M.maxPitch!=null&&M.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");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 Fw(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 LF,this._domRenderTaskQueue=new LF,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.r(),this._locale=Object.assign({},Epe,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 Ape(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=M.scaleFactor,this._requestManager=new X(M.transformRequest,M.accessToken,M.testMode);const v=pe(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 A=document.getElementById(M.container);if(!A)throw new Error(`Container '${M.container.toString()}' not found.`);this._container=A}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 PF(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 Mpe(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 A=M.bounds;A&&(this.resize(),this.fitBounds(A,Object.assign({},M.fitBoundsOptions,{duration:0})))}this.resize(),M.attributionControl&&this.addControl(new VP({customAttribution:M.customAttribution})),this._logoControl=new HP,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",A=>{this._update(A.dataType==="style"),this.fire(new i.C(`${A.dataType}data`,A))}),this.on("dataloading",A=>{this.fire(new i.C(`${A.dataType}dataloading`,A))}),this._interactions=new M3(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 A=this._controlPositions[m];return m.indexOf("bottom")!==-1?A.insertBefore(v,A.firstChild):A.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 A=this.transform.getProjection().name==="mercator"&&v!==this.transform.mercatorFromTransition;return(m||A)&&(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 A=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=A(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=>{A(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=A(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 A=this._createDelegatedListener(M,m,v);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[M]=this._delegatedListeners[M]||[],this._delegatedListeners[M].push(A);for(const D in A.delegates)this.on(D,A.delegates[D]);return this}once(M,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 A=this._createDelegatedListener(M,m,v);for(const D in A.delegates)this.once(D,A.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 A=this._delegatedListeners?this._delegatedListeners[M]:void 0;return A&&(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 A&&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 Um(this,v).load(M),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Um(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:A=!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:ee,height:ne,data:de}=i.o.getImageData(m);this.style.addImage(W,{data:new i.q({width:ee,height:ne},de),pixelRatio:v,stretchX:D,stretchY:z,content:B,sdf:A,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:ee,height:ne}=m,de=m;this.style.addImage(W,{data:new i.q({width:ee,height:ne},new Uint8Array(de.data)),pixelRatio:v,stretchX:D,stretchY:z,content:B,sdf:A,usvg:!1,version:0,userImage:de}),de.onAdd&&de.onAdd(this,M)}}updateImage(M,m){this._lazyInitEmptyStyle();const v=i.I.from(M),A=this.style.getImage(v);if(!A)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!==(A.usvg?A.icon.usvg_tree.width:A.data.width)||B!==(A.usvg?A.icon.usvg_tree.height:A.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 (${A.data.width}, ${A.data.height})`)));const ee=!(m instanceof HTMLImageElement||ImageBitmap&&m instanceof ImageBitmap);let ne=!1;A.usvg?(A.data=new i.q({width:z,height:B},new Uint8Array(W)),A.usvg=!1,A.icon=void 0,ne=!0):A.data.replace(W,ee),this.style.updateImage(v,A,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,A)=>{m(v,A)})}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,A={}){return this._isValidId(M)?(this.style.setPaintProperty(M,m,v,A),this._update(!0)):this}getPaintProperty(M,m){return this._isValidId(M)?this.style.getPaintProperty(M,m):null}setLayoutProperty(M,m,v,A={}){return this._isValidId(M)?(this.style.setLayoutProperty(M,m,v,A),this._update(!0)):this}getLayoutProperty(M,m){return this._isValidId(M)?this.style.getLayoutProperty(M,m):null}setLayerProperty(M,m,v,A={}){return this._isValidId(M)?(m==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(M,m,v,A),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(M){return this.style.setGlyphsUrl(M),this._update(!0)}getSchema(M){return this.style.getSchema(M)}setSchema(M,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,A,D,z=this._container;for(;z&&(!A||!D);){const B=window.getComputedStyle(z).transform;B&&B!=="none"&&(v=B.match(/matrix.*\((.+)\)/)[1].split(", "),v[0]&&v[0]!=="0"&&v[0]!=="1"&&(A=v[0]),v[3]&&v[3]!=="0"&&v[3]!=="1"&&(D=v[3])),z=z.parentElement}this._containerWidth=A?Math.abs(M/A):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),A=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(D=>{A[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?(Ae(m,!0),this.painter=new Cpe(m,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",v=>{if(v.dataType==="source"){const A=this.transform.elevation?this.transform.elevation._source():null;A&&v.sourceCacheId===A.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,A=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 ee=this.transform.zoom,ne=this.transform.pitch,de=i.o.now(),be=new i.ae(ee,{now:de,fadeDuration:z,pitch:ne,transition:this.style.transition,worldview:this._worldview});this.style.update(be)}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(A),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):B=this._updateAverageElevation(A),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 ee=i.o.now()-A;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:ee,gpuTime:ne}))},50)}if(this.listens("gpu-timing-layer")){const ee=this.painter.collectGpuTimers();setTimeout(()=>{const ne=this.painter.queryGpuTimers(ee);this.fire(new i.C("gpu-timing-layer",{layerTimes:ne}))},50)}if(this.listens("gpu-timing-deferred-render")){const ee=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const ne=this.painter.queryGpuTimeDeferredRender(ee);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 ee=this.idle();if(ee&&(B=this._updateAverageElevation(A,!0)),B)this.triggerRepaint();else if(this._triggerFrame(!1),ee&&(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&&fe(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 A=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(A||(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||A)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;Ae(M,!1),this._logoControl instanceof HP&&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(){Je(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,M=>{M&&(M.message!==J&&M.status!==401||this._revokeAuth())}),this._isTokenExpired()&&this._revokeAuth(),Me(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Le(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&qe(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){ve(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,A=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,A),this._canvasPixelComparison(D(M),m.canvasCopies.map(D),m.timeStamps)}_canvasPixelComparison(M,m,v){let A=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,A)=>v._preloadTiles(M,A),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(M){this._trackResize&&this.resize({originalEvent:M})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(M){this._showTileBoundaries!==M&&(this._showTileBoundaries=M,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(M){this._showParseStatus!==M&&(this._showParseStatus=M,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(M){this._showTerrainWireframe!==M&&(this._showTerrainWireframe=M,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(M){this._showLayers2DWireframe!==M&&(this._showLayers2DWireframe=M,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(M){this._showLayers3DWireframe!==M&&(this._showLayers3DWireframe=M,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(M){this._speedIndexTiming!==M&&(this._speedIndexTiming=M,this._update())}get showPadding(){return!!this._showPadding}set showPadding(M){this._showPadding!==M&&(this._showPadding=M,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(M){this._showCollisionBoxes!==M&&(this._showCollisionBoxes=M,this.style&&M?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(M){this._showOverdrawInspector!==M&&(this._showOverdrawInspector=M,this._update())}get repaint(){return!!this._repaint}set repaint(M){this._repaint!==M&&(this._repaint=M,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(M){this._vertices=M,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(M){this._showTileAABBs!==M&&(this._showTileAABBs=M,M&&this._update())}_setCacheLimits(M,m){i.e_(M,m)}get version(){return d}},NavigationControl:class{constructor(M={}){this.options=Object.assign({},Lpe,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(),A=m===M.getMinZoom();this._zoomInButton.disabled=v,this._zoomOutButton.disabled=A,this._zoomInButton.setAttribute("aria-disabled",v.toString()),this._zoomOutButton.setAttribute("aria-disabled",A.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 g2(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},v2,M),i.aZ(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=TP(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,A=this._map.getBearing(),D=Object.assign({bearing:A},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 Gm({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=N("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Gm({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??v2.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:VP,ScaleControl:class{constructor(M={}){this.options=Object.assign({},vl,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,A=m._containerWidth/2-M/2,D=m.unproject([A,v]),z=m.unproject([A+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 A=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(ee){const ne=Math.pow(10,Math.ceil(-Math.log(ee)/Math.LN10));return Math.round(ee*ne)/ne}(W),B*W}(m),D=A/m;this._container.innerHTML=v!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:v}).format(A):`${A} ${Wm[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((A,D)=>A.id!==M.floors[D].id);if(v&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),M.selectedFloorId){if(M.selectedFloorId!==this._lastSelectedFloorId||v){const A=M.floors.findIndex(D=>D.id===M.selectedFloorId);if(A!==-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),AB&&(this._visibleFloorStart=A-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 A=this._visibleFloorStart===0,D=this._visibleFloorStart>=v-3;if(A)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=A?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(),A=M.zIndex.toString(),D=v?Array.from(v).slice(0,3).join(""):A;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(_2),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 A;for(v.innerHTML=M;A=v.firstChild,A;)m.appendChild(A);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,A=this._pos;if(!m||!v||!A)return"bottom";const D=v.offsetWidth,z=v.offsetHeight,B=A.xm.transform.width-D/2;if(A.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 A=this._container;if(A||(A=this._container=N("div","mapboxgl-popup",m.getContainer()),this._tip=N("div","mapboxgl-popup-tip",A),A.appendChild(v)),this.options.maxWidth&&A.style.maxWidth!==this.options.maxWidth&&(A.style.maxWidth=this.options.maxWidth),m.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=GP(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=T3(this.options.offset),B=this._anchor=this._getAnchor(z.y),W=T3(this.options.offset,B),ee=D.add(W).round();m._requestDomTask(()=>{this._container&&B&&(this._container.style.transform=`${y2[B]} translate(${ee.x}px,${ee.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(Dpe);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:Gm,Style:Um,LngLat:i.aU,LngLatBounds:i.aK,Point:i.P,MercatorCoordinate:i.ag,FreeCameraOptions:Rw,Evented:i.E,config:i.g,prewarm:function(){Et().acquire(et)},clearPrewarmedResources:function(){const M=Ke;M&&(M.isPreloaded()&&M.numActive()===1?(M.release(et),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 ht.workerCount},set workerCount(M){ht.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})})(wGe);var pNt=wGe.exports;const xc=so(pNt);function Ns({className:t,...s}){return e.jsx("div",{className:Rt("animate-pulse rounded-md bg-muted",t),...s})}const DPe={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},RPe={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function fNt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function xNt({listings:t,isLoading:s}){const r=_r(),n=S.useRef(null),a=S.useRef(null),o=S.useRef([]),[l,i]=S.useState(""),[d,u]=S.useState(!0);return S.useEffect(()=>{(async()=>{u(!0);try{const{data: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)})()},[]),S.useEffect(()=>{if(!n.current||!l||a.current)return;xc.accessToken=l;const x=t.filter(b=>b.latitude!=null&&b.longitude!=null);let y=[-98.5795,39.8283],_=4;if(x.length>0){const b=x.reduce((w,k)=>w+k.longitude,0)/x.length,N=x.reduce((w,k)=>w+k.latitude,0)/x.length;y=[b,N],_=x.length===1?12:10}return a.current=new xc.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:_,center:y}),a.current.addControl(new xc.NavigationControl,"top-right"),()=>{var b;(b=a.current)==null||b.remove(),a.current=null}},[l]),S.useEffect(()=>{if(!a.current||!l)return;o.current.forEach(y=>y.remove()),o.current=[];const x=t.filter(y=>y.latitude!=null&&y.longitude!=null);if(x.forEach(y=>{var L,I,O;const _=DPe[y.status]||"#10B981",b=((L=y.photos)==null?void 0:L.find(V=>V.is_primary))||((I=y.photos)==null?void 0:I[0]),w=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${y.slug||y.id}`:`/public/listing/${y.slug||y.id}`,k=document.createElement("div");k.className="cursor-pointer",k.innerHTML=`
`;const C=new xc.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${b!=null&&b.photo_url?``:""}
${fNt(y.price)}
${y.property_address||""}
${y.city}, ${y.state}
${RPe[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 →
`),E=new xc.Marker(k).setLngLat([y.longitude,y.latitude]).setPopup(C).addTo(a.current);o.current.push(E)}),x.length>1){const y=new xc.LngLatBounds;x.forEach(_=>y.extend([_.longitude,_.latitude])),a.current.fitBounds(y,{padding:60,maxZoom:13})}else x.length===1&&a.current.flyTo({center:[x[0].longitude,x[0].latitude],zoom:12})},[t,l]),S.useEffect(()=>(window.__navigateToPublicListing__=x=>{r(x)},()=>{delete window.__navigateToPublicListing__}),[r]),d||s?e.jsx(Ns,{className:"w-full h-[500px] rounded-lg"}):!l||t.filter(x=>x.latitude!=null&&x.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(DPe).map(([x,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:RPe[x]})]},x))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function eD(t,[s,r]){return Math.min(r,Math.max(s,t))}function DR(t){const s=S.useRef({value:t,previous:t});return S.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var gNt=[" ","Enter","ArrowUp","ArrowDown"],yNt=[" ","Enter"],US="Select",[bue,wue,vNt]=yR(US),[qA,bTs]=$c(US,[vNt,_0]),jue=_0(),[_Nt,mw]=qA(US),[bNt,wNt]=qA(US),NGe=t=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:o,value:l,defaultValue:i,onValueChange:d,dir:u,name:p,autoComplete:x,disabled:y,required:_,form:b}=t,N=jue(s),[w,k]=S.useState(null),[C,E]=S.useState(null),[L,I]=S.useState(!1),O=uw(u),[V,q]=$u({prop:n,defaultProp:a??!1,onChange:o,caller:US}),[$,U]=$u({prop:l,defaultProp:i,onChange:d,caller:US}),se=S.useRef(null),Y=w?b||!!w.closest("form"):!0,[J,X]=S.useState(new Set),ce=Array.from(J).map(ie=>ie.props.value).join(";");return e.jsx(wR,{...N,children:e.jsxs(_Nt,{required:_,scope:s,trigger:w,onTriggerChange:k,valueNode:C,onValueNodeChange:E,valueNodeHasChildren:L,onValueNodeHasChildrenChange:I,contentId:pu(),value:$,onValueChange:U,open:V,onOpenChange:q,dir:O,triggerPointerDownPosRef:se,disabled:y,children:[e.jsx(bue.Provider,{scope:s,children:e.jsx(bNt,{scope:t.__scopeSelect,onNativeOptionAdd:S.useCallback(ie=>{X(ae=>new Set(ae).add(ie))},[]),onNativeOptionRemove:S.useCallback(ie=>{X(ae=>{const oe=new Set(ae);return oe.delete(ie),oe})},[]),children:r})}),Y?e.jsxs(KGe,{"aria-hidden":!0,required:_,tabIndex:-1,name:p,autoComplete:x,value:$,onChange:ie=>U(ie.target.value),disabled:y,form:b,children:[$===void 0?e.jsx("option",{value:""}):null,Array.from(J)]},ce):null]})})};NGe.displayName=US;var kGe="SelectTrigger",SGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=jue(r),l=mw(kGe,r),i=l.disabled||n,d=Aa(s,l.onTriggerChange),u=wue(r),p=S.useRef("touch"),[x,y,_]=YGe(N=>{const w=u().filter(E=>!E.disabled),k=w.find(E=>E.value===l.value),C=XGe(w,N,k);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(LA,{asChild:!0,...o,children:e.jsx(Yr.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":ZGe(l.value)?"":void 0,...a,ref:d,onClick:Cr(a.onClick,N=>{N.currentTarget.focus(),p.current!=="mouse"&&b(N)}),onPointerDown:Cr(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:Cr(a.onKeyDown,N=>{const w=x.current!=="";!(N.ctrlKey||N.altKey||N.metaKey)&&N.key.length===1&&y(N.key),!(w&&N.key===" ")&&gNt.includes(N.key)&&(b(),N.preventDefault())})})})});SGe.displayName=kGe;var CGe="SelectValue",MGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,d=mw(CGe,r),{onValueNodeHasChildrenChange:u}=d,p=o!==void 0,x=Aa(s,d.onValueNodeChange);return rd(()=>{u(p)},[u,p]),e.jsx(Yr.span,{...i,ref:x,style:{pointerEvents:"none"},children:ZGe(d.value)?e.jsx(e.Fragment,{children:l}):o})});MGe.displayName=CGe;var jNt="SelectIcon",TGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(Yr.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});TGe.displayName=jNt;var NNt="SelectPortal",AGe=t=>e.jsx(AA,{asChild:!0,...t});AGe.displayName=NNt;var VS="SelectContent",EGe=S.forwardRef((t,s)=>{const r=mw(VS,t.__scopeSelect),[n,a]=S.useState();if(rd(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?ip.createPortal(e.jsx(PGe,{scope:t.__scopeSelect,children:e.jsx(bue.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(IGe,{...t,ref:s})});EGe.displayName=VS;var dg=10,[PGe,pw]=qA(VS),kNt="SelectContentImpl",SNt=Vb("SelectContent.RemoveScroll"),IGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:i,sideOffset:d,align:u,alignOffset:p,arrowPadding:x,collisionBoundary:y,collisionPadding:_,sticky:b,hideWhenDetached:N,avoidCollisions:w,...k}=t,C=mw(VS,r),[E,L]=S.useState(null),[I,O]=S.useState(null),V=Aa(s,Fe=>L(Fe)),[q,$]=S.useState(null),[U,se]=S.useState(null),Y=wue(r),[J,X]=S.useState(!1),ce=S.useRef(!1);S.useEffect(()=>{if(E)return mue(E)},[E]),due();const ie=S.useCallback(Fe=>{const[Le,...Ne]=Y().map(ve=>ve.ref.current),[qe]=Ne.slice(-1),ze=document.activeElement;for(const ve of Fe)if(ve===ze||(ve==null||ve.scrollIntoView({block:"nearest"}),ve===Le&&I&&(I.scrollTop=0),ve===qe&&I&&(I.scrollTop=I.scrollHeight),ve==null||ve.focus(),document.activeElement!==ze))return},[Y,I]),ae=S.useCallback(()=>ie([q,E]),[ie,q,E]);S.useEffect(()=>{J&&ae()},[J,ae]);const{onOpenChange:oe,triggerPointerDownPosRef:pe}=C;S.useEffect(()=>{if(E){let Fe={x:0,y:0};const Le=qe=>{var ze,ve;Fe={x:Math.abs(Math.round(qe.pageX)-(((ze=pe.current)==null?void 0:ze.x)??0)),y:Math.abs(Math.round(qe.pageY)-(((ve=pe.current)==null?void 0:ve.y)??0))}},Ne=qe=>{Fe.x<=10&&Fe.y<=10?qe.preventDefault():E.contains(qe.target)||oe(!1),document.removeEventListener("pointermove",Le),pe.current=null};return pe.current!==null&&(document.addEventListener("pointermove",Le),document.addEventListener("pointerup",Ne,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Le),document.removeEventListener("pointerup",Ne,{capture:!0})}}},[E,oe,pe]),S.useEffect(()=>{const Fe=()=>oe(!1);return window.addEventListener("blur",Fe),window.addEventListener("resize",Fe),()=>{window.removeEventListener("blur",Fe),window.removeEventListener("resize",Fe)}},[oe]);const[_e,he]=YGe(Fe=>{const Le=Y().filter(ze=>!ze.disabled),Ne=Le.find(ze=>ze.ref.current===document.activeElement),qe=XGe(Le,Fe,Ne);qe&&setTimeout(()=>qe.ref.current.focus())}),we=S.useCallback((Fe,Le,Ne)=>{const qe=!ce.current&&!Ne;(C.value!==void 0&&C.value===Le||qe)&&($(Fe),qe&&(ce.current=!0))},[C.value]),je=S.useCallback(()=>E==null?void 0:E.focus(),[E]),Ue=S.useCallback((Fe,Le,Ne)=>{const qe=!ce.current&&!Ne;(C.value!==void 0&&C.value===Le||qe)&&se(Fe)},[C.value]),Te=n==="popper"?h1e:LGe,Me=Te===h1e?{side:i,sideOffset:d,align:u,alignOffset:p,arrowPadding:x,collisionBoundary:y,collisionPadding:_,sticky:b,hideWhenDetached:N,avoidCollisions:w}:{};return e.jsx(PGe,{scope:r,content:E,viewport:I,onViewportChange:O,itemRefCallback:we,selectedItem:q,onItemLeave:je,itemTextRefCallback:Ue,focusSelectedItem:ae,selectedItemText:U,position:n,isPositioned:J,searchRef:_e,children:e.jsx(TR,{as:SNt,allowPinchZoom:!0,children:e.jsx(CR,{asChild:!0,trapped:C.open,onMountAutoFocus:Fe=>{Fe.preventDefault()},onUnmountAutoFocus:Cr(a,Fe=>{var Le;(Le=C.trigger)==null||Le.focus({preventScroll:!0}),Fe.preventDefault()}),children:e.jsx(lw,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Fe=>Fe.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:e.jsx(Te,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:Fe=>Fe.preventDefault(),...k,...Me,onPlaced:()=>X(!0),ref:V,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:Cr(k.onKeyDown,Fe=>{const Le=Fe.ctrlKey||Fe.altKey||Fe.metaKey;if(Fe.key==="Tab"&&Fe.preventDefault(),!Le&&Fe.key.length===1&&he(Fe.key),["ArrowUp","ArrowDown","Home","End"].includes(Fe.key)){let qe=Y().filter(ze=>!ze.disabled).map(ze=>ze.ref.current);if(["ArrowUp","End"].includes(Fe.key)&&(qe=qe.slice().reverse()),["ArrowUp","ArrowDown"].includes(Fe.key)){const ze=Fe.target,ve=qe.indexOf(ze);qe=qe.slice(ve+1)}setTimeout(()=>ie(qe)),Fe.preventDefault()}})})})})})})});IGe.displayName=kNt;var CNt="SelectItemAlignedPosition",LGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=mw(VS,r),l=pw(VS,r),[i,d]=S.useState(null),[u,p]=S.useState(null),x=Aa(s,V=>p(V)),y=wue(r),_=S.useRef(!1),b=S.useRef(!0),{viewport:N,selectedItem:w,selectedItemText:k,focusSelectedItem:C}=l,E=S.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&N&&w&&k){const V=o.trigger.getBoundingClientRect(),q=u.getBoundingClientRect(),$=o.valueNode.getBoundingClientRect(),U=k.getBoundingClientRect();if(o.dir!=="rtl"){const ze=U.left-q.left,ve=$.left-ze,dt=V.left-ve,fe=V.width+dt,Ve=Math.max(fe,q.width),Je=window.innerWidth-dg,at=eD(ve,[dg,Math.max(dg,Je-Ve)]);i.style.minWidth=fe+"px",i.style.left=at+"px"}else{const ze=q.right-U.right,ve=window.innerWidth-$.right-ze,dt=window.innerWidth-V.right-ve,fe=V.width+dt,Ve=Math.max(fe,q.width),Je=window.innerWidth-dg,at=eD(ve,[dg,Math.max(dg,Je-Ve)]);i.style.minWidth=fe+"px",i.style.right=at+"px"}const se=y(),Y=window.innerHeight-dg*2,J=N.scrollHeight,X=window.getComputedStyle(u),ce=parseInt(X.borderTopWidth,10),ie=parseInt(X.paddingTop,10),ae=parseInt(X.borderBottomWidth,10),oe=parseInt(X.paddingBottom,10),pe=ce+ie+J+oe+ae,_e=Math.min(w.offsetHeight*5,pe),he=window.getComputedStyle(N),we=parseInt(he.paddingTop,10),je=parseInt(he.paddingBottom,10),Ue=V.top+V.height/2-dg,Te=Y-Ue,Me=w.offsetHeight/2,Fe=w.offsetTop+Me,Le=ce+ie+Fe,Ne=pe-Le;if(Le<=Ue){const ze=se.length>0&&w===se[se.length-1].ref.current;i.style.bottom="0px";const ve=u.clientHeight-N.offsetTop-N.offsetHeight,dt=Math.max(Te,Me+(ze?je:0)+ve+ae),fe=Le+dt;i.style.height=fe+"px"}else{const ze=se.length>0&&w===se[0].ref.current;i.style.top="0px";const dt=Math.max(Ue,ce+N.offsetTop+(ze?we:0)+Me)+Ne;i.style.height=dt+"px",N.scrollTop=Le-Ue+N.offsetTop}i.style.margin=`${dg}px 0`,i.style.minHeight=_e+"px",i.style.maxHeight=Y+"px",n==null||n(),requestAnimationFrame(()=>_.current=!0)}},[y,o.trigger,o.valueNode,i,u,N,w,k,o.dir,n]);rd(()=>E(),[E]);const[L,I]=S.useState();rd(()=>{u&&I(window.getComputedStyle(u).zIndex)},[u]);const O=S.useCallback(V=>{V&&b.current===!0&&(E(),C==null||C(),b.current=!1)},[E,C]);return e.jsx(TNt,{scope:r,contentWrapper:i,shouldExpandOnScrollRef:_,onScrollButtonChange:O,children:e.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:L},children:e.jsx(Yr.div,{...a,ref:x,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});LGe.displayName=CNt;var MNt="SelectPopperPosition",h1e=S.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=dg,...o}=t,l=jue(r);return e.jsx(jR,{...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)"}})});h1e.displayName=MNt;var[TNt,qje]=qA(VS,{}),m1e="SelectViewport",DGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=pw(m1e,r),l=qje(m1e,r),i=Aa(s,o.onViewportChange),d=S.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),e.jsx(bue.Slot,{scope:r,children:e.jsx(Yr.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Cr(a.onScroll,u=>{const p=u.currentTarget,{contentWrapper:x,shouldExpandOnScrollRef:y}=l;if(y!=null&&y.current&&x){const _=Math.abs(d.current-p.scrollTop);if(_>0){const b=window.innerHeight-dg*2,N=parseFloat(x.style.minHeight),w=parseFloat(x.style.height),k=Math.max(N,w);if(k0?L:0,x.style.justifyContent="flex-end")}}}d.current=p.scrollTop})})})]})});DGe.displayName=m1e;var RGe="SelectGroup",[ANt,ENt]=qA(RGe),PNt=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=pu();return e.jsx(ANt,{scope:r,id:a,children:e.jsx(Yr.div,{role:"group","aria-labelledby":a,...n,ref:s})})});PNt.displayName=RGe;var OGe="SelectLabel",FGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=ENt(OGe,r);return e.jsx(Yr.div,{id:a.id,...n,ref:s})});FGe.displayName=OGe;var Goe="SelectItem",[INt,zGe]=qA(Goe),BGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=mw(Goe,r),d=pw(Goe,r),u=i.value===n,[p,x]=S.useState(o??""),[y,_]=S.useState(!1),b=Aa(s,C=>{var E;return(E=d.itemRefCallback)==null?void 0:E.call(d,C,n,a)}),N=pu(),w=S.useRef("touch"),k=()=>{a||(i.onValueChange(n),i.onOpenChange(!1))};if(n==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(INt,{scope:r,value:n,disabled:a,textId:N,isSelected:u,onItemTextChange:S.useCallback(C=>{x(E=>E||((C==null?void 0:C.textContent)??"").trim())},[]),children:e.jsx(bue.ItemSlot,{scope:r,value:n,disabled:a,textValue:p,children:e.jsx(Yr.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:Cr(l.onFocus,()=>_(!0)),onBlur:Cr(l.onBlur,()=>_(!1)),onClick:Cr(l.onClick,()=>{w.current!=="mouse"&&k()}),onPointerUp:Cr(l.onPointerUp,()=>{w.current==="mouse"&&k()}),onPointerDown:Cr(l.onPointerDown,C=>{w.current=C.pointerType}),onPointerMove:Cr(l.onPointerMove,C=>{var E;w.current=C.pointerType,a?(E=d.onItemLeave)==null||E.call(d):w.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Cr(l.onPointerLeave,C=>{var E;C.currentTarget===document.activeElement&&((E=d.onItemLeave)==null||E.call(d))}),onKeyDown:Cr(l.onKeyDown,C=>{var L;((L=d.searchRef)==null?void 0:L.current)!==""&&C.key===" "||(yNt.includes(C.key)&&k(),C.key===" "&&C.preventDefault())})})})})});BGe.displayName=Goe;var TI="SelectItemText",$Ge=S.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=mw(TI,r),i=pw(TI,r),d=zGe(TI,r),u=wNt(TI,r),[p,x]=S.useState(null),y=Aa(s,k=>x(k),d.onItemTextChange,k=>{var C;return(C=i.itemTextRefCallback)==null?void 0:C.call(i,k,d.value,d.disabled)}),_=p==null?void 0:p.textContent,b=S.useMemo(()=>e.jsx("option",{value:d.value,disabled:d.disabled,children:_},d.value),[d.disabled,d.value,_]),{onNativeOptionAdd:N,onNativeOptionRemove:w}=u;return rd(()=>(N(b),()=>w(b)),[N,w,b]),e.jsxs(e.Fragment,{children:[e.jsx(Yr.span,{id:d.textId,...o,ref:y}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?ip.createPortal(o.children,l.valueNode):null]})});$Ge.displayName=TI;var qGe="SelectItemIndicator",UGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return zGe(qGe,r).isSelected?e.jsx(Yr.span,{"aria-hidden":!0,...n,ref:s}):null});UGe.displayName=qGe;var p1e="SelectScrollUpButton",VGe=S.forwardRef((t,s)=>{const r=pw(p1e,t.__scopeSelect),n=qje(p1e,t.__scopeSelect),[a,o]=S.useState(!1),l=Aa(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(GGe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop-d.offsetHeight)}}):null});VGe.displayName=p1e;var f1e="SelectScrollDownButton",HGe=S.forwardRef((t,s)=>{const r=pw(f1e,t.__scopeSelect),n=qje(f1e,t.__scopeSelect),[a,o]=S.useState(!1),l=Aa(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(GGe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop+d.offsetHeight)}}):null});HGe.displayName=f1e;var GGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=pw("SelectScrollButton",r),l=S.useRef(null),i=wue(r),d=S.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return S.useEffect(()=>()=>d(),[d]),rd(()=>{var p;const u=i().find(x=>x.ref.current===document.activeElement);(p=u==null?void 0:u.ref.current)==null||p.scrollIntoView({block:"nearest"})},[i]),e.jsx(Yr.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Cr(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Cr(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Cr(a.onPointerLeave,()=>{d()})})}),LNt="SelectSeparator",WGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(Yr.div,{"aria-hidden":!0,...n,ref:s})});WGe.displayName=LNt;var x1e="SelectArrow",DNt=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=jue(r),o=mw(x1e,r),l=pw(x1e,r);return o.open&&l.position==="popper"?e.jsx(NR,{...a,...n,ref:s}):null});DNt.displayName=x1e;var RNt="SelectBubbleInput",KGe=S.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=S.useRef(null),o=Aa(n,a),l=DR(s);return S.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&p){const x=new Event("change",{bubbles:!0});p.call(i,s),i.dispatchEvent(x)}},[l,s]),e.jsx(Yr.select,{...r,style:{...Tqe,...r.style},ref:o,defaultValue:s})});KGe.displayName=RNt;function ZGe(t){return t===""||t===void 0}function YGe(t){const s=ed(t),r=S.useRef(""),n=S.useRef(0),a=S.useCallback(l=>{const i=r.current+l;s(i),function d(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>d(""),1e3))}(i)},[s]),o=S.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return S.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function XGe(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=ONt(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 ONt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var FNt=NGe,QGe=SGe,zNt=MGe,BNt=TGe,$Nt=AGe,JGe=EGe,qNt=DGe,eWe=FGe,tWe=BGe,UNt=$Ge,VNt=UGe,sWe=VGe,rWe=HGe,nWe=WGe;const Bs=FNt,qs=zNt,Rs=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(QGe,{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(BNt,{asChild:!0,children:e.jsx(Oi,{className:"h-4 w-4 opacity-50"})})]}));Rs.displayName=QGe.displayName;const aWe=S.forwardRef(({className:t,...s},r)=>e.jsx(sWe,{ref:r,className:Rt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(nf,{className:"h-4 w-4"})}));aWe.displayName=sWe.displayName;const iWe=S.forwardRef(({className:t,...s},r)=>e.jsx(rWe,{ref:r,className:Rt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Oi,{className:"h-4 w-4"})}));iWe.displayName=rWe.displayName;const Os=S.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx($Nt,{children:e.jsxs(JGe,{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(aWe,{}),e.jsx(qNt,{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(iWe,{})]})}));Os.displayName=JGe.displayName;const HNt=S.forwardRef(({className:t,...s},r)=>e.jsx(eWe,{ref:r,className:Rt("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));HNt.displayName=eWe.displayName;const vt=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(tWe,{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(VNt,{children:e.jsx(Jn,{className:"h-4 w-4"})})}),e.jsx(UNt,{children:s})]}));vt.displayName=tWe.displayName;const GNt=S.forwardRef(({className:t,...s},r)=>e.jsx(nWe,{ref:r,className:Rt("-mx-1 my-1 h-px bg-muted",t),...s}));GNt.displayName=nWe.displayName;const WNt=t=>gt({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}}),oWe=t=>gt({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}),lWe=()=>It({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:x})=>{let y=null,_=null;if(l){const{data:k}=await G.from("listing_shares").select("id, sharing_agent_id").eq("share_token",l).eq("listing_id",t).maybeSingle();k&&(y=k.id,_=k.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:x||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}}),KNt=()=>It({mutationFn:async t=>{const{error:s}=await G.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),ZNt={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},OPe={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},YNt={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function cWe(){const[t,s]=S.useState(""),[r,n]=S.useState(!1),[a,o]=S.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=WNt({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=x=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(x),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(wc,{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(ha,{to:"/public/listings",className:"flex items-center",children:e.jsx("img",{src:bGe,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(${mNt})`},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(an,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx(De,{placeholder:"Enter an address, neighborhood, city, or ZIP code",value:t,onChange:x=>s(x.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(an,{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(fS,{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(Bs,{value:a.status||"all",onValueChange:x=>o({...a,status:x==="all"?"":x}),children:[e.jsx(Rs,{className:"bg-white",children:e.jsx(qs,{placeholder:"Any status"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"Any status"}),Object.entries(OPe).map(([x,y])=>e.jsx(vt,{value:x,children:y},x))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Property Type"}),e.jsxs(Bs,{value:a.propertyType||"all",onValueChange:x=>o({...a,propertyType:x==="all"?"":x}),children:[e.jsx(Rs,{className:"bg-white",children:e.jsx(qs,{placeholder:"Any type"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"Any type"}),Object.entries(YNt).map(([x,y])=>e.jsx(vt,{value:x,children:y},x))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Min Price"}),e.jsx(De,{type:"number",placeholder:"No min",value:a.minPrice,onChange:x=>o({...a,minPrice:x.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(De,{type:"number",placeholder:"No max",value:a.maxPrice,onChange:x=>o({...a,maxPrice:x.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(xNt,{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((x,y)=>e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm",children:[e.jsx(Ns,{className:"aspect-[4/3]"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(Ns,{className:"h-7 w-28"}),e.jsx(Ns,{className:"h-4 w-full"}),e.jsx(Ns,{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(x=>{var N,w,k;const y=((N=x.photos)==null?void 0:N.find(C=>C.is_primary))||((w=x.photos)==null?void 0:w[0]),b=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${x.slug||x.id}`:`/public/listing/${x.slug||x.id}`;return e.jsx(ha,{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:x.property_address||x.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(Qe,{className:`absolute top-2 left-2 ${ZNt[x.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:OPe[x.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(x.price)}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-700 mb-2",children:[x.bedrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:x.bedrooms}),e.jsx("span",{className:"text-gray-500",children:"bds"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),x.bathrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:x.bathrooms}),e.jsx("span",{className:"text-gray-500",children:"ba"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),x.square_footage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:x.square_footage.toLocaleString()}),e.jsx("span",{className:"text-gray-500",children:"sqft"})]})]}),x.property_address&&e.jsx("p",{className:"text-sm text-gray-700 truncate",children:x.property_address}),e.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[x.city,", ",x.state]}),x.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:x.agent.name}),((k=x.agent.brokerage)==null?void 0:k.name)&&e.jsx("p",{className:"text-xs text-gray-400 truncate",children:x.agent.brokerage.name})]})]})]})},x.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:$je,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 Pe=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Rt("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Pe.displayName="Card";const Lt=S.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 Ot=S.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:Rt("text-2xl font-semibold leading-none tracking-tight",t),...s}));Ot.displayName="CardTitle";const hr=S.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:Rt("text-sm text-muted-foreground",t),...s}));hr.displayName="CardDescription";const Re=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Rt("p-6 pt-0",t),...s}));Re.displayName="CardContent";const GL=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Rt("flex items-center p-6 pt-0",t),...s}));GL.displayName="CardFooter";var XNt="Label",dWe=S.forwardRef((t,s)=>e.jsx(Yr.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())}}));dWe.displayName=XNt;var uWe=dWe;const QNt=gC("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),xe=S.forwardRef(({className:t,...s},r)=>e.jsx(uWe,{ref:r,className:Rt(QNt(),t),...s}));xe.displayName=uWe.displayName;const Woe="/assets/levelup-logo-color-D3mY9gCJ.png";function JNt(){const t=Ol(),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(cWe,{}):n.startsWith("public/")?null:e.jsx(ekt,{slug:n})}function ekt({slug:t}){return e.jsx(rkt,{slug:t})}const tkt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},skt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},FPe={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function rkt({slug:t}){var $,U;const{data:s,isLoading:r}=oWe(t),n=lWe(),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,x]=S.useState(""),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.useState(null),C=se=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(se),E=async se=>{if(se.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(Y){console.error("Lead submission error:",Y),me.error(`Failed to submit: ${Y.message||"Please try again"}`)}finally{_(!1)}}},L=(s==null?void 0:s.photos)||[],I=L.find(se=>se.is_primary)||L[0],O=()=>{w!==null&&k(w===0?L.length-1:w-1)},V=()=>{w!==null&&k(w===L.length-1?0:w+1)};if(r)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(Ns,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(Ns,{className:"h-10 w-48 mb-6"}),e.jsx(Ns,{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(Ns,{className:"h-12 w-48"}),e.jsx(Ns,{className:"h-6 w-full"}),e.jsx(Ns,{className:"h-6 w-3/4"})]}),e.jsx(Ns,{className:"h-64"})]})]})]});if(!s)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("a",{href:"/",className:"flex items-center gap-2",children:e.jsx("img",{src:Woe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(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(wc,{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":""} ${FPe[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"}),I&&e.jsx("meta",{property:"og:image",content:I.photo_url})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("a",{href:"/",className:"flex items-center gap-2",children:e.jsx("img",{src:Woe,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs("a",{href:"/",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(Fa,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),L.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>k(0),children:e.jsx("img",{src:I==null?void 0:I.photo_url,alt:"Primary",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:L.slice(1,5).map((se,Y)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>k(Y+1),children:[e.jsx("img",{src:se.photo_url,alt:`Photo ${Y+2}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),Y===3&&L.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",L.length-5," more"]})]},se.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(Qe,{className:`${tkt[s.status]} text-white border-0`,children:skt[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(Da,{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(Wy,{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(rf,{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(s0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),s.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(on,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Qe,{variant:"secondary",children:[e.jsx(pa,{className:"h-3 w-3 mr-1"}),FPe[s.property_type]]}),s.lot_size&&e.jsxs(Qe,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(Qe,{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(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ti,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Re,{children:[e.jsx("p",{className:"font-semibold text-lg",children:s.agent.name}),((U=s.agent.brokerage)==null?void 0:U.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.agent.brokerage.name})]})]}),e.jsxs(Pe,{className:"border-primary",children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Re,{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(rr,{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:E,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"firstName",children:"First Name *"}),e.jsx(De,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:se=>o(se.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lastName",children:"Last Name"}),e.jsx(De,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:se=>i(se.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"email",children:"Email *"}),e.jsx(De,{id:"email",type:"email",placeholder:"you@example.com",value:d,onChange:se=>u(se.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"phone",children:"Phone"}),e.jsx(De,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:p,onChange:se=>x(se.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:()=>k(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:()=>k(null),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Sr,{className:"h-5 w-5"})}),w!==null&&L[w]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:L[w].photo_url,alt:`Photo ${w+1}`,className:"w-full max-h-[80vh] object-contain"}),L.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:O,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(xl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:V,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(Sa,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[w+1," / ",L.length]})]})]})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function Nue({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 hWe=t=>gt({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}),nkt=()=>gt({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}}),akt=t=>gt({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}),mWe=()=>{const t=Jt();return It({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)})},pWe=()=>{const t=Jt();return It({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)})},qi=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:{}})},ikt=async(t,s)=>{const{error:r}=await G.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},fWe=t=>gt({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 kue({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=S.useState(""),[i,d]=S.useState(""),[u,p]=S.useState(""),[x,y]=S.useState(""),[_,b]=S.useState(""),[N,w]=S.useState(!1),k=async C=>{if(C.preventDefault(),!o.trim()){me.error("Please enter your name");return}w(!0);try{await ikt(r,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:_.trim()||void 0,intent:x||void 0}),qi(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:x||void 0}}).catch(E=>console.error("Card lead notify failed:",E)),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(Ir,{children:n==="booking"?`Let ${a} know you'd like to connect.`:n==="connect"?`Share your info and ${a} will reach out.`:`Know someone who could use ${a}'s help?`})]}),e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lead-name",children:"Name *"}),e.jsx(De,{id:"lead-name",value:o,onChange:C=>l(C.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lead-phone",children:"Phone"}),e.jsx(De,{id:"lead-phone",type:"tel",value:u,onChange:C=>p(C.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lead-email",children:"Email"}),e.jsx(De,{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(xe,{htmlFor:"lead-intent",children:"I'm looking to..."}),e.jsxs(Bs,{value:x,onValueChange:y,children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select one"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"buy",children:"Buy a home"}),e.jsx(vt,{value:"sell",children:"Sell my home"}),e.jsx(vt,{value:"both",children:"Buy & Sell"}),e.jsx(vt,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),e.jsx(De,{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 okt=t=>gt({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}),lkt=t=>gt({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}),ckt=()=>{const t=Jt();return It({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)})},dkt=()=>{const t=Jt();return It({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)})},ukt=()=>{const t=Jt();return It({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 hkt(t){const s=t.match(/(?:iframe\.mediadelivery\.net\/embed\/|video\.bunnycdn\.com\/play\/)(\d+)\/([a-f0-9-]+)/i);return s?`https://iframe.mediadelivery.net/embed/${s[1]}/${s[2]}?autoplay=false&responsive=true`:(t.includes("iframe.mediadelivery.net"),t)}function mkt(t){const s=t.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/);return s?`https://www.youtube.com/embed/${s[1]}`:null}const pkt={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 fkt({block:t,variant:s}){const r=t.config;if(!r.video_url)return null;const n=r.video_url.includes("mediadelivery.net")||r.video_url.includes("bunnycdn.com"),a=mkt(r.video_url),o=n||!!a,l=n?hkt(r.video_url):a||r.video_url;return e.jsx("div",{className:pkt[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 xkt={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 gkt({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=S.useState(0);if(n.length===0)return null;const l=xkt[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(cS,{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(xl,{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(Sa,{className:"h-4 w-4"})})]})]})}const ykt={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 vkt({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=ykt[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const _kt={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 bkt({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=_kt[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:()=>qi(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 g1e={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 wkt({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 jkt={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 Nkt({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=jkt[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=g1e[l.platform.toLowerCase()];return!d||!l.url?null:e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>qi(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:d.label,children:e.jsx(wkt,{path:d.icon,color:d.color})},i)})})]})}function Sue({cardId:t,variant:s}){const{data:r}=okt(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(fkt,{block:l,variant:s},l.id);case"testimonials":return e.jsx(gkt,{block:l,variant:s},l.id);case"specialties":return e.jsx(vkt,{block:l,variant:s},l.id);case"custom_links":return e.jsx(bkt,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx(Nkt,{block:o,cardId:t,variant:s})]})}async function kkt(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 Skt(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 Cue(t){const{first:s,last:r}=Skt(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 kkt(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 Ckt({card:t}){var k;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,E)=>{qi(t.id,"button_click",C),E()},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")}),x=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),qi(t.id,"button_click","book"))},y=()=>{var C,E;qi(t.id,"contact_saved"),Cue({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(E=t.profile)==null?void 0:E.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{qi(t.id,"share_event");const C=`https://cards.relevelup.com/${t.slug}`,E="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:E,url:C})}catch{}else await navigator.clipboard.writeText(C),me.success("Link copied!")},b=()=>{a("referral"),r(!0),qi(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),qi(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(Ta,{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(Pn,{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(ki,{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(rr,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),e.jsxs(K,{onClick:x,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[e.jsx(on,{className:"h-5 w-5 mr-2"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm text-slate-600",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Hn,{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(Nue,{card:t,variant:"standard"}),e.jsx(Sue,{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:()=>{qi(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(Hn,{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(lr,{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(al,{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,E)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>qi(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()]||"🔗"},E))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),e.jsx(kue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Mkt({card:t}){var k;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,E)=>{qi(t.id,"button_click",C),E()},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")}),x=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),qi(t.id,"button_click","book"))},y=()=>{var C,E;qi(t.id,"contact_saved"),Cue({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(E=t.profile)==null?void 0:E.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{qi(t.id,"share_event");const C=`https://cards.relevelup.com/${t.slug}`,E="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:E,url:C})}catch{}else await navigator.clipboard.writeText(C),me.success("Link copied!")},b=()=>{a("referral"),r(!0),qi(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),qi(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(Ta,{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:Pn,label:"Call",handler:d},{icon:ki,label:"Text",handler:u},{icon:rr,label:"Email",handler:p}].map(({icon:C,label:E,handler:L})=>e.jsxs("button",{onClick:L,className:"flex flex-col items-center gap-1.5 py-4 bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/20 rounded-xl transition-colors",children:[e.jsx(C,{className:"h-5 w-5 text-[#c9a84c]"}),e.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:E})]},E))}),e.jsxs("button",{onClick:x,className:"w-full h-12 text-base font-semibold rounded-xl mb-6 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] text-[#0f1419] hover:opacity-90 transition-opacity flex items-center justify-center gap-2",children:[e.jsx(on,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Hn,{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(Nue,{card:t,variant:"luxury"}),e.jsx(Sue,{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:()=>{qi(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(Hn,{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(lr,{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(al,{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,E)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>qi(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()]||"🔗"},E))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(kue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Tkt({card:t}){var E,L,I,O;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((E=t.profile)==null?void 0:E.name)||"Agent",l=o.split(" ").map(V=>V[0]).join("").toUpperCase().slice(0,2),i={accent:((L=t.bold_theme_colors)==null?void 0:L.accent)||"#ff5722",dark:((I=t.bold_theme_colors)==null?void 0:I.dark)||"#1a1a2e",button:((O=t.bold_theme_colors)==null?void 0:O.button)||"#ff5722"},d=(V,q)=>{const $=parseInt(V.replace("#",""),16),U=Math.max(0,($>>16)-q),se=Math.max(0,($>>8&255)-q),Y=Math.max(0,($&255)-q);return`#${(U<<16|se<<8|Y).toString(16).padStart(6,"0")}`};d(i.accent,25),d(i.dark,-20),d(i.button,25);const u=(V,q)=>{qi(t.id,"button_click",V),q()},p=()=>u("call",()=>{var V;(V=t.profile)!=null&&V.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),x=()=>u("text",()=>{var V;(V=t.profile)!=null&&V.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),y=()=>u("email",()=>{var V;(V=t.profile)!=null&&V.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),qi(t.id,"button_click","book"))},b=()=>{var V,q;qi(t.id,"contact_saved"),Cue({name:o,phone:(V=t.profile)==null?void 0:V.phone,email:(q=t.profile)==null?void 0:q.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},N=async()=>{qi(t.id,"share_event");const V=`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:V})}catch{}else await navigator.clipboard.writeText(V),me.success("Link copied!")},w=()=>{a("referral"),r(!0),qi(t.id,"button_click","refer")},k=()=>{a("connect"),r(!0),qi(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(Ta,{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:Pn,label:"Call",handler:p},{icon:ki,label:"Text",handler:x},{icon:rr,label:"Email",handler:y}].map(({icon:V,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(V,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:q})]},q))}),e.jsxs("button",{onClick:_,className:"w-full h-14 text-base font-black rounded-2xl mb-6 text-white transition-opacity hover:opacity-90 flex items-center justify-center gap-2 uppercase tracking-wide",style:{backgroundColor:i.button},children:[e.jsx(on,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-5 mb-6",children:t.review_snippet&&e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Hn,{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(Nue,{card:t,variant:"bold"}),e.jsx(Sue,{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:()=>{qi(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(Hn,{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(lr,{className:"h-4 w-4",style:{color:i.accent}})," Refer a Friend"]}),e.jsxs("button",{onClick:k,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(al,{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((V,q)=>e.jsx("a",{href:V.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>qi(t.id,"button_click",`social_${V.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[V.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(kue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Akt({card:t}){var k;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,E)=>{qi(t.id,"button_click",C),E()},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")}),x=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),qi(t.id,"button_click","book"))},y=()=>{var C,E;qi(t.id,"contact_saved"),Cue({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(E=t.profile)==null?void 0:E.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{qi(t.id,"share_event");const C=`https://cards.relevelup.com/${t.slug}`,E="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:E,url:C})}catch{}else await navigator.clipboard.writeText(C),me.success("Link copied!")},b=()=>{a("referral"),r(!0),qi(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),qi(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(Ta,{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:Pn,label:"Call",handler:d},{icon:ki,label:"Text",handler:u},{icon:rr,label:"Email",handler:p}].map(({icon:C,label:E,handler:L})=>e.jsxs("button",{onClick:L,className:"flex flex-col items-center gap-1.5 py-4 bg-white hover:bg-[#e8e3db] border border-[#d4cfc5] rounded-lg transition-colors shadow-sm",children:[e.jsx(C,{className:"h-5 w-5 text-[#1b3a4b]"}),e.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:E})]},E))}),e.jsxs("button",{onClick:x,className:"w-full h-12 text-base font-semibold rounded-lg mb-6 bg-[#1b3a4b] hover:bg-[#264d61] text-white transition-colors flex items-center justify-center gap-2 shadow-sm",children:[e.jsx(on,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsx("div",{className:"flex items-center justify-center gap-6",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Hn,{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(Nue,{card:t,variant:"classic"}),e.jsx(Sue,{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:()=>{qi(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(Hn,{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(lr,{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(al,{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,E)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>qi(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()]||"🔗"},E))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(kue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Uje({card:t}){switch(t.theme){case"luxury":return e.jsx(Mkt,{card:t});case"bold":return e.jsx(Tkt,{card:t});case"classic":return e.jsx(Akt,{card:t});case"standard":default:return e.jsx(Ckt,{card:t})}}function Ekt(){const t=Ol();S.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]);const s=t.pathname.slice(1);return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Agent Cards"}),e.jsx("p",{className:"text-slate-500",children:"Visit a specific agent's card URL to view their digital business card."})]})}):e.jsx(Pkt,{slug:s})}function Pkt({slug:t}){return e.jsx(Ikt,{slug:t})}function Ikt({slug:t}){var o;const{data:s,isLoading:r,error:n}=hWe(t);if(S.useEffect(()=>{s!=null&&s.id&&qi(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(Ns,{className:"h-28 w-28 rounded-full"}),e.jsx(Ns,{className:"h-6 w-48"}),e.jsx(Ns,{className:"h-4 w-36"})]}),e.jsx(Ns,{className:"h-12 w-full"}),e.jsx(Ns,{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(wc,{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(Uje,{card:s})]})}function xWe({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=S.useState(n||""),[d,u]=S.useState(a||""),[p,x]=S.useState(o||""),[y,_]=S.useState(""),[b,N]=S.useState(""),[w,k]=S.useState(!1),[C,E]=S.useState(!1),L=async I=>{if(I.preventDefault(),!l.trim()){me.error("Please enter your name");return}k(!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(V=>console.error("Presentation lead notify failed:",V)),E(!0)}catch{me.error("Something went wrong. Please try again.")}finally{k(!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(Jn,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Thank you!"}),e.jsx("p",{className:"text-gray-500",children:r?`${r} will be in touch soon.`:"We'll be in touch soon."})]}):e.jsxs("form",{onSubmit:L,className:"space-y-4 max-w-md mx-auto",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"pres-lead-name",children:"Name *"}),e.jsx(De,{id:"pres-lead-name",value:l,onChange:I=>i(I.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"pres-lead-phone",children:"Phone"}),e.jsx(De,{id:"pres-lead-phone",type:"tel",value:p,onChange:I=>x(I.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"pres-lead-email",children:"Email"}),e.jsx(De,{id:"pres-lead-email",type:"email",value:d,onChange:I=>u(I.target.value),placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),e.jsxs(Bs,{value:y,onValueChange:_,children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select one"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"buy",children:"Buy a home"}),e.jsx(vt,{value:"sell",children:"Sell my home"}),e.jsx(vt,{value:"both",children:"Buy & Sell"}),e.jsx(vt,{value:"other",children:"Something else"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"pres-lead-message",children:"Message (optional)"}),e.jsx(De,{id:"pres-lead-message",value:b,onChange:I=>N(I.target.value),placeholder:"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:w,children:w?"Sending...":s})]})}function Lkt(){const t=Ol();S.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]);const s=t.pathname.slice(1);return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Smart Presentations"}),e.jsx("p",{className:"text-slate-500",children:"Visit a specific presentation URL to view it."})]})}):e.jsx(Dkt,{shareToken:s})}function Dkt({shareToken:t}){var b;const[s,r]=S.useState(null),[n,a]=S.useState(!0),[o,l]=S.useState(0),[i,d]=S.useState(!1);S.useEffect(()=>{u()},[t]);const u=async()=>{const{data: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:k}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",N.owner_user_id).single();let C;if(k!=null&&k.brokerage_id){const{data:L}=await G.from("brokerages").select("name").eq("id",k.brokerage_id).single();C=(L==null?void 0:L.name)||void 0}let E=null;if(N.contact_id){const{data:L}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",N.contact_id).single();E=L}r({...N,owner_name:k==null?void 0:k.name,owner_email:k==null?void 0:k.email,owner_phone:k==null?void 0:k.phone,owner_avatar:k==null?void 0:k.avatar_url,owner_title:(k==null?void 0:k.title)||void 0,brokerage_name:C,contact_name:E?[E.first_name,E.last_name].filter(Boolean).join(" "):void 0,contact_email:(E==null?void 0:E.email)||void 0,contact_phone:(E==null?void 0:E.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")}},x=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 E=N.replace("/play/","/embed/"),L=E.includes("?")?"&":"?";return`${E}${L}responsive=true`}if(N.includes("iframe.mediadelivery.net")){const E=N.includes("?")?"&":"?";return`${N}${E}responsive=true`}const k=N.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(k)return`https://www.loom.com/embed/${k[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(Ns,{className:"h-12 w-3/4 mx-auto"}),e.jsx(Ns,{className:"h-64 w-full"}),e.jsx(Ns,{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:x(_.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(xWe,{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 Px=()=>{const t=ja();return gt({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 Rkt(){const{user:t}=Fs(),s=ja(),{data:r}=Px();return gt({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(x=>x.agent_id))],u={};if(d.length>0){const{data:x}=await G.from("profiles").select("id, name").in("id",d);x==null||x.forEach(y=>{y.name&&(u[y.id]=y.name)})}const p=l.map(x=>({...x,agent_name:u[x.agent_id]||void 0}));o=[...o,...p]}}return o.sort((l,i)=>i.event_date.localeCompare(l.event_date)),o},enabled:!!t&&!!s})}function wTs(t){const{user:s}=Fs();return gt({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 gWe(t){const{user:s}=Fs(),r=Jt();return S.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]),gt({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 Okt(){const t=Jt(),s=ja();return It({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"]}),gn({title:"Open house created!"})},onError:r=>{gn({title:"Error",description:r.message,variant:"destructive"})}})}function yWe(){const t=Jt();return It({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 Fkt(){const t=Jt();return It({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"]}),gn({title:"Open house deleted"})}})}function zkt(t){return gt({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 Bkt(t){const{user:s}=Fs();return gt({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 $kt(t){return gt({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 qkt(){return It({mutationFn:async t=>{const{error:s}=await G.from("open_house_survey_responses").insert(t);if(s)throw s}})}function Ukt(t){const{user:s}=Fs();return gt({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 Vkt(){const t=Jt();return It({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 Hkt(){const t=Jt();return It({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 Gkt(){const t=Jt();return It({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 Wkt(){const t=Jt();return It({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 Kkt(){return It({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 Zkt(){return It({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 Ykt(){return It({mutationFn:async t=>{await G.rpc("increment_open_house_scan",{_slug:t})}})}var Mue="Switch",[Xkt,jTs]=$c(Mue),[Qkt,Jkt]=Xkt(Mue),vWe=S.forwardRef((t,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d="on",onCheckedChange:u,form:p,...x}=t,[y,_]=S.useState(null),b=Aa(s,E=>_(E)),N=S.useRef(!1),w=y?p||!!y.closest("form"):!0,[k,C]=$u({prop:a,defaultProp:o??!1,onChange:u,caller:Mue});return e.jsxs(Qkt,{scope:r,checked:k,disabled:i,children:[e.jsx(Yr.button,{type:"button",role:"switch","aria-checked":k,"aria-required":l,"data-state":jWe(k),"data-disabled":i?"":void 0,disabled:i,value:d,...x,ref:b,onClick:Cr(t.onClick,E=>{C(L=>!L),w&&(N.current=E.isPropagationStopped(),N.current||E.stopPropagation())})}),w&&e.jsx(wWe,{control:y,bubbles:!N.current,name:n,value:d,checked:k,required:l,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});vWe.displayName=Mue;var _We="SwitchThumb",bWe=S.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=Jkt(_We,r);return e.jsx(Yr.span,{"data-state":jWe(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});bWe.displayName=_We;var e4t="SwitchBubbleInput",wWe=S.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=S.useRef(null),i=Aa(l,o),d=DR(r),u=bR(s);return S.useEffect(()=>{const p=l.current;if(!p)return;const x=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(x,"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}})});wWe.displayName=e4t;function jWe(t){return t?"checked":"unchecked"}var NWe=vWe,t4t=bWe;const Er=S.forwardRef(({className:t,...s},r)=>e.jsx(NWe,{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(t4t,{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")})}));Er.displayName=NWe.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 Go(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function cl(t,s){const r=Kn(t);return isNaN(s)?Go(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function Am(t,s){const r=Kn(t);if(isNaN(s))return Go(t,NaN);if(!s)return r;const n=r.getDate(),a=Go(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 kWe(t,s){const r=+Kn(t);return Go(t,r+s)}const Vje=6048e5,s4t=864e5,Tue=6e4,RR=36e5,r4t=1e3,Nz=43200,zPe=1440;function BPe(t,s){return kWe(t,s*RR)}let n4t={};function fw(){return n4t}function zh(t,s){var i,d,u,p;const r=fw(),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 Em(t){const s=Kn(t);return s.setHours(0,0,0,0),s}function Yb(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 tf(t,s){const r=Em(t),n=Em(s),a=+r-Yb(r),o=+n-Yb(n);return Math.round((a-o)/s4t)}function a4t(t){const s=SWe(t),r=Go(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),p1(r)}function Z5(t,s){return kWe(t,s*Tue)}function h4(t,s){const r=s*7;return cl(t,r)}function i4t(t,s){return Am(t,s*12)}function o4t(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 Oie(t,s){const r=Kn(t),n=Kn(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function Hje(t){return Go(t,Date.now())}function rl(t,s){const r=Em(t),n=Em(s);return+r==+n}function Gje(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function y1e(t){if(!Gje(t)&&typeof t!="number")return!1;const s=Kn(t);return!isNaN(Number(s))}function CT(t,s){const r=Kn(t),n=Kn(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function c4t(t,s,r){const n=zh(t,r),a=zh(s,r),o=+n-Yb(n),l=+a-Yb(a);return Math.round((o-l)/Vje)}function Bg(t,s){const r=Kn(t),n=Kn(s),a=$Pe(r,n),o=Math.abs(tf(r,n));r.setDate(r.getDate()-a*o);const l=+($Pe(r,n)===-a),i=a*(o-l);return i===0?0:i}function $Pe(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 CWe(t){return s=>{const n=(t?Math[t]:Math.trunc)(s);return n===0?0:n}}function MWe(t,s){return+Kn(t)-+Kn(s)}function d4t(t,s,r){const n=MWe(t,s)/RR;return CWe(r==null?void 0:r.roundingMethod)(n)}function u4t(t){const s=Kn(t);return s.setHours(23,59,59,999),s}function ex(t){const s=Kn(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function h4t(t){const s=Kn(t);return+u4t(s)==+ex(s)}function m4t(t,s){const r=Kn(t),n=Kn(s),a=Oie(r,n),o=Math.abs(CT(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=Oie(r,n)===-a;h4t(Kn(t))&&o===1&&Oie(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function p4t(t,s,r){const n=MWe(t,s)/1e3;return CWe(r==null?void 0:r.roundingMethod)(n)}function f4t(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 pc(t){const s=Kn(t);return s.setDate(1),s.setHours(0,0,0,0),s}function TWe(t){const s=Kn(t),r=Go(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Aue(t,s){var i,d,u,p;const r=fw(),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=x4t[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 xge(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const y4t={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},v4t={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},_4t={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},b4t={date:xge({formats:y4t,defaultWidth:"full"}),time:xge({formats:v4t,defaultWidth:"full"}),dateTime:xge({formats:_4t,defaultWidth:"full"})},w4t={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},j4t=(t,s,r,n)=>w4t[t];function K6(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 N4t={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},k4t={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},S4t={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"]},C4t={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"]},M4t={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"}},T4t={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"}},A4t=(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"},E4t={ordinalNumber:A4t,era:K6({values:N4t,defaultWidth:"wide"}),quarter:K6({values:k4t,defaultWidth:"wide",argumentCallback:t=>t-1}),month:K6({values:S4t,defaultWidth:"wide"}),day:K6({values:C4t,defaultWidth:"wide"}),dayPeriod:K6({values:M4t,defaultWidth:"wide",formattingValues:T4t,defaultFormattingWidth:"wide"})};function Z6(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)?I4t(i,x=>x.test(l)):P4t(i,x=>x.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 P4t(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function I4t(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 D4t=/^(\d+)(th|st|nd|rd)?/i,R4t=/\d+/i,O4t={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},F4t={any:[/^b/i,/^(a|c)/i]},z4t={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},B4t={any:[/1/i,/2/i,/3/i,/4/i]},$4t={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},q4t={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]},U4t={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},V4t={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]},H4t={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},G4t={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}},W4t={ordinalNumber:L4t({matchPattern:D4t,parsePattern:R4t,valueCallback:t=>parseInt(t,10)}),era:Z6({matchPatterns:O4t,defaultMatchWidth:"wide",parsePatterns:F4t,defaultParseWidth:"any"}),quarter:Z6({matchPatterns:z4t,defaultMatchWidth:"wide",parsePatterns:B4t,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Z6({matchPatterns:$4t,defaultMatchWidth:"wide",parsePatterns:q4t,defaultParseWidth:"any"}),day:Z6({matchPatterns:U4t,defaultMatchWidth:"wide",parsePatterns:V4t,defaultParseWidth:"any"}),dayPeriod:Z6({matchPatterns:H4t,defaultMatchWidth:"any",parsePatterns:G4t,defaultParseWidth:"any"})},Eue={code:"en-US",formatDistance:g4t,formatLong:b4t,formatRelative:j4t,localize:E4t,match:W4t,options:{weekStartsOn:0,firstWeekContainsDate:1}};function K4t(t){const s=Kn(t);return tf(s,TWe(s))+1}function Wje(t){const s=Kn(t),r=+p1(s)-+a4t(s);return Math.round(r/Vje)+1}function Kje(t,s){var p,x,y,_;const r=Kn(t),n=r.getFullYear(),a=fw(),o=(s==null?void 0:s.firstWeekContainsDate)??((x=(p=s==null?void 0:s.locale)==null?void 0:p.options)==null?void 0:x.firstWeekContainsDate)??a.firstWeekContainsDate??((_=(y=a.locale)==null?void 0:y.options)==null?void 0:_.firstWeekContainsDate)??1,l=Go(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=zh(l,s),d=Go(t,0);d.setFullYear(n,0,o),d.setHours(0,0,0,0);const u=zh(d,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function Z4t(t,s){var i,d,u,p;const r=fw(),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=Kje(t,s),o=Go(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),zh(o,s)}function Zje(t,s){const r=Kn(t),n=+zh(r,s)-+Z4t(r,s);return Math.round(n/Vje)+1}function Ho(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const f_={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return Ho(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):Ho(r+1,2)},d(t,s){return Ho(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 Ho(t.getHours()%12||12,s.length)},H(t,s){return Ho(t.getHours(),s.length)},m(t,s){return Ho(t.getMinutes(),s.length)},s(t,s){return Ho(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return Ho(a,s.length)}},u5={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},qPe={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 f_.y(t,s)},Y:function(t,s,r,n){const a=Kje(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return Ho(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):Ho(o,s.length)},R:function(t,s){const r=SWe(t);return Ho(r,s.length)},u:function(t,s){const r=t.getFullYear();return Ho(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 Ho(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 Ho(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 f_.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 Ho(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=Zje(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):Ho(a,s.length)},I:function(t,s,r){const n=Wje(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):Ho(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):f_.d(t,s)},D:function(t,s,r){const n=K4t(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):Ho(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 Ho(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 Ho(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 Ho(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=u5.noon:n===0?a=u5.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=u5.evening:n>=12?a=u5.afternoon:n>=4?a=u5.morning:a=u5.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 f_.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):f_.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):Ho(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):Ho(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):f_.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):f_.s(t,s)},S:function(t,s){return f_.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return VPe(n);case"XXXX":case"XX":return e4(n);case"XXXXX":case"XXX":default:return e4(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return VPe(n);case"xxxx":case"xx":return e4(n);case"xxxxx":case"xxx":default:return e4(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+UPe(n,":");case"OOOO":default:return"GMT"+e4(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+UPe(n,":");case"zzzz":default:return"GMT"+e4(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return Ho(n,s.length)},T:function(t,s,r){const n=t.getTime();return Ho(n,s.length)}};function UPe(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+Ho(o,2)}function VPe(t,s){return t%60===0?(t>0?"-":"+")+Ho(Math.abs(t)/60,2):e4(t,s)}function e4(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=Ho(Math.trunc(n/60),2),o=Ho(n%60,2);return r+a+s+o}const HPe=(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"})}},EWe=(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"})}},Y4t=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return HPe(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}}",HPe(n,s)).replace("{{time}}",EWe(a,s))},v1e={p:EWe,P:Y4t},X4t=/^D+$/,Q4t=/^Y+$/,J4t=["D","DD","YY","YYYY"];function PWe(t){return X4t.test(t)}function IWe(t){return Q4t.test(t)}function _1e(t,s,r){const n=eSt(t,s,r);if(console.warn(n),J4t.includes(t))throw new RangeError(n)}function eSt(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 tSt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,sSt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,rSt=/^'([^]*?)'?$/,nSt=/''/g,aSt=/[a-zA-Z]/;function ps(t,s,r){var p,x,y,_,b,N,w,k;const n=fw(),a=(r==null?void 0:r.locale)??n.locale??Eue,o=(r==null?void 0:r.firstWeekContainsDate)??((x=(p=r==null?void 0:r.locale)==null?void 0:p.options)==null?void 0:x.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??((k=(w=n.locale)==null?void 0:w.options)==null?void 0:k.weekStartsOn)??0,i=Kn(t);if(!y1e(i))throw new RangeError("Invalid time value");let d=s.match(sSt).map(C=>{const E=C[0];if(E==="p"||E==="P"){const L=v1e[E];return L(C,a.formatLong)}return C}).join("").match(tSt).map(C=>{if(C==="''")return{isToken:!1,value:"'"};const E=C[0];if(E==="'")return{isToken:!1,value:iSt(C)};if(qPe[E])return{isToken:!0,value:C};if(E.match(aSt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+E+"`");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 E=C.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&IWe(E)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&PWe(E))&&_1e(E,s,String(t));const L=qPe[E[0]];return L(i,E,a.localize,u)}).join("")}function iSt(t){const s=t.match(rSt);return s?s[1].replace(nSt,"'"):t}function oSt(t,s,r){const n=fw(),a=(r==null?void 0:r.locale)??n.locale??Eue,o=2520,l=Oie(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=p4t(u,d),x=(Yb(u)-Yb(d))/1e3,y=Math.round((p-x)/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 GS(t,s){const r=Kn(t),n=Kn(s);return+r<+n}function pSt(t){return+Kn(t)>Date.now()}function fSt(t,s){const r=s instanceof Date?Go(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 xSt=10;class LWe{constructor(){Sn(this,"subPriority",0)}validate(s,r){return!0}}class gSt extends LWe{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 ySt extends LWe{constructor(){super(...arguments);Sn(this,"priority",xSt);Sn(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:Go(r,fSt(r,Date))}}class Ro{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new gSt(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class vSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",140);Sn(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 pd={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},zy={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function fd(t,s){return t&&{value:s(t.value),rest:t.rest}}function Dc(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function By(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*RR+o*Tue+l*r4t),rest:s.slice(r[0].length)}}function DWe(t){return Dc(pd.anyDigitsSigned,t)}function nd(t,s){switch(t){case 1:return Dc(pd.singleDigit,s);case 2:return Dc(pd.twoDigits,s);case 3:return Dc(pd.threeDigits,s);case 4:return Dc(pd.fourDigits,s);default:return Dc(new RegExp("^\\d{1,"+t+"}"),s)}}function Koe(t,s){switch(t){case 1:return Dc(pd.singleDigitSigned,s);case 2:return Dc(pd.twoDigitsSigned,s);case 3:return Dc(pd.threeDigitsSigned,s);case 4:return Dc(pd.fourDigitsSigned,s);default:return Dc(new RegExp("^-?\\d{1,"+t+"}"),s)}}function Yje(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 RWe(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 OWe(t){return t%400===0||t%4===0&&t%100!==0}class _St extends Ro{constructor(){super(...arguments);Sn(this,"priority",130);Sn(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 fd(nd(4,r),o);case"yo":return fd(a.ordinalNumber(r,{unit:"year"}),o);default:return fd(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=RWe(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 bSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",130);Sn(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 fd(nd(4,r),o);case"Yo":return fd(a.ordinalNumber(r,{unit:"year"}),o);default:return fd(nd(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=Kje(r,o);if(a.isTwoDigitYear){const d=RWe(a.year,l);return r.setFullYear(d,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),zh(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),zh(r,o)}}class wSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",130);Sn(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return Koe(n==="R"?4:n.length,r)}set(r,n,a){const o=Go(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),p1(o)}}class jSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",130);Sn(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return Koe(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class NSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",120);Sn(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 kSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",120);Sn(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 SSt extends Ro{constructor(){super(...arguments);Sn(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);Sn(this,"priority",110)}parse(r,n,a){const o=l=>l-1;switch(n){case"M":return fd(Dc(pd.month,r),o);case"MM":return fd(nd(2,r),o);case"Mo":return fd(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 CSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",110);Sn(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 fd(Dc(pd.month,r),o);case"LL":return fd(nd(2,r),o);case"Lo":return fd(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 MSt(t,s,r){const n=Kn(t),a=Zje(n,r)-s;return n.setDate(n.getDate()-a*7),n}class TSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",100);Sn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,a){switch(n){case"w":return Dc(pd.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 zh(MSt(r,a,o),o)}}function ASt(t,s){const r=Kn(t),n=Wje(r)-s;return r.setDate(r.getDate()-n*7),r}class ESt extends Ro{constructor(){super(...arguments);Sn(this,"priority",100);Sn(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 Dc(pd.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 p1(ASt(r,a))}}const PSt=[31,28,31,30,31,30,31,31,30,31,30,31],ISt=[31,29,31,30,31,30,31,31,30,31,30,31];class LSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",90);Sn(this,"subPriority",1);Sn(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"d":return Dc(pd.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return nd(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=OWe(a),l=r.getMonth();return o?n>=1&&n<=ISt[l]:n>=1&&n<=PSt[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class DSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",90);Sn(this,"subpriority",1);Sn(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 Dc(pd.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return nd(n.length,r)}}validate(r,n){const a=r.getFullYear();return OWe(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 Xje(t,s,r){var x,y,_,b;const n=fw(),a=(r==null?void 0:r.weekStartsOn)??((y=(x=r==null?void 0:r.locale)==null?void 0:x.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 cl(o,p)}class RSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",90);Sn(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=Xje(r,a,o),r.setHours(0,0,0,0),r}}class OSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",90);Sn(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 fd(nd(n.length,r),l);case"eo":return fd(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=Xje(r,a,o),r.setHours(0,0,0,0),r}}class FSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",90);Sn(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 fd(nd(n.length,r),l);case"co":return fd(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=Xje(r,a,o),r.setHours(0,0,0,0),r}}function zSt(t,s){const r=Kn(t),n=dSt(r),a=s-n;return cl(r,a)}class BSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",90);Sn(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 fd(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 fd(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return fd(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return fd(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=zSt(r,a),r.setHours(0,0,0,0),r}}class $St extends Ro{constructor(){super(...arguments);Sn(this,"priority",80);Sn(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(Yje(a),0,0,0),r}}class qSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",80);Sn(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(Yje(a),0,0,0),r}}class USt extends Ro{constructor(){super(...arguments);Sn(this,"priority",80);Sn(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(Yje(a),0,0,0),r}}class VSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",70);Sn(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return Dc(pd.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 HSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",70);Sn(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,a){switch(n){case"H":return Dc(pd.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 GSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",70);Sn(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return Dc(pd.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 WSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",70);Sn(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,a){switch(n){case"k":return Dc(pd.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 KSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",60);Sn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return Dc(pd.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 ZSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",50);Sn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return Dc(pd.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 YSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",30);Sn(this,"incompatibleTokens",["t","T"])}parse(r,n){const a=o=>Math.trunc(o*Math.pow(10,-n.length+3));return fd(nd(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class XSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",10);Sn(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return By(zy.basicOptionalMinutes,r);case"XX":return By(zy.basic,r);case"XXXX":return By(zy.basicOptionalSeconds,r);case"XXXXX":return By(zy.extendedOptionalSeconds,r);case"XXX":default:return By(zy.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Go(r,r.getTime()-Yb(r)-a)}}class QSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",10);Sn(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return By(zy.basicOptionalMinutes,r);case"xx":return By(zy.basic,r);case"xxxx":return By(zy.basicOptionalSeconds,r);case"xxxxx":return By(zy.extendedOptionalSeconds,r);case"xxx":default:return By(zy.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Go(r,r.getTime()-Yb(r)-a)}}class JSt extends Ro{constructor(){super(...arguments);Sn(this,"priority",40);Sn(this,"incompatibleTokens","*")}parse(r){return DWe(r)}set(r,n,a){return[Go(r,a*1e3),{timestampIsSet:!0}]}}class eCt extends Ro{constructor(){super(...arguments);Sn(this,"priority",20);Sn(this,"incompatibleTokens","*")}parse(r){return DWe(r)}set(r,n,a){return[Go(r,a),{timestampIsSet:!0}]}}const tCt={G:new vSt,y:new _St,Y:new bSt,R:new wSt,u:new jSt,Q:new NSt,q:new kSt,M:new SSt,L:new CSt,w:new TSt,I:new ESt,d:new LSt,D:new DSt,E:new RSt,e:new OSt,c:new FSt,i:new BSt,a:new $St,b:new qSt,B:new USt,h:new VSt,H:new HSt,K:new GSt,k:new WSt,m:new KSt,s:new ZSt,S:new YSt,X:new XSt,x:new QSt,t:new JSt,T:new eCt},sCt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,rCt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,nCt=/^'([^]*?)'?$/,aCt=/''/g,iCt=/\S/,oCt=/[a-zA-Z]/;function Qje(t,s,r,n){var N,w,k,C;const a=cSt(),o=a.locale??Eue,l=a.firstWeekContainsDate??((w=(N=a.locale)==null?void 0:N.options)==null?void 0:w.firstWeekContainsDate)??1,i=a.weekStartsOn??((C=(k=a.locale)==null?void 0:k.options)==null?void 0:C.weekStartsOn)??0;if(s==="")return t===""?Kn(r):Go(r,NaN);const d={firstWeekContainsDate:l,weekStartsOn:i,locale:o},u=[new ySt],p=s.match(rCt).map(E=>{const L=E[0];if(L in v1e){const I=v1e[L];return I(E,o.formatLong)}return E}).join("").match(sCt),x=[];for(let E of p){IWe(E)&&_1e(E,s,t),PWe(E)&&_1e(E,s,t);const L=E[0],I=tCt[L];if(I){const{incompatibleTokens:O}=I;if(Array.isArray(O)){const q=x.find($=>O.includes($.token)||$.token===L);if(q)throw new RangeError(`The format string mustn't contain \`${q.fullToken}\` and \`${E}\` at the same time`)}else if(I.incompatibleTokens==="*"&&x.length>0)throw new RangeError(`The format string mustn't contain \`${E}\` and any other token at the same time`);x.push({token:L,fullToken:E});const V=I.run(t,E,o.match,d);if(!V)return Go(r,NaN);u.push(V.setter),t=V.rest}else{if(L.match(oCt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+L+"`");if(E==="''"?E="'":L==="'"&&(E=lCt(E)),t.indexOf(E)===0)t=t.slice(E.length);else return Go(r,NaN)}}if(t.length>0&&iCt.test(t))return Go(r,NaN);const y=u.map(E=>E.priority).sort((E,L)=>L-E).filter((E,L,I)=>I.indexOf(E)===L).map(E=>u.filter(L=>L.priority===E).sort((L,I)=>I.subPriority-L.subPriority)).map(E=>E[0]);let _=Kn(r);if(isNaN(_.getTime()))return Go(r,NaN);const b={};for(const E of y){if(!E.validate(_,d))return Go(r,NaN);const L=E.set(_,b,d);Array.isArray(L)?(_=L[0],Object.assign(b,L[1])):_=L}return Go(r,_)}function lCt(t){return t.match(nCt)[1].replace(aCt,"'")}function r0(t){return+Kn(t)o-l);return r>=n&&r<=a}function Fie(t,s){return cl(t,-s)}function xm(t,s){const n=fCt(t);let a;if(n.date){const d=xCt(n.date,2);a=gCt(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=yCt(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=vCt(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 kz={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},hCt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,mCt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,pCt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function fCt(t){const s={},r=t.split(kz.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],kz.timeZoneDelimiter.test(s.date)&&(s.date=t.split(kz.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=kz.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function xCt(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 gCt(t,s){if(s===null)return new Date(NaN);const r=t.match(hCt);if(!r)return new Date(NaN);const n=!!r[4],a=Y6(r[1]),o=Y6(r[2])-1,l=Y6(r[3]),i=Y6(r[4]),d=Y6(r[5])-1;if(n)return NCt(s,i,d)?_Ct(s,i,d):new Date(NaN);{const u=new Date(0);return!wCt(s,o,l)||!jCt(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function Y6(t){return t?parseInt(t):1}function yCt(t){const s=t.match(mCt);if(!s)return NaN;const r=gge(s[1]),n=gge(s[2]),a=gge(s[3]);return kCt(r,n,a)?r*RR+n*Tue+a*1e3:NaN}function gge(t){return t&&parseFloat(t.replace(",","."))||0}function vCt(t){if(t==="Z")return 0;const s=t.match(pCt);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return SCt(n,a)?r*(n*RR+a*Tue):NaN}function _Ct(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 bCt=[31,null,31,30,31,30,31,31,30,31,30,31];function FWe(t){return t%400===0||t%4===0&&t%100!==0}function wCt(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(bCt[s]||(FWe(t)?29:28))}function jCt(t,s){return s>=1&&s<=(FWe(t)?366:365)}function NCt(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function kCt(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function SCt(t,s){return s>=0&&s<=59}function yge(t,s){const r=Kn(t),n=r.getFullYear(),a=r.getDate(),o=Go(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=lSt(o);return r.setMonth(s,Math.min(a,l)),r}function WL(t,s){const r=Kn(t);return r.setHours(s),r}function KL(t,s){const r=Kn(t);return r.setMinutes(s),r}function WPe(t,s){const r=Kn(t);return isNaN(+r)?Go(t,NaN):(r.setFullYear(s),r)}function m4(t,s){return Am(t,-s)}var bo;(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})(bo||(bo={}));var KPe;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(KPe||(KPe={}));const ca=bo.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),E_=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=bo.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 b1e=(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,bo.jsonStringifyReplacer)}`;break;case Xr.unrecognized_keys:r=`Unrecognized key(s) in object: ${bo.joinValues(t.keys,", ")}`;break;case Xr.invalid_union:r="Invalid input";break;case Xr.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${bo.joinValues(t.options)}`;break;case Xr.invalid_enum_value:r=`Invalid enum value. Expected ${bo.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}"`:bo.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,bo.assertNever(t)}return{message:r}};let CCt=b1e;function MCt(){return CCt}const TCt=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=MCt(),n=TCt({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===b1e?void 0:b1e].filter(a=>!!a)});t.common.issues.push(n)}class xf{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(s,r){const n=[];for(const a of r){if(a.status==="aborted")return fi;a.status==="dirty"&&s.dirty(),n.push(a.value)}return{status:s.value,value:n}}static async mergeObjectAsync(s,r){const n=[];for(const a of r){const o=await a.key,l=await a.value;n.push({key:o,value:l})}return xf.mergeObjectSync(s,n)}static mergeObjectSync(s,r){const n={};for(const a of r){const{key:o,value:l}=a;if(o.status==="aborted"||l.status==="aborted")return fi;o.status==="dirty"&&s.dirty(),l.status==="dirty"&&s.dirty(),o.value!=="__proto__"&&(typeof l.value<"u"||a.alwaysSet)&&(n[o.value]=l.value)}return{status:s.value,value:n}}}const fi=Object.freeze({status:"aborted"}),AI=t=>({status:"dirty",value:t}),Ix=t=>({status:"valid",value:t}),ZPe=t=>t.status==="aborted",YPe=t=>t.status==="dirty",MT=t=>t.status==="valid",Zoe=t=>typeof Promise<"u"&&t instanceof Promise;var ma;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(ma||(ma={}));class Xb{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 XPe=(t,s)=>{if(MT(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 Ri(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 vo{get description(){return this._def.description}_getType(s){return E_(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:E_(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new xf,ctx:{common:s.parent.common,data:s.data,parsedType:E_(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(Zoe(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:E_(s)},a=this._parseSync({data:s,path:n.path,parent:n});return XPe(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:E_(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return MT(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=>MT(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:E_(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(Zoe(a)?a:Promise.resolve(a));return XPe(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 ET({schema:this,typeName:xi.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 Ib.create(this,this._def)}nullable(){return PT.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return n0.create(this)}promise(){return Joe.create(this,this._def)}or(s){return Xoe.create([this,s],this._def)}and(s){return Qoe.create(this,s,this._def)}transform(s){return new ET({...Ri(this._def),schema:this,typeName:xi.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new k1e({...Ri(this._def),innerType:this,defaultValue:r,typeName:xi.ZodDefault})}brand(){return new QCt({typeName:xi.ZodBranded,type:this,...Ri(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new S1e({...Ri(this._def),innerType:this,catchValue:r,typeName:xi.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return Jje.create(this,s)}readonly(){return C1e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ACt=/^c[^\s-]{8,}$/i,ECt=/^[0-9a-z]+$/,PCt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ICt=/^[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,LCt=/^[a-z0-9_-]{21}$/i,DCt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,RCt=/^[-+]?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)?)??$/,OCt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,FCt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let vge;const zCt=/^(?:(?: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])$/,BCt=/^(?:(?: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])$/,$Ct=/^(([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]))$/,qCt=/^(([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])$/,UCt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,VCt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,zWe="((\\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])))",HCt=new RegExp(`^${zWe}$`);function BWe(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 GCt(t){return new RegExp(`^${BWe(t)}$`)}function WCt(t){let s=`${zWe}T${BWe(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 KCt(t,s){return!!((s==="v4"||!s)&&zCt.test(t)||(s==="v6"||!s)&&$Ct.test(t))}function ZCt(t,s){if(!DCt.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 YCt(t,s){return!!((s==="v4"||!s)&&BCt.test(t)||(s==="v6"||!s)&&qCt.test(t))}class ob extends vo{_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}),fi}const n=new xf;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,...ma.errToObj(n)})}_addCheck(s){return new ob({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...ma.errToObj(s)})}url(s){return this._addCheck({kind:"url",...ma.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...ma.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...ma.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...ma.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...ma.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...ma.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...ma.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...ma.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...ma.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...ma.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...ma.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...ma.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,...ma.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,...ma.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",...ma.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...ma.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,...ma.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...ma.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...ma.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...ma.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...ma.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...ma.errToObj(r)})}nonempty(s){return this.min(1,ma.errToObj(s))}trim(){return new ob({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ob({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ob({...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 ob({checks:[],typeName:xi.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Ri(t)});function XCt(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 TT extends vo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(s){if(this._def.coerce&&(s.data=Number(s.data)),this._getType(s)!==ca.number){const o=this._getOrReturnCtx(s);return zn(o,{code:Xr.invalid_type,expected:ca.number,received:o.parsedType}),fi}let n;const a=new xf;for(const o of this._def.checks)o.kind==="int"?bo.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"?XCt(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()):bo.assertNever(o);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,ma.toString(r))}gt(s,r){return this.setLimit("min",s,!1,ma.toString(r))}lte(s,r){return this.setLimit("max",s,!0,ma.toString(r))}lt(s,r){return this.setLimit("max",s,!1,ma.toString(r))}setLimit(s,r,n,a){return new TT({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ma.toString(a)}]})}_addCheck(s){return new TT({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:ma.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ma.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ma.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ma.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ma.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:ma.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:ma.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ma.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ma.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"&&bo.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 TT({checks:[],typeName:xi.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Ri(t)});class tD extends vo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(s){if(this._def.coerce)try{s.data=BigInt(s.data)}catch{return this._getInvalidInput(s)}if(this._getType(s)!==ca.bigint)return this._getInvalidInput(s);let n;const a=new xf;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()):bo.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}),fi}gte(s,r){return this.setLimit("min",s,!0,ma.toString(r))}gt(s,r){return this.setLimit("min",s,!1,ma.toString(r))}lte(s,r){return this.setLimit("max",s,!0,ma.toString(r))}lt(s,r){return this.setLimit("max",s,!1,ma.toString(r))}setLimit(s,r,n,a){return new tD({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ma.toString(a)}]})}_addCheck(s){return new tD({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ma.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ma.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ma.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ma.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:ma.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 tD({checks:[],typeName:xi.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Ri(t)});class w1e extends vo{_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}),fi}return Ix(s.data)}}w1e.create=t=>new w1e({typeName:xi.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Ri(t)});class Yoe extends vo{_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}),fi}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return zn(o,{code:Xr.invalid_date}),fi}const n=new xf;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()):bo.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new Yoe({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:ma.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:ma.toString(r)})}get minDate(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s!=null?new Date(s):null}get maxDate(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.valuenew Yoe({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:xi.ZodDate,...Ri(t)});class QPe extends vo{_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}),fi}return Ix(s.data)}}QPe.create=t=>new QPe({typeName:xi.ZodSymbol,...Ri(t)});class JPe extends vo{_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}),fi}return Ix(s.data)}}JPe.create=t=>new JPe({typeName:xi.ZodUndefined,...Ri(t)});class e6e extends vo{_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}),fi}return Ix(s.data)}}e6e.create=t=>new e6e({typeName:xi.ZodNull,...Ri(t)});class t6e extends vo{constructor(){super(...arguments),this._any=!0}_parse(s){return Ix(s.data)}}t6e.create=t=>new t6e({typeName:xi.ZodAny,...Ri(t)});class s6e extends vo{constructor(){super(...arguments),this._unknown=!0}_parse(s){return Ix(s.data)}}s6e.create=t=>new s6e({typeName:xi.ZodUnknown,...Ri(t)});class Qb extends vo{_parse(s){const r=this._getOrReturnCtx(s);return zn(r,{code:Xr.invalid_type,expected:ca.never,received:r.parsedType}),fi}}Qb.create=t=>new Qb({typeName:xi.ZodNever,...Ri(t)});class r6e extends vo{_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}),fi}return Ix(s.data)}}r6e.create=t=>new r6e({typeName:xi.ZodVoid,...Ri(t)});class n0 extends vo{_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}),fi;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 Xb(r,l,r.path,i)))).then(l=>xf.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new Xb(r,l,r.path,i)));return xf.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new n0({...this._def,minLength:{value:s,message:ma.toString(r)}})}max(s,r){return new n0({...this._def,maxLength:{value:s,message:ma.toString(r)}})}length(s,r){return new n0({...this._def,exactLength:{value:s,message:ma.toString(r)}})}nonempty(s){return this.min(1,s)}}n0.create=(t,s)=>new n0({type:t,minLength:null,maxLength:null,exactLength:null,typeName:xi.ZodArray,...Ri(s)});function M5(t){if(t instanceof Wc){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=Ib.create(M5(n))}return new Wc({...t._def,shape:()=>s})}else return t instanceof n0?new n0({...t._def,type:M5(t.element)}):t instanceof Ib?Ib.create(M5(t.unwrap())):t instanceof PT?PT.create(M5(t.unwrap())):t instanceof WS?WS.create(t.items.map(s=>M5(s))):t}class Wc extends vo{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const s=this._def.shape(),r=bo.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}),fi}const{status:n,ctx:a}=this._processInputParams(s),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof Qb&&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],x=a.data[u];d.push({key:{status:"valid",value:u},value:p._parse(new Xb(a,x,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof Qb){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 x=a.data[p];d.push({key:{status:"valid",value:p},value:u._parse(new Xb(a,x,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of d){const x=await p.key,y=await p.value;u.push({key:x,value:y,alwaysSet:p.alwaysSet})}return u}).then(u=>xf.mergeObjectSync(n,u)):xf.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(s){return ma.errToObj,new Wc({...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:ma.errToObj(s).message??a}:{message:a}}}:{}})}strip(){return new Wc({...this._def,unknownKeys:"strip"})}passthrough(){return new Wc({...this._def,unknownKeys:"passthrough"})}extend(s){return new Wc({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new Wc({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:xi.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new Wc({...this._def,catchall:s})}pick(s){const r={};for(const n of bo.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Wc({...this._def,shape:()=>r})}omit(s){const r={};for(const n of bo.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new Wc({...this._def,shape:()=>r})}deepPartial(){return M5(this)}partial(s){const r={};for(const n of bo.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new Wc({...this._def,shape:()=>r})}required(s){const r={};for(const n of bo.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Ib;)o=o._def.innerType;r[n]=o}return new Wc({...this._def,shape:()=>r})}keyof(){return $We(bo.objectKeys(this.shape))}}Wc.create=(t,s)=>new Wc({shape:()=>t,unknownKeys:"strip",catchall:Qb.create(),typeName:xi.ZodObject,...Ri(s)});Wc.strictCreate=(t,s)=>new Wc({shape:()=>t,unknownKeys:"strict",catchall:Qb.create(),typeName:xi.ZodObject,...Ri(s)});Wc.lazycreate=(t,s)=>new Wc({shape:t,unknownKeys:"strip",catchall:Qb.create(),typeName:xi.ZodObject,...Ri(s)});class Xoe extends vo{_parse(s){const{ctx:r}=this._processInputParams(s),n=this._def.options;function a(o){for(const i of o)if(i.result.status==="valid")return i.result;for(const i of o)if(i.result.status==="dirty")return r.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(i=>new u0(i.ctx.common.issues));return zn(r,{code:Xr.invalid_union,unionErrors:l}),fi}if(r.common.async)return Promise.all(n.map(async o=>{const l={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:l}),ctx:l}})).then(a);{let o;const l=[];for(const 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}),fi}}get options(){return this._def.options}}Xoe.create=(t,s)=>new Xoe({options:t,typeName:xi.ZodUnion,...Ri(s)});function j1e(t,s){const r=E_(t),n=E_(s);if(t===s)return{valid:!0,data:t};if(r===ca.object&&n===ca.object){const a=bo.objectKeys(s),o=bo.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const d=j1e(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(ZPe(o)||ZPe(l))return fi;const i=j1e(o.value,l.value);return i.valid?((YPe(o)||YPe(l))&&r.dirty(),{status:r.value,value:i.data}):(zn(n,{code:Xr.invalid_intersection_types}),fi)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,l])=>a(o,l)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Qoe.create=(t,s,r)=>new Qoe({left:t,right:s,typeName:xi.ZodIntersection,...Ri(r)});class WS extends vo{_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}),fi;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 Xb(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>xf.mergeArray(r,l)):xf.mergeArray(r,o)}get items(){return this._def.items}rest(s){return new WS({...this._def,rest:s})}}WS.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new WS({items:t,typeName:xi.ZodTuple,rest:null,...Ri(s)})};class n6e extends vo{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ca.map)return zn(n,{code:Xr.invalid_type,expected:ca.map,received:n.parsedType}),fi;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,d],u)=>({key:a._parse(new Xb(n,i,n.path,[u,"key"])),value:o._parse(new Xb(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 fi;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}})}else{const i=new Map;for(const d of l){const u=d.key,p=d.value;if(u.status==="aborted"||p.status==="aborted")return fi;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}}}}n6e.create=(t,s,r)=>new n6e({valueType:s,keyType:t,typeName:xi.ZodMap,...Ri(r)});class sD extends vo{_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}),fi;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 fi;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 Xb(n,d,n.path,u)));return n.common.async?Promise.all(i).then(d=>l(d)):l(i)}min(s,r){return new sD({...this._def,minSize:{value:s,message:ma.toString(r)}})}max(s,r){return new sD({...this._def,maxSize:{value:s,message:ma.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}sD.create=(t,s)=>new sD({valueType:t,minSize:null,maxSize:null,typeName:xi.ZodSet,...Ri(s)});class a6e extends vo{get schema(){return this._def.getter()}_parse(s){const{ctx:r}=this._processInputParams(s);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}a6e.create=(t,s)=>new a6e({getter:t,typeName:xi.ZodLazy,...Ri(s)});class N1e extends vo{_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}),fi}return{status:"valid",value:s.data}}get value(){return this._def.value}}N1e.create=(t,s)=>new N1e({value:t,typeName:xi.ZodLiteral,...Ri(s)});function $We(t,s){return new AT({values:t,typeName:xi.ZodEnum,...Ri(s)})}class AT extends vo{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return zn(r,{expected:bo.joinValues(n),received:r.parsedType,code:Xr.invalid_type}),fi}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(s.data)){const r=this._getOrReturnCtx(s),n=this._def.values;return zn(r,{received:r.data,code:Xr.invalid_enum_value,options:n}),fi}return Ix(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 AT.create(s,{...this._def,...r})}exclude(s,r=this._def){return AT.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}AT.create=$We;class i6e extends vo{_parse(s){const r=bo.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==ca.string&&n.parsedType!==ca.number){const a=bo.objectValues(r);return zn(n,{expected:bo.joinValues(a),received:n.parsedType,code:Xr.invalid_type}),fi}if(this._cache||(this._cache=new Set(bo.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=bo.objectValues(r);return zn(n,{received:n.data,code:Xr.invalid_enum_value,options:a}),fi}return Ix(s.data)}get enum(){return this._def.values}}i6e.create=(t,s)=>new i6e({values:t,typeName:xi.ZodNativeEnum,...Ri(s)});class Joe extends vo{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}),fi;const n=r.parsedType===ca.promise?r.data:Promise.resolve(r.data);return Ix(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Joe.create=(t,s)=>new Joe({type:t,typeName:xi.ZodPromise,...Ri(s)});class ET extends vo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===xi.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 fi;const d=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return d.status==="aborted"?fi:d.status==="dirty"||r.value==="dirty"?AI(d.value):d});{if(r.value==="aborted")return fi;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?fi:i.status==="dirty"||r.value==="dirty"?AI(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"?fi:(i.status==="dirty"&&r.dirty(),l(i.value),{status:r.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?fi:(i.status==="dirty"&&r.dirty(),l(i.value).then(()=>({status:r.value,value:i.value}))))}if(a.type==="transform")if(n.common.async===!1){const l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!MT(l))return fi;const i=a.transform(l.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>MT(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):fi);bo.assertNever(a)}}ET.create=(t,s,r)=>new ET({schema:t,typeName:xi.ZodEffects,effect:s,...Ri(r)});ET.createWithPreprocess=(t,s,r)=>new ET({schema:s,effect:{type:"preprocess",transform:t},typeName:xi.ZodEffects,...Ri(r)});class Ib extends vo{_parse(s){return this._getType(s)===ca.undefined?Ix(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}Ib.create=(t,s)=>new Ib({innerType:t,typeName:xi.ZodOptional,...Ri(s)});class PT extends vo{_parse(s){return this._getType(s)===ca.null?Ix(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}PT.create=(t,s)=>new PT({innerType:t,typeName:xi.ZodNullable,...Ri(s)});class k1e extends vo{_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}}k1e.create=(t,s)=>new k1e({innerType:t,typeName:xi.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...Ri(s)});class S1e extends vo{_parse(s){const{ctx:r}=this._processInputParams(s),n={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Zoe(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}}S1e.create=(t,s)=>new S1e({innerType:t,typeName:xi.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...Ri(s)});class o6e extends vo{_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}),fi}return{status:"valid",value:s.data}}}o6e.create=t=>new o6e({typeName:xi.ZodNaN,...Ri(t)});class QCt extends vo{_parse(s){const{ctx:r}=this._processInputParams(s),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class Jje extends vo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?fi:o.status==="dirty"?(r.dirty(),AI(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?fi:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(s,r){return new Jje({in:s,out:r,typeName:xi.ZodPipeline})}}class C1e extends vo{_parse(s){const r=this._def.innerType._parse(s),n=a=>(MT(a)&&(a.value=Object.freeze(a.value)),a);return Zoe(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}C1e.create=(t,s)=>new C1e({innerType:t,typeName:xi.ZodReadonly,...Ri(s)});Wc.lazycreate;var xi;(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"})(xi||(xi={}));const Wl=ob.create,ZL=TT.create,JCt=w1e.create;Qb.create;n0.create;const bC=Wc.create;Wc.strictCreate;Xoe.create;Qoe.create;WS.create;const ele=N1e.create,qWe=AT.create;Joe.create;Ib.create;PT.create;const vr=S.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}));vr.displayName="Textarea";const e3t=["Excellent","Good","Neutral","Bad","Very Bad"],t3t=[5,4,3,2,1];function s3t({questions:t,visitorId:s,onComplete:r,onSkip:n}){const a=qkt(),[o,l]=S.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:_}}))},x=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"}),e3t.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}),t3t.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(vr,{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:x,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(_s,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}const r3t=bC({first_name:Wl().trim().min(1,"First name is required").max(50),last_name:Wl().trim().max(50).optional(),email:Wl().trim().email("Please enter a valid email").max(255).optional().or(ele("")),phone:Wl().trim().max(20).optional().or(ele(""))}),n3t=[{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 UWe({slug:t}={}){var _e;const s=co(),r=t||s.slug,{data:n,isLoading:a,error:o}=zkt(r),l=Kkt(),i=Zkt(),d=Ykt(),u=S.useRef(!1),[p,x]=S.useState("welcome"),[y,_]=S.useState(null),[b,N]=S.useState({first_name:"",last_name:"",email:"",phone:""}),[w,k]=S.useState(""),[C,E]=S.useState(!1),[L,I]=S.useState(!1),[O,V]=S.useState(""),[q,$]=S.useState(""),{data:U,isLoading:se}=$kt(n==null?void 0:n.id),Y=!!(n!=null&&n.enable_survey),J=(n==null?void 0:n.ask_visitor_intent)!==!1;S.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]),S.useEffect(()=>{p==="pending_survey"&&(se||x(Y&&((U==null?void 0:U.length)??0)>0?"survey":"done"))},[p,se,Y,U]);const X=he=>{if(!he)return"";const[we,je]=he.split(":"),Ue=parseInt(we),Te=Ue>=12?"PM":"AM";return`${Ue>12?Ue-12:Ue||12}:${je} ${Te}`},ce=async()=>{$("");const he=r3t.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:L,working_with_agent_name:L&&O.trim()?O.trim():void 0,partial_signin:J});_(we.id)}catch{}if(!J){Y?!se&&U&&U.length>0?x("survey"):x("pending_survey"):x("done");return}x("intent")},ie=async he=>{k(he);try{let we=y;we?await i.mutateAsync({visitor_id:we,visitor_intent:he,wants_market_updates:C,has_agent:L,working_with_agent_name:L&&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:L,working_with_agent_name:L&&O.trim()?O.trim():void 0,partial_signin:!1})).id,_(we)),Y?!se&&U&&U.length>0?x("survey"):x("pending_survey"):x("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 ae=n.profiles,oe=((_e=ae==null?void 0:ae.name)==null?void 0:_e.split(" ").map(he=>he[0]).join("").slice(0,2))||"?",pe=n.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs(wc,{children:[e.jsxs("title",{children:[pe?"Community Event":"Open House"," | ",n.property_address]}),e.jsx("meta",{name:"description",content:`Sign in to the ${pe?"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(Ta,{src:(ae==null?void 0:ae.avatar_url)||"",alt:(ae==null?void 0:ae.name)||""}),e.jsx(_n,{className:"bg-white/10 text-white text-lg",children:oe})]}),e.jsx("p",{className:"text-white/60 text-sm",children:ae==null?void 0:ae.name}),(ae==null?void 0:ae.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:ae.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(Da,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ps(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(ln,{className:"h-3 w-3"}),X(n.start_time),n.end_time?` – ${X(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:pe?e.jsx(pa,{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(Da,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ps(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(ln,{className:"h-3 w-3"}),X(n.start_time),n.end_time?` – ${X(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:()=>x("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",e.jsx(ei,{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:()=>x("welcome"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Fa,{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(xe,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(De,{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(xe,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(De,{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(xe,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(De,{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(xe,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(De,{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=>E(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:L?"Yes":"No"}),e.jsx(Er,{checked:L,onCheckedChange:I})]})]}),L&&e.jsx(De,{value:O,onChange:he=>V(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(ei,{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:()=>x("info"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Fa,{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:n3t.map(he=>e.jsxs("button",{onClick:()=>ie(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&&U&&e.jsx(s3t,{questions:U,visitorId:y,onComplete:()=>x("done"),onSkip:()=>x("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(Qn,{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,". ",pe?"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(fn,{className:"h-4 w-4"}),"View Seller's Disclosures"]}),(ae==null?void 0:ae.name)&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:ae.name})]})]})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function NTs(t){const{user:s}=Fs();return gt({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 kTs(){const t=Jt(),{user:s}=Fs();return It({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 STs(){const t=Jt();return It({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 a3t(t){return gt({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 eNe="ScrollArea",[VWe,CTs]=$c(eNe),[o3t,Lx]=VWe(eNe),HWe=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,d]=S.useState(null),[u,p]=S.useState(null),[x,y]=S.useState(null),[_,b]=S.useState(null),[N,w]=S.useState(null),[k,C]=S.useState(0),[E,L]=S.useState(0),[I,O]=S.useState(!1),[V,q]=S.useState(!1),$=Aa(s,se=>d(se)),U=uw(a);return e.jsx(o3t,{scope:r,type:n,dir:U,scrollHideDelay:o,scrollArea:i,viewport:u,onViewportChange:p,content:x,onContentChange:y,scrollbarX:_,onScrollbarXChange:b,scrollbarXEnabled:I,onScrollbarXEnabledChange:O,scrollbarY:N,onScrollbarYChange:w,scrollbarYEnabled:V,onScrollbarYEnabledChange:q,onCornerWidthChange:C,onCornerHeightChange:L,children:e.jsx(Yr.div,{dir:U,...l,ref:$,style:{position:"relative","--radix-scroll-area-corner-width":k+"px","--radix-scroll-area-corner-height":E+"px",...t.style}})})});HWe.displayName=eNe;var GWe="ScrollAreaViewport",WWe=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=Lx(GWe,r),i=S.useRef(null),d=Aa(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(Yr.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})})]})});WWe.displayName=GWe;var w0="ScrollAreaScrollbar",tNe=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Lx(w0,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return S.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?e.jsx(l3t,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(c3t,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx(KWe,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(sNe,{...n,ref:s}):null});tNe.displayName=w0;var l3t=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Lx(w0,t.__scopeScrollArea),[o,l]=S.useState(!1);return S.useEffect(()=>{const i=a.scrollArea;let d=0;if(i){const u=()=>{window.clearTimeout(d),l(!0)},p=()=>{d=window.setTimeout(()=>l(!1),a.scrollHideDelay)};return i.addEventListener("pointerenter",u),i.addEventListener("pointerleave",p),()=>{window.clearTimeout(d),i.removeEventListener("pointerenter",u),i.removeEventListener("pointerleave",p)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(wd,{present:r||o,children:e.jsx(KWe,{"data-state":o?"visible":"hidden",...n,ref:s})})}),c3t=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Lx(w0,t.__scopeScrollArea),o=t.orientation==="horizontal",l=Lue(()=>d("SCROLL_END"),100),[i,d]=i3t("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return S.useEffect(()=>{if(i==="idle"){const u=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,a.scrollHideDelay,d]),S.useEffect(()=>{const u=a.viewport,p=o?"scrollLeft":"scrollTop";if(u){let x=u[p];const y=()=>{const _=u[p];x!==_&&(d("SCROLL"),l()),x=_};return u.addEventListener("scroll",y),()=>u.removeEventListener("scroll",y)}},[a.viewport,o,d,l]),e.jsx(wd,{present:r||i!=="hidden",children:e.jsx(sNe,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Cr(t.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Cr(t.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),KWe=S.forwardRef((t,s)=>{const r=Lx(w0,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=S.useState(!1),i=t.orientation==="horizontal",d=Lue(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=Lx(w0,t.__scopeScrollArea),o=S.useRef(null),l=S.useRef(0),[i,d]=S.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=JWe(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 x(y,_){return f3t(y,l.current,i,_)}return r==="horizontal"?e.jsx(d3t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const y=a.viewport.scrollLeft,_=l6e(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=x(y,a.dir))}}):r==="vertical"?e.jsx(u3t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const y=a.viewport.scrollTop,_=l6e(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=x(y))}}):null}),d3t=S.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Lx(w0,t.__scopeScrollArea),[l,i]=S.useState(),d=S.useRef(null),u=Aa(s,d,o.onScrollbarXChange);return S.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(YWe,{"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":Iue(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,x)=>{if(o.viewport){const y=o.viewport.scrollLeft+p.deltaX;t.onWheelScroll(y),tKe(y,x)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:sle(l.paddingLeft),paddingEnd:sle(l.paddingRight)}})}})}),u3t=S.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Lx(w0,t.__scopeScrollArea),[l,i]=S.useState(),d=S.useRef(null),u=Aa(s,d,o.onScrollbarYChange);return S.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(YWe,{"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":Iue(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,x)=>{if(o.viewport){const y=o.viewport.scrollTop+p.deltaY;t.onWheelScroll(y),tKe(y,x)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:sle(l.paddingTop),paddingEnd:sle(l.paddingBottom)}})}})}),[h3t,ZWe]=VWe(w0),YWe=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:p,onResize:x,...y}=t,_=Lx(w0,r),[b,N]=S.useState(null),w=Aa(s,$=>N($)),k=S.useRef(null),C=S.useRef(""),E=_.viewport,L=n.content-n.viewport,I=ed(p),O=ed(d),V=Lue(x,10);function q($){if(k.current){const U=$.clientX-k.current.left,se=$.clientY-k.current.top;u({x:U,y:se})}}return S.useEffect(()=>{const $=U=>{const se=U.target;(b==null?void 0:b.contains(se))&&I(U,L)};return document.addEventListener("wheel",$,{passive:!1}),()=>document.removeEventListener("wheel",$,{passive:!1})},[E,b,L,I]),S.useEffect(O,[n,O]),IT(b,V),IT(_.content,V),e.jsx(h3t,{scope:r,scrollbar:b,hasThumb:a,onThumbChange:ed(o),onThumbPointerUp:ed(l),onThumbPositionChange:O,onThumbPointerDown:ed(i),children:e.jsx(Yr.div,{...y,ref:w,style:{position:"absolute",...y.style},onPointerDown:Cr(t.onPointerDown,$=>{$.button===0&&($.target.setPointerCapture($.pointerId),k.current=b.getBoundingClientRect(),C.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",_.viewport&&(_.viewport.style.scrollBehavior="auto"),q($))}),onPointerMove:Cr(t.onPointerMove,q),onPointerUp:Cr(t.onPointerUp,$=>{const U=$.target;U.hasPointerCapture($.pointerId)&&U.releasePointerCapture($.pointerId),document.body.style.webkitUserSelect=C.current,_.viewport&&(_.viewport.style.scrollBehavior=""),k.current=null})})})}),tle="ScrollAreaThumb",XWe=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=ZWe(tle,t.__scopeScrollArea);return e.jsx(wd,{present:r||a.hasThumb,children:e.jsx(m3t,{ref:s,...n})})}),m3t=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=Lx(tle,r),l=ZWe(tle,r),{onThumbPositionChange:i}=l,d=Aa(s,x=>l.onThumbChange(x)),u=S.useRef(void 0),p=Lue(()=>{u.current&&(u.current(),u.current=void 0)},100);return S.useEffect(()=>{const x=o.viewport;if(x){const y=()=>{if(p(),!u.current){const _=x3t(x,i);u.current=_,i()}};return i(),x.addEventListener("scroll",y),()=>x.removeEventListener("scroll",y)}},[o.viewport,p,i]),e.jsx(Yr.div,{"data-state":l.hasThumb?"visible":"hidden",...a,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Cr(t.onPointerDownCapture,x=>{const _=x.target.getBoundingClientRect(),b=x.clientX-_.left,N=x.clientY-_.top;l.onThumbPointerDown({x:b,y:N})}),onPointerUp:Cr(t.onPointerUp,l.onThumbPointerUp)})});XWe.displayName=tle;var rNe="ScrollAreaCorner",QWe=S.forwardRef((t,s)=>{const r=Lx(rNe,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(p3t,{...t,ref:s}):null});QWe.displayName=rNe;var p3t=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=Lx(rNe,r),[o,l]=S.useState(0),[i,d]=S.useState(0),u=!!(o&&i);return IT(a.scrollbarX,()=>{var x;const p=((x=a.scrollbarX)==null?void 0:x.offsetHeight)||0;a.onCornerHeightChange(p),d(p)}),IT(a.scrollbarY,()=>{var x;const p=((x=a.scrollbarY)==null?void 0:x.offsetWidth)||0;a.onCornerWidthChange(p),l(p)}),u?e.jsx(Yr.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 sle(t){return t?parseInt(t,10):0}function JWe(t,s){const r=t/s;return isNaN(r)?0:r}function Iue(t){const s=JWe(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function f3t(t,s,r,n="ltr"){const a=Iue(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,x=n==="ltr"?[0,p]:[p*-1,0];return eKe([d,u],x)(t)}function l6e(t,s,r="ltr"){const n=Iue(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=eD(t,d);return eKe([0,l],[0,i])(u)}function eKe(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 tKe(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 Lue(t,s){const r=ed(t),n=S.useRef(0);return S.useEffect(()=>()=>window.clearTimeout(n.current),[]),S.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function IT(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 sKe=HWe,g3t=WWe,y3t=QWe;const ui=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(sKe,{ref:n,className:Rt("relative overflow-hidden",t),...r,children:[e.jsx(g3t,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(Due,{}),e.jsx(y3t,{})]}));ui.displayName=sKe.displayName;const Due=S.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(tNe,{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(XWe,{className:"relative flex-1 rounded-full bg-border"})}));Due.displayName=tNe.displayName;const nNe=S.createContext({});function aNe(t){const s=S.useRef(null);return s.current===null&&(s.current=t()),s.current}const v3t=typeof window<"u",rKe=v3t?S.useLayoutEffect:S.useEffect,Rue=S.createContext(null);function iNe(t,s){t.indexOf(s)===-1&&t.push(s)}function rle(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const h0=(t,s,r)=>r>s?s:r{},LT=()=>{};const Jb={},nKe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function aKe(t){return typeof t=="object"&&t!==null}const iKe=t=>/^0[^.\s]+$/u.test(t);function oKe(t){let s;return()=>(s===void 0&&(s=t()),s)}const _x=t=>t,_3t=(t,s)=>r=>s(t(r)),OR=(...t)=>t.reduce(_3t),rD=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class oNe{constructor(){this.subscriptions=[]}add(s){return iNe(this.subscriptions,s),()=>rle(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,ux=t=>t/1e3;function lKe(t,s){return s?t*(1e3/s):0}const cKe=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,b3t=1e-7,w3t=12;function j3t(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=cKe(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>b3t&&++ij3t(o,0,1,t,r);return o=>o===0||o===1?o:cKe(a(o),s,n)}const dKe=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,uKe=t=>s=>1-t(1-s),hKe=FR(.33,1.53,.69,.99),lNe=uKe(hKe),mKe=dKe(lNe),pKe=t=>t>=1?1:(t*=2)<1?.5*lNe(t):.5*(2-Math.pow(2,-10*(t-1))),cNe=t=>1-Math.sin(Math.acos(t)),fKe=uKe(cNe),xKe=dKe(cNe),N3t=FR(.42,0,1,1),k3t=FR(0,0,.58,1),gKe=FR(.42,0,.58,1),S3t=t=>Array.isArray(t)&&typeof t[0]!="number",yKe=t=>Array.isArray(t)&&typeof t[0]=="number",c6e={linear:_x,easeIn:N3t,easeInOut:gKe,easeOut:k3t,circIn:cNe,circInOut:xKe,circOut:fKe,backIn:lNe,backInOut:mKe,backOut:hKe,anticipate:pKe},C3t=t=>typeof t=="string",d6e=t=>{if(yKe(t)){LT(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[s,r,n,a]=t;return FR(s,r,n,a)}else if(C3t(t))return LT(c6e[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),c6e[t];return t},Sz=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],u6e={value:null,addProjectionMetrics:null};function M3t(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},d=0;function u(x){l.has(x)&&(p.schedule(x),t()),d++,x(i)}const p={schedule:(x,y=!1,_=!1)=>{const N=_&&a?r:n;return y&&l.add(x),N.add(x),x},cancel:x=>{n.delete(x),l.delete(x)},process:x=>{if(i=x,a){o=!0;return}a=!0;const y=r;r=n,n=y,r.forEach(u),s&&u6e.value&&u6e.value.frameloop[s].push(d),d=0,r.clear(),a=!1,o&&(o=!1,p.process(x))}};return p}const T3t=40;function vKe(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=Sz.reduce((E,L)=>(E[L]=M3t(o,s?L:void 0),E),{}),{setup:i,read:d,resolveKeyframes:u,preUpdate:p,update:x,preRender:y,render:_,postRender:b}=l,N=()=>{const E=Jb.useManualTiming,L=E?a.timestamp:performance.now();r=!1,E||(a.delta=n?1e3/60:Math.max(Math.min(L-a.timestamp,T3t),1)),a.timestamp=L,a.isProcessing=!0,i.process(a),d.process(a),u.process(a),p.process(a),x.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:Sz.reduce((E,L)=>{const I=l[L];return E[L]=(O,V=!1,q=!1)=>(r||w(),I.schedule(O,V,q)),E},{}),cancel:E=>{for(let L=0;L(zie===void 0&&gm.set(eh.isProcessing||Jb.useManualTiming?eh.timestamp:performance.now()),zie),set:t=>{zie=t,queueMicrotask(A3t)}},_Ke=t=>s=>typeof s=="string"&&s.startsWith(t),bKe=_Ke("--"),E3t=_Ke("var(--"),dNe=t=>E3t(t)?P3t.test(t.split("/*")[0].trim()):!1,P3t=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function h6e(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const UA={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},nD={...UA,transform:t=>h0(0,1,t)},Cz={...UA,default:1},YL=t=>Math.round(t*1e5)/1e5,uNe=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function I3t(t){return t==null}const L3t=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,hNe=(t,s)=>r=>!!(typeof r=="string"&&L3t.test(r)&&r.startsWith(t)||s&&!I3t(r)&&Object.prototype.hasOwnProperty.call(r,s)),wKe=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(uNe);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},D3t=t=>h0(0,255,t),bge={...UA,transform:t=>Math.round(D3t(t))},p4={test:hNe("rgb","red"),parse:wKe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+bge.transform(t)+", "+bge.transform(s)+", "+bge.transform(r)+", "+YL(nD.transform(n))+")"};function R3t(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 M1e={test:hNe("#"),parse:R3t,transform:p4.transform},zR=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),N_=zR("deg"),a0=zR("%"),ra=zR("px"),O3t=zR("vh"),F3t=zR("vw"),m6e={...a0,parse:t=>a0.parse(t)/100,transform:t=>a0.transform(t*100)},Y5={test:hNe("hsl","hue"),parse:wKe("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+a0.transform(YL(s))+", "+a0.transform(YL(r))+", "+YL(nD.transform(n))+")"},Ld={test:t=>p4.test(t)||M1e.test(t)||Y5.test(t),parse:t=>p4.test(t)?p4.parse(t):Y5.test(t)?Y5.parse(t):M1e.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?p4.transform(t):Y5.transform(t),getAnimatableNone:t=>{const s=Ld.parse(t);return s.alpha=0,Ld.transform(s)}},z3t=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function B3t(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(uNe))==null?void 0:s.length)||0)+(((r=t.match(z3t))==null?void 0:r.length)||0)>0}const jKe="number",NKe="color",$3t="var",q3t="var(",p6e="${}",U3t=/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 DT(t){const s=t.toString(),r=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=s.replace(U3t,d=>(Ld.test(d)?(n.color.push(o),a.push(NKe),r.push(Ld.parse(d))):d.startsWith(q3t)?(n.var.push(o),a.push($3t),r.push(d)):(n.number.push(o),a.push(jKe),r.push(parseFloat(d))),++o,p6e)).split(p6e);return{values:r,split:i,indexes:n,types:a}}function V3t(t){return DT(t).values}function kKe({split:t,types:s}){const r=t.length;return n=>{let a="";for(let o=0;otypeof t=="number"?0:Ld.test(t)?Ld.getAnimatableNone(t):t,W3t=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:G3t(t);function K3t(t){const s=DT(t);return kKe(s)(s.values.map((n,a)=>W3t(n,s.split[a])))}const Lg={test:B3t,parse:V3t,createTransformer:H3t,getAnimatableNone:K3t};function wge(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 Z3t({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=wge(d,i,t+1/3),o=wge(d,i,t),l=wge(d,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function nle(t,s){return r=>r>0?s:t}const Ql=(t,s,r)=>t+(s-t)*r,jge=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},Y3t=[M1e,p4,Y5],X3t=t=>Y3t.find(s=>s.test(t));function f6e(t){const s=X3t(t);if(Oue(!!s,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!s)return!1;let r=s.parse(t);return s===Y5&&(r=Z3t(r)),r}const x6e=(t,s)=>{const r=f6e(t),n=f6e(s);if(!r||!n)return nle(t,s);const a={...r};return o=>(a.red=jge(r.red,n.red,o),a.green=jge(r.green,n.green,o),a.blue=jge(r.blue,n.blue,o),a.alpha=Ql(r.alpha,n.alpha,o),p4.transform(a))},T1e=new Set(["none","hidden"]);function Q3t(t,s){return T1e.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function J3t(t,s){return r=>Ql(t,s,r)}function mNe(t){return typeof t=="number"?J3t:typeof t=="string"?dNe(t)?nle:Ld.test(t)?x6e:s5t:Array.isArray(t)?SKe:typeof t=="object"?Ld.test(t)?x6e:e5t:nle}function SKe(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>mNe(o)(o,s[l]));return o=>{for(let l=0;l{for(const o in n)r[o]=n[o](a);return r}}function t5t(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=Lg.createTransformer(s),n=DT(t),a=DT(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?T1e.has(t)&&!a.values.length||T1e.has(s)&&!n.values.length?Q3t(t,s):OR(SKe(t5t(n,a),a.values),r):(Oue(!0,`Complex values '${t}' and '${s}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),nle(t,s))};function CKe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?Ql(t,s,r):mNe(t)(t,s)}const r5t=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>hl.update(s,r),stop:()=>ew(s),now:()=>eh.isProcessing?eh.timestamp:gm.now()}},MKe=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=ale?1/0:s}function n5t(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(pNe(n),ale);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:ux(a)}}const Pc={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 A1e(t,s){return t*Math.sqrt(1-s*s)}const a5t=12;function i5t(t,s,r){let n=r;for(let a=1;a{const p=u*l,x=p*t,y=p-r,_=A1e(u,l),b=Math.exp(-x);return Nge-y/_*b},o=u=>{const x=u*l*t,y=x*r+r,_=Math.pow(l,2)*Math.pow(u,2)*t,b=Math.exp(-x),N=A1e(Math.pow(u,2),l);return(-a(u)+Nge>0?-1:1)*((y-_)*b)/N}):(a=u=>{const p=Math.exp(-u*t),x=(u-r)*t+1;return-Nge+p*x},o=u=>{const p=Math.exp(-u*t),x=(r-u)*(t*t);return p*x});const i=5/t,d=i5t(a,o,i);if(t=gp(t),isNaN(d))return{stiffness:Pc.stiffness,damping:Pc.damping,duration:t};{const u=Math.pow(d,2)*n;return{stiffness:u,damping:l*2*Math.sqrt(n*u),duration:t}}}const l5t=["duration","bounce"],c5t=["stiffness","damping","mass"];function g6e(t,s){return s.some(r=>t[r]!==void 0)}function d5t(t){let s={velocity:Pc.velocity,stiffness:Pc.stiffness,damping:Pc.damping,mass:Pc.mass,isResolvedFromDuration:!1,...t};if(!g6e(t,c5t)&&g6e(t,l5t))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:Pc.mass,stiffness:a,damping:o}}else{const r=o5t({...t,velocity:0});s={...s,...r,mass:Pc.mass},s.isResolvedFromDuration=!0}return s}function ile(t=Pc.visualDuration,s=Pc.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:x,velocity:y,isResolvedFromDuration:_}=d5t({...r,velocity:-ux(r.velocity||0)}),b=y||0,N=u/(2*Math.sqrt(d*p)),w=l-o,k=ux(Math.sqrt(d/p)),C=Math.abs(w)<5;n||(n=C?Pc.restSpeed.granular:Pc.restSpeed.default),a||(a=C?Pc.restDelta.granular:Pc.restDelta.default);let E,L,I,O,V,q;if(N<1)I=A1e(k,N),O=(b+N*k*w)/I,E=U=>{const se=Math.exp(-N*k*U);return l-se*(O*Math.sin(I*U)+w*Math.cos(I*U))},V=N*k*O+w*I,q=N*k*w-O*I,L=U=>Math.exp(-N*k*U)*(V*Math.sin(I*U)+q*Math.cos(I*U));else if(N===1){E=se=>l-Math.exp(-k*se)*(w+(b+k*w)*se);const U=b+k*w;L=se=>Math.exp(-k*se)*(k*U*se-b)}else{const U=k*Math.sqrt(N*N-1);E=X=>{const ce=Math.exp(-N*k*X),ie=Math.min(U*X,300);return l-ce*((b+N*k*w)*Math.sinh(ie)+U*w*Math.cosh(ie))/U};const se=(b+N*k*w)/U,Y=N*k*se-w*U,J=N*k*w-se*U;L=X=>{const ce=Math.exp(-N*k*X),ie=Math.min(U*X,300);return ce*(Y*Math.sinh(ie)+J*Math.cosh(ie))}}const $={calculatedDuration:_&&x||null,velocity:U=>gp(L(U)),next:U=>{if(!_&&N<1){const Y=Math.exp(-N*k*U),J=Math.sin(I*U),X=Math.cos(I*U),ce=l-Y*(O*J+w*X),ie=gp(Y*(V*J+q*X));return i.done=Math.abs(ie)<=n&&Math.abs(l-ce)<=a,i.value=i.done?l:ce,i}const se=E(U);if(_)i.done=U>=x;else{const Y=gp(L(U));i.done=Math.abs(Y)<=n&&Math.abs(l-se)<=a}return i.value=i.done?l:se,i},toString:()=>{const U=Math.min(pNe($),ale),se=MKe(Y=>$.next(U*Y).value,U,30);return U+"ms "+se},toTransition:()=>{}};return $}ile.applyToOptions=t=>{const s=n5t(t,100,ile);return t.ease=s.ease,t.duration=gp(s.duration),t.type="keyframes",t};const u5t=5;function TKe(t,s,r){const n=Math.max(s-u5t,0);return lKe(r-t(n),s-n)}function E1e({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 x=t[0],y={done:!1,value:x},_=q=>i!==void 0&&qd,b=q=>i===void 0?d:d===void 0||Math.abs(i-q)-N*Math.exp(-q/n),E=q=>k+C(q),L=q=>{const $=C(q),U=E(q);y.done=Math.abs($)<=u,y.value=y.done?k:U};let I,O;const V=q=>{_(y.value)&&(I=q,O=ile({keyframes:[y.value,b(y.value)],velocity:TKe(E,q,y.value),damping:a,stiffness:o,restDelta:u,restSpeed:p}))};return V(0),{calculatedDuration:null,next:q=>{let $=!1;return!O&&I===void 0&&($=!0,L(q),V(q)),I!==void 0&&q>=I?O.next(q-I):(!$&&L(q),y)}}}function h5t(t,s,r){const n=[],a=r||Jb.mix||CKe,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=h5t(s,n,a),d=i.length,u=p=>{if(l&&p1)for(;xu(h0(t[0],t[o-1],p)):u}function p5t(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=rD(0,s,n);t.push(Ql(r,1,a))}}function f5t(t){const s=[0];return p5t(s,t.length-1),s}function x5t(t,s){return t.map(r=>r*s)}function g5t(t,s){return t.map(()=>s||gKe).splice(0,t.length-1)}function XL({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=S3t(n)?n.map(d6e):d6e(n),o={done:!1,value:s[0]},l=x5t(r&&r.length===s.length?r:f5t(s),t),i=m5t(l,s,{ease:Array.isArray(a)?a:g5t(s,a)});return{calculatedDuration:t,next:d=>(o.value=i(d),o.done=d>=t,o)}}const y5t=t=>t!==null;function Fue(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(y5t),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const v5t={decay:E1e,inertia:E1e,tween:XL,keyframes:XL,spring:ile};function AKe(t){typeof t.type=="string"&&(t.type=v5t[t.type])}class fNe{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 _5t=t=>t/100;class ole extends fNe{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!==gm.now()&&this.tick(gm.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;AKe(s);const{type:r=XL,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const d=r||XL;d!==XL&&typeof i[0]!="number"&&(this.mixKeyframes=OR(_5t,CKe(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=pNe(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:x,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 k=this.currentTime-u*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?k<0:k>a;this.currentTime=Math.max(k,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let E=this.currentTime,L=n;if(x){const q=Math.min(this.currentTime,a)/i;let $=Math.floor(q),U=q%1;!U&&q>=1&&(U=1),U===1&&$--,$=Math.min($,x+1),!!($%2)&&(y==="reverse"?(U=1-U,_&&(U-=_/i)):y==="mirror"&&(L=l)),E=h0(0,1,U)*i}let I;C?(this.delayState.value=p[0],I=this.delayState):I=L.next(E),o&&!C&&(I.value=o(I.value));let{done:O}=I;!C&&d!==null&&(O=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const V=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&O);return V&&b!==E1e&&(I.value=Fue(p,this.options,w,this.speed)),N&&N(I.value),V&&this.finish(),I}then(s,r){return this.finished.then(s,r)}get duration(){return ux(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+ux(s)}get time(){return ux(this.currentTime)}set time(s){s=gp(s),this.currentTime=s,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=s:this.driver&&(this.startTime=this.driver.now()-s/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=s,this.tick(s))}getGeneratorVelocity(){const s=this.currentTime;if(s<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(s);const r=this.generator.next(s).value;return TKe(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(gm.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=ux(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:s=r5t,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(gm.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 b5t(t){for(let s=1;st*180/Math.PI,P1e=t=>{const s=f4(Math.atan2(t[1],t[0]));return I1e(s)},w5t={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:P1e,rotateZ:P1e,skewX:t=>f4(Math.atan(t[1])),skewY:t=>f4(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},I1e=t=>(t=t%360,t<0&&(t+=360),t),y6e=P1e,v6e=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),_6e=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),j5t={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:v6e,scaleY:_6e,scale:t=>(v6e(t)+_6e(t))/2,rotateX:t=>I1e(f4(Math.atan2(t[6],t[5]))),rotateY:t=>I1e(f4(Math.atan2(-t[2],t[0]))),rotateZ:y6e,rotate:y6e,skewX:t=>f4(Math.atan(t[4])),skewY:t=>f4(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function L1e(t){return t.includes("scale")?1:0}function D1e(t,s){if(!t||t==="none")return L1e(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=j5t,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=w5t,a=i}if(!a)return L1e(s);const o=n[s],l=a[1].split(",").map(k5t);return typeof o=="function"?o(l):l[o]}const N5t=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return D1e(r,s)};function k5t(t){return parseFloat(t.trim())}const VA=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],HA=new Set(VA),b6e=t=>t===UA||t===ra,S5t=new Set(["x","y","z"]),C5t=VA.filter(t=>!S5t.has(t));function M5t(t){const s=[];return C5t.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const lb={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})=>D1e(s,"x"),y:(t,{transform:s})=>D1e(s,"y")};lb.translateX=lb.x;lb.translateY=lb.y;const _S=new Set;let R1e=!1,O1e=!1,F1e=!1;function EKe(){if(O1e){const t=Array.from(_S).filter(n=>n.needsMeasurement),s=new Set(t.map(n=>n.element)),r=new Map;s.forEach(n=>{const a=M5t(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)})}O1e=!1,R1e=!1,_S.forEach(t=>t.complete(F1e)),_S.clear()}function PKe(){_S.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(O1e=!0)})}function T5t(){F1e=!0,PKe(),EKe(),F1e=!1}class xNe{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?(_S.add(this),R1e||(R1e=!0,hl.read(PKe),hl.resolveKeyframes(EKe))):(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])}b5t(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),_S.delete(this)}cancel(){this.state==="scheduled"&&(_S.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const A5t=t=>t.startsWith("--");function IKe(t,s,r){A5t(s)?t.style.setProperty(s,r):t.style[s]=r}const E5t={};function LKe(t,s){const r=oKe(t);return()=>E5t[s]??r()}const P5t=LKe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),DKe=LKe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),EI=([t,s,r,n])=>`cubic-bezier(${t}, ${s}, ${r}, ${n})`,w6e={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:EI([0,.65,.55,1]),circOut:EI([.55,0,1,.45]),backIn:EI([.31,.01,.66,-.59]),backOut:EI([.33,1.53,.69,.99])};function RKe(t,s){if(t)return typeof t=="function"?DKe()?MKe(t,s):"ease-out":yKe(t)?EI(t):Array.isArray(t)?t.map(r=>RKe(r,s)||w6e.easeOut):w6e[t]}function I5t(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 x=RKe(i,a);Array.isArray(x)&&(p.easing=x);const y={delay:n,duration:a,easing:Array.isArray(x)?"linear":x,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return u&&(y.pseudoElement=u),t.animate(p,y)}function OKe(t){return typeof t=="function"&&"applyToOptions"in t}function L5t({type:t,...s}){return OKe(t)&&DKe()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class FKe extends fNe{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,LT(typeof s.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=L5t(s);this.animation=I5t(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=Fue(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(p),IKe(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 ux(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+ux(s)}get time(){return ux(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=gp(s),r&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(s){s<0&&(this.finishedTime=null),this.animation.playbackRate=s}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(s){this.manualStartTime=this.animation.startTime=s}attachTimeline({timeline:s,rangeStart:r,rangeEnd:n,observe:a}){var o;return this.allowFlatten&&((o=this.animation.effect)==null||o.updateTiming({easing:"linear"})),this.animation.onfinish=null,s&&P5t()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),_x):a(this)}}const zKe={anticipate:pKe,backInOut:mKe,circInOut:xKe};function D5t(t){return t in zKe}function R5t(t){typeof t.ease=="string"&&D5t(t.ease)&&(t.ease=zKe[t.ease])}const kge=10;class O5t extends FKe{constructor(s){R5t(s),AKe(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 ole({...l,autoplay:!1}),d=Math.max(kge,gm.now()-this.startTime),u=h0(0,kge,d-kge),p=i.sample(d).value,{name:x}=this.options;o&&x&&IKe(o,x,p),r.setWithVelocity(i.sample(Math.max(0,d-u)).value,p,u),i.stop()}}const j6e=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Lg.test(t)||t==="0")&&!t.startsWith("url("));function F5t(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function V5t(t){var x;const{motionValue:s,name:r,repeatDelay:n,repeatType:a,damping:o,type:l,keyframes:i}=t;if(!(((x=s==null?void 0:s.owner)==null?void 0:x.current)instanceof HTMLElement))return!1;const{onUpdate:u,transformTemplate:p}=s.owner.getProps();return U5t()&&r&&(BKe.has(r)||q5t.has(r)&&$5t(i))&&(r!=="transform"||!p)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const H5t=40;class G5t extends fNe{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,...x}){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=gm.now();const y={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:d,motionValue:u,element:p,...x},_=(p==null?void 0:p.KeyframeResolver)||xNe;this.keyframeResolver=new _(i,(N,w,k)=>this.onKeyframesResolved(N,w,y,!k),d,u,p),(b=this.keyframeResolver)==null||b.scheduleResolve()}onKeyframesResolved(s,r,n,a){var k,C;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:d,isHandoff:u,onUpdate:p}=n;this.resolvedAt=gm.now();let x=!0;z5t(s,o,l,i)||(x=!1,(Jb.instantAnimations||!d)&&(p==null||p(Fue(s,n,r))),s[0]=s[s.length-1],z1e(n),n.repeat=0);const _={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>H5t?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},b=x&&!u&&V5t(_),N=(C=(k=_.motionValue)==null?void 0:k.owner)==null?void 0:C.current;let w;if(b)try{w=new O5t({..._,element:N})}catch{w=new ole(_)}else w=new ole(_);w.finished.then(()=>{this.notifyFinished()}).catch(_x),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(),T5t()),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 $Ke(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 W5t=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function K5t(t){const s=W5t.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}const Z5t=4;function qKe(t,s,r=1){LT(r<=Z5t,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[n,a]=K5t(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return nKe(l)?parseFloat(l):l}return dNe(a)?qKe(a,s,r+1):a}const Y5t={type:"spring",stiffness:500,damping:25,restSpeed:10},X5t=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Q5t={type:"keyframes",duration:.8},J5t={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},eMt=(t,{keyframes:s})=>s.length>2?Q5t:HA.has(t)?t.startsWith("scale")?X5t(s[1]):Y5t:J5t;function UKe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function gNe(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?UKe(r,t):r}const tMt=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function sMt(t){for(const s in t)if(!tMt.has(s))return!0;return!1}const yNe=(t,s,r,n={},a,o)=>l=>{const i=gNe(n,t)||{},d=i.delay||n.delay||0;let{elapsed:u=0}=n;u=u-gp(d);const p={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:s.getVelocity(),...i,delay:-u,onUpdate:y=>{s.set(y),i.onUpdate&&i.onUpdate(y)},onComplete:()=>{l(),i.onComplete&&i.onComplete()},name:t,motionValue:s,element:o?void 0:a};sMt(i)||Object.assign(p,eMt(t,p)),p.duration&&(p.duration=gp(p.duration)),p.repeatDelay&&(p.repeatDelay=gp(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let x=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(z1e(p),p.delay===0&&(x=!0)),(Jb.instantAnimations||Jb.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(x=!0,z1e(p),p.delay=0),p.allowFlatten=!i.type&&!i.ease,x&&!o&&s.get()!==void 0){const y=Fue(p.keyframes,i);if(y!==void 0){hl.update(()=>{p.onUpdate(y),p.onComplete()});return}}return i.isSync?new ole(p):new G5t(p)};function N6e(t){const s=[{},{}];return t==null||t.values.forEach((r,n)=>{s[0][n]=r.get(),s[1][n]=r.getVelocity()}),s}function vNe(t,s,r,n){if(typeof s=="function"){const[a,o]=N6e(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]=N6e(n);s=s(r!==void 0?r:t.custom,a,o)}return s}function bS(t,s,r){const n=t.getProps();return vNe(n,s,r!==void 0?r:n.custom,t)}const VKe=new Set(["width","height","top","left","right","bottom",...VA]),k6e=30,rMt=t=>!isNaN(parseFloat(t));class nMt{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=gm.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=gm.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=rMt(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 oNe);const n=this.events[s].add(r);return s==="change"?()=>{n(),hl.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=gm.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>k6e)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,k6e);return lKe(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 RT(t,s){return new nMt(t,s)}const B1e=t=>Array.isArray(t);function aMt(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,RT(r))}function iMt(t){return B1e(t)?t[t.length-1]||0:t}function oMt(t,s){const r=bS(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=iMt(o[l]);aMt(t,l,i)}}const rh=t=>!!(t&&t.getVelocity);function lMt(t){return!!(rh(t)&&t.add)}function $1e(t,s){const r=t.getValue("willChange");if(lMt(r))return r.add(s);if(!r&&Jb.WillChange){const n=new Jb.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function _Ne(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const cMt="framerAppearId",HKe="data-"+_Ne(cMt);function GKe(t){return t.props[HKe]}function dMt({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function WKe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const d=t.getDefaultTransition();o=o?UKe(o,d):d;const u=o==null?void 0:o.reduceMotion;n&&(o=n);const p=[],x=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||x&&dMt(x,y))continue;const N={delay:r,...gNe(o||{},y)},w=_.get();if(w!==void 0&&!_.isAnimating()&&!Array.isArray(b)&&b===w&&!N.velocity){hl.update(()=>_.set(b));continue}let k=!1;if(window.MotionHandoffAnimation){const L=GKe(t);if(L){const I=window.MotionHandoffAnimation(L,y,hl);I!==null&&(N.startTime=I,k=!0)}}$1e(t,y);const C=u??t.shouldReduceMotion;_.start(yNe(y,_,b,C&&VKe.has(y)?{type:!1}:N,t,k));const E=_.animation;E&&p.push(E)}if(l){const y=()=>hl.update(()=>{l&&oMt(t,l)});p.length?Promise.all(p).then(y):y()}return p}function q1e(t,s,r={}){var d;const n=bS(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(WKe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:p=0,staggerChildren:x,staggerDirection:y}=a;return uMt(t,s,u,p,x,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 uMt(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(q1e(d,s,{...l,delay:r+(typeof n=="function"?0:n)+$Ke(t.variantChildren,d,n,a,o)}).then(()=>d.notify("AnimationComplete",s)));return Promise.all(i)}function hMt(t,s,r={}){t.notify("AnimationStart",s);let n;if(Array.isArray(s)){const a=s.map(o=>q1e(t,o,r));n=Promise.all(a)}else if(typeof s=="string")n=q1e(t,s,r);else{const a=typeof s=="function"?bS(t,s,r.custom):s;n=Promise.all(WKe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const mMt={test:t=>t==="auto",parse:t=>t},KKe=t=>s=>s.test(t),ZKe=[UA,ra,a0,N_,F3t,O3t,mMt],S6e=t=>ZKe.find(KKe(t));function pMt(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||iKe(t):!0}const fMt=new Set(["brightness","contrast","saturate","opacity"]);function xMt(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(uNe)||[];if(!n)return t;const a=r.replace(n,"");let o=fMt.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const gMt=/\b([a-z-]*)\(.*?\)/gu,U1e={...Lg,getAnimatableNone:t=>{const s=t.match(gMt);return s?s.map(xMt).join(" "):t}},V1e={...Lg,getAnimatableNone:t=>{const s=Lg.parse(t);return Lg.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},C6e={...UA,transform:Math.round},yMt={rotate:N_,rotateX:N_,rotateY:N_,rotateZ:N_,scale:Cz,scaleX:Cz,scaleY:Cz,scaleZ:Cz,skew:N_,skewX:N_,skewY:N_,distance:ra,translateX:ra,translateY:ra,translateZ:ra,x:ra,y:ra,z:ra,perspective:ra,transformPerspective:ra,opacity:nD,originX:m6e,originY:m6e,originZ:ra},bNe={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,...yMt,zIndex:C6e,fillOpacity:nD,strokeOpacity:nD,numOctaves:C6e},vMt={...bNe,color:Ld,backgroundColor:Ld,outlineColor:Ld,fill:Ld,stroke:Ld,borderColor:Ld,borderTopColor:Ld,borderRightColor:Ld,borderBottomColor:Ld,borderLeftColor:Ld,filter:U1e,WebkitFilter:U1e,mask:V1e,WebkitMask:V1e},YKe=t=>vMt[t],_Mt=new Set([U1e,V1e]);function XKe(t,s){let r=YKe(t);return _Mt.has(r)||(r=Lg),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const bMt=new Set(["auto","none","0"]);function wMt(t,s,r){let n=0,a;for(;n{s.getValue(d).set(u)}),this.resolveNoneKeyframes()}}function wNe(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 QKe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function Bie(t){return aKe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:jNe,cancel:MTs}=vKe(queueMicrotask,!1),ug={x:!1,y:!1};function JKe(){return ug.x||ug.y}function NMt(t){return t==="x"||t==="y"?ug[t]?null:(ug[t]=!0,()=>{ug[t]=!1}):ug.x||ug.y?null:(ug.x=ug.y=!0,()=>{ug.x=ug.y=!1})}function eZe(t,s){const r=wNe(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function kMt(t){return!(t.pointerType==="touch"||JKe())}function SMt(t,s,r={}){const[n,a,o]=eZe(t,r);return n.forEach(l=>{let i=!1,d=!1,u;const p=()=>{l.removeEventListener("pointerleave",b)},x=w=>{u&&(u(w),u=void 0),p()},y=w=>{i=!1,window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),d&&(d=!1,x(w))},_=()=>{i=!0,window.addEventListener("pointerup",y,a),window.addEventListener("pointercancel",y,a)},b=w=>{if(w.pointerType!=="touch"){if(i){d=!0;return}x(w)}},N=w=>{if(!kMt(w))return;d=!1;const k=s(l,w);typeof k=="function"&&(u=k,l.addEventListener("pointerleave",b,a))};l.addEventListener("pointerenter",N,a),l.addEventListener("pointerdown",_,a)}),o}const tZe=(t,s)=>s?t===s?!0:tZe(t,s.parentElement):!1,NNe=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,CMt=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function MMt(t){return CMt.has(t.tagName)||t.isContentEditable===!0}const TMt=new Set(["INPUT","SELECT","TEXTAREA"]);function AMt(t){return TMt.has(t.tagName)||t.isContentEditable===!0}const $ie=new WeakSet;function M6e(t){return s=>{s.key==="Enter"&&t(s)}}function Sge(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const EMt=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=M6e(()=>{if($ie.has(r))return;Sge(r,"down");const a=M6e(()=>{Sge(r,"up")}),o=()=>Sge(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 T6e(t){return NNe(t)&&!JKe()}const A6e=new WeakSet;function PMt(t,s,r={}){const[n,a,o]=eZe(t,r),l=i=>{const d=i.currentTarget;if(!T6e(i)||A6e.has(i))return;$ie.add(d),r.stopPropagation&&A6e.add(i);const u=s(d,i),p=(_,b)=>{window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",y),$ie.has(d)&&$ie.delete(d),T6e(_)&&typeof u=="function"&&u(_,{success:b})},x=_=>{p(_,d===window||d===document||r.useGlobalTarget||tZe(d,_.target))},y=_=>{p(_,!1)};window.addEventListener("pointerup",x,a),window.addEventListener("pointercancel",y,a)};return n.forEach(i=>{(r.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),Bie(i)&&(i.addEventListener("focus",u=>EMt(u,a)),!MMt(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function kNe(t){return aKe(t)&&"ownerSVGElement"in t}const qie=new WeakMap;let k_;const sZe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:kNe(n)&&"getBBox"in n?n.getBBox()[s]:n[r],IMt=sZe("inline","width","offsetWidth"),LMt=sZe("block","height","offsetHeight");function DMt({target:t,borderBoxSize:s}){var r;(r=qie.get(t))==null||r.forEach(n=>{n(t,{get width(){return IMt(t,s)},get height(){return LMt(t,s)}})})}function RMt(t){t.forEach(DMt)}function OMt(){typeof ResizeObserver>"u"||(k_=new ResizeObserver(RMt))}function FMt(t,s){k_||OMt();const r=wNe(t);return r.forEach(n=>{let a=qie.get(n);a||(a=new Set,qie.set(n,a)),a.add(s),k_==null||k_.observe(n)}),()=>{r.forEach(n=>{const a=qie.get(n);a==null||a.delete(s),a!=null&&a.size||k_==null||k_.unobserve(n)})}}const Uie=new Set;let X5;function zMt(){X5=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};Uie.forEach(s=>s(t))},window.addEventListener("resize",X5)}function BMt(t){return Uie.add(t),X5||zMt(),()=>{Uie.delete(t),!Uie.size&&typeof X5=="function"&&(window.removeEventListener("resize",X5),X5=void 0)}}function E6e(t,s){return typeof t=="function"?BMt(t):FMt(t,s)}function $Mt(t){return kNe(t)&&t.tagName==="svg"}const qMt=[...ZKe,Ld,Lg],UMt=t=>qMt.find(KKe(t)),P6e=()=>({translate:0,scale:1,origin:0,originPoint:0}),Q5=()=>({x:P6e(),y:P6e()}),I6e=()=>({min:0,max:0}),Jd=()=>({x:I6e(),y:I6e()}),VMt=new WeakMap;function zue(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function aD(t){return typeof t=="string"||Array.isArray(t)}const SNe=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],CNe=["initial",...SNe];function Bue(t){return zue(t.animate)||CNe.some(s=>aD(t[s]))}function rZe(t){return!!(Bue(t)||t.variants)}function HMt(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,RT(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,RT(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const H1e={current:null},nZe={current:!1},GMt=typeof window<"u";function WMt(){if(nZe.current=!0,!!GMt)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>H1e.current=t.matches;t.addEventListener("change",s),s()}else H1e.current=!1}const L6e=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let lle={};function aZe(t){lle=t}function KMt(){return lle}class ZMt{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=xNe,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 _=gm.now();this.renderScheduledAt<_&&(this.renderScheduledAt=_,hl.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=Bue(r),this.isVariantNode=rZe(r),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(s&&s.current);const{willChange:x,...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,VMt.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||WMt(),this.shouldReduceMotion=H1e.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(),ew(this.notifyUpdate),ew(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&&BKe.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:d,ease:u,duration:p}=r.accelerate,x=new FKe({element:this.current,name:s,keyframes:i,times:d,ease:u,duration:gp(p)}),y=l(x);this.valueSubscriptions.set(s,()=>{y(),x.cancel()});return}const n=HA.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&hl.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 lle){const r=lle[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):Jd()}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=RT(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)||iKe(n))?n=parseFloat(n):!UMt(n)&&Lg.test(r)&&(n=XKe(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=vNe(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 oNe),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){jNe.render(this.render)}}class iZe extends ZMt{constructor(){super(...arguments),this.KeyframeResolver=jMt}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 xw{constructor(s){this.isMounted=!1,this.node=s}update(){}}function oZe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function YMt({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function XMt(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 Cge(t){return t===void 0||t===1}function G1e({scale:t,scaleX:s,scaleY:r}){return!Cge(t)||!Cge(s)||!Cge(r)}function t4(t){return G1e(t)||lZe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function lZe(t){return D6e(t.x)||D6e(t.y)}function D6e(t){return t&&t!=="0%"}function cle(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=cle(t,a,n)),cle(t,r,n)+s}function W1e(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 cZe(t,{x:s,y:r}){W1e(t.x,s.translate,s.scale,s.originPoint),W1e(t.y,r.translate,r.scale,r.originPoint)}const O6e=.999999999999,F6e=1.0000000000001;function QMt(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;dO6e&&(s.x=1),s.yO6e&&(s.y=1)}function Ry(t,s){t.min+=s,t.max+=s}function z6e(t,s,r,n,a=.5){const o=Ql(t.min,t.max,a);W1e(t,s,r,o,n)}function B6e(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function Vie(t,s,r){const n=r??t;z6e(t.x,B6e(s.x,n.x),s.scaleX,s.scale,s.originX),z6e(t.y,B6e(s.y,n.y),s.scaleY,s.scale,s.originY)}function dZe(t,s){return oZe(XMt(t.getBoundingClientRect(),s))}function JMt(t,s,r){const n=dZe(t,r),{scroll:a}=s;return a&&(Ry(n.x,a.offset.x),Ry(n.y,a.offset.y)),n}const eTt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},tTt=VA.length;function sTt(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=$6e(t,s.target.x),n=$6e(t,s.target.y);return`${r}% ${n}%`}},rTt={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=Lg.parse(t);if(a.length>5)return n;const o=Lg.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=Ql(i,d,.5);return typeof a[2+l]=="number"&&(a[2+l]/=u),typeof a[3+l]=="number"&&(a[3+l]/=u),o(a)}},K1e={borderRadius:{...X6,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:X6,borderTopRightRadius:X6,borderBottomLeftRadius:X6,borderBottomRightRadius:X6,boxShadow:rTt};function hZe(t,{layout:s,layoutId:r}){return HA.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!K1e[t]||t==="opacity")}function TNe(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])||hZe(i,t)||((l=r==null?void 0:r.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function nTt(t){return window.getComputedStyle(t)}class aTt extends iZe{constructor(){super(...arguments),this.type="html",this.renderInstance=uZe}readValueFromInstance(s,r){var n;if(HA.has(r))return(n=this.projection)!=null&&n.isProjecting?L1e(r):N5t(s,r);{const a=nTt(s),o=(bKe(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return dZe(s,r)}build(s,r,n){MNe(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return TNe(s,r,n)}}const iTt={offset:"stroke-dashoffset",array:"stroke-dasharray"},oTt={offset:"strokeDashoffset",array:"strokeDasharray"};function lTt(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?iTt:oTt;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const cTt=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function mZe(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},d,u,p){if(MNe(t,i,u),d){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:x,style:y}=t;x.transform&&(y.transform=x.transform,delete x.transform),(y.transform||x.transformOrigin)&&(y.transformOrigin=x.transformOrigin??"50% 50%",delete x.transformOrigin),y.transform&&(y.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete x.transformBox);for(const _ of cTt)x[_]!==void 0&&(y[_]=x[_],delete x[_]);s!==void 0&&(x.x=s),r!==void 0&&(x.y=r),n!==void 0&&(x.scale=n),a!==void 0&&lTt(x,a,o,l,!1)}const pZe=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"]),fZe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function dTt(t,s,r,n){uZe(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(pZe.has(a)?a:_Ne(a),s.attrs[a])}function xZe(t,s,r){const n=TNe(t,s,r);for(const a in t)if(rh(t[a])||rh(s[a])){const o=VA.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class uTt extends iZe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Jd}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(HA.has(r)){const n=YKe(r);return n&&n.default||0}return r=pZe.has(r)?r:_Ne(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return xZe(s,r,n)}build(s,r,n){mZe(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){dTt(s,r,n,a)}mount(s){this.isSVGTag=fZe(s.tagName),super.mount(s)}}const hTt=CNe.length;function gZe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?gZe(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})=>hMt(t,r,n)))}function xTt(t){let s=fTt(t),r=q6e(),n=!0,a=!1;const o=u=>(p,x)=>{var _;const y=bS(t,x,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,x=gZe(t.parent)||{},y=[],_=new Set;let b={},N=1/0;for(let k=0;kN&&I,U=!1;const se=Array.isArray(L)?L:[L];let Y=se.reduce(o(C),{});O===!1&&(Y={});const{prevResolvedValues:J={}}=E,X={...J,...Y},ce=oe=>{$=!0,_.has(oe)&&(U=!0,_.delete(oe)),E.needsAnimating[oe]=!0;const pe=t.getValue(oe);pe&&(pe.liveStyle=!1)};for(const oe in X){const pe=Y[oe],_e=J[oe];if(b.hasOwnProperty(oe))continue;let he=!1;B1e(pe)&&B1e(_e)?he=!yZe(pe,_e):he=pe!==_e,he?pe!=null?ce(oe):_.add(oe):pe!==void 0&&_.has(oe)?ce(oe):E.protectedKeys[oe]=!0}E.prevProp=L,E.prevResolvedValues=Y,E.isActive&&(b={...b,...Y}),(n||a)&&t.blockInitialAnimation&&($=!1);const ie=V&&q;$&&(!ie||U)&&y.push(...se.map(oe=>{const pe={type:C};if(typeof oe=="string"&&(n||a)&&!ie&&t.manuallyAnimateOnMount&&t.parent){const{parent:_e}=t,he=bS(_e,oe);if(_e.enteringChildren&&he){const{delayChildren:we}=he.transition||{};pe.delay=$Ke(_e.enteringChildren,t,we)}}return{animation:oe,options:pe}}))}if(_.size){const k={};if(typeof p.initial!="boolean"){const C=bS(t,Array.isArray(p.initial)?p.initial[0]:p.initial);C&&C.transition&&(k.transition=C.transition)}_.forEach(C=>{const E=t.getBaseTarget(C),L=t.getValue(C);L&&(L.liveStyle=!0),k[C]=E??null}),y.push({animation:k})}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 x=i(u);for(const _ in r)r[_].protectedKeys={};return x}return{animateChanges:i,setActive:d,setAnimateFunction:l,getState:()=>r,reset:()=>{r=q6e(),a=!0}}}function gTt(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!yZe(s,t):!1}function D2(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function q6e(){return{animate:D2(!0),whileInView:D2(),whileHover:D2(),whileTap:D2(),whileDrag:D2(),whileFocus:D2(),exit:D2()}}function Z1e(t,s){t.min=s.min,t.max=s.max}function og(t,s){Z1e(t.x,s.x),Z1e(t.y,s.y)}function U6e(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const vZe=1e-4,yTt=1-vZe,vTt=1+vZe,_Ze=.01,_Tt=0-_Ze,bTt=0+_Ze;function ym(t){return t.max-t.min}function wTt(t,s,r){return Math.abs(t-s)<=r}function V6e(t,s,r,n=.5){t.origin=n,t.originPoint=Ql(s.min,s.max,t.origin),t.scale=ym(r)/ym(s),t.translate=Ql(r.min,r.max,t.origin)-t.originPoint,(t.scale>=yTt&&t.scale<=vTt||isNaN(t.scale))&&(t.scale=1),(t.translate>=_Tt&&t.translate<=bTt||isNaN(t.translate))&&(t.translate=0)}function QL(t,s,r,n){V6e(t.x,s.x,r.x,n?n.originX:void 0),V6e(t.y,s.y,r.y,n?n.originY:void 0)}function H6e(t,s,r,n=0){const a=n?Ql(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+ym(s)}function jTt(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 G6e(t,s,r,n=0){const a=n?Ql(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+ym(s)}function dle(t,s,r,n){G6e(t.x,s.x,r.x,n==null?void 0:n.x),G6e(t.y,s.y,r.y,n==null?void 0:n.y)}function W6e(t,s,r,n,a){return t-=s,t=cle(t,1/r,n),a!==void 0&&(t=cle(t,1/a,n)),t}function NTt(t,s=0,r=1,n=.5,a,o=t,l=t){if(a0.test(s)&&(s=parseFloat(s),s=Ql(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=Ql(o.min,o.max,n);t===o&&(i-=s),t.min=W6e(t.min,s,r,i,a),t.max=W6e(t.max,s,r,i,a)}function K6e(t,s,[r,n,a],o,l){NTt(t,s[r],s[n],s[a],s.scale,o,l)}const kTt=["x","scaleX","originX"],STt=["y","scaleY","originY"];function Z6e(t,s,r,n){K6e(t.x,s,kTt,r?r.x:void 0,n?n.x:void 0),K6e(t.y,s,STt,r?r.y:void 0,n?n.y:void 0)}function Y6e(t){return t.translate===0&&t.scale===1}function bZe(t){return Y6e(t.x)&&Y6e(t.y)}function X6e(t,s){return t.min===s.min&&t.max===s.max}function CTt(t,s){return X6e(t.x,s.x)&&X6e(t.y,s.y)}function Q6e(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function wZe(t,s){return Q6e(t.x,s.x)&&Q6e(t.y,s.y)}function J6e(t){return ym(t.x)/ym(t.y)}function eIe(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function Cy(t){return[t("x"),t("y")]}function MTt(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:x,rotateY:y,skewX:_,skewY:b}=r;u&&(n=`perspective(${u}px) ${n}`),p&&(n+=`rotate(${p}deg) `),x&&(n+=`rotateX(${x}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 jZe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],TTt=jZe.length,tIe=t=>typeof t=="string"?parseFloat(t):t,sIe=t=>typeof t=="number"||ra.test(t);function ATt(t,s,r,n,a,o){a?(t.opacity=Ql(0,r.opacity??1,ETt(n)),t.opacityExit=Ql(s.opacity??1,0,PTt(n))):o&&(t.opacity=Ql(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(rD(t,s,n))}function ITt(t,s,r){const n=rh(t)?t:RT(t);return n.start(yNe("",n,s,r)),n.animation}function iD(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const LTt=(t,s)=>t.depth-s.depth;class DTt{constructor(){this.children=[],this.isDirty=!1}add(s){iNe(this.children,s),this.isDirty=!0}remove(s){rle(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(LTt),this.isDirty=!1,this.children.forEach(s)}}function RTt(t,s){const r=gm.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(ew(n),t(o-s))};return hl.setup(n,!0),()=>ew(n)}function Hie(t){return rh(t)?t.get():t}class OTt{constructor(){this.members=[]}add(s){iNe(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&&(rle(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(rle(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 Gie={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Mge=["","X","Y","Z"],FTt=1e3;let zTt=0;function Tge(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function kZe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=GKe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",hl,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&kZe(n)}function SZe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=zTt++,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(qTt),this.nodes.forEach(KTt),this.nodes.forEach(ZTt),this.nodes.forEach(UTt)},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;hl.read(()=>{x=window.innerWidth}),t(l,()=>{const _=window.innerWidth;_!==x&&(x=_,this.root.updateBlockedByResize=!0,p&&p(),p=RTt(y,250),Gie.hasAnimatedSinceResize&&(Gie.hasAnimatedSinceResize=!1,this.nodes.forEach(iIe)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&u&&(i||d)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:x,hasRelativeLayoutChanged:y,layout:_})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||u.getDefaultTransition()||eAt,{onLayoutAnimationStart:N,onLayoutAnimationComplete:w}=u.getProps(),k=!this.targetLayout||!wZe(this.targetLayout,_),C=!x&&y;if(this.options.layoutRoot||this.resumeFrom||C||x&&(k||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const E={...gNe(b,"layout"),onPlay:N,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(E.delay=0,E.type=!1),this.startAnimation(E),this.setAnimationOrigin(p,C)}else x||iIe(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(),ew(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(YTt),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&&kZe(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let p=0;p{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ym(this.snapshot.measuredBox.x)&&!ym(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let d=0;d{const I=L/1e3;oIe(x.x,l.x,I),oIe(x.y,l.y,I),this.setTargetDelta(x),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(dle(y,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),QTt(this.relativeTarget,this.relativeTargetOrigin,y,I),E&&CTt(this.relativeTarget,E)&&(this.isProjectionDirty=!1),E||(E=Jd()),og(E,this.relativeTarget)),N&&(this.animationValues=p,ATt(p,u,this.latestValues,I,C,k)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=I},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&&(ew(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=hl.update(()=>{Gie.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=RT(0)),this.motionValue.jump(0,!1),this.currentAnimation=ITt(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(FTt),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&&CZe(this.options.animationType,this.layout.layoutBox,u.layoutBox)){d=this.target||Jd();const x=ym(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+x;const y=ym(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+y}og(i,d),Vie(i,p),QL(this.projectionDeltaWithTransform,this.layoutCorrected,i,p)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new OTt),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&&Tge("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(nIe),this.root.sharedNodes.clear()}}}function BTt(t){t.updateLayout()}function $Tt(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")Cy(x=>{const y=l?s.measuredBox[x]:s.layoutBox[x],_=ym(y);y.min=n[x].min,y.max=y.min+_});else if(o==="x"||o==="y"){const x=o==="x"?"y":"x";Z1e(l?s.measuredBox[x]:s.layoutBox[x],n[x])}else CZe(o,s.layoutBox,n)&&Cy(x=>{const y=l?s.measuredBox[x]:s.layoutBox[x],_=ym(n[x]);y.max=y.min+_,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[x].max=t.relativeTarget[x].min+_)});const i=Q5();QL(i,n,s.layoutBox);const d=Q5();l?QL(d,t.applyTransform(a,!0),s.measuredBox):QL(d,n,s.layoutBox);const u=!bZe(i);let p=!1;if(!t.resumeFrom){const x=t.getClosestProjectingParent();if(x&&!x.resumeFrom){const{snapshot:y,layout:_}=x;if(y&&_){const b=t.options.layoutAnchor||void 0,N=Jd();dle(N,s.layoutBox,y.layoutBox,b);const w=Jd();dle(w,n,_.layoutBox,b),wZe(N,w)||(p=!0),x.options.layoutRoot&&(t.relativeTarget=w,t.relativeTargetOrigin=N,t.relativeParent=x)}}}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 qTt(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 UTt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function VTt(t){t.clearSnapshot()}function nIe(t){t.clearMeasurements()}function HTt(t){t.isLayoutDirty=!0,t.updateLayout()}function aIe(t){t.isLayoutDirty=!1}function GTt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function WTt(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function iIe(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function KTt(t){t.resolveTargetDelta()}function ZTt(t){t.calcProjection()}function YTt(t){t.resetSkewAndRotation()}function XTt(t){t.removeLeadSnapshot()}function oIe(t,s,r){t.translate=Ql(s.translate,0,r),t.scale=Ql(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function lIe(t,s,r,n){t.min=Ql(s.min,r.min,n),t.max=Ql(s.max,r.max,n)}function QTt(t,s,r,n){lIe(t.x,s.x,r.x,n),lIe(t.y,s.y,r.y,n)}function JTt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const eAt={duration:.45,ease:[.4,0,.1,1]},cIe=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),dIe=cIe("applewebkit/")&&!cIe("chrome/")?Math.round:_x;function uIe(t){t.min=dIe(t.min),t.max=dIe(t.max)}function tAt(t){uIe(t.x),uIe(t.y)}function CZe(t,s,r){return t==="position"||t==="preserve-aspect"&&!wTt(J6e(s),J6e(r),.2)}function sAt(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const rAt=SZe({attachResizeListener:(t,s)=>iD(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}),Age={current:void 0},MZe=SZe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Age.current){const t=new rAt({});t.mount(window),t.setOptions({layoutScroll:!0}),Age.current=t}return Age.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),ANe=S.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function hIe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function nAt(...t){return s=>{let r=!1;const n=t.map(a=>{const o=hIe(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:k,bottom:C}=d.current;if(s||o===!1||!i.current||!_||!b)return;const E=r==="left"?`left: ${w}`:`right: ${k}`,L=n==="bottom"?`bottom: ${C}`:`top: ${N}`;i.current.dataset.motionPopId=l;const I=document.createElement("style");u&&(I.nonce=u);const O=a??document.head;return O.appendChild(I),I.sheet&&I.sheet.insertRule(` [data-motion-pop-id="${l}"] { position: absolute !important; width: ${_}px !important; height: ${b}px !important; ${E}px !important; ${L}px !important; } `),()=>{var V;(V=i.current)==null||V.removeAttribute("data-motion-pop-id"),O.contains(I)&&O.removeChild(I)}},[s]),e.jsx(iAt,{isPresent:s,childRef:i,sizeRef:d,pop:o,children:o===!1?t:S.cloneElement(t,{ref:x})})}const lAt=({children:t,initial:s,isPresent:r,onExitComplete:n,custom:a,presenceAffectsLayout:o,mode:l,anchorX:i,anchorY:d,root:u})=>{const p=aNe(cAt),x=S.useId();let y=!0,_=S.useMemo(()=>(y=!1,{id:x,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&&(_={..._}),S.useMemo(()=>{p.forEach((b,N)=>p.set(N,!1))},[r]),S.useEffect(()=>{!r&&!p.size&&n&&n()},[r]),t=e.jsx(oAt,{pop:l==="popLayout",isPresent:r,anchorX:i,anchorY:d,root:u,children:t}),e.jsx(Rue.Provider,{value:_,children:t})};function cAt(){return new Map}function TZe(t=!0){const s=S.useContext(Rue);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=S.useId();S.useEffect(()=>{if(t)return a(o)},[t]);const l=S.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const Mz=t=>t.key||"";function mIe(t){const s=[];return S.Children.forEach(t,r=>{S.isValidElement(r)&&s.push(r)}),s}const ENe=({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,x]=TZe(l),y=S.useMemo(()=>mIe(t),[t]),_=l&&!p?[]:y.map(Mz),b=S.useRef(!0),N=S.useRef(y),w=aNe(()=>new Map),k=S.useRef(new Set),[C,E]=S.useState(y),[L,I]=S.useState(y);rKe(()=>{b.current=!1,N.current=y;for(let q=0;q{const $=Mz(q),U=l&&!p?!1:y===L||_.includes($),se=()=>{if(k.current.has($))return;if(w.has($))k.current.add($),w.set($,!0);else return;let Y=!0;w.forEach(J=>{J||(Y=!1)}),Y&&(V==null||V(),I(N.current),l&&(x==null||x()),n&&n())};return e.jsx(lAt,{isPresent:U,initial:!b.current||r?void 0:!1,custom:s,presenceAffectsLayout:a,mode:o,root:u,onExitComplete:U?void 0:se,anchorX:i,anchorY:d,children:q},$)})})},AZe=S.createContext({strict:!1}),pIe={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 fIe=!1;function dAt(){if(fIe)return;const t={};for(const s in pIe)t[s]={isEnabled:r=>pIe[s].some(n=>!!r[n])};aZe(t),fIe=!0}function EZe(){return dAt(),KMt()}function uAt(t){const s=EZe();for(const r in t)s[r]={...s[r],...t[r]};aZe(s)}const hAt=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 ule(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||hAt.has(t)}let PZe=t=>!ule(t);function mAt(t){typeof t=="function"&&(PZe=s=>s.startsWith("on")?!ule(s):t(s))}try{mAt(require("@emotion/is-prop-valid").default)}catch{}function pAt(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||rh(t[a])||(PZe(a)||r===!0&&ule(a)||!s&&!ule(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const $ue=S.createContext({});function fAt(t,s){if(Bue(t)){const{initial:r,animate:n}=t;return{initial:r===!1||aD(r)?r:void 0,animate:aD(n)?n:void 0}}return t.inherit!==!1?s:{}}function xAt(t){const{initial:s,animate:r}=fAt(t,S.useContext($ue));return S.useMemo(()=>({initial:s,animate:r}),[xIe(s),xIe(r)])}function xIe(t){return Array.isArray(t)?t.join(" "):t}const PNe=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function IZe(t,s,r){for(const n in s)!rh(s[n])&&!hZe(n,r)&&(t[n]=s[n])}function gAt({transformTemplate:t},s){return S.useMemo(()=>{const r=PNe();return MNe(r,s,t),Object.assign({},r.vars,r.style)},[s])}function yAt(t,s){const r=t.style||{},n={};return IZe(n,r,t),Object.assign(n,gAt(t,s)),n}function vAt(t,s){const r={},n=yAt(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 LZe=()=>({...PNe(),attrs:{}});function _At(t,s,r,n){const a=S.useMemo(()=>{const o=LZe();return mZe(o,s,fZe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};IZe(o,t.style,t),a.style={...o,...a.style}}return a}const bAt=["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 INe(t){return typeof t!="string"||t.includes("-")?!1:!!(bAt.indexOf(t)>-1||/[A-Z]/u.test(t))}function wAt(t,s,r,{latestValues:n},a,o=!1,l){const d=(l??INe(t)?_At:vAt)(s,n,a,t),u=pAt(s,typeof t=="string",o),p=t!==S.Fragment?{...u,...d,ref:r}:{},{children:x}=s,y=S.useMemo(()=>rh(x)?x.get():x,[x]);return S.createElement(t,{...p,children:y})}function jAt({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:NAt(r,n,a,t),renderState:s()}}function NAt(t,s,r,n){const a={},o=n(t,{});for(const y in o)a[y]=Hie(o[y]);let{initial:l,animate:i}=t;const d=Bue(t),u=rZe(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 x=p?i:l;if(x&&typeof x!="boolean"&&!zue(x)){const y=Array.isArray(x)?x:[x];for(let _=0;_(s,r)=>{const n=S.useContext($ue),a=S.useContext(Rue),o=()=>jAt(t,s,n,a);return r?o():aNe(o)},kAt=DZe({scrapeMotionValuesFromProps:TNe,createRenderState:PNe}),SAt=DZe({scrapeMotionValuesFromProps:xZe,createRenderState:LZe}),CAt=Symbol.for("motionComponentSymbol");function MAt(t,s,r){const n=S.useRef(r);S.useInsertionEffect(()=>{n.current=r});const a=S.useRef(null);return S.useCallback(o=>{var i;o&&((i=t.onMount)==null||i.call(t,o));const l=n.current;if(typeof l=="function")if(o){const d=l(o);typeof d=="function"&&(a.current=d)}else a.current?(a.current(),a.current=null):l(o);else l&&(l.current=o);s&&(o?s.mount(o):s.unmount())},[s])}const RZe=S.createContext({});function T5(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function TAt(t,s,r,n,a,o){var E,L;const{visualElement:l}=S.useContext($ue),i=S.useContext(AZe),d=S.useContext(Rue),u=S.useContext(ANe),p=u.reducedMotion,x=u.skipAnimations,y=S.useRef(null),_=S.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:x,isSVG:o}),_.current&&y.current&&(y.current.manuallyAnimateOnMount=!0));const b=y.current,N=S.useContext(RZe);b&&!b.projection&&a&&(b.type==="html"||b.type==="svg")&&AAt(y.current,r,a,N);const w=S.useRef(!1);S.useInsertionEffect(()=>{b&&w.current&&b.update(r,d)});const k=r[HKe],C=S.useRef(!!k&&typeof window<"u"&&!((E=window.MotionHandoffIsComplete)!=null&&E.call(window,k))&&((L=window.MotionHasOptimisedAnimation)==null?void 0:L.call(window,k)));return rKe(()=>{_.current=!0,b&&(w.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),b.scheduleRenderMicrotask(),C.current&&b.animationState&&b.animationState.animateChanges())}),S.useEffect(()=>{b&&(!C.current&&b.animationState&&b.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{var I;(I=window.MotionHandoffMarkAsComplete)==null||I.call(window,k)}),C.current=!1),b.enteringChildren=void 0)}),b}function AAt(t,s,r,n){const{layoutId:a,layout:o,drag:l,dragConstraints:i,layoutScroll:d,layoutRoot:u,layoutAnchor:p,layoutCrossfade:x}=s;t.projection=new r(t.latestValues,s["data-framer-portal-id"]?void 0:OZe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&T5(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:x,layoutScroll:d,layoutRoot:u,layoutAnchor:p})}function OZe(t){if(t)return t.options.allowProjection!==!1?t.projection:OZe(t.parent)}function Ege(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&uAt(n);const o=r?r==="svg":INe(t),l=o?SAt:kAt;function i(u,p){let x;const y={...S.useContext(ANe),...u,layoutId:EAt(u)},{isStatic:_}=y,b=xAt(u),N=l(u,_);if(!_&&typeof window<"u"){PAt();const w=IAt(y);x=w.MeasureLayout,b.visualElement=TAt(t,N,y,a,w.ProjectionNode,o)}return e.jsxs($ue.Provider,{value:b,children:[x&&b.visualElement?e.jsx(x,{visualElement:b.visualElement,...y}):null,wAt(t,u,MAt(N,b.visualElement,p),N,_,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const d=S.forwardRef(i);return d[CAt]=t,d}function EAt({layoutId:t}){const s=S.useContext(nNe).id;return s&&t!==void 0?s+"-"+t:t}function PAt(t,s){S.useContext(AZe).strict}function IAt(t){const s=EZe(),{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 LAt(t,s){if(typeof Proxy>"u")return Ege;const r=new Map,n=(o,l)=>Ege(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,Ege(l,void 0,t,s)),r.get(l))})}const DAt=(t,s)=>s.isSVG??INe(t)?new uTt(s):new aTt(s,{allowProjection:t!==S.Fragment});class RAt extends xw{constructor(s){super(s),s.animationState||(s.animationState=xTt(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();zue(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 OAt=0;class FAt extends xw{constructor(){super(...arguments),this.id=OAt++,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=bS(this.node,l,i);if(d){const{transition:u,transitionEnd:p,...x}=d;for(const y in x)(o=this.node.getValue(y))==null||o.jump(x[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 zAt={animation:{Feature:RAt},exit:{Feature:FAt}};function BR(t){return{point:{x:t.pageX,y:t.pageY}}}const BAt=t=>s=>NNe(s)&&t(s,BR(s));function JL(t,s,r,n){return iD(t,s,BAt(r),n)}const FZe=({current:t})=>t?t.ownerDocument.defaultView:null,gIe=(t,s)=>Math.abs(t-s);function $At(t,s){const r=gIe(t.x,s.x),n=gIe(t.y,s.y);return Math.sqrt(r**2+n**2)}const yIe=new Set(["auto","scroll"]);class zZe{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=Tz(this.lastRawMoveEventInfo,this.transformPagePoint));const _=Pge(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,N=$At(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!b&&!N)return;const{point:w}=_,{timestamp:k}=eh;this.history.push({...w,timestamp:k});const{onStart:C,onMove:E}=this.handlers;b||(C&&C(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),E&&E(this.lastMoveEvent,_)},this.handlePointerMove=(_,b)=>{this.lastMoveEvent=_,this.lastRawMoveEventInfo=b,this.lastMoveEventInfo=Tz(b,this.transformPagePoint),hl.update(this.updatePoint,!0)},this.handlePointerUp=(_,b)=>{this.end();const{onEnd:N,onSessionEnd:w,resumeAnimation:k}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&k&&k(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=Pge(_.type==="pointercancel"?this.lastMoveEventInfo:Tz(b,this.transformPagePoint),this.history);this.startEvent&&N&&N(_,C),w&&w(_,C)},!NNe(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const d=BR(s),u=Tz(d,this.transformPagePoint),{point:p}=u,{timestamp:x}=eh;this.history=[{...p,timestamp:x}];const{onSessionStart:y}=r;y&&y(s,Pge(u,this.history)),this.removeListeners=OR(JL(this.contextWindow,"pointermove",this.handlePointerMove),JL(this.contextWindow,"pointerup",this.handlePointerUp),JL(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(yIe.has(n.overflowX)||yIe.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),hl.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ew(this.updatePoint)}}function Tz(t,s){return s?{point:s(t.point)}:t}function vIe(t,s){return{x:t.x-s.x,y:t.y-s.y}}function Pge({point:t},s){return{point:t,delta:vIe(t,BZe(s)),offset:vIe(t,qAt(s)),velocity:UAt(s,.1)}}function qAt(t){return t[0]}function BZe(t){return t[t.length-1]}function UAt(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=BZe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>gp(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>gp(s)*2&&(n=t[1]);const o=ux(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 VAt(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?Ql(r,t,n.max):Math.min(t,r)),t}function _Ie(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 HAt(t,{top:s,left:r,bottom:n,right:a}){return{x:_Ie(t.x,r,a),y:_Ie(t.y,s,n)}}function bIe(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=rD(s.min,s.max-n,t.min):n>a&&(r=rD(t.min,t.max-a,s.min)),h0(0,1,r)}function KAt(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 Y1e=.35;function ZAt(t=Y1e){return t===!1?t=0:t===!0&&(t=Y1e),{x:wIe(t,"left","right"),y:wIe(t,"top","bottom")}}function wIe(t,s,r){return{min:jIe(t,s),max:jIe(t,r)}}function jIe(t,s){return typeof t=="number"?t:t[s]||0}const YAt=new WeakMap;class XAt{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=Jd(),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=x=>{r&&this.snapToCursor(BR(x).point),this.stopAnimation()},l=(x,y)=>{const{drag:_,dragPropagation:b,onDragStart:N}=this.getProps();if(_&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=NMt(_),!this.openDragLock))return;this.latestPointerEvent=x,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),Cy(k=>{let C=this.getAxisMotionValue(k).get()||0;if(a0.test(C)){const{projection:E}=this.visualElement;if(E&&E.layout){const L=E.layout.layoutBox[k];L&&(C=ym(L)*(parseFloat(C)/100))}}this.originPoint[k]=C}),N&&hl.update(()=>N(x,y),!1,!0),$1e(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},i=(x,y)=>{this.latestPointerEvent=x,this.latestPanInfo=y;const{dragPropagation:_,dragDirectionLock:b,onDirectionLock:N,onDrag:w}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:k}=y;if(b&&this.currentDirection===null){this.currentDirection=JAt(k),this.currentDirection!==null&&N&&N(this.currentDirection);return}this.updateAxis("x",y.point,k),this.updateAxis("y",y.point,k),this.visualElement.render(),w&&hl.update(()=>w(x,y),!1,!0)},d=(x,y)=>{this.latestPointerEvent=x,this.latestPanInfo=y,this.stop(x,y),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:x}=this.getProps();(x||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new zZe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:d,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:n,contextWindow:FZe(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&&hl.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||!Az(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=VAt(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&&T5(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=HAt(n.layoutBox,s):this.constraints=!1,this.elastic=ZAt(r),a!==this.constraints&&!T5(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&Cy(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=KAt(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!T5(s))return!1;const n=s.current;LT(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=JMt(n,a.root,this.visualElement.getTransformPagePoint());let l=GAt(a.layout.layoutBox,o);if(r){const i=r(YMt(l));this.hasMutatedConstraints=!!i,i&&(l=oZe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),d=this.constraints||{},u=Cy(p=>{if(!Az(p,r,this.currentDirection))return;let x=d&&d[p]||{};(l===!0||l===p)&&(x={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,...x};return this.startAxisValueAnimation(p,b)});return Promise.all(u).then(i)}startAxisValueAnimation(s,r){const n=this.getAxisMotionValue(s);return $1e(this.visualElement,s),n.start(yNe(s,n,0,r,this.visualElement,!1))}stopAnimation(){Cy(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){Cy(r=>{const{drag:n}=this.getProps();if(!Az(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]-Ql(l,i,.5)+d)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!T5(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Cy(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const d=i.get();a[l]=WAt({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(),Cy(l=>{if(!Az(l,s,null))return;const i=this.getAxisMotionValue(l),{min:d,max:u}=this.constraints[l];i.set(Ql(d,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;YAt.set(this.visualElement,this);const s=this.visualElement.current,r=JL(s,"pointerdown",u=>{const{drag:p,dragListener:x=!0}=this.getProps(),y=u.target,_=y!==s&&AMt(y);p&&x&&!_&&this.start(u)});let n;const a=()=>{const{dragConstraints:u}=this.getProps();T5(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),n||(n=QAt(s,u.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),hl.read(a);const i=iD(window,"resize",()=>this.scalePositionWithinConstraints()),d=o.addEventListener("didUpdate",({delta:u,hasLayoutChanged:p})=>{this.isDragging&&p&&(Cy(x=>{const y=this.getAxisMotionValue(x);y&&(this.originPoint[x]+=u[x].translate,y.set(y.get()+u[x].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=Y1e,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function NIe(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function QAt(t,s,r){const n=E6e(t,NIe(r)),a=E6e(s,NIe(r));return()=>{n(),a()}}function Az(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function JAt(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class eEt extends xw{constructor(s){super(s),this.removeGroupControls=_x,this.removeListeners=_x,this.controls=new XAt(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||_x}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 Ige=t=>(s,r)=>{t&&hl.update(()=>t(s,r),!1,!0)};class tEt extends xw{constructor(){super(...arguments),this.removePointerDownListener=_x}onPointerDown(s){this.session=new zZe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:FZe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:Ige(s),onStart:Ige(r),onMove:Ige(n),onEnd:(o,l)=>{delete this.session,a&&hl.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=JL(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 Lge=!1;class sEt extends S.Component{componentDidMount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n,layoutId:a}=this.props,{projection:o}=s;o&&(r.group&&r.group.add(o),n&&n.register&&a&&n.register(o),Lge&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Gie.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}),Lge=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||hl.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(),jNe.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;Lge=!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 $Ze(t){const[s,r]=TZe(),n=S.useContext(nNe);return e.jsx(sEt,{...t,layoutGroup:n,switchLayoutGroup:S.useContext(RZe),isPresent:s,safeToRemove:r})}const rEt={pan:{Feature:tEt},drag:{Feature:eEt,ProjectionNode:MZe,MeasureLayout:$Ze}};function kIe(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&&hl.postRender(()=>o(s,BR(s)))}class nEt extends xw{mount(){const{current:s}=this.node;s&&(this.unmount=SMt(s,(r,n)=>(kIe(this.node,n,"Start"),a=>kIe(this.node,a,"End"))))}unmount(){}}class aEt extends xw{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=OR(iD(this.node.current,"focus",()=>this.onFocus()),iD(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function SIe(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&&hl.postRender(()=>o(s,BR(s)))}class iEt extends xw{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=PMt(s,(a,o)=>(SIe(this.node,o,"Start"),(l,{success:i})=>SIe(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const X1e=new WeakMap,Dge=new WeakMap,oEt=t=>{const s=X1e.get(t.target);s&&s(t)},lEt=t=>{t.forEach(oEt)};function cEt({root:t,...s}){const r=t||document;Dge.has(r)||Dge.set(r,{});const n=Dge.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(lEt,{root:t,...s})),n[a]}function dEt(t,s,r){const n=cEt(s);return X1e.set(t,r),n.observe(t),()=>{X1e.delete(t),n.unobserve(t)}}const uEt={some:0,all:1};class hEt extends xw{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:uEt[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:x,onViewportLeave:y}=this.node.getProps(),_=p?x:y;_&&_(u)};this.stopObserver=dEt(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(mEt(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function mEt({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const pEt={inView:{Feature:hEt},tap:{Feature:iEt},focus:{Feature:aEt},hover:{Feature:nEt}},fEt={layout:{ProjectionNode:MZe,MeasureLayout:$Ze}},xEt={...zAt,...pEt,...rEt,...fEt},ur=LAt(xEt,DAt),gEt={some:0,all:1};function yEt(t,s,{root:r,margin:n,amount:a="some"}={}){const o=wNe(t),l=new WeakMap,i=u=>{u.forEach(p=>{const x=l.get(p.target);if(p.isIntersecting!==!!x)if(p.isIntersecting){const y=s(p.target,p);typeof y=="function"?l.set(p.target,y):d.unobserve(p.target)}else typeof x=="function"&&(x(p),l.delete(p.target))})},d=new IntersectionObserver(i,{root:r,rootMargin:n,threshold:typeof a=="number"?a:gEt[a]});return o.forEach(u=>d.observe(u)),()=>d.disconnect()}function vEt(t,{root:s,margin:r,amount:n,once:a=!1,initial:o=!1}={}){const[l,i]=S.useState(o);return S.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 yEt(t.current,d,u)},[s,t,r,a,n]),l}function _Et(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 CIe(t){return t.visitor_intent==="buying"&&!t.has_agent}function bEt({token:t}={}){var b;const s=co(),r=t||s.token,{data:n,isLoading:a,isError:o}=a3t(r),l=Jt(),i=(b=n==null?void 0:n.open_houses)==null?void 0:b.id,{data:d}=gt({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(S.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,x=(d==null?void 0:d.filter(N=>N.visitor_intent==="buying").length)||0,y=(d==null?void 0:d.filter(CIe).length)||0,_=N=>{if(!N)return"";const[w,k]=N.split(":"),C=parseInt(w);return`${C>12?C-12:C||12}:${k} ${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(lr,{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:x})]})]})]}),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:ps(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(ui,{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(ENe,{children:d.map((N,w)=>{var E;const k=_Et(N.visitor_intent),C=CIe(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:(E=N.first_name[0])==null?void 0:E.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(Qe,{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(Qe,{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(Qe,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${k.color}`,children:[k.emoji," ",k.label]}),e.jsx("span",{className:"text-white/30 text-xs",children:ps(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(Jv,{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 wEt(){const s=Ol().pathname.slice(1);if(S.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(bEt,{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(UWe,{slug:s})}function jEt({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(Da,{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(Pn,{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(rr,{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(vc,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function NEt({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(ei,{className:"w-4 h-4 text-white/80"}),e.jsx("h3",{className:"text-sm font-semibold text-white",children:"Current Stage"})]})}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-lg font-bold text-slate-800",children:t.label}),e.jsx("p",{className:"text-sm text-slate-500 mt-1 leading-relaxed",children:t.description})]}),s&&e.jsxs("div",{className:"bg-slate-50 rounded-xl p-4 border border-slate-100",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:"Update from your agent"}),e.jsx("p",{className:"text-sm text-slate-700 leading-relaxed",children:s})]}),r&&e.jsxs("div",{className:"bg-blue-50/60 rounded-xl p-4 border border-blue-100",children:[e.jsx("p",{className:"text-xs font-semibold text-blue-600 uppercase tracking-wider mb-1.5",children:"What's Next"}),e.jsx("p",{className:"text-sm text-blue-800 leading-relaxed",children:r})]}),n&&e.jsx("div",{className:"rounded-xl overflow-hidden bg-slate-900 aspect-video shadow-md",children:e.jsx("iframe",{src:a(n)||n,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Next step video"})})]})]})}function ml(t){const s=t.split(/[-/T]/);if(s.length>=3){const r=Number(s[0]);return r>99?new Date(r,Number(s[1])-1,Number(s[2])):new Date(Number(s[2]),Number(s[0])-1,Number(s[1]))}return new Date(`${t}T12:00:00`)}function CEt(t,s){const r=ps(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 MEt(t,s){const r=ps(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 TEt({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:yM,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:an,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:on,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,d,u)=>{const p=ml(d);if(u==="google")window.open(CEt(i,p),"_blank");else{const x=MEt(i,p),y=document.createElement("a");y.href=x,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 x=ml(d),y=r0(x)&&!au(x),_=au(x),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:[ps(x,"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(bb,{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 AEt({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(fn,{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 EEt({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(Sm,{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:ps(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 PEt({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var b,N;const[l,i]=S.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]=S.useState({}),[p,x]=S.useState(!1),y=It({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(Da,{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(xe,{className:"text-xs text-slate-600",children:"First Name *"}),e.jsx(De,{required:!0,value:l.first_name,onChange:w=>i(k=>({...k,first_name:w.target.value})),className:"mt-1 rounded-xl",placeholder:"John"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(De,{value:l.last_name,onChange:w=>i(k=>({...k,last_name:w.target.value})),className:"mt-1 rounded-xl",placeholder:"Doe"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(De,{type:"email",value:l.email,onChange:w=>i(k=>({...k,email:w.target.value})),className:"mt-1 rounded-xl",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(De,{type:"tel",value:l.phone,onChange:w=>i(k=>({...k,phone:w.target.value})),className:"mt-1 rounded-xl",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Preferred Contact Method"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:[{value:"email",label:"Email"},{value:"call",label:"Phone"},{value:"text",label:"Text"}].map(w=>e.jsx("button",{type:"button",onClick:()=>i(k=>({...k,preferred_contact_method:w.value})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===w.value?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.label},w.value))})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Your Role"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:["buyer","seller","both"].map(w=>e.jsx("button",{type:"button",onClick:()=>i(k=>({...k,client_role:w})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===w?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.charAt(0).toUpperCase()+w.slice(1)},w))})]}),n.map(w=>e.jsxs("div",{children:[e.jsxs(xe,{className:"text-xs text-slate-600",children:[w.question_text," ",w.is_required&&"*"]}),w.field_type==="text"&&e.jsx(De,{required:w.is_required,value:d[w.id]||"",onChange:k=>u(C=>({...C,[w.id]:k.target.value})),className:"mt-1 rounded-xl"}),w.field_type==="textarea"&&e.jsx("textarea",{required:w.is_required,value:d[w.id]||"",onChange:k=>u(C=>({...C,[w.id]:k.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),w.field_type==="dropdown"&&e.jsxs("select",{required:w.is_required,value:d[w.id]||"",onChange:k=>u(C=>({...C,[w.id]:k.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm h-10",children:[e.jsx("option",{value:"",children:"Select..."}),(w.options||[]).map(k=>e.jsx("option",{value:k,children:k},k))]}),w.field_type==="toggle"&&e.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(k=>e.jsx("button",{type:"button",onClick:()=>u(C=>({...C,[w.id]:k})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${d[w.id]===k?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:k},k))})]},w.id)),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Notes for your agent"}),e.jsx("textarea",{value:l.notes,onChange:w=>i(k=>({...k,notes:w.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Anything you'd like your agent to know..."})]}),t.allow_spouse&&e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>x(!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(xe,{className:"text-xs text-slate-600",children:"First Name"}),e.jsx(De,{value:l.spouse_first_name,onChange:w=>i(k=>({...k,spouse_first_name:w.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(De,{value:l.spouse_last_name,onChange:w=>i(k=>({...k,spouse_last_name:w.target.value})),className:"mt-1 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(De,{type:"email",value:l.spouse_email,onChange:w=>i(k=>({...k,spouse_email:w.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(De,{type:"tel",value:l.spouse_phone,onChange:w=>i(k=>({...k,spouse_phone:w.target.value})),className:"mt-1 rounded-xl"})]})]})]}),e.jsx(K,{type:"submit",disabled: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 IEt(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function LEt(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 DEt={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. 🎉"}},qZe=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function LNe(t){return qZe.map(s=>{if(s==="Active")return{key:"Active",label:IEt(t),description:LEt(t)};const r=DEt[s];return{key:s,label:r.label,description:r.description}})}function MIe(t){if(!t)return 0;const s=qZe.indexOf(t);return s>=0?s:0}function REt(t,s){return gt({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 OEt(t){return gt({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 UZe({slug:t}){var Y,J,X,ce,ie,ae;const[s,r]=S.useState(!1),[n,a]=S.useState("primary"),[o]=S.useState(()=>{const oe=`portal_fp_${t}`;let pe=localStorage.getItem(oe);return pe||(pe=localStorage.getItem("portal_fp"),pe?localStorage.setItem(oe,pe):(pe=crypto.randomUUID(),localStorage.setItem(oe,pe),localStorage.setItem("portal_fp",pe))),pe});S.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:d}=REt(t,!0),u=l==null?void 0:l.linked_portal_id,{data:p}=OEt(u),x=(Y=l==null?void 0:l.deal_pipeline)==null?void 0:Y.owner_user_id;gt({queryKey:["portal-stages",x],queryFn:async()=>{const{data:oe,error:pe}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",x).order("sort_order",{ascending:!0});if(pe)throw pe;return oe},enabled:!!x});const{data:y}=gt({queryKey:["portal-agent",x],queryFn:async()=>{const{data:oe,error:pe}=await G.from("profiles").select("id, name, avatar_url, phone, email").eq("id",x).single();if(pe)throw pe;return oe},enabled:!!x}),_=n==="linked"&&p?p:l,b=_==null?void 0:_.id,{data:N}=gt({queryKey:["portal-updates-public",b],queryFn:async()=>{const{data:oe,error:pe}=await G.from("portal_updates").select("*").eq("portal_id",b).order("created_at",{ascending:!1});if(pe)throw pe;return oe},enabled:!!b}),w=(J=_==null?void 0:_.deal_pipeline)==null?void 0:J.id,{data:k}=gt({queryKey:["portal-documents",w],queryFn:async()=>{const{data:oe,error:pe}=await G.from("deal_files").select("*").eq("deal_id",w).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(pe)throw pe;return oe},enabled:!!w}),C=l==null?void 0:l.id,{data:E,isLoading:L}=gt({queryKey:["portal-onboarding-check",C,o],queryFn:async()=>{const{data:oe,error:pe}=await G.from("portal_onboarding_submissions").select("id").eq("portal_id",C).eq("device_fingerprint",o).maybeSingle();if(pe)throw pe;return oe},enabled:!!C&&!!(l!=null&&l.require_onboarding)}),{data:I}=gt({queryKey:["portal-custom-questions-public",x],queryFn:async()=>{const{data:oe,error:pe}=await G.from("portal_custom_questions").select("*").eq("owner_user_id",x).eq("is_active",!0).order("sort_order",{ascending:!0});if(pe)throw pe;return oe},enabled:!!x&&!!(l!=null&&l.require_onboarding)}),O=!!E||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(Ns,{className:"h-48 w-full rounded-2xl"}),e.jsx(Ns,{className:"h-10 w-48 mx-auto"}),e.jsx(Ns,{className:"h-32 w-full rounded-2xl"}),e.jsx(Ns,{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(!O){const oe=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(PEt,{portal:l,dealData:oe,agentProfile:y,customQuestions:I||[],deviceFingerprint:o,onComplete:()=>r(!0)})})}const V=(X=l==null?void 0:l.deal_pipeline)==null?void 0:X.deal_type,q=(ce=p==null?void 0:p.deal_pipeline)==null?void 0:ce.deal_type,$=!!p,U=oe=>oe==="listing"?"Your Sale":oe==="buy-side"?"Your Purchase":"Transaction",se=oe=>oe==="listing"?e.jsx(Mn,{className:"w-3.5 h-3.5"}):e.jsx(pp,{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(jEt,{dealData:_==null?void 0:_.deal_pipeline,agentProfile:y,welcomeMessage:_==null?void 0:_.welcome_message,isWon:(ae=(ie=_==null?void 0:_.deal_pipeline)==null?void 0:ie.deal_pipeline_stages)==null?void 0:ae.is_won_stage}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 space-y-5 mt-6",children:[$&&e.jsxs("div",{className:"flex gap-1 bg-slate-100 rounded-xl p-1",children:[e.jsxs("button",{onClick:()=>a("primary"),className:`flex-1 flex items-center justify-center gap-1.5 rounded-lg py-2.5 text-sm font-medium transition-all ${n==="primary"?"bg-white text-slate-800 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[se(V),U(V)]}),e.jsxs("button",{onClick:()=>a("linked"),className:`flex-1 flex items-center justify-center gap-1.5 rounded-lg py-2.5 text-sm font-medium transition-all ${n==="linked"?"bg-white text-slate-800 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[se(q),U(q)]})]}),e.jsx(FEt,{portal:_,updates:N,documents:k}),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(Ou,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs",children:"Secure Client Portal"})]}),y&&e.jsxs("p",{className:"text-xs text-slate-400",children:["Managed by ",e.jsx("span",{className:"font-medium text-slate-500",children:y.name})]}),e.jsx("p",{className:"text-[10px] text-slate-300",children:"Powered by ReLevelUp"})]})]})]})}function FEt({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=LNe(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(MIe(o==null?void 0:o.name),u.length-1):MIe(o==null?void 0:o.name),x=u[p],y=x==null?void 0:x.video_url;return e.jsxs(e.Fragment,{children:[e.jsx(kEt,{targetCloseDate:a==null?void 0:a.target_close_date,actualCloseDate:a==null?void 0:a.actual_close_date,clientName:t.client_name}),e.jsx(NEt,{journeyStages:u,currentIndex:p}),x&&e.jsx(SEt,{currentStage:x,nextStepText:t.next_step_text,nextStepVideoUrl:y||t.next_step_video_url}),e.jsx(TEt,{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(AEt,{documents:r}),s&&s.length>0&&e.jsx(EEt,{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 zEt(){const s=Ol().pathname.slice(1);return S.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>{document.body.classList.remove("client-portal-page")}),[]),!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Client Portal"}),e.jsx("p",{className:"text-slate-500",children:"Visit your personalized portal link to view your transaction details."})]})}):e.jsx(UZe,{slug:s})}const Q1e="levelup_affiliate_ref",BEt=30,$Et=()=>{const[t]=Nc();S.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(Q1e,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},qEt=()=>{try{const t=localStorage.getItem(Q1e);if(!t)return null;const s=JSON.parse(t),r=BEt*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(Q1e),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},hle="/assets/levelup-logo-header-_ZX7DvlA.png",UEt="/assets/scale-your-team-ku4MPatU.png";function VEt({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(pa,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(bs,{children:"Schedule a Brokerage Interest Meeting"}),e.jsx(Ir,{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 Mu={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",popular:!1},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"],popular:!0},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"],popular:!1}},HEt=[{icon:sp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Dl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:on,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:vc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:fn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:Ui,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],GEt=[{icon:lr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:$r,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Pn,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:Da,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:to,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:Oh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],WEt=[{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."}],KEt=()=>{const{user:t,loading:s}=Fs(),r=_r(),[n]=Nc();S.useEffect(()=>{const V=window.location.host==="listings.relevelup.com",q=window.location.pathname==="/";if(V&&q){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=S.useState(null),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,x]=S.useState(""),[y,_]=S.useState(""),[b,N]=S.useState(""),[w,k]=S.useState(!1),[C,E]=S.useState(!1),L=(V,q=!1)=>{i({tier:V,skipTrial:q}),u(!0)};$Et(),S.useEffect(()=>{const V=window.location.host==="listings.relevelup.com",q=location.pathname.startsWith("/public/");!s&&t&&!V&&!q&&r("/dashboard")},[t,s,r,location.pathname]),S.useEffect(()=>{n.get("canceled")==="true"&&me.error("Checkout was canceled. Feel free to try again when you're ready!")},[n]);const I=async(V,q=!1)=>{if(!p){me.error("Please enter your email address");return}if(!y.trim()){me.error("Please enter your full name");return}k(!0),o(V+(q?"_direct":""));const $=qEt();try{const{data:U,error:se}=await G.functions.invoke("create-checkout",{body:{tier:V,email:p,name:y.trim(),couponCode:b.trim()||void 0,skipTrial:q,referralCode:$}});if(se)throw se;if(U!=null&&U.url)window.open(U.url,"_blank","noopener,noreferrer"),me.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(U){console.error("Checkout error:",U),me.error(U.message||"Failed to start checkout. Please try again.")}finally{k(!1),o(null),u(!1),i(null)}},O=()=>{l&&I(l.tier,l.skipTrial)};return s?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#4a6b6d]",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-white border-t-transparent"})}):e.jsxs("div",{className:"min-h-screen bg-background overflow-hidden",children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:e.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:hle,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 V;return(V=document.getElementById("features"))==null?void 0:V.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 V;return(V=document.getElementById("pricing"))==null?void 0:V.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 V;return(V=document.getElementById("free-trial"))==null?void 0:V.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(ei,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(K,{size:"lg",variant:"outline",onClick:()=>{var V;return(V=document.getElementById("features"))==null?void 0:V.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 V;return(V=document.getElementById("brokerage"))==null?void 0:V.scrollIntoView({behavior:"smooth"})},className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/5",children:[e.jsx(pa,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),e.jsxs(K,{size:"lg",onClick:()=>{var V;return(V=document.getElementById("pricing"))==null?void 0:V.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:[e.jsx(Ti,{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:HEt.map((V,q)=>e.jsxs(Pe,{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(V.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Ot,{className:"text-xl font-sans",children:V.title})]}),e.jsx(Re,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:V.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($r,{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:GEt.map((V,q)=>e.jsxs(Pe,{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(V.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Ot,{className:"text-lg font-semibold text-white",children:V.title})]}),e.jsx(Re,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:V.description})})]},q))}),e.jsx("div",{className:"text-center mt-12",children:e.jsxs(K,{size:"lg",onClick:()=>{var V;return(V=document.getElementById("pricing"))==null?void 0:V.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(ei,{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(pa,{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((V,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(Jn,{className:"w-4 h-4 text-[#4a6b6d]"})}),e.jsx("span",{className:"text-foreground",children:V})]},q))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var V;return(V=document.getElementById("pricing"))==null?void 0:V.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["See Brokerage Plans",e.jsx(Sa,{className:"ml-2 w-5 h-5"})]}),e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>E(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[e.jsx(on,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:UEt,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:WEt.map((V,q)=>e.jsx(Pe,{className:"bg-muted/30 border-0",children:e.jsxs(Re,{className:"pt-8",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map($=>e.jsx(Hn,{className:"w-5 h-5 fill-yellow-400 text-yellow-400"},$))}),e.jsxs("p",{className:"text-lg mb-6 italic text-muted-foreground",children:['"',V.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:V.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:V.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:()=>L("individual_agent"),children:["Start Free Trial",e.jsx(ei,{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(Pe,{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(Ti,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsx(Ot,{className:"text-xl font-sans",children:Mu.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:Mu.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Mu.individual_agent.period})]}),e.jsx(hr,{className:"text-base mt-2",children:Mu.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(ln,{className:"w-4 h-4"}),Mu.individual_agent.trial]})]}),e.jsx(Re,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Mu.individual_agent.features.map((V,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(Jn,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:V})]},q))})}),e.jsxs(GL,{className:"flex flex-col gap-3 pt-4",children:[e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>L("individual_agent"),children:"Start Free Trial"}),e.jsx(K,{variant:"outline",className:"w-full rounded-full border-2 border-[#4a6b6d] text-[#4a6b6d] bg-white hover:bg-[#4a6b6d]/5 uppercase text-sm font-medium tracking-wide",onClick:()=>L("individual_agent",!0),children:"Skip Trial, Subscribe Now"})]})]}),e.jsxs(Pe,{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(pa,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-xl font-sans",children:Mu.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Mu.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:Mu.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Mu.brokerage_under_25.period})]}),e.jsx(hr,{className:"text-base mt-2",children:Mu.brokerage_under_25.description})]}),e.jsx(Re,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Mu.brokerage_under_25.features.map((V,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(Jn,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:V})]},q))})}),e.jsx(GL,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg shadow-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>L("brokerage_under_25"),children:"Get Started"})})]}),e.jsxs(Pe,{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(pa,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-xl font-sans",children:Mu.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Mu.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:Mu.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Mu.brokerage_over_25.period})]}),e.jsx(hr,{className:"text-base mt-2",children:Mu.brokerage_over_25.description})]}),e.jsx(Re,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Mu.brokerage_over_25.features.map((V,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(Jn,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:V})]},q))})}),e.jsx(GL,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>L("brokerage_over_25"),children:"Get Started"})})]})]})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl text-white font-sans md:text-5xl",children:"Ready to Level Up?"}),e.jsx("p",{className:"text-lg text-white/80 max-w-2xl mx-auto",children:"Join thousands of agents who are closing more deals, saving time, and growing their business with LevelUp."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs(K,{size:"lg",onClick:()=>{var V;return(V=document.getElementById("pricing"))==null?void 0:V.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(ei,{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:hle,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(VEt,{open:C,onOpenChange:E}),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(Ir,{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(xe,{htmlFor:"dialog-name",children:["Full Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(De,{id:"dialog-name",type:"text",placeholder:"John Smith",value:y,onChange:V=>_(V.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(xe,{htmlFor:"dialog-email",children:["Email Address ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(De,{id:"dialog-email",type:"email",placeholder:"you@example.com",value:p,onChange:V=>x(V.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(xe,{htmlFor:"dialog-coupon",children:["Discount Code ",e.jsx("span",{className:"text-muted-foreground",children:"(Optional)"})]}),e.jsx(De,{id:"dialog-coupon",type:"text",placeholder:"Enter discount code",value:b,onChange:V=>N(V.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"})]})})]})},TIe=()=>e.jsxs(e.Fragment,{children:[e.jsxs(wc,{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"})]})]})]})]})})]}),AIe=()=>e.jsxs(e.Fragment,{children:[e.jsxs(wc,{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"})]})]})]})]})})]}),ZEt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(wc,{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"})]})]})]})]})})]}),YEt=bC({email:Wl().email("Invalid email address"),password:Wl().min(6,"Password must be at least 6 characters")}),XEt=()=>{const{signIn:t,user:s}=Fs(),r=_r(),[n,a]=S.useState(!1),[o,l]=S.useState({}),[i,d]=S.useState(""),[u,p]=S.useState(!1),[x,y]=S.useState(!1);S.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),k=w.get("email"),C=w.get("password");try{YEt.parse({email:k,password:C}),await t(k,C)}catch(E){if(E instanceof u0){const L={};E.errors.forEach(I=>{I.path[0]&&(L[I.path[0]]=I.message)}),l(L)}}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(ha,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[e.jsx(Fa,{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:bGe,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(Pe,{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(Ot,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(hr,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),e.jsx(Re,{children:e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"signin-email",className:"text-gray-700",children:"Email"}),e.jsx(De,{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(xe,{htmlFor:"signin-password",className:"text-gray-700",children:"Password"}),e.jsx(De,{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:x,onOpenChange:y,children:[e.jsx(pi,{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(Ir,{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(xe,{htmlFor:"reset-email",className:"text-gray-700",children:"Email"}),e.jsx(De,{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(ha,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},QEt=()=>{const[t]=Nc(),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(Pe,{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(ti,{className:"w-10 h-10 text-green-500"})}),e.jsx(Ot,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(hr,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),e.jsxs(Re,{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(rr,{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."})})]})]})})},VZe=t=>{const[s,r]=S.useState(null),[n,a]=S.useState(!0);return S.useEffect(()=>{if(!t){a(!1);return}(async()=>{try{const{data:i}=await G.storage.from("avatars").list(`${t}`);if(i&&i.length>0){const{data:d}=G.storage.from("avatars").getPublicUrl(`${t}/${i[0].name}`);r(`${d.publicUrl}?t=${Date.now()}`)}else r(null)}catch(i){console.error("Error fetching avatar:",i),r(null)}finally{a(!1)}})()},[t]),{avatarUrl:s,loading:n,refreshAvatar:async()=>{if(t)try{const{data:l}=await G.storage.from("avatars").list(`${t}`);if(l&&l.length>0){const{data:i}=G.storage.from("avatars").getPublicUrl(`${t}/${l[0].name}`);r(`${i.publicUrl}?t=${Date.now()}`)}}catch(l){console.error("Error refreshing avatar:",l)}}}},HZe=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},JEt=t=>{const[s,r]=S.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return S.useEffect(()=>{if(!t){r(a=>({...a,loading:!1}));return}(async()=>{try{const{data:a,error:o}=await G.from("profiles").select("is_trial, trial_expires_at, subscription_status, subscription_end_date").eq("id",t).single();if(o){console.error("Error fetching trial status:",o),r(d=>({...d,loading:!1}));return}const l=(a==null?void 0:a.subscription_status)==="trialing"&&(a==null?void 0:a.subscription_end_date),i=(a==null?void 0:a.is_trial)&&(a==null?void 0:a.trial_expires_at);if(l){const d=new Date().getTime(),u=new Date(a.subscription_end_date).getTime(),p=Math.ceil((u-d)/(1e3*60*60*24)),x=p<=0;r({isTrial:!0,isExpired:x,expiresAt:a.subscription_end_date,daysLeft:x?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)),x=p<=0;r({isTrial:!0,isExpired:x,expiresAt:a.trial_expires_at,daysLeft:x?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},GZe=()=>{const{data:t,isLoading:s}=gt({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")}},EIe="community_last_seen_post_at";function ePt(){const{user:t}=Fs(),s=Ol(),[r,n]=S.useState(0),[a,o]=S.useState(null);S.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${EIe}_${t.id}`);o(i)},[t]),S.useEffect(()=>{if(!t)return;(async()=>{let d=G.from("community_posts").select("id",{count:"exact",head:!0});a&&(d=d.gt("created_at",a)),await G.from("profiles").select("brokerage_id").eq("id",t.id).single();const{count:u,error:p}=await d;!p&&u!==null&&n(u)})()},[t,a]),S.useEffect(()=>{if(!t)return;const i=G.channel("community-new-posts").on("postgres_changes",{event:"INSERT",schema:"public",table:"community_posts"},async d=>{const u=d.new;if(u.user_id===t.id)return;const p=s.pathname==="/community";p||n(N=>N+1);const{data:x}=await G.from("profiles").select("name").eq("id",u.user_id).single(),y=(x==null?void 0:x.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=S.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${EIe}_${t.id}`,i),o(i),n(0)},[t]);return S.useEffect(()=>{s.pathname==="/community"&&r>0&&l()},[s.pathname,r,l]),{unreadCount:r,markAsRead:l}}function tPt(){const{isAdmin:t}=Fs(),{data:s=0}=gt({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 GA=vue,DNe=Bje,sPt=_ue,WZe=S.forwardRef(({className:t,...s},r)=>e.jsx(BA,{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}));WZe.displayName=BA.displayName;const rPt=gC("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"}}),wC=S.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(sPt,{children:[e.jsx(WZe,{}),e.jsxs($A,{ref:a,className:Rt(rPt({side:t}),s),...n,children:[r,e.jsxs(LR,{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"})]})]})]}));wC.displayName=$A.displayName;const WA=({className:t,...s})=>e.jsx("div",{className:Rt("flex flex-col space-y-2 text-center sm:text-left",t),...s});WA.displayName="SheetHeader";const KA=S.forwardRef(({className:t,...s},r)=>e.jsx(PR,{ref:r,className:Rt("text-lg font-semibold text-foreground",t),...s}));KA.displayName=PR.displayName;const KZe=S.forwardRef(({className:t,...s},r)=>e.jsx(IR,{ref:r,className:Rt("text-sm text-muted-foreground",t),...s}));KZe.displayName=IR.displayName;var que="Collapsible",[nPt,ATs]=$c(que),[aPt,RNe]=nPt(que),ZZe=S.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[d,u]=$u({prop:n,defaultProp:a??!1,onChange:l,caller:que});return e.jsx(aPt,{scope:r,disabled:o,contentId:pu(),open:d,onOpenToggle:S.useCallback(()=>u(p=>!p),[u]),children:e.jsx(Yr.div,{"data-state":FNe(d),"data-disabled":o?"":void 0,...i,ref:s})})});ZZe.displayName=que;var YZe="CollapsibleTrigger",XZe=S.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=RNe(YZe,r);return e.jsx(Yr.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":FNe(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Cr(t.onClick,a.onOpenToggle)})});XZe.displayName=YZe;var ONe="CollapsibleContent",QZe=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=RNe(ONe,t.__scopeCollapsible);return e.jsx(wd,{present:r||a.open,children:({present:o})=>e.jsx(iPt,{...n,ref:s,present:o})})});QZe.displayName=ONe;var iPt=S.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=RNe(ONe,r),[i,d]=S.useState(n),u=S.useRef(null),p=Aa(s,u),x=S.useRef(0),y=x.current,_=S.useRef(0),b=_.current,N=l.open||i,w=S.useRef(N),k=S.useRef(void 0);return S.useEffect(()=>{const C=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(C)},[]),rd(()=>{const C=u.current;if(C){k.current=k.current||{transitionDuration:C.style.transitionDuration,animationName:C.style.animationName},C.style.transitionDuration="0s",C.style.animationName="none";const E=C.getBoundingClientRect();x.current=E.height,_.current=E.width,w.current||(C.style.transitionDuration=k.current.transitionDuration,C.style.animationName=k.current.animationName),d(n)}},[l.open,n]),e.jsx(Yr.div,{"data-state":FNe(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 FNe(t){return t?"open":"closed"}var oPt=ZZe;const of=oPt,lf=XZe,cf=QZe,lPt="/assets/levelup-logo-Eif24dqY.png",cPt="/assets/levelup-logo-icon-C-7iromj.png",dPt="/assets/levelup-logo-mobile-B9skSjUG.png";var $R=t=>t.type==="checkbox",x4=t=>t instanceof Date,fm=t=>t==null;const JZe=t=>typeof t=="object";var bd=t=>!fm(t)&&!Array.isArray(t)&&JZe(t)&&!x4(t),eYe=t=>bd(t)&&t.target?$R(t.target)?t.target.checked:t.target.value:t,uPt=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,tYe=(t,s)=>t.has(uPt(s)),hPt=t=>{const s=t.constructor&&t.constructor.prototype;return bd(s)&&s.hasOwnProperty("isPrototypeOf")},zNe=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Qd(t){let s;const r=Array.isArray(t),n=typeof FileList<"u"?t instanceof FileList:!1;if(t instanceof Date)s=new Date(t);else if(!(zNe&&(t instanceof Blob||n))&&(r||bd(t)))if(s=r?[]:{},!r&&!hPt(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=Qd(t[a]));else return t;return s}var Uue=t=>/^\w*$/.test(t),dd=t=>t===void 0,BNe=t=>Array.isArray(t)?t.filter(Boolean):[],$Ne=t=>BNe(t.replace(/["|']|\]/g,"").split(/\.|\[/)),Cn=(t,s,r)=>{if(!s||!bd(t))return r;const n=(Uue(s)?[s]:$Ne(s)).reduce((a,o)=>fm(a)?a:a[o],t);return dd(n)||n===t?dd(t[s])?r:t[s]:n},Kp=t=>typeof t=="boolean",Vo=(t,s,r)=>{let n=-1;const a=Uue(s)?[s]:$Ne(s),o=a.length,l=o-1;for(;++nft.useContext(qNe),mPt=t=>{const{children:s,...r}=t;return ft.createElement(qNe.Provider,{value:r},s)};var sYe=(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]!==bg.all&&(s._proxyFormState[l]=!n||bg.all),r&&(r[l]=!0),t[l]}});return a};const UNe=typeof window<"u"?ft.useLayoutEffect:ft.useEffect;function pPt(t){const s=Vue(),{control:r=s.control,disabled:n,name:a,exact:o}=t||{},[l,i]=ft.useState(r._formState),d=ft.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return UNe(()=>r._subscribe({name:a,formState:d.current,exact:o,callback:u=>{!n&&i({...r._formState,...u})}}),[a,n,o]),ft.useEffect(()=>{d.current.isValid&&r._setValid(!0)},[r]),ft.useMemo(()=>sYe(l,r,d.current,!1),[l,r])}var $y=t=>typeof t=="string",rYe=(t,s,r,n,a)=>$y(t)?(n&&s.watch.add(t),Cn(r,t,a)):Array.isArray(t)?t.map(o=>(n&&s.watch.add(o),Cn(r,o))):(n&&(s.watchAll=!0),r),J1e=t=>fm(t)||!JZe(t);function Lv(t,s,r=new WeakSet){if(J1e(t)||J1e(s))return t===s;if(x4(t)&&x4(s))return t.getTime()===s.getTime();const n=Object.keys(t),a=Object.keys(s);if(n.length!==a.length)return!1;if(r.has(t)||r.has(s))return!0;r.add(t),r.add(s);for(const o of n){const l=t[o];if(!a.includes(o))return!1;if(o!=="ref"){const i=s[o];if(x4(l)&&x4(i)||bd(l)&&bd(i)||Array.isArray(l)&&Array.isArray(i)?!Lv(l,i,r):l!==i)return!1}}return!0}function fPt(t){const s=Vue(),{control:r=s.control,name:n,defaultValue:a,disabled:o,exact:l,compute:i}=t||{},d=ft.useRef(a),u=ft.useRef(i),p=ft.useRef(void 0);u.current=i;const x=ft.useMemo(()=>r._getWatch(n,d.current),[r,n]),[y,_]=ft.useState(u.current?u.current(x):x);return UNe(()=>r._subscribe({name:n,formState:{values:!0},exact:l,callback:b=>{if(!o){const N=rYe(n,r._names,b.values||r._formValues,!1,d.current);if(u.current){const w=u.current(N);Lv(w,p.current)||(_(w),p.current=w)}else _(N)}}}),[r,o,n,l]),ft.useEffect(()=>r._removeUnmounted()),y}function xPt(t){const s=Vue(),{name:r,disabled:n,control:a=s.control,shouldUnregister:o,defaultValue:l}=t,i=tYe(a._names.array,r),d=ft.useMemo(()=>Cn(a._formValues,r,Cn(a._defaultValues,r,l)),[a,r,l]),u=fPt({control:a,name:r,defaultValue:d,exact:!0}),p=pPt({control:a,name:r,exact:!0}),x=ft.useRef(t),y=ft.useRef(a.register(r,{...t.rules,value:u,...Kp(t.disabled)?{disabled:t.disabled}:{}}));x.current=t;const _=ft.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Cn(p.errors,r)},isDirty:{enumerable:!0,get:()=>!!Cn(p.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!Cn(p.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!Cn(p.validatingFields,r)},error:{enumerable:!0,get:()=>Cn(p.errors,r)}}),[p,r]),b=ft.useCallback(C=>y.current.onChange({target:{value:eYe(C),name:r},type:mle.CHANGE}),[r]),N=ft.useCallback(()=>y.current.onBlur({target:{value:Cn(a._formValues,r),name:r},type:mle.BLUR}),[r,a._formValues]),w=ft.useCallback(C=>{const E=Cn(a._fields,r);E&&C&&(E._f.ref={focus:()=>C.focus&&C.focus(),select:()=>C.select&&C.select(),setCustomValidity:L=>C.setCustomValidity(L),reportValidity:()=>C.reportValidity()})},[a._fields,r]),k=ft.useMemo(()=>({name:r,value:u,...Kp(n)||p.disabled?{disabled:p.disabled||n}:{},onChange:b,onBlur:N,ref:w}),[r,n,p.disabled,b,N,w,u]);return ft.useEffect(()=>{const C=a._options.shouldUnregister||o;a.register(r,{...x.current.rules,...Kp(x.current.disabled)?{disabled:x.current.disabled}:{}});const E=(L,I)=>{const O=Cn(a._fields,L);O&&O._f&&(O._f.mount=I)};if(E(r,!0),C){const L=Qd(Cn(a._options.defaultValues,r));Vo(a._defaultValues,r,L),dd(Cn(a._formValues,r))&&Vo(a._formValues,r,L)}return!i&&a.register(r),()=>{(i?C&&!a._state.action:C)?a.unregister(r):E(r,!1)}},[r,a,i,o]),ft.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),ft.useMemo(()=>({field:k,formState:p,fieldState:_}),[k,p,_])}const gPt=t=>t.render(xPt(t));var nYe=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},e8=t=>Array.isArray(t)?t:[t],PIe=()=>{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=[]}}},Qm=t=>bd(t)&&!Object.keys(t).length,VNe=t=>t.type==="file",wg=t=>typeof t=="function",ple=t=>{if(!zNe)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},aYe=t=>t.type==="select-multiple",HNe=t=>t.type==="radio",yPt=t=>HNe(t)||$R(t),Rge=t=>ple(t)&&t.isConnected;function vPt(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if(wg(t[s]))return!0;return!1};function fle(t,s={}){const r=Array.isArray(t);if(bd(t)||r)for(const n in t)Array.isArray(t[n])||bd(t[n])&&!iYe(t[n])?(s[n]=Array.isArray(t[n])?[]:{},fle(t[n],s[n])):fm(t[n])||(s[n]=!0);return s}function oYe(t,s,r){const n=Array.isArray(t);if(bd(t)||n)for(const a in t)Array.isArray(t[a])||bd(t[a])&&!iYe(t[a])?dd(s)||J1e(r[a])?r[a]=Array.isArray(t[a])?fle(t[a],[]):{...fle(t[a])}:oYe(t[a],fm(s)?{}:s[a],r[a]):r[a]=!Lv(t[a],s[a]);return r}var Q6=(t,s)=>oYe(t,s,fle(s));const IIe={value:!1,isValid:!1},LIe={value:!0,isValid:!0};var lYe=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&&!dd(t[0].attributes.value)?dd(t[0].value)||t[0].value===""?LIe:{value:t[0].value,isValid:!0}:LIe:IIe}return IIe},cYe=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>dd(t)?t:s?t===""?NaN:t&&+t:r&&$y(t)?new Date(t):n?n(t):t;const DIe={isValid:!1,value:null};var dYe=t=>Array.isArray(t)?t.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,DIe):DIe;function RIe(t){const s=t.ref;return VNe(s)?s.files:HNe(s)?dYe(t.refs).value:aYe(s)?[...s.selectedOptions].map(({value:r})=>r):$R(s)?lYe(t.refs).value:cYe(dd(s.value)?t.ref.value:s.value,t)}var bPt=(t,s,r,n)=>{const a={};for(const o of t){const l=Cn(s,o);l&&Vo(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},xle=t=>t instanceof RegExp,J6=t=>dd(t)?t:xle(t)?t.source:bd(t)?xle(t.value)?t.value.source:t.value:t,OIe=t=>({isOnSubmit:!t||t===bg.onSubmit,isOnBlur:t===bg.onBlur,isOnChange:t===bg.onChange,isOnAll:t===bg.all,isOnTouch:t===bg.onTouched});const FIe="AsyncFunction";var wPt=t=>!!t&&!!t.validate&&!!(wg(t.validate)&&t.validate.constructor.name===FIe||bd(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===FIe)),jPt=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),zIe=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const t8=(t,s,r,n)=>{for(const a of r||Object.keys(t)){const o=Cn(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(t8(i,s))break}else if(bd(i)&&t8(i,s))break}}};function BIe(t,s,r){const n=Cn(t,r);if(n||Uue(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const o=a.join("."),l=Cn(s,o),i=Cn(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 NPt=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return Qm(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||bg.all))},kPt=(t,s,r)=>!t||!s||t===s||e8(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),SPt=(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,CPt=(t,s)=>!BNe(Cn(t,s)).length&&Pd(t,s),MPt=(t,s,r)=>{const n=e8(Cn(t,r));return Vo(n,"root",s[r]),Vo(t,r,n),t},Wie=t=>$y(t);function $Ie(t,s,r="validate"){if(Wie(t)||Array.isArray(t)&&t.every(Wie)||Kp(t)&&!t)return{type:r,message:Wie(t)?t:"",ref:s}}var h5=t=>bd(t)&&!xle(t)?t:{value:t,message:""},qIe=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:d,maxLength:u,minLength:p,min:x,max:y,pattern:_,validate:b,name:N,valueAsNumber:w,mount:k}=t._f,C=Cn(r,N);if(!k||s.has(N))return{};const E=i?i[0]:l,L=Y=>{a&&E.reportValidity&&(E.setCustomValidity(Kp(Y)?"":Y||""),E.reportValidity())},I={},O=HNe(l),V=$R(l),q=O||V,$=(w||VNe(l))&&dd(l.value)&&dd(C)||ple(l)&&l.value===""||C===""||Array.isArray(C)&&!C.length,U=nYe.bind(null,N,n,I),se=(Y,J,X,ce=uv.maxLength,ie=uv.minLength)=>{const ae=Y?J:X;I[N]={type:Y?ce:ie,message:ae,ref:l,...U(Y?ce:ie,ae)}};if(o?!Array.isArray(C)||!C.length:d&&(!q&&($||fm(C))||Kp(C)&&!C||V&&!lYe(i).isValid||O&&!dYe(i).isValid)){const{value:Y,message:J}=Wie(d)?{value:!!d,message:d}:h5(d);if(Y&&(I[N]={type:uv.required,message:J,ref:E,...U(uv.required,J)},!n))return L(J),I}if(!$&&(!fm(x)||!fm(y))){let Y,J;const X=h5(y),ce=h5(x);if(!fm(C)&&!isNaN(C)){const ie=l.valueAsNumber||C&&+C;fm(X.value)||(Y=ie>X.value),fm(ce.value)||(J=ienew Date(new Date().toDateString()+" "+_e),oe=l.type=="time",pe=l.type=="week";$y(X.value)&&C&&(Y=oe?ae(C)>ae(X.value):pe?C>X.value:ie>new Date(X.value)),$y(ce.value)&&C&&(J=oe?ae(C)+Y.value,ce=!fm(J.value)&&C.length<+J.value;if((X||ce)&&(se(X,Y.message,J.message),!n))return L(I[N].message),I}if(_&&!$&&$y(C)){const{value:Y,message:J}=h5(_);if(xle(Y)&&!C.match(Y)&&(I[N]={type:uv.pattern,message:J,ref:l,...U(uv.pattern,J)},!n))return L(J),I}if(b){if(wg(b)){const Y=await b(C,r),J=$Ie(Y,E);if(J&&(I[N]={...J,...U(uv.validate,J.message)},!n))return L(J.message),I}else if(bd(b)){let Y={};for(const J in b){if(!Qm(Y)&&!n)break;const X=$Ie(await b[J](C,r),E,J);X&&(Y={...X,...U(J,X.message)},L(X.message),n&&(I[N]=Y))}if(!Qm(Y)&&(I[N]={ref:E,...Y},!n))return I}}return L(!0),I};const TPt={mode:bg.onSubmit,reValidateMode:bg.onChange,shouldFocusError:!0};function APt(t={}){let s={...TPt,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:wg(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=bd(s.defaultValues)||bd(s.values)?Qd(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:Qd(a),l={action:!1,mount:!1,watch:!1},i={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},d,u=0;const p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let x={...p};const y={array:PIe(),state:PIe()},_=s.criteriaMode===bg.all,b=We=>ot=>{clearTimeout(u),u=setTimeout(We,ot)},N=async We=>{if(!s.disabled&&(p.isValid||x.isValid||We)){const ot=s.resolver?Qm((await V()).errors):await $(n,!0);ot!==r.isValid&&y.state.next({isValid:ot})}},w=(We,ot)=>{!s.disabled&&(p.isValidating||p.validatingFields||x.isValidating||x.validatingFields)&&((We||Array.from(i.mount)).forEach(Ge=>{Ge&&(ot?Vo(r.validatingFields,Ge,ot):Pd(r.validatingFields,Ge))}),y.state.next({validatingFields:r.validatingFields,isValidating:!Qm(r.validatingFields)}))},k=(We,ot=[],Ge,et,ht=!0,xt=!0)=>{if(et&&Ge&&!s.disabled){if(l.action=!0,xt&&Array.isArray(Cn(n,We))){const Ke=Ge(Cn(n,We),et.argA,et.argB);ht&&Vo(n,We,Ke)}if(xt&&Array.isArray(Cn(r.errors,We))){const Ke=Ge(Cn(r.errors,We),et.argA,et.argB);ht&&Vo(r.errors,We,Ke),CPt(r.errors,We)}if((p.touchedFields||x.touchedFields)&&xt&&Array.isArray(Cn(r.touchedFields,We))){const Ke=Ge(Cn(r.touchedFields,We),et.argA,et.argB);ht&&Vo(r.touchedFields,We,Ke)}(p.dirtyFields||x.dirtyFields)&&(r.dirtyFields=Q6(a,o)),y.state.next({name:We,isDirty:se(We,ot),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Vo(o,We,ot)},C=(We,ot)=>{Vo(r.errors,We,ot),y.state.next({errors:r.errors})},E=We=>{r.errors=We,y.state.next({errors:r.errors,isValid:!1})},L=(We,ot,Ge,et)=>{const ht=Cn(n,We);if(ht){const xt=Cn(o,We,dd(Ge)?Cn(a,We):Ge);dd(xt)||et&&et.defaultChecked||ot?Vo(o,We,ot?xt:RIe(ht._f)):X(We,xt),l.mount&&N()}},I=(We,ot,Ge,et,ht)=>{let xt=!1,Ke=!1;const Ze={name:We};if(!s.disabled){if(!Ge||et){(p.isDirty||x.isDirty)&&(Ke=r.isDirty,r.isDirty=Ze.isDirty=se(),xt=Ke!==Ze.isDirty);const Et=Lv(Cn(a,We),ot);Ke=!!Cn(r.dirtyFields,We),Et?Pd(r.dirtyFields,We):Vo(r.dirtyFields,We,!0),Ze.dirtyFields=r.dirtyFields,xt=xt||(p.dirtyFields||x.dirtyFields)&&Ke!==!Et}if(Ge){const Et=Cn(r.touchedFields,We);Et||(Vo(r.touchedFields,We,Ge),Ze.touchedFields=r.touchedFields,xt=xt||(p.touchedFields||x.touchedFields)&&Et!==Ge)}xt&&ht&&y.state.next(Ze)}return xt?Ze:{}},O=(We,ot,Ge,et)=>{const ht=Cn(r.errors,We),xt=(p.isValid||x.isValid)&&Kp(ot)&&r.isValid!==ot;if(s.delayError&&Ge?(d=b(()=>C(We,Ge)),d(s.delayError)):(clearTimeout(u),d=null,Ge?Vo(r.errors,We,Ge):Pd(r.errors,We)),(Ge?!Lv(ht,Ge):ht)||!Qm(et)||xt){const Ke={...et,...xt&&Kp(ot)?{isValid:ot}:{},errors:r.errors,name:We};r={...r,...Ke},y.state.next(Ke)}},V=async We=>{w(We,!0);const ot=await s.resolver(o,s.context,bPt(We||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return w(We),ot},q=async We=>{const{errors:ot}=await V(We);if(We)for(const Ge of We){const et=Cn(ot,Ge);et?Vo(r.errors,Ge,et):Pd(r.errors,Ge)}else r.errors=ot;return ot},$=async(We,ot,Ge={valid:!0})=>{for(const et in We){const ht=We[et];if(ht){const{_f:xt,...Ke}=ht;if(xt){const Ze=i.array.has(xt.name),Et=ht._f&&wPt(ht._f);Et&&p.validatingFields&&w([et],!0);const $t=await qIe(ht,i.disabled,o,_,s.shouldUseNativeValidation&&!ot,Ze);if(Et&&p.validatingFields&&w([et]),$t[xt.name]&&(Ge.valid=!1,ot))break;!ot&&(Cn($t,xt.name)?Ze?MPt(r.errors,$t,xt.name):Vo(r.errors,xt.name,$t[xt.name]):Pd(r.errors,xt.name))}!Qm(Ke)&&await $(Ke,ot,Ge)}}return Ge.valid},U=()=>{for(const We of i.unMount){const ot=Cn(n,We);ot&&(ot._f.refs?ot._f.refs.every(Ge=>!Rge(Ge)):!Rge(ot._f.ref))&&Fe(We)}i.unMount=new Set},se=(We,ot)=>!s.disabled&&(We&&ot&&Vo(o,We,ot),!Lv(_e(),a)),Y=(We,ot,Ge)=>rYe(We,i,{...l.mount?o:dd(ot)?a:$y(We)?{[We]:ot}:ot},Ge,ot),J=We=>BNe(Cn(l.mount?o:a,We,s.shouldUnregister?Cn(a,We,[]):[])),X=(We,ot,Ge={})=>{const et=Cn(n,We);let ht=ot;if(et){const xt=et._f;xt&&(!xt.disabled&&Vo(o,We,cYe(ot,xt)),ht=ple(xt.ref)&&fm(ot)?"":ot,aYe(xt.ref)?[...xt.ref.options].forEach(Ke=>Ke.selected=ht.includes(Ke.value)):xt.refs?$R(xt.ref)?xt.refs.forEach(Ke=>{(!Ke.defaultChecked||!Ke.disabled)&&(Array.isArray(ht)?Ke.checked=!!ht.find(Ze=>Ze===Ke.value):Ke.checked=ht===Ke.value||!!ht)}):xt.refs.forEach(Ke=>Ke.checked=Ke.value===ht):VNe(xt.ref)?xt.ref.value="":(xt.ref.value=ht,xt.ref.type||y.state.next({name:We,values:Qd(o)})))}(Ge.shouldDirty||Ge.shouldTouch)&&I(We,ht,Ge.shouldTouch,Ge.shouldDirty,!0),Ge.shouldValidate&&pe(We)},ce=(We,ot,Ge)=>{for(const et in ot){if(!ot.hasOwnProperty(et))return;const ht=ot[et],xt=We+"."+et,Ke=Cn(n,xt);(i.array.has(We)||bd(ht)||Ke&&!Ke._f)&&!x4(ht)?ce(xt,ht,Ge):X(xt,ht,Ge)}},ie=(We,ot,Ge={})=>{const et=Cn(n,We),ht=i.array.has(We),xt=Qd(ot);Vo(o,We,xt),ht?(y.array.next({name:We,values:Qd(o)}),(p.isDirty||p.dirtyFields||x.isDirty||x.dirtyFields)&&Ge.shouldDirty&&y.state.next({name:We,dirtyFields:Q6(a,o),isDirty:se(We,xt)})):et&&!et._f&&!fm(xt)?ce(We,xt,Ge):X(We,xt,Ge),zIe(We,i)&&y.state.next({...r,name:We}),y.state.next({name:l.mount?We:void 0,values:Qd(o)})},ae=async We=>{l.mount=!0;const ot=We.target;let Ge=ot.name,et=!0;const ht=Cn(n,Ge),xt=Et=>{et=Number.isNaN(Et)||x4(Et)&&isNaN(Et.getTime())||Lv(Et,Cn(o,Ge,Et))},Ke=OIe(s.mode),Ze=OIe(s.reValidateMode);if(ht){let Et,$t;const Yt=ot.type?RIe(ht._f):eYe(We),Ps=We.type===mle.BLUR||We.type===mle.FOCUS_OUT,zs=!jPt(ht._f)&&!s.resolver&&!Cn(r.errors,Ge)&&!ht._f.deps||SPt(Ps,Cn(r.touchedFields,Ge),r.isSubmitted,Ze,Ke),Zs=zIe(Ge,i,Ps);Vo(o,Ge,Yt),Ps?(ht._f.onBlur&&ht._f.onBlur(We),d&&d(0)):ht._f.onChange&&ht._f.onChange(We);const Dr=I(Ge,Yt,Ps),zt=!Qm(Dr)||Zs;if(!Ps&&y.state.next({name:Ge,type:We.type,values:Qd(o)}),zs)return(p.isValid||x.isValid)&&(s.mode==="onBlur"?Ps&&N():Ps||N()),zt&&y.state.next({name:Ge,...Zs?{}:Dr});if(!Ps&&Zs&&y.state.next({...r}),s.resolver){const{errors:$s}=await V([Ge]);if(xt(Yt),et){const kr=BIe(r.errors,n,Ge),Xs=BIe($s,n,kr.name||Ge);Et=Xs.error,Ge=Xs.name,$t=Qm($s)}}else w([Ge],!0),Et=(await qIe(ht,i.disabled,o,_,s.shouldUseNativeValidation))[Ge],w([Ge]),xt(Yt),et&&(Et?$t=!1:(p.isValid||x.isValid)&&($t=await $(n,!0)));et&&(ht._f.deps&&pe(ht._f.deps),O(Ge,$t,Et,Dr))}},oe=(We,ot)=>{if(Cn(r.errors,ot)&&We.focus)return We.focus(),1},pe=async(We,ot={})=>{let Ge,et;const ht=e8(We);if(s.resolver){const xt=await q(dd(We)?We:ht);Ge=Qm(xt),et=We?!ht.some(Ke=>Cn(xt,Ke)):Ge}else We?(et=(await Promise.all(ht.map(async xt=>{const Ke=Cn(n,xt);return await $(Ke&&Ke._f?{[xt]:Ke}:Ke)}))).every(Boolean),!(!et&&!r.isValid)&&N()):et=Ge=await $(n);return y.state.next({...!$y(We)||(p.isValid||x.isValid)&&Ge!==r.isValid?{}:{name:We},...s.resolver||!We?{isValid:Ge}:{},errors:r.errors}),ot.shouldFocus&&!et&&t8(n,oe,We?ht:i.mount),et},_e=We=>{const ot={...l.mount?o:a};return dd(We)?ot:$y(We)?Cn(ot,We):We.map(Ge=>Cn(ot,Ge))},he=(We,ot)=>({invalid:!!Cn((ot||r).errors,We),isDirty:!!Cn((ot||r).dirtyFields,We),error:Cn((ot||r).errors,We),isValidating:!!Cn(r.validatingFields,We),isTouched:!!Cn((ot||r).touchedFields,We)}),we=We=>{We&&e8(We).forEach(ot=>Pd(r.errors,ot)),y.state.next({errors:We?r.errors:{}})},je=(We,ot,Ge)=>{const et=(Cn(n,We,{_f:{}})._f||{}).ref,ht=Cn(r.errors,We)||{},{ref:xt,message:Ke,type:Ze,...Et}=ht;Vo(r.errors,We,{...Et,...ot,ref:et}),y.state.next({name:We,errors:r.errors,isValid:!1}),Ge&&Ge.shouldFocus&&et&&et.focus&&et.focus()},Ue=(We,ot)=>wg(We)?y.state.subscribe({next:Ge=>"values"in Ge&&We(Y(void 0,ot),Ge)}):Y(We,ot,!0),Te=We=>y.state.subscribe({next:ot=>{kPt(We.name,ot.name,We.exact)&&NPt(ot,We.formState||p,at,We.reRenderRoot)&&We.callback({values:{...o},...r,...ot,defaultValues:a})}}).unsubscribe,Me=We=>(l.mount=!0,x={...x,...We.formState},Te({...We,formState:x})),Fe=(We,ot={})=>{for(const Ge of We?e8(We):i.mount)i.mount.delete(Ge),i.array.delete(Ge),ot.keepValue||(Pd(n,Ge),Pd(o,Ge)),!ot.keepError&&Pd(r.errors,Ge),!ot.keepDirty&&Pd(r.dirtyFields,Ge),!ot.keepTouched&&Pd(r.touchedFields,Ge),!ot.keepIsValidating&&Pd(r.validatingFields,Ge),!s.shouldUnregister&&!ot.keepDefaultValue&&Pd(a,Ge);y.state.next({values:Qd(o)}),y.state.next({...r,...ot.keepDirty?{isDirty:se()}:{}}),!ot.keepIsValid&&N()},Le=({disabled:We,name:ot})=>{(Kp(We)&&l.mount||We||i.disabled.has(ot))&&(We?i.disabled.add(ot):i.disabled.delete(ot))},Ne=(We,ot={})=>{let Ge=Cn(n,We);const et=Kp(ot.disabled)||Kp(s.disabled);return Vo(n,We,{...Ge||{},_f:{...Ge&&Ge._f?Ge._f:{ref:{name:We}},name:We,mount:!0,...ot}}),i.mount.add(We),Ge?Le({disabled:Kp(ot.disabled)?ot.disabled:s.disabled,name:We}):L(We,!0,ot.value),{...et?{disabled:ot.disabled||s.disabled}:{},...s.progressive?{required:!!ot.required,min:J6(ot.min),max:J6(ot.max),minLength:J6(ot.minLength),maxLength:J6(ot.maxLength),pattern:J6(ot.pattern)}:{},name:We,onChange:ae,onBlur:ae,ref:ht=>{if(ht){Ne(We,ot),Ge=Cn(n,We);const xt=dd(ht.value)&&ht.querySelectorAll&&ht.querySelectorAll("input,select,textarea")[0]||ht,Ke=yPt(xt),Ze=Ge._f.refs||[];if(Ke?Ze.find(Et=>Et===xt):xt===Ge._f.ref)return;Vo(n,We,{_f:{...Ge._f,...Ke?{refs:[...Ze.filter(Rge),xt,...Array.isArray(Cn(a,We))?[{}]:[]],ref:{type:xt.type,name:We}}:{ref:xt}}}),L(We,!1,void 0,xt)}else Ge=Cn(n,We,{}),Ge._f&&(Ge._f.mount=!1),(s.shouldUnregister||ot.shouldUnregister)&&!(tYe(i.array,We)&&l.action)&&i.unMount.add(We)}}},qe=()=>s.shouldFocusError&&t8(n,oe,i.mount),ze=We=>{Kp(We)&&(y.state.next({disabled:We}),t8(n,(ot,Ge)=>{const et=Cn(n,Ge);et&&(ot.disabled=et._f.disabled||We,Array.isArray(et._f.refs)&&et._f.refs.forEach(ht=>{ht.disabled=et._f.disabled||We}))},0,!1))},ve=(We,ot)=>async Ge=>{let et;Ge&&(Ge.preventDefault&&Ge.preventDefault(),Ge.persist&&Ge.persist());let ht=Qd(o);if(y.state.next({isSubmitting:!0}),s.resolver){const{errors:xt,values:Ke}=await V();r.errors=xt,ht=Qd(Ke)}else await $(n);if(i.disabled.size)for(const xt of i.disabled)Pd(ht,xt);if(Pd(r.errors,"root"),Qm(r.errors)){y.state.next({errors:{}});try{await We(ht,Ge)}catch(xt){et=xt}}else ot&&await ot({...r.errors},Ge),qe(),setTimeout(qe);if(y.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Qm(r.errors)&&!et,submitCount:r.submitCount+1,errors:r.errors}),et)throw et},dt=(We,ot={})=>{Cn(n,We)&&(dd(ot.defaultValue)?ie(We,Qd(Cn(a,We))):(ie(We,ot.defaultValue),Vo(a,We,Qd(ot.defaultValue))),ot.keepTouched||Pd(r.touchedFields,We),ot.keepDirty||(Pd(r.dirtyFields,We),r.isDirty=ot.defaultValue?se(We,Qd(Cn(a,We))):se()),ot.keepError||(Pd(r.errors,We),p.isValid&&N()),y.state.next({...r}))},fe=(We,ot={})=>{const Ge=We?Qd(We):a,et=Qd(Ge),ht=Qm(We),xt=ht?a:et;if(ot.keepDefaultValues||(a=Ge),!ot.keepValues){if(ot.keepDirtyValues){const Ke=new Set([...i.mount,...Object.keys(Q6(a,o))]);for(const Ze of Array.from(Ke))Cn(r.dirtyFields,Ze)?Vo(xt,Ze,Cn(o,Ze)):ie(Ze,Cn(xt,Ze))}else{if(zNe&&dd(We))for(const Ke of i.mount){const Ze=Cn(n,Ke);if(Ze&&Ze._f){const Et=Array.isArray(Ze._f.refs)?Ze._f.refs[0]:Ze._f.ref;if(ple(Et)){const $t=Et.closest("form");if($t){$t.reset();break}}}}if(ot.keepFieldsRef)for(const Ke of i.mount)ie(Ke,Cn(xt,Ke));else n={}}o=s.shouldUnregister?ot.keepDefaultValues?Qd(a):{}:Qd(xt),y.array.next({values:{...xt}}),y.state.next({values:{...xt}})}i={mount:ot.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!p.isValid||!!ot.keepIsValid||!!ot.keepDirtyValues,l.watch=!!s.shouldUnregister,y.state.next({submitCount:ot.keepSubmitCount?r.submitCount:0,isDirty:ht?!1:ot.keepDirty?r.isDirty:!!(ot.keepDefaultValues&&!Lv(We,a)),isSubmitted:ot.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:ht?{}:ot.keepDirtyValues?ot.keepDefaultValues&&o?Q6(a,o):r.dirtyFields:ot.keepDefaultValues&&We?Q6(a,We):ot.keepDirty?r.dirtyFields:{},touchedFields:ot.keepTouched?r.touchedFields:{},errors:ot.keepErrors?r.errors:{},isSubmitSuccessful:ot.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Ve=(We,ot)=>fe(wg(We)?We(o):We,ot),Je=(We,ot={})=>{const Ge=Cn(n,We),et=Ge&&Ge._f;if(et){const ht=et.refs?et.refs[0]:et.ref;ht.focus&&(ht.focus(),ot.shouldSelect&&wg(ht.select)&&ht.select())}},at=We=>{r={...r,...We}},Ye={control:{register:Ne,unregister:Fe,getFieldState:he,handleSubmit:ve,setError:je,_subscribe:Te,_runSchema:V,_focusError:qe,_getWatch:Y,_getDirty:se,_setValid:N,_setFieldArray:k,_setDisabledField:Le,_setErrors:E,_getFieldArray:J,_reset:fe,_resetDefaultValues:()=>wg(s.defaultValues)&&s.defaultValues().then(We=>{Ve(We,s.resetOptions),y.state.next({isLoading:!1})}),_removeUnmounted:U,_disableForm:ze,_subjects:y,_proxyFormState:p,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(We){l=We},get _defaultValues(){return a},get _names(){return i},set _names(We){i=We},get _formState(){return r},get _options(){return s},set _options(We){s={...s,...We}}},subscribe:Me,trigger:pe,register:Ne,handleSubmit:ve,watch:Ue,setValue:ie,getValues:_e,reset:Ve,resetField:dt,clearErrors:we,unregister:Fe,setError:je,setFocus:Je,getFieldState:he};return{...Ye,formControl:Ye}}function Hue(t={}){const s=ft.useRef(void 0),r=ft.useRef(void 0),[n,a]=ft.useState({isDirty:!1,isValidating:!1,isLoading:wg(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:wg(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!wg(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=APt(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,UNe(()=>{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]),ft.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),ft.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),ft.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),ft.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),ft.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==n.isDirty&&o._subjects.state.next({isDirty:l})}},[o,n.isDirty]),ft.useEffect(()=>{t.values&&!Lv(t.values,r.current)?(o._reset(t.values,{keepFieldsRef:!0,...o._options.resetOptions}),r.current=t.values,a(l=>({...l}))):o._resetDefaultValues()},[o,t.values]),ft.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=sYe(n,o),s.current}const UIe=(t,s,r)=>{if(t&&"reportValidity"in t){const n=Cn(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},uYe=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?UIe(n.ref,r,t):n.refs&&n.refs.forEach(a=>UIe(a,r,t))}},EPt=(t,s)=>{s.shouldUseNativeValidation&&uYe(t,s);const r={};for(const n in t){const a=Cn(s.fields,n),o=Object.assign(t[n]||{},{ref:a&&a.ref});if(PPt(s.names||Object.keys(t),n)){const l=Object.assign({},Cn(r,n));Vo(l,"root",o),Vo(r,n,l)}else Vo(r,n,o)}return r},PPt=(t,s)=>t.some(r=>r.startsWith(s+"."));var IPt=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(x){return t.push(x)})}),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},Gue=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&&uYe({},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:EPt(IPt(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const Wue=mPt,hYe=S.createContext({}),Ec=({...t})=>e.jsx(hYe.Provider,{value:{name:t.name},children:e.jsx(gPt,{...t})}),Kue=()=>{const t=S.useContext(hYe),s=S.useContext(mYe),{getFieldState:r,formState:n}=Vue(),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}},mYe=S.createContext({}),dc=S.forwardRef(({className:t,...s},r)=>{const n=S.useId();return e.jsx(mYe.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:Rt("space-y-2",t),...s})})});dc.displayName="FormItem";const uc=S.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=Kue();return e.jsx(xe,{ref:r,className:Rt(n&&"text-destructive",t),htmlFor:a,...s})});uc.displayName="FormLabel";const hc=S.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=Kue();return e.jsx(X2e,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});hc.displayName="FormControl";const Kie=S.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=Kue();return e.jsx("p",{ref:r,id:n,className:Rt("text-sm text-muted-foreground",t),...s})});Kie.displayName="FormDescription";const vm=S.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=Kue(),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});vm.displayName="FormMessage";const LPt=bC({category:qWe(["general","technology","crm","marketing"]),subject:Wl().min(5,"Subject must be at least 5 characters").max(200),description:Wl().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),DPt={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function e_e({trigger:t}){const[s,r]=S.useState(!1),[n,a]=S.useState(!1),{user:o}=Fs(),l=Hue({resolver:Gue(LPt),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:DPt[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(pi,{asChild:!0,children:t||e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(vL,{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(Ir,{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(Pn,{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(Wue,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(Ec,{control:l.control,name:"category",render:({field:d})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Category"}),e.jsxs(Bs,{onValueChange:d.onChange,defaultValue:d.value,children:[e.jsx(hc,{children:e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select a category"})})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"general",children:"General Support"}),e.jsx(vt,{value:"technology",children:"Technology Support"}),e.jsx(vt,{value:"crm",children:"CRM Support"}),e.jsx(vt,{value:"marketing",children:"Marketing Support"})]})]}),e.jsx(vm,{})]})}),e.jsx(Ec,{control:l.control,name:"subject",render:({field:d})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Subject"}),e.jsx(hc,{children:e.jsx(De,{placeholder:"Brief description of your issue",...d})}),e.jsx(vm,{})]})}),e.jsx(Ec,{control:l.control,name:"description",render:({field:d})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Description"}),e.jsx(hc,{children:e.jsx(vr,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...d})}),e.jsx(vm,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:n,children:n?"Submitting...":"Submit Ticket"})]})]})})]})]})}const RPt=()=>{const{user:t}=Fs(),s=_r(),[r,n]=S.useState([]),[a,o]=S.useState(0),[l,i]=S.useState(!1),[d,u]=S.useState(null);S.useEffect(()=>{if(!t)return;const b=`notification_last_read_${t.id}`;let N=d;if(!N){const C=localStorage.getItem(b);C&&(N=C,u(C))}(async()=>{const{data:C,error:E}=await G.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!E&&C){n(C);const L=N?new Date(N):null,I=C.filter(O=>L?new Date(O.created_at)>L:!0);o(I.length)}})();const k=G.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},C=>{const E=C.new;n(I=>[E,...I].slice(0,20));const L=N?new Date(N):null;(!L||new Date(E.created_at)>L)&&o(I=>I+1),Notification.permission==="granted"&&new Notification(E.title,{body:E.body,icon:"/favicon.ico"})}).subscribe();return()=>{G.removeChannel(k)}},[t,d]);const p=b=>{const N=b.toLowerCase();return N.includes("community")||N.includes("post")?ki:N.includes("academy")||N.includes("video")?Tn:N.includes("template")?Dl:N.includes("event")?on:N.includes("newsletter")?Qv:N.includes("brokerage")?Ih:N.includes("swag")||N.includes("social")?Ui:N.includes("toolbox")||N.includes("tool")?Ig:N.includes("brief")?$r:ki},x=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(Sm,{className:"h-5 w-5"}),a>0&&e.jsx(Qe,{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(ui,{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(va,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>x(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:gl(new Date(b.created_at),{addSuffix:!0})})]})]},b.id)})})]})]})};var VIe=1,OPt=.9,FPt=.8,zPt=.17,Oge=.1,Fge=.999,BPt=.9999,$Pt=.99,qPt=/[\\\/_+.#"@\[\(\{&]/,UPt=/[\\\/_+.#"@\[\(\{&]/g,VPt=/[\s-]/,pYe=/[\s-]/g;function t_e(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?VIe:$Pt;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,x,y,_,b;u>=0;)x=t_e(t,s,r,n,u+1,o+1,l),x>p&&(u===a?x*=VIe:qPt.test(t.charAt(u-1))?(x*=FPt,_=t.slice(a,u-1).match(UPt),_&&a>0&&(x*=Math.pow(Fge,_.length))):VPt.test(t.charAt(u-1))?(x*=OPt,b=t.slice(a,u-1).match(pYe),b&&a>0&&(x*=Math.pow(Fge,b.length))):(x*=zPt,a>0&&(x*=Math.pow(Fge,u-a))),t.charAt(u)!==s.charAt(o)&&(x*=BPt)),(xx&&(x=y*Oge)),x>p&&(p=x),u=r.indexOf(d,u+1);return l[i]=p,p}function HIe(t){return t.toLowerCase().replace(pYe," ")}function HPt(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,t_e(t,s,HIe(t),HIe(s),0,0,{})}var eI='[cmdk-group=""]',zge='[cmdk-group-items=""]',GPt='[cmdk-group-heading=""]',fYe='[cmdk-item=""]',GIe=`${fYe}:not([aria-disabled="true"])`,s_e="cmdk-item-select",A5="data-value",WPt=(t,s,r)=>HPt(t,s,r),xYe=S.createContext(void 0),qR=()=>S.useContext(xYe),gYe=S.createContext(void 0),GNe=()=>S.useContext(gYe),yYe=S.createContext(void 0),vYe=S.forwardRef((t,s)=>{let r=E5(()=>{var we,je;return{search:"",value:(je=(we=t.value)!=null?we:t.defaultValue)!=null?je:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=E5(()=>new Set),a=E5(()=>new Map),o=E5(()=>new Map),l=E5(()=>new Set),i=_Ye(t),{label:d,children:u,value:p,onValueChange:x,filter:y,shouldFilter:_,loop:b,disablePointerSelection:N=!1,vimBindings:w=!0,...k}=t,C=pu(),E=pu(),L=pu(),I=S.useRef(null),O=n6t();KS(()=>{if(p!==void 0){let we=p.trim();r.current.value=we,V.emit()}},[p]),KS(()=>{O(6,J)},[]);let V=S.useMemo(()=>({subscribe:we=>(l.current.add(we),()=>l.current.delete(we)),snapshot:()=>r.current,setState:(we,je,Ue)=>{var Te,Me,Fe,Le;if(!Object.is(r.current[we],je)){if(r.current[we]=je,we==="search")Y(),U(),O(1,se);else if(we==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Ne=document.getElementById(L);Ne?Ne.focus():(Te=document.getElementById(C))==null||Te.focus()}if(O(7,()=>{var Ne;r.current.selectedItemId=(Ne=X())==null?void 0:Ne.id,V.emit()}),Ue||O(5,J),((Me=i.current)==null?void 0:Me.value)!==void 0){let Ne=je??"";(Le=(Fe=i.current).onValueChange)==null||Le.call(Fe,Ne);return}}V.emit()}},emit:()=>{l.current.forEach(we=>we())}}),[]),q=S.useMemo(()=>({value:(we,je,Ue)=>{var Te;je!==((Te=o.current.get(we))==null?void 0:Te.value)&&(o.current.set(we,{value:je,keywords:Ue}),r.current.filtered.items.set(we,$(je,Ue)),O(2,()=>{U(),V.emit()}))},item:(we,je)=>(n.current.add(we),je&&(a.current.has(je)?a.current.get(je).add(we):a.current.set(je,new Set([we]))),O(3,()=>{Y(),U(),r.current.value||se(),V.emit()}),()=>{o.current.delete(we),n.current.delete(we),r.current.filtered.items.delete(we);let Ue=X();O(4,()=>{Y(),(Ue==null?void 0:Ue.getAttribute("id"))===we&&se(),V.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:L,labelId:E,listInnerRef:I}),[]);function $(we,je){var Ue,Te;let Me=(Te=(Ue=i.current)==null?void 0:Ue.filter)!=null?Te:WPt;return we?Me(we,r.current.search,je):0}function U(){if(!r.current.search||i.current.shouldFilter===!1)return;let we=r.current.filtered.items,je=[];r.current.filtered.groups.forEach(Te=>{let Me=a.current.get(Te),Fe=0;Me.forEach(Le=>{let Ne=we.get(Le);Fe=Math.max(Ne,Fe)}),je.push([Te,Fe])});let Ue=I.current;ce().sort((Te,Me)=>{var Fe,Le;let Ne=Te.getAttribute("id"),qe=Me.getAttribute("id");return((Fe=we.get(qe))!=null?Fe:0)-((Le=we.get(Ne))!=null?Le:0)}).forEach(Te=>{let Me=Te.closest(zge);Me?Me.appendChild(Te.parentElement===Me?Te:Te.closest(`${zge} > *`)):Ue.appendChild(Te.parentElement===Ue?Te:Te.closest(`${zge} > *`))}),je.sort((Te,Me)=>Me[1]-Te[1]).forEach(Te=>{var Me;let Fe=(Me=I.current)==null?void 0:Me.querySelector(`${eI}[${A5}="${encodeURIComponent(Te[0])}"]`);Fe==null||Fe.parentElement.appendChild(Fe)})}function se(){let we=ce().find(Ue=>Ue.getAttribute("aria-disabled")!=="true"),je=we==null?void 0:we.getAttribute(A5);V.setState("value",je||void 0)}function Y(){var we,je,Ue,Te;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Me=0;for(let Fe of n.current){let Le=(je=(we=o.current.get(Fe))==null?void 0:we.value)!=null?je:"",Ne=(Te=(Ue=o.current.get(Fe))==null?void 0:Ue.keywords)!=null?Te:[],qe=$(Le,Ne);r.current.filtered.items.set(Fe,qe),qe>0&&Me++}for(let[Fe,Le]of a.current)for(let Ne of Le)if(r.current.filtered.items.get(Ne)>0){r.current.filtered.groups.add(Fe);break}r.current.filtered.count=Me}function J(){var we,je,Ue;let Te=X();Te&&(((we=Te.parentElement)==null?void 0:we.firstChild)===Te&&((Ue=(je=Te.closest(eI))==null?void 0:je.querySelector(GPt))==null||Ue.scrollIntoView({block:"nearest"})),Te.scrollIntoView({block:"nearest"}))}function X(){var we;return(we=I.current)==null?void 0:we.querySelector(`${fYe}[aria-selected="true"]`)}function ce(){var we;return Array.from(((we=I.current)==null?void 0:we.querySelectorAll(GIe))||[])}function ie(we){let je=ce()[we];je&&V.setState("value",je.getAttribute(A5))}function ae(we){var je;let Ue=X(),Te=ce(),Me=Te.findIndex(Le=>Le===Ue),Fe=Te[Me+we];(je=i.current)!=null&&je.loop&&(Fe=Me+we<0?Te[Te.length-1]:Me+we===Te.length?Te[0]:Te[Me+we]),Fe&&V.setState("value",Fe.getAttribute(A5))}function oe(we){let je=X(),Ue=je==null?void 0:je.closest(eI),Te;for(;Ue&&!Te;)Ue=we>0?s6t(Ue,eI):r6t(Ue,eI),Te=Ue==null?void 0:Ue.querySelector(GIe);Te?V.setState("value",Te.getAttribute(A5)):ae(we)}let pe=()=>ie(ce().length-1),_e=we=>{we.preventDefault(),we.metaKey?pe():we.altKey?oe(1):ae(1)},he=we=>{we.preventDefault(),we.metaKey?ie(0):we.altKey?oe(-1):ae(-1)};return S.createElement(Yr.div,{ref:s,tabIndex:-1,...k,"cmdk-root":"",onKeyDown:we=>{var je;(je=k.onKeyDown)==null||je.call(k,we);let Ue=we.nativeEvent.isComposing||we.keyCode===229;if(!(we.defaultPrevented||Ue))switch(we.key){case"n":case"j":{w&&we.ctrlKey&&_e(we);break}case"ArrowDown":{_e(we);break}case"p":case"k":{w&&we.ctrlKey&&he(we);break}case"ArrowUp":{he(we);break}case"Home":{we.preventDefault(),ie(0);break}case"End":{we.preventDefault(),pe();break}case"Enter":{we.preventDefault();let Te=X();if(Te){let Me=new Event(s_e);Te.dispatchEvent(Me)}}}}},S.createElement("label",{"cmdk-label":"",htmlFor:q.inputId,id:q.labelId,style:i6t},d),Zue(t,we=>S.createElement(gYe.Provider,{value:V},S.createElement(xYe.Provider,{value:q},we))))}),KPt=S.forwardRef((t,s)=>{var r,n;let a=pu(),o=S.useRef(null),l=S.useContext(yYe),i=qR(),d=_Ye(t),u=(n=(r=d.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;KS(()=>{if(!u)return i.item(a,l==null?void 0:l.id)},[u]);let p=bYe(a,o,[t.value,t.children,o],t.keywords),x=GNe(),y=tw(O=>O.value&&O.value===p.current),_=tw(O=>u||i.filter()===!1?!0:O.search?O.filtered.items.get(a)>0:!0);S.useEffect(()=>{let O=o.current;if(!(!O||t.disabled))return O.addEventListener(s_e,b),()=>O.removeEventListener(s_e,b)},[_,t.onSelect,t.disabled]);function b(){var O,V;N(),(V=(O=d.current).onSelect)==null||V.call(O,p.current)}function N(){x.setState("value",p.current,!0)}if(!_)return null;let{disabled:w,value:k,onSelect:C,forceMount:E,keywords:L,...I}=t;return S.createElement(Yr.div,{ref:u1(o,s),...I,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)}),ZPt=S.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=pu(),i=S.useRef(null),d=S.useRef(null),u=pu(),p=qR(),x=tw(_=>a||p.filter()===!1?!0:_.search?_.filtered.groups.has(l):!0);KS(()=>p.group(l),[]),bYe(l,i,[t.value,t.heading,d]);let y=S.useMemo(()=>({id:l,forceMount:a}),[a]);return S.createElement(Yr.div,{ref:u1(i,s),...o,"cmdk-group":"",role:"presentation",hidden:x?void 0:!0},r&&S.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),Zue(t,_=>S.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},S.createElement(yYe.Provider,{value:y},_))))}),YPt=S.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=S.useRef(null),o=tw(l=>!l.search);return!r&&!o?null:S.createElement(Yr.div,{ref:u1(a,s),...n,"cmdk-separator":"",role:"separator"})}),XPt=S.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=GNe(),l=tw(u=>u.search),i=tw(u=>u.selectedItemId),d=qR();return S.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),S.createElement(Yr.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)}})}),QPt=S.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=S.useRef(null),l=S.useRef(null),i=tw(u=>u.selectedItemId),d=qR();return S.useEffect(()=>{if(l.current&&o.current){let u=l.current,p=o.current,x,y=new ResizeObserver(()=>{x=requestAnimationFrame(()=>{let _=u.offsetHeight;p.style.setProperty("--cmdk-list-height",_.toFixed(1)+"px")})});return y.observe(u),()=>{cancelAnimationFrame(x),y.unobserve(u)}}},[]),S.createElement(Yr.div,{ref:u1(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:d.listId},Zue(t,u=>S.createElement("div",{ref:u1(l,d.listInnerRef),"cmdk-list-sizer":""},u)))}),JPt=S.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return S.createElement(vue,{open:r,onOpenChange:n},S.createElement(_ue,{container:l},S.createElement(BA,{"cmdk-overlay":"",className:a}),S.createElement($A,{"aria-label":t.label,"cmdk-dialog":"",className:o},S.createElement(vYe,{ref:s,...i}))))}),e6t=S.forwardRef((t,s)=>tw(r=>r.filtered.count===0)?S.createElement(Yr.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),t6t=S.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return S.createElement(Yr.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Zue(t,l=>S.createElement("div",{"aria-hidden":!0},l)))}),_p=Object.assign(vYe,{List:QPt,Item:KPt,Input:XPt,Group:ZPt,Separator:YPt,Dialog:JPt,Empty:e6t,Loading:t6t});function s6t(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function r6t(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function _Ye(t){let s=S.useRef(t);return KS(()=>{s.current=t}),s}var KS=typeof window>"u"?S.useEffect:S.useLayoutEffect;function E5(t){let s=S.useRef();return s.current===void 0&&(s.current=t()),s}function tw(t){let s=GNe(),r=()=>t(s.snapshot());return S.useSyncExternalStore(s.subscribe,r,r)}function bYe(t,s,r,n=[]){let a=S.useRef(),o=qR();return KS(()=>{var l;let i=(()=>{var u;for(let p of r){if(typeof p=="string")return p.trim();if(typeof p=="object"&&"current"in p)return p.current?(u=p.current.textContent)==null?void 0:u.trim():a.current}})(),d=n.map(u=>u.trim());o.value(t,i,d),(l=s.current)==null||l.setAttribute(A5,i),a.current=i}),a}var n6t=()=>{let[t,s]=S.useState(),r=E5(()=>new Map);return KS(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function a6t(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function Zue({asChild:t,children:s},r){return t&&S.isValidElement(s)?S.cloneElement(a6t(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 Sx=S.forwardRef(({className:t,...s},r)=>e.jsx(_p,{ref:r,className:Rt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));Sx.displayName=_p.displayName;const o6t=({children:t,...s})=>e.jsx(fs,{...s,children:e.jsx(ms,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(Sx,{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})})}),Cx=S.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(an,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(_p.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})]}));Cx.displayName=_p.Input.displayName;const Mx=S.forwardRef(({className:t,...s},r)=>e.jsx(_p.List,{ref:r,className:Rt("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));Mx.displayName=_p.List.displayName;const Tx=S.forwardRef((t,s)=>e.jsx(_p.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Tx.displayName=_p.Empty.displayName;const Ax=S.forwardRef(({className:t,...s},r)=>e.jsx(_p.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}));Ax.displayName=_p.Group.displayName;const l6t=S.forwardRef(({className:t,...s},r)=>e.jsx(_p.Separator,{ref:r,className:Rt("-mx-1 h-px bg-border",t),...s}));l6t.displayName=_p.Separator.displayName;const lp=S.forwardRef(({className:t,...s},r)=>e.jsx(_p.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}));lp.displayName=_p.Item.displayName;const c6t={event:{label:"Events",icon:xd,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:Dl,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:Lh,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:Ig,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:$r,color:"bg-fuchsia-500/10 text-fuchsia-600"}},WIe=()=>{const[t,s]=S.useState(!1),[r,n]=S.useState(""),[a,o]=S.useState([]),[l,i]=S.useState(!1),d=_r();S.useEffect(()=>{const y=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),s(b=>!b))};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[]);const u=S.useCallback(async y=>{if(!y.trim()){o([]);return}i(!0);const _=`%${y}%`;try{const[b,N,w,k,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)]),E=[];b.data&&b.data.forEach(L=>{E.push({id:L.id,title:L.title,description:L.description,type:"event",date:L.event_date,path:`/event/${L.id}`})}),N.data&&N.data.forEach(L=>{E.push({id:L.id,title:L.name,description:L.description,type:"template",date:L.publish_date,path:`/templates/${L.id}`})}),w.data&&w.data.forEach(L=>{E.push({id:L.id,title:L.title,description:L.description,type:"academy",date:L.publish_date,path:`/academy/${L.id}`})}),k.data&&k.data.forEach(L=>{E.push({id:L.id,title:L.name,description:L.description,type:"toolbox",date:L.publish_date,path:`/toolbox/${L.id}`})}),C.data&&C.data.forEach(L=>{E.push({id:L.id,title:L.title,description:L.description,type:"social-swag",date:L.publish_date,path:`/social-swag/${L.id}`})}),o(E)}catch(b){console.error("Search error:",b)}finally{i(!1)}},[]);S.useEffect(()=>{const y=setTimeout(()=>{u(r)},300);return()=>clearTimeout(y)},[r,u]);const p=y=>{s(!1),n(""),d(y)},x=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(an,{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(o6t,{open:t,onOpenChange:s,children:[e.jsx(Cx,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(Mx,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(Tx,{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(x).map(([y,_])=>{const b=c6t[y],N=b.icon;return e.jsx(Ax,{heading:b.label,children:_.map(w=>e.jsxs(lp,{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(Qe,{variant:"secondary",className:"text-xs",children:b.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:gl(new Date(w.date),{addSuffix:!0})})]})]},`${w.type}-${w.id}`))},y)})]})]})]})},d6t=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=S.useState(null),o=_r();if(S.useEffect(()=>{const u=()=>{const x=new Date().getTime(),_=new Date(t).getTime()-x;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($r,{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(ln,{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($r,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},u6t=()=>{const t=_r();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(Pe,{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(Ot,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(hr,{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(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(Pe,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Re,{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(lr,{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($r,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),e.jsx(Pe,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Re,{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(pa,{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(pa,{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(Pn,{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(rr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},h6t=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(Yl,{children:[e.jsx(Xl,{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(Cl,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var Yue="Checkbox",[m6t,ETs]=$c(Yue),[p6t,WNe]=m6t(Yue);function f6t(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:x}=t,[y,_]=$u({prop:r,defaultProp:a??!1,onChange:d,caller:Yue}),[b,N]=S.useState(null),[w,k]=S.useState(null),C=S.useRef(!1),E=b?!!l||!!b.closest("form"):!0,L={checked:y,disabled:o,setChecked:_,control:b,setControl:N,name:i,form:l,value:p,hasConsumerStoppedPropagationRef:C,required:u,defaultChecked:Lb(a)?!1:a,isFormControl:E,bubbleInput:w,setBubbleInput:k};return e.jsx(p6t,{scope:s,...L,children:x6t(x)?x(L):n})}var wYe="CheckboxTrigger",jYe=S.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},a)=>{const{control:o,value:l,disabled:i,checked:d,required:u,setControl:p,setChecked:x,hasConsumerStoppedPropagationRef:y,isFormControl:_,bubbleInput:b}=WNe(wYe,t),N=Aa(a,p),w=S.useRef(d);return S.useEffect(()=>{const k=o==null?void 0:o.form;if(k){const C=()=>x(w.current);return k.addEventListener("reset",C),()=>k.removeEventListener("reset",C)}},[o,x]),e.jsx(Yr.button,{type:"button",role:"checkbox","aria-checked":Lb(d)?"mixed":d,"aria-required":u,"data-state":MYe(d),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:N,onKeyDown:Cr(s,k=>{k.key==="Enter"&&k.preventDefault()}),onClick:Cr(r,k=>{x(C=>Lb(C)?!0:!C),b&&_&&(y.current=k.isPropagationStopped(),y.current||k.stopPropagation())})})});jYe.displayName=wYe;var KNe=S.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d,onCheckedChange:u,form:p,...x}=t;return e.jsx(f6t,{__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(jYe,{...x,ref:s,__scopeCheckbox:r}),y&&e.jsx(CYe,{__scopeCheckbox:r})]})})});KNe.displayName=Yue;var NYe="CheckboxIndicator",kYe=S.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=WNe(NYe,r);return e.jsx(wd,{present:n||Lb(o.checked)||o.checked===!0,children:e.jsx(Yr.span,{"data-state":MYe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});kYe.displayName=NYe;var SYe="CheckboxBubbleInput",CYe=S.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:i,disabled:d,name:u,value:p,form:x,bubbleInput:y,setBubbleInput:_}=WNe(SYe,t),b=Aa(r,_),N=DR(o),w=bR(n);S.useEffect(()=>{const C=y;if(!C)return;const E=window.HTMLInputElement.prototype,I=Object.getOwnPropertyDescriptor(E,"checked").set,O=!a.current;if(N!==o&&I){const V=new Event("click",{bubbles:O});C.indeterminate=Lb(o),I.call(C,Lb(o)?!1:o),C.dispatchEvent(V)}},[y,N,o,a]);const k=S.useRef(Lb(o)?!1:o);return e.jsx(Yr.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??k.current,required:i,disabled:d,name:u,value:p,form:x,...s,tabIndex:-1,ref:b,style:{...s.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});CYe.displayName=SYe;function x6t(t){return typeof t=="function"}function Lb(t){return t==="indeterminate"}function MYe(t){return Lb(t)?"indeterminate":t?"checked":"unchecked"}const Ki=S.forwardRef(({className:t,...s},r)=>e.jsx(KNe,{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(kYe,{className:Rt("flex items-center justify-center text-current"),children:e.jsx(Jn,{className:"h-4 w-4"})})}));Ki.displayName=KNe.displayName;var ZNe="Radio",[g6t,TYe]=$c(ZNe),[y6t,v6t]=g6t(ZNe),AYe=S.forwardRef((t,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:o,disabled:l,value:i="on",onCheck:d,form:u,...p}=t,[x,y]=S.useState(null),_=Aa(s,w=>y(w)),b=S.useRef(!1),N=x?u||!!x.closest("form"):!0;return e.jsxs(y6t,{scope:r,checked:a,disabled:l,children:[e.jsx(Yr.button,{type:"button",role:"radio","aria-checked":a,"data-state":LYe(a),"data-disabled":l?"":void 0,disabled:l,value:i,...p,ref:_,onClick:Cr(t.onClick,w=>{a||d==null||d(),N&&(b.current=w.isPropagationStopped(),b.current||w.stopPropagation())})}),N&&e.jsx(IYe,{control:x,bubbles:!b.current,name:n,value:i,checked:a,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});AYe.displayName=ZNe;var EYe="RadioIndicator",PYe=S.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=v6t(EYe,r);return e.jsx(wd,{present:n||o.checked,children:e.jsx(Yr.span,{"data-state":LYe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});PYe.displayName=EYe;var _6t="RadioBubbleInput",IYe=S.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=S.useRef(null),i=Aa(l,o),d=DR(r),u=bR(s);return S.useEffect(()=>{const p=l.current;if(!p)return;const x=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(x,"checked").set;if(d!==r&&_){const b=new Event("click",{bubbles:n});_.call(p,r),p.dispatchEvent(b)}},[d,r,n]),e.jsx(Yr.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}})});IYe.displayName=_6t;function LYe(t){return t?"checked":"unchecked"}var b6t=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Xue="RadioGroup",[w6t,PTs]=$c(Xue,[hw,TYe]),DYe=hw(),RYe=TYe(),[j6t,N6t]=w6t(Xue),OYe=S.forwardRef((t,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:a,value:o,required:l=!1,disabled:i=!1,orientation:d,dir:u,loop:p=!0,onValueChange:x,...y}=t,_=DYe(r),b=uw(u),[N,w]=$u({prop:o,defaultProp:a??null,onChange:x,caller:Xue});return e.jsx(j6t,{scope:r,name:n,required:l,disabled:i,value:N,onValueChange:w,children:e.jsx(uue,{asChild:!0,..._,orientation:d,dir:b,loop:p,children:e.jsx(Yr.div,{role:"radiogroup","aria-required":l,"aria-orientation":d,"data-disabled":i?"":void 0,dir:b,...y,ref:s})})})});OYe.displayName=Xue;var FYe="RadioGroupItem",zYe=S.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=N6t(FYe,r),l=o.disabled||n,i=DYe(r),d=RYe(r),u=S.useRef(null),p=Aa(s,u),x=o.value===a.value,y=S.useRef(!1);return S.useEffect(()=>{const _=N=>{b6t.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(hue,{asChild:!0,...i,focusable:!l,active:x,children:e.jsx(AYe,{disabled:l,required:o.required,checked:x,...d,...a,name:o.name,ref:p,onCheck:()=>o.onValueChange(a.value),onKeyDown:Cr(_=>{_.key==="Enter"&&_.preventDefault()}),onFocus:Cr(a.onFocus,()=>{var _;y.current&&((_=u.current)==null||_.click())})})})});zYe.displayName=FYe;var k6t="RadioGroupIndicator",BYe=S.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=RYe(r);return e.jsx(PYe,{...a,...n,ref:s})});BYe.displayName=k6t;var $Ye=OYe,qYe=zYe,S6t=BYe;const YNe=S.forwardRef(({className:t,...s},r)=>e.jsx($Ye,{className:Rt("grid gap-2",t),...s,ref:r}));YNe.displayName=$Ye.displayName;const gle=S.forwardRef(({className:t,...s},r)=>e.jsx(qYe,{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(S6t,{className:"flex items-center justify-center",children:e.jsx(sd,{className:"h-2.5 w-2.5 fill-current text-current"})})}));gle.displayName=qYe.displayName;const C6t=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=Fs(),[o,l]=S.useState({}),[i,d]=S.useState({}),[u,p]=S.useState([]);S.useEffect(()=>{s&&a&&t.polls.length>0&&x()},[s,a,t.polls]);const x=async()=>{if(!a)return;const w=t.polls.map(C=>C.id),{data:k}=await G.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",w);if(k){const C={};k.forEach(E=>{C[E.poll_id]||(C[E.poll_id]=[]),C[E.poll_id].push(E.option_id)}),d(C)}},y=(w,k)=>{l(C=>({...C,[w]:k}))},_=(w,k,C)=>{l(E=>{const L=E[w]||[];return C?{...E,[w]:[...L,k]}:{...E,[w]:L.filter(I=>I!==k)}})},b=async w=>{if(!a)return;const k=o[w];if(!k||Array.isArray(k)&&k.length===0){me.error("Please select an option");return}p(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(k)?k:[k],E=C.map(I=>({poll_id:w,option_id:I,user_id:a.id})),{error:L}=await G.from("levelup_brief_poll_responses").insert(E);if(L)throw L;d(I=>({...I,[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(E=>E!==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(Qe,{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(ui,{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 E,L;const k=((E=i[w.id])==null?void 0:E.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}),k&&e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(Qn,{className:"h-3 w-3"}),"Responded"]})]}),w.poll_type==="single"?e.jsx(YNe,{value:o[w.id]||((L=i[w.id])==null?void 0:L[0])||"",onValueChange:I=>y(w.id,I),className:"space-y-2",children:w.options.map(I=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(gle,{value:I.id,id:I.id}),e.jsx(xe,{htmlFor:I.id,className:"cursor-pointer",children:I.option_text})]},I.id))}):e.jsx("div",{className:"space-y-2",children:w.options.map(I=>{const V=(o[w.id]||i[w.id]||[]).includes(I.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ki,{id:I.id,checked:V,onCheckedChange:q=>_(w.id,I.id,q)}),e.jsx(xe,{htmlFor:I.id,className:"cursor-pointer",children:I.option_text})]},I.id)})}),e.jsx(K,{size:"sm",onClick:()=>b(w.id),disabled:C,children:C?"Submitting...":k?"Update Response":"Submit"})]},w.id)})]})}),e.jsxs("div",{className:"p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] border-t bg-muted/30 flex flex-col items-center gap-2 sticky bottom-0 z-10",children:[e.jsx(K,{onClick:r,className:"w-full max-w-xs",children:"Got it!"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},M6t=()=>{const{user:t}=Fs(),[s,r]=S.useState(null),[n,a]=S.useState(!1),[o,l]=S.useState(!0),[i,d]=S.useState(!1),u=S.useCallback(async()=>{if(!t){l(!1);return}try{const{data:b,error: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(),[k,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")]),E=[];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");E.push({...q,options:$||[]})}const L={brief:b,links:k.data||[],polls:E};r(L);const I=!!w,O=(w==null?void 0:w.dismissed_at)!=null,V=localStorage.getItem(`brief-dismissed-${b.id}`)==="true";if(O||V)d(!1),a(!1);else if(!I)a(!0),d(!0);else if(b.show_frequency==="every_login")a(!0),d(!0);else if(b.show_frequency==="daily"){const q=new Date(w.viewed_at);(new Date().getTime()-q.getTime())/(1e3*60*60)>=24&&(a(!0),d(!0))}else d(!1)}catch(b){console.error("Error fetching brief:",b)}finally{l(!1)}},[t]);S.useEffect(()=>{u()},[u]);const p=async()=>{if(!(!t||!s))try{const{data:b}=await G.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();b?await G.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",b.id):await G.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id})}catch(b){console.error("Error marking brief as viewed:",b)}};return{currentBrief:s,shouldShowPopup:n,hasUnseenBrief:i,loading:o,openBrief:()=>{a(!0)},closeBrief:()=>{a(!1),p()},dismissBrief:async()=>{if(!(!t||!s)){a(!1),d(!1);try{const{data:b,error: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 T6t(){const[t,s]=S.useState(!1),[r,n]=S.useState(!1),[a,o]=S.useState(null);S.useEffect(()=>{if(localStorage.getItem("install-banner-dismissed")||window.matchMedia("(display-mode: standalone)").matches||!/iPhone|iPad|iPod|Android/i.test(navigator.userAgent))return;const x=/iPhone|iPad|iPod/i.test(navigator.userAgent);n(x),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(LL,{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 A6t=({children:t,onRefresh:s})=>{const[r,n]=S.useState(!1),[a,o]=S.useState(0),[l,i]=S.useState(!1),d=S.useRef(null),u=S.useRef(0),p=Jt(),x=80,y=120,_=S.useCallback(C=>{const E=d.current;E&&E.scrollTop<=0&&(u.current=C.touches[0].clientY,n(!0))},[]),b=S.useCallback(C=>{if(!r||l)return;const E=d.current;if(!E||E.scrollTop>0){n(!1),o(0);return}const I=C.touches[0].clientY-u.current;if(I>0){const V=Math.min(I*.5,y);o(V),V>10&&C.preventDefault()}},[r,l]),N=S.useCallback(async()=>{if(r)if(n(!1),a>=x&&!l){i(!0),o(x);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/x,1),k=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(${k}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:e.jsx(oo,{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})]})},UYe=()=>{const{user:t}=Fs(),[s,r]=S.useState(!1),[n,a]=S.useState(!1),[o,l]=S.useState(0),[i,d]=S.useState(!0);S.useEffect(()=>{(async()=>{if(!t){d(!1);return}try{const{data:_}=await G.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(_){a(!0),r(!1),d(!1);return}const{data:b}=await G.from("profiles").select("login_count").eq("id",t.id).single(),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=S.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),p=S.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]),x=S.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:x}},E6t="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",P6t=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=UYe(),[o,l]=S.useState(!1),[i,d]=S.useState("review"),[u,p]=S.useState(0),[x,y]=S.useState(0),[_,b]=S.useState(""),[N,w]=S.useState(!1),[k,C]=S.useState(!1);if(s||!t&&!k)return null;const E=async()=>{if(u===0){gn({title:"Please select a rating",variant:"destructive"});return}w(!0);const O=await n(u,_);w(!1),O.success?(C(!0),gn({title:"Thank you for your feedback!",description:"Your review helps us improve."}),d("google")):gn({title:"Error submitting review",description:O.error,variant:"destructive"})},L=async O=>{O&&(await navigator.clipboard.writeText(_||`${u} star rating for LevelUp!`),gn({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(E6t,"_blank")),l(!1),r()},I=()=>{l(!1),r()};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>l(!0),className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-40 flex items-center gap-2 rounded-full bg-primary/90 px-3 py-2 text-xs text-primary-foreground shadow-lg backdrop-blur-sm transition-all hover:bg-primary hover:scale-105 md:bottom-6",children:[e.jsx(Hn,{className:"h-3.5 w-3.5 fill-current"}),e.jsx("span",{className:"hidden sm:inline",children:"Leave a Review"})]}),e.jsx(fs,{open:o,onOpenChange:I,children:e.jsx(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(Ir,{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(Hn,{className:Rt("h-8 w-8 transition-colors",(x||u)>=O?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},O))}),e.jsx(vr,{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:I,className:"flex-1",children:"Maybe Later"}),e.jsx(K,{onClick:E,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(Ir,{className:"text-center",children:"Would you mind sharing your review on Google? It really helps other agents discover LevelUp!"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"We'll copy your review so you can easily paste it."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),className:"flex-1",children:"No Thanks"}),e.jsx(K,{onClick:()=>L(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function I6t(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(!x){l(!1);return}(async()=>{try{const N="vapid_public_key";let w=localStorage.getItem(N);if(!w){const{data:E,error:L}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(L)throw L;if(w=(E==null?void 0:E.vapidPublicKey)??null,!w)throw new Error("Missing VAPID public key");localStorage.setItem(N,w)}p(w);const k=await navigator.serviceWorker.register("/push-sw.js",{scope:"/push-notifications/"});d(k),r(Notification.permission);const C=await k.pushManager.getSubscription();a(!!C)}catch(N){console.error("Error initializing push notifications:",N)}finally{l(!1)}})()},[x]);const y=S.useCallback(async()=>{if(!x||!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(L){console.warn("Failed to unsubscribe existing push subscription:",L)}const{error:E}=await G.from("push_subscriptions").delete().eq("user_id",t.id);E&&console.warn("Failed to cleanup push_subscriptions rows:",E)}if(Notification.permission!=="granted"){const E=await Notification.requestPermission();if(r(E),E!=="granted")return E==="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=I6t(u);let w;try{w=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:N})}catch(E){console.error("PushManager.subscribe() failed:",E);const L=(E==null?void 0:E.message)||String(E);return L.includes("permission")?me.error("Push permission denied. Check your browser notification settings."):L.includes("key")||L.includes("VAPID")?me.error("Push configuration error. Please contact support."):L.includes("AbortError")?me.error("Push subscription was cancelled. Please try again."):me.error(`Failed to subscribe: ${L}`),!1}const k=w.toJSON(),{error:C}=await G.from("push_subscriptions").upsert({user_id:t.id,endpoint:k.endpoint,p256dh_key:k.keys.p256dh,auth_key:k.keys.auth},{onConflict:"user_id,endpoint"});if(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)}},[x,i,t,u]),_=S.useCallback(async()=>{if(!i||!t)return!1;try{l(!0);const b=await i.pushManager.getSubscription();return b&&await b.unsubscribe(),await G.from("push_subscriptions").delete().eq("user_id",t.id),a(!1),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:x,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:u,subscribe:y,unsubscribe:_}}const Bge="push_notification_prompt_dismissed",L6t=["/dashboard","/admin"],D6t=()=>{const{user:t}=Fs(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=VYe(),o=Ol(),[l,i]=S.useState(!1),[d,u]=S.useState(!1),p=L6t.some(_=>o.pathname===_||o.pathname.startsWith(`${_}/`));S.useEffect(()=>{if(p){i(!1);return}if(!t||!s||r||n||localStorage.getItem(`${Bge}_${t.id}`))return;const b=setTimeout(()=>{i(!0)},2e3);return()=>clearTimeout(b)},[t,s,r,n,p]);const x=async()=>{u(!0);const _=await a();u(!1),_&&(t&&localStorage.setItem(`${Bge}_${t.id}`,"true"),i(!1))},y=()=>{t&&localStorage.setItem(`${Bge}_${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(Sm,{className:"h-6 w-6 text-primary"})}),e.jsx(bs,{className:"text-center",children:"Stay in the Loop!"}),e.jsx(Ir,{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:x,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."})]})})},KIe=t=>{let s;const r=new Set,n=(u,p)=>{const x=typeof u=="function"?u(s):u;if(!Object.is(x,s)){const y=s;s=p??(typeof x!="object"||x===null)?x:Object.assign({},s,x),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},R6t=t=>t?KIe(t):KIe,O6t=t=>t;function F6t(t,s=O6t){const r=ft.useSyncExternalStore(t.subscribe,ft.useCallback(()=>s(t.getState()),[t,s]),ft.useCallback(()=>s(t.getInitialState()),[t,s]));return ft.useDebugValue(r),r}const ZIe=t=>{const s=R6t(t),r=n=>F6t(s,n);return Object.assign(r,s),r},z6t=t=>t?ZIe(t):ZIe;function B6t(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 r_e=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return r_e(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return r_e(n)(r)}}}},$6t=(t,s)=>(r,n,a)=>{let o={storage:B6t(()=>window.localStorage),partialize:w=>w,version:0,merge:(w,k)=>({...k,...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 x=()=>{const w=o.partialize({...n()});return p.setItem(o.name,{state:w,version:o.version})},y=a.setState;a.setState=(w,k)=>(y(w,k),x());const _=t((...w)=>(r(...w),x()),n,a);a.getInitialState=()=>_;let b;const N=()=>{var w,k;if(!p)return;const C=++i;l=!1,d.forEach(L=>{var I;return L((I=n())!=null?I:_)});const E=((k=o.onRehydrateStorage)==null?void 0:k.call(o,(w=n())!=null?w:_))||void 0;return r_e(p.getItem.bind(p))(o.name).then(L=>{if(L)if(typeof L.version=="number"&&L.version!==o.version){if(o.migrate){const I=o.migrate(L.state,L.version);return I instanceof Promise?I.then(O=>[!0,O]):[!0,I]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,L.state];return[!1,void 0]}).then(L=>{var I;if(C!==i)return;const[O,V]=L;if(b=o.merge(V,(I=n())!=null?I:_),r(b,!0),O)return x()}).then(()=>{C===i&&(E==null||E(n(),void 0),b=n(),l=!0,u.forEach(L=>L(b)))}).catch(L=>{C===i&&(E==null||E(void 0,L))})};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||_},q6t=$6t,Que=z6t()(q6t((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 ZA(){const{user:t}=Fs(),{data:s,isLoading:r}=gt({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 HYe=S.createContext({onlineUsers:[],totalOnline:0}),U6t=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{}},V6t=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=Fs(),[a,o]=S.useState([]),[l,i]=S.useState(null);S.useEffect(()=>{if(!s)return;const u=G.channel("app-presence",{config:{presence:{key:s.id}}});return u.on("presence",{event:"sync"},()=>{const p=u.presenceState(),x=[];Object.entries(p).forEach(([y,_])=>{if(_&&_.length>0){const b=_[0];x.push({id:y,name:b.name||"Unknown",avatarUrl:b.avatarUrl,brokerageId:b.brokerageId,onlineSince:b.onlineSince})}}),o(x)}).on("presence",{event:"join"},()=>{}).on("presence",{event:"leave"},()=>{}).subscribe(async p=>{var x;if(p==="SUBSCRIBED"){const{data:y}=await G.from("profiles").select("name, brokerage_id").eq("id",s.id).single(),_=await U6t(s.id);await u.track({name:(y==null?void 0:y.name)||((x=s.email)==null?void 0:x.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(HYe.Provider,{value:{onlineUsers:d,totalOnline:a.length},children:t})},GYe=()=>S.useContext(HYe),YIe="dashboard-sidebar-collapsed",Es=({children:t,title:s})=>{var fe;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Fs(),{isAssistant:i,actingAsAgent:d,hasPermission:u}=Cje(),{isImpersonating:p}=cue(),y=(i&&!!d?40:0)+(p?40:0),{avatarUrl:_}=VZe(r==null?void 0:r.id),{isTrial:b,isExpired:N,expiresAt:w}=JEt(r==null?void 0:r.id),{isInnerCircleEnabled:k,isMarketplaceEnabled:C}=GZe(),{currentBrief:E,shouldShowPopup:L,hasUnseenBrief:I,openBrief:O,closeBrief:V,dismissBrief:q}=M6t(),{unreadCount:$}=ePt(),{openCount:U}=tPt(),{data:se}=Px(),Y=!!se,X=Que(Ve=>Ve.cartItems).reduce((Ve,Je)=>Ve+Je.quantity,0),{leadSite:ce,hasLeadSite:ie,siteUrl:ae}=ZA(),oe=_r(),pe=Ol(),[_e,he]=S.useState(null);S.useEffect(()=>{r!=null&&r.id&&G.from("profiles").select("name").eq("id",r.id).single().then(({data:Ve})=>{Ve!=null&&Ve.name&&he(Ve.name)})},[r==null?void 0:r.id]);const we=_e||((fe=r==null?void 0:r.user_metadata)==null?void 0:fe.name)||(r==null?void 0:r.email)||"User",[je,Ue]=S.useState(()=>typeof window<"u"?localStorage.getItem(YIe)==="true":!1);S.useEffect(()=>{localStorage.setItem(YIe,String(je))},[je]);const[Te,Me]=S.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,contacts:!0,website:!0,help:!1}),Fe=Ve=>{Me(Je=>({...Je,[Ve]:!Je[Ve]}))},Le=Ve=>Ve.split(" ").map(Je=>Je[0]).join("").toUpperCase().slice(0,2),Ne=Ve=>pe.pathname===Ve,qe=Ve=>Ve.some(Je=>pe.pathname===Je),ze=({path:Ve,icon:Je,label:at,badgeCount:Ae})=>{const Ye=e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Ne(Ve)&&"bg-sidebar-accent text-sidebar-accent-foreground",je?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>oe(Ve),children:[e.jsxs("div",{className:"relative",children:[e.jsx(Je,{className:"h-4 w-4 shrink-0"}),je&&Ae!=null&&Ae>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!je&&at,!je&&Ae!=null&&Ae>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:Ae>9?"9+":Ae})]});return je?e.jsxs(Yl,{delayDuration:0,children:[e.jsx(Xl,{asChild:!0,children:Ye}),e.jsxs(Cl,{side:"right",className:"flex items-center gap-2",children:[at,Ae!=null&&Ae>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:Ae>9?"9+":Ae})]})]}):Ye},ve=({id:Ve,label:Je,icon:at,children:Ae,activePaths:Ye,showBetaBadge:We,defaultPath:ot,badgeCount:Ge})=>{if(je){const et=ot||Ye[0];return e.jsxs(Yl,{delayDuration:0,children:[e.jsx(Xl,{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",qe(Ye)&&"text-primary"),onClick:()=>oe(et),children:e.jsxs("div",{className:"relative",children:[e.jsx(at,{className:"h-4 w-4"}),Ge!=null&&Ge>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(Cl,{side:"right",className:"flex items-center gap-2",children:[Je,We&&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"}),Ge!=null&&Ge>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:Ge>9?"9+":Ge})]})]})}return e.jsxs(of,{open:Te[Ve],onOpenChange:()=>Fe(Ve),children:[e.jsx(lf,{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",qe(Ye)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(at,{className:"h-4 w-4"}),Je,We&&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:[Ge!=null&&Ge>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:Ge>9?"9+":Ge}),e.jsx(Oi,{className:Rt("h-4 w-4 transition-transform duration-200",Te[Ve]&&"rotate-180")})]})]})}),e.jsx(cf,{className:"pl-4 space-y-1 mt-1",children:Ae})]})},dt=({isMobile:Ve=!1})=>{const Je=Ve?!1:je;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:Rt("p-3 border-b border-sidebar-border",Je?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[Je?e.jsx("img",{src:cPt,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:lPt,alt:"LevelUp",className:"h-8 w-auto"}),!Ve&&e.jsxs(Yl,{delayDuration:0,children:[e.jsx(Xl,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>Ue(!Je),children:e.jsx(xl,{className:Rt("h-4 w-4 transition-transform duration-300",Je&&"rotate-180")})})}),e.jsx(Cl,{side:"right",children:Je?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(ui,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:e.jsxs("nav",{className:Rt("p-3 space-y-1",Je&&"flex flex-col items-center"),children:[e.jsx(ze,{path:"/dashboard",icon:tS,label:"Dashboard"}),e.jsx(ze,{path:"/apps",icon:Yf,label:"Apps & Tools"}),je?e.jsxs(Yl,{delayDuration:0,children:[e.jsx(Xl,{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",Ne("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/levelup-u"),children:[e.jsx(Lh,{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(Cl,{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",Ne("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/levelup-u"),children:[e.jsx(Lh,{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(ze,{path:"/events",icon:xd,label:"Events"}),e.jsxs(ve,{id:"agentos",label:"Agent OS",icon:fM,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(ze,{path:"/mission-control",icon:Za,label:"Mission Control"}),u("contacts")&&!Je&&e.jsxs(of,{open:Te.contacts,onOpenChange:()=>Fe("contacts"),children:[e.jsx(lf,{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",qe(["/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(lr,{className:"h-4 w-4"}),"Contacts"]}),e.jsx(Oi,{className:Rt("h-3.5 w-3.5 transition-transform duration-200",Te.contacts&&"rotate-180")})]})}),e.jsxs(cf,{className:"pl-4 pr-1 space-y-0.5 mt-0.5",children:[e.jsx(ze,{path:"/mission-control/contacts",icon:lr,label:"All Contacts"}),e.jsx(ze,{path:"/mission-control/relationship-scorecard",icon:ih,label:"Relationship Report"}),e.jsx(ze,{path:"/mission-control/sphere-gaps",icon:PL,label:"Sphere Gaps"}),e.jsx(ze,{path:"/mission-control/connect-page",icon:Do,label:"Connect Page"})]})]}),u("contacts")&&Je&&e.jsx(ze,{path:"/mission-control/contacts",icon:lr,label:"Contacts"}),u("contacts")&&e.jsx(ze,{path:"/mission-control/plans",icon:xd,label:"TouchPlans"}),u("pipeline")&&e.jsx(ze,{path:"/mission-control/pipeline",icon:Ky,label:"Deal Pipeline"}),u("pipeline")&&e.jsx(ze,{path:"/mission-control/tasks",icon:Av,label:"Tasks"}),u("popbys")&&e.jsx(ze,{path:"/mission-control/popbys",icon:Ui,label:"Popbys"}),u("videos")&&e.jsx(ze,{path:"/mission-control/video-library",icon:Tn,label:"Video Library"}),u("scorecard")&&e.jsx(ze,{path:"/mission-control/scorecard",icon:to,label:"Scorecard"}),u("listings")&&e.jsx(ze,{path:"/mission-control/listings",icon:pa,label:"Listing Exchange"}),!Je&&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",Ne("/mission-control/smart-drips")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/mission-control/smart-drips"),children:[e.jsx(Oh,{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"})]}),Je&&e.jsx(ze,{path:"/mission-control/smart-drips",icon:Oh,label:"Smart Drips"})]}),ie&&ce&&e.jsxs(ve,{id:"website",label:"My Website",icon:gd,activePaths:[`/admin/lead-sites/${ce.id}/edit`],defaultPath:`/admin/lead-sites/${ce.id}/edit`,children:[Je?e.jsxs(Yl,{delayDuration:0,children:[e.jsx(Xl,{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(wn,{className:"h-4 w-4"})})}),e.jsx(Cl,{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(wn,{className:"h-4 w-4"}),"View Site",e.jsx(Kr,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsx(ze,{path:`/my-website/${ce.id}/edit`,icon:ga,label:"Edit Website"}),e.jsx(ze,{path:"/my-website/mls-listings",icon:Mn,label:"MLS Listings"}),e.jsx(ze,{path:"/my-website/market-report",icon:to,label:"Market Reports"}),e.jsx(ze,{path:"/mission-control/website-activity",icon:ih,label:"Website Activity"}),e.jsx(ze,{path:"/m",icon:t0,label:"Mobile Command"})]}),e.jsxs(ve,{id:"marketing",label:"Marketing",icon:dh,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(ze,{path:"/templates",icon:Dl,label:"Templates"}),e.jsx(ze,{path:"/social-swag-2",icon:t0,label:"Social Swag"}),e.jsx(ze,{path:"/newsletters",icon:Qv,label:"Newsletters"})]}),e.jsxs(ve,{id:"learning",label:"Learning",icon:oh,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(ze,{path:"/academy",icon:Lh,label:"Academy"}),e.jsx(ze,{path:"/toolbox",icon:Ig,label:"Toolbox"})]}),e.jsxs(ve,{id:"community",label:"Community",icon:ki,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:$,children:[e.jsx(ze,{path:"/community",icon:lr,label:"Community",badgeCount:$}),e.jsx(ze,{path:"/wishlist",icon:kb,label:"Wishlist",badgeCount:U}),!Je&&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(ve,{id:"goods",label:"The Goods",icon:op,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[C&&!Je&&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",pe.pathname.startsWith("/marketplace")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/marketplace"),children:[e.jsx(op,{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"})]}),C&&Je&&e.jsx(ze,{path:"/marketplace",icon:op,label:"Marketplace"}),e.jsx(ze,{path:"/reward-store",icon:Vi,label:"Reward Store"})]}),e.jsxs(ve,{id:"help",label:"Help & Services",icon:Sv,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(ze,{path:"/support",icon:SM,label:"Support"}),e.jsx(ze,{path:"/additional-services",icon:$r,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!Je&&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"})}),Je?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx(ze,{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",pe.pathname==="/admin"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/admin"),children:[e.jsx(yd,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!Je&&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"})}),Je?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(ze,{path:"/my-brokerage",icon:pa,label:"My Brokerage"}),e.jsx(ze,{path:"/brokerage-content",icon:oh,label:"Brokerage Content"})]}),Y&&!o&&e.jsx(ze,{path:"/my-team",icon:lr,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx(ze,{path:"/brokerage/dashboard",icon:ko,label:"Manage Brokerages"}),e.jsx(ze,{path:"/brokerage/teams",icon:lr,label:"Teams"}),e.jsx(ze,{path:"/brokerage/recruiting",icon:dh,label:"Recruiting"}),e.jsx(ze,{path:"/brokerage-resources",icon:Ih,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",Ne("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/my-brokerage"),children:[e.jsx(pa,{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",Ne("/brokerage-content")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage-content"),children:[e.jsx(oh,{className:"h-4 w-4"}),"Brokerage Content"]})]}),Y&&!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",Ne("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/my-team"),children:[e.jsx(lr,{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",Ne("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage/dashboard"),children:[e.jsx(ko,{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",Ne("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage/teams"),children:[e.jsx(lr,{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",Ne("/brokerage/recruiting")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/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",Ne("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage-resources"),children:[e.jsx(Ih,{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",Ne("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/profile"),children:[e.jsx(Ti,{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(MM,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(V6t,{children:e.jsx(N1,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[b&&N&&e.jsx(u6t,{}),typeof document<"u"&&ip.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",je?"w-16":"w-56"),style:{top:`${y}px`,height:`calc(100vh - ${y}px)`},children:e.jsx(dt,{})}),document.body),e.jsxs("div",{className:Rt("flex-1 flex flex-col overflow-hidden transition-all duration-300",je?"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(GA,{children:[e.jsx(DNe,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(aS,{className:"h-5 w-5"})})}),e.jsx(wC,{side:"left",className:"w-56 p-0 bg-card",children:e.jsx(dt,{isMobile:!0})})]}),e.jsx("div",{className:"flex-1 md:hidden",children:e.jsx("img",{src:dPt,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(WIe,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[b&&!N&&w&&e.jsx(d6t,{expiresAt:w,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(WIe,{})}),E&&e.jsx(h6t,{hasUnseenBrief:I,onClick:O}),C&&e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",onClick:()=>oe("/marketplace/cart"),children:[e.jsx(op,{className:"h-5 w-5"}),X>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:X>99?"99+":X})]}),e.jsx(RPt,{}),e.jsx(e_e,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",we.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(Ta,{src:_||void 0}),e.jsx(_n,{className:"bg-primary text-primary-foreground font-medium text-sm",children:Le(we)})]})})}),e.jsxs(jd,{align:"end",className:"w-48",children:[e.jsxs(va,{onClick:()=>oe("/profile"),className:"cursor-pointer",children:[e.jsx(Ti,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(va,{onClick:()=>oe("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(kL,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(Zb,{}),e.jsxs(va,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(MM,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(A6t,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),E&&e.jsx(C6t,{brief:E,open:L,onClose:V,onDismiss:q}),e.jsx(T6t,{}),e.jsx(P6t,{}),e.jsx(D6t,{})]})]})})})},H6t=()=>{const{user:t}=Fs(),[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState(""),i=async x=>{var y;if(!(t!=null&&t.email)){me.error("Please sign in to upgrade");return}r(!0),a(x);try{const{data:_,error:b}=await G.functions.invoke("create-checkout",{body:{tier:x,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(Es,{children:e.jsxs("div",{className:"container max-w-6xl py-8 px-4",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold mb-2",children:"Upgrade Your Membership"}),e.jsx("p",{className:"text-muted-foreground text-lg",children:"Choose the plan that's right for you and unlock the full power of LevelUp"})]}),e.jsxs("div",{className:"max-w-md mx-auto mb-8",children:[e.jsx(xe,{htmlFor:"coupon",className:"text-sm font-medium",children:"Have a discount code?"}),e.jsx(De,{id:"coupon",placeholder:"Enter discount code",value:o,onChange:x=>l(x.target.value),className:"mt-1"})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6 mb-8",children:[e.jsxs(Pe,{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(lr,{className:"h-7 w-7 text-primary"})}),e.jsx(Ot,{className:"text-xl",children:"Individual Agent"}),e.jsx(hr,{children:"Perfect for solo agents ready to level up"})]}),e.jsxs(Re,{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((x,y)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(Jn,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:x})]},y))}),e.jsxs(K,{className:"w-full",size:"lg",onClick:()=>i("individual_agent"),disabled:s,children:[s&&n==="individual_agent"?e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx($r,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Pe,{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(pa,{className:"h-7 w-7 text-amber-600"})}),e.jsx(Ot,{className:"text-xl",children:"Brokerage"}),e.jsx(hr,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs(Re,{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((x,y)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(Jn,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsx("span",{children:x})]},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(_s,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(pa,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Pe,{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(pa,{className:"h-7 w-7 text-purple-600"})}),e.jsx(Ot,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(hr,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs(Re,{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((x,y)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(Jn,{className:"h-4 w-4 text-purple-600 mt-0.5 shrink-0"}),e.jsx("span",{children:x})]},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(_s,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(pa,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),e.jsx(Pe,{className:"bg-muted/50",children:e.jsxs(Re,{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(Pn,{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(rr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},G6t=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=Fs(),a=_r(),[o,l]=S.useState(""),[i,d]=S.useState(!1),[u,p]=S.useState(!1);S.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),S.useEffect(()=>{!s&&t&&n&&a("/profile?setup=true")},[t,s,n,a]);const x=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(Pe,{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(_s,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(Ot,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(hr,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(ti,{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(_s,{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(Pe,{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(pa,{className:"w-10 h-10 text-primary"})}),e.jsx(Ot,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(hr,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),e.jsxs(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(De,{id:"brokerage-name",placeholder:"Enter your brokerage name",value:o,onChange:y=>l(y.target.value),onKeyDown:y=>y.key==="Enter"&&x()}),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(lr,{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(ti,{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(ti,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(ti,{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(ti,{className:"w-4 h-4 text-green-500"}),"Share resources with your agents"]})]})]}),e.jsxs(K,{onClick:x,className:"w-full",disabled:i||!o.trim(),children:[i?"Creating...":"Create Brokerage",e.jsx(ei,{className:"w-4 h-4 ml-2"})]})]})]})})},XIe=()=>{const t=_r(),[s,r]=S.useState("verifying"),[n,a]=S.useState("");S.useEffect(()=>{(async()=>{try{const{data:{session:i},error:d}=await G.auth.getSession();if(d)throw d;if(i!=null&&i.user){const{data:u}=await G.from("profiles").select("login_count").eq("id",i.user.id).single();if(((u==null?void 0:u.login_count)||0)>1){console.log("Account already claimed, redirecting to dashboard"),r("already_claimed");return}console.log("User logged in successfully:",i.user.email),r("success");try{await G.functions.invoke("trial-claim-hook",{body:{userId:i.user.id}})}catch(p){console.log("Trial claim hook (non-critical):",p)}setTimeout(()=>{t("/profile?setup=true")},1500)}else setTimeout(()=>{r("already_claimed")},2e3)}catch(i){console.error("Claim error:",i),r("already_claimed")}})()},[t]);const o=()=>{window.location.href="https://dashboard.relevelup.com/auth"};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Pe,{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(Ot,{className:"text-2xl",children:[s==="verifying"&&"Claiming Your Account...",s==="success"&&"Account Claimed!",s==="already_claimed"&&"Account Already Claimed",s==="error"&&"Claim Failed"]}),e.jsxs(hr,{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(Re,{children:e.jsx(K,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},W6t=()=>{const t=_r(),[s]=Nc(),[r,n]=S.useState(s.get("code")||""),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,x]=S.useState(!1),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.useState(!1),[C,E]=S.useState(null),[L,I]=S.useState(null),[O,V]=S.useState(null),[q,$]=S.useState(null);S.useEffect(()=>{const J=s.get("code");J&&(n(J),U(J))},[s]);const U=async J=>{N(!0);const{data:X,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||!X){me.error("Invalid invite code"),N(!1);return}if(!X.is_active){me.error("This invite code is no longer active"),N(!1);return}if(X.max_uses&&X.uses_count>=X.max_uses){me.error("This invite code has reached its maximum uses"),N(!1);return}if(X.expires_at&&new Date(X.expires_at){J.preventDefault(),U(r)},Y=async J=>{var X;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:ie,error:ae}=await G.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:ce,data:{name:d.trim()}}});if(ae){ae.message.includes("already registered")?me.error("This email is already registered. Please sign in instead."):me.error(ae.message);return}ie.user&&(await G.rpc("add_default_signup_tag",{user_id:ie.user.id}),L?await G.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,brokerageId:L}}):q?await G.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,trialDays:q}}):await G.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,grandfathered:!0}}),C&&await G.from("invite_codes").update({uses_count:((X=(await G.from("invite_codes").select("uses_count").eq("id",C).single()).data)==null?void 0:X.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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[e.jsx(Ot,{className:"text-2xl font-bold text-primary",children:O?`Join ${O}`:"Join LevelUp"}),e.jsx(hr,{children:w?O?`Create your account to join ${O}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(Re,{children:w?e.jsxs("form",{onSubmit:Y,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Full Name"}),e.jsx(De,{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(xe,{htmlFor:"email",children:"Email"}),e.jsx(De,{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(xe,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{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:()=>x(!p),children:p?e.jsx(mp,{className:"h-4 w-4"}):e.jsx(wn,{className:"h-4 w-4"})})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:y,children:y?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:se,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"inviteCode",children:"Invite Code"}),e.jsx(De,{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(_s,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},K6t="/assets/testimonial-avatar-1-BsCQFauB.jpg",Z6t="/assets/testimonial-avatar-2-B6VPVc2t.jpg",Y6t="/assets/testimonial-avatar-3-GuEFwYUE.jpg",X6t="/assets/testimonial-avatar-4-98iKMtkB.jpg",Q6t="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",J6t=[K6t,Z6t,Y6t,X6t,Q6t],eIt=bC({name:Wl().trim().min(2,"Name must be at least 2 characters").max(100),email:Wl().trim().email("Please enter a valid email address").max(255),phone:Wl().trim().min(10,"Please enter a valid phone number").max(20).optional().or(ele("")),brokerage:Wl().trim().max(200).optional().or(ele(""))}),tIt=[{icon:sp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Dl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:on,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:vc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:fn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:Ui,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],sIt=[{icon:lr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:$r,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Pn,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:Da,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:to,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:Oh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],rIt=[{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."}],nIt=()=>{const t=_r(),[s,r]=S.useState(!1),[n,a]=S.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=S.useState({}),i=async d=>{var p,x;d.preventDefault(),l({});const u=eIt.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:((x=n.brokerage)==null?void 0:x.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(wc,{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:hle,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($r,{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(Qn,{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(Qn,{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:J6t.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(Hn,{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(Pe,{className:"bg-white shadow-2xl border-0",children:e.jsxs(Re,{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(Qy,{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(xe,{htmlFor:"name",children:"Full Name *"}),e.jsx(De,{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(xe,{htmlFor:"email",children:"Email Address *"}),e.jsx(De,{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(xe,{htmlFor:"phone",children:"Phone Number"}),e.jsx(De,{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(xe,{htmlFor:"brokerage",children:"Brokerage Name"}),e.jsx(De,{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(_s,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(ei,{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:tIt.map((d,u)=>e.jsxs(Pe,{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(Ot,{className:"text-xl font-sans",children:d.title})]}),e.jsx(Re,{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($r,{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:sIt.map((d,u)=>e.jsxs(Pe,{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(Ot,{className:"text-lg font-semibold text-white",children:d.title})]}),e.jsx(Re,{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:rIt.map((d,u)=>e.jsx(Pe,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs(Re,{className:"p-6",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(p=>e.jsx(Hn,{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(Ou,{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(Oh,{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(lr,{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(Pe,{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(Re,{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(ei,{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:$je,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."})]})})})]})]})},aIt=()=>{const t=_r();return e.jsxs(e.Fragment,{children:[e.jsx(wc,{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:hle,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(Pe,{className:"max-w-lg w-full bg-white shadow-2xl border-0",children:e.jsxs(Re,{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(Qn,{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(rr,{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(ei,{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:$je,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},iIt=bC({viewerName:Wl().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:Wl().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:Wl().max(20,"Phone must be less than 20 characters").optional(),message:Wl().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function oIt({shareToken:t,agentName:s,hasContact:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(null),u=Hue({resolver:Gue(iIt),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),p=async x=>{a(!0),d(null);try{const{data:y,error:_}=await G.functions.invoke("video-reply-notify",{body:{shareToken:t,viewerName:x.viewerName,viewerEmail:x.viewerEmail,viewerPhone:x.viewerPhone||void 0,message:x.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(Pe,{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:e.jsxs(Re,{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(Qn,{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(Pe,{children:[e.jsxs(Lt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(vc,{className:"h-5 w-5 text-primary"}),e.jsx(Ot,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(hr,{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(Re,{children:e.jsx(Wue,{...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(Ec,{control:u.control,name:"viewerName",render:({field:x})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Your Name *"}),e.jsx(hc,{children:e.jsx(De,{placeholder:"John Smith",...x})}),e.jsx(vm,{})]})}),e.jsx(Ec,{control:u.control,name:"viewerEmail",render:({field:x})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Email *"}),e.jsx(hc,{children:e.jsx(De,{type:"email",placeholder:"john@example.com",...x})}),e.jsx(vm,{})]})})]}),!r&&e.jsx(Ec,{control:u.control,name:"viewerPhone",render:({field:x})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Phone (optional)"}),e.jsx(hc,{children:e.jsx(De,{type:"tel",placeholder:"(555) 123-4567",...x})}),e.jsx(vm,{})]})}),e.jsx(Ec,{control:u.control,name:"message",render:({field:x})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Message *"}),e.jsx(hc,{children:e.jsx(vr,{placeholder:r?"Thanks for the video! I had a question about...":"I'm interested in learning more about...",className:"min-h-[100px] resize-none",...x})}),e.jsx(vm,{})]})}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),e.jsx(K,{type:"submit",className:"w-full gap-2",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(An,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const lIt=()=>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(Hn,{className:"absolute top-[5%] left-[8%] w-6 h-6 text-blue-600/30 fill-blue-600/20"}),e.jsx(Hn,{className:"absolute top-[15%] left-[20%] w-4 h-4 text-blue-600/25 fill-blue-600/15"}),e.jsx(Hn,{className:"absolute top-[8%] left-[28%] w-5 h-5 text-blue-600/30 fill-blue-600/20"}),e.jsx(Hn,{className:"absolute top-[25%] left-[12%] w-4 h-4 text-blue-600/20 fill-blue-600/10"}),e.jsx(Hn,{className:"absolute top-[20%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse"}),e.jsx(Zv,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),cIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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($r,{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(Hn,{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($r,{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(Hn,{className:"absolute bottom-[25%] left-[10%] w-6 h-6 text-blue-500/25 fill-blue-500/15 animate-pulse"}),e.jsx(Hn,{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(Zv,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),dIt=()=>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(kg,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(kg,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(kg,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(kg,{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"})]}),uIt=()=>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(ec,{className:"absolute top-[8%] left-[12%] w-12 h-12 text-blue-600/15"}),e.jsx(Hn,{className:"absolute top-[15%] left-[22%] w-5 h-5 text-amber-500/25 fill-amber-500/15"}),e.jsx(ec,{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(Hn,{className:"absolute bottom-[25%] left-[15%] w-6 h-6 text-blue-500/20 fill-blue-500/10 animate-pulse"}),e.jsx(Hn,{className:"absolute top-[20%] right-[22%] w-5 h-5 text-indigo-400/20 fill-indigo-400/10 animate-pulse",style:{animationDelay:"0.5s"}})]}),hIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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(kg,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(kg,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(_M,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),mIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-900/12 via-purple-900/8 to-slate-900/12"}),e.jsx(Y4,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx(Y4,{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($r,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx($r,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),pIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-900/8 via-green-900/5 to-emerald-900/8"}),e.jsx(Mb,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(Mb,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(Mb,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx(zv,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx(zv,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(zv,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(zv,{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(Hn,{className:"absolute top-[3%] left-[50%] -translate-x-1/2 w-10 h-10 text-amber-400/35 fill-amber-400/25"})]}),fIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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"})]}),xIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-yellow-900/8 via-amber-900/4 to-purple-900/8"}),e.jsx(Hn,{className:"absolute top-[5%] left-[15%] w-12 h-12 text-yellow-400/35 fill-yellow-400/25 animate-pulse"}),e.jsx(Hn,{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(Hn,{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(Hn,{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($r,{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"})]}),gIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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(Hn,{className:"absolute top-[8%] left-[50%] -translate-x-1/2 w-14 h-14 text-yellow-400/28 fill-yellow-400/18"}),e.jsx($r,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx($r,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),yIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-green-900/12 via-emerald-900/6 to-teal-900/10"}),e.jsx(Fv,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx(Fv,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx(Fv,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx(Fv,{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"})]})]})]}),vIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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(Hn,{className:"absolute top-[5%] left-[42%] w-10 h-10 text-amber-400/30 fill-amber-400/20"}),e.jsx(Hn,{className:"absolute top-[15%] right-[25%] w-7 h-7 text-yellow-400/25 fill-yellow-400/15"}),e.jsx(ec,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(ec,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(Zv,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),_It=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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(Ui,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),bIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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"})]}),wIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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(e1,{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(e1,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx($r,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(e1,{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"})]}),jIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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(pp,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(pp,{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($r,{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"})]}),NIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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(pp,{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($r,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx($r,{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"})]}),kIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/10 via-yellow-900/6 to-orange-900/10"}),e.jsx(pp,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(pp,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(pp,{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($r,{className:"absolute top-[5%] right-[35%] w-8 h-8 text-yellow-400/35"}),e.jsx(Hn,{className:"absolute top-[18%] left-[28%] w-6 h-6 text-amber-400/25 fill-amber-400/15"})]}),SIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-teal-900/10 via-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(pp,{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($r,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(Wv,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),QIe=()=>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"})]}),CIt=()=>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"})]}),MIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Wv,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx($r,{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"})]}),TIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(W4,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(TM,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(W4,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),tI=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx($r,{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($r,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),JIe=()=>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($r,{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"})]}),n_e=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx($r,{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(CIt,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(nL,{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(tI,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(W4,{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(TIt,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(to,{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(lr,{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(tI,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(ec,{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(QIe,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(Da,{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(JIe,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(TM,{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(tI,{})},{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(_It,{})},{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(bIt,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(e1,{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(wIt,{})},{id:"new_years",name:"New Year's Day",description:"Ring in the new year",icon:e.jsx(Hn,{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(xIt,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(_M,{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(hIt,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(kg,{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(dIt,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(ec,{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(uIt,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(Zv,{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(lIt,{})},{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(cIt,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(ec,{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(vIt,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx(Y4,{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(mIt,{})},{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(fIt,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(Mb,{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(pIt,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx($r,{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(gIt,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx(Fv,{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(yIt,{})},{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(jIt,{})},{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(NIt,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(on,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Exciting News, ${t}!`:"Just Listed!",subText:"A new property is now on the market",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-violet-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-violet-950/20",accentColor:"blue",decorativeElement:e.jsx(JIe,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(yc,{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(tI,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(gS,{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(Wv,{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(MIt,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(pp,{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(kIt,{})},{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(SIt,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(Fu,{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(tI,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(ec,{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(QIe,{})}],AIt=[{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 EIt(t){return n_e.filter(s=>s.category===t)}function UM(t){return n_e.find(s=>s.id===t)||n_e[0]}function eLe(){const{shareToken:t,recipientToken:s}=co(),[r,n]=S.useState(null),[a,o]=S.useState(null),[l,i]=S.useState(null),[d,u]=S.useState(!0),[p,x]=S.useState(null),[y,_]=S.useState(!0),b=S.useRef(null),N=S.useRef(0),w=S.useRef(0),k=(()=>{const Y=new URLSearchParams(window.location.search);return s||Y.get("rt")||null})(),C=S.useCallback((Y,J=!1)=>{if(!k||Y<=0)return;const X=Math.max(1,Math.round(Y));if(X<=w.current)return;const ie=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(k)}&e=watch&ws=${X}`;J&&navigator.sendBeacon?navigator.sendBeacon(ie):fetch(ie,{method:"GET",keepalive:J}).catch(()=>{}),w.current=Math.max(w.current,X)},[k]);S.useEffect(()=>{var oe;if(!y||!(r!=null&&r.playback_url)||!k)return;let Y=!1;const J=()=>{N.current>0&&C(N.current,!0)},X=()=>{document.visibilityState==="hidden"&&J()},ce=()=>{J()},ie=()=>{var _e;if(Y||!b.current||!((_e=window.playerjs)!=null&&_e.Player))return;const pe=new window.playerjs.Player(b.current);pe.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))}),pe.on("pause",()=>{N.current>0&&C(N.current)}),pe.on("ended",()=>{N.current>0&&C(N.current,!0)})},ae=document.querySelector('script[data-bunny-playerjs="true"]');if((oe=window.playerjs)!=null&&oe.Player)ie();else if(ae)ae.addEventListener("load",ie,{once:!0});else{const pe=document.createElement("script");pe.src="https://assets.mediadelivery.net/playerjs/playerjs-latest.min.js",pe.async=!0,pe.defer=!0,pe.dataset.bunnyPlayerjs="true",pe.onload=ie,document.body.appendChild(pe)}return document.addEventListener("visibilitychange",X),window.addEventListener("beforeunload",ce),()=>{Y=!0,document.removeEventListener("visibilitychange",X),window.removeEventListener("beforeunload",ce),J()}},[y,r==null?void 0:r.playback_url,k,C]),S.useEffect(()=>{N.current=0,w.current=0},[k,t]),S.useEffect(()=>{const Y=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="msgsndr"]',"[data-chat-widget]"].forEach(ie=>{document.querySelectorAll(ie).forEach(ae=>{ae.style.display="none"})})};Y();const J=[setTimeout(Y,500),setTimeout(Y,1500),setTimeout(Y,3e3)],X=new MutationObserver(Y);return X.observe(document.body,{childList:!0,subtree:!0}),()=>{J.forEach(clearTimeout),X.disconnect()}},[]),S.useEffect(()=>{(async()=>{if(!t){x("Invalid share link"),u(!1);return}const{data:J,error:X}=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(X||!J){x("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:ie}=await G.storage.from("avatars").list(`${J.owner_user_id}`);if(ie&&ie.length>0){const{data:ae}=G.storage.from("avatars").getPublicUrl(`${J.owner_user_id}/${ie[0].name}`);i(ae.publicUrl)}}catch{}}}u(!1)})()},[t]);const E=Y=>{if(!Y)return"0:00";const J=Math.floor(Y/60),X=Y%60;return`${J}:${X.toString().padStart(2,"0")}`},L=Y=>Y.includes("iframe.mediadelivery.net/play/")?Y.replace("/play/","/embed/")+"?autoplay=true&responsive=true":Y,I=Y=>{if(!Y)return"?";const J=Y.split(" ");return J.length>=2?`${J[0][0]}${J[1][0]}`.toUpperCase():Y.substring(0,2).toUpperCase()},O=UM((r==null?void 0:r.page_template)||"default"),V=(r==null?void 0:r.recipient_name)||null,q=O.headerText(V),U=`https://dashboard.relevelup.com/share/video/${t}`;if(d)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(_s,{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(Pe,{className:"max-w-md w-full",children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(Tn,{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 se=O.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs(wc,{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:U}),r.preview_url&&e.jsx("meta",{property:"og:image",content:r.preview_url}),!r.preview_url&&r.thumbnail_url&&e.jsx("meta",{property:"og:image",content:r.thumbnail_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{property:"og:video",content:r.playback_url}),e.jsx("meta",{property:"og:video:type",content:"text/html"}),e.jsx("meta",{property:"og:video:width",content:"1280"}),e.jsx("meta",{property:"og:video:height",content:"720"})]}),e.jsx("meta",{name:"twitter:card",content:"player"}),e.jsx("meta",{name:"twitter:title",content:q}),e.jsx("meta",{name:"twitter:description",content: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:[se&&O.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[se&&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(Ta,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(_n,{className:"bg-primary/10 text-primary font-semibold",children:I(a.name)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:se?"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(Pn,{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(rr,{className:"h-4 w-4"})})})]})]}),e.jsx(Pe,{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:L(r.playback_url),title:r.title||"Video message",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})}):e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>_(!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:Y=>{var X;Y.currentTarget.style.display="none";const J=(X=Y.currentTarget.parentElement)==null?void 0:X.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(Tn,{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(So,{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:E(r.duration_seconds)})]})}),!se&&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(So,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(oIt,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function PIt(){return S.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(m1t,{})}function IIt(){const{token:t}=co();return S.useEffect(()=>{if(!t)return;const s=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/video-og-image?token=${t}`;window.location.replace(s)},[t]),e.jsx("main",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(_s,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}var Jue="Tabs",[LIt,ITs]=$c(Jue,[hw]),WYe=hw(),[DIt,XNe]=LIt(Jue),KYe=S.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:d="automatic",...u}=t,p=uw(i),[x,y]=$u({prop:n,onChange:a,defaultProp:o??"",caller:Jue});return e.jsx(DIt,{scope:r,baseId:pu(),value:x,onValueChange:y,orientation:l,dir:p,activationMode:d,children:e.jsx(Yr.div,{dir:p,"data-orientation":l,...u,ref:s})})});KYe.displayName=Jue;var ZYe="TabsList",YYe=S.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=XNe(ZYe,r),l=WYe(r);return e.jsx(uue,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:n,children:e.jsx(Yr.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});YYe.displayName=ZYe;var XYe="TabsTrigger",QYe=S.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=XNe(XYe,r),i=WYe(r),d=tXe(l.baseId,n),u=sXe(l.baseId,n),p=n===l.value;return e.jsx(hue,{asChild:!0,...i,focusable:!a,active:p,children:e.jsx(Yr.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...o,ref:s,onMouseDown:Cr(t.onMouseDown,x=>{!a&&x.button===0&&x.ctrlKey===!1?l.onValueChange(n):x.preventDefault()}),onKeyDown:Cr(t.onKeyDown,x=>{[" ","Enter"].includes(x.key)&&l.onValueChange(n)}),onFocus:Cr(t.onFocus,()=>{const x=l.activationMode!=="manual";!p&&!a&&x&&l.onValueChange(n)})})})});QYe.displayName=XYe;var JYe="TabsContent",eXe=S.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=XNe(JYe,r),d=tXe(i.baseId,n),u=sXe(i.baseId,n),p=n===i.value,x=S.useRef(p);return S.useEffect(()=>{const y=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(y)},[]),e.jsx(wd,{present:a||p,children:({present:y})=>e.jsx(Yr.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:x.current?"0s":void 0},children:y&&o})})});eXe.displayName=JYe;function tXe(t,s){return`${t}-trigger-${s}`}function sXe(t,s){return`${t}-content-${s}`}var RIt=KYe,rXe=YYe,nXe=QYe,aXe=eXe;const ia=RIt,ea=S.forwardRef(({className:t,...s},r)=>e.jsx(rXe,{ref:r,className:Rt("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));ea.displayName=rXe.displayName;const ls=S.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=S.forwardRef(({className:t,...s},r)=>e.jsx(aXe,{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=aXe.displayName;const OIt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},FIt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},m5={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function zIt(){var Ue,Te,Me,Fe;const{slugOrId:t}=co(),[s]=Nc(),{data:r,isLoading:n}=oWe(t||""),a=lWe(),o=KNt(),l=s.get("ref"),[i,d]=S.useState(""),[u,p]=S.useState(""),[x,y]=S.useState(""),[_,b]=S.useState(""),[N,w]=S.useState(""),[k,C]=S.useState(""),[E,L]=S.useState(""),[I,O]=S.useState("in_person"),[V,q]=S.useState("info"),[$,U]=S.useState(!1),[se,Y]=S.useState(!1),[J,X]=S.useState(null),[ce,ie]=S.useState(!1);S.useEffect(()=>{l&&o.mutate(l)},[l]);const ae=Le=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Le),oe=async Le=>{if(Le.preventDefault(),!i.trim()||!x.trim()||!r)return;const Ne=V==="showing";if(Ne&&!k){me.error("Please pick a preferred date for your showing");return}U(!0);try{await a.mutateAsync({listingId:r.id,agentId:r.agent_id,firstName:i.trim(),lastName:u.trim(),email:x.trim(),phone:_.trim(),shareToken:l,leadType:Ne?"showing_request":"info_request",preferredDate:Ne?k:null,preferredTime:Ne&&E||null,showingMode:Ne?I:null,message:N.trim()||null}),Y(!0),me.success(Ne?"Showing request sent! The agent will confirm details shortly.":"Thanks! The agent will be in touch soon.")}catch(qe){console.error("Lead submission error:",qe),me.error(`Failed to submit: ${qe.message||"Please try again"}`)}finally{U(!1)}},pe=(r==null?void 0:r.photos)||[],_e=pe.find(Le=>Le.is_primary)||pe[0],he=()=>{J!==null&&X(J===0?pe.length-1:J-1)},we=()=>{J!==null&&X(J===pe.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(Ns,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(Ns,{className:"h-10 w-48 mb-6"}),e.jsx(Ns,{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(Ns,{className:"h-12 w-48"}),e.jsx(Ns,{className:"h-6 w-full"}),e.jsx(Ns,{className:"h-6 w-3/4"})]}),e.jsx(Ns,{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(ha,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Woe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(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(ha,{to:"/public/listings",children:"Browse All Listings"})})]})]});const je=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(wc,{children:[e.jsxs("title",{children:[je," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${ae(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${r.square_footage?r.square_footage.toLocaleString()+" sqft":""} ${m5[r.property_type]} in ${r.city}, ${r.state}. ${((Ue=r.description)==null?void 0:Ue.slice(0,150))||""}`}),e.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${r.slug||r.id}`}),e.jsx("meta",{property:"og:title",content:je}),e.jsx("meta",{property:"og:description",content:`${ae(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${m5[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}`}),_e&&e.jsx("meta",{property:"og:image",content:_e.photo_url}),_e&&e.jsx("meta",{property:"og:image:alt",content:`${r.property_address||r.city} - ${m5[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:je}),e.jsx("meta",{name:"twitter:description",content:`${ae(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA in ${r.city}, ${r.state}`}),_e&&e.jsx("meta",{name:"twitter:image",content:_e.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||`${m5[r.property_type]} for sale in ${r.city}, ${r.state}`,url:`https://listings.relevelup.com/${r.slug||r.id}`,datePosted:r.created_at,image:pe.map(Le=>Le.photo_url),address:{"@type":"PostalAddress",streetAddress:r.property_address||void 0,addressLocality:r.city,addressRegion:r.state,addressCountry:"US"},geo:r.neighborhood?{"@type":"GeoCoordinates",name:r.neighborhood}:void 0,offers:{"@type":"Offer",price:r.price,priceCurrency:"USD",availability:r.status==="sold"?"https://schema.org/SoldOut":r.status==="under_contract"?"https://schema.org/LimitedAvailability":"https://schema.org/InStock"},numberOfRooms:r.bedrooms||void 0,numberOfBathroomsTotal:r.bathrooms||void 0,floorSize:r.square_footage?{"@type":"QuantitativeValue",value:r.square_footage,unitCode:"FTK"}:void 0,yearBuilt:r.year_built||void 0,broker:r.agent?{"@type":"RealEstateAgent",name:r.agent.name,email:r.agent.email,worksFor:(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(ha,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Woe,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs(ha,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(Fa,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),pe.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:()=>X(0),children:e.jsx("img",{src:_e==null?void 0:_e.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${m5[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:pe.slice(1,5).map((Le,Ne)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>X(Ne+1),children:[e.jsx("img",{src:Le.photo_url,alt:`${r.property_address||r.city} - Photo ${Ne+2} of ${pe.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),Ne===3&&pe.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",pe.length-5," more"]})]},Le.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(Qe,{className:`${OIt[r.status]} text-white border-0`,children:FIt[r.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:ae(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(Da,{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(Wy,{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(rf,{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(s0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),r.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(on,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Qe,{variant:"secondary",children:[e.jsx(pa,{className:"h-3 w-3 mr-1"}),m5[r.property_type]]}),r.lot_size&&e.jsxs(Qe,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(Qe,{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(Pe,{className:"overflow-hidden bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:e.jsxs(Re,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>ie(!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(Tn,{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(So,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs(K,{onClick:()=>ie(!0),className:"w-full gap-2",size:"lg",children:[e.jsx(So,{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(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ti,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Re,{children:[e.jsx("p",{className:"font-semibold text-lg",children:r.agent.name}),((Me=r.agent.brokerage)==null?void 0:Me.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.agent.brokerage.name})]})]}),e.jsxs(Pe,{className:"border-primary",children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(Ot,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Re,{children:se?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(rr,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:V==="showing"?"Showing request sent!":"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:V==="showing"?"The listing agent will reach out to confirm your showing time.":"The listing agent will contact you soon."})]}):e.jsxs(ia,{value:V,onValueChange:Le=>q(Le),children:[e.jsxs(ea,{className:"grid w-full grid-cols-2 mb-4",children:[e.jsxs(ls,{value:"info",className:"gap-1.5",children:[e.jsx(rr,{className:"h-3.5 w-3.5"}),"Get Info"]}),e.jsxs(ls,{value:"showing",className:"gap-1.5",children:[e.jsx(gM,{className:"h-3.5 w-3.5"}),"Request Tour"]})]}),e.jsxs("form",{onSubmit:oe,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(xe,{htmlFor:"preferredDate",children:"Preferred Date *"}),e.jsx(De,{id:"preferredDate",type:"date",value:k,onChange:Le=>C(Le.target.value),min:new Date().toISOString().split("T")[0],required:V==="showing"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"preferredTime",children:"Preferred Time"}),e.jsxs(Bs,{value:E,onValueChange:L,children:[e.jsx(Rs,{id:"preferredTime",children:e.jsx(qs,{placeholder:"Any time"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"morning",children:"Morning (9am–12pm)"}),e.jsx(vt,{value:"afternoon",children:"Afternoon (12pm–5pm)"}),e.jsx(vt,{value:"evening",children:"Evening (5pm–8pm)"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"showingMode",children:"Tour Type"}),e.jsxs(Bs,{value:I,onValueChange:Le=>O(Le),children:[e.jsx(Rs,{id:"showingMode",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"in_person",children:"🏡 In-person showing"}),e.jsx(vt,{value:"video",children:"📱 Video tour (FaceTime/Zoom)"}),e.jsx(vt,{value:"either",children:"Either works for me"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"firstName",children:"First Name *"}),e.jsx(De,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:Le=>d(Le.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lastName",children:"Last Name"}),e.jsx(De,{id:"lastName",type:"text",placeholder:"Doe",value:u,onChange:Le=>p(Le.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"email",children:"Email *"}),e.jsx(De,{id:"email",type:"email",placeholder:"you@example.com",value:x,onChange:Le=>y(Le.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsxs(xe,{htmlFor:"phone",children:["Phone ",V==="showing"&&"*"]}),e.jsx(De,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:_,onChange:Le=>b(Le.target.value),required:V==="showing"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"message",children:V==="showing"?"Anything else?":"Message (optional)"}),e.jsx(vr,{id:"message",placeholder:V==="showing"?"e.g. I have flexibility on weekends":"Any specific questions about the property?",value:N,onChange:Le=>w(Le.target.value),rows:2})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:$,children:$?"Submitting...":V==="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:()=>X(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:()=>X(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&&pe[J]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:pe[J].photo_url,alt:`Photo ${J+1}`,className:"w-full max-h-[80vh] object-contain"}),pe.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(xl,{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(Sa,{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," / ",pe.length]})]})]})]})}),e.jsx(fs,{open:ce,onOpenChange:ie,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:()=>ie(!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"})}),((Fe=r==null?void 0:r.video)==null?void 0:Fe.playback_url)&&e.jsx("div",{className:"aspect-video w-full",children:e.jsx("iframe",{src:r.video.playback_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function BIt(){var o;const{slug:t}=co(),{data:s,isLoading:r,error:n}=hWe(t);if(S.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),S.useEffect(()=>{s!=null&&s.id&&qi(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(Ns,{className:"h-28 w-28 rounded-full"}),e.jsx(Ns,{className:"h-6 w-48"}),e.jsx(Ns,{className:"h-4 w-36"})]}),e.jsx(Ns,{className:"h-12 w-full"}),e.jsx(Ns,{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(wc,{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(Uje,{card:s})]})}function iXe({slugOverride:t}={}){var Ae;const{slug:s}=co(),r=t||s,[n]=Nc(),a=n.get("t"),[o,l]=S.useState(!0),[i,d]=S.useState(null),[u,p]=S.useState(null),x=S.useRef(null),y=S.useRef(null),[_,b]=S.useState(null),[N,w]=S.useState(null),[k,C]=S.useState(!1),[E,L]=S.useState(!1),[I,O]=S.useState(0),[V,q]=S.useState(!1),[$,U]=S.useState(""),[se,Y]=S.useState(""),[J,X]=S.useState(""),[ce,ie]=S.useState(""),[ae,oe]=S.useState(""),[pe,_e]=S.useState(""),[he,we]=S.useState(""),[je,Ue]=S.useState(""),[Te,Me]=S.useState(""),[Fe,Le]=S.useState(""),[Ne,qe]=S.useState(""),[ze,ve]=S.useState("");S.useEffect(()=>{dt()},[r,a]);const dt=async()=>{if(!r)return;l(!0);const{data:Ye,error:We}=await G.from("contact_intake_pages").select("*").eq("slug",r).eq("is_active",!0).maybeSingle();if(We||!Ye){q(!0),l(!1);return}p(Ye),y.current=Ye;const{data:ot}=await G.from("profiles").select("name, avatar_url, title, phone, email, brokerage_id").eq("id",Ye.user_id).single();if(ot){let Ge;if(ot.brokerage_id){const{data:xt}=await G.from("brokerages").select("name").eq("id",ot.brokerage_id).single();Ge=(xt==null?void 0:xt.name)||void 0}let et=ot.avatar_url||null;if(!et){const{data:xt}=G.storage.from("avatars").getPublicUrl(`${Ye.user_id}/avatar.jpg`);xt!=null&&xt.publicUrl&&(et=`${xt.publicUrl}?t=${Date.now()}`)}const ht={...ot,avatar_url:et,brokerage_name:Ge};d(ht),x.current=ht}if(a)try{console.log("[ConnectPage] Resolving token:",a,"for page:",Ye.id);const{data:Ge,error:et}=await G.functions.invoke("process-intake-submissions",{body:{action:"resolve_token",token:a,page_id:Ye.id}});if(console.log("[ConnectPage] Resolve result:",{resolved:Ge,resolveErr:et}),!et&&(Ge!=null&&Ge.contact_id)){w(Ge.contact_id);const ht=Ge.contact;ht&&(b(ht),U(ht.first_name||""),Y(ht.last_name||""),X(ht.email||""),ie(ht.phone||""),oe(ht.address||""),_e(ht.city||""),we(ht.state||""),Ue(ht.zip||""),Me(ht.birthday||""),Le(ht.home_anniversary||""))}}catch(Ge){console.error("Failed to resolve token:",Ge)}l(!1)},fe=async()=>{var Ye,We;if(!$.trim()){me.error("Please enter your first name");return}if(!r){me.error("Invalid page. Please refresh.");return}L(!0);try{let ot=(Ye=y.current)==null?void 0:Ye.id,Ge=(We=y.current)==null?void 0:We.user_id;if(!ot||!Ge){const{data:ht}=await G.from("contact_intake_pages").select("id, user_id").eq("slug",r).eq("is_active",!0).maybeSingle();if(!ht){me.error("This page is no longer active. Please contact the agent directly."),L(!1);return}ot=ht.id,Ge=ht.user_id}const{error:et}=await G.from("contact_intake_submissions").insert({intake_page_id:ot,agent_user_id:Ge,existing_contact_id:N,first_name:$.trim(),last_name:se.trim()||null,email:J.trim()||null,phone:ce.trim()||null,address:ae.trim()||null,city:pe.trim()||null,state:he.trim()||null,zip:je.trim()||null,birthday:Te||null,home_anniversary:Fe||null,real_estate_interest:Ne||null,message:ze.trim()||null});if(console.log("[ConnectPage] Insert result:",{error:et}),et)throw et;a&&await G.from("contact_intake_tokens").update({used_at:new Date().toISOString()}).eq("token",a);try{const ht=[$.trim(),se.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:Ge,contactName:ht,contactEmail:J.trim()||null,contactPhone:ce.trim()||null,slug:r})})}catch(ht){console.warn("Connect page notification failed (non-blocking):",ht)}C(!0)}catch(ot){console.error(ot),me.error("Something went wrong. Please try again.")}finally{L(!1)}};if(o)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsx(_s,{className:"h-8 w-8 animate-spin text-slate-400"})});if(V)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("h1",{className:"text-2xl font-semibold text-slate-700",children:"Page Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This connect page doesn't exist or is no longer active."})]})});if(k)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50 p-4",children:[e.jsx(wc,{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(Qn,{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 Ve=!!a&&!!_,Je=3,at=[{title:Ve?"Confirm Your Info":"Let's Get Connected",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"First Name *"}),e.jsx("input",{type:"text",value:$,onChange:Ye=>U(Ye.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:se,onChange:Ye=>Y(Ye.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:Ye=>X(Ye.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:Ye=>ie(Ye.target.value),placeholder:"(555) 123-4567",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]})},{title:"A Little More About You",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Street Address"}),e.jsx("input",{type:"text",value:ae,onChange:Ye=>oe(Ye.target.value),placeholder:"123 Main St",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"City"}),e.jsx("input",{type:"text",value:pe,onChange:Ye=>_e(Ye.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:Ye=>we(Ye.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:je,onChange:Ye=>Ue(Ye.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:Ye=>Me(Ye.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:Fe,onChange:Ye=>Le(Ye.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(Ye=>e.jsxs("button",{type:"button",onClick:()=>qe(Ne===Ye.value?"":Ye.value),className:`p-3.5 rounded-xl border-2 text-left transition-all ${Ne===Ye.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:Ye.label}),e.jsx("span",{className:"block text-xs text-slate-500 mt-0.5",children:Ye.desc})]},Ye.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:ze,onChange:Ye=>ve(Ye.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(wc,{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:((Ae=i==null?void 0:i.name)==null?void 0:Ae.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(Pn,{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(rr,{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:Je}).map((Ye,We)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-500 ${We<=I?"bg-blue-500":"bg-slate-200"}`},We))}),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(ENe,{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($r,{className:"h-5 w-5 text-blue-500"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-800",children:at[I].title})]}),at[I].fields]},I)}),e.jsxs("div",{className:"flex justify-between mt-8",children:[I>0?e.jsx("button",{type:"button",onClick:()=>O(Ye=>Ye-1),className:"px-5 py-2.5 text-sm font-medium text-slate-600 hover:text-slate-800 transition-colors",children:"Back"}):e.jsx("div",{}),I{if(I===0&&!$.trim()){me.error("Please enter your first name");return}O(Ye=>Ye+1)},className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm",children:"Continue"}):e.jsx("button",{type:"button",onClick:()=>fe(),disabled:E,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:E?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):"Submit"})]}),I>0&&IO(Ye=>Ye+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 YA=()=>({trackEngagement:S.useCallback(async(s,r,n,a="view")=>{try{const{data:{user:o}}=await G.auth.getUser();if(!o)return;await G.from("content_engagement_logs").insert({user_id:o.id,resource_type:s,resource_id:r,resource_title:n,action_type:a})}catch(o){console.error("Error tracking engagement:",o)}},[])});function sI({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=S.useState(0),[o,l]=S.useState(!1),{trackEngagement:i}=YA(),d=S.useCallback(_=>{i("newsletter",_.id,_.title,"click_link")},[i]),u=S.useCallback(()=>{a(_=>(_+1)%t.length)},[t.length]),p=S.useCallback(()=>{a(_=>(_-1+t.length)%t.length)},[t.length]),x=S.useCallback(_=>{a(_)},[]);if(S.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(xl,{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(Sa,{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:()=>x(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 $It(t){return"EST"}function oD(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=$It();return`${r} ${n}`}function VM(t){const s=new Date,r=new Date(t),n=Z5(r,-15),a=Z5(r,30);return s>a?"ended":gg(s,{start:r,end:a})?"live":gg(s,{start:n,end:r})?"starting_soon":"upcoming"}function QNe(t){const s=VM(t);return s==="starting_soon"||s==="live"}const tLe=QNe,qIt=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=S.useState(new Date);S.useEffect(()=>{const _=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(_)},[]);const o=t.filter(_=>QNe(_.event_date));if(o.length===0)return null;const l=o[0],i=VM(l.event_date),d=s.find(_=>_.event_id===l.id),u=(d==null?void 0:d.zoom_join_url)||l.zoom_link,p=!!d,x=i==="live",y=x?{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:x?e.jsxs(e.Fragment,{children:[e.jsx(Jv,{className:"h-4 w-4"}),"Live Now"]}):e.jsxs(e.Fragment,{children:[e.jsx(ln,{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:x?`Started at ${oD(new Date(l.event_date))}`:`Starts at ${oD(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"}),x?"Join Now":"Join When Live"]}):e.jsxs(K,{variant:"outline",onClick:r,className:`${y.outlineButton} gap-2`,children:[e.jsx(lr,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var JNe="Progress",eke=100,[UIt,LTs]=$c(JNe),[VIt,HIt]=UIt(JNe),oXe=S.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=GIt,...l}=t;(a||a===0)&&!sLe(a)&&console.error(WIt(`${a}`,"Progress"));const i=sLe(a)?a:eke;n!==null&&!rLe(n,i)&&console.error(KIt(`${n}`,"Progress"));const d=rLe(n,i)?n:null,u=yle(d)?o(d,i):void 0;return e.jsx(VIt,{scope:r,value:d,max:i,children:e.jsx(Yr.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":yle(d)?d:void 0,"aria-valuetext":u,role:"progressbar","data-state":dXe(d,i),"data-value":d??void 0,"data-max":i,...l,ref:s})})});oXe.displayName=JNe;var lXe="ProgressIndicator",cXe=S.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=HIt(lXe,r);return e.jsx(Yr.div,{"data-state":dXe(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});cXe.displayName=lXe;function GIt(t,s){return`${Math.round(t/s*100)}%`}function dXe(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function yle(t){return typeof t=="number"}function sLe(t){return yle(t)&&!isNaN(t)&&t>0}function rLe(t,s){return yle(t)&&!isNaN(t)&&t<=s&&t>=0}function WIt(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${eke}\`.`}function KIt(t,s){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${s}\`. The \`value\` prop must be: - a positive number - less than the value passed to \`max\` (or ${eke} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var uXe=oXe,ZIt=cXe;const gi=S.forwardRef(({className:t,value:s,...r},n)=>e.jsx(uXe,{ref:n,className:Rt("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(ZIt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));gi.displayName=uXe.displayName;function YIt(){const{user:t,isBrokerageManager:s}=Fs(),[r,n]=S.useState([]),[a,o]=S.useState([]),[l,i]=S.useState(!1),[d,u]=S.useState(!0),p=s?"brokerage_manager":"agent";S.useEffect(()=>{if(!(t!=null&&t.id)){u(!1);return}x()},[t==null?void 0:t.id,p]);const x=async()=>{if(t!=null&&t.id)try{const{data:L,error:I}=await G.from("onboarding_checklist_items").select("*").eq("target_role",p).eq("is_active",!0).order("sort_order");if(I)throw I;const{data:O,error:V}=await G.from("onboarding_checklist_progress").select("item_id, completed_at").eq("user_id",t.id);if(V)throw V;const{data:q,error:$}=await G.from("onboarding_checklist_dismissed").select("id").eq("user_id",t.id).maybeSingle();if($)throw $;n(L||[]),o(O||[]),i(!!q),L&&L.length>0&&await y(L,O||[])}catch(L){console.error("Error fetching checklist data:",L)}finally{u(!1)}},y=async(L,I)=>{var Le,Ne;if(!(t!=null&&t.id))return;const O=I.map(qe=>qe.item_id),V=L.filter(qe=>!O.includes(qe.id));if(V.length===0)return;const[q,$,U,se,Y,J,X,ce,ie,ae,oe,pe,_e,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)]),je={},Ue=(Le=q.data)==null?void 0:Le.brokerage_id;je.share_resource=($.count||0)>0,je.post_community=(U.count||0)>0,je.register_event=(se.count||0)>0,je.view_template=(Y.count||0)>0,je.watch_academy=(J.count||0)>0,je.use_toolbox=(X.count||0)>0,je.launch_app=(ce.count||0)>0,je.add_contact=(ie.count||0)>0,je.create_video=(ae.count||0)>0,je.complete_touch=(oe.count||0)>0,je.add_transaction=(pe.count||0)>0,je.add_listing=(_e.count||0)>0,je.add_deal=(we.count||0)>0;const Te=((Ne=he.data)==null?void 0:Ne.map(qe=>qe.id))||[],Me=[];Ue?Me.push(G.from("profiles").select("id").eq("brokerage_id",Ue).neq("id",t.id).then(qe=>{var ze;je.add_agent=(((ze=qe.data)==null?void 0:ze.length)||0)>0})):je.add_agent=!1,Te.length>0?(Me.push(G.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",Te).then(qe=>{je.add_plan=(qe.count||0)>0})),Me.push(G.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",Te).then(qe=>{je.schedule_popby=(qe.count||0)>0}))):(je.add_plan=!1,je.schedule_popby=!1),await Promise.all(Me);const Fe=V.filter(qe=>je[qe.action_type]);if(Fe.length>0){const qe=Fe.map(ve=>({user_id:t.id,item_id:ve.id})),{error:ze}=await G.from("onboarding_checklist_progress").upsert(qe,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!ze){const ve=Fe.map(dt=>({item_id:dt.id,completed_at:new Date().toISOString()}));o(dt=>[...dt,...ve])}}},_=async L=>{if(t!=null&&t.id)try{const{error:I}=await G.from("onboarding_checklist_progress").insert({user_id:t.id,item_id:L});if(I)throw I;o(O=>[...O,{item_id:L,completed_at:new Date().toISOString()}])}catch(I){console.error("Error marking item complete:",I)}},b=async()=>{if(t!=null&&t.id)try{const{error:L}=await G.from("onboarding_checklist_dismissed").insert({user_id:t.id});if(L)throw L;i(!0)}catch(L){console.error("Error dismissing checklist:",L)}},N=a.length,w=r.length,k=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:k,progressPercentage:C,isItemComplete:L=>a.some(I=>I.item_id===L),markComplete:_,dismiss:b,refetch:x}}const XIt={add_agent:e.jsx(lr,{className:"h-4 w-4"}),share_resource:e.jsx(vd,{className:"h-4 w-4"}),post_community:e.jsx(ki,{className:"h-4 w-4"}),register_event:e.jsx(on,{className:"h-4 w-4"}),view_template:e.jsx(Mv,{className:"h-4 w-4"}),watch_academy:e.jsx(Lh,{className:"h-4 w-4"}),use_toolbox:e.jsx(Ig,{className:"h-4 w-4"}),launch_app:e.jsx(QI,{className:"h-4 w-4"}),add_deal:e.jsx(Ky,{className:"h-4 w-4"}),add_listing:e.jsx(Mn,{className:"h-4 w-4"})},QIt={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function JIt(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:d,dismiss:u}=YIt(),p=_r(),[x,y]=S.useState(!0);return r||s||a===0||o?null:e.jsxs(Pe,{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(Qy,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Get Started with LevelUp"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Complete these steps to make the most of your membership"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>y(!x),className:"h-8 w-8 p-0",children:x?e.jsx(nf,{className:"h-4 w-4"}):e.jsx(Oi,{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(gi,{value:l,className:"h-2"})]})]}),x&&e.jsx(Re,{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=QIt[_.action_type];N?p(N):d(_.id)},children:[e.jsx("div",{className:"mt-0.5",children:b?e.jsx(Qn,{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:XIt[_.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 jf=()=>gt({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}}),qh=t=>{const s=ja(),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})},eLt=t=>gt({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}),hXe=()=>{const t=ja();return gt({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})},ehe=()=>{const t=Jt(),s=ja();return It({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"]}),gn({title:"Contact created successfully"})},onError:r=>{gn({title:"Error creating contact",description:r.message,variant:"destructive"})}})},tke=()=>{const t=Jt();return It({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"]}),gn({title:"Contact updated successfully"})},onError:s=>{gn({title:"Error updating contact",description:s.message,variant:"destructive"})}})},mXe=()=>{const t=Jt();return It({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"]}),gn({title:"Spouse link updated"})},onError:s=>{gn({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},ske=()=>{const t=Jt();return It({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"]}),gn({title:"Contact deleted successfully"})},onError:s=>{gn({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},UR=()=>gt({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}}),tLt=t=>gt({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}}),sLt=()=>gt({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}}),rLt=()=>{const t=Jt(),s=ja();return It({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"]}),gn({title:"Plan created successfully"})},onError:r=>{gn({title:"Error creating plan",description:r.message,variant:"destructive"})}})},nLt=()=>{const t=Jt(),s=ja();return It({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"]}),gn({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{gn({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},aLt=()=>{const t=Jt();return It({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"]}),gn({title:"Plan updated successfully"})}})},iLt=()=>{const t=Jt();return It({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"]}),gn({title:"Plan deleted successfully"})}})},oLt=()=>{const t=Jt();return It({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"]}),gn({title:"Plan schedule updated"})}})},lLt=()=>{const t=Jt();return It({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"]}),gn({title:"Script created successfully"})},onError:s=>{gn({title:"Error creating script",description:s.message,variant:"destructive"})}})},cLt=()=>{const t=ja();return gt({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})},dLt=()=>{const t=Jt(),s=ja();return It({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"]}),gn({title:"Plan enrollment updated"})}})},VR=(t=7)=>{const s=ja();return gt({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})},pXe=()=>{const t=ja();return gt({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})},uLt=(t=90)=>{const{data:s}=qh(),{data:r}=pXe();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=Jt(),s=ja();return It({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"]}),gn({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{}}})},fXe="agentos_weekly_touch_goal",nLe=20,vle=()=>{if(typeof window>"u")return nLe;const t=localStorage.getItem(fXe);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return nLe},xXe=t=>{localStorage.setItem(fXe,t.toString())},rke=()=>{const{data:t}=VR(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=vle();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},hLt=()=>{const t=ja();return gt({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})},mLt=()=>{const t=Jt();return ja(),It({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&&gn({title:`${s} contact(s) enrolled in plans`})}})},gXe=()=>{const t=ja(),{data:s}=hLt(),{data:r}=VR(30);return gt({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,E=N.plan.items.find(L=>L.month_number===C);if(E&&E.action_type){const L=`${N.contact_id}-${E.action_type_id}`;if(!d.has(L)){const{data:I}=await G.from("relationship_types").select("name").eq("id",N.relationship_type_id).single();l.push({contact:N.contact,actionType:E.action_type,script:E.default_script||void 0,planName:N.plan.name,relationshipTypeName:(I==null?void 0:I.name)||"",monthNumber:C})}}}const u=5,p=o.getDate(),x=l.sort((N,w)=>N.contact.first_name.localeCompare(w.contact.first_name)),y=(p-1)%Math.max(1,x.length);return[...x.slice(y),...x.slice(0,y)].slice(0,u)},enabled:!!t&&!!s})};function pLt(){const t=_r(),{data:s,isLoading:r}=gXe(),{data:n}=qh(),a=rke(),[o,l]=S.useState(vle()),[i,d]=S.useState(""),[u,p]=S.useState(!1);S.useEffect(()=>{l(vle())},[]);const x=()=>{const O=parseInt(i,10);if(isNaN(O)||O<1){gn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(O),xXe(O),p(!1),gn({title:"Goal updated",description:`Weekly touch goal set to ${O}`})},y=()=>{d(o.toString()),p(!0)},_=Em(new Date),b=cl(_,7),N=O=>{if(!O)return null;const V=O.split(/[-/T]/);if(V.length<3)return null;const q=parseInt(V[1],10)-1,$=parseInt(V[2],10);return isNaN(q)||isNaN($)?null:new Date(_.getFullYear(),q,$)},w=(n==null?void 0:n.map(O=>{const V=N(O.birthday),q=N(O.home_anniversary),$=[];return V&&V>=_&&V<=b&&$.push({contact:O,type:"birthday",date:V,isToday:rl(V,_)}),q&&q>=_&&q<=b&&$.push({contact:O,type:"anniversary",date:q,isToday:rl(q,_)}),$}).flat().sort((O,V)=>O.date.getTime()-V.date.getTime()).slice(0,3))||[],k=(n==null?void 0:n.filter(O=>{const V=N(O.birthday),q=N(O.home_anniversary);return V&&rl(V,_)||q&&rl(q,_)}).length)||0,C=(s==null?void 0:s.length)||0,E=k+C,L=(a==null?void 0:a.actionsThisWeek)||0,I=(a==null?void 0:a.streak)||0;return r?e.jsx(Pe,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:e.jsx(Re,{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(Pe,{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(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),e.jsx("div",{className:"flex items-center gap-2",children:I>0&&e.jsxs(Qe,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx(ch,{className:"h-3 w-3"}),I," day streak"]})})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[E>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-primary font-medium",children:[E," tasks"]})," for today"]}):"No tasks for today",L>0&&e.jsxs("span",{className:"ml-2",children:["• ",e.jsx("span",{className:"text-emerald-600 font-medium",children:L})," touches this week"]})]})]}),e.jsxs(Re,{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(al,{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(Pn,{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(Tn,{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(Da,{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(Ky,{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(Rh,{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(pi,{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(ko,{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(Ir,{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(xe,{htmlFor:"weekly-goal",children:"Weekly touch goal"}),e.jsx(De,{id:"weekly-goal",type:"number",min:"1",value:i,onChange:O=>d(O.target.value),placeholder:"20",onKeyDown:O=>{O.key==="Enter"&&x()}})]}),e.jsx(K,{onClick:x,className:"w-full",children:"Save Goal"})]})]})]})]}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium text-primary",children:L}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",o," touches"]})]})]}),e.jsx(gi,{value:Math.min(L/o*100,100),className:"h-2 bg-muted [&>div]:bg-primary"}),L>=o&&e.jsxs("p",{className:"text-xs text-emerald-600 mt-1.5 flex items-center gap-1",children:[e.jsx("span",{children:"🎉"})," Goal achieved! Keep the momentum going."]}),L0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5",children:[o-L," more to hit your weekly goal"]})]}),w.length>0&&e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(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,V)=>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(Qe,{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"?"🎂":"🏠":ps(O.date,"EEE, MMM d")}),e.jsx(Sa,{className:"h-3 w-3"})]})]},`${O.contact.id}-${O.type}-${V}`))})]}),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(ei,{className:"h-4 w-4"})]})]})]})}function fLt(t){return gt({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 xLt(t,s){return gt({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 gLt(t,s=4){return gt({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 yLt(t){const s=Jt();return It({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 vLt(){const t=Jt();return It({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 _Lt(t){const s=Jt();return It({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 bLt(){const t=Jt();return It({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 wLt(t){const s=Jt();return It({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 jLt={video:So,pdf:fn,link:Do,event:on,graphic:Dl},NLt={video:"bg-red-500/10 text-red-600 dark:text-red-400",pdf:"bg-blue-500/10 text-blue-600 dark:text-blue-400",link:"bg-green-500/10 text-green-600 dark:text-green-400",event:"bg-purple-500/10 text-purple-600 dark:text-purple-400",graphic:"bg-amber-500/10 text-amber-600 dark:text-amber-400"};function kLt(t){if(!t)return null;try{const s=new URL(t),r=s.hostname.replace("www.","");let n=null;if(r==="youtube.com"||r==="m.youtube.com"?n=s.searchParams.get("v"):r==="youtu.be"&&(n=s.pathname.slice(1)),n)return`https://img.youtube.com/vi/${n}/hqdefault.jpg`}catch{}return null}function SLt(t){if(!t)return!1;try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function CLt({item:t}){const s=_r(),r=jLt[t.content_type]||Do,n=NLt[t.content_type]||"",[a,o]=S.useState(null),l=t.thumbnail_url||(t.content_type==="graphic"&&t.file_url?t.file_url:null)||(t.content_type==="video"?kLt(t.url):null);S.useEffect(()=>{l||!t.url||t.content_type!=="video"||!SLt(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(Pe,{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(Re,{className:"p-3",children:[e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsxs(Qe,{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:ps(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function MLt(){const{brokerageId:t}=Fs(),s=_r(),{data:r=[],isLoading:n}=gLt(t,4);return!t||n||r.length===0?null:e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{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(ei,{className:"h-4 w-4"})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:r.map(a=>e.jsx(CLt,{item:a},a.id))})]})}const yXe=()=>gt({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}}),vXe=t=>{const{user:s,brokerageId:r}=Fs();return gt({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(x=>x.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 x=new Set(l.map(_=>_.id)),y=p.filter(_=>!x.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}=Fs();return gt({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})},bXe=t=>{const{user:s}=Fs();return gt({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})},TLt=()=>{const t=Jt(),{user:s}=Fs();return It({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"]})}})},ALt=()=>{const t=Jt();return It({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"]})}})},ELt=()=>{const t=Jt();return It({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]})}})},wXe=()=>{const t=Jt();return It({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"]})}})},PLt=()=>{const t=Jt();return It({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"]})}})},ILt=()=>{const t=Jt();return It({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"]})}})},LLt=()=>{const t=Jt();return It({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"]})}})},DLt=()=>{const t=Jt();return It({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"]})}})},RLt=()=>{const{user:t}=Fs();return gt({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})},jXe=()=>{const t=Jt(),{user:s}=Fs();return It({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"]})}})},NXe=t=>{const{user:s}=Fs();return gt({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})},OLt=()=>{const t=Jt(),{user:s}=Fs();return It({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"]})}})},FLt=t=>{const{user:s}=Fs();return gt({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})},zLt=()=>{const{user:t}=Fs();return It({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}})},BLt=()=>{const{user:t}=Fs();return gt({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})},$Lt=()=>{const t=Jt(),{user:s}=Fs();return It({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"]})}})},qLt=()=>gt({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}}}),ULt=()=>{const{user:t,brokerageId:s}=Fs();return gt({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})},kXe=({className:t,variant:s="default"})=>e.jsx(Qe,{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"}),VLt={coming_soon:"bg-amber-500/10 text-amber-600 border-amber-200",active:"bg-emerald-500/10 text-emerald-600 border-emerald-200",under_contract:"bg-blue-500/10 text-blue-600 border-blue-200",sold:"bg-purple-500/10 text-purple-600 border-purple-200",withdrawn:"bg-muted text-muted-foreground border-border"},HLt={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function GLt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function WLt(){const t=_r(),{data:s,isLoading:r}=yXe(),{data:n,isLoading:a}=vXe({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(Pe,{className:"bg-gradient-to-br from-emerald-500/5 via-emerald-500/10 to-emerald-500/5 border-emerald-500/20",children:e.jsx(Re,{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(kXe,{})]}),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(ei,{className:"h-4 w-4"})]})]}),d.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{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 x=((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:[x!=null&&x.photo_url?e.jsx("img",{src:x.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(Qe,{className:"gap-1 bg-amber-500 text-white border-0 text-[10px] px-1.5 py-0.5",children:[e.jsx(Hn,{className:"h-2.5 w-2.5 fill-current"}),"Featured"]})}),e.jsx("div",{className:"absolute top-1.5 right-1.5",children:e.jsx(Qe,{className:`text-[10px] px-1.5 py-0.5 ${VLt[p.status]}`,children:HLt[p.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:GLt(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 SXe(t=10,s){return gt({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),x=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:x.get(y.user_id)||null}))}})}function CXe(t){return gt({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 MXe(t){return gt({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 TXe(t,s){return gt({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 KLt(){const{user:t,brokerageId:s,isAdmin:r}=Fs();_r();const n=!!s,[a,o]=S.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:d}=SXe(5,l()),{data:u}=CXe(t==null?void 0:t.id),{data:p}=TXe(t==null?void 0:t.id,l()),{data:x}=MXe(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(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Vi,{className:"h-4 w-4 text-yellow-500"}),_()]})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-2",children:[...Array(y?5:3)].map((N,w)=>e.jsx(Ns,{className:"h-10 w-full"},w))})})]});const b=N=>N===0?e.jsx(Vi,{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(Pe,{children:[e.jsxs(Lt,{className:"pb-2",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Vi,{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(Re,{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,k)=>{var C,E,L;return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${w.user_id===(t==null?void 0:t.id)?"bg-primary/10 border border-primary/20":k===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:b(k)}),e.jsx(vn,{className:"h-6 w-6",children:e.jsx(_n,{className:"text-xs",children:((E=(C=w.profile)==null?void 0:C.name)==null?void 0:E.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((L=w.profile)==null?void 0:L.name)||"Unknown"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:w.total_points})]},w.user_id)}),N.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-2 text-sm",children:"No data yet"})]}),e.jsxs(ha,{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(Ui,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(Sa,{className:"h-4 w-4"})]})]})]})}return e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Vi,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),e.jsx(Re,{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," 🔥"]})]}),x&&x.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(ec,{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:[x.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)),x.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",x.length-4," more"]})]})]}),e.jsxs(ha,{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(Ui,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(Sa,{className:"h-4 w-4"})]})]}):e.jsxs("div",{className:"text-center text-muted-foreground py-4 text-sm",children:[e.jsx(Hn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{children:"Attend events to earn points!"}),e.jsxs(ha,{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(Ui,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(Sa,{className:"h-4 w-4"})]})]})})]})}const XA=()=>gt({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}}),nke=()=>{const t=Jt(),{user:s}=Fs();return It({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)}})},ZLt=()=>{const t=Jt();return It({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")}})},YLt=()=>{const t=Jt();return It({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")}})},ake=(t,s)=>{const{user:r,isAdmin:n}=Fs(),a=n&&s?s:r==null?void 0:r.id;return gt({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})},ike=t=>{const{user:s,isAdmin:r}=Fs(),n=r&&t?t:s==null?void 0:s.id;return gt({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})},she=()=>{const t=Jt(),{user:s}=Fs();return It({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)}})},XLt=()=>{const t=Jt();return It({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)}})},QLt=()=>{const t=Jt();return It({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)}})},AXe=(t,s)=>{const{user:r,isAdmin:n}=Fs(),a=n&&s?s:r==null?void 0:r.id;return gt({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})},JLt=()=>{const t=Jt(),{user:s}=Fs();return It({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)}})},rhe=()=>{const{user:t}=Fs();return gt({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)})},e8t=()=>{const t=Jt(),{user:s}=Fs();return It({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)}})},EXe=(t,s)=>{const{data:r,isLoading:n}=ake(t,s),{data:a,isLoading:o}=ike(s),{data:l}=rhe(),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(I=>I.transaction_type==="buyer").length,x=u.filter(I=>I.transaction_type==="seller").length,y=u.reduce((I,O)=>I+Number(O.sale_price),0),_=u.reduce((I,O)=>I+(Number(O.commission_amount)||0),0),b=u.reduce((I,O)=>{const V=Number(O.commission_amount)||0;if(!V)return I;let q=V;return O.brokerage_split_pct&&(q-=V*(O.brokerage_split_pct/100)),O.team_split_pct&&(q-=V*(O.team_split_pct/100)),O.franchise_fee_pct&&(q-=V*(O.franchise_fee_pct/100)),O.referral_fee_pct&&(q-=V*(O.referral_fee_pct/100)),O.transaction_fee&&(q-=O.transaction_fee),I+Math.max(0,q)},0),N={};u.forEach(I=>{var V;const O=((V=I.lead_source)==null?void 0:V.name)||"Unknown";N[O]=(N[O]||0)+1});const w=Object.entries(N).map(([I,O])=>({name:I,count:O})).sort((I,O)=>O.count-I.count),k=w[0]||null,C={};u.forEach(I=>{const O=ml(I.close_date).toLocaleString("default",{month:"short"});C[O]=(C[O]||0)+1});const L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(I=>({month:I,count:C[I]||0}));return{totalTransactions:u.length,buyerCount:p,sellerCount:x,totalVolume:y,averagePrice:u.length>0?y/u.length:0,totalCommission:i?_:0,totalNetToAgent:i?b:0,topLeadSource:k,transactionsByMonth:L,leadSourceBreakdown:w}};return{yearStats:d(r),lifetimeStats:d(a),isLoading:n||o,showCommission:i}},t8t=()=>{const{isAdmin:t}=Fs();return gt({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})},P_={recency:40,touchpoints:30,transactions:20,referrals:10},aLe={warm:70,cooling:40};function s8t(t){return t===null?0:t<=14?P_.recency:t<=30?P_.recency*.85:t<=60?P_.recency*.65:t<=90?P_.recency*.4:t<=180?P_.recency*.2:P_.recency*.05}function r8t(t){const s=Math.min(t/12,1);return Math.round(P_.touchpoints*s)}function n8t(t){return t?P_.transactions:0}function a8t(){return 0}function i8t(t){return t>=aLe.warm?"warm":t>=aLe.cooling?"cooling":"at-risk"}function nhe(){const{data:t,isLoading:s}=qh(),{data:r}=pXe(),{data:n}=VR(365),{data:a}=ike(),o=S.useMemo(()=>{if(!t)return[];const i=new Date,d=m4(i,12),u={};n==null||n.forEach(x=>{new Date(x.completed_at)>=d&&(u[x.contact_id]=(u[x.contact_id]||0)+1)});const p=new Set((a==null?void 0:a.filter(x=>x.contact_id).map(x=>x.contact_id))||[]);return t.map(x=>{const y=(r==null?void 0:r[x.id])||null,_=y?Bg(i,new Date(y)):null,b=u[x.id]||0,N=p.has(x.id),w=s8t(_),k=r8t(b),C=n8t(N),E=a8t(),L=Math.round(w+k+C+E),I={score:L,status:i8t(L),breakdown:{recency:Math.round(w),touchpoints:Math.round(k),transactions:Math.round(C),referrals:Math.round(E)},lastTouchDate:y,daysSinceTouch:_,touchCountLast12Months:b,hasTransaction:N};return{...x,relationshipScore:I}})},[t,r,n,a]),l=S.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,x=p>0?Math.round(o.reduce((y,_)=>y+_.relationshipScore.score,0)/p):0;return{warm:i,cooling:d,atRisk:u,total:p,averageScore:x}},[o]);return{contactsWithScores:o,stats:l,isLoading:s}}function PXe(){const t=_r(),{stats:s,contactsWithScores:r,isLoading:n}=nhe();if(n)return e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ns,{className:"h-5 w-40"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx(Ns,{className:"h-20 w-full"}),e.jsx(Ns,{className:"h-16 w-full"})]})]});if(s.total===0)return e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(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(Re,{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(gi,{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(gi,{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(gi,{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(gS,{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(Sa,{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(Sa,{className:"h-4 w-4 ml-1"})]})]})]})}const o8t=()=>{var ie;const{user:t,isAdmin:s}=Fs(),r=_r(),[n,a]=S.useState([]),[o,l]=S.useState([]),[i,d]=S.useState([]),[u,p]=S.useState([]),[x,y]=S.useState([]),[_,b]=S.useState([]),[N,w]=S.useState(new Set),[k,C]=S.useState([]),[E,L]=S.useState([]),[I,O]=S.useState([]),[V,q]=S.useState(null),[$,U]=S.useState(!0);S.useEffect(()=>{se()},[t]);const se=async()=>{var ae,oe,pe,_e,he;try{const[we,je,Ue,Te,Me,Fe,Le,Ne,qe,ze,ve]=await Promise.all([G.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),G.from("app_tiles").select("*").order("name"),G.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),G.from("events").select("*").order("event_date",{ascending:!0}),G.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",t==null?void 0:t.id),G.from("canva_templates").select("id, name, preview_image_url, publish_date").order("publish_date",{ascending:!1}).limit(4),G.from("resource_kits").select("id, name, description, featured_image_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.from("academy_videos").select("id, title, description, thumbnail_url, duration, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.from("additional_services").select("id, name, description, preview_image_url, signup_link_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.from("dashboard_banners").select("id, title, description, image_url, link_url, link_text, placement, section_after").eq("is_active",!0).order("sort_order"),G.from("profiles").select("name").eq("id",t==null?void 0:t.id).single()]);(ae=ve.data)!=null&&ae.name&&q(ve.data.name);const dt=((oe=we.data)==null?void 0:oe.map(Ye=>Ye.tag))||[],fe=new Set(((pe=Ue.data)==null?void 0:pe.map(Ye=>Ye.app_id))||[]);w(fe);const Je=(((_e=je.data)==null?void 0:_e.filter(Ye=>!Ye.required_tags||Ye.required_tags.length===0?!0:Ye.required_tags.some(We=>dt.includes(We))))||[]).sort((Ye,We)=>Ye.name==="LevelUp Members Portal"?-1:We.name==="LevelUp Members Portal"?1:0);a(Je.slice(0,6));const at=((he=Te.data)==null?void 0:he.filter(Ye=>VM(Ye.event_date)!=="ended"))||[];l(at.slice(0,4)),C(Me.data||[]),d(Fe.data||[]),p(Le.data||[]),y(Ne.data||[]),b(qe.data||[]);const Ae=ze.data||[];L(Ae.filter(Ye=>Ye.placement==="top")),O(Ae.filter(Ye=>Ye.placement==="between"))}catch(we){console.error("Error loading dashboard:",we),me.error("Failed to load dashboard data")}finally{U(!1)}},Y=async ae=>{var pe;const oe=window.open("about:blank","_blank");try{await G.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:ae.app_id,app_name:ae.name,user_agent:navigator.userAgent});const{data:_e,error:he}=await G.functions.invoke("sso-launch",{body:{app_id:ae.app_id}});if(he)throw he;_e!=null&&_e.redirect_url?oe&&!oe.closed?(oe.location.href=_e.redirect_url,(pe=oe.focus)==null||pe.call(oe)):window.location.assign(_e.redirect_url):(oe==null||oe.close(),me.error("Launch link unavailable"))}catch(_e){oe==null||oe.close(),console.error("Error launching app:",_e),me.error("Failed to launch app")}},J=ae=>k==null?void 0:k.some(oe=>oe.event_id===ae),X=ae=>{const oe=k==null?void 0:k.find(pe=>pe.event_id===ae);return oe==null?void 0:oe.zoom_join_url};if($)return e.jsx(Es,{title:"Dashboard",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading your dashboard..."})]})})});const ce=ae=>I.filter(oe=>oe.section_after===ae);return e.jsxs(Es,{title:"Dashboard",children:[e.jsx(qIt,{events:o,registrations:k,onNavigateToEvents:()=>r("/events")}),E.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(sI,{banners:E})}),e.jsx(JIt,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",(V||((ie=t==null?void 0:t.user_metadata)==null?void 0:ie.name)||"there").split(" ")[0],"!"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Are you ready to LevelUp today?"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 mb-8",children:[e.jsx(pLt,{}),e.jsx(PXe,{}),e.jsx(KLt,{})]}),e.jsx(MLt,{}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Upcoming Events"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/events"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(ei,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(on,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming events"})]})})}):e.jsx("div",{className:"bg-card rounded-xl border border-border overflow-hidden divide-y divide-border max-w-full",children:o.map(ae=>{const oe=J(ae.id),pe=X(ae.id)||ae.zoom_link;return e.jsxs("div",{className:`flex items-start gap-3 sm:gap-4 p-3 sm:p-4 hover:bg-muted/50 transition-colors cursor-pointer group ${tLe(ae.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[tLe(ae.event_date)?e.jsxs("div",{className:"flex-shrink-0 w-12 h-12 sm:w-14 sm:h-14 rounded-lg bg-red-500/10 flex flex-col items-center justify-center relative",children:[e.jsx("span",{className:"absolute inline-flex h-3 w-3 top-1 right-1 animate-ping rounded-full bg-red-500 opacity-75"}),e.jsx(Jv,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"text-[10px] font-bold text-red-500 uppercase mt-0.5",children:"Live"})]}):e.jsxs("div",{className:"flex-shrink-0 w-12 h-12 sm:w-14 sm:h-14 rounded-lg bg-primary/10 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-[10px] sm:text-xs font-medium text-primary uppercase",children:new Intl.DateTimeFormat("en-US",{month:"short",timeZone:"America/New_York"}).format(new Date(ae.event_date))}),e.jsx("span",{className:"text-lg sm:text-xl font-bold text-primary",children:new Intl.DateTimeFormat("en-US",{day:"numeric",timeZone:"America/New_York"}).format(new Date(ae.event_date))})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm sm:text-base text-foreground group-hover:text-primary transition-colors line-clamp-2 sm:truncate",children:ae.title}),e.jsxs("p",{className:"text-xs sm:text-sm text-muted-foreground mt-0.5",children:[new Intl.DateTimeFormat("en-US",{weekday:"long",timeZone:"America/New_York"}).format(new Date(ae.event_date))," at ",oD(new Date(ae.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:oe?e.jsxs(K,{size:"sm",variant:"default",className:"gap-1",onClick:_e=>{_e.stopPropagation(),window.open(pe,"_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(Sa,{className:"h-4 w-4"})]})})]},ae.id)})})]}),ce("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(sI,{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(ei,{className:"h-4 w-4"})]})]}),x.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(sp,{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:x.map(ae=>e.jsxs("div",{onClick:()=>r(`/academy/${ae.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden relative",children:[ae.thumbnail_url?e.jsx("img",{src:ae.thumbnail_url,alt:ae.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(sp,{className:"h-8 w-8 text-muted-foreground/50"})}),ae.duration&&e.jsx("span",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:ae.duration})]}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground line-clamp-2 group-hover:text-primary transition-colors",children:ae.title})})]},ae.id))})]}),ce("academy").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(sI,{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(ei,{className:"h-4 w-4"})]})]}),u.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Mm,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No resource kits available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:u.map(ae=>e.jsxs("div",{onClick:()=>r(`/toolbox/${ae.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden",children:ae.featured_image_url?e.jsx("img",{src:ae.featured_image_url,alt:ae.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Mm,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:ae.name})})]},ae.id))})]}),ce("toolbox").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(sI,{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(ei,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(jb,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No templates available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:i.map(ae=>e.jsxs("div",{onClick:()=>r("/templates"),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden",children:ae.preview_image_url?e.jsx("img",{src:ae.preview_image_url,alt:ae.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(jb,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:ae.name})})]},ae.id))})]}),ce("templates").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(sI,{banners:ce("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(WLt,{})}),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(ei,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx(fx,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No apps available"})]})})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:n.map(ae=>{const oe=N.has(ae.id);return e.jsxs("div",{onClick:()=>Y(ae),className:"group flex items-start gap-4 p-5 bg-card rounded-xl border border-border cursor-pointer transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-3xl",children:ae.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:ae.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ae.description})]}),oe&&e.jsx(fx,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},ae.id)})})]}),e.jsxs("section",{className:"mt-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Additional Services"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/additional-services"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(ei,{className:"h-4 w-4"})]})]}),_.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx($r,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional services available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:_.map(ae=>e.jsxs("div",{onClick:()=>window.open(ae.signup_link_url,"_blank"),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden",children:ae.preview_image_url?e.jsx("img",{src:ae.preview_image_url,alt:ae.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx($r,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsxs("div",{className:"p-3",children:[e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:ae.name}),ae.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:ae.description})]})]},ae.id))})]})]})};var IXe="AlertDialog",[l8t,DTs]=$c(IXe,[nGe]),k1=nGe(),LXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=k1(s);return e.jsx(vue,{...n,...r,modal:!0})};LXe.displayName=IXe;var c8t="AlertDialogTrigger",DXe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=k1(r);return e.jsx(Bje,{...a,...n,ref:s})});DXe.displayName=c8t;var d8t="AlertDialogPortal",RXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=k1(s);return e.jsx(_ue,{...n,...r})};RXe.displayName=d8t;var u8t="AlertDialogOverlay",OXe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=k1(r);return e.jsx(BA,{...a,...n,ref:s})});OXe.displayName=u8t;var HM="AlertDialogContent",[h8t,m8t]=l8t(HM),p8t=kqe("AlertDialogContent"),FXe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=k1(r),l=S.useRef(null),i=Aa(s,l),d=S.useRef(null);return e.jsx(iNt,{contentName:HM,titleName:zXe,docsSlug:"alert-dialog",children:e.jsx(h8t,{scope:r,cancelRef:d,children:e.jsxs($A,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:Cr(a.onOpenAutoFocus,u=>{var p;u.preventDefault(),(p=d.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[e.jsx(p8t,{children:n}),e.jsx(x8t,{contentRef:l})]})})})});FXe.displayName=HM;var zXe="AlertDialogTitle",BXe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=k1(r);return e.jsx(PR,{...a,...n,ref:s})});BXe.displayName=zXe;var $Xe="AlertDialogDescription",qXe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=k1(r);return e.jsx(IR,{...a,...n,ref:s})});qXe.displayName=$Xe;var f8t="AlertDialogAction",UXe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=k1(r);return e.jsx(LR,{...a,...n,ref:s})});UXe.displayName=f8t;var VXe="AlertDialogCancel",HXe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=m8t(VXe,r),o=k1(r),l=Aa(s,a);return e.jsx(LR,{...o,...n,ref:l})});HXe.displayName=VXe;var x8t=({contentRef:t})=>{const s=`\`${HM}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${HM}\` by passing a \`${$Xe}\` component as a child, which also benefits sighted users by adding visible context to the dialog. Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${HM}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return S.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},g8t=LXe,y8t=DXe,v8t=RXe,GXe=OXe,WXe=FXe,KXe=UXe,ZXe=HXe,YXe=BXe,XXe=qXe;const tc=g8t,_m=y8t,_8t=v8t,QXe=S.forwardRef(({className:t,...s},r)=>e.jsx(GXe,{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}));QXe.displayName=GXe.displayName;const Ml=S.forwardRef(({className:t,...s},r)=>e.jsxs(_8t,{children:[e.jsx(QXe,{}),e.jsx(WXe,{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})]}));Ml.displayName=WXe.displayName;const Tl=({className:t,...s})=>e.jsx("div",{className:Rt("flex flex-col space-y-2 text-center sm:text-left",t),...s});Tl.displayName="AlertDialogHeader";const Al=({className:t,...s})=>e.jsx("div",{className:Rt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Al.displayName="AlertDialogFooter";const El=S.forwardRef(({className:t,...s},r)=>e.jsx(YXe,{ref:r,className:Rt("text-lg font-semibold",t),...s}));El.displayName=YXe.displayName;const Pl=S.forwardRef(({className:t,...s},r)=>e.jsx(XXe,{ref:r,className:Rt("text-sm text-muted-foreground",t),...s}));Pl.displayName=XXe.displayName;const pl=S.forwardRef(({className:t,...s},r)=>e.jsx(KXe,{ref:r,className:Rt(X8(),t),...s}));pl.displayName=KXe.displayName;const Il=S.forwardRef(({className:t,...s},r)=>e.jsx(ZXe,{ref:r,className:Rt(X8({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));Il.displayName=ZXe.displayName;const b8t=[{key:"contacts",label:"Contacts",icon:Pn,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:tS,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:Mm,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:Tn,description:"View and upload videos"},{key:"listings",label:"Listings",icon:Mn,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:wb,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:Da,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:yx,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:Pg,description:"Create and manage smart presentations"}];function w8t(){var V;const{user:t}=Fs(),[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(null),[x,y]=S.useState({email:"",name:"",password:""}),[_,b]=S.useState("create"),[N,w]=S.useState(!1),[k,C]=S.useState(null);S.useEffect(()=>{t&&E()},[t]);const E=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 U=q.map(J=>J.assistant_id),{data:se}=await G.from("profiles").select("id, name, email").in("id",U),Y=q.map(J=>{const X=se==null?void 0:se.find(ce=>ce.id===J.assistant_id);return{...J,permissions:J.permissions,assistant_profile:X?{name:X.name||"",email:X.email||""}:void 0}});r(Y)}else r([])}catch(q){console.error("Error loading assistants:",q)}finally{a(!1)}}},L=async()=>{if(t){if(_==="link"){if(!x.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:U}=await G.from("profiles").select("id, name, email").eq("email",x.email.trim().toLowerCase()).single();if(U||!$){me.error("No account found with that email. Try creating a new assistant instead.");return}const{data:se}=await G.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",$.id);if(se&&se.length>0){me.error("This assistant is already assigned to you");return}const Y=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 Y.json();if(!Y.ok)throw new Error(J.error||"Failed to assign assistant role");const{error:X}=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(X)throw X;me.success(`${$.name||$.email} linked as your assistant`),l(!1),y({email:"",name:"",password:""}),E()}catch(q){console.error("Error linking assistant:",q),me.error(q.message||"Failed to link assistant")}finally{w(!1)}return}if(!x.email.trim()||!x.name.trim()||!x.password.trim()){me.error("Please fill in all fields");return}if(x.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:x.email.trim(),password:x.password,name:x.name.trim(),purpose:"assistant"})}),U=await $.json();if(!$.ok)throw new Error(U.error||"Failed to create assistant account");const se=U.userId||U.id;if(!se)throw new Error("No user ID returned");const Y=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:se,role:"assistant",action:"add",agentId:t.id})}),J=await Y.json();if(!Y.ok)throw new Error(J.error||"Failed to assign assistant role");const{error:X}=await G.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:se,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(X)throw X;me.success(`Assistant account created for ${x.name.trim()}`),l(!1),y({email:"",name:"",password:""}),E()}catch(q){console.error("Error adding assistant:",q),me.error(q.message||"Failed to add assistant")}finally{w(!1)}}},I=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:U}=await G.from("agent_assistant_assignments").select("id").eq("assistant_id",u.assistant_id);(!U||U.length===0)&&await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:u.assistant_id,role:"assistant",action:"remove"})}),me.success("Assistant removed"),d(!1),p(null),E()}catch(q){console.error("Error removing assistant:",q),me.error(q.message||"Failed to remove assistant")}},O=async(q,$,U)=>{C(q);try{const se=s.find(X=>X.id===q);if(!se)return;const Y={...se.permissions,[$]:U},{error:J}=await G.from("agent_assistant_assignments").update({permissions:Y}).eq("id",q);if(J)throw J;r(X=>X.map(ce=>ce.id===q?{...ce,permissions:Y}:ce))}catch(se){console.error("Error updating permissions:",se),me.error("Failed to update permissions")}finally{C(null)}};return n?e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx(Re,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(_s,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(hr,{children:"Add assistants to help manage your Agent OS"})]}),e.jsxs(K,{size:"sm",onClick:()=>{b("create"),l(!0)},children:[e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Add Assistant"]})]})}),e.jsx(Re,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No assistant assigned. Add one to help manage your contacts, deals, and more."}):e.jsx("div",{className:"space-y-4",children:s.map(q=>{var $,U,se,Y;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:((U=($=q.assistant_profile)==null?void 0:$.name)==null?void 0:U.split(" ").map(J=>J[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((se=q.assistant_profile)==null?void 0:se.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((Y=q.assistant_profile)==null?void 0:Y.email)||""})]}),e.jsxs(Qe,{variant:"secondary",className:"ml-2",children:[e.jsx(Ou,{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(gr,{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:b8t.map(J=>{const X=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(X,{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(Er,{checked:q.permissions[J.key]||!1,onCheckedChange:ce=>O(q.id,J.key,ce),disabled:k===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(Ir,{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(Us,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(K,{variant:_==="link"?"default":"outline",size:"sm",onClick:()=>b("link"),children:[e.jsx(fo,{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(xe,{htmlFor:"assistant-name",children:"Name"}),e.jsx(De,{id:"assistant-name",value:x.name,onChange:q=>y({...x,name:q.target.value}),placeholder:"Assistant's full name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"assistant-email",children:"Email"}),e.jsx(De,{id:"assistant-email",type:"email",value:x.email,onChange:q=>y({...x,email:q.target.value}),placeholder:"assistant@email.com"})]}),_==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"assistant-password",children:"Temporary Password"}),e.jsx(De,{id:"assistant-password",type:"password",value:x.password,onChange:q=>y({...x,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(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:L,disabled:N,children:[N&&e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}),_==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(tc,{open:i,onOpenChange:d,children:e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Remove Assistant?"}),e.jsxs(Pl,{children:["This will remove ",(V=u==null?void 0:u.assistant_profile)==null?void 0:V.name,"'s access to your Agent OS. Their account will remain active but they won't be able to manage your data."]})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:I,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function Ju(t){this.content=t}Ju.prototype={constructor:Ju,find:function(t){for(var s=0;s>1}};Ju.from=function(t){if(t instanceof Ju)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new Ju(s)};function JXe(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=JXe(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function eQe(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 Mr(n,a)}cutByIndex(s,r){return s==r?Mr.empty:s==0&&r==this.content.length?this:new Mr(this.content.slice(s,r))}replaceChild(s,r){let n=this.content[s];if(n==r)return this;let a=this.content.slice(),o=this.size+r.nodeSize-n.nodeSize;return a[s]=r,new Mr(a,o)}addToStart(s){return new Mr([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Mr(this.content.concat(s),this.size+s.nodeSize)}eq(s){if(this.content.length!=s.content.length)return!1;for(let r=0;rthis.size||s<0)throw new RangeError(`Position ${s} outside of fragment (${this})`);for(let r=0,n=0;;r++){let a=this.child(r),o=n+a.nodeSize;if(o>=s)return o==s?Ez(r+1,o):Ez(r,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(s=>s.toJSON()):null}static fromJSON(s,r){if(!r)return Mr.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Mr(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Mr.empty;let r,n=0;for(let a=0;athis.type.rank&&(r||(r=s.slice(0,a)),r.push(this),n=!0),r&&r.push(o)}}return r||(r=s.slice()),n||r.push(this),r}removeFromSet(s){for(let r=0;rn.type.rank-a.type.rank),r}};ul.none=[];class ble 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=sQe(this.content,s+this.openStart,r);return n&&new yn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new yn(tQe(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(Mr.fromJSON(s,r.content),n,a)}static maxOpen(s,r=!0){let n=0,a=0;for(let o=s.firstChild;o&&!o.isLeaf&&(r||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=s.lastChild;o&&!o.isLeaf&&(r||!o.type.spec.isolating);o=o.lastChild)a++;return new yn(s,n,a)}}yn.empty=new yn(Mr.empty,0,0);function tQe(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(tQe(o.content,s-a-1,r-a-1)))}function sQe(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=sQe(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function j8t(t,s,r){if(r.openStart>t.depth)throw new ble("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new ble("Inconsistent open depths");return rQe(t,s,r,0)}function rQe(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 s8(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&&(wS(t.nodeAfter,n),o++));for(let i=o;ia&&i_e(t,s,a+1),l=n.depth>a&&i_e(r,n,a+1),i=[];return s8(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(nQe(o,l),wS(jS(o,aQe(t,s,r,n,a+1)),i)):(o&&wS(jS(o,wle(t,s,a+1)),i),s8(s,r,a,i),l&&wS(jS(l,wle(r,n,a+1)),i)),s8(n,null,a,i),new Mr(i)}function wle(t,s,r){let n=[];if(s8(null,t,r,n),t.depth>r){let a=i_e(t,s,r+1);wS(jS(a,wle(t,s,r+1)),n)}return s8(s,null,r,n),new Mr(n)}function N8t(t,s){let r=s.depth-t.openStart,a=s.node(r).copy(t.content);for(let o=r-1;o>=0;o--)a=s.node(o).copy(Mr.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class lD{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 jle(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 lD(r,n,o)}static resolveCached(s,r){let n=iLe.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()+")"),iQe(this.marks,s)}contentMatchAt(s){let r=this.type.contentMatch.matchFragment(this.content,0,s);if(!r)throw new Error("Called contentMatchAt on a node with invalid content");return r}canReplace(s,r,n=Mr.empty,a=0,o=n.childCount){let l=this.contentMatchAt(s).matchFragment(n,a,o),i=l&&l.matchFragment(this.content,r);if(!i||!i.validEnd)return!1;for(let d=a;dr.type.name)}`);this.content.forEach(r=>r.check())}toJSON(){let s={type:this.type.name};for(let r in this.attrs){s.attrs=this.attrs;break}return this.content.size&&(s.content=this.content.toJSON()),this.marks.length&&(s.marks=this.marks.map(r=>r.toJSON())),s}static fromJSON(s,r){if(!r)throw new RangeError("Invalid input for Node.fromJSON");let n;if(r.marks){if(!Array.isArray(r.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=r.marks.map(s.markFromJSON)}if(r.type=="text"){if(typeof r.text!="string")throw new RangeError("Invalid text node in JSON");return s.text(r.text,n)}let a=Mr.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};Db.prototype.text=void 0;class Nle extends Db{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):iQe(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 Nle(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new Nle(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 iQe(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class ZS{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new M8t(s,r);if(n.next==null)return ZS.empty;let a=oQe(n);n.next&&n.err("Unexpected trailing text");let o=D8t(L8t(a));return R8t(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(` `)}}ZS.empty=new ZS(!0);class M8t{constructor(s,r){this.string=s,this.nodeTypes=r,this.inline=null,this.pos=0,this.tokens=s.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(s){return this.next==s&&(this.pos++||!0)}err(s){throw new SyntaxError(s+" (in content expression '"+this.string+"')")}}function oQe(t){let s=[];do s.push(T8t(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function T8t(t){let s=[];do s.push(A8t(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function A8t(t){let s=I8t(t);for(;;)if(t.eat("+"))s={type:"plus",expr:s};else if(t.eat("*"))s={type:"star",expr:s};else if(t.eat("?"))s={type:"opt",expr:s};else if(t.eat("{"))s=E8t(t,s);else break;return s}function oLe(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function E8t(t,s){let r=oLe(t),n=r;return t.eat(",")&&(t.next!="}"?n=oLe(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function P8t(t,s){let r=t.nodeTypes,n=r[s];if(n)return[n];let a=[];for(let o in r){let l=r[o];l.isInGroup(s)&&a.push(l)}return a.length==0&&t.err("No node type or group '"+s+"' found"),a}function I8t(t){if(t.eat("(")){let s=oQe(t);return t.eat(")")||t.err("Missing closing paren"),s}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let s=P8t(t,t.next).map(r=>(t.inline==null?t.inline=r.isInline:t.inline!=r.isInline&&t.err("Mixing inline and block content"),{type:"name",value:r}));return t.pos++,s.length==1?s[0]:{type:"choice",exprs:s}}}function L8t(t){let s=[[]];return a(o(t,0),r()),s;function r(){return s.push([])-1}function n(l,i,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 ZS(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:dQe(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Db(this,this.computeAttrs(s),Mr.from(r),ul.setFrom(n))}createChecked(s=null,r,n){return r=Mr.from(r),this.checkContent(r),new Db(this,this.computeAttrs(s),r,ul.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=Mr.from(r),r.size){let l=this.contentMatch.fillBefore(r);if(!l)return null;r=l.append(r)}let a=this.contentMatch.matchFragment(r),o=a&&a.fillBefore(Mr.empty,!0);return o?new Db(this,s,r.append(o),ul.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 mQe(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 O8t(t,s,r){let n=r.split("|");return a=>{let o=a===null?"null":typeof a;if(n.indexOf(o)<0)throw new RangeError(`Expected value of type ${n} for attribute ${s} on type ${t}, got ${o}`)}}class F8t{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?O8t(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class ahe{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=hQe(s,a.attrs),this.excluded=null;let o=cQe(this.attrs);this.instance=o?new ul(this,o):null}create(s=null){return!s&&this.instance?this.instance:new ul(this,dQe(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new ahe(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class pQe{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=Ju.from(s.nodes),r.marks=Ju.from(s.marks||{}),this.nodes=cLe.compile(this.spec.nodes,this),this.marks=ahe.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]=ZS.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?dLe(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==""?[]:dLe(this,l.split(" "))}this.nodeFromJSON=a=>Db.fromJSON(this,a),this.markFromJSON=a=>ul.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 cLe){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 Nle(n,n.defaultAttrs,s,ul.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 dLe(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 z8t(t){return t.tag!=null}function B8t(t){return t.style!=null}let r8=class l_e{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if(z8t(a))this.tags.push(a);else if(B8t(a)){let o=/[^=]*/.exec(a.style)[0];n.indexOf(o)<0&&n.push(o),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let o=s.nodes[a.node];return o.contentMatch.matchType(o)})}parse(s,r={}){let n=new hLe(this,r,!1);return n.addAll(s,ul.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new hLe(this,r,!0);return n.addAll(s,ul.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=mLe(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=mLe(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new l_e(s,l_e.schemaRules(s)))}};const fQe={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},$8t={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},xQe={ol:!0,ul:!0},cD=1,c_e=2,n8=4;function uLe(t,s,r){return s!=null?(s?cD:0)|(s==="full"?c_e:0):t&&t.whitespace=="pre"?cD|c_e:r&~n8}class Pz{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=ul.none,this.match=o||(l&n8?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Mr.from(s));if(r)this.match=this.type.contentMatch.matchFragment(r);else{let n=this.type.contentMatch,a;return(a=n.findWrapping(s.type))?(this.match=n,a):null}}return this.match.findWrapping(s.type)}finish(s){if(!(this.options&cD)){let n=this.content[this.content.length-1],a;if(n&&n.isText&&(a=/[ \t\r\n\u000c]+$/.exec(n.text))){let o=n;n.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-a[0].length))}}let r=Mr.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Mr.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r}inlineContext(s){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:s.parentNode&&!fQe.hasOwnProperty(s.parentNode.nodeName.toLowerCase())}}class hLe{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=uLe(null,r.preserveWhitespace,0)|(n?n8:0);a?o=new Pz(a.type,a.attrs,ul.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new Pz(null,null,ul.none,!0,null,l):o=new Pz(s.schema.topNodeType,null,ul.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&c_e?"full":this.localPreserveWS||(a.options&cD)>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):pLe(u.type,s))?(d=u.addToSet(d),!1):!0),this.nodes.push(new Pz(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|=cD)}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 q8t(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&xQe.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function U8t(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function mLe(t){let s={};for(let r in t)s[r]=t[r];return s}function pLe(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&&Zie(qge(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return Zie(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new jC(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=fLe(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return fLe(s.marks)}}function fLe(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function qge(t){return t.document||window.document}const xLe=new WeakMap;function V8t(t){let s=xLe.get(t);return s===void 0&&xLe.set(t,s=H8t(t)),s}function H8t(t){let s=null;function r(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")s||(s=[]),s.push(n);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=a.indexOf(" ");l>0&&(r=a.slice(0,l),a=a.slice(l+1));let i,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 x in u)if(u[x]!=null){let y=x.indexOf(" ");y>0?d.setAttributeNS(x.slice(0,y),x.slice(y+1),u[x]):x=="style"&&d.style?d.style.cssText=u[x]:d.setAttribute(x,u[x])}}for(let x=p;xp)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:_,contentDOM:b}=Zie(t,y,r,n);if(d.appendChild(_),b){if(i)throw new RangeError("Multiple content holes");i=b}}}return{dom:d,contentDOM:i}}const gQe=65535,yQe=Math.pow(2,16);function G8t(t,s){return t+s*yQe}function gLe(t){return t&gQe}function W8t(t){return(t-(t&gQe))/yQe}const vQe=1,_Qe=2,Yie=4,bQe=8;class d_e{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&bQe)>0}get deletedBefore(){return(this.delInfo&(vQe|Yie))>0}get deletedAfter(){return(this.delInfo&(_Qe|Yie))>0}get deletedAcross(){return(this.delInfo&Yie)>0}}class Xp{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&Xp.empty)return Xp.empty}recover(s){let r=0,n=gLe(s);if(!this.inverted)for(let a=0;as)break;let u=this.ranges[i+o],p=this.ranges[i+l],x=d+u;if(s<=x){let y=u?s==d?-1:s==x?1:r:r,_=d+a+(y<0?0:p);if(n)return _;let b=s==(r<0?d:x)?null:G8t(i/3,s-d),N=s==d?_Qe:s==x?vQe:Yie;return(r<0?s!=d:s!=x)&&(N|=bQe),new d_e(_,N,b)}a+=p-u}return n?s+a:new d_e(s+a,0,null)}touches(s,r){let n=0,a=gLe(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 dD;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 qy(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 cb(r.pos,n.pos,this.mark)}merge(s){return s instanceof cb&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new cb(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 cb(r.from,r.to,s.markFromJSON(r.mark))}}Uh.jsonID("addMark",cb);class qy extends Uh{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(oke(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 cb(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 qy(r.pos,n.pos,this.mark)}merge(s){return s instanceof qy&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new qy(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 qy(r.from,r.to,s.markFromJSON(r.mark))}}Uh.jsonID("removeMark",qy);class db extends Uh{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(Mr.from(n),0,r.isLeaf?0:1))}invert(s){let r=s.nodeAt(this.pos);if(r){let n=this.mark.addToSet(r.marks);if(n.length==r.marks.length){for(let a=0;an.pos?null:new zu(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 zu(r.from,r.to,r.gapFrom,r.gapTo,yn.fromJSON(s,r.slice),r.insert,!!r.structure)}}Uh.jsonID("replaceAround",zu);function u_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 K8t(t,s,r,n){let a=[],o=[],l,i;t.doc.nodesBetween(s,r,(d,u,p)=>{if(!d.isInline)return;let x=d.marks;if(!n.isInSet(x)&&p.type.allowsMarkType(n.type)){let y=Math.max(u,s),_=Math.min(u+d.nodeSize,r),b=n.addToSet(x);for(let N=0;Nt.step(d)),o.forEach(d=>t.step(d))}function Z8t(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 ahe){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 qy(l.from,l.to,l.style)))}function lke(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 Y8t(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function QA(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=Mr.from(n.node(b).copy(p)),x++):d--;let y=Mr.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=Mr.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new zu(a,o,a,o,new yn(n,0,0),r.length,!0))}function tDt(t,s,r,n,a){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(s,r,(l,i)=>{let d=typeof a=="function"?a(l):a;if(l.isTextblock&&!l.hasMarkup(n,d)&&sDt(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&&jQe(t,l,i,o),lke(t,t.mapping.slice(o).map(i,1),n,void 0,u===null);let p=t.mapping.slice(o),x=p.map(i,1),y=p.map(i+l.nodeSize,1);return t.step(new zu(x,y,x+1,y-1,new yn(Mr.from(n.create(d,null,l.marks)),0,0),1,!0)),u===!0&&wQe(t,l,i,o),!1}})}function wQe(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 jQe(t,s,r,n){s.forEach((a,o)=>{if(a.type==a.type.schema.linebreakReplacement){let l=t.mapping.slice(n).map(r+1+o);t.replaceWith(l,l+1,s.type.schema.text(` `))}})}function sDt(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function rDt(t,s,r,n,a){let o=t.doc.nodeAt(s);if(!o)throw new RangeError("No node at given position");r||(r=o.type);let l=r.create(n,null,a||o.marks);if(o.isLeaf)return t.replaceWith(s,s+o.nodeSize,l);if(!r.validContent(o.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new zu(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new yn(Mr.from(l),0,0),1,!0))}function GM(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 x=a.node(u),y=a.index(u);if(x.type.spec.isolating)return!1;let _=x.content.cutByIndex(y,x.childCount),b=n&&n[p+1];b&&(_=_.replaceChild(0,b.type.create(b.attrs)));let N=n&&n[p]||x;if(!x.canReplace(y+1,x.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 nDt(t,s,r=1,n){let a=t.doc.resolve(s),o=Mr.empty,l=Mr.empty;for(let i=a.depth,d=a.depth-r,u=r-1;i>d;i--,u--){o=Mr.from(a.node(i).copy(o));let p=n&&n[u];l=Mr.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 gw(t,s){let r=t.resolve(s),n=r.index();return NQe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function aDt(t,s){s.content.size||t.type.compatibleContent(s.type);let r=t.contentMatchAt(t.childCount),{linebreakReplacement:n}=t.type.schema;for(let a=0;a0?(o=n.node(a+1),i++,l=n.node(a).maybeChild(i)):(o=n.node(a).maybeChild(i-1),l=n.node(a+1)),o&&!o.isTextblock&&NQe(o,l)&&n.node(a).canReplace(i,i+1))return s;if(a==0)break;s=r<0?n.before(a):n.after(a)}}function iDt(t,s,r){let n=null,{linebreakReplacement:a}=t.doc.type.schema,o=t.doc.resolve(s-r),l=o.node().type;if(a&&l.inlineContent){let p=l.whitespace=="pre",x=!!l.contentMatch.matchType(a);p&&!x?n=!1:!p&&x&&(n=!0)}let i=t.steps.length;if(n===!1){let p=t.doc.resolve(s+r);jQe(t,p.node(),p.before(),i)}l.inlineContent&&lke(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);wQe(t,p.node(),p.before(),t.steps.length)}return t}function oDt(t,s,r){let n=t.resolve(s);if(n.parent.canReplaceWith(n.index(),n.index(),r))return s;if(n.parentOffset==0)for(let a=n.depth-1;a>=0;a--){let o=n.index(a);if(n.node(a).canReplaceWith(o,o,r))return n.before(a+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let a=n.depth-1;a>=0;a--){let o=n.indexAfter(a);if(n.node(a).canReplaceWith(o,o,r))return n.after(a+1);if(o=0;l--){let i=l==n.depth?0:n.pos<=(n.start(l+1)+n.end(l+1))/2?-1:1,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 x=u.contentMatchAt(d).findWrapping(a.firstChild.type);p=x&&u.canReplaceWith(d,d,x[0])}if(p)return i==0?n.pos:i<0?n.before(l+1):n.after(l+1)}return null}function ohe(t,s,r=s,n=yn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return SQe(a,o,n)?new Dd(s,r,n):new lDt(a,o,n).fit()}function SQe(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class lDt{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Mr.empty;for(let a=0;a<=s.depth;a++){let o=s.node(a);this.frontier.push({type:o.type,match:o.contentMatchAt(s.indexAfter(a))})}for(let a=s.depth;a>0;a--)this.placed=Mr.from(s.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let s=this.mustMoveInline(),r=this.placed.size-this.depth-this.$from.depth,n=this.$from,a=this.close(s<0?this.$to:n.doc.resolve(s));if(!a)return null;let o=this.placed,l=n.depth,i=a.depth;for(;l&&i&&o.childCount==1;)o=o.firstChild.content,l--,i--;let d=new yn(o,l,i);return s>-1?new zu(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=Vge(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,x=null;if(r==1&&(l?u.matchType(l.type)||(x=u.fillBefore(Mr.from(l),!1)):o&&d.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:i,parent:o,inject:x};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=Vge(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=Vge(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new yn(PI(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new yn(PI(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)&&(x=w,p.push(CQe(N.mark(y.allowedMarks(N.marks)),u==1?d:0,u==i.childCount?_:-1)))}let b=u==i.childCount;b||(_=-1),this.placed=II(this.placed,r,Mr.from(p)),this.frontier[r].match=x,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 k=w.lastChild;this.frontier.push({type:k.type,match:k.contentMatchAt(k.childCount)}),w=k.content}this.unplaced=b?s==0?yn.empty:new yn(PI(l.content,s-1,1),s-1,_<0?l.openEnd:s-1):new yn(PI(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||!Hge(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=Hge(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=II(this.placed,r.depth,r.fit)),s=r.move;for(let n=r.depth+1;n<=s.depth;n++){let a=s.node(n),o=a.type.contentMatch.fillBefore(a.content,!0,s.index(n));this.openFrontierNode(a.type,a.attrs,o)}return s}openFrontierNode(s,r=null,n){let a=this.frontier[this.depth];a.match=a.match.matchType(s),this.placed=II(this.placed,this.depth,Mr.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Mr.empty,!0);r.childCount&&(this.placed=II(this.placed,this.frontier.length,r))}}function PI(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(PI(t.firstChild.content,s-1,r)))}function II(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(II(t.lastChild.content,s-1,r)))}function Vge(t,s){for(let r=0;r1&&(n=n.replaceChild(0,CQe(n.firstChild,s-1,n.childCount==1?r-1:0))),s>0&&(n=t.type.contentMatch.fillBefore(n).append(n),r<=0&&(n=n.append(t.type.contentMatch.matchFragment(n).fillBefore(Mr.empty,!0)))),t.copy(n)}function Hge(t,s,r,n,a){let o=t.node(s),l=a?t.indexAfter(s):t.index(s);if(l==o.childCount&&!r.compatibleContent(o.type))return null;let i=n.fillBefore(o.content,!0,l);return i&&!cDt(r,o.content,l)?i:null}function cDt(t,s,r){for(let n=r;n0;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=dDt(_.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>x));y--){let _=l[y];_<0||(s=a.before(_),r=o.after(_))}}function MQe(t,s,r,n,a){if(sn){let o=a.contentMatchAt(0),l=o.fillBefore(t).append(t);t=l.append(o.matchFragment(l).fillBefore(Mr.empty,!0))}return t}function hDt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=oDt(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new yn(Mr.from(n),0,0))}function mDt(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=TQe(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 TQe(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 WM extends Uh{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(Mr.from(a),0,r.isLeaf?0:1))}getMap(){return Xp.empty}invert(s){return new WM(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 WM(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 WM(r.pos,r.attr,r.value)}}Uh.jsonID("attr",WM);class uD extends Uh{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 Xp.empty}invert(s){return new uD(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 uD(r.attr,r.value)}}Uh.jsonID("docAttr",uD);let OT=class extends Error{};OT=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};OT.prototype=Object.create(Error.prototype);OT.prototype.constructor=OT;OT.prototype.name="TransformError";class dke{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new dD}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new OT(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=ohe(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new yn(Mr.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 uDt(this,s,r,n),this}replaceRangeWith(s,r,n){return hDt(this,s,r,n),this}deleteRange(s,r){return mDt(this,s,r),this}lift(s,r){return X8t(this,s,r),this}join(s,r=1){return iDt(this,s,r),this}wrap(s,r){return eDt(this,s,r),this}setBlockType(s,r=s,n,a=null){return tDt(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return rDt(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new WM(s,r,n)),this}setDocAttribute(s,r){return this.step(new uD(s,r)),this}addNodeMark(s,r){return this.step(new db(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 ul)r.isInSet(n.marks)&&this.step(new YS(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new YS(s,o)),a=o.removeFromSet(a);for(let i=l.length-1;i>=0;i--)this.step(l[i])}return this}split(s,r=1,n){return nDt(this,s,r,n),this}addMark(s,r,n){return K8t(this,s,r,n),this}removeMark(s,r,n){return Z8t(this,s,r,n),this}clearIncompatible(s,r,n){return lke(this,s,r,n),this}}const Gge=Object.create(null);class Ja{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new AQe(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?P5(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):P5(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 bx(s.node(0))}static atStart(s){return P5(s,s,0,0,1)||new bx(s)}static atEnd(s){return P5(s,s,s.content.size,s.childCount,-1)||new bx(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Gge[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 Gge)throw new RangeError("Duplicate use of selection JSON ID "+s);return Gge[s]=r,r.prototype.jsonID=s,r}getBookmark(){return Ua.between(this.$anchor,this.$head).getBookmark()}}Ja.prototype.visible=!0;class AQe{constructor(s,r){this.$from=s,this.$to=r}}let vLe=!1;function _Le(t){!vLe&&!t.parent.inlineContent&&(vLe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Ua extends Ja{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 Ja.near(n);let a=s.resolve(r.map(this.anchor));return new Ua(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 Ua&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new lhe(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 Ua(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=Ja.findFrom(r,n,!0)||Ja.findFrom(r,-n,!0);if(o)r=o.$head;else return Ja.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(Ja.findFrom(s,-n,!0)||Ja.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&&Ra.isSelectable(i))return Ra.create(t,r-(a<0?i.nodeSize:0))}else{let d=P5(t,i,r+a,a<0?i.childCount:0,a,o);if(d)return d}r+=i.nodeSize*a}return null}function bLe(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=p)}),t.setSelection(Ja.near(t.doc.resolve(l),r))}const wLe=1,Iz=2,jLe=4;class fDt extends dke{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|=Iz,this}ensureMarks(s){return ul.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&Iz)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~Iz,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)||ul.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(Ja.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|=jLe,this}get scrolledIntoView(){return(this.updated&jLe)>0}}function NLe(t,s){return!s||!t?t:t.bind(s)}class LI{constructor(s,r,n){this.name=s,this.init=NLe(r.init,n),this.apply=NLe(r.apply,n)}}const xDt=[new LI("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new LI("selection",{init(t,s){return t.selection||Ja.atStart(s.doc)},apply(t){return t.selection}}),new LI("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new LI("scrollToSelection",{init(){return 0},apply(t,s){return t.scrolledIntoView?s+1:s}})];class Wge{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=xDt.slice(),r&&r.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new LI(n.key,n.spec.state,n))})}}class J5{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 Wge(s.schema,s.plugins),o=new J5(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=Db.fromJSON(s.schema,r.doc);else if(l.name=="selection")o.selection=Ja.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 EQe(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=EQe(a,s,{})),r[n]=a}return r}class yu{constructor(s){this.spec=s,this.props={},s.props&&EQe(s.props,this,this.props),this.key=s.key?s.key.key:PQe("plugin")}getState(s){return s[this.key]}}const Kge=Object.create(null);function PQe(t){return t in Kge?t+"$"+ ++Kge[t]:(Kge[t]=0,t+"$")}class Vh{constructor(s="key"){this.key=PQe(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const th=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},FT=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let h_e=null;const jv=function(t,s,r){let n=h_e||(h_e=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},gDt=function(){h_e=null},XS=function(t,s,r,n){return r&&(kLe(t,s,r,n,-1)||kLe(t,s,r,n,1))},yDt=/^(img|br|input|textarea|hr)$/i;function kLe(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:ox(t))){let l=t.parentNode;if(!l||l.nodeType!=1||HR(t)||yDt.test(t.nodeName)||t.contentEditable=="false")return!1;s=th(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?ox(t):0}else return!1}}function ox(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function vDt(t,s){for(;;){if(t.nodeType==3&&s)return t;if(t.nodeType==1&&s>0){if(t.contentEditable=="false")return null;t=t.childNodes[s-1],s=ox(t)}else if(t.parentNode&&!HR(t))s=th(t),t=t.parentNode;else return null}}function _Dt(t,s){for(;;){if(t.nodeType==3&&s2),tx=zT||(m0?/Mac/.test(m0.platform):!1),DQe=m0?/Win/.test(m0.platform):!1,Bv=/Android \d/.test(yw),GR=!!SLe&&"webkitFontSmoothing"in SLe.documentElement.style,NDt=GR?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function kDt(t){let s=t.defaultView&&t.defaultView.visualViewport;return s?{left:0,right:s.width,top:0,bottom:s.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function hv(t,s){return typeof t=="number"?t:t[s]}function SDt(t){let s=t.getBoundingClientRect(),r=s.width/t.offsetWidth||1,n=s.height/t.offsetHeight||1;return{left:s.left,right:s.left+t.clientWidth*r,top:s.top,bottom:s.top+t.clientHeight*n}}function CLe(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=FT(l);continue}let i=l,d=i==o.body,u=d?kDt(o):SDt(i),p=0,x=0;if(s.topu.bottom-hv(n,"bottom")&&(x=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||x)if(d)o.defaultView.scrollBy(p,x);else{let _=i.scrollLeft,b=i.scrollTop;x&&(i.scrollTop+=x),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:FT(l)}}function CDt(t){let s=t.dom.getBoundingClientRect(),r=Math.max(0,s.top),n,a;for(let o=(s.left+s.right)/2,l=r+1;l=r-20){n=i,a=d.top;break}}return{refDOM:n,refTop:a,stack:RQe(t.dom)}}function RQe(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=FT(n));return s}function MDt({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;OQe(r,n==0?0:n-s)}function OQe(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=x+1)}}return!r&&d&&(r=d,a=u,n=0),r&&r.nodeType==3?ADt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:FQe(r,a)}function ADt(t,s){let r=t.nodeValue.length,n=document.createRange(),a;for(let o=0;o=(l.left+l.right)/2?1:0)};break}}return n.detach(),a||{node:t,offset:0}}function hke(t,s){return t.left>=s.left-1&&t.left<=s.right+1&&t.top>=s.top-1&&t.top<=s.bottom+1}function EDt(t,s){let r=t.parentNode;return r&&/^li$/i.test(r.nodeName)&&s.left(l.left+l.right)/2?1:-1}return t.docView.posFromDOM(n,a,o)}function IDt(t,s,r,n){let a=-1;for(let o=s,l=!1;o!=t.dom;){let i=t.docView.nearestDesc(o,!0),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 zQe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let u;GR&&a&&n.nodeType==1&&(u=n.childNodes[a-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=s.top&&a--,n==t.dom&&a==n.childNodes.length-1&&n.lastChild.nodeType==1&&s.top>n.lastChild.getBoundingClientRect().bottom?i=t.state.doc.content.size:(a==0||n.nodeType!=1||n.childNodes[a-1].nodeName!="BR")&&(i=IDt(t,n,a,s))}i==null&&(i=PDt(t,l,s));let d=t.docView.nearestDesc(l,!0);return{pos:i,inside:d?d.posAtStart-d.border:-1}}function MLe(t){return t.top=0&&a==n.nodeValue.length?(d--,p=1):r<0?d--:u++,rI(S_(jv(n,d,u),p),p<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==ox(n))){let d=n.childNodes[a-1];if(d.nodeType==1)return Zge(d.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==ox(n))){let d=n.childNodes[a-1],u=d.nodeType==3?jv(d,ox(d)-(l?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(u)return rI(S_(u,1),!1)}if(o==null&&a=0)}function rI(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 Zge(t,s){if(t.height==0)return t;let r=s?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function $Qe(t,s,r){let n=t.state,a=t.root.activeElement;n!=s&&t.updateState(s),a!=t.dom&&t.focus();try{return r()}finally{n!=s&&t.updateState(n),a!=t.dom&&a&&a.focus()}}function RDt(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return $Qe(t,s,()=>{let{node:o}=t.docView.domFromPos(a.pos,r=="up"?-1:1);for(;;){let i=t.docView.nearestDesc(o,!0);if(!i)break;if(i.node.isBlock){o=i.contentDOM||i.dom;break}o=i.dom.parentNode}let l=BQe(t,a.pos,1);for(let i=o.firstChild;i;i=i.nextSibling){let 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 ODt=/[\u0590-\u08ac]/;function FDt(t,s,r){let{$head:n}=s.selection;if(!n.parent.isTextblock)return!1;let a=n.parentOffset,o=!a,l=a==n.parent.content.size,i=t.domSelection();return i?!ODt.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:$Qe(t,s,()=>{let{focusNode:d,focusOffset:u,anchorNode:p,anchorOffset:x}=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,x),d&&(d!=p||u!=x)&&i.extend&&i.extend(d,u)}catch{}return y!=null&&(i.caretBidiLevel=y),w}):n.pos==n.start()||n.pos==n.end()}let TLe=null,ALe=null,ELe=!1;function zDt(t,s,r){return TLe==s&&ALe==r?ELe:(TLe=s,ALe=r,ELe=r=="up"||r=="down"?RDt(t,s,r):FDt(t,s,r))}const jx=0,PLe=1,g4=2,p0=3;class WR{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=jx,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;rth(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 UQe){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 qQe&&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?th(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 x=i;x>0;x--){let y=this.children[x-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){a=th(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?g4:PLe,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?g4:p0}n=l}this.dirty=g4}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?g4:PLe;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==jx&&s.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(s){let r=this.widget.spec.stopEvent;return r?r(s):!1}ignoreMutation(s){return s.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class BDt extends WR{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 QS extends WR{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=jC.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new QS(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!=jx){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=g_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,x=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:x}=jC.renderSpec(document,r.type.spec.toDOM(r),null,r.attrs));!x&&!r.isText&&p.nodeName!="BR"&&(p.hasAttribute("contenteditable")||(p.contentEditable="false"),r.type.spec.draggable&&(p.draggable=!0));let y=p;return p=GQe(p,n,r),u?d=new $Dt(s,r,n,a,p,x||null,y,u,o,l+1):r.isText?new dhe(s,r,n,a,p,y,o):new Ob(s,r,n,a,p,x||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=()=>Mr.empty)}return s}matchesNode(s,r,n){return this.dirty==jx&&s.eq(this.node)&&kle(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 UDt(this,l&&l.node,s);GDt(this.node,this.innerDeco,(u,p,x)=>{u.spec.marks?d.syncToMarks(u.spec.marks,n,s,p):u.type.side>=0&&!x&&d.syncToMarks(p==this.node.childCount?ul.none:this.node.child(p).marks,n,s,p),d.placeWidget(u,s,a)},(u,p,x,y)=>{d.syncToMarks(u.marks,n,s,y);let _;d.findNodeMatch(u,p,x,y)||i&&s.state.selection.from>a&&s.state.selection.to-1&&d.updateNodeAt(u,p,x,_,s)||d.updateNextNode(u,p,x,s,y,a)||d.addNode(u,p,x,s,a),a+=u.nodeSize}),d.syncToMarks([],n,s,0),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.dirty==g4)&&(l&&this.protectLocalComposition(s,l),VQe(this.contentDOM,this.children,s),zT&&WDt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof Ua)||nr+this.node.content.size)return null;let o=s.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let l=o.nodeValue,i=KDt(this.node.content,l,n-r,a-r);return i<0?null:{node:o,pos:i,text:l}}else return{node:o,pos:-1,text:""}}protectLocalComposition(s,{node:r,pos:n,text:a}){if(this.getDesc(r))return;let o=r;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let l=new BDt(this,o,r,a);s.input.compositionNodes.push(l),this.children=g_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=jx}updateOuterDeco(s){if(kle(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=HQe(this.dom,this.nodeDOM,x_e(this.outerDeco,this.node,r),x_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 ILe(t,s,r,n,a){GQe(n,s,t);let o=new Ob(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class dhe extends Ob{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!=jx&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=jx||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=jx,!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 dhe(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 UQe extends WR{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==jx&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class $Dt extends Ob{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 VQe(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=QS.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 QS)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 HDt(t,s){return t.type.side-s.type.side}function GDt(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 WDt(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let s=t.style.cssText;t.style.cssText=s+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=s}}function KDt(t,s,r,n){for(let a=0,o=0;a=r){if(o>=n&&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 g_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 mke(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(che(r)){for(d=l;a&&!a.node;)a=a.parent;let x=a.node;if(a&&x.isAtom&&Ra.isSelectable(x)&&a.parent&&!(x.isInline&&bDt(r.focusNode,r.focusOffset,a.dom))){let y=a.posBefore;u=new Ra(l==y?i:n.resolve(y))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let x=l,y=l;for(let _=0;_{(r.anchorNode!=n||r.anchorOffset!=a)&&(s.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!WQe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function YDt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,th(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&yp&&Rb<=11&&(r.disabled=!0,r.disabled=!1)}function KQe(t,s){if(s instanceof Ra){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&(FLe(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else FLe(t)}function FLe(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function pke(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||Ua.between(s,r,n)}function zLe(t){return t.editable&&!t.hasFocus()?!1:ZQe(t)}function ZQe(t){let s=t.domSelectionRange();if(!s.anchorNode)return!1;try{return t.dom.contains(s.anchorNode.nodeType==3?s.anchorNode.parentNode:s.anchorNode)&&(t.editable||t.dom.contains(s.focusNode.nodeType==3?s.focusNode.parentNode:s.focusNode))}catch{return!1}}function XDt(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return XS(s.node,s.offset,r.anchorNode,r.anchorOffset)}function y_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&&Ja.findFrom(o,s)}function I_(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function BLe(t,s,r){let n=t.state.selection;if(n instanceof Ua)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 I_(t,new Ua(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=y_e(t.state,s);return a&&a instanceof Ra?I_(t,a):!1}else if(!(tx&&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?Ra.isSelectable(o)?I_(t,new Ra(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):GR?I_(t,new Ua(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof Ra&&n.node.isInline)return I_(t,new Ua(s>0?n.$to:n.$from));{let a=y_e(t.state,s);return a?I_(t,a):!1}}}function Sle(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function i8(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function f5(t,s){return s<0?QDt(t):JDt(t)}function QDt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(wx&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(i8(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(YQe(r))break;{let i=r.previousSibling;for(;i&&i8(i,-1);)a=r.parentNode,o=th(i),i=i.previousSibling;if(i)r=i,n=Sle(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?v_e(t,r,n):a&&v_e(t,a,o)}function JDt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=Sle(r),o,l;for(;;)if(n{t.state==a&&t1(t)},50)}function $Le(t,s){let r=t.state.doc.resolve(s);if(!(nh||DQe)&&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 qLe(t,s,r){let n=t.state.selection;if(n instanceof Ua&&!n.empty||r.indexOf("s")>-1||tx&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=y_e(t.state,s);if(l&&l instanceof Ra)return I_(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof bx?Ja.near(l,s):Ja.findFrom(l,s);return i?I_(t,i):!1}return!1}function ULe(t,s){if(!(t.state.selection instanceof Ua))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 VLe(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function sRt(t){if(!Bh||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;VLe(t,n,"true"),setTimeout(()=>VLe(t,n,"false"),20)}return!1}function rRt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function nRt(t,s){let r=s.keyCode,n=rRt(s);if(r==8||tx&&r==72&&n=="c")return ULe(t,-1)||f5(t,-1);if(r==46&&!s.shiftKey||tx&&r==68&&n=="c")return ULe(t,1)||f5(t,1);if(r==13||r==27)return!0;if(r==37||tx&&r==66&&n=="c"){let a=r==37?$Le(t,t.state.selection.from)=="ltr"?-1:1:-1;return BLe(t,a,n)||f5(t,a)}else if(r==39||tx&&r==70&&n=="c"){let a=r==39?$Le(t,t.state.selection.from)=="ltr"?1:-1:1;return BLe(t,a,n)||f5(t,a)}else{if(r==38||tx&&r==80&&n=="c")return qLe(t,-1,n)||f5(t,-1);if(r==40||tx&&r==78&&n=="c")return sRt(t)||qLe(t,1,n)||f5(t,1);if(n==(tx?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function fke(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")||jC.fromSchema(t.state.schema),i=sJe(),d=i.createElement("div");d.appendChild(l.serializeFragment(n,{document:i}));let u=d.firstChild,p,x=0;for(;u&&u.nodeType==1&&(p=tJe[u.nodeName.toLowerCase()]);){for(let _=p.length-1;_>=0;_--){let b=i.createElement(p[_]);for(;d.firstChild;)b.appendChild(d.firstChild);d.appendChild(b),x++}u=d.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${a} ${o}${x?` -${x}`:""} ${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 XQe(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(Mr.from(t.state.schema.text(s.replace(/\r\n?/g,` `))),0,0),t.someProp("transformPasted",y=>{i=y(i,t,!0)}),i;let x=t.someProp("clipboardTextParser",y=>y(s,a,n,t));if(x)i=x;else{let y=a.marks(),{schema:_}=t.state,b=jC.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",x=>{r=x(r,t)}),l=lRt(r),GR&&cRt(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 x=+p[3];x>0;x--){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")||r8.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(d||p),context:a,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!aRt.test(y.parentNode.nodeName)?{ignore:!0}:null}})),p)i=dRt(HLe(i,+p[1],+p[2]),p[4]);else if(i=yn.maxOpen(iRt(i.content,a),!0),i.openStart||i.openEnd){let x=0,y=0;for(let _=i.content.firstChild;x{i=x(i,t,d)}),i}const aRt=/^(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 iRt(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&&JQe(d,o,i,l[l.length-1],0))l[l.length-1]=u;else{l.length&&(l[l.length-1]=eJe(l[l.length-1],o.length));let p=QQe(i,d);l.push(p),a=a.matchType(p.type),o=d}}),l)return Mr.from(l)}return t}function QQe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Mr.from(t));return t}function JQe(t,s,r,n,a){if(a1&&(o=0),a=r&&(i=s<0?l.contentMatchAt(0).fillBefore(i,o<=a).append(i):i.append(l.contentMatchAt(l.childCount).fillBefore(Mr.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function HLe(t,s,r){return sr})),Xge.createHTML(t)):t}function lRt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=sJe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&tJe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=oRt(t),a)for(let o=0;o=0;i-=2){let d=r.nodes[n[i]];if(!d||d.hasRequiredAttrs())break;a=Mr.from(d.create(n[i+1],a)),o++,l++}return new yn(a,o,l)}const Pm={},Im={},uRt={touchstart:!0,touchmove:!0};class hRt{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 mRt(t){for(let s in Pm){let r=Pm[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{fRt(t,n)&&!xke(t,n)&&(t.editable||!(n.type in Im))&&r(t,n)},uRt[s]?{passive:!0}:void 0)}Bh&&t.dom.addEventListener("input",()=>null),b_e(t)}function ub(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function pRt(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 b_e(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>xke(t,n))})}function xke(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function fRt(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 xRt(t,s){!xke(t,s)&&Pm[s.type]&&(t.editable||!(s.type in Im))&&Pm[s.type](t,s)}Im.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!nJe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Bv&&nh&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),zT&&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,i4(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||nRt(t,r)?r.preventDefault():ub(t,"key")};Im.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};Im.keypress=(t,s)=>{let r=s;if(nJe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||tx&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof Ua)||!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 uhe(t){return{left:t.clientX,top:t.clientY}}function gRt(t,s){let r=s.x-t.clientX,n=s.y-t.clientY;return r*r+n*n<100}function gke(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 KM(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 yRt(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&Ra.isSelectable(n)?(KM(t,new Ra(r)),!0):!1}function vRt(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof Ra&&(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(Ra.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?(KM(t,Ra.create(t.state.doc,a)),!0):!1}function _Rt(t,s,r,n,a){return gke(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?vRt(t,r):yRt(t,r))}function bRt(t,s,r,n){return gke(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function wRt(t,s,r,n){return gke(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||jRt(t,r,n)}function jRt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(KM(t,Ua.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)KM(t,Ua.create(n,i+1,i+1+l.content.size));else if(Ra.isSelectable(l))KM(t,Ra.create(n,i));else continue;return!0}}function yke(t){return Cle(t)}const rJe=tx?"metaKey":"ctrlKey";Pm.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=yke(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&gRt(r,t.input.lastClick)&&!r[rJe]&&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(uhe(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new NRt(t,l,r,!!n)):(o=="doubleClick"?bRt:wRt)(t,l.pos,l.inside,r)?r.preventDefault():ub(t,"pointer"))};class NRt{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[rJe],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 Ra&&u.from<=l&&u.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&wx&&!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)),ub(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(()=>t1(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(uhe(s))),this.updateAllowDefault(s),this.allowDefault||!r?ub(this.view,"pointer"):_Rt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||Bh&&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)?(KM(this.view,Ja.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):ub(this.view,"pointer")}move(s){this.updateAllowDefault(s),ub(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)}}Pm.touchstart=t=>{t.input.lastTouch=Date.now(),yke(t),ub(t,"pointer")};Pm.touchmove=t=>{t.input.lastTouch=Date.now(),ub(t,"pointer")};Pm.contextmenu=t=>yke(t);function nJe(t,s){return t.composing?!0:Bh&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const kRt=Bv?5e3:-1;Im.compositionstart=Im.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof Ua&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||nh&&DQe&&SRt(t)))t.markCursor=t.state.storedMarks||r.marks(),Cle(t,!0),t.markCursor=null;else if(Cle(t,!s.selection.empty),wx&&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}aJe(t,kRt)};function SRt(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"}Im.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++,aJe(t,20))};function aJe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>Cle(t),s))}function iJe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=MRt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function CRt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=vDt(s.focusNode,s.focusOffset),n=_Dt(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 MRt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Cle(t,s=!1){if(!(Bv&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),iJe(t),s||t.docView&&t.docView.dirty){let r=mke(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 TRt(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 hD=yp&&Rb<15||zT&&NDt<604;Pm.copy=Im.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=hD?null:r.clipboardData,l=n.content(),{dom:i,text:d}=fke(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",d)):TRt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ARt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function ERt(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?mD(t,n.value,null,a,s):mD(t,n.textContent,n.innerHTML,a,s)},50)}function mD(t,s,r,n,a){let o=XQe(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=ARt(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 oJe(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," "):""}Im.paste=(t,s)=>{let r=s;if(t.composing&&!Bv)return;let n=hD?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&mD(t,oJe(n),n.getData("text/html"),a,r)?r.preventDefault():ERt(t,r)};class lJe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const PRt=tx?"altKey":"ctrlKey";function cJe(t,s){let r;return t.someProp("dragCopies",n=>{r=r||n(s)}),r!=null?!r:!s[PRt]}Pm.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(uhe(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof Ra?a.to-1:a.to))){if(n&&n.mightDrag)l=Ra.create(t.state.doc,n.mightDrag.pos);else if(r.target&&r.target.nodeType==1){let x=t.docView.nearestDesc(r.target,!0);x&&x.node.type.spec.draggable&&x!=t.docView&&(l=Ra.create(t.state.doc,x.posBefore))}}let i=(l||t.state.selection).content(),{dom:d,text:u,slice:p}=fke(t,i);(!r.dataTransfer.files.length||!nh||LQe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(hD?"Text":"text/html",d.innerHTML),r.dataTransfer.effectAllowed="copyMove",hD||r.dataTransfer.setData("text/plain",u),t.dragging=new lJe(p,cJe(t,r),l)};Pm.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};Im.dragover=Im.dragenter=(t,s)=>s.preventDefault();Im.drop=(t,s)=>{try{IRt(t,s,t.dragging)}finally{t.dragging=null}};function IRt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(uhe(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=XQe(t,oJe(s.dataTransfer),hD?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&cJe(t,s));if(t.someProp("handleDrop",_=>_(t,s,o||yn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?kQe(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,x=d.doc;if(p?d.replaceRangeWith(u,u,o.content.firstChild):d.replaceRange(u,u,o),d.doc.eq(x))return;let y=d.doc.resolve(u);if(p&&Ra.isSelectable(o.content.firstChild)&&y.nodeAfter&&y.nodeAfter.sameMarkup(o.content.firstChild))d.setSelection(new Ra(y));else{let _=d.mapping.map(i);d.mapping.maps[d.mapping.maps.length-1].forEach((b,N,w,k)=>_=k),d.setSelection(pke(t,y,d.doc.resolve(_)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}Pm.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())&&t1(t)},20))};Pm.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)};Pm.beforeinput=(t,s)=>{if(nh&&Bv&&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,i4(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 Im)Pm[t]=Im[t];function pD(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 Mle{constructor(s,r){this.toDOM=s,this.spec=r||NS,this.side=this.spec.side||0}map(s,r,n,a){let{pos:o,deleted:l}=s.mapResult(r.from+a,this.side<0?-1:1);return l?null:new bm(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof Mle&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&pD(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class Fb{constructor(s,r){this.attrs=s,this.spec=r||NS}map(s,r,n,a){let o=s.map(r.from+a,this.spec.inclusiveStart?-1:1)-n,l=s.map(r.to+a,this.spec.inclusiveEnd?1:-1)-n;return o>=l?null:new bm(o,l,this)}valid(s,r){return r.from=s&&(!o||o(i.spec))&&n.push(i.copy(i.from+a,i.to+a))}for(let l=0;ls){let i=this.children[l]+1;this.children[l+2].findInner(s-i,r-i,n,a+i,o)}}map(s,r,n){return this==Sh||s.maps.length==0?this:this.mapInner(s,r,0,0,n||NS)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let u=d+n,p;if(p=uJe(r,i,u)){for(a||(a=this.children.slice());oi&&x.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 Fb){let u=Math.max(o,d.from)-o,p=Math.min(l,d.to)-o;ua.map(s,r,NS));return U_.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 k=0;kC+p-x)continue;let E=i[k]+p-x;_>=E?i[k+1]=y<=E?-2:-1:y>=p&&w&&(i[k]+=w,i[k+1]+=w)}x+=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(x),w=n.maybeChild(b);if(w&&N==x&&N+w.nodeSize==_){let k=i[u+2].mapInner(r,w,p+1,t[u]+o+1,l);k!=Sh?(i[u]=x,i[u+1]=_,i[u+2]=k):(i[u+1]=-2,d=!0)}else d=!0}if(d){let u=DRt(i,t,s,r,a,o,l),p=Tle(u,n,0,l);s=p.local;for(let x=0;xr&&l.to{let u=uJe(t,i,d+r);if(u){o=!0;let p=Tle(u,i,r+d+1,n);p!=Sh&&a.push(d,d+i.nodeSize,p)}});let l=dJe(o?hJe(t):t,-r).sort(kS);for(let i=0;i0;)s++;t.splice(s,0,r)}function Qge(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])),U_.from(s)}const RRt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ORt=yp&&Rb<=11;class FRt{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 zRt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new FRt,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():Bh&&s.composing&&n.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(s.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),ORt&&(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,RRt)),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(zLe(this.view)){if(this.suppressingSelectionUpdates)return t1(this.view);if(yp&&Rb<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&XS(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=FT(o))r.add(o);for(let o=s.anchorNode;o;o=FT(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)&&zLe(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 x=p.nextSibling;for(;x&&x.nodeType==1;){if(x.contentEditable=="false"){p.parentNode.removeChild(p);break}x=x.firstChild}}}else if(wx&&d.length){let p=d.filter(x=>x.nodeName=="BR");if(p.length==2){let[x,y]=p;x.parentNode&&x.parentNode.parentNode==y.parentNode?y.remove():x.remove()}else{let{focusNode:x}=this.currentSelection;for(let y of p){let _=y.parentNode;_&&_.nodeName=="LI"&&(!x||qRt(s,x)!=_)&&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),BRt(s)),s.input.badSafariComposition&&(s.input.badSafariComposition=!1,URt(s,d)),this.handleDOMChange(o,l,i,d),s.docView&&s.docView.dirty?s.updateState(s.state):this.currentSelection.eq(n)||t1(s),this.currentSelection.set(n))}registerMutation(s,r){if(r.indexOf(s.target)>-1)return null;let n=this.view.docView.nearestDesc(s.target);if(s.type=="attributes"&&(n==this.view.docView||s.attributeName=="contenteditable"||s.attributeName=="style"&&!s.oldValue&&!s.target.getAttribute("style"))||!n||n.ignoreMutation(s))return null;if(s.type=="childList"){for(let p=0;pa;w--){let k=n.childNodes[w-1],C=k.pmViewDesc;if(k.nodeName=="BR"&&!C){o=w;break}if(!C||C.size)break}let x=t.state.doc,y=t.someProp("domParser")||r8.fromSchema(t.state.schema),_=x.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:HRt,context:_});if(u&&u[0].pos!=null){let w=u[0].pos,k=u[1]&&u[1].pos;k==null&&(k=w),b={anchor:w+l,head:k+l}}return{doc:N,sel:b,from:l,to:i}}function HRt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Bh&&/^(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||Bh&&/^(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 GRt=/^(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 WRt(t,s,r,n,a){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,s<0){let V=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,q=mke(t,V);if(q&&!t.state.selection.eq(q)){if(nh&&Bv&&t.input.lastKeyCode===13&&Date.now()-100U(t,i4(13,"Enter"))))return;let $=t.state.tr.setSelection(q);V=="pointer"?$.setMeta("pointer",!0):V=="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=VRt(t,s,r),p=t.state.doc,x=p.slice(u.from,u.to),y,_;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Bv)&&a.some(V=>V.nodeType==1&&!GRt.test(V.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",V=>V(t,i4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(n&&d instanceof Ua&&!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 V=XLe(t,t.state.doc,u.sel);if(V&&!V.eq(t.state.selection)){let q=t.state.tr.setSelection(V);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)),yp&&Rb<=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),k=p.resolve(b.start),C=N.sameParent(w)&&N.parent.inlineContent&&k.end()>=b.endA;if((zT&&t.input.lastIOSEnter>Date.now()-225&&(!C||a.some(V=>V.nodeName=="DIV"||V.nodeName=="P"))||!C&&N.posV(t,i4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&ZRt(p,b.start,b.endA,N,w)&&t.someProp("handleKeyDown",V=>V(t,i4(8,"Backspace")))){Bv&&nh&&t.domObserver.suppressSelectionUpdates();return}nh&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),Bv&&!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(V){return V(t,i4(13,"Enter"))})},20));let E=b.start,L=b.endA,I=V=>{let q=V||t.state.tr.replace(E,L,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let $=XLe(t,q.doc,u.sel);$&&!(nh&&t.composing&&$.empty&&(b.start!=b.endB||t.input.lastChromeDeletet1(t),20));let V=I(t.state.tr.delete(E,L)),q=p.resolve(b.start).marksAcross(p.resolve(b.endA));q&&V.ensureMarks(q),t.dispatch(V)}else if(b.endA==b.endB&&(O=KRt(N.parent.content.cut(N.parentOffset,w.parentOffset),k.parent.content.cut(k.parentOffset,b.endA-k.start())))){let V=I(t.state.tr);O.type=="add"?V.addMark(E,L,O.mark):V.removeMark(E,L,O.mark),t.dispatch(V)}else if(N.parent.child(N.index()).isText&&N.index()==w.index()-(w.textOffset?0:1)){let V=N.parent.textBetween(N.parentOffset,w.parentOffset),q=()=>I(t.state.tr.insertText(V,E,L));t.someProp("handleTextInput",$=>$(t,E,L,V,q))||t.dispatch(q())}else t.dispatch(I());else t.dispatch(I())}function XLe(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:pke(t,s.resolve(r.anchor),s.resolve(r.head))}function KRt(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||Jge(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 YRt(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 mJe{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 hRt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(r8e),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=t8e(this),e8e(this),this.nodeViews=s8e(this),this.docView=ILe(this.state.doc,JLe(this),Qge(this),this.dom,this),this.domObserver=new zRt(this,(n,a,o,l)=>WRt(this,n,a,o,l)),this.domObserver.start(),mRt(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&&b_e(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach(r8e),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&&(iJe(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 _=s8e(this);QRt(_,this.nodeViews)&&(this.nodeViews=_,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&b_e(this),this.editable=t8e(this),e8e(this);let d=Qge(this),u=JLe(this),p=a.plugins!=s.plugins&&!a.doc.eq(s.doc)?"reset":s.scrollToSelection>a.scrollToSelection?"to selection":"preserve",x=o||!this.docView.matchesNode(s.doc,u,d);(x||!s.selection.eq(a.selection))&&(l=!0);let y=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&CDt(this);if(l){this.domObserver.stop();let _=x&&(yp||nh)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&XRt(a.selection,s.selection);if(x){let b=nh?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=CRt(this)),(o||!this.docView.update(s.doc,u,d,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=ILe(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())&&XDt(this))?t1(this,_):(KQe(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&&MDt(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 Ra){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&CLe(this,r.getBoundingClientRect(),s)}else CLe(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 LDt(this,s)}coordsAtPos(s,r=1){return BQe(this,s,r)}domAtPos(s,r=0){return this.docView.domFromPos(s,r)}nodeDOM(s){let r=this.docView.descAt(s);return r?r.nodeDOM:null}posAtDOM(s,r,n=-1){let a=this.docView.posFromDOM(s,r,n);if(a==null)throw new RangeError("DOM position not inside the editor");return a}endOfTextblock(s,r){return zDt(this,r||this.state,s)}pasteHTML(s,r){return mD(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return mD(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return fke(this,s)}destroy(){this.docView&&(pRt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Qge(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,gDt())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return xRt(this,s)}domSelectionRange(){let s=this.domSelection();return s?Bh&&this.root.nodeType===11&&wDt(this.dom.ownerDocument)==this.dom&&$Rt(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}mJe.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function JLe(t){let s=Object.create(null);return s.class="ProseMirror",s.contenteditable=String(t.editable),t.someProp("attributes",r=>{if(typeof r=="function"&&(r=r(t.state)),r)for(let n in r)n=="class"?s.class+=" "+r[n]:n=="style"?s.style=(s.style?s.style+";":"")+r[n]:!s[n]&&n!="contenteditable"&&n!="nodeName"&&(s[n]=String(r[n]))}),s.translate||(s.translate="no"),[bm.node(0,t.state.doc.content.size,s)]}function e8e(t){if(t.markCursor){let s=document.createElement("img");s.className="ProseMirror-separator",s.setAttribute("mark-placeholder","true"),s.setAttribute("alt",""),t.cursorWrapper={dom:s,deco:bm.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function t8e(t){return!t.someProp("editable",s=>s(t.state)===!1)}function XRt(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 s8e(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 QRt(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 r8e(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 sw={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ale={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},JRt=typeof navigator<"u"&&/Mac/.test(navigator.platform),eOt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var sh=0;sh<10;sh++)sw[48+sh]=sw[96+sh]=String(sh);for(var sh=1;sh<=24;sh++)sw[sh+111]="F"+sh;for(var sh=65;sh<=90;sh++)sw[sh]=String.fromCharCode(sh+32),Ale[sh]=String.fromCharCode(sh);for(var eye in sw)Ale.hasOwnProperty(eye)||(Ale[eye]=sw[eye]);function tOt(t){var s=JRt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||eOt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?Ale:sw)[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 sOt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),rOt=typeof navigator<"u"&&/Win/.test(navigator.platform);function nOt(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 pJe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const lOt=(t,s,r)=>{let n=pJe(t,r);if(!n)return!1;let a=wke(n);if(!a){let l=n.blockRange(),i=l&&QA(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(yJe(t,a,s,-1))return!0;if(n.parent.content.size==0&&(BT(o,"end")||Ra.isSelectable(o)))for(let l=n.depth;;l--){let i=ohe(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},cOt=(t,s,r)=>{let n=pJe(t,r);if(!n)return!1;let a=wke(n);return a?fJe(t,a,s):!1},dOt=(t,s,r)=>{let n=xJe(t,r);if(!n)return!1;let a=jke(n);return a?fJe(t,a,s):!1};function fJe(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=ohe(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(Ua.create(p.doc,o)),r(p.scrollIntoView())}return!0}function BT(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 uOt=(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=wke(n)}let l=o&&o.nodeBefore;return!l||!Ra.isSelectable(l)?!1:(s&&s(t.tr.setSelection(Ra.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function wke(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 xJe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=xJe(t,r);if(!n)return!1;let a=jke(n);if(!a)return!1;let o=a.nodeAfter;if(yJe(t,a,s,1))return!0;if(n.parent.content.size==0&&(BT(o,"start")||Ra.isSelectable(o))){let l=ohe(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 Ra,a;if(n){if(r.node.isTextblock||!gw(t.doc,r.from))return!1;a=r.from}else if(a=ihe(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(Ra.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},fOt=(t,s)=>{let r=t.selection,n;if(r instanceof Ra){if(r.node.isTextblock||!gw(t.doc,r.to))return!1;n=r.to}else if(n=ihe(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},xOt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&QA(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},gOt=(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 gJe(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=gJe(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(Ja.near(d.doc.resolve(i),1)),s(d.scrollIntoView())}return!0},vOt=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof bx||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=gJe(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(GM(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&QA(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)},bOt=(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(Ra.create(t.doc,a))),!0)};function wOt(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||gw(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function yJe(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,d=a.type.spec.isolating||o.type.spec.isolating;if(!d&&wOt(t,s,r))return!0;let u=!d&&s.parent.canReplace(s.index(),s.index()+1);if(u&&(l=(i=a.contentMatchAt(a.childCount)).findWrapping(o.type))&&i.matchType(l[0]||o.type).validEnd){if(r){let _=s.pos+o.nodeSize,b=Mr.empty;for(let k=l.length-1;k>=0;k--)b=Mr.from(l[k].create(null,b));b=Mr.from(a.copy(b));let N=t.tr.step(new zu(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&&gw(N.doc,w.pos)&&N.join(w.pos),r(N.scrollIntoView())}return!0}let p=o.type.spec.isolating||n>0&&d?null:Ja.findFrom(s,1),x=p&&p.$from.blockRange(p.$to),y=x&&QA(x);if(y!=null&&y>=s.depth)return r&&r(t.tr.lift(x,y).scrollIntoView()),!0;if(u&&BT(o,"start",!0)&&BT(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 k=Mr.empty;for(let E=b.length-1;E>=0;E--)k=Mr.from(b[E].copy(k));let C=t.tr.step(new zu(s.pos-b.length,s.pos+o.nodeSize,s.pos+w,s.pos+o.nodeSize-w,new yn(k,b.length,0),0,!0));r(C.scrollIntoView())}return!0}}return!1}function vJe(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(Ua.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const jOt=vJe(-1),NOt=vJe(1);function kOt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&cke(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function n8e(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),x=p.index();a=p.parent.canReplaceWith(x,x+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 jle(d,d,s.depth),s.endIndex=0;p--)o=Mr.from(r[p].type.create(r[p].attrs,o));t.step(new zu(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?AOt(s,r,t,o):EOt(s,r,o):!0:!1}}function AOt(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?Mr.empty:Mr.from(a))))return!1;let x=o.pos,y=x+l.nodeSize;return n.step(new zu(x-(i?1:0),y+(d?1:0),x+1,y-1,new yn((i?Mr.empty:Mr.from(a.copy(Mr.empty))).append(d?Mr.empty:Mr.from(a.copy(Mr.empty))),i?0:1,d?0:1),i?0:1)),s(n.scrollIntoView()),!0}function POt(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=Mr.from(u?t.create():null),x=new yn(Mr.from(t.create(null,Mr.from(i.type.create(null,p)))),u?3:1,0),y=o.start,_=o.end;r(s.tr.step(new zu(y-(u?3:1),_,y,_,x,1,!0)).scrollIntoView())}return!0}}function hhe(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 mhe{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 x=d(...p)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(o),x}]))}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)),x={...Object.fromEntries(Object.entries(n).map(([y,_])=>[y,(...N)=>{const w=this.buildProps(u,r),k=_(...N)(w);return i.push(k),x}])),run:p};return x}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:hhe({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 IOt=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 phe(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 _Je(t){const s=[],{nodeExtensions:r,markExtensions:n}=phe(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(x=>{Object.entries(p.attributes).forEach(([y,_])=>{s.push({type:x,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,x])=>{const y={...o,...x};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 qu(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 jc(...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[x,y]=p.split(":").map(_=>_.trim());u.set(x,y)}),i.forEach(p=>{const[x,y]=p.split(":").map(_=>_.trim());u.set(x,y)}),n[a]=Array.from(u.entries()).map(([p,x])=>`${p}: ${x}`).join("; ")}else n[a]=o}),n},{})}function w_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)=>jc(r,n),{})}function bJe(t){return typeof t=="function"}function Li(t,s=void 0,...r){return bJe(t)?s?t.bind(s)(...r):t(...r):t}function LOt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function DOt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function a8e(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):DOt(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function i8e(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&LOt(r)?!1:r!=null))}function ROt(t,s){var r;const n=_Je(t),{nodeExtensions:a,markExtensions:o}=phe(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(k=>k.type===u.name),x={name:u.name,options:u.options,storage:u.storage,editor:s},y=t.reduce((k,C)=>{const E=na(C,"extendNodeSchema",x);return{...k,...E?E(u):{}}},{}),_=i8e({...y,content:Li(na(u,"content",x)),marks:Li(na(u,"marks",x)),group:Li(na(u,"group",x)),inline:Li(na(u,"inline",x)),atom:Li(na(u,"atom",x)),selectable:Li(na(u,"selectable",x)),draggable:Li(na(u,"draggable",x)),code:Li(na(u,"code",x)),whitespace:Li(na(u,"whitespace",x)),linebreakReplacement:Li(na(u,"linebreakReplacement",x)),defining:Li(na(u,"defining",x)),isolating:Li(na(u,"isolating",x)),attrs:Object.fromEntries(p.map(k=>{var C;return[k.name,{default:(C=k==null?void 0:k.attribute)===null||C===void 0?void 0:C.default}]}))}),b=Li(na(u,"parseHTML",x));b&&(_.parseDOM=b.map(k=>a8e(k,p)));const N=na(u,"renderHTML",x);N&&(_.toDOM=k=>N({node:k,HTMLAttributes:w_e(k,p)}));const w=na(u,"renderText",x);return w&&(_.toText=w),[u.name,_]})),d=Object.fromEntries(o.map(u=>{const p=n.filter(w=>w.type===u.name),x={name:u.name,options:u.options,storage:u.storage,editor:s},y=t.reduce((w,k)=>{const C=na(k,"extendMarkSchema",x);return{...w,...C?C(u):{}}},{}),_=i8e({...y,inclusive:Li(na(u,"inclusive",x)),excludes:Li(na(u,"excludes",x)),group:Li(na(u,"group",x)),spanning:Li(na(u,"spanning",x)),code:Li(na(u,"code",x)),attrs:Object.fromEntries(p.map(w=>{var k;return[w.name,{default:(k=w==null?void 0:w.attribute)===null||k===void 0?void 0:k.default}]}))}),b=Li(na(u,"parseHTML",x));b&&(_.parseDOM=b.map(w=>a8e(w,p)));const N=na(u,"renderHTML",x);return N&&(_.toDOM=w=>N({mark:w,HTMLAttributes:w_e(w,p)})),[u.name,_]}));return new pQe({topNode:l,nodes:i,marks:d})}function sye(t,s){return s.nodes[t]||s.marks[t]||null}function o8e(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function Nke(t,s){const r=jC.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const OOt=(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 kke(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class fhe{constructor(s){this.find=s.find,this.handler=s.handler}}const FOt=(t,s)=>{if(kke(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 Lz(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 x=OOt(u)+o;return l.forEach(y=>{if(p)return;const _=FOt(x,y.find);if(!_)return;const b=d.state.tr,N=hhe({state:d.state,transaction:b}),w={from:n-(_[0].length-o.length),to:a},{commands:k,chain:C,can:E}=new mhe({editor:r,state:N});y.handler({state:N,range:w,match:_,commands:k,chain:C,can:E})===null||!b.steps.length||(b.setMeta(i,{transform:b,from:n,to:a,text:o}),d.dispatch(b),p=!0)}),p}function zOt(t){const{editor:s,rules:r}=t,n=new yu({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=Nke(Mr.from(p),l.schema);const{from:x}=d,y=x+p.length;Lz({editor:s,from:x,to:y,text:p,rules:r,plugin:n})}),a.selectionSet||a.docChanged?null:o}},props:{handleTextInput(a,o,l,i){return Lz({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&Lz({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?Lz({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function BOt(t){return Object.prototype.toString.call(t).slice(8,-1)}function Dz(t){return BOt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function xhe(t,s){const r={...t};return Dz(t)&&Dz(s)&&Object.keys(s).forEach(n=>{Dz(s[n])&&Dz(t[n])?r[n]=xhe(t[n],s[n]):r[n]=s[n]}),r}class $g{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 $g(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>xhe(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new $g(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 $Ot(t){return typeof t=="number"}class qOt{constructor(s){this.find=s.find,this.handler=s.handler}}const UOt=(t,s,r)=>{if(kke(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 VOt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:d,chain:u,can:p}=new mhe({editor:s,state:r}),x=[];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),k=_.textBetween(N-b,w-b,void 0,"");UOt(k,o.find,l).forEach(E=>{if(E.index===void 0)return;const L=N+E.index+1,I=L+E[0].length,O={from:r.tr.mapping.map(L),to:r.tr.mapping.map(I)},V=o.handler({state:r,range:O,match:E,commands:d,chain:u,can:p,pasteEvent:l,dropEvent:i});x.push(V)})}),x.every(_=>_!==null)}let Rz=null;const HOt=t=>{var s;const r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(s=r.clipboardData)===null||s===void 0||s.setData("text/html",t),r};function GOt(t){const{editor:s,rules:r}=t;let n=null,a=!1,o=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,i;try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}const d=({state:p,from:x,to:y,rule:_,pasteEvt:b})=>{const N=p.tr,w=hhe({state:p,transaction:N});if(!(!VOt({editor:s,state:w,from:Math.max(x-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 yu({view(x){const y=b=>{var N;n=!((N=x.dom.parentElement)===null||N===void 0)&&N.contains(b.target)?x.dom.parentElement:null,n&&(Rz=s)},_=()=>{Rz&&(Rz=null)};return window.addEventListener("dragstart",y),window.addEventListener("dragend",_),{destroy(){window.removeEventListener("dragstart",y),window.removeEventListener("dragend",_)}}},props:{handleDOMEvents:{drop:(x,y)=>{if(o=n===x.dom.parentElement,i=y,!o){const _=Rz;_!=null&&_.isEditable&&setTimeout(()=>{const b=_.state.selection;b&&_.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(x,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:(x,y,_)=>{const b=x[0],N=b.getMeta("uiEvent")==="paste"&&!a,w=b.getMeta("uiEvent")==="drop"&&!o,k=b.getMeta("applyPasteRules"),C=!!k;if(!N&&!w&&!C)return;if(C){let{text:I}=k;typeof I=="string"?I=I:I=Nke(Mr.from(I),_.schema);const{from:O}=k,V=O+I.length,q=HOt(I);return d({rule:p,state:_,from:O,to:{b:V},pasteEvt:q})}const E=y.doc.content.findDiffStart(_.doc.content),L=y.doc.content.findDiffEnd(_.doc.content);if(!(!$Ot(E)||!L||E===L.b))return d({rule:p,state:_,from:E,to:L,pasteEvt:l})}}))}function WOt(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class eM{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=eM.resolve(s),this.schema=ROt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=eM.sort(eM.flatten(s)),n=WOt(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:sye(r.name,this.schema)},a=na(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=eM.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:sye(l.name,this.schema)},d=[],u=na(l,"addKeyboardShortcuts",i);let p={};if(l.type==="mark"&&na(l,"exitable",i)&&(p.ArrowRight=()=>$g.handleExit({editor:s,mark:l})),u){const N=Object.fromEntries(Object.entries(u()).map(([w,k])=>[w,()=>k({editor:s})]));p={...p,...N}}const x=iOt(p);d.push(x);const y=na(l,"addInputRules",i);o8e(l,s.options.enableInputRules)&&y&&n.push(...y());const _=na(l,"addPasteRules",i);o8e(l,s.options.enablePasteRules)&&_&&a.push(..._());const b=na(l,"addProseMirrorPlugins",i);if(b){const N=b();d.push(...N)}return d}).flat();return[zOt({editor:s,rules:n}),...GOt({editor:s,rules:a}),...o]}get attributes(){return _Je(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=phe(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:qu(n.name,this.schema)},l=na(n,"addNodeView",o);if(!l)return[];const i=(d,u,p,x,y)=>{const _=w_e(d,a);return l()({node:d,view:u,getPos:p,decorations:x,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:sye(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),x=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),x&&this.editor.on("destroy",x)})}}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:()=>xhe(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 wJe(t,s,r){const{from:n,to:a}=s,{blockSeparator:o=` `,textSerializers:l={}}=r||{};let i="";return t.nodesBetween(n,a,(d,u,p,x)=>{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:x,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 jJe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const KOt=fh.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new yu({key:new Vh("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=jJe(r);return wJe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),ZOt=()=>({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),YOt=(t=!1)=>({commands:s})=>s.setContent("",t),XOt=()=>({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,x=u.resolve(p.map(d)),y=u.resolve(p.map(d+i.nodeSize)),_=x.blockRange(y);if(!_)return;const b=QA(_);if(i.type.isTextblock){const{defaultType:N}=x.parent.contentMatchAt(x.index());s.setNodeMarkup(_.start,N)}(b||b===0)&&s.lift(_,b)})}),!0},QOt=t=>s=>t(s),JOt=()=>({state:t,dispatch:s})=>vOt(t,s),eFt=(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 Ua(n.doc.resolve(Math.max(l-1,0)))),!0},tFt=()=>({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},sFt=t=>({tr:s,state:r,dispatch:n})=>{const a=qu(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},rFt=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},nFt=()=>({state:t,dispatch:s})=>oOt(t,s),aFt=()=>({commands:t})=>t.keyboardShortcut("Enter"),iFt=()=>({state:t,dispatch:s})=>yOt(t,s);function Ele(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:kke(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function NJe(t,s,r={}){return t.find(n=>n.type===s&&Ele(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function l8e(t,s,r={}){return!!NJe(t,s,r)}function Ske(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),!NJe([...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&&l8e([...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=vw(t,n.schema),{doc:l,selection:i}=r,{$from:d,from:u,to:p}=i;if(a){const x=Ske(d,o,s);if(x&&x.from<=u&&x.to>=p){const y=Ua.create(l,x.from,x.to);r.setSelection(y)}}return!0},lFt=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=()=>{(Ple()||c8e())&&n.dom.focus(),requestAnimationFrame(()=>{r.isDestroyed||(n.focus(),cFt()&&!Ple()&&!c8e()&&n.dom.focus({preventScroll:!0}))})};if(n.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!kJe(r.state.selection))return l(),!0;const i=SJe(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},uFt=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),hFt=(t,s)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,s),CJe=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&&CJe(n)}return t};function Oz(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return CJe(r)}function fD(t,s,r){if(t instanceof Db||t instanceof Mr)return t;r={slice:!0,parseOptions:{},...r};const n=typeof t=="object"&&t!==null,a=typeof t=="string";if(n)try{if(Array.isArray(t)&&t.length>0)return Mr.fromArray(t.map(i=>s.nodeFromJSON(i)));const l=s.nodeFromJSON(t);return r.errorOnInvalidContent&&l.check(),l}catch(o){if(r.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),fD("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const d=new pQe({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?r8.fromSchema(d).parseSlice(Oz(t),r.parseOptions):r8.fromSchema(d).parse(Oz(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=r8.fromSchema(s);return r.slice?o.parseSlice(Oz(t),r.parseOptions).content:o.parse(Oz(t),r.parseOptions)}return fD("",s,r)}function mFt(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=p)}),t.setSelection(Ja.near(t.doc.resolve(l),r))}const pFt=t=>!("type"in t),fFt=(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{fD(s,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(w){d(w)}try{i=fD(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:x}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},y=!0,_=!0;if((pFt(i)?i:[i]).forEach(w=>{w.check(),y=y?w.isText&&w.marks.length===0:!1,_=_?w.isBlock:!1}),p===x&&_){const{parent:w}=n.doc.resolve(p);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(p-=1,x+=1)}let N;if(y){if(Array.isArray(s))N=s.map(w=>w.text||"").join("");else if(s instanceof Mr){let w="";s.forEach(k=>{k.text&&(w+=k.text)}),N=w}else typeof s=="object"&&s&&s.text?N=s.text:N=s;n.insertText(N,p,x)}else N=i,n.replaceWith(p,x,N);r.updateSelection&&mFt(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},xFt=()=>({state:t,dispatch:s})=>pOt(t,s),gFt=()=>({state:t,dispatch:s})=>fOt(t,s),yFt=()=>({state:t,dispatch:s})=>lOt(t,s),vFt=()=>({state:t,dispatch:s})=>hOt(t,s),_Ft=()=>({state:t,dispatch:s,tr:r})=>{try{const n=ihe(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},bFt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=ihe(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},wFt=()=>({state:t,dispatch:s})=>cOt(t,s),jFt=()=>({state:t,dispatch:s})=>dOt(t,s);function MJe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function NFt(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=NFt(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 xD(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?qu(s,t.schema):null,i=[];t.doc.nodesBetween(n,a,(x,y)=>{if(x.isText)return;const _=Math.max(n,y),b=Math.min(a,y+x.nodeSize);i.push({node:x,from:_,to:b})});const d=a-n,u=i.filter(x=>l?l.name===x.node.type.name:!0).filter(x=>Ele(x.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((x,y)=>x+y.to-y.from,0)>=d}const SFt=(t,s={})=>({state:r,dispatch:n})=>{const a=qu(t,r.schema);return xD(r,a,s)?xOt(r,n):!1},CFt=()=>({state:t,dispatch:s})=>_Ot(t,s),MFt=t=>({state:s,dispatch:r})=>{const n=qu(t,s.schema);return TOt(n)(s,r)},TFt=()=>({state:t,dispatch:s})=>gOt(t,s);function ghe(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function d8e(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 AFt=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=ghe(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=qu(t,n.schema)),i==="mark"&&(l=vw(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,d8e(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(x=>{l===x.type&&r.addMark(p,p+u.nodeSize,l.create(d8e(x.attrs,s)))})})}),!0):!1},EFt=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),PFt=()=>({tr:t,dispatch:s})=>{if(s){const r=new bx(t.doc);t.setSelection(r)}return!0},IFt=()=>({state:t,dispatch:s})=>uOt(t,s),LFt=()=>({state:t,dispatch:s})=>mOt(t,s),DFt=()=>({state:t,dispatch:s})=>bOt(t,s),RFt=()=>({state:t,dispatch:s})=>NOt(t,s),OFt=()=>({state:t,dispatch:s})=>jOt(t,s);function j_e(t,s,r={},n={}){return fD(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const FFt=(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 x=j_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,x).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 TJe(t,s){const r=vw(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 zFt(t,s){const r=new dke(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function BFt(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function AJe(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 Cke(t){return s=>AJe(s.$from,t)}function qFt(t,s){const r={from:0,to:t.content.size};return wJe(t,r,s)}function UFt(t,s){const r=qu(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 EJe(t,s){const r=ghe(typeof s=="string"?s:s.name,t.schema);return r==="node"?UFt(t,s):r==="mark"?TJe(t,s):{}}function VFt(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 HFt(t){const s=VFt(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 GFt(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),x=s.invert().map(u,-1),y=s.invert().map(p);n.push({oldRange:{from:x,to:y},newRange:{from:u,to:p}})})}),HFt(n)}function Mke(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=Ske(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 Xie(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 N_e(t,s,r={}){const{empty:n,ranges:a}=t.selection,o=s?vw(s,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(x=>o?o.name===x.type.name:!0).find(x=>Ele(x.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:x,$to:y})=>{const _=x.pos,b=y.pos;t.doc.nodesBetween(_,b,(N,w)=>{if(!N.isText&&!N.marks.length)return;const k=Math.max(_,w),C=Math.min(b,w+N.nodeSize),E=C-k;l+=E,i.push(...N.marks.map(L=>({mark:L,from:k,to:C})))})}),l===0)return!1;const d=i.filter(x=>o?o.name===x.mark.type.name:!0).filter(x=>Ele(x.mark.attrs,r,{strict:!1})).reduce((x,y)=>x+y.to-y.from,0),u=i.filter(x=>o?x.mark.type!==o&&x.mark.type.excludes(o):!0).reduce((x,y)=>x+y.to-y.from,0);return(d>0?d+u:d)>=l}function WFt(t,s,r={}){if(!s)return xD(t,null,r)||N_e(t,null,r);const n=ghe(s,t.schema);return n==="node"?xD(t,s,r):n==="mark"?N_e(t,s,r):!1}function u8e(t,s){const{nodeExtensions:r}=phe(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 Tke(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&&(Tke(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function KFt(t){return t instanceof Ra}function ZFt(t,s,r){var n;const{selection:a}=s;let o=null;if(kJe(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,x,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 YFt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{const{selection:o}=r,{empty:l,ranges:i}=o,d=vw(t,n.schema);if(a)if(l){const u=TJe(n,d);r.addStoredMark(d.create({...u,...s}))}else i.forEach(u=>{const p=u.$from.pos,x=u.$to.pos;n.doc.nodesBetween(p,x,(y,_)=>{const b=Math.max(_,p),N=Math.min(_+y.nodeSize,x);y.marks.find(k=>k.type===d)?y.marks.forEach(k=>{d===k.type&&r.addMark(b,N,d.create({...k.attrs,...s}))}):r.addMark(b,N,d.create(s))})});return ZFt(n,r,d)},XFt=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),QFt=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=qu(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})=>n8e(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>n8e(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},JFt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=v4(t,0,n.content.size),o=Ra.create(n,a);s.setSelection(o)}return!0},e7t=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=Ua.atStart(n).from,i=Ua.atEnd(n).to,d=v4(a,l,i),u=v4(o,l,i),p=Ua.create(n,d,u);s.setSelection(p)}return!0},t7t=t=>({state:s,dispatch:r})=>{const n=qu(t,s.schema);return POt(n)(s,r)};function h8e(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 s7t=({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=Xie(u,i.node().type.name,i.node().attrs);if(o instanceof Ra&&o.node.isBlock)return!i.parentOffset||!GM(l,i.pos)?!1:(n&&(t&&h8e(r,a.extensionManager.splittableMarks),s.split(i.pos).scrollIntoView()),!0);if(!i.parent.isBlock)return!1;const x=d.parentOffset===d.parent.content.size,y=i.depth===0?void 0:BFt(i.node(-1).contentMatchAt(i.indexAfter(-1)));let _=x&&y?[{type:y,attrs:p}]:void 0,b=GM(s.doc,s.mapping.map(i.pos),1,_);if(!_&&!b&&GM(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 Ua&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,_),y&&!x&&!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&&h8e(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return b},r7t=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=qu(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 x=d.node(-1);if(x.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 k=Mr.empty;const C=d.index(-1)?1:d.index(-2)?2:3;for(let q=d.depth-C;q>=d.depth-3;q-=1)k=Mr.from(d.node(q).copy(k));const E=d.indexAfter(-1){if(V>-1)return!1;q.isTextblock&&q.content.size===0&&(V=$+1)}),V>-1&&r.setSelection(Ua.near(r.doc.resolve(V))),r.scrollIntoView()}return!0}const _=u.pos===d.end()?x.contentMatchAt(0).defaultType:null,b={...Xie(y,x.type.name,x.attrs),...s},N={...Xie(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(!GM(r.doc,d.pos,2))return!1;if(a){const{selection:k,storedMarks:C}=n,{splittableMarks:E}=o.extensionManager,L=C||k.$to.parentOffset&&k.$from.marks();if(r.split(d.pos,2,w).scrollIntoView(),!L||!a)return!0;const I=L.filter(O=>E.includes(O.type.name));r.ensureMarks(I)}return!0},rye=(t,s)=>{const r=Cke(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)&&gw(t.doc,r.pos)&&t.join(r.pos),!0},nye=(t,s)=>{const r=Cke(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)&&gw(t.doc,n)&&t.join(n),!0},n7t=(t,s,r,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:d,commands:u,can:p})=>{const{extensions:x,splittableMarks:y}=a.extensionManager,_=qu(t,l.schema),b=qu(s,l.schema),{selection:N,storedMarks:w}=l,{$from:k,$to:C}=N,E=k.blockRange(C),L=w||N.$to.parentOffset&&N.$from.marks();if(!E)return!1;const I=Cke(O=>u8e(O.type.name,x))(N);if(E.depth>=1&&I&&E.depth-I.depth<=1){if(I.node.type===_)return u.liftListItem(b);if(u8e(I.node.type.name,x)&&_.validContent(I.node.content)&&i)return d().command(()=>(o.setNodeMarkup(I.pos,_),!0)).command(()=>rye(o,_)).command(()=>nye(o,_)).run()}return!r||!L||!i?d().command(()=>p().wrapInList(_,n)?!0:u.clearNodes()).wrapInList(_,n).command(()=>rye(o,_)).command(()=>nye(o,_)).run():d().command(()=>{const O=p().wrapInList(_,n),V=L.filter(q=>y.includes(q.type.name));return o.ensureMarks(V),O?!0:u.clearNodes()}).wrapInList(_,n).command(()=>rye(o,_)).command(()=>nye(o,_)).run()},a7t=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=vw(t,n.schema);return N_e(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},i7t=(t,s,r={})=>({state:n,commands:a})=>{const o=qu(t,n.schema),l=qu(s,n.schema),i=xD(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})},o7t=(t,s={})=>({state:r,commands:n})=>{const a=qu(t,r.schema);return xD(r,a,s)?n.lift(a):n.wrapIn(a,s)},l7t=()=>({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},c7t=()=>({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},d7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=s,{selection:i}=r,d=vw(t,n.schema),{$from:u,empty:p,ranges:x}=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=Ske(u,d,b);N&&(y=N.from,_=N.to),r.removeMark(y,_,d)}else x.forEach(y=>{r.removeMark(y.$from.pos,y.$to.pos,d)});return r.removeStoredMark(d),!0},u7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=ghe(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=qu(t,n.schema)),i==="mark"&&(l=vw(t,n.schema)),a&&r.selection.ranges.forEach(d=>{const u=d.$from.pos,p=d.$to.pos;let x,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),x=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(k=>{if(l===k.type){const C=Math.max(w,u),E=Math.min(w+N.nodeSize,p);r.addMark(C,E,l.create({...k.attrs,...s}))}}))}),y&&(x!==void 0&&r.setNodeMarkup(x,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},h7t=(t,s={})=>({state:r,dispatch:n})=>{const a=qu(t,r.schema);return kOt(a,s)(r,n)},m7t=(t,s={})=>({state:r,dispatch:n})=>{const a=qu(t,r.schema);return SOt(a,s)(r,n)};var p7t=Object.freeze({__proto__:null,blur:ZOt,clearContent:YOt,clearNodes:XOt,command:QOt,createParagraphNear:JOt,cut:eFt,deleteCurrentNode:tFt,deleteNode:sFt,deleteRange:rFt,deleteSelection:nFt,enter:aFt,exitCode:iFt,extendMarkRange:oFt,first:lFt,focus:dFt,forEach:uFt,insertContent:hFt,insertContentAt:fFt,joinBackward:yFt,joinDown:gFt,joinForward:vFt,joinItemBackward:_Ft,joinItemForward:bFt,joinTextblockBackward:wFt,joinTextblockForward:jFt,joinUp:xFt,keyboardShortcut:kFt,lift:SFt,liftEmptyBlock:CFt,liftListItem:MFt,newlineInCode:TFt,resetAttributes:AFt,scrollIntoView:EFt,selectAll:PFt,selectNodeBackward:IFt,selectNodeForward:LFt,selectParentNode:DFt,selectTextblockEnd:RFt,selectTextblockStart:OFt,setContent:FFt,setMark:YFt,setMeta:XFt,setNode:QFt,setNodeSelection:JFt,setTextSelection:e7t,sinkListItem:t7t,splitBlock:s7t,splitListItem:r7t,toggleList:n7t,toggleMark:a7t,toggleNode:i7t,toggleWrap:o7t,undoInputRule:l7t,unsetAllMarks:c7t,unsetMark:d7t,updateAttributes:u7t,wrapIn:h7t,wrapInList:m7t});const f7t=fh.create({name:"commands",addCommands(){return{...p7t}}}),x7t=fh.create({name:"drop",addProseMirrorPlugins(){return[new yu({key:new Vh("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),g7t=fh.create({name:"editable",addProseMirrorPlugins(){return[new yu({key:new Vh("editable"),props:{editable:()=>this.editor.options.editable}})]}}),y7t=new Vh("focusEvents"),v7t=fh.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new yu({key:y7t,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}}}})]}}),_7t=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:x}=d,{pos:y,parent:_}=x,b=x.parent.isTextblock&&y>0?i.doc.resolve(y-1):x,N=b.parent.type.spec.isolating,w=x.pos-x.parentOffset,k=N&&b.parent.childCount===1?w===x.pos:Ja.atStart(u).from===y;return!p||!_.type.isTextblock||_.textContent.length||!k||k&&x.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 Ple()||MJe()?o:a},addProseMirrorPlugins(){return[new yu({key:new Vh("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=Ja.atStart(s.doc).from,u=Ja.atEnd(s.doc).to;if(o||!(l===d&&i===u)||!Tke(r.doc))return;const y=r.tr,_=hhe({state:r,transaction:y}),{commands:b}=new mhe({editor:this.editor,state:_});if(b.clearNodes(),!!y.steps.length)return y}})]}}),b7t=fh.create({name:"paste",addProseMirrorPlugins(){return[new yu({key:new Vh("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),w7t=fh.create({name:"tabindex",addProseMirrorPlugins(){return[new yu({key:new Vh("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class o4{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 o4(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 o4(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 o4(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 o4(i,this.editor,a,a?r:null);a&&(d.actualDepth=this.depth+1),s.push(new o4(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 j7t=`.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 N7t(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 k7t extends IOt{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=N7t(j7t,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=bJe(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?[g7t,KOt.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),f7t,v7t,_7t,w7t,x7t,b7t].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 eM(a,this)}createCommandManager(){this.commandManager=new mhe({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=j_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=j_e(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=SJe(r,this.options.autofocus);this.view=new mJe(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:J5.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 EJe(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return WFt(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Nke(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return qFt(this.state.doc,{blockSeparator:r,textSerializers:{...jJe(this.schema),...n}})}get isEmpty(){return Tke(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 o4(r,this)}get $doc(){return this.$pos(0)}}function $T(t){return new fhe({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(Mke(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 PJe(t){return new fhe({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 x=n[0][n[0].length-1];o.insertText(x,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 k_e(t){return new fhe({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 gD(t){return new fhe({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&&cke(d,t.type,o);if(!u)return null;if(l.wrap(d,u),t.keepMarks&&t.editor){const{selection:x,storedMarks:y}=s,{splittableMarks:_}=t.editor.extensionManager,b=y||x.$to.parentOffset&&x.$from.marks();if(b){const N=b.filter(w=>_.includes(w.type.name));l.ensureMarks(N)}}if(t.keepAttributes){const x=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(x,o).run()}const p=l.doc.resolve(r.from-1).nodeBefore;p&&p.type===t.type&&gw(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,p))&&l.join(r.from-1)}})}let Hh=class S_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 S_e(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>xhe(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new S_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 JS(t){return new qOt({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/),x=r.from+d.indexOf(i),y=x+i.length;if(Mke(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>x).length)return null;yr.from&&l.delete(r.from+p,x),u=r.from+p+i.length,l.addMark(r.from+p,u,t.type.create(o||{})),l.removeStoredMark(t.type)}}})}function S7t(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof Ra){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 C7t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var IJe={exports:{}},aye={};/** * @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 m8e;function M7t(){if(m8e)return aye;m8e=1;var t=ft;function s(x,y){return x===y&&(x!==0||1/x===1/y)||x!==x&&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(x,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})},[x,_,y]),a(function(){return d(N)&&w({inst:N}),x(function(){d(N)&&w({inst:N})})},[x]),l(_),_}function d(x){var y=x.getSnapshot;x=x.value;try{var _=y();return!r(x,_)}catch{return!0}}function u(x,y){return y()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:i;return aye.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,aye}IJe.exports=M7t();var Ake=IJe.exports;const T7t=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},A7t=({contentComponent:t})=>{const s=Ake.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return ft.createElement(ft.Fragment,null,Object.values(s))};function E7t(){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]:Y2e.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 P7t extends ft.Component{constructor(s){var r;super(s),this.editorContentRef=ft.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=E7t(),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 ft.createElement(ft.Fragment,null,ft.createElement("div",{ref:T7t(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&&ft.createElement(A7t,{contentComponent:s.contentComponent}))}}const I7t=S.forwardRef((t,s)=>{const r=ft.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ft.createElement(P7t,{key:r,innerRef:s,...t})}),Eke=ft.memo(I7t);var L7t=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},D7t=C7t(L7t),LJe={exports:{}},iye={};/** * @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 p8e;function R7t(){if(p8e)return iye;p8e=1;var t=ft,s=Ake;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 iye.useSyncExternalStoreWithSelector=function(u,p,x,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 k(O){if(!C){if(C=!0,E=O,O=y(O),_!==void 0&&N.hasValue){var V=N.value;if(_(V,O))return L=V}return L=O}if(V=L,n(E,O))return V;var q=y(O);return _!==void 0&&_(V,q)?V:(E=O,L=q)}var C=!1,E,L,I=x===void 0?null:x;return[function(){return k(p())},I===null?void 0:function(){return k(I())}]},[p,x,y,_]);var w=a(u,b[0],b[1]);return l(function(){N.hasValue=!0,N.value=w},[w]),d(w),w},iye}LJe.exports=R7t();var O7t=LJe.exports;const F7t=typeof window<"u"?S.useLayoutEffect:S.useEffect;class z7t{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 B7t(t){var s;const[r]=S.useState(()=>new z7t(t.editor)),n=O7t.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:D7t);return F7t(()=>r.watch(t.editor),[t.editor,r]),S.useDebugValue(n),n}const $7t=!1,C_e=typeof window>"u",q7t=C_e||!!(typeof window<"u"&&window.next);class Pke{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(){if(this.options.current.immediatelyRender===void 0)return C_e||q7t?null:this.createEditor();if(this.options.current.immediatelyRender&&C_e&&$7t)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return 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 k7t(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?Pke.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 Ike(t={},s=[]){const r=S.useRef(t);r.current=t;const[n]=S.useState(()=>new Pke(r)),a=Ake.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return S.useDebugValue(a),S.useEffect(n.onRender(s)),B7t({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const U7t=S.createContext({editor:null});U7t.Consumer;const V7t=S.createContext({onDragStart:void 0}),H7t=()=>S.useContext(V7t);ft.forwardRef((t,s)=>{const{onDragStart:r}=H7t(),n=t.as||"div";return ft.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const G7t=/^\s*>\s$/,W7t=Hh.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",jc(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[gD({find:G7t,type:this.type})]}}),K7t=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Z7t=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Y7t=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,X7t=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Q7t=$g.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",jc(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[$T({find:K7t,type:this.type}),$T({find:Y7t,type:this.type})]},addPasteRules(){return[JS({find:Z7t,type:this.type}),JS({find:X7t,type:this.type})]}}),J7t="listItem",f8e="textStyle",x8e=/^\s*([-+*])\s$/,ezt=Hh.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",jc(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(J7t,this.editor.getAttributes(f8e)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=gD({find:x8e,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=gD({find:x8e,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(f8e),editor:this.editor})),[t]}}),tzt=/(^|[^`])`([^`]+)`(?!`)/,szt=/(^|[^`])`([^`]+)`(?!`)/g,rzt=$g.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",jc(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[$T({find:tzt,type:this.type})]},addPasteRules(){return[JS({find:szt,type:this.type})]}}),nzt=/^```([a-z]+)?[\s\n]$/,azt=/^~~~([a-z]+)?[\s\n]$/,izt=Hh.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",jc(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(Ja.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[k_e({find:nzt,type:this.type,getAttributes:t=>({language:t[1]})}),k_e({find:azt,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new yu({key:new Vh("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(Ua.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),ozt=Hh.create({name:"doc",topNode:!0,content:"block+"});function lzt(t={}){return new yu({view(s){return new czt(s,t)}})}class czt{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 x=s.nodeBefore,y=s.nodeAfter;if(x||y){let _=this.editorView.nodeDOM(this.cursorPos-(x?x.nodeSize:0));if(_){let b=_.getBoundingClientRect(),N=x?b.bottom:b.top;x&&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 x=this.editorView.coordsAtPos(this.cursorPos),y=this.width/2*l;n={left:x.left-y,right:x.left+y,top:x.top,bottom:x.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 x=d.getBoundingClientRect(),y=x.width/d.offsetWidth,_=x.height/d.offsetHeight;u=x.left-d.scrollLeft*y,p=x.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=kQe(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 dzt=fh.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[lzt(this.options)]}});class Xc extends Ja{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return Xc.valid(n)?new Xc(n):Ja.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 Lke(this.anchor)}static valid(s){let r=s.parent;if(r.inlineContent||!uzt(s)||!hzt(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&&!Ra.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;Ja.jsonID("gapcursor",Xc);class Lke{constructor(s){this.pos=s}map(s){return new Lke(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return Xc.valid(r)?new Xc(r):Ja.near(r)}}function DJe(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function uzt(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||DJe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function hzt(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||DJe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function mzt(){return new yu({props:{decorations:gzt,createSelectionBetween(t,s,r){return s.pos==r.pos&&Xc.valid(r)?new Xc(r):null},handleClick:fzt,handleKeyDown:pzt,handleDOMEvents:{beforeinput:xzt}}})}const pzt=bke({ArrowLeft:Fz("horiz",-1),ArrowRight:Fz("horiz",1),ArrowUp:Fz("vert",-1),ArrowDown:Fz("vert",1)});function Fz(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 Ua){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 fzt(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&&Ra.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Xc(n))),!0)}function xzt(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=Mr.empty;for(let l=n.length-1;l>=0;l--)a=Mr.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new yn(a,0,0));return o.setSelection(Ua.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function gzt(t){if(!(t.selection instanceof Xc))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",Yc.create(t.doc,[bm.widget(t.selection.head,s,{key:"gapcursor"})])}const yzt=fh.create({name:"gapCursor",addProseMirrorPlugins(){return[mzt()]},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}}}),vzt=Hh.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",jc(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 x=d.filter(y=>i.includes(y.type.name));u.ensureMarks(x)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),_zt=Hh.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]}`,jc(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=>k_e({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Ile=200,Bu=function(){};Bu.prototype.append=function(s){return s.length?(s=Bu.from(s),!this.length&&s||s.length=r?Bu.empty:this.sliceInner(Math.max(0,s),Math.min(this.length,r))};Bu.prototype.get=function(s){if(!(s<0||s>=this.length))return this.getInner(s)};Bu.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)};Bu.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};Bu.from=function(s){return s instanceof Bu?s:s&&s.length?new RJe(s):Bu.empty};var RJe=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<=Ile)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=Ile)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}(Bu);Bu.empty=new RJe([]);var bzt=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}(Bu);const wzt=500;class jg{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((x,y)=>{if(!x.step){a||(a=this.remapping(n,y+1),o=a.maps.length),o--,p.push(x);return}if(a){p.push(new My(x.map));let _=x.step.map(a.slice(o)),b;_&&l.maybeStep(_).doc&&(b=l.mapping.maps[l.mapping.maps.length-1],u.push(new My(b,void 0,void 0,u.length+p.length))),o--,b&&a.appendMap(b,o)}else l.maybeStep(x.step);if(x.selection)return i=a?x.selection.map(a.slice(o)):x.selection,d=new jg(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;pNzt&&(i=jzt(i,u),l-=u),new jg(i.append(o),l)}remapping(s,r){let n=new dD;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 jg(this.items.append(s.map(r=>new My(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 My(b,N,w))}else n.push(new My(b))},a);let u=[];for(let y=r;ywzt&&(x=x.compress(this.items.length-n.length)),x}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 x=new My(u.invert(),d,p),y,_=a.length-1;(y=a.length&&a[_].merge(x))?a[_]=y:a.push(x)}}else l.map&&n--},this.items.length,0),new jg(Bu.from(a.reverse()),o)}}jg.empty=new jg(Bu.empty,0);function jzt(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class My{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 My(r.getMap().invert(),r,this.selection)}}}class L_{constructor(s,r,n,a,o){this.done=s,this.undone=r,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const Nzt=20;function kzt(t,s,r,n){let a=r.getMeta(SS),o;if(a)return a.historyState;r.getMeta(Mzt)&&(t=new L_(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(SS))return l.getMeta(SS).redo?new L_(t.done.addTransform(r,void 0,n,Qie(s)),t.undone,g8e(r.mapping.maps),t.prevTime,t.prevComposition):new L_(t.done,t.undone.addTransform(r,void 0,n,Qie(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||!Szt(r,t.prevRanges)),u=l?oye(t.prevRanges,r.mapping):g8e(r.mapping.maps);return new L_(t.done.addTransform(r,d?s.selection.getBookmark():void 0,n,Qie(s)),jg.empty,u,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new L_(t.done.rebased(r,o),t.undone.rebased(r,o),oye(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new L_(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),oye(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function Szt(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 g8e(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 oye(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=SS.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=Czt(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const FJe=OJe(!1,!0),zJe=OJe(!0,!0),Azt=fh.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>FJe(t,s),redo:()=>({state:t,dispatch:s})=>zJe(t,s)}},addProseMirrorPlugins(){return[Tzt(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()}}}),Ezt=Hh.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",jc(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!S7t(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}):KFt(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(Ua.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Ra.create(l.doc,u.pos)):l.setSelection(Ua.create(l.doc,u.pos));else{const x=(d=u.parent.type.contentMatch.defaultType)===null||d===void 0?void 0:d.create();x&&(l.insert(p,x),l.setSelection(Ua.create(l.doc,p+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[PJe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Pzt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Izt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Lzt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Dzt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Rzt=$g.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",jc(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[$T({find:Pzt,type:this.type}),$T({find:Lzt,type:this.type})]},addPasteRules(){return[JS({find:Izt,type:this.type}),JS({find:Dzt,type:this.type})]}}),Ozt=Hh.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",jc(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)}}}),Fzt="listItem",v8e="textStyle",_8e=/^(\d+)\.\s$/,zzt=Hh.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",jc(this.options.HTMLAttributes,r),0]:["ol",jc(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(Fzt,this.editor.getAttributes(v8e)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=gD({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=gD({find:_8e,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(v8e)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),Bzt=Hh.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",jc(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),$zt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,qzt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Uzt=$g.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",jc(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[$T({find:$zt,type:this.type})]},addPasteRules(){return[JS({find:qzt,type:this.type})]}}),Vzt=Hh.create({name:"text",group:"inline"}),Dke=fh.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(Q7t.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(W7t.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(ezt.configure(this.options.bulletList)),this.options.code!==!1&&t.push(rzt.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(izt.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(ozt.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(dzt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(yzt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(vzt.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(_zt.configure(this.options.heading)),this.options.history!==!1&&t.push(Azt.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(Ezt.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(Rzt.configure(this.options.italic)),this.options.listItem!==!1&&t.push(Ozt.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(zzt.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(Bzt.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(Uzt.configure(this.options.strike)),this.options.text!==!1&&t.push(Vzt.configure(this.options.text)),t}}),Hzt="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Gzt="ελ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",M_e="numeric",T_e="ascii",A_e="alpha",o8="asciinumeric",DI="alphanumeric",E_e="domain",BJe="emoji",Wzt="scheme",Kzt="slashscheme",cye="whitespace";function Zzt(t,s){return t in s||(s[t]=[]),s[t]}function _4(t,s,r){s[M_e]&&(s[o8]=!0,s[DI]=!0),s[T_e]&&(s[o8]=!0,s[A_e]=!0),s[o8]&&(s[DI]=!0),s[A_e]&&(s[DI]=!0),s[DI]&&(s[E_e]=!0),s[BJe]&&(s[E_e]=!0);for(const n in s){const a=Zzt(n,r);a.indexOf(t)<0&&a.push(t)}}function Yzt(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function np(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}np.groups={};np.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),b8e=(t,s,r,n,a)=>t.ts(s,r,n,a),Ur=(t,s,r,n,a)=>t.tt(s,r,n,a),vv="WORD",P_e="UWORD",$Je="ASCIINUMERICAL",qJe="ALPHANUMERICAL",yD="LOCALHOST",I_e="TLD",L_e="UTLD",Jie="SCHEME",L5="SLASH_SCHEME",Rke="NUM",D_e="WS",Oke="NL",l8="OPENBRACE",c8="CLOSEBRACE",Lle="OPENBRACKET",Dle="CLOSEBRACKET",Rle="OPENPAREN",Ole="CLOSEPAREN",Fle="OPENANGLEBRACKET",zle="CLOSEANGLEBRACKET",Ble="FULLWIDTHLEFTPAREN",$le="FULLWIDTHRIGHTPAREN",qle="LEFTCORNERBRACKET",Ule="RIGHTCORNERBRACKET",Vle="LEFTWHITECORNERBRACKET",Hle="RIGHTWHITECORNERBRACKET",Gle="FULLWIDTHLESSTHAN",Wle="FULLWIDTHGREATERTHAN",Kle="AMPERSAND",Zle="APOSTROPHE",Yle="ASTERISK",D_="AT",Xle="BACKSLASH",Qle="BACKTICK",Jle="CARET",V_="COLON",Fke="COMMA",ece="DOLLAR",Ty="DOT",tce="EQUALS",zke="EXCLAMATION",Zf="HYPHEN",d8="PERCENT",sce="PIPE",rce="PLUS",nce="POUND",u8="QUERY",Bke="QUOTE",UJe="FULLWIDTHMIDDLEDOT",$ke="SEMI",Ay="SLASH",h8="TILDE",ace="UNDERSCORE",VJe="EMOJI",ice="SYM";var HJe=Object.freeze({__proto__:null,ALPHANUMERICAL:qJe,AMPERSAND:Kle,APOSTROPHE:Zle,ASCIINUMERICAL:$Je,ASTERISK:Yle,AT:D_,BACKSLASH:Xle,BACKTICK:Qle,CARET:Jle,CLOSEANGLEBRACKET:zle,CLOSEBRACE:c8,CLOSEBRACKET:Dle,CLOSEPAREN:Ole,COLON:V_,COMMA:Fke,DOLLAR:ece,DOT:Ty,EMOJI:VJe,EQUALS:tce,EXCLAMATION:zke,FULLWIDTHGREATERTHAN:Wle,FULLWIDTHLEFTPAREN:Ble,FULLWIDTHLESSTHAN:Gle,FULLWIDTHMIDDLEDOT:UJe,FULLWIDTHRIGHTPAREN:$le,HYPHEN:Zf,LEFTCORNERBRACKET:qle,LEFTWHITECORNERBRACKET:Vle,LOCALHOST:yD,NL:Oke,NUM:Rke,OPENANGLEBRACKET:Fle,OPENBRACE:l8,OPENBRACKET:Lle,OPENPAREN:Rle,PERCENT:d8,PIPE:sce,PLUS:rce,POUND:nce,QUERY:u8,QUOTE:Bke,RIGHTCORNERBRACKET:Ule,RIGHTWHITECORNERBRACKET:Hle,SCHEME:Jie,SEMI:$ke,SLASH:Ay,SLASH_SCHEME:L5,SYM:ice,TILDE:h8,TLD:I_e,UNDERSCORE:ace,UTLD:L_e,UWORD:P_e,WORD:vv,WS:D_e});const mv=/[a-z]/,nI=new RegExp("\\p{L}","u"),dye=new RegExp("\\p{Emoji}","u"),pv=/\d/,uye=/\s/,w8e="\r",hye=` `,Xzt="️",Qzt="‍",mye="";let zz=null,Bz=null;function Jzt(t=[]){const s={};np.groups=s;const r=new np;zz==null&&(zz=j8e(Hzt)),Bz==null&&(Bz=j8e(Gzt)),Ur(r,"'",Zle),Ur(r,"{",l8),Ur(r,"}",c8),Ur(r,"[",Lle),Ur(r,"]",Dle),Ur(r,"(",Rle),Ur(r,")",Ole),Ur(r,"<",Fle),Ur(r,">",zle),Ur(r,"(",Ble),Ur(r,")",$le),Ur(r,"「",qle),Ur(r,"」",Ule),Ur(r,"『",Vle),Ur(r,"』",Hle),Ur(r,"<",Gle),Ur(r,">",Wle),Ur(r,"&",Kle),Ur(r,"*",Yle),Ur(r,"@",D_),Ur(r,"`",Qle),Ur(r,"^",Jle),Ur(r,":",V_),Ur(r,",",Fke),Ur(r,"$",ece),Ur(r,".",Ty),Ur(r,"=",tce),Ur(r,"!",zke),Ur(r,"-",Zf),Ur(r,"%",d8),Ur(r,"|",sce),Ur(r,"+",rce),Ur(r,"#",nce),Ur(r,"?",u8),Ur(r,'"',Bke),Ur(r,"/",Ay),Ur(r,";",$ke),Ur(r,"~",h8),Ur(r,"_",ace),Ur(r,"\\",Xle),Ur(r,"・",UJe);const n=qc(r,pv,Rke,{[M_e]:!0});qc(n,pv,n);const a=qc(n,mv,$Je,{[o8]:!0}),o=qc(n,nI,qJe,{[DI]:!0}),l=qc(r,mv,vv,{[T_e]:!0});qc(l,pv,a),qc(l,mv,l),qc(a,pv,a),qc(a,mv,a);const i=qc(r,nI,P_e,{[A_e]:!0});qc(i,mv),qc(i,pv,o),qc(i,nI,i),qc(o,pv,o),qc(o,mv),qc(o,nI,o);const d=Ur(r,hye,Oke,{[cye]:!0}),u=Ur(r,w8e,D_e,{[cye]:!0}),p=qc(r,uye,D_e,{[cye]:!0});Ur(r,mye,p),Ur(u,hye,d),Ur(u,mye,p),qc(u,uye,p),Ur(p,w8e),Ur(p,hye),qc(p,uye,p),Ur(p,mye,p);const x=qc(r,dye,VJe,{[BJe]:!0});Ur(x,"#"),qc(x,dye,x),Ur(x,Xzt,x);const y=Ur(x,Qzt);Ur(y,"#"),qc(y,dye,x);const _=[[mv,l],[pv,a]],b=[[mv,null],[nI,i],[pv,o]];for(let N=0;NN[0]>w[0]?1:-1);for(let N=0;N=0?C[E_e]=!0:mv.test(w)?pv.test(w)?C[o8]=!0:C[T_e]=!0:C[M_e]=!0,b8e(r,w,w,C)}return b8e(r,"localhost",yD,{ascii:!0}),r.jd=new np(ice),{start:r,tokens:Object.assign({groups:s},HJe)}}function GJe(t,s){const r=e9t(s.replace(/[A-Z]/g,i=>i.toLowerCase())),n=r.length,a=[];let o=0,l=0;for(;l=0&&(x+=r[l].length,y++),u+=r[l].length,o+=r[l].length,l++;o-=x,l-=y,u-=x,a.push({t:p.t,v:s.slice(o-u,o),s:o-u,e:o})}return a}function e9t(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 x_(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 vD={defaultProtocol:"http",events:null,format:N8e,formatHref:N8e,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function qke(t,s=null){let r=Object.assign({},vD);t&&(r=Object.assign(r,t instanceof qke?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=vD.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),x=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:x}}};function yhe(t,s){class r extends WJe{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 k8e=yhe("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),S8e=yhe("text"),t9t=yhe("nl"),$z=yhe("url",{isLink:!0,toHref(t=vD.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==yD&&t[1].t===V_}}),qf=t=>new np(t);function s9t({groups:t}){const s=t.domain.concat([Kle,Yle,D_,Xle,Qle,Jle,ece,tce,Zf,Rke,d8,sce,rce,nce,Ay,ice,h8,ace]),r=[Zle,V_,Fke,Ty,zke,d8,u8,Bke,$ke,Fle,zle,l8,c8,Dle,Lle,Rle,Ole,Ble,$le,qle,Ule,Vle,Hle,Gle,Wle],n=[Kle,Zle,Yle,Xle,Qle,Jle,ece,tce,Zf,l8,c8,d8,sce,rce,nce,u8,Ay,ice,h8,ace],a=qf(),o=Ur(a,h8);Ii(o,n,o),Ii(o,t.domain,o);const l=qf(),i=qf(),d=qf();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=Ur(l,D_);Ur(o,D_,u),Ur(i,D_,u),Ur(d,D_,u);const p=Ur(o,Ty);Ii(p,n,o),Ii(p,t.domain,o);const x=qf();Ii(u,t.domain,x),Ii(x,t.domain,x);const y=Ur(x,Ty);Ii(y,t.domain,x);const _=qf(k8e);Ii(y,t.tld,_),Ii(y,t.utld,_),Ur(u,yD,_);const b=Ur(x,Zf);Ur(b,Zf,b),Ii(b,t.domain,x),Ii(_,t.domain,x),Ur(_,Ty,y),Ur(_,Zf,b);const N=Ur(_,V_);Ii(N,t.numeric,k8e);const w=Ur(l,Zf),k=Ur(l,Ty);Ur(w,Zf,w),Ii(w,t.domain,l),Ii(k,n,o),Ii(k,t.domain,l);const C=qf($z);Ii(k,t.tld,C),Ii(k,t.utld,C),Ii(C,t.domain,l),Ii(C,n,o),Ur(C,Ty,k),Ur(C,Zf,w),Ur(C,D_,u);const E=Ur(C,V_),L=qf($z);Ii(E,t.numeric,L);const I=qf($z),O=qf();Ii(I,s,I),Ii(I,r,O),Ii(O,s,I),Ii(O,r,O),Ur(C,Ay,I),Ur(L,Ay,I);const V=Ur(i,V_),q=Ur(d,V_),$=Ur(q,Ay),U=Ur($,Ay);Ii(i,t.domain,l),Ur(i,Ty,k),Ur(i,Zf,w),Ii(d,t.domain,l),Ur(d,Ty,k),Ur(d,Zf,w),Ii(V,t.domain,I),Ur(V,Ay,I),Ur(V,u8,I),Ii(U,t.domain,I),Ii(U,s,I),Ur(U,Ay,I);const se=[[l8,c8],[Lle,Dle],[Rle,Ole],[Fle,zle],[Ble,$le],[qle,Ule],[Vle,Hle],[Gle,Wle]];for(let Y=0;Y=0&&y++,a++,p++;if(y<0)a-=p,a0&&(o.push(pye(S8e,s,l)),l=[]),a-=y,p-=y;const _=x.t,b=r.slice(a-p,a);o.push(pye(_,s,b))}}return l.length>0&&o.push(pye(S8e,s,l)),o}function pye(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 n9t=typeof console<"u"&&console&&console.warn||(()=>{}),a9t="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Gl={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function i9t(){return np.groups={},Gl.scanner=null,Gl.parser=null,Gl.tokenQueue=[],Gl.pluginQueue=[],Gl.customSchemes=[],Gl.initialized=!1,Gl}function C8e(t,s=!1){if(Gl.initialized&&n9t(`linkifyjs: already initialized - will not register custom scheme "${t}" ${a9t}`),!/^[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`);Gl.customSchemes.push([t,s])}function o9t(){Gl.scanner=Jzt(Gl.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=zFt(r.doc,[...s]);if(GFt(i).forEach(({newRange:u})=>{const p=$Ft(n.doc,u,_=>_.isTextblock);let x,y;if(p.length>1)x=p[0],y=n.doc.textBetween(x.pos,x.pos+x.node.nodeSize,void 0," ");else if(p.length){const _=n.doc.textBetween(u.from,u.to," "," ");if(!c9t.test(_))return;x=p[0],y=n.doc.textBetween(x.pos,u.to,void 0," ")}if(x&&y){const _=y.split(l9t).filter(Boolean);if(_.length<=0)return!1;const b=_[_.length-1],N=x.pos+y.lastIndexOf(b);if(!b)return!1;const w=Uke(b).map(k=>k.toObject(t.defaultProtocol));if(!u9t(w))return!1;w.filter(k=>k.isLink).map(k=>({...k,from:N+k.start+1,to:N+k.end+1})).filter(k=>n.schema.marks.code?!n.doc.rangeHasMark(k.from,k.to,n.schema.marks.code):!0).filter(k=>t.validate(k.value)).filter(k=>t.shouldAutoLink(k.value)).forEach(k=>{Mke(k.from,k.to,n.doc).some(C=>C.mark.type===t.type)||l.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!l.steps.length)return l}})}function m9t(t){return new yu({key:new Vh("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=EJe(s.state,t.type.name),u=n.target,p=(a=u==null?void 0:u.href)!==null&&a!==void 0?a:d.href,x=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:d.target;return u&&p?(window.open(p,x),!0):!1}}})}function p9t(t){return new yu({key:new Vh("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=KJe(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 R2(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(d9t,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Hke=$g.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"){C8e(t);return}C8e(t.scheme,t.optionalSlashes)})},onDestroy(){i9t()},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)=>!!R2(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=>!!R2(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=>!!R2(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",jc(this.options.HTMLAttributes,t),0]:["a",jc(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!R2(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=>!!R2(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[JS({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=KJe(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!R2(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(h9t({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!R2(a,s),protocols:s,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(m9t({type:this.type})),this.options.linkOnPaste&&t.push(p9t({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),Gke=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")}}}),f9t=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}`)})},Wke=$g.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&f9t(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",jc(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}}}}),x9t=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,g9t=Hh.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",jc(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[PJe({find:x9t,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let R_e,O_e;if(typeof WeakMap<"u"){let t=new WeakMap;R_e=s=>t.get(s),O_e=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;R_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:k-E});break}const L=a+E*s;for(let I=0;In&&(o+=u.attrs.colspan)}}for(let l=0;l1&&(r=!0)}s==-1?s=o:s!=o&&(s=Math.max(s,o))}return s}function _9t(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 w9t(t){for(let s=t.depth;s>0;s--){const r=t.node(s).type.spec.tableRole;if(r==="cell"||r==="header_cell")return t.node(s)}return null}function Hg(t){const s=t.selection.$head;for(let r=s.depth;r>0;r--)if(s.node(r).type.spec.tableRole=="row")return!0;return!1}function vhe(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=eC(s.$head)||j9t(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function j9t(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 F_e(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function N9t(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Kke(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function ZJe(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 tC(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 YJe(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 x=n.nodeAt(p);if(!x)throw new RangeError(`No cell with offset ${p} found`);const y=o+p+1;return new AQe(i.resolve(y),i.resolve(y+x.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(F_e(n)&&F_e(a)&&Kke(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 Ua.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 k=b.attrs;if(N>0&&(k=tC(k,0,N)),w>0&&(k=tC(k,k.colspan-w,w)),_.lefta.bottom){const k={...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(bm.node(n,n+r.nodeSize,{class:"selectedCell"}))}),Yc.create(t.doc,s)}function M9t({$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 T9t({$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 A9t(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof Ra&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=Rl.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=Rl.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=Rl.create(a,d+1,u)}}else n instanceof Ua&&M9t(n)?o=Ua.create(a,n.from):n instanceof Ua&&T9t(n)&&(o=Ua.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const E9t=new Vh("fix-tables");function QJe(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=P9t(t,a,o,r))};return s?s.doc!=t.doc&&QJe(s.doc,t.doc,0,n):t.doc.descendants(n),r}function P9t(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;k9t(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;O9t(s,n,a+i)&&(i=a==0||a==s.height?null:0);for(let u=0,p=s.width*a;u0&&a0&&x==s.map[p-s.width]){const y=r.nodeAt(x).attrs;t.setNodeMarkup(t.mapping.slice(i).map(x+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,x=M8e(u)?d+1:p;o.replaceWith(x+n.tableStart,p+n.tableStart,i)}o.setSelection(new Rl(o.doc.resolve(d+n.tableStart))),s(o)}return!0}function A8e(t,s){const r=$h(t.schema);return U9t(({node:n})=>r[n.type.spec.tableRole])(t,s)}function U9t(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof Rl){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=w9t(n.$from),!a)return!1;o=(l=eC(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),x=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 H9t(t){return function(s,r){if(!Hg(s))return!1;if(r){const n=$h(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(_,x,b.attrs)}),n(l)}return!0}}_D("row",{useDeprecatedLogic:!0});_D("column",{useDeprecatedLogic:!0});const G9t=_D("cell",{useDeprecatedLogic:!0});function W9t(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 qz(t,s){const r=t.selection;if(!(r instanceof Rl))return!1;if(s){const n=t.tr,a=$h(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 Z9t(t){if(t.size===0)return null;let{content:s,openStart:r,openEnd:n}=t;for(;s.childCount==1&&(r>0&&n>0||s.child(0).type.spec.tableRole=="table");)r--,n--,s=s.child(0).content;const a=s.child(0),o=a.type.spec.tableRole,l=a.type.schema,i=[];if(o=="row")for(let d=0;d=0;l--){const{rowspan:i,colspan:d}=o.child(l).attrs;for(let u=a;u=s.length&&s.push(Mr.empty),r[a]n&&(y=y.type.createChecked(tC(y.attrs,y.attrs.colspan,p+y.attrs.colspan-n),y.content)),u.push(y),p+=y.attrs.colspan;for(let _=1;_a&&(x=x.type.create({...x.attrs,rowspan:Math.max(1,a-x.attrs.rowspan)},x.content)),d.push(x)}o.push(Mr.from(d))}r=o,s=a}return{width:t,height:s,rows:r}}function Q9t(t,s,r,n,a,o,l){const i=t.doc.type.schema,d=$h(i);let u,p;if(a>s.width)for(let x=0,y=0;xs.height){const x=[];for(let b=0,N=(s.height-1)*s.width;b=s.width?!1:r.nodeAt(s.map[N+b]).type==d.header_cell;x.push(w?p||(p=d.header_cell.createAndFill()):u||(u=d.cell.createAndFill()))}const y=d.row.create(null,Mr.from(x)),_=[];for(let b=s.height;b{if(!a)return!1;const o=r.selection;if(o instanceof Rl)return eoe(r,n,Ja.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=set(a,t,s);if(l==null)return!1;if(t=="horiz")return eoe(r,n,Ja.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),d=ZJe(i,t,s);let u;return d?u=Ja.near(d,1):s<0?u=Ja.near(r.doc.resolve(i.before(-1)),-1):u=Ja.near(r.doc.resolve(i.after(-1)),1),eoe(r,n,u)}}}function Vz(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof Rl)l=o;else{const d=set(a,t,s);if(d==null)return!1;l=new Rl(r.doc.resolve(d))}const i=ZJe(l.$headCell,t,s);return i?eoe(r,n,new Rl(l.$anchorCell,i)):!1}}function eBt(t,s){const r=t.state.doc,n=eC(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new Rl(n))),!0):!1}function tBt(t,s,r){if(!Hg(t.state))return!1;let n=Z9t(r);const a=t.state.selection;if(a instanceof Rl){n||(n={width:1,height:1,rows:[Mr.from(z_e($h(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=X9t(n,i.right-i.left,i.bottom-i.top),D8e(t.state,t.dispatch,l,i,n),!0}else if(n){const o=vhe(t.state),l=o.start(-1);return D8e(t.state,t.dispatch,l,Jc.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function sBt(t,s){var r;if(s.button!=0||s.ctrlKey||s.metaKey)return;const n=R8e(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof Rl)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=eC(t.state.selection.$anchor))!=null&&((r=fye(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=fye(t,u);const x=H_.getState(t.state)==null;if(!p||!Kke(d,p))if(x)p=d;else return;const y=new Rl(d,p);if(x||!t.state.selection.eq(y)){const _=t.state.tr.setSelection(y);x&&_.setMeta(H_,d.pos),t.dispatch(_)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),H_.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(H_,-1))}function i(d){const u=d,p=H_.getState(t.state);let x;if(p!=null)x=t.state.doc.resolve(p);else if(R8e(t,u.target)!=n&&(x=fye(t,s),!x))return l();x&&o(x,u)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",i)}function set(t,s,r){if(!(t.state.selection instanceof Ua))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 R8e(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function fye(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&&eC(t.state.doc.resolve(n))||eC(t.state.doc.resolve(a))}var rBt=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")),B_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,B_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 B_e(t,s,r,n,a,o){let l=0,i=!0,d=s.firstChild;const u=t.firstChild;if(u){for(let x=0,y=0;xnew n(x,r,y)),new aBt(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=Qp.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{iBt(l,i,t,a)},mouseleave:l=>{oBt(l)},mousedown:(l,i)=>{lBt(l,i,s,r)}},decorations:l=>{const i=Qp.getState(l);if(i&&i.activeHandle>-1)return mBt(l,i.activeHandle)},nodeViews:{}}});return o}var aBt=class toe{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta(Qp);if(n&&n.setHandle!=null)return new toe(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new toe(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return F_e(s.doc.resolve(a))||(a=-1),new toe(a,r.dragging)}return r}};function iBt(t,s,r,n){if(!t.editable)return;const a=Qp.getState(t.state);if(a&&!a.dragging){const o=dBt(s.target);let l=-1;if(o){const{left:i,right:d}=o.getBoundingClientRect();s.clientX-i<=r?l=O8e(t,s,"left",r):d-s.clientX<=r&&(l=O8e(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}ret(t,l)}}}function oBt(t){if(!t.editable)return;const s=Qp.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&ret(t,-1)}function lBt(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=Qp.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),d=cBt(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(Qp,{setDragging:{startX:s.clientX,startWidth:d}}));function u(x){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",p);const y=Qp.getState(t.state);y!=null&&y.dragging&&(uBt(t,y.activeHandle,F8e(y.dragging,x,r)),t.dispatch(t.state.tr.setMeta(Qp,{setDragging:null})))}function p(x){if(!x.which)return u(x);const y=Qp.getState(t.state);if(y&&y.dragging){const _=F8e(y.dragging,x,r);z8e(t,y.activeHandle,_,n)}}return z8e(t,l.activeHandle,d,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",p),s.preventDefault(),!0}function cBt(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 yBt(t,s,r,n,a){const o=gBt(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!vBt(s))return!1;let r=0;const n=AJe(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},_Bt=Hh.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:fBt,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}=xBt(t,this.options.cellMinWidth),o=["table",jc(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=yBt(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(Ua.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>I9t(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>L9t(t,s),deleteColumn:()=>({state:t,dispatch:s})=>R9t(t,s),addRowBefore:()=>({state:t,dispatch:s})=>F9t(t,s),addRowAfter:()=>({state:t,dispatch:s})=>z9t(t,s),deleteRow:()=>({state:t,dispatch:s})=>$9t(t,s),deleteTable:()=>({state:t,dispatch:s})=>K9t(t,s),mergeCells:()=>({state:t,dispatch:s})=>T8e(t,s),splitCell:()=>({state:t,dispatch:s})=>A8e(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>_D("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>_D("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>G9t(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>T8e(t,s)?!0:A8e(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>V9t(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>P8e(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>P8e(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&JJe(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=Rl.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:Hz,"Mod-Backspace":Hz,Delete:Hz,"Mod-Delete":Hz}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[nBt({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],pBt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:Li(na(t,"tableRole",s))}}}),bBt=Hh.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",jc(this.options.HTMLAttributes,t),0]}}),wBt=Hh.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",jc(this.options.HTMLAttributes,t),0]}}),jBt=Hh.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",jc(this.options.HTMLAttributes,t),0]}});function Gg({content:t,onChange:s,placeholder:r="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=S.useState(!1),[i,d]=S.useState(""),[u,p]=S.useState(!0),x=Ike({extensions:[Dke,Hke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),Gke.configure({types:["heading","paragraph"]}),Wke,g9t.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}),_Bt.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}),bBt.extend({addAttributes(){var N;return{...(N=this.parent)==null?void 0:N.call(this),style:{default:null}}}}),wBt.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}}}}),jBt.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 k=(C=w.clipboardData)==null?void 0:C.items;if(!k)return!1;for(const E of Array.from(k))if(E.type.startsWith("image/")){w.preventDefault();const L=E.getAsFile();if(!L)continue;const I=new FileReader;return I.onload=O=>{var q;const V=(q=O.target)==null?void 0:q.result;N.dispatch(N.state.tr.replaceSelectionWith(N.state.schema.nodes.image.create({src:V})))},I.readAsDataURL(L),!0}return!1}}});S.useEffect(()=>{x&&t!==x.getHTML()&&x.commands.setContent(t)},[t,x]);const y=()=>{if(!x)return;const N=x.getAttributes("link").href||"",w=x.getAttributes("link").target;d(N),p(w==="_blank"),l(!0)},_=()=>{x&&(i===""?x.chain().focus().extendMarkRange("link").unsetLink().run():x.chain().focus().extendMarkRange("link").setLink({href:i,target:u?"_blank":null,rel:u?"noopener noreferrer nofollow":null}).run(),l(!1),d(""))},b=()=>{x&&x.chain().focus().extendMarkRange("link").unsetLink().run()};return x?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:()=>x.chain().focus().toggleHeading({level:1}).run(),className:x.isActive("heading",{level:1})?"bg-muted":"",title:"Heading 1",children:e.jsx(wM,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>x.chain().focus().toggleHeading({level:2}).run(),className:x.isActive("heading",{level:2})?"bg-muted":"",title:"Heading 2",children:e.jsx(jM,{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:()=>x.chain().focus().toggleBold().run(),className:x.isActive("bold")?"bg-muted":"",title:"Bold",children:e.jsx(V4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>x.chain().focus().toggleItalic().run(),className:x.isActive("italic")?"bg-muted":"",title:"Italic",children:e.jsx(J4,{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:()=>x.chain().focus().toggleBulletList().run(),className:x.isActive("bulletList")?"bg-muted":"",title:"Bullet List",children:e.jsx(Dh,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>x.chain().focus().toggleOrderedList().run(),className:x.isActive("orderedList")?"bg-muted":"",title:"Numbered List",children:e.jsx(Zy,{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:()=>x.chain().focus().setTextAlign("left").run(),className:x.isActive({textAlign:"left"})?"bg-muted":"",title:"Align Left",children:e.jsx($4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>x.chain().focus().setTextAlign("center").run(),className:x.isActive({textAlign:"center"})?"bg-muted":"",title:"Align Center",children:e.jsx(B4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>x.chain().focus().setTextAlign("right").run(),className:x.isActive({textAlign:"right"})?"bg-muted":"",title:"Align Right",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:y,className:x.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(fo,{className:"h-4 w-4"})}),x.isActive("link")&&e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:b,title:"Remove Link",children:e.jsx(fo,{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:()=>x.chain().focus().undo().run(),disabled:!x.can().undo(),title:"Undo",children:e.jsx(yS,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>x.chain().focus().redo().run(),disabled:!x.can().redo(),title:"Redo",children:e.jsx(dS,{className:"h-4 w-4"})})]}),e.jsx(Eke,{editor:x,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(xe,{htmlFor:"link-url",children:"URL"}),e.jsx(De,{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(Er,{id:"link-new-tab",checked:u,onCheckedChange:p}),e.jsx(xe,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(En,{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 NBt=Object.defineProperty,kBt=(t,s,r)=>s in t?NBt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,cc=(t,s,r)=>kBt(t,typeof s!="symbol"?s+"":s,r);const oce={x:0,y:0,width:0,height:0,unit:"px"},x5=(t,s,r)=>Math.min(Math.max(t,s),r),SBt=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),q8e=(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 CBt(t,s,r,n){const a=Ey(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==="%"?R_(a,r,n):a}function MBt(t,s,r){const n=Ey(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?R_(n,s,r):n}function R_(t,s,r){return t.unit==="%"?{...oce,...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 Ey(t,s,r){return t.unit?t.unit==="px"?{...oce,...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}:{...oce,...t,unit:"px"}}function U8e(t,s,r,n,a,o=0,l=0,i=n,d=a){const u={...t};let p=Math.min(o,n),x=Math.min(l,a),y=Math.min(i,n),_=Math.min(d,a);s&&(s>1?(p=l?l*s:p,x=p/s,y=i*s):(x=o?o/s:x,p=x*s,_=d/s)),u.y<0&&(u.height=Math.max(u.height+u.y,x),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-x),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 k=Math.max(u.height*s,p);(r==="sw"||r=="nw")&&(u.x-=k-u.width),u.width=k}}return u}function TBt(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 g5={capture:!0,passive:!1};let ABt=0;const C_=class cg extends S.PureComponent{constructor(){super(...arguments),cc(this,"docMoveBound",!1),cc(this,"mouseDownOnCrop",!1),cc(this,"dragStarted",!1),cc(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),cc(this,"componentRef",S.createRef()),cc(this,"mediaRef",S.createRef()),cc(this,"resizeObserver"),cc(this,"initChangeCalled",!1),cc(this,"instanceId",`rc-${ABt++}`),cc(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),cc(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=Ey(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,x=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,x=o.y+o.height):l==="se"||l==="s"?(b=y-(o.x+o.width),N=_-(o.y+o.height),p=o.x,x=o.y):l==="sw"||l=="w"?(b=y-o.x,N=_-(o.y+o.height),p=o.x+o.width,x=o.y):(l==="nw"||l=="n")&&(b=y-o.x,N=_-o.y,p=o.x+o.width,x=o.y+o.height),d=p+a.x+b,u=x+a.y+N}this.evData={startClientX:d,startClientY:u,startCropX:p,startCropY:x,clientX:s.clientX,clientY:s.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),cc(this,"onComponentPointerDown",s=>{const{crop:r,disabled:n,locked:a,keepSelection:o,onChange:l}=this.props,i=this.getBox();if(n||a||o&&r)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const d=s.clientX-i.x,u=s.clientY-i.y,p={unit:"px",x:d,y:u,width:0,height:0};this.evData={startClientX:s.clientX,startClientY:s.clientY,startCropX:d,startCropY:u,clientX:s.clientX,clientY:s.clientY,isResize:!0},this.mouseDownOnCrop=!0,l(Ey(p,i.width,i.height),R_(p,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),cc(this,"onDocPointerMove",s=>{const{crop:r,disabled:n,onChange:a,onDragStart:o}=this.props,l=this.getBox();if(n||!r||!this.mouseDownOnCrop)return;s.cancelable&&s.preventDefault(),this.dragStarted||(this.dragStarted=!0,o&&o(s));const{evData:i}=this;i.clientX=s.clientX,i.clientY=s.clientY;let d;i.isResize?d=this.resizeCrop():d=this.dragCrop(),q8e(r,d)||a(Ey(d,l.width,l.height),R_(d,l.width,l.height))}),cc(this,"onComponentKeyDown",s=>{const{crop:r,disabled:n,onChange:a,onComplete:o}=this.props;if(n)return;const l=s.key;let i=!1;if(!r)return;const d=this.getBox(),u=this.makePixelCrop(d),p=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?cg.nudgeStepLarge:s.shiftKey?cg.nudgeStepMedium:cg.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=x5(u.x,0,d.width-u.width),u.y=x5(u.y,0,d.height-u.height);const x=Ey(u,d.width,d.height),y=R_(u,d.width,d.height);a(x,y),o&&o(x,y)}}),cc(this,"onHandlerKeyDown",(s,r)=>{const{aspect:n=0,crop:a,disabled:o,minWidth:l=0,minHeight:i=0,maxWidth:d,maxHeight:u,onChange:p,onComplete:x}=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)?cg.nudgeStepLarge:s.shiftKey?cg.nudgeStepMedium:cg.nudgeStep,b=Ey(a,y.width,y.height),N=TBt(b,s.key,_,r),w=U8e(N,n,r,y.width,y.height,l,i,d,u);if(!q8e(a,w)){const k=R_(w,y.width,y.height);p(w,k),x&&x(w,k)}}),cc(this,"onDocPointerDone",s=>{const{crop:r,disabled:n,onComplete:a,onDragEnd:o}=this.props,l=this.getBox();this.unbindDocMove(),!(n||!r)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,o&&o(s),a&&a(Ey(r,l.width,l.height),R_(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),cc(this,"onDragFocus",()=>{var s;(s=this.componentRef.current)==null||s.scrollTo(0,0)})}get document(){return document}getBox(){const s=this.mediaRef.current;if(!s)return{x:0,y:0,width:0,height:0};const{x:r,y:n,width:a,height:o}=s.getBoundingClientRect();return{x:r,y:n,width:a,height:o}}componentDidUpdate(s){const{crop:r,onComplete:n}=this.props;if(n&&!s.crop&&r){const{width:a,height:o}=this.getBox();a&&o&&n(Ey(r,a,o),R_(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,g5),this.document.addEventListener("pointerup",this.onDocPointerDone,g5),this.document.addEventListener("pointercancel",this.onDocPointerDone,g5),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,g5),this.document.removeEventListener("pointerup",this.onDocPointerDone,g5),this.document.removeEventListener("pointercancel",this.onDocPointerDone,g5),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=x5(s.startCropX+a,0,r.width-n.width),n.y=x5(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 x=s.clientX-s.startClientX,y=s.clientY-s.startClientY;(l&&p==="nw"||p==="w"||p==="sw")&&(x=Math.min(x,-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=x,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=x,r?_.height=_.width/r:_.height=y):u==="sw"?(_.x=s.startCropX+x,_.y=s.startCropY,_.width=Math.abs(x),r?_.height=_.width/r:_.height=y):u==="nw"&&(_.x=s.startCropX+x,_.width=Math.abs(x),r?(_.height=_.width/r,_.y=s.startCropY-_.height):(_.height=Math.abs(y),_.y=s.startCropY+y));const b=U8e(_,r,u,o.width,o.height,l,i,n,a);return r||cg.xyOrds.indexOf(p)>-1?d=b:cg.xOrds.indexOf(p)>-1?(d.x=b.x,d.width=b.width):cg.yOrds.indexOf(p)>-1&&(d.y=b.y,d.height=b.height),d.x=x5(d.x,0,o.width-d.width),d.y=x5(d.y,0,o.height-d.height),d}renderCropSelection(){const{ariaLabels:s=cg.defaultProps.ariaLabels,disabled:r,locked:n,renderSelectionAddon:a,ruleOfThirds:o,crop:l}=this.props,i=this.getCropStyle();if(l)return ft.createElement("div",{style:i,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":s.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!r&&!n&&ft.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},ft.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),ft.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),ft.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),ft.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),ft.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"}),ft.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"}),ft.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"}),ft.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"}),ft.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"}),ft.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"}),ft.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"}),ft.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&&ft.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:d=>d.stopPropagation()},a(this.state)),o&&ft.createElement(ft.Fragment,null,ft.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),ft.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(s){const r={...oce,...this.props.crop||{}};return Ey(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:x}=this.state,y=o?this.renderCropSelection():null,_=SBt("ReactCrop",a,p&&"ReactCrop--active",l&&"ReactCrop--disabled",i&&"ReactCrop--locked",x&&"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 ft.createElement("div",{ref:this.componentRef,className:_,style:d},ft.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},r),o?ft.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},ft.createElement("defs",null,ft.createElement("mask",{id:`hole-${this.instanceId}`},ft.createElement("rect",{width:"100%",height:"100%",fill:"white"}),n?ft.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"}):ft.createElement("rect",{x:`${o.x}${o.unit}`,y:`${o.y}${o.unit}`,width:`${o.width}${o.unit}`,height:`${o.height}${o.unit}`,fill:"black"}))),ft.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,y)}};cc(C_,"xOrds",["e","w"]),cc(C_,"yOrds",["n","s"]),cc(C_,"xyOrds",["nw","ne","se","sw"]),cc(C_,"nudgeStep",1),cc(C_,"nudgeStepMedium",10),cc(C_,"nudgeStepLarge",100),cc(C_,"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 EBt=C_;var net=["PageUp","PageDown"],aet=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],iet={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},JA="Slider",[q_e,PBt,IBt]=yR(JA),[oet,zTs]=$c(JA,[IBt]),[LBt,_he]=oet(JA),cet=S.forwardRef((t,s)=>{const{name:r,min:n=0,max:a=100,step:o=1,orientation:l="horizontal",disabled:i=!1,minStepsBetweenThumbs:d=0,defaultValue:u=[n],value:p,onValueChange:x=()=>{},onValueCommit:y=()=>{},inverted:_=!1,form:b,...N}=t,w=S.useRef(new Set),k=S.useRef(0),E=l==="horizontal"?DBt:RBt,[L=[],I]=$u({prop:p,defaultProp:u,onChange:se=>{var J;(J=[...w.current][k.current])==null||J.focus(),x(se)}}),O=S.useRef(L);function V(se){const Y=$Bt(L,se);U(se,Y)}function q(se){U(se,k.current)}function $(){const se=O.current[k.current];L[k.current]!==se&&y(L)}function U(se,Y,{commit:J}={commit:!1}){const X=HBt(o),ce=GBt(Math.round((se-n)/o)*o+n,X),ie=eD(ce,[n,a]);I((ae=[])=>{const oe=zBt(ae,ie,Y);if(VBt(oe,d*o)){k.current=oe.indexOf(ie);const pe=String(oe)!==String(ae);return pe&&J&&y(oe),pe?oe:ae}else return ae})}return e.jsx(LBt,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:k,thumbs:w.current,values:L,orientation:l,form:b,children:e.jsx(q_e.Provider,{scope:t.__scopeSlider,children:e.jsx(q_e.Slot,{scope:t.__scopeSlider,children:e.jsx(E,{"aria-disabled":i,"data-disabled":i?"":void 0,...N,ref:s,onPointerDown:Cr(N.onPointerDown,()=>{i||(O.current=L)}),min:n,max:a,inverted:_,onSlideStart:i?void 0:V,onSlideMove:i?void 0:q,onSlideEnd:i?void 0:$,onHomeKeyDown:()=>!i&&U(n,0,{commit:!0}),onEndKeyDown:()=>!i&&U(a,L.length-1,{commit:!0}),onStepKeyDown:({event:se,direction:Y})=>{if(!i){const ce=net.includes(se.key)||se.shiftKey&&aet.includes(se.key)?10:1,ie=k.current,ae=L[ie],oe=o*ce*Y;U(ae+oe,ie,{commit:!0})}}})})})})});cet.displayName=JA;var[det,uet]=oet(JA,{startEdge:"left",endEdge:"right",size:"width",direction:1}),DBt=S.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:d,onStepKeyDown:u,...p}=t,[x,y]=S.useState(null),_=Aa(s,E=>y(E)),b=S.useRef(void 0),N=uw(a),w=N==="ltr",k=w&&!o||!w&&o;function C(E){const L=b.current||x.getBoundingClientRect(),I=[0,L.width],V=Zke(I,k?[r,n]:[n,r]);return b.current=L,V(E-L.left)}return e.jsx(det,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:e.jsx(het,{dir:N,"data-orientation":"horizontal",...p,ref:_,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:E=>{const L=C(E.clientX);l==null||l(L)},onSlideMove:E=>{const L=C(E.clientX);i==null||i(L)},onSlideEnd:()=>{b.current=void 0,d==null||d()},onStepKeyDown:E=>{const I=iet[k?"from-left":"from-right"].includes(E.key);u==null||u({event:E,direction:I?-1:1})}})})}),RBt=S.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:d,...u}=t,p=S.useRef(null),x=Aa(s,p),y=S.useRef(void 0),_=!a;function b(N){const w=y.current||p.current.getBoundingClientRect(),k=[0,w.height],E=Zke(k,_?[n,r]:[r,n]);return y.current=w,E(N-w.top)}return e.jsx(det,{scope:t.__scopeSlider,startEdge:_?"bottom":"top",endEdge:_?"top":"bottom",size:"height",direction:_?1:-1,children:e.jsx(het,{"data-orientation":"vertical",...u,ref:x,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 k=iet[_?"from-bottom":"from-top"].includes(N.key);d==null||d({event:N,direction:k?-1:1})}})})}),het=S.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:d,...u}=t,p=_he(JA,r);return e.jsx(Yr.span,{...u,ref:s,onKeyDown:Cr(t.onKeyDown,x=>{x.key==="Home"?(l(x),x.preventDefault()):x.key==="End"?(i(x),x.preventDefault()):net.concat(aet).includes(x.key)&&(d(x),x.preventDefault())}),onPointerDown:Cr(t.onPointerDown,x=>{const y=x.target;y.setPointerCapture(x.pointerId),x.preventDefault(),p.thumbs.has(y)?y.focus():n(x)}),onPointerMove:Cr(t.onPointerMove,x=>{x.target.hasPointerCapture(x.pointerId)&&a(x)}),onPointerUp:Cr(t.onPointerUp,x=>{const y=x.target;y.hasPointerCapture(x.pointerId)&&(y.releasePointerCapture(x.pointerId),o(x))})})}),met="SliderTrack",pet=S.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=_he(met,r);return e.jsx(Yr.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});pet.displayName=met;var U_e="SliderRange",fet=S.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=_he(U_e,r),o=uet(U_e,r),l=S.useRef(null),i=Aa(s,l),d=a.values.length,u=a.values.map(y=>yet(y,a.min,a.max)),p=d>1?Math.min(...u):0,x=100-Math.max(...u);return e.jsx(Yr.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:i,style:{...t.style,[o.startEdge]:p+"%",[o.endEdge]:x+"%"}})});fet.displayName=U_e;var V_e="SliderThumb",xet=S.forwardRef((t,s)=>{const r=PBt(t.__scopeSlider),[n,a]=S.useState(null),o=Aa(s,i=>a(i)),l=S.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(OBt,{...t,ref:o,index:l})}),OBt=S.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=_he(V_e,r),i=uet(V_e,r),[d,u]=S.useState(null),p=Aa(s,C=>u(C)),x=d?l.form||!!d.closest("form"):!0,y=bR(d),_=l.values[n],b=_===void 0?0:yet(_,l.min,l.max),N=BBt(n,l.values.length),w=y==null?void 0:y[i.size],k=w?qBt(w,b,i.direction):0;return S.useEffect(()=>{if(d)return l.thumbs.add(d),()=>{l.thumbs.delete(d)}},[d,l.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${b}% + ${k}px)`},children:[e.jsx(q_e.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(Yr.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:Cr(t.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),x&&e.jsx(get,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:_},n)]})});xet.displayName=V_e;var FBt="RadioBubbleInput",get=S.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=S.useRef(null),o=Aa(a,n),l=DR(s);return S.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&p){const x=new Event("input",{bubbles:!0});p.call(i,s),i.dispatchEvent(x)}},[l,s]),e.jsx(Yr.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});get.displayName=FBt;function zBt(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function yet(t,s,r){const o=100/(r-s)*(t-s);return eD(o,[0,100])}function BBt(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function $Bt(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 qBt(t,s,r){const n=t/2,o=Zke([0,50],[0,n]);return(n-o(s)*r)*r}function UBt(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function VBt(t,s){if(s>0){const r=UBt(t);return Math.min(...r)>=s}return!0}function Zke(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 HBt(t){return(String(t).split(".")[1]||"").length}function GBt(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var vet=cet,WBt=pet,KBt=fet,ZBt=xet;const Cg=S.forwardRef(({className:t,...s},r)=>e.jsxs(vet,{ref:r,className:Rt("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(WBt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(KBt,{className:"absolute h-full bg-primary"})}),e.jsx(ZBt,{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"})]}));Cg.displayName=vet.displayName;function YBt(t,s,r){return MBt(CBt({unit:"%",width:90},r,t,s),t,s)}const Yke=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=S.useRef(null),[l,i]=S.useState(),[d,u]=S.useState(),[p,x]=S.useState(1),[y,_]=S.useState(0),b=S.useCallback(k=>{const{width:C,height:E}=k.currentTarget;i(YBt(C,E,a))},[a]),N=S.useCallback(async()=>{const k=o.current;if(!k||!d)return;const C=document.createElement("canvas"),E=C.getContext("2d");if(!E)return;const L=k.naturalWidth/k.width,I=k.naturalHeight/k.height,O=400;C.width=O,C.height=O,E.imageSmoothingQuality="high";const V=d.x*L,q=d.y*I,$=d.width*L,U=d.height*I,se=y*Math.PI/180,Y=C.width/2,J=C.height/2;return E.save(),E.translate(Y,J),E.rotate(se),E.scale(p,p),E.translate(-Y,-J),E.drawImage(k,V,q,$,U,0,0,O,O),E.restore(),new Promise((X,ce)=>{C.toBlob(ie=>{ie?X(ie):ce(new Error("Canvas is empty"))},"image/jpeg",.95)})},[d,p,y]),w=async()=>{try{const k=await N();k&&(n(k),s())}catch(k){console.error("Error cropping image:",k)}};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(EBt,{crop:l,onChange:(k,C)=>i(C),onComplete:k=>u(k),aspect:a,circularCrop:!0,className:"max-h-[400px]",children:e.jsx("img",{ref:o,src:r,alt:"Crop preview",style:{transform:`scale(${p}) rotate(${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(RM,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Cg,{value:[p],min:.5,max:3,step:.1,onValueChange:([k])=>x(k),className:"flex-1"}),e.jsx(Ab,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(AL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Cg,{value:[y],min:-180,max:180,step:1,onValueChange:([k])=>_(k),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[y,"°"]})]})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(K,{onClick:w,children:"Save Photo"})]})]})})},XBt=()=>{const{user:t}=Fs(),{toast:s}=wa(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(null);S.useEffect(()=>{t&&d()},[t]);const d=async()=>{n(!0);try{const{data:x}=await G.from("profiles").select("subscription_status, subscription_product_id, subscription_end_date, is_grandfathered").eq("id",t==null?void 0:t.id).single();x&&i({status:x.subscription_status||"none",productId:x.subscription_product_id,endDate:x.subscription_end_date,isGrandfathered:x.is_grandfathered||!1})}catch(x){console.error("Error loading subscription:",x)}finally{n(!1)}},u=async()=>{o(!0);try{const{data:{session:x}}=await G.auth.getSession();if(!x)throw new Error("Not authenticated");const{data:y,error:_}=await G.functions.invoke("customer-portal",{headers:{Authorization:`Bearer ${x.access_token}`}});if(_)throw _;y!=null&&y.url&&window.open(y.url,"_blank")}catch(x){console.error("Error opening customer portal:",x),s({title:"Error",description:x.message||"Failed to open billing portal",variant:"destructive"})}finally{o(!1)}},p=()=>{if(l!=null&&l.isGrandfathered)return e.jsx(Qe,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(Qe,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(Qe,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(Qe,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(Qe,{variant:"secondary",children:"Canceled"});default:return e.jsx(Qe,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(yx,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(Re,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(_s,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(yx,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(hr,{children:"Manage your subscription and billing"})]}),e.jsxs(Re,{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(_s,{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."})]})]})},QBt=()=>{const{user:t}=Fs(),s=_r(),{toast:r}=wa(),[n]=Nc(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:d,subscribe:u,unsubscribe:p}=VYe(),[x,y]=S.useState(!1),[_,b]=S.useState(""),[N,w]=S.useState(!1),[k,C]=S.useState(!1),[E,L]=S.useState(""),[I,O]=S.useState({name:"",email:"",phone:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[V,q]=S.useState(!1),[$,U]=S.useState(!1),[se,Y]=S.useState({newPassword:"",confirmPassword:""});S.useEffect(()=>{t&&J()},[t]),S.useEffect(()=>{o&&t&&setTimeout(()=>{var oe;(oe=document.getElementById("change-password-section"))==null||oe.scrollIntoView({behavior:"smooth",block:"center"})},500)},[o,t]);const J=async()=>{var oe,pe,_e;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:((oe=he.years_experience)==null?void 0:oe.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:((pe=t.user_metadata)==null?void 0:pe.name)||((_e=t.email)==null?void 0:_e.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:je}=await G.storage.from("avatars").list(`${t.id}`);if(je&&je.length>0){const{data:Ue}=G.storage.from("avatars").getPublicUrl(`${t.id}/${je[0].name}`);b(Ue.publicUrl)}}catch(he){console.error("Error loading profile:",he),r({title:"Error",description:he.message||"Failed to load profile",variant:"destructive"})}},X=oe=>{var he;const pe=(he=oe.target.files)==null?void 0:he[0];if(!pe)return;const _e=new FileReader;_e.onloadend=()=>{L(_e.result),C(!0)},_e.readAsDataURL(pe),oe.target.value=""},ce=async oe=>{if(t){w(!0);try{const{data:pe}=await G.storage.from("avatars").list(`${t.id}`);pe&&pe.length>0&&await G.storage.from("avatars").remove(pe.map(Te=>`${t.id}/${Te.name}`));const he=`${t.id}/avatar.jpg`,{error:we}=await G.storage.from("avatars").upload(he,oe,{upsert:!0,contentType:"image/jpeg"});if(we)throw we;const{data:je}=G.storage.from("avatars").getPublicUrl(he),Ue=je.publicUrl;b(`${Ue}?t=${Date.now()}`),await G.from("profiles").update({avatar_url:Ue}).eq("id",t.id),r({title:"Success",description:"Profile photo updated successfully"})}catch(pe){console.error("Error uploading avatar:",pe),r({title:"Error",description:pe.message||"Failed to upload photo",variant:"destructive"})}finally{w(!1)}}},ie=async()=>{if(!I.name.trim()||!I.email.trim()){r({title:"Error",description:"Name and email are required",variant:"destructive"});return}y(!0);try{const{error:oe}=await G.from("profiles").update({name:I.name.trim(),email:I.email.trim(),phone:I.phone.trim()||null,title:I.title.trim()||null,bio:I.bio.trim()||null,areas_served:I.areas_served.trim()||null,years_experience:I.years_experience?parseInt(I.years_experience):null,instagram_url:I.instagram_url.trim()||null,facebook_url:I.facebook_url.trim()||null,linkedin_url:I.linkedin_url.trim()||null,email_signature:I.email_signature||"",use_email_signature:I.use_email_signature}).eq("id",t==null?void 0:t.id);if(oe)throw oe;r({title:"Success",description:"Profile updated successfully"})}catch(oe){console.error("Error updating profile:",oe),r({title:"Error",description:oe.message||"Failed to update profile",variant:"destructive"})}finally{y(!1)}},ae=async()=>{if(!se.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(se.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(se.newPassword!==se.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}y(!0);try{const{error:oe}=await G.auth.updateUser({password:se.newPassword});if(oe)throw oe;r({title:"Success",description:"Password updated successfully"}),Y({newPassword:"",confirmPassword:""}),a&&setTimeout(()=>s("/dashboard"),1e3)}catch(oe){console.error("Error updating password:",oe),r({title:"Error",description:oe.message||"Failed to update password",variant:"destructive"})}finally{y(!1)}};return e.jsx(Es,{title:a?"Complete Your Profile":o?"Reset Your Password":"Profile Settings",description:a?"Welcome! Please complete your profile setup":o?"Please set a new password for your account":"Manage your account information and password",children:e.jsxs("div",{className:"mx-auto max-w-4xl",children:[!a&&!o&&e.jsx("div",{className:"mb-6",children:e.jsxs(K,{variant:"outline",onClick:()=>{var oe;(oe=document.getElementById("change-password-section"))==null||oe.scrollIntoView({behavior:"smooth",block:"center"})},className:"gap-2",children:[e.jsx(eS,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"Profile Photo"}),e.jsx(hr,{children:"Upload a professional photo for your profile"})]}),e.jsxs(Re,{className:"flex items-center gap-6",children:[e.jsxs(vn,{className:"h-24 w-24",children:[e.jsx(Ta,{src:_}),e.jsx(_n,{className:"text-2xl",children:I.name.split(" ").map(oe=>oe[0]).join("").toUpperCase()||"U"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",id:"avatar-upload",accept:"image/*",className:"hidden",onChange:X,disabled:N}),e.jsxs(K,{variant:"outline",onClick:()=>{var oe;return(oe=document.getElementById("avatar-upload"))==null?void 0:oe.click()},disabled:N,children:[e.jsx($a,{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(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"Personal Information"}),e.jsx(hr,{children:"Update your profile details"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",value:I.name,onChange:oe=>O({...I,name:oe.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"email",children:"Email"}),e.jsx(De,{id:"email",type:"email",value:I.email,onChange:oe=>O({...I,email:oe.target.value}),maxLength:255})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"phone",children:"Phone Number"}),e.jsx(De,{id:"phone",type:"tel",value:I.phone,onChange:oe=>O({...I,phone:oe.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(xe,{htmlFor:"title",children:"Job Title"}),e.jsx(De,{id:"title",value:I.title,onChange:oe=>O({...I,title:oe.target.value}),placeholder:"e.g., Broker Associate, Team Lead",maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"bio",children:"Bio"}),e.jsx(vr,{id:"bio",value:I.bio,onChange:oe=>O({...I,bio:oe.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(xe,{htmlFor:"areas_served",children:"Areas Served"}),e.jsx(De,{id:"areas_served",value:I.areas_served,onChange:oe=>O({...I,areas_served:oe.target.value}),placeholder:"e.g., Downtown, Suburbs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"years_experience",children:"Years Experience"}),e.jsx(De,{id:"years_experience",type:"number",min:"0",value:I.years_experience,onChange:oe=>O({...I,years_experience:oe.target.value}),placeholder:"e.g., 5"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Social Links"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsx(De,{value:I.linkedin_url,onChange:oe=>O({...I,linkedin_url:oe.target.value}),placeholder:"LinkedIn URL"}),e.jsx(De,{value:I.instagram_url,onChange:oe=>O({...I,instagram_url:oe.target.value}),placeholder:"Instagram URL"}),e.jsx(De,{value:I.facebook_url,onChange:oe=>O({...I,facebook_url:oe.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(K,{onClick:ie,disabled:x,children:[e.jsx(_c,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Tv,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(hr,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Use email signature in all emails"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:I.use_email_signature?"Your signature will be added to every email sent via Gmail":"Signature is currently disabled"})]}),e.jsx(Er,{checked:I.use_email_signature,onCheckedChange:oe=>O({...I,use_email_signature:oe})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Signature"}),e.jsx(Gg,{content:I.email_signature,onChange:oe=>O({...I,email_signature:oe}),placeholder:"Paste your Gmail signature here or create one...",minHeight:"120px",compact:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tip: Copy your signature from Gmail Settings and paste it here — images and formatting will be preserved."})]}),e.jsxs(K,{onClick:ie,disabled:x,children:[e.jsx(_c,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(Pe,{id:"change-password-section",children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:a?"Set Your Password":"Change Password"}),e.jsx(hr,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"newPassword",children:"New Password"}),e.jsx(De,{id:"newPassword",type:"password",value:se.newPassword,onChange:oe=>Y({...se,newPassword:oe.target.value}),placeholder:"Min 6 characters"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(De,{id:"confirmPassword",type:"password",value:se.confirmPassword,onChange:oe=>Y({...se,confirmPassword:oe.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(K,{onClick:ae,disabled:x,children:[e.jsx(_c,{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(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[i?e.jsx(Sm,{className:"h-5 w-5"}):e.jsx(Gv,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(hr,{children:"Receive browser notifications when new content is added"})]}),e.jsx(Re,{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(Er,{checked:i,onCheckedChange:oe=>{oe?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(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[V?e.jsx(gL,{className:"h-5 w-5"}):e.jsx(rr,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(hr,{children:"Manage your email subscription settings"})]}),e.jsx(Re,{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:V?"You won't receive weekly digest emails":"Receive a weekly summary of new content, events, and your progress"})]}),e.jsx(Er,{checked:!V,onCheckedChange:async oe=>{U(!0);try{const{error:pe}=await G.from("profiles").update({digest_opt_out:!oe}).eq("id",t==null?void 0:t.id);if(pe)throw pe;q(!oe),r({title:oe?"Subscribed":"Unsubscribed",description:oe?"You will now receive weekly digest emails":"You will no longer receive weekly digest emails"})}catch(pe){r({title:"Error",description:pe.message||"Failed to update preference",variant:"destructive"})}finally{U(!1)}},disabled:$})]})})]}),e.jsx(w8t,{}),e.jsx(XBt,{})]}),e.jsx(Yke,{open:k,onClose:()=>C(!1),imageSrc:E,onCropComplete:ce,aspectRatio:1})]})})};var JBt="AspectRatio",_et=S.forwardRef((t,s)=>{const{ratio:r=1/1,style:n,...a}=t;return e.jsx("div",{style:{position:"relative",width:"100%",paddingBottom:`${100/r}%`},"data-radix-aspect-ratio-wrapper":"",children:e.jsx(Yr.div,{...a,ref:s,style:{...n,position:"absolute",top:0,right:0,bottom:0,left:0}})})});_et.displayName=JBt;var e$t=_et;const t$t=e$t;function s$t(){const{user:t}=Fs(),s=Jt(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),{data:l,isLoading:i}=gt({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=It({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))},x=()=>{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(pi,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-5 w-5 text-primary"}),"Subscribe to Events Calendar"]}),e.jsx(Ir,{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(_s,{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(De,{value:u,readOnly:!0,className:"text-xs font-mono"}),e.jsx(K,{variant:"outline",size:"icon",onClick:p,children:r?e.jsx(Jn,{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:x,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(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(on,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}const r$t={first_timer:Hn,regular:Xv,dedicated:ec,veteran:Vi,streak_master:ch,century:Vi},n$t={first_timer:"bg-green-500/10 text-green-500 border-green-500/20",regular:"bg-blue-500/10 text-blue-500 border-blue-500/20",dedicated:"bg-purple-500/10 text-purple-500 border-purple-500/20",veteran:"bg-amber-500/10 text-amber-500 border-amber-500/20",streak_master:"bg-orange-500/10 text-orange-500 border-orange-500/20",century:"bg-yellow-500/10 text-yellow-500 border-yellow-500/20"};function V8e(t){return t===1?e.jsx(Vi,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(Xv,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(ec,{className:"h-5 w-5 text-amber-600"}):e.jsx("span",{className:"w-5 text-center text-sm font-medium text-muted-foreground",children:t})}function bet({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=Fs(),{data:o,isLoading:l}=SXe(s?5:10,r),{data:i}=CXe(a==null?void 0:a.id),{data:d}=TXe(a==null?void 0:a.id),{data:u}=MXe(a==null?void 0:a.id);return l?e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Vi,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((p,x)=>e.jsx(Ns,{className:"h-12 w-full"},x))})})]}):e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Vi,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsxs(Re,{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(Qe,{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 x=r$t[p.badge_type]||Hn;return e.jsxs(Qe,{variant:"outline",className:`text-xs ${n$t[p.badge_type]||""}`,title:p.badge_description||"",children:[e.jsx(x,{className:"h-3 w-3 mr-1"}),p.badge_name]},p.id)}),u.length>4&&e.jsxs(Qe,{variant:"outline",className:"text-xs",children:["+",u.length-4," more"]})]})]}),e.jsxs(ia,{defaultValue:"points",className:"w-full",children:[e.jsxs(ea,{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,x)=>{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":""} ${x===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:V8e(x+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,x)=>x.total_events_attended-p.total_events_attended).map((p,x)=>{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":""} ${x===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:V8e(x+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 a$t(){const t=_r(),{user:s,isAdmin:r}=Fs(),n=Jt(),{data:a,isLoading:o}=gt({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}=gt({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}=gt({queryKey:["event-registration-counts"],queryFn:async()=>{let N=[],w=0;const k=1e3;for(;;){const{data:E,error:L}=await G.from("event_registrations").select("event_id").range(w,w+k-1);if(L)throw L;if(!E||E.length===0||(N=N.concat(E),E.length{C[E.event_id]=(C[E.event_id]||0)+1}),C}}),d=It({mutationFn:async N=>{await G.auth.refreshSession();const{data:w,error:k}=await G.functions.invoke("zoom-register",{body:{event_id:N}});if(k)throw k;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=It({mutationFn:async N=>{const{data:w,error:k}=await G.functions.invoke("zoom-unregister",{body:{event_id:N}});if(k)throw k;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),me.success("Registration cancelled and removed from Zoom")},onError:N=>{me.error("Failed to cancel: "+N.message)}}),p=N=>l==null?void 0:l.some(w=>w.event_id===N),x=N=>{const w=l==null?void 0:l.find(k=>k.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=>VM(N.event_date)!=="ended"))||[],b=(a==null?void 0:a.filter(N=>VM(N.event_date)==="ended"))||[];return e.jsx(Es,{title:"Events",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Events"}),e.jsx("p",{className:"text-muted-foreground",children:"Browse and register for upcoming events"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(s$t,{}),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(Pe,{className:"text-center py-12",children:e.jsx(Re,{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=VM(N.event_date),k=QNe(N.event_date),C=w==="live",E=w==="starting_soon";return e.jsxs(Pe,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${C?"border-red-500 ring-2 ring-red-500/20":E?"border-amber-500 ring-2 ring-amber-500/20":"hover:border-primary/50"}`,onClick:()=>t(`/events/${N.id}`),children:[k&&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(Jv,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):e.jsxs(e.Fragment,{children:[e.jsx(ln,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),N.image_url&&e.jsx(t$t,{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(Ot,{className:"line-clamp-2",children:N.title}),N.description&&e.jsx(hr,{className:"line-clamp-2",children:N.description.replace(/<[^>]*>/g,"")})]}),e.jsxs(Re,{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(on,{className:"h-4 w-4"}),new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(N.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ln,{className:"h-4 w-4"}),oD(new Date(N.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(lr,{className:"h-4 w-4"}),(i==null?void 0:i[N.id])||0," registered",N.capacity&&` / ${N.capacity} spots`]})]}),e.jsx(GL,{className:"flex gap-2",onClick:L=>L.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(x(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(Jn,{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(Pe,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${N.id}`),children:e.jsxs(Lt,{children:[e.jsx(Ot,{className:"text-base line-clamp-1",children:N.title}),e.jsx(hr,{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(bet,{showUserStats:!0})})]})]})})}const xye=[{value:"all",label:"All Roles",icon:lr},{value:"newest",label:"Newest Members",icon:ln},{value:"brokerage_manager",label:"Brokerage Managers",icon:BL},{value:"admin",label:"Admins",icon:Ou}];function i$t({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var qe,ze;const{user:o,isAdmin:l,isBrokerageManager:i}=Fs(),[d,u]=S.useState([]),[p,x]=S.useState([]),[y,_]=S.useState([]),[b,N]=S.useState([]),[w,k]=S.useState(""),[C,E]=S.useState(""),[L,I]=S.useState(""),[O,V]=S.useState(!1),[q,$]=S.useState(!1),[U,se]=S.useState("agents"),[Y,J]=S.useState("all"),[X,ce]=S.useState({}),ie=l||i;S.useEffect(()=>{t&&o&&(l?ae():oe())},[t,o,l]),S.useEffect(()=>{t||(_([]),N([]),k(""),E(""),I(""),se("agents"),J("all"))},[t]);const ae=async()=>{if(o){V(!0);try{const{data:ve,error:dt}=await G.from("brokerages").select("id, name").order("name");if(dt)throw dt;const fe=1e3,Ve={};let Je=0,at=!0;for(;at;){const{data:We,error:ot}=await G.from("profiles").select("brokerage_id").range(Je*fe,(Je+1)*fe-1);if(ot)throw ot;We==null||We.forEach(Ge=>{Ge.brokerage_id&&(Ve[Ge.brokerage_id]=(Ve[Ge.brokerage_id]||0)+1)}),at=(We==null?void 0:We.length)===fe,Je++}x((ve==null?void 0:ve.map(We=>({...We,agent_count:Ve[We.id]||0})))||[]);const Ae=[];for(Je=0,at=!0;at;){const{data:We,error:ot}=await G.from("profiles").select("id, name, email, brokerage_id, created_at, brokerages(name)").neq("id",o.id).order("name").range(Je*fe,(Je+1)*fe-1);if(ot)throw ot;We&&Ae.push(...We),at=(We==null?void 0:We.length)===fe,Je++}const Ye={};for(Je=0,at=!0;at;){const{data:We,error:ot}=await G.from("user_roles").select("user_id, role").range(Je*fe,(Je+1)*fe-1);if(ot)throw ot;We==null||We.forEach(Ge=>{Ye[Ge.user_id]||(Ye[Ge.user_id]=[]),Ye[Ge.user_id].push(Ge.role)}),at=(We==null?void 0:We.length)===fe,Je++}ce(Ye),u(Ae.map(We=>{var ot;return{id:We.id,name:We.name,email:We.email,brokerage_name:((ot=We.brokerages)==null?void 0:ot.name)||"No Brokerage",roles:Ye[We.id]||[],created_at:We.created_at}}))}catch(ve){console.error("Error loading data:",ve),me.error("Failed to load agents and brokerages")}finally{V(!1)}}},oe=async()=>{if(o){V(!0);try{const{data:ve}=await G.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(ve!=null&&ve.brokerage_id)){me.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:dt,error:fe}=await G.from("profiles").select("id, name, email").eq("brokerage_id",ve.brokerage_id).neq("id",o.id).order("name");if(fe)throw fe;u(dt||[])}catch(ve){console.error("Error loading agents:",ve),me.error("Failed to load agents")}finally{V(!1)}}},pe=d.filter(ve=>{var fe;const dt=ve.name.toLowerCase().includes(w.toLowerCase())||ve.email.toLowerCase().includes(w.toLowerCase())||((fe=ve.brokerage_name)==null?void 0:fe.toLowerCase().includes(w.toLowerCase()));if(l&&Y!=="all"&&Y!=="newest"){const Ve=X[ve.id]||[];return dt&&Ve.includes(Y)}return dt}).sort((ve,dt)=>Y==="newest"?(dt.created_at||"").localeCompare(ve.created_at||""):0),_e=p.filter(ve=>ve.name.toLowerCase().includes(C.toLowerCase())),he=()=>{y.length===pe.length?_([]):_(pe.map(ve=>ve.id))},we=()=>{b.length===_e.length?N([]):N(_e.map(ve=>ve.id))},je=ve=>{if(!ie){_([ve]);return}_(dt=>dt.includes(ve)?dt.filter(fe=>fe!==ve):[...dt,ve])},Ue=ve=>{N(dt=>dt.includes(ve)?dt.filter(fe=>fe!==ve):[...dt,ve])},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:dt,error:fe}=await G.functions.invoke("send-share-notification",{body:{recipientIds:y,brokerageIds:b,resourceType:r,resourceId:n,resourceTitle:a,message:L.trim()||void 0}});if(fe)throw fe;const Ve=(dt==null?void 0:dt.sharesCreated)||y.length;me.success(`Shared with ${Ve} agent${Ve!==1?"s":""}`),s(!1)}catch(dt){console.error("Error sharing resource:",dt),me.error("Failed to share resource")}finally{$(!1)}},Me=ve=>ve.split(" ").map(dt=>dt[0]).join("").toUpperCase().slice(0,2),Fe=ve=>{const dt=X[ve]||[];return dt.includes("admin")?e.jsx(Qe,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):dt.includes("brokerage_manager")?e.jsx(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},Le=y.length+b.length,Ne=Y!=="all"&&Y!=="newest"?pe.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(An,{className:"h-5 w-5 text-primary"}),"Share Resource"]}),e.jsxs(Ir,{className:"line-clamp-2",children:['Share "',a,'" with ',l?"agents or brokerages":"agents in your brokerage"]})]}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[l?e.jsxs(ia,{value:U,onValueChange:se,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(ea,{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(lr,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),y.length>0&&e.jsx(Qe,{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(pa,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),b.length>0&&e.jsx(Qe,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name, email, or brokerage...",value:w,onChange:ve=>k(ve.target.value),className:"pl-9"})]}),e.jsxs(Bs,{value:Y,onValueChange:J,children:[e.jsxs(Rs,{className:"w-[180px]",children:[e.jsx(Eg,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(qs,{placeholder:"Filter by role"})]}),e.jsx(Os,{children:xye.map(ve=>e.jsx(vt,{value:ve.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve.icon,{className:"h-4 w-4"}),e.jsx("span",{children:ve.label})]})},ve.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:pe.length===0,children:[e.jsx(lr,{className:"h-3.5 w-3.5 mr-1.5"}),y.length===pe.length&&pe.length>0?"Deselect All":"Select All"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[Ne!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[Ne," ",(qe=xye.find(ve=>ve.value===Y))==null?void 0:qe.label]}),e.jsxs("span",{className:"font-medium",children:[y.length," selected"]})]})]}),e.jsx(ui,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(_s,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):pe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(lr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:Y!=="all"?`No ${(ze=xye.find(ve=>ve.value===Y))==null?void 0:ze.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:pe.map(ve=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${y.includes(ve.id)?"bg-accent":""}`,onClick:()=>je(ve.id),children:[e.jsx(Ki,{checked:y.includes(ve.id),onCheckedChange:()=>je(ve.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:Me(ve.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:ve.name}),Fe(ve.id)]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[ve.email,ve.brokerage_name&&e.jsxs("span",{className:"ml-1 opacity-75",children:["• ",ve.brokerage_name]})]})]})]},ve.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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search brokerages...",value:C,onChange:ve=>E(ve.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:_e.length===0,children:[e.jsx(pa,{className:"h-3.5 w-3.5 mr-1.5"}),b.length===_e.length&&_e.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(ui,{className:"h-[250px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(_s,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):_e.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[180px] text-muted-foreground",children:[e.jsx(pa,{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:_e.map(ve=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${b.includes(ve.id)?"bg-accent":""}`,onClick:()=>Ue(ve.id),children:[e.jsx(Ki,{checked:b.includes(ve.id),onCheckedChange:()=>Ue(ve.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(pa,{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:ve.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ve.agent_count," agent",ve.agent_count!==1?"s":""]})]})]},ve.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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search agents...",value:w,onChange:ve=>k(ve.target.value),className:"pl-9"})]}),ie&&e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:he,className:"text-xs h-8",disabled:pe.length===0,children:[e.jsx(lr,{className:"h-3.5 w-3.5 mr-1.5"}),y.length===pe.length&&pe.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[y.length," selected"]})]}),e.jsx(ui,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(_s,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):pe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(lr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:pe.map(ve=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${y.includes(ve.id)?"bg-accent":""}`,onClick:()=>je(ve.id),children:[e.jsx(Ki,{checked:y.includes(ve.id),onCheckedChange:()=>je(ve.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:Me(ve.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:ve.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:ve.email})]})]},ve.id))})})]}),e.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[e.jsx(xe,{htmlFor:"message",className:"text-sm font-medium",children:"Add a message (optional)"}),e.jsx(vr,{id:"message",placeholder:"I thought you might find this useful...",value:L,onChange:ve=>I(ve.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:Le===0||q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(An,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function eE({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=S.useState(!1),{user:d}=Fs();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(i$t,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function o$t(){const{eventId:t}=co(),s=_r(),{user:r}=Fs(),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(0),[u,p]=S.useState(!0),[x,y]=S.useState(!1);S.useEffect(()=>{t&&_()},[t,r]);const _=async()=>{try{const{data:E,error:L}=await G.from("events").select("*").eq("id",t).single();if(L)throw L;a(E);const{count:I}=await G.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",t);if(d(I||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(E){console.error("Error loading event:",E),me.error("Failed to load event"),s("/events")}finally{p(!1)}},b=async()=>{if(!(!r||!n)){y(!0);try{const{error:E}=await G.auth.refreshSession();if(E){console.error("Session refresh failed:",E),me.error("Your session has expired. Please log in again.");return}if(o){const{error:L}=await G.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(L)throw L;me.success("Successfully cancelled registration"),l(null),d(I=>I-1)}else{const{data:L,error:I}=await G.functions.invoke("zoom-register",{body:{event_id:n.id}});if(I)throw I;me.success("Successfully registered for event!"),l({id:L.registration_id,zoom_join_url:L.zoom_join_url}),d(O=>O+1)}}catch(E){console.error("Registration error:",E),me.error(o?"Failed to cancel registration":"Failed to register for event")}finally{y(!1)}}},N=E=>{var L,I,O;if(E.includes("iframe.mediadelivery.net")||E.includes("video.bunnycdn.com")){const V=E.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(V)return`https://iframe.mediadelivery.net/embed/${V[1]}/${V[2]}?autoplay=false&preload=true`}if(E.includes("youtube.com")||E.includes("youtu.be")){const V=E.includes("youtu.be")?(L=E.split("youtu.be/")[1])==null?void 0:L.split("?")[0]:(I=E.split("v=")[1])==null?void 0:I.split("&")[0];if(V)return`https://www.youtube.com/embed/${V}`}if(E.includes("vimeo.com")){const V=(O=E.split("vimeo.com/")[1])==null?void 0:O.split("?")[0];if(V)return`https://player.vimeo.com/video/${V}`}return E};if(u)return e.jsx(Es,{title:"Event",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading event..."})]})})});if(!n)return e.jsx(Es,{title:"Event Not Found",children:e.jsxs("div",{className:"text-center py-16",children:[e.jsx("p",{className:"text-muted-foreground",children:"Event not found"}),e.jsx(K,{onClick:()=>s("/events"),className:"mt-4",children:"Back to Events"})]})});const w=r0(new Date(n.event_date)),k=n.capacity&&i>=n.capacity,C=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return e.jsx(Es,{title:n.title,children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(K,{variant:"ghost",className:"mb-6 gap-2",onClick:()=>s("/events"),children:[e.jsx(Fa,{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(Qe,{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(eE,{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(sp,{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(Pe,{children:e.jsxs(Re,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(on,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(n.event_date))}),e.jsx("p",{className:"text-sm text-muted-foreground",children:oD(new Date(n.event_date))})]})]}),n.capacity&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(lr,{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(ti,{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:x,children:[x?e.jsx(_s,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(K,{className:"w-full gap-2",onClick:b,disabled:x||(k??!1),children:x?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):k?"Event Full":"Register Now"})}),w&&o&&e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(Kr,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const l$t=[{id:"quickvid",name:"QuickVid",description:"Record, manage, and share personalized video messages",icon:e.jsx(Tn,{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(yx,{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(Pg,{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(fn,{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($r,{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(rr,{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(tu,{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(An,{className:"h-6 w-6"}),path:"/admin/email-campaigns",category:"Marketing",beta:!0,color:"bg-teal-500/15 text-teal-600"}],c$t=()=>{const{user:t,isAdmin:s}=Fs(),r=_r(),[n,a]=S.useState([]),[o,l]=S.useState(!0),[i,d]=S.useState(""),[u,p]=S.useState("all"),[x,y]=S.useState(new Set),[_,b]=S.useState(new Set);S.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),U=($==null?void 0:$.map(pe=>pe.tag))||[],{data:se,error:Y}=await G.from("app_tiles").select("*").order("name");if(Y)throw Y;const[{data:J},{data:X}]=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(pe=>pe.app_id))||[]);y(ce);const ie=new Set((X||[]).map(pe=>pe.tool_id));b(ie);const oe=((se==null?void 0:se.filter(pe=>!pe.required_tags||pe.required_tags.length===0?!0:pe.required_tags.some(_e=>U.includes(_e))))||[]).sort((pe,_e)=>pe.name==="LevelUp Members Portal"?-1:_e.name==="LevelUp Members Portal"?1:0);a(oe)}catch($){console.error("Error loading apps:",$),me.error("Failed to load apps")}finally{l(!1)}},w=async $=>{var se;const U=window.open("about:blank","_blank");try{const{data:Y,error:J}=await G.auth.getSession();if(J||!Y.session){U==null||U.close(),me.error("Session expired. Please refresh the page and try again.");return}const X=Y.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:ie}=await G.functions.invoke("sso-launch",{body:{app_id:$.app_id},headers:{Authorization:`Bearer ${X}`}});if(ie)throw ie;ce!=null&&ce.redirect_url?U&&!U.closed?(U.location.href=ce.redirect_url,(se=U.focus)==null||se.call(U)):window.location.assign(ce.redirect_url):(U==null||U.close(),me.error("Launch link unavailable"))}catch(Y){U==null||U.close(),console.error("Error launching app:",Y),me.error("Failed to launch app. Please try again.")}},k=async($,U)=>{$.stopPropagation();const se=x.has(U);try{if(se){const{error:Y}=await G.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",U);if(Y)throw Y;y(J=>{const X=new Set(J);return X.delete(U),X}),me.success("Removed from favorites")}else{const{error:Y}=await G.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:U});if(Y)throw Y;y(J=>new Set(J).add(U)),me.success("Added to favorites")}}catch(Y){console.error("Error toggling favorite:",Y),me.error("Failed to update favorites")}},C=async($,U)=>{$.stopPropagation();const se=_.has(U);try{if(se){const{error:Y}=await G.from("user_tool_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("tool_id",U);if(Y)throw Y;b(J=>{const X=new Set(J);return X.delete(U),X}),me.success("Removed from favorites")}else{const{error:Y}=await G.from("user_tool_favorites").insert({user_id:t==null?void 0:t.id,tool_id:U});if(Y)throw Y;b(J=>new Set(J).add(U)),me.success("Added to favorites")}}catch(Y){console.error("Error toggling tool favorite:",Y),me.error("Failed to update favorites")}},E=n.filter($=>{var se;const U=$.name.toLowerCase().includes(i.toLowerCase())||((se=$.description)==null?void 0:se.toLowerCase().includes(i.toLowerCase()));return u==="favorites"?U&&x.has($.id):U}),L=l$t.filter($=>{if($.adminOnly&&!s)return!1;const U=$.name.toLowerCase().includes(i.toLowerCase())||$.description.toLowerCase().includes(i.toLowerCase());return u==="favorites"?U&&_.has($.id):U}),I=L.reduce(($,U)=>($[U.category]||($[U.category]=[]),$[U.category].push(U),$),{}),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(Es,{title:"Apps & Tools",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading apps & tools..."})]})})});const V=u==="all"||u==="tools"||u==="favorites",q=u==="all"||u==="apps"||u==="favorites";return e.jsxs(Es,{title:"Apps & Tools",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Apps & Tools"}),e.jsxs("div",{className:"relative max-w-sm w-full",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{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))}),V&&Object.keys(I).length>0&&e.jsxs("div",{className:"mb-10",children:[u==="all"&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(Ig,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Built-in Tools"})]}),Object.entries(I).map(([$,U])=>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:U.map(se=>{const Y=_.has(se.id);return e.jsxs("div",{onClick:()=>r(se.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",se.isNew?"border-primary/40 ring-1 ring-primary/20 hover:border-primary/60":"border-border hover:border-primary/30"),children:[se.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",se.color||"bg-primary/10 text-primary"),children:se.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:[se.name,se.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:se.description})]}),e.jsx("button",{className:Rt("flex-shrink-0 p-1 transition-colors",Y?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:J=>C(J,se.id),children:e.jsx(fx,{className:Rt("h-5 w-5",Y&&"fill-current")})})]},se.id)})})]},$))]}),q&&e.jsxs("div",{children:[u==="all"&&E.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"})]}),E.length===0&&u!=="all"&&!(u==="favorites"&&L.length>0)?e.jsx("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:u==="favorites"?e.jsxs(e.Fragment,{children:[e.jsx(fx,{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:E.map($=>{const U=x.has($.id),se=$.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",U?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:Y=>k(Y,$.id),children:e.jsx(fx,{className:Rt("h-5 w-5",U&&"fill-current")})})]}),se&&e.jsx("a",{href:"https://forms.gle/vXnrzgSnPbw7CKPV6",target:"_blank",rel:"noopener noreferrer",onClick:Y=>Y.stopPropagation(),className:"mt-3 text-sm text-primary hover:underline flex items-center gap-1",children:"Create your account with this link →"})]},$.id)})})]}),V&&q&&E.length===0&&L.length===0&&i&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:[e.jsx(an,{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"})]})]})},d$t=()=>{const t=_r(),[s,r]=S.useState(""),[n,a]=S.useState("all"),[o,l]=S.useState("all"),[i,d]=S.useState("grid"),{data:u=[]}=gt({queryKey:["template-categories"],queryFn:async()=>{const{data:k,error:C}=await G.from("template_categories").select("*").order("name");if(C)throw C;return k}}),{data:p=[]}=gt({queryKey:["template-types"],queryFn:async()=>{const{data:k,error:C}=await G.from("template_types").select("*").order("name");if(C)throw C;return k}}),{data:x=[],isLoading:y}=gt({queryKey:["canva-templates"],queryFn:async()=>{const{data:k,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:E,error:L}=await G.from("template_links").select("*").order("sort_order");if(L)throw L;const{data:I}=await G.from("template_likes").select("template_id"),{data:O}=await G.from("template_comments").select("template_id"),V=new Map;I==null||I.forEach(U=>{V.set(U.template_id,(V.get(U.template_id)||0)+1)});const q=new Map;return O==null||O.forEach(U=>{q.set(U.template_id,(q.get(U.template_id)||0)+1)}),(k||[]).map(U=>({...U,links:(E||[]).filter(se=>se.template_id===U.id)||[],likesCount:V.get(U.id)||0,commentsCount:q.get(U.id)||0}))}}),_=x.filter(k=>{var I;const C=k.name.toLowerCase().includes(s.toLowerCase())||((I=k.description)==null?void 0:I.toLowerCase().includes(s.toLowerCase())),E=n==="all"||k.category_id===n,L=o==="all"||k.type_id===o;return C&&E&&L}),b=()=>{r(""),a("all"),l("all")},N=s||n!=="all"||o!=="all",w=k=>{t(`/templates/${k}`)};return e.jsx(Es,{title:"Canva Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-bold text-foreground text-5xl",children:"Canva Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Browse and use our collection of professionally designed templates"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search templates...",value:s,onChange:k=>r(k.target.value),className:"pl-9"})]}),e.jsxs(Bs,{value:n,onValueChange:a,children:[e.jsx(Rs,{className:"w-full sm:w-48",children:e.jsx(qs,{placeholder:"All Categories"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Categories"}),u.map(k=>e.jsx(vt,{value:k.id,children:k.name},k.id))]})]}),e.jsxs(Bs,{value:o,onValueChange:l,children:[e.jsx(Rs,{className:"w-full sm:w-48",children:e.jsx(qs,{placeholder:"All Types"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Types"}),p.map(k=>e.jsx(vt,{value:k.id,children:k.name},k.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(fp,{className:"h-4 w-4"})}),e.jsx(K,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>d("list"),className:"rounded-full",children:e.jsx(Dh,{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((k,C)=>e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsx(Ns,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(Ns,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ns,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ns,{className:"h-5 w-16"}),e.jsx(Ns,{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(k=>e.jsxs(Pe,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>w(k.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[k.preview_image_url?e.jsx("img",{src:k.preview_image_url,alt:k.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),k.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Qe,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(fo,{className:"h-3 w-3"}),k.links.length]})})]}),e.jsxs(Re,{className:`p-4 flex flex-col ${i==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:k.name}),k.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:Kde(k.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[k.category&&e.jsx(Qe,{variant:"secondary",className:"text-xs",children:k.category.name}),k.type&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:k.type.name})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fu,{className:"h-3.5 w-3.5"}),k.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vc,{className:"h-3.5 w-3.5"}),k.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:C=>{C.stopPropagation(),w(k.id)},children:[e.jsx(Kr,{className:"h-4 w-4"}),"View Template"]})]})]},k.id))})]})})};var u$t="Separator",H8e="horizontal",h$t=["horizontal","vertical"],wet=S.forwardRef((t,s)=>{const{decorative:r,orientation:n=H8e,...a}=t,o=m$t(n)?n:H8e,i=r?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return e.jsx(Yr.div,{"data-orientation":o,...i,...a,ref:s})});wet.displayName=u$t;function m$t(t){return h$t.includes(t)}var jet=wet;const wo=S.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(jet,{ref:a,decorative:r,orientation:s,className:Rt("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));wo.displayName=jet.displayName;const p$t=()=>{const{templateId:t}=co(),s=_r(),{user:r,isAdmin:n}=Fs(),{toast:a}=wa(),o=Jt(),{trackEngagement:l}=YA(),[i,d]=S.useState(""),{data:u,isLoading:p}=gt({queryKey:["template-detail",t],queryFn:async()=>{const{data:L,error:I}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("id",t).single();if(I)throw I;const{data:O}=await G.from("template_links").select("*").eq("template_id",t).order("sort_order"),{data:V}=await G.from("template_guides").select("*").eq("template_id",t).order("sort_order");return{...L,links:O||[],guides:V||[]}},enabled:!!t}),{data:x=[]}=gt({queryKey:["template-linked-toolkits",t],queryFn:async()=>{const{data:L,error:I}=await G.from("resource_kit_templates").select("kit_id, resource_kits:kit_id(id, name, featured_image_url)").eq("template_id",t);if(I)throw I;return(L||[]).map(O=>O.resource_kits).filter(Boolean)},enabled:!!t});S.useEffect(()=>{u&&l("template",u.id,u.name,"view")},[u==null?void 0:u.id]);const{data:y=[]}=gt({queryKey:["template-likes",t],queryFn:async()=>{const{data:L,error:I}=await G.from("template_likes").select("*").eq("template_id",t);if(I)throw I;return L},enabled:!!t}),{data:_=[]}=gt({queryKey:["template-comments",t],queryFn:async()=>{const{data:L,error:I}=await G.from("template_comments").select("*").eq("template_id",t).order("created_at",{ascending:!1});if(I)throw I;const O=[...new Set(L.map($=>$.user_id))],{data:V}=await G.from("profiles").select("id, name").in("id",O),q=new Map((V==null?void 0:V.map($=>[$.id,$.name]))||[]);return L.map($=>({...$,user_name:q.get($.user_id)||"Unknown User"}))},enabled:!!t}),b=It({mutationFn:async L=>{const{error:I}=await G.from("template_comments").insert({template_id:t,user_id:r.id,content:L});if(I)throw I},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),d(""),a({title:"Comment added!"})},onError:L=>{a({title:"Error adding comment",description:L.message,variant:"destructive"})}}),N=It({mutationFn:async L=>{const{error:I}=await G.from("template_comments").delete().eq("id",L);if(I)throw I},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),a({title:"Comment deleted"})}}),w=It({mutationFn:async()=>{const L=y.find(I=>I.user_id===(r==null?void 0:r.id));if(L){const{error:I}=await G.from("template_likes").delete().eq("id",L.id);if(I)throw I}else{const{error:I}=await G.from("template_likes").insert({template_id:t,user_id:r.id});if(I)throw I}},onSuccess:()=>{o.invalidateQueries({queryKey:["template-likes",t]})}}),k=y.some(L=>L.user_id===(r==null?void 0:r.id)),C=L=>L.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),E=L=>{L.preventDefault(),!(!i.trim()||!r)&&b.mutate(i.trim())};return p?e.jsx(Es,{title:"Templates",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):u?e.jsx(Es,{title:u.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(ha,{to:"/templates",children:[e.jsx(Fa,{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(Qe,{variant:"secondary",children:u.category.name}),u.type&&e.jsx(Qe,{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(ha,{to:`/admin/templates?edit=${u.id}`,children:[e.jsx(ga,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(eE,{resourceType:"template",resourceId:u.id,resourceTitle:u.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:k?"default":"outline",className:"gap-2 rounded-full",onClick:()=>w.mutate(),disabled:!r||w.isPending,children:[e.jsx(Fu,{className:`h-4 w-4 ${k?"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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(fo,{className:"h-4 w-4"}),u.links.length===1?"Template Link":"Template Links"]}),e.jsx("div",{className:"grid gap-2",children:u.links.map(L=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_canva"),window.open(L.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(Kr,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]})}),u.video_url&&e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(fn,{className:"h-4 w-4"}),"Guide Files"]}),e.jsx("div",{className:"grid gap-2",children:u.guides.map(L=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_pdf"),window.open(L.file_url,"_blank")},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:L.name}),L.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(L.file_size/1024).toFixed(0)," KB)"]})]}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]})}),x.length>0&&e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(nl,{className:"h-4 w-4"}),"Related Toolkits"]}),e.jsx("div",{className:"grid gap-2",children:x.map(L=>e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-3 h-auto py-3",onClick:()=>s(`/toolbox/${L.id}`),children:[L.featured_image_url?e.jsx("img",{src:L.featured_image_url,alt:"",className:"w-10 h-10 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(nl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"font-medium",children:L.name})]},L.id))})]})}),e.jsx(wo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(vc,{className:"h-5 w-5"}),"Comments (",_.length,")"]}),r?e.jsxs("form",{onSubmit:E,className:"flex gap-2",children:[e.jsx(vr,{placeholder:"Add a comment...",value:i,onChange:L=>d(L.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!i.trim()||b.isPending,children:e.jsx(An,{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(Pe,{children:e.jsx(Re,{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(L=>e.jsx(Pe,{children:e.jsx(Re,{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(L.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:L.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:gl(new Date(L.created_at),{addSuffix:!0})}),L.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>N.mutate(L.id),children:e.jsx(gr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:L.content})]})]})})},L.id))})]})]})}):e.jsx(Es,{title:"Templates",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(fo,{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(ha,{to:"/templates",children:"Back to Templates"})})]})})},f$t=()=>{const{user:t}=Fs(),[s,r]=S.useState(""),[n,a]=S.useState("all"),{data:o=[]}=gt({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}=gt({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(k=>({...k,resources:(b==null?void 0:b.filter(C=>C.video_id===k.id))||[]}))}}),{data:d=[]}=gt({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,x=y=>d.some(_=>_.video_id===y&&_.user_id===(t==null?void 0:t.id));return e.jsx(Es,{title:"Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Academy"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"On-demand training videos and resources"})]}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-4",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search videos...",value:s,onChange:y=>r(y.target.value),className:"pl-10"})]})}),e.jsx(ia,{value:n,onValueChange:a,children:e.jsxs(ea,{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(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Tn,{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(ha,{to:`/academy/${y.id}`,children:e.jsxs(Pe,{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(Tn,{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(So,{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(ln,{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(Ot,{className:"text-lg line-clamp-2",children:y.title})}),y.category&&e.jsx(Qe,{variant:"secondary",className:"w-fit",children:y.category.name})]}),e.jsxs(Re,{className:"pt-0",children:[y.description&&e.jsx(hr,{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(Fu,{className:`h-4 w-4 ${x(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(fn,{className:"h-4 w-4"}),y.resources.length]})]})]})]})},y.id))})]})})};function Net({resourceType:t,resourceId:s}){const{data:r=[]}=gt({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(Dl,{className:"h-4 w-4"}),"Related Templates"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(n=>e.jsx(ha,{to:`/templates/${n.id}`,children:e.jsxs(Qe,{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(Dl,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const x$t=(t,s)=>{if(s==="bunny_stream"){let r=t.replace("iframe.mediadelivery.net","player.mediadelivery.net");return r.includes("?")||(r+="?autoplay=false&loop=false&muted=false&preload=true&responsive=true"),r}if(s==="youtube"){const r=/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,n=t.match(r);if(n)return`https://www.youtube.com/embed/${n[1]}`}if(s==="vimeo"){const r=/vimeo\.com\/(?:video\/)?(\d+)/,n=t.match(r);if(n)return`https://player.vimeo.com/video/${n[1]}`}if(s==="loom"){const r=/loom\.com\/share\/([a-zA-Z0-9]+)/,n=t.match(r);if(n)return`https://www.loom.com/embed/${n[1]}`}return t},g$t=()=>{const{videoId:t}=co();_r();const{user:s,isAdmin:r}=Fs(),{toast:n}=wa(),a=Jt(),{trackEngagement:o}=YA(),[l,i]=S.useState(""),{data:d,isLoading:u}=gt({queryKey:["academy-video",t],queryFn:async()=>{const{data:E,error:L}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("id",t).eq("is_published",!0).single();if(L)throw L;const{data:I}=await G.from("academy_resources").select("*").eq("video_id",t).order("sort_order");return{...E,resources:I||[]}},enabled:!!t});S.useEffect(()=>{d&&o("academy_video",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p=[]}=gt({queryKey:["academy-video-likes",t],queryFn:async()=>{const{data:E,error:L}=await G.from("academy_video_likes").select("*").eq("video_id",t);if(L)throw L;return E},enabled:!!t}),{data:x=[]}=gt({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:E,error:L}=await G.from("academy_video_comments").select("*").eq("video_id",t).order("created_at",{ascending:!1});if(L)throw L;const I=[...new Set(E.map(q=>q.user_id))],{data:O}=await G.from("profiles").select("id, name").in("id",I),V=new Map((O==null?void 0:O.map(q=>[q.id,q.name]))||[]);return E.map(q=>({...q,user_name:V.get(q.user_id)||"Unknown User"}))},enabled:!!t}),y=It({mutationFn:async E=>{const{error:L}=await G.from("academy_video_comments").insert({video_id:t,user_id:s.id,content:E});if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),i(""),n({title:"Comment added!"})},onError:E=>{n({title:"Error adding comment",description:E.message,variant:"destructive"})}}),_=It({mutationFn:async E=>{const{error:L}=await G.from("academy_video_comments").delete().eq("id",E);if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),n({title:"Comment deleted"})}}),b=It({mutationFn:async()=>{const E=p.find(L=>L.user_id===(s==null?void 0:s.id));if(E){const{error:L}=await G.from("academy_video_likes").delete().eq("id",E.id);if(L)throw L}else{const{error:L}=await G.from("academy_video_likes").insert({video_id:t,user_id:s.id});if(L)throw L}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",t]})}}),N=p.some(E=>E.user_id===(s==null?void 0:s.id)),w=E=>{switch(E==null?void 0:E.toLowerCase()){case"pdf":return"📄";case"pptx":case"ppt":return"📊";case"xlsx":case"xls":return"📈";case"docx":case"doc":return"📝";case"zip":return"📦";default:return"📁"}},k=E=>E.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),C=E=>{E.preventDefault(),!(!l.trim()||!s)&&y.mutate(l.trim())};return u?e.jsx(Es,{title:"Academy",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):d?e.jsx(Es,{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(ha,{to:"/academy",children:[e.jsx(Fa,{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:x$t(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(Tn,{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(Qe,{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(ha,{to:`/admin/academy?edit=${d.id}`,children:[e.jsx(ga,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(eE,{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(Fu,{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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(fn,{className:"h-4 w-4"}),"Resources"]}),e.jsx("div",{className:"grid gap-2",children:d.resources.map(E=>e.jsxs("a",{href:E.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(E.file_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:E.title}),e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:E.file_type})]}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"})]},E.id))})]})}),e.jsx(Net,{resourceType:"academy_video",resourceId:d.id}),e.jsx(wo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(vc,{className:"h-5 w-5"}),"Comments (",x.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(vr,{placeholder:"Add a comment...",value:l,onChange:E=>i(E.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(An,{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:x.length===0?e.jsx(Pe,{children:e.jsx(Re,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):x.map(E=>e.jsx(Pe,{children:e.jsx(Re,{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:k(E.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:E.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:gl(new Date(E.created_at),{addSuffix:!0})}),E.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(E.id),children:e.jsx(gr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:E.content})]})]})})},E.id))})]})]})}):e.jsx(Es,{title:"Academy",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Tn,{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(ha,{to:"/academy",children:"Back to Academy"})})]})})};function y$t(){const t=_r(),[s,r]=S.useState(""),{data:n,isLoading:a}=gt({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}=gt({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}=gt({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}=gt({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,x=_=>(i==null?void 0:i.filter(b=>b.kit_id===_).length)||0,y=_=>{t(`/toolbox/${_}`)};return e.jsx(Es,{title:"Toolbox",description:"Download resource kits and tools to help grow your business",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Toolbox"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Download resource kits and tools to help grow your business"})]}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{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(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsx(Ns,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(Ns,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ns,{className:"h-4 w-full mb-4"}),e.jsx(Ns,{className:"h-4 w-2/3"})]})},b))}):(d==null?void 0:d.length)===0?e.jsxs(Pe,{className:"p-12 text-center",children:[e.jsx(nl,{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=x(_.id);return e.jsxs(Pe,{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(nl,{className:"h-16 w-16 text-muted-foreground"})})}),e.jsxs(Re,{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:Kde(_.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(fn,{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(Fu,{className:"h-3.5 w-3.5"}),N]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vc,{className:"h-3.5 w-3.5"}),w]})]})]})]})]},_.id)})})]})})}const v$t=()=>{const{kitId:t}=co(),{user:s,isAdmin:r}=Fs(),{toast:n}=wa(),a=Jt(),{trackEngagement:o}=YA(),[l,i]=S.useState(""),{data:d,isLoading:u}=gt({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:E,error:L}=await G.from("resource_kits").select("*").eq("id",t).eq("is_published",!0).single();if(L)throw L;const{data:I}=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{...E,files:I||[],links:O||[]}},enabled:!!t});S.useEffect(()=>{d&&o("toolbox",d.id,d.name,"view")},[d==null?void 0:d.id]);const{data:p=[]}=gt({queryKey:["resource-kit-likes",t],queryFn:async()=>{const{data:E,error:L}=await G.from("resource_kit_likes").select("*").eq("kit_id",t);if(L)throw L;return E},enabled:!!t}),{data:x=[]}=gt({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:E,error:L}=await G.from("resource_kit_comments").select("*").eq("kit_id",t).order("created_at",{ascending:!1});if(L)throw L;const I=[...new Set(E.map(q=>q.user_id))],{data:O}=await G.from("profiles").select("id, name").in("id",I),V=new Map((O==null?void 0:O.map(q=>[q.id,q.name]))||[]);return E.map(q=>({...q,user_name:V.get(q.user_id)||"Unknown User"}))},enabled:!!t}),y=It({mutationFn:async E=>{const{error:L}=await G.from("resource_kit_comments").insert({kit_id:t,user_id:s.id,content:E});if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),i(""),n({title:"Comment added!"})},onError:E=>{n({title:"Error adding comment",description:E.message,variant:"destructive"})}}),_=It({mutationFn:async E=>{const{error:L}=await G.from("resource_kit_comments").delete().eq("id",E);if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),n({title:"Comment deleted"})}}),b=It({mutationFn:async()=>{const E=p.find(L=>L.user_id===(s==null?void 0:s.id));if(E){const{error:L}=await G.from("resource_kit_likes").delete().eq("id",E.id);if(L)throw L}else{const{error:L}=await G.from("resource_kit_likes").insert({kit_id:t,user_id:s.id});if(L)throw L}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",t]})}}),N=p.some(E=>E.user_id===(s==null?void 0:s.id)),w=E=>E.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),k=E=>E?E<1024?E+" B":E<1024*1024?(E/1024).toFixed(1)+" KB":(E/(1024*1024)).toFixed(1)+" MB":"",C=E=>{E.preventDefault(),!(!l.trim()||!s)&&y.mutate(l.trim())};return u?e.jsx(Es,{title:"Toolbox",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):d?e.jsx(Es,{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(ha,{to:"/toolbox",children:[e.jsx(Fa,{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(ha,{to:`/admin/toolbox?edit=${d.id}`,children:[e.jsx(ga,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(eE,{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(Fu,{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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(fn,{className:"h-4 w-4"}),"Included Resources (",d.files.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.files.map(E=>e.jsxs("a",{href:E.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(fn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:E.name}),E.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:k(E.file_size)})]})]}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},E.id))})]})}),d.links&&d.links.length>0&&e.jsx(Pe,{children:e.jsxs(Re,{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(E=>e.jsxs("a",{href:E.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:E.title})]}),e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary transition-colors",children:"Open in Canva"})]},E.id))})]})}),e.jsx(Net,{resourceType:"resource_kit",resourceId:d.id}),e.jsx(wo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(vc,{className:"h-5 w-5"}),"Comments (",x.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(vr,{placeholder:"Add a comment...",value:l,onChange:E=>i(E.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(An,{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:x.length===0?e.jsx(Pe,{children:e.jsx(Re,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):x.map(E=>e.jsx(Pe,{children:e.jsx(Re,{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(E.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:E.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:gl(new Date(E.created_at),{addSuffix:!0})}),E.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(E.id),children:e.jsx(gr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:E.content})]})]})})},E.id))})]})]})}):e.jsx(Es,{title:"Toolbox",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(nl,{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(ha,{to:"/toolbox",children:"Back to Toolbox"})})]})})},_$t=()=>{const t=_r(),[s,r]=S.useState(""),[n,a]=S.useState("grid"),{data:o=[],isLoading:l}=gt({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:x,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:(x||[]).filter(E=>E.swag_id===C.id)||[],likesCount:N.get(C.id)||0,commentsCount:w.get(C.id)||0}))}}),i=o.filter(u=>{var x;return u.title.toLowerCase().includes(s.toLowerCase())||((x=u.description)==null?void 0:x.toLowerCase().includes(s.toLowerCase()))}),d=u=>{t(`/social-swag/${u}`)};return e.jsx(Es,{title:"Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Social Swag"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Browse our collection of social media content and graphics"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{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(fp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Dh,{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(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsx(Ns,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(Ns,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ns,{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(Pe,{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(Qe,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(fo,{className:"h-3 w-3"}),u.links.length]})})]}),e.jsxs(Re,{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(Fu,{className:"h-3.5 w-3.5"}),u.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vc,{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 ri=function(){return ri=Object.assign||function(s){for(var r,n=1,a=arguments.length;n1&&(d||!u),x=s>1&&(u||!d),y=function(){n&&o(n)},_=function(){a&&o(a)};return e.jsx(J$t,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:x,nextMonth:a,previousMonth:n,onPreviousClick:y,onNextClick:_})}function eqt(t){var s,r=Fl(),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:Met,u;return a?u=e.jsx(d,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?u=e.jsx(G8e,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(G8e,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(W8e,{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(W8e,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function tqt(t){var s=Fl(),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 sqt(t,s,r){for(var n=r?p1(new Date):zh(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=cl(n,o);a.push(l)}return a}function rqt(){var t=Fl(),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=sqt(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,x){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})},x)})]})}function nqt(){var t,s=Fl(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:rqt;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function aqt(t){var s=Fl(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var Xke=S.createContext(void 0);function iqt(t){if(!KR(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(Xke.Provider,{value:s,children:t.children})}return e.jsx(oqt,{initialProps:t.initialProps,children:t.children})}function oqt(t){var s=t.initialProps,r=t.children,n=s.selected,a=s.min,o=s.max,l=function(u,p,x){var y,_;(y=s.onDayClick)===null||y===void 0||y.call(s,u,p,x);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?ket([],n):[];if(p.selected){var k=w.findIndex(function(C){return rl(u,C)});w.splice(k,1)}else w.push(u);(_=s.onSelect)===null||_===void 0||_.call(s,w,u,p,x)}}},i={disabled:[]};n&&i.disabled.push(function(u){var p=o&&n.length>o-1,x=n.some(function(y){return rl(y,u)});return!!(p&&!x)});var d={selected:n,onDayClick:l,modifiers:i};return e.jsx(Xke.Provider,{value:d,children:r})}function Qke(){var t=S.useContext(Xke);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function lqt(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:HS(n,t)?{from:t,to:a}:{from:n,to:t}:a?HS(t,a)?{from:a,to:t}:{from:t,to:a}:n?GS(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var Jke=S.createContext(void 0);function cqt(t){if(!ZR(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(Jke.Provider,{value:s,children:t.children})}return e.jsx(dqt,{initialProps:t.initialProps,children:t.children})}function dqt(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,k;(w=s.onDayClick)===null||w===void 0||w.call(s,_,b,N);var C=lqt(_,n);(k=s.onSelect)===null||k===void 0||k.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:Fie(o,i-1),before:cl(o,i-1)}),o&&l&&p.disabled.push({after:o,before:cl(o,i-1)}),!o&&l&&p.disabled.push({after:Fie(l,i-1),before:cl(l,i-1)})),d){if(o&&!l&&(p.disabled.push({before:cl(o,-d+1)}),p.disabled.push({after:cl(o,d-1)})),o&&l){var x=tf(l,o)+1,y=d-x;p.disabled.push({before:Fie(o,y)}),p.disabled.push({after:cl(l,y)})}!o&&l&&(p.disabled.push({before:cl(l,-d+1)}),p.disabled.push({after:cl(l,d-1)}))}return e.jsx(Jke.Provider,{value:{selected:n,onDayClick:u,modifiers:p},children:r})}function e4e(){var t=S.useContext(Jke);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function soe(t){return Array.isArray(t)?ket([],t):t!==void 0?[t]:[]}function uqt(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=soe(a)}),s}var qg;(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"})(qg||(qg={}));var hqt=qg.Selected,fv=qg.Disabled,mqt=qg.Hidden,pqt=qg.Today,gye=qg.RangeEnd,yye=qg.RangeMiddle,vye=qg.RangeStart,fqt=qg.Outside;function xqt(t,s,r){var n,a=(n={},n[hqt]=soe(t.selected),n[fv]=soe(t.disabled),n[mqt]=soe(t.hidden),n[pqt]=[t.today],n[gye]=[],n[yye]=[],n[vye]=[],n[fqt]=[],n);return t.fromDate&&a[fv].push({before:t.fromDate}),t.toDate&&a[fv].push({after:t.toDate}),KR(t)?a[fv]=a[fv].concat(s.modifiers[fv]):ZR(t)&&(a[fv]=a[fv].concat(r.modifiers[fv]),a[vye]=r.modifiers[vye],a[yye]=r.modifiers[yye],a[gye]=r.modifiers[gye]),a}var Eet=S.createContext(void 0);function gqt(t){var s=Fl(),r=Qke(),n=e4e(),a=xqt(s,r,n),o=uqt(s.modifiers),l=ri(ri({},a),o);return e.jsx(Eet.Provider,{value:l,children:t.children})}function Pet(){var t=S.useContext(Eet);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function yqt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function vqt(t){return!!(t&&typeof t=="object"&&"from"in t)}function _qt(t){return!!(t&&typeof t=="object"&&"after"in t)}function bqt(t){return!!(t&&typeof t=="object"&&"before"in t)}function wqt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function jqt(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=tf(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=tf(t,n)>=0&&tf(a,t)>=0;return l}return a?rl(a,t):n?rl(n,t):!1}function Nqt(t){return Gje(t)}function kqt(t){return Array.isArray(t)&&t.every(Gje)}function Sqt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(Nqt(r))return rl(t,r);if(kqt(r))return r.includes(t);if(vqt(r))return jqt(t,r);if(wqt(r))return r.dayOfWeek.includes(t.getDay());if(yqt(r)){var n=tf(r.before,t),a=tf(r.after,t),o=n>0,l=a<0,i=HS(r.before,r.after);return i?l&&o:o||l}return _qt(r)?tf(t,r.after)>0:bqt(r)?tf(r.before,t)>0:typeof r=="function"?r(t):!1})}function t4e(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return Sqt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!Pue(t,r)&&(a.outside=!0),a}function Cqt(t,s){for(var r=pc(t[0]),n=ex(t[t.length-1]),a,o,l=r;l<=n;){var i=t4e(l,s),d=!i.disabled&&!i.hidden;if(!d){l=cl(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=cl(l,1)}return o||a}var Mqt=365;function Iet(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,x=a.locale,y={day:cl,week:h4,month:Am,year:i4t,startOfWeek:function(w){return a.ISOWeek?p1(w):zh(w,{locale:x,weekStartsOn:d})},endOfWeek:function(w){return a.ISOWeek?AWe(w):Aue(w,{locale:x,weekStartsOn:d})}},_=y[r](t,n==="after"?1:-1);n==="before"&&u?_=o4t([u,_]):n==="after"&&p&&(_=l4t([p,_]));var b=!0;if(o){var N=t4e(_,o);b=!N.disabled&&!N.hidden}return b?_:i.count>Mqt?i.lastFocused:Iet(_,{moveBy:r,direction:n,context:a,modifiers:o,retry:ri(ri({},i),{count:i.count+1})})}var Let=S.createContext(void 0);function Tqt(t){var s=YR(),r=Pet(),n=S.useState(),a=n[0],o=n[1],l=S.useState(),i=l[0],d=l[1],u=Cqt(s.displayMonths,r),p=a??(i&&s.isDateDisplayed(i))?i:u,x=function(){d(a),o(void 0)},y=function(w){o(w)},_=Fl(),b=function(w,k){if(a){var C=Iet(a,{moveBy:w,direction:k,context:_,modifiers:r});rl(a,C)||(s.goToDate(C,a),y(C))}},N={focusedDay:a,focusTarget:p,blur:x,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(Let.Provider,{value:N,children:t.children})}function s4e(){var t=S.useContext(Let);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function Aqt(t,s){var r=Pet(),n=t4e(t,r,s);return n}var r4e=S.createContext(void 0);function Eqt(t){if(!bhe(t.initialProps)){var s={selected:void 0};return e.jsx(r4e.Provider,{value:s,children:t.children})}return e.jsx(Pqt,{initialProps:t.initialProps,children:t.children})}function Pqt(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(r4e.Provider,{value:a,children:r})}function Det(){var t=S.useContext(r4e);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function Iqt(t,s){var r=Fl(),n=Det(),a=Qke(),o=e4e(),l=s4e(),i=l.focusDayAfter,d=l.focusDayBefore,u=l.focusWeekAfter,p=l.focusWeekBefore,x=l.blur,y=l.focus,_=l.focusMonthBefore,b=l.focusMonthAfter,N=l.focusYearBefore,w=l.focusYearAfter,k=l.focusStartOfWeek,C=l.focusEndOfWeek,E=function(ae){var oe,pe,_e,he;bhe(r)?(oe=n.onDayClick)===null||oe===void 0||oe.call(n,t,s,ae):KR(r)?(pe=a.onDayClick)===null||pe===void 0||pe.call(a,t,s,ae):ZR(r)?(_e=o.onDayClick)===null||_e===void 0||_e.call(o,t,s,ae):(he=r.onDayClick)===null||he===void 0||he.call(r,t,s,ae)},L=function(ae){var oe;y(t),(oe=r.onDayFocus)===null||oe===void 0||oe.call(r,t,s,ae)},I=function(ae){var oe;x(),(oe=r.onDayBlur)===null||oe===void 0||oe.call(r,t,s,ae)},O=function(ae){var oe;(oe=r.onDayMouseEnter)===null||oe===void 0||oe.call(r,t,s,ae)},V=function(ae){var oe;(oe=r.onDayMouseLeave)===null||oe===void 0||oe.call(r,t,s,ae)},q=function(ae){var oe;(oe=r.onDayPointerEnter)===null||oe===void 0||oe.call(r,t,s,ae)},$=function(ae){var oe;(oe=r.onDayPointerLeave)===null||oe===void 0||oe.call(r,t,s,ae)},U=function(ae){var oe;(oe=r.onDayTouchCancel)===null||oe===void 0||oe.call(r,t,s,ae)},se=function(ae){var oe;(oe=r.onDayTouchEnd)===null||oe===void 0||oe.call(r,t,s,ae)},Y=function(ae){var oe;(oe=r.onDayTouchMove)===null||oe===void 0||oe.call(r,t,s,ae)},J=function(ae){var oe;(oe=r.onDayTouchStart)===null||oe===void 0||oe.call(r,t,s,ae)},X=function(ae){var oe;(oe=r.onDayKeyUp)===null||oe===void 0||oe.call(r,t,s,ae)},ce=function(ae){var oe;switch(ae.key){case"ArrowLeft":ae.preventDefault(),ae.stopPropagation(),r.dir==="rtl"?i():d();break;case"ArrowRight":ae.preventDefault(),ae.stopPropagation(),r.dir==="rtl"?d():i();break;case"ArrowDown":ae.preventDefault(),ae.stopPropagation(),u();break;case"ArrowUp":ae.preventDefault(),ae.stopPropagation(),p();break;case"PageUp":ae.preventDefault(),ae.stopPropagation(),ae.shiftKey?N():_();break;case"PageDown":ae.preventDefault(),ae.stopPropagation(),ae.shiftKey?w():b();break;case"Home":ae.preventDefault(),ae.stopPropagation(),k();break;case"End":ae.preventDefault(),ae.stopPropagation(),C();break}(oe=r.onDayKeyDown)===null||oe===void 0||oe.call(r,t,s,ae)},ie={onClick:E,onFocus:L,onBlur:I,onKeyDown:ce,onKeyUp:X,onMouseEnter:O,onMouseLeave:V,onPointerEnter:q,onPointerLeave:$,onTouchCancel:U,onTouchEnd:se,onTouchMove:Y,onTouchStart:J};return ie}function Lqt(){var t=Fl(),s=Det(),r=Qke(),n=e4e(),a=bhe(t)?s.selected:KR(t)?r.selected:ZR(t)?n.selected:void 0;return a}function Dqt(t){return Object.values(qg).includes(t)}function Rqt(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(Dqt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function Oqt(t,s){var r=ri({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=ri(ri({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function Fqt(t,s,r){var n,a,o,l=Fl(),i=s4e(),d=Aqt(t,s),u=Iqt(t,d),p=Lqt(),x=!!(l.onDayClick||l.mode!=="default");S.useEffect(function(){var O;d.outside||i.focusedDay&&x&&rl(i.focusedDay,t)&&((O=r.current)===null||O===void 0||O.focus())},[i.focusedDay,t,r,x,d.outside]);var y=Rqt(l,d).join(" "),_=Oqt(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:aqt,w=e.jsx(N,{date:t,displayMonth:s,activeModifiers:d}),k={style:_,className:y,children:w,role:"gridcell"},C=i.focusTarget&&rl(i.focusTarget,t)&&!d.outside,E=i.focusedDay&&rl(i.focusedDay,t),L=ri(ri(ri({},k),(n={disabled:d.disabled,role:"gridcell"},n["aria-selected"]=d.selected,n.tabIndex=E||C?0:-1,n)),u),I={isButton:x,isHidden:b,activeModifiers:d,selectedDays:p,buttonProps:L,divProps:k};return I}function zqt(t){var s=S.useRef(null),r=Fqt(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(lce,ri({name:"day",ref:s},r.buttonProps)):e.jsx("div",ri({},r.divProps))}function Bqt(t){var s=t.number,r=t.dates,n=Fl(),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 x=d(Number(s),{locale:i}),y=function(_){a(s,r,_)};return e.jsx(lce,{name:"week-number","aria-label":x,className:l.weeknumber,style:o.weeknumber,onClick:y,children:p})}function $qt(t){var s,r,n=Fl(),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:zqt,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:Bqt,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(x){return e.jsx("td",{className:o.cell,style:a.cell,role:"presentation",children:e.jsx(d,{displayMonth:t.displayMonth,date:x})},uSt(x))})]})}function K8e(t,s,r){for(var n=r!=null&&r.ISOWeek?AWe(s):Aue(s,r),a=r!=null&&r.ISOWeek?p1(t):zh(t,r),o=tf(n,a),l=[],i=0;i<=o;i++)l.push(cl(a,i));var d=l.reduce(function(u,p){var x=r!=null&&r.ISOWeek?Wje(p):Zje(p,r),y=u.find(function(_){return _.weekNumber===x});return y?(y.dates.push(p),u):(u.push({weekNumber:x,dates:[p]}),u)},[]);return d}function qqt(t,s){var r=K8e(pc(t),ex(t),s);if(s!=null&&s.useFixedWeeks){var n=mSt(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=h4(o,6-n),i=K8e(h4(o,1),l,s);r.push.apply(r,i)}}return r}function Uqt(t){var s,r,n,a=Fl(),o=a.locale,l=a.classNames,i=a.styles,d=a.hideHead,u=a.fixedWeeks,p=a.components,x=a.weekStartsOn,y=a.firstWeekContainsDate,_=a.ISOWeek,b=qqt(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:_,locale:o,weekStartsOn:x,firstWeekContainsDate:y}),N=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:nqt,w=(r=p==null?void 0:p.Row)!==null&&r!==void 0?r:$qt,k=(n=p==null?void 0:p.Footer)!==null&&n!==void 0?n:tqt;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(k,{displayMonth:t.displayMonth})]})}function Vqt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Hqt=Vqt()?S.useLayoutEffect:S.useEffect,_ye=!1,Gqt=0;function Z8e(){return"react-day-picker-".concat(++Gqt)}function Wqt(t){var s,r=t??(_ye?Z8e():null),n=S.useState(r),a=n[0],o=n[1];return Hqt(function(){a===null&&o(Z8e())},[]),S.useEffect(function(){_ye===!1&&(_ye=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function Kqt(t){var s,r,n=Fl(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,d=YR().displayMonths,u=Wqt(n.id?"".concat(n.id,"-").concat(t.displayIndex):void 0),p=n.id?"".concat(n.id,"-grid-").concat(t.displayIndex):void 0,x=[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]),_&&(x.push(o.caption_start),y=ri(ri({},y),l.caption_start)),b&&(x.push(o.caption_end),y=ri(ri({},y),l.caption_end)),N&&(x.push(o.caption_between),y=ri(ri({},y),l.caption_between));var w=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:eqt;return e.jsxs("div",{className:x.join(" "),style:y,children:[e.jsx(w,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(Uqt,{id:p,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function Zqt(t){var s=Fl(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function Yqt(t){var s,r,n=t.initialProps,a=Fl(),o=s4e(),l=YR(),i=S.useState(!1),d=i[0],u=i[1];S.useEffect(function(){a.initialFocus&&o.focusTarget&&(d||(o.focus(o.focusTarget),u(!0)))},[a.initialFocus,d,o.focus,o.focusTarget,o]);var p=[a.classNames.root,a.className];a.numberOfMonths>1&&p.push(a.classNames.multiple_months),a.showWeekNumber&&p.push(a.classNames.with_weeknumber);var x=ri(ri({},a.styles.root),a.style),y=Object.keys(n).filter(function(b){return b.startsWith("data-")}).reduce(function(b,N){var w;return ri(ri({},b),(w={},w[N]=n[N],w))},{}),_=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:Zqt;return e.jsx("div",ri({className:p.join(" "),style:x,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(Kqt,{displayIndex:N,displayMonth:b},N)})})}))}function Xqt(t){var s=t.children,r=b$t(t,["children"]);return e.jsx(B$t,{initialProps:r,children:e.jsx(Y$t,{children:e.jsx(Eqt,{initialProps:r,children:e.jsx(iqt,{initialProps:r,children:e.jsx(cqt,{initialProps:r,children:e.jsx(gqt,{children:e.jsx(Tqt,{children:s})})})})})})})}function Qqt(t){return e.jsx(Xqt,ri({},t,{children:e.jsx(Yqt,{initialProps:t})}))}function df({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(Qqt,{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(X8({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(X8({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...s},components:{IconLeft:({...a})=>e.jsx(xl,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(Sa,{className:"h-4 w-4"})},...n})}df.displayName="Calendar";var whe="Popover",[Ret,BTs]=$c(whe,[_0]),XR=_0(),[Jqt,_w]=Ret(whe),Oet=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=XR(s),d=S.useRef(null),[u,p]=S.useState(!1),[x,y]=$u({prop:n,defaultProp:a??!1,onChange:o,caller:whe});return e.jsx(wR,{...i,children:e.jsx(Jqt,{scope:s,contentId:pu(),triggerRef:d,open:x,onOpenChange:y,onOpenToggle:S.useCallback(()=>y(_=>!_),[y]),hasCustomAnchor:u,onCustomAnchorAdd:S.useCallback(()=>p(!0),[]),onCustomAnchorRemove:S.useCallback(()=>p(!1),[]),modal:l,children:r})})};Oet.displayName=whe;var Fet="PopoverAnchor",eUt=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=_w(Fet,r),o=XR(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return S.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(LA,{...o,...n,ref:s})});eUt.displayName=Fet;var zet="PopoverTrigger",Bet=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=_w(zet,r),o=XR(r),l=Aa(s,a.triggerRef),i=e.jsx(Yr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Het(a.open),...n,ref:l,onClick:Cr(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(LA,{asChild:!0,...o,children:i})});Bet.displayName=zet;var n4e="PopoverPortal",[tUt,sUt]=Ret(n4e,{forceMount:void 0}),$et=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=_w(n4e,s);return e.jsx(tUt,{scope:s,forceMount:r,children:e.jsx(wd,{present:r||o.open,children:e.jsx(AA,{asChild:!0,container:a,children:n})})})};$et.displayName=n4e;var qT="PopoverContent",qet=S.forwardRef((t,s)=>{const r=sUt(qT,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=_w(qT,t.__scopePopover);return e.jsx(wd,{present:n||o.open,children:o.modal?e.jsx(nUt,{...a,ref:s}):e.jsx(aUt,{...a,ref:s})})});qet.displayName=qT;var rUt=Vb("PopoverContent.RemoveScroll"),nUt=S.forwardRef((t,s)=>{const r=_w(qT,t.__scopePopover),n=S.useRef(null),a=Aa(s,n),o=S.useRef(!1);return S.useEffect(()=>{const l=n.current;if(l)return mue(l)},[]),e.jsx(TR,{as:rUt,allowPinchZoom:!0,children:e.jsx(Uet,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Cr(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Cr(t.onPointerDownOutside,l=>{const i=l.detail.originalEvent,d=i.button===0&&i.ctrlKey===!0,u=i.button===2||d;o.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Cr(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),aUt=S.forwardRef((t,s)=>{const r=_w(qT,t.__scopePopover),n=S.useRef(!1),a=S.useRef(!1);return e.jsx(Uet,{...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()}})}),Uet=S.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:p,...x}=t,y=_w(qT,r),_=XR(r);return due(),e.jsx(CR,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(lw,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>y.onOpenChange(!1),children:e.jsx(jR,{"data-state":Het(y.open),role:"dialog",id:y.contentId,..._,...x,ref:s,style:{...x.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)"}})})})}),Vet="PopoverClose",iUt=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=_w(Vet,r);return e.jsx(Yr.button,{type:"button",...n,ref:s,onClick:Cr(t.onClick,()=>a.onOpenChange(!1))})});iUt.displayName=Vet;var oUt="PopoverArrow",lUt=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=XR(r);return e.jsx(NR,{...a,...n,ref:s})});lUt.displayName=oUt;function Het(t){return t?"open":"closed"}var cUt=Oet,dUt=Bet,uUt=$et,Get=qet;const xo=cUt,go=dUt,lo=S.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(uUt,{children:e.jsx(Get,{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})}));lo.displayName=Get.displayName;const hUt=gC("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"}}),a4e=S.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:Rt(hUt({variant:s}),t),...r}));a4e.displayName="Alert";const mUt=S.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:Rt("mb-1 font-medium leading-none tracking-tight",t),...s}));mUt.displayName="AlertTitle";const i4e=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Rt("text-sm [&_p]:leading-relaxed",t),...s}));i4e.displayName="AlertDescription";function pUt({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=Jt(),[d,u]=S.useState(a),[p,x]=S.useState([]),[y,_]=S.useState(null),[b,N]=S.useState("now"),[w,k]=S.useState(BPe(GPe(new Date),1)),[C,E]=S.useState("12"),[L,I]=S.useState("00"),[O,V]=S.useState("PM");S.useEffect(()=>{if(t){u(a),N("now"),x([]);const je=BPe(GPe(new Date),1);k(je);const Ue=je.getHours();E(String(Ue>12?Ue-12:Ue===0?12:Ue)),I("00"),V(Ue>=12?"PM":"AM")}},[t,a]);const q=()=>{if(!w)return null;let je=parseInt(C);const Ue=parseInt(L);return O==="PM"&&je!==12&&(je+=12),O==="AM"&&je===12&&(je=0),KL(WL(w,je),Ue)},{data:$,isLoading:U}=gt({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:je}}=await G.auth.getUser();if(!je)return[];const{data:Ue,error:Te}=await G.from("social_accounts").select("*").eq("user_id",je.id).eq("is_active",!0).order("platform",{ascending:!0});if(Te)throw Te;return console.log("Fetched social accounts for posting:",Ue),Ue},enabled:t,staleTime:0}),se=It({mutationFn:async({accountId:je,platform:Ue})=>{_(je);const{data:Te,error:Me}=await G.functions.invoke("social-post",{body:{platform:Ue,accountId:je,imageUrl:r,caption:d}});if(Me)throw Me;if(Te!=null&&Te.error)throw new Error(Te.error);return Te},onSuccess:je=>{const Ue=je.platform==="facebook"?"Facebook":je.platform==="instagram"?"Instagram":je.platform==="linkedin"?"LinkedIn":"Google Business";me.success(`Posted to ${Ue}!`)},onError:je=>{me.error(`Failed to post: ${je.message}`)},onSettled:()=>{_(null)}}),Y=It({mutationFn:async({accountId:je,platform:Ue,scheduledFor:Te})=>{const{data:{user:Me}}=await G.auth.getUser();if(!Me)throw new Error("Not authenticated");const{error:Fe}=await G.from("scheduled_posts").insert({user_id:Me.id,social_account_id:je,platform:Ue,image_url:r,caption:d,swag_item_id:o||null,reel_id:l||null,scheduled_for:Te.toISOString(),status:"scheduled"});if(Fe)throw Fe;return{platform:Ue}},onSuccess:je=>{const Ue=je.platform==="facebook"?"Facebook":je.platform==="instagram"?"Instagram":"LinkedIn";me.success(`Post scheduled for ${Ue}!`)},onError:je=>{me.error(`Failed to schedule: ${je.message}`)}}),J=async()=>{if(p.length===0){me.error("Please select at least one account");return}if(b==="schedule"){const je=q();if(!je||je<=new Date){me.error("Please select a future date and time");return}for(const Ue of p){const Te=$==null?void 0:$.find(Me=>Me.id===Ue);Te&&await Y.mutateAsync({accountId:Ue,platform:Te.platform,scheduledFor:je})}i.invalidateQueries({queryKey:["scheduled-posts"]}),me.success(`${p.length} post(s) scheduled for ${ps(je,"PPp")}`)}else for(const je of p){const Ue=$==null?void 0:$.find(Te=>Te.id===je);Ue&&await se.mutateAsync({accountId:je,platform:Ue.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),x([]),s(!1)},X=je=>{x(Ue=>Ue.includes(je)?Ue.filter(Te=>Te!==je):[...Ue,je])},ce=($==null?void 0:$.filter(je=>je.platform==="facebook"))||[],ie=($==null?void 0:$.filter(je=>je.platform==="instagram"))||[],ae=($==null?void 0:$.filter(je=>je.platform==="linkedin"))||[],oe=($==null?void 0:$.filter(je=>je.platform==="google_business"))||[],pe=(($==null?void 0:$.length)||0)>0,_e=se.isPending||Y.isPending,he=Array.from({length:12},(je,Ue)=>String(Ue+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(Ir,{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(xe,{htmlFor:"caption",children:"Caption"}),e.jsx(vr,{id:"caption",placeholder:"Write a caption for your post...",value:d,onChange:je=>u(je.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(xe,{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(ln,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(xo,{children:[e.jsx(go,{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(on,{className:"mr-2 h-4 w-4"}),w?ps(w,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(lo,{className:"w-auto p-0",align:"start",children:e.jsx(df,{mode:"single",selected:w,onSelect:k,disabled:je=>jee.jsx(vt,{value:je,children:je},je))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(Bs,{value:L,onValueChange:I,children:[e.jsx(Rs,{className:"w-[70px]",children:e.jsx(qs,{})}),e.jsx(Os,{children:we.map(je=>e.jsx(vt,{value:je,children:je},je))})]}),e.jsxs(Bs,{value:O,onValueChange:je=>V(je),children:[e.jsx(Rs,{className:"w-[70px]",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"AM",children:"AM"}),e.jsx(vt,{value:"PM",children:"PM"})]})]})]})]}),w&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",ps(q()||new Date,"PPP 'at' p")]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{children:"Post to"}),U&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(_s,{className:"h-6 w-6 animate-spin"})}),!U&&!pe&&e.jsxs(a4e,{children:[e.jsx(Lo,{className:"h-4 w-4"}),e.jsxs(i4e,{className:"flex flex-col gap-2",children:[e.jsx("span",{children:"No social accounts connected yet."}),e.jsxs(ha,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[e.jsx(ko,{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(uu,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),ce.map(je=>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(Ki,{checked:p.includes(je.id),onCheckedChange:()=>X(je.id),disabled:y===je.id}),e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ta,{src:je.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(uu,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:je.page_name||je.platform_username}),y===je.id&&e.jsx(_s,{className:"h-4 w-4 animate-spin"})]},je.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(mu,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),ie.map(je=>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(Ki,{checked:p.includes(je.id),onCheckedChange:()=>X(je.id),disabled:y===je.id}),e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ta,{src:je.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(mu,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",je.platform_username]}),y===je.id&&e.jsx(_s,{className:"h-4 w-4 animate-spin"})]},je.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(xp,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),ae.map(je=>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(Ki,{checked:p.includes(je.id),onCheckedChange:()=>X(je.id),disabled:y===je.id}),e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ta,{src:je.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(xp,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:je.platform_username}),y===je.id&&e.jsx(_s,{className:"h-4 w-4 animate-spin"})]},je.id))]}),oe.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Da,{className:"h-4 w-4 text-red-600"})," Google Business"]}),oe.map(je=>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(Ki,{checked:p.includes(je.id),onCheckedChange:()=>X(je.id),disabled:y===je.id}),e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ta,{src:je.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(Da,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:je.page_name||je.platform_username}),y===je.id&&e.jsx(_s,{className:"h-4 w-4 animate-spin"})]},je.id))]})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:J,disabled:p.length===0||_e,className:"gap-2",children:[_e?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):b==="schedule"?e.jsx(on,{className:"h-4 w-4"}):e.jsx(An,{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 fUt(){const t=Jt(),[s,r]=S.useState(void 0),[n,a]=S.useState("all"),[o,l]=S.useState(null),[i,d]=S.useState(""),[u,p]=S.useState(void 0),[x,y]=S.useState("12"),[_,b]=S.useState("00"),[N,w]=S.useState("PM"),{data:k=[],isLoading:C}=gt({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:oe,error:pe}=await G.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(pe)throw pe;return oe}}),E=k.filter(oe=>{if(n!=="all"&&oe.status!==n)return!1;if(s&&oe.scheduled_for){const pe=new Date(oe.scheduled_for);if(!rl(pe,s))return!1}return!0}),L=k.filter(oe=>oe.scheduled_for).map(oe=>Em(new Date(oe.scheduled_for))),I=It({mutationFn:async oe=>{const{error:pe}=await G.from("scheduled_posts").update({caption:oe.caption,scheduled_for:oe.scheduled_for}).eq("id",oe.id);if(pe)throw pe},onSuccess:()=>{me.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:oe=>{me.error(`Failed to update: ${oe.message}`)}}),O=It({mutationFn:async oe=>{const{error:pe}=await G.from("scheduled_posts").update({status:"cancelled"}).eq("id",oe);if(pe)throw pe},onSuccess:()=>{me.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:oe=>{me.error(`Failed to cancel: ${oe.message}`)}}),V=It({mutationFn:async oe=>{const{error:pe}=await G.from("scheduled_posts").delete().eq("id",oe);if(pe)throw pe},onSuccess:()=>{me.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:oe=>{me.error(`Failed to delete: ${oe.message}`)}}),q=It({mutationFn:async oe=>{const{data:pe,error:_e}=await G.functions.invoke("social-post",{body:{platform:oe.platform,accountId:oe.social_account_id,imageUrl:oe.image_url,caption:oe.caption}});if(_e)throw _e;if(pe!=null&&pe.error)throw new Error(pe.error);return await G.from("scheduled_posts").update({status:"posted",posted_at:new Date().toISOString(),post_id:pe.postId}).eq("id",oe.id),pe},onSuccess:oe=>{const pe=oe.platform==="facebook"?"Facebook":oe.platform==="instagram"?"Instagram":"LinkedIn";me.success(`Posted to ${pe}!`),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:oe=>{me.error(`Failed to post: ${oe.message}`)}}),$=oe=>{if(l(oe),d(oe.caption||""),oe.scheduled_for){const pe=new Date(oe.scheduled_for);p(pe);const _e=pe.getHours();y(String(_e>12?_e-12:_e===0?12:_e)),b(String(pe.getMinutes()).padStart(2,"0")),w(_e>=12?"PM":"AM")}},U=()=>{if(!o||!u)return;let oe=parseInt(x);const pe=parseInt(_);N==="PM"&&oe!==12&&(oe+=12),N==="AM"&&oe===12&&(oe=0);const _e=KL(WL(u,oe),pe);I.mutate({id:o.id,caption:i,scheduled_for:_e.toISOString()})},se=oe=>{switch(oe){case"facebook":return e.jsx(uu,{className:"h-4 w-4 text-blue-600"});case"instagram":return e.jsx(mu,{className:"h-4 w-4 text-pink-600"});case"linkedin":return e.jsx(xp,{className:"h-4 w-4 text-blue-700"});default:return null}},Y=oe=>{switch(oe){case"scheduled":return e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(ln,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(Qe,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(ti,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(Qe,{variant:"destructive",className:"gap-1",children:[e.jsx(Zl,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(Qe,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(Lo,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(Qe,{variant:"outline",children:oe})}},J=Array.from({length:12},(oe,pe)=>String(pe+1)),X=["00","15","30","45"],ce=k.filter(oe=>oe.status==="scheduled").length,ie=k.filter(oe=>oe.status==="posted").length,ae=k.filter(oe=>oe.status==="scheduled"&&oe.scheduled_for&&pSt(new Date(oe.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(Pe,{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(Pe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ae}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Upcoming"})]}),e.jsxs(Pe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ie}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Posted"})]}),e.jsxs(Pe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:k.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total"})]})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[e.jsxs(Pe,{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(df,{mode:"single",selected:s,onSelect:r,className:Rt("pointer-events-auto"),modifiers:{hasPost:L},modifiersStyles:{hasPost:{fontWeight:"bold",backgroundColor:"hsl(var(--primary) / 0.1)",borderRadius:"50%"}}}),s&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>r(void 0),className:"w-full mt-2",children:"Clear date filter"})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Eg,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:["all","scheduled","posted","failed","cancelled"].map(oe=>e.jsx(K,{variant:n===oe?"default":"outline",size:"sm",onClick:()=>a(oe),className:"capitalize",children:oe},oe))})]}),C&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(_s,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!C&&E.length===0&&e.jsxs(Pe,{className:"p-8 text-center",children:[e.jsx(on,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"font-medium mb-2",children:"No posts found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?`No posts scheduled for ${ps(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:E.map(oe=>{var pe,_e;return e.jsx(Pe,{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:oe.image_url,alt:"Post preview",className:"w-full h-full object-cover"})}),e.jsxs(Re,{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:[se(oe.platform),e.jsx("span",{className:"font-medium",children:((pe=oe.social_accounts)==null?void 0:pe.page_name)||((_e=oe.social_accounts)==null?void 0:_e.platform_username)||"Unknown"}),Y(oe.status)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[oe.status==="scheduled"&&e.jsxs(N1,{children:[e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$(oe),children:e.jsx(ga,{className:"h-4 w-4"})})}),e.jsx(Cl,{children:"Edit post"})]}),e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>q.mutate(oe),disabled:q.isPending,children:q.isPending?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(An,{className:"h-4 w-4"})})}),e.jsx(Cl,{children:"Post now"})]}),e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Cancel this scheduled post?"}),e.jsx(Pl,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Keep"}),e.jsx(pl,{onClick:()=>O.mutate(oe.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(pl,{onClick:()=>V.mutate(oe.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(oe.status==="posted"||oe.status==="cancelled"||oe.status==="failed")&&e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Delete this post?"}),e.jsx(Pl,{children:"This will permanently remove this post from your history."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:()=>V.mutate(oe.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),oe.caption&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:oe.caption}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ln,{className:"h-3 w-3"}),oe.status==="posted"&&oe.posted_at?`Posted ${ps(new Date(oe.posted_at),"PPp")}`:oe.scheduled_for?`Scheduled for ${ps(new Date(oe.scheduled_for),"PPp")}`:"Not scheduled"]}),oe.status==="failed"&&oe.error_message&&e.jsxs("p",{className:"text-xs text-destructive mt-2",children:["Error: ",oe.error_message]})]})]})},oe.id)})})]})]}),e.jsx(fs,{open:!!o,onOpenChange:oe=>!oe&&l(null),children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Edit Scheduled Post"}),e.jsx(Ir,{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(xe,{children:"Caption"}),e.jsx(vr,{value:i,onChange:oe=>d(oe.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[e.jsx(xe,{children:"Schedule for"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(xo,{children:[e.jsx(go,{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(on,{className:"mr-2 h-4 w-4"}),u?ps(u,"PPP"):"Pick a date"]})}),e.jsx(lo,{className:"w-auto p-0",align:"start",children:e.jsx(df,{mode:"single",selected:u,onSelect:p,disabled:oe=>oee.jsx(vt,{value:oe,children:oe},oe))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(Bs,{value:_,onValueChange:b,children:[e.jsx(Rs,{className:"w-[70px]",children:e.jsx(qs,{})}),e.jsx(Os,{children:X.map(oe=>e.jsx(vt,{value:oe,children:oe},oe))})]}),e.jsxs(Bs,{value:N,onValueChange:oe=>w(oe),children:[e.jsx(Rs,{className:"w-[70px]",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"AM",children:"AM"}),e.jsx(vt,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{onClick:U,disabled:I.isPending,children:[I.isPending?e.jsx(_s,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function Gz(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Wet={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */(function(t,s){(function(r){t.exports=r()})(function(){return function r(n,a,o){function l(u,p){if(!a[u]){if(!n[u]){var x=typeof Gz=="function"&&Gz;if(!p&&x)return x(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 Gz=="function"&&Gz,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,x=(3&_)<<6|(b=i.indexOf(d.charAt(N++))),C[w++]=u,_!==64&&(C[w++]=p),b!==64&&(C[w++]=x);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,x,y,_,b){this.compressedSize=p,this.uncompressedSize=x,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")),x=this;return p.on("end",function(){if(this.streamInfo.data_length!==x.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,x,y){return p.pipe(new i).pipe(new d("uncompressedSize")).pipe(x.compressWorker(y)).pipe(new d("compressedSize")).withStreamInfo("compression",x)},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,x,y){var _=l,b=y+x;u^=-1;for(var N=y;N>>8^_[255&(u^p[N])];return-1^u}(0|d,i,i.length,0):function(u,p,x,y){var _=l,b=y+x;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(x,y){d.call(this,"FlateWorker/"+x),this._pako=null,this._pakoAction=x,this._pakoOptions=y,this.meta={}}a.magic="\b\0",i.inherits(p,d),p.prototype.processChunk=function(x){this.meta=x.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(u,x.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 x=this;this._pako.onData=function(y){x.push({data:y,meta:x.meta})}},a.compressWorker=function(x){return new p("Deflate",x)},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,k,C){var E,L,I=_.file,O=_.compression,V=C!==u.utf8encode,q=i.transformTo("string",C(I.name)),$=i.transformTo("string",u.utf8encode(I.name)),U=I.comment,se=i.transformTo("string",C(U)),Y=i.transformTo("string",u.utf8encode(U)),J=$.length!==I.name.length,X=Y.length!==U.length,ce="",ie="",ae="",oe=I.dir,pe=I.date,_e={crc32:0,compressedSize:0,uncompressedSize:0};b&&!N||(_e.crc32=_.crc32,_e.compressedSize=_.compressedSize,_e.uncompressedSize=_.uncompressedSize);var he=0;b&&(he|=8),V||!J&&!X||(he|=2048);var we=0,je=0;oe&&(we|=16),k==="UNIX"?(je=798,we|=function(Te,Me){var Fe=Te;return Te||(Fe=Me?16893:33204),(65535&Fe)<<16}(I.unixPermissions,oe)):(je=20,we|=function(Te){return 63&(Te||0)}(I.dosPermissions)),E=pe.getUTCHours(),E<<=6,E|=pe.getUTCMinutes(),E<<=5,E|=pe.getUTCSeconds()/2,L=pe.getUTCFullYear()-1980,L<<=4,L|=pe.getUTCMonth()+1,L<<=5,L|=pe.getUTCDate(),J&&(ie=o(1,1)+o(p(q),4)+$,ce+="up"+o(ie.length,2)+ie),X&&(ae=o(1,1)+o(p(se),4)+Y,ce+="uc"+o(ae.length,2)+ae);var Ue="";return Ue+=` \0`,Ue+=o(he,2),Ue+=O.magic,Ue+=o(E,2),Ue+=o(L,2),Ue+=o(_e.crc32,4),Ue+=o(_e.compressedSize,4),Ue+=o(_e.uncompressedSize,4),Ue+=o(q.length,2),Ue+=o(ce.length,2),{fileRecord:x.LOCAL_FILE_HEADER+Ue+q+ce,dirRecord:x.CENTRAL_FILE_HEADER+o(je,2)+Ue+o(se.length,2)+"\0\0\0\0"+o(we,4)+o(w,4)+q+ce+se}}var i=r("../utils"),d=r("../stream/GenericWorker"),u=r("../utf8"),p=r("../crc32"),x=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 x.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(x){var y=o.getTypeOf(x);return o.checkSupport(y),y!=="string"||l.uint8array?y==="nodebuffer"?new u(x):l.uint8array?new p(o.transformTo("uint8array",x)):new i(o.transformTo("array",x)):new d(x)}},{"../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"),x=null;if(u.nodestream)try{x=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function y(b,N){return new p.Promise(function(w,k){var C=[],E=b._internalType,L=b._outputType,I=b._mimeType;b.on("data",function(O,V){C.push(O),N&&N(V)}).on("error",function(O){C=[],k(O)}).on("end",function(){try{var O=function(V,q,$){switch(V){case"blob":return o.newBlob(o.transformTo("arraybuffer",q),$);case"base64":return d.encode(q);default:return o.transformTo(V,q)}}(L,function(V,q){var $,U=0,se=null,Y=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 x(){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,k,C,E,L=b.length,I=0;for(C=0;C>>6:(w<65536?N[E++]=224|w>>>12:(N[E++]=240|w>>>18,N[E++]=128|w>>>12&63),N[E++]=128|w>>>6&63),N[E++]=128|63&w);return N}(_)},a.utf8decode=function(_){return l.nodebuffer?o.transformTo("nodebuffer",_).toString("utf-8"):function(b){var N,w,k,C,E=b.length,L=new Array(2*E);for(N=w=0;N>10&1023,L[w++]=56320|1023&k)}return L.length!==w&&(L.subarray?L=L.subarray(0,w):L.length=w),o.applyFromCharCode(L)}(_=o.transformTo(l.uint8array?"uint8array":"array",_))},o.inherits(x,d),x.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,E){var L;for((E=E||C.length)>C.length&&(E=C.length),L=E-1;0<=L&&(192&C[L])==128;)L--;return L<0||L===0?E:L+u[C[L]]>E?L:E}(b),k=b;w!==b.length&&(l.uint8array?(k=b.subarray(0,w),this.leftOver=b.subarray(w,b.length)):(k=b.slice(0,w),this.leftOver=b.slice(w,b.length))),this.push({data:a.utf8decode(k),meta:_.meta})},x.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:a.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},a.Utf8DecodeWorker=x,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 k=0;k>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,k=_.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(x){return p(x,x.length)},a.binstring2buf=function(x){for(var y=new o.Buf8(x.length),_=0,b=y.length;_>10&1023,C[b++]=56320|1023&N)}return p(C,b)},a.utf8border=function(x,y){var _;for((y=y||x.length)>x.length&&(y=x.length),_=y-1;0<=_&&(192&x[_])==128;)_--;return _<0||_===0?y:_+d[x[_]]>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,x=0;i!==0;){for(i-=x=2e3>>1:l>>>1;i[d]=l}return i}();n.exports=function(l,i,d,u){var p=o,x=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"),x=0,y=4,_=0,b=-2,N=-1,w=4,k=2,C=8,E=9,L=286,I=30,O=19,V=2*L+1,q=15,$=3,U=258,se=U+$+1,Y=42,J=113,X=1,ce=2,ie=3,ae=4;function oe(fe,Ve){return fe.msg=p[Ve],Ve}function pe(fe){return(fe<<1)-(4fe.avail_out&&(Je=fe.avail_out),Je!==0&&(l.arraySet(fe.output,Ve.pending_buf,Ve.pending_out,Je,fe.next_out),fe.next_out+=Je,Ve.pending_out+=Je,fe.total_out+=Je,fe.avail_out-=Je,Ve.pending-=Je,Ve.pending===0&&(Ve.pending_out=0))}function we(fe,Ve){i._tr_flush_block(fe,0<=fe.block_start?fe.block_start:-1,fe.strstart-fe.block_start,Ve),fe.block_start=fe.strstart,he(fe.strm)}function je(fe,Ve){fe.pending_buf[fe.pending++]=Ve}function Ue(fe,Ve){fe.pending_buf[fe.pending++]=Ve>>>8&255,fe.pending_buf[fe.pending++]=255&Ve}function Te(fe,Ve){var Je,at,Ae=fe.max_chain_length,Ye=fe.strstart,We=fe.prev_length,ot=fe.nice_match,Ge=fe.strstart>fe.w_size-se?fe.strstart-(fe.w_size-se):0,et=fe.window,ht=fe.w_mask,xt=fe.prev,Ke=fe.strstart+U,Ze=et[Ye+We-1],Et=et[Ye+We];fe.prev_length>=fe.good_match&&(Ae>>=2),ot>fe.lookahead&&(ot=fe.lookahead);do if(et[(Je=Ve)+We]===Et&&et[Je+We-1]===Ze&&et[Je]===et[Ye]&&et[++Je]===et[Ye+1]){Ye+=2,Je++;do;while(et[++Ye]===et[++Je]&&et[++Ye]===et[++Je]&&et[++Ye]===et[++Je]&&et[++Ye]===et[++Je]&&et[++Ye]===et[++Je]&&et[++Ye]===et[++Je]&&et[++Ye]===et[++Je]&&et[++Ye]===et[++Je]&&YeGe&&--Ae!=0);return We<=fe.lookahead?We:fe.lookahead}function Me(fe){var Ve,Je,at,Ae,Ye,We,ot,Ge,et,ht,xt=fe.w_size;do{if(Ae=fe.window_size-fe.lookahead-fe.strstart,fe.strstart>=xt+(xt-se)){for(l.arraySet(fe.window,fe.window,xt,xt,0),fe.match_start-=xt,fe.strstart-=xt,fe.block_start-=xt,Ve=Je=fe.hash_size;at=fe.head[--Ve],fe.head[Ve]=xt<=at?at-xt:0,--Je;);for(Ve=Je=xt;at=fe.prev[--Ve],fe.prev[Ve]=xt<=at?at-xt:0,--Je;);Ae+=xt}if(fe.strm.avail_in===0)break;if(We=fe.strm,ot=fe.window,Ge=fe.strstart+fe.lookahead,et=Ae,ht=void 0,ht=We.avail_in,et=$)for(Ye=fe.strstart-fe.insert,fe.ins_h=fe.window[Ye],fe.ins_h=(fe.ins_h<=$&&(fe.ins_h=(fe.ins_h<=$)if(at=i._tr_tally(fe,fe.strstart-fe.match_start,fe.match_length-$),fe.lookahead-=fe.match_length,fe.match_length<=fe.max_lazy_match&&fe.lookahead>=$){for(fe.match_length--;fe.strstart++,fe.ins_h=(fe.ins_h<=$&&(fe.ins_h=(fe.ins_h<=$&&fe.match_length<=fe.prev_length){for(Ae=fe.strstart+fe.lookahead-$,at=i._tr_tally(fe,fe.strstart-1-fe.prev_match,fe.prev_length-$),fe.lookahead-=fe.prev_length-1,fe.prev_length-=2;++fe.strstart<=Ae&&(fe.ins_h=(fe.ins_h<fe.pending_buf_size-5&&(Je=fe.pending_buf_size-5);;){if(fe.lookahead<=1){if(Me(fe),fe.lookahead===0&&Ve===x)return X;if(fe.lookahead===0)break}fe.strstart+=fe.lookahead,fe.lookahead=0;var at=fe.block_start+Je;if((fe.strstart===0||fe.strstart>=at)&&(fe.lookahead=fe.strstart-at,fe.strstart=at,we(fe,!1),fe.strm.avail_out===0)||fe.strstart-fe.block_start>=fe.w_size-se&&(we(fe,!1),fe.strm.avail_out===0))return X}return fe.insert=0,Ve===y?(we(fe,!0),fe.strm.avail_out===0?ie:ae):(fe.strstart>fe.block_start&&(we(fe,!1),fe.strm.avail_out),X)}),new Ne(4,4,8,4,Fe),new Ne(4,5,16,8,Fe),new Ne(4,6,32,32,Fe),new Ne(4,4,16,16,Le),new Ne(8,16,32,32,Le),new Ne(8,16,128,128,Le),new Ne(8,32,128,256,Le),new Ne(32,128,258,1024,Le),new Ne(32,258,258,4096,Le)],a.deflateInit=function(fe,Ve){return dt(fe,Ve,C,15,8,0)},a.deflateInit2=dt,a.deflateReset=ve,a.deflateResetKeep=ze,a.deflateSetHeader=function(fe,Ve){return fe&&fe.state?fe.state.wrap!==2?b:(fe.state.gzhead=Ve,_):b},a.deflate=function(fe,Ve){var Je,at,Ae,Ye;if(!fe||!fe.state||5>8&255),je(at,at.gzhead.time>>16&255),je(at,at.gzhead.time>>24&255),je(at,at.level===9?2:2<=at.strategy||at.level<2?4:0),je(at,255&at.gzhead.os),at.gzhead.extra&&at.gzhead.extra.length&&(je(at,255&at.gzhead.extra.length),je(at,at.gzhead.extra.length>>8&255)),at.gzhead.hcrc&&(fe.adler=u(fe.adler,at.pending_buf,at.pending,0)),at.gzindex=0,at.status=69):(je(at,0),je(at,0),je(at,0),je(at,0),je(at,0),je(at,at.level===9?2:2<=at.strategy||at.level<2?4:0),je(at,3),at.status=J);else{var We=C+(at.w_bits-8<<4)<<8;We|=(2<=at.strategy||at.level<2?0:at.level<6?1:at.level===6?2:3)<<6,at.strstart!==0&&(We|=32),We+=31-We%31,at.status=J,Ue(at,We),at.strstart!==0&&(Ue(at,fe.adler>>>16),Ue(at,65535&fe.adler)),fe.adler=1}if(at.status===69)if(at.gzhead.extra){for(Ae=at.pending;at.gzindex<(65535&at.gzhead.extra.length)&&(at.pending!==at.pending_buf_size||(at.gzhead.hcrc&&at.pending>Ae&&(fe.adler=u(fe.adler,at.pending_buf,at.pending-Ae,Ae)),he(fe),Ae=at.pending,at.pending!==at.pending_buf_size));)je(at,255&at.gzhead.extra[at.gzindex]),at.gzindex++;at.gzhead.hcrc&&at.pending>Ae&&(fe.adler=u(fe.adler,at.pending_buf,at.pending-Ae,Ae)),at.gzindex===at.gzhead.extra.length&&(at.gzindex=0,at.status=73)}else at.status=73;if(at.status===73)if(at.gzhead.name){Ae=at.pending;do{if(at.pending===at.pending_buf_size&&(at.gzhead.hcrc&&at.pending>Ae&&(fe.adler=u(fe.adler,at.pending_buf,at.pending-Ae,Ae)),he(fe),Ae=at.pending,at.pending===at.pending_buf_size)){Ye=1;break}Ye=at.gzindexAe&&(fe.adler=u(fe.adler,at.pending_buf,at.pending-Ae,Ae)),Ye===0&&(at.gzindex=0,at.status=91)}else at.status=91;if(at.status===91)if(at.gzhead.comment){Ae=at.pending;do{if(at.pending===at.pending_buf_size&&(at.gzhead.hcrc&&at.pending>Ae&&(fe.adler=u(fe.adler,at.pending_buf,at.pending-Ae,Ae)),he(fe),Ae=at.pending,at.pending===at.pending_buf_size)){Ye=1;break}Ye=at.gzindexAe&&(fe.adler=u(fe.adler,at.pending_buf,at.pending-Ae,Ae)),Ye===0&&(at.status=103)}else at.status=103;if(at.status===103&&(at.gzhead.hcrc?(at.pending+2>at.pending_buf_size&&he(fe),at.pending+2<=at.pending_buf_size&&(je(at,255&fe.adler),je(at,fe.adler>>8&255),fe.adler=0,at.status=J)):at.status=J),at.pending!==0){if(he(fe),fe.avail_out===0)return at.last_flush=-1,_}else if(fe.avail_in===0&&pe(Ve)<=pe(Je)&&Ve!==y)return oe(fe,-5);if(at.status===666&&fe.avail_in!==0)return oe(fe,-5);if(fe.avail_in!==0||at.lookahead!==0||Ve!==x&&at.status!==666){var ot=at.strategy===2?function(Ge,et){for(var ht;;){if(Ge.lookahead===0&&(Me(Ge),Ge.lookahead===0)){if(et===x)return X;break}if(Ge.match_length=0,ht=i._tr_tally(Ge,0,Ge.window[Ge.strstart]),Ge.lookahead--,Ge.strstart++,ht&&(we(Ge,!1),Ge.strm.avail_out===0))return X}return Ge.insert=0,et===y?(we(Ge,!0),Ge.strm.avail_out===0?ie:ae):Ge.last_lit&&(we(Ge,!1),Ge.strm.avail_out===0)?X:ce}(at,Ve):at.strategy===3?function(Ge,et){for(var ht,xt,Ke,Ze,Et=Ge.window;;){if(Ge.lookahead<=U){if(Me(Ge),Ge.lookahead<=U&&et===x)return X;if(Ge.lookahead===0)break}if(Ge.match_length=0,Ge.lookahead>=$&&0Ge.lookahead&&(Ge.match_length=Ge.lookahead)}if(Ge.match_length>=$?(ht=i._tr_tally(Ge,1,Ge.match_length-$),Ge.lookahead-=Ge.match_length,Ge.strstart+=Ge.match_length,Ge.match_length=0):(ht=i._tr_tally(Ge,0,Ge.window[Ge.strstart]),Ge.lookahead--,Ge.strstart++),ht&&(we(Ge,!1),Ge.strm.avail_out===0))return X}return Ge.insert=0,et===y?(we(Ge,!0),Ge.strm.avail_out===0?ie:ae):Ge.last_lit&&(we(Ge,!1),Ge.strm.avail_out===0)?X:ce}(at,Ve):o[at.level].func(at,Ve);if(ot!==ie&&ot!==ae||(at.status=666),ot===X||ot===ie)return fe.avail_out===0&&(at.last_flush=-1),_;if(ot===ce&&(Ve===1?i._tr_align(at):Ve!==5&&(i._tr_stored_block(at,0,0,!1),Ve===3&&(_e(at.head),at.lookahead===0&&(at.strstart=0,at.block_start=0,at.insert=0))),he(fe),fe.avail_out===0))return at.last_flush=-1,_}return Ve!==y?_:at.wrap<=0?1:(at.wrap===2?(je(at,255&fe.adler),je(at,fe.adler>>8&255),je(at,fe.adler>>16&255),je(at,fe.adler>>24&255),je(at,255&fe.total_in),je(at,fe.total_in>>8&255),je(at,fe.total_in>>16&255),je(at,fe.total_in>>24&255)):(Ue(at,fe.adler>>>16),Ue(at,65535&fe.adler)),he(fe),0=Je.w_size&&(Ye===0&&(_e(Je.head),Je.strstart=0,Je.block_start=0,Je.insert=0),et=new l.Buf8(Je.w_size),l.arraySet(et,Ve,ht-Je.w_size,Je.w_size,0),Ve=et,ht=Je.w_size),We=fe.avail_in,ot=fe.next_in,Ge=fe.input,fe.avail_in=ht,fe.next_in=0,fe.input=Ve,Me(Je);Je.lookahead>=$;){for(at=Je.strstart,Ae=Je.lookahead-($-1);Je.ins_h=(Je.ins_h<>>=$=q>>>24,E-=$,($=q>>>16&255)===0)ce[p++]=65535&q;else{if(!(16&$)){if(!(64&$)){q=L[(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}U=65535&q,($&=15)&&(E<$&&(C+=X[d++]<>>=$,E-=$),E<15&&(C+=X[d++]<>>=$=q>>>24,E-=$,!(16&($=q>>>16&255))){if(!(64&$)){q=I[(65535&q)+(C&(1<<$)-1)];continue s}o.msg="invalid distance code",i.mode=30;break e}if(se=65535&q,E<($&=15)&&(C+=X[d++]<>>=$,E-=$,($=p-x)>3,C&=(1<<(E-=U<<3))-1,o.next_in=d,o.next_out=p,o.avail_in=d>>24&255)+(Y>>>8&65280)+((65280&Y)<<8)+((255&Y)<<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 E(Y){var J;return Y&&Y.state?(J=Y.state,Y.total_in=Y.total_out=J.total=0,Y.msg="",J.wrap&&(Y.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 L(Y){var J;return Y&&Y.state?((J=Y.state).wsize=0,J.whave=0,J.wnext=0,E(Y)):_}function I(Y,J){var X,ce;return Y&&Y.state?(ce=Y.state,J<0?(X=0,J=-J):(X=1+(J>>4),J<48&&(J&=15)),J&&(J<8||15=ae.wsize?(o.arraySet(ae.window,J,X-ae.wsize,ae.wsize,0),ae.wnext=0,ae.whave=ae.wsize):(ce<(ie=ae.wsize-ae.wnext)&&(ie=ce),o.arraySet(ae.window,J,X-ce,ie,ae.wnext),(ce-=ie)?(o.arraySet(ae.window,J,X-ce,ce,0),ae.wnext=ce,ae.whave=ae.wsize):(ae.wnext+=ie,ae.wnext===ae.wsize&&(ae.wnext=0),ae.whave>>8&255,X.check=i(X.check,Ye,2,0),we=he=0,X.mode=2;break}if(X.flags=0,X.head&&(X.head.done=!1),!(1&X.wrap)||(((255&he)<<8)+(he>>8))%31){Y.msg="incorrect header check",X.mode=30;break}if((15&he)!=8){Y.msg="unknown compression method",X.mode=30;break}if(we-=4,fe=8+(15&(he>>>=4)),X.wbits===0)X.wbits=fe;else if(fe>X.wbits){Y.msg="invalid window size",X.mode=30;break}X.dmax=1<>8&1),512&X.flags&&(Ye[0]=255&he,Ye[1]=he>>>8&255,X.check=i(X.check,Ye,2,0)),we=he=0,X.mode=3;case 3:for(;we<32;){if(pe===0)break e;pe--,he+=ce[ae++]<>>8&255,Ye[2]=he>>>16&255,Ye[3]=he>>>24&255,X.check=i(X.check,Ye,4,0)),we=he=0,X.mode=4;case 4:for(;we<16;){if(pe===0)break e;pe--,he+=ce[ae++]<>8),512&X.flags&&(Ye[0]=255&he,Ye[1]=he>>>8&255,X.check=i(X.check,Ye,2,0)),we=he=0,X.mode=5;case 5:if(1024&X.flags){for(;we<16;){if(pe===0)break e;pe--,he+=ce[ae++]<>>8&255,X.check=i(X.check,Ye,2,0)),we=he=0}else X.head&&(X.head.extra=null);X.mode=6;case 6:if(1024&X.flags&&(pe<(Te=X.length)&&(Te=pe),Te&&(X.head&&(fe=X.head.extra_len-X.length,X.head.extra||(X.head.extra=new Array(X.head.extra_len)),o.arraySet(X.head.extra,ce,ae,Te,fe)),512&X.flags&&(X.check=i(X.check,ce,Te,ae)),pe-=Te,ae+=Te,X.length-=Te),X.length))break e;X.length=0,X.mode=7;case 7:if(2048&X.flags){if(pe===0)break e;for(Te=0;fe=ce[ae+Te++],X.head&&fe&&X.length<65536&&(X.head.name+=String.fromCharCode(fe)),fe&&Te>9&1,X.head.done=!0),Y.adler=X.check=0,X.mode=12;break;case 10:for(;we<32;){if(pe===0)break e;pe--,he+=ce[ae++]<>>=7&we,we-=7&we,X.mode=27;break}for(;we<3;){if(pe===0)break e;pe--,he+=ce[ae++]<>>=1)){case 0:X.mode=14;break;case 1:if(U(X),X.mode=20,J!==6)break;he>>>=2,we-=2;break e;case 2:X.mode=17;break;case 3:Y.msg="invalid block type",X.mode=30}he>>>=2,we-=2;break;case 14:for(he>>>=7&we,we-=7&we;we<32;){if(pe===0)break e;pe--,he+=ce[ae++]<>>16^65535)){Y.msg="invalid stored block lengths",X.mode=30;break}if(X.length=65535&he,we=he=0,X.mode=15,J===6)break e;case 15:X.mode=16;case 16:if(Te=X.length){if(pe>>=5,we-=5,X.ndist=1+(31&he),he>>>=5,we-=5,X.ncode=4+(15&he),he>>>=4,we-=4,286>>=3,we-=3}for(;X.have<19;)X.lens[We[X.have++]]=0;if(X.lencode=X.lendyn,X.lenbits=7,Je={bits:X.lenbits},Ve=u(0,X.lens,0,19,X.lencode,0,X.work,Je),X.lenbits=Je.bits,Ve){Y.msg="invalid code lengths set",X.mode=30;break}X.have=0,X.mode=19;case 19:for(;X.have>>16&255,qe=65535&Ae,!((Le=Ae>>>24)<=we);){if(pe===0)break e;pe--,he+=ce[ae++]<>>=Le,we-=Le,X.lens[X.have++]=qe;else{if(qe===16){for(at=Le+2;we>>=Le,we-=Le,X.have===0){Y.msg="invalid bit length repeat",X.mode=30;break}fe=X.lens[X.have-1],Te=3+(3&he),he>>>=2,we-=2}else if(qe===17){for(at=Le+3;we>>=Le)),he>>>=3,we-=3}else{for(at=Le+7;we>>=Le)),he>>>=7,we-=7}if(X.have+Te>X.nlen+X.ndist){Y.msg="invalid bit length repeat",X.mode=30;break}for(;Te--;)X.lens[X.have++]=fe}}if(X.mode===30)break;if(X.lens[256]===0){Y.msg="invalid code -- missing end-of-block",X.mode=30;break}if(X.lenbits=9,Je={bits:X.lenbits},Ve=u(p,X.lens,0,X.nlen,X.lencode,0,X.work,Je),X.lenbits=Je.bits,Ve){Y.msg="invalid literal/lengths set",X.mode=30;break}if(X.distbits=6,X.distcode=X.distdyn,Je={bits:X.distbits},Ve=u(x,X.lens,X.nlen,X.ndist,X.distcode,0,X.work,Je),X.distbits=Je.bits,Ve){Y.msg="invalid distances set",X.mode=30;break}if(X.mode=20,J===6)break e;case 20:X.mode=21;case 21:if(6<=pe&&258<=_e){Y.next_out=oe,Y.avail_out=_e,Y.next_in=ae,Y.avail_in=pe,X.hold=he,X.bits=we,d(Y,Ue),oe=Y.next_out,ie=Y.output,_e=Y.avail_out,ae=Y.next_in,ce=Y.input,pe=Y.avail_in,he=X.hold,we=X.bits,X.mode===12&&(X.back=-1);break}for(X.back=0;Ne=(Ae=X.lencode[he&(1<>>16&255,qe=65535&Ae,!((Le=Ae>>>24)<=we);){if(pe===0)break e;pe--,he+=ce[ae++]<>ze)])>>>16&255,qe=65535&Ae,!(ze+(Le=Ae>>>24)<=we);){if(pe===0)break e;pe--,he+=ce[ae++]<>>=ze,we-=ze,X.back+=ze}if(he>>>=Le,we-=Le,X.back+=Le,X.length=qe,Ne===0){X.mode=26;break}if(32&Ne){X.back=-1,X.mode=12;break}if(64&Ne){Y.msg="invalid literal/length code",X.mode=30;break}X.extra=15&Ne,X.mode=22;case 22:if(X.extra){for(at=X.extra;we>>=X.extra,we-=X.extra,X.back+=X.extra}X.was=X.length,X.mode=23;case 23:for(;Ne=(Ae=X.distcode[he&(1<>>16&255,qe=65535&Ae,!((Le=Ae>>>24)<=we);){if(pe===0)break e;pe--,he+=ce[ae++]<>ze)])>>>16&255,qe=65535&Ae,!(ze+(Le=Ae>>>24)<=we);){if(pe===0)break e;pe--,he+=ce[ae++]<>>=ze,we-=ze,X.back+=ze}if(he>>>=Le,we-=Le,X.back+=Le,64&Ne){Y.msg="invalid distance code",X.mode=30;break}X.offset=qe,X.extra=15&Ne,X.mode=24;case 24:if(X.extra){for(at=X.extra;we>>=X.extra,we-=X.extra,X.back+=X.extra}if(X.offset>X.dmax){Y.msg="invalid distance too far back",X.mode=30;break}X.mode=25;case 25:if(_e===0)break e;if(Te=Ue-_e,X.offset>Te){if((Te=X.offset-Te)>X.whave&&X.sane){Y.msg="invalid distance too far back",X.mode=30;break}Me=Te>X.wnext?(Te-=X.wnext,X.wsize-Te):X.wnext-Te,Te>X.length&&(Te=X.length),Fe=X.window}else Fe=ie,Me=oe-X.offset,Te=X.length;for(_eV?($=Me[Fe+w[J]],we[je+w[J]]):($=96,0),C=1<>oe)+(E-=C)]=q<<24|$<<16|U|0,E!==0;);for(C=1<>=1;if(C!==0?(he&=C-1,he+=C):he=0,J++,--Ue[Y]==0){if(Y===ce)break;Y=x[y+w[J]]}if(ie>>7)]}function je(Ae,Ye){Ae.pending_buf[Ae.pending++]=255&Ye,Ae.pending_buf[Ae.pending++]=Ye>>>8&255}function Ue(Ae,Ye,We){Ae.bi_valid>k-We?(Ae.bi_buf|=Ye<>k-Ae.bi_valid,Ae.bi_valid+=We-k):(Ae.bi_buf|=Ye<>>=1,We<<=1,0<--Ye;);return We>>>1}function Fe(Ae,Ye,We){var ot,Ge,et=new Array(w+1),ht=0;for(ot=1;ot<=w;ot++)et[ot]=ht=ht+We[ot-1]<<1;for(Ge=0;Ge<=Ye;Ge++){var xt=Ae[2*Ge+1];xt!==0&&(Ae[2*Ge]=Me(et[xt]++,xt))}}function Le(Ae){var Ye;for(Ye=0;Ye>1;1<=We;We--)ze(Ae,et,We);for(Ge=Ke;We=Ae.heap[1],Ae.heap[1]=Ae.heap[Ae.heap_len--],ze(Ae,et,1),ot=Ae.heap[1],Ae.heap[--Ae.heap_max]=We,Ae.heap[--Ae.heap_max]=ot,et[2*Ge]=et[2*We]+et[2*ot],Ae.depth[Ge]=(Ae.depth[We]>=Ae.depth[ot]?Ae.depth[We]:Ae.depth[ot])+1,et[2*We+1]=et[2*ot+1]=Ge,Ae.heap[1]=Ge++,ze(Ae,et,1),2<=Ae.heap_len;);Ae.heap[--Ae.heap_max]=Ae.heap[1],function(Et,$t){var Yt,Ps,zs,Zs,Dr,zt,$s=$t.dyn_tree,kr=$t.max_code,Xs=$t.stat_desc.static_tree,ir=$t.stat_desc.has_stree,Or=$t.stat_desc.extra_bits,Vn=$t.stat_desc.extra_base,Qr=$t.stat_desc.max_length,Gr=0;for(Zs=0;Zs<=w;Zs++)Et.bl_count[Zs]=0;for($s[2*Et.heap[Et.heap_max]+1]=0,Yt=Et.heap_max+1;Yt>=7;Ge<_;Ge++)for(pe[Ge]=et<<7,Ye=0;Ye<1<>>=1)if(1&Ze&&xt.dyn_ltree[2*Ke]!==0)return l;if(xt.dyn_ltree[18]!==0||xt.dyn_ltree[20]!==0||xt.dyn_ltree[26]!==0)return i;for(Ke=32;Ke>>3,(et=Ae.static_len+3+7>>>3)<=Ge&&(Ge=et)):Ge=et=We+5,We+4<=Ge&&Ye!==-1?at(Ae,Ye,We,ot):Ae.strategy===4||et===Ge?(Ue(Ae,2+(ot?1:0),3),ve(Ae,se,Y)):(Ue(Ae,4+(ot?1:0),3),function(xt,Ke,Ze,Et){var $t;for(Ue(xt,Ke-257,5),Ue(xt,Ze-1,5),Ue(xt,Et-4,4),$t=0;$t>>8&255,Ae.pending_buf[Ae.d_buf+2*Ae.last_lit+1]=255&Ye,Ae.pending_buf[Ae.l_buf+Ae.last_lit]=255&We,Ae.last_lit++,Ye===0?Ae.dyn_ltree[2*We]++:(Ae.matches++,Ye--,Ae.dyn_ltree[2*(X[We]+x+1)]++,Ae.dyn_dtree[2*we(Ye)]++),Ae.last_lit===Ae.lit_bufsize-1},a._tr_align=function(Ae){Ue(Ae,2,3),Te(Ae,E,se),function(Ye){Ye.bi_valid===16?(je(Ye,Ye.bi_buf),Ye.bi_buf=0,Ye.bi_valid=0):8<=Ye.bi_valid&&(Ye.pending_buf[Ye.pending++]=255&Ye.bi_buf,Ye.bi_buf>>=8,Ye.bi_valid-=8)}(Ae)}},{"../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,x,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(L){process.nextTick(function(){C(L)})}:function(){if(l.postMessage&&!l.importScripts){var L=!0,I=l.onmessage;return l.onmessage=function(){L=!1},l.postMessage("","*"),l.onmessage=I,L}}()?(x="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",E,!1):l.attachEvent("onmessage",E),function(L){l.postMessage(x+L,"*")}):l.MessageChannel?((p=new MessageChannel).port1.onmessage=function(L){C(L.data)},function(L){p.port2.postMessage(L)}):N&&"onreadystatechange"in N.createElement("script")?(u=N.documentElement,function(L){var I=N.createElement("script");I.onreadystatechange=function(){C(L),I.onreadystatechange=null,u.removeChild(I),I=null},u.appendChild(I)}):function(L){setTimeout(C,0,L)},w.setImmediate=function(L){typeof L!="function"&&(L=new Function(""+L));for(var I=new Array(arguments.length-1),O=0;O"u"?o===void 0?this:o:self)}).call(this,typeof md<"u"?md:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Wet);var xUt=Wet.exports;const gUt=so(xUt);function bye(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 yUt=()=>{const{isAdmin:t}=Fs(),[s,r]=S.useState(null),[n,a]=S.useState(null),[o,l]=S.useState("all"),[i,d]=S.useState(new Set),[u,p]=S.useState(!1),[x,y]=S.useState(!1),[_,b]=S.useState("images"),[N,w]=S.useState(null),{data:k=[],isLoading:C}=gt({queryKey:["social-swag-2"],queryFn:async()=>{const{data:pe,error:_e}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(_e)throw _e;return pe}}),{data:E=[]}=gt({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:pe,error:_e}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(_e)throw _e;return pe}}),{data:L=[]}=gt({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:pe,error:_e}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(_e)throw _e;return pe}}),{data:I=[]}=gt({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:pe,error:_e}=await G.from("social_accounts").select("id, platform").eq("is_active",!0);if(_e)throw _e;return pe||[]}}),O=I.length>0,V=S.useMemo(()=>o==="all"?null:L.find(pe=>pe.month===o)||null,[o,L]),q=S.useMemo(()=>[...new Set(k.map(_e=>_e.month))].sort((_e,he)=>he.localeCompare(_e)),[k]);S.useEffect(()=>{q.length>0&&o==="all"&&l(q[0])},[q,o]);const $=pe=>{try{const _e=Qje(pe,"yyyy-MM",new Date);return ps(_e,"MMMM yyyy")}catch{return pe}},U=S.useMemo(()=>o==="all"?k:k.filter(pe=>pe.month===o),[o,k]),se=S.useMemo(()=>{var pe;return o==="all"?null:((pe=E.find(_e=>_e.month===o))==null?void 0:pe.canva_link)||null},[o,E]),Y=async pe=>{try{await navigator.clipboard.writeText(pe),me.success("Caption copied to clipboard!")}catch{me.error("Failed to copy caption")}},J=async(pe,_e)=>{try{const we=await(await fetch(pe)).blob(),je=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),Ue=navigator.canShare&&navigator.canShare({files:[new File([we],"test.jpg",{type:"image/jpeg"})]});if(je&&Ue){const Te=new File([we],`social-swag-${_e}.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),Me=document.createElement("a");Me.href=Te,Me.download=`social-swag-${_e}.jpg`,document.body.appendChild(Me),Me.click(),document.body.removeChild(Me),window.URL.revokeObjectURL(Te),me.success("Image downloaded!")}}catch(he){he.name!=="AbortError"&&me.error("Failed to download image")}},X=pe=>{d(_e=>{const he=new Set(_e);return he.has(pe)?he.delete(pe):he.add(pe),he})},ce=()=>{d(new Set(U.map(pe=>pe.id)))},ie=()=>{d(new Set),p(!1)},ae=async()=>{const pe=U.filter(_e=>i.has(_e.id));if(pe.length===0){me.error("No images selected");return}y(!0),me.info(`Preparing ${pe.length} images for download...`);try{const _e=new gUt,he=[...pe].sort((Me,Fe)=>Me.sort_order-Fe.sort_order);for(let Me=0;Me{u?X(pe.id):r(pe)};return e.jsx(Es,{title:"Social Swag 2.0",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary via-primary/80 to-info p-8 text-primary-foreground",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzMiAyIDIgNC0yIDQtMiA0LTItMi0yLTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsxs(Qe,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx($r,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(Qe,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(Wo,{className:"h-3 w-3 mr-1"}),k.length," images"]})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3",children:"Social Swag 📸"}),e.jsx("p",{className:"text-lg text-primary-foreground/90 max-w-2xl",children:"Ready-to-post social media images delivered to you monthly. Just download, copy the caption, and share with your audience!"})]})]}),t?e.jsxs(ia,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(ea,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(ls,{value:"gallery",className:"gap-2",children:[e.jsx(Wo,{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(Pe,{className:"border rounded-xl",children:e.jsx(Re,{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(ha,{to:"/social-connections",children:"Manage Accounts"})})]})})}):e.jsx(Pe,{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(Re,{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(uu,{className:"h-5 w-5 text-blue-600"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(mu,{className:"h-5 w-5 text-pink-600"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Post directly to social media"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your Facebook & Instagram accounts to post images with one click!"})]}),e.jsx(K,{asChild:!0,className:"gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600",children:e.jsxs(ha,{to:"/social-connections",children:[e.jsx(Do,{className:"h-4 w-4"}),"Connect Accounts"]})})]})})}):e.jsx(Pe,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Re,{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(ln,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(uu,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(mu,{className:"h-5 w-5 text-pink-400"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(pe=>e.jsx("button",{onClick:()=>l(pe),className:Rt("px-4 py-2 rounded-full text-sm font-medium transition-all",o===pe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:$(pe)},pe))}),o!=="all"&&(se?e.jsxs("a",{href:se,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"),ie()},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(Wo,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),ie()},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(tu,{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 (",U.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,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:ae,disabled:x,className:"gap-2",children:[e.jsx(Xa,{className:"h-4 w-4"}),x?"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(Jn,{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:U.map(pe=>{const _e=i.has(pe.id);return e.jsx(Pe,{className:Rt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&_e&&"ring-2 ring-primary ring-offset-2"),onClick:()=>oe(pe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:bye(pe.image_url,400,75),alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110",loading:"lazy",decoding:"async"}),pe.post_date&&!u&&e.jsx("div",{className:"absolute top-0 left-0 w-24 h-24 overflow-hidden pointer-events-none",children:e.jsx("div",{className:"absolute flex items-center justify-center text-white font-bold text-[10px] tracking-wider uppercase",style:{top:"20px",left:"-34px",width:"136px",transform:"rotate(-45deg)",backgroundColor:"#2d5052",padding:"5px 0",boxShadow:"0 2px 4px rgba(0,0,0,0.25)"},children:ps(new Date(pe.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",_e?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:_e&&e.jsx(Jn,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},pe.id)})}),U.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Wo,{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:V?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(Pe,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a(V),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:bye(V.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(Qe,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(tu,{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(tu,{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:bye(s.image_url,900,85),alt:"Social swag",className:"w-full h-full object-cover",decoding:"async"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground mb-4",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(on,{className:"h-4 w-4"}),ps(new Date(s.created_at),"MMMM d, yyyy")]}),s.post_date&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium rounded-full px-3 py-1 text-xs text-white",style:{background:"#406E71"},children:[e.jsx(on,{className:"h-3.5 w-3.5"}),"Post on ",ps(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(An,{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:()=>Y(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(tu,{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:()=>Y(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(pUt,{open:!!N,onOpenChange:pe=>!pe&&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(fUt,{})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Re,{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(ln,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(uu,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(mu,{className:"h-5 w-5 text-pink-400"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(pe=>e.jsx("button",{onClick:()=>l(pe),className:Rt("px-4 py-2 rounded-full text-sm font-medium transition-all",o===pe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:$(pe)},pe))}),o!=="all"&&(se?e.jsxs("a",{href:se,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"),ie()},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(Wo,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),ie()},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(tu,{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 (",U.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,className:"gap-2",children:[e.jsx(Sr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(K,{size:"sm",onClick:ae,disabled:x,className:"gap-2",children:[e.jsx(Xa,{className:"h-4 w-4"}),x?"Downloading...":`Download ${i.size} Selected`]})]}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[e.jsx(Jn,{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:U.map(pe=>{const _e=i.has(pe.id);return e.jsx(Pe,{className:Rt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&_e&&"ring-2 ring-primary ring-offset-2"),onClick:()=>oe(pe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:pe.image_url,alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"}),u&&e.jsx("div",{className:Rt("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",_e?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:_e&&e.jsx(Jn,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},pe.id)})}),U.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Wo,{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:V?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(Pe,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a(V),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:V.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(Qe,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(tu,{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(tu,{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(on,{className:"h-4 w-4"}),ps(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:()=>Y(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(tu,{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:()=>Y(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"]})]})]})]})})})})]})]})})},vUt=()=>{const{swagId:t}=co(),{user:s}=Fs(),{toast:r}=wa(),n=Jt(),{trackEngagement:a}=YA(),[o,l]=S.useState(""),{data:i,isLoading:d}=gt({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:k,error:C}=await G.from("social_swag").select("*").eq("id",t).single();if(C)throw C;const{data:E}=await G.from("social_swag_links").select("*").eq("swag_id",t).order("sort_order");return{...k,links:E||[]}},enabled:!!t});S.useEffect(()=>{i&&a("social_swag",i.id,i.title,"view")},[i==null?void 0:i.id]);const{data:u=[]}=gt({queryKey:["social-swag-likes",t],queryFn:async()=>{const{data:k,error:C}=await G.from("social_swag_likes").select("*").eq("swag_id",t);if(C)throw C;return k},enabled:!!t}),{data:p=[]}=gt({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:k,error:C}=await G.from("social_swag_comments").select("*").eq("swag_id",t).order("created_at",{ascending:!1});if(C)throw C;const E=[...new Set(k.map(O=>O.user_id))],{data:L}=await G.from("profiles").select("id, name").in("id",E),I=new Map((L==null?void 0:L.map(O=>[O.id,O.name]))||[]);return k.map(O=>({...O,user_name:I.get(O.user_id)||"Unknown User"}))},enabled:!!t}),x=It({mutationFn:async k=>{const{error:C}=await G.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:k});if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),l(""),r({title:"Comment added!"})},onError:k=>{r({title:"Error adding comment",description:k.message,variant:"destructive"})}}),y=It({mutationFn:async k=>{const{error:C}=await G.from("social_swag_comments").delete().eq("id",k);if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),_=It({mutationFn:async()=>{const k=u.find(C=>C.user_id===(s==null?void 0:s.id));if(k){const{error:C}=await G.from("social_swag_likes").delete().eq("id",k.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(k=>k.user_id===(s==null?void 0:s.id)),N=k=>k.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),w=k=>{k.preventDefault(),!(!o.trim()||!s)&&x.mutate(o.trim())};return d?e.jsx(Es,{title:"Social Swag",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):i?e.jsx(Es,{title:i.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(ha,{to:"/social-swag",children:[e.jsx(Fa,{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(eE,{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(Fu,{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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(fo,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),e.jsx("div",{className:"grid gap-2",children:i.links.map(k=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{a("social_swag",i.id,i.title,"click_canva"),window.open(k.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:k.title}),e.jsx(Kr,{className:"h-4 w-4 text-muted-foreground"})]},k.id))})]})}),e.jsx(wo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(vc,{className:"h-5 w-5"}),"Comments (",p.length,")"]}),s?e.jsxs("form",{onSubmit:w,className:"flex gap-2",children:[e.jsx(vr,{placeholder:"Add a comment...",value:o,onChange:k=>l(k.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!o.trim()||x.isPending,children:e.jsx(An,{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(Pe,{children:e.jsx(Re,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):p.map(k=>e.jsx(Pe,{children:e.jsx(Re,{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(k.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:k.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:gl(new Date(k.created_at),{addSuffix:!0})}),k.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>y.mutate(k.id),children:e.jsx(gr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:k.content})]})]})})},k.id))})]})]})}):e.jsx(Es,{title:"Social Swag",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(fo,{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(ha,{to:"/social-swag",children:"Back to Social Swag"})})]})})},_Ut=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=S.useState(!0),[i,d]=S.useState(!0),[u,p]=S.useState(!0),x=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(X4,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(of,{open:o,onOpenChange:l,children:[e.jsx(lf,{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(Oi,{className:"h-4 w-4"}):e.jsx(Sa,{className:"h-4 w-4"})]})}),e.jsx(cf,{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(of,{open:i,onOpenChange:d,children:[e.jsx(lf,{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(Oi,{className:"h-4 w-4"}):e.jsx(Sa,{className:"h-4 w-4"})]})}),e.jsx(cf,{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(of,{open:u,onOpenChange:p,children:[e.jsx(lf,{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(lr,{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(Oi,{className:"h-4 w-4"}):e.jsx(Sa,{className:"h-4 w-4"})]})}),e.jsx(cf,{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(Ta,{src:y.avatarUrl}),e.jsx(_n,{className:"text-xs",children:x(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))})]})]})})})},bUt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=S.useState(!1),i=u=>u.split(" ").map(p=>p[0]).join("").toUpperCase().slice(0,2),d=()=>{if(r==="all")return"All Posts";if(r.startsWith("group:")){const p=r.replace("group:",""),x=s.find(y=>y.id===p);return x?`🔒 ${x.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(Oi,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(jd,{className:"w-56 bg-background border",children:[e.jsxs(va,{onClick:()=>n("all"),children:[e.jsx(X4,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(Zb,{}),e.jsx(u1e,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(u=>e.jsxs(va,{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(Zb,{}),e.jsxs(u1e,{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(va,{onClick:()=>n(`group:${u.id}`),children:[e.jsx("span",{className:"mr-2",children:u.icon||"🔒"}),u.name]},u.id))]})]})]}),e.jsxs(GA,{open:o,onOpenChange:l,children:[e.jsx(DNe,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(lr,{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(wC,{children:[e.jsx(WA,{children:e.jsxs(KA,{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(ui,{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(Ta,{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 wye,jhe="HoverCard",[Ket,$Ts]=$c(jhe,[_0]),Nhe=_0(),[wUt,o4e]=Ket(jhe),Zet=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,d=Nhe(s),u=S.useRef(0),p=S.useRef(0),x=S.useRef(!1),y=S.useRef(!1),[_,b]=$u({prop:n,defaultProp:a??!1,onChange:o,caller:jhe}),N=S.useCallback(()=>{clearTimeout(p.current),u.current=window.setTimeout(()=>b(!0),l)},[l,b]),w=S.useCallback(()=>{clearTimeout(u.current),!x.current&&!y.current&&(p.current=window.setTimeout(()=>b(!1),i))},[i,b]),k=S.useCallback(()=>b(!1),[b]);return S.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(p.current)},[]),e.jsx(wUt,{scope:s,open:_,onOpenChange:b,onOpen:N,onClose:w,onDismiss:k,hasSelectionRef:x,isPointerDownOnContentRef:y,children:e.jsx(wR,{...d,children:r})})};Zet.displayName=jhe;var Yet="HoverCardTrigger",Xet=S.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=o4e(Yet,r),o=Nhe(r);return e.jsx(LA,{asChild:!0,...o,children:e.jsx(Yr.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Cr(t.onPointerEnter,dce(a.onOpen)),onPointerLeave:Cr(t.onPointerLeave,dce(a.onClose)),onFocus:Cr(t.onFocus,a.onOpen),onBlur:Cr(t.onBlur,a.onClose),onTouchStart:Cr(t.onTouchStart,l=>l.preventDefault())})})});Xet.displayName=Yet;var jUt="HoverCardPortal",[qTs,NUt]=Ket(jUt,{forceMount:void 0}),cce="HoverCardContent",Qet=S.forwardRef((t,s)=>{const r=NUt(cce,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=o4e(cce,t.__scopeHoverCard);return e.jsx(wd,{present:n||o.open,children:e.jsx(kUt,{"data-state":o.open?"open":"closed",...a,onPointerEnter:Cr(t.onPointerEnter,dce(o.onOpen)),onPointerLeave:Cr(t.onPointerLeave,dce(o.onClose)),ref:s})})});Qet.displayName=cce;var kUt=S.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,d=o4e(cce,r),u=Nhe(r),p=S.useRef(null),x=Aa(s,p),[y,_]=S.useState(!1);return S.useEffect(()=>{if(y){const b=document.body;return wye=b.style.userSelect||b.style.webkitUserSelect,b.style.userSelect="none",b.style.webkitUserSelect="none",()=>{b.style.userSelect=wye,b.style.webkitUserSelect=wye}}},[y]),S.useEffect(()=>{if(p.current){const b=()=>{_(!1),d.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var w;((w=document.getSelection())==null?void 0:w.toString())!==""&&(d.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",b),()=>{document.removeEventListener("pointerup",b),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!1}}},[d.isPointerDownOnContentRef,d.hasSelectionRef]),S.useEffect(()=>{p.current&&MUt(p.current).forEach(N=>N.setAttribute("tabindex","-1"))}),e.jsx(lw,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Cr(o,b=>{b.preventDefault()}),onDismiss:d.onDismiss,children:e.jsx(jR,{...u,...i,onPointerDown:Cr(i.onPointerDown,b=>{b.currentTarget.contains(b.target)&&_(!0),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!0}),ref:x,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)"}})})}),SUt="HoverCardArrow",CUt=S.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Nhe(r);return e.jsx(NR,{...a,...n,ref:s})});CUt.displayName=SUt;function dce(t){return s=>s.pointerType==="touch"?void 0:t()}function MUt(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 TUt=Zet,AUt=Xet,Jet=Qet;const EUt=TUt,PUt=AUt,ett=S.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(Jet,{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}));ett.displayName=Jet.displayName;const IUt=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"},{type:"laugh",emoji:"😂",label:"Haha"},{type:"wow",emoji:"😮",label:"Wow"},{type:"sad",emoji:"😢",label:"Sad"},{type:"angry",emoji:"😠",label:"Angry"}],LUt=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),ttt=({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(EUt,{openDelay:200,closeDelay:100,children:[e.jsx(PUt,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(ett,{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=IUt.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(Ta,{src:l.user_avatar||void 0}),e.jsx(_n,{className:"text-[10px]",children:LUt(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 DUt({images:t,initialIndex:s=0,open:r,onOpenChange:n}){const[a,o]=S.useState(s),[l,i]=S.useState(!1);S.useEffect(()=>{r&&(o(s),i(!1))},[r,s]);const d=()=>{o(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]);S.useEffect(()=>(window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)),[p]);const x=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(xl,{className:"h-8 w-8"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:u,children:e.jsx(Sa,{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]}),(x==null?void 0:x.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(RM,{className:"h-5 w-5"}):e.jsx(Ab,{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:()=>(x==null?void 0:x.type)==="image"&&i(!l),children:(x==null?void 0:x.type)==="video"?e.jsx("video",{src:x.url,controls:!0,autoPlay:!0,className:"max-w-full max-h-[85vh] object-contain",onClick:y=>y.stopPropagation()}):e.jsx("img",{src:x==null?void 0:x.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 Wz=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],RUt=({commentId:t,reactions:s,currentUserId:r})=>{var u,p;const n=Jt(),[a,o]=S.useState(!1),l=s.find(x=>x.user_id===r),i=It({mutationFn:async x=>{l?l.reaction_type===x?await G.from("community_comment_reactions").delete().eq("id",l.id):await G.from("community_comment_reactions").update({reaction_type:x}).eq("id",l.id):await G.from("community_comment_reactions").insert({comment_id:t,user_id:r,reaction_type:x})},onSuccess:()=>{n.invalidateQueries({queryKey:["community-posts"]}),o(!1)}}),d={};return s.forEach(x=>{d[x.reaction_type]=(d[x.reaction_type]||0)+1}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.length>0&&e.jsx(ttt,{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(x=>{var y;return e.jsx("span",{className:"text-sm",children:(y=Wz.find(_=>_.type===x))==null?void 0:y.emoji},x)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs(xo,{open:a,onOpenChange:o,children:[e.jsx(go,{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=Wz.find(x=>x.type===l.reaction_type))==null?void 0:u.emoji," ",(p=Wz.find(x=>x.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(lo,{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:Wz.map(x=>e.jsx("button",{onClick:()=>i.mutate(x.type),className:"text-xl hover:scale-125 transition-transform p-1",title:x.label,children:x.emoji},x.type))})})]})]})};function l4e({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(ha,{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:x=>x.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 x=new URL(d);p=x.hostname+(x.pathname!=="/"?x.pathname.slice(0,20)+(x.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:x=>x.stopPropagation(),children:p},`url-${l++}`)),u&&n.push(u)}a=o.index+o[0].length}return ae.jsx(S.Fragment,{children:i},d))})}function uce({value:t,onChange:s,placeholder:r="What's on your mind? Use @ to mention someone",className:n,minHeight:a="80px",onMentionsChange:o,onTemplatesChange:l,onKeyDown:i,mentionFormat:d="encoded",enableTemplateMentions:u=!1}){const p=S.useRef(null),x=S.useRef(null),[y,_]=S.useState(!1),[b,N]=S.useState("user"),[w,k]=S.useState(""),[C,E]=S.useState(null),[L,I]=S.useState(0),[O,V]=S.useState({top:0,left:0,width:0}),q=S.useRef(new Map),$=S.useRef(new Map),U=we=>{if(d==="plain"){const Me=[];return q.current.forEach((Le,Ne)=>{we.includes(`@${Ne}`)&&Me.push(Le)}),[...new Set(Me)]}const je=/@\[([^\]]+)\]\(([^)]+)\)/g,Ue=[];let Te;for(;(Te=je.exec(we))!==null;)Ue.push(Te[2]);return[...new Set(Ue)]},se=we=>{if(d==="plain"){const Me=[];return $.current.forEach((Le,Ne)=>{we.includes(`#${Ne}`)&&Me.push(Le)}),[...new Set(Me)]}const je=/#\[([^\]]+)\]\(([^)]+)\)/g,Ue=[];let Te;for(;(Te=je.exec(we))!==null;)Ue.push(Te[2]);return[...new Set(Ue)]};S.useEffect(()=>{if(o){const we=U(t);o(we)}if(l){const we=se(t);l(we)}},[t,o,l,d]);const{data:Y=[],isLoading:J}=gt({queryKey:["mention-users",w],queryFn:async()=>{const we=G.from("profiles").select("id, name").limit(8),je=w.length>=1?we.ilike("name",`%${w}%`):we.order("name"),{data:Ue,error:Te}=await je;if(Te)throw Te;const Me=Ue.map(Le=>Le.id),Fe=await HZe(Me);return Ue.map(Le=>({id:Le.id,name:Le.name||"Unknown",avatar_url:Fe.get(Le.id)}))},enabled:y&&b==="user",staleTime:3e4}),{data:X=[],isLoading:ce}=gt({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:je,error:Ue}=await we;if(Ue)throw Ue;return je||[]},enabled:y&&b==="template"&&u,staleTime:3e4}),ie=b==="user"?J:ce,ae=b==="user"?Y:X,oe=we=>we.split(" ").map(je=>je[0]).join("").toUpperCase().slice(0,2),pe=we=>{const je=we.target.value,Ue=we.target.selectionStart;s(je);const Te=je.substring(0,Ue),Me=Te.lastIndexOf("@"),Fe=u?Te.lastIndexOf("#"):-1;let Le=-1,Ne="user";if(Me>Fe?(Le=Me,Ne="user"):Fe>Me&&u&&(Le=Fe,Ne="template"),Le!==-1){const qe=Te.substring(Le+1),ze=qe.includes(" "),ve=qe.includes(` `);if(!ze&&!ve&&qe.length<=30){E(Le),k(qe),N(Ne),_(!0),I(0);return}}_(!1),E(null)},_e=we=>{if(C===null)return;const je=t.substring(0,C),Ue=t.substring(C+w.length+1),Te=b==="user"?"@":"#",Me=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 Fe=je+Me+Ue;s(Fe),_(!1),E(null),k(""),setTimeout(()=>{if(p.current){const Le=je.length+Me.length;p.current.focus(),p.current.setSelectionRange(Le,Le)}},0)},he=we=>{if(!(!y||ae.length===0))switch(we.key){case"ArrowDown":we.preventDefault(),I(je=>(je+1)%ae.length);break;case"ArrowUp":we.preventDefault(),I(je=>(je-1+ae.length)%ae.length);break;case"Enter":ae[L]&&(we.preventDefault(),_e(ae[L]));break;case"Escape":we.preventDefault(),_(!1);break;case"Tab":ae[L]&&(we.preventDefault(),_e(ae[L]));break}};return S.useEffect(()=>{const we=je=>{x.current&&!x.current.contains(je.target)&&p.current&&!p.current.contains(je.target)&&_(!1)};return document.addEventListener("mousedown",we),()=>document.removeEventListener("mousedown",we)},[]),S.useEffect(()=>{if(!y)return;const we=()=>{const je=p.current;if(!je)return;const Ue=je.getBoundingClientRect();V({top:Ue.bottom+4,left:Ue.left,width:Ue.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(vr,{ref:p,value:t,onChange:pe,onKeyDown:we=>{he(we),we.defaultPrevented||i==null||i(we)},placeholder:r,className:Rt("resize-none",n),style:{minHeight:a}}),y&&ip.createPortal(e.jsxs("div",{ref:x,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"}),ie?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):ae.length===0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:w.length<1?`Type to search ${b==="user"?"people":"templates"}...`:`No ${b==="user"?"users":"templates"} found`}):e.jsx("ul",{className:"py-1 max-h-[180px] overflow-y-auto",children:ae.map((we,je)=>e.jsx("li",{className:Rt("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",je===L?"bg-accent":"hover:bg-accent/50"),onClick:()=>_e(we),onMouseEnter:()=>I(je),children:b==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(vn,{className:"h-6 w-6",children:[e.jsx(Ta,{src:we.avatar_url}),e.jsx(_n,{className:"text-xs",children:oe(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(Dl,{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 OUt(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const Y8e=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function stt({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=Jt(),[d,u]=S.useState(!1),[p,x]=S.useState(""),[y,_]=S.useState([]),b=It({mutationFn:async({content:C,parentCommentId:E})=>{const{data:L,error:I}=await G.from("community_comments").insert({post_id:s,user_id:r,content:C,parent_comment_id:E}).select("id").single();if(I)throw I;const O=y;if(O.length>0&&L){const V=O.filter(q=>q!==r).map(q=>({comment_id:L.id,mentioned_user_id:q,mentioned_by_user_id:r}));V.length>0&&await G.from("community_comment_mentions").insert(V)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),x(""),_([]),u(!1)}}),N=It({mutationFn:async C=>{const{error:E}=await G.from("community_comments").delete().eq("id",C);if(E)throw E},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(Ta,{src:t.user_avatar||void 0}),e.jsx(_n,{className:"text-xs",children:Y8e(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(l4e,{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:gl(new Date(t.created_at),{addSuffix:!0})}),e.jsx(RUt,{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(TL,{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(Ta,{src:n||void 0}),e.jsx(_n,{className:"text-xs",children:Y8e((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(uce,{placeholder:`Reply to ${t.user_name}...`,value:p,onChange:x,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(An,{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(stt,{comment:C,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},C.id))})]})}const Kz=[{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"}],FUt=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=Fs(),{avatarUrl:a}=VZe(t==null?void 0:t.id),{onlineUsers:o}=GYe(),{toast:l}=wa(),i=Jt(),d=S.useRef(null),[u,p]=S.useState("all"),[x,y]=S.useState(""),[_,b]=S.useState(""),[N,w]=S.useState(""),[k,C]=S.useState([]),[E,L]=S.useState([]),[I,O]=S.useState(""),[V,q]=S.useState(!1),[$,U]=S.useState(null),[se,Y]=S.useState(""),[J,X]=S.useState(new Set),[ce,ie]=S.useState({}),[ae,oe]=S.useState({}),[pe,_e]=S.useState([]),[he,we]=S.useState([]),[je,Ue]=S.useState({open:!1,images:[],index:0});S.useEffect(()=>{if(u.startsWith("group:")){const Ze=u.replace("group:","");w(Ze),b("")}else u!=="all"?(b(u),w("")):(b(""),w(""))},[u]);const{data:Te=[]}=gt({queryKey:["community-categories"],queryFn:async()=>{const{data:Ze,error:Et}=await G.from("community_categories").select("*").order("sort_order");if(Et)throw Et;return Ze}}),{data:Me=[]}=gt({queryKey:["community-private-groups"],queryFn:async()=>{const{data:Ze,error:Et}=await G.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(Et)throw Et;return Ze}}),Fe=20,{data:Le,isLoading:Ne,hasNextPage:qe,fetchNextPage:ze,isFetchingNextPage:ve}=jvt({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:Ze})=>{var Oe;const Et=Ze*Fe,$t=Et+Fe;let Yt=G.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(Et,$t);if(u.startsWith("group:")){const Xe=u.replace("group:","");Yt=Yt.eq("private_group_id",Xe)}else u==="all"||(Yt=Yt.eq("category_id",u).is("private_group_id",null));const{data:Ps,error:zs}=await Yt;if(zs)throw zs;const Zs=((Ps==null?void 0:Ps.length)||0)>Fe,Dr=(Ps||[]).slice(0,Fe);if(Dr.length===0)return{posts:[],hasMore:!1,nextPage:Ze+1};const zt=Dr.map(Xe=>Xe.id),$s=[...new Set(Dr.filter(Xe=>Xe.category_id).map(Xe=>Xe.category_id))].filter(Boolean),[kr,Xs,ir,Or,Vn]=await Promise.all([$s.length?G.from("community_categories").select("*").in("id",$s):Promise.resolve({data:[]}),G.from("community_post_media").select("*").in("post_id",zt).order("sort_order"),G.from("community_reactions").select("*").in("post_id",zt),G.from("community_comments").select("*").in("post_id",zt).order("created_at",{ascending:!0}),G.from("community_post_resources").select("*").in("post_id",zt)]),Qr=kr==null?void 0:kr.data,Gr=Xs==null?void 0:Xs.data,tr=ir==null?void 0:ir.data,cr=Or==null?void 0:Or.data,cn=Vn==null?void 0:Vn.data,rn=(cr||[]).map(Xe=>Xe.id),[jn,ni]=await Promise.all([rn.length?G.from("community_comment_reactions").select("*").in("comment_id",rn):Promise.resolve({data:[]}),(()=>{const Xe=(cn||[]).filter(_t=>_t.resource_type==="template").map(_t=>_t.resource_id);return Xe.length===0?Promise.resolve({data:[]}):G.from("canva_templates").select("id, name, preview_image_url").in("id",Xe)})()]),rs=(jn==null?void 0:jn.data)||[],Bn=(ni==null?void 0:ni.data)||[],mn=new Map(Bn.map(Xe=>[Xe.id,{name:Xe.name,preview_image_url:Xe.preview_image_url}])),Fr=Array.from(new Set([...Dr.map(Xe=>Xe.user_id),...(tr||[]).map(Xe=>Xe.user_id),...(cr||[]).map(Xe=>Xe.user_id),...rs.map(Xe=>Xe.user_id)])),[Kt,jr]=await Promise.all([Fr.length?G.from("profiles").select("id, name").in("id",Fr):Promise.resolve({data:[]}),HZe(Fr)]),zr=new Map(((Oe=Kt==null?void 0:Kt.data)==null?void 0:Oe.map(Xe=>[Xe.id,Xe.name]))||[]),fa=new Map((Qr||[]).map(Xe=>[Xe.id,Xe])),qt=Xe=>{const _t=new Map,bt=[];return Xe.forEach(Mt=>{_t.set(Mt.id,{...Mt,user_name:zr.get(Mt.user_id)||"Unknown User",user_avatar:jr.get(Mt.user_id),reactions:rs.filter(Ht=>Ht.comment_id===Mt.id).map(Ht=>({...Ht,user_name:zr.get(Ht.user_id)||"Unknown User",user_avatar:jr.get(Ht.user_id)})),replies:[]})}),Xe.forEach(Mt=>{const Ht=_t.get(Mt.id);if(Mt.parent_comment_id&&_t.has(Mt.parent_comment_id)){const Vt=_t.get(Mt.parent_comment_id);Vt.replies=Vt.replies||[],Vt.replies.push(Ht)}else bt.push(Ht)}),bt};return{posts:Dr.map(Xe=>{const _t=(cn||[]).filter(bt=>bt.post_id===Xe.id).map(bt=>{let Mt="",Ht=null;if(bt.resource_type==="template"){const Vt=mn.get(bt.resource_id);Mt=(Vt==null?void 0:Vt.name)||"Unknown Template",Ht=(Vt==null?void 0:Vt.preview_image_url)||null}return{id:bt.id,resource_type:bt.resource_type,resource_id:bt.resource_id,resource_name:Mt,resource_preview_url:Ht}});return{...Xe,user_name:zr.get(Xe.user_id)||"Unknown User",user_avatar:jr.get(Xe.user_id),category:Xe.category_id?fa.get(Xe.category_id):null,media:(Gr||[]).filter(bt=>bt.post_id===Xe.id),reactions:((tr||[]).filter(bt=>bt.post_id===Xe.id)||[]).map(bt=>({...bt,user_name:zr.get(bt.user_id)||"Unknown User",user_avatar:jr.get(bt.user_id)})),comments:qt((cr||[]).filter(bt=>bt.post_id===Xe.id)),resources:_t}}),hasMore:Zs,nextPage:Ze+1}},getNextPageParam:Ze=>Ze.hasMore?Ze.nextPage:void 0}),dt=S.useMemo(()=>(Le==null?void 0:Le.pages.flatMap(Ze=>Ze.posts))??[],[Le]),fe=It({mutationFn:async()=>{q(!0);const{data:Ze,error:Et}=await G.from("community_posts").insert({user_id:t.id,category_id:N?null:_||null,private_group_id:N||null,content:x,link_url:I||null}).select().single();if(Et)throw Et;for(let Yt=0;Yt0){const Yt=pe.filter(Ps=>Ps!==t.id).map(Ps=>({post_id:Ze.id,mentioned_user_id:Ps,mentioned_by_user_id:t.id}));Yt.length>0&&await G.from("community_post_mentions").insert(Yt)}const $t=OUt(x);if($t.length>0){const Yt=$t.map(Ps=>({post_id:Ze.id,resource_type:"template",resource_id:Ps}));await G.from("community_post_resources").insert(Yt)}return Ze},onSuccess:async Ze=>{var Et;i.invalidateQueries({queryKey:["community-posts"]}),y(""),_e([]),we([]),b(""),w(""),C([]),L([]),O(""),l({title:"Post created!"});try{const $t=((Et=t==null?void 0:t.user_metadata)==null?void 0:Et.name)||"Someone",Yt=x.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),Ps=Yt.length>50?Yt.substring(0,50)+"...":Yt;await G.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${$t}: ${Ps}`,url:"/community"}})}catch($t){console.error("Failed to send push notification:",$t)}},onError:Ze=>{l({title:"Error creating post",description:Ze.message,variant:"destructive"})},onSettled:()=>q(!1)}),Ve=It({mutationFn:async({postId:Ze,content:Et})=>{const{error:$t}=await G.from("community_posts").update({content:Et}).eq("id",Ze);if($t)throw $t},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),U(null),Y(""),l({title:"Post updated!"})}}),Je=It({mutationFn:async Ze=>{const{error:Et}=await G.from("community_posts").delete().eq("id",Ze);if(Et)throw Et},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),at=It({mutationFn:async({postId:Ze,isPinned:Et})=>{const{error:$t}=await G.from("community_posts").update({is_pinned:!Et,pinned_at:Et?null:new Date().toISOString(),pinned_by:Et?null:t==null?void 0:t.id}).eq("id",Ze);if($t)throw $t},onSuccess:(Ze,{isPinned:Et})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:Et?"Post unpinned":"Post pinned to top"})}}),Ae=It({mutationFn:async({postId:Ze,reactionType:Et})=>{var Yt;const $t=(Yt=dt.find(Ps=>Ps.id===Ze))==null?void 0:Yt.reactions.find(Ps=>Ps.user_id===(t==null?void 0:t.id));$t?$t.reaction_type===Et?await G.from("community_reactions").delete().eq("id",$t.id):await G.from("community_reactions").update({reaction_type:Et}).eq("id",$t.id):await G.from("community_reactions").insert({post_id:Ze,user_id:t.id,reaction_type:Et})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),Ye=It({mutationFn:async({postId:Ze,content:Et})=>{const{data:$t,error:Yt}=await G.from("community_comments").insert({post_id:Ze,user_id:t.id,content:Et}).select("id").single();if(Yt)throw Yt;const Ps=ae[Ze]||[];if(Ps.length>0&&$t){const zs=Ps.filter(Zs=>Zs!==t.id).map(Zs=>({comment_id:$t.id,mentioned_user_id:Zs,mentioned_by_user_id:t.id}));zs.length>0&&await G.from("community_comment_mentions").insert(zs)}},onSuccess:(Ze,{postId:Et})=>{i.invalidateQueries({queryKey:["community-posts"]}),ie($t=>({...$t,[Et]:""})),oe($t=>({...$t,[Et]:[]}))}});It({mutationFn:async Ze=>{const{error:Et}=await G.from("community_comments").delete().eq("id",Ze);if(Et)throw Et},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const We=Ze=>{const Et=Array.from(Ze.target.files||[]);if(Et.length+k.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}C($t=>[...$t,...Et]),Et.forEach($t=>{const Yt=new FileReader;Yt.onloadend=()=>{L(Ps=>[...Ps,Yt.result])},Yt.readAsDataURL($t)})},ot=Ze=>{C(Et=>Et.filter(($t,Yt)=>Yt!==Ze)),L(Et=>Et.filter(($t,Yt)=>Yt!==Ze))},Ge=Ze=>Ze.split(" ").map(Et=>Et[0]).join("").toUpperCase().slice(0,2),et=Ze=>{const Et={};return Ze.forEach($t=>{Et[$t.reaction_type]=(Et[$t.reaction_type]||0)+1}),Et},ht=Ze=>{var Et;return(Et=Ze.find($t=>$t.user_id===(t==null?void 0:t.id)))==null?void 0:Et.reaction_type},xt=Ze=>Ze.reduce((Et,$t)=>Et+1+($t.replies?xt($t.replies):0),0),Ke=Ze=>{if(n)return!0;if(!s||!Ze.private_group_id)return!1;const Et=Me.find($t=>$t.id===Ze.private_group_id);return Et!=null&&Et.brokerage_id?r.some($t=>$t.id===Et.brokerage_id):!1};return e.jsx(Es,{title:"Community",children:e.jsxs("div",{className:"flex gap-6 w-full isolate z-0",children:[e.jsx(_Ut,{categories:Te,privateGroups:Me,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsxs("div",{className:"flex-1 min-w-0 max-w-2xl mx-auto lg:mx-0 space-y-6",children:[e.jsxs("div",{className:"px-1",children:[e.jsx("h1",{className:"text-4xl lg:text-5xl font-bold text-foreground",children:"Community"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Connect and share with fellow agents"})]}),e.jsx(bUt,{categories:Te,privateGroups:Me,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsx(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(vn,{className:"h-10 w-10",children:[e.jsx(Ta,{src:a||void 0}),e.jsx(_n,{children:t!=null&&t.email?Ge(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(uce,{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:x,onChange:y,onMentionsChange:_e,onTemplatesChange:we,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),E.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:E.map((Ze,Et)=>{var $t;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[($t=k[Et])!=null&&$t.type.startsWith("video/")?e.jsx("video",{src:Ze,className:"w-full h-full object-cover"}):e.jsx("img",{src:Ze,alt:"",className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>ot(Et),children:e.jsx(Sr,{className:"h-3 w-3"})})]},Et)})}),I&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(De,{value:I,onChange:Ze=>O(Ze.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:We,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var Ze;return(Ze=d.current)==null?void 0:Ze.click()},children:[e.jsx(Wo,{className:"h-4 w-4 mr-1"}),"Photo"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var Ze;return(Ze=d.current)==null?void 0:Ze.click()},children:[e.jsx(Tn,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>O("https://"),children:[e.jsx(fo,{className:"h-4 w-4 mr-1"}),"Link"]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end",children:[Me.length>0?e.jsxs(Bs,{value:N||_||"none",onValueChange:Ze=>{Ze==="none"?(b(""),w("")):Ze.startsWith("group:")?(w(Ze.replace("group:","")),b("")):(b(Ze),w(""))},children:[e.jsx(Rs,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(qs,{placeholder:"Select..."})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"No category"}),Te.map(Ze=>e.jsxs(vt,{value:Ze.id,children:[Ze.icon," ",Ze.name]},Ze.id)),Me.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-muted-foreground border-t mt-1 pt-1",children:"🔒 Private Groups"}),Me.map(Ze=>e.jsxs(vt,{value:`group:${Ze.id}`,children:[Ze.icon||"🔒"," ",Ze.name]},Ze.id))]})]})]}):e.jsxs(Bs,{value:_,onValueChange:b,children:[e.jsx(Rs,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx(qs,{placeholder:"Category"})}),e.jsx(Os,{children:Te.map(Ze=>e.jsxs(vt,{value:Ze.id,children:[Ze.icon," ",Ze.name]},Ze.id))})]}),e.jsxs(K,{size:"sm",onClick:()=>fe.mutate(),disabled:!x.trim()||V,children:[e.jsx(An,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),Ne?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((Ze,Et)=>e.jsx(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Ns,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Ns,{className:"h-4 w-32"}),e.jsx(Ns,{className:"h-4 w-full"}),e.jsx(Ns,{className:"h-4 w-3/4"})]})]})})},Et))}):dt.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(vc,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No posts yet"}),e.jsx("p",{className:"text-muted-foreground",children:"Be the first to start a conversation!"})]})}):e.jsxs("div",{className:"space-y-4",children:[dt.map(Ze=>{var Et,$t,Yt,Ps;return e.jsx(Pe,{children:e.jsxs(Re,{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(Ta,{src:Ze.user_avatar||void 0}),e.jsx(_n,{children:Ge(Ze.user_name||"U")})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold break-words",children:Ze.user_name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:gl(new Date(Ze.created_at),{addSuffix:!0})}),Ze.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:[Ze.category.icon," ",Ze.category.name]})]})]})]})]}),(Ze.user_id===(t==null?void 0:t.id)||Ke(Ze))&&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(ix,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",children:[Ke(Ze)&&Ze.private_group_id&&e.jsx(va,{onClick:()=>at.mutate({postId:Ze.id,isPinned:Ze.is_pinned}),children:Ze.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(NL,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):e.jsxs(e.Fragment,{children:[e.jsx(Cb,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),Ze.user_id===(t==null?void 0:t.id)&&e.jsxs(va,{onClick:()=>{U(Ze),Y(Ze.content)},children:[e.jsx(ga,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(va,{className:"text-destructive",onClick:()=>Je.mutate(Ze.id),children:[e.jsx(gr,{className:"h-4 w-4 mr-2"}),Ze.user_id!==(t==null?void 0:t.id)?"Remove (Moderate)":"Delete"]})]})]})]}),Ze.is_pinned&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-primary",children:[e.jsx(Cb,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Pinned"})]}),e.jsx("div",{className:"mb-3",children:e.jsx(l4e,{content:Ze.content})}),Ze.media.length>0&&e.jsx("div",{className:`grid gap-2 mb-3 ${Ze.media.length===1?"grid-cols-1":Ze.media.length===2?"grid-cols-2":Ze.media.length===3?"grid-cols-3":"grid-cols-2"}`,children:Ze.media.slice(0,4).map((zs,Zs)=>{const Dr=Zs===3&&Ze.media.length>4,zt=Ze.media.length-4;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden bg-muted cursor-pointer group ${Ze.media.length===1?"max-h-[500px]":Ze.media.length===2?"aspect-[4/3]":"aspect-square"}`,onClick:()=>Ue({open:!0,images:Ze.media.map($s=>({url:$s.media_url,type:$s.media_type==="video"?"video":"image"})),index:Zs}),children:[zs.media_type==="video"?e.jsx("video",{src:zs.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:zs.media_url,alt:"",className:"w-full h-full object-cover transition-transform group-hover:scale-105"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors flex items-center justify-center",children:e.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-white",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})})})}),Dr&&e.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:e.jsxs("span",{className:"text-white text-2xl font-bold",children:["+",zt]})})]},zs.id)})}),Ze.link_url&&e.jsxs("a",{href:Ze.link_url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg border hover:bg-muted transition-colors mb-3 overflow-hidden",children:[Ze.link_image&&e.jsx("div",{className:"aspect-video bg-muted",children:e.jsx("img",{src:Ze.link_image,alt:Ze.link_title||"Link preview",className:"w-full h-full object-cover",onError:zs=>{zs.currentTarget.style.display="none"}})}),e.jsx("div",{className:"p-3",children:Ze.link_title?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-foreground line-clamp-2",children:Ze.link_title}),Ze.link_description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:Ze.link_description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 truncate",children:new URL(Ze.link_url).hostname})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary",children:[e.jsx(fo,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:Ze.link_url})]})})]}),Ze.reactions.length>0&&e.jsx(ttt,{reactions:Ze.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(et(Ze.reactions)).slice(0,3).map(([zs])=>{var Zs;return e.jsx("span",{className:"text-base",children:(Zs=Kz.find(Dr=>Dr.type===zs))==null?void 0:Zs.emoji},zs)})}),e.jsx("span",{children:Ze.reactions.length})]})}),e.jsxs("div",{className:"flex items-center gap-1 border-t border-b py-1 my-2",children:[e.jsxs(xo,{children:[e.jsx(go,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",children:[ht(Ze.reactions)?e.jsx("span",{className:"mr-1",children:(Et=Kz.find(zs=>zs.type===ht(Ze.reactions)))==null?void 0:Et.emoji}):e.jsx(Fu,{className:"h-4 w-4 mr-1"}),ht(Ze.reactions)?($t=Kz.find(zs=>zs.type===ht(Ze.reactions)))==null?void 0:$t.label:"Like"]})}),e.jsx(lo,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:Kz.map(zs=>e.jsx("button",{onClick:()=>Ae.mutate({postId:Ze.id,reactionType:zs.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:zs.label,children:zs.emoji},zs.type))})})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>X(zs=>{const Zs=new Set(zs);return Zs.has(Ze.id)?Zs.delete(Ze.id):Zs.add(Ze.id),Zs}),children:[e.jsx(vc,{className:"h-4 w-4 mr-1"}),(()=>{const zs=xt(Ze.comments);return zs>0?`Comment (${zs})`:"Comment"})()]})]}),J.has(Ze.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[Ze.comments.map(zs=>e.jsx(stt,{comment:zs,postId:Ze.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:Ke(Ze)},zs.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ta,{src:a||void 0}),e.jsx(_n,{className:"text-xs",children:Ge(((Yt=t.email)==null?void 0:Yt.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(uce,{placeholder:"Write a comment... (use @ to mention)",value:ce[Ze.id]||"",onChange:zs=>ie(Zs=>({...Zs,[Ze.id]:zs})),onMentionsChange:zs=>oe(Zs=>({...Zs,[Ze.id]:zs})),mentionFormat:"plain",onKeyDown:zs=>{var Zs;zs.defaultPrevented||zs.key==="Enter"&&!zs.shiftKey&&((Zs=ce[Ze.id])!=null&&Zs.trim())&&(zs.preventDefault(),Ye.mutate({postId:Ze.id,content:ce[Ze.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{var zs;(zs=ce[Ze.id])!=null&&zs.trim()&&Ye.mutate({postId:Ze.id,content:ce[Ze.id]})},disabled:!((Ps=ce[Ze.id])!=null&&Ps.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(An,{className:"h-4 w-4"})})]})]})]})]})},Ze.id)}),qe&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(K,{variant:"outline",onClick:()=>ze(),disabled:ve,children:ve?"Loading…":"Load more posts"})})]}),e.jsx(fs,{open:!!$,onOpenChange:()=>U(null),children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsx(bs,{children:"Edit Post"})}),e.jsx(vr,{value:se,onChange:Ze=>Y(Ze.target.value),className:"min-h-[120px]"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>U(null),children:"Cancel"}),e.jsx(K,{onClick:()=>{$&&Ve.mutate({postId:$.id,content:se})},disabled:!se.trim(),children:"Save Changes"})]})]})}),e.jsx(DUt,{images:je.images,initialIndex:je.index,open:je.open,onOpenChange:Ze=>Ue(Et=>({...Et,open:Ze}))})]})]})})},y5={open:{label:"Open",icon:ln,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:vc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:ti,color:"bg-green-500"},closed:{label:"Closed",icon:Zl,color:"bg-muted-foreground"}},X8e={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function zUt(){const{user:t}=Fs(),s=Jt(),[r,n]=S.useState(null),[a,o]=S.useState(""),{data:l=[],isLoading:i}=gt({queryKey:["support-tickets"],queryFn:async()=>{const{data:x,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 x},enabled:!!t}),{data:d=[]}=gt({queryKey:["ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:x,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 x},enabled:!!r}),u=It({mutationFn:async x=>{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:x,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 x=y5[r.status].icon;return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Fa,{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(Qe,{variant:"secondary",children:X8e[r.category]}),e.jsxs(Qe,{className:y5[r.status].color,children:[e.jsx(x,{className:"h-3 w-3 mr-1"}),y5[r.status].label]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(hr,{children:["Created on ",ps(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Re,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"Conversation"})}),e.jsxs(Re,{children:[e.jsx(ui,{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:ps(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(wo,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(vr,{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(An,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{className:"bg-gradient-to-br from-primary/10 via-primary/5 to-background border-primary/20",children:e.jsx(Re,{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(e_e,{trigger:e.jsxs(K,{size:"lg",className:"gap-2",children:[e.jsx(Us,{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(Pn,{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(e_e,{trigger:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(Us,{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(Pe,{className:"border-dashed",children:e.jsxs(Re,{className:"text-center py-12",children:[e.jsx(vc,{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(x=>{const y=y5[x.status].icon;return e.jsx(Pe,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(x),children:e.jsx(Re,{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:x.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Qe,{variant:"outline",className:"text-xs",children:X8e[x.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ps(new Date(x.created_at),"MMM d, yyyy")})]})]}),e.jsxs(Qe,{className:y5[x.status].color,children:[e.jsx(y,{className:"h-3 w-3 mr-1"}),y5[x.status].label]})]})})},x.id)})})]})})}function BUt({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(on,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(bs,{children:"Schedule Agent Onboarding"}),e.jsx(Ir,{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 $Ut({open:t,onOpenChange:s}){const{brokerageId:r}=Fs(),[n,a]=S.useState(""),[o,l]=S.useState([]),[i,d]=S.useState(!1),{data:u,isLoading:p}=gt({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}),x=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(k=>k!==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(An,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(bs,{children:"Send Onboarding Link"}),e.jsx(Ir,{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(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{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(_s,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):(x==null?void 0:x.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(lr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(ui,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:x==null?void 0:x.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(Ki,{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(En,{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(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(An,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function qUt(){const[t,s]=S.useState(!1),[r,n]=S.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{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(lr,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{children:"Agent Onboarding"}),e.jsx(hr,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx(Re,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Schedule Agent Onboarding"]}),e.jsxs(K,{variant:"outline",onClick:()=>n(!0),className:"flex items-center gap-2",children:[e.jsx(An,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(BUt,{open:t,onOpenChange:s}),e.jsx($Ut,{open:r,onOpenChange:n})]})}function UUt({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(Qy,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(bs,{children:"Schedule Launch Meeting"}),e.jsx(Ir,{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 VUt(){const[t,s]=S.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{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(Qy,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{children:"Launch or ReLaunch Meeting"}),e.jsx(hr,{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(Re,{children:e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(Qy,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(UUt,{open:t,onOpenChange:s})]})}function HUt(){const t=_r(),[s,r]=S.useState(""),[n,a]=S.useState(null),{data:o,isLoading:l}=gt({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}=gt({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}=gt({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}=gt({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}=gt({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}}),x=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())),k=!n||N.category_id===n;return w&&k}),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(E=>E.resource_id===N).length)||0,k=(u==null?void 0:u.filter(E=>E.resource_id===N).length)||0,C=(p==null?void 0:p.filter(E=>E.resource_id===N).length)||0;return{pdfCount:w,videoCount:k,linkCount:C}},b=N=>{t(`/brokerage-resources/${N}`)};return e.jsx(Es,{title:"Brokerage Resources",description:"Access exclusive resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(qUt,{}),e.jsx(VUt,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{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(Qe,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),y.map(N=>e.jsx(Qe,{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:[(x==null?void 0:x.length)||0," resource",(x==null?void 0:x.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(Pe,{children:[e.jsx(Ns,{className:"h-40 w-full"}),e.jsx(Lt,{children:e.jsx(Ns,{className:"h-5 w-3/4"})}),e.jsxs(Re,{children:[e.jsx(Ns,{className:"h-4 w-full mb-2"}),e.jsx(Ns,{className:"h-4 w-2/3"})]})]},w))}):(x==null?void 0:x.length)===0?e.jsxs(Pe,{className:"p-12 text-center",children:[e.jsx(Ih,{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:x==null?void 0:x.map(N=>{const{pdfCount:w,videoCount:k,linkCount:C}=_(N.id),E=i==null?void 0:i.find(L=>L.id===N.category_id);return e.jsxs(Pe,{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(Ih,{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(Ot,{className:"text-lg line-clamp-1",children:N.title}),E&&e.jsx(Qe,{variant:"secondary",className:"shrink-0 text-xs",children:E.name})]})}),e.jsxs(Re,{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(fn,{className:"h-4 w-4"}),w]}),k>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-4 w-4"}),k]}),C>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(fo,{className:"h-4 w-4"}),C]})]})]})]},N.id)})})]})})}const GUt=()=>{const{resourceId:t}=co(),{data:s,isLoading:r}=gt({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(Es,{title:"Brokerage Resources",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):s?e.jsx(Es,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(ha,{to:"/brokerage-resources",children:[e.jsx(Fa,{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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Tn,{className:"h-4 w-4"}),"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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(fn,{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(fn,{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(Pe,{children:e.jsxs(Re,{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(Es,{title:"Brokerage Resources",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ih,{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(ha,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function WUt(){const{onlineUsers:t,totalOnline:s}=GYe();return e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(lr,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(Qe,{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(Re,{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(ui,{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(Ta,{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 ",gl(new Date(r.onlineSince),{addSuffix:!1})]})]})]},r.id)})})})})]})}const Q8e={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:lr,path:"/admin/members",color:"bg-blue-500/10 text-blue-600"},{title:"Invite Codes",description:"Create and manage signup invite codes",icon:OL,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:yx,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:lL,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:lr,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:Rh,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:al,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:Dl,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:Lh,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:Ig,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:$r,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:$r,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:Qv,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:Ih,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:Ih,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:rr,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:tS,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:Yf,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:rr,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:yM,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:e0,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:Ui,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:Vi,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:lr,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:ki,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:SM,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:kb,path:"/admin/wishlist",color:"bg-yellow-500/10 text-yellow-600"},{title:"Membership Reviews",description:"View member feedback and ratings",icon:Hn,path:"/admin/membership-reviews",color:"bg-amber-500/10 text-amber-600"},{title:"Weekly Digest",description:"Configure automated weekly email digests",icon:rr,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:to,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:Lh,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:Pg,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:Wo,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:rr,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:Nb,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:cL,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:fn,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:fn,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:yc,path:"/admin/mls-fee-tracker",color:"bg-gradient-to-br from-teal-500/20 to-cyan-500/10 text-teal-600"}]}};function J8e(){const t=_r();return console.log("[AdminDashboard] render"),e.jsx(Es,{title:"Admin Dashboard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Admin Dashboard"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage all aspects of your platform"})]}),e.jsx("div",{className:"w-full lg:w-80",children:e.jsx(WUt,{})})]}),e.jsxs(ia,{defaultValue:"users",className:"w-full",children:[e.jsx(ea,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1 overflow-x-auto",children:Object.entries(Q8e).map(([s,r])=>e.jsx(ls,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(Q8e).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(Pe,{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(Ot,{className:"text-base",children:n.title})]}),e.jsx(Re,{className:"pt-0",children:e.jsx(hr,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const In=S.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})}));In.displayName="Table";const Ln=S.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:Rt("[&_tr]:border-b",t),...s}));Ln.displayName="TableHeader";const Dn=S.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:Rt("[&_tr:last-child]:border-0",t),...s}));Dn.displayName="TableBody";const KUt=S.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}));KUt.displayName="TableFooter";const Ms=S.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}));Ms.displayName="TableRow";const Nt=S.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 ut=S.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:Rt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));ut.displayName="TableCell";const ZUt=S.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:Rt("mt-4 text-sm text-muted-foreground",t),...s}));ZUt.displayName="TableCaption";const YUt=()=>{const{isAdmin:t}=Fs(),s=_r(),[r,n]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(!1),[d,u]=S.useState(null);S.useEffect(()=>{if(!t){s("/dashboard");return}p()},[t]);const p=async()=>{try{const{data: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)}},x=async N=>{N.preventDefault();const w=new FormData(N.currentTarget),k={name:w.get("name"),description:w.get("description"),icon:w.get("icon"),app_id:w.get("app_id"),target_url:w.get("target_url"),required_tags:w.get("required_tags").split(",").map(C=>C.trim()).filter(Boolean)};try{if(d){const{error:C}=await G.from("app_tiles").update(k).eq("id",d.id);if(C)throw C;me.success("App updated successfully")}else{const{error:C}=await G.from("app_tiles").insert([k]);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(Fa,{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(pi,{asChild:!0,children:e.jsxs(K,{onClick:b,children:[e.jsx(Us,{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(Ir,{children:"Configure the application tile settings"})]}),e.jsxs("form",{onSubmit:x,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(xe,{htmlFor:"name",children:"App Name"}),e.jsx(De,{id:"name",name:"name",defaultValue:d==null?void 0:d.name,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"app_id",children:"App ID"}),e.jsx(De,{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(xe,{htmlFor:"description",children:"Description"}),e.jsx(vr,{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(xe,{htmlFor:"icon",children:"Icon (emoji)"}),e.jsx(De,{id:"icon",name:"icon",defaultValue:d==null?void 0:d.icon,placeholder:"🚀",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"target_url",children:"Target URL"}),e.jsx(De,{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(xe,{htmlFor:"required_tags",children:"Required Tags (comma-separated)"}),e.jsx(De,{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(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"Application Tiles"}),e.jsx(hr,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx(Re,{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(Us,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:r.map(N=>e.jsxs(Ms,{children:[e.jsx(ut,{className:"text-2xl",children:N.icon}),e.jsx(ut,{className:"font-medium",children:N.name}),e.jsx(ut,{className:"font-mono text-sm",children:N.app_id}),e.jsx(ut,{className:"text-sm text-muted-foreground max-w-xs truncate",children:N.target_url}),e.jsx(ut,{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(ut,{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(ga,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>y(N.id),children:e.jsx(gr,{className:"h-4 w-4"})})]})})]},N.id))})]})})]})})]})};function Uu({title:t,description:s,children:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(ha,{to:"/admin",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(Fa,{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 eDe=({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(Qe,{variant:"destructive",className:Rt("gap-1",s),children:[e.jsx(Qc,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(Qe,{variant:"destructive",className:Rt("gap-1",s),children:[e.jsx(ln,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(Qe,{className:Rt("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(ln,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(Qe,{variant:"secondary",className:Rt("gap-1",s),children:[e.jsx(ln,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},rtt=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=wa(),l=S.useRef(null),[i,d]=S.useState([]),[u,p]=S.useState(""),[x,y]=S.useState(!1),[_,b]=S.useState("upload"),[N,w]=S.useState(null),k=()=>{d([]),p(""),b("upload"),w(null),l.current&&(l.current.value="")},C=()=>{k(),s(!1)},E=q=>{const $=q.split(` `).map(X=>X.trim()).filter(X=>X);if($.length===0)return[];const U=$[0].toLowerCase(),Y=U.includes("first")||U.includes("last")||U.includes("email")||U.includes("name")||U.includes("phone")||U.includes("sms")||U.includes("consent")?$.slice(1):$,J=[];for(const X of Y){const ie=(X.includes(" ")?X.split(" "):X.split(",")).map(ae=>ae.trim().replace(/^["']|["']$/g,""));if(ie.length>=2){let ae="",oe="",pe="",_e="",he;if(ie.length===2){const Ue=ie[0].split(" ");ae=Ue[0]||"",oe=Ue.slice(1).join(" ")||"",pe=ie[1]}else if(ie.length===3)ae=ie[0],oe=ie[1],pe=ie[2];else if(ie.length===4)ae=ie[0],oe=ie[1],pe=ie[2],_e=ie[3];else if(ie.length>=5){ae=ie[0],oe=ie[1],pe=ie[2],_e=ie[3];const Ue=ie[4].toLowerCase();he=Ue==="true"||Ue==="yes"||Ue==="1"||Ue==="y"}const je=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(pe);J.push({firstName:ae.trim(),lastName:oe.trim(),email:pe.trim().toLowerCase(),phone:_e.trim()||void 0,smsConsent:he,isValid:je&&ae.trim().length>0,error:je?ae.trim()?void 0:"Missing name":"Invalid email"})}}return J},L=q=>{var se;const $=(se=q.target.files)==null?void 0:se[0];if(!$)return;const U=new FileReader;U.onload=Y=>{var ce;const J=(ce=Y.target)==null?void 0:ce.result,X=E(J);if(X.length===0){o({title:"No data found",description:"The CSV file appears to be empty or in an unsupported format.",variant:"destructive"});return}d(X),b("preview")},U.readAsText($)},I=async()=>{const q=i.filter(U=>U.isValid);if(q.length===0){o({title:"No valid users",description:"There are no valid users to import.",variant:"destructive"});return}const $=n||u||null;y(!0);try{const{data:{session:U}}=await G.auth.getSession(),se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/bulk-create-users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U==null?void 0:U.access_token}`},body:JSON.stringify({users:q.map(J=>({firstName:J.firstName,lastName:J.lastName,email:J.email,phone:J.phone,smsConsent:J.smsConsent})),brokerageId:$})}),Y=await se.json();if(!se.ok)throw new Error(Y.error||"Failed to import users");w(Y),b("result"),Y.created>0&&a(),o({title:"Import Complete",description:`${Y.created} user(s) created successfully.${Y.failed>0?` ${Y.failed} failed.`:""}`})}catch(U){console.error("Import error:",U),o({title:"Import Failed",description:U.message||"Failed to import users",variant:"destructive"})}finally{y(!1)}},O=i.filter(q=>q.isValid).length,V=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(Kv,{className:"h-5 w-5"}),"Import Agents from CSV"]}),e.jsx(Ir,{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:L,className:"hidden"}),e.jsx($a,{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(xe,{children:"Assign to Brokerage (optional)"}),e.jsxs(Bs,{value:u||"none",onValueChange:q=>p(q==="none"?"":q),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select a brokerage..."})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"No brokerage"}),r.map(q=>e.jsx(vt,{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(Qn,{className:"h-4 w-4 text-green-500"}),e.jsxs("span",{children:[O," valid"]})]}),V>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Lo,{className:"h-4 w-4"}),e.jsxs("span",{children:[V," invalid"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:i.slice(0,100).map((q,$)=>e.jsxs(Ms,{children:[e.jsx(ut,{children:q.firstName}),e.jsx(ut,{children:q.lastName}),e.jsx(ut,{children:q.email}),e.jsx(ut,{className:"text-muted-foreground",children:q.phone||"-"}),e.jsx(ut,{className:"text-muted-foreground",children:q.smsConsent===!0?"✓":q.smsConsent===!1?"✗":"-"}),e.jsx(ut,{children:q.isValid?e.jsx(Qe,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(Qe,{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(Qn,{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(En,{children:[_==="upload"&&e.jsx(K,{variant:"outline",onClick:C,children:"Cancel"}),_==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:k,children:"Back"}),e.jsx(K,{onClick:I,disabled:x||O===0,children:x?e.jsxs(e.Fragment,{children:[e.jsx(_s,{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(du,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Ph,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(td,{className:"h-3.5 w-3.5 shrink-0 opacity-40"})]})})}function QR(t=null,s=null){const[r,n]=S.useState(t),[a,o]=S.useState(s),l=S.useCallback(d=>{r===d?a==="asc"?o("desc"):a==="desc"?(n(null),o(null)):o("asc"):(n(d),o("asc"))},[r,a]),i=S.useCallback((d,u)=>{if(!r||!a||!u[r])return d;const p=u[r];return[...d].sort((x,y)=>{const _=p(x),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 XUt=[{type:"custom",title:"Great job!",message:"Keep up the amazing work!",icon:Hn},{type:"custom",title:"You're on fire!",message:"Your dedication is inspiring!",icon:Vi},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:Bd}];function ntt({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=S.useState("custom"),[l,i]=S.useState(""),[d,u]=S.useState(""),p=Jjt(),x=_=>{o(_.type),i(_.title),u(_.message)},y=async _=>{if(_.preventDefault(),!l.trim()){gn({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}),gn({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{gn({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(Ir,{children:"They'll see confetti and this message next time they log in!"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(xe,{className:"text-sm text-muted-foreground mb-2 block",children:"Quick presets:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:XUt.map((_,b)=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>x(_),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(xe,{htmlFor:"type",children:"Celebration Type"}),e.jsxs(Bs,{value:a,onValueChange:_=>o(_),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"custom",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hn,{className:"h-4 w-4"})," Custom"]})}),e.jsx(vt,{value:"points_earned",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vi,{className:"h-4 w-4"})," Points Earned"]})}),e.jsx(vt,{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(vt,{value:"deal_closed",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yc,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{id:"title",value:l,onChange:_=>i(_.target.value),placeholder:"e.g., Congratulations!",maxLength:100})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"message",children:"Message (optional)"}),e.jsx(vr,{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 jye={points_earned:{label:"Points Earned",icon:Vi,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:Mn,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:yc,color:"bg-green-500"},custom:{label:"Custom",icon:$r,color:"bg-purple-500"}};function QUt(){const[t,s]=S.useState(""),[r,n]=S.useState("all"),[a,o]=S.useState("all"),{data:l=[],isLoading:i}=gt({queryKey:["admin-celebrations"],queryFn:async()=>{const{data:p,error:x}=await G.from("celebration_queue").select("*").order("created_at",{ascending:!1}).limit(500);if(x)throw x;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,k,C;return{...N,user_name:((w=b.get(N.user_id))==null?void 0:w.name)||"Unknown",user_email:((k=b.get(N.user_id))==null?void 0:k.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 x=((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 x&&y&&_}),u={total:l.length,seen:l.filter(p=>p.seen_at).length,unseen:l.filter(p=>!p.seen_at).length,byType:Object.keys(jye).reduce((p,x)=>(p[x]=l.filter(y=>y.celebration_type===x).length,p),{})};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(_s,{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(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:u.total})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:u.seen})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:u.unseen})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:u.byType.custom||0})})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Bd,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(hr,{children:"View all celebrations awarded to agents"})]}),e.jsxs(Re,{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(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by agent name, email, or title...",value:t,onChange:p=>s(p.target.value),className:"pl-9"})]}),e.jsxs(Bs,{value:r,onValueChange:n,children:[e.jsx(Rs,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"Filter by type"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Types"}),Object.entries(jye).map(([p,x])=>e.jsx(vt,{value:p,children:x.label},p))]})]}),e.jsxs(Bs,{value:a,onValueChange:o,children:[e.jsx(Rs,{className:"w-[140px]",children:e.jsx(qs,{placeholder:"Status"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Status"}),e.jsx(vt,{value:"seen",children:"Seen"}),e.jsx(vt,{value:"unseen",children:"Pending"})]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:d.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):d.map(p=>{const x=jye[p.celebration_type],y=x.icon;return e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(y,{className:"h-3 w-3"}),x.label]})}),e.jsx(ut,{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(ut,{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(ut,{children:p.points_amount?e.jsxs(Qe,{variant:"secondary",children:["+",p.points_amount]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ut,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:p.creator_name})}),e.jsx(ut,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ps(new Date(p.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(ut,{children:p.seen_at?e.jsx(Qe,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(Qe,{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 JUt=()=>{const{user:t}=Fs(),{toast:s}=wa(),[r,n]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(!1),[d,u]=S.useState("all"),[p,x]=S.useState("all"),[y,_]=S.useState("new"),[b,N]=S.useState(new Set),w=S.useCallback(async()=>{try{o(!0);const{data:J,error:X}=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(X)throw X;const{data:ce,error:ie}=await G.from("trial_email_exports").select("user_id");if(ie)throw ie;const ae=new Set((ce||[]).map(pe=>pe.user_id)),oe=(J||[]).map(pe=>({...pe,converted_from_trial_at:pe.converted_from_trial_at??null,already_exported:ae.has(pe.id)}));oe.sort((pe,_e)=>new Date(_e.created_at).getTime()-new Date(pe.created_at).getTime()),n(oe)}catch(J){console.error("Error loading trial users:",J),s({title:"Error",description:"Failed to load trial users",variant:"destructive"})}finally{o(!1)}},[s]);S.useEffect(()=>{w()},[w]);const k=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,E=J=>J.converted_from_trial_at!==null,L=J=>{if(E(J))return!1;const X=C(J);return X?new Date(X).getTime()<=Date.now():!1},I=r.filter(J=>!(d!=="all"&&k(J)!==d||p==="active"&&(L(J)||E(J))||p==="expired"&&!L(J)||p==="converted"&&!E(J)||y==="new"&&J.already_exported||y==="exported"&&!J.already_exported)),O=()=>{b.size===I.length?N(new Set):N(new Set(I.map(J=>J.id)))},V=J=>{const X=new Set(b);X.has(J)?X.delete(J):X.add(J),N(X)},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)),X="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",ce=J.map(he=>{const we=(he.name||"").split(" "),je=we[0]||"",Ue=we.slice(1).join(" ")||"",Te=k(he)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Me=E(he)?"Converted":L(he)?"Expired":"Active",Fe=he.created_at?new Date(he.created_at).toLocaleDateString():"",Le=C(he)?new Date(C(he)).toLocaleDateString():"";return`"${je}","${Ue}","${he.email}","${he.phone||""}","${Te}","${Me}","${Fe}","${Le}"`}),ie=[X,...ce].join(` `),ae=new Blob([ie],{type:"text/csv"}),oe=URL.createObjectURL(ae),pe=document.createElement("a");pe.href=oe,pe.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,pe.click(),URL.revokeObjectURL(oe);const _e=J.filter(he=>!he.already_exported).map(he=>({user_id:he.id,exported_by:t.id}));if(_e.length>0){const{error:he}=await G.from("trial_email_exports").upsert(_e,{onConflict:"user_id"});he&&console.error("Error marking exports:",he)}s({title:"Export complete",description:`Downloaded ${J.length} trial user(s). ${_e.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,U=r.filter(J=>J.already_exported).length,se=r.filter(J=>E(J)).length,Y=r.filter(J=>!L(J)&&!E(J)).length;return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(_s,{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(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(hr,{children:"Total"}),e.jsx(Ot,{className:"text-2xl",children:r.length})]})}),e.jsx(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(hr,{children:"New (Not Exported)"}),e.jsx(Ot,{className:"text-2xl text-green-600",children:$})]})}),e.jsx(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(hr,{children:"Active Trials"}),e.jsx(Ot,{className:"text-2xl",children:Y})]})}),e.jsx(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(hr,{children:"Converted 🎉"}),e.jsx(Ot,{className:"text-2xl text-primary",children:se})]})}),e.jsx(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(hr,{children:"Already Exported"}),e.jsx(Ot,{className:"text-2xl text-muted-foreground",children:U})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(Bs,{value:y,onValueChange:J=>_(J),children:[e.jsx(Rs,{className:"w-[160px]",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Users"}),e.jsx(vt,{value:"new",children:"New Only"}),e.jsx(vt,{value:"exported",children:"Already Exported"})]})]}),e.jsxs(Bs,{value:d,onValueChange:J=>u(J),children:[e.jsx(Rs,{className:"w-[180px]",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Trial Types"}),e.jsx(vt,{value:"stripe",children:"Credit Card Trial"}),e.jsx(vt,{value:"ghl",children:"Free Trial (No CC)"})]})]}),e.jsxs(Bs,{value:p,onValueChange:J=>x(J),children:[e.jsx(Rs,{className:"w-[160px]",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Statuses"}),e.jsx(vt,{value:"active",children:"Active Trial"}),e.jsx(vt,{value:"expired",children:"Expired"}),e.jsx(vt,{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(_s,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(Nt,{className:"w-[40px]",children:e.jsx(Ki,{checked:I.length>0&&b.size===I.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(Dn,{children:I.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):I.map(J=>{const X=k(J),ce=E(J),ie=L(J),ae=C(J);return e.jsxs(Ms,{className:`hover:bg-muted/30 ${ce?"bg-primary/5":""}`,children:[e.jsx(ut,{children:e.jsx(Ki,{checked:b.has(J.id),onCheckedChange:()=>V(J.id)})}),e.jsx(ut,{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(ut,{className:"text-muted-foreground",children:J.email}),e.jsx(ut,{children:X==="stripe"?e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(yx,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(rr,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(ut,{children:ce?e.jsxs(Qe,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(Yo,{className:"h-3 w-3"}),"Converted"]}):ie?e.jsx(Qe,{variant:"destructive",children:"Expired"}):e.jsx(Qe,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),e.jsx(ut,{className:"text-sm",children:J.created_at?new Date(J.created_at).toLocaleDateString():"—"}),e.jsx(ut,{className:"text-sm",children:ce&&ae?e.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(ae).toLocaleDateString()]}):ae?new Date(ae).toLocaleDateString():"—"}),e.jsx(ut,{children:J.already_exported?e.jsx(Qn,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Qe,{variant:"outline",className:"text-green-600 border-green-300",children:"New"})})]},J.id)})})]})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",I.length," of ",r.length," trial users · ",se," converted to paid"]})]})},eVt=()=>{const[t,s]=S.useState([]),[r,n]=S.useState(!0);return S.useEffect(()=>{(async()=>{const{data:o,error:l}=await G.from("user_deletion_log").select("*").order("created_at",{ascending:!1});!l&&o&&s(o),n(!1)})()},[]),r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(_s,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(gr,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{children:"No deletion records yet"})]})}):e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"User Deletion History"})}),e.jsx(Re,{children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:t.map(a=>e.jsxs(Ms,{children:[e.jsx(ut,{className:"whitespace-nowrap text-sm",children:ps(new Date(a.created_at),"MMM d, yyyy h:mm a")}),e.jsx(ut,{className:"font-medium",children:a.deleted_user_name||"—"}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:a.deleted_user_email||"—"}),e.jsx(ut,{children:a.brokerage_name||"—"}),e.jsx(ut,{children:e.jsx(Qe,{variant:a.deletion_type==="deleted"?"destructive":"secondary",children:a.deletion_type==="deleted"?"Account Deleted":"Removed"})}),e.jsx(ut,{className:"text-sm",children:a.deleted_by_name||a.deleted_by_email||"—"})]},a.id))})]})})]})},NC=t=>{const{user:s}=Fs(),r=Jt(),n=gt({queryKey:["teams",t],queryFn:async()=>{let x=G.from("teams").select("*").order("created_at",{ascending:!1});t&&(x=x.eq("brokerage_id",t));const{data:y,error:_}=await x;if(_)throw _;return y||[]},enabled:!!s}),a=x=>gt({queryKey:["team-members",x],queryFn:async()=>{const{data:y,error:_}=await G.from("team_members").select("*").eq("team_id",x).order("role",{ascending:!0});if(_)throw _;const b=(y||[]).map(k=>k.user_id),{data:N}=await G.from("profiles").select("id, name, email, avatar_url").in("id",b),w=new Map((N||[]).map(k=>[k.id,k]));return(y||[]).map(k=>({...k,profile:w.get(k.user_id)||null}))},enabled:!!x}),o=It({mutationFn:async x=>{const y={name:x.name,created_by:s.id,description:x.description,contact_visibility:x.contact_visibility,lead_pond_enabled:x.lead_pond_enabled,shared_assets_enabled:x.shared_assets_enabled};x.brokerage_id&&(y.brokerage_id=x.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:x=>{me.error("Failed to create team: "+x.message)}}),l=It({mutationFn:async({id:x,...y})=>{const{data:_,error:b}=await G.from("teams").update(y).eq("id",x).select().single();if(b)throw b;return _},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),me.success("Team updated")},onError:x=>{me.error("Failed to update team: "+x.message)}}),i=It({mutationFn:async x=>{const{error:y}=await G.from("teams").delete().eq("id",x);if(y)throw y},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),me.success("Team deleted")},onError:x=>{me.error("Failed to delete team: "+x.message)}}),d=It({mutationFn:async x=>{const{data:y,error:_}=await G.from("team_members").insert({team_id:x.team_id,user_id:x.user_id,role:x.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:(x,y)=>{r.invalidateQueries({queryKey:["team-members",y.team_id]}),me.success("Member added to team")},onError:x=>{me.error(x.message)}}),u=It({mutationFn:async x=>{const{error:y}=await G.from("team_members").delete().eq("id",x.member_id);if(y)throw y},onSuccess:(x,y)=>{r.invalidateQueries({queryKey:["team-members",y.team_id]}),me.success("Member removed from team")},onError:x=>{me.error("Failed to remove member: "+x.message)}}),p=It({mutationFn:async x=>{const{error:y}=await G.from("team_members").update({role:x.role}).eq("id",x.member_id);if(y)throw y},onSuccess:(x,y)=>{r.invalidateQueries({queryKey:["team-members",y.team_id]}),me.success("Member role updated")},onError:x=>{me.error("Failed to update role: "+x.message)}});return{teams:n.data||[],isLoading:n.isLoading,createTeam:o,updateTeam:l,deleteTeam:i,addMember:d,removeMember:u,updateMemberRole:p,useTeamMembers:a}},tVt=()=>{const{user:t}=Fs();return gt({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})},att=t=>{const{user:s}=Fs(),r=Jt(),n=gt({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(k=>k.contact_id),p=[...new Set(i.map(k=>k.added_by))],x=i.filter(k=>k.claimed_by).map(k=>k.claimed_by),y=[...new Set([...p,...x])],[_,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(k=>[k.id,k])),w=new Map((b.data||[]).map(k=>[k.id,k]));return i.map(k=>({...k,status:k.claimed_by?"claimed":"available",contact:N.get(k.contact_id)||null,contributor:w.get(k.added_by)||null,claimer:k.claimed_by&&w.get(k.claimed_by)||null}))},enabled:!!t&&!!s}),a=It({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=It({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=It({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}},sVt=()=>{const t=Jt();return It({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 I;const{user:o}=Fs(),{data:l}=Px(),{useTeamMembers:i}=NC(),{data:d=[]}=i((l==null?void 0:l.teamId)||""),u=sVt(),[p,x]=S.useState(null),[y,_]=S.useState(""),[b,N]=S.useState(!1),w=d.filter(O=>O.user_id!==(o==null?void 0:o.id)),k=async()=>{if(p){N(!0);try{for(const O of r)await u.mutateAsync({contactId:O,toUserId:p,notes:y||void 0});s(!1),x(null),_(""),a==null||a()}catch{}finally{N(!1)}}},C=w.find(O=>O.user_id===p),E=r.length>1,L=n.length>0?E?`${n.length} contacts`:n[0]:E?`${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(Hv,{className:"h-5 w-5"}),"Transfer ",L]}),e.jsxs(Ir,{children:["Select a team member to transfer ",E?"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(xe,{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 V,q,$;return e.jsxs("button",{onClick:()=>x(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(Ta,{src:((V=O.profile)==null?void 0:V.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(xe,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),e.jsx(vr,{id:"transfer-notes",value:y,onChange:O=>_(O.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:k,disabled:!p||b,children:[b?e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Hv,{className:"h-4 w-4 mr-2"}),"Transfer",C?` to ${(I=C.profile)==null?void 0:I.name}`:""]})]})]})})}const c4e=()=>{const t=_r(),{data:s,isLoading:r}=tVt(),{data:n}=Px(),[a,o]=S.useState(""),[l,i]=S.useState("all"),[d,u]=S.useState(null),[p,x]=S.useState(""),y=(n==null?void 0:n.role)==="team_leader",_=S.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=S.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(k=>{var C,E,L;return(k.first_name+" "+(k.last_name||"")).toLowerCase().includes(w)||((C=k.email)==null?void 0:C.toLowerCase().includes(w))||((E=k.phone)==null?void 0:E.includes(w))||((L=k.owner_name)==null?void 0:L.toLowerCase().includes(w))})}return N},[s,a,l]);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ns,{className:"h-10 w-full"}),e.jsx(Ns,{className:"h-64 w-full"})]}):!s||s.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(lr,{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(Pe,{children:e.jsx(Re,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name, email, phone, or agent...",value:a,onChange:N=>o(N.target.value),className:"pl-9"})]}),e.jsxs(Bs,{value:l,onValueChange:i,children:[e.jsx(Rs,{className:"w-[200px]",children:e.jsx(qs,{placeholder:"Filter by agent"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Team Members"}),_.map(N=>e.jsx(vt,{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(Pe,{children:e.jsx(Re,{className:"p-0 overflow-x-auto",children:e.jsxs(In,{className:"min-w-[800px]",children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:b.length===0?e.jsx(Ms,{children:e.jsx(ut,{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(Ms,{className:`hover:bg-accent/50 ${y?"cursor-pointer":""}`,onClick:y?()=>t(`/mission-control/contacts/${N.id}`):void 0,children:[e.jsx(ut,{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(ut,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(vn,{className:"h-6 w-6",children:[e.jsx(Ta,{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(ut,{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(rr,{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(Pn,{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(ut,{children:N.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(Da,{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(ut,{children:N.lead_source?e.jsx(Qe,{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(ut,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ps(new Date(N.created_at),"MMM d, yyyy")})}),y&&e.jsx(ut,{children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:w=>{w.stopPropagation(),u(N.id),x(`${N.first_name} ${N.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(Hv,{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)})]})},d4e=({teamId:t})=>{const{user:s}=Fs(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=att(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(Ns,{className:"h-20 w-full"},d))});if(r.length===0)return e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ag,{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,x,y,_,b,N;return e.jsx(Pe,{children:e.jsxs(Re,{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:[((x=d.contact)==null?void 0:x.email)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(rr,{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(Pn,{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(Ta,{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(hL,{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,x;return e.jsx(Pe,{className:"opacity-75",children:e.jsxs(Re,{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(Qe,{variant:"secondary",className:"text-xs",children:["Claimed by ",((x=d.claimer)==null?void 0:x.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(Jy,{className:"mr-1 h-3 w-3"}),"Return"]})]})},d.id)})})]})]})},ott=({teamId:t})=>{const{useTeamMembers:s}=NC(),{data:r=[]}=s(t),n=r.map(_=>_.user_id),a=new Map(r.map(_=>[_.user_id,_.profile])),{data:o=[],isLoading:l}=gt({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}=gt({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}=gt({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(Ns,{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(Pe,{children:e.jsxs(Re,{className:"flex items-center gap-3 p-4",children:[e.jsx(Pg,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{className:"flex items-center gap-3 p-4",children:[e.jsx(Tn,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:u.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]}),e.jsxs(ia,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(ea,{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(Nye,{icon:e.jsx(Pg,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(_=>{const b=y(_.owner_user_id);return e.jsx(Pe,{children:e.jsxs(Re,{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(Ta,{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," · ",ps(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(Qe,{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(wn,{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(Nye,{icon:e.jsx(Mn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(_=>{const b=y(_.agent_id);return e.jsx(Pe,{children:e.jsxs(Re,{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(Ta,{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," · ",ps(new Date(_.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[_.is_active?e.jsx(Qe,{className:"text-xs",children:"Active"}):e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"Inactive"}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(lr,{className:"h-3 w-3"}),_.visitor_count||0]})]})]})},_.id)})}),e.jsx(js,{value:"videos",className:"space-y-2",children:u.length===0?e.jsx(Nye,{icon:e.jsx(Tn,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(_=>{const b=y(_.owner_user_id);return e.jsx(Pe,{children:e.jsxs(Re,{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(Ta,{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," · ",ps(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(Qe,{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(wn,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})})]})]})},Nye=({icon:t,label:s})=>e.jsx(Pe,{children:e.jsxs(Re,{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})]})}),ltt=({team:t,brokerageAgents:s,onBack:r,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:d,isAddingMember:u})=>{var V,q;const{useTeamMembers:p}=NC(),{data:x=[],isLoading:y}=p(t.id),[_,b]=S.useState(!1),[N,w]=S.useState(""),[k,C]=S.useState("team_member"),{data:E}=gt({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),U=new Map;return($||[]).forEach(se=>{var Y;U.set(se.user_id,((Y=se.teams)==null?void 0:Y.name)||"another team")}),U}}),L=new Set(x.map($=>$.user_id)),I=s.filter($=>!L.has($.id)),O=async()=>{N&&(await a(N,k),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(ia,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(ea,{children:[e.jsx(ls,{value:"members",children:"Members"}),e.jsxs(ls,{value:"contacts",children:[e.jsx(K4,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(ls,{value:"lead-pond",children:[e.jsx(Ag,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(ls,{value:"shared-assets",children:[e.jsx(Mm,{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(pi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(al,{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(Ir,{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(xe,{children:"Agent"}),e.jsxs(xo,{children:[e.jsx(go,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[N&&(((V=I.find($=>$.id===N))==null?void 0:V.name)||((q=I.find($=>$.id===N))==null?void 0:q.email))||"Select an agent",e.jsx(gx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(lo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search agents..."}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:"No agents found."}),e.jsx(Ax,{children:I.map($=>{const U=E==null?void 0:E.get($.id);return e.jsxs(lp,{value:$.name||$.email||$.id,disabled:!!U,onSelect:()=>w($.id),children:[e.jsx(Jn,{className:Rt("mr-2 h-4 w-4",N===$.id?"opacity-100":"opacity-0")}),$.name||$.email,U&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",U,")"]})]},$.id)})})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Role"}),e.jsxs(Bs,{value:k,onValueChange:C,children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"team_leader",children:"Team Leader"}),e.jsx(vt,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(En,{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(Ns,{className:"h-16 w-full"},$))}):x.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(lr,{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:x.map($=>{var U,se,Y,J,X;return e.jsx(Pe,{children:e.jsxs(Re,{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(Ta,{src:((U=$.profile)==null?void 0:U.avatar_url)||""}),e.jsx(_n,{children:(((se=$.profile)==null?void 0:se.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Y=$.profile)==null?void 0:Y.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(J=$.profile)==null?void 0:J.email})]}),$.role==="team_leader"?e.jsxs(Qe,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(Cm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(Qe,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Bs,{value:$.role,onValueChange:ce=>l($.id,ce),children:[e.jsx(Rs,{className:"w-[140px]",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"team_leader",children:"Team Leader"}),e.jsx(vt,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx($L,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Remove Member?"}),e.jsxs(Pl,{children:["Remove ",((X=$.profile)==null?void 0:X.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{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(c4e,{})}),t.lead_pond_enabled&&e.jsx(js,{value:"lead-pond",className:"space-y-4",children:e.jsx(d4e,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(js,{value:"shared-assets",className:"space-y-4",children:e.jsx(ott,{teamId:t.id})}),e.jsxs(js,{value:"settings",className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{className:"text-lg",children:"Team Settings"}),e.jsx(hr,{children:"Configure how this team operates."})]}),e.jsxs(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Team Name"}),e.jsx(De,{defaultValue:t.name,onBlur:$=>{$.target.value!==t.name&&n({name:$.target.value})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(vr,{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(xe,{children:"Contact Visibility"}),e.jsxs(Bs,{defaultValue:t.contact_visibility,onValueChange:$=>n({contact_visibility:$}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"private",children:"Private — Members keep their contacts private"}),e.jsx(vt,{value:"leader_only",children:"Leader Only — Only team leaders can see member contacts"}),e.jsx(vt,{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(xe,{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(Er,{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(xe,{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(Er,{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(xe,{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(Er,{checked:t.shared_videos_enabled??!1,onCheckedChange:$=>n({shared_videos_enabled:$})})]})]})]}),e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsxs(K,{variant:"destructive",size:"sm",children:[e.jsx(gr,{className:"mr-2 h-4 w-4"}),"Delete Team"]})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Delete Team?"}),e.jsxs(Pl,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},ctt=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[d,u]=S.useState(1),[p,x]=S.useState(""),[y,_]=S.useState(""),[b,N]=S.useState(""),[w,k]=S.useState(""),[C,E]=S.useState([]),L=()=>{u(1),x(""),_(""),N(""),k(""),E([])},I=$=>{$||L(),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}),L()},V=$=>{$!==w&&E(U=>U.includes($)?U.filter(se=>se!==$):[...U,$])},q=a.filter($=>$.id!==w);return e.jsx(fs,{open:t,onOpenChange:I,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(Ir,{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(xe,{htmlFor:"team-name",children:"Team Name *"}),e.jsx(De,{id:"team-name",value:p,onChange:$=>x($.target.value),placeholder:"e.g., Downtown Squad",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"team-desc",children:"Description"}),e.jsx(vr,{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(xe,{children:"Brokerage"}),e.jsxs(Bs,{value:b,onValueChange:N,children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"No brokerage (independent team)"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"No brokerage (independent)"}),l.map($=>e.jsx(vt,{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(xe,{className:"flex items-center gap-1.5",children:[e.jsx(Cm,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs(Bs,{value:w,onValueChange:$=>{k($),E(U=>U.filter(se=>se!==$))},children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select a team leader (optional)"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"No leader for now"}),a.map($=>e.jsx(vt,{value:$.id,children:$.name||$.email||"Unknown"},$.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{className:"flex items-center gap-1.5",children:[e.jsx(al,{className:"h-3.5 w-3.5"}),"Initial Members",C.length>0&&e.jsxs(Qe,{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(lr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):q.map($=>{const U=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",U&&"bg-primary/5"),onClick:()=>V($.id),children:[e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ta,{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",U?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:U&&e.jsx(Jn,{className:"h-3 w-3"})})]},$.id)})})]})]})}),e.jsx(En,{className:"gap-2 sm:gap-0",children:d===1?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>u(2),disabled:!p.trim(),children:["Next",e.jsx(ei,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>u(1),children:[e.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(K,{onClick:O,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},rVt=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=NC(),[d,u]=S.useState(!1),[p,x]=S.useState(null),[y,_]=S.useState(""),{data:b}=gt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:I,error:O}=await G.from("brokerages").select("id, name").order("name");if(O)throw O;return I||[]}}),{data:N}=gt({queryKey:["admin-team-member-info",t.map(I=>I.id).join(",")],queryFn:async()=>{var $;if(t.length===0)return{};const{data:I}=await G.from("team_members").select("team_id, user_id, role").in("team_id",t.map(U=>U.id));if(!I)return{};const O=I.filter(U=>U.role==="team_leader").map(U=>U.user_id);let V={};if(O.length>0){const{data:U}=await G.from("profiles").select("id, name").in("id",O);U&&(V=Object.fromEntries(U.map(se=>[se.id,{name:se.name}])))}const q={};for(const U of t){const se=I.filter(J=>J.team_id===U.id),Y=se.find(J=>J.role==="team_leader");q[U.id]={count:se.length,leaderName:Y&&(($=V[Y.user_id])==null?void 0:$.name)||null}}return q},enabled:t.length>0}),w=(p==null?void 0:p.brokerage_id)||null,{data:k}=gt({queryKey:["brokerage-agents-for-teams",w],queryFn:async()=>{let I=G.from("profiles").select("id, name, email, avatar_url").order("name");w&&(I=I.eq("brokerage_id",w));const{data:O,error:V}=await I;if(V)throw V;return O||[]},enabled:!!p}),C=Object.fromEntries((b||[]).map(I=>[I.id,I.name])),E=async I=>{const O=await r.mutateAsync({name:I.name,brokerage_id:I.brokerage_id||null,description:I.description});if(I.leaderId&&I.leaderId!=="none"&&await o.mutateAsync({team_id:O.id,user_id:I.leaderId,role:"team_leader"}),I.memberIds)for(const V of I.memberIds)await o.mutateAsync({team_id:O.id,user_id:V,role:"team_member"});u(!1)};if(p)return e.jsx(ltt,{team:p,brokerageAgents:k||[],onBack:()=>x(null),onUpdate:I=>n.mutateAsync({id:p.id,...I}).then(O=>x(O)),onAddMember:(I,O)=>o.mutateAsync({team_id:p.id,user_id:I,role:O}),onRemoveMember:I=>l.mutateAsync({team_id:p.id,member_id:I}),onUpdateRole:(I,O)=>i.mutateAsync({team_id:p.id,member_id:I,role:O}),onDeleteTeam:()=>{a.mutate(p.id),x(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const L=t.filter(I=>I.name.toLowerCase().includes(y.toLowerCase())||(I.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(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search teams...",value:y,onChange:I=>_(I.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[L.length," of ",t.length," teams"]})]}),e.jsxs(K,{size:"sm",onClick:()=>u(!0),children:[e.jsx(Us,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(ctt,{open:d,onOpenChange:u,onCreateTeam:E,isCreating:r.isPending,brokerageAgents:[],isAdmin:!0,allBrokerages:b,activeBrokerageId:null}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(I=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsx(Ns,{className:"h-4 w-32"})}),e.jsx(ut,{children:e.jsx(Ns,{className:"h-4 w-24"})}),e.jsx(ut,{children:e.jsx(Ns,{className:"h-4 w-28"})}),e.jsx(ut,{children:e.jsx(Ns,{className:"h-4 w-12"})}),e.jsx(ut,{children:e.jsx(Ns,{className:"h-4 w-20"})}),e.jsx(ut,{children:e.jsx(Ns,{className:"h-4 w-16"})})]},I))}):L.length===0?e.jsx(Ms,{children:e.jsx(ut,{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."})}):L.map(I=>{const O=N==null?void 0:N[I.id];return e.jsxs(Ms,{className:"hover:bg-muted/30",children:[e.jsxs(ut,{children:[e.jsx("button",{onClick:()=>x(I),className:"text-primary hover:underline font-medium",children:I.name}),I.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:I.description})]}),e.jsx(ut,{children:I.brokerage_id?e.jsx("span",{className:"text-sm",children:C[I.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(ut,{children:O!=null&&O.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(Cm,{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(ut,{children:e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:[e.jsx(lr,{className:"h-3 w-3 mr-1"}),(O==null?void 0:O.count)??0]})}),e.jsx(ut,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(Ou,{className:"h-3 w-3"}),I.contact_visibility.replace("_"," ")]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>x(I),title:"Edit team",children:e.jsx(ga,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>{confirm(`Delete team "${I.name}"? This cannot be undone.`)&&a.mutate(I.id)},title:"Delete team",children:e.jsx(gr,{className:"h-3.5 w-3.5"})})]})})]},I.id)})})]})})]})},nVt=()=>{const t=_r(),{user:s,isAdmin:r}=Fs(),{startImpersonation:n,isLoading:a}=cue(),{toast:o}=wa(),[l,i]=S.useState([]),[d,u]=S.useState([]),[p,x]=S.useState([]),[y,_]=S.useState({}),[b,N]=S.useState(!0);S.useState({});const[w,k]=S.useState(!1),[C,E]=S.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[L,I]=S.useState(!1),[O,V]=S.useState(""),[q,$]=S.useState(1),[U,se]=S.useState(50),[Y,J]=S.useState("all"),[X,ce]=S.useState("all"),[ie,ae]=S.useState("all"),[oe,pe]=S.useState("all"),[_e,he]=S.useState(!1),[we,je]=S.useState(!1),[Ue,Te]=S.useState(null),[Me,Fe]=S.useState(null),[Le,Ne]=S.useState(!1),[qe,ze]=S.useState({name:"",email:"",brokerage_id:"",phone:""}),[ve,dt]=S.useState(null),[fe,Ve]=S.useState(!1),[Je,at]=S.useState(""),[Ae,Ye]=S.useState(!1),[We,ot]=S.useState(!1),[Ge,et]=S.useState(null),[ht,xt]=S.useState(""),[Ke,Ze]=S.useState(!1),[Et,$t]=S.useState(!1),[Yt,Ps]=S.useState(null),[zs,Zs]=S.useState(!1),[Dr,zt]=S.useState(!1),[$s,kr]=S.useState(null),[Xs,ir]=S.useState(""),[Or,Vn]=S.useState(!1),[Qr,Gr]=S.useState({email:"",name:"",password:"",phone:""}),[tr,cr]=S.useState(!1),[cn,rn]=S.useState(!1),[jn,ni]=S.useState(""),[rs,Bn]=S.useState(!1),[mn,Fr]=S.useState(!1),[Kt,jr]=S.useState(""),[zr,fa]=S.useState(new Set),[qt,Se]=S.useState(!1),[Oe,Xe]=S.useState(!1),[_t,bt]=S.useState(null),[Mt,Ht]=S.useState(!1),[Vt,Xt]=S.useState(null),[Ts,xs]=S.useState([]),[or,Lr]=S.useState([]),[Hr,Rr]=S.useState(!1),[dn,Gn]=S.useState({});S.useEffect(()=>{!s||!r||(da(),Mo())},[s,r]);const ta=async()=>{try{const{data:kt,error:Ds}=await G.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(Ds)throw Ds;const nr={};for(const Jr of kt??[])nr[Jr.brokerage_id]||(nr[Jr.brokerage_id]=[]),nr[Jr.brokerage_id].push(Jr.user_id);_(nr)}catch(kt){console.error("Error loading brokerage manager assignments:",kt)}},da=async()=>{try{N(!0);const{data:kt,error:Ds}=await G.functions.invoke("get-user-details");if(Ds)throw Ds;const nr=kt.users||[];i(nr),x(kt.brokerages||[]),await ta();const Jr=nr.filter(pn=>pn.roles.includes("assistant"));if(Jr.length>0){const pn=Jr.map(xa=>xa.id),{data:oa}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",pn);if(oa&&oa.length>0){const xa=[...new Set(oa.map(Bm=>Bm.agent_id))],{data:Ai}=await G.from("profiles").select("id, name, email").in("id",xa),kc={};for(const Bm of oa){const Zh=Ai==null?void 0:Ai.find(D0=>D0.id===Bm.agent_id);Zh&&(kc[Bm.assistant_id]={agent_name:Zh.name||"",agent_email:Zh.email||""})}Gn(kc)}}}catch(kt){console.error("Error loading members:",kt),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{N(!1)}},Mo=async()=>{try{const{data:kt,error:Ds}=await G.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(Ds)throw Ds;u(kt||[])}catch(kt){console.error("Error loading apps:",kt),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},_o=async kt=>{if(!qe.name.trim()||!qe.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(qe.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:nr}=await G.from("profiles").update({name:qe.name.trim(),email:qe.email.trim(),brokerage_id:qe.brokerage_id||null,phone:qe.phone.trim()||null}).eq("id",kt);if(nr)throw nr;o({title:"Success",description:"Member details updated successfully"}),Te(null),da()}catch(nr){console.error("Error updating member:",nr),o({title:"Error",description:nr.message||"Failed to update member",variant:"destructive"})}},Zi=async kt=>{try{const{data:{session:Ds}}=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 ${Ds==null?void 0:Ds.access_token}`},body:JSON.stringify({userId:kt})}),Jr=await nr.json();if(!nr.ok)throw new Error(Jr.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(Ds){console.error("Error resending welcome email:",Ds),o({title:"Error",description:Ds.message||"Failed to resend welcome email",variant:"destructive"})}},ai=async(kt,Ds)=>{try{const{error:nr}=await G.functions.invoke("send-password-reset",{body:{email:kt,redirectTo:window.location.origin}});if(nr)throw nr;o({title:"Password Reset Sent",description:`Password reset email sent to ${Ds}`})}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(kt,Ds)=>{if(confirm(`Are you sure you want to delete ${Ds}? This action cannot be undone.`))try{const{data:{session:nr}}=await G.auth.getSession(),Jr=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:kt})}),pn=await Jr.json();if(!Jr.ok)throw new Error(pn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),da()}catch(nr){console.error("Error deleting user:",nr),o({title:"Error",description:nr.message||"Failed to delete user",variant:"destructive"})}},Qo=async()=>{if(!C.email||!C.name||!C.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}if(C.role==="brokerage_manager"&&!C.brokerage_id){o({title:"Error",description:"Please select a brokerage for this manager",variant:"destructive"});return}k(!0);try{const{data:{session:kt}}=await G.auth.getSession(),Ds=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${kt==null?void 0:kt.access_token}`},body:JSON.stringify(C)}),nr=await Ds.json();if(!Ds.ok)throw new Error(nr.error||"Failed to create user");if(C.role&&C.role!=="user"&&nr.userId){const Jr=C.role==="brokerage_manager"?C.brokerage_id:void 0;await di(nr.userId,C.role,"add",Jr)}o({title:"Success",description:`User ${C.email} created successfully`}),E({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),I(!1),da()}catch(kt){console.error("Error creating user:",kt),o({title:"Error",description:kt.message||"Failed to create user",variant:"destructive"})}finally{k(!1)}},di=async(kt,Ds,nr,Jr)=>{try{const{data:{session:pn}}=await G.auth.getSession(),oa={userId:kt,role:Ds,action:nr};if(Ds==="brokerage_manager"){if(!Jr){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}oa.brokerageId=Jr}const xa=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(oa)}),Ai=await xa.json();if(!xa.ok)throw new Error(Ai.error||"Failed to manage user role");o({title:"Success",description:`Role ${nr==="add"?"added":"removed"} successfully`}),da()}catch(pn){console.error("Error managing user role:",pn),o({title:"Error",description:pn.message||"Failed to manage user role",variant:"destructive"})}},zi=(kt,Ds)=>Ds.length===0?!0:Ds.some(nr=>kt.includes(nr)),Yi=async(kt,Ds,nr)=>{const Jr=`${kt}-${Ds.id}`;dt(Jr);try{if(nr){const pn=l.find(xa=>xa.id===kt),oa=Ds.required_tags.filter(xa=>pn==null?void 0:pn.tags.includes(xa));for(const xa of oa){const{error:Ai}=await G.from("user_tags").delete().eq("user_id",kt).eq("tag",xa);if(Ai)throw Ai}o({title:"Access Removed",description:`Removed access to ${Ds.name}`})}else if(Ds.required_tags.length>0){const{error:pn}=await G.from("user_tags").insert({user_id:kt,tag:Ds.required_tags[0]});if(pn)throw pn;o({title:"Access Granted",description:`Granted access to ${Ds.name}`})}await da()}catch(pn){console.error("Error toggling access:",pn),o({title:"Error",description:pn.message||"Failed to update access",variant:"destructive"})}finally{dt(null)}},ua=async()=>{const kt=Je.trim();if(!kt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(kt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(p.find(nr=>nr.name.toLowerCase()===kt.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}Ye(!0);try{const{error:nr}=await G.from("brokerages").insert({name:kt});if(nr)throw nr;o({title:"Success",description:`Brokerage "${kt}" created successfully`}),at(""),Ve(!1),da()}catch(nr){console.error("Error creating brokerage:",nr),o({title:"Error",description:nr.message||"Failed to create brokerage",variant:"destructive"})}finally{Ye(!1)}},Jo=kt=>{et(kt),xt(kt.name),ot(!0)},sc=()=>{et(null),xt(""),ot(!1)},rc=async()=>{if(!Ge)return;const kt=ht.trim();if(!kt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(kt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}Ze(!0);try{const{error:Ds}=await G.from("brokerages").update({name:kt}).eq("id",Ge.id);if(Ds)throw Ds;o({title:"Success",description:"Brokerage updated successfully"}),sc(),da()}catch(Ds){console.error("Error updating brokerage:",Ds),o({title:"Error",description:Ds.message||"Failed to update brokerage",variant:"destructive"})}finally{Ze(!1)}},_u=async(kt,Ds)=>{var nr;if(!Ds||typeof Ds!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const Jr={userId:kt,role:"brokerage_manager",action:"add",brokerageId:Ds};console.debug("[assignManagerToBrokerage] payload",Jr);const{data:{session:pn}}=await G.auth.getSession(),oa=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(Jr)}),xa=await oa.json();if(!oa.ok&&!((nr=xa.error)!=null&&nr.includes("duplicate")))throw new Error(xa.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await da()}catch(Jr){console.error("Error assigning manager:",Jr),o({title:"Error",description:Jr.message||"Failed to assign manager",variant:"destructive"})}},bu=kt=>{Ps(kt),$t(!0)},Om=async()=>{if(Yt){Zs(!0);try{const kt=l.filter(Jr=>Jr.brokerage_id===Yt.id),{data:{session:Ds}}=await G.auth.getSession();for(const Jr of kt){const pn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ds==null?void 0:Ds.access_token}`},body:JSON.stringify({userId:Jr.id})});if(!pn.ok){const oa=await pn.json();console.error(`Failed to delete user ${Jr.email}:`,oa.error)}}const{error:nr}=await G.from("brokerages").delete().eq("id",Yt.id);if(nr)throw nr;o({title:"Success",description:`Brokerage "${Yt.name}" and ${kt.length} member(s) deleted`}),$t(!1),Ps(null),da()}catch(kt){console.error("Error deleting brokerage:",kt),o({title:"Error",description:kt.message||"Failed to delete brokerage",variant:"destructive"})}finally{Zs(!1)}}},Nd=kt=>{kr(kt),ir(""),zt(!0)},wu=()=>{kr(null),ir(""),zt(!1)},Fm=async kt=>{try{const{error:Ds}=await G.from("profiles").update({brokerage_id:null}).eq("id",kt);if(Ds)throw Ds;o({title:"Success",description:"User removed from brokerage"}),da()}catch(Ds){console.error("Error removing user from brokerage:",Ds),o({title:"Error",description:Ds.message||"Failed to remove user",variant:"destructive"})}},Hu=async(kt,Ds)=>{try{const{error:nr}=await G.from("profiles").update({brokerage_id:Ds}).eq("id",kt);if(nr)throw nr;o({title:"Success",description:"User added to brokerage"}),da()}catch(nr){console.error("Error adding user to brokerage:",nr),o({title:"Error",description:nr.message||"Failed to add user",variant:"destructive"})}},zm=async()=>{if(!$s||!Qr.email||!Qr.name||!Qr.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}cr(!0);try{const{data:{session:kt}}=await G.auth.getSession(),Ds=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${kt==null?void 0:kt.access_token}`},body:JSON.stringify({...Qr,brokerage_id:$s.id,role:"user"})}),nr=await Ds.json();if(!Ds.ok)throw new Error(nr.error||"Failed to create agent");o({title:"Success",description:`Agent ${Qr.email} created successfully`}),Gr({email:"",name:"",password:"",phone:""}),Vn(!1),da()}catch(kt){console.error("Error creating agent:",kt),o({title:"Error",description:kt.message||"Failed to create agent",variant:"destructive"})}finally{cr(!1)}},kd=kt=>l.filter(Ds=>Ds.brokerage_id===kt),Sd=kt=>{const Ds=kd(kt);if(!Xs)return Ds;const nr=Xs.toLowerCase();return Ds.filter(Jr=>Jr.name.toLowerCase().includes(nr)||Jr.email.toLowerCase().includes(nr))},P0=kt=>l.filter(Ds=>Ds.brokerage_id!==kt),Cw=l.filter(kt=>{var nr;if(O){const Jr=O.toLowerCase();if(!(kt.name.toLowerCase().includes(Jr)||kt.email.toLowerCase().includes(Jr)||((nr=kt.brokerage_name)==null?void 0:nr.toLowerCase().includes(Jr))))return!1}if(Y==="claimed"&&!kt.claimed||Y==="unclaimed"&&kt.claimed||X!=="all"&&!kt.roles.includes(X))return!1;const Ds=kt.is_trial||kt.subscription_status==="trialing";return!(ie==="trial"&&!Ds||ie==="non-trial"&&Ds||oe==="none"&&kt.brokerage_id||oe!=="all"&&oe!=="none"&&kt.brokerage_id!==oe)}),{sortKey:xh,sortDirection:kp,handleSort:Sp,sortData:Mw}=QR("created_at","desc"),Kh=Mw(Cw,{name:kt=>{var Ds;return((Ds=kt.name)==null?void 0:Ds.toLowerCase())||""},brokerage:kt=>{var Ds;return((Ds=kt.brokerage_name)==null?void 0:Ds.toLowerCase())||""},status:kt=>kt.claimed?"active":"pending",role:kt=>kt.roles[0]||"",last_login:kt=>kt.last_sign_in_at?new Date(kt.last_sign_in_at).getTime():null,created_at:kt=>kt.created_at?new Date(kt.created_at).getTime():null}),Sf=Kh.length,zx=U===0,Cd=zx?1:Math.ceil(Sf/U),Bx=zx?0:(q-1)*U,Cp=zx?Sf:Bx+U,Hd=Kh.slice(Bx,Cp),Tw=kt=>{V(kt),$(1)},gh=kt=>{se(kt),$(1)},Xg=(kt,Ds)=>{kt(Ds),$(1)},Cf=async(kt,Ds)=>{he(!0);try{const nr=l.find(xa=>xa.id===kt);if(!nr)return;const Jr=nr.trial_expires_at?new Date(nr.trial_expires_at):new Date,pn=new Date(Jr.getTime()+Ds*24*60*60*1e3),{error:oa}=await G.from("profiles").update({trial_expires_at:pn.toISOString()}).eq("id",kt);if(oa)throw oa;o({title:"Trial Extended",description:`Trial extended by ${Ds} days`}),da()}catch(nr){console.error("Error extending trial:",nr),o({title:"Error",description:nr.message||"Failed to extend trial",variant:"destructive"})}finally{he(!1)}},I0=async kt=>{je(!0);try{const{error:Ds}=await G.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",kt);if(Ds)throw Ds;o({title:"Account Converted",description:"User has been converted to a full account"}),da(),Ca()}catch(Ds){console.error("Error converting trial:",Ds),o({title:"Error",description:Ds.message||"Failed to convert account",variant:"destructive"})}finally{je(!1)}},Aw=async kt=>{Rr(!0);try{const{data:Ds}=await G.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",kt);if(Ds&&Ds.length>0){const Jr=Ds.map(oa=>oa.assistant_id),{data:pn}=await G.from("profiles").select("id, name, email").in("id",Jr);xs(Ds.map(oa=>{const xa=pn==null?void 0:pn.find(Ai=>Ai.id===oa.assistant_id);return{id:oa.id,assistant_id:oa.assistant_id,assistant_name:(xa==null?void 0:xa.name)||"Unknown",assistant_email:(xa==null?void 0:xa.email)||"",permissions:oa.permissions||{}}}))}else xs([]);const{data:nr}=await G.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",kt);if(nr&&nr.length>0){const Jr=nr.map(oa=>oa.agent_id),{data:pn}=await G.from("profiles").select("id, name, email").in("id",Jr);Lr(nr.map(oa=>{const xa=pn==null?void 0:pn.find(Ai=>Ai.id===oa.agent_id);return{id:oa.id,agent_id:oa.agent_id,agent_name:(xa==null?void 0:xa.name)||"Unknown",agent_email:(xa==null?void 0:xa.email)||"",permissions:oa.permissions||{}}}))}else Lr([])}catch(Ds){console.error("Error loading assistant data:",Ds)}finally{Rr(!1)}},A1=kt=>{Fe(kt),ze({name:kt.name,email:kt.email,brokerage_id:kt.brokerage_id||"",phone:kt.phone||""}),Ne(!0),Aw(kt.id)},Ca=()=>{Fe(null),Ne(!1),ze({name:"",email:"",brokerage_id:"",phone:""})},Qg=async()=>{Me&&(await _o(Me.id),Ca())},Jg=kt=>{fa(Ds=>{const nr=new Set(Ds);return nr.has(kt)?nr.delete(kt):nr.add(kt),nr})},IE=()=>{if(zr.size===Hd.length&&Hd.every(kt=>zr.has(kt.id))){const kt=new Set(zr);Hd.forEach(Ds=>kt.delete(Ds.id)),fa(kt)}else{const kt=new Set(zr);Hd.forEach(Ds=>kt.add(Ds.id)),fa(kt)}},$x=()=>{fa(new Set)},Mf=async()=>{if(zr.size===0)return;Se(!0);let kt=0,Ds=0;try{const{data:{session:nr}}=await G.auth.getSession();for(const Jr of zr)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:Jr})})).ok?kt++:Ds++}catch{Ds++}o({title:"Bulk Email Complete",description:`Sent ${kt} emails${Ds>0?`, ${Ds} failed`:""}`}),$x()}catch(nr){o({title:"Error",description:nr.message||"Failed to send emails",variant:"destructive"})}finally{Se(!1)}},ey=async()=>{if(zr.size===0)return;Se(!0);let kt=0,Ds=0;try{const{data:{session:nr}}=await G.auth.getSession();for(const Jr of zr)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:Jr})})).ok?kt++:Ds++}catch{Ds++}o({title:"Bulk Password Reset Complete",description:`Sent ${kt} reset emails${Ds>0?`, ${Ds} failed`:""}`}),$x()}catch(nr){o({title:"Error",description:nr.message||"Failed to send password reset emails",variant:"destructive"})}finally{Se(!1)}},L0=async()=>{if(zr.size===0)return;const kt=l.filter(pn=>zr.has(pn.id)).map(pn=>pn.name).slice(0,5).join(", "),Ds=zr.size>5?` and ${zr.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${zr.size} users (${kt}${Ds})? This action cannot be undone.`))return;Se(!0);let nr=0,Jr=0;try{const{data:{session:pn}}=await G.auth.getSession();for(const oa of zr)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:oa})})).ok?nr++:Jr++}catch{Jr++}o({title:"Bulk Delete Complete",description:`Deleted ${nr} users${Jr>0?`, ${Jr} failed`:""}`}),$x(),da()}catch(pn){o({title:"Error",description:pn.message||"Failed to delete users",variant:"destructive"})}finally{Se(!1)}},E1=async()=>{Xe(!0);try{const{data:{session:kt}}=await G.auth.getSession(),Ds=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-phone-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${kt==null?void 0:kt.access_token}`}});if(!Ds.ok){const Jr=await Ds.json();throw new Error(Jr.error||"Failed to sync phones")}const nr=await Ds.json();o({title:"Phone Sync Complete",description:`Pulled ${nr.summary.pulledFromGHL} from GHL, pushed ${nr.summary.pushedToGHL} to GHL, ${nr.summary.alreadySynced} already synced`}),da()}catch(kt){o({title:"Error",description:kt.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{Xe(!1)}},PC=async(kt,Ds)=>{bt(kt);try{const{data:{session:nr}}=await G.auth.getSession(),{data:Jr}=await G.from("profiles").select("phone").eq("id",kt).single(),pn=(Jr==null?void 0:Jr.phone)||"",oa=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:Ds,action:"update",phone:pn||void 0})});if(!oa.ok){const Ai=await oa.json();throw new Error(Ai.error||"Failed to sync with GHL")}const xa=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(Ds)}`,{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"}),da()}catch(nr){o({title:"Error",description:nr.message||"Failed to sync phone",variant:"destructive"})}finally{bt(null)}},Tf=async kt=>{await n(kt)},IC=()=>{if(zr.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const kt=l.filter(Ai=>zr.has(Ai.id)),Ds=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],nr=kt.map(Ai=>[Ai.name,Ai.email,Ai.phone||"",Ai.brokerage_name||"",Ai.roles.join("; "),Ai.claimed?"Claimed":"Unclaimed",new Date(Ai.created_at).toLocaleDateString()]),Jr=[Ds.join(","),...nr.map(Ai=>Ai.map(kc=>`"${(kc||"").replace(/"/g,'""')}"`).join(","))].join(` `),pn=new Blob([Jr],{type:"text/csv"}),oa=URL.createObjectURL(pn),xa=document.createElement("a");xa.href=oa,xa.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,xa.click(),URL.revokeObjectURL(oa),o({title:"Export complete",description:`Exported ${kt.length} member(s)`})};return b?e.jsx(Es,{title:"Members",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(Es,{title:"Members",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{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:E1,disabled:Oe,children:[Oe?e.jsx(_s,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Pn,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:Oe?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:Oe?"Syncing...":"Sync GHL"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>rn(!0),children:[e.jsx(Kv,{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:L,onOpenChange:I,children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(al,{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(Ir,{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(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",placeholder:"John Doe",value:C.name,onChange:kt=>E({...C,name:kt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"email",children:"Email"}),e.jsx(De,{id:"email",type:"email",placeholder:"john@example.com",value:C.email,onChange:kt=>E({...C,email:kt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"password",children:"Password"}),e.jsx(De,{id:"password",type:"password",placeholder:"Min 6 characters",value:C.password,onChange:kt=>E({...C,password:kt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(De,{id:"phone",type:"tel",placeholder:"555-123-4567",value:C.phone,onChange:kt=>E({...C,phone:kt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{htmlFor:"brokerage",children:["Brokerage",C.role==="brokerage_manager"?" (required)":""]}),e.jsxs(Bs,{value:C.brokerage_id||"none",onValueChange:kt=>E({...C,brokerage_id:kt==="none"?"":kt}),children:[e.jsx(Rs,{id:"brokerage",children:e.jsx(qs,{placeholder:C.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"None"}),p.map(kt=>e.jsx(vt,{value:kt.id,children:kt.name},kt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"role",children:"Role"}),e.jsxs(Bs,{value:C.role,onValueChange:kt=>E({...C,role:kt}),children:[e.jsx(Rs,{id:"role",children:e.jsx(qs,{placeholder:"Select role"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"user",children:"User"}),e.jsx(vt,{value:"moderator",children:"Moderator"}),e.jsx(vt,{value:"brokerage_manager",children:"Brokerage Manager"}),e.jsx(vt,{value:"admin",children:"Admin"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"trial_days",children:"Trial Period (optional)"}),e.jsxs(Bs,{value:C.trial_days||"none",onValueChange:kt=>E({...C,trial_days:kt==="none"?"":kt}),children:[e.jsx(Rs,{id:"trial_days",children:e.jsx(qs,{placeholder:"No trial (full access)"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"No trial (full access)"}),e.jsx(vt,{value:"7",children:"7-day trial"}),e.jsx(vt,{value:"30",children:"30-day trial"}),e.jsx(vt,{value:"60",children:"60-day trial"}),e.jsx(vt,{value:"90",children:"90-day trial"}),e.jsx(vt,{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(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsx(K,{onClick:Qo,disabled:w,children:w?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(ia,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(ea,{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(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search members...",value:O,onChange:kt=>Tw(kt.target.value),className:"pl-10 h-9"})]}),e.jsxs(Bs,{value:Y,onValueChange:kt=>Xg(J,kt),children:[e.jsx(Rs,{className:"w-[130px] h-9",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Status"}),e.jsx(vt,{value:"claimed",children:"Active"}),e.jsx(vt,{value:"unclaimed",children:"Pending"})]})]}),e.jsxs(Bs,{value:X,onValueChange:kt=>Xg(ce,kt),children:[e.jsx(Rs,{className:"w-[130px] h-9",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Roles"}),e.jsx(vt,{value:"admin",children:"Admin"}),e.jsx(vt,{value:"brokerage_manager",children:"Manager"}),e.jsx(vt,{value:"assistant",children:"Assistant"}),e.jsx(vt,{value:"user",children:"User"})]})]}),e.jsxs(Bs,{value:ie,onValueChange:kt=>Xg(ae,kt),children:[e.jsx(Rs,{className:"w-[130px] h-9",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Users"}),e.jsx(vt,{value:"trial",children:"Trial Only"}),e.jsx(vt,{value:"non-trial",children:"Full Only"})]})]}),e.jsxs(Bs,{value:oe,onValueChange:kt=>Xg(pe,kt),children:[e.jsx(Rs,{className:"w-[150px] h-9",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Brokerages"}),e.jsx(vt,{value:"none",children:"No Brokerage"}),p.map(kt=>e.jsx(vt,{value:kt.id,children:kt.name},kt.id))]})]}),(O||Y!=="all"||X!=="all"||ie!=="all"||oe!=="all")&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{V(""),J("all"),ce("all"),ae("all"),pe("all"),$(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:zx?`Showing all ${Sf} members`:`Showing ${Bx+1}-${Math.min(Cp,Sf)} of ${Sf} members`}),e.jsxs(Bs,{value:U.toString(),onValueChange:kt=>gh(Number(kt)),children:[e.jsx(Rs,{className:"h-9 w-[110px]",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"50",children:"50 / page"}),e.jsx(vt,{value:"100",children:"100 / page"}),e.jsx(vt,{value:"250",children:"250 / page"}),e.jsx(vt,{value:"0",children:"All"})]})]})]})]}),zr.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:[zr.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:Mf,disabled:qt,children:[qt?e.jsx(_s,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(rr,{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:ey,disabled:qt,children:[qt?e.jsx(_s,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(pp,{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:IC,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:L0,disabled:qt,children:[qt?e.jsx(_s,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(gr,{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:$x,disabled:qt,children:e.jsx(Sr,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(Nt,{className:"w-[50px]",children:e.jsx(Ki,{checked:Hd.length>0&&Hd.every(kt=>zr.has(kt.id)),onCheckedChange:IE,"aria-label":"Select all on page"})}),e.jsx(Ko,{sortKey:"name",currentSortKey:xh,currentDirection:kp,onSort:Sp,children:"Name"}),e.jsx(Ko,{sortKey:"brokerage",currentSortKey:xh,currentDirection:kp,onSort:Sp,children:"Brokerage"}),e.jsx(Ko,{sortKey:"status",currentSortKey:xh,currentDirection:kp,onSort:Sp,children:"Status"}),e.jsx(Ko,{sortKey:"role",currentSortKey:xh,currentDirection:kp,onSort:Sp,children:"Role"}),e.jsx(Ko,{sortKey:"last_login",currentSortKey:xh,currentDirection:kp,onSort:Sp,children:"Last Login"}),e.jsx(Ko,{sortKey:"created_at",currentSortKey:xh,currentDirection:kp,onSort:Sp,children:"Member Since"}),e.jsx(Nt,{className:"w-[100px]"})]})}),e.jsx(Dn,{children:Hd.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):Hd.map(kt=>e.jsxs(Ms,{className:`hover:bg-muted/30 ${zr.has(kt.id)?"bg-primary/5":""}`,children:[e.jsx(ut,{children:e.jsx(Ki,{checked:zr.has(kt.id),onCheckedChange:()=>Jg(kt.id),"aria-label":`Select ${kt.name}`})}),e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>A1(kt),className:"text-primary hover:underline font-medium text-left",children:kt.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:kt.email})]})}),e.jsx(ut,{className:"text-muted-foreground",children:kt.brokerage_name||"—"}),e.jsx(ut,{children:e.jsx("div",{className:"flex flex-col",children:(()=>{const Ds=kt.is_trial&&kt.trial_expires_at||!kt.is_trial&&kt.subscription_status==="trialing"&&kt.subscription_end_date,nr=kt.trial_expires_at||kt.subscription_end_date;if(Ds&&nr){const Jr=Math.ceil((new Date(nr).getTime()-Date.now())/864e5),pn=Jr<=0,oa=Jr<=3;return e.jsx(Qe,{variant:"outline",className:Rt("w-fit",pn?"border-destructive text-destructive":oa?"border-amber-500 text-amber-600":"border-violet-300 text-violet-700 bg-violet-50"),children:pn?"Trial Expired":`Trial · ${Jr}d left`})}return e.jsx(Qe,{variant:kt.claimed?"default":"secondary",className:kt.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:kt.claimed?"Active":"Pending"})})()})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex flex-col",children:[kt.roles.length>0?e.jsx("span",{className:"text-sm capitalize",children:kt.roles[0]}):e.jsx("span",{className:"text-muted-foreground",children:"—"}),kt.roles.includes("assistant")&&dn[kt.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",dn[kt.id].agent_name||dn[kt.id].agent_email]})]})}),e.jsx(ut,{className:"text-muted-foreground",children:kt.last_sign_in_at?new Date(kt.last_sign_in_at).toLocaleDateString():"—"}),e.jsx(ut,{className:"text-muted-foreground",children:kt.created_at?new Date(kt.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}),e.jsx(ut,{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:()=>{Xt(kt),Ht(!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:()=>A1(kt),title:"Edit member",children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>PC(kt.id,kt.email),disabled:_t===kt.id,title:"Sync phone with GHL",children:_t===kt.id?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(Pn,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Zi(kt.id),title:"Resend welcome email",children:e.jsx(rr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ai(kt.email,kt.name),title:"Send password reset",children:e.jsx(eS,{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:()=>Tf(kt.id),disabled:a||kt.id===(s==null?void 0:s.id),title:kt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${kt.name}`,children:a?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(rS,{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(kt.id,kt.name),title:"Delete user",children:e.jsx(gr,{className:"h-4 w-4"})})]})})]},kt.id))})]})}),Cd>1&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",q," of ",Cd]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>$(1),disabled:q===1,children:"First"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>$(kt=>Math.max(1,kt-1)),disabled:q===1,children:e.jsx(xl,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,Cd)},(kt,Ds)=>{let nr;return Cd<=5||q<=3?nr=Ds+1:q>=Cd-2?nr=Cd-4+Ds:nr=q-2+Ds,e.jsx(K,{variant:q===nr?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>$(nr),children:nr},nr)})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>$(kt=>Math.min(Cd,kt+1)),disabled:q===Cd,children:e.jsx(Sa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>$(Cd),disabled:q===Cd,children:"Last"})]})]})]}),e.jsx(fs,{open:Le,onOpenChange:Ne,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(Ir,{children:"Update member details, roles, and app access"})]}),Me&&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(xe,{htmlFor:"edit-name",children:"Name"}),e.jsx(De,{id:"edit-name",value:qe.name,onChange:kt=>ze({...qe,name:kt.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"edit-email",children:"Email"}),e.jsx(De,{id:"edit-email",type:"email",value:qe.email,onChange:kt=>ze({...qe,email:kt.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(xe,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(De,{id:"edit-phone",type:"tel",value:qe.phone,onChange:kt=>ze({...qe,phone:kt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(Bs,{value:qe.brokerage_id||"none",onValueChange:kt=>ze({...qe,brokerage_id:kt==="none"?"":kt}),children:[e.jsx(Rs,{id:"edit-brokerage",children:e.jsx(qs,{placeholder:"Select brokerage"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"None"}),p.map(kt=>e.jsx(vt,{value:kt.id,children:kt.name},kt.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:[Me.roles.map(kt=>e.jsxs(Qe,{variant:"default",className:"gap-1",children:[e.jsx(Ou,{className:"h-3 w-3"}),kt,kt==="brokerage_manager"?e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(manage in Brokerages tab)"}):e.jsx("button",{onClick:()=>di(Me.id,kt,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(Sr,{className:"h-3 w-3"})})]},kt)),Me.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs(Bs,{onValueChange:kt=>di(Me.id,kt,"add"),children:[e.jsx(Rs,{className:"w-[200px]",children:e.jsx(qs,{placeholder:"Add role..."})}),e.jsxs(Os,{children:[!Me.roles.includes("admin")&&e.jsx(vt,{value:"admin",children:"Admin"}),!Me.roles.includes("user")&&e.jsx(vt,{value:"user",children:"User"})]})]}),!Me.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"})]}),(Ts.length>0||or.length>0||Me.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(lr,{className:"h-4 w-4"}),"Assistant Relationships"]}),Hr?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(_s,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[Ts.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:"}),Ts.map(kt=>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:kt.assistant_name}),e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:kt.assistant_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(kt.permissions).filter(([,Ds])=>Ds).map(([Ds])=>e.jsx(Qe,{variant:"secondary",className:"text-[10px] capitalize",children:Ds},Ds))})]},kt.id))]}),or.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:"}),or.map(kt=>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:kt.agent_name}),e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Agent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:kt.agent_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(kt.permissions).filter(([,Ds])=>Ds).map(([Ds])=>e.jsx(Qe,{variant:"secondary",className:"text-[10px] capitalize",children:Ds},Ds))})]},kt.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(kt=>{const Ds=zi(Me.tags,kt.required_tags),nr=`${Me.id}-${kt.id}`,Jr=ve===nr,pn=kt.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:kt.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:kt.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:Jr?e.jsx(_s,{className:"h-4 w-4 animate-spin text-muted-foreground"}):pn?e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx(Er,{checked:Ds,onCheckedChange:()=>Yi(Me.id,kt,Ds)})})]},kt.id)})})]}),(Me.is_trial||Me.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(ln,{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:[Me.trial_expires_at&&e.jsx(eDe,{expiresAt:Me.trial_expires_at}),!Me.trial_expires_at&&Me.subscription_status==="trialing"&&Me.subscription_end_date&&e.jsx(eDe,{expiresAt:Me.subscription_end_date})]}),(Me.trial_expires_at||Me.subscription_end_date)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(Me.trial_expires_at||Me.subscription_end_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Cf(Me.id,7),disabled:_e,children:[e.jsx(bb,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Cf(Me.id,14),disabled:_e,children:[e.jsx(bb,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Cf(Me.id,30),disabled:_e,children:[e.jsx(bb,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(K,{size:"sm",variant:"default",onClick:()=>I0(Me.id),disabled:we,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Tb,{className:"h-4 w-4 mr-1"}),"Convert to Full Account"]})]}),Me.trial_started_at&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(Me.trial_started_at).toLocaleDateString(),Me.trial_claimed_at&&e.jsxs("span",{children:[" • Claimed: ",new Date(Me.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:[Me.email_confirmed_at&&e.jsxs("div",{children:["Claimed: ",new Date(Me.email_confirmed_at).toLocaleString()]}),Me.last_sign_in_at&&e.jsxs("div",{children:["Last login: ",new Date(Me.last_sign_in_at).toLocaleString()]}),e.jsxs("div",{children:["Created: ",new Date(Me.created_at).toLocaleString()]})]})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:Ca,children:"Cancel"}),e.jsx(K,{onClick:Qg,children:"Save Changes"})]})]})}),e.jsxs(js,{value:"access",children:[d.length===0?e.jsx(Pe,{children:e.jsxs(Re,{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(Pe,{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(Ot,{children:"Member Access Matrix"}),e.jsx(hr,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search agents by name or email...",value:O,onChange:kt=>{V(kt.target.value),$(1)},className:"pl-9"})]})]}),e.jsxs(Re,{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(kt=>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:kt.icon}),e.jsx("span",{className:"text-sm",children:kt.name})]})},kt.id))]})}),e.jsxs("tbody",{children:[Hd.map(kt=>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:kt.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:kt.email})]})}),d.map(Ds=>{const nr=zi(kt.tags,Ds.required_tags),Jr=`${kt.id}-${Ds.id}`,pn=ve===Jr;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:pn?e.jsx(_s,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx(Er,{checked:nr,onCheckedChange:()=>Yi(kt.id,Ds,nr),disabled:Ds.required_tags.length===0})})},Ds.id)})]},kt.id)),Hd.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"})})]})]})}),Cd>1&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",Bx+1,"-",Math.min(Cp,Sf)," of ",Sf," • Page ",q," of ",Cd]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>$(kt=>Math.max(1,kt-1)),disabled:q===1,children:e.jsx(xl,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>$(kt=>Math.min(Cd,kt+1)),disabled:q===Cd,children:e.jsx(Sa,{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(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search brokerages...",value:jn,onChange:kt=>ni(kt.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[p.filter(kt=>kt.name.toLowerCase().includes(jn.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 kt=[];for(const xa of p){const Ai=y[xa.id]??[];for(const kc of Ai){const Bm=l.find(Zh=>Zh.id===kc);if(Bm){const Zh=(Bm.name||"").trim().split(/\s+/),D0=Zh[0]||"",Ea=Zh.slice(1).join(" ")||"";kt.push({firstName:D0,lastName:Ea,email:Bm.email,brokerageName:xa.name})}}}if(kt.length===0){o({title:"No managers found to export"});return}const nr=[["First Name","Last Name","Email","Brokerage Name"].join(","),...kt.map(xa=>[xa.firstName,xa.lastName,xa.email,xa.brokerageName].map(Ai=>`"${(Ai||"").replace(/"/g,'""')}"`).join(","))].join(` `),Jr=new Blob([nr],{type:"text/csv"}),pn=URL.createObjectURL(Jr),oa=document.createElement("a");oa.href=pn,oa.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,oa.click(),URL.revokeObjectURL(pn),o({title:`Exported ${kt.length} managers`})},children:[e.jsx(Xa,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(fs,{open:fe,onOpenChange:Ve,children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(pa,{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(Ir,{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(xe,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(De,{id:"brokerage-name",placeholder:"Enter brokerage name",value:Je,onChange:kt=>at(kt.target.value),maxLength:100})]})}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>Ve(!1),children:"Cancel"}),e.jsx(K,{onClick:ua,disabled:Ae,children:Ae?"Creating...":"Create Brokerage"})]})]})]})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:(()=>{const kt=p.filter(Ds=>Ds.name.toLowerCase().includes(jn.toLowerCase()));return kt.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:jn?"No brokerages match your search":"No brokerages found"})}):kt.map(Ds=>{const nr=l.filter(xa=>xa.brokerage_id===Ds.id),pn=(y[Ds.id]??[]).map(xa=>l.find(Ai=>Ai.id===xa)).filter(Boolean),oa=nr.length;return e.jsxs(Ms,{className:"hover:bg-muted/30",children:[e.jsx(ut,{children:e.jsx("button",{onClick:()=>Jo(Ds),className:"text-primary hover:underline font-medium",children:Ds.name})}),e.jsx(ut,{children:pn.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:pn.map(xa=>e.jsx(Qe,{variant:"secondary",className:"text-xs",children:xa.name},xa.id))}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"No manager"})}),e.jsxs(ut,{children:[oa," member",oa!==1?"s":""]}),e.jsx(ut,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"h-8",onClick:()=>Nd(Ds),children:[e.jsx(lr,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Jo(Ds),title:"Edit brokerage",children:e.jsx(ga,{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:()=>bu(Ds),title:"Delete brokerage",children:e.jsx(gr,{className:"h-4 w-4"})})]})})]},Ds.id)})})()})]})}),e.jsx(fs,{open:We,onOpenChange:ot,children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Edit Brokerage"}),e.jsx(Ir,{children:"Update brokerage details and manage managers"})]}),Ge&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"edit-brokerage-name",children:"Brokerage Name"}),e.jsx(De,{id:"edit-brokerage-name",value:ht,onChange:kt=>xt(kt.target.value),maxLength:100})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{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 Ds=(y[Ge.id]??[]).map(nr=>l.find(Jr=>Jr.id===nr)).filter(Boolean);return Ds.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):Ds.map(nr=>e.jsxs(Qe,{variant:"default",className:"gap-1",children:[e.jsx(Ou,{className:"h-3 w-3"}),nr.name,e.jsx("button",{onClick:()=>di(nr.id,"brokerage_manager","remove",Ge.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(xe,{className:"text-sm text-muted-foreground",children:"Assign manager from existing members:"}),e.jsxs(xo,{open:rs,onOpenChange:Bn,children:[e.jsx(go,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":rs,className:"w-full justify-between",children:["Search for a member...",e.jsx(an,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(lo,{className:"w-full p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search by name or email..."}),e.jsxs(Mx,{className:"max-h-[200px]",children:[e.jsx(Tx,{children:"No members found."}),e.jsx(Ax,{children:(()=>{const kt=new Set(y[Ge.id]??[]);return l.filter(Ds=>!kt.has(Ds.id)&&(r||Ds.brokerage_id===Ge.id)).map(Ds=>e.jsxs(lp,{value:`${Ds.name} ${Ds.email}`,onSelect:()=>{_u(Ds.id,Ge.id),Bn(!1)},children:[Ds.name," (",Ds.email,")"]},Ds.id))})()})]})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Members in this Brokerage"}),e.jsx("div",{className:"max-h-32 overflow-y-auto border rounded p-2",children:l.filter(kt=>kt.brokerage_id===Ge.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(kt=>kt.brokerage_id===Ge.id).map(kt=>e.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[e.jsx("span",{children:kt.name}),kt.roles.includes("brokerage_manager")&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Manager"})]},kt.id))})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:sc,children:"Cancel"}),e.jsx(K,{onClick:rc,disabled:Ke,children:Ke?"Saving...":"Save Changes"})]})]})}),e.jsx(fs,{open:Et,onOpenChange:$t,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Ir,{children:['Are you sure you want to delete "',Yt==null?void 0:Yt.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 "',Yt==null?void 0:Yt.name,'"']}),e.jsxs("li",{children:["All ",l.filter(kt=>kt.brokerage_id===(Yt==null?void 0:Yt.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>$t(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Om,disabled:zs,children:zs?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(fs,{open:Dr,onOpenChange:zt,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(pa,{className:"h-5 w-5"}),"Manage ",$s==null?void 0:$s.name]}),e.jsx(Ir,{children:"Add, remove, or manage users in this brokerage"})]}),$s&&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(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search members...",value:Xs,onChange:kt=>ir(kt.target.value),className:"pl-10 h-9"})]}),e.jsxs(fs,{open:Or,onOpenChange:Vn,children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(al,{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(Ir,{children:["Create a new agent for ",$s.name]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"agent-name",children:"Name"}),e.jsx(De,{id:"agent-name",placeholder:"John Doe",value:Qr.name,onChange:kt=>Gr({...Qr,name:kt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"agent-email",children:"Email"}),e.jsx(De,{id:"agent-email",type:"email",placeholder:"john@example.com",value:Qr.email,onChange:kt=>Gr({...Qr,email:kt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"agent-password",children:"Password"}),e.jsx(De,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:Qr.password,onChange:kt=>Gr({...Qr,password:kt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(De,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:Qr.phone,onChange:kt=>Gr({...Qr,phone:kt.target.value})})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>Vn(!1),children:"Cancel"}),e.jsx(K,{onClick:zm,disabled:tr,children:tr?"Creating...":"Create Agent"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Add existing user:"}),e.jsxs(xo,{open:mn,onOpenChange:Fr,children:[e.jsx(go,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":mn,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(an,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(lo,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search users...",value:Kt,onValueChange:jr}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:"No users found."}),e.jsx(Ax,{children:P0($s.id).filter(kt=>Kt===""||kt.name.toLowerCase().includes(Kt.toLowerCase())||kt.email.toLowerCase().includes(Kt.toLowerCase())).map(kt=>e.jsxs(lp,{value:`${kt.name} ${kt.email}`,onSelect:()=>{Hu(kt.id,$s.id),Fr(!1),jr("")},children:[kt.name," (",kt.email,")"]},kt.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:Sd($s.id).length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:Xs?"No matching members found":"No members in this brokerage"})}):Sd($s.id).map(kt=>e.jsxs(Ms,{className:"hover:bg-muted/30",children:[e.jsx(ut,{className:"font-medium",children:kt.name}),e.jsx(ut,{className:"text-muted-foreground",children:kt.email}),e.jsx(ut,{children:kt.claimed?e.jsx(Qe,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(Qe,{variant:"secondary",children:"Pending"})}),e.jsx(ut,{children:kt.roles.includes("brokerage_manager")?e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(Ou,{className:"h-3 w-3"}),"Manager"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Agent"})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[!kt.claimed&&e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Zi(kt.id),title:"Resend welcome email",children:e.jsx(rr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Fm(kt.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:()=>Tf(kt.id),disabled:a||kt.id===(s==null?void 0:s.id),title:kt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${kt.name}`,children:a?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(rS,{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(kt.id,kt.name),title:"Delete user",children:e.jsx(gr,{className:"h-4 w-4"})})]})})]},kt.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[kd($s.id).length," total member",kd($s.id).length!==1?"s":""," •",kd($s.id).filter(kt=>kt.roles.includes("brokerage_manager")).length," manager",kd($s.id).filter(kt=>kt.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(En,{children:e.jsx(K,{variant:"outline",onClick:wu,children:"Close"})})]})})]}),e.jsx(js,{value:"teams",children:e.jsx(rVt,{})}),e.jsx(js,{value:"trials",children:e.jsx(JUt,{})}),e.jsx(js,{value:"celebrations",children:e.jsx(QUt,{})}),e.jsx(js,{value:"deletions",children:e.jsx(eVt,{})})]})]}),e.jsx(rtt,{open:cn,onOpenChange:rn,brokerages:p,onSuccess:da}),Vt&&e.jsx(ntt,{open:Mt,onOpenChange:kt=>{Ht(kt),kt||Xt(null)},userId:Vt.id,userName:Vt.name})]})},aVt=()=>{const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,x]=S.useState(""),[y,_]=S.useState("");S.useEffect(()=>{b()},[]);const b=async()=>{const{data:I,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(I||[]),n(!1)},N=async I=>{if(I.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(""),x(""),_(""),b()),o(!1)},w=async(I,O)=>{const{error:V}=await G.from("invite_codes").update({is_active:!O}).eq("id",I);V?me.error("Failed to update code"):s(t.map(q=>q.id===I?{...q,is_active:!O}:q))},k=async I=>{const{error:O}=await G.from("invite_codes").delete().eq("id",I);O?me.error("Failed to delete code"):(me.success("Code deleted"),s(t.filter(V=>V.id!==I)))},C="https://dashboard.relevelup.com",E=I=>{const O=`${C}/join?code=${I}`;navigator.clipboard.writeText(O),me.success("Link copied to clipboard")},L=`${C}/join`;return e.jsx(Es,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"Create New Code"}),e.jsxs(hr,{children:["Share link: ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:L})]})]}),e.jsx(Re,{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(xe,{htmlFor:"code",children:"Code"}),e.jsx(De,{id:"code",placeholder:"WELCOME2024",value:l,onChange:I=>i(I.target.value),className:"w-40"})]}),e.jsxs("div",{className:"space-y-2 flex-1 min-w-[200px]",children:[e.jsx(xe,{htmlFor:"description",children:"Description (optional)"}),e.jsx(De,{id:"description",placeholder:"For marketing campaign",value:d,onChange:I=>u(I.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"maxUses",children:"Max Uses"}),e.jsx(De,{id:"maxUses",type:"number",placeholder:"Unlimited",value:p,onChange:I=>x(I.target.value),className:"w-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"trialDays",children:"Trial Days"}),e.jsx(De,{id:"trialDays",type:"number",placeholder:"None",value:y,onChange:I=>_(I.target.value),className:"w-28"})]}),e.jsxs(K,{type:"submit",disabled:a,children:[a?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Active Codes"})}),e.jsx(Re,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(_s,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:t.map(I=>e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-mono font-medium",children:I.code}),e.jsx(ut,{className:"text-muted-foreground",children:I.description||"—"}),e.jsxs(ut,{children:[I.uses_count,I.max_uses&&` / ${I.max_uses}`]}),e.jsx(ut,{children:I.trial_days?e.jsxs("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:[I.trial_days," days"]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ut,{className:"text-muted-foreground",children:ps(new Date(I.created_at),"MMM d, yyyy")}),e.jsx(ut,{children:e.jsx(Er,{checked:I.is_active,onCheckedChange:()=>w(I.id,I.is_active)})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>E(I.code),title:"Copy invite link",children:e.jsx(Ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>k(I.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(gr,{className:"h-4 w-4"})})]})})]},I.id))})]})})]})]})})},JR=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}},tE=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}}},iVt=async(t,s)=>await JR("new_templates")?tE({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}),oVt=async(t,s)=>tE({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),lVt=async(t,s)=>await JR("new_events")?tE({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),cVt=async(t,s)=>await JR("new_toolbox")?tE({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),H_e=async(t,s)=>await JR("new_social_swag")?tE({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}),dVt=async(t,s)=>await JR("new_newsletters")?tE({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),Zz={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 uVt(){const t=_r(),s=Jt(),[r,n]=S.useState(!1),[a,o]=S.useState(null),[l,i]=S.useState(Zz),[d,u]=S.useState(null),[p,x]=S.useState(null),[y,_]=S.useState(!1),b=S.useRef(null),[N,w]=S.useState(!1),[k,C]=S.useState(null),[E,L]=S.useState(!1),[I,O]=S.useState(null),[V,q]=S.useState(null),[$,U]=S.useState(!0),[se,Y]=S.useState(""),{data:J,isLoading:X}=gt({queryKey:["admin-events"],queryFn:async()=>{const{data:Ae,error:Ye}=await G.from("events").select("*").order("event_date",{ascending:!0});if(Ye)throw Ye;return Ae}}),{data:ce}=gt({queryKey:["event-registrations-count"],queryFn:async()=>{let Ae=[],Ye=0;const We=1e3;for(;;){const{data:Ge,error:et}=await G.from("event_registrations").select("event_id").range(Ye,Ye+We-1);if(et)throw et;if(!Ge||Ge.length===0||(Ae=Ae.concat(Ge),Ge.length{ot[Ge.event_id]=(ot[Ge.event_id]||0)+1}),ot}}),{data:ie,isLoading:ae}=gt({queryKey:["event-registrations-details",k==null?void 0:k.id],queryFn:async()=>{if(!k)return[];const{data:Ae,error:Ye}=await G.from("event_registrations").select("id, user_id, registered_at, zoom_join_url, zoom_name, zoom_email").eq("event_id",k.id).order("registered_at",{ascending:!1});if(Ye)throw Ye;if(!Ae||Ae.length===0)return[];const We=Ae.map(et=>et.user_id).filter(Boolean);let ot=[];if(We.length>0){const{data:et,error:ht}=await G.from("profiles").select("id, name, email").in("id",We);if(ht)throw ht;ot=et||[]}const Ge=new Map((ot==null?void 0:ot.map(et=>[et.id,et]))||[]);return Ae.map(et=>({...et,profiles:et.user_id&&Ge.get(et.user_id)||null}))},enabled:!!k}),{data:oe,isLoading:pe}=gt({queryKey:["event-attendees-details",k==null?void 0:k.id],queryFn:async()=>{if(!k)return[];const{data:Ae,error:Ye}=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",k.id).order("created_at",{ascending:!1});if(Ye)throw Ye;if(!Ae||Ae.length===0)return[];const We=Ae.map(xt=>xt.user_id).filter(Boolean);let ot=[];if(We.length>0){const{data:xt,error:Ke}=await G.from("profiles").select("id, name, email").in("id",We);if(Ke)throw Ke;ot=xt||[]}const{data:Ge}=await G.from("agent_points").select("user_id").eq("event_id",k.id),et=new Set((Ge==null?void 0:Ge.map(xt=>xt.user_id))||[]),ht=new Map((ot==null?void 0:ot.map(xt=>[xt.id,xt]))||[]);return Ae.map(xt=>({...xt,profiles:xt.user_id&&ht.get(xt.user_id)||null,points_awarded:xt.user_id?et.has(xt.user_id):!1}))},enabled:!!k}),_e=Ae=>{C(Ae),w(!0)},he=It({mutationFn:async Ae=>{const{data:{session:Ye}}=await G.auth.getSession();if(!Ye)throw new Error("Not authenticated");const We=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ye.access_token}`},body:JSON.stringify({event_id:Ae})}),ot=await We.json();if(!We.ok)throw new Error(ot.error||"Failed to sync");return ot},onSuccess:Ae=>{s.invalidateQueries({queryKey:["event-registrations-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),me.success(Ae.message)},onError:Ae=>{me.error("Failed to sync: "+Ae.message)}}),we=It({mutationFn:async Ae=>{const{data:{session:Ye}}=await G.auth.getSession();if(!Ye)throw new Error("Not authenticated");const We=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ye.access_token}`},body:JSON.stringify({event_id:Ae})}),ot=await We.json();if(!We.ok)throw new Error(ot.error||"Failed to sync attendees");return ot},onSuccess:Ae=>{s.invalidateQueries({queryKey:["event-attendees-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),Ae!=null&&Ae.message?me.success(Ae.message):me.success(`Synced ${Ae.synced||0} attendees. ${Ae.points_awarded||0} points awarded!`)},onError:Ae=>{me.error("Failed to sync attendees: "+Ae.message)}}),je=It({mutationFn:async({eventId:Ae,testMode:Ye})=>{const{data:{session:We}}=await G.auth.getSession();if(!We)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 ${We.access_token}`},body:JSON.stringify({event_id:Ae,test_mode:Ye})}),Ge=await ot.json();if(!ot.ok)throw new Error(Ge.error||"Failed to send reminders");return Ge},onSuccess:Ae=>{Ae.test?me.success(Ae.message||"Test email sent!"):me.success(Ae.message||`Reminder emails sent to ${Ae.sent} registrants!`)},onError:Ae=>{me.error("Failed to send reminders: "+Ae.message)}}),{data:Ue}=gt({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let Ae=[],Ye=0;const We=1e3;for(;;){const{data:ot,error:Ge}=await G.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(Ye,Ye+We-1);if(Ge)throw Ge;if(!ot||ot.length===0||(Ae=[...Ae,...ot],ot.length{const{error:Ge}=await G.from("event_attendees").update({user_id:Ye}).eq("id",Ae);if(Ge)throw Ge;if(ot&&We){const{error:ht}=await G.from("zoom_email_aliases").upsert({user_id:Ye,zoom_email:We.toLowerCase()},{onConflict:"zoom_email"});ht&&console.error("Failed to save alias:",ht)}const et=k==null?void 0:k.id;if(et){const{data:ht}=await G.from("user_roles").select("id").eq("user_id",Ye).eq("role","admin").single();if(!ht){const{data:xt}=await G.from("agent_points").select("id").eq("user_id",Ye).eq("event_id",et).single();xt||(await G.rpc("award_attendance_points",{p_user_id:Ye,p_event_id:et,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await G.rpc("check_and_award_badges",{p_user_id:Ye}))}}return{userId:Ye,zoomEmail:We,shouldSaveAlias:ot}},onSuccess:Ae=>{s.invalidateQueries({queryKey:["event-attendees-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let Ye="Attendee linked and points awarded!";Ae.shouldSaveAlias&&Ae.zoomEmail&&(Ye+=` Email "${Ae.zoomEmail}" will be auto-matched in the future.`),me.success(Ye),L(!1),O(null),q(null),Y("")},onError:Ae=>{me.error("Failed to link attendee: "+Ae.message)}}),Me=Ae=>{O(Ae),q(null),U(!0),Y(""),L(!0)},Fe=()=>{!I||!V||Te.mutate({attendeeId:I.id,userId:V,zoomEmail:I.zoom_email,shouldSaveAlias:$})},Le=(Ue==null?void 0:Ue.filter(Ae=>{var We,ot;if(!se)return!0;const Ye=se.toLowerCase();return((We=Ae.name)==null?void 0:We.toLowerCase().includes(Ye))||((ot=Ae.email)==null?void 0:ot.toLowerCase().includes(Ye))}))||[],Ne=async Ae=>{const Ye=Ae.name.split(".").pop(),ot=`${`${crypto.randomUUID()}.${Ye}`}`,{error:Ge}=await G.storage.from("event-images").upload(ot,Ae);if(Ge)throw Ge;const{data:{publicUrl:et}}=G.storage.from("event-images").getPublicUrl(ot);return et},qe=Ae=>{var We;const Ye=(We=Ae.target.files)==null?void 0:We[0];if(Ye){if(Ye.size>5*1024*1024){me.error("Image must be less than 5MB");return}u(Ye),x(URL.createObjectURL(Ye))}},ze=()=>{u(null),x(null),i({...l,image_url:""}),b.current&&(b.current.value="")},ve=It({mutationFn:async Ae=>{_(!0);let Ye=Ae.image_url;d&&(Ye=await Ne(d)||"");const We=new Date(Ae.event_date),[ot,Ge]=Ae.event_time.split(":");We.setHours(parseInt(ot),parseInt(Ge));const et=[new Date(We)];if(Ae.is_recurring&&Ae.recurrence_end_date){let Ze=new Date(We);for(;Ae.recurrence_pattern==="weekly"?Ze=h4(Ze,1):Ae.recurrence_pattern==="biweekly"?Ze=h4(Ze,2):Ze=Am(Ze,1),!(Ze>Ae.recurrence_end_date);)et.push(new Date(Ze))}const ht=et.map(Ze=>({title:Ae.title,description:Ae.description||null,image_url:Ye||null,video_url:Ae.video_url||null,event_date:Ze.toISOString(),zoom_link:Ae.zoom_link,zoom_meeting_id:Ae.zoom_meeting_id||null,capacity:Ae.capacity?parseInt(Ae.capacity):null,is_published:Ae.is_published})),{data:xt,error:Ke}=await G.from("events").insert(ht).select();if(Ke)throw Ke;return xt&&xt.length>0&&lVt(Ae.title,xt[0].id),et.length},onSuccess:Ae=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success(Ae>1?`${Ae} recurring events created successfully`:"Event created successfully"),n(!1),i(Zz),u(null),x(null),_(!1)},onError:Ae=>{me.error("Failed to create event: "+Ae.message),_(!1)}}),dt=It({mutationFn:async({id:Ae,data:Ye})=>{_(!0);let We=Ye.image_url;d&&(We=await Ne(d)||"");const ot=new Date(Ye.event_date),[Ge,et]=Ye.event_time.split(":");ot.setHours(parseInt(Ge),parseInt(et));const{error:ht}=await G.from("events").update({title:Ye.title,description:Ye.description||null,image_url:We||null,video_url:Ye.video_url||null,event_date:ot.toISOString(),zoom_link:Ye.zoom_link,zoom_meeting_id:Ye.zoom_meeting_id||null,capacity:Ye.capacity?parseInt(Ye.capacity):null,is_published:Ye.is_published}).eq("id",Ae);if(ht)throw ht},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event updated successfully"),n(!1),o(null),i(Zz),u(null),x(null),_(!1)},onError:Ae=>{me.error("Failed to update event: "+Ae.message),_(!1)}}),fe=It({mutationFn:async Ae=>{const{error:Ye}=await G.from("events").delete().eq("id",Ae);if(Ye)throw Ye},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event deleted successfully")},onError:Ae=>{me.error("Failed to delete event: "+Ae.message)}}),Ve=Ae=>{var We;const Ye=new Date(Ae.event_date);o(Ae),i({title:Ae.title,description:Ae.description||"",image_url:Ae.image_url||"",video_url:Ae.video_url||"",event_date:Ye,event_time:ps(Ye,"HH:mm"),zoom_link:Ae.zoom_link,zoom_meeting_id:Ae.zoom_meeting_id||"",capacity:((We=Ae.capacity)==null?void 0:We.toString())||"",is_published:Ae.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),x(Ae.image_url||null),u(null),n(!0)},Je=Ae=>{if(Ae.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?dt.mutate({id:a.id,data:l}):ve.mutate(l)},at=()=>{n(!1),o(null),i(Zz),u(null),x(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(Fa,{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(Pe,{className:"mb-6",children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{children:"All Events"}),e.jsxs(fs,{open:r,onOpenChange:Ae=>!Ae&&at(),children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Us,{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:Je,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{id:"title",value:l.title,onChange:Ae=>i({...l,title:Ae.target.value}),placeholder:"Event title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Gg,{content:l.description,onChange:Ae=>i({...l,description:Ae}),placeholder:"Event description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Event Image"}),e.jsx("input",{type:"file",ref:b,accept:"image/*",onChange:qe,className:"hidden"}),p?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:p,alt:"Event preview",className:"w-full h-32 object-cover rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:ze,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 Ae;return(Ae=b.current)==null?void 0:Ae.click()},children:[e.jsx($a,{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(xe,{children:"Date *"}),e.jsxs(xo,{children:[e.jsx(go,{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(on,{className:"mr-2 h-4 w-4"}),l.event_date?ps(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(lo,{className:"w-auto p-0",align:"start",children:e.jsx(df,{mode:"single",selected:l.event_date,onSelect:Ae=>i({...l,event_date:Ae}),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"time",children:"Time *"}),e.jsx(De,{id:"time",type:"time",value:l.event_time,onChange:Ae=>i({...l,event_time:Ae.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(De,{id:"zoom_link",value:l.zoom_link,onChange:Ae=>i({...l,zoom_link:Ae.target.value}),placeholder:"https://zoom.us/j/...",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"zoom_meeting_id",children:"Zoom Meeting ID (for API registration)"}),e.jsx(De,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:Ae=>i({...l,zoom_meeting_id:Ae.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(xe,{htmlFor:"video_url",children:"Promo Video URL (optional)"}),e.jsx(De,{id:"video_url",value:l.video_url,onChange:Ae=>i({...l,video_url:Ae.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(xe,{htmlFor:"capacity",children:"Capacity (optional)"}),e.jsx(De,{id:"capacity",type:"number",value:l.capacity,onChange:Ae=>i({...l,capacity:Ae.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(ML,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{htmlFor:"is_recurring",children:"Recurring Event"})]}),e.jsx(Er,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:Ae=>i({...l,is_recurring:Ae})})]}),l.is_recurring&&e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Frequency"}),e.jsxs(Bs,{value:l.recurrence_pattern,onValueChange:Ae=>i({...l,recurrence_pattern:Ae}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"weekly",children:"Weekly"}),e.jsx(vt,{value:"biweekly",children:"Every 2 Weeks"}),e.jsx(vt,{value:"monthly",children:"Monthly"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Repeat Until"}),e.jsxs(xo,{children:[e.jsx(go,{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(on,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?ps(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(lo,{className:"w-auto p-0",align:"start",children:e.jsx(df,{mode:"single",selected:l.recurrence_end_date,onSelect:Ae=>i({...l,recurrence_end_date:Ae}),disabled:Ae=>Ae<(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 Ae=1,Ye=new Date(l.event_date);for(;Ye=l.recurrence_pattern==="weekly"?h4(Ye,1):l.recurrence_pattern==="biweekly"?h4(Ye,2):Am(Ye,1),!(Ye>l.recurrence_end_date);)Ae++;return Ae})()," events with the same Zoom link"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{htmlFor:"is_published",children:"Published"}),e.jsx(Er,{id:"is_published",checked:l.is_published,onCheckedChange:Ae=>i({...l,is_published:Ae})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:at,className:"flex-1",children:"Cancel"}),e.jsx(K,{type:"submit",className:"flex-1",disabled:ve.isPending||dt.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(Re,{children:X?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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:J==null?void 0:J.map(Ae=>e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:Ae.title}),e.jsx(ut,{children:ps(new Date(Ae.event_date),"PPP p")}),e.jsx(ut,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>_e(Ae),children:[e.jsx(lr,{className:"h-4 w-4"}),(ce==null?void 0:ce[Ae.id])||0,Ae.capacity&&` / ${Ae.capacity}`]})}),e.jsx(ut,{children:e.jsx("span",{className:Rt("px-2 py-1 rounded-full text-xs font-medium",Ae.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:Ae.is_published?"Published":"Draft"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(Ae.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(Kr,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ve(Ae),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&fe.mutate(Ae.id)},children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]})})]},Ae.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(lr,{className:"h-5 w-5"}),k==null?void 0:k.title]}),e.jsx(Ir,{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:()=>je.mutate({eventId:k.id,testMode:!0}),disabled:je.isPending,children:[e.jsx(rr,{className:Rt("h-4 w-4 mr-2",je.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>je.mutate({eventId:k.id}),disabled:je.isPending||!(ie!=null&&ie.length),children:[e.jsx(rr,{className:Rt("h-4 w-4 mr-2",je.isPending&&"animate-spin")}),je.isPending?"Sending...":"Send Reminder to All"]}),(k==null?void 0:k.zoom_meeting_id)&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>he.mutate(k.id),disabled:he.isPending,children:[e.jsx(oo,{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(k.id),disabled:we.isPending,children:[e.jsx(Vi,{className:Rt("h-4 w-4 mr-2",we.isPending&&"animate-spin")}),we.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(ia,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(ea,{className:"grid w-full grid-cols-2",children:[e.jsxs(ls,{value:"registrations",className:"gap-2",children:[e.jsx(lr,{className:"h-4 w-4"}),"Registrations (",(ie==null?void 0:ie.length)||0,")"]}),e.jsxs(ls,{value:"attendees",className:"gap-2",children:[e.jsx(Qn,{className:"h-4 w-4"}),"Attendees (",(oe==null?void 0:oe.length)||0,")"]})]}),e.jsx(js,{value:"registrations",className:"mt-4",children:ae?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading registrations..."}):(ie==null?void 0:ie.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No registrations yet for this event."}),(k==null?void 0:k.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Registrations" to import from Zoom.'})]}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Email"}),e.jsx(Nt,{children:"Registered"}),e.jsx(Nt,{children:"Status"})]})}),e.jsx(Dn,{children:ie==null?void 0:ie.map(Ae=>{var Ge,et;const Ye=((Ge=Ae.profiles)==null?void 0:Ge.name)||Ae.zoom_name||"Unknown",We=((et=Ae.profiles)==null?void 0:et.email)||Ae.zoom_email||null,ot=!Ae.user_id;return e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Ye,ot&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(ut,{children:We?e.jsxs("a",{href:`mailto:${We}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(rr,{className:"h-3 w-3"}),We]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(ut,{className:"text-muted-foreground text-sm",children:ps(new Date(Ae.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(ut,{children:Ae.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"})})]},Ae.id)})})]})}),e.jsx(js,{value:"attendees",className:"mt-4",children:pe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading attendees..."}):(oe==null?void 0:oe.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No attendees recorded yet."}),(k==null?void 0:k.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Attendees & Award Points" after the event ends to import actual participants from Zoom.'})]}):e.jsxs(e.Fragment,{children:[(oe==null?void 0:oe.filter(Ae=>!Ae.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(Lo,{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 (",oe==null?void 0:oe.filter(Ae=>!Ae.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:oe==null?void 0:oe.filter(Ae=>!Ae.user_id).map(Ae=>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:Ae.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Ae.zoom_email||"No email"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Me(Ae),className:"gap-1",children:[e.jsx(Do,{className:"h-3 w-3"}),"Link to Profile"]})]},Ae.id))})]}),e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Nt,{children:"Name"}),e.jsx(Nt,{children:"Email"}),e.jsx(Nt,{children:"Duration"}),e.jsx(Nt,{children:"Points"})]})}),e.jsx(Dn,{children:oe==null?void 0:oe.filter(Ae=>Ae.user_id).map(Ae=>{var ot,Ge;const Ye=((ot=Ae.profiles)==null?void 0:ot.name)||Ae.zoom_name||"Unknown",We=((Ge=Ae.profiles)==null?void 0:Ge.email)||Ae.zoom_email||null;return e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Ye,Ae.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(ut,{children:We?e.jsxs("a",{href:`mailto:${We}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(rr,{className:"h-3 w-3"}),We]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(ut,{children:Ae.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(ln,{className:"h-3 w-3"}),Ae.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ut,{children:Ae.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(Vi,{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"})})]},Ae.id)})})]})]})})]})]})}),e.jsx(fs,{open:E,onOpenChange:L,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(Ir,{children:"Link this Zoom attendee to an existing member profile to award them points."})]}),I&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm font-medium",children:I.zoom_name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:I.zoom_email||"No email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Search for a profile"}),e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or email...",value:se,onChange:Ae=>Y(Ae.target.value),className:"pl-9"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:Le.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:Le.slice(0,20).map(Ae=>e.jsxs("button",{type:"button",onClick:()=>q(Ae.id),className:Rt("w-full p-3 text-left hover:bg-muted/50 transition-colors",V===Ae.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:Ae.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ae.email})]},Ae.id))})}),I.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ki,{id:"save-alias",checked:$,onCheckedChange:Ae=>U(Ae)}),e.jsx("label",{htmlFor:"save-alias",className:"text-sm text-muted-foreground cursor-pointer",children:"Remember this email for future auto-matching"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsx(K,{onClick:Fe,disabled:!V||Te.isPending,children:Te.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function hVt({selectedKitIds:t,onChange:s}){const[r,n]=S.useState(""),[a,o]=S.useState(!1),{data:l=[]}=gt({queryKey:["all-resource-kits-picker"],queryFn:async()=>{const{data:x,error:y}=await G.from("resource_kits").select("id, name, featured_image_url").eq("is_published",!0).order("name");if(y)throw y;return x}}),i=l.filter(x=>t.includes(x.id)),d=l.filter(x=>!t.includes(x.id)&&x.name.toLowerCase().includes(r.toLowerCase())),u=x=>{s([...t,x])},p=x=>{s(t.filter(y=>y!==x))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(nl,{className:"h-4 w-4"}),"Linked Toolkits"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(x=>e.jsxs(Qe,{variant:"secondary",className:"gap-1 pr-1",children:[x.name,e.jsx("button",{type:"button",onClick:()=>p(x.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Sr,{className:"h-3 w-3"})})]},x.id))}),e.jsxs(xo,{open:a,onOpenChange:o,children:[e.jsx(go,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(nl,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs(lo,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(an,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{placeholder:"Search toolkits...",value:r,onChange:x=>n(x.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(x=>e.jsxs("button",{type:"button",onClick:()=>{u(x.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:[x.featured_image_url?e.jsx("img",{src:x.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(nl,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:x.name})]},x.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link toolkits that agents can download alongside this template."})]})}const mVt=()=>{const{user:t}=Fs(),{toast:s}=wa(),r=Jt(),[n,a]=Nc(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),[x,y]=S.useState(null),[_,b]=S.useState(0),[N,w]=S.useState(!1),[k,C]=S.useState(null),[E,L]=S.useState(""),[I,O]=S.useState([]),[V,q]=S.useState(""),[$,U]=S.useState(""),[se,Y]=S.useState(!1),[J,X]=S.useState(!1),{data:ce=[]}=gt({queryKey:["template-categories"],queryFn:async()=>{const{data:Ve,error:Je}=await G.from("template_categories").select("*").order("name");if(Je)throw Je;return Ve}}),{data:ie=[]}=gt({queryKey:["template-types"],queryFn:async()=>{const{data:Ve,error:Je}=await G.from("template_types").select("*").order("name");if(Je)throw Je;return Ve}}),{data:ae=[],isLoading:oe}=gt({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:Ve,error:Je}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(Je)throw Je;const{data:at,error:Ae}=await G.from("template_links").select("*").order("sort_order");if(Ae)throw Ae;const{data:Ye,error:We}=await G.from("template_guides").select("*").order("sort_order");if(We)throw We;return Ve.map(Ge=>({...Ge,links:(at==null?void 0:at.filter(et=>et.template_id===Ge.id))||[],guides:(Ye==null?void 0:Ye.filter(et=>et.template_id===Ge.id))||[]}))}});S.useEffect(()=>{const Ve=n.get("edit");if(Ve&&ae.length>0){const Je=ae.find(at=>at.id===Ve);Je&&(Ue(Je),a({},{replace:!0}))}},[ae,n]);const pe=It({mutationFn:async Ve=>{const{data:Je,error:at}=await G.from("template_categories").insert({name:Ve}).select().single();if(at)throw at;return Je},onSuccess:Ve=>{r.invalidateQueries({queryKey:["template-categories"]}),p({...u,category_id:Ve.id}),q(""),Y(!1),s({title:"Category added"})},onError:Ve=>{s({title:"Error adding category",description:Ve.message,variant:"destructive"})}}),_e=It({mutationFn:async Ve=>{const{data:Je,error:at}=await G.from("template_types").insert({name:Ve}).select().single();if(at)throw at;return Je},onSuccess:Ve=>{r.invalidateQueries({queryKey:["template-types"]}),p({...u,type_id:Ve.id}),U(""),X(!1),s({title:"Type added"})},onError:Ve=>{s({title:"Error adding type",description:Ve.message,variant:"destructive"})}}),he=It({mutationFn:async Ve=>{var We;let Je=Ve.existingImageUrl;if(Ve.image){const ot=Ve.image.name.split(".").pop(),Ge=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ot}`,{error:et}=await G.storage.from("template-previews").upload(Ge,Ve.image);if(et)throw et;const{data:ht}=G.storage.from("template-previews").getPublicUrl(Ge);Je=ht.publicUrl}const at={name:Ve.template.name,description:Ve.template.description||null,category_id:Ve.template.category_id||null,type_id:Ve.template.type_id||null,preview_image_url:Je,video_url:Ve.videoUrl||null,publish_date:Ve.template.publish_date?new Date(Ve.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let Ae=Ve.templateId;if(Ae){const{error:ot}=await G.from("canva_templates").update(at).eq("id",Ae);if(ot)throw ot;const{error:Ge}=await G.from("template_links").delete().eq("template_id",Ae);if(Ge)throw Ge;const et=((We=Ve.existingGuides)==null?void 0:We.map(Ke=>Ke.id).filter(Boolean))||[],ht=Ve.template.guides.map(Ke=>Ke.id).filter(Boolean),xt=et.filter(Ke=>!ht.includes(Ke));xt.length>0&&await G.from("template_guides").delete().in("id",xt)}else{const{data:ot,error:Ge}=await G.from("canva_templates").insert(at).select().single();if(Ge)throw Ge;Ae=ot.id,iVt(Ve.template.name,ot.id)}const Ye=Ve.template.links.filter(ot=>ot.title.trim()&&ot.canva_share_link.trim());if(Ye.length>0){const ot=Ye.map((et,ht)=>({template_id:Ae,title:et.title.trim(),canva_share_link:et.canva_share_link.trim(),sort_order:ht})),{error:Ge}=await G.from("template_links").insert(ot);if(Ge)throw Ge}for(let ot=0;ot0)){const{error:ot}=await G.from("resource_kit_templates").insert(Ve.linkedKitIds.map(Ge=>({template_id:Ae,kit_id:Ge})));if(ot)throw ot}},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),je(),l(!1),s({title:i?"Template updated":"Template created"})},onError:Ve=>{s({title:"Error saving template",description:Ve.message,variant:"destructive"})}}),we=It({mutationFn:async Ve=>{const{error:Je}=await G.from("canva_templates").delete().eq("id",Ve);if(Je)throw Je},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:Ve=>{s({title:"Error deleting template",description:Ve.message,variant:"destructive"})}}),je=()=>{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),L(""),d(null),Y(!1),X(!1),q(""),U(""),y(null),b(0),w(!1),O([])},Ue=async Ve=>{var at;d(Ve),p({name:Ve.name,description:Ve.description||"",category_id:Ve.category_id||"",type_id:Ve.type_id||"",publish_date:Ve.publish_date?new Date(Ve.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:Ve.links&&Ve.links.length>0?Ve.links.map(Ae=>({id:Ae.id,title:Ae.title,canva_share_link:Ae.canva_share_link,sort_order:Ae.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((at=Ve.guides)==null?void 0:at.map(Ae=>({id:Ae.id,name:Ae.name,file_url:Ae.file_url,file_type:Ae.file_type,file_size:Ae.file_size,sort_order:Ae.sort_order})))||[],video_url:Ve.video_url||""}),L(Ve.preview_image_url||""),y(null);const{data:Je}=await G.from("resource_kit_templates").select("kit_id").eq("template_id",Ve.id);O((Je||[]).map(Ae=>Ae.kit_id)),l(!0)},Te=Ve=>{var at;const Je=(at=Ve.target.files)==null?void 0:at[0];Je&&(C(Je),L(URL.createObjectURL(Je)))},Me=()=>{p({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},Fe=Ve=>{if(u.links.length<=1)return;const Je=u.links.filter((at,Ae)=>Ae!==Ve);p({...u,links:Je})},Le=(Ve,Je,at)=>{const Ae=[...u.links];Ae[Ve]={...Ae[Ve],[Je]:at},p({...u,links:Ae})},Ne=Ve=>{const Je=Ve.target.files;if(!Je)return;const at=Array.from(Je).map((Ae,Ye)=>({name:Ae.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:Ae.type,file_size:Ae.size,sort_order:u.guides.length+Ye,file:Ae}));p({...u,guides:[...u.guides,...at]}),Ve.target.value=""},qe=Ve=>{const Je=u.guides.filter((at,Ae)=>Ae!==Ve);p({...u,guides:Je})},ze=(Ve,Je)=>{const at=[...u.guides];at[Ve]={...at[Ve],name:Je},p({...u,guides:at})},ve=async()=>{if(!x)return null;w(!0),b(0);try{const{data:Ve,error:Je}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||x.name}});if(Je)throw new Error(Je.message);const{videoId:at,libraryId:Ae}=Ve,{data:Ye,error:We}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:at}});if(We)throw new Error(We.message);const ot=new XMLHttpRequest;return await new Promise((et,ht)=>{ot.upload.addEventListener("progress",xt=>{if(xt.lengthComputable){const Ke=Math.round(xt.loaded/xt.total*100);b(Ke)}}),ot.addEventListener("load",()=>{ot.status>=200&&ot.status<300?et():ht(new Error(`Upload failed with status ${ot.status}`))}),ot.addEventListener("error",()=>ht(new Error("Upload failed"))),ot.open("PUT",Ye.uploadUrl),ot.setRequestHeader("AccessKey",Ye.apiKey),ot.send(x)}),`https://player.mediadelivery.net/embed/${Ae}/${at}`}catch(Ve){return console.error("Bunny upload error:",Ve),s({title:"Video upload failed",description:Ve instanceof Error?Ve.message:"Unknown error",variant:"destructive"}),null}finally{w(!1)}},dt=Ve=>{var at;const Je=(at=Ve.target.files)==null?void 0:at[0];Je&&y(Je),Ve.target.value=""},fe=async Ve=>{if(Ve.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(Ae=>Ae.title.trim()&&Ae.canva_share_link.trim()).length===0){s({title:"Please add at least one Canva link",variant:"destructive"});return}let at=u.video_url;if(x){const Ae=await ve();if(!Ae)return;at=Ae}he.mutate({template:u,image:k,existingImageUrl:(i==null?void 0:i.preview_image_url)||null,templateId:i==null?void 0:i.id,existingGuides:i==null?void 0:i.guides,videoUrl:at,linkedKitIds:I})};return e.jsx(Es,{title:"Manage Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{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(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:ae.length})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:ce.length})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:ie.length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:Ve=>{l(Ve),Ve||je()},children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Us,{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:fe,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Name *"}),e.jsx(De,{id:"name",value:u.name,onChange:Ve=>p({...u,name:Ve.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Gg,{content:u.description,onChange:Ve=>p({...u,description:Ve}),placeholder:"Brief description of the template",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Canva Links *"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Me,className:"gap-1",children:[e.jsx(Us,{className:"h-3 w-3"}),"Add Link"]})]}),e.jsx("div",{className:"space-y-3",children:u.links.map((Ve,Je)=>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(De,{value:Ve.title,onChange:at=>Le(Je,"title",at.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(De,{value:Ve.canva_share_link,onChange:at=>Le(Je,"canva_share_link",at.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:()=>Fe(Je),children:e.jsx(Sr,{className:"h-4 w-4"})})]},Je))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Category"}),se?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:V,onChange:Ve=>q(Ve.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>V.trim()&&pe.mutate(V.trim()),disabled:pe.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Y(!1),q("")},children:e.jsx(Sr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Bs,{value:u.category_id,onValueChange:Ve=>p({...u,category_id:Ve}),children:[e.jsx(Rs,{className:"flex-1",children:e.jsx(qs,{placeholder:"Select category"})}),e.jsx(Os,{children:ce.map(Ve=>e.jsx(vt,{value:Ve.id,children:Ve.name},Ve.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>Y(!0),children:e.jsx(Us,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Template Type"}),J?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:$,onChange:Ve=>U(Ve.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>$.trim()&&_e.mutate($.trim()),disabled:_e.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{X(!1),U("")},children:e.jsx(Sr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Bs,{value:u.type_id,onValueChange:Ve=>p({...u,type_id:Ve}),children:[e.jsx(Rs,{className:"flex-1",children:e.jsx(qs,{placeholder:"Select type"})}),e.jsx(Os,{children:ie.map(Ve=>e.jsx(vt,{value:Ve.id,children:Ve.name},Ve.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>X(!0),children:e.jsx(Us,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(De,{id:"publish_date",type:"date",value:u.publish_date,onChange:Ve=>p({...u,publish_date:Ve.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Templates are sorted by publish date (newest first) on the member page"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[E?e.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border bg-muted",children:[e.jsx("img",{src:E,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),L("")},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(Wo,{className:"h-8 w-8 text-muted-foreground/50"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(De,{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(xe,{children:"Video (Optional)"}),u.video_url&&!x?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(Tn,{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(_s,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",_,"%"]})]}),e.jsx(gi,{value:_,className:"h-2"})]}):x?e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[e.jsx(Tn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:x.name}),e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(x.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(De,{type:"file",accept:"video/*",onChange:dt,className:"hidden"}),e.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 border-2 border-dashed rounded-lg hover:border-primary/50 transition-colors",children:[e.jsx(Tn,{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(xe,{children:"Guide Files (PDFs)"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(De,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:Ne,className:"hidden"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:e.jsxs("span",{children:[e.jsx($a,{className:"h-3 w-3"}),"Add Files"]})})]})]}),u.guides.length>0?e.jsx("div",{className:"space-y-2",children:u.guides.map((Ve,Je)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(fn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(De,{value:Ve.name,onChange:at=>ze(Je,at.target.value),placeholder:"Guide name",className:"flex-1"}),Ve.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(Ve.file_size/1024).toFixed(0)," KB"]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>qe(Je),children:e.jsx(Sr,{className:"h-4 w-4"})})]},Ve.id||Je))}):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(hVt,{selectedKitIds:I,onChange:O}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{l(!1),je()},children:"Cancel"}),e.jsx(K,{type:"submit",disabled:he.isPending,children:he.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:oe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):ae.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No templates yet. Add your first template!"}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:ae.map(Ve=>{var Je,at,Ae,Ye,We;return e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:Ve.preview_image_url?e.jsx("img",{src:Ve.preview_image_url,alt:Ve.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Wo,{className:"h-4 w-4 text-muted-foreground"})})})}),e.jsx(ut,{className:"font-medium",children:Ve.name}),e.jsx(ut,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(Qe,{variant:"secondary",children:[((Je=Ve.links)==null?void 0:Je.length)||0," link",(((at=Ve.links)==null?void 0:at.length)||0)!==1?"s":""]}),(((Ae=Ve.guides)==null?void 0:Ae.length)||0)>0&&e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(fn,{className:"h-3 w-3"}),(Ye=Ve.guides)==null?void 0:Ye.length," guide",(((We=Ve.guides)==null?void 0:We.length)||0)!==1?"s":""]})]})}),e.jsx(ut,{children:Ve.category?e.jsx(Qe,{variant:"secondary",children:Ve.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ut,{children:Ve.type?e.jsx(Qe,{variant:"outline",children:Ve.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ut,{className:"text-muted-foreground",children:new Date(Ve.publish_date).toLocaleDateString()}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"icon",variant:"ghost",onClick:()=>Ue(Ve),children:e.jsx(ga,{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(Ve.id)},children:e.jsx(gr,{className:"h-4 w-4"})})]})})]},Ve.id)})})]})})})]})})};function dtt({selectedTemplateIds:t,onChange:s}){const[r,n]=S.useState(""),[a,o]=S.useState(!1),{data:l=[]}=gt({queryKey:["all-canva-templates-picker"],queryFn:async()=>{const{data:x,error:y}=await G.from("canva_templates").select("id, name, preview_image_url").order("name");if(y)throw y;return x}}),i=l.filter(x=>t.includes(x.id)),d=l.filter(x=>!t.includes(x.id)&&x.name.toLowerCase().includes(r.toLowerCase())),u=x=>{s([...t,x])},p=x=>{s(t.filter(y=>y!==x))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(sS,{className:"h-4 w-4"}),"Linked Templates"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(x=>e.jsxs(Qe,{variant:"secondary",className:"gap-1 pr-1",children:[x.name,e.jsx("button",{type:"button",onClick:()=>p(x.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Sr,{className:"h-3 w-3"})})]},x.id))}),e.jsxs(xo,{open:a,onOpenChange:o,children:[e.jsx(go,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(sS,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(lo,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(an,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{placeholder:"Search templates...",value:r,onChange:x=>n(x.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(x=>e.jsxs("button",{type:"button",onClick:()=>{u(x.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:[x.preview_image_url?e.jsx("img",{src:x.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(sS,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:x.name})]},x.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link templates that agents can use alongside this content."})]})}const pVt=[{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"}],fVt=()=>{const{user:t}=Fs(),[s,r]=Nc(),{toast:n}=wa(),a=Jt(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[x,y]=S.useState(null),[_,b]=S.useState(""),[N,w]=S.useState([]),[k,C]=S.useState([]),[E,L]=S.useState([]),[I,O]=S.useState([]),[V,q]=S.useState(""),[$,U]=S.useState(!1),[se,Y]=S.useState(null),[J,X]=S.useState(0),[ce,ie]=S.useState(!1),[ae,oe]=S.useState(null),{data:pe=[]}=gt({queryKey:["academy-categories"],queryFn:async()=>{const{data:fe,error:Ve}=await G.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(Ve)throw Ve;return fe}}),{data:_e=[],isLoading:he}=gt({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:fe,error:Ve}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(Ve)throw Ve;const{data:Je,error:at}=await G.from("academy_resources").select("*").order("sort_order");if(at)throw at;return fe.map(Ye=>({...Ye,resources:(Je==null?void 0:Je.filter(We=>We.video_id===Ye.id))||[]}))}});S.useEffect(()=>{const fe=s.get("edit");if(fe&&_e.length>0){const Ve=_e.find(Je=>Je.id===fe);Ve&&(Fe(Ve),r({},{replace:!0}))}},[_e,s]);const we=It({mutationFn:async fe=>{const{data:Ve,error:Je}=await G.from("academy_categories").insert({name:fe,sort_order:pe.length}).select().single();if(Je)throw Je;return Ve},onSuccess:fe=>{a.invalidateQueries({queryKey:["academy-categories"]}),p({...u,category_id:fe.id}),q(""),U(!1),n({title:"Category added"})},onError:fe=>{n({title:"Error adding category",description:fe.message,variant:"destructive"})}}),je=It({mutationFn:async fe=>{let Ve=fe.existingThumbnailUrl;if(fe.thumbnail){const Ae=fe.thumbnail.name.split(".").pop(),Ye=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${Ae}`,{error:We}=await G.storage.from("academy-resources").upload(Ye,fe.thumbnail);if(We)throw We;const{data:ot}=G.storage.from("academy-resources").getPublicUrl(Ye);Ve=ot.publicUrl}const Je={title:fe.video.title,description:fe.video.description||null,video_url:fe.video.video_url,video_type:fe.video.video_type,duration:fe.video.duration||null,thumbnail_url:Ve,category_id:fe.video.category_id||null,publish_date:fe.video.publish_date?new Date(fe.video.publish_date).toISOString():new Date().toISOString(),is_published:fe.video.is_published,created_by:t==null?void 0:t.id};let at=fe.videoId;if(at){const{error:Ae}=await G.from("academy_videos").update(Je).eq("id",at);if(Ae)throw Ae}else{const{data:Ae,error:Ye}=await G.from("academy_videos").insert(Je).select().single();if(Ye)throw Ye;at=Ae.id,oVt(fe.video.title,Ae.id)}if(fe.resourcesToDelete.length>0){const{error:Ae}=await G.from("academy_resources").delete().in("id",fe.resourcesToDelete);if(Ae)throw Ae}for(let Ae=0;Ae0){const{error:Ae}=await G.from("academy_video_templates").insert(I.map(Ye=>({video_id:at,template_id:Ye})));if(Ae)throw Ae}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Me(),l(!1),n({title:i?"Video updated":"Video created"})},onError:fe=>{n({title:"Error saving video",description:fe.message,variant:"destructive"})}}),Ue=It({mutationFn:async fe=>{const{error:Ve}=await G.from("academy_videos").delete().eq("id",fe);if(Ve)throw Ve},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),n({title:"Video deleted"})},onError:fe=>{n({title:"Error deleting video",description:fe.message,variant:"destructive"})}}),Te=It({mutationFn:async({id:fe,is_published:Ve})=>{const{error:Je}=await G.from("academy_videos").update({is_published:Ve}).eq("id",fe);if(Je)throw Je},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:fe=>{n({title:"Error updating video",description:fe.message,variant:"destructive"})}}),Me=()=>{p({title:"",description:"",video_url:"",video_type:"bunny_stream",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),y(null),b(""),w([]),C([]),L([]),d(null),O([]),q(""),Y(null),X(0),ie(!1),oe(null)},Fe=async fe=>{d(fe),p({title:fe.title,description:fe.description||"",video_url:fe.video_url,video_type:fe.video_type,duration:fe.duration||"",category_id:fe.category_id||"",publish_date:fe.publish_date?new Date(fe.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:fe.is_published}),b(fe.thumbnail_url||""),C(fe.resources||[]),w([]),L([]);const{data:Ve}=await G.from("academy_video_templates").select("template_id").eq("video_id",fe.id);O((Ve||[]).map(Je=>Je.template_id)),l(!0)},Le=fe=>{var Je;const Ve=(Je=fe.target.files)==null?void 0:Je[0];Ve&&(y(Ve),b(URL.createObjectURL(Ve)))},Ne=fe=>{const Ve=fe.target.files;if(Ve){const Je=Array.from(Ve).map(at=>({file:at,title:at.name.replace(/\.[^/.]+$/,"")}));w([...N,...Je])}fe.target.value=""},qe=fe=>{w(N.filter((Ve,Je)=>Je!==fe))},ze=fe=>{L([...E,fe]),C(k.filter(Ve=>Ve.id!==fe))},ve=async()=>{if(!se)return null;ie(!0),X(0);try{const{data:fe,error:Ve}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||se.name}});if(Ve)throw new Error(Ve.message);const{videoId:Je,libraryId:at}=fe;oe(Je);const{data:Ae,error:Ye}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Je}});if(Ye)throw new Error(Ye.message);const We=new XMLHttpRequest;return await new Promise((Ge,et)=>{We.upload.addEventListener("progress",ht=>{if(ht.lengthComputable){const xt=Math.round(ht.loaded/ht.total*100);X(xt)}}),We.addEventListener("load",()=>{We.status>=200&&We.status<300?Ge():et(new Error(`Upload failed with status ${We.status}`))}),We.addEventListener("error",()=>et(new Error("Upload failed"))),We.open("PUT",Ae.uploadUrl),We.setRequestHeader("AccessKey",Ae.apiKey),We.send(se)}),`https://player.mediadelivery.net/embed/${at}/${Je}`}catch(fe){return console.error("Bunny upload error:",fe),n({title:"Video upload failed",description:fe instanceof Error?fe.message:"Unknown error",variant:"destructive"}),null}finally{ie(!1)}},dt=async fe=>{if(fe.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let Ve=u.video_url;if(u.video_type==="bunny_stream"&&se&&!i){const Je=await ve();if(!Je)return;Ve=Je}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"&&!se&&!u.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}je.mutate({video:{...u,video_url:Ve},thumbnail:x,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:N,resourcesToDelete:E})};return e.jsx(Es,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{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(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:_e.length})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:_e.filter(fe=>fe.is_published).length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:fe=>{l(fe),fe||Me()},children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Us,{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:dt,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{id:"title",value:u.title,onChange:fe=>p({...u,title:fe.target.value}),placeholder:"Video title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Gg,{content:u.description,onChange:fe=>p({...u,description:fe}),placeholder:"Brief description of the video",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Video Type"}),e.jsxs(Bs,{value:u.video_type,onValueChange:fe=>{p({...u,video_type:fe,video_url:""}),Y(null)},disabled:ce,children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:pVt.map(fe=>e.jsx(vt,{value:fe.value,children:fe.label},fe.value))})]})]}),u.video_type==="bunny_stream"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs(xe,{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(De,{type:"file",accept:"video/*",onChange:fe=>{var Je;const Ve=(Je=fe.target.files)==null?void 0:Je[0];Ve&&Y(Ve)},disabled:ce}),se&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Tn,{className:"h-4 w-4"}),se.name," (",(se.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(_s,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(gi,{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(xe,{htmlFor:"video_url",children:"Video URL *"}),e.jsx(De,{id:"video_url",value:u.video_url,onChange:fe=>p({...u,video_url:fe.target.value}),placeholder:"https://...",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"duration",children:"Duration"}),e.jsx(De,{id:"duration",value:u.duration,onChange:fe=>p({...u,duration:fe.target.value}),placeholder:"e.g., 45:30"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(De,{id:"publish_date",type:"date",value:u.publish_date,onChange:fe=>p({...u,publish_date:fe.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Category"}),$?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:V,onChange:fe=>q(fe.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>V.trim()&&we.mutate(V.trim()),disabled:we.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{U(!1),q("")},children:e.jsx(Sr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Bs,{value:u.category_id,onValueChange:fe=>p({...u,category_id:fe}),children:[e.jsx(Rs,{className:"flex-1",children:e.jsx(qs,{placeholder:"Select category"})}),e.jsx(Os,{children:pe.map(fe=>e.jsx(vt,{value:fe.id,children:fe.name},fe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>U(!0),children:e.jsx(Us,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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(De,{type:"file",accept:"image/*",onChange:Le,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(xe,{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($a,{className:"h-3 w-3"}),"Add Files",e.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:Ne,className:"hidden"})]})})]}),(k.length>0||N.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[k.map(fe=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(fn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:fe.title}),e.jsx(Qe,{variant:"outline",className:"text-xs",children:fe.file_type}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>ze(fe.id),className:"text-destructive hover:text-destructive",children:e.jsx(Sr,{className:"h-4 w-4"})})]},fe.id)),N.map((fe,Ve)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(fn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(De,{value:fe.title,onChange:Je=>{const at=[...N];at[Ve].title=Je.target.value,w(at)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>qe(Ve),className:"text-destructive hover:text-destructive",children:e.jsx(Sr,{className:"h-4 w-4"})})]},Ve))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),e.jsx(dtt,{selectedTemplateIds:I,onChange:O}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Er,{id:"is_published",checked:u.is_published,onCheckedChange:fe=>p({...u,is_published:fe})}),e.jsx(xe,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(En,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:ce,children:"Cancel"}),e.jsx(K,{type:"submit",disabled:je.isPending||ce,children:ce?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):je.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{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"})}):_e.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Tn,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:_e.map(fe=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[fe.thumbnail_url?e.jsx("img",{src:fe.thumbnail_url,alt:"",className:"w-16 h-10 object-cover rounded"}):e.jsx("div",{className:"w-16 h-10 bg-muted rounded flex items-center justify-center",children:e.jsx(Tn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:fe.title}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:fe.video_type.replace("_"," ")})]})]})}),e.jsx(ut,{children:fe.category?e.jsx(Qe,{variant:"outline",children:fe.category.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(ut,{children:fe.duration||"-"}),e.jsx(ut,{children:fe.resources&&fe.resources.length>0?e.jsxs(Qe,{variant:"secondary",children:[fe.resources.length," file(s)"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(ut,{children:new Date(fe.publish_date).toLocaleDateString()}),e.jsx(ut,{children:e.jsx(Er,{checked:fe.is_published,onCheckedChange:Ve=>Te.mutate({id:fe.id,is_published:Ve})})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Fe(fe),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Ue.mutate(fe.id),className:"text-destructive hover:text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})]})})]},fe.id))})]})})})]})})};function xVt(){var je,Ue,Te;const t=Jt(),[s,r]=Nc(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=S.useState(null),[x,y]=S.useState(""),[_,b]=S.useState([]),[N,w]=S.useState([]),[k,C]=S.useState([]),[E,L]=S.useState(null),{data:I,isLoading:O}=gt({queryKey:["resource-kits"],queryFn:async()=>{const{data:Me,error:Fe}=await G.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(Fe)throw Fe;return Me}}),{data:V}=gt({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Me,error:Fe}=await G.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(Fe)throw Fe;return Me}}),{data:q}=gt({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Me,error:Fe}=await G.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(Fe)throw Fe;return Me}});S.useEffect(()=>{const Me=s.get("edit");if(Me&&I&&I.length>0&&V&&q){const Fe=I.find(Le=>Le.id===Me);Fe&&(U(Fe),r({},{replace:!0}))}},[I,V,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)},U=async Me=>{l(Me),d({name:Me.name,description:Me.description||"",publish_date:Me.publish_date.split("T")[0],is_published:Me.is_published}),y(Me.featured_image_url||"");const Fe=(V==null?void 0:V.filter(qe=>qe.kit_id===Me.id))||[];b(Fe.map(qe=>({id:qe.id,name:qe.name,file_url:qe.file_url,file_type:qe.file_type,file_size:qe.file_size,sort_order:qe.sort_order})));const Le=(q==null?void 0:q.filter(qe=>qe.kit_id===Me.id))||[];w(Le.map(qe=>({id:qe.id,title:qe.title,canva_share_link:qe.canva_share_link,sort_order:qe.sort_order})));const{data:Ne}=await G.from("resource_kit_templates").select("template_id").eq("kit_id",Me.id);C((Ne||[]).map(qe=>qe.template_id)),a(!0)},se=Me=>{var Le;const Fe=(Le=Me.target.files)==null?void 0:Le[0];Fe&&(p(Fe),y(URL.createObjectURL(Fe)))},Y=()=>{b([..._,{name:"",file_url:"",sort_order:_.length}])},J=Me=>{b(_.filter((Fe,Le)=>Le!==Me))},X=(Me,Fe,Le)=>{const Ne=[..._];Ne[Me]={...Ne[Me],[Fe]:Le},b(Ne)},ce=()=>{w([...N,{title:"",canva_share_link:"",sort_order:N.length}])},ie=Me=>{w(N.filter((Fe,Le)=>Le!==Me))},ae=(Me,Fe,Le)=>{const Ne=[...N];Ne[Me]={...Ne[Me],[Fe]:Le},w(Ne)},oe=(Me,Fe)=>{var Ne;const Le=(Ne=Fe.target.files)==null?void 0:Ne[0];if(Le){const qe=[..._],ze=Le.name.replace(/\.[^/.]+$/,"");qe[Me]={...qe[Me],file:Le,file_type:Le.type,file_size:Le.size,name:qe[Me].name||ze},b(qe)}},pe=It({mutationFn:async()=>{let Me=(o==null?void 0:o.featured_image_url)||null;if(u){const ze=u.name.split(".").pop(),ve=`${Date.now()}.${ze}`,{error:dt}=await G.storage.from("resource-kits").upload(`featured/${ve}`,u);if(dt)throw dt;const{data:fe}=G.storage.from("resource-kits").getPublicUrl(`featured/${ve}`);Me=fe.publicUrl}const Fe={name:i.name,description:i.description||null,featured_image_url:Me,publish_date:i.publish_date,is_published:i.is_published};let Le;const Ne=!o,qe=(o==null?void 0:o.is_published)||!1;if(o){const{error:ze}=await G.from("resource_kits").update(Fe).eq("id",o.id);if(ze)throw ze;Le=o.id;const ve=(V==null?void 0:V.filter(Ae=>Ae.kit_id===o.id).map(Ae=>Ae.id))||[],dt=_.filter(Ae=>Ae.id).map(Ae=>Ae.id),fe=ve.filter(Ae=>!dt.includes(Ae));fe.length>0&&await G.from("resource_kit_files").delete().in("id",fe);const Ve=(q==null?void 0:q.filter(Ae=>Ae.kit_id===o.id).map(Ae=>Ae.id))||[],Je=N.filter(Ae=>Ae.id).map(Ae=>Ae.id),at=Ve.filter(Ae=>!Je.includes(Ae));at.length>0&&await G.from("resource_kit_links").delete().in("id",at)}else{const{data:ze,error:ve}=await G.from("resource_kits").insert(Fe).select().single();if(ve)throw ve;Le=ze.id}for(let ze=0;ze<_.length;ze++){const ve=_[ze];let dt=ve.file_url;if(ve.file){const fe=ve.file.name.split(".").pop(),Ve=`${Date.now()}-${ze}.${fe}`,{error:Je}=await G.storage.from("resource-kits").upload(`files/${Ve}`,ve.file);if(Je)throw Je;const{data:at}=G.storage.from("resource-kits").getPublicUrl(`files/${Ve}`);dt=at.publicUrl}ve.id?await G.from("resource_kit_files").update({name:ve.name,file_url:dt,file_type:ve.file_type,file_size:ve.file_size,sort_order:ze}).eq("id",ve.id):dt&&ve.name&&await G.from("resource_kit_files").insert({kit_id:Le,name:ve.name,file_url:dt,file_type:ve.file_type,file_size:ve.file_size,sort_order:ze})}for(let ze=0;ze0){const{error:ze}=await G.from("resource_kit_templates").insert(k.map(ve=>({kit_id:Le,template_id:ve})));if(ze)throw ze}return{kitId:Le,kitName:i.name,isNewKit:Ne,wasPublished:qe,isPublished:i.is_published}},onSuccess:Me=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),t.invalidateQueries({queryKey:["resource-kit-links"]}),me.success(o?"Resource kit updated":"Resource kit created"),Me.isPublished&&(Me.isNewKit||!Me.wasPublished)&&cVt(Me.kitName,Me.kitId),a(!1),$()},onError:Me=>{me.error("Failed to save resource kit: "+Me.message)}}),_e=It({mutationFn:async Me=>{const{error:Fe}=await G.from("resource_kits").delete().eq("id",Me);if(Fe)throw Fe},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),me.success("Resource kit deleted")},onError:Me=>{me.error("Failed to delete: "+Me.message)}}),he=Me=>{if(Me.preventDefault(),!i.name){me.error("Please enter a name");return}pe.mutate()},we=Me=>(V==null?void 0:V.filter(Fe=>Fe.kit_id===Me).length)||0;return e.jsx(Es,{title:"Toolbox Management",description:"Create and manage resource kits for agents",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(I==null?void 0:I.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(I==null?void 0:I.filter(Me=>Me.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{$(),a(!0)},children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:O?e.jsx(Ms,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(I==null?void 0:I.length)===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No resource kits yet. Create your first one!"})}):I==null?void 0:I.map(Me=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Me.featured_image_url?e.jsx("img",{src:Me.featured_image_url,alt:Me.name,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(nl,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Me.name}),Me.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Me.description})]})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(fn,{className:"h-4 w-4 text-muted-foreground"}),we(Me.id)]})}),e.jsx(ut,{children:ps(new Date(Me.publish_date),"MMM d, yyyy")}),e.jsx(ut,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Me.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Me.is_published?"Published":"Draft"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const Fe=(V==null?void 0:V.filter(Ne=>Ne.kit_id===Me.id))||[],Le=(q==null?void 0:q.filter(Ne=>Ne.kit_id===Me.id))||[];L({...Me,files:Fe,links:Le})},children:e.jsx(wn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>U(Me),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&_e.mutate(Me.id)},children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]})})]},Me.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(xe,{children:"Featured Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[x?e.jsx("img",{src:x,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(nl,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(De,{type:"file",accept:"image/*",onChange:se})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Name *"}),e.jsx(De,{id:"name",value:i.name,onChange:Me=>d({...i,name:Me.target.value}),placeholder:"Resource Kit Name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Gg,{content:i.description,onChange:Me=>d({...i,description:Me}),placeholder:"Brief description of this resource kit",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(De,{id:"publish_date",type:"date",value:i.publish_date,onChange:Me=>d({...i,publish_date:Me.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(Er,{checked:i.is_published,onCheckedChange:Me=>d({...i,is_published:Me})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:i.is_published?"Visible to agents":"Hidden from agents"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(xe,{children:"Resource Files"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Y,children:[e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Add File"]})]}),_.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No files added yet. Click "Add File" to include resources.'}):e.jsx("div",{className:"space-y-3",children:_.map((Me,Fe)=>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 ",Fe+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>J(Fe),children:e.jsx(Sr,{className:"h-4 w-4"})})]}),e.jsx(De,{placeholder:"File name (e.g., Getting Started Guide)",value:Me.name,onChange:Le=>X(Fe,"name",Le.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{type:"file",onChange:Le=>oe(Fe,Le),className:"flex-1"}),Me.file_url&&!Me.file&&e.jsx("a",{href:Me.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),Me.file&&e.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},Fe))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(xe,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ce,children:[e.jsx(Us,{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((Me,Fe)=>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 ",Fe+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ie(Fe),children:e.jsx(Sr,{className:"h-4 w-4"})})]}),e.jsx(De,{placeholder:"Link title (e.g., Social Media Post Template)",value:Me.title,onChange:Le=>ae(Fe,"title",Le.target.value)}),e.jsx(De,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Me.canva_share_link,onChange:Le=>ae(Fe,"canva_share_link",Le.target.value)})]},Fe))})]}),e.jsx(dtt,{selectedTemplateIds:k,onChange:C}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:pe.isPending,children:pe.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!E,onOpenChange:()=>L(null),children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsx(ks,{children:e.jsx(bs,{children:E==null?void 0:E.name})}),e.jsxs("div",{className:"space-y-4",children:[(E==null?void 0:E.featured_image_url)&&e.jsx("img",{src:E.featured_image_url,alt:E.name,className:"w-full h-48 object-cover rounded-lg"}),(E==null?void 0:E.description)&&e.jsx("p",{className:"text-muted-foreground",children:E.description}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Resource Files (",((je=E==null?void 0:E.files)==null?void 0:je.length)||0,")"]}),((Ue=E==null?void 0:E.files)==null?void 0:Ue.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=E==null?void 0:E.files)==null?void 0:Te.map(Me=>e.jsxs("a",{href:Me.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(fn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Me.name})]},Me.id))})]}),(E==null?void 0:E.links)&&E.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Canva Links (",E.links.length,")"]}),e.jsx("div",{className:"space-y-2",children:E.links.map(Me=>e.jsxs("a",{href:Me.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(fo,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Me.title})]},Me.id))})]})]})]})})]})})}const gVt=()=>{const{user:t}=Fs(),{toast:s}=wa(),r=Jt(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[u,p]=S.useState(null),[x,y]=S.useState(""),{data:_=[],isLoading:b}=gt({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:U,error:se}=await G.from("social_swag_links").select("*").order("sort_order");if(se)throw se;return q.map(J=>({...J,links:(U==null?void 0:U.filter(X=>X.swag_id===J.id))||[]}))}}),N=It({mutationFn:async q=>{let $=q.existingImageUrl;if(q.image){const ce=q.image.name.split(".").pop(),ie=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ce}`,{error:ae}=await G.storage.from("template-previews").upload(ie,q.image);if(ae)throw ae;const{data:oe}=G.storage.from("template-previews").getPublicUrl(ie);$=oe.publicUrl}const U={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 se=q.itemId;const Y=!se,J=(o==null?void 0:o.is_published)||!1;if(se){const{error:ce}=await G.from("social_swag").update(U).eq("id",se);if(ce)throw ce;await G.from("social_swag_links").delete().eq("swag_id",se)}else{const{data:ce,error:ie}=await G.from("social_swag").insert(U).select().single();if(ie)throw ie;se=ce.id}const X=q.item.links.filter(ce=>ce.title.trim()&&ce.canva_share_link.trim());if(X.length>0){const ce=X.map((ae,oe)=>({swag_id:se,title:ae.title.trim(),canva_share_link:ae.canva_share_link.trim(),sort_order:oe})),{error:ie}=await G.from("social_swag_links").insert(ce);if(ie)throw ie}return{itemId:se,itemTitle:q.item.title,isNewItem:Y,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)&&H_e(q.itemTitle,q.itemId),a(!1),k()},onError:q=>{s({title:"Error saving item",description:q.message,variant:"destructive"})}}),w=It({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"})}}),k=()=>{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)},E=q=>{var U;const $=(U=q.target.files)==null?void 0:U[0];$&&(p($),y(URL.createObjectURL($)))},L=()=>{d({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},I=q=>{if(i.links.length<=1)return;const $=i.links.filter((U,se)=>se!==q);d({...i,links:$})},O=(q,$,U)=>{const se=[...i.links];se[q]={...se[q],[$]:U},d({...i,links:se})},V=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(Es,{title:"Manage Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{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(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{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||k()},children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Us,{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:V,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{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(xe,{children:"Description"}),e.jsx(Gg,{content:i.description,onChange:q=>d({...i,description:q}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(De,{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(Er,{id:"is_published",checked:i.is_published,onCheckedChange:q=>d({...i,is_published:q})}),e.jsx(xe,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Preview Image"}),x?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:x,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(Wo,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(De,{type:"file",accept:"image/*",onChange:E,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:L,children:[e.jsx(Us,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((q,$)=>e.jsx(Pe,{children:e.jsxs(Re,{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:()=>I($),children:e.jsx(Sr,{className:"h-3 w-3"})})]}),e.jsx(De,{placeholder:"Link title (e.g., Instagram Post)",value:q.title,onChange:U=>O($,"title",U.target.value)}),e.jsx(De,{placeholder:"Canva share link",value:q.canva_share_link,onChange:U=>O($,"canva_share_link",U.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(Pe,{children:e.jsx(Re,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:_.map(q=>{var $;return e.jsxs(Ms,{children:[e.jsx(ut,{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(Wo,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(ut,{className:"font-medium",children:q.title}),e.jsxs(ut,{children:[(($=q.links)==null?void 0:$.length)||0," links"]}),e.jsx(ut,{children:new Date(q.publish_date).toLocaleDateString()}),e.jsx(ut,{children:e.jsx(Qe,{variant:q.is_published?"default":"secondary",children:q.is_published?"Published":"Draft"})}),e.jsx(ut,{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(wn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(q),children:e.jsx(ga,{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(gr,{className:"h-4 w-4"})})]})})]},q.id)})})]})})})]})})};function yVt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const khe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function sE(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function u4e(t){return"nodeType"in t}function bp(t){var s,r;return t?sE(t)?t:u4e(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function h4e(t){const{Document:s}=bp(t);return t instanceof s}function eO(t){return sE(t)?!1:t instanceof bp(t).HTMLElement}function utt(t){return t instanceof bp(t).SVGElement}function rE(t){return t?sE(t)?t.document:u4e(t)?h4e(t)?t:eO(t)||utt(t)?t.ownerDocument:document:document:document}const f0=khe?S.useLayoutEffect:S.useEffect;function m4e(t){const s=S.useRef(t);return f0(()=>{s.current=t}),S.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a{t.current=setInterval(n,a)},[]),r=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,r]}function bD(t,s){s===void 0&&(s=[t]);const r=S.useRef(t);return f0(()=>{r.current!==t&&(r.current=t)},s),r}function tO(t,s){const r=S.useRef();return S.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function hce(t){const s=m4e(t),r=S.useRef(null),n=S.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function G_e(t){const s=S.useRef();return S.useEffect(()=>{s.current=t},[t]),s.current}let kye={};function sO(t,s){return S.useMemo(()=>{if(s)return s;const r=kye[t]==null?0:kye[t]+1;return kye[t]=r,t+"-"+r},[t,s])}function htt(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 ZM=htt(1),wD=htt(-1);function _Vt(t){return"clientX"in t&&"clientY"in t}function p4e(t){if(!t)return!1;const{KeyboardEvent:s}=bp(t.target);return s&&t instanceof s}function bVt(t){if(!t)return!1;const{TouchEvent:s}=bp(t.target);return s&&t instanceof s}function W_e(t){if(bVt(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 _Vt(t)?{x:t.clientX,y:t.clientY}:null}const sC=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[sC.Translate.toString(t),sC.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),tDe="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function wVt(t){return t.matches(tDe)?t:t.querySelector(tDe)}const jVt={display:"none"};function NVt(t){let{id:s,value:r}=t;return ft.createElement("div",{id:s,style:jVt},r)}function kVt(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 ft.createElement("div",{id:s,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function SVt(){const[t,s]=S.useState("");return{announce:S.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const mtt=S.createContext(null);function CVt(t){const s=S.useContext(mtt);S.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function MVt(){const[t]=S.useState(()=>new Set),s=S.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[S.useCallback(n=>{let{type:a,event:o}=n;t.forEach(l=>{var i;return(i=l[a])==null?void 0:i.call(l,o)})},[t]),s]}const TVt={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. `},AVt={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 EVt(t){let{announcements:s=AVt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=TVt}=t;const{announce:o,announcement:l}=SVt(),i=sO("DndLiveRegion"),[d,u]=S.useState(!1);if(S.useEffect(()=>{u(!0)},[]),CVt(S.useMemo(()=>({onDragStart(x){let{active:y}=x;o(s.onDragStart({active:y}))},onDragMove(x){let{active:y,over:_}=x;s.onDragMove&&o(s.onDragMove({active:y,over:_}))},onDragOver(x){let{active:y,over:_}=x;o(s.onDragOver({active:y,over:_}))},onDragEnd(x){let{active:y,over:_}=x;o(s.onDragEnd({active:y,over:_}))},onDragCancel(x){let{active:y,over:_}=x;o(s.onDragCancel({active:y,over:_}))}}),[o,s])),!d)return null;const p=ft.createElement(ft.Fragment,null,ft.createElement(NVt,{id:n,value:a.draggable}),ft.createElement(kVt,{id:i,announcement:l}));return r?ip.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 mce(){}function pce(t,s){return S.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function f4e(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const Ug=Object.freeze({x:0,y:0});function ptt(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function ftt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function PVt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function sDe(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 xtt(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function rDe(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 x4e=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=rDe(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=ptt(rDe(d),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort(ftt)},IVt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=sDe(s),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=sDe(d),p=a.reduce((y,_,b)=>y+ptt(u[b],_),0),x=Number((p/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:x}})}}return o.sort(ftt)};function LVt(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=LVt(i,s);d>0&&a.push({id:l,data:{droppableContainer:o,value:d}})}}return a.sort(PVt)};function RVt(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function gtt(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:Ug}function OVt(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 FVt=OVt(1);function zVt(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 BVt(t,s,r){const n=zVt(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,x=o?t.height/o:t.height;return{width:p,height:x,top:u,right:d+p,bottom:u+x,left:d}}const $Vt={ignoreTransform:!1};function nE(t,s){s===void 0&&(s=$Vt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:p}=bp(t).getComputedStyle(t);u&&(r=BVt(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 nDe(t){return nE(t,{ignoreTransform:!0})}function qVt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function UVt(t,s){return s===void 0&&(s=bp(t).getComputedStyle(t)),s.position==="fixed"}function VVt(t,s){s===void 0&&(s=bp(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 She(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(h4e(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!eO(a)||utt(a)||r.includes(a))return r;const o=bp(t).getComputedStyle(a);return a!==t&&VVt(a,o)&&r.push(a),UVt(a,o)?r:n(a.parentNode)}return t?n(t):r}function ytt(t){const[s]=She(t,1);return s??null}function Sye(t){return!khe||!t?null:sE(t)?t:u4e(t)?h4e(t)||t===rE(t).scrollingElement?window:eO(t)?t:null:null}function vtt(t){return sE(t)?t.scrollX:t.scrollLeft}function _tt(t){return sE(t)?t.scrollY:t.scrollTop}function K_e(t){return{x:vtt(t),y:_tt(t)}}var Iu;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Iu||(Iu={}));function btt(t){return!khe||!t?!1:t===document.scrollingElement}function wtt(t){const s={x:0,y:0},r=btt(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},n={x:t.scrollWidth-r.width,y:t.scrollHeight-r.height},a=t.scrollTop<=s.y,o=t.scrollLeft<=s.x,l=t.scrollTop>=n.y,i=t.scrollLeft>=n.x;return{isTop:a,isLeft:o,isBottom:l,isRight:i,maxScroll:n,minScroll:s}}const HVt={x:.2,y:.2};function GVt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:d}=r;n===void 0&&(n=10),a===void 0&&(a=HVt);const{isTop:u,isBottom:p,isLeft:x,isRight:y}=wtt(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=Iu.Backward,b.y=n*Math.abs((s.top+N.height-o)/N.height)):!p&&d>=s.bottom-N.height&&(_.y=Iu.Forward,b.y=n*Math.abs((s.bottom-N.height-d)/N.height)),!y&&i>=s.right-N.width?(_.x=Iu.Forward,b.x=n*Math.abs((s.right-N.width-i)/N.width)):!x&&l<=s.left+N.width&&(_.x=Iu.Backward,b.x=n*Math.abs((s.left+N.width-l)/N.width)),{direction:_,speed:b}}function WVt(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 jtt(t){return t.reduce((s,r)=>ZM(s,K_e(r)),Ug)}function KVt(t){return t.reduce((s,r)=>s+vtt(r),0)}function ZVt(t){return t.reduce((s,r)=>s+_tt(r),0)}function YVt(t,s){if(s===void 0&&(s=nE),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);ytt(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const XVt=[["x",["left","right"],KVt],["y",["top","bottom"],ZVt]];class g4e{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=She(r),a=jtt(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of XVt)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 m8{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 QVt(t){const{EventTarget:s}=bp(t);return t instanceof s?t:rE(t)}function Cye(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 sx;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(sx||(sx={}));function aDe(t){t.preventDefault()}function JVt(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 Ntt={start:[eo.Space,eo.Enter],cancel:[eo.Esc],end:[eo.Space,eo.Enter,eo.Tab]},eHt=(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 y4e{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 m8(rE(r)),this.windowListeners=new m8(bp(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(sx.Resize,this.handleCancel),this.windowListeners.add(sx.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(sx.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&YVt(n),r(Ug)}handleKeyDown(s){if(p4e(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=Ntt,coordinateGetter:l=eHt,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}:Ug;this.referenceCoordinates||(this.referenceCoordinates=p);const x=l(s,{active:r,context:n.current,currentCoordinates:p});if(x){const y=wD(x,p),_={x:0,y:0},{scrollableAncestors:b}=n.current;for(const N of b){const w=s.code,{isTop:k,isRight:C,isLeft:E,isBottom:L,maxScroll:I,minScroll:O}=wtt(N),V=WVt(N),q={x:Math.min(w===eo.Right?V.right-V.width/2:V.right,Math.max(w===eo.Right?V.left:V.left+V.width/2,x.x)),y:Math.min(w===eo.Down?V.bottom-V.height/2:V.bottom,Math.max(w===eo.Down?V.top:V.top+V.height/2,x.y))},$=w===eo.Right&&!C||w===eo.Left&&!E,U=w===eo.Down&&!L||w===eo.Up&&!k;if($&&q.x!==x.x){const se=N.scrollLeft+y.x,Y=w===eo.Right&&se<=I.x||w===eo.Left&&se>=O.x;if(Y&&!y.y){N.scrollTo({left:se,behavior:i});return}Y?_.x=N.scrollLeft-se:_.x=w===eo.Right?N.scrollLeft-I.x:N.scrollLeft-O.x,_.x&&N.scrollBy({left:-_.x,behavior:i});break}else if(U&&q.y!==x.y){const se=N.scrollTop+y.y,Y=w===eo.Down&&se<=I.y||w===eo.Up&&se>=O.y;if(Y&&!y.x){N.scrollTo({top:se,behavior:i});return}Y?_.y=N.scrollTop-se:_.y=w===eo.Down?N.scrollTop-I.y:N.scrollTop-O.y,_.y&&N.scrollBy({top:-_.y,behavior:i});break}}this.handleMove(s,ZM(wD(x,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()}}y4e.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=Ntt,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 iDe(t){return!!(t&&"distance"in t)}function oDe(t){return!!(t&&"delay"in t)}class v4e{constructor(s,r,n){var a;n===void 0&&(n=QVt(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=rE(l),this.documentListeners=new m8(this.document),this.listeners=new m8(n),this.windowListeners=new m8(bp(l)),this.initialCoordinates=(a=W_e(o))!=null?a:Ug,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(sx.Resize,this.handleCancel),this.windowListeners.add(sx.DragStart,aDe),this.windowListeners.add(sx.VisibilityChange,this.handleCancel),this.windowListeners.add(sx.ContextMenu,aDe),this.documentListeners.add(sx.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(oDe(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(iDe(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(sx.Click,JVt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(sx.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=W_e(s))!=null?r:Ug,u=wD(a,d);if(!n&&i){if(iDe(i)){if(i.tolerance!=null&&Cye(u,i.tolerance))return this.handleCancel();if(Cye(u,i.distance))return this.handleStart()}if(oDe(i)&&Cye(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 tHt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class rO extends v4e{constructor(s){const{event:r}=s,n=rE(r.target);super(s,tHt,n)}}rO.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 sHt={move:{name:"mousemove"},end:{name:"mouseup"}};var Z_e;(function(t){t[t.RightClick=2]="RightClick"})(Z_e||(Z_e={}));class rHt extends v4e{constructor(s){super(s,sHt,rE(s.event.target))}}rHt.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===Z_e.RightClick?!1:(n==null||n({event:r}),!0)}}];const Mye={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class nHt extends v4e{constructor(s){super(s,Mye)}static setup(){return window.addEventListener(Mye.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Mye.move.name,s)};function s(){}}}nHt.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 p8;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(p8||(p8={}));var fce;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(fce||(fce={}));function aHt(t){let{acceleration:s,activator:r=p8.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=fce.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:p,delta:x,threshold:y}=t;const _=oHt({delta:x,disabled:!o}),[b,N]=vVt(),w=S.useRef({x:0,y:0}),k=S.useRef({x:0,y:0}),C=S.useMemo(()=>{switch(r){case p8.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case p8.DraggableRect:return a}},[r,a,d]),E=S.useRef(null),L=S.useCallback(()=>{const O=E.current;if(!O)return;const V=w.current.x*k.current.x,q=w.current.y*k.current.y;O.scrollBy(V,q)},[]),I=S.useMemo(()=>i===fce.TreeOrder?[...u].reverse():u,[i,u]);S.useEffect(()=>{if(!o||!u.length||!C){N();return}for(const O of I){if((n==null?void 0:n(O))===!1)continue;const V=u.indexOf(O),q=p[V];if(!q)continue;const{direction:$,speed:U}=GVt(O,q,C,s,y);for(const se of["x","y"])_[se][$[se]]||(U[se]=0,$[se]=0);if(U.x>0||U.y>0){N(),E.current=O,b(L,l),w.current=U,k.current=$;return}}w.current={x:0,y:0},k.current={x:0,y:0},N()},[s,L,n,N,o,l,JSON.stringify(C),JSON.stringify(_),b,u,I,p,JSON.stringify(y)])}const iHt={x:{[Iu.Backward]:!1,[Iu.Forward]:!1},y:{[Iu.Backward]:!1,[Iu.Forward]:!1}};function oHt(t){let{delta:s,disabled:r}=t;const n=G_e(s);return tO(a=>{if(r||!n||!a)return iHt;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[Iu.Backward]:a.x[Iu.Backward]||o.x===-1,[Iu.Forward]:a.x[Iu.Forward]||o.x===1},y:{[Iu.Backward]:a.y[Iu.Backward]||o.y===-1,[Iu.Forward]:a.y[Iu.Forward]||o.y===1}}},[r,s,n])}function lHt(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return tO(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function cHt(t,s){return S.useMemo(()=>t.reduce((r,n)=>{const{sensor:a}=n,o=a.activators.map(l=>({eventName:l.eventName,handler:s(l.handler,n)}));return[...r,...o]},[]),[t,s])}var jD;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(jD||(jD={}));var Y_e;(function(t){t.Optimized="optimized"})(Y_e||(Y_e={}));const lDe=new Map;function dHt(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=S.useState(null),{frequency:i,measure:d,strategy:u}=a,p=S.useRef(t),x=w(),y=bD(x),_=S.useCallback(function(k){k===void 0&&(k=[]),!y.current&&l(C=>C===null?k:C.concat(k.filter(E=>!C.includes(E))))},[y]),b=S.useRef(null),N=tO(k=>{if(x&&!r)return lDe;if(!k||k===lDe||p.current!==t||o!=null){const C=new Map;for(let E of t){if(!E)continue;if(o&&o.length>0&&!o.includes(E.id)&&E.rect.current){C.set(E.id,E.rect.current);continue}const L=E.node.current,I=L?new g4e(d(L),L):null;E.rect.current=I,I&&C.set(E.id,I)}return C}return k},[t,o,r,x,d]);return S.useEffect(()=>{p.current=t},[t]),S.useEffect(()=>{x||_()},[r,x]),S.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),S.useEffect(()=>{x||typeof i!="number"||b.current!==null||(b.current=setTimeout(()=>{_(),b.current=null},i))},[i,x,_,...n]),{droppableRects:N,measureDroppableContainers:_,measuringScheduled:o!=null};function w(){switch(u){case jD.Always:return!1;case jD.BeforeDragging:return r;default:return!r}}}function ktt(t,s){return tO(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function uHt(t,s){return ktt(t,s)}function hHt(t){let{callback:s,disabled:r}=t;const n=m4e(s),a=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return S.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function Che(t){let{callback:s,disabled:r}=t;const n=m4e(s),a=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return S.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function mHt(t){return new g4e(nE(t),t)}function cDe(t,s,r){s===void 0&&(s=mHt);const[n,a]=S.useState(null);function o(){a(d=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=d??r)!=null?u:null}const p=s(t);return JSON.stringify(d)===JSON.stringify(p)?d:p})}const l=hHt({callback(d){if(t)for(const u of d){const{type:p,target:x}=u;if(p==="childList"&&x instanceof HTMLElement&&x.contains(t)){o();break}}}}),i=Che({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 pHt(t){const s=ktt(t);return gtt(t,s)}const dDe=[];function fHt(t){const s=S.useRef(t),r=tO(n=>t?n&&n!==dDe&&t&&s.current&&t.parentNode===s.current.parentNode?n:She(t):dDe,[t]);return S.useEffect(()=>{s.current=t},[t]),r}function xHt(t){const[s,r]=S.useState(null),n=S.useRef(t),a=S.useCallback(o=>{const l=Sye(o.target);l&&r(i=>i?(i.set(l,K_e(l)),new Map(i)):null)},[]);return S.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(d=>{const u=Sye(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,K_e(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=Sye(d);u==null||u.removeEventListener("scroll",a)})}},[a,t]),S.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>ZM(o,l),Ug):jtt(t):Ug,[t,s])}function uDe(t,s){s===void 0&&(s=[]);const r=S.useRef(null);return S.useEffect(()=>{r.current=null},s),S.useEffect(()=>{const n=t!==Ug;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?wD(t,r.current):Ug}function gHt(t){S.useEffect(()=>{if(!khe)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 yHt(t,s){return S.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:o}=n;return r[a]=l=>{o(l,s)},r},{}),[t,s])}function Stt(t){return S.useMemo(()=>t?qVt(t):null,[t])}const hDe=[];function vHt(t,s){s===void 0&&(s=nE);const[r]=t,n=Stt(r?bp(r):null),[a,o]=S.useState(hDe);function l(){o(()=>t.length?t.map(d=>btt(d)?n:new g4e(s(d),d)):hDe)}const i=Che({callback:l});return f0(()=>{i==null||i.disconnect(),l(),t.forEach(d=>i==null?void 0:i.observe(d))},[t]),a}function _Ht(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return eO(s)?s:t}function bHt(t){let{measure:s}=t;const[r,n]=S.useState(null),a=S.useCallback(u=>{for(const{target:p}of u)if(eO(p)){n(x=>{const y=s(p);return x?{...x,width:y.width,height:y.height}:y});break}},[s]),o=Che({callback:a}),l=S.useCallback(u=>{const p=_Ht(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),n(p?s(p):null)},[s,o]),[i,d]=hce(l);return S.useMemo(()=>({nodeRef:i,rect:r,setRef:d}),[r,i,d])}const wHt=[{sensor:rO,options:{}},{sensor:y4e,options:{}}],jHt={current:{}},roe={draggable:{measure:nDe},droppable:{measure:nDe,strategy:jD.WhileDragging,frequency:Y_e.Optimized},dragOverlay:{measure:nE}};class f8 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 NHt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new f8,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:mce},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:roe,measureDroppableContainers:mce,windowRect:null,measuringScheduled:!1},kHt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:mce,draggableNodes:new Map,over:null,measureDroppableContainers:mce},Mhe=S.createContext(kHt),Ctt=S.createContext(NHt);function SHt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new f8}}}function CHt(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 f8(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 f8(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 f8(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function MHt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=S.useContext(Mhe),o=G_e(n),l=G_e(r==null?void 0:r.id);return S.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!p4e(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 x=wVt(p);if(x){x.focus();break}}})}},[n,s,a,l,o]),null}function THt(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function AHt(t){return S.useMemo(()=>({draggable:{...roe.draggable,...t==null?void 0:t.draggable},droppable:{...roe.droppable,...t==null?void 0:t.droppable},dragOverlay:{...roe.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 EHt(t){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=t;const o=S.useRef(!1),{x:l,y:i}=typeof a=="boolean"?{x:a,y:a}:a;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),x=gtt(p,n);if(l||(x.x=0),i||(x.y=0),o.current=!0,Math.abs(x.x)>0||Math.abs(x.y)>0){const y=ytt(u);y&&y.scrollBy({top:x.y,left:x.x})}},[s,l,i,n,r])}const Mtt=S.createContext({...Ug,scaleX:1,scaleY:1});var O_;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(O_||(O_={}));const _4e=S.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:d=!0,children:u,sensors:p=wHt,collisionDetection:x=DVt,measuring:y,modifiers:_,...b}=s;const N=S.useReducer(CHt,void 0,SHt),[w,k]=N,[C,E]=MVt(),[L,I]=S.useState(O_.Uninitialized),O=L===O_.Initialized,{draggable:{active:V,nodes:q,translate:$},droppable:{containers:U}}=w,se=V!=null?q.get(V):null,Y=S.useRef({initial:null,translated:null}),J=S.useMemo(()=>{var Qr;return V!=null?{id:V,data:(Qr=se==null?void 0:se.data)!=null?Qr:jHt,rect:Y}:null},[V,se]),X=S.useRef(null),[ce,ie]=S.useState(null),[ae,oe]=S.useState(null),pe=bD(b,Object.values(b)),_e=sO("DndDescribedBy",l),he=S.useMemo(()=>U.getEnabled(),[U]),we=AHt(y),{droppableRects:je,measureDroppableContainers:Ue,measuringScheduled:Te}=dHt(he,{dragging:O,dependencies:[$.x,$.y],config:we.droppable}),Me=lHt(q,V),Fe=S.useMemo(()=>ae?W_e(ae):null,[ae]),Le=Vn(),Ne=uHt(Me,we.draggable.measure);EHt({activeNode:V!=null?q.get(V):null,config:Le.layoutShiftCompensation,initialRect:Ne,measure:we.draggable.measure});const qe=cDe(Me,we.draggable.measure,Ne),ze=cDe(Me?Me.parentElement:null),ve=S.useRef({activatorEvent:null,active:null,activeNode:Me,collisionRect:null,collisions:null,droppableRects:je,draggableNodes:q,draggingNode:null,draggingNodeRect:null,droppableContainers:U,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),dt=U.getNodeFor((r=ve.current.over)==null?void 0:r.id),fe=bHt({measure:we.dragOverlay.measure}),Ve=(n=fe.nodeRef.current)!=null?n:Me,Je=O?(a=fe.rect)!=null?a:qe:null,at=!!(fe.nodeRef.current&&fe.rect),Ae=pHt(at?null:qe),Ye=Stt(Ve?bp(Ve):null),We=fHt(O?dt??Me:null),ot=vHt(We),Ge=THt(_,{transform:{x:$.x-Ae.x,y:$.y-Ae.y,scaleX:1,scaleY:1},activatorEvent:ae,active:J,activeNodeRect:qe,containerNodeRect:ze,draggingNodeRect:Je,over:ve.current.over,overlayNodeRect:fe.rect,scrollableAncestors:We,scrollableAncestorRects:ot,windowRect:Ye}),et=Fe?ZM(Fe,$):null,ht=xHt(We),xt=uDe(ht),Ke=uDe(ht,[qe]),Ze=ZM(Ge,xt),Et=Je?FVt(Je,Ge):null,$t=J&&Et?x({active:J,collisionRect:Et,droppableRects:je,droppableContainers:he,pointerCoordinates:et}):null,Yt=xtt($t,"id"),[Ps,zs]=S.useState(null),Zs=at?Ge:ZM(Ge,Ke),Dr=RVt(Zs,(o=Ps==null?void 0:Ps.rect)!=null?o:null,qe),zt=S.useRef(null),$s=S.useCallback((Qr,Gr)=>{let{sensor:tr,options:cr}=Gr;if(X.current==null)return;const cn=q.get(X.current);if(!cn)return;const rn=Qr.nativeEvent,jn=new tr({active:X.current,activeNode:cn,event:rn,options:cr,context:ve,onAbort(rs){if(!q.get(rs))return;const{onDragAbort:mn}=pe.current,Fr={id:rs};mn==null||mn(Fr),C({type:"onDragAbort",event:Fr})},onPending(rs,Bn,mn,Fr){if(!q.get(rs))return;const{onDragPending:jr}=pe.current,zr={id:rs,constraint:Bn,initialCoordinates:mn,offset:Fr};jr==null||jr(zr),C({type:"onDragPending",event:zr})},onStart(rs){const Bn=X.current;if(Bn==null)return;const mn=q.get(Bn);if(!mn)return;const{onDragStart:Fr}=pe.current,Kt={activatorEvent:rn,active:{id:Bn,data:mn.data,rect:Y}};ip.unstable_batchedUpdates(()=>{Fr==null||Fr(Kt),I(O_.Initializing),k({type:su.DragStart,initialCoordinates:rs,active:Bn}),C({type:"onDragStart",event:Kt}),ie(zt.current),oe(rn)})},onMove(rs){k({type:su.DragMove,coordinates:rs})},onEnd:ni(su.DragEnd),onCancel:ni(su.DragCancel)});zt.current=jn;function ni(rs){return async function(){const{active:mn,collisions:Fr,over:Kt,scrollAdjustedTranslate:jr}=ve.current;let zr=null;if(mn&&jr){const{cancelDrop:fa}=pe.current;zr={activatorEvent:rn,active:mn,collisions:Fr,delta:jr,over:Kt},rs===su.DragEnd&&typeof fa=="function"&&await Promise.resolve(fa(zr))&&(rs=su.DragCancel)}X.current=null,ip.unstable_batchedUpdates(()=>{k({type:rs}),I(O_.Uninitialized),zs(null),ie(null),oe(null),zt.current=null;const fa=rs===su.DragEnd?"onDragEnd":"onDragCancel";if(zr){const qt=pe.current[fa];qt==null||qt(zr),C({type:fa,event:zr})}})}}},[q]),kr=S.useCallback((Qr,Gr)=>(tr,cr)=>{const cn=tr.nativeEvent,rn=q.get(cr);if(X.current!==null||!rn||cn.dndKit||cn.defaultPrevented)return;const jn={active:rn};Qr(tr,Gr.options,jn)===!0&&(cn.dndKit={capturedBy:Gr.sensor},X.current=cr,$s(tr,Gr))},[q,$s]),Xs=cHt(p,kr);gHt(p),f0(()=>{qe&&L===O_.Initializing&&I(O_.Initialized)},[qe,L]),S.useEffect(()=>{const{onDragMove:Qr}=pe.current,{active:Gr,activatorEvent:tr,collisions:cr,over:cn}=ve.current;if(!Gr||!tr)return;const rn={active:Gr,activatorEvent:tr,collisions:cr,delta:{x:Ze.x,y:Ze.y},over:cn};ip.unstable_batchedUpdates(()=>{Qr==null||Qr(rn),C({type:"onDragMove",event:rn})})},[Ze.x,Ze.y]),S.useEffect(()=>{const{active:Qr,activatorEvent:Gr,collisions:tr,droppableContainers:cr,scrollAdjustedTranslate:cn}=ve.current;if(!Qr||X.current==null||!Gr||!cn)return;const{onDragOver:rn}=pe.current,jn=cr.get(Yt),ni=jn&&jn.rect.current?{id:jn.id,rect:jn.rect.current,data:jn.data,disabled:jn.disabled}:null,rs={active:Qr,activatorEvent:Gr,collisions:tr,delta:{x:cn.x,y:cn.y},over:ni};ip.unstable_batchedUpdates(()=>{zs(ni),rn==null||rn(rs),C({type:"onDragOver",event:rs})})},[Yt]),f0(()=>{ve.current={activatorEvent:ae,active:J,activeNode:Me,collisionRect:Et,collisions:$t,droppableRects:je,draggableNodes:q,draggingNode:Ve,draggingNodeRect:Je,droppableContainers:U,over:Ps,scrollableAncestors:We,scrollAdjustedTranslate:Ze},Y.current={initial:Je,translated:Et}},[J,Me,$t,Et,q,Ve,Je,je,U,Ps,We,Ze]),aHt({...Le,delta:$,draggingRect:Et,pointerCoordinates:et,scrollableAncestors:We,scrollableAncestorRects:ot});const ir=S.useMemo(()=>({active:J,activeNode:Me,activeNodeRect:qe,activatorEvent:ae,collisions:$t,containerNodeRect:ze,dragOverlay:fe,draggableNodes:q,droppableContainers:U,droppableRects:je,over:Ps,measureDroppableContainers:Ue,scrollableAncestors:We,scrollableAncestorRects:ot,measuringConfiguration:we,measuringScheduled:Te,windowRect:Ye}),[J,Me,qe,ae,$t,ze,fe,q,U,je,Ps,Ue,We,ot,we,Te,Ye]),Or=S.useMemo(()=>({activatorEvent:ae,activators:Xs,active:J,activeNodeRect:qe,ariaDescribedById:{draggable:_e},dispatch:k,draggableNodes:q,over:Ps,measureDroppableContainers:Ue}),[ae,Xs,J,qe,k,_e,q,Ps,Ue]);return ft.createElement(mtt.Provider,{value:E},ft.createElement(Mhe.Provider,{value:Or},ft.createElement(Ctt.Provider,{value:ir},ft.createElement(Mtt.Provider,{value:Dr},u)),ft.createElement(MHt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),ft.createElement(EVt,{...i,hiddenTextDescribedById:_e}));function Vn(){const Qr=(ce==null?void 0:ce.autoScrollEnabled)===!1,Gr=typeof d=="object"?d.enabled===!1:d===!1,tr=O&&!Qr&&!Gr;return typeof d=="object"?{...d,enabled:tr}:{enabled:tr}}}),PHt=S.createContext(null),mDe="button",IHt="Draggable";function LHt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=sO(IHt),{activators:l,activatorEvent:i,active:d,activeNodeRect:u,ariaDescribedById:p,draggableNodes:x,over:y}=S.useContext(Mhe),{role:_=mDe,roleDescription:b="draggable",tabIndex:N=0}=a??{},w=(d==null?void 0:d.id)===s,k=S.useContext(w?Mtt:PHt),[C,E]=hce(),[L,I]=hce(),O=yHt(l,s),V=bD(r);f0(()=>(x.set(s,{id:s,key:o,node:C,activatorNode:L,data:V}),()=>{const $=x.get(s);$&&$.key===o&&x.delete(s)}),[x,s]);const q=S.useMemo(()=>({role:_,tabIndex:N,"aria-disabled":n,"aria-pressed":w&&_===mDe?!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:E,setActivatorNodeRef:I,transform:k}}function DHt(){return S.useContext(Ctt)}const RHt="Droppable",OHt={timeout:25};function FHt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=sO(RHt),{active:l,dispatch:i,over:d,measureDroppableContainers:u}=S.useContext(Mhe),p=S.useRef({disabled:r}),x=S.useRef(!1),y=S.useRef(null),_=S.useRef(null),{disabled:b,updateMeasurementsFor:N,timeout:w}={...OHt,...a},k=bD(N??n),C=S.useCallback(()=>{if(!x.current){x.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{u(Array.isArray(k.current)?k.current:[k.current]),_.current=null},w)},[w]),E=Che({callback:C,disabled:b||!l}),L=S.useCallback((q,$)=>{E&&($&&(E.unobserve($),x.current=!1),q&&E.observe(q))},[E]),[I,O]=hce(L),V=bD(s);return S.useEffect(()=>{!E||!I.current||(E.disconnect(),x.current=!1,E.observe(I.current))},[I,E]),S.useEffect(()=>(i({type:su.RegisterDroppable,element:{id:n,key:o,disabled:r,node:I,rect:y,data:V}}),()=>i({type:su.UnregisterDroppable,key:o,id:n})),[n]),S.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:I,over:d,setNodeRef:O}}function b4e(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function zHt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function Yz(t){return t!==null&&t>=0}function BHt(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=qHt(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-d,y:0,...Xz}:l=o?{x:i.width+d,y:0,...Xz}:{x:0,y:0,...Xz}};function qHt(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=b4e(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}},Qz={scaleX:1,scaleY:1},VTs=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,...Qz}:a=l?{x:0,y:i.height+d,...Qz}:{x:0,y:0,...Qz}};function UHt(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,k=S.useRef(_),C=!BHt(_,k.current),E=w!==-1&&N===-1||C,L=$Ht(o);f0(()=>{C&&b&&p(_)},[C,_,b,p]),S.useEffect(()=>{k.current=_},[_]);const I=S.useMemo(()=>({activeIndex:N,containerId:x,disabled:L,disableTransforms:E,items:_,overIndex:w,useDragOverlay:y,sortedRects:zHt(_,d),strategy:a}),[N,x,L.draggable,L.droppable,E,_,w,d,y,a]);return ft.createElement(Att.Provider,{value:I},s)}const VHt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return b4e(r,n,a).indexOf(s)},HHt=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},GHt={duration:200,easing:"ease"},Ett="transform",WHt=sC.Transition.toString({property:Ett,duration:0,easing:"linear"}),KHt={roleDescription:"sortable"};function ZHt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=S.useState(null),i=S.useRef(r);return f0(()=>{if(!s&&r!==i.current&&n.current){const d=a.current;if(d){const u=nE(n.current,{ignoreTransform:!0}),p={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(p.x||p.y)&&l(p)}}r!==i.current&&(i.current=r)},[s,r,n,a]),S.useEffect(()=>{o&&l(null)},[o]),o}function j4e(t){let{animateLayoutChanges:s=HHt,attributes:r,disabled:n,data:a,getNewIndex:o=VHt,id:l,strategy:i,resizeObserverConfig:d,transition:u=GHt}=t;const{items:p,containerId:x,activeIndex:y,disabled:_,disableTransforms:b,sortedRects:N,overIndex:w,useDragOverlay:k,strategy:C}=S.useContext(Att),E=YHt(n,_),L=p.indexOf(l),I=S.useMemo(()=>({sortable:{containerId:x,index:L,items:p},...a}),[x,a,L,p]),O=S.useMemo(()=>p.slice(p.indexOf(l)),[p,l]),{rect:V,node:q,isOver:$,setNodeRef:U}=FHt({id:l,data:I,disabled:E.droppable,resizeObserverConfig:{updateMeasurementsFor:O,...d}}),{active:se,activatorEvent:Y,activeNodeRect:J,attributes:X,setNodeRef:ce,listeners:ie,isDragging:ae,over:oe,setActivatorNodeRef:pe,transform:_e}=LHt({id:l,data:I,attributes:{...KHt,...r},disabled:E.draggable}),he=yVt(U,ce),we=!!se,je=we&&!b&&Yz(y)&&Yz(w),Ue=!k&&ae,Te=Ue&&je?_e:null,Fe=je?Te??(i??C)({rects:N,activeNodeRect:J,activeIndex:y,overIndex:w,index:L}):null,Le=Yz(y)&&Yz(w)?o({id:l,items:p,activeIndex:y,overIndex:w}):L,Ne=se==null?void 0:se.id,qe=S.useRef({activeId:Ne,items:p,newIndex:Le,containerId:x}),ze=p!==qe.current.items,ve=s({active:se,containerId:x,isDragging:ae,isSorting:we,id:l,index:L,items:p,newIndex:qe.current.newIndex,previousItems:qe.current.items,previousContainerId:qe.current.containerId,transition:u,wasDragging:qe.current.activeId!=null}),dt=ZHt({disabled:!ve,index:L,node:q,rect:V});return S.useEffect(()=>{we&&qe.current.newIndex!==Le&&(qe.current.newIndex=Le),x!==qe.current.containerId&&(qe.current.containerId=x),p!==qe.current.items&&(qe.current.items=p)},[we,Le,x,p]),S.useEffect(()=>{if(Ne===qe.current.activeId)return;if(Ne!=null&&qe.current.activeId==null){qe.current.activeId=Ne;return}const Ve=setTimeout(()=>{qe.current.activeId=Ne},50);return()=>clearTimeout(Ve)},[Ne]),{active:se,activeIndex:y,attributes:X,data:I,rect:V,index:L,newIndex:Le,items:p,isOver:$,isSorting:we,isDragging:ae,listeners:ie,node:q,overIndex:w,over:oe,setNodeRef:he,setActivatorNodeRef:pe,setDroppableNodeRef:U,setDraggableNodeRef:ce,transform:dt??Fe,transition:fe()};function fe(){if(dt||ze&&qe.current.newIndex===L)return WHt;if(!(Ue&&!p4e(Y)||!u)&&(we||ve))return sC.Transition.toString({...u,property:Ett})}}function YHt(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 xce(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 XHt=[eo.Down,eo.Right,eo.Up,eo.Left],QHt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(XHt.includes(t.code)){if(t.preventDefault(),!r||!n)return;const d=[];o.getEnabled().forEach(x=>{if(!x||x!=null&&x.disabled)return;const y=a.get(x.id);if(y)switch(t.code){case eo.Down:n.topy.top&&d.push(x);break;case eo.Left:n.left>y.left&&d.push(x);break;case eo.Right:n.left1&&(p=u[1].id),p!=null){const x=o.get(r.id),y=o.get(p),_=y?a.get(y.id):null,b=y==null?void 0:y.node.current;if(b&&_&&x&&y){const w=She(b).some((O,V)=>i[V]!==O),k=Ptt(x,y),C=JHt(x,y),E=w||!k?{x:0,y:0}:{x:C?n.width-_.width:0,y:C?n.height-_.height:0},L={x:_.left,y:_.top};return E.x&&E.y?L:wD(L,E)}}}};function Ptt(t,s){return!xce(t)||!xce(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function JHt(t,s){return!xce(t)||!xce(s)||!Ptt(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx(ga,{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(gr,{className:"h-3.5 w-3.5"})})]}),t.post_date&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(Qe,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[e.jsx(on,{className:"h-2.5 w-2.5"}),ps(new Date(t.post_date+"T00:00:00"),"MMM d")]})})]}),e.jsxs(Re,{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:t.caption}),e.jsxs(xo,{children:[e.jsx(go,{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(on,{className:"h-3 w-3"}),t.post_date?ps(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(lo,{className:"w-auto p-0",align:"start",children:[e.jsx(df,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:x=>n(t.id,x?ps(x,"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 tGt=()=>{const t=Jt(),[s,r]=S.useState("all"),[n,a]=S.useState(!1),[o,l]=S.useState(ps(new Date,"yyyy-MM")),[i,d]=S.useState([]),[u,p]=S.useState(!1),[x,y]=S.useState(null),[_,b]=S.useState(null),[N,w]=S.useState(""),[k,C]=S.useState(null),[E,L]=S.useState(!1),[I,O]=S.useState(!1),[V,q]=S.useState(ps(new Date,"yyyy-MM")),[$,U]=S.useState(null),[se,Y]=S.useState(""),[J,X]=S.useState(""),[ce,ie]=S.useState(""),[ae,oe]=S.useState(!1),pe=f4e(pce(rO,{activationConstraint:{distance:5}}),pce(y4e,{coordinateGetter:QHt})),{data:_e=[],isLoading:he}=gt({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:et,error:ht}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(ht)throw ht;return et}}),{data:we=[]}=gt({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:et,error:ht}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(ht)throw ht;return et}}),{data:je=[]}=gt({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:et,error:ht}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(ht)throw ht;return et}}),Ue=[...new Set(_e.map(et=>et.month))].sort((et,ht)=>ht.localeCompare(et)),Te=s==="all"?_e:_e.filter(et=>et.month===s),Me=et=>{const ht=Qje(et,"yyyy-MM",new Date);return ps(ht,"MMMM yyyy")},Fe=et=>{b(et),w(et.caption),C(et.post_date)},Le=async()=>{if(_){L(!0);try{const{error:et}=await G.from("social_swag_2").update({caption:N,post_date:k}).eq("id",_.id);if(et)throw et;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{L(!1)}}},Ne=async et=>{const{active:ht,over:xt}=et;if(!xt||ht.id===xt.id)return;const Ke=Te,Ze=Ke.findIndex(Yt=>Yt.id===ht.id),Et=Ke.findIndex(Yt=>Yt.id===xt.id);if(Ze===-1||Et===-1)return;const $t=b4e(Ke,Ze,Et);t.setQueryData(["admin-social-swag-2"],Yt=>{if(!Yt)return Yt;const Ps={};return $t.forEach((zs,Zs)=>{Ps[zs.id]=Zs}),Yt.map(zs=>Ps[zs.id]!==void 0?{...zs,sort_order:Ps[zs.id]}:zs).sort((zs,Zs)=>zs.month!==Zs.month?Zs.month.localeCompare(zs.month):zs.sort_order-Zs.sort_order)});try{await Promise.all($t.map((Yt,Ps)=>G.from("social_swag_2").update({sort_order:Ps}).eq("id",Yt.id)))}catch{me.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},qe=et=>{const xt=Array.from(et.target.files||[]).sort((Ke,Ze)=>Ke.name.localeCompare(Ze.name,void 0,{numeric:!0,sensitivity:"base"})).slice(0,16-i.length).map(Ke=>({file:Ke,preview:URL.createObjectURL(Ke),caption:""}));d(Ke=>[...Ke,...xt].slice(0,16))},ze=et=>{d(ht=>{const xt=[...ht];return URL.revokeObjectURL(xt[et].preview),xt.splice(et,1),xt})},ve=(et,ht)=>{d(xt=>{const Ke=[...xt];return Ke[et]={...Ke[et],caption:ht},Ke})},dt=async()=>{var ht;if(i.length===0){me.error("Please add at least one image");return}if(i.filter(xt=>!xt.caption.trim()).length>0){me.error("Please add captions to all images");return}p(!0);try{const{data:xt}=await G.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),Ke=(((ht=xt==null?void 0:xt[0])==null?void 0:ht.sort_order)??-1)+1;for(let Ze=0;Ze{const ht=et.image_url.split("/social-swag-2/");ht[1]&&await G.storage.from("social-swag-2").remove([ht[1]]);const{error:xt}=await G.from("social_swag_2").delete().eq("id",et.id);if(xt)throw xt},onSuccess:()=>{me.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>me.error("Failed to delete image")}),Ve=It({mutationFn:async({id:et,postDate:ht})=>{const{error:xt}=await G.from("social_swag_2").update({post_date:ht}).eq("id",et);if(xt)throw xt},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")}),Je=It({mutationFn:async({month:et,link:ht})=>{const{error:xt}=await G.from("social_swag_2_months").upsert({month:et,canva_link:ht||null},{onConflict:"month"});if(xt)throw xt},onSuccess:()=>{me.success("Canva link updated"),y(null),t.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>me.error("Failed to update Canva link")}),at=et=>{var ht;return((ht=we.find(xt=>xt.month===et))==null?void 0:ht.canva_link)||""},Ae=et=>je.find(ht=>ht.month===et)||null,Ye=et=>{var xt;const ht=(xt=et.target.files)==null?void 0:xt[0];ht&&(U(ht),Y(URL.createObjectURL(ht)))},We=()=>{se&&URL.revokeObjectURL(se),U(null),Y(""),X(""),ie("")},ot=async()=>{if(!$){me.error("Please select an image");return}oe(!0);try{const et=$.name.split(".").pop(),ht=`reels/${V}-${Date.now()}.${et}`,{error:xt}=await G.storage.from("social-swag-2").upload(ht,$);if(xt)throw xt;const{data:{publicUrl:Ke}}=G.storage.from("social-swag-2").getPublicUrl(ht),{error:Ze}=await G.from("social_swag_2_reels").upsert({month:V,image_url:Ke,canva_link:ce||null,caption:J||null},{onConflict:"month"});if(Ze)throw Ze;me.success("Reel uploaded successfully!"),H_e(`${Me(V)} Reel`,"social-swag-2"),We(),O(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(et){console.error("Reel upload error:",et),me.error("Failed to upload reel")}finally{oe(!1)}},Ge=It({mutationFn:async et=>{const ht=et.image_url.split("/social-swag-2/");ht[1]&&await G.storage.from("social-swag-2").remove([ht[1]]);const{error:xt}=await G.from("social_swag_2_reels").delete().eq("id",et.id);if(xt)throw xt},onSuccess:()=>{me.success("Reel deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>me.error("Failed to delete reel")});return e.jsxs(Es,{title:"Admin - Social Swag 2.0",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Social Swag 2.0"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage monthly social media images and captions"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(fs,{open:n,onOpenChange:a,children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Us,{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(xe,{children:"Month"}),e.jsx(De,{type:"month",value:o,onChange:et=>l(et.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{children:["Images (",i.length,"/16)"]}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",multiple:!0,onChange:qe,className:"hidden",id:"swag-upload",disabled:i.length>=16}),e.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[e.jsx($a,{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((et,ht)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative aspect-[4/5] rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:et.preview,alt:`Upload ${ht+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:()=>ze(ht),children:e.jsx(Sr,{className:"h-3 w-3"})})]}),e.jsx(vr,{placeholder:"Caption...",value:et.caption,onChange:xt=>ve(ht,xt.target.value),className:"text-xs h-20"})]},ht))}),e.jsx(K,{onClick:dt,disabled:u||i.length===0,className:"w-full gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx($a,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(fs,{open:I,onOpenChange:et=>{O(et),et||We()},children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(tu,{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(xe,{children:"Month"}),e.jsx(De,{type:"month",value:V,onChange:et=>q(et.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Reel Preview Image"}),se?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:se,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(se),U(null),Y("")},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:Ye,className:"hidden",id:"reel-upload"}),e.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[e.jsx(tu,{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(xe,{children:"Canva Download Link"}),e.jsx(De,{value:ce,onChange:et=>ie(et.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Caption"}),e.jsx(vr,{value:J,onChange:et=>X(et.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(K,{onClick:ot,disabled:ae||!$,className:"w-full gap-2",children:ae?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx($a,{className:"h-4 w-4"}),"Upload Reel"]})})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:_e.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:Ue.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ia,{value:s,onValueChange:r,children:e.jsxs(ea,{children:[e.jsx(ls,{value:"all",children:"All"}),Ue.map(et=>e.jsx(ls,{value:et,children:Me(et)},et))]})}),s!=="all"&&e.jsx(Pe,{children:e.jsx(Re,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(fo,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(xe,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",Me(s)]}),(x==null?void 0:x.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(De,{value:x.link,onChange:et=>y({...x,link:et.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(K,{size:"sm",onClick:()=>Je.mutate(x),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:at(s)||"No link set"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>y({month:s,link:at(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(Pe,{children:e.jsx(Re,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(tu,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(xe,{className:"text-sm text-muted-foreground",children:["Reel for ",Me(s)]}),(()=>{const et=Ae(s);return et?e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("img",{src:et.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:et.caption||"No caption"}),et.canva_link&&e.jsx("a",{href:et.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:()=>Ge.mutate(et),children:e.jsx(gr,{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(Wo,{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(_4e,{sensors:pe,collisionDetection:x4e,onDragEnd:Ne,children:e.jsx(w4e,{items:Te.map(et=>et.id),strategy:nO,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:Te.map(et=>e.jsx(eGt,{item:et,onEdit:Fe,onDelete:ht=>fe.mutate(ht),onDateChange:(ht,xt)=>Ve.mutate({id:ht,postDate:xt})},et.id))})})})]}),e.jsx(fs,{open:!!_,onOpenChange:et=>{et||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(xe,{children:"Caption"}),e.jsx(vr,{value:N,onChange:et=>w(et.target.value),placeholder:"Enter caption...",className:"h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Post Date"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(xo,{children:[e.jsx(go,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Rt("flex-1 justify-start gap-2 font-normal",!k&&"text-muted-foreground"),children:[e.jsx(on,{className:"h-4 w-4"}),k?ps(new Date(k+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(lo,{className:"w-auto p-0",align:"start",children:e.jsx(df,{mode:"single",selected:k?new Date(k+"T00:00:00"):void 0,onSelect:et=>C(et?ps(et,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),k&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(null),children:e.jsx(Sr,{className:"h-4 w-4"})})]})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(null),children:"Cancel"}),e.jsx(K,{onClick:Le,disabled:E,className:"gap-2",children:E?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},sGt=()=>{const{toast:t}=wa(),s=Jt(),[r,n]=S.useState("categories"),[a,o]=S.useState(!1),[l,i]=S.useState(null),[d,u]=S.useState({name:"",description:"",icon:""}),[p,x]=S.useState(!1),[y,_]=S.useState(null),[b,N]=S.useState({name:"",description:"",icon:""}),[w,k]=S.useState(!1),[C,E]=S.useState(null),[L,I]=S.useState(""),{data:O=[],isLoading:V}=gt({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:Ne,error:qe}=await G.from("community_categories").select("*").order("sort_order");if(qe)throw qe;return Ne}}),{data:q=[],isLoading:$}=gt({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:Ne,error:qe}=await G.from("community_private_groups").select("*").order("sort_order");if(qe)throw qe;return Ne}}),{data:U=[]}=gt({queryKey:["admin-group-members",C==null?void 0:C.id],queryFn:async()=>{if(!C)return[];const{data:Ne,error:qe}=await G.from("community_private_group_members").select("*").eq("group_id",C.id);if(qe)throw qe;return Ne},enabled:!!C}),{data:se=[]}=gt({queryKey:["admin-all-profiles"],queryFn:async()=>{let qe=[],ze=0,ve=!0;for(;ve;){const{data:dt,error:fe}=await G.from("profiles").select("id, name, email, brokerage_id").order("name").range(ze,ze+1e3-1);if(fe)throw fe;dt&&dt.length>0?(qe=[...qe,...dt],ze+=1e3,ve=dt.length===1e3):ve=!1}return qe}}),{data:Y=[]}=gt({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:Ne,error:qe}=await G.from("brokerages").select("*").order("name");if(qe)throw qe;return Ne}}),J=It({mutationFn:async Ne=>{if(Ne.id){const{error:qe}=await G.from("community_categories").update({name:Ne.name,description:Ne.description||null,icon:Ne.icon||null}).eq("id",Ne.id);if(qe)throw qe}else{const qe=Math.max(...O.map(ve=>ve.sort_order),0),{error:ze}=await G.from("community_categories").insert({name:Ne.name,description:Ne.description||null,icon:Ne.icon||null,sort_order:qe+1});if(ze)throw ze}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),u({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:Ne=>{t({title:"Error",description:Ne.message,variant:"destructive"})}}),X=It({mutationFn:async Ne=>{const{error:qe}=await G.from("community_categories").delete().eq("id",Ne);if(qe)throw qe},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),ce=It({mutationFn:async({id:Ne,direction:qe})=>{const ze=O.findIndex(ve=>ve.id===Ne);if(qe==="up"&&ze>0){const ve=O[ze-1],dt=O[ze];await G.from("community_categories").update({sort_order:dt.sort_order}).eq("id",ve.id),await G.from("community_categories").update({sort_order:ve.sort_order}).eq("id",dt.id)}else if(qe==="down"&&zes.invalidateQueries({queryKey:["admin-community-categories"]})}),ie=It({mutationFn:async Ne=>{if(Ne.id){const{error:qe}=await G.from("community_private_groups").update({name:Ne.name,description:Ne.description||null,icon:Ne.icon||null}).eq("id",Ne.id);if(qe)throw qe}else{const qe=Math.max(...q.map(ve=>ve.sort_order),0),{error:ze}=await G.from("community_private_groups").insert({name:Ne.name,description:Ne.description||null,icon:Ne.icon||null,sort_order:qe+1});if(ze)throw ze}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),x(!1),_(null),N({name:"",description:"",icon:""}),t({title:y?"Private group updated!":"Private group created!"})},onError:Ne=>{t({title:"Error",description:Ne.message,variant:"destructive"})}}),ae=It({mutationFn:async Ne=>{const{error:qe}=await G.from("community_private_groups").delete().eq("id",Ne);if(qe)throw qe},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),oe=It({mutationFn:async({id:Ne,direction:qe})=>{const ze=q.findIndex(ve=>ve.id===Ne);if(qe==="up"&&ze>0){const ve=q[ze-1],dt=q[ze];await G.from("community_private_groups").update({sort_order:dt.sort_order}).eq("id",ve.id),await G.from("community_private_groups").update({sort_order:ve.sort_order}).eq("id",dt.id)}else if(qe==="down"&&zes.invalidateQueries({queryKey:["admin-private-groups"]})}),pe=It({mutationFn:async({groupId:Ne,userId:qe,isMember:ze})=>{if(ze){const{error:ve}=await G.from("community_private_group_members").delete().eq("group_id",Ne).eq("user_id",qe);if(ve)throw ve}else{const{error:ve}=await G.from("community_private_group_members").insert({group_id:Ne,user_id:qe});if(ve)throw ve}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),_e=It({mutationFn:async({groupId:Ne,brokerageId:qe,isMember:ze})=>{if(ze){const{error:ve}=await G.from("community_private_group_members").delete().eq("group_id",Ne).eq("brokerage_id",qe);if(ve)throw ve}else{const{error:ve}=await G.from("community_private_group_members").insert({group_id:Ne,brokerage_id:qe});if(ve)throw ve}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),he=Ne=>{i(Ne),u({name:Ne.name,description:Ne.description||"",icon:Ne.icon||""}),o(!0)},we=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},je=Ne=>{_(Ne),N({name:Ne.name,description:Ne.description||"",icon:Ne.icon||""}),x(!0)},Ue=()=>{_(null),N({name:"",description:"",icon:""}),x(!0)},Te=Ne=>{E(Ne),I(""),k(!0)},Me=Ne=>U.some(qe=>qe.user_id===Ne),Fe=Ne=>U.some(qe=>qe.brokerage_id===Ne),Le=se.filter(Ne=>Ne.name.toLowerCase().includes(L.toLowerCase())||Ne.email.toLowerCase().includes(L.toLowerCase()));return e.jsx(Es,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(ia,{value:r,onValueChange:n,children:[e.jsxs(ea,{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(Us,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:V?e.jsx(Ms,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):O.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):O.map((Ne,qe)=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:qe===0,onClick:()=>ce.mutate({id:Ne.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:qe===O.length-1,onClick:()=>ce.mutate({id:Ne.id,direction:"down"}),children:"↓"})]})}),e.jsx(ut,{className:"text-2xl",children:Ne.icon||"📁"}),e.jsx(ut,{className:"font-medium",children:Ne.name}),e.jsx(ut,{className:"text-muted-foreground",children:Ne.description||"—"}),e.jsx(ut,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>he(Ne),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&X.mutate(Ne.id)},children:e.jsx(gr,{className:"h-4 w-4"})})]})})]},Ne.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(pa,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(K,{onClick:Ue,children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:$?e.jsx(Ms,{children:e.jsx(ut,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):q.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No private groups yet. Create your first one!"})}):q.map((Ne,qe)=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:qe===0,onClick:()=>oe.mutate({id:Ne.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:qe===q.length-1,onClick:()=>oe.mutate({id:Ne.id,direction:"down"}),children:"↓"})]})}),e.jsx(ut,{className:"text-2xl",children:Ne.icon||"🔒"}),e.jsx(ut,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Ne.name,Ne.brokerage_id?e.jsxs(Qe,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(pa,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:[e.jsx(yd,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(ut,{className:"text-muted-foreground",children:Ne.description||"—"}),e.jsx(ut,{children:e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Te(Ne),children:[e.jsx(lr,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex gap-1",children:[!Ne.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>je(Ne),children:e.jsx(ga,{className:"h-4 w-4"})}),!Ne.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this private group? All posts in this group will be deleted.")&&ae.mutate(Ne.id)},children:e.jsx(gr,{className:"h-4 w-4"})}),Ne.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},Ne.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(De,{value:d.icon,onChange:Ne=>u(qe=>({...qe,icon:Ne.target.value})),placeholder:"💬",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(De,{value:d.name,onChange:Ne=>u(qe=>({...qe,name:Ne.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(vr,{value:d.description,onChange:Ne=>u(qe=>({...qe,description:Ne.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:x,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(De,{value:b.icon,onChange:Ne=>N(qe=>({...qe,icon:Ne.target.value})),placeholder:"🔒",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(De,{value:b.name,onChange:Ne=>N(qe=>({...qe,name:Ne.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(vr,{value:b.description,onChange:Ne=>N(qe=>({...qe,description:Ne.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:()=>x(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>ie.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:k,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(ia,{defaultValue:"brokerages",children:[e.jsxs(ea,{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(ui,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Y.map(Ne=>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(Ki,{checked:Fe(Ne.id),onCheckedChange:()=>{C&&_e.mutate({groupId:C.id,brokerageId:Ne.id,isMember:Fe(Ne.id)})}}),e.jsx("span",{className:"font-medium",children:Ne.name})]}),e.jsxs(Qe,{variant:"secondary",children:[se.filter(qe=>qe.brokerage_id===Ne.id).length," agents"]})]},Ne.id)),Y.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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search users...",value:L,onChange:Ne=>I(Ne.target.value),className:"pl-9"})]}),e.jsx(ui,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Le.map(Ne=>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(Ki,{checked:Me(Ne.id),onCheckedChange:()=>{C&&pe.mutate({groupId:C.id,userId:Ne.id,isMember:Me(Ne.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ne.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:Ne.email})]})]})},Ne.id)),Le.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No users found"})]})})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{onClick:()=>k(!1),children:"Done"})})]})]})})]})})},pDe=t=>{switch(t){case"academy_video":return e.jsx(So,{className:"h-3 w-3"});case"template":return e.jsx(fn,{className:"h-3 w-3"});case"toolbox":return e.jsx(nl,{className:"h-3 w-3"});case"newsletter":return e.jsx(Qv,{className:"h-3 w-3"});case"social_swag":return e.jsx($r,{className:"h-3 w-3"});default:return e.jsx(Kr,{className:"h-3 w-3"})}},rGt=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}},nGt=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}},aGt=()=>{const{toast:t}=wa(),[s,r]=S.useState([]),[n,a]=S.useState([]),[o,l]=S.useState([]),[i,d]=S.useState(!0),[u,p]=S.useState(""),[x,y]=S.useState(null),[_,b]=S.useState([]),[N,w]=S.useState([]);S.useEffect(()=>{k()},[]);const k=async()=>{try{d(!0);const{data:U,error:se}=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(se)throw se;const{data:Y,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 X=[...new Set((Y==null?void 0:Y.map(he=>he.user_id))||[])],{data:ce}=await G.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",X),ie=new Map((ce==null?void 0:ce.map(he=>[he.id,he]))||[]),ae=(U==null?void 0:U.map(he=>{var we,je,Ue,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:((je=he.profiles)==null?void 0:je.email)||"Unknown",brokerage_name:((Te=(Ue=he.profiles)==null?void 0:Ue.brokerages)==null?void 0:Te.name)||null}}))||[],oe=(Y==null?void 0:Y.map(he=>{var je;const we=ie.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:((je=we==null?void 0:we.brokerages)==null?void 0:je.name)||null}}))||[];r(ae),a(oe);const pe=new Map;ae.forEach(he=>{if(!pe.has(he.user_id))pe.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=pe.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)}}),oe.forEach(he=>{if(!pe.has(he.user_id))pe.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=pe.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 _e=Array.from(pe.values()).sort((he,we)=>new Date(we.last_activity_at).getTime()-new Date(he.last_activity_at).getTime());l(_e)}catch(U){console.error("Error loading activity:",U),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{d(!1)}},C=U=>{y({id:U.user_id,name:U.user_name,email:U.user_email});const se=s.filter(J=>J.user_id===U.user_id),Y=n.filter(J=>J.user_id===U.user_id);b(se),w(Y)},E=()=>{y(null),b([]),w([])},{sortKey:L,sortDirection:I,handleSort:O,sortData:V}=QR("last_activity_at","desc"),q=o.filter(U=>{var Y;if(!u)return!0;const se=u.toLowerCase();return U.user_name.toLowerCase().includes(se)||U.user_email.toLowerCase().includes(se)||((Y=U.brokerage_name)==null?void 0:Y.toLowerCase().includes(se))}),$=V(q,{user:U=>{var se;return((se=U.user_name)==null?void 0:se.toLowerCase())||""},brokerage:U=>{var se;return((se=U.brokerage_name)==null?void 0:se.toLowerCase())||""},last_activity_at:U=>new Date(U.last_activity_at).getTime(),apps:U=>U.total_app_launches,content:U=>U.total_content_views});return i?e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"User Activity"}),e.jsx(hr,{children:"App launches and content engagement - click to see full history"})]}),e.jsxs(Re,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name, email, or brokerage...",value:u,onChange:U=>p(U.target.value),className:"pl-9"})]})}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Ko,{sortKey:"user",currentSortKey:L,currentDirection:I,onSort:O,children:"User"}),e.jsx(Ko,{sortKey:"brokerage",currentSortKey:L,currentDirection:I,onSort:O,children:"Brokerage"}),e.jsx(Nt,{children:"Last Activity"}),e.jsx(Ko,{sortKey:"last_activity_at",currentSortKey:L,currentDirection:I,onSort:O,children:"Last Active"}),e.jsx(Ko,{sortKey:"apps",currentSortKey:L,currentDirection:I,onSort:O,className:"text-right",children:"Apps"}),e.jsx(Ko,{sortKey:"content",currentSortKey:L,currentDirection:I,onSort:O,className:"text-right",children:"Content"})]})}),e.jsx(Dn,{children:$.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):$.map(U=>e.jsxs(Ms,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>C(U),children:[e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:U.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:U.user_email})]})}),e.jsx(ut,{children:U.brokerage_name?e.jsx(Qe,{variant:"outline",children:U.brokerage_name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(ut,{children:e.jsx("div",{className:"flex items-center gap-2",children:U.last_activity_type==="app"?e.jsxs(Qe,{variant:"secondary",children:[e.jsx(Kr,{className:"h-3 w-3 mr-1"}),U.last_activity_name]}):e.jsxs(Qe,{variant:"outline",className:"flex items-center gap-1",children:[pDe(U.last_activity_type),e.jsx("span",{className:"max-w-32 truncate",children:U.last_activity_name})]})})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:gl(new Date(U.last_activity_at),{addSuffix:!0})}),e.jsx(ut,{className:"text-right",children:e.jsx(Qe,{variant:"outline",children:U.total_app_launches})}),e.jsx(ut,{className:"text-right",children:e.jsx(Qe,{variant:"outline",children:U.total_content_views})})]},U.user_id))})]})})]})]}),e.jsx(fs,{open:!!x,onOpenChange:U=>!U&&E(),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:[x==null?void 0:x.name,"'s Activity"]}),e.jsx(Ir,{children:x==null?void 0:x.email})]}),e.jsxs(ia,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(ea,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Nt,{children:"Type"}),e.jsx(Nt,{children:"Resource"}),e.jsx(Nt,{children:"Action"}),e.jsx(Nt,{children:"Time"})]})}),e.jsx(Dn,{children:N.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):N.map(U=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsxs(Qe,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[pDe(U.resource_type),rGt(U.resource_type)]})}),e.jsx(ut,{className:"max-w-48",children:e.jsx("span",{className:"truncate block",children:U.resource_title})}),e.jsx(ut,{children:e.jsx(Qe,{variant:"secondary",children:nGt(U.action_type)})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:gl(new Date(U.created_at),{addSuffix:!0})})]},U.id))})]})})}),e.jsx(js,{value:"apps",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Nt,{children:"App"}),e.jsx(Nt,{children:"Time"})]})}),e.jsx(Dn,{children:_.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):_.map(U=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsx(Qe,{variant:"secondary",children:U.app_name})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:gl(new Date(U.launched_at),{addSuffix:!0})})]},U.id))})]})})})]})]})})]})},iGt=()=>{const{toast:t}=wa(),[s,r]=S.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=S.useState(!0);S.useEffect(()=>{o()},[]);const o=async()=>{try{a(!0);const{count:l}=await G.from("profiles").select("*",{count:"exact",head:!0}),{count:i}=await G.from("profiles").select("*",{count:"exact",head:!0}).not("last_login","is",null),d=(l||0)-(i||0),{count:u}=await G.from("brokerages").select("*",{count:"exact",head:!0}),{count:p}=await G.from("activity_logs").select("*",{count:"exact",head:!0}),x=new Date;x.setDate(x.getDate()-7);const{count:y}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",x.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",x.toISOString()),w=new Set(N==null?void 0:N.map(k=>k.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(Pe,{children:e.jsx(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(lr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(ti,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(ln,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(pa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(ih,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(ih,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(ih,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(Yo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.uniqueActiveThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},fDe={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},xDe={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 Itt({brokerageOnly:t=!1,brokerageId:s}){const[r,n]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(""),[d,u]=S.useState("all");S.useEffect(()=>{p()},[s]);const p=async()=>{o(!0);try{let O=[];if(t&&s){const{data:X}=await G.from("profiles").select("id").eq("brokerage_id",s);if(O=(X==null?void 0:X.map(ce=>ce.id))||[],O.length===0){n([]),o(!1);return}}let V=G.from("resource_shares").select("*").order("created_at",{ascending:!1});t&&O.length>0&&(V=V.or(`sender_id.in.(${O.join(",")}),recipient_id.in.(${O.join(",")})`));const{data:q,error:$}=await V;if($)throw $;const U=new Set;q==null||q.forEach(X=>{U.add(X.sender_id),U.add(X.recipient_id)});const{data:se}=await G.from("profiles").select("id, name, email").in("id",Array.from(U)),Y=new Map((se==null?void 0:se.map(X=>[X.id,X]))||[]),J=(q==null?void 0:q.map(X=>({...X,sender:Y.get(X.sender_id),recipient:Y.get(X.recipient_id)})))||[];n(J)}catch(O){console.error("Error loading shares:",O)}finally{o(!1)}},{sortKey:x,sortDirection:y,handleSort:_,sortData:b}=QR("created_at","desc"),N=r.filter(O=>{var $,U;const V=l===""||O.resource_title.toLowerCase().includes(l.toLowerCase())||(($=O.sender)==null?void 0:$.name.toLowerCase().includes(l.toLowerCase()))||((U=O.recipient)==null?void 0:U.name.toLowerCase().includes(l.toLowerCase())),q=d==="all"||O.resource_type===d;return V&&q}),w=b(N,{resource:O=>{var V;return((V=O.resource_title)==null?void 0:V.toLowerCase())||""},type:O=>O.resource_type,sender:O=>{var V,q;return((q=(V=O.sender)==null?void 0:V.name)==null?void 0:q.toLowerCase())||""},recipient:O=>{var V,q;return((q=(V=O.recipient)==null?void 0:V.name)==null?void 0:q.toLowerCase())||""},status:O=>O.is_read?1:0,created_at:O=>new Date(O.created_at).getTime()}),k=r.length,C=new Set(r.map(O=>O.sender_id)).size,E=new Set(r.map(O=>O.recipient_id)).size,L=r.length>0?Math.round(r.filter(O=>O.is_read).length/r.length*100):0,I=r.reduce((O,V)=>(O[V.resource_type]=(O[V.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,V)=>e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ns,{className:"h-4 w-20"})}),e.jsx(Re,{children:e.jsx(Ns,{className:"h-8 w-16"})})]},V))}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-6",children:e.jsx(Ns,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(vd,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:k})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(lr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:C})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(Yo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:E})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(fn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[L,"%"]})})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),e.jsx(Re,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(I).map(([O,V])=>e.jsxs(Qe,{variant:"secondary",className:xDe[O],children:[fDe[O],": ",V]},O)),Object.keys(I).length===0&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"Share History"}),e.jsxs(hr,{children:["All resource shares ",t?"in your brokerage":"across the platform"]})]}),e.jsxs(Re,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by resource, sender, or recipient...",value:l,onChange:O=>i(O.target.value),className:"pl-9"})]}),e.jsxs(Bs,{value:d,onValueChange:u,children:[e.jsx(Rs,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"Resource type"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Types"}),e.jsx(vt,{value:"event",children:"Events"}),e.jsx(vt,{value:"template",children:"Templates"}),e.jsx(vt,{value:"academy_video",children:"Academy Videos"}),e.jsx(vt,{value:"resource_kit",children:"Resource Kits"}),e.jsx(vt,{value:"newsletter",children:"Newsletters"}),e.jsx(vt,{value:"social_swag",children:"Social Swag"})]})]})]}),e.jsx(ui,{className:"h-[400px]",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Ko,{sortKey:"resource",currentSortKey:x,currentDirection:y,onSort:_,children:"Resource"}),e.jsx(Ko,{sortKey:"type",currentSortKey:x,currentDirection:y,onSort:_,children:"Type"}),e.jsx(Ko,{sortKey:"sender",currentSortKey:x,currentDirection:y,onSort:_,children:"Sender"}),e.jsx(Ko,{sortKey:"recipient",currentSortKey:x,currentDirection:y,onSort:_,children:"Recipient"}),e.jsx(Ko,{sortKey:"status",currentSortKey:x,currentDirection:y,onSort:_,children:"Status"}),e.jsx(Ko,{sortKey:"created_at",currentSortKey:x,currentDirection:y,onSort:_,children:"Date"})]})}),e.jsx(Dn,{children:w.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):w.map(O=>{var V,q;return e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium max-w-[200px] truncate",children:O.resource_title}),e.jsx(ut,{children:e.jsx(Qe,{variant:"secondary",className:xDe[O.resource_type],children:fDe[O.resource_type]})}),e.jsx(ut,{children:((V=O.sender)==null?void 0:V.name)||"Unknown"}),e.jsx(ut,{children:((q=O.recipient)==null?void 0:q.name)||"Unknown"}),e.jsx(ut,{children:e.jsx(Qe,{variant:O.is_read?"default":"outline",children:O.is_read?"Read":"Unread"})}),e.jsx(ut,{className:"text-muted-foreground",children:ps(new Date(O.created_at),"MMM d, yyyy")})]},O.id)})})]})})]})]})]})}const Tye={academy_video:{label:"Academy Videos",icon:Tn,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:wn},template:{label:"Templates",icon:Mv,color:"bg-blue-100 text-blue-800",actionLabel:"Accessed",actionIcon:nu},toolbox:{label:"Toolkit",icon:Ig,color:"bg-amber-100 text-amber-800",actionLabel:"Downloaded",actionIcon:Xa},newsletter:{label:"Newsletters",icon:rr,color:"bg-emerald-100 text-emerald-800",actionLabel:"Clicked",actionIcon:nu},social_swag:{label:"Social Swag",icon:Dl,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:nu},event:{label:"Events",icon:on,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:nu}};function gDe(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function oGt(t,s){return t==="toolbox"?s.downloads:s.clicks}function lGt(){var O;const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(null),l=S.useRef(null),{sortKey:i,sortDirection:d,handleSort:u,sortData:p}=QR("total_views","desc");S.useEffect(()=>{x()},[]);const x=async()=>{try{const{data:V,error:q}=await G.rpc("get_admin_content_engagement");if(q)throw q;s(V||[])}catch(V){console.error("Error loading content engagement:",V)}finally{n(!1)}},y=V=>{o(q=>{const $=q===V?null:V;return requestAnimationFrame(()=>{var U;(U=l.current)==null||U.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((V,q)=>e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ns,{className:"h-4 w-20"})}),e.jsx(Re,{children:e.jsx(Ns,{className:"h-8 w-16"})})]},q))}),e.jsx(Pe,{children:e.jsx(Re,{className:"py-8",children:e.jsx(Ns,{className:"h-64 w-full"})})})]});const _=t.reduce((V,q)=>V+q.total_views,0),b=t.reduce((V,q)=>V+q.total_clicks,0),N=t.reduce((V,q)=>V+q.total_downloads,0),w=t.length,k=t.reduce((V,q)=>(V[q.resource_type]||(V[q.resource_type]={views:0,clicks:0,downloads:0,assets:0,uniqueUsers:0}),V[q.resource_type].views+=q.total_views,V[q.resource_type].clicks+=q.total_clicks,V[q.resource_type].downloads+=q.total_downloads,V[q.resource_type].assets+=1,V[q.resource_type].uniqueUsers+=q.unique_users,V),{}),C=a?t.filter(V=>V.resource_type===a):t,E=p(C,{asset:V=>{var q;return((q=V.resource_title)==null?void 0:q.toLowerCase())||""},type:V=>V.resource_type,views:V=>V.total_views,actions:V=>gDe(V),unique_users:V=>V.unique_users,last_activity:V=>V.last_engaged_at?new Date(V.last_engaged_at).getTime():0}),L=a?Tye[a]||{label:a,icon:wn,color:"bg-muted text-muted-foreground",actionLabel:"Actions",actionIcon:nu}:null,I=L==null?void 0:L.icon;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-5",children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(nu,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(Yo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(nu,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(hr,{children:"Click a category to see individual asset performance"})]}),e.jsx(Re,{children:e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-3",children:Object.entries(k).map(([V,q])=>{const $=Tye[V]||{label:V,icon:wn,color:"bg-muted text-muted-foreground",actionLabel:"Actions",actionIcon:nu},U=$.icon,se=a===V;return e.jsxs("button",{type:"button",onClick:()=>y(V),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors cursor-pointer ${se?"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(U,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:$.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(wn,{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"})," ",oGt(V,q)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lr,{className:"h-3 w-3"})," ",q.uniqueUsers]})]})]}),e.jsxs(Qe,{variant:"secondary",className:"text-[10px]",children:[q.assets," items"]})]},V)})})})]}),e.jsx("div",{ref:l,children:e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{className:"text-sm font-medium flex items-center gap-2",children:L&&I?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"h-4 w-4"}),L.label," — Top Performers"]}):"Top Content by Engagement"}),e.jsx(hr,{children:a?`${C.length} ${((O=L==null?void 0:L.label)==null?void 0:O.toLowerCase())||"items"} ranked by total interactions`:"All tracked assets ranked by total interactions"})]}),a&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>o(null),className:"gap-1",children:[e.jsx(Fa,{className:"h-3.5 w-3.5"}),"Show All"]})]})}),e.jsx(Re,{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(ui,{className:"h-[400px]",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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:L?L.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(Dn,{children:E.map((V,q)=>{const $=Tye[V.resource_type]||{label:V.resource_type,color:"bg-muted text-muted-foreground",actionLabel:"Actions",actionIcon:nu};return e.jsxs(Ms,{children:[e.jsx(ut,{className:"text-muted-foreground text-xs",children:q+1}),e.jsx(ut,{children:e.jsx("p",{className:"font-medium text-sm truncate max-w-[250px]",children:V.resource_title})}),!a&&e.jsx(ut,{children:e.jsx(Qe,{className:`text-[10px] ${$.color}`,children:$.label})}),e.jsx(ut,{className:"text-right font-medium",children:V.total_views}),e.jsx(ut,{className:"text-right font-medium",children:gDe(V)}),e.jsx(ut,{className:"text-right",children:V.unique_users}),e.jsx(ut,{className:"text-xs text-muted-foreground",children:V.last_engaged_at?gl(new Date(V.last_engaged_at),{addSuffix:!0}):"—"})]},`${V.resource_type}-${V.resource_id}`)})})]})})})]})})]})}var cGt=Array.isArray,wp=cGt,dGt=typeof md=="object"&&md&&md.Object===Object&&md,Ltt=dGt,uGt=Ltt,hGt=typeof self=="object"&&self&&self.Object===Object&&self,mGt=uGt||hGt||Function("return this")(),N0=mGt,pGt=N0,fGt=pGt.Symbol,aO=fGt,yDe=aO,Dtt=Object.prototype,xGt=Dtt.hasOwnProperty,gGt=Dtt.toString,aI=yDe?yDe.toStringTag:void 0;function yGt(t){var s=xGt.call(t,aI),r=t[aI];try{t[aI]=void 0;var n=!0}catch{}var a=gGt.call(t);return n&&(s?t[aI]=r:delete t[aI]),a}var vGt=yGt,_Gt=Object.prototype,bGt=_Gt.toString;function wGt(t){return bGt.call(t)}var jGt=wGt,vDe=aO,NGt=vGt,kGt=jGt,SGt="[object Null]",CGt="[object Undefined]",_De=vDe?vDe.toStringTag:void 0;function MGt(t){return t==null?t===void 0?CGt:SGt:_De&&_De in Object(t)?NGt(t):kGt(t)}var S1=MGt;function TGt(t){return t!=null&&typeof t=="object"}var C1=TGt,AGt=S1,EGt=C1,PGt="[object Symbol]";function IGt(t){return typeof t=="symbol"||EGt(t)&&AGt(t)==PGt}var aE=IGt,LGt=wp,DGt=aE,RGt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,OGt=/^\w*$/;function FGt(t,s){if(LGt(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||DGt(t)?!0:OGt.test(t)||!RGt.test(t)||s!=null&&t in Object(s)}var N4e=FGt;function zGt(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var bw=zGt;const iE=so(bw);var BGt=S1,$Gt=bw,qGt="[object AsyncFunction]",UGt="[object Function]",VGt="[object GeneratorFunction]",HGt="[object Proxy]";function GGt(t){if(!$Gt(t))return!1;var s=BGt(t);return s==UGt||s==VGt||s==qGt||s==HGt}var k4e=GGt;const ci=so(k4e);var WGt=N0,KGt=WGt["__core-js_shared__"],ZGt=KGt,Aye=ZGt,bDe=function(){var t=/[^.]+$/.exec(Aye&&Aye.keys&&Aye.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function YGt(t){return!!bDe&&bDe in t}var XGt=YGt,QGt=Function.prototype,JGt=QGt.toString;function eWt(t){if(t!=null){try{return JGt.call(t)}catch{}try{return t+""}catch{}}return""}var Rtt=eWt,tWt=k4e,sWt=XGt,rWt=bw,nWt=Rtt,aWt=/[\\^$.*+?()[\]{}|]/g,iWt=/^\[object .+?Constructor\]$/,oWt=Function.prototype,lWt=Object.prototype,cWt=oWt.toString,dWt=lWt.hasOwnProperty,uWt=RegExp("^"+cWt.call(dWt).replace(aWt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function hWt(t){if(!rWt(t)||sWt(t))return!1;var s=tWt(t)?uWt:iWt;return s.test(nWt(t))}var mWt=hWt;function pWt(t,s){return t==null?void 0:t[s]}var fWt=pWt,xWt=mWt,gWt=fWt;function yWt(t,s){var r=gWt(t,s);return xWt(r)?r:void 0}var kC=yWt,vWt=kC,_Wt=vWt(Object,"create"),The=_Wt,wDe=The;function bWt(){this.__data__=wDe?wDe(null):{},this.size=0}var wWt=bWt;function jWt(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var NWt=jWt,kWt=The,SWt="__lodash_hash_undefined__",CWt=Object.prototype,MWt=CWt.hasOwnProperty;function TWt(t){var s=this.__data__;if(kWt){var r=s[t];return r===SWt?void 0:r}return MWt.call(s,t)?s[t]:void 0}var AWt=TWt,EWt=The,PWt=Object.prototype,IWt=PWt.hasOwnProperty;function LWt(t){var s=this.__data__;return EWt?s[t]!==void 0:IWt.call(s,t)}var DWt=LWt,RWt=The,OWt="__lodash_hash_undefined__";function FWt(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=RWt&&s===void 0?OWt:s,this}var zWt=FWt,BWt=wWt,$Wt=NWt,qWt=AWt,UWt=DWt,VWt=zWt;function oE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var oKt=iKt,lKt=Ahe;function cKt(t,s){var r=this.__data__,n=lKt(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var dKt=cKt,uKt=WWt,hKt=tKt,mKt=nKt,pKt=oKt,fKt=dKt;function lE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},b4=function(s){return rC(s)&&s.indexOf("%")===s.length-1},en=function(s){return OZt(s)&&!iO(s)},$Zt=function(s){return yi(s)},lu=function(s){return en(s)||rC(s)},qZt=0,dE=function(s){var r=++qZt;return"".concat(s||"").concat(r)},jm=function(s,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!en(s)&&!rC(s))return n;var o;if(b4(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return iO(o)&&(o=n),a&&o>r&&(o=r),o},G_=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},UZt=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 YZt(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 Q_e(t){"@babel/helpers - typeof";return Q_e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Q_e(t)}var TDe={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"},s1=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},ADe=null,Pye=null,D4e=function t(s){if(s===ADe&&Array.isArray(Pye))return Pye;var r=[];return S.Children.forEach(s,function(n){yi(n)||(PZt.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),Pye=r,ADe=s,r};function hf(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return s1(a)}):n=[s1(s)],D4e(t).forEach(function(a){var o=uf(a,"type.displayName")||uf(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function Wp(t,s){var r=hf(t,s);return r&&r[0]}var EDe=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!en(n)||n<=0||!en(a)||a<=0)},XZt=["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"],QZt=function(s){return s&&s.type&&rC(s.type)&&XZt.indexOf(s.type)>=0},JZt=function(s){return s&&Q_e(s)==="object"&&"clipDot"in s},eYt=function(s,r,n,a){var o,l=(o=Eye==null?void 0:Eye[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!ci(s)&&(a&&l.includes(r)||GZt.includes(r))||n&&L4e.includes(r)},qa=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(S.isValidElement(s)&&(a=s.props),!iE(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;eYt((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},J_e=function t(s,r){if(s===r)return!0;var n=S.Children.count(s);if(n!==S.Children.count(r))return!1;if(n===0)return!0;if(n===1)return PDe(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 aYt(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 tbe(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=nYt(t,rYt),p=a||{width:r,height:n,x:0,y:0},x=_i("recharts-surface",o);return ft.createElement("svg",ebe({},qa(u,!0,"svg"),{className:x,width:r,height:n,style:l,viewBox:"".concat(p.x," ").concat(p.y," ").concat(p.width," ").concat(p.height)}),ft.createElement("title",null,i),ft.createElement("desc",null,d),s)}var iYt=["children","className"];function sbe(){return sbe=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 lYt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var jo=ft.forwardRef(function(t,s){var r=t.children,n=t.className,a=oYt(t,iYt),o=_i("recharts-layer",n);return ft.createElement("g",sbe({className:o},qa(a,!0),{ref:s}),r)}),Dg=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:uYt(t,s,r)}var mYt=hYt,pYt="\\ud800-\\udfff",fYt="\\u0300-\\u036f",xYt="\\ufe20-\\ufe2f",gYt="\\u20d0-\\u20ff",yYt=fYt+xYt+gYt,vYt="\\ufe0e\\ufe0f",_Yt="\\u200d",bYt=RegExp("["+_Yt+pYt+yYt+vYt+"]");function wYt(t){return bYt.test(t)}var Gtt=wYt;function jYt(t){return t.split("")}var NYt=jYt,Wtt="\\ud800-\\udfff",kYt="\\u0300-\\u036f",SYt="\\ufe20-\\ufe2f",CYt="\\u20d0-\\u20ff",MYt=kYt+SYt+CYt,TYt="\\ufe0e\\ufe0f",AYt="["+Wtt+"]",rbe="["+MYt+"]",nbe="\\ud83c[\\udffb-\\udfff]",EYt="(?:"+rbe+"|"+nbe+")",Ktt="[^"+Wtt+"]",Ztt="(?:\\ud83c[\\udde6-\\uddff]){2}",Ytt="[\\ud800-\\udbff][\\udc00-\\udfff]",PYt="\\u200d",Xtt=EYt+"?",Qtt="["+TYt+"]?",IYt="(?:"+PYt+"(?:"+[Ktt,Ztt,Ytt].join("|")+")"+Qtt+Xtt+")*",LYt=Qtt+Xtt+IYt,DYt="(?:"+[Ktt+rbe+"?",rbe,Ztt,Ytt,AYt].join("|")+")",RYt=RegExp(nbe+"(?="+nbe+")|"+DYt+LYt,"g");function OYt(t){return t.match(RYt)||[]}var FYt=OYt,zYt=NYt,BYt=Gtt,$Yt=FYt;function qYt(t){return BYt(t)?$Yt(t):zYt(t)}var UYt=qYt,VYt=mYt,HYt=Gtt,GYt=UYt,WYt=Btt;function KYt(t){return function(s){s=WYt(s);var r=HYt(s)?GYt(s):void 0,n=r?r[0]:s.charAt(0),a=r?VYt(r,1).join(""):s.slice(1);return n[t]()+a}}var ZYt=KYt,YYt=ZYt,XYt=YYt("toUpperCase"),QYt=XYt;const Vhe=so(QYt);function Nl(t){return function(){return t}}const Jtt=Math.cos,vce=Math.sin,Wg=Math.sqrt,_ce=Math.PI,Hhe=2*_ce,abe=Math.PI,ibe=2*abe,s4=1e-6,JYt=ibe-s4;function est(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return est;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;as4)if(!(Math.abs(x*d-u*p)>s4)||!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,k=Math.sqrt(N),C=Math.sqrt(y),E=o*Math.tan((abe-Math.acos((N+y-w)/(2*k*C)))/2),L=E/C,I=E/k;Math.abs(L-1)>s4&&this._append`L${s+L*p},${r+L*x}`,this._append`A${o},${o},0,0,${+(x*_>p*b)},${this._x1=s+I*d},${this._y1=r+I*u}`}}arc(s,r,n,a,o,l){if(s=+s,r=+r,n=+n,l=!!l,n<0)throw new Error(`negative radius: ${n}`);let i=n*Math.cos(a),d=n*Math.sin(a),u=s+i,p=r+d,x=1^l,y=l?a-o:o-a;this._x1===null?this._append`M${u},${p}`:(Math.abs(this._x1-u)>s4||Math.abs(this._y1-p)>s4)&&this._append`L${u},${p}`,n&&(y<0&&(y=y%ibe+ibe),y>JYt?this._append`A${n},${n},0,1,${x},${s-i},${r-d}A${n},${n},0,1,${x},${this._x1=u},${this._y1=p}`:y>s4&&this._append`A${n},${n},0,${+(y>=abe)},${x},${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 R4e(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 tXt(s)}function O4e(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function tst(t){this._context=t}tst.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 Ghe(t){return new tst(t)}function sst(t){return t[0]}function rst(t){return t[1]}function nst(t,s){var r=Nl(!0),n=null,a=Ghe,o=null,l=R4e(i);t=typeof t=="function"?t:t===void 0?sst:Nl(t),s=typeof s=="function"?s:s===void 0?rst:Nl(s);function i(d){var u,p=(d=O4e(d)).length,x,y=!1,_;for(n==null&&(o=a(_=l())),u=0;u<=p;++u)!(u=_;--b)i.point(E[b],L[b]);i.lineEnd(),i.areaEnd()}k&&(E[y]=+t(w,y,x),L[y]=+s(w,y,x),i.point(n?+n(w,y,x):E[y],r?+r(w,y,x):L[y]))}if(C)return i=null,C+""||null}function p(){return nst().defined(a).curve(l).context(o)}return u.x=function(x){return arguments.length?(t=typeof x=="function"?x:Nl(+x),n=null,u):t},u.x0=function(x){return arguments.length?(t=typeof x=="function"?x:Nl(+x),u):t},u.x1=function(x){return arguments.length?(n=x==null?null:typeof x=="function"?x:Nl(+x),u):n},u.y=function(x){return arguments.length?(s=typeof x=="function"?x:Nl(+x),r=null,u):s},u.y0=function(x){return arguments.length?(s=typeof x=="function"?x:Nl(+x),u):s},u.y1=function(x){return arguments.length?(r=x==null?null:typeof x=="function"?x:Nl(+x),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(x){return arguments.length?(a=typeof x=="function"?x:Nl(!!x),u):a},u.curve=function(x){return arguments.length?(l=x,o!=null&&(i=l(o)),u):l},u.context=function(x){return arguments.length?(x==null?o=i=null:i=l(o=x),u):o},u}class ast{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 sXt(t){return new ast(t,!0)}function rXt(t){return new ast(t,!1)}const F4e={draw(t,s){const r=Wg(s/_ce);t.moveTo(r,0),t.arc(0,0,r,0,Hhe)}},nXt={draw(t,s){const r=Wg(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=Wg(1/3),aXt=ist*2,iXt={draw(t,s){const r=Wg(s/aXt),n=r*ist;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},oXt={draw(t,s){const r=Wg(s),n=-r/2;t.rect(n,n,r,r)}},lXt=.8908130915292852,ost=vce(_ce/10)/vce(7*_ce/10),cXt=vce(Hhe/10)*ost,dXt=-Jtt(Hhe/10)*ost,uXt={draw(t,s){const r=Wg(s*lXt),n=cXt*r,a=dXt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=Hhe*o/5,i=Jtt(l),d=vce(l);t.lineTo(d*r,-i*r),t.lineTo(i*n-d*a,d*n+i*a)}t.closePath()}},Iye=Wg(3),hXt={draw(t,s){const r=-Wg(s/(Iye*3));t.moveTo(0,r*2),t.lineTo(-Iye*r,-r),t.lineTo(Iye*r,-r),t.closePath()}},Uf=-.5,Vf=Wg(3)/2,obe=1/Wg(12),mXt=(obe/2+1)*3,pXt={draw(t,s){const r=Wg(s/mXt),n=r/2,a=r*obe,o=n,l=r*obe+r,i=-o,d=l;t.moveTo(n,a),t.lineTo(o,l),t.lineTo(i,d),t.lineTo(Uf*n-Vf*a,Vf*n+Uf*a),t.lineTo(Uf*o-Vf*l,Vf*o+Uf*l),t.lineTo(Uf*i-Vf*d,Vf*i+Uf*d),t.lineTo(Uf*n+Vf*a,Uf*a-Vf*n),t.lineTo(Uf*o+Vf*l,Uf*l-Vf*o),t.lineTo(Uf*i+Vf*d,Uf*d-Vf*i),t.closePath()}};function fXt(t,s){let r=null,n=R4e(a);t=typeof t=="function"?t:Nl(t||F4e),s=typeof s=="function"?s:Nl(s===void 0?64:+s);function a(){let o;if(r||(r=o=n()),t.apply(this,arguments).draw(r,+s.apply(this,arguments)),o)return r=null,o+""||null}return a.type=function(o){return arguments.length?(t=typeof o=="function"?o:Nl(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:Nl(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function bce(){}function wce(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 lst(t){this._context=t}lst.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:wce(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:wce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function xXt(t){return new lst(t)}function cst(t){this._context=t}cst.prototype={areaStart:bce,areaEnd:bce,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:wce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function gXt(t){return new cst(t)}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(){(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:wce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function yXt(t){return new dst(t)}function ust(t){this._context=t}ust.prototype={areaStart:bce,areaEnd:bce,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 vXt(t){return new ust(t)}function LDe(t){return t<0?-1:1}function DDe(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(LDe(o)+LDe(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function RDe(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function Lye(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 jce(t){this._context=t}jce.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:Lye(this,this._t0,RDe(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,Lye(this,RDe(this,r=DDe(this,t,s)),r);break;default:Lye(this,this._t0,r=DDe(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function hst(t){this._context=new mst(t)}(hst.prototype=Object.create(jce.prototype)).point=function(t,s){jce.prototype.point.call(this,s,t)};function mst(t){this._context=t}mst.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 _Xt(t){return new jce(t)}function bXt(t){return new hst(t)}function pst(t){this._context=t}pst.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=ODe(t),a=ODe(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 jXt(t){return new Whe(t,.5)}function NXt(t){return new Whe(t,0)}function kXt(t){return new Whe(t,1)}function UT(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 SXt(t,s){return t[s]}function CXt(t){const s=[];return s.key=t,s}function MXt(){var t=Nl([]),s=lbe,r=UT,n=SXt;function a(o){var l=Array.from(t.apply(this,arguments),CXt),i,d=l.length,u=-1,p;for(const x 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 OXt(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 fst={symbolCircle:F4e,symbolCross:nXt,symbolDiamond:iXt,symbolSquare:oXt,symbolStar:uXt,symbolTriangle:hXt,symbolWye:pXt},FXt=Math.PI/180,zXt=function(s){var r="symbol".concat(Vhe(s));return fst[r]||F4e},BXt=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*FXt;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}},$Xt=function(s,r){fst["symbol".concat(Vhe(s))]=r},z4e=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=RXt(s,PXt),u=zDe(zDe({},d),{},{type:n,size:o,sizeType:i}),p=function(){var w=zXt(n),k=fXt().type(w).size(BXt(o,i,n));return k()},x=u.className,y=u.cx,_=u.cy,b=qa(u,!0);return y===+y&&_===+_&&o===+o?ft.createElement("path",cbe({},b,{className:_i("recharts-symbols",x),transform:"translate(".concat(y,", ").concat(_,")"),d:p()})):null};z4e.registerSymbol=$Xt;function VT(t){"@babel/helpers - typeof";return VT=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},VT(t)}function dbe(){return dbe=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var C=_.inactive?u:_.color;return ft.createElement("li",dbe({className:w,style:x,key:"legend-item-".concat(b)},nC(n.props,_,b)),ft.createElement(tbe,{width:l,height:l,viewBox:p,style:y},n.renderIcon(_)),ft.createElement("span",{className:"recharts-legend-item-text",style:{color:C}},N?N(k,_,b):k))})}},{key:"render",value:function(){var n=this.props,a=n.payload,o=n.layout,l=n.align;if(!a||!a.length)return null;var i={padding:0,margin:0,textAlign:o==="horizontal"?l:"left"};return ft.createElement("ul",{className:"recharts-default-legend",style:i},this.renderItems())}}])}(S.PureComponent);kD(B4e,"displayName","Legend");kD(B4e,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var XXt=Ehe;function QXt(){this.__data__=new XXt,this.size=0}var JXt=QXt;function eQt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var tQt=eQt;function sQt(t){return this.__data__.get(t)}var rQt=sQt;function nQt(t){return this.__data__.has(t)}var aQt=nQt,iQt=Ehe,oQt=C4e,lQt=M4e,cQt=200;function dQt(t,s){var r=this.__data__;if(r instanceof iQt){var n=r.__data__;if(!oQt||n.lengthi))return!1;var u=o.get(t),p=o.get(s);if(u&&p)return u==s&&p==t;var x=-1,y=!0,_=r&PQt?new MQt:void 0;for(o.set(t,s),o.set(s,t);++x-1&&t%1==0&&t-1&&t%1==0&&t<=RJt}var V4e=OJt,FJt=S1,zJt=V4e,BJt=C1,$Jt="[object Arguments]",qJt="[object Array]",UJt="[object Boolean]",VJt="[object Date]",HJt="[object Error]",GJt="[object Function]",WJt="[object Map]",KJt="[object Number]",ZJt="[object Object]",YJt="[object RegExp]",XJt="[object Set]",QJt="[object String]",JJt="[object WeakMap]",ees="[object ArrayBuffer]",tes="[object DataView]",ses="[object Float32Array]",res="[object Float64Array]",nes="[object Int8Array]",aes="[object Int16Array]",ies="[object Int32Array]",oes="[object Uint8Array]",les="[object Uint8ClampedArray]",ces="[object Uint16Array]",des="[object Uint32Array]",Hl={};Hl[ses]=Hl[res]=Hl[nes]=Hl[aes]=Hl[ies]=Hl[oes]=Hl[les]=Hl[ces]=Hl[des]=!0;Hl[$Jt]=Hl[qJt]=Hl[ees]=Hl[UJt]=Hl[tes]=Hl[VJt]=Hl[HJt]=Hl[GJt]=Hl[WJt]=Hl[KJt]=Hl[ZJt]=Hl[YJt]=Hl[XJt]=Hl[QJt]=Hl[JJt]=!1;function ues(t){return BJt(t)&&zJt(t.length)&&!!Hl[FJt(t)]}var hes=ues;function mes(t){return function(s){return t(s)}}var Sst=mes,Cce={exports:{}};Cce.exports;(function(t,s){var r=Ltt,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})(Cce,Cce.exports);var pes=Cce.exports,fes=hes,xes=Sst,GDe=pes,WDe=GDe&&GDe.isTypedArray,ges=WDe?xes(WDe):fes,Cst=ges,yes=bJt,ves=q4e,_es=wp,bes=kst,wes=U4e,jes=Cst,Nes=Object.prototype,kes=Nes.hasOwnProperty;function Ses(t,s){var r=_es(t),n=!r&&ves(t),a=!r&&!n&&bes(t),o=!r&&!n&&!a&&jes(t),l=r||n||a||o,i=l?yes(t.length,String):[],d=i.length;for(var u in t)(s||kes.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||wes(u,d)))&&i.push(u);return i}var Ces=Ses,Mes=Object.prototype;function Tes(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||Mes;return t===r}var Aes=Tes;function Ees(t,s){return function(r){return t(s(r))}}var Mst=Ees,Pes=Mst,Ies=Pes(Object.keys,Object),Les=Ies,Des=Aes,Res=Les,Oes=Object.prototype,Fes=Oes.hasOwnProperty;function zes(t){if(!Des(t))return Res(t);var s=[];for(var r in Object(t))Fes.call(t,r)&&r!="constructor"&&s.push(r);return s}var Bes=zes,$es=k4e,qes=V4e;function Ues(t){return t!=null&&qes(t.length)&&!$es(t)}var oO=Ues,Ves=Ces,Hes=Bes,Ges=oO;function Wes(t){return Ges(t)?Ves(t):Hes(t)}var Khe=Wes,Kes=cJt,Zes=vJt,Yes=Khe;function Xes(t){return Kes(t,Yes,Zes)}var Qes=Xes,KDe=Qes,Jes=1,ets=Object.prototype,tts=ets.hasOwnProperty;function sts(t,s,r,n,a,o){var l=r&Jes,i=KDe(t),d=i.length,u=KDe(s),p=u.length;if(d!=p&&!l)return!1;for(var x=d;x--;){var y=i[x];if(!(l?y in s:tts.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;++x-1}var ers=Jss;function trs(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=xrs){var u=s?null:prs(t);if(u)return frs(u);l=!1,a=mrs,d=new drs}else d=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Prs(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 Irs(t){return t.value}function Lrs(t,s){if(ft.isValidElement(t))return ft.cloneElement(t,s);if(typeof t=="function")return ft.createElement(t,s);s.ref;var r=Ers(s,jrs);return ft.createElement(B4e,r)}var dRe=1,XM=function(t){function s(){var r;Nrs(this,s);for(var n=arguments.length,a=new Array(n),o=0;odRe||Math.abs(a.height-this.lastBoundingBox.height)>dRe)&&(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,x,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();x={left:((u||0)-_.width)/2}}else x=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({},x),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,x=xv(xv({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(d)),d);return ft.createElement("div",{className:"recharts-legend-wrapper",style:x,ref:function(_){n.wrapperNode=_}},Lrs(o,xv(xv({},this.props),{},{payload:Dst(p,u,Irs)})))}}],[{key:"getWithHeight",value:function(n,a){var o=xv(xv({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&en(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(S.PureComponent);Zhe(XM,"displayName","Legend");Zhe(XM,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var uRe=aO,Drs=q4e,Rrs=wp,hRe=uRe?uRe.isConcatSpreadable:void 0;function Ors(t){return Rrs(t)||Drs(t)||!!(hRe&&t&&t[hRe])}var Frs=Ors,zrs=jst,Brs=Frs;function Fst(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=Brs),a||(a=[]);++o0&&r(i)?s>1?Fst(i,s-1,r,n,a):zrs(a,i):n||(a[a.length]=i)}return a}var zst=Fst;function $rs(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 qrs=$rs,Urs=qrs,Vrs=Urs(),Hrs=Vrs,Grs=Hrs,Wrs=Khe;function Krs(t,s){return t&&Grs(t,s,Wrs)}var Bst=Krs,Zrs=oO;function Yrs(t,s){return function(r,n){if(r==null)return r;if(!Zrs(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 dns=cns,Fye=A4e,uns=E4e,hns=k0,mns=$st,pns=ans,fns=Sst,xns=dns,gns=mE,yns=wp;function vns(t,s,r){s.length?s=Fye(s,function(o){return yns(o)?function(l){return uns(l,o.length===1?o[0]:o)}:o}):s=[gns];var n=-1;s=Fye(s,fns(hns));var a=mns(t,function(o,l,i){var d=Fye(s,function(u){return u(o)});return{criteria:d,index:++n,value:o}});return pns(a,function(o,l){return xns(o,l,r)})}var _ns=vns;function bns(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 wns=bns,jns=wns,pRe=Math.max;function Nns(t,s,r){return s=pRe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=pRe(n.length-s,0),l=Array(o);++a0){if(++s>=Lns)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var Fns=Ons,zns=Ins,Bns=Fns,$ns=Bns(zns),qns=$ns,Uns=mE,Vns=kns,Hns=qns;function Gns(t,s){return Hns(Vns(t,s,Uns),t+"")}var Wns=Gns,Kns=S4e,Zns=oO,Yns=U4e,Xns=bw;function Qns(t,s,r){if(!Xns(r))return!1;var n=typeof s;return(n=="number"?Zns(r)&&Yns(s,r.length):n=="string"&&s in r)?Kns(r[s],t):!1}var Yhe=Qns,Jns=zst,eas=_ns,tas=Wns,xRe=Yhe,sas=tas(function(t,s){if(t==null)return[];var r=s.length;return r>1&&xRe(t,s[0],s[1])?s=[]:r>2&&xRe(s[0],s[1],s[2])&&(s=[s[0]]),eas(t,Jns(s,1),[])}),ras=sas;const W4e=so(ras);function SD(t){"@babel/helpers - typeof";return SD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},SD(t)}function ybe(){return ybe=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(iI,"-left"),en(r)&&s&&en(s.x)&&r=s.y),"".concat(iI,"-top"),en(n)&&s&&en(s.y)&&nN?Math.max(p,d[n]):Math.max(x,d[n])}function yas(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 vas(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,x;return l.height>0&&l.width>0&&r?(p=vRe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:d,viewBoxDimension:d.width}),x=vRe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:d,viewBoxDimension:d.height}),u=yas({translateX:p,translateY:x,useTranslate3d:i})):u=xas,{cssProperties:u,cssClasses:gas({translateX:p,translateY:x,coordinate:r})}}function GT(t){"@babel/helpers - typeof";return GT=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},GT(t)}function _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 bRe(t){for(var s=1;swRe||Math.abs(n.height-this.state.lastBoundingBox.height)>wRe)&&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,x=a.hasPayload,y=a.isAnimationActive,_=a.offset,b=a.position,N=a.reverseDirection,w=a.useTranslate3d,k=a.viewBox,C=a.wrapperStyle,E=vas({allowEscapeViewBox:l,coordinate:p,offsetTopLeft:_,position:b,reverseDirection:N,tooltipBox:this.state.lastBoundingBox,useTranslate3d:w,viewBox:k}),L=E.cssClasses,I=E.cssProperties,O=bRe(bRe({transition:y&&o?"transform ".concat(i,"ms ").concat(d):void 0},I),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&x?"visible":"hidden",position:"absolute",top:0,left:0},C);return ft.createElement("div",{tabIndex:-1,className:L,style:O,ref:function(q){n.wrapperNode=q}},u)}}])}(S.PureComponent),Tas=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},i0={isSsr:Tas(),get:function(s){return i0[s]},set:function(s,r){if(typeof s=="string")i0[s]=r;else{var n=Object.keys(s);n&&n.length&&n.forEach(function(a){i0[a]=s[a]})}}};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 jRe(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 NRe(t){for(var s=1;s0;return ft.createElement(Mas,{allowEscapeViewBox:l,animationDuration:i,animationEasing:d,isAnimationActive:y,active:o,coordinate:p,hasPayload:O,offset:_,position:w,reverseDirection:k,useTranslate3d:C,viewBox:E,wrapperStyle:L},zas(u,NRe(NRe({},this.props),{},{payload:I})))}}])}(S.PureComponent);K4e(ep,"displayName","Tooltip");K4e(ep,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!i0.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 Bas=N0,$as=function(){return Bas.Date.now()},qas=$as,Uas=/\s/;function Vas(t){for(var s=t.length;s--&&Uas.test(t.charAt(s)););return s}var Has=Vas,Gas=Has,Was=/^\s+/;function Kas(t){return t&&t.slice(0,Gas(t)+1).replace(Was,"")}var Zas=Kas,Yas=Zas,kRe=bw,Xas=aE,SRe=NaN,Qas=/^[-+]0x[0-9a-f]+$/i,Jas=/^0b[01]+$/i,eis=/^0o[0-7]+$/i,tis=parseInt;function sis(t){if(typeof t=="number")return t;if(Xas(t))return SRe;if(kRe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=kRe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=Yas(t);var r=Jas.test(t);return r||eis.test(t)?tis(t.slice(2),r?2:8):Qas.test(t)?SRe:+t}var Wst=sis,ris=bw,Bye=qas,CRe=Wst,nis="Expected a function",ais=Math.max,iis=Math.min;function ois(t,s,r){var n,a,o,l,i,d,u=0,p=!1,x=!1,y=!0;if(typeof t!="function")throw new TypeError(nis);s=CRe(s)||0,ris(r)&&(p=!!r.leading,x="maxWait"in r,o=x?ais(CRe(r.maxWait)||0,s):o,y="trailing"in r?!!r.trailing:y);function _(O){var V=n,q=a;return n=a=void 0,u=O,l=t.apply(q,V),l}function b(O){return u=O,i=setTimeout(k,s),p?_(O):l}function N(O){var V=O-d,q=O-u,$=s-V;return x?iis($,o-q):$}function w(O){var V=O-d,q=O-u;return d===void 0||V>=s||V<0||x&&q>=o}function k(){var O=Bye();if(w(O))return C(O);i=setTimeout(k,N(O))}function C(O){return i=void 0,y&&n?_(O):(n=a=void 0,l)}function E(){i!==void 0&&clearTimeout(i),u=0,n=d=a=i=void 0}function L(){return i===void 0?l:C(Bye())}function I(){var O=Bye(),V=w(O);if(n=arguments,a=this,d=O,V){if(i===void 0)return b(d);if(x)return clearTimeout(i),i=setTimeout(k,s),_(d)}return i===void 0&&(i=setTimeout(k,s)),l}return I.cancel=E,I.flush=L,I}var lis=ois,cis=lis,dis=bw,uis="Expected a function";function his(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(uis);return dis(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),cis(t,s,{leading:n,maxWait:s,trailing:a})}var mis=his;const Kst=so(mis);function MD(t){"@babel/helpers - typeof";return MD=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},MD(t)}function MRe(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 s9(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(J=Kst(J,N,{trailing:!0,leading:!1}));var X=new ResizeObserver(J),ce=I.current.getBoundingClientRect(),ie=ce.width,ae=ce.height;return se(ie,ae),X.observe(I.current),function(){X.disconnect()}},[se,N]);var Y=S.useMemo(function(){var J=$.containerWidth,X=$.containerHeight;if(J<0||X<0)return null;Dg(b4(l)||b4(d),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,d),Dg(!r||r>0,"The aspect(%s) must be greater than zero.",r);var ce=b4(l)?J:l,ie=b4(d)?X:d;r&&r>0&&(ce?ie=ce/r:ie&&(ce=ie*r),y&&ie>y&&(ie=y)),Dg(ce>0||ie>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the height and width.`,ce,ie,l,d,p,x,r);var ae=!Array.isArray(_)&&s1(_.type).endsWith("Chart");return ft.Children.map(_,function(oe){return ft.isValidElement(oe)?S.cloneElement(oe,s9({width:ce,height:ie},ae?{style:s9({height:"100%",width:"100%",maxHeight:ie,maxWidth:ce},oe.props.style)}:{})):oe})},[r,_,d,y,x,p,$,l]);return ft.createElement("div",{id:w?"".concat(w):void 0,className:_i("recharts-responsive-container",k),style:s9(s9({},L),{},{width:l,height:d,minWidth:p,minHeight:x,maxHeight:y}),ref:I},Y)}),lO=function(s){return null};lO.displayName="Cell";function TD(t){"@babel/helpers - typeof";return TD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},TD(t)}function ARe(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 wbe(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||i0.isSsr)return{width:0,height:0};var n=Cis(r),a=JSON.stringify({text:s,copyStyle:n});if(v5.widthCache[a])return v5.widthCache[a];try{var o=document.getElementById(ERe);o||(o=document.createElement("span"),o.setAttribute("id",ERe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=wbe(wbe({},Sis),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),d={width:i.width,height:i.height};return v5.widthCache[a]=d,++v5.cacheCount>kis&&(v5.cacheCount=0,v5.widthCache={}),d}catch{return{width:0,height:0}}},Mis=function(s){return{top:s.top+window.scrollY-document.documentElement.clientTop,left:s.left+window.scrollX-document.documentElement.clientLeft}};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 Ece(t,s){return Pis(t)||Eis(t,s)||Ais(t,s)||Tis()}function Tis(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ais(t,s){if(t){if(typeof t=="string")return PRe(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 PRe(t,s)}}function PRe(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 Gis(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 FRe(t,s){return Yis(t)||Zis(t,s)||Kis(t,s)||Wis()}function Wis(){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 Kis(t,s){if(t){if(typeof t=="string")return zRe(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 zRe(t,s)}}function zRe(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(ie,ae){var oe=ae.word,pe=ae.width,_e=ie[ie.length-1];if(_e&&(a==null||o||_e.width+pe+nae.width?ie:ae})};if(!p)return _;for(var N="…",w=function(ce){var ie=x.slice(0,ce),ae=Qst({breakAll:u,style:d,children:ie+N}).wordsWithComputedWidth,oe=y(ae),pe=oe.length>l||b(oe).width>Number(a);return[pe,oe]},k=0,C=x.length-1,E=0,L;k<=C&&E<=x.length-1;){var I=Math.floor((k+C)/2),O=I-1,V=w(O),q=FRe(V,2),$=q[0],U=q[1],se=w(I),Y=FRe(se,1),J=Y[0];if(!$&&!J&&(k=I+1),$&&J&&(C=I-1),!$&&J){L=U;break}E++}return L||_},BRe=function(s){var r=yi(s)?[]:s.toString().split(Xst);return[{words:r}]},Qis=function(s){var r=s.width,n=s.scaleToFit,a=s.children,o=s.style,l=s.breakAll,i=s.maxLines;if((r||n)&&!i0.isSsr){var d,u,p=Qst({breakAll:l,children:a,style:o});if(p){var x=p.wordsWithComputedWidth,y=p.spaceWidth;d=x,u=y}else return BRe(a);return Xis({breakAll:l,children:a,maxLines:i,style:o},d,u,r,n)}return BRe(a)},$Re="#808080",aC=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,x=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,k=w===void 0?$Re:w,C=ORe(s,Vis),E=S.useMemo(function(){return Qis({breakAll:C.breakAll,children:C.children,maxLines:C.maxLines,scaleToFit:x,style:C.style,width:C.width})},[C.breakAll,C.children,C.maxLines,x,C.style,C.width]),L=C.dx,I=C.dy,O=C.angle,V=C.className,q=C.breakAll,$=ORe(C,His);if(!lu(n)||!lu(o))return null;var U=n+(en(L)?L:0),se=o+(en(I)?I:0),Y;switch(N){case"start":Y=$ye("calc(".concat(u,")"));break;case"middle":Y=$ye("calc(".concat((E.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:Y=$ye("calc(".concat(E.length-1," * -").concat(i,")"));break}var J=[];if(x){var X=E[0].width,ce=C.width;J.push("scale(".concat((en(ce)?ce/X:1)/X,")"))}return O&&J.push("rotate(".concat(O,", ").concat(U,", ").concat(se,")")),J.length&&($.transform=J.join(" ")),ft.createElement("text",jbe({},qa($,!0),{x:U,y:se,className:_i("recharts-text",V),textAnchor:_,fill:k.includes("url")?$Re:k}),E.map(function(ie,ae){var oe=ie.words.join(q?"":" ");return ft.createElement("tspan",{x:U,dy:ae===0?Y:i,key:"".concat(oe,"-").concat(ae)},oe)}))};function zb(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function Jis(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function Z4e(t){let s,r,n;t.length!==2?(s=zb,r=(i,d)=>zb(t(i),d),n=(i,d)=>t(i)-d):(s=t===zb||t===Jis?t:eos,r=t,n=t);function a(i,d,u=0,p=i.length){if(u>>1;r(i[x],d)<0?u=x+1:p=x}while(u>>1;r(i[x],d)<=0?u=x+1:p=x}while(uu&&n(i[x-1],d)>-n(i[x],d)?x-1:x}return{left:a,center:l,right:o}}function eos(){return 0}function Jst(t){return t===null?NaN:+t}function*tos(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const sos=Z4e(zb),cO=sos.right;Z4e(Jst).center;class qRe extends Map{constructor(s,r=aos){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(URe(this,s))}has(s){return super.has(URe(this,s))}set(s,r){return super.set(ros(this,s),r)}delete(s){return super.delete(nos(this,s))}}function URe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function ros({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function nos({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function aos(t){return t!==null&&typeof t=="object"?t.valueOf():t}function ios(t=zb){if(t===zb)return ert;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 ert(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const oos=Math.sqrt(50),los=Math.sqrt(10),cos=Math.sqrt(2);function Pce(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>=oos?10:o>=los?5:o>=cos?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 HRe(t,s){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function trt(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?ert:ios(a);n>r;){if(n-r>600){const d=n-r+1,u=s-r+1,p=Math.log(d),x=.5*Math.exp(2*p/3),y=.5*Math.sqrt(p*x*(d-x)/d)*(u-d/2<0?-1:1),_=Math.max(r,Math.floor(s-u*x/d+y)),b=Math.min(n,Math.floor(s+(d-u)*x/d+y));trt(t,s,_,b,a)}const o=t[s];let l=r,i=n;for(oI(t,r,s),a(t[n],o)>0&&oI(t,r,n);l0;)--i}a(t[r],o)===0?oI(t,r,i):(++i,oI(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function oI(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function dos(t,s,r){if(t=Float64Array.from(tos(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return HRe(t);if(s>=1)return VRe(t);var n,a=(n-1)*s,o=Math.floor(a),l=VRe(trt(t,o).subarray(0,o+1)),i=HRe(t.subarray(o+1));return l+(i-l)*(a-o)}}function uos(t,s,r=Jst){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 hos(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?n9(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?n9(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=pos.exec(t))?new cp(s[1],s[2],s[3],1):(s=fos.exec(t))?new cp(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=xos.exec(t))?n9(s[1],s[2],s[3],s[4]):(s=gos.exec(t))?n9(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=yos.exec(t))?QRe(s[1],s[2]/100,s[3]/100,1):(s=vos.exec(t))?QRe(s[1],s[2]/100,s[3]/100,s[4]):GRe.hasOwnProperty(t)?ZRe(GRe[t]):t==="transparent"?new cp(NaN,NaN,NaN,0):null}function ZRe(t){return new cp(t>>16&255,t>>8&255,t&255,1)}function n9(t,s,r,n){return n<=0&&(t=s=r=NaN),new cp(t,s,r,n)}function wos(t){return t instanceof dO||(t=LD(t)),t?(t=t.rgb(),new cp(t.r,t.g,t.b,t.opacity)):new cp}function Mbe(t,s,r,n){return arguments.length===1?wos(t):new cp(t,s,r,n??1)}function cp(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}X4e(cp,Mbe,rrt(dO,{brighter(t){return t=t==null?Ice:Math.pow(Ice,t),new cp(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?PD:Math.pow(PD,t),new cp(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new cp(CS(this.r),CS(this.g),CS(this.b),Lce(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:YRe,formatHex:YRe,formatHex8:jos,formatRgb:XRe,toString:XRe}));function YRe(){return`#${w4(this.r)}${w4(this.g)}${w4(this.b)}`}function jos(){return`#${w4(this.r)}${w4(this.g)}${w4(this.b)}${w4((isNaN(this.opacity)?1:this.opacity)*255)}`}function XRe(){const t=Lce(this.opacity);return`${t===1?"rgb(":"rgba("}${CS(this.r)}, ${CS(this.g)}, ${CS(this.b)}${t===1?")":`, ${t})`}`}function Lce(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function CS(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function w4(t){return t=CS(t),(t<16?"0":"")+t.toString(16)}function QRe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new Ng(t,s,r,n)}function nrt(t){if(t instanceof Ng)return new Ng(t.h,t.s,t.l,t.opacity);if(t instanceof dO||(t=LD(t)),!t)return new Ng;if(t instanceof Ng)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 Ng(l,i,d,t.opacity)}function Nos(t,s,r,n){return arguments.length===1?nrt(t):new Ng(t,s,r,n??1)}function Ng(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}X4e(Ng,Nos,rrt(dO,{brighter(t){return t=t==null?Ice:Math.pow(Ice,t),new Ng(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?PD:Math.pow(PD,t),new Ng(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 cp(qye(t>=240?t-240:t+120,a,n),qye(t,a,n),qye(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new Ng(JRe(this.h),a9(this.s),a9(this.l),Lce(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=Lce(this.opacity);return`${t===1?"hsl(":"hsla("}${JRe(this.h)}, ${a9(this.s)*100}%, ${a9(this.l)*100}%${t===1?")":`, ${t})`}`}}));function JRe(t){return t=(t||0)%360,t<0?t+360:t}function a9(t){return Math.max(0,Math.min(1,t||0))}function qye(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 Q4e=t=>()=>t;function kos(t,s){return function(r){return t+r*s}}function Sos(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 Cos(t){return(t=+t)==1?art:function(s,r){return r-s?Sos(s,r,t):Q4e(isNaN(s)?r:s)}}function art(t,s){var r=s-t;return r?kos(t,r):Q4e(isNaN(t)?s:t)}const eOe=function t(s){var r=Cos(s);function n(a,o){var l=r((a=Mbe(a)).r,(o=Mbe(o)).r),i=r(a.g,o.g),d=r(a.b,o.b),u=art(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 Mos(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:Dce(n,a)})),r=Uye.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function zos(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?Bos:zos,d=u=null,x}function x(y){return y==null||isNaN(y=+y)?o:(d||(d=i(t.map(n),s,r)))(n(l(y)))}return x.invert=function(y){return l(a((u||(u=i(s,t.map(n),Dce)))(y)))},x.domain=function(y){return arguments.length?(t=Array.from(y,Rce),p()):t.slice()},x.range=function(y){return arguments.length?(s=Array.from(y),p()):s.slice()},x.rangeRound=function(y){return s=Array.from(y),r=J4e,p()},x.clamp=function(y){return arguments.length?(l=y?!0:Nm,p()):l!==Nm},x.interpolate=function(y){return arguments.length?(r=y,p()):r},x.unknown=function(y){return arguments.length?(o=y,x):o},function(y,_){return n=y,a=_,p()}}function eSe(){return Xhe()(Nm,Nm)}function $os(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Oce(t,s){if((r=(t=s?t.toExponential(s-1):t.toExponential()).indexOf("e"))<0)return null;var r,n=t.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+t.slice(r+1)]}function KT(t){return t=Oce(Math.abs(t)),t?t[1]:NaN}function qos(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 Uos(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var Vos=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function DD(t){if(!(s=Vos.exec(t)))throw new Error("invalid format: "+t);var s;return new tSe({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]})}DD.prototype=tSe.prototype;function tSe(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+""}tSe.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 Hos(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 irt;function Gos(t,s){var r=Oce(t,s);if(!r)return t+"";var n=r[0],a=r[1],o=a-(irt=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")+Oce(t,Math.max(0,s+o-1))[0]}function sOe(t,s){var r=Oce(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 rOe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:$os,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)=>sOe(t*100,s),r:sOe,s:Gos,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function nOe(t){return t}var aOe=Array.prototype.map,iOe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Wos(t){var s=t.grouping===void 0||t.thousands===void 0?nOe:qos(aOe.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?nOe:Uos(aOe.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(x){x=DD(x);var y=x.fill,_=x.align,b=x.sign,N=x.symbol,w=x.zero,k=x.width,C=x.comma,E=x.precision,L=x.trim,I=x.type;I==="n"?(C=!0,I="g"):rOe[I]||(E===void 0&&(E=12),L=!0,I="g"),(w||y==="0"&&_==="=")&&(w=!0,y="0",_="=");var O=N==="$"?r:N==="#"&&/[boxX]/.test(I)?"0"+I.toLowerCase():"",V=N==="$"?n:/[%p]/.test(I)?l:"",q=rOe[I],$=/[defgprs%]/.test(I);E=E===void 0?6:/[gprs]/.test(I)?Math.max(1,Math.min(21,E)):Math.max(0,Math.min(20,E));function U(se){var Y=O,J=V,X,ce,ie;if(I==="c")J=q(se)+J,se="";else{se=+se;var ae=se<0||1/se<0;if(se=isNaN(se)?d:q(Math.abs(se),E),L&&(se=Hos(se)),ae&&+se==0&&b!=="+"&&(ae=!1),Y=(ae?b==="("?b:i:b==="-"||b==="("?"":b)+Y,J=(I==="s"?iOe[8+irt/3]:"")+J+(ae&&b==="("?")":""),$){for(X=-1,ce=se.length;++Xie||ie>57){J=(ie===46?a+se.slice(X+1):se.slice(X))+J,se=se.slice(0,X);break}}}C&&!w&&(se=s(se,1/0));var oe=Y.length+se.length+J.length,pe=oe>1)+Y+se+J+pe.slice(oe);break;default:se=pe+Y+se+J;break}return o(se)}return U.toString=function(){return x+""},U}function p(x,y){var _=u((x=DD(x),x.type="f",x)),b=Math.max(-8,Math.min(8,Math.floor(KT(y)/3)))*3,N=Math.pow(10,-b),w=iOe[8+b/3];return function(k){return _(N*k)+w}}return{format:u,formatPrefix:p}}var i9,sSe,ort;Kos({thousands:",",grouping:[3],currency:["$",""]});function Kos(t){return i9=Wos(t),sSe=i9.format,ort=i9.formatPrefix,i9}function Zos(t){return Math.max(0,-KT(Math.abs(t)))}function Yos(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(KT(s)/3)))*3-KT(Math.abs(t)))}function Xos(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,KT(s)-KT(t))+1}function lrt(t,s,r,n){var a=Sbe(t,s,r),o;switch(n=DD(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(t),Math.abs(s));return n.precision==null&&!isNaN(o=Yos(a,l))&&(n.precision=o),ort(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=Xos(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=Zos(a))&&(n.precision=o-(n.type==="%")*2);break}}return sSe(n)}function ww(t){var s=t.domain;return t.ticks=function(r){var n=s();return Nbe(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=kbe(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 Fce(){var t=eSe();return t.copy=function(){return uO(t,Fce())},Rx.apply(t,arguments),ww(t)}function crt(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,Rce),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return crt(t).unknown(s)},t=arguments.length?Array.from(t,Rce):[0,1],ww(r)}function drt(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 sls(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 cOe(t){return(s,r)=>-t(-s,r)}function rSe(t){const s=t(oOe,lOe),r=s.domain;let n=10,a,o;function l(){return a=sls(n),o=tls(n),r()[0]<0?(a=cOe(a),o=cOe(o),t(Qos,Jos)):t(oOe,lOe),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 x=p0){for(;y<=_;++y)for(b=1;bp)break;k.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;k.push(N)}k.length*2{if(i==null&&(i=10),d==null&&(d=n===10?"s":","),typeof d!="function"&&(!(n%1)&&(d=DD(d)).precision==null&&(d.trim=!0),d=sSe(d)),i===1/0)return d;const u=Math.max(1,n*i/s.ticks().length);return p=>{let x=p/o(Math.round(a(p)));return x*nr(drt(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function urt(){const t=rSe(Xhe()).domain([1,10]);return t.copy=()=>uO(t,urt()).base(t.base()),Rx.apply(t,arguments),t}function dOe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function uOe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function nSe(t){var s=1,r=t(dOe(s),uOe(s));return r.constant=function(n){return arguments.length?t(dOe(s=+n),uOe(s)):s},ww(r)}function hrt(){var t=nSe(Xhe());return t.copy=function(){return uO(t,hrt()).constant(t.constant())},Rx.apply(t,arguments)}function hOe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function rls(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function nls(t){return t<0?-t*t:t*t}function aSe(t){var s=t(Nm,Nm),r=1;function n(){return r===1?t(Nm,Nm):r===.5?t(rls,nls):t(hOe(r),hOe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},ww(s)}function iSe(){var t=aSe(Xhe());return t.copy=function(){return uO(t,iSe()).exponent(t.exponent())},Rx.apply(t,arguments),t}function als(){return iSe.apply(null,arguments).exponent(.5)}function mOe(t){return Math.sign(t)*t*t}function ils(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function mrt(){var t=eSe(),s=[0,1],r=!1,n;function a(o){var l=ils(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(mOe(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,Rce)).map(mOe)),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 mrt(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},Rx.apply(a,arguments),ww(a)}function prt(){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 frt().domain([t,s]).range(a).unknown(o)},Rx.apply(ww(l),arguments)}function xrt(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[cO(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 xrt().domain(t).range(s).unknown(r)},Rx.apply(a,arguments)}const Vye=new Date,Hye=new Date;function vu(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(uvu(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)=>(Vye.setTime(+o),Hye.setTime(+l),t(Vye),t(Hye),Math.floor(r(Vye,Hye))),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 zce=vu(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);zce.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?vu(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):zce);zce.range;const $v=1e3,hx=$v*60,qv=hx*60,f1=qv*24,oSe=f1*7,pOe=f1*30,Gye=f1*365,j4=vu(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*$v)},(t,s)=>(s-t)/$v,t=>t.getUTCSeconds());j4.range;const lSe=vu(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*$v)},(t,s)=>{t.setTime(+t+s*hx)},(t,s)=>(s-t)/hx,t=>t.getMinutes());lSe.range;const cSe=vu(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*hx)},(t,s)=>(s-t)/hx,t=>t.getUTCMinutes());cSe.range;const dSe=vu(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*$v-t.getMinutes()*hx)},(t,s)=>{t.setTime(+t+s*qv)},(t,s)=>(s-t)/qv,t=>t.getHours());dSe.range;const uSe=vu(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*qv)},(t,s)=>(s-t)/qv,t=>t.getUTCHours());uSe.range;const hO=vu(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*hx)/f1,t=>t.getDate()-1);hO.range;const Qhe=vu(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/f1,t=>t.getUTCDate()-1);Qhe.range;const grt=vu(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/f1,t=>Math.floor(t/f1));grt.range;function SC(t){return vu(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())*hx)/oSe)}const Jhe=SC(0),Bce=SC(1),ols=SC(2),lls=SC(3),ZT=SC(4),cls=SC(5),dls=SC(6);Jhe.range;Bce.range;ols.range;lls.range;ZT.range;cls.range;dls.range;function CC(t){return vu(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)/oSe)}const eme=CC(0),$ce=CC(1),uls=CC(2),hls=CC(3),YT=CC(4),mls=CC(5),pls=CC(6);eme.range;$ce.range;uls.range;hls.range;YT.range;mls.range;pls.range;const hSe=vu(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());hSe.range;const mSe=vu(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());mSe.range;const x1=vu(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());x1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:vu(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)});x1.range;const g1=vu(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());g1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:vu(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)});g1.range;function yrt(t,s,r,n,a,o){const l=[[j4,1,$v],[j4,5,5*$v],[j4,15,15*$v],[j4,30,30*$v],[o,1,hx],[o,5,5*hx],[o,15,15*hx],[o,30,30*hx],[a,1,qv],[a,3,3*qv],[a,6,6*qv],[a,12,12*qv],[n,1,f1],[n,2,2*f1],[r,1,oSe],[s,1,pOe],[s,3,3*pOe],[t,1,Gye]];function i(u,p,x){const y=pw).right(l,y);if(_===l.length)return t.every(Sbe(u/Gye,p/Gye,x));if(_===0)return zce.every(Math.max(Sbe(u,p,x),1));const[b,N]=l[y/l[_-1][2]53)return null;"w"in ve||(ve.w=1),"Z"in ve?(fe=Kye(lI(ve.y,0,1)),Ve=fe.getUTCDay(),fe=Ve>4||Ve===0?$ce.ceil(fe):$ce(fe),fe=Qhe.offset(fe,(ve.V-1)*7),ve.y=fe.getUTCFullYear(),ve.m=fe.getUTCMonth(),ve.d=fe.getUTCDate()+(ve.w+6)%7):(fe=Wye(lI(ve.y,0,1)),Ve=fe.getDay(),fe=Ve>4||Ve===0?Bce.ceil(fe):Bce(fe),fe=hO.offset(fe,(ve.V-1)*7),ve.y=fe.getFullYear(),ve.m=fe.getMonth(),ve.d=fe.getDate()+(ve.w+6)%7)}else("W"in ve||"U"in ve)&&("w"in ve||(ve.w="u"in ve?ve.u%7:"W"in ve?1:0),Ve="Z"in ve?Kye(lI(ve.y,0,1)).getUTCDay():Wye(lI(ve.y,0,1)).getDay(),ve.m=0,ve.d="W"in ve?(ve.w+6)%7+ve.W*7-(Ve+5)%7:ve.w+ve.U*7-(Ve+6)%7);return"Z"in ve?(ve.H+=ve.Z/100|0,ve.M+=ve.Z%100,Kye(ve)):Wye(ve)}}function q(Ne,qe,ze,ve){for(var dt=0,fe=qe.length,Ve=ze.length,Je,at;dt=Ve)return-1;if(Je=qe.charCodeAt(dt++),Je===37){if(Je=qe.charAt(dt++),at=I[Je in fOe?qe.charAt(dt++):Je],!at||(ve=at(Ne,ze,ve))<0)return-1}else if(Je!=ze.charCodeAt(ve++))return-1}return ve}function $(Ne,qe,ze){var ve=u.exec(qe.slice(ze));return ve?(Ne.p=p.get(ve[0].toLowerCase()),ze+ve[0].length):-1}function U(Ne,qe,ze){var ve=_.exec(qe.slice(ze));return ve?(Ne.w=b.get(ve[0].toLowerCase()),ze+ve[0].length):-1}function se(Ne,qe,ze){var ve=x.exec(qe.slice(ze));return ve?(Ne.w=y.get(ve[0].toLowerCase()),ze+ve[0].length):-1}function Y(Ne,qe,ze){var ve=k.exec(qe.slice(ze));return ve?(Ne.m=C.get(ve[0].toLowerCase()),ze+ve[0].length):-1}function J(Ne,qe,ze){var ve=N.exec(qe.slice(ze));return ve?(Ne.m=w.get(ve[0].toLowerCase()),ze+ve[0].length):-1}function X(Ne,qe,ze){return q(Ne,s,qe,ze)}function ce(Ne,qe,ze){return q(Ne,r,qe,ze)}function ie(Ne,qe,ze){return q(Ne,n,qe,ze)}function ae(Ne){return l[Ne.getDay()]}function oe(Ne){return o[Ne.getDay()]}function pe(Ne){return d[Ne.getMonth()]}function _e(Ne){return i[Ne.getMonth()]}function he(Ne){return a[+(Ne.getHours()>=12)]}function we(Ne){return 1+~~(Ne.getMonth()/3)}function je(Ne){return l[Ne.getUTCDay()]}function Ue(Ne){return o[Ne.getUTCDay()]}function Te(Ne){return d[Ne.getUTCMonth()]}function Me(Ne){return i[Ne.getUTCMonth()]}function Fe(Ne){return a[+(Ne.getUTCHours()>=12)]}function Le(Ne){return 1+~~(Ne.getUTCMonth()/3)}return{format:function(Ne){var qe=O(Ne+="",E);return qe.toString=function(){return Ne},qe},parse:function(Ne){var qe=V(Ne+="",!1);return qe.toString=function(){return Ne},qe},utcFormat:function(Ne){var qe=O(Ne+="",L);return qe.toString=function(){return Ne},qe},utcParse:function(Ne){var qe=V(Ne+="",!0);return qe.toString=function(){return Ne},qe}}}var fOe={"-":"",_:" ",0:"0"},Vu=/^\s*\d+/,_ls=/^%/,bls=/[\\^$*+?|[\]().{}]/g;function Co(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function jls(t,s,r){var n=Vu.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function Nls(t,s,r){var n=Vu.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function kls(t,s,r){var n=Vu.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function Sls(t,s,r){var n=Vu.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function Cls(t,s,r){var n=Vu.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function xOe(t,s,r){var n=Vu.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function gOe(t,s,r){var n=Vu.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function Mls(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 Tls(t,s,r){var n=Vu.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function Als(t,s,r){var n=Vu.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function yOe(t,s,r){var n=Vu.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Els(t,s,r){var n=Vu.exec(s.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function vOe(t,s,r){var n=Vu.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function Pls(t,s,r){var n=Vu.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function Ils(t,s,r){var n=Vu.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function Lls(t,s,r){var n=Vu.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function Dls(t,s,r){var n=Vu.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function Rls(t,s,r){var n=_ls.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function Ols(t,s,r){var n=Vu.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function Fls(t,s,r){var n=Vu.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function _Oe(t,s){return Co(t.getDate(),s,2)}function zls(t,s){return Co(t.getHours(),s,2)}function Bls(t,s){return Co(t.getHours()%12||12,s,2)}function $ls(t,s){return Co(1+hO.count(x1(t),t),s,3)}function vrt(t,s){return Co(t.getMilliseconds(),s,3)}function qls(t,s){return vrt(t,s)+"000"}function Uls(t,s){return Co(t.getMonth()+1,s,2)}function Vls(t,s){return Co(t.getMinutes(),s,2)}function Hls(t,s){return Co(t.getSeconds(),s,2)}function Gls(t){var s=t.getDay();return s===0?7:s}function Wls(t,s){return Co(Jhe.count(x1(t)-1,t),s,2)}function _rt(t){var s=t.getDay();return s>=4||s===0?ZT(t):ZT.ceil(t)}function Kls(t,s){return t=_rt(t),Co(ZT.count(x1(t),t)+(x1(t).getDay()===4),s,2)}function Zls(t){return t.getDay()}function Yls(t,s){return Co(Bce.count(x1(t)-1,t),s,2)}function Xls(t,s){return Co(t.getFullYear()%100,s,2)}function Qls(t,s){return t=_rt(t),Co(t.getFullYear()%100,s,2)}function Jls(t,s){return Co(t.getFullYear()%1e4,s,4)}function ecs(t,s){var r=t.getDay();return t=r>=4||r===0?ZT(t):ZT.ceil(t),Co(t.getFullYear()%1e4,s,4)}function tcs(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+Co(s/60|0,"0",2)+Co(s%60,"0",2)}function bOe(t,s){return Co(t.getUTCDate(),s,2)}function scs(t,s){return Co(t.getUTCHours(),s,2)}function rcs(t,s){return Co(t.getUTCHours()%12||12,s,2)}function ncs(t,s){return Co(1+Qhe.count(g1(t),t),s,3)}function brt(t,s){return Co(t.getUTCMilliseconds(),s,3)}function acs(t,s){return brt(t,s)+"000"}function ics(t,s){return Co(t.getUTCMonth()+1,s,2)}function ocs(t,s){return Co(t.getUTCMinutes(),s,2)}function lcs(t,s){return Co(t.getUTCSeconds(),s,2)}function ccs(t){var s=t.getUTCDay();return s===0?7:s}function dcs(t,s){return Co(eme.count(g1(t)-1,t),s,2)}function wrt(t){var s=t.getUTCDay();return s>=4||s===0?YT(t):YT.ceil(t)}function ucs(t,s){return t=wrt(t),Co(YT.count(g1(t),t)+(g1(t).getUTCDay()===4),s,2)}function hcs(t){return t.getUTCDay()}function mcs(t,s){return Co($ce.count(g1(t)-1,t),s,2)}function pcs(t,s){return Co(t.getUTCFullYear()%100,s,2)}function fcs(t,s){return t=wrt(t),Co(t.getUTCFullYear()%100,s,2)}function xcs(t,s){return Co(t.getUTCFullYear()%1e4,s,4)}function gcs(t,s){var r=t.getUTCDay();return t=r>=4||r===0?YT(t):YT.ceil(t),Co(t.getUTCFullYear()%1e4,s,4)}function ycs(){return"+0000"}function wOe(){return"%"}function jOe(t){return+t}function NOe(t){return Math.floor(+t/1e3)}var _5,jrt,Nrt;vcs({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 vcs(t){return _5=vls(t),jrt=_5.format,_5.parse,Nrt=_5.utcFormat,_5.utcParse,_5}function _cs(t){return new Date(t)}function bcs(t){return t instanceof Date?+t:+new Date(+t)}function pSe(t,s,r,n,a,o,l,i,d,u){var p=eSe(),x=p.invert,y=p.domain,_=u(".%L"),b=u(":%S"),N=u("%I:%M"),w=u("%I %p"),k=u("%a %d"),C=u("%b %d"),E=u("%B"),L=u("%Y");function I(O){return(d(O)s(a/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,o)=>dos(t,o/n))},r.copy=function(){return Mrt(s).domain(t)},M1.apply(r,arguments)}function sme(){var t=0,s=.5,r=1,n=1,a,o,l,i,d,u=Nm,p,x=!1,y;function _(N){return isNaN(N=+N)?y:(N=.5+((N=+p(N))-o)*(n*Ns}var Prt=Mcs,Tcs=rme,Acs=Prt,Ecs=mE;function Pcs(t){return t&&t.length?Tcs(t,Ecs,Acs):void 0}var Ics=Pcs;const nme=so(Ics);function Lcs(t,s){return tt.e^o.s<0?1:-1;for(n=o.d.length,a=t.d.length,s=0,r=nt.d[s]^o.s<0?1:-1;return n===a?0:n>a^o.s<0?1:-1};Yn.decimalPlaces=Yn.dp=function(){var t=this,s=t.d.length-1,r=(s-t.e)*Kl;if(s=t.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};Yn.dividedBy=Yn.div=function(t){return r1(this,new this.constructor(t))};Yn.dividedToIntegerBy=Yn.idiv=function(t){var s=this,r=s.constructor;return fl(r1(s,new r(t),0,1),r.precision)};Yn.equals=Yn.eq=function(t){return!this.cmp(t)};Yn.exponent=function(){return $d(this)};Yn.greaterThan=Yn.gt=function(t){return this.cmp(t)>0};Yn.greaterThanOrEqualTo=Yn.gte=function(t){return this.cmp(t)>=0};Yn.isInteger=Yn.isint=function(){return this.e>this.d.length-2};Yn.isNegative=Yn.isneg=function(){return this.s<0};Yn.isPositive=Yn.ispos=function(){return this.s>0};Yn.isZero=function(){return this.s===0};Yn.lessThan=Yn.lt=function(t){return this.cmp(t)<0};Yn.lessThanOrEqualTo=Yn.lte=function(t){return this.cmp(t)<1};Yn.logarithm=Yn.log=function(t){var s,r=this,n=r.constructor,a=n.precision,o=a+5;if(t===void 0)t=new n(10);else if(t=new n(t),t.s<1||t.eq(Jp))throw Error(Ex+"NaN");if(r.s<1)throw Error(Ex+(r.s?"NaN":"-Infinity"));return r.eq(Jp)?new n(0):(gc=!1,s=r1(RD(r,o),RD(t,o),o),gc=!0,fl(s,a))};Yn.minus=Yn.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?Ort(s,t):Drt(s,(t.s=-t.s,t))};Yn.modulo=Yn.mod=function(t){var s,r=this,n=r.constructor,a=n.precision;if(t=new n(t),!t.s)throw Error(Ex+"NaN");return r.s?(gc=!1,s=r1(r,t,0,1).times(t),gc=!0,r.minus(s)):fl(new n(r),a)};Yn.naturalExponential=Yn.exp=function(){return Rrt(this)};Yn.naturalLogarithm=Yn.ln=function(){return RD(this)};Yn.negated=Yn.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Yn.plus=Yn.add=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?Drt(s,t):Ort(s,(t.s=-t.s,t))};Yn.precision=Yn.sd=function(t){var s,r,n,a=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(MS+t);if(s=$d(a)+1,n=a.d.length-1,r=n*Kl+1,n=a.d[n],n){for(;n%10==0;n/=10)r--;for(n=a.d[0];n>=10;n/=10)r++}return t&&s>r?s:r};Yn.squareRoot=Yn.sqrt=function(){var t,s,r,n,a,o,l,i=this,d=i.constructor;if(i.s<1){if(!i.s)return new d(0);throw Error(Ex+"NaN")}for(t=$d(i),gc=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=Uy(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=xE((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(r1(i,o,l+2)).times(.5),Uy(o.d).slice(0,l)===(s=Uy(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(fl(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return gc=!0,fl(n,r)};Yn.times=Yn.mul=function(t){var s,r,n,a,o,l,i,d,u,p=this,x=p.constructor,y=p.d,_=(t=new x(t)).d;if(!p.s||!t.s)return new x(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%Eu|0,s=i/Eu|0;o[a]=(o[a]+s)%Eu|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,gc?fl(t,x.precision):t};Yn.toDecimalPlaces=Yn.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(x0(t,0,fE),s===void 0?s=n.rounding:x0(s,0,8),fl(r,t+$d(r)+1,s))};Yn.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=iC(n,!0):(x0(t,0,fE),s===void 0?s=a.rounding:x0(s,0,8),n=fl(new a(n),t+1,s),r=iC(n,!0,t+1)),r};Yn.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?iC(a):(x0(t,0,fE),s===void 0?s=o.rounding:x0(s,0,8),n=fl(new o(a),t+$d(a)+1,s),r=iC(n.abs(),!1,t+$d(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};Yn.toInteger=Yn.toint=function(){var t=this,s=t.constructor;return fl(new s(t),$d(t)+1,s.rounding)};Yn.toNumber=function(){return+this};Yn.toPower=Yn.pow=function(t){var s,r,n,a,o,l,i=this,d=i.constructor,u=12,p=+(t=new d(t));if(!t.s)return new d(Jp);if(i=new d(i),!i.s){if(t.s<1)throw Error(Ex+"Infinity");return i}if(i.eq(Jp))return i;if(n=d.precision,t.eq(Jp))return fl(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=p<0?-p:p)<=Lrt){for(a=new d(Jp),s=Math.ceil(n/Kl+4),gc=!1;r%2&&(a=a.times(i),COe(a.d,s)),r=xE(r/2),r!==0;)i=i.times(i),COe(i.d,s);return gc=!0,t.s<0?new d(Jp).div(a):fl(a,n)}}else if(o<0)throw Error(Ex+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,gc=!1,a=t.times(RD(i,n+u)),gc=!0,a=Rrt(a),a.s=o,a};Yn.toPrecision=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?(r=$d(a),n=iC(a,r<=o.toExpNeg||r>=o.toExpPos)):(x0(t,1,fE),s===void 0?s=o.rounding:x0(s,0,8),a=fl(new o(a),t,s),r=$d(a),n=iC(a,t<=r||r<=o.toExpNeg,t)),n};Yn.toSignificantDigits=Yn.tosd=function(t,s){var r=this,n=r.constructor;return t===void 0?(t=n.precision,s=n.rounding):(x0(t,1,fE),s===void 0?s=n.rounding:x0(s,0,8)),fl(new n(r),t,s)};Yn.toString=Yn.valueOf=Yn.val=Yn.toJSON=Yn[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,s=$d(t),r=t.constructor;return iC(t,s<=r.toExpNeg||s>=r.toExpPos)};function Drt(t,s){var r,n,a,o,l,i,d,u,p=t.constructor,x=p.precision;if(!t.s||!s.s)return s.s||(s=new p(t)),gc?fl(s,x):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(x/Kl),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)/Eu|0,d[o]%=Eu;for(r&&(d.unshift(r),++a),i=d.length;d[--i]==0;)d.pop();return s.d=d,s.e=a,gc?fl(s,x):s}function x0(t,s,r){if(t!==~~t||tr)throw Error(MS+t)}function Uy(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,x,y,_,b,N,w,k,C,E,L,I,O,V,q,$=n.constructor,U=n.s==a.s?1:-1,se=n.d,Y=a.d;if(!n.s)return new $(n);if(!a.s)throw Error(Ex+"Division by zero");for(d=n.e-a.e,V=Y.length,I=se.length,_=new $(U),b=_.d=[],u=0;Y[u]==(se[u]||0);)++u;if(Y[u]>(se[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/Kl+2|0,u=0,V==1)for(p=0,Y=Y[0],C++;(u1&&(Y=t(Y,p),se=t(se,p),V=Y.length,I=se.length),L=V,N=se.slice(0,V),w=N.length;w=Eu/2&&++O;do p=0,i=s(Y,N,V,w),i<0?(k=N[0],V!=w&&(k=k*Eu+(N[1]||0)),p=k/O|0,p>1?(p>=Eu&&(p=Eu-1),x=t(Y,p),y=x.length,w=N.length,i=s(x,N,y,w),i==1&&(p--,r(x,V16)throw Error(gSe+$d(t));if(!t.s)return new p(Jp);for(s==null?(gc=!1,i=x):i=s,l=new p(.03125);t.abs().gte(.1);)t=t.times(l),u+=5;for(n=Math.log(n4(2,u))/Math.LN10*2+5|0,i+=n,r=a=o=new p(Jp),p.precision=i;;){if(a=fl(a.times(t),i),r=r.times(++d),l=o.plus(r1(a,r,i)),Uy(l.d).slice(0,i)===Uy(o.d).slice(0,i)){for(;u--;)o=fl(o.times(o),i);return p.precision=x,s==null?(gc=!0,fl(o,x)):o}o=l}}function $d(t){for(var s=t.e*Kl,r=t.d[0];r>=10;r/=10)s++;return s}function Zye(t,s,r){if(s>t.LN10.sd())throw gc=!0,r&&(t.precision=r),Error(Ex+"LN10 precision limit exceeded");return fl(new t(t.LN10),s)}function F_(t){for(var s="";t--;)s+="0";return s}function RD(t,s){var r,n,a,o,l,i,d,u,p,x=1,y=10,_=t,b=_.d,N=_.constructor,w=N.precision;if(_.s<1)throw Error(Ex+(_.s?"NaN":"-Infinity"));if(_.eq(Jp))return new N(0);if(s==null?(gc=!1,u=w):u=s,_.eq(10))return s==null&&(gc=!0),Zye(N,u);if(u+=y,N.precision=u,r=Uy(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=Uy(_.d),n=r.charAt(0),x++;o=$d(_),n>1?(_=new N("0."+r),o++):_=new N(n+"."+r.slice(1))}else return d=Zye(N,u+2,w).times(o+""),_=RD(new N(n+"."+r.slice(1)),u-y).plus(d),N.precision=w,s==null?(gc=!0,fl(_,w)):_;for(i=l=_=r1(_.minus(Jp),_.plus(Jp),u),p=fl(_.times(_),u),a=3;;){if(l=fl(l.times(p),u),d=i.plus(r1(l,new N(a),u)),Uy(d.d).slice(0,u)===Uy(i.d).slice(0,u))return i=i.times(2),o!==0&&(i=i.plus(Zye(N,u+2,w).times(o+""))),i=r1(i,new N(x),u),N.precision=w,s==null?(gc=!0,fl(i,w)):i;i=d,a+=2}}function SOe(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=xE(r/Kl),t.d=[],n=(r+1)%Kl,r<0&&(n+=Kl),nqce||t.e<-qce))throw Error(gSe+r)}else t.s=0,t.e=0,t.d=[0];return t}function fl(t,s,r){var n,a,o,l,i,d,u,p,x=t.d;for(l=1,o=x[0];o>=10;o/=10)l++;if(n=s-l,n<0)n+=Kl,a=s,u=x[p=0];else{if(p=Math.ceil((n+1)/Kl),o=x.length,p>=o)return t;for(u=o=x[p],l=1;o>=10;o/=10)l++;n%=Kl,a=n-Kl+l}if(r!==void 0&&(o=n4(10,l-a-1),i=u/o%10|0,d=s<0||x[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/n4(10,l-a):0:x[p-1])%10&1||r==(t.s<0?8:7))),s<1||!x[0])return d?(o=$d(t),x.length=1,s=s-o-1,x[0]=n4(10,(Kl-s%Kl)%Kl),t.e=xE(-s/Kl)||0):(x.length=1,x[0]=t.e=t.s=0),t;if(n==0?(x.length=p,o=1,p--):(x.length=p+1,o=n4(10,Kl-n),x[p]=a>0?(u/n4(10,l-a)%n4(10,a)|0)*o:0),d)for(;;)if(p==0){(x[0]+=o)==Eu&&(x[0]=1,++t.e);break}else{if(x[p]+=o,x[p]!=Eu)break;x[p--]=0,o=1}for(n=x.length;x[--n]===0;)x.pop();if(gc&&(t.e>qce||t.e<-qce))throw Error(gSe+$d(t));return t}function Ort(t,s){var r,n,a,o,l,i,d,u,p,x,y=t.constructor,_=y.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new y(t),gc?fl(s,_):s;if(d=t.d,x=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=x.length):(r=x,n=u,i=d.length),a=Math.max(Math.ceil(_/Kl),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=x.length,p=a0;--a)d[i++]=0;for(a=x.length;a>l;){if(d[--a]0?o=o.charAt(0)+"."+o.slice(1)+F_(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+F_(-a-1)+o,r&&(n=r-l)>0&&(o+=F_(n))):a>=l?(o+=F_(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+F_(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=F_(n))),t.s<0?"-"+o:o}function COe(t,s){if(t.length>s)return t.length=s,!0}function Frt(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(MS+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 SOe(l,o.toString())}else if(typeof o!="string")throw Error(MS+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,tds.test(o))SOe(l,o);else throw Error(MS+o)}if(a.prototype=Yn,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.clone=Frt,a.config=a.set=sds,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(MS+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(MS+r+": "+n);return this}var ySe=Frt(eds);Jp=new ySe(1);const tl=ySe;function rds(t){return ods(t)||ids(t)||ads(t)||nds()}function nds(){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 ads(t,s){if(t){if(typeof t=="string")return Ebe(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ebe(t,s)}}function ids(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function ods(t){if(Array.isArray(t))return Ebe(t)}function Ebe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=s?r.apply(void 0,a):t(s-l,MOe(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 wds(t){if(Array.isArray(t))return t}function Urt(t){var s=OD(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function Vrt(t,s,r){if(t.lte(0))return new tl(0);var n=ome.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 jds(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(ome.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=uds(dds(function(d){return a.add(new tl(d-l).mul(n)).toNumber()}),Pbe);return i(0,s)}function Hrt(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=Vrt(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?Hrt(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 Nds(t){var s=OD(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=Urt([r,n]),d=OD(i,2),u=d[0],p=d[1];if(u===-1/0||p===1/0){var x=p===1/0?[u].concat(Lbe(Pbe(0,a-1).map(function(){return 1/0}))):[].concat(Lbe(Pbe(0,a-1).map(function(){return-1/0})),[p]);return r>n?Ibe(x):x}if(u===p)return jds(u,a,o);var y=Hrt(u,p,l,o),_=y.step,b=y.tickMin,N=y.tickMax,w=ome.rangeStep(b,N.add(new tl(.1).mul(_)),_);return r>n?Ibe(w):w}function kds(t,s){var r=OD(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=Urt([n,a]),i=OD(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),x=Vrt(new tl(u).sub(d).div(p-1),o,0),y=[].concat(Lbe(ome.rangeStep(new tl(d),new tl(u).sub(new tl(.99).mul(x)),x)),[u]);return n>a?Ibe(y):y}var Sds=$rt(Nds),Cds=$rt(kds),Mds="Invariant failed";function oC(t,s){throw new Error(Mds)}var Tds=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function XT(t){"@babel/helpers - typeof";return XT=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},XT(t)}function Uce(){return Uce=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 Rds(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 Ods(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Fds(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,x=a[u].coordinate,y=u>=i-1?a[0].coordinate:a[u+1].coordinate,_=void 0;if(wm(x-p)!==wm(y-x)){var b=[];if(wm(y-x)===wm(d[1]-d[0])){_=y;var N=x+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(x,(w+x)/2),b[1]=Math.max(x,(w+x)/2)}var k=[Math.min(x,(_+x)/2),Math.max(x,(_+x)/2)];if(s>k[0]&&s<=k[1]||s>=b[0]&&s<=b[1]){l=a[u].index;break}}else{var C=Math.min(p,y),E=Math.max(p,y);if(s>(C+x)/2&&s<=(E+x)/2){l=a[u].index;break}}}else for(var L=0;L0&&L(n[L].coordinate+n[L-1].coordinate)/2&&s<=(n[L].coordinate+n[L+1].coordinate)/2||L===i-1&&s>(n[L].coordinate+n[L-1].coordinate)/2){l=n[L].index;break}return l},vSe=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},tus=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(k&&k.length){var C=k[0].type.defaultProps,E=C!==void 0?Zc(Zc({},C),k[0].props):k[0].props,L=E.barSize,I=E[w];l[I]||(l[I]=[]);var O=yi(L)?r:L;l[I].push({item:k[0],stackList:k.slice(1),barSize:yi(O)?void 0:jm(O,n,0)})}}return l},sus=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=jm(r,a,0,!0),p,x=[];if(l[0].barSize===+l[0].barSize){var y=!1,_=a/d,b=l.reduce(function(L,I){return L+I.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(L,I){var O={item:I.item,position:{offset:w.offset+w.size+u,size:y?_:I.barSize}},V=[].concat(EOe(L),[O]);return w=V[V.length-1].position,I.stackList&&I.stackList.length&&I.stackList.forEach(function(q){V.push({item:q,position:w})}),V},x)}else{var k=jm(n,a,0,!0);a-2*k-(d-1)*u<=0&&(u=0);var C=(a-2*k-(d-1)*u)/d;C>1&&(C>>=0);var E=i===+i?Math.min(C,i):C;p=l.reduce(function(L,I,O){var V=[].concat(EOe(L),[{item:I.item,position:{offset:k+(C+u)*O+(C-E)/2,size:E}}]);return I.stackList&&I.stackList.length&&I.stackList.forEach(function(q){V.push({item:q,position:V[V.length-1].position})}),V},x)}return p},rus=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,d=l-(i.left||0)-(i.right||0),u=Zrt({children:o,legendWidth:d});if(u){var p=a||{},x=p.width,y=p.height,_=u.align,b=u.verticalAlign,N=u.layout;if((N==="vertical"||N==="horizontal"&&b==="middle")&&_!=="center"&&en(s[_]))return Zc(Zc({},s),{},eT({},_,s[_]+(x||0)));if((N==="horizontal"||N==="vertical"&&_==="center")&&b!=="middle"&&en(s[b]))return Zc(Zc({},s),{},eT({},b,s[b]+(y||0)))}return s},nus=function(s,r,n){return yi(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},Yrt=function(s,r,n,a,o){var l=r.props.children,i=hf(l,pO).filter(function(u){return nus(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 x=iu(p,n);if(yi(x))return u;var y=Array.isArray(x)?[ame(x),nme(x)]:[x,x],_=d.reduce(function(b,N){var w=iu(p,N,0),k=y[0]-Math.abs(Array.isArray(w)?w[0]:w),C=y[1]+Math.abs(Array.isArray(w)?w[1]:w);return[Math.min(k,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},aus=function(s,r,n,a,o){var l=r.map(function(i){return Yrt(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},Xrt=function(s,r,n,a,o){var l=r.map(function(d){var u=d.props.dataKey;return n==="number"&&u&&Yrt(s,d,u,a)||y8(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,x=u.length;p=2?wm(i[0]-i[1])*2*u:u,r&&(s.ticks||s.niceTicks)){var p=(s.ticks||s.niceTicks).map(function(x){var y=o?o.indexOf(x):x;return{coordinate:a(y)+u,value:x,offset:u}});return p.filter(function(x){return!iO(x.coordinate)})}return s.isCategorical&&s.categoricalDomain?s.categoricalDomain.map(function(x,y){return{coordinate:a(x)+u,value:x,index:y,offset:u}}):a.ticks&&!n?a.ticks(s.tickCount).map(function(x){return{coordinate:a(x)+u,value:x,offset:u}}):a.domain().map(function(x,y){return{coordinate:a(x)+u,value:o?o[x]:x,index:y,offset:u}})},Yye=new WeakMap,o9=function(s,r){if(typeof r!="function")return s;Yye.has(s)||Yye.set(s,new WeakMap);var n=Yye.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},ent=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:ED(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:Fce(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:g8(),realScaleType:"point"}:o==="category"?{scale:ED(),realScaleType:"band"}:{scale:Fce(),realScaleType:"linear"};if(rC(a)){var d="scale".concat(Vhe(a));return{scale:(kOe[d]||g8)(),realScaleType:kOe[d]?d:"point"}}return ci(a)?{scale:a}:{scale:g8(),realScaleType:"point"}},IOe=1e-4,tnt=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])-IOe,l=Math.max(a[0],a[1])+IOe,i=s(r[0]),d=s(r[n-1]);(il||dl)&&s.domain([r[0],r[n-1]])}},ius=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])}},cus=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)}},dus={sign:lus,expand:TXt,none:UT,silhouette:AXt,wiggle:EXt,positive:cus},uus=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=dus[n],l=MXt().keys(a).value(function(i,d){return+iu(i,d,0)}).order(lbe).offset(o);return l(s)},hus=function(s,r,n,a,o,l){if(!s)return null;var i=l?r.reverse():r,d={},u=i.reduce(function(x,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 x;var k=b[n],C=x[k]||{hasStack:!1,stackGroups:{}};if(lu(N)){var E=C.stackGroups[N]||{numericAxisId:n,cateAxisId:a,items:[]};E.items.push(y),C.hasStack=!0,C.stackGroups[N]=E}else C.stackGroups[dE("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[y]};return Zc(Zc({},x),{},eT({},k,C))},d),p={};return Object.keys(u).reduce(function(x,y){var _=u[y];if(_.hasStack){var b={};_.stackGroups=Object.keys(_.stackGroups).reduce(function(N,w){var k=_.stackGroups[w];return Zc(Zc({},N),{},eT({},w,{numericAxisId:n,cateAxisId:a,items:k.items,stackedData:uus(s,k.items,o)}))},b)}return Zc(Zc({},x),{},eT({},y,_))},p)},snt=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=Sds(u,o,i);return s.domain([ame(p),nme(p)]),{niceTicks:p}}if(o&&a==="number"){var x=s.domain(),y=Cds(x,o,i);return{niceTicks:y}}return null};function LOe(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=gce(r,"value",a[s.dataKey]);if(i)return i.coordinate+n/2}return r[o]?r[o].coordinate+n/2:null}var d=iu(a,yi(l)?s.dataKey:l);return yi(d)?null:s.scale(d)}var DOe=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=iu(l,r.dataKey,r.domain[i]);return yi(d)?null:r.scale(d)-o/2+a},mus=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]},pus=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(lu(o)){var l=r[o];if(l){var i=l.items.indexOf(s);return i>=0?l.stackedData[i]:null}}return null},fus=function(s){return s.reduce(function(r,n){return[ame(n.concat([r[0]]).filter(en)),nme(n.concat([r[1]]).filter(en))]},[1/0,-1/0])},rnt=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 x=fus(p.slice(r,n+1));return[Math.min(u[0],x[0]),Math.max(u[1],x[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})},ROe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,OOe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Fbe=function(s,r,n){if(ci(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(en(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(ROe.test(s[0])){var o=+ROe.exec(s[0])[1];a[0]=r[0]-o}else ci(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(en(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(OOe.test(s[1])){var l=+OOe.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},Hce=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=W4e(r,function(x){return x.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},Nus=function(s,r,n,a,o){var l=s.width,i=s.height,d=s.startAngle,u=s.endAngle,p=jm(s.cx,l,l/2),x=jm(s.cy,i,i/2),y=int(l,i,n),_=jm(s.innerRadius,y,0),b=jm(s.outerRadius,y,y*.8),N=Object.keys(r);return N.reduce(function(w,k){var C=r[k],E=C.domain,L=C.reversed,I;if(yi(C.range))a==="angleAxis"?I=[d,u]:a==="radiusAxis"&&(I=[_,b]),L&&(I=[I[1],I[0]]);else{I=C.range;var O=I,V=yus(O,2);d=V[0],u=V[1]}var q=ent(C,o),$=q.realScaleType,U=q.scale;U.domain(E).range(I),tnt(U);var se=snt(U,Nv(Nv({},C),{},{realScaleType:$})),Y=Nv(Nv(Nv({},C),se),{},{range:I,radius:b,realScaleType:$,scale:U,cx:p,cy:x,innerRadius:_,outerRadius:b,startAngle:d,endAngle:u});return Nv(Nv({},w),{},ant({},k,Y))},{})},kus=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))},Sus=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=kus({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:jus(u),angleInRadian:u}},Cus=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}},Mus=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},$Oe=function(s,r){var n=s.x,a=s.y,o=Sus({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=Cus(r),x=p.startAngle,y=p.endAngle,_=i,b;if(x<=y){for(;_>y;)_-=360;for(;_=x&&_<=y}else{for(;_>x;)_-=360;for(;_=y&&_<=x}return b?Nv(Nv({},r),{},{radius:l,angle:Mus(_,r)}):null},ont=function(s){return!S.isValidElement(s)&&!ci(s)&&typeof s!="boolean"?s.className:""};function $D(t){"@babel/helpers - typeof";return $D=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},$D(t)}var Tus=["offset"];function Aus(t){return Lus(t)||Ius(t)||Pus(t)||Eus()}function Eus(){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 Pus(t,s){if(t){if(typeof t=="string")return zbe(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 zbe(t,s)}}function Ius(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Lus(t){if(Array.isArray(t))return zbe(t)}function zbe(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 Rus(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 qOe(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 Xd(t){for(var s=1;s=0?1:-1,E,L;a==="insideStart"?(E=_+C*l,L=N):a==="insideEnd"?(E=b-C*l,L=!N):a==="end"&&(E=b+C*l,L=N),L=k<=0?L:!L;var I=Ll(u,p,w,E),O=Ll(u,p,w,E+(L?1:-1)*359),V="M".concat(I.x,",").concat(I.y,` A`).concat(w,",").concat(w,",0,1,").concat(L?0:1,`, `).concat(O.x,",").concat(O.y),q=yi(s.id)?dE("recharts-radial-line-"):s.id;return ft.createElement("text",qD({},n,{dominantBaseline:"central",className:_i("recharts-radial-bar-label",i)}),ft.createElement("defs",null,ft.createElement("path",{id:q,d:V})),ft.createElement("textPath",{xlinkHref:"#".concat(q)},r))},Uus=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,x=o.endAngle,y=(p+x)/2;if(a==="outside"){var _=Ll(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,k=Ll(l,i,w,y),C=k.x,E=k.y;return{x:C,y:E,textAnchor:"middle",verticalAnchor:"middle"}},Vus=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,x=p>=0?1:-1,y=x*a,_=x>0?"end":"start",b=x>0?"start":"end",N=u>=0?1:-1,w=N*a,k=N>0?"end":"start",C=N>0?"start":"end";if(o==="top"){var E={x:i+u/2,y:d-x*a,textAnchor:"middle",verticalAnchor:_};return Xd(Xd({},E),n?{height:Math.max(d-n.y,0),width:u}:{})}if(o==="bottom"){var L={x:i+u/2,y:d+p+y,textAnchor:"middle",verticalAnchor:b};return Xd(Xd({},L),n?{height:Math.max(n.y+n.height-(d+p),0),width:u}:{})}if(o==="left"){var I={x:i-w,y:d+p/2,textAnchor:k,verticalAnchor:"middle"};return Xd(Xd({},I),n?{width:Math.max(I.x-n.x,0),height:p}:{})}if(o==="right"){var O={x:i+u+w,y:d+p/2,textAnchor:C,verticalAnchor:"middle"};return Xd(Xd({},O),n?{width:Math.max(n.x+n.width-O.x,0),height:p}:{})}var V=n?{width:u,height:p}:{};return o==="insideLeft"?Xd({x:i+w,y:d+p/2,textAnchor:C,verticalAnchor:"middle"},V):o==="insideRight"?Xd({x:i+u-w,y:d+p/2,textAnchor:k,verticalAnchor:"middle"},V):o==="insideTop"?Xd({x:i+u/2,y:d+y,textAnchor:"middle",verticalAnchor:b},V):o==="insideBottom"?Xd({x:i+u/2,y:d+p-y,textAnchor:"middle",verticalAnchor:_},V):o==="insideTopLeft"?Xd({x:i+w,y:d+y,textAnchor:C,verticalAnchor:b},V):o==="insideTopRight"?Xd({x:i+u-w,y:d+y,textAnchor:k,verticalAnchor:b},V):o==="insideBottomLeft"?Xd({x:i+w,y:d+p-y,textAnchor:C,verticalAnchor:_},V):o==="insideBottomRight"?Xd({x:i+u-w,y:d+p-y,textAnchor:k,verticalAnchor:_},V):iE(o)&&(en(o.x)||b4(o.x))&&(en(o.y)||b4(o.y))?Xd({x:i+jm(o.x,u),y:d+jm(o.y,p),textAnchor:"end",verticalAnchor:"end"},V):Xd({x:i+u/2,y:d+p/2,textAnchor:"middle",verticalAnchor:"middle"},V)},Hus=function(s){return"cx"in s&&en(s.cx)};function Du(t){var s=t.offset,r=s===void 0?5:s,n=Dus(t,Tus),a=Xd({offset:r},n),o=a.viewBox,l=a.position,i=a.value,d=a.children,u=a.content,p=a.className,x=p===void 0?"":p,y=a.textBreakAll;if(!o||yi(i)&&yi(d)&&!S.isValidElement(u)&&!ci(u))return null;if(S.isValidElement(u))return S.cloneElement(u,a);var _;if(ci(u)){if(_=S.createElement(u,a),S.isValidElement(_))return _}else _=Bus(a);var b=Hus(o),N=qa(a,!0);if(b&&(l==="insideStart"||l==="insideEnd"||l==="end"))return qus(a,_,N);var w=b?Uus(a):Vus(a);return ft.createElement(aC,qD({className:_i("recharts-label",x)},N,w,{breakAll:y}),_)}Du.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,x=s.x,y=s.y,_=s.top,b=s.left,N=s.width,w=s.height,k=s.clockWise,C=s.labelViewBox;if(C)return C;if(en(N)&&en(w)){if(en(x)&&en(y))return{x,y,width:N,height:w};if(en(_)&&en(b))return{x:_,y:b,width:N,height:w}}return en(x)&&en(y)?{x,y,width:0,height:0}:en(r)&&en(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:u||0,outerRadius:p||d||i||0,clockWise:k}:s.viewBox?s.viewBox:{}},Gus=function(s,r){return s?s===!0?ft.createElement(Du,{key:"label-implicit",viewBox:r}):lu(s)?ft.createElement(Du,{key:"label-implicit",viewBox:r,value:s}):S.isValidElement(s)?s.type===Du?S.cloneElement(s,{key:"label-implicit",viewBox:r}):ft.createElement(Du,{key:"label-implicit",content:s,viewBox:r}):ci(s)?ft.createElement(Du,{key:"label-implicit",content:s,viewBox:r}):iE(s)?ft.createElement(Du,qD({viewBox:r},s,{key:"label-implicit"})):null:null},Wus=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=hf(a,Du).map(function(d,u){return S.cloneElement(d,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=Gus(s.label,r||o);return[i].concat(Aus(l))};Du.parseViewBox=lnt;Du.renderCallByParent=Wus;function Kus(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var Zus=Kus;const Yus=so(Zus);function UD(t){"@babel/helpers - typeof";return UD=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},UD(t)}var Xus=["valueAccessor"],Qus=["data","dataKey","clockWise","id","textBreakAll"];function Jus(t){return rhs(t)||shs(t)||ths(t)||ehs()}function ehs(){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 ths(t,s){if(t){if(typeof t=="string")return Bbe(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 Bbe(t,s)}}function shs(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function rhs(t){if(Array.isArray(t))return Bbe(t)}function Bbe(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 ohs(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 lhs=function(s){return Array.isArray(s.value)?Yus(s.value):s.value};function n1(t){var s=t.valueAccessor,r=s===void 0?lhs:s,n=HOe(t,Xus),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,d=n.textBreakAll,u=HOe(n,Qus);return!a||!a.length?null:ft.createElement(jo,{className:"recharts-label-list"},a.map(function(p,x){var y=yi(o)?r(p,x):iu(p&&p.payload,o),_=yi(i)?{}:{id:"".concat(i,"-").concat(x)};return ft.createElement(Du,Wce({},qa(p,!0),u,_,{parentViewBox:p.parentViewBox,value:y,textBreakAll:d,viewBox:Du.parseViewBox(yi(l)?p:VOe(VOe({},p),{},{clockWise:l})),key:"label-".concat(x),index:x}))}))}n1.displayName="LabelList";function chs(t,s){return t?t===!0?ft.createElement(n1,{key:"labelList-implicit",data:s}):ft.isValidElement(t)||ci(t)?ft.createElement(n1,{key:"labelList-implicit",data:s,content:t}):iE(t)?ft.createElement(n1,Wce({data:s},t,{key:"labelList-implicit"})):null:null}function dhs(t,s){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&r&&!t.label)return null;var n=t.children,a=hf(n,n1).map(function(l,i){return S.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=chs(t.label,s);return[o].concat(Jus(a))}n1.renderCallByParent=dhs;function VD(t){"@babel/helpers - typeof";return VD=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},VD(t)}function $be(){return $be=Object.assign?Object.assign.bind():function(t){for(var s=1;s180),",").concat(+(l>u),`, `).concat(x.x,",").concat(x.y,` `);if(a>0){var _=Ll(r,n,a,l),b=Ll(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},fhs=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,x=wm(p-u),y=l9({cx:r,cy:n,radius:o,angle:u,sign:x,cornerRadius:l,cornerIsExternal:d}),_=y.circleTangency,b=y.lineTangency,N=y.theta,w=l9({cx:r,cy:n,radius:o,angle:p,sign:-x,cornerRadius:l,cornerIsExternal:d}),k=w.circleTangency,C=w.lineTangency,E=w.theta,L=d?Math.abs(u-p):Math.abs(u-p)-N-E;if(L<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 `):cnt({cx:r,cy:n,innerRadius:a,outerRadius:o,startAngle:u,endAngle:p});var I="M ".concat(b.x,",").concat(b.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(x<0),",").concat(_.x,",").concat(_.y,` A`).concat(o,",").concat(o,",0,").concat(+(L>180),",").concat(+(x<0),",").concat(k.x,",").concat(k.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(x<0),",").concat(C.x,",").concat(C.y,` `);if(a>0){var O=l9({cx:r,cy:n,radius:a,angle:u,sign:x,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),V=O.circleTangency,q=O.lineTangency,$=O.theta,U=l9({cx:r,cy:n,radius:a,angle:p,sign:-x,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),se=U.circleTangency,Y=U.lineTangency,J=U.theta,X=d?Math.abs(u-p):Math.abs(u-p)-$-J;if(X<0&&l===0)return"".concat(I,"L").concat(r,",").concat(n,"Z");I+="L".concat(Y.x,",").concat(Y.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(x<0),",").concat(se.x,",").concat(se.y,` A`).concat(a,",").concat(a,",0,").concat(+(X>180),",").concat(+(x>0),",").concat(V.x,",").concat(V.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(x<0),",").concat(q.x,",").concat(q.y,"Z")}else I+="L".concat(r,",").concat(n,"Z");return I},xhs={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},dnt=function(s){var r=WOe(WOe({},xhs),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,x=r.endAngle,y=r.className;if(l0&&Math.abs(p-x)<360?w=fhs({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(N,b/2),forceCornerRadius:d,cornerIsExternal:u,startAngle:p,endAngle:x}):w=cnt({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:p,endAngle:x}),ft.createElement("path",$be({},qa(r,!0),{className:_,d:w,role:"img"}))};function HD(t){"@babel/helpers - typeof";return HD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},HD(t)}function qbe(){return qbe=Object.assign?Object.assign.bind():function(t){for(var s=1;s0;)if(!r.equals(t[n],s[n],n,n,t,s,r))return!1;return!0}function Ehs(t,s){return gE(t.getTime(),s.getTime())}function tFe(t,s,r){if(t.size!==s.size)return!1;for(var n={},a=t.entries(),o=0,l,i;(l=a.next())&&!l.done;){for(var d=s.entries(),u=!1,p=0;(i=d.next())&&!i.done;){var x=l.value,y=x[0],_=x[1],b=i.value,N=b[0],w=b[1];!u&&!n[p]&&(u=r.equals(y,N,o,p,t,s,r)&&r.equals(_,w,y,N,t,s,r))&&(n[p]=!0),p++}if(!u)return!1;o++}return!0}function Phs(t,s,r){var n=eFe(t),a=n.length;if(eFe(s).length!==a)return!1;for(var o;a-- >0;)if(o=n[a],o===fnt&&(t.$$typeof||s.$$typeof)&&t.$$typeof!==s.$$typeof||!pnt(s,o)||!r.equals(t[o],s[o],o,o,t,s,r))return!1;return!0}function mI(t,s,r){var n=QOe(t),a=n.length;if(QOe(s).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],o===fnt&&(t.$$typeof||s.$$typeof)&&t.$$typeof!==s.$$typeof||!pnt(s,o)||!r.equals(t[o],s[o],o,o,t,s,r)||(l=JOe(t,o),i=JOe(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function Ihs(t,s){return gE(t.valueOf(),s.valueOf())}function Lhs(t,s){return t.source===s.source&&t.flags===s.flags}function sFe(t,s,r){if(t.size!==s.size)return!1;for(var n={},a=t.values(),o,l;(o=a.next())&&!o.done;){for(var i=s.values(),d=!1,u=0;(l=i.next())&&!l.done;)!d&&!n[u]&&(d=r.equals(o.value,l.value,o.value,l.value,t,s,r))&&(n[u]=!0),u++;if(!d)return!1}return!0}function Dhs(t,s){var r=t.length;if(s.length!==r)return!1;for(;r-- >0;)if(t[r]!==s[r])return!1;return!0}var Rhs="[object Arguments]",Ohs="[object Boolean]",Fhs="[object Date]",zhs="[object Map]",Bhs="[object Number]",$hs="[object Object]",qhs="[object RegExp]",Uhs="[object Set]",Vhs="[object String]",Hhs=Array.isArray,rFe=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,nFe=Object.assign,Ghs=Object.prototype.toString.call.bind(Object.prototype.toString);function Whs(t){var s=t.areArraysEqual,r=t.areDatesEqual,n=t.areMapsEqual,a=t.areObjectsEqual,o=t.arePrimitiveWrappersEqual,l=t.areRegExpsEqual,i=t.areSetsEqual,d=t.areTypedArraysEqual;return function(p,x,y){if(p===x)return!0;if(p==null||x==null||typeof p!="object"||typeof x!="object")return p!==p&&x!==x;var _=p.constructor;if(_!==x.constructor)return!1;if(_===Object)return a(p,x,y);if(Hhs(p))return s(p,x,y);if(rFe!=null&&rFe(p))return d(p,x,y);if(_===Date)return r(p,x,y);if(_===RegExp)return l(p,x,y);if(_===Map)return n(p,x,y);if(_===Set)return i(p,x,y);var b=Ghs(p);return b===Fhs?r(p,x,y):b===qhs?l(p,x,y):b===zhs?n(p,x,y):b===Uhs?i(p,x,y):b===$hs?typeof p.then!="function"&&typeof x.then!="function"&&a(p,x,y):b===Rhs?a(p,x,y):b===Ohs||b===Bhs||b===Vhs?o(p,x,y):!1}}function Khs(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?mI:Ahs,areDatesEqual:Ehs,areMapsEqual:n?XOe(tFe,mI):tFe,areObjectsEqual:n?mI:Phs,arePrimitiveWrappersEqual:Ihs,areRegExpsEqual:Lhs,areSetsEqual:n?XOe(sFe,mI):sFe,areTypedArraysEqual:n?mI:Dhs};if(r&&(a=nFe({},a,r(a))),s){var o=d9(a.areArraysEqual),l=d9(a.areMapsEqual),i=d9(a.areObjectsEqual),d=d9(a.areSetsEqual);a=nFe({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:d})}return a}function Zhs(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function Yhs(t){var s=t.circular,r=t.comparator,n=t.createState,a=t.equals,o=t.strict;if(n)return function(d,u){var p=n(),x=p.cache,y=x===void 0?s?new WeakMap:void 0:x,_=p.meta;return r(d,u,{cache:y,equals:a,meta:_,strict:o})};if(s)return function(d,u){return r(d,u,{cache:new WeakMap,equals:a,meta:void 0,strict:o})};var l={cache:void 0,equals:a,meta:void 0,strict:o};return function(d,u){return r(d,u,l)}}var Xhs=Nw();Nw({strict:!0});Nw({circular:!0});Nw({circular:!0,strict:!0});Nw({createInternalComparator:function(){return gE}});Nw({strict:!0,createInternalComparator:function(){return gE}});Nw({circular:!0,createInternalComparator:function(){return gE}});Nw({circular:!0,createInternalComparator:function(){return gE},strict:!0});function Nw(t){t===void 0&&(t={});var s=t.circular,r=s===void 0?!1:s,n=t.createInternalComparator,a=t.createState,o=t.strict,l=o===void 0?!1:o,i=Khs(t),d=Whs(i),u=n?n(d):Zhs(d);return Yhs({circular:r,comparator:d,createState:a,equals:u,strict:l})}function Qhs(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function aFe(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):Qhs(a)};requestAnimationFrame(n)}function Ube(t){"@babel/helpers - typeof";return Ube=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},Ube(t)}function Jhs(t){return rms(t)||sms(t)||tms(t)||ems()}function ems(){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 tms(t,s){if(t){if(typeof t=="string")return iFe(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 iFe(t,s)}}function iFe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r1?1:k<0?0:k},N=function(k){for(var C=k>1?1:k,E=C,L=0;L<8;++L){var I=x(E)-C,O=_(E);if(Math.abs(I-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,x,y){var _=-(p-x)*n,b=y*o,N=y+(_-b)*i/1e3,w=y*i/1e3+p;return Math.abs(w-x)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 Lms(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 Xye(t){return Fms(t)||Oms(t)||Rms(t)||Dms()}function Dms(){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 Rms(t,s){if(t){if(typeof t=="string")return Kbe(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 Kbe(t,s)}}function Oms(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Fms(t){if(Array.isArray(t))return Kbe(t)}function Kbe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Xce(t){return Xce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Xce(t)}var g0=function(t){Ums(r,t);var s=Vms(r);function r(n,a){var o;zms(this,r),o=s.call(this,n,a);var l=o.props,i=l.isActive,d=l.attributeName,u=l.from,p=l.to,x=l.steps,y=l.children,_=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(Xbe(o)),o.changeStyle=o.changeStyle.bind(Xbe(o)),!i||_<=0)return o.state={style:{}},typeof y=="function"&&(o.state={style:p}),Ybe(o);if(x&&x.length)o.state={style:x[0].style};else if(u){if(typeof y=="function")return o.state={style:u},Ybe(o);o.state={style:d?RI({},d,u):u}}else o.state={style:{}};return o}return $ms(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,x=o.from,y=this.state.style;if(i){if(!l){var _={style:d?RI({},d,p):p};this.state&&y&&(d&&y[d]!==p||!d&&y!==p)&&this.setState(_);return}if(!(Xhs(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?x:a.to;if(this.state&&y){var w={style:d?RI({},d,N):N};(d&&y[d]!==N||!d&&y!==N)&&this.setState(w)}this.runAnimation(lg(lg({},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,x=a.onAnimationEnd,y=a.onAnimationStart,_=Ems(l,i,_ms(u),d,this.changeStyle),b=function(){o.stopJSAnimation=_()};this.manager.start([y,p,b,d,x])}},{key:"runStepAnimation",value:function(a){var o=this,l=a.steps,i=a.begin,d=a.onAnimationStart,u=l[0],p=u.style,x=u.duration,y=x===void 0?0:x,_=function(N,w,k){if(k===0)return N;var C=w.duration,E=w.easing,L=E===void 0?"ease":E,I=w.style,O=w.properties,V=w.onAnimationEnd,q=k>0?l[k-1]:w,$=O||Object.keys(I);if(typeof L=="function"||L==="spring")return[].concat(Xye(N),[o.runJSAnimation.bind(o,{from:q.style,to:I,duration:C,easing:L}),C]);var U=cFe($,C,L),se=lg(lg(lg({},q.style),I),{},{transition:U});return[].concat(Xye(N),[se,C,V]).filter(lms)};return this.manager.start([d].concat(Xye(l.reduce(_,[p,Math.max(y,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=nms());var o=a.begin,l=a.duration,i=a.attributeName,d=a.to,u=a.easing,p=a.onAnimationStart,x=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?RI({},i,d):d,w=cFe(Object.keys(N),l,u);b.start([p,o,lg(lg({},N),{},{transition:w}),l,x])}},{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=Ims(a,Pms),u=S.Children.count(o),p=this.state.style;if(typeof o=="function")return o(p);if(!i||u===0||l<=0)return o;var x=function(_){var b=_.props,N=b.style,w=N===void 0?{}:N,k=b.className,C=S.cloneElement(_,lg(lg({},d),{},{style:lg(lg({},w),p),className:k}));return C};return u===1?x(S.Children.only(o)):ft.createElement("div",null,S.Children.map(o,function(y){return x(y)}))}}]),r}(S.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 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 Qce(){return Qce=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 x=[0,0,0,0],y=0,_=4;y<_;y++)x[y]=o[y]>l?l:o[y];p="M".concat(s,",").concat(r+i*x[0]),x[0]>0&&(p+="A ".concat(x[0],",").concat(x[0],",0,0,").concat(u,",").concat(s+d*x[0],",").concat(r)),p+="L ".concat(s+n-d*x[1],",").concat(r),x[1]>0&&(p+="A ".concat(x[1],",").concat(x[1],",0,0,").concat(u,`, `).concat(s+n,",").concat(r+i*x[1])),p+="L ".concat(s+n,",").concat(r+a-i*x[2]),x[2]>0&&(p+="A ".concat(x[2],",").concat(x[2],",0,0,").concat(u,`, `).concat(s+n-d*x[2],",").concat(r+a)),p+="L ".concat(s+d*x[3],",").concat(r+a),x[3]>0&&(p+="A ".concat(x[3],",").concat(x[3],",0,0,").concat(u,`, `).concat(s,",").concat(r+a-i*x[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},eps=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),x=Math.min(l,l+d),y=Math.max(l,l+d);return n>=u&&n<=p&&a>=x&&a<=y}return!1},tps={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},_Se=function(s){var r=gFe(gFe({},tps),s),n=S.useRef(),a=S.useState(-1),o=Gms(a,2),l=o[0],i=o[1];S.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var L=n.current.getTotalLength();L&&i(L)}catch{}},[]);var d=r.x,u=r.y,p=r.width,x=r.height,y=r.radius,_=r.className,b=r.animationEasing,N=r.animationDuration,w=r.animationBegin,k=r.isAnimationActive,C=r.isUpdateAnimationActive;if(d!==+d||u!==+u||p!==+p||x!==+x||p===0||x===0)return null;var E=_i("recharts-rectangle",_);return C?ft.createElement(g0,{canBegin:l>0,from:{width:p,height:x,x:d,y:u},to:{width:p,height:x,x:d,y:u},duration:N,animationEasing:b,isActive:C},function(L){var I=L.width,O=L.height,V=L.x,q=L.y;return ft.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:k,easing:b},ft.createElement("path",Qce({},qa(r,!0),{className:E,d:yFe(V,q,I,O,y),ref:n})))}):ft.createElement("path",Qce({},qa(r,!0),{className:E,d:yFe(d,u,p,x,y)}))},sps=["points","className","baseLinePoints","connectNulls"];function sM(){return sM=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 nps(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 vFe(t){return lps(t)||ops(t)||ips(t)||aps()}function aps(){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 ips(t,s){if(t){if(typeof t=="string")return Qbe(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 Qbe(t,s)}}function ops(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function lps(t){if(Array.isArray(t))return Qbe(t)}function Qbe(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){_Fe(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),_Fe(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},_8=function(s,r){var n=cps(s);r&&(n=[n.reduce(function(o,l){return[].concat(vFe(o),vFe(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},dps=function(s,r,n){var a=_8(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(_8(r.reverse(),n).slice(1))},ups=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=rps(s,sps);if(!r||!r.length)return null;var i=_i("recharts-polygon",n);if(a&&a.length){var d=l.stroke&&l.stroke!=="none",u=dps(r,a,o);return ft.createElement("g",{className:i},ft.createElement("path",sM({},qa(l,!0),{fill:u.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:u})),d?ft.createElement("path",sM({},qa(l,!0),{fill:"none",d:_8(r,o)})):null,d?ft.createElement("path",sM({},qa(l,!0),{fill:"none",d:_8(a,o)})):null)}var p=_8(r,o);return ft.createElement("path",sM({},qa(l,!0),{fill:p.slice(-1)==="Z"?l.fill:"none",className:i,d:p}))};function Jbe(){return Jbe=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 yps(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 vps=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},_ps=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,x=p===void 0?0:p,y=s.height,_=y===void 0?0:y,b=s.className,N=gps(s,hps),w=mps({x:n,y:o,top:i,left:u,width:x,height:_},N);return!en(n)||!en(o)||!en(x)||!en(_)||!en(i)||!en(u)?null:ft.createElement("path",ewe({},qa(w,!0),{className:_i("recharts-cross",b),d:vps(n,o,x,_,i,u)}))},bps=rme,wps=Prt,jps=k0;function Nps(t,s){return t&&t.length?bps(t,jps(s),wps):void 0}var kps=Nps;const Sps=so(kps);var Cps=rme,Mps=k0,Tps=Irt;function Aps(t,s){return t&&t.length?Cps(t,Mps(s),Tps):void 0}var Eps=Aps;const Pps=so(Eps);var Ips=["cx","cy","angle","ticks","axisLine"],Lps=["ticks","tick","angle","tickFormatter","stroke"];function JT(t){"@babel/helpers - typeof";return JT=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},JT(t)}function b8(){return b8=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 Dps(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 Rps(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function NFe(t,s){for(var r=0;rCFe?l=a==="outer"?"start":"end":o<-CFe?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=z2(z2({},qa(this.props,!1)),{},{fill:"none"},qa(i,!1));if(d==="circle")return ft.createElement(lme,l4({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:o,r:l}));var p=this.props.ticks,x=p.map(function(y){return Ll(a,o,l,y.coordinate)});return ft.createElement(ups,l4({className:"recharts-polar-angle-axis-line"},u,{points:x}))}},{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=qa(this.props,!1),x=qa(l,!1),y=z2(z2({},p),{},{fill:"none"},qa(i,!1)),_=o.map(function(b,N){var w=n.getTickLineCoord(b),k=n.getTickTextAnchor(b),C=z2(z2(z2({textAnchor:k},p),{},{stroke:"none",fill:u},x),{},{index:N,payload:b,x:w.x2,y:w.y2});return ft.createElement(jo,l4({className:_i("recharts-polar-angle-axis-tick",ont(l)),key:"tick-".concat(b.coordinate)},nC(n.props,b,N)),i&&ft.createElement("line",l4({className:"recharts-polar-angle-axis-tick-line"},y,w)),l&&s.renderTickItem(l,C,d?d(b.value,N):b.value))});return ft.createElement(jo,{className:"recharts-polar-angle-axis-ticks"},_)}},{key:"render",value:function(){var n=this.props,a=n.ticks,o=n.radius,l=n.axisLine;return o<=0||!a||!a.length?null:ft.createElement(jo,{className:_i("recharts-polar-angle-axis",this.props.className)},l&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,o){var l;return ft.isValidElement(n)?l=ft.cloneElement(n,a):ci(n)?l=n(a):l=ft.createElement(aC,l4({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(S.PureComponent);ume(hme,"displayName","PolarAngleAxis");ume(hme,"axisType","angleAxis");ume(hme,"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 Xps=Mst,Qps=Xps(Object.getPrototypeOf,Object),Jps=Qps,efs=S1,tfs=Jps,sfs=C1,rfs="[object Object]",nfs=Function.prototype,afs=Object.prototype,Snt=nfs.toString,ifs=afs.hasOwnProperty,ofs=Snt.call(Object);function lfs(t){if(!sfs(t)||efs(t)!=rfs)return!1;var s=tfs(t);if(s===null)return!0;var r=ifs.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&Snt.call(r)==ofs}var cfs=lfs;const dfs=so(cfs);var ufs=S1,hfs=C1,mfs="[object Boolean]";function pfs(t){return t===!0||t===!1||hfs(t)&&ufs(t)==mfs}var ffs=pfs;const xfs=so(ffs);function YD(t){"@babel/helpers - typeof";return YD=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},YD(t)}function tde(){return tde=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:x,height:y,x:d,y:u},duration:N,animationEasing:b,isActive:k},function(E){var L=E.upperWidth,I=E.lowerWidth,O=E.height,V=E.x,q=E.y;return ft.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},ft.createElement("path",tde({},qa(r,!0),{className:C,d:EFe(V,q,L,I,O),ref:n})))}):ft.createElement("g",null,ft.createElement("path",tde({},qa(r,!0),{className:C,d:EFe(d,u,p,x,y)})))},Cfs=["option","shapeType","propTransformer","activeClassName","isActive"];function XD(t){"@babel/helpers - typeof";return XD=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},XD(t)}function Mfs(t,s){if(t==null)return{};var r=Tfs(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 Tfs(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 PFe(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 sde(t){for(var s=1;s0?uf(E,"paddingAngle",0):0;if(I){var V=Yp(I.endAngle-I.startAngle,E.endAngle-E.startAngle),q=jl(jl({},E),{},{startAngle:C+O,endAngle:C+V(N)+O});w.push(q),C=q.endAngle}else{var $=E.endAngle,U=E.startAngle,se=Yp(0,$-U),Y=se(N),J=jl(jl({},E),{},{startAngle:C+O,endAngle:C+Y+O});w.push(J),C=J.endAngle}}),ft.createElement(jo,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||!mO(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,x=a.innerRadius,y=a.outerRadius,_=a.isAnimationActive,b=this.state.isAnimationFinished;if(o||!l||!l.length||!en(u)||!en(p)||!en(x)||!en(y))return null;var N=_i("recharts-pie",i);return ft.createElement(jo,{tabIndex:this.props.rootTabIndex,className:N,ref:function(k){n.pieRef=k}},this.renderSectors(),d&&this.renderLabels(l),Du.renderCallByParent(this.props,null,!1),(!_||b)&&n1.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,L=w-C*_-E,I=a.reduce(function(q,$){var U=iu($,k,0);return q+(en(U)?U:0)},0),O;if(I>0){var V;O=a.map(function(q,$){var U=iu(q,k,0),se=iu(q,p,$),Y=(en(U)?U:0)/I,J;$?J=V.endAngle+wm(N)*d*(U!==0?1:0):J=l;var X=J+wm(N)*((U!==0?_:0)+Y*L),ce=(J+X)/2,ie=(b.innerRadius+b.outerRadius)/2,ae=[{name:se,value:U,payload:q,dataKey:k,type:y}],oe=Ll(b.cx,b.cy,ie,ce);return V=jl(jl(jl({percent:Y,cornerRadius:o,name:se,tooltipPayload:ae,midAngle:ce,middleRadius:ie,tooltipPosition:oe},q),b),{},{value:iu(q,k),startAngle:J,endAngle:X,payload:q,paddingAngle:wm(N)*d}),V})}return jl(jl({},b),{},{sectors:O,data:a})});var Yfs=Math.ceil,Xfs=Math.max;function Qfs(t,s,r,n){for(var a=-1,o=Xfs(Yfs((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var Jfs=Qfs,exs=Wst,RFe=1/0,txs=17976931348623157e292;function sxs(t){if(!t)return t===0?t:0;if(t=exs(t),t===RFe||t===-RFe){var s=t<0?-1:1;return s*txs}return t===t?t:0}var Ant=sxs,rxs=Jfs,nxs=Yhe,Qye=Ant;function axs(t){return function(s,r,n){return n&&typeof n!="number"&&nxs(s,r,n)&&(r=n=void 0),s=Qye(s),r===void 0?(r=s,s=0):r=Qye(r),n=n===void 0?s0&&n.handleDrag(a.changedTouches[0])}),Hp(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()}),Hp(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),Hp(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),Hp(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),Hp(n,"handleSlideDragStart",function(a){var o=$Fe(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 vxs(s,t),fxs(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,x=Math.min(a,o),y=Math.max(a,o),_=s.getIndexInRange(l,x),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=iu(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,x=d.travellerWidth,y=d.startIndex,_=d.endIndex,b=d.onChange,N=n.pageX-o;N>0?N=Math.min(N,u+p-x-i,u+p-x-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=$Fe(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,x=p.x,y=p.width,_=p.travellerWidth,b=p.onChange,N=p.gap,w=p.data,k={startX:this.state.startX,endX:this.state.endX},C=n.pageX-o;C>0?C=Math.min(C,x+y-_-u):C<0&&(C=Math.max(C,x-u)),k[l]=u+C;var E=this.getIndex(k),L=E.startIndex,I=E.endIndex,O=function(){var q=w.length-1;return l==="startX"&&(i>d?L%N===0:I%N===0)||id?I%N===0:L%N===0)||i>d&&I===q};this.setState(Hp(Hp({},l,u+C),"brushMoveStartX",n.pageX),function(){b&&O()&&b(E)})}},{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],x=i.indexOf(p);if(x!==-1){var y=x+n;if(!(y===-1||y>=i.length)){var _=i[y];a==="startX"&&_>=u||a==="endX"&&_<=d||this.setState(Hp({},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 ft.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,x=S.Children.only(u);return x?ft.cloneElement(x,{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,x=d.height,y=d.traveller,_=d.ariaLabel,b=d.data,N=d.startIndex,w=d.endIndex,k=Math.max(n,this.props.x),C=Jye(Jye({},qa(this.props,!1)),{},{x:k,y:u,width:p,height:x}),E=_||"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 ft.createElement(jo,{tabIndex:0,role:"slider","aria-label":E,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(I){["ArrowLeft","ArrowRight"].includes(I.key)&&(I.preventDefault(),I.stopPropagation(),i.handleTravellerMoveKeyboard(I.key==="ArrowRight"?1:-1,a))},onFocus:function(){i.setState({isTravellerFocused:!0})},onBlur:function(){i.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},s.renderTraveller(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,x=Math.max(Math.abs(a-n)-u,0);return ft.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:x,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,x=p.startX,y=p.endX,_=5,b={pointerEvents:"none",fill:u};return ft.createElement(jo,{className:"recharts-brush-texts"},ft.createElement(aC,ade({textAnchor:"end",verticalAnchor:"middle",x:Math.min(x,y)-_,y:l+i/2},b),this.getTextOfTick(a)),ft.createElement(aC,ade({textAnchor:"start",verticalAnchor:"middle",x:Math.max(x,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,x=n.alwaysShowText,y=this.state,_=y.startX,b=y.endX,N=y.isTextActive,w=y.isSlideMoving,k=y.isTravellerMoving,C=y.isTravellerFocused;if(!a||!a.length||!en(i)||!en(d)||!en(u)||!en(p)||u<=0||p<=0)return null;var E=_i("recharts-brush",o),L=ft.Children.count(l)===1,I=mxs("userSelect","none");return ft.createElement(jo,{className:E,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:I},this.renderBackground(),L&&this.renderPanorama(),this.renderSlide(_,b),this.renderTravellerLayer(_,"startX"),this.renderTravellerLayer(b,"endX"),(N||w||k||C||x)&&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 ft.createElement(ft.Fragment,null,ft.createElement("rect",{x:a,y:o,width:l,height:i,fill:d,stroke:"none"}),ft.createElement("line",{x1:a+1,y1:u,x2:a+l-1,y2:u,fill:"none",stroke:"#fff"}),ft.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 ft.isValidElement(n)?o=ft.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,x=n.endIndex;if(o!==a.prevData||u!==a.prevUpdateId)return Jye({prevData:o,prevTravellerWidth:d,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?bxs({data:o,width:l,x:i,travellerWidth:d,startIndex:p,endIndex:x}):{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}}])}(S.PureComponent);Hp(rA,"displayName","Brush");Hp(rA,"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 wxs=G4e;function jxs(t,s){var r;return wxs(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var Nxs=jxs,kxs=_st,Sxs=k0,Cxs=Nxs,Mxs=wp,Txs=Yhe;function Axs(t,s,r){var n=Mxs(t)?kxs:Cxs;return r&&Txs(t,s,r)&&(s=void 0),n(t,Sxs(s))}var Exs=Axs;const Pxs=so(Exs);var l0=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},qFe=qst;function Ixs(t,s,r){s=="__proto__"&&qFe?qFe(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var Lxs=Ixs,Dxs=Lxs,Rxs=Bst,Oxs=k0;function Fxs(t,s){var r={};return s=Oxs(s),Rxs(t,function(n,a,o){Dxs(r,a,s(n,a,o))}),r}var zxs=Fxs;const Bxs=so(zxs);function $xs(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 ngs(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 ags(t,s){var r=t.x,n=t.y,a=rgs(t,Jxs),o="".concat(r),l=parseInt(o,10),i="".concat(n),d=parseInt(i,10),u="".concat(s.height||a.height),p=parseInt(u,10),x="".concat(s.width||a.width),y=parseInt(x,10);return pI(pI(pI(pI(pI({},s),a),l?{x:l}:{}),d?{y:d}:{}),{},{height:p,width:y,name:s.name,radius:s.radius})}function VFe(t){return ft.createElement(Cnt,awe({shapeType:"rectangle",propTransformer:ags,activeClassName:"recharts-active-bar"},t))}var igs=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=en(n)||$Zt(n);return o?s(n,a):(o||oC(),r)}},ogs=["value","background"],Dnt;function nA(t){"@babel/helpers - typeof";return nA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},nA(t)}function lgs(t,s){if(t==null)return{};var r=cgs(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 cgs(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 ode(){return ode=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(ce)0&&Math.abs(X)0&&(J=Math.min((Ue||0)-(X[Te-1]||0),J))}),Number.isFinite(J)){var ce=J/Y,ie=N.layout==="vertical"?n.height:n.width;if(N.padding==="gap"&&(V=ce*ie/2),N.padding==="no-gap"){var ae=jm(s.barCategoryGap,ce*ie),oe=ce*ie/2;V=oe-ae-(oe-ae)/ie*ae}}}a==="xAxis"?q=[n.left+(E.left||0)+(V||0),n.left+n.width-(E.right||0)-(V||0)]:a==="yAxis"?q=d==="horizontal"?[n.top+n.height-(E.bottom||0),n.top+(E.top||0)]:[n.top+(E.top||0)+(V||0),n.top+n.height-(E.bottom||0)-(V||0)]:q=N.range,I&&(q=[q[1],q[0]]);var pe=ent(N,o,y),_e=pe.scale,he=pe.realScaleType;_e.domain(k).range(q),tnt(_e);var we=snt(_e,yg(yg({},N),{},{realScaleType:he}));a==="xAxis"?(se=w==="top"&&!L||w==="bottom"&&L,$=n.left,U=x[O]-se*N.height):a==="yAxis"&&(se=w==="left"&&!L||w==="right"&&L,$=x[O]-se*N.width,U=n.top);var je=yg(yg(yg({},N),we),{},{realScaleType:he,x:$,y:U,scale:_e,width:a==="xAxis"?n.width:N.width,height:a==="yAxis"?n.height:N.height});return je.bandSize=Hce(je,we),!N.hide&&a==="xAxis"?x[O]+=(se?-1:1)*je.height:N.hide||(x[O]+=(se?-1:1)*je.width),yg(yg({},_),{},fme({},b,je))},{})},Bnt=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)}},_gs=function(s){var r=s.x1,n=s.y1,a=s.x2,o=s.y2;return Bnt({x:r,y:n},{x:a,y:o})},$nt=function(){function t(s){ggs(this,t),this.scale=s}return ygs(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)}}])}();fme($nt,"EPS",1e-4);var bSe=function(s){var r=Object.keys(s).reduce(function(n,a){return yg(yg({},n),{},fme({},a,$nt.create(s[a])))},{});return yg(yg({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return Bxs(a,function(d,u){return r[u].apply(d,{bandAware:l,position:i})})},isInRange:function(a){return Lnt(a,function(o,l){return r[l].isInRange(o)})}})};function bgs(t){return(t%180+180)%180}var wgs=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=bgs(a),l=o*Math.PI/180,i=Math.atan(n/r),d=l>i&&l-1?a[o?s[l]:l]:void 0}}var Cgs=Sgs,Mgs=Ant;function Tgs(t){var s=Mgs(t),r=s%1;return s===s?r?s-r:s:0}var Ags=Tgs,Egs=Lst,Pgs=k0,Igs=Ags,Lgs=Math.max;function Dgs(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:Igs(r);return a<0&&(a=Lgs(n+a,0)),Egs(t,Pgs(s),a)}var Rgs=Dgs,Ogs=Cgs,Fgs=Rgs,zgs=Ogs(Fgs),Bgs=zgs;const $gs=so(Bgs);var qgs=HKt(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("")}),wSe=S.createContext(void 0),jSe=S.createContext(void 0),qnt=S.createContext(void 0),Unt=S.createContext({}),Vnt=S.createContext(void 0),Hnt=S.createContext(0),Gnt=S.createContext(0),ZFe=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=qgs(o);return ft.createElement(wSe.Provider,{value:n},ft.createElement(jSe.Provider,{value:a},ft.createElement(Unt.Provider,{value:o},ft.createElement(qnt.Provider,{value:p},ft.createElement(Vnt.Provider,{value:l},ft.createElement(Hnt.Provider,{value:u},ft.createElement(Gnt.Provider,{value:d},i)))))))},Ugs=function(){return S.useContext(Vnt)},Wnt=function(s){var r=S.useContext(wSe);r==null&&oC();var n=r[s];return n==null&&oC(),n},Vgs=function(){var s=S.useContext(wSe);return G_(s)},Hgs=function(){var s=S.useContext(jSe),r=$gs(s,function(n){return Lnt(n.domain,Number.isFinite)});return r||G_(s)},Knt=function(s){var r=S.useContext(jSe);r==null&&oC();var n=r[s];return n==null&&oC(),n},Ggs=function(){var s=S.useContext(qnt);return s},Wgs=function(){return S.useContext(Unt)},NSe=function(){return S.useContext(Gnt)},kSe=function(){return S.useContext(Hnt)};function aA(t){"@babel/helpers - typeof";return aA=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},aA(t)}function Kgs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Zgs(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 Ays(t,s){return tat(t,s+1)}function Eys(t,s,r,n,a){for(var o=(n||[]).slice(),l=s.start,i=s.end,d=0,u=1,p=l,x=function(){var b=n==null?void 0:n[d];if(b===void 0)return{v:tat(n,u)};var N=d,w,k=function(){return w===void 0&&(w=r(b,N)),w},C=b.coordinate,E=d===0||hde(t,C,k,p,i);E||(d=0,p=l,u+=1),E&&(p=C+t*(k()/2+a),d+=u)},y;u<=o.length;)if(y=x(),y)return y.v;return[]}function sR(t){"@babel/helpers - typeof";return sR=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},sR(t)}function r7e(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 k=hde(t,_.tickCoord,N,i,d);k&&(d=_.tickCoord-t*(N()/2+a),o[y]=Ch(Ch({},_),{},{isShow:!0}))},p=l-1;p>=0;p--)u(p);return o}function Rys(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],x=r(p,i-1),y=t*(p.coordinate+t*x/2-u);l[i-1]=p=Ch(Ch({},p),{},{tickCoord:y>0?p.coordinate-y*t:p.coordinate});var _=hde(t,p.tickCoord,function(){return x},d,u);_&&(u=p.tickCoord-t*(x/2+a),l[i-1]=Ch(Ch({},p),{},{isShow:!0}))}for(var b=o?i-1:i,N=function(C){var E=l[C],L,I=function(){return L===void 0&&(L=r(E,C)),L};if(C===0){var O=t*(E.coordinate-t*I()/2-d);l[C]=E=Ch(Ch({},E),{},{tickCoord:O<0?E.coordinate-O*t:E.coordinate})}else l[C]=E=Ch(Ch({},E),{},{tickCoord:E.coordinate});var V=hde(t,E.tickCoord,I,d,u);V&&(d=E.tickCoord+t*(I()/2+a),l[C]=Ch(Ch({},E),{},{isShow:!0}))},w=0;w=2?wm(a[1].coordinate-a[0].coordinate):1,k=Tys(o,w,_);return d==="equidistantPreserveStart"?Eys(w,k,N,a,l):(d==="preserveStart"||d==="preserveStartEnd"?y=Rys(w,k,N,a,l,d==="preserveStartEnd"):y=Dys(w,k,N,a,l),y.filter(function(C){return C.isShow}))}var Oys=["viewBox"],Fys=["viewBox"],zys=["ticks"];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 nM(){return nM=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 Bys(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function $ys(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function a7e(t,s){for(var r=0;r0?d(this.props):d(_)),l<=0||i<=0||!b||!b.length?null:ft.createElement(jo,{className:_i("recharts-cartesian-axis",u),ref:function(w){n.layerReference=w}},o&&this.renderAxisLine(),this.renderTicks(b,this.state.fontSize,this.state.letterSpacing),Du.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,o){var l,i=_i(a.className,"recharts-cartesian-axis-tick-value");return ft.isValidElement(n)?l=ft.cloneElement(n,Yd(Yd({},a),{},{className:i})):ci(n)?l=n(Yd(Yd({},a),{},{className:i})):l=ft.createElement(aC,nM({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(S.Component);TSe(yE,"displayName","CartesianAxis");TSe(yE,"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 Kys=["x1","y1","x2","y2","key"],Zys=["offset"];function lC(t){"@babel/helpers - typeof";return lC=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},lC(t)}function i7e(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 Jys(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 e0s=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 ft.createElement("rect",{x:a,y:o,ry:d,width:l,height:i,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function nat(t,s){var r;if(ft.isValidElement(t))r=ft.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=o7e(s,Kys),u=qa(d,!1);u.offset;var p=o7e(u,Zys);r=ft.createElement("line",N4({},p,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function t0s(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 nat(a,u)});return ft.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function s0s(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 nat(a,u)});return ft.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function r0s(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 x=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 ft.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 ft.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},x)}function n0s(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 x=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 ft.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 ft.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},x)}var a0s=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return Jrt(MSe(Ah(Ah(Ah({},yE.defaultProps),n),{},{ticks:Uv(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},i0s=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return Jrt(MSe(Ah(Ah(Ah({},yE.defaultProps),n),{},{ticks:Uv(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},b5={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function aat(t){var s,r,n,a,o,l,i=NSe(),d=kSe(),u=Wgs(),p=Ah(Ah({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:b5.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:b5.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:b5.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:b5.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:b5.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:b5.verticalFill,x:en(t.x)?t.x:u.left,y:en(t.y)?t.y:u.top,width:en(t.width)?t.width:u.width,height:en(t.height)?t.height:u.height}),x=p.x,y=p.y,_=p.width,b=p.height,N=p.syncWithTicks,w=p.horizontalValues,k=p.verticalValues,C=Vgs(),E=Hgs();if(!en(_)||_<=0||!en(b)||b<=0||!en(x)||x!==+x||!en(y)||y!==+y)return null;var L=p.verticalCoordinatesGenerator||a0s,I=p.horizontalCoordinatesGenerator||i0s,O=p.horizontalPoints,V=p.verticalPoints;if((!O||!O.length)&&ci(I)){var q=w&&w.length,$=I({yAxis:E?Ah(Ah({},E),{},{ticks:q?w:E.ticks}):void 0,width:i,height:d,offset:u},q?!0:N);Dg(Array.isArray($),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(lC($),"]")),Array.isArray($)&&(O=$)}if((!V||!V.length)&&ci(L)){var U=k&&k.length,se=L({xAxis:C?Ah(Ah({},C),{},{ticks:U?k:C.ticks}):void 0,width:i,height:d,offset:u},U?!0:N);Dg(Array.isArray(se),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(lC(se),"]")),Array.isArray(se)&&(V=se)}return ft.createElement("g",{className:"recharts-cartesian-grid"},ft.createElement(e0s,{fill:p.fill,fillOpacity:p.fillOpacity,x:p.x,y:p.y,width:p.width,height:p.height,ry:p.ry}),ft.createElement(t0s,N4({},p,{offset:u,horizontalPoints:O,xAxis:C,yAxis:E})),ft.createElement(s0s,N4({},p,{offset:u,verticalPoints:V,xAxis:C,yAxis:E})),ft.createElement(r0s,N4({},p,{horizontalPoints:O})),ft.createElement(n0s,N4({},p,{verticalPoints:V})))}aat.displayName="CartesianGrid";var o0s=["type","layout","connectNulls","ref"],l0s=["key"];function cA(t){"@babel/helpers - typeof";return cA=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},cA(t)}function l7e(t,s){if(t==null)return{};var r=c0s(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 c0s(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 w8(){return w8=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);rx){_=[].concat(w5(d.slice(0,b)),[x-N]);break}var w=_.length%2===0?[0,y]:[y];return[].concat(w5(s.repeat(d,p)),w5(_),w).map(function(k){return"".concat(k,"px")}).join(", ")}),vg(r,"id",dE("recharts-line-")),vg(r,"pathRef",function(l){r.mainCurve=l}),vg(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),vg(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return v0s(s,t),f0s(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,x=hf(p,pO);if(!x)return null;var y=function(N,w){return{x:N.x,y:N.y,value:N.value,errorVal:iu(N.payload,w)}},_={clipPath:n?"url(#clipPath-".concat(a,")"):null};return ft.createElement(jo,_,x.map(function(b){return ft.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,x=qa(this.props,!1),y=qa(d,!0),_=u.map(function(N,w){var k=Up(Up(Up({key:"dot-".concat(w),r:3},x),y),{},{index:w,cx:N.x,cy:N.y,value:N.value,dataKey:p,payload:N.payload,points:u});return s.renderDotItem(d,k)}),b={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return ft.createElement(jo,w8({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 x=l7e(i,o0s),y=Up(Up(Up({},qa(x,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(o,")"):null,points:n},l),{},{type:d,layout:u,connectNulls:p});return ft.createElement(Kce,w8({},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,x=l.animationDuration,y=l.animationEasing,_=l.animationId,b=l.animateNewValues,N=l.width,w=l.height,k=this.state,C=k.prevPoints,E=k.totalLength;return ft.createElement(g0,{begin:p,duration:x,isActive:u,easing:y,from:{t:0},to:{t:1},key:"line-".concat(_),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(L){var I=L.t;if(C){var O=C.length/i.length,V=i.map(function(Y,J){var X=Math.floor(J*O);if(C[X]){var ce=C[X],ie=Yp(ce.x,Y.x),ae=Yp(ce.y,Y.y);return Up(Up({},Y),{},{x:ie(I),y:ae(I)})}if(b){var oe=Yp(N*2,Y.x),pe=Yp(w/2,Y.y);return Up(Up({},Y),{},{x:oe(I),y:pe(I)})}return Up(Up({},Y),{},{x:Y.x,y:Y.y})});return o.renderCurveStatically(V,n,a)}var q=Yp(0,E),$=q(I),U;if(d){var se="".concat(d).split(/[,\s]+/gim).map(function(Y){return parseFloat(Y)});U=o.getStrokeDasharray($,E,se)}else U=o.generateSimpleStrokeDasharray(E,$);return o.renderCurveStatically(i,n,a,{strokeDasharray:U})})}},{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||!mO(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,x=a.top,y=a.left,_=a.width,b=a.height,N=a.isAnimationActive,w=a.id;if(o||!i||!i.length)return null;var k=this.state.isAnimationFinished,C=i.length===1,E=_i("recharts-line",d),L=u&&u.allowDataOverflow,I=p&&p.allowDataOverflow,O=L||I,V=yi(w)?this.id:w,q=(n=qa(l,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},$=q.r,U=$===void 0?3:$,se=q.strokeWidth,Y=se===void 0?2:se,J=JZt(l)?l:{},X=J.clipDot,ce=X===void 0?!0:X,ie=U*2+Y;return ft.createElement(jo,{className:E},L||I?ft.createElement("defs",null,ft.createElement("clipPath",{id:"clipPath-".concat(V)},ft.createElement("rect",{x:L?y:y-_/2,y:I?x:x-b/2,width:L?_:_*2,height:I?b:b*2})),!ce&&ft.createElement("clipPath",{id:"clipPath-dots-".concat(V)},ft.createElement("rect",{x:y-ie/2,y:x-ie/2,width:_+ie,height:b+ie}))):null,!C&&this.renderCurve(O,V),this.renderErrorBar(O,V),(C||l)&&this.renderDots(O,ce,V),(!N||k)&&n1.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(w5(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 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 cvs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function dvs(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&en(a)&&en(o)?s.slice(a,o+1):[]};function bat(t){return t==="number"?[0,"auto"]:void 0}var Nwe=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=_me(r,s);return n<0||!o||!o.length||n>=i.length?null:o.reduce(function(d,u){var p,x=(p=u.props.data)!==null&&p!==void 0?p:r;x&&s.dataStartIndex+s.dataEndIndex!==0&&s.dataEndIndex-s.dataStartIndex>=n&&(x=x.slice(s.dataStartIndex,s.dataEndIndex+1));var y;if(l.dataKey&&!l.allowDuplicatedCategory){var _=x===void 0?i:x;y=gce(_,l.dataKey,a)}else y=x&&x[n]||i[n];return y?[].concat(mA(d),[nnt(u,y)]):d},[])},x7e=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=wvs(o,n),i=s.orderedTooltipTicks,d=s.tooltipAxis,u=s.tooltipTicks,p=eus(l,i,u,d);if(p>=0&&u){var x=u[p]&&u[p].value,y=Nwe(s,r,p,x),_=jvs(n,i,p,o);return{activeTooltipIndex:p,activeLabel:x,activePayload:y,activeCoordinate:_}}return null},Nvs=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,x=s.children,y=s.stackOffset,_=Qrt(p,o);return n.reduce(function(b,N){var w,k=N.type.defaultProps!==void 0?fr(fr({},N.type.defaultProps),N.props):N.props,C=k.type,E=k.dataKey,L=k.allowDataOverflow,I=k.allowDuplicatedCategory,O=k.scale,V=k.ticks,q=k.includeHidden,$=k[l];if(b[$])return b;var U=_me(s.data,{graphicalItems:a.filter(function(we){var je,Ue=l in we.props?we.props[l]:(je=we.type.defaultProps)===null||je===void 0?void 0:je[l];return Ue===$}),dataStartIndex:d,dataEndIndex:u}),se=U.length,Y,J,X;Y0s(k.domain,L,C)&&(Y=Fbe(k.domain,null,L),_&&(C==="number"||O!=="auto")&&(X=y8(U,E,"category")));var ce=bat(C);if(!Y||Y.length===0){var ie,ae=(ie=k.domain)!==null&&ie!==void 0?ie:ce;if(E){if(Y=y8(U,E,C),C==="category"&&_){var oe=UZt(Y);I&&oe?(J=Y,Y=nde(0,se)):I||(Y=FOe(ae,Y,N).reduce(function(we,je){return we.indexOf(je)>=0?we:[].concat(mA(we),[je])},[]))}else if(C==="category")I?Y=Y.filter(function(we){return we!==""&&!yi(we)}):Y=FOe(ae,Y,N).reduce(function(we,je){return we.indexOf(je)>=0||je===""||yi(je)?we:[].concat(mA(we),[je])},[]);else if(C==="number"){var pe=aus(U,a.filter(function(we){var je,Ue,Te=l in we.props?we.props[l]:(je=we.type.defaultProps)===null||je===void 0?void 0:je[l],Me="hide"in we.props?we.props.hide:(Ue=we.type.defaultProps)===null||Ue===void 0?void 0:Ue.hide;return Te===$&&(q||!Me)}),E,o,p);pe&&(Y=pe)}_&&(C==="number"||O!=="auto")&&(X=y8(U,E,"category"))}else _?Y=nde(0,se):i&&i[$]&&i[$].hasStack&&C==="number"?Y=y==="expand"?[0,1]:rnt(i[$].stackGroups,d,u):Y=Xrt(U,a.filter(function(we){var je=l in we.props?we.props[l]:we.type.defaultProps[l],Ue="hide"in we.props?we.props.hide:we.type.defaultProps.hide;return je===$&&(q||!Ue)}),C,p,!0);if(C==="number")Y=bwe(x,Y,$,o,V),ae&&(Y=Fbe(ae,Y,L));else if(C==="category"&&ae){var _e=ae,he=Y.every(function(we){return _e.indexOf(we)>=0});he&&(Y=_e)}}return fr(fr({},b),{},Ka({},$,fr(fr({},k),{},{axisType:o,domain:Y,categoricalDomain:X,duplicateDomain:J,originalDomain:(w=k.domain)!==null&&w!==void 0?w:ce,isCategorical:_,layout:p})))},{})},kvs=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,x=s.children,y=_me(s.data,{graphicalItems:n,dataStartIndex:d,dataEndIndex:u}),_=y.length,b=Qrt(p,o),N=-1;return n.reduce(function(w,k){var C=k.type.defaultProps!==void 0?fr(fr({},k.type.defaultProps),k.props):k.props,E=C[l],L=bat("number");if(!w[E]){N++;var I;return b?I=nde(0,_):i&&i[E]&&i[E].hasStack?(I=rnt(i[E].stackGroups,d,u),I=bwe(x,I,E,o)):(I=Fbe(L,Xrt(y,n.filter(function(O){var V,q,$=l in O.props?O.props[l]:(V=O.type.defaultProps)===null||V===void 0?void 0:V[l],U="hide"in O.props?O.props.hide:(q=O.type.defaultProps)===null||q===void 0?void 0:q.hide;return $===E&&!U}),"number",p),a.defaultProps.allowDataOverflow),I=bwe(x,I,E,o)),fr(fr({},w),{},Ka({},E,fr(fr({axisType:o},a.defaultProps),{},{hide:!0,orientation:uf(_vs,"".concat(o,".").concat(N%2),null),domain:I,originalDomain:L,isCategorical:b,layout:p})))}return w},{})},Svs=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,x="".concat(a,"Id"),y=hf(p,o),_={};return y&&y.length?_=Nvs(s,{axes:y,graphicalItems:l,axisType:a,axisIdKey:x,stackGroups:i,dataStartIndex:d,dataEndIndex:u}):l&&l.length&&(_=kvs(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:x,stackGroups:i,dataStartIndex:d,dataEndIndex:u})),_},Cvs=function(s){var r=G_(s),n=Uv(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:W4e(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:Hce(r,n)}},g7e=function(s){var r=s.children,n=s.defaultShowTooltip,a=Wp(r,rA),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}},Mvs=function(s){return!s||!s.length?!1:s.some(function(r){var n=s1(r&&r.type);return n&&n.indexOf("Bar")>=0})},y7e=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"}},Tvs=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,x=n.children,y=n.margin||{},_=Wp(x,rA),b=Wp(x,XM),N=Object.keys(d).reduce(function(I,O){var V=d[O],q=V.orientation;return!V.mirror&&!V.hide?fr(fr({},I),{},Ka({},q,I[q]+V.width)):I},{left:y.left||0,right:y.right||0}),w=Object.keys(l).reduce(function(I,O){var V=l[O],q=V.orientation;return!V.mirror&&!V.hide?fr(fr({},I),{},Ka({},q,uf(I,"".concat(q))+V.height)):I},{top:y.top||0,bottom:y.bottom||0}),k=fr(fr({},w),N),C=k.bottom;_&&(k.bottom+=_.props.height||rA.defaultProps.height),b&&r&&(k=rus(k,a,n,r));var E=u-k.left-k.right,L=p-k.top-k.bottom;return fr(fr({brushBottom:C},k),{},{width:Math.max(E,0),height:Math.max(L,0)})},Avs=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},ASe=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,x=s.defaultProps,y=function(k,C){var E=C.graphicalItems,L=C.stackGroups,I=C.offset,O=C.updateId,V=C.dataStartIndex,q=C.dataEndIndex,$=k.barSize,U=k.layout,se=k.barGap,Y=k.barCategoryGap,J=k.maxBarSize,X=y7e(U),ce=X.numericAxisName,ie=X.cateAxisName,ae=Mvs(E),oe=[];return E.forEach(function(pe,_e){var he=_me(k.data,{graphicalItems:[pe],dataStartIndex:V,dataEndIndex:q}),we=pe.type.defaultProps!==void 0?fr(fr({},pe.type.defaultProps),pe.props):pe.props,je=we.dataKey,Ue=we.maxBarSize,Te=we["".concat(ce,"Id")],Me=we["".concat(ie,"Id")],Fe={},Le=d.reduce(function(ot,Ge){var et=C["".concat(Ge.axisType,"Map")],ht=we["".concat(Ge.axisType,"Id")];et&&et[ht]||Ge.axisType==="zAxis"||oC();var xt=et[ht];return fr(fr({},ot),{},Ka(Ka({},Ge.axisType,xt),"".concat(Ge.axisType,"Ticks"),Uv(xt)))},Fe),Ne=Le[ie],qe=Le["".concat(ie,"Ticks")],ze=L&&L[Te]&&L[Te].hasStack&&pus(pe,L[Te].stackGroups),ve=s1(pe.type).indexOf("Bar")>=0,dt=Hce(Ne,qe),fe=[],Ve=ae&&tus({barSize:$,stackGroups:L,totalSize:Avs(Le,ie)});if(ve){var Je,at,Ae=yi(Ue)?J:Ue,Ye=(Je=(at=Hce(Ne,qe,!0))!==null&&at!==void 0?at:Ae)!==null&&Je!==void 0?Je:0;fe=sus({barGap:se,barCategoryGap:Y,bandSize:Ye!==dt?Ye:dt,sizeList:Ve[Me],maxBarSize:Ae}),Ye!==dt&&(fe=fe.map(function(ot){return fr(fr({},ot),{},{position:fr(fr({},ot.position),{},{offset:ot.position.offset-Ye/2})})}))}var We=pe&&pe.type&&pe.type.getComposedData;We&&oe.push({props:fr(fr({},We(fr(fr({},Le),{},{displayedData:he,props:k,dataKey:je,item:pe,bandSize:dt,barPosition:fe,offset:I,stackedData:ze,layout:U,dataStartIndex:V,dataEndIndex:q}))),{},Ka(Ka(Ka({key:pe.key||"item-".concat(_e)},ce,Le[ce]),ie,Le[ie]),"animationId",O)),childIndex:sYt(pe,k.children),item:pe})}),oe},_=function(k,C){var E=k.props,L=k.dataStartIndex,I=k.dataEndIndex,O=k.updateId;if(!EDe({props:E}))return null;var V=E.children,q=E.layout,$=E.stackOffset,U=E.data,se=E.reverseStackOrder,Y=y7e(q),J=Y.numericAxisName,X=Y.cateAxisName,ce=hf(V,n),ie=hus(U,ce,"".concat(J,"Id"),"".concat(X,"Id"),$,se),ae=d.reduce(function(we,je){var Ue="".concat(je.axisType,"Map");return fr(fr({},we),{},Ka({},Ue,Svs(E,fr(fr({},je),{},{graphicalItems:ce,stackGroups:je.axisType===J&&ie,dataStartIndex:L,dataEndIndex:I}))))},{}),oe=Tvs(fr(fr({},ae),{},{props:E,graphicalItems:ce}),C==null?void 0:C.legendBBox);Object.keys(ae).forEach(function(we){ae[we]=p(E,ae[we],oe,we.replace("Map",""),r)});var pe=ae["".concat(X,"Map")],_e=Cvs(pe),he=y(E,fr(fr({},ae),{},{dataStartIndex:L,dataEndIndex:I,updateId:O,graphicalItems:ce,stackGroups:ie,offset:oe}));return fr(fr({formattedGraphicalItems:he,graphicalItems:ce,offset:oe,stackGroups:ie},_e),ae)},b=function(w){function k(C){var E,L,I;return cvs(this,k),I=hvs(this,k,[C]),Ka(I,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),Ka(I,"accessibilityManager",new Z0s),Ka(I,"handleLegendBBoxUpdate",function(O){if(O){var V=I.state,q=V.dataStartIndex,$=V.dataEndIndex,U=V.updateId;I.setState(fr({legendBBox:O},_({props:I.props,dataStartIndex:q,dataEndIndex:$,updateId:U},fr(fr({},I.state),{},{legendBBox:O}))))}}),Ka(I,"handleReceiveSyncEvent",function(O,V,q){if(I.props.syncId===O){if(q===I.eventEmitterSymbol&&typeof I.props.syncMethod!="function")return;I.applySyncEvent(V)}}),Ka(I,"handleBrushChange",function(O){var V=O.startIndex,q=O.endIndex;if(V!==I.state.dataStartIndex||q!==I.state.dataEndIndex){var $=I.state.updateId;I.setState(function(){return fr({dataStartIndex:V,dataEndIndex:q},_({props:I.props,dataStartIndex:V,dataEndIndex:q,updateId:$},I.state))}),I.triggerSyncEvent({dataStartIndex:V,dataEndIndex:q})}}),Ka(I,"handleMouseEnter",function(O){var V=I.getMouseInfo(O);if(V){var q=fr(fr({},V),{},{isTooltipActive:!0});I.setState(q),I.triggerSyncEvent(q);var $=I.props.onMouseEnter;ci($)&&$(q,O)}}),Ka(I,"triggeredAfterMouseMove",function(O){var V=I.getMouseInfo(O),q=V?fr(fr({},V),{},{isTooltipActive:!0}):{isTooltipActive:!1};I.setState(q),I.triggerSyncEvent(q);var $=I.props.onMouseMove;ci($)&&$(q,O)}),Ka(I,"handleItemMouseEnter",function(O){I.setState(function(){return{isTooltipActive:!0,activeItem:O,activePayload:O.tooltipPayload,activeCoordinate:O.tooltipPosition||{x:O.cx,y:O.cy}}})}),Ka(I,"handleItemMouseLeave",function(){I.setState(function(){return{isTooltipActive:!1}})}),Ka(I,"handleMouseMove",function(O){O.persist(),I.throttleTriggeredAfterMouseMove(O)}),Ka(I,"handleMouseLeave",function(O){I.throttleTriggeredAfterMouseMove.cancel();var V={isTooltipActive:!1};I.setState(V),I.triggerSyncEvent(V);var q=I.props.onMouseLeave;ci(q)&&q(V,O)}),Ka(I,"handleOuterEvent",function(O){var V=tYt(O),q=uf(I.props,"".concat(V));if(V&&ci(q)){var $,U;/.*touch.*/i.test(V)?U=I.getMouseInfo(O.changedTouches[0]):U=I.getMouseInfo(O),q(($=U)!==null&&$!==void 0?$:{},O)}}),Ka(I,"handleClick",function(O){var V=I.getMouseInfo(O);if(V){var q=fr(fr({},V),{},{isTooltipActive:!0});I.setState(q),I.triggerSyncEvent(q);var $=I.props.onClick;ci($)&&$(q,O)}}),Ka(I,"handleMouseDown",function(O){var V=I.props.onMouseDown;if(ci(V)){var q=I.getMouseInfo(O);V(q,O)}}),Ka(I,"handleMouseUp",function(O){var V=I.props.onMouseUp;if(ci(V)){var q=I.getMouseInfo(O);V(q,O)}}),Ka(I,"handleTouchMove",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&I.throttleTriggeredAfterMouseMove(O.changedTouches[0])}),Ka(I,"handleTouchStart",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&I.handleMouseDown(O.changedTouches[0])}),Ka(I,"handleTouchEnd",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&I.handleMouseUp(O.changedTouches[0])}),Ka(I,"handleDoubleClick",function(O){var V=I.props.onDoubleClick;if(ci(V)){var q=I.getMouseInfo(O);V(q,O)}}),Ka(I,"handleContextMenu",function(O){var V=I.props.onContextMenu;if(ci(V)){var q=I.getMouseInfo(O);V(q,O)}}),Ka(I,"triggerSyncEvent",function(O){I.props.syncId!==void 0&&t0e.emit(s0e,I.props.syncId,O,I.eventEmitterSymbol)}),Ka(I,"applySyncEvent",function(O){var V=I.props,q=V.layout,$=V.syncMethod,U=I.state.updateId,se=O.dataStartIndex,Y=O.dataEndIndex;if(O.dataStartIndex!==void 0||O.dataEndIndex!==void 0)I.setState(fr({dataStartIndex:se,dataEndIndex:Y},_({props:I.props,dataStartIndex:se,dataEndIndex:Y,updateId:U},I.state)));else if(O.activeTooltipIndex!==void 0){var J=O.chartX,X=O.chartY,ce=O.activeTooltipIndex,ie=I.state,ae=ie.offset,oe=ie.tooltipTicks;if(!ae)return;if(typeof $=="function")ce=$(oe,O);else if($==="value"){ce=-1;for(var pe=0;pe=0){var ze,ve;if(J.dataKey&&!J.allowDuplicatedCategory){var dt=typeof J.dataKey=="function"?qe:"payload.".concat(J.dataKey.toString());ze=gce(pe,dt,ce),ve=_e&&he&&gce(he,dt,ce)}else ze=pe==null?void 0:pe[X],ve=_e&&he&&he[X];if(Me||Te){var fe=O.props.activeIndex!==void 0?O.props.activeIndex:X;return[S.cloneElement(O,fr(fr(fr({},$.props),Le),{},{activeIndex:fe})),null,null]}if(!yi(ze))return[Ne].concat(mA(I.renderActivePoints({item:$,activePoint:ze,basePoint:ve,childIndex:X,isRange:_e})))}else{var Ve,Je=(Ve=I.getItemByXY(I.state.activeCoordinate))!==null&&Ve!==void 0?Ve:{graphicalItem:Ne},at=Je.graphicalItem,Ae=at.item,Ye=Ae===void 0?O:Ae,We=at.childIndex,ot=fr(fr(fr({},$.props),Le),{},{activeIndex:We});return[S.cloneElement(Ye,ot),null,null]}return _e?[Ne,null,null]:[Ne,null]}),Ka(I,"renderCustomized",function(O,V,q){return S.cloneElement(O,fr(fr({key:"recharts-customized-".concat(q)},I.props),I.state))}),Ka(I,"renderMap",{CartesianGrid:{handler:h9,once:!0},ReferenceArea:{handler:I.renderReferenceElement},ReferenceLine:{handler:h9},ReferenceDot:{handler:I.renderReferenceElement},XAxis:{handler:h9},YAxis:{handler:h9},Brush:{handler:I.renderBrush,once:!0},Bar:{handler:I.renderGraphicChild},Line:{handler:I.renderGraphicChild},Area:{handler:I.renderGraphicChild},Radar:{handler:I.renderGraphicChild},RadialBar:{handler:I.renderGraphicChild},Scatter:{handler:I.renderGraphicChild},Pie:{handler:I.renderGraphicChild},Funnel:{handler:I.renderGraphicChild},Tooltip:{handler:I.renderCursor,once:!0},PolarGrid:{handler:I.renderPolarGrid,once:!0},PolarAngleAxis:{handler:I.renderPolarAxis},PolarRadiusAxis:{handler:I.renderPolarAxis},Customized:{handler:I.renderCustomized}}),I.clipPathId="".concat((E=C.id)!==null&&E!==void 0?E:dE("recharts"),"-clip"),I.throttleTriggeredAfterMouseMove=Kst(I.triggeredAfterMouseMove,(L=C.throttleDelay)!==null&&L!==void 0?L:1e3/60),I.state={},I}return fvs(k,w),uvs(k,[{key:"componentDidMount",value:function(){var E,L;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(E=this.props.margin.left)!==null&&E!==void 0?E:0,top:(L=this.props.margin.top)!==null&&L!==void 0?L:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var E=this.props,L=E.children,I=E.data,O=E.height,V=E.layout,q=Wp(L,ep);if(q){var $=q.props.defaultIndex;if(!(typeof $!="number"||$<0||$>this.state.tooltipTicks.length-1)){var U=this.state.tooltipTicks[$]&&this.state.tooltipTicks[$].value,se=Nwe(this.state,I,$,U),Y=this.state.tooltipTicks[$].coordinate,J=(this.state.offset.top+O)/2,X=V==="horizontal",ce=X?{x:Y,y:J}:{y:Y,x:J},ie=this.state.formattedGraphicalItems.find(function(oe){var pe=oe.item;return pe.type.name==="Scatter"});ie&&(ce=fr(fr({},ce),ie.props.points[$].tooltipPosition),se=ie.props.points[$].tooltipPayload);var ae={activeTooltipIndex:$,isTooltipActive:!0,activeLabel:U,activePayload:se,activeCoordinate:ce};this.setState(ae),this.renderCursor(q),this.accessibilityManager.setIndex($)}}}},{key:"getSnapshotBeforeUpdate",value:function(E,L){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==L.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==E.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==E.margin){var I,O;this.accessibilityManager.setDetails({offset:{left:(I=this.props.margin.left)!==null&&I!==void 0?I:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0}})}return null}},{key:"componentDidUpdate",value:function(E){J_e([Wp(E.children,ep)],[Wp(this.props.children,ep)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var E=Wp(this.props.children,ep);if(E&&typeof E.props.shared=="boolean"){var L=E.props.shared?"axis":"item";return i.indexOf(L)>=0?L:o}return o}},{key:"getMouseInfo",value:function(E){if(!this.container)return null;var L=this.container,I=L.getBoundingClientRect(),O=Mis(I),V={chartX:Math.round(E.pageX-O.left),chartY:Math.round(E.pageY-O.top)},q=I.width/L.offsetWidth||1,$=this.inRange(V.chartX,V.chartY,q);if(!$)return null;var U=this.state,se=U.xAxisMap,Y=U.yAxisMap,J=this.getTooltipEventType(),X=x7e(this.state,this.props.data,this.props.layout,$);if(J!=="axis"&&se&&Y){var ce=G_(se).scale,ie=G_(Y).scale,ae=ce&&ce.invert?ce.invert(V.chartX):null,oe=ie&&ie.invert?ie.invert(V.chartY):null;return fr(fr({},V),{},{xValue:ae,yValue:oe},X)}return X?fr(fr({},V),X):null}},{key:"inRange",value:function(E,L){var I=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,O=this.props.layout,V=E/I,q=L/I;if(O==="horizontal"||O==="vertical"){var $=this.state.offset,U=V>=$.left&&V<=$.left+$.width&&q>=$.top&&q<=$.top+$.height;return U?{x:V,y:q}:null}var se=this.state,Y=se.angleAxisMap,J=se.radiusAxisMap;if(Y&&J){var X=G_(Y);return $Oe({x:V,y:q},X)}return null}},{key:"parseEventsOfWrapper",value:function(){var E=this.props.children,L=this.getTooltipEventType(),I=Wp(E,ep),O={};I&&L==="axis"&&(I.props.trigger==="click"?O={onClick:this.handleClick}:O={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var V=yce(this.props,this.handleOuterEvent);return fr(fr({},V),O)}},{key:"addListener",value:function(){t0e.on(s0e,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){t0e.removeListener(s0e,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(E,L,I){for(var O=this.state.formattedGraphicalItems,V=0,q=O.length;V{const{data:C,error:E}=await G.from("email_campaigns").select("*").eq("status","sent").order("sent_at",{ascending:!0});if(E)throw E;return C}}),{data:n}=gt({queryKey:["campaign-agent-profiles"],queryFn:async()=>{const{data:C,error:E}=await G.from("profiles").select("id, name, email");if(E)throw E;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,E)=>C+(E.sent_count||0),0),i=a.reduce((C,E)=>C+(E.open_count||0),0),d=a.reduce((C,E)=>C+(E.click_count||0),0),u=a.reduce((C,E)=>C+(E.bounce_count||0),0),p=a.reduce((C,E)=>C+(E.complaint_count||0),0),x=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:An,color:"text-foreground"},{label:"Total Emails Sent",value:l,icon:lr,color:"text-green-600"},{label:"Avg Open Rate",value:`${x}%`,icon:wn,color:"text-blue-600"},{label:"Avg Click Rate",value:`${y}%`,icon:nu,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 I,O;const E=C.user_id,L=b.get(E)||{name:((I=o.get(E))==null?void 0:I.name)||((O=o.get(E))==null?void 0:O.email)||"Unknown",campaigns:0,sent:0,opens:0,clicks:0};L.campaigns++,L.sent+=C.sent_count||0,L.opens+=C.open_count||0,L.clicks+=C.click_count||0,b.set(E,L)});const N=[...b.entries()].map(([C,E])=>({id:C,...E,openRate:E.sent>0?+(E.opens/E.sent*100).toFixed(1):0})).sort((C,E)=>E.sent-C.sent),w=N.slice(0,6).map(C=>({name:C.name,value:C.sent})),k=a.map(C=>{var E;return{name:C.name.length>20?C.name.slice(0,20)+"…":C.name,agent:((E=o.get(C.user_id))==null?void 0:E.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?ps(new Date(C.sent_at),"MMM d"):""}});return e.jsx("div",{className:"space-y-6",children:a.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(An,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold 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(Pe,{children:e.jsxs(Re,{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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Open & Click Rates by Campaign"})}),e.jsx(Re,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(QM,{width:"100%",height:"100%",children:e.jsxs(wat,{data:k,children:[e.jsx(cC,{dataKey:"date",fontSize:11}),e.jsx(dC,{fontSize:11,unit:"%"}),e.jsx(ep,{formatter:C=>`${C}%`}),e.jsx(y1,{dataKey:"openRate",fill:"hsl(220, 70%, 50%)",name:"Open Rate",radius:[2,2,0,0]}),e.jsx(y1,{dataKey:"clickRate",fill:"hsl(270, 70%, 50%)",name:"Click Rate",radius:[2,2,0,0]})]})})})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Send Volume by Agent"})}),e.jsx(Re,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(QM,{width:"100%",height:"100%",children:e.jsxs(jat,{children:[e.jsx(S0,{data:w,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:100,label:({name:C,percent:E})=>`${C} (${(E*100).toFixed(0)}%)`,fontSize:11,children:w.map((C,E)=>e.jsx(lO,{fill:v7e[E%v7e.length]},E))}),e.jsx(ep,{})]})})})})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Send Volume Trend"})}),e.jsx(Re,{children:e.jsx("div",{className:"h-[240px]",children:e.jsx(QM,{width:"100%",height:"100%",children:e.jsxs(Evs,{data:k,children:[e.jsx(cC,{dataKey:"date",fontSize:11}),e.jsx(dC,{fontSize:11}),e.jsx(ep,{}),e.jsx(fO,{type:"monotone",dataKey:"sent",stroke:"hsl(142, 71%, 45%)",strokeWidth:2,name:"Emails Sent",dot:{r:4}})]})})})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Agent Performance"})}),e.jsx(Re,{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(Qe,{variant:"outline",children:[C.openRate,"%"]})})]},C.id))})]})})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Campaign Leaderboard"})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-2",children:[...a].sort((C,E)=>{const L=C.sent_count>0?C.open_count/C.sent_count:0;return(E.sent_count>0?E.open_count/E.sent_count:0)-L}).slice(0,10).map((C,E)=>{const L=C.sent_count>0?(C.open_count/C.sent_count*100).toFixed(1):"0.0",I=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:["#",E+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?ps(new Date(C.sent_at),"MMM d, yyyy"):""," · ",C.sent_count," sent"]})]}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(wn,{className:"h-3 w-3"})," ",L,"%"]}),e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(nu,{className:"h-3 w-3"})," ",I,"%"]})]})]},C.id)})})})]})]})})}const Ivs=()=>e.jsx(Es,{title:"Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Analytics & Activity"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Platform-wide usage statistics and user activity"})]}),e.jsxs(ia,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(ea,{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(iGt,{})}),e.jsx(js,{value:"content",className:"space-y-4",children:e.jsx(lGt,{})}),e.jsx(js,{value:"email-campaigns",className:"space-y-4",children:e.jsx(Pvs,{})}),e.jsx(js,{value:"activity",className:"space-y-4",children:e.jsx(aGt,{})}),e.jsx(js,{value:"shares",className:"space-y-4",children:e.jsx(Itt,{})})]})]})});function Lvs(){const t=Jt(),[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,d]=S.useState(null),[u,p]=S.useState(""),[x,y]=S.useState([]),[_,b]=S.useState([]),[N,w]=S.useState([]),[k,C]=S.useState(!1),[E,L]=S.useState(null),[I,O]=S.useState(""),{data:V,isLoading:q}=gt({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:ve,error:dt}=await G.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(dt)throw dt;return ve}}),{data:$}=gt({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:ve,error:dt}=await G.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(dt)throw dt;return ve}}),{data:U}=gt({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:ve,error:dt}=await G.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(dt)throw dt;return ve}}),{data:se}=gt({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:ve,error:dt}=await G.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(dt)throw dt;return ve}}),{data:Y,isLoading:J}=gt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:ve,error:dt}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(dt)throw dt;return ve}}),X=()=>{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=ve=>{a(ve),l({title:ve.title,description:ve.description||"",publish_date:ve.publish_date.split("T")[0],is_published:ve.is_published,category_id:ve.category_id||""}),p(ve.preview_image_url||""),O("");const dt=($==null?void 0:$.filter(Je=>Je.resource_id===ve.id))||[];y(dt.map(Je=>({id:Je.id,name:Je.name,file_url:Je.file_url,file_size:Je.file_size,sort_order:Je.sort_order})));const fe=(U==null?void 0:U.filter(Je=>Je.resource_id===ve.id))||[];b(fe.map(Je=>({id:Je.id,title:Je.title,video_url:Je.video_url,sort_order:Je.sort_order})));const Ve=(se==null?void 0:se.filter(Je=>Je.resource_id===ve.id))||[];w(Ve.map(Je=>({id:Je.id,title:Je.title,canva_share_link:Je.canva_share_link,sort_order:Je.sort_order}))),r(!0)},ie=ve=>{var fe;const dt=(fe=ve.target.files)==null?void 0:fe[0];dt&&(d(dt),p(URL.createObjectURL(dt)))},ae=()=>{y([...x,{name:"",file_url:"",sort_order:x.length}])},oe=ve=>{y(x.filter((dt,fe)=>fe!==ve))},pe=(ve,dt,fe)=>{const Ve=[...x];if(dt==="file"&&fe instanceof File){const Je=fe.name.replace(/\.[^/.]+$/,"");Ve[ve]={...Ve[ve],file:fe,file_size:fe.size,name:Ve[ve].name||Je}}else Ve[ve]={...Ve[ve],[dt]:fe};y(Ve)},_e=()=>{b([..._,{title:"",video_url:"",sort_order:_.length}])},he=ve=>{b(_.filter((dt,fe)=>fe!==ve))},we=(ve,dt,fe)=>{const Ve=[..._];dt==="file"&&fe instanceof File?Ve[ve]={...Ve[ve],file:fe}:Ve[ve]={...Ve[ve],[dt]:fe},b(Ve)},je=()=>{w([...N,{title:"",canva_share_link:"",sort_order:N.length}])},Ue=ve=>{w(N.filter((dt,fe)=>fe!==ve))},Te=(ve,dt,fe)=>{const Ve=[...N];Ve[ve]={...Ve[ve],[dt]:fe},w(Ve)},Me=async(ve,dt)=>{try{const fe=await G.functions.invoke("bunny-upload",{body:{action:"create",title:ve.name}});if(fe.error)throw fe.error;const{videoId:Ve,uploadUrl:Je,libraryId:at}=fe.data,Ae=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Ve,libraryId:at}});if(Ae.error)throw Ae.error;const{uploadUrl:Ye,apiKey:We}=Ae.data,ot=new XMLHttpRequest;return ot.open("PUT",Ye,!0),ot.setRequestHeader("AccessKey",We),ot.upload.onprogress=Ge=>{if(Ge.lengthComputable){const et=Math.round(Ge.loaded/Ge.total*100),ht=[..._];ht[dt]={...ht[dt],uploadProgress:et},b(ht)}},await new Promise((Ge,et)=>{ot.onload=()=>ot.status>=200&&ot.status<300?Ge():et(new Error("Upload failed")),ot.onerror=()=>et(new Error("Upload failed")),ot.send(ve)}),`https://iframe.mediadelivery.net/embed/${at}/${Ve}`}catch(fe){throw console.error("Bunny upload error:",fe),fe}},Fe=It({mutationFn:async ve=>{const{data:dt,error:fe}=await G.from("brokerage_resource_categories").insert({name:ve,sort_order:(Y==null?void 0:Y.length)||0}).select().single();if(fe)throw fe;return dt},onSuccess:ve=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:ve.id}),O(""),me.success("Category created")},onError:ve=>{me.error("Failed to create category: "+ve.message)}}),Le=It({mutationFn:async()=>{C(!0);let ve=(n==null?void 0:n.preview_image_url)||null;if(i){const Ve=i.name.split(".").pop(),Je=`${Date.now()}.${Ve}`,{error:at}=await G.storage.from("brokerage-resources").upload(`previews/${Je}`,i);if(at)throw at;const{data:Ae}=G.storage.from("brokerage-resources").getPublicUrl(`previews/${Je}`);ve=Ae.publicUrl}const dt={title:o.title,description:o.description||null,preview_image_url:ve,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let fe;if(n){const{error:Ve}=await G.from("brokerage_resources").update(dt).eq("id",n.id);if(Ve)throw Ve;fe=n.id;const Je=($==null?void 0:$.filter(xt=>xt.resource_id===n.id).map(xt=>xt.id))||[],at=x.filter(xt=>xt.id).map(xt=>xt.id),Ae=Je.filter(xt=>!at.includes(xt));Ae.length>0&&await G.from("brokerage_resource_pdfs").delete().in("id",Ae);const Ye=(U==null?void 0:U.filter(xt=>xt.resource_id===n.id).map(xt=>xt.id))||[],We=_.filter(xt=>xt.id).map(xt=>xt.id),ot=Ye.filter(xt=>!We.includes(xt));ot.length>0&&await G.from("brokerage_resource_videos").delete().in("id",ot);const Ge=(se==null?void 0:se.filter(xt=>xt.resource_id===n.id).map(xt=>xt.id))||[],et=N.filter(xt=>xt.id).map(xt=>xt.id),ht=Ge.filter(xt=>!et.includes(xt));ht.length>0&&await G.from("brokerage_resource_links").delete().in("id",ht)}else{const{data:Ve,error:Je}=await G.from("brokerage_resources").insert(dt).select().single();if(Je)throw Je;fe=Ve.id}for(let Ve=0;Ve{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),me.success(n?"Resource updated":"Resource created"),r(!1),X(),C(!1)},onError:ve=>{me.error("Failed to save resource: "+ve.message),C(!1)}}),Ne=It({mutationFn:async ve=>{const{error:dt}=await G.from("brokerage_resources").delete().eq("id",ve);if(dt)throw dt},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),me.success("Resource deleted")},onError:ve=>{me.error("Failed to delete: "+ve.message)}}),qe=ve=>{if(ve.preventDefault(),!o.title){me.error("Please enter a title");return}Le.mutate()},ze=ve=>{const dt=($==null?void 0:$.filter(Je=>Je.resource_id===ve).length)||0,fe=(U==null?void 0:U.filter(Je=>Je.resource_id===ve).length)||0,Ve=(se==null?void 0:se.filter(Je=>Je.resource_id===ve).length)||0;return{pdfCount:dt,videoCount:fe,linkCount:Ve}};return e.jsx(Es,{title:"Brokerage Resources Management",description:"Create and manage resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.filter(ve=>ve.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{X(),r(!0)},children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:q?e.jsx(Ms,{children:e.jsx(ut,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):(V==null?void 0:V.length)===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No brokerage resources yet. Create your first one!"})}):V==null?void 0:V.map(ve=>{const{pdfCount:dt,videoCount:fe,linkCount:Ve}=ze(ve.id),Je=Y==null?void 0:Y.find(at=>at.id===ve.category_id);return e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[ve.preview_image_url?e.jsx("img",{src:ve.preview_image_url,alt:ve.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(Ih,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ve.title}),ve.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:ve.description})]})]})}),e.jsx(ut,{children:Je?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:Je.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ut,{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(fn,{className:"h-3.5 w-3.5"}),dt]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"}),fe]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(fo,{className:"h-3.5 w-3.5"}),Ve]})]})}),e.jsx(ut,{children:ps(new Date(ve.publish_date),"MMM d, yyyy")}),e.jsx(ut,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${ve.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:ve.is_published?"Published":"Draft"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const at=($==null?void 0:$.filter(We=>We.resource_id===ve.id))||[],Ae=(U==null?void 0:U.filter(We=>We.resource_id===ve.id))||[],Ye=(se==null?void 0:se.filter(We=>We.resource_id===ve.id))||[];L({...ve,pdfs:at,videos:Ae,links:Ye})},children:e.jsx(wn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ce(ve),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&Ne.mutate(ve.id)},children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]})})]},ve.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:qe,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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(Ih,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(De,{type:"file",accept:"image/*",onChange:ie})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{id:"title",value:o.title,onChange:ve=>l({...o,title:ve.target.value}),placeholder:"Resource Title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{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(Bs,{value:o.category_id,onValueChange:ve=>l({...o,category_id:ve}),children:[e.jsx(Rs,{className:"flex-1",children:e.jsx(qs,{placeholder:"Select a category"})}),e.jsx(Os,{children:Y==null?void 0:Y.map(ve=>e.jsx(vt,{value:ve.id,children:ve.name},ve.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(De,{placeholder:"Or create new category...",value:I,onChange:ve=>O(ve.target.value),className:"flex-1"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",disabled:!I.trim()||Fe.isPending,onClick:()=>Fe.mutate(I.trim()),children:[e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Gg,{content:o.description,onChange:ve=>l({...o,description:ve}),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(xe,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(De,{id:"publish_date",type:"date",value:o.publish_date,onChange:ve=>l({...o,publish_date:ve.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(Er,{checked:o.is_published,onCheckedChange:ve=>l({...o,is_published:ve})}),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(xe,{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4"}),"PDF Documents (",x.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ae,children:[e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),x.map((ve,dt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(De,{placeholder:"PDF Name",value:ve.name,onChange:fe=>pe(dt,"name",fe.target.value),className:"flex-1"}),e.jsx(De,{type:"file",accept:".pdf",onChange:fe=>{var Je;const Ve=(Je=fe.target.files)==null?void 0:Je[0];Ve&&pe(dt,"file",Ve)},className:"flex-1"}),ve.file_url&&!ve.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>oe(dt),children:e.jsx(Sr,{className:"h-4 w-4"})})]},dt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-4 w-4"}),"Videos (",_.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:_e,children:[e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),_.map((ve,dt)=>e.jsxs("div",{className:"space-y-2 p-3 border rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{placeholder:"Video Title",value:ve.title,onChange:fe=>we(dt,"title",fe.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>he(dt),children:e.jsx(Sr,{className:"h-4 w-4"})})]}),e.jsx(De,{type:"file",accept:"video/*",onChange:fe=>{var Je;const Ve=(Je=fe.target.files)==null?void 0:Je[0];Ve&&we(dt,"file",Ve)}}),ve.uploadProgress!==void 0&&ve.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:`${ve.uploadProgress}%`}})}),ve.video_url&&!ve.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},dt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(fo,{className:"h-4 w-4"}),"Canva Links (",N.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:je,children:[e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),N.map((ve,dt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(De,{placeholder:"Link Title",value:ve.title,onChange:fe=>Te(dt,"title",fe.target.value),className:"flex-1"}),e.jsx(De,{placeholder:"Canva Share Link",value:ve.canva_share_link,onChange:fe=>Te(dt,"canva_share_link",fe.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>Ue(dt),children:e.jsx(Sr,{className:"h-4 w-4"})})]},dt))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:Le.isPending||k,children:Le.isPending||k?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!E,onOpenChange:()=>L(null),children:e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:E==null?void 0:E.title})}),E&&e.jsxs("div",{className:"space-y-4",children:[E.preview_image_url&&e.jsx("img",{src:E.preview_image_url,alt:E.title,className:"w-full h-48 object-cover rounded-lg"}),E.description&&e.jsx("p",{className:"text-muted-foreground",children:E.description}),E.pdfs&&E.pdfs.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4"}),"PDF Documents (",E.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:E.pdfs.map(ve=>e.jsx("a",{href:ve.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:ve.name},ve.id))})]}),E.videos&&E.videos.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Tn,{className:"h-4 w-4"}),"Videos (",E.videos.length,")"]}),e.jsx("div",{className:"space-y-2",children:E.videos.map(ve=>e.jsx("div",{className:"p-2 border rounded",children:e.jsx("p",{className:"font-medium text-sm",children:ve.title})},ve.id))})]}),E.links&&E.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(fo,{className:"h-4 w-4"}),"Canva Links (",E.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:E.links.map(ve=>e.jsx("a",{href:ve.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:ve.title},ve.id))})]})]})]})})]})})}const Nat=[{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 Dvs(){const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(null),[p,x]=S.useState(!1),[y,_]=S.useState(!1),[b,N]=S.useState(""),[w,k]=S.useState(""),[C,E]=S.useState(""),[L,I]=S.useState(""),[O,V]=S.useState("Learn More"),[q,$]=S.useState("top"),[U,se]=S.useState(""),[Y,J]=S.useState(!0),[X,ce]=S.useState(""),[ie,ae]=S.useState("");S.useEffect(()=>{oe()},[]);const oe=async()=>{try{const{data:Fe,error:Le}=await G.from("dashboard_banners").select("*").order("placement").order("sort_order");if(Le)throw Le;s(Fe||[])}catch(Fe){me.error("Failed to load banners: "+Fe.message)}finally{n(!1)}},pe=()=>{N(""),k(""),E(""),I(""),V("Learn More"),$("top"),se(""),J(!0),ce(""),ae(""),u(null)},_e=Fe=>{u(Fe),N(Fe.title),k(Fe.description||""),E(Fe.image_url),I(Fe.link_url||""),V(Fe.link_text||"Learn More"),$(Fe.placement),se(Fe.section_after||""),J(Fe.is_active),ce(Fe.start_date?ps(new Date(Fe.start_date),"yyyy-MM-dd'T'HH:mm"):""),ae(Fe.end_date?ps(new Date(Fe.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},he=async Fe=>{var Ne;const Le=(Ne=Fe.target.files)==null?void 0:Ne[0];if(Le){x(!0);try{const qe=Le.name.split(".").pop(),ze=`${Date.now()}.${qe}`,{error:ve}=await G.storage.from("banner-images").upload(ze,Le);if(ve)throw ve;const{data:{publicUrl:dt}}=G.storage.from("banner-images").getPublicUrl(ze);E(dt),me.success("Image uploaded successfully")}catch(qe){me.error("Failed to upload image: "+qe.message)}finally{x(!1)}}},we=async()=>{if(!b.trim()||!C){me.error("Please fill in required fields (title and image)");return}_(!0);try{const Fe={title:b.trim(),description:w.trim()||null,image_url:C,link_url:L.trim()||null,link_text:O.trim()||"Learn More",placement:q,section_after:q==="between"?U:null,is_active:Y,start_date:X?new Date(X).toISOString():null,end_date:ie?new Date(ie).toISOString():null};if(d){const{error:Le}=await G.from("dashboard_banners").update(Fe).eq("id",d.id);if(Le)throw Le;me.success("Banner updated successfully")}else{const Le=t.filter(qe=>qe.placement===q).length,{error:Ne}=await G.from("dashboard_banners").insert({...Fe,sort_order:Le});if(Ne)throw Ne;me.success("Banner created successfully")}o(!1),pe(),oe()}catch(Fe){me.error("Failed to save banner: "+Fe.message)}finally{_(!1)}},je=async()=>{if(d)try{const{error:Fe}=await G.from("dashboard_banners").delete().eq("id",d.id);if(Fe)throw Fe;me.success("Banner deleted successfully"),i(!1),u(null),oe()}catch(Fe){me.error("Failed to delete banner: "+Fe.message)}},Ue=async Fe=>{try{const{error:Le}=await G.from("dashboard_banners").update({is_active:!Fe.is_active}).eq("id",Fe.id);if(Le)throw Le;me.success(Fe.is_active?"Banner deactivated":"Banner activated"),oe()}catch(Le){me.error("Failed to update banner: "+Le.message)}},Te=t.filter(Fe=>Fe.placement==="top"),Me=t.filter(Fe=>Fe.placement==="between");return r?e.jsx(Es,{title:"Dashboard Management",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):e.jsxs(Es,{title:"Dashboard Management",description:"Configure dashboard modules and banners",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Wo,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(hr,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(fs,{open:a&&q==="top",onOpenChange:Fe=>{Fe||pe(),o(Fe),Fe&&$("top")},children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{pe(),$("top")},children:[e.jsx(Us,{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(Ir,{children:"Configure the banner's content and display settings"})]}),e.jsx(_7e,{title:b,setTitle:N,description:w,setDescription:k,imageUrl:C,linkUrl:L,setLinkUrl:I,linkText:O,setLinkText:V,placement:q,setPlacement:$,sectionAfter:U,setSectionAfter:se,isActive:Y,setIsActive:J,startDate:X,setStartDate:ce,endDate:ie,setEndDate:ae,handleImageUpload:he,uploading:p,showPlacementOptions:!1}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),pe()},children:"Cancel"}),e.jsx(K,{onClick:we,disabled:y,children:y?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Re,{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(Fe=>e.jsx(b7e,{banner:Fe,onEdit:()=>_e(Fe),onDelete:()=>{u(Fe),i(!0)},onToggleActive:()=>Ue(Fe)},Fe.id))})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Wo,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(hr,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(fs,{open:a&&q==="between",onOpenChange:Fe=>{Fe||pe(),o(Fe),Fe&&$("between")},children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{pe(),$("between")},children:[e.jsx(Us,{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(Ir,{children:"Configure where this banner appears between sections"})]}),e.jsx(_7e,{title:b,setTitle:N,description:w,setDescription:k,imageUrl:C,linkUrl:L,setLinkUrl:I,linkText:O,setLinkText:V,placement:q,setPlacement:$,sectionAfter:U,setSectionAfter:se,isActive:Y,setIsActive:J,startDate:X,setStartDate:ce,endDate:ie,setEndDate:ae,handleImageUpload:he,uploading:p,showPlacementOptions:!0}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),pe()},children:"Cancel"}),e.jsx(K,{onClick:we,disabled:y,children:y?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Re,{children:Me.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No section banners yet. Add your first banner above."}):e.jsx("div",{className:"space-y-3",children:Me.map(Fe=>e.jsx(b7e,{banner:Fe,onEdit:()=>_e(Fe),onDelete:()=>{u(Fe),i(!0)},onToggleActive:()=>Ue(Fe),showSection:!0},Fe.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(Ir,{children:['Are you sure you want to delete "',d==null?void 0:d.title,'"? This action cannot be undone.']})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:je,children:"Delete"})]})]})})]})}function _7e({title:t,setTitle:s,description:r,setDescription:n,imageUrl:a,linkUrl:o,setLinkUrl:l,linkText:i,setLinkText:d,placement:u,setPlacement:p,sectionAfter:x,setSectionAfter:y,isActive:_,setIsActive:b,startDate:N,setStartDate:w,endDate:k,setEndDate:C,handleImageUpload:E,uploading:L,showPlacementOptions:I}){return e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{id:"title",placeholder:"Banner headline...",value:t,onChange:O=>s(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(vr,{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(xe,{children:"Banner Image *"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(De,{type:"file",accept:"image/*",onChange:E,disabled:L,className:"flex-1"}),L&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),a&&e.jsx("div",{className:"mt-2 relative rounded-lg overflow-hidden border",children:e.jsx("img",{src:a,alt:"Preview",className:"w-full h-40 object-cover"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"linkUrl",children:"Link URL (optional)"}),e.jsx(De,{id:"linkUrl",placeholder:"https://...",value:o,onChange:O=>l(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"linkText",children:"Button Text"}),e.jsx(De,{id:"linkText",placeholder:"Learn More",value:i,onChange:O=>d(O.target.value)})]})]}),I&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Placement"}),e.jsxs(Bs,{value:x,onValueChange:y,children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select section placement..."})}),e.jsx(Os,{children:Nat.map(O=>e.jsx(vt,{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(xe,{htmlFor:"startDate",className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(De,{id:"startDate",type:"datetime-local",value:N,onChange:O=>w(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{htmlFor:"endDate",className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(De,{id:"endDate",type:"datetime-local",value:k,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(Er,{id:"isActive",checked:_,onCheckedChange:b}),e.jsx(xe,{htmlFor:"isActive",children:"Active"})]})})]})}function b7e({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var d;const o=(d=Nat.find(u=>u.value===t.section_after))==null?void 0:d.label,[l,i]=S.useState(null);return S.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(hu,{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(Qe,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(Qe,{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(Tm,{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(wn,{className:"h-4 w-4"}):e.jsx(mp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:s,children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]})]})}const m9={open:{label:"Open",icon:ln,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:vc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:ti,color:"bg-green-500"},closed:{label:"Closed",icon:Zl,color:"bg-muted-foreground"}},w7e={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function Rvs(){var O,V;const{user:t}=Fs(),s=Jt(),[r,n]=S.useState(null),[a,o]=S.useState(""),[l,i]=S.useState("all"),[d,u]=S.useState("all"),[p,x]=S.useState(!1),{data:y=[],isLoading:_}=gt({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:U}=await q;if(U)throw U;return $}}),{data:b=[]}=gt({queryKey:["admin-users-notifications"],queryFn:async()=>{const{data:q,error:$}=await G.from("user_roles").select("user_id").eq("role","admin");if($)throw $;const U=q.map(ie=>ie.user_id),{data:se,error:Y}=await G.from("profiles").select("id, name, email").in("id",U);if(Y)throw Y;const{data:J,error:X}=await G.from("support_notification_settings").select("user_id, receive_notifications");if(X)throw X;const ce=new Map((J==null?void 0:J.map(ie=>[ie.user_id,ie.receive_notifications]))||[]);return se.map(ie=>({...ie,receives_notifications:ce.get(ie.id)||!1}))}}),{data:N=[]}=gt({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=It({mutationFn:async({userId:q,enabled:$})=>{const{data:U}=await G.from("support_notification_settings").select("id").eq("user_id",q).maybeSingle();if(U){const{error:se}=await G.from("support_notification_settings").update({receive_notifications:$}).eq("user_id",q);if(se)throw se}else{const{error:se}=await G.from("support_notification_settings").insert({user_id:q,receive_notifications:$});if(se)throw se}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),me.success("Notification settings updated")},onError:()=>{me.error("Failed to update settings")}}),k=It({mutationFn:async({ticketId:q,status:$})=>{const{error:U}=await G.from("support_tickets").update({status:$}).eq("id",q);if(U)throw U},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=It({mutationFn:async({ticketId:q,assignedTo:$})=>{const{error:U}=await G.from("support_tickets").update({assigned_to:$}).eq("id",q);if(U)throw U},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),me.success("Ticket assigned")},onError:()=>{me.error("Failed to assign ticket")}}),E=It({mutationFn:async q=>{var U,se;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:(U=r.profiles)==null?void 0:U.email,userName:(se=r.profiles)==null?void 0:se.name}})}catch(Y){console.error("Failed to send reply notification:",Y)}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-ticket-replies",r==null?void 0:r.id]}),o(""),me.success("Reply sent!")},onError:()=>{me.error("Failed to send reply")}}),L=()=>{a.trim()&&E.mutate(a)};S.useEffect(()=>{const q=G.channel("admin-tickets").on("postgres_changes",{event:"*",schema:"public",table:"support_tickets"},()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]})}).subscribe();return()=>{G.removeChannel(q)}},[s]);const I=y.filter(q=>q.status==="open").length;return r?(m9[r.status].icon,e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Fa,{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(Qe,{variant:"secondary",children:w7e[r.category]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["from ",((O=r.profiles)==null?void 0:O.name)||"Unknown"," (",(V=r.profiles)==null?void 0:V.email,")"]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm",children:"Status"})}),e.jsx(Re,{children:e.jsxs(Bs,{value:r.status,onValueChange:q=>{k.mutate({ticketId:r.id,status:q}),n({...r,status:q})},children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"open",children:"Open"}),e.jsx(vt,{value:"in_progress",children:"In Progress"}),e.jsx(vt,{value:"resolved",children:"Resolved"}),e.jsx(vt,{value:"closed",children:"Closed"})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm",children:"Assigned To"})}),e.jsx(Re,{children:e.jsxs(Bs,{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(Rs,{children:e.jsx(qs,{placeholder:"Unassigned"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"unassigned",children:"Unassigned"}),b.map(q=>e.jsx(vt,{value:q.id,children:q.name},q.id))]})]})})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(hr,{children:["Created on ",ps(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Re,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"Conversation"})}),e.jsxs(Re,{children:[e.jsx(ui,{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 $,U;return e.jsxs("div",{className:`p-4 rounded-lg ${q.is_admin_reply?"bg-primary/10 ml-4":"bg-muted mr-4"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:q.is_admin_reply?`${(($=q.profiles)==null?void 0:$.name)||"Admin"} (Support)`:((U=q.profiles)==null?void 0:U.name)||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ps(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(wo,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(vr,{placeholder:"Type your reply...",value:a,onChange:q=>o(q.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:L,disabled:!a.trim()||E.isPending,className:"self-end",children:e.jsx(An,{className:"h-4 w-4"})})]})]})]})]})})):e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Support Tickets"}),e.jsxs("p",{className:"text-muted-foreground",children:["Manage support requests from agents",I>0&&e.jsxs(Qe,{variant:"destructive",className:"ml-2",children:[I," open"]})]})]}),e.jsxs(fs,{open:p,onOpenChange:x,children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(ko,{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(Ir,{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(Ti,{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(Sm,{className:"h-4 w-4 text-primary"}):e.jsx(Gv,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Er,{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(ia,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(ea,{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(Bs,{value:d,onValueChange:u,children:[e.jsx(Rs,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"All Categories"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Categories"}),e.jsx(vt,{value:"general",children:"General Support"}),e.jsx(vt,{value:"technology",children:"Technology Support"}),e.jsx(vt,{value:"crm",children:"CRM Support"}),e.jsx(vt,{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(Pe,{children:e.jsxs(Re,{className:"text-center py-12",children:[e.jsx(vc,{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 U,se;const $=m9[q.status].icon;return e.jsx(Pe,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(q),children:e.jsx(Re,{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(Qe,{variant:"outline",className:"text-xs",children:w7e[q.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(U=q.profiles)==null?void 0:U.name," • ",ps(new Date(q.created_at),"MMM d, yyyy")]}),q.assigned_to&&e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Ti,{className:"h-3 w-3"}),((se=b.find(Y=>Y.id===q.assigned_to))==null?void 0:se.name)||"Assigned"]})]})]}),e.jsxs(Qe,{className:m9[q.status].color,children:[e.jsx($,{className:"h-3 w-3 mr-1"}),m9[q.status].label]})]})})},q.id)})})})]})]})})}const kat=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 Ovs({content:t,onChange:s,variables:r}){const n=Ike({extensions:[Dke,Hke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),Gke.configure({types:["heading","paragraph"]}),Wke,kat],content:t,onUpdate:({editor:l})=>{s(l.getHTML())}});S.useEffect(()=>{n&&t!==n.getHTML()&&n.commands.setContent(t)},[t,n]);const a=l=>{n&&n.chain().focus().insertContent(`{{${l.key}}}`).run()},o=()=>{if(!n)return;const l=n.getAttributes("link").href,i=window.prompt("URL",l);if(i!==null){if(i===""){n.chain().focus().extendMarkRange("link").unsetLink().run();return}n.chain().focus().extendMarkRange("link").setLink({href:i}).run()}};return n?e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBold().run(),className:n.isActive("bold")?"bg-muted":"",children:e.jsx(V4,{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(J4,{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(Dh,{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(Zy,{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($4,{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(B4,{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(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:o,className:n.isActive("link")?"bg-muted":"",children:e.jsx(fo,{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(G4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().undo().run(),disabled:!n.can().undo(),children:e.jsx(yS,{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(dS,{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(DM,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(jd,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(va,{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(Eke,{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(Qe,{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 Fvs(){const t=Jt(),[s,r]=S.useState(null),[n,a]=S.useState(null),[o,l]=S.useState(""),[i,d]=S.useState(""),[u,p]=S.useState(""),[x,y]=S.useState(!0),[_,b]=S.useState("visual"),{data:N,isLoading:w}=gt({queryKey:["email-templates"],queryFn:async()=>{const{data:I,error:O}=await G.from("email_templates").select("*").order("name");if(O)throw O;return I.map(V=>({...V,available_variables:V.available_variables||[]}))}}),k=It({mutationFn:async I=>{const{error:O}=await G.from("email_templates").update({subject:I.subject,body_html:I.body_html,description:I.description,is_active:I.is_active}).eq("id",I.id);if(O)throw O},onSuccess:()=>{t.invalidateQueries({queryKey:["email-templates"]}),me.success("Email template updated successfully"),r(null)},onError:I=>{me.error("Failed to update template: "+I.message)}}),C=I=>{r(I),l(I.subject),d(I.body_html),p(I.description||""),y(I.is_active),b("visual")},E=()=>{s&&k.mutate({id:s.id,subject:o,body_html:i,description:u,is_active:x})},L=(I,O)=>{let V=I;return O.forEach(q=>{const $=`{{${q.key}}}`,U=`[${q.label}]`;V=V.replace(new RegExp($.replace(/[{}]/g,"\\$&"),"g"),U)}),V};return s?e.jsxs(Es,{title:"Edit Email Template",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(K,{variant:"ghost",onClick:()=>r(null),children:[e.jsx(Fa,{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(wn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{onClick:E,disabled:k.isPending,children:[e.jsx(_c,{className:"h-4 w-4 mr-2"}),k.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(rr,{className:"h-5 w-5"}),s.name]}),e.jsxs(hr,{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(xe,{htmlFor:"active-toggle",children:"Active"}),e.jsx(Er,{id:"active-toggle",checked:x,onCheckedChange:y})]})]})}),e.jsxs(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(vr,{id:"description",value:u,onChange:I=>p(I.target.value),placeholder:"Brief description of when this email is sent",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"subject",children:"Email Subject"}),e.jsx(De,{id:"subject",value:o,onChange:I=>l(I.target.value),placeholder:"Email subject line"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["You can use variables like ","{{name}}"," in the subject"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Email Body"}),e.jsx(ia,{value:_,onValueChange:I=>b(I),children:e.jsxs(ea,{className:"h-8",children:[e.jsxs(ls,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(oS,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(ls,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(G4,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),_==="visual"?e.jsx(Ovs,{content:i,onChange:d,variables:s.available_variables}):e.jsx(vr,{value:i,onChange:I=>d(I.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"HTML email body"})]})]})]})]}),e.jsx(fs,{open:!!n,onOpenChange:()=>a(null),children:e.jsxs(ms,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Email Preview"}),e.jsxs(Ir,{children:["Subject: ",o.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),e.jsx("div",{className:"border rounded-lg p-4 bg-white",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:L(i,s.available_variables)}})})]})})]}):e.jsx(Es,{title:"Email Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Email Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage and customize system email templates"})]}),w?e.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((I,O)=>e.jsx(Pe,{children:e.jsxs(Lt,{children:[e.jsx(Ns,{className:"h-5 w-48"}),e.jsx(Ns,{className:"h-4 w-96"})]})},O))}):e.jsx("div",{className:"grid gap-4",children:N==null?void 0:N.map(I=>e.jsxs(Pe,{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(Ot,{className:"flex items-center gap-2 text-lg",children:[e.jsx(rr,{className:"h-5 w-5 text-muted-foreground"}),I.name,!I.is_active&&e.jsx(Qe,{variant:"secondary",children:"Inactive"})]}),e.jsx(hr,{children:I.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>a(I),children:[e.jsx(wn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{size:"sm",onClick:()=>C(I),children:[e.jsx(Gc,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),e.jsx(Re,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subject:"}),e.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-sm",children:I.subject})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Variables:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:I.available_variables.map(O=>e.jsx(Qe,{variant:"outline",className:"font-mono text-xs",children:`{{${O.key}}}`},O.key))})]})]})})]},I.id))}),e.jsx(fs,{open:!!n&&!s,onOpenChange:()=>a(null),children:e.jsxs(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(Ir,{children:["Subject: ",n==null?void 0:n.subject.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),n&&e.jsx("div",{className:"border rounded-lg p-4 bg-white",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:L(n.body_html,n.available_variables)}})})]})})]})})}function zvs(){const t=Jt(),[s,r]=S.useState("templates"),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[x,y]=S.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[_,b]=S.useState({name:"",description:"",icon:"📧"}),{data:N=[]}=gt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:U,error:se}=await G.from("email_template_categories").select("*").order("sort_order");if(se)throw se;return U}}),{data:w=[],isLoading:k}=gt({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:U,error:se}=await G.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(se)throw se;return U}}),C=It({mutationFn:async U=>{const se={title:U.title,subject:U.subject,body:U.body,description:U.description||null,tone:U.tone||null,category_id:U.category_id||null,is_active:U.is_active};if(U.id){const{error:Y}=await G.from("agent_email_templates").update(se).eq("id",U.id);if(Y)throw Y}else{const{error:Y}=await G.from("agent_email_templates").insert(se);if(Y)throw Y}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),d(!1),me.success(n?"Template updated":"Template created")},onError:()=>me.error("Failed to save template")}),E=It({mutationFn:async U=>{const{error:se}=await G.from("agent_email_templates").delete().eq("id",U);if(se)throw se},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),me.success("Template deleted")}}),L=It({mutationFn:async U=>{const se={name:U.name,description:U.description||null,icon:U.icon};if(U.id){const{error:Y}=await G.from("email_template_categories").update(se).eq("id",U.id);if(Y)throw Y}else{const Y=N.length>0?Math.max(...N.map(X=>X.sort_order))+1:0,{error:J}=await G.from("email_template_categories").insert({...se,sort_order:Y});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")}),I=It({mutationFn:async U=>{const{error:se}=await G.from("email_template_categories").delete().eq("id",U);if(se)throw se},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)},V=U=>{a(U),y({title:U.title,subject:U.subject,body:U.body,description:U.description||"",tone:U.tone||"",category_id:U.category_id||"",is_active:U.is_active}),d(!0)},q=()=>{l(null),b({name:"",description:"",icon:"📧"}),p(!0)},$=U=>{l(U),b({name:U.name,description:U.description||"",icon:U.icon}),p(!0)};return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(Uu,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(ia,{value:s,onValueChange:r,children:[e.jsxs(ea,{children:[e.jsxs(ls,{value:"templates",className:"gap-2",children:[e.jsx(rr,{className:"h-4 w-4"})," Templates"]}),e.jsxs(ls,{value:"categories",className:"gap-2",children:[e.jsx(Mm,{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(Us,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:k?e.jsx(Ms,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8",children:e.jsx(_s,{className:"h-6 w-6 animate-spin mx-auto"})})}):w.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):w.map(U=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:U.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:U.subject})]})}),e.jsx(ut,{className:"hidden md:table-cell",children:U.category?e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[U.category.icon," ",U.category.name]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ut,{className:"hidden md:table-cell",children:U.tone?e.jsx(Qe,{variant:"secondary",children:U.tone}):"—"}),e.jsx(ut,{children:e.jsx(Qe,{variant:U.is_active?"default":"secondary",children:U.is_active?"Active":"Inactive"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>V(U),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&E.mutate(U.id)},children:e.jsx(gr,{className:"h-4 w-4"})})]})})]},U.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(Us,{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(U=>e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:U.icon})," ",U.name]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>$(U),children:e.jsx(ga,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{confirm("Delete this category?")&&I.mutate(U.id)},children:e.jsx(gr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Re,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:U.description||"No description"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[w.filter(se=>se.category_id===U.id).length," templates"]})]})]},U.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(xe,{children:"Title"}),e.jsx(De,{value:x.title,onChange:U=>y(se=>({...se,title:U.target.value})),placeholder:"e.g. Quick Check-in"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Category"}),e.jsxs(Bs,{value:x.category_id,onValueChange:U=>y(se=>({...se,category_id:U})),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select category"})}),e.jsx(Os,{children:N.map(U=>e.jsxs(vt,{value:U.id,children:[U.icon," ",U.name]},U.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Subject Line"}),e.jsx(De,{value:x.subject,onChange:U=>y(se=>({...se,subject:U.target.value})),placeholder:"e.g. Hey {{first_name}}, just checking in!"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}",", ","{{full_name}}"," for merge variables"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Email Body"}),e.jsx(vr,{value:x.body,onChange:U=>y(se=>({...se,body:U.target.value})),rows:12,placeholder:"Write your email template...",className:"resize-y"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Description (internal)"}),e.jsx(De,{value:x.description,onChange:U=>y(se=>({...se,description:U.target.value})),placeholder:"Short description for admin reference"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Tone"}),e.jsx(De,{value:x.tone,onChange:U=>y(se=>({...se,tone:U.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Er,{checked:x.is_active,onCheckedChange:U=>y(se=>({...se,is_active:U}))}),e.jsx(xe,{children:"Active"})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>C.mutate({...x,id:n==null?void 0:n.id}),disabled:C.isPending||!x.title||!x.subject||!x.body,children:[C.isPending&&e.jsx(_s,{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(xe,{children:"Icon"}),e.jsx(De,{value:_.icon,onChange:U=>b(se=>({...se,icon:U.target.value})),className:"text-center text-lg"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Name"}),e.jsx(De,{value:_.name,onChange:U=>b(se=>({...se,name:U.target.value})),placeholder:"e.g. Check-in & Stay in Touch"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Description"}),e.jsx(De,{value:_.description,onChange:U=>b(se=>({...se,description:U.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>L.mutate({..._,id:o==null?void 0:o.id}),disabled:L.isPending||!_.name,children:[L.isPending&&e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const Bvs=({brokerageId:t})=>{var fa,qt;const{toast:s}=wa(),r=_r(),[n,a]=S.useState([]),[o,l]=S.useState(!0),[i,d]=S.useState(""),[u,p]=S.useState("all"),[x,y]=S.useState(new Set),[_,b]=S.useState(!1),[N,w]=S.useState({}),[k,C]=S.useState(!1),[E,L]=S.useState(!1),[I,O]=S.useState({email:"",name:"",password:"",phone:""}),[V,q]=S.useState(!1),[$,U]=S.useState(null),[se,Y]=S.useState(!1),[J,X]=S.useState(!1),[ce,ie]=S.useState(!1),[ae,oe]=S.useState(""),[pe,_e]=S.useState(!1),[he,we]=S.useState([]),[je,Ue]=S.useState(!1),[Te,Me]=S.useState(!1),[Fe,Le]=S.useState(null),[Ne,qe]=S.useState({name:"",phone:"",email:""}),[ze,ve]=S.useState(!1),[dt,fe]=S.useState(!1),[Ve,Je]=S.useState(null),[at,Ae]=S.useState("asc"),[Ye,We]=S.useState(!1),[ot,Ge]=S.useState(null),[et,ht]=S.useState(!1),[xt,Ke]=S.useState(null),[Ze,Et]=S.useState(""),[$t,Yt]=S.useState(!1),[Ps,zs]=S.useState(null);S.useEffect(()=>{Dr(),Zs()},[t]);const Zs=async()=>{try{const{data:Se,error:Oe}=await G.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if(Oe)throw Oe;we((Se==null?void 0:Se.map(Xe=>Xe.user_id))||[])}catch(Se){console.error("Error loading brokerage managers:",Se)}},Dr=async()=>{try{l(!0);const{data:Se,error:Oe}=await G.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if(Oe)throw Oe;const Xe=Se.agents||[];if(a(Xe),Xe.length>0){const _t=Xe.map(Mt=>Mt.id),{data:bt}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",_t);if(bt&&bt.length>0){const Mt=bt.map(Xt=>Xt.assistant_id),{data:Ht}=await G.from("profiles").select("id, name, email").in("id",Mt),Vt={};for(const Xt of bt){const Ts=Ht==null?void 0:Ht.find(xs=>xs.id===Xt.assistant_id);Ts&&(Vt[Xt.agent_id]={name:Ts.name||"",email:Ts.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)}},zt=async()=>{if(!I.email||!I.name||!I.password){s({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}L(!0);try{const{data:{session:Se}}=await G.auth.getSession(),Oe=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({...I,brokerageId:t})}),Xe=await Oe.json();if(!Oe.ok)throw new Error(Xe.error||"Failed to create agent");s({title:"Success",description:`Agent ${I.email} created successfully`}),O({email:"",name:"",password:"",phone:""}),C(!1),Dr()}catch(Se){console.error("Error creating agent:",Se),s({title:"Error",description:Se.message||"Failed to create agent",variant:"destructive"})}finally{L(!1)}},$s=async Se=>{try{const{data:{session:Oe}}=await G.auth.getSession(),Xe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Oe==null?void 0:Oe.access_token}`},body:JSON.stringify({userId:Se})}),_t=await Xe.json();if(!Xe.ok)throw new Error(_t.error||"Failed to resend welcome email");s({title:"Success",description:"Welcome email sent successfully"})}catch(Oe){console.error("Error resending welcome email:",Oe),s({title:"Error",description:Oe.message||"Failed to resend welcome email",variant:"destructive"})}},kr=async(Se,Oe)=>{try{const{error:Xe}=await G.functions.invoke("send-password-reset",{body:{email:Se,redirectTo:window.location.origin}});if(Xe)throw Xe;s({title:"Password Reset Sent",description:`Password reset email sent to ${Oe}`})}catch(Xe){console.error("Error sending password reset:",Xe),s({title:"Error",description:Xe.message||"Failed to send password reset email",variant:"destructive"})}},Xs=Se=>{U(Se),q(!0)},ir=Se=>{Le(Se),qe({name:Se.name,phone:Se.phone||"",email:Se.email}),Me(!0)},Or=async()=>{if(!Fe)return;if(!Ne.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const Se=Ne.email.trim().toLowerCase()!==Fe.email.toLowerCase();ve(!0);try{if(Se){if(!Ne.email.trim())throw new Error("Email is required");fe(!0);const{data:{session:Xe}}=await G.auth.getSession(),_t=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Xe==null?void 0:Xe.access_token}`},body:JSON.stringify({agentId:Fe.id,newEmail:Ne.email.trim(),brokerageId:t})}),bt=await _t.json();if(fe(!1),!_t.ok)throw new Error(bt.error||"Failed to update email")}const{error:Oe}=await G.from("profiles").update({name:Ne.name.trim(),phone:Ne.phone.trim()||null}).eq("id",Fe.id);if(Oe)throw Oe;s({title:"Success",description:"Agent profile updated successfully"}),Me(!1),Le(null),Dr()}catch(Oe){console.error("Error updating agent:",Oe),s({title:"Error",description:Oe.message||"Failed to update agent",variant:"destructive"})}finally{ve(!1),fe(!1)}},Vn=async()=>{if(!ae){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}_e(!0);try{const{data:{session:Se}}=await G.auth.getSession(),Oe=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:ae,role:"brokerage_manager",action:"add",brokerageId:t})}),Xe=await Oe.json();if(!Oe.ok)throw new Error(Xe.error||"Failed to add brokerage manager");s({title:"Success",description:"Brokerage manager added successfully"}),ie(!1),oe(""),Zs()}catch(Se){console.error("Error adding brokerage manager:",Se),s({title:"Error",description:Se.message||"Failed to add brokerage manager",variant:"destructive"})}finally{_e(!1)}},Qr=async Se=>{try{const{data:{session:Oe}}=await G.auth.getSession(),Xe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Oe==null?void 0:Oe.access_token}`},body:JSON.stringify({userId:Se,role:"brokerage_manager",action:"remove",brokerageId:t})}),_t=await Xe.json();if(!Xe.ok)throw new Error(_t.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),Zs()}catch(Oe){console.error("Error removing brokerage manager:",Oe),s({title:"Error",description:Oe.message||"Failed to remove brokerage manager",variant:"destructive"})}},Gr=Se=>he.includes(Se),tr=Se=>{Ke(Se),Et(""),ht(!0)},cr=async()=>{if(!(!xt||!Ze)){if(Ze.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}Yt(!0);try{const{data:{session:Se}}=await G.auth.getSession(),Oe=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:xt.id,brokerageId:t,action:"set_password",newPassword:Ze})}),Xe=await Oe.json();if(!Oe.ok)throw new Error(Xe.error||"Failed to set password");s({title:"Success",description:`Password set for ${xt.name}`}),ht(!1),Ke(null),Et("")}catch(Se){console.error("Error setting password:",Se),s({title:"Error",description:Se.message||"Failed to set password",variant:"destructive"})}finally{Yt(!1)}}},cn=async Se=>{zs(Se.id);try{const{data:{session:Oe}}=await G.auth.getSession(),Xe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Oe==null?void 0:Oe.access_token}`},body:JSON.stringify({agentId:Se.id,brokerageId:t,action:"claim_account"})}),_t=await Xe.json();if(!Xe.ok)throw new Error(_t.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${Se.name}`}),Dr()}catch(Oe){console.error("Error claiming account:",Oe),s({title:"Error",description:Oe.message||"Failed to claim account",variant:"destructive"})}finally{zs(null)}},rn=async()=>{if($){Y(!0);try{const{data:{session:Se}}=await G.auth.getSession(),Oe=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})}),Xe=await Oe.json();if(!Oe.ok)throw new Error(Xe.error||"Failed to remove agent");s({title:"Success",description:`${$.name} has been removed from your brokerage`}),q(!1),U(null),Dr()}catch(Se){console.error("Error removing agent:",Se),s({title:"Error",description:Se.message||"Failed to remove agent",variant:"destructive"})}finally{Y(!1)}}},jn=Se=>{const Oe=Se.trim().split(" ");return Oe.length>1?Oe[Oe.length-1].toLowerCase():Se.toLowerCase()},ni=Se=>{Ve===Se?Ae(at==="asc"?"desc":"asc"):(Je(Se),Ae("asc"))},rs=Se=>Ve!==Se?e.jsx(td,{className:"ml-1 h-4 w-4"}):at==="asc"?e.jsx(du,{className:"ml-1 h-4 w-4"}):e.jsx(Ph,{className:"ml-1 h-4 w-4"}),Bn=n.filter(Se=>{if(u==="active"&&!Se.claimed||u==="pending"&&Se.claimed)return!1;if(!i)return!0;const Oe=i.toLowerCase();return Se.name.toLowerCase().includes(Oe)||Se.email.toLowerCase().includes(Oe)}),mn=[...Bn].sort((Se,Oe)=>{if(!Ve)return 0;let Xe=0;return Ve==="name"?Xe=jn(Se.name).localeCompare(jn(Oe.name)):Ve==="status"&&(Xe=Se.claimed===Oe.claimed?0:Se.claimed?-1:1),at==="asc"?Xe:-Xe});Bn.filter(Se=>Se.claimed&&!Gr(Se.id));const Fr=Se=>{y(Oe=>{const Xe=new Set(Oe);return Xe.has(Se)?Xe.delete(Se):Xe.add(Se),Xe})},Kt=()=>{x.size===mn.length?y(new Set):y(new Set(mn.map(Se=>Se.id)))},jr=()=>{y(new Set)},zr=async()=>{const Se=Array.from(x);if(Se.length===0)return;b(!0);let Oe=0,Xe=0;try{const{data:{session:_t}}=await G.auth.getSession();for(const bt of Se)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_t==null?void 0:_t.access_token}`},body:JSON.stringify({userId:bt})})).ok?Oe++:Xe++}catch{Xe++}Oe>0?s({title:"Success",description:`Welcome emails sent to ${Oe} agent${Oe>1?"s":""}${Xe>0?` (${Xe} failed)`:""}`}):s({title:"Error",description:"Failed to send welcome emails",variant:"destructive"}),jr()}catch(_t){console.error("Error bulk sending welcome emails:",_t),s({title:"Error",description:_t.message||"Failed to send welcome emails",variant:"destructive"})}finally{b(!1)}};return o?e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Agents"}),e.jsx(hr,{children:"Manage your brokerage's agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>ie(!0),children:[e.jsx(Ou,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(K,{variant:"outline",onClick:()=>X(!0),children:[e.jsx(Kv,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(K,{onClick:()=>C(!0),children:[e.jsx(al,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),e.jsxs(Re,{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(an,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search agents...",value:i,onChange:Se=>d(Se.target.value),className:"pl-9"})]}),e.jsxs(Bs,{value:u,onValueChange:Se=>p(Se),children:[e.jsx(Rs,{className:"w-[160px]",children:e.jsx(qs,{placeholder:"Filter by status"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Agents"}),e.jsx(vt,{value:"active",children:"Active"}),e.jsx(vt,{value:"pending",children:"Pending"})]})]})]}),x.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:[x.size," agent",x.size>1?"s":""," selected"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{const Oe=n.filter(Xe=>x.has(Xe.id)&&Xe.email).map(Xe=>({email:Xe.email,name:Xe.name}));sessionStorage.setItem("campaign_direct_recipients",JSON.stringify(Oe)),r("/admin/email-campaigns/new?directMode=1",{state:{directRecipients:Oe}})},disabled:_,children:[e.jsx(dh,{className:"mr-2 h-4 w-4"}),"Email Agents (",x.size,")"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:zr,disabled:_,children:[e.jsx(rr,{className:"mr-2 h-4 w-4"}),_?"Sending...":"Resend Welcome Email"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:jr,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Nt,{className:"w-[40px]",children:e.jsx(Ki,{checked:mn.length>0&&x.size===mn.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:()=>ni("name"),children:["Name (Last)",rs("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:()=>ni("status"),children:["Status",rs("status")]})}),e.jsx(Nt,{children:"Actions"})]})}),e.jsx(Dn,{children:mn.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):mn.map(Se=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsx(Ki,{checked:x.has(Se.id),onCheckedChange:()=>Fr(Se.id),"aria-label":`Select ${Se.name}`})}),e.jsx(ut,{className:"font-medium",children:Se.name}),e.jsx(ut,{children:Se.email}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Se.claimed?e.jsx(Qe,{variant:"default",children:"Active"}):e.jsx(Qe,{variant:"secondary",children:"Pending"}),Gr(Se.id)&&e.jsxs(Qe,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(hS,{className:"mr-1 h-3 w-3"}),"Manager"]}),N[Se.id]&&e.jsxs(Qe,{variant:"outline",className:"text-xs",children:[e.jsx(lr,{className:"mr-1 h-3 w-3"}),"Asst: ",N[Se.id].name||N[Se.id].email]})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{Ge(Se),We(!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:()=>ir(Se),title:"Edit agent",children:e.jsx(ga,{className:"h-4 w-4"})}),!Se.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>$s(Se.id),title:"Resend welcome email",children:e.jsx(rr,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>cn(Se),title:"Claim account for agent",disabled:Ps===Se.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(Tb,{className:"h-4 w-4"})})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>tr(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:()=>kr(Se.email,Se.name),title:"Send password reset email",children:e.jsx(eS,{className:"h-4 w-4"})}),Gr(Se.id)&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Qr(Se.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(Ou,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Xs(Se),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(gr,{className:"h-4 w-4"})})]})})]},Se.id))})]})})]})]}),e.jsx(fs,{open:k,onOpenChange:C,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Add New Agent"}),e.jsx(Ir,{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(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",value:I.name,onChange:Se=>O({...I,name:Se.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"email",children:"Email"}),e.jsx(De,{id:"email",type:"email",value:I.email,onChange:Se=>O({...I,email:Se.target.value}),placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(De,{id:"phone",type:"tel",value:I.phone,onChange:Se=>O({...I,phone:Se.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"password",children:"Temporary Password"}),e.jsx(De,{id:"password",type:"password",value:I.password,onChange:Se=>O({...I,password:Se.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(K,{onClick:zt,disabled:E,children:E?"Creating...":"Create Agent"})]})]})}),e.jsx(fs,{open:V,onOpenChange:q,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Remove Agent"}),e.jsxs(Ir,{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(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:rn,disabled:se,children:se?"Removing...":"Remove Agent"})]})]})}),e.jsx(rtt,{open:J,onOpenChange:X,fixedBrokerageId:t,onSuccess:Dr}),e.jsx(fs,{open:ce,onOpenChange:ie,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Add Brokerage Manager"}),e.jsx(Ir,{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(xe,{children:"Select Agent"}),e.jsxs(xo,{open:je,onOpenChange:Ue,children:[e.jsx(go,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":je,className:"w-full justify-between",children:[ae?((fa=n.find(Se=>Se.id===ae))==null?void 0:fa.name)+" ("+((qt=n.find(Se=>Se.id===ae))==null?void 0:qt.email)+")":"Select an agent to promote...",e.jsx(gx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(lo,{className:"w-full p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search by name or email..."}),e.jsxs(Mx,{className:"max-h-[200px]",children:[e.jsx(Tx,{children:"No eligible agents found."}),e.jsx(Ax,{children:n.filter(Se=>!Gr(Se.id)).map(Se=>e.jsxs(lp,{value:`${Se.name} ${Se.email}`,onSelect:()=>{oe(Se.id),Ue(!1)},children:[e.jsx(Jn,{className:`mr-2 h-4 w-4 ${ae===Se.id?"opacity-100":"opacity-0"}`}),Se.name," (",Se.email,")"]},Se.id))})]})]})})]}),n.filter(Se=>!Gr(Se.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>ie(!1),children:"Cancel"}),e.jsx(K,{onClick:Vn,disabled:pe||!ae,children:pe?"Adding...":"Add as Manager"})]})]})}),e.jsx(fs,{open:Te,onOpenChange:Me,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Edit Agent"}),e.jsxs(Ir,{children:["Update profile information for ",Fe==null?void 0:Fe.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"edit-name",children:"Name"}),e.jsx(De,{id:"edit-name",value:Ne.name,onChange:Se=>qe({...Ne,name:Se.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"edit-email",children:"Email"}),e.jsx(De,{id:"edit-email",type:"email",value:Ne.email,onChange:Se=>qe({...Ne,email:Se.target.value}),placeholder:"agent@example.com"}),Ne.email.trim().toLowerCase()!==(Fe==null?void 0:Fe.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(xe,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(De,{id:"edit-phone",type:"tel",value:Ne.phone,onChange:Se=>qe({...Ne,phone:Se.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>Me(!1),children:"Cancel"}),e.jsx(K,{onClick:Or,disabled:ze||dt,children:dt?"Updating email...":ze?"Saving...":"Save Changes"})]})]})}),ot&&e.jsx(ntt,{open:Ye,onOpenChange:Se=>{We(Se),Se||Ge(null)},userId:ot.id,userName:ot.name}),e.jsx(fs,{open:et,onOpenChange:ht,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Set Password"}),e.jsxs(Ir,{children:["Set a new password for ",xt==null?void 0:xt.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(xe,{htmlFor:"new-password",children:"New Password"}),e.jsx(De,{id:"new-password",type:"password",value:Ze,onChange:Se=>Et(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(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>ht(!1),children:"Cancel"}),e.jsx(K,{onClick:cr,disabled:$t||!Ze||Ze.length<6,children:$t?"Setting...":"Set Password"})]})]})})]})},$vs={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},qvs={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},Uvs=t=>{switch(t){case"academy_video":return e.jsx(Tn,{className:"h-4 w-4"});case"template":return e.jsx(fn,{className:"h-4 w-4"});case"toolbox":return e.jsx(fn,{className:"h-4 w-4"});case"newsletter":return e.jsx(Qv,{className:"h-4 w-4"});case"social_swag":return e.jsx($r,{className:"h-4 w-4"});case"event":return e.jsx(on,{className:"h-4 w-4"});default:return e.jsx(Kr,{className:"h-4 w-4"})}},Vvs=({brokerageId:t})=>{const{toast:s}=wa(),[r,n]=S.useState([]),[a,o]=S.useState([]),[l,i]=S.useState([]),[d,u]=S.useState(!0),[p,x]=S.useState(null);S.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 k=N.map(se=>se.id),C=new Map(N.map(se=>[se.id,se]));if(k.length===0){n([]),o([]),i([]);return}const{data:E,error:L}=await G.from("activity_logs").select("*").in("user_id",k).order("launched_at",{ascending:!1});if(L)throw L;const I=E.map(se=>{var Y,J;return{id:se.id,user_id:se.user_id,app_name:se.app_name,launched_at:se.launched_at,user_name:((Y=C.get(se.user_id))==null?void 0:Y.name)||"Unknown",user_email:((J=C.get(se.user_id))==null?void 0:J.email)||"Unknown"}});n(I);const{data:O,error:V}=await G.from("content_engagement_logs").select("*").in("user_id",k).order("created_at",{ascending:!1});if(V)throw V;const q=(O||[]).map(se=>{var Y,J;return{id:se.id,user_id:se.user_id,resource_type:se.resource_type,resource_id:se.resource_id,resource_title:se.resource_title,action_type:se.action_type,created_at:se.created_at,user_name:((Y=C.get(se.user_id))==null?void 0:Y.name)||"Unknown",user_email:((J=C.get(se.user_id))==null?void 0:J.email)||"Unknown"}});o(q);const $=new Map;N.forEach(se=>{$.set(se.id,{user_id:se.id,user_name:se.name,user_email:se.email,app_launches:0,content_views:0,last_activity:""})}),I.forEach(se=>{const Y=$.get(se.user_id);Y&&(Y.app_launches++,(!Y.last_activity||new Date(se.launched_at)>new Date(Y.last_activity))&&(Y.last_activity=se.launched_at))}),q.forEach(se=>{const Y=$.get(se.user_id);Y&&(Y.content_views++,(!Y.last_activity||new Date(se.created_at)>new Date(Y.last_activity))&&(Y.last_activity=se.created_at))});const U=Array.from($.values()).filter(se=>se.app_launches>0||se.content_views>0).sort((se,Y)=>new Date(Y.last_activity).getTime()-new Date(se.last_activity).getTime());i(U)}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(Pe,{children:e.jsx(Re,{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(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"Agent Activity"}),e.jsx(hr,{children:"Track app usage and content engagement - click an agent for details"})]}),e.jsx(Re,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:l.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(N=>e.jsxs(Ms,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>x({id:N.user_id,name:N.user_name,email:N.user_email}),children:[e.jsx(ut,{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(ut,{className:"text-center",children:e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(So,{className:"h-3 w-3"}),N.app_launches]})}),e.jsx(ut,{className:"text-center",children:e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(fn,{className:"h-3 w-3"}),N.content_views]})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:N.last_activity&&gl(new Date(N.last_activity),{addSuffix:!0})})]},N.user_id))})]})})})]}),e.jsx(fs,{open:!!p,onOpenChange:N=>!N&&x(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(Ir,{children:p==null?void 0:p.email})]}),e.jsxs(ia,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(ea,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Nt,{children:"Resource"}),e.jsx(Nt,{children:"Type"}),e.jsx(Nt,{children:"Action"}),e.jsx(Nt,{children:"Time"})]})}),e.jsx(Dn,{children:p&&b(p.id).length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):p&&b(p.id).map(N=>e.jsxs(Ms,{children:[e.jsx(ut,{className:"max-w-[200px] truncate font-medium",children:N.resource_title}),e.jsx(ut,{children:e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[Uvs(N.resource_type),$vs[N.resource_type]||N.resource_type]})}),e.jsx(ut,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:qvs[N.action_type]||N.action_type})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:gl(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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Nt,{children:"App"}),e.jsx(Nt,{children:"Time"})]})}),e.jsx(Dn,{children:p&&_(p.id).length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):p&&_(p.id).map(N=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsx(Qe,{variant:"outline",children:N.app_name})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:gl(new Date(N.launched_at),{addSuffix:!0})})]},N.id))})]})})})]})]})})]})},Hvs=({brokerageId:t})=>{const{toast:s}=wa(),[r,n]=S.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=S.useState(!0);S.useEffect(()=>{l()},[t]);const l=async()=>{try{o(!0);const{data:i,error:d}=await G.from("profiles").select("id").eq("brokerage_id",t);if(d)throw d;const u=i.map(I=>I.id),p=u.length;if(u.length===0){o(!1);return}const{data:x,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),k=new Date;k.setDate(k.getDate()-7);const{count:C}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",k.toISOString()),E=new Date;E.setMonth(E.getMonth()-1);const{count:L}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",E.toISOString());n({totalAgents:p,activeAgents:b,pendingAgents:N,totalLaunches:w||0,launchesThisWeek:C||0,launchesThisMonth:L||0})}catch(i){console.error("Error loading analytics:",i),s({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{o(!1)}};return a?e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(lr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(ti,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(ln,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(ih,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"This Week"}),e.jsx(ih,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"This Month"}),e.jsx(ih,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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"})]})]})]})},Gvs=({brokerageId:t})=>{const[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState({description:"",maxUses:""});S.useEffect(()=>{x()},[t]);const x=async()=>{try{const{data:k,error:C}=await G.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(C)throw C;r(k||[])}catch(k){console.error("Error loading invite codes:",k),me.error("Failed to load invite links")}finally{a(!1)}},y=()=>Math.random().toString(36).substring(2,8).toUpperCase(),_=async()=>{l(!0);try{const k=y(),{error:C}=await G.from("invite_codes").insert({code:k,description:u.description||null,max_uses:u.maxUses?parseInt(u.maxUses):null,brokerage_id:t,is_active:!0});if(C)throw C;me.success("Invite link created!"),d(!1),p({description:"",maxUses:""}),x()}catch(k){console.error("Error creating invite code:",k),me.error("Failed to create invite link")}finally{l(!1)}},b=async k=>{try{const{error:C}=await G.from("invite_codes").delete().eq("id",k);if(C)throw C;me.success("Invite link deleted"),r(s.filter(E=>E.id!==k))}catch(C){console.error("Error deleting invite code:",C),me.error("Failed to delete invite link")}},N=async(k,C)=>{try{const{error:E}=await G.from("invite_codes").update({is_active:!C}).eq("id",k);if(E)throw E;r(s.map(L=>L.id===k?{...L,is_active:!C}:L)),me.success(`Invite link ${C?"deactivated":"activated"}`)}catch(E){console.error("Error toggling invite code:",E),me.error("Failed to update invite link")}},w=k=>{const C=`${window.location.origin}/join?code=${k}`;navigator.clipboard.writeText(C),me.success("Link copied to clipboard!")};return n?e.jsx(Pe,{children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsx(_s,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(fo,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(hr,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(fs,{open:i,onOpenChange:d,children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Us,{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(Ir,{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(xe,{htmlFor:"description",children:"Description (optional)"}),e.jsx(De,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:u.description,onChange:k=>p({...u,description:k.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(De,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:u.maxUses,onChange:k=>p({...u,maxUses:k.target.value})})]}),e.jsx(K,{onClick:_,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Invite Link"})]})]})]})]}),e.jsx(Re,{children:s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(fo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No invite links yet"}),e.jsx("p",{className:"text-sm",children:"Create one to start inviting agents"})]}):e.jsx("div",{className:"space-y-3",children:s.map(k=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-sm font-mono bg-muted px-2 py-0.5 rounded",children:k.code}),e.jsx(Qe,{variant:k.is_active?"default":"secondary",children:k.is_active?"Active":"Inactive"})]}),k.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:k.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[k.uses_count," uses",k.max_uses&&` / ${k.max_uses} max`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(k.code),title:"Copy link",children:e.jsx(Ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N(k.id,k.is_active),title:k.is_active?"Deactivate":"Activate",children:k.is_active?"Disable":"Enable"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(k.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(gr,{className:"h-4 w-4"})})]})]},k.id))})})]})},Wvs=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,d]=S.useState(""),[u,p]=S.useState([]),[x,y]=S.useState(""),[_,b]=S.useState(!1),N=L=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(L),w=()=>{const L=i.trim().toLowerCase();if(L&&N(L)&&!u.includes(L)){if(u.length>=10){me.error("Maximum 10 emails per invite");return}p([...u,L]),d("")}else L&&!N(L)?me.error("Please enter a valid email address"):u.includes(L)&&me.error("Email already added")},k=L=>{p(u.filter(I=>I!==L))},C=L=>{(L.key==="Enter"||L.key===",")&&(L.preventDefault(),w())},E=async()=>{if(u.length===0){me.error("Please add at least one email address");return}b(!0);try{const{data:L,error:I}=await G.functions.invoke("send-referral-invite",{body:{emails:u,personalMessage:x.trim()||void 0,referralCode:r,brokerageId:n,senderName:a,brokerageName:o}});if(I)throw I;L.successCount===L.totalCount?me.success(`${L.successCount} invite${L.successCount>1?"s":""} sent successfully!`):me.warning(`${L.successCount} of ${L.totalCount} invites sent. Some failed.`),p([]),y(""),s(!1),l==null||l()}catch(L){console.error("Error sending invites:",L),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(rr,{className:"h-5 w-5 text-primary"}),"Invite Broker Friends"]}),e.jsx(Ir,{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(Ui,{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(xe,{htmlFor:"email",children:"Email Addresses (up to 10)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{id:"email",type:"email",placeholder:"Enter email and press Enter",value:i,onChange:L=>d(L.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(L=>e.jsxs(Qe,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[L,e.jsx("button",{type:"button",onClick:()=>k(L),className:"ml-1 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Sr,{className:"h-3 w-3"})})]},L))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"message",children:"Personal Message (optional)"}),e.jsx(vr,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:x,onChange:L=>y(L.target.value),rows:3,maxLength:500}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[x.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($r,{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:E,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(An,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},Kvs=({brokerageId:t,refreshTrigger:s})=>{const[r,n]=S.useState([]),[a,o]=S.useState(!0);S.useEffect(()=>{l()},[t,s]);const l=async()=>{try{const{data:d,error:u}=await G.from("referral_invites").select("*").eq("referrer_brokerage_id",t).order("sent_at",{ascending:!1}).limit(20);if(u)throw u;n(d||[])}catch(d){console.error("Error fetching invites:",d)}finally{o(!1)}},i=d=>{switch(d){case"signed_up":return e.jsxs(Qe,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(ti,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(Qe,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(Zl,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(ln,{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(rr,{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 ",ps(new Date(d.sent_at),"MMM d, yyyy")]})]}),i(d.status)]},d.id))]})},Zvs=()=>{const{brokerageId:t,user:s}=Fs(),[r,n]=S.useState(null),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState([]),[p,x]=S.useState(!0),[y,_]=S.useState(!1),[b,N]=S.useState(0);S.useEffect(()=>{t&&w()},[t]);const w=async()=>{try{const[O,V]=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),V.data&&i(V.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 U=`REF${t==null?void 0:t.slice(0,8).toUpperCase()}`;await G.from("referral_codes").insert({brokerage_id:t,code:U}),n(U)}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{x(!1)}},k=()=>{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,E=d.filter(O=>O.status==="pending").length,L=C*25,I=Math.max(0,Math.ceil((299-L)/25));return p?null:e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{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(Ui,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold",children:"Referral Rewards Program"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Earn $25/month off your membership for every broker you refer"})]})]}),e.jsx("div",{className:"mt-4 bg-background/80 rounded-lg p-4 border",children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-3xl font-bold text-primary",children:["$",L]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Savings"})]}),L>0&&e.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[e.jsx(ti,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Active"})]})]}),I>0&&L<299&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Refer ",I," more = ",e.jsx("span",{className:"text-primary",children:"FREE membership!"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your membership could cost $0/month"})]}),L>=299&&e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx($r,{className:"h-5 w-5"}),e.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),e.jsxs(Re,{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(rr,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(K,{onClick:k,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(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(yc,{className:"h-5 w-5 mx-auto text-green-600 mb-1"}),e.jsxs("p",{className:"text-2xl font-bold text-green-700 dark:text-green-400",children:["$",L]}),e.jsx("p",{className:"text-xs text-green-600 dark:text-green-500",children:"Monthly Savings"})]}),e.jsxs("div",{className:"text-center p-4 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(lr,{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(ln,{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:E}),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(Kvs,{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 V,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:((V=O.referred_brokerage)==null?void 0:V.name)||((q=O.referred_user)==null?void 0:q.email)||"Pending setup"}),e.jsxs(Qe,{variant:O.status==="qualified"?"default":O.status==="pending"?"secondary":"destructive",className:O.status==="qualified"?"bg-green-600":"",children:[O.status==="qualified"&&e.jsx(ti,{className:"h-3 w-3 mr-1"}),O.status]})]},O.id)})]})]})]}),e.jsx(Wvs,{open:y,onOpenChange:_,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>N(O=>O+1)})]})},Yvs=({brokerageId:t})=>{const s=_r(),{teams:r,isLoading:n}=NC(t),{data:a,isLoading:o}=gt({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:x}=await G.from("team_members").select("team_id, user_id, role").in("team_id",p);if(!x||x.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=x.map(O=>O.user_id),_=x.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:k}=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),E=new Map;(w||[]).forEach(O=>{E.set(O.owner_user_id,(E.get(O.owner_user_id)||0)+1)});const L=new Map;(k||[]).forEach(O=>{L.set(O.owner_user_id,(L.get(O.owner_user_id)||0)+1)});const I=new Map;return(C||[]).forEach(O=>{I.set(O.owner_user_id,(I.get(O.owner_user_id)||0)+1)}),r.map(O=>{const V=x.filter(X=>X.team_id===O.id),q=V.find(X=>X.role==="team_leader"),$=q?N.get(q.user_id):null,U=V.map(X=>X.user_id),se=U.reduce((X,ce)=>X+(E.get(ce)||0),0),Y=U.reduce((X,ce)=>X+(L.get(ce)||0),0),J=U.reduce((X,ce)=>X+(I.get(ce)||0),0);return{team_id:O.id,team_name:O.name,member_count:V.length,leader_name:($==null?void 0:$.name)||null,leader_avatar:($==null?void 0:$.avatar_url)||null,total_contacts:se,total_deals:Y,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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ns,{className:"h-5 w-32"})}),e.jsx(Re,{children:e.jsx(Ns,{className:"h-24 w-full"})})]},p))});if(r.length===0)return e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(lr,{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,x)=>p+x.member_count,0),d=(a||[]).reduce((p,x)=>p+x.total_contacts,0),u=(a||[]).reduce((p,x)=>p+x.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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(lr,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(lr,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(K4,{className:"h-4 w-4"})," Total Contacts"]}),e.jsx("p",{className:"text-2xl font-bold",children:d.toLocaleString()})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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"})," 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(Pe,{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(Ot,{className:"text-lg",children:p.team_name}),e.jsxs(Qe,{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(Ta,{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(Cm,{className:"h-3 w-3 text-amber-500"}),p.leader_name]})]})]}),e.jsx(Re,{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 →"})})]})},Xvs=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Fs(),i=_r(),{toast:d}=wa(),[u,p]=S.useState(""),[x,y]=S.useState(!0),_=o||(a.length>0?a[0].id:r);S.useEffect(()=>{if(!t||!s&&!n){i("/dashboard");return}!o&&a.length>0&&l(a[0].id),_?b():a.length===0&&!r&&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 x?e.jsx(Es,{title:"Manage Brokerages",description:"Loading brokerage information...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):_?e.jsx(Es,{title:u||"Manage Brokerages",description:"Brokerage Management Dashboard",children:e.jsxs("div",{className:"space-y-6",children:[a.length>1&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Managing:"}),e.jsxs(Bs,{value:o||"",onValueChange:l,children:[e.jsxs(Rs,{className:"w-[280px]",children:[e.jsx(pa,{className:"mr-2 h-4 w-4"}),e.jsx(qs,{placeholder:"Select brokerage"})]}),e.jsx(Os,{children:a.map(N=>e.jsx(vt,{value:N.id,children:N.name},N.id))})]})]}),e.jsxs(ia,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(ea,{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(Bvs,{brokerageId:_})}),e.jsx(js,{value:"teams",className:"space-y-4",children:e.jsx(Yvs,{brokerageId:_})}),e.jsx(js,{value:"invite",className:"space-y-4",children:e.jsx(Gvs,{brokerageId:_})}),e.jsx(js,{value:"referrals",className:"space-y-4",children:e.jsx(Zvs,{})}),e.jsx(js,{value:"leaderboard",className:"space-y-4",children:e.jsx(bet,{brokerageId:_,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx(js,{value:"activity",className:"space-y-4",children:e.jsx(Vvs,{brokerageId:_})}),e.jsx(js,{value:"analytics",className:"space-y-4",children:e.jsx(Hvs,{brokerageId:_})}),e.jsx(js,{value:"shares",className:"space-y-4",children:e.jsx(Itt,{brokerageOnly:!0,brokerageId:_})})]})]})}):e.jsx(Es,{title:"Manage Brokerages",description:"Brokerage Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pa,{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 Qvs({brokerageId:t,canManage:s}){const{user:r}=Fs(),[n,a]=S.useState([]),[o,l]=S.useState(!0),[i,d]=S.useState(!1),[u,p]=S.useState(null),[x,y]=S.useState(null),[_,b]=S.useState(!1),[N,w]=S.useState(""),[k,C]=S.useState(""),[E,L]=S.useState(!1),I=async()=>{try{const{data:U,error:se}=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(se)throw se;const Y=U;if(Y&&Y.length>0){const J=[...new Set(Y.map(ae=>ae.created_by))],{data:X}=await G.from("profiles").select("id, name, avatar_url").in("id",J),ce=new Map((X==null?void 0:X.map(ae=>[ae.id,ae]))||[]),ie=Y.map(ae=>({...ae,author:ce.get(ae.created_by)||{name:"Unknown",avatar_url:null}}));a(ie)}else a([])}catch(U){console.error("Error fetching announcements:",U)}finally{l(!1)}};S.useEffect(()=>{I()},[t]);const O=()=>{w(""),C(""),L(!1),p(null)},V=U=>{U?(p(U),w(U.title),C(U.content),L(U.is_pinned)):O(),d(!0)},q=async()=>{if(!N.trim()||!k.trim()){me.error("Please fill in all fields");return}b(!0);try{if(u){const{error:U}=await G.from("brokerage_announcements").update({title:N.trim(),content:k.trim(),is_pinned:E,pinned_at:E?new Date().toISOString():null}).eq("id",u.id);if(U)throw U;me.success("Announcement updated")}else{const{error:U}=await G.from("brokerage_announcements").insert({brokerage_id:t,created_by:r==null?void 0:r.id,title:N.trim(),content:k.trim(),is_pinned:E,pinned_at:E?new Date().toISOString():null});if(U)throw U;me.success("Announcement created")}d(!1),O(),I()}catch(U){console.error("Error saving announcement:",U),me.error("Failed to save announcement")}finally{b(!1)}},$=async()=>{if(x)try{const{error:U}=await G.from("brokerage_announcements").delete().eq("id",x);if(U)throw U;me.success("Announcement deleted"),I()}catch(U){console.error("Error deleting announcement:",U),me.error("Failed to delete announcement")}finally{y(null)}};return o?e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(dh,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(dh,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(K,{size:"sm",onClick:()=>V(),className:"gap-1",children:[e.jsx(Us,{className:"h-4 w-4"}),"New"]})]}),e.jsx(Re,{children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No announcements yet"}):e.jsx("div",{className:"space-y-4",children:n.map(U=>{var se,Y,J,X;return e.jsx("div",{className:`p-4 rounded-lg border ${U.is_pinned?"bg-primary/5 border-primary/20":"bg-muted/30"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[U.is_pinned&&e.jsx(Cb,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold truncate",children:U.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:U.content}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-muted-foreground",children:[e.jsxs(vn,{className:"h-5 w-5",children:[e.jsx(Ta,{src:((se=U.author)==null?void 0:se.avatar_url)||void 0}),e.jsx(_n,{className:"text-[10px]",children:((J=(Y=U.author)==null?void 0:Y.name)==null?void 0:J.charAt(0))||"?"})]}),e.jsx("span",{children:(X=U.author)==null?void 0:X.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:ps(new Date(U.created_at),"MMM d, yyyy")})]})]}),s&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>V(U),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>y(U.id),children:e.jsx(gr,{className:"h-4 w-4"})})]})]})},U.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(xe,{htmlFor:"title",children:"Title"}),e.jsx(De,{id:"title",value:N,onChange:U=>w(U.target.value),placeholder:"Announcement title..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"content",children:"Content"}),e.jsx(vr,{id:"content",value:k,onChange:U=>C(U.target.value),placeholder:"Write your announcement...",rows:4})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Er,{id:"pinned",checked:E,onCheckedChange:L}),e.jsxs(xe,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[e.jsx(Cb,{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(tc,{open:!!x,onOpenChange:()=>y(null),children:e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Delete Announcement"}),e.jsx(Pl,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:$,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function Jvs({brokerageId:t,canManage:s=!1}){const{startImpersonation:r,isLoading:n}=cue(),{user:a}=Fs(),[o,l]=S.useState([]),[i,d]=S.useState(!0),[u,p]=S.useState(""),[x,y]=S.useState(new Set);S.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 k=N.map(E=>E.id),{data:C}=await G.from("agent_assistant_assignments").select("agent_id").in("agent_id",k);C&&y(new Set(C.map(E=>E.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(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(lr,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search agents...",value:u,onChange:b=>p(b.target.value),className:"pl-9"})]})]}),e.jsx(Re,{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(e1s,{agent:b,hasAssistant:x.has(b.id),canImpersonate:s&&b.id!==(a==null?void 0:a.id),onImpersonate:()=>r(b.id,"/my-brokerage"),impersonationLoading:n},b.id))})})]})}function e1s({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(Ta,{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(Qe,{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(Da,{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(Yl,{children:[e.jsx(Xl,{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(rS,{className:"h-4 w-4"})})}),e.jsxs(Cl,{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(Pn,{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(rr,{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(xp,{className:"h-4 w-4"})})}),t.instagram_url&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:t.instagram_url,target:"_blank",rel:"noopener noreferrer",title:"Instagram",children:e.jsx(mu,{className:"h-4 w-4"})})})]})]})}function t1s({brokerageId:t}){const[s,r]=S.useState([]),[n,a]=S.useState(!0);if(S.useEffect(()=>{(async()=>{try{const{data:d,error:u}=await G.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!d||d.length===0){r([]),a(!1);return}const p=d.map(N=>N.id),{data:x,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=(x||[]).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(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Vi,{className:"h-5 w-5"}),"Team Leaderboard"]})}),e.jsx(Re,{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(Xv,{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(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Vi,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),e.jsx(Re,{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(x=>x[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(Ta,{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 s1s({brokerageId:t}){const s=_r(),[r,n]=S.useState([]),[a,o]=S.useState(!0);S.useEffect(()=>{(async()=>{try{const{data:d,error:u}=await G.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!d||d.length===0){n([]),o(!1);return}const p=d.map(N=>N.id),x=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:x.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(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(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(Us,{className:"h-4 w-4"}),"Add Listing"]})]}),e.jsxs(Re,{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(Us,{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 r1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=Fs(),n=_r(),[a,o]=S.useState(!0),[l,i]=S.useState(null),[d,u]=S.useState(""),[p,x]=S.useState(0),[y,_]=S.useState(!1),[b,N]=S.useState(!1);return S.useEffect(()=>{(async()=>{if(t)try{const{data:k}=await G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(k!=null&&k.brokerage_id)){o(!1);return}i(k.brokerage_id);const{data:C}=await G.from("brokerages").select("name").eq("id",k.brokerage_id).maybeSingle();C&&u(C.name);const{count:E}=await G.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",k.brokerage_id);if(x(E||0),s)_(!0),N(!0);else if(r){const{data:L}=await G.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",k.brokerage_id).maybeSingle();_(!!L),N(!!L)}}catch(k){console.error("Error fetching brokerage info:",k)}finally{o(!1)}})()},[t,s,r]),a?e.jsx(Es,{title:"My Brokerage",description:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):l?e.jsx(Es,{title: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(lr,{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(Qvs,{brokerageId:l,canManage:y}),e.jsx(Jvs,{brokerageId:l,canManage:y}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(t1s,{brokerageId:l}),e.jsx(s1s,{brokerageId:l})]})]})}):e.jsx(Es,{title:"My Brokerage",description:"Team Hub",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pa,{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 n1s(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 a1s(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 j7e={video:{icon:So,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:fn,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:on,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Dl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function i1s({item:t,canManage:s}){const[r,n]=S.useState(!1),[a,o]=S.useState(null),l=vLt(),i=_r(),d=j7e[t.content_type]||j7e.link,u=d.icon,p=S.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?n1s(t.url):null,[t]);S.useEffect(()=>{p||!t.url||t.content_type!=="video"||!a1s(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 x=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(Pe,{className:"group overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30 cursor-pointer",onClick:y,children:[x?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:x,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(Re,{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(Qe,{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(Qe,{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:["📅 ",ps(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",ps(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(ax,{className:"h-4 w-4"})})}),e.jsx(jd,{align:"end",children:e.jsxs(va,{onClick:b=>{b.stopPropagation(),n(!0)},className:"text-destructive",children:[e.jsx(gr,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(tc,{open:r,onOpenChange:n,children:e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Delete Content"}),e.jsxs(Pl,{children:['Are you sure you want to delete "',t.title,'"? This cannot be undone.']})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:_,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function o1s(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 N7e=[{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 l1s({brokerageId:t,categories:s}){var we;const{user:r}=Fs(),[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(""),[u,p]=S.useState("📁"),[x,y]=S.useState(!1);S.useRef(null);const[_,b]=S.useState("video"),[N,w]=S.useState(""),[k,C]=S.useState(""),[E,L]=S.useState(""),[I,O]=S.useState(""),[V,q]=S.useState(""),[$,U]=S.useState(""),[se,Y]=S.useState(""),J=yLt(),X=_Lt(t),ce=bLt(),ie=wLt(t),ae=()=>{b("video"),w(""),C(""),L(""),O(""),q(""),U(""),Y("")},oe=async(je,Ue)=>{var Me;const Te=(Me=je.target.files)==null?void 0:Me[0];if(Te){y(!0);try{const Fe=Te.name.split(".").pop(),Le=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${Fe}`,{error:Ne}=await G.storage.from("brokerage-content").upload(Le,Te);if(Ne)throw Ne;const{data:{publicUrl:qe}}=G.storage.from("brokerage-content").getPublicUrl(Le);Ue==="file"?(O(qe),_==="graphic"&&!V&&q(qe)):q(qe),me.success("File uploaded")}catch(Fe){me.error(Fe.message||"Upload failed")}finally{y(!1)}}},pe=async()=>{if(!N.trim()){me.error("Title is required");return}if(r)try{await J.mutateAsync({brokerage_id:t,category_id:se||null,content_type:_,title:N.trim(),description:k.trim()||null,url:E.trim()||null,file_url:I.trim()||null,thumbnail_url:V.trim()||null,event_date:$?new Date($).toISOString():null,created_by:r.id}),me.success("Content added!"),ae(),a(!1)}catch(je){me.error(je.message||"Failed to add content")}},_e=async()=>{if(i.trim())try{await X.mutateAsync({name:i.trim(),icon:u,sort_order:s.length}),d(""),p("📁"),me.success("Category created")}catch(je){me.error(je.message||"Failed to create category")}},he=async()=>{try{await ie.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(pi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Us,{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(xe,{children:"Content Type"}),e.jsxs(Bs,{value:_,onValueChange:b,children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:N7e.map(je=>e.jsx(vt,{value:je.value,children:je.label},je.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(we=N7e.find(je=>je.value===_))==null?void 0:we.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Category"}),e.jsxs(Bs,{value:se,onValueChange:Y,children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select category (optional)"})}),e.jsx(Os,{children:s.map(je=>e.jsxs(vt,{value:je.id,children:[je.icon," ",je.name]},je.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Title *"}),e.jsx(De,{value:N,onChange:je=>w(je.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Description"}),e.jsx(vr,{value:k,onChange:je=>C(je.target.value),placeholder:"Brief description...",rows:2})]}),["video","link","graphic","event"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:_==="video"?"Video URL":_==="graphic"?"Canva / Image URL":_==="event"?"Event Link (Zoom, etc.)":"URL"}),e.jsx(De,{value:E,onChange:je=>{const Ue=je.target.value;if(L(Ue),_==="video"&&!V){const Te=o1s(Ue);Te&&q(Te)}},placeholder:"https://..."})]}),["pdf","graphic"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:_==="pdf"?"Upload PDF":"Upload Image"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{type:"file",accept:_==="pdf"?".pdf,.doc,.docx":"image/*",onChange:je=>oe(je,"file"),disabled:x}),x&&e.jsx(_s,{className:"h-4 w-4 animate-spin"})]}),I&&e.jsx("p",{className:"text-xs text-green-600",children:"✓ File uploaded"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Thumbnail Image (optional)"}),e.jsx(De,{type:"file",accept:"image/*",onChange:je=>oe(je,"thumbnail"),disabled:x}),V&&e.jsxs("div",{className:"relative w-20 h-20 rounded overflow-hidden",children:[e.jsx("img",{src:V,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(xe,{children:"Event Date & Time"}),e.jsx(De,{type:"datetime-local",value:$,onChange:je=>U(je.target.value)})]}),e.jsxs(K,{onClick:pe,disabled:J.isPending||!N.trim(),className:"w-full",children:[J.isPending?e.jsx(_s,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Content"]})]})]})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",children:[e.jsx(ko,{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:ie.isPending,children:[ie.isPending?e.jsx(_s,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Default Categories"]})]}),s.map(je=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border",children:[e.jsxs("span",{className:"text-sm",children:[je.icon," ",je.name]}),!je.is_default&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:async()=>{await ce.mutateAsync(je.id),me.success("Category deleted")},children:e.jsx(Sr,{className:"h-4 w-4"})})]},je.id)),e.jsxs("div",{className:"flex gap-2 pt-2 border-t",children:[e.jsx(De,{value:u,onChange:je=>p(je.target.value),className:"w-14 text-center",maxLength:2}),e.jsx(De,{value:i,onChange:je=>d(je.target.value),placeholder:"New category name",className:"flex-1",onKeyDown:je=>je.key==="Enter"&&_e()}),e.jsx(K,{size:"sm",onClick:_e,disabled:!i.trim(),children:"Add"})]})]})]})]})]})}function c1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=Fs(),[n,a]=S.useState(!0),[o,l]=S.useState(null),[i,d]=S.useState(""),[u,p]=S.useState(!1),[x,y]=S.useState(null),[_,b]=S.useState("");S.useEffect(()=>{(async()=>{if(t)try{const{data:L}=await G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(L!=null&&L.brokerage_id)){a(!1);return}l(L.brokerage_id);const{data:I}=await G.from("brokerages").select("name").eq("id",L.brokerage_id).maybeSingle();if(I&&d(I.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",L.brokerage_id).maybeSingle();p(!!O)}}catch(L){console.error("Error fetching brokerage info:",L)}finally{a(!1)}})()},[t,s,r]);const{data:N=[]}=fLt(o),{data:w=[],isLoading:k}=xLt(o,x),C=S.useMemo(()=>{if(!_.trim())return w;const E=_.toLowerCase();return w.filter(L=>{var I;return L.title.toLowerCase().includes(E)||((I=L.description)==null?void 0:I.toLowerCase().includes(E))||L.content_type.toLowerCase().includes(E)})},[w,_]);return n?e.jsx(Es,{title:"Brokerage Content",description:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):o?e.jsx(Es,{title:`${i} Content`,description:"Brokerage Content Hub",children:e.jsxs("div",{className:"space-y-6",children:[u&&o&&e.jsx(l1s,{brokerageId:o,categories:N}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search content...",value:_,onChange:E=>b(E.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{variant:x===null?"default":"outline",size:"sm",onClick:()=>y(null),children:"All"}),N.map(E=>e.jsxs(K,{variant:x===E.id?"default":"outline",size:"sm",onClick:()=>y(E.id),children:[e.jsx("span",{className:"mr-1",children:E.icon}),E.name]},E.id))]})]}),k?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):C.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Mm,{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(E=>e.jsx(i1s,{item:E,canManage:u},E.id))})]})}):e.jsx(Es,{title:"Brokerage Content",description:"Content Hub",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pa,{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 k7e={video:{icon:So,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:fn,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:on,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Dl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function d1s(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 u1s(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function h1s(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function m1s(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function p1s(){const{contentId:t}=co(),{data:s,isLoading:r}=gt({queryKey:["brokerage-content-detail",t],queryFn:async()=>{const{data:u,error:p}=await G.from("brokerage_content").select(` *, category:brokerage_content_categories(*) `).eq("id",t).single();if(p)throw p;return u},enabled:!!t});if(r)return e.jsx(Es,{title:"Brokerage Content",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})});if(!s)return e.jsx(Es,{title:"Brokerage Content",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pa,{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(ha,{to:"/brokerage-content",children:"Back to Content"})})]})});const n=k7e[s.content_type]||k7e.link,a=n.icon,o=s.url||s.file_url,l=o&&u1s(o)?d1s(o):null,i=o&&h1s(o)?m1s(o):null,d=l||i;return e.jsx(Es,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(ha,{to:"/brokerage-content",children:[e.jsx(Fa,{className:"h-4 w-4"}),"Back to Content"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Qe,{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(Qe,{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 ",ps(new Date(s.created_at),"MMMM d, yyyy")]})]}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),d&&e.jsx(Pe,{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(Pe,{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(Pe,{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(Pe,{children:e.jsx(Re,{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(Pe,{children:e.jsxs(Re,{className:"pt-6 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(on,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Event Date"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:ps(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 f1s(){const t=_r(),[s,r]=S.useState(""),[n,a]=S.useState("grid"),{data:o,isLoading:l}=gt({queryKey:["newsletters"],queryFn:async()=>{const{data:E,error:L}=await G.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(L)throw L;return E}}),{data:i}=gt({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:E}=await G.from("newsletter_likes").select("newsletter_id");return E||[]}}),{data:d}=gt({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:E}=await G.from("newsletter_comments").select("newsletter_id");return E||[]}}),{data:u}=gt({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[E,L,I,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:E.data||[],pdfs:L.data||[],videos:I.data||[],drives:O.data||[]}}}),p=E=>(i==null?void 0:i.filter(L=>L.newsletter_id===E).length)||0,x=E=>(d==null?void 0:d.filter(L=>L.newsletter_id===E).length)||0,y=E=>{var L;return((L=u==null?void 0:u.canva)==null?void 0:L.filter(I=>I.newsletter_id===E).length)||0},_=E=>{var L;return((L=u==null?void 0:u.pdfs)==null?void 0:L.filter(I=>I.newsletter_id===E).length)||0},b=E=>{var L;return((L=u==null?void 0:u.videos)==null?void 0:L.filter(I=>I.newsletter_id===E).length)||0},N=E=>{var L;return((L=u==null?void 0:u.drives)==null?void 0:L.filter(I=>I.newsletter_id===E).length)||0},w=E=>y(E)+_(E)+b(E)+N(E),k=o==null?void 0:o.filter(E=>{var L;return E.title.toLowerCase().includes(s.toLowerCase())||((L=E.description)==null?void 0:L.toLowerCase().includes(s.toLowerCase()))}),C=E=>{t(`/newsletters/${E}`)};return e.jsx(Es,{title:"Newsletter Content",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-bold text-foreground text-5xl",children:"Newsletter Content"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Monthly newsletter templates and resources"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search newsletters...",value:s,onChange:E=>r(E.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(fp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Dh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[(k==null?void 0:k.length)||0," item",(k==null?void 0:k.length)!==1?"s":""," found"]}),l&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((E,L)=>e.jsx(Pe,{children:e.jsxs(Re,{className:"p-0",children:[e.jsx(Ns,{className:"aspect-[3/2] w-full"}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx(Ns,{className:"h-5 w-3/4"}),e.jsx(Ns,{className:"h-4 w-full"})]})]})},L))}),!l&&(k==null?void 0:k.length)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(fn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No newsletters match your search":"No newsletters available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&k&&k.length>0&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-3",children:k.map(E=>{const L=w(E.id),I=y(E.id),O=_(E.id),V=b(E.id);return n==="grid"?e.jsxs(Pe,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(E.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:E.preview_image_url?e.jsx("img",{src:E.preview_image_url,alt:E.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(fn,{className:"h-16 w-16"})})}),e.jsxs(Re,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:E.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[e.jsx(on,{className:"h-3 w-3"}),ps(new Date(E.publish_date),"MMM d, yyyy")]})]}),E.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:E.description.replace(/<[^>]*>/g,"")}),L>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[I>0&&e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Dl,{className:"h-3 w-3"})," ",I," Template",I>1?"s":""]}),O>0&&e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Xa,{className:"h-3 w-3"})," ",O," PDF",O>1?"s":""]}),V>0&&e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(So,{className:"h-3 w-3"})," ",V," Video",V>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(Fu,{className:"h-3 w-3"})," ",p(E.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vc,{className:"h-3 w-3"})," ",x(E.id)]})]})]})]},E.id):e.jsx(Pe,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(E.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:E.preview_image_url?e.jsx("img",{src:E.preview_image_url,alt:E.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(fn,{className:"h-10 w-10"})})}),e.jsxs(Re,{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:E.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:[e.jsx(on,{className:"h-3 w-3"}),ps(new Date(E.publish_date),"MMM d, yyyy")]})]}),E.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:E.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[L>0&&e.jsxs("span",{children:[L," resource",L>1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fu,{className:"h-3 w-3"})," ",p(E.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vc,{className:"h-3 w-3"})," ",x(E.id)]})]})]})]})},E.id)})})]})})}function x1s({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(Pe,{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(Re,{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 g1s(){const{id:t}=co(),s=_r(),{user:r}=Fs(),{toast:n}=wa(),a=Jt(),{trackEngagement:o}=YA(),[l,i]=S.useState(""),{data:d,isLoading:u}=gt({queryKey:["newsletter",t],queryFn:async()=>{const{data:I,error:O}=await G.from("newsletter_content").select("*").eq("id",t).single();if(O)throw O;return I},enabled:!!t});S.useEffect(()=>{d&&o("newsletter",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p}=gt({queryKey:["newsletter-drives",t],queryFn:async()=>{const{data:I}=await G.from("newsletter_drive_links").select("*").eq("newsletter_id",t).order("sort_order");return I||[]},enabled:!!t}),{data:x}=gt({queryKey:["newsletter-pdfs",t],queryFn:async()=>{const{data:I}=await G.from("newsletter_pdfs").select("*").eq("newsletter_id",t).order("sort_order");return I||[]},enabled:!!t}),{data:y}=gt({queryKey:["newsletter-videos",t],queryFn:async()=>{const{data:I}=await G.from("newsletter_videos").select("*").eq("newsletter_id",t).order("sort_order");return I||[]},enabled:!!t}),{data:_}=gt({queryKey:["newsletter-canva-links",t],queryFn:async()=>{const{data:I}=await G.from("newsletter_canva_links").select("*").eq("newsletter_id",t).order("sort_order");return I||[]},enabled:!!t}),{data:b}=gt({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:I}=await G.from("newsletter_likes").select("*").eq("newsletter_id",t);return I||[]},enabled:!!t}),{data:N}=gt({queryKey:["newsletter-comments",t],queryFn:async()=>{const{data:I}=await G.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",t).order("created_at",{ascending:!1});return I||[]},enabled:!!t}),w=b==null?void 0:b.some(I=>I.user_id===(r==null?void 0:r.id)),k=It({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=It({mutationFn:async I=>{const{error:O}=await G.from("newsletter_comments").insert({newsletter_id:t,user_id:r==null?void 0:r.id,content:I});if(O)throw O},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),i(""),n({title:"Comment added"})}}),E=It({mutationFn:async I=>{const{error:O}=await G.from("newsletter_comments").delete().eq("id",I);if(O)throw O},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),n({title:"Comment deleted"})}}),L=I=>{if(I.includes("player.mediadelivery.net")||I.includes("iframe.mediadelivery.net")){const O=I.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(O)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://iframe.mediadelivery.net/embed/${O[1]}/${O[2]}?autoplay=false`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}if(I.includes("youtube.com")||I.includes("youtu.be")){const O=I.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([^&\s]+)/);if(O)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${O[1]}`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}return e.jsxs("a",{href:I,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(So,{className:"h-4 w-4"})," Watch Video"]})};return u?e.jsx(Es,{title:"",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ns,{className:"h-8 w-32"}),e.jsx(Ns,{className:"h-64 w-full"}),e.jsx(Ns,{className:"h-32 w-full"})]})}):d?e.jsx(Es,{title:"",description:"",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/newsletters"),className:"mb-4",children:[e.jsx(Fa,{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:ps(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(x1s,{rows:d.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(eE,{resourceType:"newsletter",resourceId:d.id,resourceTitle:d.title}),e.jsxs(K,{variant:w?"default":"outline",size:"sm",onClick:()=>k.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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"Canva Templates"})}),e.jsx(Re,{className:"space-y-2",children:_.map(I=>e.jsxs("a",{href:I.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(Dl,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:I.title}),e.jsx(Kr,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},I.id))})]}),p&&p.length>0&&e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"Google Drive Files"})}),e.jsx(Re,{className:"space-y-2",children:p.map(I=>e.jsxs("a",{href:I.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:I.title})]},I.id))})]}),x&&x.length>0&&e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(Re,{className:"space-y-2",children:x.map(I=>e.jsxs("a",{href:I.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(fn,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:I.name}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]}),y&&y.length>0&&e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"Videos"})}),e.jsx(Re,{className:"space-y-6",children:y.map(I=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:I.title}),L(I.video_url)]},I.id))})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"text-lg",children:["Comments (",(N==null?void 0:N.length)||0,")"]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(vr,{placeholder:"Write a comment...",value:l,onChange:I=>i(I.target.value),className:"flex-1"}),e.jsx(K,{onClick:()=>l.trim()&&C.mutate(l),disabled:!l.trim()||C.isPending,children:e.jsx(An,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:N==null?void 0:N.map(I=>{var O,V,q;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(vn,{className:"h-8 w-8",children:e.jsx(_n,{children:((V=(O=I.profiles)==null?void 0:O.name)==null?void 0:V[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=I.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:ps(new Date(I.created_at),"MMM d, yyyy")}),I.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>E.mutate(I.id),children:e.jsx(gr,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:I.content})]})]},I.id)})})]})]})]})}):e.jsx(Es,{title:"Not Found",description:"",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Newsletter not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/newsletters"),children:"Back to Newsletters"})]})})}function y1s({rows:t,onChange:s}){const[r,n]=S.useState(null),a=()=>{s([...t,{columns:[{title:"",description:""},{title:"",description:""},{title:"",description:""}]}])},o=u=>{s(t.filter((p,x)=>x!==u))},l=(u,p,x,y)=>{const _=[...t];_[u]={..._[u],columns:_[u].columns.map((b,N)=>N===p?{...b,[x]:y}:b)},s(_)},i=async(u,p,x)=>{var b;const y=(b=x.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:k}=G.storage.from("newsletter-content").getPublicUrl(N);l(u,p,"image_url",k.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(xe,{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(Us,{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(Pe,{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(Re,{className:"p-4 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(hu,{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((x,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]}),x.image_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:x.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(De,{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(Wo,{className:"h-3 w-3 mr-1"})," Image"]})})})]}),e.jsx(De,{placeholder:"Title",value:x.title,onChange:b=>l(p,y,"title",b.target.value),className:"h-8 text-sm"}),e.jsx(vr,{placeholder:"Description",value:x.description,onChange:b=>l(p,y,"description",b.target.value),className:"text-sm min-h-[60px] resize-none"})]},y)})})]})]},p))]})}function v1s(){const{toast:t}=wa(),s=Jt(),[r,n]=S.useState(!1),[a,o]=S.useState(null),[l,i]=S.useState({title:"",description:"",publish_date:ps(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[d,u]=S.useState(null),[p,x]=S.useState(null),[y,_]=S.useState([]),[b,N]=S.useState([]),[w,k]=S.useState([]),[C,E]=S.useState([]),[L,I]=S.useState([]),[O,V]=S.useState([]),[q,$]=S.useState(!1),{data:U,isLoading:se}=gt({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:Te,error:Me}=await G.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Me)throw Me;return Te}}),Y=It({mutationFn:async Te=>{const{data:Me,error:Fe}=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(Fe)throw Fe;return Me},onSuccess:async Te=>{await ce(Te.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),Te.is_published&&dVt(Te.title,Te.id),oe()},onError:Te=>{t({title:"Error creating newsletter",description:Te.message,variant:"destructive"})}}),J=It({mutationFn:async Te=>{const{error:Me}=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(Me)throw Me;return Te.id},onSuccess:async Te=>{await ce(Te),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),oe()},onError:Te=>{t({title:"Error updating newsletter",description:Te.message,variant:"destructive"})}}),X=It({mutationFn:async Te=>{const{error:Me}=await G.from("newsletter_content").delete().eq("id",Te);if(Me)throw Me},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 Me of O){const Fe=`${Te}/${Date.now()}-${Me.file.name}`,{error:Le}=await G.storage.from("newsletter-content").upload(Fe,Me.file);if(!Le){const{data:Ne}=G.storage.from("newsletter-content").getPublicUrl(Fe);b.push({name:Me.name,file_url:Ne.publicUrl,file_size:Me.file.size,sort_order:b.length})}}y.length>0&&await G.from("newsletter_drive_links").insert(y.map((Me,Fe)=>({newsletter_id:Te,title:Me.title,drive_url:Me.drive_url,sort_order:Fe}))),b.length>0&&await G.from("newsletter_pdfs").insert(b.map((Me,Fe)=>({newsletter_id:Te,name:Me.name,file_url:Me.file_url,file_size:Me.file_size||null,sort_order:Fe}))),w.length>0&&await G.from("newsletter_videos").insert(w.map((Me,Fe)=>({newsletter_id:Te,title:Me.title,video_url:Me.video_url,sort_order:Fe}))),C.length>0&&await G.from("newsletter_canva_links").insert(C.map((Me,Fe)=>({newsletter_id:Te,title:Me.title,canva_share_link:Me.canva_share_link,sort_order:Fe})))},ie=async Te=>{o(Te),i({title:Te.title,description:Te.description||"",publish_date:ps(new Date(Te.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:Te.is_published}),x(Te.preview_image_url),I(Te.content_blocks||[]);const[Me,Fe,Le,Ne]=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")]);_(Me.data||[]),N(Fe.data||[]),k(Le.data||[]),E(Ne.data||[]),V([]),n(!0)},ae=async Te=>{const[Me,Fe,Le,Ne]=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:ps(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),x(Te.preview_image_url),I(Te.content_blocks||[]),_((Me.data||[]).map(({id:qe,...ze})=>ze)),N((Fe.data||[]).map(({id:qe,...ze})=>ze)),k((Le.data||[]).map(({id:qe,...ze})=>ze)),E((Ne.data||[]).map(({id:qe,...ze})=>ze)),V([]),n(!0)},oe=()=>{n(!1),o(null),i({title:"",description:"",publish_date:ps(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),x(null),_([]),N([]),k([]),E([]),I([]),V([])},pe=async Te=>{var Fe;const Me=(Fe=Te.target.files)==null?void 0:Fe[0];Me&&(u(Me),x(URL.createObjectURL(Me)))},_e=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}$(!0);let Te=p;if(d){const Me=`previews/${Date.now()}-${d.name}`,{error:Fe}=await G.storage.from("newsletter-content").upload(Me,d);if(!Fe){const{data:Le}=G.storage.from("newsletter-content").getPublicUrl(Me);Te=Le.publicUrl}}a?J.mutate({id:a.id,...l,preview_image_url:Te,content_blocks:L}):Y.mutate({...l,preview_image_url:Te,content_blocks:L}),$(!1)},he=()=>_([...y,{title:"",drive_url:"",sort_order:y.length}]),we=()=>k([...w,{title:"",video_url:"",sort_order:w.length}]),je=()=>E([...C,{title:"",canva_share_link:"",sort_order:C.length}]),Ue=Te=>{const Me=Te.target.files;if(!Me)return;const Fe=Array.from(Me).map(Le=>({file:Le,name:Le.name.replace(/\.[^/.]+$/,"")}));V([...O,...Fe])};return e.jsx(Es,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{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(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(U==null?void 0:U.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(U==null?void 0:U.filter(Te=>Te.is_published).length)||0})})]})]}),e.jsxs(fs,{open:r,onOpenChange:Te=>!Te&&oe(),children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Us,{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(xe,{children:"Title *"}),e.jsx(De,{value:l.title,onChange:Te=>i({...l,title:Te.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Publish Date"}),e.jsx(De,{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(xe,{children:"Description"}),e.jsx(Gg,{content:l.description,onChange:Te=>i({...l,description:Te}),placeholder:"Newsletter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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),x(null)},children:e.jsx(Sr,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(De,{type:"file",accept:"image/*",onChange:pe,className:"hidden",id:"preview-upload"}),e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("label",{htmlFor:"preview-upload",className:"cursor-pointer",children:[e.jsx($a,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Er,{checked:l.is_published,onCheckedChange:Te=>i({...l,is_published:Te})}),e.jsx(xe,{children:"Published"})]}),e.jsx(y1s,{rows:L,onChange:I}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-base font-medium",children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:je,children:[e.jsx(Us,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),C.map((Te,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(De,{placeholder:"Link title",value:Te.title,onChange:Fe=>{const Le=[...C];Le[Me].title=Fe.target.value,E(Le)},className:"w-1/3"}),e.jsx(De,{placeholder:"Canva share link",value:Te.canva_share_link,onChange:Fe=>{const Le=[...C];Le[Me].canva_share_link=Fe.target.value,E(Le)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>E(C.filter((Fe,Le)=>Le!==Me)),children:e.jsx(Sr,{className:"h-4 w-4"})})]},Me))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-base font-medium",children:"Google Drive Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:he,children:[e.jsx(Us,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),y.map((Te,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(De,{placeholder:"Link title",value:Te.title,onChange:Fe=>{const Le=[...y];Le[Me].title=Fe.target.value,_(Le)},className:"w-1/3"}),e.jsx(De,{placeholder:"Google Drive URL",value:Te.drive_url,onChange:Fe=>{const Le=[...y];Le[Me].drive_url=Fe.target.value,_(Le)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>_(y.filter((Fe,Le)=>Le!==Me)),children:e.jsx(Sr,{className:"h-4 w-4"})})]},Me))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-base font-medium",children:"PDF Files"}),e.jsxs("div",{children:[e.jsx(De,{type:"file",accept:".pdf",multiple:!0,onChange:Ue,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($a,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),b.map((Te,Me)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(fn,{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((Fe,Le)=>Le!==Me)),children:e.jsx(Sr,{className:"h-4 w-4"})})]},`existing-${Me}`)),O.map((Te,Me)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(fn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(De,{value:Te.name,onChange:Fe=>{const Le=[...O];Le[Me].name=Fe.target.value,V(Le)},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:()=>V(O.filter((Fe,Le)=>Le!==Me)),children:e.jsx(Sr,{className:"h-4 w-4"})})]},`pending-${Me}`))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-base font-medium",children:"Video Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:we,children:[e.jsx(Us,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),w.map((Te,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(De,{placeholder:"Video title",value:Te.title,onChange:Fe=>{const Le=[...w];Le[Me].title=Fe.target.value,k(Le)},className:"w-1/3"}),e.jsx(De,{placeholder:"Video URL",value:Te.video_url,onChange:Fe=>{const Le=[...w];Le[Me].video_url=Fe.target.value,k(Le)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>k(w.filter((Fe,Le)=>Le!==Me)),children:e.jsx(Sr,{className:"h-4 w-4"})})]},Me))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:oe,children:"Cancel"}),e.jsx(K,{onClick:_e,disabled:q||Y.isPending||J.isPending,children:q?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:se?e.jsx(Ms,{children:e.jsx(ut,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(U==null?void 0:U.length)===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No newsletters yet. Create your first one!"})}):U==null?void 0:U.map(Te=>e.jsxs(Ms,{children:[e.jsx(ut,{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(fn,{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(ut,{children:ps(new Date(Te.publish_date),"MMM d, yyyy")}),e.jsx(ut,{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(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ie(Te),title:"Edit",children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ae(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?")&&X.mutate(Te.id)},children:e.jsx(gr,{className:"h-4 w-4"})})]})})]},Te.id))})]})})})]})})}const S7e={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 _1s(){const{user:t}=Fs(),{toast:s}=wa(),r=_r(),n=Jt(),[a,o]=S.useState(""),[l,i]=S.useState("popular"),[d,u]=S.useState(!1),[p,x]=S.useState(""),[y,_]=S.useState(""),[b,N]=S.useState(!1),{data:w=[],isLoading:k}=gt({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:V,error:q}=await O;if(q)throw q;const $=[...new Set((V==null?void 0:V.map(ie=>ie.user_id))||[])],{data:U}=await G.from("profiles").select("id, name").in("id",$),se=new Map((U==null?void 0:U.map(ie=>[ie.id,ie]))||[]);let Y=[];if(t){const{data:ie}=await G.from("wishlist_votes").select("item_id").eq("user_id",t.id);Y=(ie==null?void 0:ie.map(ae=>ae.item_id))||[]}const J=(V==null?void 0:V.map(ie=>ie.id))||[],{data:X}=await G.from("wishlist_comments").select("item_id").in("item_id",J),ce=new Map;return X==null||X.forEach(ie=>{ce.set(ie.item_id,(ce.get(ie.item_id)||0)+1)}),V==null?void 0:V.map(ie=>{const ae=se.get(ie.user_id),oe=(ae==null?void 0:ae.name)||"Unknown";return{...ie,user_name:oe,user_initials:oe.split(" ").map(pe=>pe[0]).join("").toUpperCase().slice(0,2),has_voted:Y.includes(ie.id),comment_count:ce.get(ie.id)||0}})}}),C=It({mutationFn:async({title:O,description:V})=>{const{error:q}=await G.from("wishlist_items").insert({user_id:t.id,title:O,description:V});if(q)throw q},onSuccess:()=>{n.invalidateQueries({queryKey:["wishlist-items"]}),u(!1),x(""),_(""),s({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:O=>{s({title:"Error",description:O.message,variant:"destructive"})}}),E=It({mutationFn:async({itemId:O,hasVoted:V})=>{if(V){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 V=w.find($=>$.id===O.itemId),q=((V==null?void 0:V.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"})}}),L=w.filter(O=>O.title.toLowerCase().includes(a.toLowerCase())||O.description.toLowerCase().includes(a.toLowerCase())),I=()=>{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(Es,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(kb,{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(pi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Us,{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(xe,{htmlFor:"title",children:"Title"}),e.jsx(De,{id:"title",placeholder:"Give your idea a clear title...",value:p,onChange:O=>x(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(vr,{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:I,className:"w-full",disabled:C.isPending,children:C.isPending?e.jsxs(e.Fragment,{children:[e.jsx(_s,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search ideas...",value:a,onChange:O=>o(O.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ia,{value:l,onValueChange:O=>i(O),children:e.jsxs(ea,{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"})}),k?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(_s,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):L.length===0?e.jsxs("div",{className:"text-center py-12 bg-muted/30 rounded-lg",children:[e.jsx(kb,{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(Us,{className:"h-4 w-4 mr-2"}),"Add Idea"]})]}):e.jsx("div",{className:"space-y-3",children:L.map(O=>e.jsx("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>r(`/wishlist/${O.id}`),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:V=>{V.stopPropagation(),E.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(du,{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(Qe,{className:Rt("text-xs",S7e[O.status].color),children:S7e[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(ki,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:O.comment_count})]})]})},O.id))})]})})}const C7e={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 b1s(){const{itemId:t}=co(),s=_r(),{user:r}=Fs(),{toast:n}=wa(),a=Jt(),[o,l]=S.useState(""),{data:i=!1}=gt({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:w,error:k}=await G.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!k&&!!w},enabled:!!r}),{data:d,isLoading:u}=gt({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:w,error:k}=await G.from("wishlist_items").select("*").eq("id",t).single();if(k)throw k;const{data:C}=await G.from("profiles").select("name").eq("id",w.user_id).single();let E=!1;if(r){const{data:L}=await G.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();E=!!L}return{...w,user_name:(C==null?void 0:C.name)||"Unknown",user_initials:((C==null?void 0:C.name)||"U").split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),has_voted:E}}}),{data:p=[],isLoading:x}=gt({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:w,error:k}=await G.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(k)throw k;const C=[...new Set((w==null?void 0:w.map(I=>I.user_id))||[])],{data:E}=await G.from("profiles").select("id, name").in("id",C),L=new Map((E==null?void 0:E.map(I=>[I.id,I]))||[]);return w==null?void 0:w.map(I=>{const O=L.get(I.user_id),V=(O==null?void 0:O.name)||"Unknown";return{...I,user_name:V,user_initials:V.split(" ").map(q=>q[0]).join("").toUpperCase().slice(0,2)}})}}),y=It({mutationFn:async w=>{if(w){const{error:k}=await G.from("wishlist_votes").delete().eq("item_id",t).eq("user_id",r.id);if(k)throw k;return{wasAdded:!1}}else{const{error:k}=await G.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(k)throw k;return{wasAdded:!0}}},onSuccess:async w=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),w!=null&&w.wasAdded&&d){const k=(d.vote_count||0)+1;G.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:k}}).catch(console.error)}},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),_=It({mutationFn:async w=>{const{error:k}=await G.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:w});if(k)throw k},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),b=It({mutationFn:async w=>{const{error:k}=await G.from("wishlist_comments").delete().eq("id",w);if(k)throw k},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),N=()=>{o.trim()&&_.mutate(o.trim())};return u?e.jsx(Es,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(Ns,{className:"h-8 w-32 mb-6"}),e.jsx(Ns,{className:"h-48 w-full mb-6"}),e.jsx(Ns,{className:"h-32 w-full"})]})}):d?e.jsx(Es,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/wishlist"),className:"mb-4",children:[e.jsx(Fa,{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(du,{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(Qe,{className:Rt("text-xs",C7e[d.status].color),children:C7e[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(uce,{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(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(An,{className:"h-4 w-4"})})]}),x?e.jsx("div",{className:"space-y-4",children:[1,2].map(w=>e.jsx(Ns,{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(l4e,{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(gr,{className:"h-4 w-4"})})]},w.id))})]})]})}):e.jsx(Es,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Item not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/wishlist"),children:"Go back to Wishlist"})]})})}const M7e={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"}},T7e=["open","under_review","planned","in_progress","launched","declined"];function w1s(){const{toast:t}=wa(),s=_r(),r=Jt(),[n,a]=S.useState(""),[o,l]=S.useState("all"),[i,d]=S.useState(!1),[u,p]=S.useState(null),{data:x=[],isLoading:y}=gt({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:k,error:C}=await G.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(C)throw C;const E=[...new Set((k==null?void 0:k.map($=>$.user_id))||[])],{data:L}=await G.from("profiles").select("id, name, email").in("id",E),I=new Map((L==null?void 0:L.map($=>[$.id,$]))||[]),O=(k==null?void 0:k.map($=>$.id))||[],{data:V}=await G.from("wishlist_comments").select("item_id").in("item_id",O),q=new Map;return V==null||V.forEach($=>{q.set($.item_id,(q.get($.item_id)||0)+1)}),k==null?void 0:k.map($=>{const U=I.get($.user_id);return{...$,user_name:(U==null?void 0:U.name)||"Unknown",user_email:(U==null?void 0:U.email)||"",comment_count:q.get($.id)||0}})}}),_=It({mutationFn:async({itemId:k,status:C})=>{const{error:E}=await G.from("wishlist_items").update({status:C}).eq("id",k);if(E)throw E},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),t({title:"Status updated!"})},onError:k=>{t({title:"Error",description:k.message,variant:"destructive"})}}),b=It({mutationFn:async k=>{const{error:C}=await G.from("wishlist_items").delete().eq("id",k);if(C)throw C},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),d(!1),p(null),t({title:"Item deleted!"})},onError:k=>{t({title:"Error",description:k.message,variant:"destructive"})}}),N=x.filter(k=>{const C=k.title.toLowerCase().includes(n.toLowerCase())||k.description.toLowerCase().includes(n.toLowerCase())||k.user_name.toLowerCase().includes(n.toLowerCase()),E=o==="all"||k.status===o;return C&&E}),w={total:x.length,open:x.filter(k=>k.status==="open").length,inProgress:x.filter(k=>k.status==="in_progress").length,launched:x.filter(k=>k.status==="launched").length,highVotes:x.filter(k=>k.vote_count>=10).length};return e.jsx(Es,{title:"Admin - Wishlist",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/admin"),children:e.jsx(Fa,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search ideas, users...",value:n,onChange:k=>a(k.target.value),className:"pl-10"})]}),e.jsxs(Bs,{value:o,onValueChange:k=>l(k),children:[e.jsx(Rs,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"Filter by status"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Statuses"}),T7e.map(k=>e.jsx(vt,{value:k,children:M7e[k].label},k))]})]})]}),y?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(k=>e.jsx(Ns,{className:"h-16 w-full"},k))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:N.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):N.map(k=>e.jsxs(Ms,{className:Rt(k.vote_count>=10&&"bg-primary/5"),children:[e.jsx(ut,{children:e.jsx(Qe,{variant:k.vote_count>=10?"default":"secondary",children:k.vote_count})}),e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium line-clamp-1",children:k.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:k.description})]})}),e.jsx(ut,{className:"hidden md:table-cell",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:k.user_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:k.user_email})]})}),e.jsx(ut,{className:"hidden sm:table-cell",children:k.comment_count}),e.jsx(ut,{children:e.jsxs(Bs,{value:k.status,onValueChange:C=>_.mutate({itemId:k.id,status:C}),children:[e.jsx(Rs,{className:"w-[140px] h-8",children:e.jsx(qs,{})}),e.jsx(Os,{children:T7e.map(C=>e.jsx(vt,{value:C,children:M7e[C].label},C))})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${k.id}`,"_blank"),children:e.jsx(Kr,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{p(k.id),d(!0)},children:e.jsx(gr,{className:"h-4 w-4"})})]})})]},k.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(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function j1s(){const{user:t}=Fs(),[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState(!1),[x,y]=S.useState(null),[_,b]=S.useState(""),[N,w]=S.useState(""),[k,C]=S.useState(""),[E,L]=S.useState(""),[I,O]=S.useState(""),[V,q]=S.useState(!1),[$,U]=S.useState(""),[se,Y]=S.useState("once"),[J,X]=S.useState([]),[ce,ie]=S.useState([]),[ae,oe]=S.useState(!1),[pe,_e]=S.useState(!1),[he,we]=S.useState([]),[je,Ue]=S.useState({total:0,dismissed:0});S.useEffect(()=>{Te()},[]);const Te=async()=>{const{data:et,error:ht}=await G.from("levelup_briefs").select("*").order("created_at",{ascending:!1});ht?(me.error("Failed to fetch briefs"),console.error(ht)):r(et||[]),a(!1)},Me=()=>{b(""),w(""),C(""),L(""),O(""),q(!1),U(new Date().toISOString().slice(0,16)),Y("once"),X([]),ie([]),d(null)},Fe=()=>{Me(),l(!0)},Le=async et=>{d(et),b(et.title),w(et.description||""),C(et.video_url||""),L(et.graphic_url||""),O(et.graphic_link_url||""),q(et.is_published),U(et.publish_date.slice(0,16)),Y(et.show_frequency);const{data:ht}=await G.from("levelup_brief_links").select("*").eq("brief_id",et.id).order("sort_order");X((ht==null?void 0:ht.map(Ke=>({title:Ke.title,url:Ke.url})))||[]);const{data:xt}=await G.from("levelup_brief_polls").select("*").eq("brief_id",et.id).order("sort_order");if(xt){const Ke=[];for(const Ze of xt){const{data:Et}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",Ze.id).order("sort_order");Ke.push({question:Ze.question,poll_type:Ze.poll_type,options:(Et==null?void 0:Et.map($t=>$t.option_text))||[]})}ie(Ke)}l(!0)},Ne=async et=>{var xt;const ht=(xt=et.target.files)==null?void 0:xt[0];if(ht){oe(!0);try{const Ke=await G.functions.invoke("bunny-upload",{body:{action:"create",title:ht.name.replace(/\.[^/.]+$/,"")}});if(Ke.error)throw Ke.error;const{videoId:Ze,libraryId:Et}=Ke.data,$t=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Ze}});if($t.error)throw $t.error;const{uploadUrl:Yt,apiKey:Ps}=$t.data,zs=new XMLHttpRequest;await new Promise((Dr,zt)=>{zs.upload.addEventListener("progress",$s=>{if($s.lengthComputable){const kr=Math.round($s.loaded/$s.total*100);console.log("Upload progress:",kr)}}),zs.addEventListener("load",()=>{zs.status>=200&&zs.status<300?Dr():zt(new Error(`Upload failed with status ${zs.status}`))}),zs.addEventListener("error",()=>zt(new Error("Upload failed"))),zs.open("PUT",Yt),zs.setRequestHeader("AccessKey",Ps),zs.send(ht)});const Zs=`https://player.mediadelivery.net/embed/${Et}/${Ze}`;C(Zs),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{oe(!1)}}},qe=async()=>{if(!_.trim()){me.error("Title is required");return}try{let et;if(i){const{error:ht}=await G.from("levelup_briefs").update({title:_,description:N||null,video_url:k||null,graphic_url:E||null,graphic_link_url:I||null,is_published:V,publish_date:$,show_frequency:se}).eq("id",i.id);if(ht)throw ht;et=i.id,await G.from("levelup_brief_links").delete().eq("brief_id",et);const{data:xt}=await G.from("levelup_brief_polls").select("id").eq("brief_id",et);if(xt)for(const Ke of xt)await G.from("levelup_brief_poll_options").delete().eq("poll_id",Ke.id);await G.from("levelup_brief_polls").delete().eq("brief_id",et)}else{const{data:ht,error:xt}=await G.from("levelup_briefs").insert({title:_,description:N||null,video_url:k||null,graphic_url:E||null,graphic_link_url:I||null,is_published:V,publish_date:$,show_frequency:se,created_by:t==null?void 0:t.id}).select().single();if(xt)throw xt;et=ht.id}if(J.length>0){const ht=J.map((xt,Ke)=>({brief_id:et,title:xt.title,url:xt.url,sort_order:Ke}));await G.from("levelup_brief_links").insert(ht)}for(let ht=0;ht0){const Et=xt.options.map(($t,Yt)=>({poll_id:Ke.id,option_text:$t,sort_order:Yt}));await G.from("levelup_brief_poll_options").insert(Et)}}me.success(i?"Brief updated":"Brief created"),l(!1),Me(),Te()}catch(et){console.error("Error saving brief:",et),me.error("Failed to save brief")}},ze=async et=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:ht}=await G.from("levelup_briefs").delete().eq("id",et);if(ht)throw ht;me.success("Brief deleted"),Te()}catch(ht){console.error("Error deleting brief:",ht),me.error("Failed to delete brief")}},ve=async et=>{y(et);const{count:ht}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",et.id),{count:xt}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",et.id).not("dismissed_at","is",null);Ue({total:ht||0,dismissed:xt||0});const{data:Ke}=await G.from("levelup_brief_polls").select("*").eq("brief_id",et.id).order("sort_order");if(Ke){const Ze=[];for(const Et of Ke){const{data:$t}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",Et.id).order("sort_order"),{data:Yt}=await G.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",Et.id),Ps=[...new Set((Yt==null?void 0:Yt.map($s=>$s.user_id))||[])];let zs={};if(Ps.length>0){const{data:$s}=await G.from("profiles").select("id, name, email").in("id",Ps);$s&&$s.forEach(kr=>{zs[kr.id]=kr.name||kr.email||"Unknown"})}const Zs=(Yt||[]).map($s=>({optionId:$s.option_id,userName:zs[$s.user_id]||"Unknown",userId:$s.user_id})),Dr={};let zt=0;$t&&$t.forEach($s=>{const kr=(Yt==null?void 0:Yt.filter(Xs=>Xs.option_id===$s.id).length)||0;Dr[$s.id]=kr,zt+=kr}),Ze.push({...Et,options:$t||[],results:Dr,respondents:Zs,totalResponses:Et.poll_type==="single"?new Set(Yt==null?void 0:Yt.map($s=>$s.user_id)).size:zt})}we(Ze)}p(!0)},dt=()=>{X([...J,{title:"",url:""}])},fe=(et,ht,xt)=>{const Ke=[...J];Ke[et][ht]=xt,X(Ke)},Ve=et=>{X(J.filter((ht,xt)=>xt!==et))},Je=()=>{ie([...ce,{question:"",poll_type:"single",options:["",""]}])},at=(et,ht)=>{const xt=[...ce];xt[et].question=ht,ie(xt)},Ae=(et,ht)=>{const xt=[...ce];xt[et].poll_type=ht,ie(xt)},Ye=et=>{const ht=[...ce];ht[et].options.push(""),ie(ht)},We=(et,ht,xt)=>{const Ke=[...ce];Ke[et].options[ht]=xt,ie(Ke)},ot=(et,ht)=>{const xt=[...ce];xt[et].options=xt[et].options.filter((Ke,Ze)=>Ze!==ht),ie(xt)},Ge=et=>{ie(ce.filter((ht,xt)=>xt!==et))};return e.jsxs(Es,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:e.jsxs(K,{onClick:Fe,children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:n?e.jsx(Ms,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(et=>e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:et.title}),e.jsx(ut,{children:e.jsx(Qe,{variant:et.is_published?"default":"secondary",children:et.is_published?"Published":"Draft"})}),e.jsx(ut,{className:"capitalize",children:et.show_frequency.replace("_"," ")}),e.jsx(ut,{children:ps(new Date(et.publish_date),"MMM d, yyyy h:mm a")}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ve(et),children:e.jsx(to,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Le(et),children:e.jsx(Gc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ze(et.id),children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]})})]},et.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(ia,{defaultValue:"content",className:"w-full",children:[e.jsxs(ea,{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(xe,{children:"Title *"}),e.jsx(De,{value:_,onChange:et=>b(et.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Gg,{content:N,onChange:et=>w(et),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(xe,{children:"Publish Date"}),e.jsx(De,{type:"datetime-local",value:$,onChange:et=>U(et.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Show Frequency"}),e.jsxs(Bs,{value:se,onValueChange:Y,children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"once",children:"Once (until dismissed)"}),e.jsx(vt,{value:"every_login",children:"Every login"}),e.jsx(vt,{value:"daily",children:"Daily"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Er,{checked:V,onCheckedChange:q}),e.jsx(xe,{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(xe,{children:"Upload Video to Bunny.net"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(De,{type:"file",accept:"video/*",onChange:Ne,disabled:ae})}),ae&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Or paste embed URL"}),e.jsx(De,{value:k,onChange:et=>C(et.target.value),placeholder:"https://iframe.mediadelivery.net/embed/..."})]}),k&&e.jsx("div",{className:"aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:k,className:"w-full h-full",allow:"autoplay; fullscreen",allowFullScreen:!0})})]}),e.jsxs("div",{className:"border-t pt-4 space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Graphic / Image (optional)"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Upload Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(De,{type:"file",accept:"image/*",onChange:async et=>{var xt;const ht=(xt=et.target.files)==null?void 0:xt[0];if(ht){_e(!0);try{const Ke=ht.name.split(".").pop(),Ze=`brief-graphics/${Date.now()}.${Ke}`,{error:Et}=await G.storage.from("banner-images").upload(Ze,ht,{upsert:!0});if(Et)throw Et;const{data:$t}=G.storage.from("banner-images").getPublicUrl(Ze);L($t.publicUrl),me.success("Image uploaded!")}catch(Ke){console.error(Ke),me.error("Failed to upload image")}finally{_e(!1)}}},disabled:pe})}),pe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Or paste Image URL"}),e.jsx(De,{value:E,onChange:et=>L(et.target.value),placeholder:"https://example.com/image.png"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Click-through Link (optional)"}),e.jsx(De,{value:I,onChange:et=>O(et.target.value),placeholder:"https://example.com/landing-page"})]}),E&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted border",children:e.jsx("img",{src:E,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(xe,{children:"Quick Links"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:dt,children:[e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),J.map((et,ht)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(De,{value:et.title,onChange:xt=>fe(ht,"title",xt.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(De,{value:et.url,onChange:xt=>fe(ht,"url",xt.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ve(ht),children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]},ht)),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(xe,{children:"Polls"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:Je,children:[e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),ce.map((et,ht)=>e.jsx(Pe,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(De,{value:et.question,onChange:xt=>at(ht,xt.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(Bs,{value:et.poll_type,onValueChange:xt=>Ae(ht,xt),children:[e.jsx(Rs,{className:"w-32",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"single",children:"Single"}),e.jsx(vt,{value:"multi",children:"Multi-select"})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ge(ht),children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[et.options.map((xt,Ke)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:xt,onChange:Ze=>We(ht,Ke,Ze.target.value),placeholder:`Option ${Ke+1}`}),et.options.length>2&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ot(ht,Ke),children:e.jsx(gr,{className:"h-4 w-4 text-muted-foreground"})})]},Ke)),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Ye(ht),children:[e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},ht)),ce.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls added yet"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:qe,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: ",x==null?void 0:x.title]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),e.jsx(Re,{children:e.jsx("p",{className:"text-2xl font-bold",children:je.total})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),e.jsx(Re,{children:e.jsx("p",{className:"text-2xl font-bold",children:je.dismissed})})]})]}),he.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Poll Results"}),he.map(et=>e.jsxs(Pe,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:et.question}),e.jsx("div",{className:"space-y-2",children:et.options.map(ht=>{const xt=et.results[ht.id]||0,Ke=et.totalResponses>0?Math.round(xt/et.totalResponses*100):0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:ht.option_text}),e.jsxs("span",{className:"text-muted-foreground",children:[xt," (",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}%`}})}),xt>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(et.respondents||[]).filter(Ze=>Ze.optionId===ht.id).map((Ze,Et)=>e.jsx(Qe,{variant:"secondary",className:"text-xs font-normal",children:Ze.userName},Et))})]},ht.id)})})]},et.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const N1s=()=>{const{user:t}=Fs(),{toast:s}=wa(),r=Jt(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=S.useState(null),[x,y]=S.useState(""),{data:_=[],isLoading:b}=gt({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:I,error:O}=await G.from("additional_services").select("*").order("publish_date",{ascending:!1});if(O)throw O;return I}}),N=It({mutationFn:async I=>{let O=I.existingImageUrl;if(I.image){const q=I.image.name.split(".").pop(),$=`${Date.now()}-${Math.random().toString(36).substring(7)}.${q}`,{error:U}=await G.storage.from("service-images").upload($,I.image);if(U)throw U;const{data:se}=G.storage.from("service-images").getPublicUrl($);O=se.publicUrl}const V={name:I.item.name,description:I.item.description||null,preview_image_url:O,signup_link_url:I.item.signup_link_url,publish_date:I.item.publish_date?new Date(I.item.publish_date).toISOString():new Date().toISOString(),is_published:I.item.is_published,created_by:t==null?void 0:t.id};if(I.itemId){const{error:q}=await G.from("additional_services").update(V).eq("id",I.itemId);if(q)throw q}else{const{error:q}=await G.from("additional_services").insert(V);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),k()},onError:I=>{s({title:"Error saving service",description:I.message,variant:"destructive"})}}),w=It({mutationFn:async I=>{const{error:O}=await G.from("additional_services").delete().eq("id",I);if(O)throw O},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:"Service deleted"})},onError:I=>{s({title:"Error deleting service",description:I.message,variant:"destructive"})}}),k=()=>{d({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),y(""),l(null)},C=I=>{l(I),d({name:I.name,description:I.description||"",signup_link_url:I.signup_link_url,publish_date:I.publish_date?new Date(I.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:I.is_published}),y(I.preview_image_url||""),a(!0)},E=I=>{var V;const O=(V=I.target.files)==null?void 0:V[0];O&&(p(O),y(URL.createObjectURL(O)))},L=I=>{if(I.preventDefault(),!i.name.trim()){s({title:"Name is required",variant:"destructive"});return}if(!i.signup_link_url.trim()){s({title:"Signup link URL is required",variant:"destructive"});return}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(Es,{title:"Manage Additional Services",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.filter(I=>I.is_published).length})})]})]}),e.jsxs(fs,{open:n,onOpenChange:I=>{a(I),I||k()},children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Us,{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:L,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Name *"}),e.jsx(De,{id:"name",value:i.name,onChange:I=>d({...i,name:I.target.value}),placeholder:"Enter service name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Gg,{content:i.description,onChange:I=>d({...i,description:I}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"signup_link_url",children:"Signup Link URL *"}),e.jsx(De,{id:"signup_link_url",type:"url",value:i.signup_link_url,onChange:I=>d({...i,signup_link_url:I.target.value}),placeholder:"https://example.com/signup"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(De,{id:"publish_date",type:"date",value:i.publish_date,onChange:I=>d({...i,publish_date:I.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Er,{id:"is_published",checked:i.is_published,onCheckedChange:I=>d({...i,is_published:I})}),e.jsx(xe,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Preview Image"}),x?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:x,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(Wo,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(De,{type:"file",accept:"image/*",onChange:E,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(Pe,{children:e.jsx(Re,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:_.map(I=>e.jsxs(Ms,{children:[e.jsx(ut,{children:I.preview_image_url?e.jsx("img",{src:I.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(Wo,{className:"h-5 w-5 text-muted-foreground"})})}),e.jsx(ut,{className:"font-medium",children:I.name}),e.jsx(ut,{children:e.jsxs("a",{href:I.signup_link_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:[e.jsx(Kr,{className:"h-3 w-3"}),"Link"]})}),e.jsx(ut,{children:new Date(I.publish_date).toLocaleDateString()}),e.jsx(ut,{children:e.jsx(Qe,{variant:I.is_published?"default":"secondary",children:I.is_published?"Published":"Draft"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(I),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&w.mutate(I.id)},children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]})})]},I.id))})]})})})]})})};function k1s(){const{toast:t}=wa(),[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});S.useEffect(()=>{x()},[]);const x=async()=>{try{const{data:w,error:k}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(k)throw k;r(w.coupons||[])}catch(w){console.error("Error fetching coupons:",w),t({title:"Error",description:"Failed to load coupons",variant:"destructive"})}finally{a(!1)}},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:k,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:""}),x()}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:k}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:w}});if(k)throw k;t({title:"Success",description:"Coupon deleted successfully"}),x()}catch(k){console.error("Error deleting coupon:",k),t({title:"Error",description:k.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(Es,{title:"Subscription Discounts",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:e.jsxs(fs,{open:i,onOpenChange:d,children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Us,{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(Ir,{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(xe,{children:"Promotion Code (what users will type)"}),e.jsx(De,{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(xe,{children:"Coupon Name (internal label)"}),e.jsx(De,{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(xe,{children:"Discount Type"}),e.jsxs(Bs,{value:u.discountType,onValueChange:w=>{const k=w==="amount"&&u.duration==="forever"?"once":u.duration;p({...u,discountType:w,duration:k})},children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(EM,{className:"mr-2 h-4 w-4"}),"Percentage Off"]})}),e.jsx(vt,{value:"amount",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(yc,{className:"mr-2 h-4 w-4"}),"Fixed Amount Off"]})})]})]})]}),u.discountType==="percent"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Percent Off"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{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(xe,{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(De,{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(xe,{children:"Duration"}),e.jsxs(Bs,{value:u.duration,onValueChange:w=>p({...u,duration:w}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"once",children:"Once (first payment only)"}),e.jsx(vt,{value:"repeating",children:"Multiple months"}),e.jsxs(vt,{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(xe,{children:"Number of Months"}),e.jsx(De,{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(_s,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"Active Coupons"}),e.jsx(hr,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),e.jsx(Re,{children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(_s,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:s.map(w=>{var k;return e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-mono font-medium",children:((k=w.promotion_codes)==null?void 0:k.length)>0?w.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(ut,{children:w.name||"-"}),e.jsx(ut,{children:b(w)}),e.jsx(ut,{children:N(w)}),e.jsx(ut,{children:w.times_redeemed}),e.jsx(ut,{children:e.jsx(Qe,{variant:w.valid?"default":"secondary",children:w.valid?"Active":"Inactive"})}),e.jsx(ut,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(w.id),children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})})]},w.id)})})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"How to Use Coupons"})}),e.jsxs(Re,{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 n0e={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 S1s(){const[t,s]=S.useState(""),[r,n]=S.useState("all"),[a,o]=S.useState("all"),[l,i]=S.useState(null),{data:d,isLoading:u,refetch:p}=gt({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:k,error:C}=await G.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(C)throw C;return k}}),{data:x}=gt({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:k,error:C}=await G.from("brokerages").select("*").order("name");if(C)throw C;return await Promise.all((k||[]).map(async L=>{const{data:I}=await G.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",L.id),{data:O}=await G.from("user_roles").select("user_id").eq("role","brokerage_manager"),V=(O==null?void 0:O.map(U=>U.user_id))||[],q=(I==null?void 0:I.filter(U=>V.includes(U.id)))||[],$=(I==null?void 0:I.length)||0;return{...L,managers:q,agentCount:$}}))}}),{data:y}=gt({queryKey:["admin-website-subscriptions"],queryFn:async()=>{const{data:k,error:C}=await G.from("local_move_subscriptions").select("*").order("created_at",{ascending:!1});if(C)throw C;return k}}),_=k=>{if(k.is_grandfathered)return{status:"Grandfathered",badge:"Legacy",variant:"secondary"};if(k.brokerage_id&&!k.subscription_product_id)return{status:"Brokerage",badge:"Team Member",variant:"outline"};if(k.is_trial&&k.trial_expires_at)return new Date(k.trial_expires_at)>new Date?{status:"Trial",badge:"Active Trial",variant:"default"}:{status:"Trial Expired",badge:"Expired",variant:"destructive"};if(k.subscription_status==="active"||k.subscription_status==="trialing"){const C=n0e[k.subscription_product_id];return{status:(C==null?void 0:C.name)||"Active",badge:k.subscription_status==="trialing"?"Trial":"Active",variant:"default"}}return k.subscription_status==="canceled"||k.subscription_status==="past_due"?{status:"Canceled",badge:"Inactive",variant:"destructive"}:{status:"None",badge:"No Subscription",variant:"outline"}},b=d==null?void 0:d.filter(k=>{var E,L;if(!(((E=k.name)==null?void 0:E.toLowerCase().includes(t.toLowerCase()))||((L=k.email)==null?void 0:L.toLowerCase().includes(t.toLowerCase()))))return!1;if(a!=="all"){const I=k.subscription_source||"platform";if(a==="platform"&&I==="local_move_website"||a==="local_move_website"&&I!=="local_move_website")return!1}switch(_(k),r){case"active":return k.subscription_status==="active";case"trialing":return k.subscription_status==="trialing"||k.is_trial&&new Date(k.trial_expires_at)>new Date;case"grandfathered":return k.is_grandfathered;case"brokerage":return k.brokerage_id&&!k.subscription_product_id&&!k.is_grandfathered;case"expired":return k.subscription_status==="canceled"||k.subscription_status==="past_due"||k.is_trial&&new Date(k.trial_expires_at)<=new Date;case"none":return!k.subscription_status||k.subscription_status==="none";default:return!0}}),N={totalUsers:(d==null?void 0:d.length)||0,activeSubscriptions:(d==null?void 0:d.filter(k=>k.subscription_status==="active").length)||0,trials:(d==null?void 0:d.filter(k=>k.subscription_status==="trialing"||k.is_trial&&new Date(k.trial_expires_at)>new Date).length)||0,grandfathered:(d==null?void 0:d.filter(k=>k.is_grandfathered).length)||0,brokerageMembers:(d==null?void 0:d.filter(k=>k.brokerage_id&&!k.subscription_product_id&&!k.is_grandfathered).length)||0,individualSubscribers:(d==null?void 0:d.filter(k=>k.subscription_status==="active"&&k.subscription_product_id==="prod_Tc07cYplXUGNkm").length)||0,brokerageSubscribers:(d==null?void 0:d.filter(k=>k.subscription_status==="active"&&(k.subscription_product_id==="prod_Tc08MupgoVySDG"||k.subscription_product_id==="prod_Tc09N1tJ4RrAFn")).length)||0},w=k=>{window.open(`https://dashboard.stripe.com/customers/${k}`,"_blank")};return e.jsx(Es,{title:"Subscription Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{title:"Subscription Management",description:"Track and manage all subscriptions",children:e.jsxs(K,{onClick:()=>p(),variant:"outline",size:"sm",children:[e.jsx(oo,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(lr,{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(Pe,{className:"border-green-500/50",children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yx,{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(Pe,{className:"border-blue-500/50",children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ln,{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(Pe,{className:"border-purple-500/50",children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cm,{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(Pe,{className:"border-orange-500/50",children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tb,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{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(ia,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(ea,{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(Qe,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or email...",value:t,onChange:k=>s(k.target.value),className:"pl-9"})]}),e.jsxs(Bs,{value:a,onValueChange:k=>o(k),children:[e.jsx(Rs,{className:"w-[200px]",children:e.jsx(qs,{placeholder:"Source"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Sources"}),e.jsx(vt,{value:"platform",children:"Platform"}),e.jsx(vt,{value:"local_move_website",children:"Local Move Website"})]})]}),e.jsxs(Bs,{value:r,onValueChange:k=>n(k),children:[e.jsx(Rs,{className:"w-[200px]",children:e.jsx(qs,{placeholder:"Filter by status"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Statuses"}),e.jsx(vt,{value:"active",children:"Active Subscriptions"}),e.jsx(vt,{value:"trialing",children:"Trials"}),e.jsx(vt,{value:"grandfathered",children:"Grandfathered"}),e.jsx(vt,{value:"brokerage",children:"Brokerage Members"}),e.jsx(vt,{value:"expired",children:"Expired/Canceled"}),e.jsx(vt,{value:"none",children:"No Subscription"})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:u?e.jsx(Ms,{children:e.jsx(ut,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(b==null?void 0:b.length)===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):b==null?void 0:b.map(k=>{var L,I;const C=_(k),E=n0e[k.subscription_product_id];return e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:k.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:k.email})]})}),e.jsx(ut,{children:e.jsx(Qe,{variant:C.variant,children:C.badge})}),e.jsx(ut,{children:e.jsx("span",{className:"text-sm",children:k.is_grandfathered?"Legacy Access":k.brokerage_id&&!k.subscription_product_id?"Brokerage Subscription":(E==null?void 0:E.name)||C.status})}),e.jsx(ut,{children:(L=k.brokerages)!=null&&L.name?e.jsx("span",{className:"text-sm",children:k.brokerages.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(ut,{children:k.subscription_end_date?e.jsx("span",{className:"text-sm",children:ps(new Date(k.subscription_end_date),"MMM d, yyyy")}):k.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",ps(new Date(k.trial_expires_at),"MMM d, yyyy")]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[k.stripe_customer_id&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(k.stripe_customer_id),children:e.jsx(Kr,{className:"h-4 w-4"})}),e.jsxs(fs,{children:[e.jsx(pi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",onClick:()=>i(k),children:"Details"})}),e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Subscription Details"}),e.jsxs(Ir,{children:[k.name," (",k.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(Qe,{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:k.is_grandfathered?"Grandfathered (Legacy)":k.brokerage_id&&!k.subscription_product_id?"Brokerage Subscription":(E==null?void 0:E.name)||"None"})]}),k.brokerage_id&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Brokerage"}),e.jsx("p",{className:"font-medium",children:((I=k.brokerages)==null?void 0:I.name)||"Unknown"})]}),k.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:ps(new Date(k.subscription_end_date),"MMMM d, yyyy")})]}),k.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:ps(new Date(k.trial_expires_at),"MMMM d, yyyy")})]}),k.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:k.stripe_customer_id})]})]}),k.stripe_customer_id&&e.jsxs(K,{className:"w-full",onClick:()=>w(k.stripe_customer_id),children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},k.id)})})]})})})]}),e.jsx(js,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:x==null?void 0:x.map(k=>{var E,L;const C=(E=k.managers)==null?void 0:E.some(I=>I.subscription_status==="active"&&(I.subscription_product_id==="prod_Tc08MupgoVySDG"||I.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(Pe,{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(pa,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:k.name}),e.jsxs(hr,{children:[k.agentCount," agents"]})]})]}),e.jsx(Qe,{variant:C?"default":"outline",children:C?"Active Subscription":"No Active Subscription"})]})}),e.jsx(Re,{children:((L=k.managers)==null?void 0:L.length)>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Managers:"}),k.managers.map(I=>{const O=n0e[I.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:I.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:I.email})]}),e.jsx("div",{className:"text-right",children:O?e.jsxs("div",{children:[e.jsx(Qe,{variant:"default",children:O.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:O.price})]}):e.jsx(Qe,{variant:"outline",children:"No Subscription"})})]},I.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},k.id)})})}),e.jsx(js,{value:"websites",className:"space-y-4",children:e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(gd,{className:"h-5 w-5 text-primary"}),"Local Move Website Subscriptions"]}),e.jsx(hr,{children:"$249 setup fee + $99/mo subscriptions from TheLocalMove.com agent websites"})]}),e.jsx(Re,{className:"p-0",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:y?y.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No website subscriptions yet"})}):y.map(k=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:k.agent_name||"—"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:k.agent_email})]})}),e.jsx(ut,{children:e.jsx(Qe,{variant:k.status==="active"?"default":k.status==="canceled"?"destructive":"outline",children:k.status})}),e.jsx(ut,{children:k.setup_fee_paid?e.jsxs(Qe,{variant:"secondary",children:["Paid · $",(k.setup_fee_amount_cents/100).toFixed(0)]}):e.jsx(Qe,{variant:"outline",children:"Unpaid"})}),e.jsxs(ut,{className:"font-medium",children:["$",(k.monthly_amount_cents/100).toFixed(0),"/mo"]}),e.jsx(ut,{children:k.current_period_end?e.jsx("span",{className:"text-sm",children:ps(new Date(k.current_period_end),"MMM d, yyyy")}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(ut,{children:e.jsx("span",{className:"text-sm",children:ps(new Date(k.created_at),"MMM d, yyyy")})}),e.jsx(ut,{className:"text-right",children:k.stripe_customer_id&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(k.stripe_customer_id),children:e.jsx(Kr,{className:"h-4 w-4"})})})]},k.id)):e.jsx(Ms,{children:e.jsx(ut,{colSpan:7,className:"text-center py-8",children:"Loading…"})})})]})})]})})]})]})})}function C1s(){const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(""),[l,i]=S.useState("all"),[d,u]=S.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});S.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:b,error: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(E=>E.status==="qualified").length)||0,k=(b==null?void 0:b.filter(E=>E.status==="pending").length)||0,C=(b==null?void 0:b.filter(E=>E.status==="cancelled").length)||0;u({total:(b==null?void 0:b.length)||0,qualified:w,pending:k,cancelled:C,totalDiscounts:w*25})}catch(b){console.error("Error fetching referrals:",b),me.error("Failed to load referrals")}finally{n(!1)}},x=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 k,C,E,L,I,O;const N=((C=(k=b.referrer_brokerage)==null?void 0:k.name)==null?void 0:C.toLowerCase().includes(a.toLowerCase()))||((L=(E=b.referred_brokerage)==null?void 0:E.name)==null?void 0:L.toLowerCase().includes(a.toLowerCase()))||((O=(I=b.referred_user)==null?void 0:I.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(Qe,{className:"bg-green-100 text-green-800",children:[e.jsx(ti,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(Qe,{variant:"secondary",children:[e.jsx(ln,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(Qe,{variant:"destructive",children:[e.jsx(Zl,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(Qe,{children:b})}};return e.jsx(Es,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{title:"Referral Program",description:"Track and manage brokerage referrals",children:e.jsxs(K,{onClick:x,variant:"outline",children:[e.jsx(oo,{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(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(lr,{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(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ti,{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(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ln,{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(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Zl,{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(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yc,{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(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"All Referrals"}),e.jsx(hr,{children:"View and manage all referral relationships"})]}),e.jsxs(Re,{children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by brokerage or email...",value:a,onChange:b=>o(b.target.value),className:"pl-10"})]}),e.jsxs(Bs,{value:l,onValueChange:i,children:[e.jsx(Rs,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"Filter by status"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Statuses"}),e.jsx(vt,{value:"pending",children:"Pending"}),e.jsx(vt,{value:"qualified",children:"Qualified"}),e.jsx(vt,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:y.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):y.map(b=>{var N,w,k,C;return e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:((N=b.referrer_brokerage)==null?void 0:N.name)||"Unknown"}),e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("p",{children:((w=b.referred_brokerage)==null?void 0:w.name)||((k=b.referred_user)==null?void 0:k.name)||"Pending setup"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(C=b.referred_user)==null?void 0:C.email})]})}),e.jsx(ut,{children:ps(new Date(b.signup_date),"MMM d, yyyy")}),e.jsx(ut,{children:_(b.status)}),e.jsx(ut,{children:b.qualified_date?ps(new Date(b.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(ut,{children:b.discount_applied?e.jsx(Qe,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},b.id)})})]})]})]})]})})}const a0e=[{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"}],M1s=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function T1s(){const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(null),[d,u]=S.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});S.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:C,error:E}=await G.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(E)throw E;s(C||[])}catch(C){console.error("Error fetching checklist items:",C),me.error("Failed to load checklist items")}finally{n(!1)}},x=()=>{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(L=>L.target_role===d.target_role).reduce((L,I)=>Math.max(L,I.sort_order),-1),{error:E}=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(E)throw E;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:E}=await G.from("onboarding_checklist_items").delete().eq("id",C);if(E)throw E;me.success("Checklist item deleted"),p()}catch(E){console.error("Error deleting checklist item:",E),me.error("Failed to delete checklist item")}},N=async C=>{try{const{error:E}=await G.from("onboarding_checklist_items").update({is_active:!C.is_active}).eq("id",C.id);if(E)throw E;me.success(C.is_active?"Item deactivated":"Item activated"),p()}catch(E){console.error("Error toggling item:",E),me.error("Failed to update item")}},w=t.filter(C=>C.target_role==="brokerage_manager"),k=t.filter(C=>C.target_role==="agent");return e.jsxs(Es,{title:"Onboarding Checklist",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Onboarding Checklist"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage checklist items shown to new users on their dashboard"})]}),e.jsxs(K,{onClick:x,className:"gap-2",children:[e.jsx(Us,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Qe,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(Re,{children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:w.map((C,E)=>{var L;return e.jsxs(Ms,{children:[e.jsx(ut,{className:"text-muted-foreground",children:E+1}),e.jsx(ut,{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(ut,{children:e.jsx(Qe,{variant:"outline",children:((L=a0e.find(I=>I.value===C.action_type))==null?void 0:L.label)||C.action_type})}),e.jsx(ut,{children:e.jsx(Er,{checked:C.is_active,onCheckedChange:()=>N(C)})}),e.jsx(ut,{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(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(C.id),children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Qe,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx(Re,{children:k.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for agents"}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:k.map((C,E)=>{var L;return e.jsxs(Ms,{children:[e.jsx(ut,{className:"text-muted-foreground",children:E+1}),e.jsx(ut,{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(ut,{children:e.jsx(Qe,{variant:"outline",children:((L=a0e.find(I=>I.value===C.action_type))==null?void 0:L.label)||C.action_type})}),e.jsx(ut,{children:e.jsx(Er,{checked:C.is_active,onCheckedChange:()=>N(C)})}),e.jsx(ut,{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(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(C.id),children:e.jsx(gr,{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(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{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(xe,{htmlFor:"description",children:"Description"}),e.jsx(vr,{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(xe,{children:"Target Role"}),e.jsxs(Bs,{value:d.target_role,onValueChange:C=>u({...d,target_role:C}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:M1s.map(C=>e.jsx(vt,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Action Type"}),e.jsxs(Bs,{value:d.action_type,onValueChange:C=>u({...d,action_type:C}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:a0e.map(C=>e.jsx(vt,{value:C.value,children:C.label},C.value))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Er,{id:"is_active",checked:d.is_active,onCheckedChange:C=>u({...d,is_active:C})}),e.jsx(xe,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:_,children:l?"Save Changes":"Create Item"})]})]})})]})}function A1s(){const[t,s]=S.useState(""),[r,n]=S.useState("all"),[a,o]=S.useState("name"),[l,i]=S.useState("asc"),[d,u]=S.useState(""),[p,x]=S.useState(""),[y,_]=S.useState(""),[b,N]=S.useState(""),{data:w}=gt({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:U,error:se}=await G.from("brokerages").select("id, name").order("name");if(se)throw se;return U}}),k=async U=>{let Y=[],J=0,X=!0;for(;X;){const{data:ce,error:ie}=await U(J,J+1e3-1);if(ie)throw ie;ce&&ce.length>0?(Y=[...Y,...ce],J+=1e3,X=ce.length===1e3):X=!1}return Y},{data:C,isLoading:E}=gt({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const U=await k((Le,Ne)=>G.from("profiles").select("id, name, email, brokerage_id, created_at").range(Le,Ne)),{data:se}=await G.from("brokerages").select("id, name"),Y=new Map((se==null?void 0:se.map(Le=>[Le.id,Le.name]))||[]),[{data:J},{data:X},{data:ce},{data:ie},{data:ae},{data:oe},{data:pe}]=await Promise.all([G.rpc("get_admin_contact_counts"),G.rpc("get_admin_video_counts"),G.rpc("get_admin_popby_counts"),G.rpc("get_admin_listing_counts"),G.rpc("get_admin_deal_counts"),G.rpc("get_admin_portal_counts"),G.rpc("get_admin_sendable_card_counts")]),_e=new Map;J==null||J.forEach(Le=>_e.set(Le.owner_user_id,Le.contact_count));const he=new Map;X==null||X.forEach(Le=>he.set(Le.owner_user_id,Le.video_count));const we=new Map;ce==null||ce.forEach(Le=>we.set(Le.owner_user_id,Le.popby_count));const je=new Map;ie==null||ie.forEach(Le=>je.set(Le.agent_id,Le.listing_count));const Ue=new Map;ae==null||ae.forEach(Le=>Ue.set(Le.owner_user_id,Le.deal_count));const Te=new Map;oe==null||oe.forEach(Le=>Te.set(Le.owner_user_id,{total:Le.portal_count,active:Le.active_portal_count}));const Me=new Map;return pe==null||pe.forEach(Le=>Me.set(Le.owner_user_id,{total:Le.card_count,sent:Le.sent_card_count,views:Le.total_card_views})),U.map(Le=>{const Ne=Te.get(Le.id),qe=Me.get(Le.id);return{id:Le.id,name:Le.name||"Unknown",email:Le.email||"",brokerage_id:Le.brokerage_id,brokerage_name:Le.brokerage_id&&Y.get(Le.brokerage_id)||null,contact_count:_e.get(Le.id)||0,video_count:he.get(Le.id)||0,popby_count:we.get(Le.id)||0,listing_count:je.get(Le.id)||0,deal_count:Ue.get(Le.id)||0,portal_count:(Ne==null?void 0:Ne.total)||0,active_portal_count:(Ne==null?void 0:Ne.active)||0,card_count:(qe==null?void 0:qe.total)||0,sent_card_count:(qe==null?void 0:qe.sent)||0,total_card_views:(qe==null?void 0:qe.views)||0,created_at:Le.created_at}})}}),L=S.useMemo(()=>{if(!C)return[];let U=C.filter(se=>{const Y=t.toLowerCase(),J=!t||se.name.toLowerCase().includes(Y)||se.email.toLowerCase().includes(Y),X=r==="all"||r==="none"&&!se.brokerage_id||se.brokerage_id===r,ce=parseInt(d)||0,ie=parseInt(p)||0,ae=parseInt(y)||0,oe=parseInt(b)||0,pe=se.contact_count>=ce&&se.video_count>=ie&&se.popby_count>=ae&&se.listing_count>=oe;return J&&X&&pe});return U.sort((se,Y)=>{let J=0;return a==="name"?J=se.name.localeCompare(Y.name):J=se[a]-Y[a],l==="asc"?J:-J}),U},[C,t,r,a,l,d,p,y,b]),I=U=>{a===U?i(l==="asc"?"desc":"asc"):(o(U),i("desc"))},O=()=>{const U=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],se=L.map(ie=>[ie.name,ie.email,ie.brokerage_name||"None",ie.contact_count,ie.video_count,ie.popby_count,ie.listing_count,ie.deal_count,`${ie.portal_count} (${ie.active_portal_count})`,ie.card_count,ie.sent_card_count,ie.total_card_views]),Y=[U.join(","),...se.map(ie=>ie.map(ae=>`"${ae}"`).join(","))].join(` `),J=new Blob([Y],{type:"text/csv"}),X=URL.createObjectURL(J),ce=document.createElement("a");ce.href=X,ce.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,ce.click(),URL.revokeObjectURL(X)},V=S.useMemo(()=>L.length?L.reduce((U,se)=>({contacts:U.contacts+se.contact_count,videos:U.videos+se.video_count,popbys:U.popbys+se.popby_count,listings:U.listings+se.listing_count,deals:U.deals+se.deal_count,portals:U.portals+se.portal_count,activePortals:U.activePortals+se.active_portal_count,cards:U.cards+se.card_count,sentCards:U.sentCards+se.sent_card_count,cardViews:U.cardViews+se.total_card_views}),{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0}):{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0},[L]),q=S.useMemo(()=>L.length?{portals:L.filter(U=>U.portal_count>0).length,cards:L.filter(U=>U.card_count>0).length}:{portals:0,cards:0},[L]),$=({field:U,children:se})=>e.jsx(Nt,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>I(U),children:e.jsxs("div",{className:"flex items-center gap-1",children:[se,e.jsx(td,{className:`h-3 w-3 ${a===U?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(N1,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Pe,{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(Ot,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Wv,{className:"h-4 w-4 text-blue-500"}),"Client Portals"]})}),e.jsx(Re,{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:V.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:V.activePortals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Active Portals"})]})]})})]}),e.jsxs(Pe,{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(Ot,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(rr,{className:"h-4 w-4 text-violet-500"}),"Card Studio"]})}),e.jsx(Re,{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:V.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:V.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:V.cardViews}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Views"})]})]})})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(hr,{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(Re,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or email...",value:t,onChange:U=>s(U.target.value),className:"pl-9"})]})}),e.jsx("div",{children:e.jsxs(Bs,{value:r,onValueChange:n,children:[e.jsxs(Rs,{children:[e.jsx(pa,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(qs,{placeholder:"Brokerage"})]}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Brokerages"}),e.jsx(vt,{value:"none",children:"No Brokerage"}),w==null?void 0:w.map(U=>e.jsx(vt,{value:U.id,children:U.name},U.id))]})]})}),e.jsx("div",{children:e.jsx(De,{type:"number",placeholder:"Min contacts",value:d,onChange:U=>u(U.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(De,{type:"number",placeholder:"Min videos",value:p,onChange:U=>x(U.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(De,{type:"number",placeholder:"Min popbys",value:y,onChange:U=>_(U.target.value),min:"0"})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-8 text-sm",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:L.length}),e.jsx("div",{className:"text-muted-foreground",children:"Users"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:V.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:V.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:V.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:V.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:V.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:V.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:V.cards.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Cards"})]})]}),E?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(_s,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Wv,{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(rr,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),e.jsx(Dn,{children:L.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):L.map(U=>e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:U.name}),e.jsx(ut,{className:"text-muted-foreground",children:U.email}),e.jsx(ut,{children:U.brokerage_name?e.jsx(Qe,{variant:"secondary",children:U.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ut,{children:e.jsx(Qe,{variant:U.contact_count>0?"default":"outline",children:U.contact_count})}),e.jsx(ut,{children:e.jsx(Qe,{variant:U.video_count>0?"default":"outline",children:U.video_count})}),e.jsx(ut,{children:e.jsx(Qe,{variant:U.popby_count>0?"default":"outline",children:U.popby_count})}),e.jsx(ut,{children:e.jsx(Qe,{variant:U.listing_count>0?"default":"outline",children:U.listing_count})}),e.jsx(ut,{children:e.jsx(Qe,{variant:U.deal_count>0?"default":"outline",children:U.deal_count})}),e.jsx(ut,{children:U.portal_count>0?e.jsxs(Yl,{children:[e.jsx(Xl,{children:e.jsxs(Qe,{variant:"default",className:"bg-blue-600 hover:bg-blue-700",children:[U.portal_count,U.active_portal_count>0&&e.jsxs("span",{className:"ml-1 opacity-75",children:["(",U.active_portal_count," active)"]})]})}),e.jsxs(Cl,{children:[e.jsxs("p",{children:[U.portal_count," total portals"]}),e.jsxs("p",{children:[U.active_portal_count," currently active"]})]})]}):e.jsx(Qe,{variant:"outline",children:"0"})}),e.jsx(ut,{children:U.card_count>0?e.jsxs(Yl,{children:[e.jsx(Xl,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Qe,{variant:"default",className:"bg-violet-600 hover:bg-violet-700",children:U.card_count}),U.sent_card_count>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600",children:[e.jsx(An,{className:"h-3 w-3"}),U.sent_card_count]}),U.total_card_views>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[e.jsx(wn,{className:"h-3 w-3"}),U.total_card_views]})]})}),e.jsxs(Cl,{children:[e.jsxs("p",{children:[U.card_count," cards created"]}),e.jsxs("p",{children:[U.sent_card_count," sent"]}),e.jsxs("p",{children:[U.total_card_views," total views"]})]})]}):e.jsx(Qe,{variant:"outline",children:"0"})})]},U.id))})]})})]})]})]})})}function E1s(){wa(),Jt();const[t,s]=S.useState("user-analytics"),{data:r}=gt({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}=gt({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}=gt({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}=gt({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}=gt({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:_,error:b}=await G.from("touchpoint_plans").select("*").order("name");if(b)throw b;return _}}),{data:x,isLoading:y}=gt({queryKey:["admin-popby-items"],queryFn:async()=>{const{data:_,error:b}=await G.from("popby_items").select("*").is("owner_user_id",null).order("name");if(b)throw b;return _}});return e.jsx(Es,{title:"Agent OS Control Center",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(ia,{value:t,onValueChange:s,children:[e.jsxs(ea,{className:"grid w-full grid-cols-9",children:[e.jsxs(ls,{value:"user-analytics",className:"gap-2",children:[e.jsx(to,{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(lr,{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(Pn,{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(fn,{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(tu,{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(on,{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(Ui,{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(ko,{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(Zv,{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(A1s,{})}),e.jsx(js,{value:"relationship-types",className:"mt-6",children:e.jsx(P1s,{types:n||[],isLoading:a})}),e.jsx(js,{value:"action-types",className:"mt-6",children:e.jsx(I1s,{types:o||[],isLoading:l})}),e.jsx(js,{value:"scripts",className:"mt-6",children:e.jsx(L1s,{scripts:i||[],actionTypes:o||[],isLoading:d})}),e.jsx(js,{value:"video-scripts",className:"mt-6",children:e.jsx(F1s,{})}),e.jsx(js,{value:"plans",className:"mt-6",children:e.jsx(D1s,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:p})}),e.jsx(js,{value:"popbys",className:"mt-6",children:e.jsx(O1s,{items:x||[],isLoading:y})}),e.jsx(js,{value:"settings",className:"mt-6",children:e.jsx(z1s,{})}),e.jsx(js,{value:"feature-flags",className:"mt-6",children:e.jsx(R1s,{flags:r||[]})})]})]})})}function P1s({types:t,isLoading:s}){const{toast:r}=wa(),n=Jt(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=It({mutationFn:async p=>{if(p.id){const{error:x}=await G.from("relationship_types").update({name:p.name,description:p.description,icon:p.icon}).eq("id",p.id);if(x)throw x}else{const{error:x}=await G.from("relationship_types").insert([{name:p.name,description:p.description,icon:p.icon,sort_order:t.length}]);if(x)throw x}},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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Relationship Types"}),e.jsx(hr,{children:"Define the relationship categories for InnerCircle contacts"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Type"]})]}),e.jsx(Re,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(_s,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:t.map(p=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsx(hu,{className:"h-4 w-4 text-muted-foreground cursor-grab"})}),e.jsx(ut,{className:"font-medium",children:p.name}),e.jsx(ut,{className:"text-muted-foreground",children:p.description}),e.jsx(ut,{children:e.jsx(Er,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(ut,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(ga,{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 x=new FormData(p.currentTarget);d.mutate({id:a==null?void 0:a.id,name:x.get("name"),description:x.get("description"),icon:x.get("icon")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(vr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"icon",children:"Icon"}),e.jsx(De,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., star, heart, user"})]})]}),e.jsxs(En,{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(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function I1s({types:t,isLoading:s}){const{toast:r}=wa(),n=Jt(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=It({mutationFn:async p=>{if(p.id){const{error:x}=await G.from("action_types").update({name:p.name,description:p.description,icon:p.icon,color:p.color}).eq("id",p.id);if(x)throw x}else{const{error:x}=await G.from("action_types").insert([{name:p.name,description:p.description,icon:p.icon,color:p.color,sort_order:t.length}]);if(x)throw x}},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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Action Types"}),e.jsx(hr,{children:"Define the types of touchpoint actions agents can take"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Action"]})]}),e.jsx(Re,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(_s,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:t.map(p=>e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:p.name}),e.jsx(ut,{className:"text-muted-foreground",children:p.description}),e.jsx(ut,{children:p.color&&e.jsx("div",{className:"w-6 h-6 rounded",style:{backgroundColor:p.color}})}),e.jsx(ut,{children:e.jsx(Er,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(ut,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(ga,{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 x=new FormData(p.currentTarget);d.mutate({id:a==null?void 0:a.id,name:x.get("name"),description:x.get("description"),icon:x.get("icon"),color:x.get("color")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(vr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"icon",children:"Icon"}),e.jsx(De,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., phone, message"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"color",children:"Color"}),e.jsx(De,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(En,{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(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function L1s({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=wa(),a=Jt(),[o,l]=S.useState(null),[i,d]=S.useState(!1),u=It({mutationFn:async x=>{if(x.id){const{error:y}=await G.from("action_scripts").update({title:x.title,action_type_id:x.action_type_id,tone:x.tone,script_body:x.script_body,active:x.active}).eq("id",x.id);if(y)throw y}else{const{error:y}=await G.from("action_scripts").insert([{title:x.title,action_type_id:x.action_type_id,tone:x.tone,script_body:x.script_body,active:!0}]);if(y)throw y}},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),d(!1),l(null),n({title:"Saved successfully"})},onError:x=>{n({title:"Error",description:x.message,variant:"destructive"})}}),p=It({mutationFn:async x=>{const{error:y}=await G.from("action_scripts").delete().eq("id",x);if(y)throw y},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),n({title:"Deleted successfully"})}});return e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Script Library"}),e.jsx(hr,{children:"Create and manage scripts for each action type"})]}),e.jsxs(K,{onClick:()=>{l(null),d(!0)},children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Re,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(_s,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:t.map(x=>{var y;return e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:x.title}),e.jsx(ut,{children:e.jsx(Qe,{variant:"outline",children:((y=x.action_type)==null?void 0:y.name)||"Unknown"})}),e.jsx(ut,{className:"text-muted-foreground",children:x.tone}),e.jsx(ut,{children:e.jsx(Qe,{variant:x.active?"default":"secondary",children:x.active?"Active":"Inactive"})}),e.jsxs(ut,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{l(x),d(!0)},children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutate(x.id),children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]})]},x.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:x=>{x.preventDefault();const y=new FormData(x.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(xe,{htmlFor:"title",children:"Title"}),e.jsx(De,{id:"title",name:"title",defaultValue:o==null?void 0:o.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"action_type_id",children:"Action Type"}),e.jsxs(Bs,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select action type"})}),e.jsx(Os,{children:s.map(x=>e.jsx(vt,{value:x.id,children:x.name},x.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"tone",children:"Tone (optional)"}),e.jsx(De,{id:"tone",name:"tone",defaultValue:(o==null?void 0:o.tone)||"",placeholder:"e.g., Friendly, Professional, Casual"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script_body",children:"Script Body"}),e.jsx(vr,{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(En,{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(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function D1s({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=wa(),o=Jt(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,x]=S.useState(null),[y,_]=S.useState(!1),[b,N]=S.useState(null),[w,k]=S.useState(null),{data:C}=gt({queryKey:["plan-items",p],queryFn:async()=>{if(!p)return[];const{data:$,error:U}=await G.from("touchpoint_plan_items").select("*").eq("plan_id",p).order("month_number");if(U)throw U;return $},enabled:!!p}),E=It({mutationFn:async $=>{if($.id){const{error:U}=await G.from("touchpoint_plans").update({name:$.name,description:$.description,active:$.active}).eq("id",$.id);if(U)throw U}else{const{error:U}=await G.from("touchpoint_plans").insert([{name:$.name,description:$.description,active:!0}]);if(U)throw U}},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-touchpoint-plans"]}),u(!1),i(null),a({title:"Saved successfully"})},onError:$=>{a({title:"Error",description:$.message,variant:"destructive"})}}),L=It({mutationFn:async $=>{if($.id){const{error:U}=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(U)throw U}else{const{error:U}=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(U)throw U}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]}),a({title:"Item saved"})}}),I=It({mutationFn:async $=>{const{error:U}=await G.from("touchpoint_plan_items").delete().eq("id",$);if(U)throw U},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]})}}),O=It({mutationFn:async $=>{const{data:U,error:se}=await G.from("action_scripts").insert([{...$,active:!0}]).select().single();if(se)throw se;return U},onSuccess:async $=>{o.invalidateQueries({queryKey:["admin-action-scripts"]}),b&&await L.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"})}}),V=($,U,se)=>{N({month:$,actionTypeId:U,itemId:se}),_(!0)},q=$=>r.find(U=>U.id===$);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Touchpoint Plans"}),e.jsx(hr,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),e.jsxs(K,{onClick:()=>{i(null),u(!0)},children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Plan"]})]}),e.jsx(Re,{children:n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(_s,{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(Pe,{className:`cursor-pointer transition-colors ${p===$.id?"border-primary":""}`,onClick:()=>x($.id),children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ot,{className:"text-base",children:$.name}),e.jsx(K,{variant:"ghost",size:"icon",onClick:U=>{U.stopPropagation(),i($),u(!0)},children:e.jsx(ga,{className:"h-4 w-4"})})]})}),e.jsxs(Re,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:$.description}),e.jsx(Qe,{variant:$.active?"default":"secondary",className:"mt-2",children:$.active?"Active":"Inactive"})]})]},$.id))})})]}),p&&e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"Plan Schedule"}),e.jsx(hr,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),e.jsx(Re,{children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:12},($,U)=>U+1).map($=>{const U=C==null?void 0:C.find(J=>J.month_number===$),se=U!=null&&U.default_script_id?q(U.default_script_id):null,Y=r.filter(J=>J.action_type_id===(U==null?void 0:U.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(Bs,{value:(U==null?void 0:U.action_type_id)||"none",onValueChange:J=>{J==="none"&&U?I.mutate(U.id):J!=="none"&&L.mutate({id:U==null?void 0:U.id,plan_id:p,month_number:$,action_type_id:J,default_script_id:null})},children:[e.jsx(Rs,{className:"w-40",children:e.jsx(qs,{placeholder:"No action"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"No action"}),s.filter(J=>J.active).map(J=>e.jsx(vt,{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))]})]}),U&&e.jsxs(e.Fragment,{children:[e.jsxs(Bs,{value:U.default_script_id||"none",onValueChange:J=>{k(null),L.mutate({id:U.id,default_script_id:J==="none"?null:J})},children:[e.jsx(Rs,{className:"w-56",children:e.jsx(qs,{placeholder:"Select script"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"No default script"}),Y.map(J=>e.jsxs(vt,{value:J.id,children:[J.title," ",J.tone&&`(${J.tone})`]},J.id))]})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>V($,U.action_type_id,U.id),children:[e.jsx(Us,{className:"h-3 w-3 mr-1"}),"New Script"]}),se&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k((w==null?void 0:w.id)===se.id?null:se),children:(w==null?void 0:w.id)===se.id?"Hide":"Preview"})]})]}),w&&(U==null?void 0:U.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(Qe,{variant:"outline",children:w.title}),w.tone&&e.jsx(Qe,{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 U=new FormData($.currentTarget);E.mutate({id:l==null?void 0:l.id,name:U.get("name"),description:U.get("description"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",name:"name",defaultValue:l==null?void 0:l.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(vr,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(En,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:E.isPending,children:[E.isPending&&e.jsx(_s,{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(Ir,{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 U=new FormData($.currentTarget);O.mutate({title:U.get("title"),action_type_id:b.actionTypeId,tone:U.get("tone"),script_body:U.get("script_body")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script_title",children:"Title"}),e.jsx(De,{id:"script_title",name:"title",placeholder:"e.g., Warm Check-In",required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script_tone",children:"Tone"}),e.jsx(De,{id:"script_tone",name:"tone",placeholder:"e.g., Friendly, Professional"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script_body",children:"Script Body"}),e.jsx(vr,{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(En,{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(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function R1s({flags:t}){const{toast:s}=wa(),r=Jt(),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(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"Feature Flags"}),e.jsx(hr,{children:"Control which features are enabled for members"})]}),e.jsx(Re,{children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Nt,{children:"Flag"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{children:"Notes"}),e.jsx(Nt,{children:"Last Updated"})]})}),e.jsx(Dn,{children:t.map(a=>e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-mono text-sm",children:a.key}),e.jsx(ut,{children:e.jsx(Er,{checked:a.enabled,onCheckedChange:o=>n(a,{enabled:o})})}),e.jsx(ut,{children:e.jsx(De,{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(ut,{className:"text-muted-foreground text-sm",children:new Date(a.updated_at).toLocaleDateString()})]},a.id))})]})})]})}function O1s({items:t,isLoading:s}){const{toast:r}=wa(),n=Jt(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=It({mutationFn:async x=>{if(x.id){const{error:y}=await G.from("popby_items").update({name:x.name,description:x.description}).eq("id",x.id);if(y)throw y}else{const{error:y}=await G.from("popby_items").insert([{name:x.name,description:x.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:x=>{r({title:"Error",description:x.message,variant:"destructive"})}}),u=async x=>{await G.from("popby_items").update({is_active:!x.is_active}).eq("id",x.id),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]})},p=async x=>{await G.from("popby_items").delete().eq("id",x),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),r({title:"Deleted successfully"})};return e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Popby Ideas"}),e.jsx(hr,{children:"Manage global popby ideas that all agents can see"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsx(Re,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(_s,{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(Ui,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:t.map(x=>e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:x.name}),e.jsx(ut,{className:"text-muted-foreground",children:x.description}),e.jsx(ut,{children:e.jsx(Er,{checked:x.is_active,onCheckedChange:()=>u(x)})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(x),i(!0)},children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p(x.id),children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]})})]},x.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:x=>{x.preventDefault();const y=new FormData(x.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(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0,placeholder:"e.g., Homemade Cookies"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(vr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(En,{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(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function F1s(){var _;const{toast:t}=wa(),s=Jt(),[r,n]=S.useState(null),[a,o]=S.useState(!1),{data:l,isLoading:i}=gt({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}=gt({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=It({mutationFn:async b=>{var N,w;if(b.id){const{error:k}=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(k)throw k}else{const{error:k}=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(k)throw k}},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"})}),x=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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Video Scripts"}),e.jsx(hr,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),e.jsxs(K,{onClick:()=>{n(null),o(!0)},children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Re,{children:u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(_s,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:d==null?void 0:d.map(b=>{var N;return e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:b.title}),e.jsx(ut,{className:"text-muted-foreground",children:((N=b.category)==null?void 0:N.name)||"Uncategorized"}),e.jsx(ut,{children:e.jsx(Er,{checked:b.is_active,onCheckedChange:()=>x(b)})}),e.jsxs(ut,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{n(b),o(!0)},children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>y(b.id),children:e.jsx(gr,{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(xe,{htmlFor:"title",children:"Title"}),e.jsx(De,{id:"title",name:"title",defaultValue:r==null?void 0:r.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"category_id",children:"Category"}),e.jsxs(Bs,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select category"})}),e.jsx(Os,{children:l==null?void 0:l.map(b=>e.jsx(vt,{value:b.id,children:b.name},b.id))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script_text",children:"Script Text"}),e.jsx(vr,{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(xe,{htmlFor:"tags",children:"Tags (comma-separated)"}),e.jsx(De,{id:"tags",name:"tags",defaultValue:((_=r==null?void 0:r.tags)==null?void 0:_.join(", "))||"",placeholder:"birthday, follow-up, thank-you"})]})]}),e.jsxs(En,{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(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function z1s(){const{toast:t}=wa(),[s,r]=S.useState(""),[n,a]=S.useState(!0),[o,l]=S.useState(!1);S.useEffect(()=>{(async()=>{a(!0);try{const{data:u}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();u!=null&&u.value&&r(u.value)}catch(u){console.error("Error fetching settings:",u)}a(!1)})()},[]);const i=async()=>{l(!0);try{await G.from("settings").upsert({key:"mapbox_public_token",value:s.trim()}),t({title:"Mapbox token saved!"})}catch{t({title:"Error saving token",variant:"destructive"})}l(!1)};return n?e.jsx(Pe,{children:e.jsx(Re,{className:"flex justify-center py-8",children:e.jsx(_s,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Da,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(hr,{children:"Configure the map feature for popbys"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"mapbox-token",children:"Mapbox Public Token"}),e.jsx(De,{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(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(Qe,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const B1s=()=>{const[t,s]=S.useState(""),[r,n]=S.useState("grid"),a=_r(),{data:o=[],isLoading:l}=gt({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(Es,{title:"Additional Services",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Additional Services"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Explore our additional services and offerings"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{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(fp,{className:"h-4 w-4"})}),e.jsx(K,{variant:r==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:e.jsx(Dh,{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(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsx(Ns,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(Ns,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ns,{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(Pe,{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($r,{className:"h-8 w-8"})})}),e.jsxs(Re,{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:Kde(d.description)})]})]},d.id))})]})})},$1s=()=>{const{serviceId:t}=co(),s=_r(),{data:r,isLoading:n}=gt({queryKey:["additional-service",t],queryFn:async()=>{const{data:a,error:o}=await G.from("additional_services").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;return a},enabled:!!t});return n?e.jsx(Es,{title:"Loading...",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(Ns,{className:"h-8 w-48"}),e.jsx(Ns,{className:"h-64 w-full rounded-lg"}),e.jsx(Ns,{className:"h-24 w-full"})]})}):r?e.jsx(Es,{title:r.name,children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/additional-services"),className:"gap-2",children:[e.jsx(Fa,{className:"h-4 w-4"}),"Back to Services"]}),e.jsx(Pe,{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($r,{className:"h-16 w-16"})})})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:r.name}),e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(on,{className:"h-4 w-4 mr-1"}),"Published ",ps(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(Es,{title:"Not Found",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center py-12",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground mb-4",children:"Service Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"The service you're looking for doesn't exist or has been removed."}),e.jsxs(K,{onClick:()=>s("/additional-services"),children:[e.jsx(Fa,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},fI=[{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 q1s(){const[t,s]=S.useState(fI[0].id),r=fI.find(n=>n.id===t)||fI[0];return e.jsx(Es,{title:"AI Toolkit",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(fM,{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(Bs,{value:t,onValueChange:s,children:[e.jsx(Rs,{className:"w-full",children:e.jsx(qs,{placeholder:"Select a tool"})}),e.jsx(Os,{children:fI.map(n=>e.jsx(vt,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(ia,{value:t,onValueChange:s,className:"w-full",children:e.jsx(ea,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:fI.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 A7e="agent-os-onboarding-completed",p9=[{icon:Qy,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:Oh,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:lr,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:Ui,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:to,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"]}],U1s=()=>{const[t,s]=S.useState(!1),[r,n]=S.useState(0),[a,o]=S.useState(!1);S.useEffect(()=>{if(!localStorage.getItem(A7e)){const b=setTimeout(()=>s(!0),500);return()=>clearTimeout(b)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):d()},i=()=>{d()},d=()=>{localStorage.setItem(A7e,"true"),s(!1)},u=p9[r],p=u.icon,x=r===p9.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($r,{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(Ir,{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(Jn,{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:p9.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}=Fs();return gt({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})},H1s=()=>{const t=Jt(),{user:s}=Fs();return It({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=cl(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"]}),gn({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{gn({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},G1s=()=>{const t=Jt();return It({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"]}),gn({title:"Snooze cancelled"})},onError:s=>{gn({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},W1s=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function bme({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=S.useState(null),l=H1s(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},d=u=>ps(cl(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(ln,{className:"h-5 w-5"}),"Snooze Touch"]}),e.jsxs(Ir,{children:["Postpone the next scheduled touch for ",n,". Select how long to snooze."]})]}),e.jsx("div",{className:"space-y-3 py-4",children:W1s.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(on,{className:"h-3.5 w-3.5"}),"Until ",d(u.days)]})]},u.days))}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:i,disabled:!a||l.isPending,children:l.isPending?"Snoozing...":"Snooze Touch"})]})]})})}const K1s={Crown:Cm,FileText:fn,Users:lr,Globe:gd,Star:Hn,Phone:Pn,MessageSquare:ki,PenTool:Sb,Video:Tn,Gift:Ui};function Z1s({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=_r(),[d,u]=S.useState("name"),[p,x]=S.useState("asc"),[y,_]=S.useState(null),[b,N]=S.useState(""),w=I=>{d===I?x(O=>O==="asc"?"desc":"asc"):(u(I),x("asc"))},k=S.useMemo(()=>[...t].sort((I,O)=>{var q,$;let V=0;switch(d){case"name":{const U=`${I.contact.first_name} ${I.contact.last_name||""}`.toLowerCase(),se=`${O.contact.first_name} ${O.contact.last_name||""}`.toLowerCase();V=U.localeCompare(se);break}case"relationship_type":V=(I.relationshipTypeName||"").localeCompare(O.relationshipTypeName||"");break;case"action_type":V=(((q=I.actionType)==null?void 0:q.name)||"").localeCompare((($=O.actionType)==null?void 0:$.name)||"");break;case"last_touch":V=(I.monthNumber||0)-(O.monthNumber||0);break}return p==="asc"?V:-V}),[t,d,p]),C=I=>K1s[I||"Phone"]||Pn,E=({field:I,children:O})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>w(I),children:[O,d===I?p==="asc"?e.jsx(du,{className:"ml-2 h-4 w-4"}):e.jsx(Ph,{className:"ml-2 h-4 w-4"}):e.jsx(td,{className:"ml-2 h-4 w-4 opacity-50"})]}),L=(I,O,V)=>{_(I),N(`${O} ${V||""}`.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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{className:"bg-muted/50",children:[e.jsx(Nt,{className:"w-[180px]",children:e.jsx(E,{field:"name",children:"Contact"})}),e.jsx(Nt,{className:"w-[130px]",children:e.jsx(E,{field:"relationship_type",children:"Type"})}),e.jsx(Nt,{className:"w-[120px]",children:e.jsx(E,{field:"action_type",children:"Action"})}),e.jsx(Nt,{className:"w-[130px]",children:"Phone"}),e.jsx(Nt,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(Dn,{children:k.map((I,O)=>{var Y,J,X,ce,ie,ae;const V=I.isSpecialDate,q=I.specialDateType,$=V?q==="birthday"?lh:Mn:C(((Y=I.actionType)==null?void 0:Y.icon)||null),U=I.contact.phone,se=I.contact.email;return e.jsxs(Ms,{className:Rt("hover:bg-muted/50 transition-colors",V&&q==="birthday"&&"bg-pink-50/50 dark:bg-pink-950/20",V&&q==="anniversary"&&"bg-purple-50/50 dark:bg-purple-950/20"),children:[e.jsx(ut,{className:"font-medium",children:e.jsx("div",{children:e.jsxs("button",{onClick:()=>i(`/mission-control/contacts/${I.contact.id}`),className:"truncate max-w-[160px] text-left hover:text-primary hover:underline transition-colors",children:[I.contact.first_name," ",I.contact.last_name]})})}),e.jsx(ut,{children:I.relationshipTypeName?e.jsx(Qe,{variant:"secondary",className:"text-xs",children:I.relationshipTypeName}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ut,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:V?e.jsx(Qe,{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(Qe,{variant:"outline",className:"gap-1",children:[e.jsx($,{className:"h-3 w-3"}),(J=I.actionType)==null?void 0:J.name]})})}),e.jsx(ut,{children:U?e.jsx("span",{className:"text-sm font-mono",children:I.contact.phone}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[U&&e.jsx("a",{href:`tel:${I.contact.phone}`,className:"p-1.5 rounded bg-primary/10 hover:bg-primary/20 text-primary transition-colors",title:"Call",children:e.jsx(Pn,{className:"h-3.5 w-3.5"})}),U&&e.jsx("a",{href:a(I.contact.phone,(X=I.script)==null?void 0:X.script_body,I.contact),className:"p-1.5 rounded bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 transition-colors",title:"Text",children:e.jsx(ki,{className:"h-3.5 w-3.5"})}),se&&(l?e.jsx("button",{onClick:()=>l({id:I.contact.id,first_name:I.contact.first_name,last_name:I.contact.last_name,email:I.contact.email}),className:"p-1.5 rounded bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 transition-colors",title:"Compose Email",children:e.jsx(rr,{className:"h-3.5 w-3.5"})}):e.jsx("a",{href:o(I.contact.email,(ce=I.script)==null?void 0:ce.script_body,(ie=I.script)==null?void 0:ie.email_subject,(ae=I.actionType)==null?void 0:ae.name,I.contact),className:"p-1.5 rounded bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 transition-colors",title:"Email",children:e.jsx(rr,{className:"h-3.5 w-3.5"})})),V&&e.jsxs("button",{onClick:()=>{const oe=`${I.contact.first_name}${I.contact.last_name?" "+I.contact.last_name:""}`,pe=q==="birthday"?"birthday":"home_anniversary",_e=new URLSearchParams({cardType:pe,contactId:I.contact.id,name:oe,...I.contact.address?{address:I.contact.address}:{},...q==="anniversary"&&I.contact.home_anniversary?{date:I.contact.home_anniversary}:{}});i(`/mission-control/card-studio?${_e.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(rr,{className:"h-3.5 w-3.5"}),"Send Card"]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>L(I.contact.id,I.contact.first_name,I.contact.last_name),title:"Snooze",children:e.jsx(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 oe;return s(I.contact.id,I.actionType.id,(oe=I.script)==null?void 0:oe.id)},disabled:n,children:[e.jsx(Qn,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${I.contact.id}-${O}`)})})]})}),e.jsx(bme,{open:!!y,onOpenChange:I=>!I&&_(null),contactId:y||"",contactName:b})]})}function jp(){const{data:t,isLoading:s}=gt({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 Y1s({onSelect:t}){const[s,r]=S.useState(null),{data:n=[],isLoading:a}=gt({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}=gt({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(_s,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):s?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:()=>r(null),className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(xl,{className:"h-3.5 w-3.5"}),"Back to categories"]}),e.jsxs("p",{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx("span",{children:i==null?void 0:i.icon})," ",i==null?void 0:i.name]}),l?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(_s,{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(ui,{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(Qe,{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(Sa,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},d.id))})]})}function ESe(){var a;const{user:t}=Fs(),{data:s,isLoading:r}=gt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,staleTime:60*1e3,queryFn:async()=>{var u,p,x,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:((x=i==null?void 0:i.display_name)==null?void 0:x.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 wme(){const{user:t}=Fs(),s=Jt(),{data:r,isLoading:n}=gt({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=It({mutationFn:async u=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:p,error:x}=await G.from("contact_intake_pages").insert({user_id:t.id,slug:u.toLowerCase().replace(/[^a-z0-9-]/g,"-")}).select().single();if(x)throw x;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=It({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}=gt({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=It({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page. Create your Connect page first.");const{data:p,error:x}=await G.from("contact_intake_tokens").insert({contact_id:u,intake_page_id:r.id}).select("token").single();if(x)throw x;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 X1s=5*1024*1024,gv=50,Q1s=["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 J1s(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function e_s(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 g_(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 T1({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const{user:d}=Fs(),u=Jt(),{isReady:p,settings:x}=ESe(),{intakePage:y}=wme(),_=y?`https://contacts.relevelup.com/${y.slug}`:null,b=!!n&&n.length>0,N=b&&p,w=b?n:r?[r]:[],k=w[0],C=b?Math.ceil(w.length/gv):1,E=b&&w.length>gv,[L,I]=S.useState((k==null?void 0:k.email)||""),[O,V]=S.useState(a),[q,$]=S.useState(o),[U,se]=S.useState(!1),[Y,J]=S.useState(!1),[X,ce]=S.useState([]),[ie,ae]=S.useState(a),[oe,pe]=S.useState(o),[_e,he]=S.useState("composing"),[we,je]=S.useState(0),[Ue,Te]=S.useState(0),[Me,Fe]=S.useState(0),[Le,Ne]=S.useState(0),qe=S.useRef(!1),[ze,ve]=S.useState(null);S.useEffect(()=>{t&&(I((k==null?void 0:k.email)||""),ae(a),pe(o),V(g_(a,k||{first_name:""})),$(g_(o,k||{first_name:""})),J(!a&&!o),ce([]),he("composing"),je(0),Te(0),Fe(0),Ne(0),qe.current=!1,ve(null))},[t,k,a,o]);const dt=async Ke=>{const Ze=Ke.target.files;if(!Ze)return;const Et=X.reduce((Yt,Ps)=>Yt+Ps.size,0),$t=[];for(const Yt of Array.from(Ze)){if(!Q1s.includes(Yt.type)){me.error(`${Yt.name}: Unsupported file type`);continue}if(Et+Yt.size>X1s){me.error("Total attachments exceed 5MB limit");break}try{const Ps=await e_s(Yt);$t.push({name:Yt.name,type:Yt.type,size:Yt.size,data:Ps})}catch{me.error(`Failed to read ${Yt.name}`)}}ce(Yt=>[...Yt,...$t]),Ke.target.value=""},fe=Ke=>{ce(Ze=>Ze.filter((Et,$t)=>$t!==Ke))},Ve=Ke=>{ae(Ke.subject),pe(Ke.body),V(g_(Ke.subject,k||{first_name:""})),$(g_(Ke.body,k||{first_name:""})),J(!1)},Je=Ke=>Ke.split(/\n\n+/).map(Ze=>`

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

`).join(""),at=async Ke=>{const Ze=g_(ie,Ke),Et=g_(oe,Ke),$t=Je(Et);try{if(N){const Yt=(x==null?void 0:x.display_name)||"ReLevelUp",Ps=`${Yt.toLowerCase().replace(/[^a-z]/g,".")}@send.relevelup.com`,zs=`${Yt} <${Ps}>`,{data:Zs,error:Dr}=await G.functions.invoke("ses-send-campaign",{body:{action:"test_send",to:Ke.email,from_email:zs,subject:Ze,body_html:$t,reply_to:(x==null?void 0:x.reply_to_email)||void 0}});if(Dr)throw Dr;if(!(Zs!=null&&Zs.success))throw new Error((Zs==null?void 0:Zs.error)||"Failed to send")}else{const{data:Yt,error:Ps}=await G.functions.invoke("gmail-send",{body:{to:Ke.email,subject:Ze,body:$t,contactId:Ke.id,attachments:X.map(({name:zs,type:Zs,data:Dr})=>({name:zs,type:Zs,data:Dr}))}});if(Ps)throw Ps;if(!(Yt!=null&&Yt.success))throw new Error((Yt==null?void 0:Yt.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:Ze,source:N?"ses_bulk":"sphere_gaps"}),!0}catch(Yt){return console.error("Send error:",Yt),me.error("Failed to send to "+Ke.first_name+": "+(Yt instanceof Error?Yt.message:"Unknown error")),!1}},Ae=()=>{const Ke=we*gv;return w.slice(Ke,Ke+gv)},Ye=async()=>{if(!O||!q){me.error("Please fill in subject and message");return}const Ke=Ae();se(!0),he("sending");let Ze=0,Et=0;for(let Yt=0;YtsetTimeout(zs,150));Te(Yt=>Yt+Ze),Fe(Yt=>Yt+Et),se(!1),u.invalidateQueries({queryKey:["bulk-email-sends"]}),we>=C-1||qe.current?he("all_done"):he("batch_complete")},We=async()=>{if(!O||!q){me.error("Please fill in subject and message");return}if(!b){se(!0);const Ke=await at(k);se(!1),Ke&&(u.invalidateQueries({queryKey:["bulk-email-sends"]}),me.success("Email sent successfully!"),s(!1),i==null||i());return}await Ye()},ot=async()=>{je(Ke=>Ke+1),Ne(0),await new Promise(Ke=>setTimeout(Ke,50)),await Ye()};S.useEffect(()=>{},[we]);const Ge=()=>{if(U){qe.current=!0;return}s(!1),i==null||i()},et=we*gv,ht=Math.min(et+gv,w.length),xt=b&&w.length>0?Math.round((Ue+Me)/w.length*100):0;return e.jsx(fs,{open:t,onOpenChange:Ge,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(rr,{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: ",x==null?void 0:x.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&&_e==="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."]})]}),_e==="sending"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(_s,{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:[Le," of ",Ae().length," in this batch"]})]}),e.jsx(gi,{value:Le/Ae().length*100,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Overall: ",Ue+Me," / ",w.length]}),e.jsxs("span",{children:[Ue," sent • ",Me," failed"]})]}),e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{qe.current=!0},children:"Stop Sending"})]}),_e==="batch_complete"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(Qn,{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:[Ue," sent, ",Me," failed so far"]})]}),e.jsx(gi,{value:xt,className:"h-2"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[w.length-Ue-Me," contacts remaining (",C-we-1," batches left)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:Ge,children:"Done for Now"}),e.jsxs(K,{className:"flex-1 gap-2",onClick:ot,children:[e.jsx(An,{className:"h-4 w-4"}),"Send Next ",Math.min(gv,w.length-ht)," Contacts"]})]})]}),_e==="all_done"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(Qn,{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:[Ue," emails sent successfully",Me>0&&e.jsxs("span",{className:"text-destructive",children:[" • ",Me," failed"]})]})]}),e.jsx(K,{className:"w-full",onClick:Ge,children:"Close"})]}),_e==="composing"&&e.jsxs("div",{className:"space-y-4",children:[Y?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(fn,{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(Y1s,{onSelect:Ve})]}):e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>J(!0),children:[e.jsx(fn,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(wo,{}),!b&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{htmlFor:"gmail-to",children:"To"}),e.jsx(De,{id:"gmail-to",value:L,onChange:Ke=>I(Ke.target.value),placeholder:"recipient@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{htmlFor:"gmail-subject",children:"Subject"}),e.jsx(De,{id:"gmail-subject",value:O,onChange:Ke=>{V(Ke.target.value),ae(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(xe,{htmlFor:"gmail-body",children:"Message"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Qe,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{$(Ke=>Ke+"{{first_name}}"),pe(Ke=>Ke+"{{first_name}}")},children:"{{first_name}}"}),e.jsx(Qe,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{$(Ke=>Ke+"{{last_name}}"),pe(Ke=>Ke+"{{last_name}}")},children:"{{last_name}}"}),_&&e.jsx(Qe,{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: ${_} `;$(Ze=>Ze+Ke),pe(Ze=>Ze+Ke)},title:"Insert your Connect Page link",children:"+ Connect Page"})]})]}),e.jsx(vr,{id:"gmail-body",value:q,onChange:Ke=>{$(Ke.target.value),pe(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:U,children:[e.jsx(lS,{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:dt})]}),X.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:X.map((Ke,Ze)=>e.jsxs(Qe,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(lS,{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:["(",J1s(Ke.size),")"]}),e.jsx("button",{type:"button",onClick:()=>fe(Ze),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Sr,{className:"h-3 w-3"})})]},Ze))})]}),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:()=>{ve(w[0]||null),he("reviewing")},disabled:!O||!q,className:"gap-2",children:["Review Emails",e.jsx(ei,{className:"h-4 w-4"})]}):e.jsxs(K,{onClick:We,disabled:U||!O||!q,className:"gap-2",children:[U?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(An,{className:"h-4 w-4"}),U?"Sending...":"Send Email"]})]})]}),_e==="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."]}),E&&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(xe,{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 ${(ze==null?void 0:ze.id)===Ke.id?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>ve(Ke),children:[Ke.first_name," ",Ke.last_name," — ",Ke.email]},Ke.id))})]}),ze&&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(rr,{className:"h-3.5 w-3.5"}),"Preview for ",ze.first_name," ",ze.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:"})," ",ze.email]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Subject:"})," ",g_(ie,ze)]})]}),e.jsx(wo,{}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-background rounded p-2.5 max-h-40 overflow-y-auto border",children:g_(oe,ze)})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>{he("composing"),ve(null)},children:[e.jsx(Fa,{className:"h-4 w-4 mr-1"}),"Back to Edit"]}),e.jsxs(K,{onClick:We,disabled:U,className:"gap-2",children:[U?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(An,{className:"h-4 w-4"}),E?`Send First ${gv}`:`Send to ${w.length}`]})]})]})]})})}function t_s(){const t=_r(),{data:s}=qh(),{data:r}=UR(),n=the(),{isGmailConnected:a,gmailEmail:o}=jp(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,x]=S.useState(new Set),y=Em(new Date),_=cl(y,30),b=L=>{if(!L)return null;const I=L.split(/[-/T]/);if(I.length<3)return null;const O=parseInt(I[1],10)-1,V=parseInt(I[2],10);return isNaN(O)||isNaN(V)?null:new Date(y.getFullYear(),O,V)},N=S.useMemo(()=>{if(!s)return[];const L=[];for(const I of s){if(I.birthday){const O=b(I.birthday);O&&(rl(O,y)||HS(O,y)&&GS(O,_))&&L.push({contact:I,type:"birthday",date:O,daysUntil:tf(O,y),dateStr:I.birthday})}if(I.home_anniversary){const O=b(I.home_anniversary);O&&(rl(O,y)||HS(O,y)&&GS(O,_))&&L.push({contact:I,type:"anniversary",date:O,daysUntil:tf(O,y),dateStr:I.home_anniversary})}}return L.sort((I,O)=>I.daysUntil-O.daysUntil),L},[s]),w=async L=>{const I=(r==null?void 0:r.find(O=>O.name==="Call"))||(r==null?void 0:r[0]);if(I)try{await n.mutateAsync({contactId:L.contact.id,actionTypeId:I.id,notes:`${L.type==="birthday"?"Birthday":"Home Anniversary"} outreach`}),x(O=>new Set(O).add(`${L.contact.id}-${L.type}`)),gn({title:"Touch logged!",description:`Logged outreach for ${L.contact.first_name}`})}catch{gn({title:"Error",description:"Failed to log touch",variant:"destructive"})}},k=L=>{const I=`${L.contact.first_name}${L.contact.last_name?" "+L.contact.last_name:""}`,O=L.type==="birthday"?"birthday":"home_anniversary",V=new URLSearchParams({cardType:O,contactId:L.contact.id,name:I,...L.contact.address?{address:L.contact.address}:{},...L.type==="anniversary"&&L.dateStr?{date:L.dateStr}:{}});t(`/mission-control/card-studio?${V.toString()}`)},C=L=>L===0?"Today!":L===1?"Tomorrow":`${L} days`,E=L=>L===0?"bg-red-500/15 text-red-600 dark:text-red-400 border-red-500/30":L<=3?"bg-amber-500/15 text-amber-600 dark:text-amber-400 border-amber-500/30":L<=7?"bg-blue-500/15 text-blue-600 dark:text-blue-400 border-blue-500/30":"bg-muted text-muted-foreground border-border";return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(xd,{className:"h-5 w-5 text-primary"}),"Upcoming Milestones",e.jsx(Qe,{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(Re,{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((L,I)=>{var $,U;const O=`${L.contact.id}-${L.type}`,V=p.has(O),q=`${(($=L.contact.first_name)==null?void 0:$[0])||""}${((U=L.contact.last_name)==null?void 0:U[0])||""}`.toUpperCase();return e.jsxs("div",{className:Rt("p-3 rounded-lg border transition-colors",L.daysUntil===0&&L.type==="birthday"?"bg-pink-500/10 border-pink-500/30 dark:bg-pink-900/20 dark:border-pink-800/40":L.daysUntil===0&&L.type==="anniversary"?"bg-blue-500/10 border-blue-500/30 dark:bg-blue-900/20 dark:border-blue-800/40":L.type==="birthday"?"bg-pink-50/60 border-pink-200/60 hover:bg-pink-100/60 dark:bg-pink-950/20 dark:border-pink-900/30 dark:hover:bg-pink-950/30":"bg-blue-50/60 border-blue-200/60 hover:bg-blue-100/60 dark:bg-blue-950/20 dark:border-blue-900/30 dark:hover:bg-blue-950/30"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(vn,{className:Rt("h-10 w-10",L.type==="birthday"?"ring-2 ring-pink-300/50 dark:ring-pink-700/50":"ring-2 ring-blue-300/50 dark:ring-blue-700/50"),children:e.jsx(_n,{className:Rt("text-xs font-medium",L.type==="birthday"?"bg-pink-100 text-pink-700 dark:bg-pink-900/40 dark:text-pink-300":"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"),children:q})}),e.jsx("span",{className:"absolute -bottom-1.5 -right-1.5 text-base leading-none drop-shadow-sm",children:L.type==="birthday"?"🎂":"🏠"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[L.contact.first_name," ",L.contact.last_name||""]}),e.jsx(Qe,{variant:"outline",className:Rt("text-[10px] shrink-0 whitespace-nowrap",E(L.daysUntil)),children:C(L.daysUntil)})]}),e.jsxs("div",{className:Rt("text-xs flex items-center gap-1.5 mt-0.5",L.type==="birthday"?"text-pink-600/80 dark:text-pink-400/80":"text-blue-600/80 dark:text-blue-400/80"),children:[L.type==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(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:ps(L.date,"MMM d")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 pl-[52px]",children:[L.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Call",asChild:!0,children:e.jsx("a",{href:`tel:${L.contact.phone}`,children:e.jsx(Pn,{className:"h-3.5 w-3.5"})})}),L.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Text",asChild:!0,children:e.jsx("a",{href:`sms:${L.contact.phone}`,children:e.jsx(ki,{className:"h-3.5 w-3.5"})})}),L.contact.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Email",onClick:()=>{a?(i({id:L.contact.id,first_name:L.contact.first_name,last_name:L.contact.last_name,email:L.contact.email}),u(!0)):window.location.href=`mailto:${L.contact.email}`},children:e.jsx(rr,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Record video",onClick:()=>t(`/mission-control/video/record?contactId=${L.contact.id}`),children:e.jsx(Tn,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"ghost",size:"sm",className:Rt("h-7 px-2 gap-1 text-xs",L.type==="birthday"?"text-pink-600 hover:text-pink-700 dark:text-pink-400":"text-blue-600 hover:text-blue-700 dark:text-blue-400"),title:`Send ${L.type==="birthday"?"birthday":"anniversary"} card`,onClick:()=>k(L),children:[e.jsx($r,{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",V&&"text-green-600"),title:"Log a touch",disabled:V||n.isPending,onClick:()=>w(L),children:e.jsx(Qn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"View contact",onClick:()=>t(`/mission-control/contacts/${L.contact.id}`),children:e.jsx(wn,{className:"h-3.5 w-3.5"})})]})]},`${O}-${I}`)})]})]}),a&&l&&e.jsx(T1,{open:d,onOpenChange:u,contact:l,gmailEmail:o})]})}function s_s(t){const[s,r]=S.useState([]),[n,a]=S.useState(!1),{data:o,isLoading:l}=gt({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 x=p.map(b=>b.contact_id).filter(Boolean);let y={};if(x.length>0){const{data:b}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",x);(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(k=>k.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});S.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}`},x=>{x.eventType==="INSERT"?r(y=>y.find(b=>b.id===x.new.id)?y:[x.new,...y]):x.eventType==="UPDATE"?r(y=>y.map(_=>_.id===x.new.id?{..._,...x.new}:_)):x.eventType==="DELETE"&&r(y=>y.filter(_=>_.id!==x.old.id))}).subscribe(x=>{x==="SUBSCRIBED"&&a(!0)});return()=>{G.removeChannel(p)}},[t]);const i=n&&s.length>0?r_s([...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 r_s(t){const s=new Set;return t.filter(r=>s.has(r.id)?!1:(s.add(r.id),!0))}const n_s={property_view:{label:"Viewed",icon:wn,color:"text-blue-500",bgColor:"bg-blue-500/10"},new_lead:{label:"New Lead",icon:al,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 a_s(){const{user:t}=Fs(),s=_r(),{isGmailConnected:r,gmailEmail:n}=jp(),{leadSite:a}=ZA(),{count:o}=s_s(a==null?void 0:a.id),[l,i]=S.useState(!1),[d,u]=S.useState(null),{data:p,isLoading:x}=gt({queryKey:["lead-site-activity",t==null?void 0:t.id],queryFn:async()=>{const{data:k,error:C}=await G.rpc("get_lead_site_activity",{_user_id:t.id});if(C)throw C;return k},enabled:!!t,refetchInterval:6e4});if(x||!(p!=null&&p.has_site))return null;const y=(p.activities||[]).filter(k=>k.visitor_name&&k.visitor_name!=="Site Visitor"),_=y.filter(k=>k.activity_type==="new_lead"),b=(p.activities||[]).filter(k=>k.activity_type==="property_view").length,N=(p.activities||[]).filter(k=>k.activity_type==="saved_listing").length,w=k=>{if(k.visitor_email)if(r){const C=(k.visitor_name||"").split(" ");u({id:k.contact_id||"",first_name:C[0]||"",last_name:C.slice(1).join(" ")||null,email:k.visitor_email}),i(!0)}else window.location.href=`mailto:${k.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(ei,{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(al,{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(wn,{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((k,C)=>{const E=n_s[k.activity_type],L=E.icon,I=gl(new Date(k.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 ${E.bgColor}`,children:e.jsx(L,{className:`h-3.5 w-3.5 ${E.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:()=>{k.contact_id&&s(`/mission-control/contacts/${k.contact_id}`)},children:k.visitor_name}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:E.label}),k.mls_number&&e.jsxs("span",{children:["· MLS# ",k.mls_number]}),k.lead_type&&e.jsxs("span",{children:["· ",k.lead_type]}),e.jsxs("span",{children:["· ",I]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[k.visitor_email&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>w(k),children:e.jsx(rr,{className:"h-3.5 w-3.5"})}),k.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:${k.visitor_phone}`,children:e.jsx(Pn,{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:${k.visitor_phone}`,children:e.jsx(ki,{className:"h-3.5 w-3.5"})})]}),k.contact_id&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>s(`/mission-control/contacts/${k.contact_id}`),children:e.jsx(Sa,{className:"h-3.5 w-3.5"})})]})]},`${k.activity_type}-${k.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(ei,{className:"h-3.5 w-3.5 ml-1"})]})]}):e.jsx(Pe,{children:e.jsxs(Re,{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(ei,{className:"h-3.5 w-3.5 ml-1"})]})]})}),r&&d&&e.jsx(T1,{open:l,onOpenChange:i,contact:d,gmailEmail:n})]})}const E7e={Crown:Cm,FileText:fn,Users:lr,Globe:gd,Star:Hn,Phone:Pn,MessageSquare:ki,PenTool:Sb,Video:Tn,Gift:Ui},i_s={"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 o_s(){var We,ot,Ge,et,ht,xt;const t=_r(),{user:s}=Fs(),{data:r}=jf(),{data:n}=hXe(),{data:a}=qh(),{data:o}=UR(),{data:l}=gXe(),i=mLt(),d=rke(),u=uLt(90),p=the(),[x,y]=S.useState(null),[_,b]=S.useState(null),[N,w]=S.useState(!1),[k,C]=S.useState(""),[E,L]=S.useState(!1),[I,O]=S.useState(""),[V,q]=S.useState(vle()),[$,U]=S.useState("cards"),[se,Y]=S.useState(!1),[J,X]=S.useState(null),[ce,ie]=S.useState(null),[ae,oe]=S.useState(""),{isGmailConnected:pe,gmailEmail:_e}=jp(),he=()=>{const Ke=parseInt(I,10);if(isNaN(Ke)||Ke<1){gn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}q(Ke),xXe(Ke),L(!1),gn({title:"Goal updated",description:`Weekly touch goal set to ${Ke}`})},we=()=>{O(V.toString()),L(!0)};S.useEffect(()=>{(async()=>{if(!(s!=null&&s.id))return;const{data:Ze}=await G.from("profiles").select("name").eq("id",s.id).single();Ze!=null&&Ze.name&&C(Ze.name.split(" ")[0])})()},[s==null?void 0:s.id]),S.useEffect(()=>{i.mutate()},[]);const je=Em(new Date),Ue=cl(je,7),Te=Ke=>{if(!Ke)return null;const Ze=Ke.split(/[-/T]/);if(Ze.length<3)return null;const Et=parseInt(Ze[1],10)-1,$t=parseInt(Ze[2],10);return isNaN(Et)||isNaN($t)?null:new Date(je.getFullYear(),Et,$t)},Me=(a==null?void 0:a.filter(Ke=>{const Ze=Te(Ke.birthday),Et=Te(Ke.home_anniversary);return Ze&&rl(Ze,je)||Et&&rl(Et,je)}))||[];a!=null&&a.filter(Ke=>{if(!Ke.birthday&&!Ke.home_anniversary)return!1;const Ze=Et=>{if(!Et)return!1;const $t=Te(Et);return $t?HS($t,je)&&GS($t,Ue):!1};return Ze(Ke.birthday)||Ze(Ke.home_anniversary)}).slice(0,5);const Fe=[],Le=(o==null?void 0:o.find(Ke=>Ke.name==="Call"))||(o==null?void 0:o[0]);for(const Ke of Me){const Ze=Te(Ke.birthday),Et=Te(Ke.home_anniversary),$t=Ze&&rl(Ze,je),Yt=Et&&rl(Et,je);$t&&Fe.push({contact:Ke,actionType:Le||{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:((Ge=(ot=(We=Ke.tags)==null?void 0:We[0])==null?void 0:ot.relationship_type)==null?void 0:Ge.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),Yt&&Fe.push({contact:Ke,actionType:Le||{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:((xt=(ht=(et=Ke.tags)==null?void 0:et[0])==null?void 0:ht.relationship_type)==null?void 0:xt.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const qe=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((Ke,Ze)=>{var $t,Yt,Ps;const Et=o==null?void 0:o[Ze%((o==null?void 0:o.length)||1)];return Et?{contact:Ke,actionType:Et,planName:"Quick Touch",relationshipTypeName:((Ps=(Yt=($t=Ke.tags)==null?void 0:$t[0])==null?void 0:Yt.relationship_type)==null?void 0:Ps.name)||"",monthNumber:0}:null}).filter(Boolean))||[],ze=[...Fe,...qe],ve=async(Ke,Ze,Et)=>{await p.mutateAsync({contactId:Ke,actionTypeId:Ze,scriptUsedId:Et}),w(!1),b(null)},dt=Ke=>{Ke.script?(b(Ke),w(!0)):ve(Ke.contact.id,Ke.actionType.id)},fe=Ke=>E7e[Ke||"Phone"]||Pn,Ve=Ke=>E7e[Ke||"Users"]||lr,Je=(Ke,Ze)=>Ke.replace(/\{\{FirstName\}\}/g,Ze.first_name).replace(/\{\{LastName\}\}/g,Ze.last_name||"").replace(/\{\{AgentName\}\}/g,k||"there"),at=(Ke,Ze)=>({Call:`Thinking of you, ${Ze}!`,Text:`Quick hello, ${Ze}`,Email:`Checking in, ${Ze}`,"Handwritten Note":`A note for ${Ze}`,Video:`Video message for ${Ze}`,Gift:`Something special for you, ${Ze}`})[Ke]||`Hello ${Ze}!`,Ae=(Ke,Ze,Et)=>{const $t=`sms:${Ke}`;if(Ze&&Et){const Yt=Je(Ze,Et);return`${$t}?body=${encodeURIComponent(Yt)}`}return $t},Ye=(Ke,Ze,Et,$t,Yt)=>{const Ps=`mailto:${Ke}`,zs=[];if(Yt){const Zs=Et||at($t||"Email",Yt.first_name);if(zs.push(`subject=${encodeURIComponent(Zs)}`),Ze){const Dr=Je(Ze,Yt);zs.push(`body=${encodeURIComponent(Dr)}`)}}return zs.length>0?`${Ps}?${zs.join("&")}`:Ps};return e.jsxs(e.Fragment,{children:[e.jsxs(Es,{title:"Mission Control",description:"Your relationship-first contact system",children:[e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Mission Control"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsx(a_s,{}),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 Ze=Ve(Ke.icon),Et=(n==null?void 0:n[Ke.id])||0,$t=x===Ke.id,Yt=i_s[Ke.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{$t?(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 ${$t?Yt:"bg-card hover:bg-accent"} `,children:[e.jsx(Ze,{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 ${$t?"opacity-90":"text-muted-foreground"}`,children:[Et," 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(tu,{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(Sa,{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(Qe,{variant:"outline",className:"gap-1",children:[e.jsx($r,{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:()=>U("cards"),title:"Card view",children:e.jsx(fp,{className:"h-4 w-4"})}),e.jsx(K,{variant:$==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>U("table"),title:"Table view",children:e.jsx(Dh,{className:"h-4 w-4"})})]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-4",children:ze.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(Z1s,{actions:ze,onMarkComplete:ve,onViewScript:dt,isLoading:p.isPending,buildSmsLink:Ae,buildEmailLink:Ye,onGmailCompose:pe?Ke=>{X(Ke),Y(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[ze.map((Ke,Ze)=>{var zt,$s,kr,Xs,ir,Or,Vn;const Et=Ke.isSpecialDate,$t=Ke.specialDateType,Yt=Et?$t==="birthday"?lh:Mn:fe(((zt=Ke.actionType)==null?void 0:zt.icon)||null),Ps=Ke.contact.phone,zs=Ke.contact.email,Zs=Et?$t==="birthday"?"#EC4899":"#8B5CF6":(($s=Ke.actionType)==null?void 0:$s.color)||"#3B82F6",Dr=Et?$t==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(kr=Ke.actionType)==null?void 0:kr.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${Et?"ring-2 ring-offset-2":""}`,style:Et?{"--tw-ring-color":Zs}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:Zs},children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:Dr})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>t(`/mission-control/contacts/${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:[Ps&&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(Pn,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:Ae(Ke.contact.phone,(Xs=Ke.script)==null?void 0:Xs.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(ki,{className:"h-3 w-3"}),"Text"]})]}),zs&&(pe?e.jsxs("button",{onClick:()=>{X({id:Ke.contact.id,first_name:Ke.contact.first_name,last_name:Ke.contact.last_name,email:Ke.contact.email}),Y(!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(rr,{className:"h-3 w-3"}),"Email"]}):e.jsxs("a",{href:Ye(Ke.contact.email,(ir=Ke.script)==null?void 0:ir.script_body,(Or=Ke.script)==null?void 0:Or.email_subject,(Vn=Ke.actionType)==null?void 0:Vn.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(rr,{className:"h-3 w-3"}),"Email"]}))]}),Et&&e.jsxs("button",{onClick:()=>{const Qr=`${Ke.contact.first_name}${Ke.contact.last_name?" "+Ke.contact.last_name:""}`,Gr=$t==="birthday"?"birthday":"home_anniversary",tr=new URLSearchParams({cardType:Gr,contactId:Ke.contact.id,name:Qr,...Ke.contact.address?{address:Ke.contact.address}:{},...$t==="anniversary"&&Ke.contact.home_anniversary?{date:Ke.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${tr.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(rr,{className:"h-3 w-3"}),"Send ",$t==="birthday"?"Birthday":"Anniversary"," Card"]}),!Ps&&!zs&&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(Qe,{variant:"secondary",className:"text-xs",children:Ke.relationshipTypeName}),Ke.monthNumber>0&&e.jsxs(Qe,{variant:"outline",className:"text-xs",children:["Month ",Ke.monthNumber]})]}),Ke.script&&e.jsx(K,{size:"sm",variant:"outline",className:"w-full",onClick:()=>dt(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:()=>{ie(Ke.contact.id),oe(`${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 Qr;return ve(Ke.contact.id,Ke.actionType.id,(Qr=Ke.script)==null?void 0:Qr.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]},Ke.contact.id+Ze)}),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(ix,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(jd,{children:e.jsx(va,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ot,{className:"text-lg",children:"Momentum"}),e.jsxs(fs,{open:E,onOpenChange:L,children:[e.jsx(pi,{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(ko,{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(Ir,{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(xe,{htmlFor:"weekly-goal-ic",children:"Weekly touch goal"}),e.jsx(De,{id:"weekly-goal-ic",type:"number",min:"1",value:I,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(Re,{className:"space-y-4",children:[e.jsx(gi,{value:Math.min(d.actionsThisWeek/V*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," / ",V]}),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(ln,{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(Sa,{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(PXe,{}),e.jsx(t_s,{})]})]}),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:Je(_.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 ve(_.contact.id,_.actionType.id,(Ke=_.script)==null?void 0:Ke.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(U1s,{})]}),pe&&J&&e.jsx(T1,{open:se,onOpenChange:Y,contact:J,gmailEmail:_e}),e.jsx(bme,{open:!!ce,onOpenChange:Ke=>!Ke&&ie(null),contactId:ce||"",contactName:ae})]})}var Sat="Toggle",PSe=S.forwardRef((t,s)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...o}=t,[l,i]=$u({prop:r,onChange:a,defaultProp:n??!1,caller:Sat});return e.jsx(Yr.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":t.disabled?"":void 0,...o,ref:s,onClick:Cr(t.onClick,()=>{t.disabled||i(!l)})})});PSe.displayName=Sat;var Cat=PSe,kw="ToggleGroup",[Mat,HTs]=$c(kw,[hw]),Tat=hw(),ISe=ft.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(l_s,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(c_s,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${kw}\``)});ISe.displayName=kw;var[Aat,Eat]=Mat(kw),l_s=ft.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=$u({prop:r,defaultProp:n??"",onChange:a,caller:kw});return e.jsx(Aat,{scope:t.__scopeToggleGroup,type:"single",value:ft.useMemo(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:ft.useCallback(()=>i(""),[i]),children:e.jsx(Pat,{...o,ref:s})})}),c_s=ft.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=$u({prop:r,defaultProp:n??[],onChange:a,caller:kw}),d=ft.useCallback(p=>i((x=[])=>[...x,p]),[i]),u=ft.useCallback(p=>i((x=[])=>x.filter(y=>y!==p)),[i]);return e.jsx(Aat,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:d,onItemDeactivate:u,children:e.jsx(Pat,{...o,ref:s})})});ISe.displayName=kw;var[d_s,u_s]=Mat(kw),Pat=ft.forwardRef((t,s)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:o,dir:l,loop:i=!0,...d}=t,u=Tat(r),p=uw(l),x={role:"group",dir:p,...d};return e.jsx(d_s,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(uue,{asChild:!0,...u,orientation:o,dir:p,loop:i,children:e.jsx(Yr.div,{...x,ref:s})}):e.jsx(Yr.div,{...x,ref:s})})}),yde="ToggleGroupItem",Iat=ft.forwardRef((t,s)=>{const r=Eat(yde,t.__scopeToggleGroup),n=u_s(yde,t.__scopeToggleGroup),a=Tat(t.__scopeToggleGroup),o=r.value.includes(t.value),l=n.disabled||t.disabled,i={...t,pressed:o,disabled:l},d=ft.useRef(null);return n.rovingFocus?e.jsx(hue,{asChild:!0,...a,focusable:!l,active:o,ref:d,children:e.jsx(P7e,{...i,ref:s})}):e.jsx(P7e,{...i,ref:s})});Iat.displayName=yde;var P7e=ft.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=Eat(yde,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(PSe,{...i,...a,ref:s,onPressedChange:d=>{d?o.onItemActivate(n):o.onItemDeactivate(n)}})}),Lat=ISe,Dat=Iat;const Rat=gC("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"}}),h_s=S.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(Cat,{ref:a,className:Rt(Rat({variant:s,size:r,className:t})),...n}));h_s.displayName=Cat.displayName;const Oat=S.createContext({size:"default",variant:"default"}),Fat=S.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(Lat,{ref:o,className:Rt("flex items-center justify-center gap-1",t),...a,children:e.jsx(Oat.Provider,{value:{variant:s,size:r},children:n})}));Fat.displayName=Lat.displayName;const zat=S.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=S.useContext(Oat);return e.jsx(Dat,{ref:o,className:Rt(Rat({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});zat.displayName=Dat.displayName;const m_s=[{value:"bidirectional",label:"Two-Way",icon:td,tooltip:"Sync contacts in both directions"},{value:"push_only",label:"Push Only",icon:du,tooltip:"Only push Agent OS → BoldTrail"},{value:"pull_only",label:"Pull Only",icon:Ph,tooltip:"Only pull BoldTrail → Agent OS"}];function kwe({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(Fat,{type:"single",value:t,onValueChange:a=>{a&&s(a)},className:"justify-start",children:m_s.map(a=>e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:e.jsxs(zat,{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(Cl,{children:a.tooltip})]},a.value))})]})}function p_s(){const t=Jt(),[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(null),[x,y]=S.useState(null),[_,b]=S.useState(0),N=S.useRef(!1),{data:w}=gt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:$,error:U}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(U)throw U;return $}}),k=(w==null?void 0:w.sync_direction)||"bidirectional",C=u??k,E=It({mutationFn:async()=>{const{data:$,error:U}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(U)throw U;if($!=null&&$.error)throw new Error($.error);return $},onSuccess:$=>{p(null),a($),r(!0)},onError:$=>{me.error($.message||"Failed to generate sync preview")}}),L=It({mutationFn:async()=>{N.current=!1,y("Initializing sync..."),b(5);const{data:$,error:U}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:C}});if(U)throw U;if($!=null&&$.error)throw new Error($.error);const se=$;let Y=se.sync_log_id,J=se.next_phase,X=se.next_offset;const ce=se.push_total||0,ie=se.pull_total||0,ae=se.update_total||0,oe=ce+ie+ae;let pe=0,_e=0,he=0;for(;J!=="finalize"&&!N.current;){J==="push"?(y(`Pushing contacts to BoldTrail... (${pe}/${ce})`),b(oe>0?pe/oe*90:0)):J==="pull"?(y(`Pulling contacts from BoldTrail... (${_e}/${ie})`),b(oe>0?(ce+_e)/oe*90:0)):J==="update"&&(y(`Updating existing contacts... (${he}/${ae})`),b(oe>0?(ce+ie+he)/oe*90:0));const{data:Ue,error:Te}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:J,offset:X,sync_log_id:Y,sync_direction:C}});if(Te)throw Te;if(Ue!=null&&Ue.error)throw new Error(Ue.error);const Me=Ue;pe+=Me.chunk_pushed||0,_e+=Me.chunk_pulled||0,he+=Me.chunk_updated||0,Me.progress&&y(Me.progress),J=Me.next_phase,X=Me.next_offset}y("Finalizing sync..."),b(95);const{data:we,error:je}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:Y,sync_direction:C}});if(je)throw je;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 U=[`Pushed ${$.contacts_pushed||0}`,`pulled ${$.contacts_pulled||0}`,`updated ${$.contacts_updated||0}`,`skipped ${$.contacts_skipped||0} duplicates`];me.success(`Sync complete! ${U.join(", ")}.`)},onError:$=>{y(null),b(0),me.error($.message||"Sync failed")}});if(!(w!=null&&w.connected))return null;const I=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,V=(n==null?void 0:n.to_update)??0,q=I>0||O>0||V>0;return e.jsxs(e.Fragment,{children:[e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",onClick:()=>E.mutate(),disabled:E.isPending,className:"shrink-0",children:E.isPending?e.jsx(oo,{className:"h-4 w-4 animate-spin"}):e.jsx(td,{className:"h-4 w-4 text-emerald-600"})})}),e.jsx(Cl,{children:"Sync with BoldTrail"})]}),e.jsx(fs,{open:s,onOpenChange:$=>{L.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(Ir,{children:"Review what will happen when you sync your contacts."})]}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(kwe,{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:I}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(du,{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(Ph,{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:V}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(PM,{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(lr,{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"]}),V>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(PM,{className:"h-3 w-3 inline mr-1"}),V," contacts have missing fields that will be filled from the other system"]}),I>0&&e.jsxs(of,{open:o,onOpenChange:l,children:[e.jsx(lf,{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(du,{className:"h-3 w-3 text-emerald-600"}),I," contacts to push to BoldTrail"]}),e.jsx(Oi,{className:`h-3 w-3 transition-transform ${o?"rotate-180":""}`})]})}),e.jsx(cf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.push_preview.map(($,U)=>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})]},U)),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(of,{open:i,onOpenChange:d,children:[e.jsx(lf,{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(Ph,{className:"h-3 w-3 text-blue-600"}),O," contacts to pull from BoldTrail"]}),e.jsx(Oi,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})}),e.jsx(cf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.pull_preview.map(($,U)=>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})]},U)),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&&!L.isPending&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer or update."}),L.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(gi,{value:_||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:x||"Sync in progress..."})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),disabled:L.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>L.mutate(),disabled:L.isPending||!q,className:"gap-2",children:[L.isPending?e.jsx(oo,{className:"h-4 w-4 animate-spin"}):e.jsx(td,{className:"h-4 w-4"}),L.isPending?"Syncing...":"Sync Now"]})]})]})]})})]})}const f_s=()=>{const{user:t}=Fs();return gt({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})},jme=t=>{const{user:s}=Fs();return gt({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})},LSe=()=>{const{user:t}=Fs();return gt({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})},Bat=()=>{const{user:t}=Fs();return gt({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})},x_s=()=>{const{data:t}=qh();jf();const{data:s}=jme(),{data:r}=Bat(),{data:n}=LSe(),a=new Map;s==null||s.forEach(u=>{const p=a.get(u.contact_id);(!p||new Date(u.completed_at)>new Date(p))&&a.set(u.contact_id,u.completed_at)});const o=new Map;n==null||n.forEach(u=>o.set(u.relationship_type_id,u.frequency_days));const l=new Map;r==null||r.filter(u=>u.is_active).forEach(u=>{l.set(u.contact_id,u.frequency_days)});const i=Em(new Date);return(t||[]).map(u=>{let p=90;if(l.has(u.id))p=l.get(u.id);else if(u.tags&&u.tags.length>0){const N=u.tags.map(w=>o.get(w.relationship_type_id)).filter(w=>w!==void 0);N.length>0&&(p=Math.min(...N))}const x=a.get(u.id)||null,y=x?Bg(i,Em(new Date(x))):null,_=y===null||y>=p,b=_&&y!==null?y-p:0;return{...u,lastPopby:x,daysSinceLastPopby:y,frequencyDays:p,isDue:_,daysOverdue:b}}).sort((u,p)=>p.daysOverdue-u.daysOverdue)},$at=()=>x_s().filter(s=>s.isDue),g_s=()=>{const t=Jt(),{user:s}=Fs();return It({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"]}),gn({title:"Popby item created!"})},onError:r=>{gn({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},y_s=()=>{const t=Jt(),{user:s}=Fs();return It({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"]}),gn({title:"Popby logged!"})},onError:r=>{gn({title:"Error logging popby",description:r.message,variant:"destructive"})}})},v_s=()=>{const t=Jt(),{user:s}=Fs();return It({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"]}),gn({title:"Frequency updated!"})},onError:r=>{gn({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},__s=()=>{const{data:t}=jme(30),s=$at(),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 b_s(){const{user:t}=Fs();return gt({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 qat(t){const{data:s}=b_s(),{data:r}=Bat(),{data:n}=LSe(),{data:a}=V1s();return S.useMemo(()=>{const o=a==null?void 0:a.find(w=>w.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=Em(new Date);if(l&&!GS(l,i))return{nextTouchDate:l,daysUntil:Bg(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const u=((s==null?void 0:s.filter(w=>w.contact_id===t.id))||[]).sort((w,k)=>new Date(k.completed_at).getTime()-new Date(w.completed_at).getTime())[0],p=u?new Date(u.completed_at):null;let x=90;const y=r==null?void 0:r.find(w=>w.contact_id===t.id&&w.is_active);if(y)x=y.frequency_days;else if(t.tags&&t.tags.length>0){const w=t.tags.map(k=>{const C=n==null?void 0:n.find(E=>E.relationship_type_id===k.relationship_type_id);return C==null?void 0:C.frequency_days}).filter(k=>k!==void 0);w.length>0&&(x=Math.min(...w))}if(!p)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:x,lastTouchDate:null,snoozedUntil:null};const _=cl(Em(p),x),b=Bg(_,i);let N;return b<0?N="overdue":b<=7?N="due-soon":N="on-track",{nextTouchDate:_,daysUntil:b,status:N,frequencyDays:x,lastTouchDate:p,snoozedUntil:null}},[t,s,r,n,a])}function Swe({contact:t}){const s=qat(t),n=(()=>{switch(s.status){case"overdue":return{variant:"destructive",icon:Lo,text:`${Math.abs(s.daysUntil)} days overdue`,className:""};case"due-soon":return{variant:"secondary",icon:ln,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:Qn,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 ${ps(s.snoozedUntil,"MMM d")}`,className:"bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300"};case"never-touched":return{variant:"outline",icon:on,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(Qe,{variant:n.variant,className:Rt("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function w_s({contact:t,onLogTouch:s,onSnooze:r}){const n=qat(t),a=G1s(),[o,l]=S.useState(!1),i=()=>{switch(n.status){case"overdue":return"text-destructive";case"due-soon":return"text-amber-600 dark:text-amber-400";case"on-track":return"text-emerald-600 dark:text-emerald-400";case"snoozed":return"text-slate-600 dark:text-slate-400";case"never-touched":return"text-muted-foreground"}},d=()=>{switch(n.status){case"overdue":return e.jsx(Lo,{className:"h-5 w-5 text-destructive"});case"due-soon":return e.jsx(ln,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return e.jsx(Qn,{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(on,{className:"h-5 w-5 text-muted-foreground"})}},u=()=>{switch(n.status){case"overdue":return`${Math.abs(n.daysUntil)} days overdue`;case"due-soon":return n.daysUntil===0?"Due today!":`Due in ${n.daysUntil} days`;case"on-track":return`On track - ${n.daysUntil} days remaining`;case"snoozed":return`Snoozed for ${n.daysUntil} more days`;case"never-touched":return"No touches logged yet"}},p=async()=>{await a.mutateAsync(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Next Touch"]})}),e.jsxs(Re,{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:"})," ",ps(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:"})," ",ps(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:"})," ",ps(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(bme,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const i0e=768;function vE(){const[t,s]=S.useState(void 0);return S.useEffect(()=>{const r=window.matchMedia(`(max-width: ${i0e-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}function j_s(){const{user:t}=Fs(),{hasLeadSite:s,leadSite:r}=ZA(),{data:n,isLoading:a}=gt({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 N_s={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"}},k_s={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 j8({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=N_s[t.status],l=k_s[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(N1,{children:e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:i}),e.jsx(Cl,{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(gi,{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 S_s=[{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}],f9=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]},C_s=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=Fs(),{toast:o}=wa(),l=S.useRef(null),[i,d]=S.useState("upload"),[u,p]=S.useState([]),[x,y]=S.useState([]),[_,b]=S.useState({}),[N,w]=S.useState([]),[k,C]=S.useState([]),[E,L]=S.useState(!1),[I,O]=S.useState(null),V=()=>{d("upload"),p([]),y([]),b({}),w([]),C([]),O(null),l.current&&(l.current.value="")},q=()=>{V(),s(!1)},$=_e=>{const he=_e.split(` `).map(Te=>Te.trim()).filter(Te=>Te);if(he.length===0)return{headers:[],data:[]};const we=Te=>{const Me=[];let Fe="",Le=!1;for(let Ne=0;Ne{var je;const he=(je=_e.target.files)==null?void 0:je[0];if(!he)return;const we=new FileReader;we.onload=Ue=>{var Ne;const Te=(Ne=Ue.target)==null?void 0:Ne.result,{headers:Me,data:Fe}=$(Te);if(Me.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}p(Me),y(Fe);const Le={};Me.forEach(qe=>{const ze=qe.toLowerCase().replace(/[_\s-]/g,"");ze.includes("firstname")||ze==="first"?Le.first_name=qe:ze.includes("lastname")||ze==="last"?Le.last_name=qe:ze.includes("spouse")&&ze.includes("email")?Le.spouse_email=qe:ze.includes("spouse")||ze.includes("partner")?Le.spouse_name=qe:ze.includes("email")?Le.email=qe:ze.includes("phone")||ze.includes("mobile")||ze.includes("cell")?Le.phone=qe:ze.includes("address")||ze.includes("street")?Le.address=qe:ze==="city"?Le.city=qe:ze==="state"||ze==="province"?Le.state=qe:ze==="zip"||ze==="zipcode"||ze==="postalcode"?Le.zip=qe:ze.includes("company")||ze.includes("organization")||ze.includes("business")?Le.company_name=qe:ze.includes("jobtitle")||ze.includes("title")&&!ze.includes("spouse")?Le.job_title=qe:ze.includes("birthday")||ze.includes("dob")||ze.includes("birthdate")?Le.birthday=qe:ze.includes("anniversary")||ze.includes("homeanniversary")?Le.home_anniversary=qe:(ze.includes("notes")||ze.includes("comment"))&&(Le.notes=qe)}),b(Le),d("mapping")},we.readAsText(he)},se=(_e,he)=>{b(we=>{if(he==="none"){const{[_e]:je,...Ue}=we;return Ue}return{...we,[_e]:he}})},Y=_e=>{w(he=>he.includes(_e)?he.filter(we=>we!==_e):[...he,_e])},J=async()=>{if(!(a!=null&&a.id))return;const{data:_e}=await G.from("innercircle_contacts").select("id, email, phone").eq("owner_user_id",a.id),he=new Set((_e||[]).filter(Ue=>Ue.email).map(Ue=>Ue.email.toLowerCase())),we=new Set((_e||[]).filter(Ue=>Ue.phone).map(Ue=>Ue.phone.replace(/[^0-9]/g,""))),je=x.map(Ue=>{const Te=ze=>{const ve=_[ze];if(!ve)return"";const dt=u.indexOf(ve);return dt>=0?(Ue[dt]||"").trim():""},Me=Te("first_name"),Fe=Te("email"),Le=Te("phone"),Ne=Me.length>0,qe=!!(Fe&&he.has(Fe.toLowerCase())||Le&&we.has(Le.replace(/[^0-9]/g,"")));return{first_name:Me,last_name:Te("last_name"),email:Fe,phone:Le,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:Ne,isDuplicate:qe,error:Ne?void 0:"First name is required"}});C(je),d("preview")},X=_e=>{const he=_e.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 _e=k.filter(Ue=>Ue.isValid);if(_e.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}L(!0);let he=0,we=0,je=0;try{for(const Ue of _e)try{let Te=null;if(Ue.email){const{data:Le}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ue.email).maybeSingle();Te=Le}if(!Te&&Ue.phone){const Le=Ue.phone.replace(/[^0-9]/g,""),{data:Ne}=await G.from("innercircle_contacts").select("id, phone").eq("owner_user_id",a.id).not("phone","is",null);if(Ne){const qe=Ne.find(ze=>ze.phone&&ze.phone.replace(/[^0-9]/g,"")===Le);qe&&(Te={id:qe.id})}}const Me={owner_user_id:a.id,first_name:Ue.first_name,last_name:Ue.last_name||null,email:Ue.email||null,phone:Ue.phone||null,address:Ue.address||null,city:Ue.city||null,state:Ue.state||null,zip:Ue.zip||null,spouse_name:Ue.spouse_name||null,spouse_email:Ue.spouse_email||null,company_name:Ue.company_name||null,job_title:Ue.job_title||null,birthday:f9(Ue.birthday),home_anniversary:f9(Ue.home_anniversary),notes:Ue.notes||null};let Fe=null;if(Te){const{data:Le}=await G.from("innercircle_contacts").select("*").eq("id",Te.id).single();if(Le){const Ne={},qe=["last_name","email","phone","address","city","state","zip","spouse_name","spouse_email","company_name","job_title","birthday","home_anniversary","notes"];for(const ze of qe){const ve=Le[ze],dt=Me[ze];(!ve||ve==="")&&dt&&(Ne[ze]=dt)}Object.keys(Ne).length>0&&await G.from("innercircle_contacts").update(Ne).eq("id",Te.id)}Fe=Te.id,we++}else{const{data:Le,error:Ne}=await G.from("innercircle_contacts").insert(Me).select("id").single();Ne?(console.error("Insert error for contact:",Ue.first_name,Ne),je++):Le?(Fe=Le.id,N.length>0&&await G.from("innercircle_contact_tags").insert(N.map(qe=>({contact_id:Le.id,relationship_type_id:qe}))),he++):je++}if(Fe&&Ue.spouse_name){const Le=X(Ue.spouse_name);let Ne=null;if(Ue.spouse_email){const{data:ze}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ue.spouse_email).maybeSingle();Ne=ze}if(!Ne){const{data:ze}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("first_name",Le.first_name).eq("last_name",Le.last_name||Ue.last_name||"").maybeSingle();Ne=ze}let qe=null;if(Ne){qe=Ne.id;const ze=f9(Ue.home_anniversary);ze&&await G.from("innercircle_contacts").update({home_anniversary:ze}).eq("id",Ne.id).is("home_anniversary",null)}else{const{data:ze}=await G.from("innercircle_contacts").insert({owner_user_id:a.id,first_name:Le.first_name,last_name:Le.last_name||Ue.last_name||null,email:Ue.spouse_email||null,address:Ue.address||null,city:Ue.city||null,state:Ue.state||null,zip:Ue.zip||null,home_anniversary:f9(Ue.home_anniversary),spouse_name:`${Ue.first_name}${Ue.last_name?" "+Ue.last_name:""}`,spouse_email:Ue.email||null,notes:`Spouse of ${Ue.first_name} ${Ue.last_name||""} (imported via CSV)`.trim()}).select("id").single();ze&&(qe=ze.id,he++)}qe&&(await G.from("innercircle_contacts").update({spouse_contact_id:qe}).eq("id",Fe),await G.from("innercircle_contacts").update({spouse_contact_id:Fe}).eq("id",qe))}}catch(Te){console.error("Error importing contact:",Te),je++}O({created:he,updated:we,failed:je}),d("result"),(he>0||we>0)&&n(),o({title:"Import Complete",description:`${he} created, ${we} updated${je>0?`, ${je} failed`:""}.`})}catch(Ue){console.error("Import error:",Ue),o({title:"Import Failed",description:Ue.message||"Failed to import contacts",variant:"destructive"})}finally{L(!1)}},ie=k.filter(_e=>_e.isValid).length,ae=k.filter(_e=>!_e.isValid).length,oe=k.filter(_e=>_e.isValid&&_e.isDuplicate).length,pe=ie-oe;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(Kv,{className:"h-5 w-5"}),"Import Contacts from CSV"]}),e.jsx(Ir,{children:"Upload a CSV file with your contacts. You can map columns and select relationship types."})]}),i==="upload"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx("input",{type:"file",accept:".csv,.txt",ref:l,onChange:U,className:"hidden"}),e.jsx($a,{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 _e;return(_e=l.current)==null?void 0:_e.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 _e=`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([_e],{type:"text/csv"}),we=URL.createObjectURL(he),je=document.createElement("a");je.href=we,je.download="contact_import_template.csv",je.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(xe,{className:"text-base font-medium",children:"Map CSV Columns to Contact Fields"}),e.jsx("div",{className:"grid gap-3",children:S_s.map(_e=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(xe,{className:"w-40 text-sm",children:[_e.label,_e.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Bs,{value:_[_e.key]||"none",onValueChange:he=>se(_e.key,he),children:[e.jsx(Rs,{className:"w-48",children:e.jsx(qs,{placeholder:"Select column..."})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"-- Not mapped --"}),u.map(he=>e.jsx(vt,{value:he,children:he},he))]})]})]},_e.key))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{className:"text-base font-medium",children:"Apply Relationship Types (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(_e=>e.jsx(Qe,{variant:N.includes(_e.id)?"default":"outline",className:"cursor-pointer",onClick:()=>Y(_e.id),children:_e.name},_e.id))})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-sm",children:e.jsxs("p",{className:"text-muted-foreground",children:["Preview: ",x.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(Qn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{children:[pe," new"]})]}),oe>0&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Lo,{className:"h-4 w-4"}),e.jsxs("span",{children:[oe," existing (will merge gaps)"]})]}),ae>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Lo,{className:"h-4 w-4"}),e.jsxs("span",{children:[ae," invalid"]})]})]}),oe>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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:k.slice(0,100).map((_e,he)=>e.jsxs(Ms,{children:[e.jsx(ut,{children:_e.first_name}),e.jsx(ut,{children:_e.last_name}),e.jsx(ut,{children:_e.email}),e.jsx(ut,{children:_e.phone}),e.jsx(ut,{children:_e.isValid?_e.isDuplicate?e.jsx(Qe,{variant:"outline",className:"bg-accent text-accent-foreground",children:"Merge"}):e.jsx(Qe,{variant:"secondary",className:"bg-primary/10 text-primary",children:"New"}):e.jsx(Qe,{variant:"destructive",children:_e.error||"Invalid"})})]},he))})]}),k.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",k.length," contacts"]})]})]}),i==="result"&&I&&e.jsxs("div",{className:"space-y-4 py-4 text-center",children:[e.jsx(Qn,{className:"h-12 w-12 mx-auto text-primary"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground",children:[I.created," created, ",I.updated," merged"]}),I.failed>0&&e.jsxs("p",{className:"text-destructive",children:[I.failed," failed to import"]})]}),e.jsxs(En,{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:V,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:E||ie===0,children:E?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${ie} Contact${ie!==1?"s":""}`})]}),i==="result"&&e.jsx(K,{onClick:q,children:"Done"})]})]})})};function M_s(){return"contacts"in navigator&&"ContactsManager"in window}function T_s(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 x=p.replace(/^\s+/,"");if(x.startsWith("N:")||x.startsWith("N;")){const _=x.substring(x.indexOf(":")+1).split(";");l=(_[0]||"").trim(),o=(_[1]||"").trim()}if((x.startsWith("FN:")||x.startsWith("FN;"))&&!o){const _=x.substring(x.indexOf(":")+1).trim().split(" ");o=_[0]||"",l=_.slice(1).join(" ")}(x.startsWith("EMAIL")||x.match(/^item\d+\.EMAIL/i))&&!i&&(i=x.substring(x.indexOf(":")+1).trim()),(x.startsWith("TEL")||x.match(/^item\d+\.TEL/i))&&!d&&(d=x.substring(x.indexOf(":")+1).trim()),(x.startsWith("ADR")||x.match(/^item\d+\.ADR/i))&&!u&&(u=x.substring(x.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 A_s({open:t,onOpenChange:s,onComplete:r}){Fs();const{data:n}=qh(),a=ehe(),o=S.useRef(null),[l,i]=S.useState("choose"),[d,u]=S.useState([]),[p,x]=S.useState(new Set),[y,_]=S.useState(0),[b,N]=S.useState(0),w=M_s(),k=S.useCallback(U=>{if(!n)return U;const se=new Set(n.filter(J=>J.email).map(J=>J.email.toLowerCase())),Y=new Set(n.filter(J=>J.phone).map(J=>J.phone.replace(/\D/g,"")));return U.map(J=>{var ie,ae;const X=(ie=J.email)==null?void 0:ie.toLowerCase(),ce=(ae=J.phone)==null?void 0:ae.replace(/\D/g,"");return X&&se.has(X)?{...J,isDuplicate:!0,duplicateField:"email"}:ce&&ce.length>=7&&Y.has(ce)?{...J,isDuplicate:!0,duplicateField:"phone"}:J})},[n]),C=async()=>{try{const U=["name","email","tel","address"],se=await navigator.contacts.select(U,{multiple:!0});if(!se||se.length===0)return;const Y=se.map(ce=>{var oe,pe,_e,he;const ae=(((oe=ce.name)==null?void 0:oe[0])||"").split(" ");return{first_name:ae[0]||"",last_name:ae.slice(1).join(" "),email:((pe=ce.email)==null?void 0:pe[0])||"",phone:((_e=ce.tel)==null?void 0:_e[0])||"",address:(he=ce.address)!=null&&he[0]?[ce.address[0].streetAddress,ce.address[0].city,ce.address[0].region,ce.address[0].postalCode].filter(Boolean).join(", "):""}}),J=k(Y);u(J);const X=new Set;J.forEach((ce,ie)=>{ce.isDuplicate||X.add(ie)}),x(X),i("preview")}catch(U){console.error("Contact Picker error:",U),gn({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},E=U=>{var J;const se=(J=U.target.files)==null?void 0:J[0];if(!se)return;const Y=new FileReader;Y.onload=X=>{var pe;const ce=(pe=X.target)==null?void 0:pe.result,ie=T_s(ce);if(ie.length===0){gn({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const ae=k(ie);u(ae);const oe=new Set;ae.forEach((_e,he)=>{_e.isDuplicate||oe.add(he)}),x(oe),i("preview")},Y.readAsText(se),o.current&&(o.current.value="")},L=async()=>{const U=d.filter((Y,J)=>p.has(J));if(U.length===0)return;i("importing");let se=0;for(const Y of U)try{await a.mutateAsync({first_name:Y.first_name,last_name:Y.last_name||void 0,email:Y.email||void 0,phone:Y.phone||void 0,address:Y.address||void 0}),se++,N(Math.round(se/U.length*100))}catch(J){console.error(`Failed to import ${Y.first_name} ${Y.last_name}:`,J)}_(se),i("done")},I=U=>{x(se=>{const Y=new Set(se);return Y.has(U)?Y.delete(U):Y.add(U),Y})},O=()=>{p.size===d.length?x(new Set):x(new Set(d.map((U,se)=>se)))},V=U=>{U||(i("choose"),u([]),x(new Set),_(0),N(0),l==="done"&&r()),s(U)},q=d.filter(U=>U.isDuplicate).length,$=p.size;return e.jsx(fs,{open:t,onOpenChange:V,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(t0,{className:"h-5 w-5 text-primary"}),l==="choose"&&"Import Phone Contacts",l==="preview"&&"Select Contacts to Import",l==="importing"&&"Importing Contacts...",l==="done"&&"Import Complete"]}),l==="choose"&&e.jsx(Ir,{children:"Add contacts from your phone directly into Agent OS."})]}),l==="choose"&&e.jsxs("div",{className:"space-y-4 pt-2",children:[w&&e.jsxs(K,{onClick:C,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(t0,{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:[w&&e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),w&&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:w?"outline":"default",onClick:()=>{var U;return(U=o.current)==null?void 0:U.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx($a,{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:w?"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:o,type:"file",accept:".vcf,.vcard",onChange:E,className:"hidden"}),!w&&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"})]})]})]}),l==="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:[d.length," contact",d.length!==1?"s":""," found",q>0&&e.jsxs("span",{className:"text-amber-600 ml-1",children:["(",q," already exist)"]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:O,children:p.size===d.length?"Deselect All":"Select All"})]}),e.jsx(ui,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:d.map((U,se)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${U.isDuplicate?"opacity-60":""}`,onClick:()=>I(se),children:[e.jsx(Ki,{checked:p.has(se),onCheckedChange:()=>I(se),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[U.first_name," ",U.last_name]}),U.isDuplicate&&e.jsxs(Qe,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",U.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[U.phone&&e.jsx("div",{children:U.phone}),U.email&&e.jsx("div",{className:"truncate",children:U.email})]})]})]},se))})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>i("choose"),children:"Back"}),e.jsxs(K,{onClick:L,disabled:$===0,children:["Import ",$," Contact",$!==1?"s":""]})]})]}),l==="importing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(_s,{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:[b,"% 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:`${b}%`}})})]}),l==="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(Jn,{className:"h-6 w-6 text-emerald-600"})}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"font-semibold text-lg",children:[y," contact",y!==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:()=>V(!1),className:"mt-2",children:"Done"})]})]})})}function DSe(){const t=ja();return gt({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 E_s(t){return gt({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 P_s(){const t=ja(),s=Jt();return It({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 Uat(){const t=Jt();return It({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 I_s(){const t=Jt();return It({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 L_s(){const t=ja(),s=Jt();return It({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(x=>({campaign_id:i.id,step_order:x.step_order,channel:x.channel,subject:x.subject,body:x.body,video_url:x.video_url,delay_type:x.delay_type,delay_days:x.delay_days,delay_hours:x.delay_hours,anchor_field:x.anchor_field,anchor_offset_days:x.anchor_offset_days,send_window_start:x.send_window_start,send_window_end:x.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 Vat(t){return gt({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 D_s(){const t=Jt();return It({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 R_s(){const t=Jt();return It({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 O_s(){const t=Jt();return It({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 F_s(t){return gt({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 z_s(t){return gt({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 Hat(){const t=Jt();return It({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 B_s(){const t=Jt();return It({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 $_s=[{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"}],Nme={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"},q_s={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"},U_s=["🌱","💎","🏠","🔑","📧","💌","🎂","🥂","🤝","⭐","🎉","📞"];function Gat({open:t,onOpenChange:s,campaignId:r}){const[n,a]=S.useState(r??null),[o,l]=S.useState("details");S.useEffect(()=>{a(r??null),l("details")},[r,t]);const i=n,d=!!i,{data:u}=E_s(i||void 0),{data:p,isLoading:x}=Vat(i||void 0),y=P_s(),_=Uat(),b=D_s(),[N,w]=S.useState(""),[k,C]=S.useState(""),[E,L]=S.useState("nurture"),[I,O]=S.useState("🌱"),[V,q]=S.useState("");S.useEffect(()=>{u?(w(u.name),C(u.description||""),L(u.category),O(u.icon),q(u.goal||"")):d||(w(""),C(""),L("nurture"),O("🌱"),q(""))},[u,d,t]);const $=q_s[E],U=async()=>{if(!N.trim()){me.error("Give your campaign a name");return}try{if(d&&i)await _.mutateAsync({id:i,name:N,description:k,category:E,icon:I,goal:V,cover_color:$}),me.success("Campaign updated");else{const Y=await y.mutateAsync({name:N,description:k,category:E,icon:I,goal:V,cover_color:$});return me.success("Campaign created — now add your first step!"),a(Y.id),l("steps"),Y}}catch(Y){me.error(Y.message||"Failed to save")}},se=async()=>{if(!i){me.error("Save the campaign first, then add steps");return}const Y=((p==null?void 0:p.length)||0)+1;try{await b.mutateAsync({campaign_id:i,step_order:Y,channel:"email",subject:"",body:"",delay_type:"relative",delay_days:Y===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:I}),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(Ir,{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(ia,{value:o,onValueChange:Y=>l(Y),className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(ea,{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(Qe,{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(ui,{className:"h-full",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Campaign Name *"}),e.jsx(De,{value:N,onChange:Y=>w(Y.target.value),placeholder:"e.g. New Buyer Lead — 7 Touch Nurture",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Description"}),e.jsx(vr,{value:k,onChange:Y=>C(Y.target.value),placeholder:"What's this campaign for? When should you use it?",rows:2,className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Goal (optional)"}),e.jsx(De,{value:V,onChange:Y=>q(Y.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(xe,{className:"text-xs",children:"Category"}),e.jsxs(Bs,{value:E,onValueChange:Y=>L(Y),children:[e.jsx(Rs,{className:"mt-1",children:e.jsx(qs,{})}),e.jsx(Os,{children:Object.entries(Nme).map(([Y,J])=>e.jsx(vt,{value:Y,children:J},Y))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Icon"}),e.jsx("div",{className:"flex gap-1.5 flex-wrap mt-1",children:U_s.map(Y=>e.jsx("button",{type:"button",onClick:()=>O(Y),className:`h-8 w-8 rounded-md text-lg flex items-center justify-center transition-all ${I===Y?"bg-primary/15 ring-2 ring-primary":"hover:bg-muted"}`,children:Y},Y))})]})]}),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(ui,{className:"h-full",children:e.jsx("div",{className:"p-5 space-y-3",children:x?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($r,{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:se,disabled:b.isPending,children:[e.jsx(Us,{className:"h-3.5 w-3.5 mr-1.5"})," Add first step"]})]}):e.jsxs(e.Fragment,{children:[p.map((Y,J)=>e.jsx(V_s,{step:Y,index:J,totalSteps:p.length},Y.id)),e.jsxs(K,{variant:"outline",size:"sm",onClick:se,disabled:b.isPending,className:"w-full",children:[b.isPending?e.jsx(_s,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):e.jsx(Us,{className:"h-3.5 w-3.5 mr-1.5"}),"Add another step"]})]})})})})]}),e.jsxs(En,{className:"border-t p-4 shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:d?"Done":"Cancel"}),e.jsxs(K,{onClick:U,disabled:y.isPending||_.isPending,children:[(y.isPending||_.isPending)&&e.jsx(_s,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),d?"Save Changes":"Create Campaign"]})]})]})})}function V_s({step:t,index:s,totalSteps:r}){const n=R_s(),a=O_s(),[o,l]=S.useState(!1),[i,d]=S.useState(t),[u,p]=S.useState(!1);S.useEffect(()=>d(t),[t]);const x=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 k=i.anchor_field==="birthday"?"birthday":"home anniversary",C=i.anchor_offset_days||0;return C===0?`On their ${k}`:C<0?`${Math.abs(C)}d before ${k}`:`${C}d after ${k}`}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(on,{className:"h-3 w-3"}):e.jsx(ln,{className:"h-3 w-3"}),e.jsx("span",{children:N()}),e.jsx("span",{children:"·"}),i.channel==="email"?e.jsx(rr,{className:"h-3 w-3"}):e.jsx(ki,{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(nf,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Oi,{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(xe,{className:"text-xs",children:"Channel"}),e.jsxs(Bs,{value:i.channel,onValueChange:w=>d({...i,channel:w}),children:[e.jsx(Rs,{className:"mt-1 h-9",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"email",children:"📧 Email"}),e.jsx(vt,{value:"sms",children:"💬 SMS"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Timing Type"}),e.jsxs(Bs,{value:i.delay_type,onValueChange:w=>d({...i,delay_type:w}),children:[e.jsx(Rs,{className:"mt-1 h-9",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"relative",children:"⏱ Relative delay"}),e.jsx(vt,{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(xe,{className:"text-xs",children:"Days delay"}),e.jsx(De,{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(xe,{className:"text-xs",children:"Hours delay"}),e.jsx(De,{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(xe,{className:"text-xs",children:"Anchor"}),e.jsxs(Bs,{value:i.anchor_field||"birthday",onValueChange:w=>d({...i,anchor_field:w}),children:[e.jsx(Rs,{className:"mt-1 h-9",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"birthday",children:"🎂 Birthday"}),e.jsx(vt,{value:"home_anniversary",children:"🏠 Home Anniversary"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Offset (days, negative = before)"}),e.jsx(De,{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(xe,{className:"text-xs",children:"Subject Line"}),e.jsx(De,{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(xe,{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(vr,{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:"}),$_s.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(xe,{className:"text-xs",children:"Video URL (optional)"}),e.jsx(De,{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(gr,{className:"h-3.5 w-3.5 mr-1"})," Delete step"]}),e.jsxs(K,{size:"sm",onClick:y,disabled:!x||u,children:[u&&e.jsx(_s,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save step"]})]})]})]})}function H_s({open:t,onOpenChange:s,contactIds:r,onSuccess:n}){const{data:a,isLoading:o}=DSe(),l=Hat(),[i,d]=S.useState(""),[u,p]=S.useState(null),[x,y]=S.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}),k=[`${w.enrolled} enrolled`];w.skipped>0&&k.push(`${w.skipped} skipped`),w.errors>0&&k.push(`${w.errors} errors`),me.success(k.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($r,{className:"h-4 w-4 text-primary"}),"Enroll in Drip Campaign"]}),e.jsxs(Ir,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{placeholder:"Search campaigns...",value:i,onChange:w=>d(w.target.value),className:"pl-9 h-9"})]}),e.jsx(ui,{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($r,{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(Us,{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(Qe,{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(Jn,{className:"h-4 w-4 text-primary shrink-0 mt-1"})]},w.id))})})]}),e.jsxs(En,{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(Us,{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(_s,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Enroll ",r.length," contact",r.length!==1?"s":""]})]})]}),e.jsx(Gat,{open:x,onOpenChange:y})]})}function kme(){const t=ja();return gt({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 G_s(t){return gt({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 RSe(){const t=Jt(),s=ja();return It({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 W_s(){const t=Jt();return It({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 K_s(){const t=Jt();return It({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 Wat(){const t=Jt();return It({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 Z_s(){const t=Jt();return It({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 Y_s(){const t=ja();return gt({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 X_s({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const i=_r(),{data:d}=jf(),u=ske(),p=Jt(),{isGmailConnected:x}=jp(),{isReady:y}=ESe(),{data:_}=kme(),b=RSe(),N=Wat(),[w,k]=S.useState(!1),[C,E]=S.useState(!1),[L,I]=S.useState(!1),[O,V]=S.useState(!1),[q,$]=S.useState(""),U=t.size;if(U===0)return null;const se=async oe=>{k(!0);try{const _e=Array.from(t).map(we=>({contact_id:we,relationship_type_id:oe})),{error:he}=await G.from("innercircle_contact_tags").upsert(_e,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(he)throw he;p.invalidateQueries({queryKey:["innercircle-contacts"]}),p.invalidateQueries({queryKey:["innercircle-contact-counts"]}),gn({title:`Assigned type to ${U} contacts`}),r()}catch(pe){gn({title:"Error assigning type",description:pe.message,variant:"destructive"})}finally{k(!1)}},Y=async oe=>{k(!0);try{const pe=Array.from(t);for(const _e of pe)try{await N.mutateAsync({contactId:_e,tagId:oe})}catch{}p.invalidateQueries({queryKey:["all-contact-custom-tags"]}),gn({title:`Tagged ${U} contacts`}),V(!1),$("")}catch(pe){gn({title:"Error adding tags",description:pe.message,variant:"destructive"})}finally{k(!1)}},J=async()=>{if(q.trim()){k(!0);try{const oe=await b.mutateAsync({name:q.trim()});await Y(oe.id)}catch(oe){gn({title:"Error creating tag",description:oe.message,variant:"destructive"}),k(!1)}}},X=(_==null?void 0:_.filter(oe=>oe.name.toLowerCase().includes(q.toLowerCase())))||[],ce=_==null?void 0:_.find(oe=>oe.name.toLowerCase()===q.trim().toLowerCase()),ie=()=>{const oe=s.filter(Te=>t.has(Te.id)),pe=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],_e=oe.map(Te=>{var Me;return[Te.first_name,Te.last_name||"",Te.email||"",Te.phone||"",Te.address||"",Te.birthday||"",Te.home_anniversary||"",Te.notes||"",((Me=Te.tags)==null?void 0:Me.map(Fe=>{var Le;return(Le=Fe.relationship_type)==null?void 0:Le.name}).join("; "))||""]}),he=[pe.join(","),..._e.map(Te=>Te.map(Me=>`"${(Me||"").replace(/"/g,'""')}"`).join(","))].join(` `),we=new Blob([he],{type:"text/csv"}),je=URL.createObjectURL(we),Ue=document.createElement("a");Ue.href=je,Ue.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,Ue.click(),URL.revokeObjectURL(je),gn({title:`Exported ${U} contacts`})},ae=async()=>{if(confirm(`Are you sure you want to delete ${U} contacts? This cannot be undone.`)){k(!0);try{const oe=Array.from(t);for(const pe of oe)await u.mutateAsync(pe);r()}catch(oe){gn({title:"Error deleting contacts",description:oe.message,variant:"destructive"})}finally{k(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 border border-primary/20 rounded-lg",children:[e.jsxs(Qe,{variant:"secondary",className:"font-semibold",children:[U," selected"]}),e.jsxs(Bs,{onValueChange:se,disabled:w,children:[e.jsx(Rs,{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(Os,{children:d==null?void 0:d.filter(oe=>oe.active).map(oe=>e.jsx(vt,{value:oe.id,children:oe.name},oe.id))})]}),e.jsxs(xo,{open:O,onOpenChange:V,children:[e.jsx(go,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",disabled:w,children:[e.jsx(Us,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(lo,{className:"w-56 p-2",align:"start",children:[e.jsx(De,{placeholder:"Search or create tag...",value:q,onChange:oe=>$(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&q.trim()&&!ce?(oe.preventDefault(),J()):oe.key==="Enter"&&ce&&(oe.preventDefault(),Y(ce.id))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[X.map(oe=>e.jsxs("button",{onClick:()=>Y(oe.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:oe.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:oe.name})]},oe.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(Us,{className:"h-3.5 w-3.5"}),'Create "',q.trim(),'"']}),X.length===0&&!q.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create a tag"})]})]})]}),x&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>E(!0),disabled:w,children:[e.jsx(rr,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),y&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{const oe=Array.from(t).join(",");i(`/admin/email-campaigns/new?contactIds=${oe}`)},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:()=>I(!0),disabled:w,children:[e.jsx($r,{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(Ag,{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(Hv,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,disabled:w,children:[e.jsx(Xa,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ae,disabled:w,className:"text-destructive hover:text-destructive",children:[e.jsx(gr,{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(H_s,{open:L,onOpenChange:I,contactIds:Array.from(t),onSuccess:r}),e.jsx(T1,{open:C,onOpenChange:E,bulkContacts:Array.from(t).map(oe=>{const pe=s.find(_e=>_e.id===oe);return pe?{id:pe.id,first_name:pe.first_name,last_name:pe.last_name,email:pe.email||""}:null}).filter(oe=>oe!==null&&oe.email!==""),onSendComplete:()=>{E(!1),r()}})]})}function I7e({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const d=_r(),{isReady:u}=ESe(),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:x=>x.stopPropagation(),children:e.jsx(ix,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",onClick:x=>x.stopPropagation(),children:[e.jsxs(va,{onClick:()=>d(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(Pn,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(va,{onClick:()=>d(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(Tn,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(va,{onClick:()=>d(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(Da,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),u&&t.email&&e.jsxs(va,{onClick:()=>d(`/admin/email-campaigns/new?contactIds=${t.id}`),children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Mass Email"]}),e.jsxs(va,{onClick:()=>n(t.id,p),children:[e.jsx(uh,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(va,{onClick:()=>a(t.id),children:[e.jsx(Ag,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(va,{onClick:()=>l(t.id),children:[e.jsx(Hv,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(va,{onClick:()=>s(t),children:[e.jsx(ga,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(va,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(gr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function Q_s(){const{user:t}=Fs();return gt({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 J_s(){const t=Jt(),{user:s}=Fs();return It({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"]}),gn({title:"Smart filter saved"})},onError:r=>{gn({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function ebs(){const t=Jt();return It({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"]}),gn({title:"Smart filter deleted"})}})}function tbs({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=Q_s(),a=J_s(),o=ebs(),[l,i]=S.useState(!1),[d,u]=S.useState(""),p=t.search||t.type&&t.type!=="all"||t.status&&t.status!=="all",x=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(Eg,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(Qe,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(Oi,{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(va,{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(gr,{className:"h-3 w-3 text-destructive"})})]},y.id)),e.jsx(Zb,{})]}):e.jsx(va,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),p&&e.jsxs(va,{onClick:()=>i(!0),children:[e.jsx(rL,{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(De,{placeholder:"e.g. Buyers in 40205",value:d,onChange:y=>u(y.target.value),onKeyDown:y=>y.key==="Enter"&&x(),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:x,disabled:!d.trim()||a.isPending,children:"Save"})]})]})]})})]})}function OI(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 D7e({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=_r(),i=L7e(t,"birthday",7),d=L7e(s,"anniversary",7);if(!i&&!d)return null;const u=(p,x)=>{x.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(Qe,{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(rr,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),d&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Qe,{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(rr,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function R7e({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(Qe,{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 O7e({count:t,className:s}){return!t||t<=0?null:e.jsxs(Qe,{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(xS,{className:"h-2.5 w-2.5"}),t===1?"In drip":`${t} drips`]})}function sbs(){const t=ja();return gt({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 rbs(){const t=ja();return gt({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 nbs({contactId:t,compact:s=!1}){const{data:r}=kme(),{data:n}=G_s(t),a=RSe(),o=Wat(),l=Z_s(),[i,d]=S.useState(!1),[u,p]=S.useState(""),x=S.useRef(null),y=new Set((n==null?void 0:n.map(k=>k.tag_id))||[]),_=(r==null?void 0:r.filter(k=>k.name.toLowerCase().includes(u.toLowerCase())))||[],b=r==null?void 0:r.find(k=>k.name.toLowerCase()===u.trim().toLowerCase()),N=async k=>{y.has(k.id)?await l.mutateAsync({contactId:t,tagId:k.id}):await o.mutateAsync({contactId:t,tagId:k.id})},w=async()=>{if(!(!u.trim()||b))try{const k=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:k.id}),p("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(k=>{var C,E,L;return e.jsxs(Qe,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((C=k.tag)==null?void 0:C.color)||"#6366F1",color:((E=k.tag)==null?void 0:E.color)||"#6366F1"},children:[e.jsx(hh,{className:"h-2.5 w-2.5"}),(L=k.tag)==null?void 0:L.name,e.jsx("button",{onClick:I=>{I.stopPropagation(),l.mutate({contactId:t,tagId:k.tag_id})},className:"ml-0.5 rounded-full hover:bg-accent p-0.5",children:e.jsx(Sr,{className:"h-2.5 w-2.5"})})]},k.id)}),e.jsxs(xo,{open:i,onOpenChange:d,children:[e.jsx(go,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:s?"h-6 w-6 p-0":"h-6 px-2 text-xs",onClick:k=>k.stopPropagation(),children:[e.jsx(Us,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(lo,{className:"w-56 p-2",align:"start",onClick:k=>k.stopPropagation(),children:[e.jsx(De,{ref:x,placeholder:"Search or create tag...",value:u,onChange:k=>p(k.target.value),onKeyDown:k=>{k.key==="Enter"&&u.trim()&&!b?(k.preventDefault(),w()):k.key==="Enter"&&b&&!y.has(b.id)&&(k.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(k=>e.jsxs("button",{onClick:()=>N(k),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx("div",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:k.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:k.name}),y.has(k.id)&&e.jsx(Jn,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},k.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(Us,{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 F7e({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(Qe,{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 x9=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function abs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=kme(),a=RSe(),o=K_s(),l=W_s(),[i,d]=S.useState(""),[u,p]=S.useState(x9[0]),[x,y]=S.useState(null),[_,b]=S.useState(""),[N,w]=S.useState(""),k=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),d(""),p(x9[0]),gn({title:"Tag created"})}catch(I){gn({title:"Error",description:I.message,variant:"destructive"})}},C=async I=>{if(_.trim())try{await o.mutateAsync({id:I,name:_.trim(),color:N}),y(null),gn({title:"Tag updated"})}catch(O){gn({title:"Error",description:O.message,variant:"destructive"})}},E=async(I,O)=>{if(confirm(`Delete tag "${O}"? It will be removed from all contacts.`))try{await l.mutateAsync(I),gn({title:"Tag deleted"})}catch(V){gn({title:"Error",description:V.message,variant:"destructive"})}},L=I=>{y(I.id),b(I.name),w(I.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(De,{placeholder:"New tag name...",value:i,onChange:I=>d(I.target.value),onKeyDown:I=>I.key==="Enter"&&k(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:k,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:x9.map(I=>e.jsx("button",{onClick:()=>p(I),className:`h-6 w-6 rounded-full border-2 transition-transform ${u===I?"border-foreground scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:I}},I))})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[320px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tags yet. Create one above!"}),r==null?void 0:r.map(I=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:x===I.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:x9.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(De,{value:_,onChange:O=>b(O.target.value),onKeyDown:O=>O.key==="Enter"&&C(I.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>C(I.id),children:e.jsx(Jn,{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:I.color}}),e.jsx("span",{className:"flex-1 text-sm",children:I.name}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>L(I),children:e.jsx(ga,{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:()=>E(I.id,I.name),children:e.jsx(gr,{className:"h-3.5 w-3.5"})})]})},I.id))]})]})})}function ibs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=XA(),a=nke(),o=ZLt(),l=YLt(),[i,d]=S.useState(""),[u,p]=S.useState(null),[x,y]=S.useState(""),_=async()=>{if(i.trim())try{await a.mutateAsync(i.trim()),d("")}catch(k){me.error(k.message||"Failed to add lead source")}},b=async k=>{if(x.trim())try{await o.mutateAsync({id:k,name:x.trim()}),p(null)}catch(C){me.error(C.message||"Failed to update")}},N=async(k,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(k)}catch(E){me.error(E.message||"Failed to remove")}},w=k=>{p(k.id),y(k.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(De,{placeholder:"New lead source name...",value:i,onChange:k=>d(k.target.value),onKeyDown:k=>k.key==="Enter"&&_(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:_,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[360px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No lead sources yet. Create one above!"}),r==null?void 0:r.map(k=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:u===k.id?e.jsxs(e.Fragment,{children:[e.jsx(De,{value:x,onChange:C=>y(C.target.value),onKeyDown:C=>C.key==="Enter"&&b(k.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>b(k.id),children:e.jsx(Jn,{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:k.name}),k.owner_user_id&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>w(k),children:e.jsx(ga,{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(k.id,k.name),children:e.jsx(gr,{className:"h-3.5 w-3.5"})})]}),!k.owner_user_id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default"})]})},k.id))]})]})})}function Kat({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=XA(),a=nke(),[o,l]=S.useState(!1),[i,d]=S.useState(""),u=async()=>{if(i.trim())try{const p=await a.mutateAsync(i.trim());p&&(s(p.id),d(""),l(!1))}catch{}};return e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:r}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Bs,{value:t||"_none",onValueChange:p=>s(p==="_none"?"":p),children:[e.jsx(Rs,{className:"flex-1",children:e.jsx(qs,{placeholder:"Select lead source"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"_none",children:"No source"}),n==null?void 0:n.map(p=>e.jsx(vt,{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(Us,{className:"h-4 w-4"})})]}),o&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{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 Cwe({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=_r(),[d,u]=S.useState(!1),[p,x]=S.useState(""),{data:y}=gt({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:_}=gt({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(xe,{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(Ti,{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(vS,{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(ei,{className:"h-3.5 w-3.5"})})]})]})}return!s&&(r||n)?e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{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(Ti,{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(xo,{open:d,onOpenChange:u,children:[e.jsx(go,{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(lo,{className:"w-72 p-2",align:"end",children:e.jsx(z7e,{search:p,setSearch:x,results:_,onSelect:b=>{a(b),u(!1),x("")}})})]})]})]}):l?e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs(xo,{open:d,onOpenChange:u,children:[e.jsx(go,{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(lo,{className:"w-72 p-2",align:"start",children:e.jsx(z7e,{search:p,setSearch:x,results:_,onSelect:b=>{a(b),u(!1),x("")}})})]})]}):null}function z7e({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(an,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{value:t,onChange:a=>s(a.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(ui,{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 obs(){var Fr;const t=_r(),[s,r]=Nc(),{user:n}=Fs(),a=vE(),o=Jt(),l=s.get("type"),i=s.get("filter")??s.get("status"),d=s.get("new")==="true",{contactsWithScores:u,isLoading:p}=nhe(),{activeContactIds:x,hasLeadSite:y}=j_s(),{data:_}=sbs(),{data:b}=jf(),{data:N}=rbs(),{data:w}=kme(),{data:k}=Y_s(),[C,E]=S.useState(new Set),[L,I]=S.useState("any"),O=ehe(),V=tke(),q=ske(),$=mXe(),[U,se]=S.useState(""),[Y,J]=S.useState(l||"all"),[X,ce]=S.useState(i||"all"),[ie,ae]=S.useState("date-added"),[oe,pe]=S.useState(d),[_e,he]=S.useState(null),[we,je]=S.useState(!1),[Ue,Te]=S.useState(!1),[Me,Fe]=S.useState(null),[Le,Ne]=S.useState(""),[qe,ze]=S.useState(new Set),[ve,dt]=S.useState(!1),fe=Math.max(1,parseInt(s.get("page")||"1",10)||1),[Ve,Je]=S.useState(fe),at=S.useCallback(Kt=>{Je(jr=>{const zr=typeof Kt=="function"?Kt(jr):Kt;return r(fa=>{const qt=new URLSearchParams(fa);return zr<=1?qt.delete("page"):qt.set("page",String(zr)),qt},{replace:!0}),zr})},[]),[Ae,Ye]=S.useState(50),[We,ot]=S.useState("my"),[Ge,et]=S.useState(!1),[ht,xt]=S.useState(!1),{data:Ke}=Px(),{addToLeadPond:Ze}=att(Ke==null?void 0:Ke.teamId),Et=!!((Fr=Ke==null?void 0:Ke.team)!=null&&Fr.lead_pond_enabled&&(Ke!=null&&Ke.teamId)),$t=!!(Ke!=null&&Ke.teamId),[Yt,Ps]=S.useState([]),[zs,Zs]=S.useState(!1),Dr=Kt=>{Ps([Kt]),Zs(!0)},zt=Kt=>{Ps(Kt),Zs(!0)},$s=Kt=>{Ke!=null&&Ke.teamId&&Ze.mutate({contact_id:Kt,team_id:Ke.teamId})},kr=Kt=>{Ke!=null&&Ke.teamId&&Kt.forEach(jr=>{Ze.mutate({contact_id:jr,team_id:Ke.teamId})})},Xs=S.useCallback(Kt=>{dt(!1),ze(jr=>{const zr=new Set(jr);return zr.has(Kt)?zr.delete(Kt):zr.add(Kt),zr})},[]);S.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]),S.useEffect(()=>{i&&ce(i)},[i]);const[ir,Or]=S.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]});S.useEffect(()=>{d&&pe(!0)},[d]),S.useEffect(()=>{var Kt;_e&&Or({first_name:_e.first_name||"",last_name:_e.last_name||"",email:_e.email||"",phone:_e.phone||"",address:_e.address||"",city:_e.city||"",state:_e.state||"",zip_code:_e.zip_code||"",birthday:_e.birthday||"",home_anniversary:_e.home_anniversary||"",spouse_name:_e.spouse_name||"",spouse_email:_e.spouse_email||"",lead_source_id:_e.lead_source_id||"",notes:_e.notes||"",tagIds:((Kt=_e.tags)==null?void 0:Kt.map(jr=>jr.relationship_type_id))||[]})},[_e]);const Vn=S.useMemo(()=>{if(!u)return[];let Kt=u.filter(jr=>{var Se,Oe,Xe;const zr=U===""||`${jr.first_name} ${jr.last_name}`.toLowerCase().includes(U.toLowerCase())||((Se=jr.email)==null?void 0:Se.toLowerCase().includes(U.toLowerCase()))||((Oe=jr.phone)==null?void 0:Oe.includes(U)),fa=Y==="all"||((Xe=jr.tags)==null?void 0:Xe.some(_t=>_t.relationship_type_id===Y)),qt=C.size===0||(()=>{const _t=(k==null?void 0:k.filter(bt=>bt.contact_id===jr.id).map(bt=>bt.tag_id))||[];return L==="any"?_t.some(bt=>C.has(bt)):Array.from(C).every(bt=>_t.includes(bt))})();return zr&&fa&&qt});return X==="not-touched-90"?Kt=Kt.filter(jr=>{const zr=jr.relationshipScore.daysSinceTouch;return zr===null||zr>90}):X==="at-risk"?Kt=Kt.filter(jr=>jr.relationshipScore.status==="at-risk"):X==="cooling"?Kt=Kt.filter(jr=>jr.relationshipScore.status==="cooling"):X==="warm"?Kt=Kt.filter(jr=>jr.relationshipScore.status==="warm"):X==="has-deal"?Kt=Kt.filter(jr=>N&&N[jr.id]):X==="no-deal"?Kt=Kt.filter(jr=>!N||!N[jr.id]):X==="open-house"?Kt=Kt.filter(jr=>{var fa;return(((fa=jr.lead_source_ref)==null?void 0:fa.name)||jr.lead_source)==="Open House"}):X==="website-active"&&(Kt=Kt.filter(jr=>x.has(jr.id))),Kt=[...Kt].sort((jr,zr)=>{switch(ie){case"important-dates":{const fa=OI(jr.birthday),qt=OI(zr.birthday),Se=OI(jr.home_anniversary),Oe=OI(zr.home_anniversary),Xe=[fa,Se].filter(bt=>bt!==null).sort((bt,Mt)=>(bt??1/0)-(Mt??1/0))[0]??1/0,_t=[qt,Oe].filter(bt=>bt!==null).sort((bt,Mt)=>(bt??1/0)-(Mt??1/0))[0]??1/0;return Xe-_t}case"last-touched":{const fa=jr.relationshipScore.lastTouchDate,qt=zr.relationshipScore.lastTouchDate;return!fa&&!qt?0:fa?qt?new Date(fa).getTime()-new Date(qt).getTime():1:-1}case"next-touch":{const fa=jr.relationshipScore.daysSinceTouch,qt=zr.relationshipScore.daysSinceTouch;return fa===null&&qt===null?0:fa===null?-1:qt===null?1:qt-fa}case"score":return jr.relationshipScore.score-zr.relationshipScore.score;case"date-added":{const fa=jr.created_at,qt=zr.created_at;return!fa&&!qt?0:fa?qt?new Date(qt).getTime()-new Date(fa).getTime():-1:1}case"name":default:{const fa=`${jr.first_name||""} ${jr.last_name||""}`.toLowerCase(),qt=`${zr.first_name||""} ${zr.last_name||""}`.toLowerCase();return fa.localeCompare(qt)}}}),Kt},[u,U,Y,C,L,X,ie,N,k,x]),Qr=Vn.length,Gr=Math.max(1,Math.ceil(Qr/Ae)),tr=Math.min(Ve,Gr),cr=S.useMemo(()=>{const Kt=(tr-1)*Ae;return Vn.slice(Kt,Kt+Ae)},[Vn,tr,Ae]),cn=S.useRef(!1);S.useEffect(()=>{if(!cn.current){cn.current=!0;return}at(1)},[U,Y,C,L,X,ie]);const rn=S.useCallback(()=>{dt(!1),ze(Kt=>Kt.size>0?new Set:new Set(cr.map(jr=>jr.id)))},[cr]),jn=S.useCallback(()=>{dt(!0),ze(new Set(Vn.map(Kt=>Kt.id)))},[Vn]),ni=S.useCallback((Kt,jr)=>{se(Kt.search||""),J(Kt.type||"all"),ce(Kt.status||"all"),ae(jr||"name")},[]),rs=()=>{Or({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},Bn=async Kt=>{Kt.preventDefault();const jr={...ir,lead_source_id:ir.lead_source_id||null};_e?(await V.mutateAsync({id:_e.id,...jr}),he(null)):(await O.mutateAsync(jr),pe(!1)),rs()},mn=async Kt=>{confirm("Are you sure you want to delete this contact?")&&await q.mutateAsync(Kt)};return e.jsx(Es,{title:"Contacts",description:"Manage your InnerCircle contacts",children:e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Contacts"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),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 ${We==="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 ${We==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(lr,{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 ${We==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Ag,{className:"h-3.5 w-3.5"}),"Lead Pond"]})]})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(xl,{className:"h-4 w-4 mr-1"}),"Back"]})}),We==="team"?e.jsx(c4e,{}):We==="lead-pond"&&Ke?e.jsx(d4e,{teamId:Ke.teamId}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{children:e.jsx(Re,{className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name, email, or phone...",value:U,onChange:Kt=>se(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:()=>pe(!0),className:"shrink-0",children:[e.jsx(Us,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),e.jsxs(K,{variant:"outline",onClick:()=>je(!0),className:"shrink-0",children:[e.jsx($a,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(K,{variant:"outline",onClick:()=>Te(!0),className:"shrink-0",children:[e.jsx(t0,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx(p_s,{})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(Bs,{value:Y,onValueChange:J,children:[e.jsx(Rs,{className:"w-[145px] h-9 text-sm",children:e.jsx(qs,{placeholder:"Filter by type"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Types"}),b==null?void 0:b.filter(Kt=>Kt.active).map(Kt=>e.jsx(vt,{value:Kt.id,children:Kt.name},Kt.id))]})]}),w&&w.length>0&&e.jsxs(xo,{children:[e.jsx(go,{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(lo,{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:()=>I("any"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${L==="any"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"Any"}),e.jsx("button",{onClick:()=>I("all"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${L==="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 jr=C.has(Kt.id);return e.jsxs("button",{onClick:()=>{E(zr=>{const fa=new Set(zr);return fa.has(Kt.id)?fa.delete(Kt.id):fa.add(Kt.id),fa})},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(Ki,{checked:jr,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:()=>E(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(ko,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs(jd,{align:"end",children:[e.jsxs(va,{onClick:()=>et(!0),children:[e.jsx(hh,{className:"h-4 w-4 mr-2"}),"Manage Tags"]}),e.jsxs(va,{onClick:()=>xt(!0),children:[e.jsx(Ag,{className:"h-4 w-4 mr-2"}),"Manage Lead Sources"]})]})]}),e.jsxs(Bs,{value:X,onValueChange:ce,children:[e.jsx(Rs,{className:"w-[145px] h-9 text-sm",children:e.jsx(qs,{placeholder:"Filter by status"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Status"}),e.jsx(vt,{value:"warm",children:"🟢 Warm"}),e.jsx(vt,{value:"cooling",children:"🟡 Cooling Off"}),e.jsx(vt,{value:"at-risk",children:"🔴 At Risk"}),e.jsx(vt,{value:"has-deal",children:"📋 Has Deal"}),e.jsx(vt,{value:"no-deal",children:"📭 No Deal"}),e.jsx(vt,{value:"open-house",children:"🏠 Open House"}),y&&e.jsx(vt,{value:"website-active",children:"🌐 Website Active"})]})]}),e.jsxs(Bs,{value:ie,onValueChange:ae,children:[e.jsx(Rs,{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(Os,{children:[e.jsx(vt,{value:"name",children:"Name (A-Z)"}),e.jsx(vt,{value:"important-dates",children:"Important Dates"}),e.jsx(vt,{value:"last-touched",children:"Last Touched"}),e.jsx(vt,{value:"next-touch",children:"Next Touch Due"}),e.jsx(vt,{value:"score",children:"Relationship Score"}),e.jsx(vt,{value:"date-added",children:"Date Added"})]})]}),e.jsx(tbs,{currentFilters:{search:U,type:Y,status:X},currentSortBy:ie,onApplySmartList:ni})]})]})})}),e.jsx(X_s,{selectedIds:qe,contacts:Vn,onClearSelection:()=>{ze(new Set),dt(!1)},showLeadPondAction:Et,onSendToLeadPond:kr,showTransferAction:$t,onTransfer:zt}),qe.size>0&&qe.size===cr.length&&!ve&&Qr>Ae&&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 ",cr.length," contacts on this page are selected."]}),e.jsxs(K,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:jn,children:["Select all ",Qr.toLocaleString()," matching contacts"]})]}),ve&&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 ",Qr.toLocaleString()," matching contacts are selected.",e.jsx(K,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{ze(new Set),dt(!1)},children:"Clear selection"})]}),Qr>Ae&&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 ",(tr-1)*Ae+1,"–",Math.min(tr*Ae,Qr)," of ",Qr.toLocaleString()," contacts"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",disabled:tr<=1,onClick:()=>at(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:tr<=1,onClick:()=>at(Kt=>Kt-1),children:e.jsx(xl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",tr," of ",Gr]}),e.jsx(K,{variant:"outline",size:"sm",disabled:tr>=Gr,onClick:()=>at(Kt=>Kt+1),children:e.jsx(Sa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:tr>=Gr,onClick:()=>at(Gr),children:"Last"})]})]}),a?e.jsx("div",{className:"space-y-3",children:p?e.jsx(Pe,{className:"p-6 text-center text-muted-foreground",children:"Loading contacts..."}):Vn.length===0?e.jsx(Pe,{className:"p-6 text-center text-muted-foreground",children:U||Y!=="all"||X!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):cr.map(Kt=>{var zr,fa,qt;const{relationshipScore:jr}=Kt;return e.jsx(Pe,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const Se=new URLSearchParams;U&&Se.set("search",U),Y!=="all"&&Se.set("type",Y),X!=="all"&&Se.set("filter",X);const Oe=Se.toString();t(`/mission-control/contacts/${Kt.id}${Oe?`?${Oe}`:""}`)},children:e.jsx(Re,{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(O7e,{count:(_==null?void 0:_[Kt.id])??0}),e.jsx(Sa,{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(rr,{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(Pn,{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(j8,{score:jr,size:"sm"}),e.jsx(Swe,{contact:Kt}),(((zr=Kt.lead_source_ref)==null?void 0:zr.name)||Kt.lead_source)&&e.jsx(Qe,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((fa=Kt.lead_source_ref)==null?void 0:fa.name)||Kt.lead_source}),(qt=Kt.tags)==null?void 0:qt.map(Se=>{var Oe;return e.jsx(Qe,{variant:"secondary",className:"text-xs",children:(Oe=Se.relationship_type)==null?void 0:Oe.name},Se.id)}),e.jsx(F7e,{contactId:Kt.id,tags:k==null?void 0:k.filter(Se=>Se.contact_id===Kt.id)}),e.jsx(R7e,{deal:N==null?void 0:N[Kt.id]})]}),e.jsx(D7e,{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:[jr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ln,{className:"h-3 w-3"}),ps(new Date(jr.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),Kt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ps(ml(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"}),ps(ml(Kt.home_anniversary),"MMM d")]}),Kt.created_at&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Us,{className:"h-3 w-3"}),"Added ",ps(new Date(Kt.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:Se=>Se.stopPropagation(),children:e.jsx(I7e,{contact:Kt,onEdit:he,onDelete:mn,onSnooze:(Se,Oe)=>{Fe(Se),Ne(Oe)},showLeadPondAction:Et,onSendToLeadPond:$s,showTransferAction:$t,onTransfer:Dr})})]})})},Kt.id)})}):e.jsx(Pe,{children:e.jsx(Re,{className:"p-0 overflow-x-auto",children:e.jsxs(In,{className:"min-w-[800px]",children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Nt,{className:"w-[40px]",children:e.jsx(Ki,{checked:cr.length>0&&cr.every(Kt=>qe.has(Kt.id)),onCheckedChange:()=>rn()})}),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:()=>ae(ie==="date-added"?"name":"date-added"),children:e.jsxs("div",{className:"flex items-center gap-1",children:["Date Added",ie==="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(Dn,{children:p?e.jsx(Ms,{children:e.jsx(ut,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):Vn.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:U||Y!=="all"||X!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):cr.map(Kt=>{var fa,qt,Se;const{relationshipScore:jr}=Kt,zr=N==null?void 0:N[Kt.id];return e.jsxs(Ms,{className:`cursor-pointer hover:bg-accent/50 ${qe.has(Kt.id)?"bg-accent/30":""}`,onClick:()=>{const Oe=new URLSearchParams;U&&Oe.set("search",U),Y!=="all"&&Oe.set("type",Y),X!=="all"&&Oe.set("status",X);const Xe=Oe.toString();t(`/mission-control/contacts/${Kt.id}${Xe?`?${Xe}`:""}`)},children:[e.jsx(ut,{onClick:Oe=>Oe.stopPropagation(),children:e.jsx(Ki,{checked:qe.has(Kt.id),onCheckedChange:()=>Xs(Kt.id)})}),e.jsx(ut,{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(O7e,{count:(_==null?void 0:_[Kt.id])??0})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(j8,{score:jr,size:"sm"}),e.jsx(Swe,{contact:Kt})]})}),e.jsx(ut,{children:e.jsx(j8,{score:jr,size:"sm",showScore:!0})}),e.jsx(ut,{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(rr,{className:"h-3 w-3"}),Kt.email]}),Kt.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Pn,{className:"h-3 w-3"}),Kt.phone]})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((fa=Kt.lead_source_ref)==null?void 0:fa.name)||Kt.lead_source)&&e.jsx(Qe,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((qt=Kt.lead_source_ref)==null?void 0:qt.name)||Kt.lead_source}),(Se=Kt.tags)==null?void 0:Se.map(Oe=>{var Xe;return e.jsx(Qe,{variant:"secondary",className:"text-xs",children:(Xe=Oe.relationship_type)==null?void 0:Xe.name},Oe.id)}),e.jsx(F7e,{contactId:Kt.id,tags:k==null?void 0:k.filter(Oe=>Oe.contact_id===Kt.id)}),e.jsx(R7e,{deal:zr})]})}),e.jsx(ut,{children:e.jsx("div",{className:"text-sm",children:jr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(ln,{className:"h-3 w-3"}),ps(new Date(jr.lastTouchDate),"MMM d, yyyy")]}):e.jsx("span",{className:"text-muted-foreground text-xs italic",children:"Never contacted"})})}),e.jsx(ut,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:Kt.created_at?ps(new Date(Kt.created_at),"MMM d, yyyy"):"—"})}),e.jsx(ut,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(D7e,{birthday:Kt.birthday,homeAnniversary:Kt.home_anniversary,contactId:Kt.id,contactName:`${Kt.first_name}${Kt.last_name?" "+Kt.last_name:""}`,contactAddress:[Kt.address,Kt.city,Kt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Kt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ps(ml(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"}),ps(ml(Kt.home_anniversary),"MMM d")]})]})]})}),e.jsx(ut,{children:e.jsx(I7e,{contact:Kt,onEdit:he,onDelete:mn,onSnooze:(Oe,Xe)=>{Fe(Oe),Ne(Xe)},showLeadPondAction:Et,onSendToLeadPond:$s,showTransferAction:$t,onTransfer:Dr})})]},Kt.id)})})]})})}),Qr>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 ",(tr-1)*Ae+1,"–",Math.min(tr*Ae,Qr)," of ",Qr.toLocaleString()," contacts"]}),e.jsxs(Bs,{value:String(Ae),onValueChange:Kt=>{Ye(Number(Kt)),at(1)},children:[e.jsx(Rs,{className:"w-[80px] h-8",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"50",children:"50"}),e.jsx(vt,{value:"100",children:"100"}),e.jsx(vt,{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:tr<=1,onClick:()=>at(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:tr<=1,onClick:()=>at(Kt=>Kt-1),children:e.jsx(xl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",tr," of ",Gr]}),e.jsx(K,{variant:"outline",size:"sm",disabled:tr>=Gr,onClick:()=>at(Kt=>Kt+1),children:e.jsx(Sa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:tr>=Gr,onClick:()=>at(Gr),children:"Last"})]})]}),e.jsx(fs,{open:oe||!!_e,onOpenChange:Kt=>{Kt||(pe(!1),he(null),rs())},children:e.jsxs(ms,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:_e?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:Bn,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"first_name",children:"First Name *"}),e.jsx(De,{id:"first_name",value:ir.first_name,onChange:Kt=>Or({...ir,first_name:Kt.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"last_name",children:"Last Name"}),e.jsx(De,{id:"last_name",value:ir.last_name,onChange:Kt=>Or({...ir,last_name:Kt.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"email",children:"Email"}),e.jsx(De,{id:"email",type:"email",value:ir.email,onChange:Kt=>Or({...ir,email:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"phone",children:"Phone"}),e.jsx(De,{id:"phone",value:ir.phone,onChange:Kt=>Or({...ir,phone:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"address",children:"Address"}),e.jsx(De,{id:"address",value:ir.address,onChange:Kt=>Or({...ir,address:Kt.target.value}),placeholder:"Street address"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"city",children:"City"}),e.jsx(De,{id:"city",value:ir.city,onChange:Kt=>Or({...ir,city:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"state",children:"State"}),e.jsx(De,{id:"state",value:ir.state,onChange:Kt=>Or({...ir,state:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"zip_code",children:"Zip"}),e.jsx(De,{id:"zip_code",value:ir.zip_code,onChange:Kt=>Or({...ir,zip_code:Kt.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"birthday",children:"Birthday"}),e.jsx(De,{id:"birthday",type:"date",value:ir.birthday,onChange:Kt=>Or({...ir,birthday:Kt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(De,{id:"home_anniversary",type:"date",value:ir.home_anniversary,onChange:Kt=>Or({...ir,home_anniversary:Kt.target.value})})]})]}),_e&&e.jsx(Cwe,{contactId:_e.id,currentSpouseContactId:(_e==null?void 0:_e.spouse_contact_id)||null,currentSpouseName:(_e==null?void 0:_e.spouse_name)||null,currentSpouseEmail:(_e==null?void 0:_e.spouse_email)||null,onLink:Kt=>$.mutate({contactId:_e.id,spouseContactId:Kt}),onUnlink:()=>$.mutate({contactId:_e.id,spouseContactId:null}),isEditing:!0}),e.jsx(Kat,{value:ir.lead_source_id,onChange:Kt=>Or({...ir,lead_source_id:Kt})}),e.jsxs("div",{children:[e.jsx(xe,{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(Ki,{checked:ir.tagIds.includes(Kt.id),onCheckedChange:jr=>{Or(jr?{...ir,tagIds:[...ir.tagIds,Kt.id]}:{...ir,tagIds:ir.tagIds.filter(zr=>zr!==Kt.id)})}}),e.jsx("span",{className:"text-sm",children:Kt.name})]},Kt.id))})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"notes",children:"Notes"}),e.jsx(vr,{id:"notes",value:ir.notes,onChange:Kt=>Or({...ir,notes:Kt.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{pe(!1),he(null),rs()},children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:O.isPending||V.isPending,children:[_e?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(C_s,{open:we,onOpenChange:je,relationshipTypes:(b==null?void 0:b.filter(Kt=>Kt.active))||[],onSuccess:()=>{je(!1)}}),e.jsx(A_s,{open:Ue,onOpenChange:Te,onComplete:()=>Te(!1)}),e.jsx(bme,{open:!!Me,onOpenChange:Kt=>{Kt||Fe(null)},contactId:Me||"",contactName:Le}),e.jsx(abs,{open:Ge,onOpenChange:et}),e.jsx(ibs,{open:ht,onOpenChange:xt}),e.jsx(itt,{open:zs,onOpenChange:Zs,contactIds:Yt,contactNames:Yt.map(Kt=>{const jr=Vn.find(zr=>zr.id===Kt);return jr?`${jr.first_name} ${jr.last_name||""}`.trim():""}),onComplete:()=>{Ps([]),ze(new Set),dt(!1)}})]})]})})}const lbs="9a88a47c-cb2a-4401-a2b5-111a76b19f9d";function cbs({open:t,onOpenChange:s,contact:r}){var Y;const{user:n}=Fs(),a=_r(),o=Jt(),{intakePage:l,isLoading:i}=wme(),{isGmailConnected:d,gmailEmail:u}=jp(),p=the(),{data:x}=gt({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=(x==null?void 0:x.name)||((Y=n==null?void 0:n.email)==null?void 0:Y.split("@")[0])||"Your Agent",_=y.split(" ")[0],b=l?`https://contacts.relevelup.com/${l.slug}`:"",N=S.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,k]=S.useState("gmail"),[C,E]=S.useState(""),[L,I]=S.useState(""),[O,V]=S.useState(!1);S.useEffect(()=>{t&&(E(`Quick favor, ${r.first_name} — can you update your info?`),I(N),k(d?"gmail":"system"))},[t,N,r.first_name,d]);const q=S.useMemo(()=>L.split(/\n\n+/).map(J=>`

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

`).join(""),[L]),$=()=>`
${x!=null&&x.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

`,U=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()||!L.trim()){me.error("Subject and message are required");return}V(!0);const J=$();try{if(w==="gmail"&&d){const{data:X,error:ce}=await G.functions.invoke("gmail-send",{body:{to:r.email,subject:C,body:J,contactId:r.id}});if(ce)throw ce;if(!(X!=null&&X.success))throw new Error((X==null?void 0:X.error)||"Failed to send")}else{const{data:X,error:ce}=await G.functions.invoke("send-connect-invite",{body:{contactEmail:r.email,subject:C,htmlBody:J,replyToEmail:(x==null?void 0:x.email)||(n==null?void 0:n.email),agentName:y}});if(ce)throw ce;if(!(X!=null&&X.success))throw new Error((X==null?void 0:X.error)||"Failed to send")}try{await p.mutateAsync({contactId:r.id,actionTypeId:lbs,notes:`Sent Connect Page invite — Subject: "${C}"`})}catch(X){console.warn("Failed to log activity:",X)}o.invalidateQueries({queryKey:["contact-touch-logs"]}),me.success("Connect Page invite sent!"),s(!1)}catch(X){console.error("Send error:",X),me.error(X instanceof Error?X.message:"Failed to send invite")}finally{V(!1)}},se=$();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($r,{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(_s,{className:"h-6 w-6 animate-spin text-primary"})}):l?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Send From"}),e.jsx(ia,{value:w,onValueChange:J=>k(J),className:"mt-1.5",children:e.jsxs(ea,{className:"grid w-full grid-cols-2",children:[e.jsxs(ls,{value:"gmail",disabled:!d,children:[e.jsx(rr,{className:"h-3.5 w-3.5 mr-1.5"}),d?`Gmail (${u})`:"Gmail (not connected)"]}),e.jsxs(ls,{value:"system",children:[e.jsx($r,{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 ${(x==null?void 0:x.email)||(n==null?void 0:n.email)||"your account email"}.`})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"invite-subject",children:"Subject"}),e.jsx(De,{id:"invite-subject",value:C,onChange:J=>E(J.target.value),className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"invite-message",children:"Personal Message"}),e.jsx(vr,{id:"invite-message",value:L,onChange:J=>I(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(xe,{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:se,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:U,disabled:O,children:O?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-4 w-4 mr-1.5 animate-spin"})," Sending…"]}):e.jsxs(e.Fragment,{children:[e.jsx(An,{className:"h-4 w-4 mr-1.5"})," Send Invite"]})})]})]}):e.jsxs("div",{className:"space-y-4 py-6 text-center",children:[e.jsx(Lo,{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 dbs(){return gt({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 ubs(t){return gt({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 hbs(){const{user:t}=Fs();return gt({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 mbs(){const{user:t}=Fs(),s=Jt();return It({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 pbs(t){const{user:s}=Fs();return gt({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 fbs(t){return gt({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 MC(){const{user:t}=Fs(),s=Jt();return It({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 xbs(){const t=Jt();return It({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 gbs(){const t=Jt();return It({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 Sme(){const{user:t}=Fs();return gt({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 Zat(){const{data:t,isLoading:s}=Sme(),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 xO(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 gO(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 pA(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 ybs(){const{user:t}=Fs(),s=Jt();return It({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 vbs(t){return gt({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 _bs(t){return gt({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 OSe(){const t=ja(),s=Jt();return It({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 yO(){const t=Jt();return It({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 bbs(){const t=Jt();return It({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 wbs(){const t=Jt();return It({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 jbs(){const t=Jt();return It({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 Yat(){const t=Jt();return It({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 Nbs(){const t=ja();return gt({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 kbs(){const t=ja(),s=Jt();return It({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 Sbs(){const t=Jt();return It({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 Cbs(){const t=Jt();return It({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 a1(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function Mbs({contactId:t}){const s=_r(),r=Jt(),[n,a]=S.useState(null),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(""),[x,y]=S.useState(""),[_,b]=S.useState(null),N=yO(),w=Yat(),{data:k,isLoading:C}=gt({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 U=q.map(J=>J.id),{data:se,error:Y}=await G.from("client_portals").select("*").in("deal_id",U).is("archived_at",null);if(Y)throw Y;return(se||[]).map(J=>({...J,deal:q.find(X=>X.id===J.deal_id)}))},enabled:!!t}),E=(k==null?void 0:k.map(q=>q.id))||[],{data:L}=gt({queryKey:["contact-portal-updates",E],queryFn:async()=>{if(E.length===0)return{};const{data:q,error:$}=await G.from("portal_updates").select("*").in("portal_id",E).order("created_at",{ascending:!1});if($)throw $;const U={};return(q||[]).forEach(se=>{U[se.portal_id]||(U[se.portal_id]=se)}),U},enabled:E.length>0}),I=q=>{navigator.clipboard.writeText(a1(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:x||void 0}),d(!1),p(""),y(""),r.invalidateQueries({queryKey:["contact-portal-updates"]}),me.success("Portal update posted!"))},V=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||!k||k.length===0?null:e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(gd,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(Re,{className:"space-y-3",children:k.map(q=>{var Y,J,X;const $=((Y=q.stage_mapping)==null?void 0:Y.length)>0?q.stage_mapping:LNe(((J=q.deal)==null?void 0:J.deal_type)||"buyer"),U=$==null?void 0:$[q.current_stage_index??0],se=L==null?void 0:L[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:((X=q.deal)==null?void 0:X.deal_name)||"Portal"}),U&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Stage: ",U.label||U.name]})]}),e.jsx(Qe,{variant:q.is_enabled?"default":"secondary",className:"text-[10px] flex-shrink-0",children:q.is_enabled?"Active":"Disabled"})]}),se&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-2",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:se.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ps(new Date(se.created_at),"MMM d, yyyy")})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>I(q.slug),children:[n===q.slug?e.jsx(Jn,{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(a1(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(pi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>d(!0),children:[e.jsx(ki,{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(xe,{children:"Title"}),e.jsx(De,{value:u,onChange:ce=>p(ce.target.value),placeholder:"e.g. Inspection completed!"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Details (optional)"}),e.jsx(vr,{value:x,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(An,{className:"h-4 w-4 mr-1"}),"Post Update"]})]})]})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{b({...q}),l(!0)},children:[e.jsx(ko,{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(xe,{children:"Portal Enabled"}),e.jsx(Er,{checked:_.is_enabled,onCheckedChange:ce=>b({..._,is_enabled:ce})})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Welcome Message"}),e.jsx(vr,{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(xe,{children:"Next Step"}),e.jsx(De,{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(xe,{children:"Review URL"}),e.jsx(De,{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(xe,{children:"Show Post-Close Tips"}),e.jsx(Er,{checked:_.show_post_close_tips,onCheckedChange:ce=>b({..._,show_post_close_tips:ce})})]}),e.jsx(wo,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:V,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(ei,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),k.length>1&&e.jsx(wo,{})]},q.id)})})]})}function Tbs({contactId:t}){const{data:s}=gt({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}=gt({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(Pe,{className:"overflow-hidden",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{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(wn,{className:"h-4 w-4 text-primary"})}),"Property Activity",e.jsxs(Qe,{variant:"secondary",className:"text-xs ml-auto",children:[n.length," ",n.length===1?"property":"properties"]})]})}),e.jsx(Re,{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(ln,{className:"h-3 w-3"}),e.jsx("span",{title:ps(new Date(l.viewed_at),"PPp"),children:gl(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 Abs=["Single Family","Condo","Townhouse","Multi-Family","Land","Commercial"];function B7e({value:t,onChange:s,onAdd:r,suggestions:n,placeholder:a,icon:o}){const[l,i]=S.useState(!1),d=S.useRef(null),u=S.useRef(null);S.useEffect(()=>{const x=y=>{u.current&&!u.current.contains(y.target)&&d.current&&!d.current.contains(y.target)&&i(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]);const p=n.filter(x=>x.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(De,{ref:d,value:t,onChange:x=>{s(x.target.value),i(!0)},onFocus:()=>i(!0),placeholder:a,onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),p.length>0?r(p[0]):r(t))}}),n.length>0&&e.jsx(Oi,{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(Us,{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(x=>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(x),i(!1)},children:[o||e.jsx(Da,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),x]},x))})]})}function Ebs({contactId:t,contactName:s}){var $,U,se;const{user:r}=Fs(),n=ja(),{hasLeadSite:a}=ZA(),o=Jt(),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,x]=S.useState(""),{data:y}=gt({queryKey:["agent-lead-site-config",n],queryFn:async()=>{const{data:Y,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||!Y)return{cities:[],zipCodes:[]};const X=Y.theme_config||{},ce=Array.isArray(X.searchCities)?X.searchCities:[];Y.mls_market_area&&!ce.includes(Y.mls_market_area)&&ce.unshift(Y.mls_market_area);const ie=Array.isArray(X.searchZipCodes)?X.searchZipCodes:[];return{cities:ce,zipCodes:ie}},enabled:!!n}),{data:_,isLoading:b}=gt({queryKey:["contact-property-alert",t],queryFn:async()=>{const{data:Y,error:J}=await G.from("contact_property_alerts").select("*").eq("contact_id",t).maybeSingle();if(J)throw J;return Y},enabled:!!t&&!!r}),[N,w]=S.useState({}),k=()=>{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=It({mutationFn:async()=>{const Y={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(Y).eq("id",_.id);if(J)throw J}else{const{error:J}=await G.from("contact_property_alerts").insert(Y);if(J)throw J}},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-property-alert",t]}),i(!1),me.success("Property alert saved!")},onError:Y=>{me.error(Y.message||"Failed to save alert")}}),E=It({mutationFn:async()=>{if(!(_!=null&&_.id))return;const{error:Y}=await G.from("contact_property_alerts").delete().eq("id",_.id);if(Y)throw Y},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-property-alert",t]}),i(!1),me.success("Property alert removed")}}),L=Y=>{var X;const J=Y.trim();J&&!((X=N.cities)!=null&&X.includes(J))&&w(ce=>({...ce,cities:[...ce.cities||[],J]})),u("")},I=Y=>{var X;const J=Y.trim();J&&!((X=N.zip_codes)!=null&&X.includes(J))&&w(ce=>({...ce,zip_codes:[...ce.zip_codes||[],J]})),x("")},O=Y=>{w(J=>{const X=J.property_types||[];return{...J,property_types:X.includes(Y)?X.filter(ce=>ce!==Y):[...X,Y]}})};if(!a||b)return null;if(_&&!l)return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{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(Sm,{className:"h-4 w-4 text-green-600"}):e.jsx(Gv,{className:"h-4 w-4 text-muted-foreground"})}),"Property Alerts",e.jsxs(Qe,{variant:_.is_active?"default":"secondary",className:"text-xs ml-auto",children:[_.is_active?"Active":"Paused"," · ",_.frequency]})]})}),e.jsxs(Re,{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(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(yc,{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(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(U4,{className:"h-3 w-3"}),_.min_beds,"+ beds"]}):null,_.min_baths?e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(rf,{className:"h-3 w-3"}),_.min_baths,"+ baths"]}):null,($=_.cities)==null?void 0:$.map(Y=>e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(Da,{className:"h-3 w-3"}),Y]},Y)),(U=_.zip_codes)==null?void 0:U.map(Y=>e.jsx(Qe,{variant:"outline",children:Y},Y)),(se=_.property_types)==null?void 0:se.map(Y=>e.jsx(Qe,{variant:"outline",children:Y},Y))]}),_.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:k,className:"flex-1",children:"Manage Alert"}),e.jsxs(K,{variant:"destructive",size:"sm",onClick:()=>E.mutate(),disabled:E.isPending,className:"flex-1",children:[E.isPending?e.jsx(_s,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Sr,{className:"h-4 w-4 mr-1"}),"Remove Alert"]})]})]})]});const V=((y==null?void 0:y.cities)||[]).filter(Y=>{var J;return!((J=N.cities)!=null&&J.includes(Y))}),q=((y==null?void 0:y.zipCodes)||[]).filter(Y=>{var J;return!((J=N.zip_codes)!=null&&J.includes(Y))});return l?e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Sm,{className:"h-4 w-4 text-primary"}),_?"Edit":"Setup"," Property Alert for ",s]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Alert Active"}),e.jsx(Er,{checked:N.is_active??!0,onCheckedChange:Y=>w(J=>({...J,is_active:Y}))})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(yc,{className:"h-3.5 w-3.5"})," Price Range"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(De,{type:"number",placeholder:"Min price",value:N.min_price??"",onChange:Y=>w(J=>({...J,min_price:Y.target.value?Number(Y.target.value):null}))}),e.jsx(De,{type:"number",placeholder:"Max price",value:N.max_price??"",onChange:Y=>w(J=>({...J,max_price:Y.target.value?Number(Y.target.value):null}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(U4,{className:"h-3.5 w-3.5"})," Min Beds"]}),e.jsxs(Bs,{value:N.min_beds?String(N.min_beds):"any",onValueChange:Y=>w(J=>({...J,min_beds:Y==="any"?null:Number(Y)})),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Any"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"any",children:"Any"}),[1,2,3,4,5].map(Y=>e.jsxs(vt,{value:String(Y),children:[Y,"+"]},Y))]})]})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(rf,{className:"h-3.5 w-3.5"})," Min Baths"]}),e.jsxs(Bs,{value:N.min_baths?String(N.min_baths):"any",onValueChange:Y=>w(J=>({...J,min_baths:Y==="any"?null:Number(Y)})),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Any"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"any",children:"Any"}),[1,1.5,2,2.5,3,4].map(Y=>e.jsxs(vt,{value:String(Y),children:[Y,"+"]},Y))]})]})]})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(uS,{className:"h-3.5 w-3.5"})," Square Feet"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(De,{type:"number",placeholder:"Min sqft",value:N.min_sqft??"",onChange:Y=>w(J=>({...J,min_sqft:Y.target.value?Number(Y.target.value):null}))}),e.jsx(De,{type:"number",placeholder:"Max sqft",value:N.max_sqft??"",onChange:Y=>w(J=>({...J,max_sqft:Y.target.value?Number(Y.target.value):null}))})]})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Da,{className:"h-3.5 w-3.5"})," Cities"]}),e.jsx(B7e,{value:d,onChange:u,onAdd:L,suggestions:V,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(Y=>e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[Y,e.jsx("button",{onClick:()=>w(J=>{var X;return{...J,cities:(X=J.cities)==null?void 0:X.filter(ce=>ce!==Y)}}),children:e.jsx(Sr,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"mb-1.5",children:"Zip Codes"}),e.jsx(B7e,{value:p,onChange:x,onAdd:I,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(Y=>e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[Y,e.jsx("button",{onClick:()=>w(J=>{var X;return{...J,zip_codes:(X=J.zip_codes)==null?void 0:X.filter(ce=>ce!==Y)}}),children:e.jsx(Sr,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{children:[e.jsxs(xe,{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:Abs.map(Y=>{var J;return e.jsx(Qe,{variant:(J=N.property_types)!=null&&J.includes(Y)?"default":"outline",className:"cursor-pointer",onClick:()=>O(Y),children:Y},Y)})})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"mb-1.5",children:"Frequency"}),e.jsxs(Bs,{value:N.frequency||"daily",onValueChange:Y=>w(J=>({...J,frequency:Y})),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"daily",children:"Daily"}),e.jsx(vt,{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(_s,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(_c,{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:()=>E.mutate(),disabled:E.isPending,children:e.jsx(Sr,{className:"h-4 w-4"})})]})]})]}):e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(Re,{className:"p-4",children:e.jsxs("button",{onClick:k,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(Sm,{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 Pbs({contactId:t,contactName:s}){var ie;const{user:r}=Fs(),n=ja(),{hasLeadSite:a}=ZA(),o=Jt(),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,x]=S.useState([]),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.useState(!1),[C,E]=S.useState(""),L=S.useRef(null),I=S.useRef(null),{data:O}=gt({queryKey:["agent-lead-site-cities",n],queryFn:async()=>{const{data:ae,error:oe}=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(oe||!ae)return[];const pe=ae.theme_config||{},_e=Array.isArray(pe.searchCities)?pe.searchCities:[];return ae.mls_market_area&&!_e.includes(ae.mls_market_area)&&_e.unshift(ae.mls_market_area),_e},enabled:!!n}),{data:V,isLoading:q}=gt({queryKey:["contact-market-report",t],queryFn:async()=>{const{data:ae,error:oe}=await G.from("innercircle_contacts").select("market_report_enabled, market_report_cities").eq("id",t).single();if(oe)throw oe;return ae},enabled:!!t&&!!r});S.useEffect(()=>{const ae=oe=>{I.current&&!I.current.contains(oe.target)&&L.current&&!L.current.contains(oe.target)&&N(!1)};return document.addEventListener("mousedown",ae),()=>document.removeEventListener("mousedown",ae)},[]);const $=()=>{_((V==null?void 0:V.market_report_enabled)??!1),x((V==null?void 0:V.market_report_cities)??[]),i(!0)},U=ae=>{const oe=(ae||d).trim();oe&&!p.includes(oe)&&x([...p,oe]),u(""),N(!1)},se=(O||[]).filter(ae=>!p.includes(ae)&&ae.toLowerCase().includes(d.toLowerCase())),Y=It({mutationFn:async()=>{const{data:ae,error:oe}=await G.functions.invoke("send-market-report",{body:{action:"preview",agentId:n,cities:(V==null?void 0:V.market_report_cities)??[]}});if(oe)throw new Error(oe.message||"Failed to generate preview");if(ae&&!ae.ok&&ae.error)throw new Error(ae.error);return ae},onSuccess:ae=>{E(ae.html),k(!0)},onError:ae=>{me.error(ae.message||"Failed to generate preview")}}),J=It({mutationFn:async()=>{const{data:ae,error:oe}=await G.functions.invoke("send-market-report",{body:{action:"send",agentId:n,cities:(V==null?void 0:V.market_report_cities)??[],contactIds:[t]}});if(oe)throw new Error(oe.message||"Failed to send report");if(ae&&!ae.ok&&ae.error)throw new Error(ae.error);return ae},onSuccess:()=>{me.success(`Market report sent to ${s}!`)},onError:ae=>{me.error(ae.message||"Failed to send report")}}),X=It({mutationFn:async()=>{const{error:ae}=await G.from("innercircle_contacts").update({market_report_enabled:y,market_report_cities:p}).eq("id",t);if(ae)throw ae},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-market-report",t]}),i(!1),me.success(y?"Monthly market report enabled!":"Market report disabled")},onError:ae=>{me.error(ae.message||"Failed to save")}}),ce=It({mutationFn:async()=>{const{error:ae}=await G.from("innercircle_contacts").update({market_report_enabled:!1,market_report_cities:[]}).eq("id",t);if(ae)throw ae},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-market-report",t]}),i(!1),_(!1),x([]),me.success("Market report removed")},onError:ae=>{me.error(ae.message||"Failed to remove market report")}});return!a||q?null:V!=null&&V.market_report_enabled&&!l?e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{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(to,{className:"h-4 w-4 text-primary"})}),"Monthly Market Report",e.jsx(Qe,{variant:"default",className:"text-xs ml-auto",children:"Active"})]})}),e.jsxs(Re,{className:"pt-0 space-y-2",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5 text-xs",children:((ie=V.market_report_cities)==null?void 0:ie.length)>0?V.market_report_cities.map(ae=>e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(Da,{className:"h-3 w-3"}),ae]},ae)):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:()=>Y.mutate(),disabled:Y.isPending,className:"flex-1",children:[Y.isPending?e.jsx(_s,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(wn,{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(_s,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(An,{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(_s,{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:k,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(to,{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:()=>{k(!1),J.mutate()},disabled:J.isPending,className:"flex-1",children:[J.isPending?e.jsx(_s,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(An,{className:"h-4 w-4 mr-1"}),"Send to ",s]}),e.jsx(K,{variant:"outline",onClick:()=>k(!1),children:"Close"})]})]})})]})]}):l?e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4 text-primary"}),"Market Report for ",s]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Send Monthly Report"}),e.jsx(Er,{checked:y,onCheckedChange:_})]}),y&&e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Da,{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(De,{ref:L,value:d,onChange:ae=>{u(ae.target.value),N(!0)},onFocus:()=>N(!0),placeholder:"Type to search cities...",onKeyDown:ae=>{ae.key==="Enter"&&(ae.preventDefault(),se.length>0?U(se[0]):U())}}),e.jsx(Oi,{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:()=>U(),children:e.jsx(Us,{className:"h-4 w-4"})})]}),b&&se.length>0&&e.jsx("div",{ref:I,className:"absolute z-50 mt-1 w-full max-h-60 overflow-y-auto rounded-md border bg-popover shadow-md",children:se.map(ae=>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:()=>U(ae),children:[e.jsx(Da,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),ae]},ae))})]}),p.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:p.map(ae=>e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[ae,e.jsx("button",{onClick:()=>x(p.filter(oe=>oe!==ae)),children:e.jsx(Sr,{className:"h-3 w-3"})})]},ae))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>X.mutate(),disabled:X.isPending,className:"flex-1",children:[X.isPending?e.jsx(_s,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(_c,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"})]})]})]}):e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(Re,{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(to,{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 Ibs(t){return gt({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 x;return{...p,campaign:{name:((x=o.get(p.campaign_id))==null?void 0:x.name)??""}}})}return{enrollments:l,stepLogs:i}},enabled:!!t})}function Lbs(t){switch(t){case"active":return e.jsx(Qe,{variant:"secondary",className:"bg-emerald-500/10 text-emerald-600 border-emerald-500/20",children:"Active"});case"paused":return e.jsx(Qe,{variant:"secondary",className:"bg-amber-500/10 text-amber-600 border-amber-500/20",children:"Paused"});case"completed":return e.jsx(Qe,{variant:"secondary",className:"bg-sky-500/10 text-sky-600 border-sky-500/20",children:"Completed"});case"exited":return e.jsx(Qe,{variant:"outline",children:"Exited"});default:return e.jsx(Qe,{variant:"outline",children:t})}}function $7e(t){return t==="sent"?e.jsx(Qn,{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(ln,{className:"h-4 w-4 text-muted-foreground"})}function Dbs({contactId:t}){const s=_r(),{data:r,isLoading:n}=Ibs(t),[a,o]=S.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(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2 text-base",children:[e.jsx(xS,{className:"h-5 w-5 text-emerald-500"}),"Drip Campaign Activity"]})}),e.jsxs(Re,{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(xS,{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"}),Lbs(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: ",gl(new Date(d.next_send_at),{addSuffix:!0})]}),d.completed_at&&e.jsxs(e.Fragment,{children:[" · Completed ",gl(new Date(d.completed_at),{addSuffix:!0})]}),d.exited_at&&!d.completed_at&&e.jsxs(e.Fragment,{children:[" · ",d.exit_reason||"Exited"," ",gl(new Date(d.exited_at),{addSuffix:!0})]})]})]}),e.jsx(Sa,{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:x=>!x&&o(null),children:[e.jsx(pi,{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:$7e(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(ki,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}):e.jsx(rr,{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"," · ",ps(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:[$7e(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:ps(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 Rbs({videoId:t}){var l;const{data:s,isLoading:r,error:n}=fbs(t);if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ns,{className:"w-full aspect-video rounded-lg"}),e.jsx(Ns,{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 Obs({contactId:t}){const s=_r(),[r,n]=S.useState(!1),{data:a,isLoading:o}=gt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:x,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 x},enabled:!!t}),l=async(x,y)=>{const _=y==="done"?"todo":"done";await G.from("deal_tasks").update({status:_,completed_at:_==="done"?new Date().toISOString():null}).eq("id",x),window.dispatchEvent(new CustomEvent("refetch-contact-tasks"))},{refetch:i}=gt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:x,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 x},enabled:!!t}),d={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"},u=(a==null?void 0:a.filter(x=>x.status!=="done"))||[],p=(a==null?void 0:a.filter(x=>x.status==="done"))||[];return e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Jn,{className:"h-4 w-4"}),"Tasks",u.length>0&&e.jsx(Qe,{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(Us,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(Re,{className:"space-y-1",children:o?e.jsx(Ns,{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(x=>e.jsxs("button",{onClick:async()=>{await l(x.id,x.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[x.priority]," ",x.title]}),x.due_date&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ps(new Date(x.due_date),"MMM d")})]},x.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(Fbs,{contactId:t,open:r,onOpenChange:x=>{n(x),x||i()}})]})}function Fbs({contactId:t,open:s,onOpenChange:r}){const[n,a]=S.useState(""),[o,l]=S.useState("medium"),[i,d]=S.useState(),{data:u}=gt({queryKey:["session"],queryFn:async()=>{const{data:x}=await G.auth.getSession();return x.session}}),p=async()=>{var y;if(!n.trim()||!((y=u==null?void 0:u.user)!=null&&y.id))return;const{error:x}=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?ps(i,"yyyy-MM-dd"):null}]);if(x){console.error("Task create error:",x);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(xe,{children:"Title"}),e.jsx(De,{value:n,onChange:x=>a(x.target.value),placeholder:"Task title...",onKeyDown:x=>x.key==="Enter"&&p()})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Priority"}),e.jsxs("select",{value:o,onChange:x=>l(x.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(xe,{children:"Due Date"}),e.jsx(De,{type:"date",value:i?ps(i,"yyyy-MM-dd"):"",onChange:x=>d(x.target.value?new Date(x.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 zbs({contactId:t}){const s=_r(),{data:r,isLoading:n}=gt({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(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Ih,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx(Re,{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(Qe,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(Qe,{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(ei,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function Bbs(){var Ge,et,ht,xt,Ke;const{contactId:t}=co(),s=_r(),[r]=Nc(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=eLt(t||""),{data:d}=jf(),{data:u}=UR(),{data:p}=VR(3650),{data:x}=jme(365),{data:y}=vbs(t),{contactsWithScores:_}=nhe(),b=tke(),N=ske(),w=the(),k=mXe(),[C,E]=S.useState(!1),[L,I]=S.useState({}),[O,V]=S.useState(!1),[q,$]=S.useState(null),[U,se]=S.useState(""),[Y,J]=S.useState(void 0),[X,ce]=S.useState(""),[ie,ae]=S.useState(null),[oe,pe]=S.useState(!1),[_e,he]=S.useState(null),[we,je]=S.useState(!1),{isGmailConnected:Ue,gmailEmail:Te}=jp(),{data:Me}=gt({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:Ze,error:Et}=await G.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(Et)throw Et;return Ze},enabled:!!t}),Fe=Ze=>{if(!Ze)return null;const Et=Ze.match(/Video ID:\s*([a-f0-9-]+)/i);return Et?Et[1]:null},Le=S.useMemo(()=>{if(!_)return[];let Ze=_.filter(Et=>{var Ps,zs,Zs;const $t=n===""||`${Et.first_name} ${Et.last_name}`.toLowerCase().includes(n.toLowerCase())||((Ps=Et.email)==null?void 0:Ps.toLowerCase().includes(n.toLowerCase()))||((zs=Et.phone)==null?void 0:zs.includes(n)),Yt=a==="all"||((Zs=Et.tags)==null?void 0:Zs.some(Dr=>Dr.relationship_type_id===a));return $t&&Yt});return o==="not-touched-90"?Ze=Ze.filter(Et=>{const $t=Et.relationshipScore.daysSinceTouch;return $t===null||$t>90}):o==="at-risk"?Ze=Ze.filter(Et=>Et.relationshipScore.status==="at-risk"):o==="cooling"?Ze=Ze.filter(Et=>Et.relationshipScore.status==="cooling"):o==="warm"&&(Ze=Ze.filter(Et=>Et.relationshipScore.status==="warm")),Ze.map(Et=>Et.id)},[_,n,a,o]),Ne=Le.indexOf(t||""),qe=Ne>0?Le[Ne-1]:null,ze=Ne1&&Ne!==-1,dt=Ze=>{const Et=new URLSearchParams;n&&Et.set("search",n),a!=="all"&&Et.set("type",a),o!=="all"&&Et.set("status",o);const $t=Et.toString();return`/mission-control/contacts/${Ze}${$t?`?${$t}`:""}`},fe=S.useMemo(()=>{const Ze=((p==null?void 0:p.filter($t=>$t.contact_id===t))||[]).map($t=>{var Zs,Dr,zt;const Yt=Fe($t.notes);let Ps=((Zs=$t.action_type)==null?void 0:Zs.name)||"Touch",zs=$t.notes;if(Ps==="Other"&&((Dr=$t.notes)!=null&&Dr.startsWith("["))){const $s=$t.notes.indexOf("]");$s>0&&(Ps=$t.notes.substring(1,$s),zs=$t.notes.substring($s+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:$t.id,type:"touch",completed_at:$t.completed_at,name:Ps,color:((zt=$t.action_type)==null?void 0:zt.color)||"#3B82F6",notes:zs,videoId:Yt}}),Et=((x==null?void 0:x.filter($t=>$t.contact_id===t))||[]).map($t=>({id:$t.id,type:"popby",completed_at:$t.completed_at,name:"Pop-by",color:"#F97316",notes:$t.notes,videoId:null}));return[...Ze,...Et].sort(($t,Yt)=>new Date(Yt.completed_at).getTime()-new Date($t.completed_at).getTime())},[p,x,t]),Ve=()=>{var Ze;l&&(I({first_name:l.first_name||"",last_name:l.last_name||"",email:l.email||"",phone:l.phone||"",address:l.address||"",city:l.city||"",state:l.state||"",zip_code:l.zip_code||"",birthday:l.birthday||"",home_anniversary:l.home_anniversary||"",spouse_name:l.spouse_name||"",spouse_email:l.spouse_email||"",company_name:l.company_name||"",job_title:l.job_title||"",lead_source_id:l.lead_source_id||"",notes:l.notes||"",tagIds:((Ze=l.tags)==null?void 0:Ze.map(Et=>Et.relationship_type_id))||[]}),E(!0))},Je=async()=>{await b.mutateAsync({id:t,...L,lead_source_id:L.lead_source_id||null}),E(!1)},at=async()=>{confirm("Are you sure you want to delete this contact?")&&(await N.mutateAsync(t),s("/mission-control/contacts"))},Ye=((Ge=u==null?void 0:u.find(Ze=>Ze.id===q))==null?void 0:Ge.name)==="Other",We=async()=>{if(!q||Ye&&!X.trim())return;const Ze=Y?new Date(Y.getFullYear(),Y.getMonth(),Y.getDate(),12,0,0).toISOString():void 0,Et=Ye?`[${X.trim()}]${U?" — "+U:""}`:U;await w.mutateAsync({contactId:t,actionTypeId:q,notes:Et,completedAt:Ze}),V(!1),$(null),se(""),J(void 0),ce("")},ot=(Ze,Et)=>{Ue&&l?(he({email:Ze,name:Et||`${l.first_name} ${l.last_name||""}`.trim()}),pe(!0)):window.location.href=`mailto:${Ze}`};return i?e.jsx(Es,{title:"Contact Details",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})})}):l?e.jsxs(e.Fragment,{children:[e.jsx(Es,{title:`${l.first_name} ${l.last_name||""}`,description:"Contact details and activity",children:e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{window.history.length>1?s(-1):s("/mission-control/contacts")},children:[e.jsx(xl,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),ve&&e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>qe&&s(dt(qe)),disabled:!qe,className:"px-2",children:[e.jsx(xl,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only sm:not-sr-only sm:ml-1",children:"Prev"})]}),e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[Ne+1," of ",Le.length]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>ze&&s(dt(ze)),disabled:!ze,className:"px-2",children:[e.jsx("span",{className:"sr-only sm:not-sr-only sm:mr-1",children:"Next"}),e.jsx(Sa,{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(rr,{className:"h-4 w-4 mr-1"}),"Email"]}),l.email&&e.jsxs(K,{variant:"outline",onClick:()=>je(!0),className:"border-primary/40 text-primary hover:bg-primary/10",children:[e.jsx($r,{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(Tn,{className:"h-4 w-4 mr-1"}),"Quick Video Touch"]}),e.jsxs(fs,{open:O,onOpenChange:V,children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Us,{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(xe,{children:"Action Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:u==null?void 0:u.filter(Ze=>Ze.active).map(Ze=>e.jsxs("button",{onClick:()=>$(Ze.id),className:` p-3 rounded-lg border text-left transition-all ${q===Ze.id?"border-primary bg-primary/10":"hover:bg-accent"} `,children:[e.jsx("div",{className:"font-medium",children:Ze.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:Ze.description})]},Ze.id))}),Ye&&e.jsxs("div",{className:"mt-3",children:[e.jsx(xe,{htmlFor:"custom-action-name",children:"What did you do?"}),e.jsx(De,{id:"custom-action-name",value:X,onChange:Ze=>ce(Ze.target.value),placeholder:"e.g. Met a client for lunch, Dropped off a gift...",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Date (optional — backdate if needed)"}),e.jsxs(xo,{children:[e.jsx(go,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Rt("w-full justify-start text-left font-normal mt-2",!Y&&"text-muted-foreground"),children:[e.jsx(on,{className:"h-4 w-4 mr-2"}),Y?ps(Y,"PPP"):"Today (default)"]})}),e.jsx(lo,{className:"w-auto p-0",align:"start",children:e.jsx(df,{mode:"single",selected:Y,onSelect:J,disabled:Ze=>Ze>new Date,initialFocus:!0,className:Rt("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(vr,{id:"action-notes",value:U,onChange:Ze=>se(Ze.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(K,{onClick:We,disabled:!q||Ye&&!X.trim()||w.isPending,className:"w-full",children:[e.jsx(Jn,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(K,{variant:"outline",onClick:Ve,children:[e.jsx(Gc,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:at,children:e.jsx(gr,{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||""]}),(((et=l.lead_source_ref)==null?void 0:et.name)||l.lead_source)&&e.jsx(Qe,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((ht=l.lead_source_ref)==null?void 0:ht.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(rr,{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(Pn,{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(Swe,{contact:l}),(xt=l.tags)==null?void 0:xt.map(Ze=>{const Et=d==null?void 0:d.find($t=>$t.id===Ze.relationship_type_id);return Et?e.jsx(Qe,{variant:"secondary",className:"text-xs",children:Et.name},Ze.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(nbs,{contactId:t})})]})}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs(Pe,{className:"md:col-span-2",children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Contact Information"})}),e.jsx(Re,{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(xe,{htmlFor:"first_name",children:"First Name"}),e.jsx(De,{id:"first_name",value:L.first_name,onChange:Ze=>I({...L,first_name:Ze.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"last_name",children:"Last Name"}),e.jsx(De,{id:"last_name",value:L.last_name,onChange:Ze=>I({...L,last_name:Ze.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"email",children:"Email"}),e.jsx(De,{id:"email",type:"email",value:L.email,onChange:Ze=>I({...L,email:Ze.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"phone",children:"Phone"}),e.jsx(De,{id:"phone",value:L.phone,onChange:Ze=>I({...L,phone:Ze.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"address",children:"Street Address"}),e.jsx(De,{id:"address",value:L.address,onChange:Ze=>I({...L,address:Ze.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(xe,{htmlFor:"city",children:"City"}),e.jsx(De,{id:"city",value:L.city,onChange:Ze=>I({...L,city:Ze.target.value}),placeholder:"City"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"state",children:"State"}),e.jsx(De,{id:"state",value:L.state,onChange:Ze=>I({...L,state:Ze.target.value}),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"zip_code",children:"Zip Code"}),e.jsx(De,{id:"zip_code",value:L.zip_code,onChange:Ze=>I({...L,zip_code:Ze.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(xe,{htmlFor:"birthday",children:"Birthday"}),e.jsx(De,{id:"birthday",type:"date",value:L.birthday,onChange:Ze=>I({...L,birthday:Ze.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(De,{id:"home_anniversary",type:"date",value:L.home_anniversary,onChange:Ze=>I({...L,home_anniversary:Ze.target.value})})]})]}),e.jsx(wo,{}),e.jsx(Cwe,{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:Ze=>k.mutate({contactId:t,spouseContactId:Ze}),onUnlink:()=>k.mutate({contactId:t,spouseContactId:null}),isEditing:!0}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"company_name",children:"Company"}),e.jsx(De,{id:"company_name",value:L.company_name,onChange:Ze=>I({...L,company_name:Ze.target.value}),placeholder:"Enter company name"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"job_title",children:"Job Title"}),e.jsx(De,{id:"job_title",value:L.job_title,onChange:Ze=>I({...L,job_title:Ze.target.value}),placeholder:"Enter job title"})]})]}),e.jsx(Kat,{value:L.lead_source_id||"",onChange:Ze=>I({...L,lead_source_id:Ze})}),e.jsxs("div",{children:[e.jsx(xe,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:d==null?void 0:d.filter(Ze=>Ze.active).map(Ze=>{var Et;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Ki,{checked:(Et=L.tagIds)==null?void 0:Et.includes(Ze.id),onCheckedChange:$t=>{var Yt;I($t?{...L,tagIds:[...L.tagIds||[],Ze.id]}:{...L,tagIds:(Yt=L.tagIds)==null?void 0:Yt.filter(Ps=>Ps!==Ze.id)})}}),e.jsx("span",{className:"text-sm",children:Ze.name})]},Ze.id)})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"notes",children:"Notes"}),e.jsx(vr,{id:"notes",value:L.notes,onChange:Ze=>I({...L,notes:Ze.target.value}),rows:4})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:Je,disabled:b.isPending,children:"Save Changes"}),e.jsx(K,{variant:"outline",onClick:()=>E(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[fe.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",ps(new Date(fe[0].completed_at),"MMM d, yyyy")," ","(",fe[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(rr,{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(Pn,{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(Da,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{className:"flex flex-col",children:[l.address&&e.jsx("span",{children:l.address}),(l.city||l.state||l.zip_code)&&e.jsxs("span",{className:"text-muted-foreground",children:[[l.city,l.state].filter(Boolean).join(", "),l.zip_code&&` ${l.zip_code}`]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[l.birthday&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",ps(ml(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: ",ps(ml(l.home_anniversary),"MMMM d")]})]}),l.created_at&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Us,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Date Added: ",ps(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(wo,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(Cwe,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:l.spouse_name||null,currentSpouseEmail:l.spouse_email||null,onLink:Ze=>k.mutate({contactId:t,spouseContactId:Ze}),onUnlink:()=>k.mutate({contactId:t,spouseContactId:null}),isEditing:!1}),(l.company_name||l.job_title)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{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(wo,{}),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(Ze=>{var Et;return e.jsx(Qe,{variant:"secondary",children:(Et=Ze.relationship_type)==null?void 0:Et.name},Ze.id)}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No relationship types assigned"})})]}),l.notes&&e.jsxs(e.Fragment,{children:[e.jsx(wo,{}),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(w_s,{contact:l,onLogTouch:()=>V(!0)}),e.jsx(zbs,{contactId:t}),e.jsx(Mbs,{contactId:t}),e.jsx(Tbs,{contactId:t}),e.jsx(Ebs,{contactId:t,contactName:l.first_name}),e.jsx(Pbs,{contactId:t,contactName:l.first_name}),e.jsx(Obs,{contactId:t}),e.jsx(Dbs,{contactId:t}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Activity Log"})}),e.jsx(Re,{children:fe.length>0?e.jsx("div",{className:"space-y-4",children:fe.map(Ze=>{var Et;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:Ze.color},children:Ze.type==="popby"?e.jsx(Ui,{className:"h-4 w-4"}):(Et=Ze.name)==null?void 0:Et.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:Ze.name}),Ze.videoId&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ae(Ze.videoId),children:[e.jsx(So,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ps(new Date(Ze.completed_at),"MMM d, yyyy h:mm a")}),Ze.notes&&!Ze.videoId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ze.notes})]})]},Ze.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(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(ki,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-4",children:y.map(Ze=>{var Et,$t;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(Et=Ze.video)!=null&&Et.thumbnail_url?e.jsx("img",{src:Ze.video.thumbnail_url,alt:Ze.video.title||"Video",className:"h-12 w-16 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>ae(Ze.video_id)}):e.jsx("div",{className:"h-12 w-16 bg-muted rounded flex items-center justify-center cursor-pointer hover:bg-muted/80 transition-colors",onClick:()=>ae(Ze.video_id),children:e.jsx(Tn,{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: ",(($t=Ze.video)==null?void 0:$t.title)||"Untitled Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>ae(Ze.video_id),children:[e.jsx(So,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ps(new Date(Ze.created_at),"MMM d, yyyy h:mm a")}),Ze.message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:['"',Ze.message,'"']})]})]},Ze.id)})})})]}),Me&&Me.length>0&&e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(An,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-3",children:Me.map(Ze=>e.jsxs(fs,{children:[e.jsx(pi,{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(rr,{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:Ze.subject}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",Ze.to_email," · ",ps(new Date(Ze.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx(Sa,{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(rr,{className:"h-5 w-5 text-sky-500"}),Ze.subject]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",Ze.to_email," · ",ps(new Date(Ze.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:Ze.body,className:"w-full h-[400px] border-0",sandbox:"",title:`Email: ${Ze.subject}`})})]})]},Ze.id))})})]})]}),e.jsx(fs,{open:!!ie,onOpenChange:Ze=>!Ze&&ae(null),children:e.jsxs(ms,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsx(bs,{children:"Video Preview"})}),ie&&e.jsx(Rbs,{videoId:ie})]})})]})]})}),Ue&&l&&_e&&e.jsx(T1,{open:oe,onOpenChange:pe,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:_e.email},gmailEmail:Te}),l&&l.email&&e.jsx(cbs,{open:we,onOpenChange:je,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:l.email}})]}):e.jsx(Es,{title:"Contact Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This contact was not found."}),e.jsx(K,{onClick:()=>s("/mission-control/contacts"),children:"Back to Contacts"})]})})}const q7e={Crown:Cm,FileText:fn,Users:lr,Globe:gd,Star:Hn,Phone:Pn,MessageSquare:ki,PenTool:Sb,Video:Tn,Gift:Ui},o0e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function $bs(){var ht,xt;const t=_r(),{user:s}=Fs(),{data:r}=jf(),{data:n}=sLt(),{data:a}=cLt(),{data:o}=hXe(),{data:l}=UR(),{data:i}=tLt(),d=dLt(),u=rLt(),p=aLt(),x=iLt(),y=oLt(),_=lLt(),b=nLt(),[N,w]=S.useState(null),[k,C]=S.useState(!1),[E,L]=S.useState(null),[I,O]=S.useState(""),[V,q]=S.useState(""),[$,U]=S.useState([]),[se,Y]=S.useState(null),[J,X]=S.useState(null),[ce,ie]=S.useState(!1),[ae,oe]=S.useState(""),[pe,_e]=S.useState(""),[he,we]=S.useState(""),[je,Ue]=S.useState(""),Te=(Ke,Ze)=>a==null?void 0:a.some(Et=>Et.plan_id===Ke&&Et.relationship_type_id===Ze&&Et.active),Me=Ke=>a==null?void 0:a.find(Ze=>Ze.relationship_type_id===Ke&&Ze.active),Fe=async(Ke,Ze)=>{const Et=Te(Ke,Ze);await d.mutateAsync({planId:Ke,relationshipTypeId:Ze,active:!Et})},Le=(n==null?void 0:n.filter(Ke=>Ke.active&&!Ke.owner_user_id))||[],Ne=(n==null?void 0:n.filter(Ke=>Ke.owner_user_id===(s==null?void 0:s.id)))||[],qe=r==null?void 0:r.find(Ke=>Ke.id===N),ze=N?Me(N):null,ve=n==null?void 0:n.find(Ke=>Ke.id===(ze==null?void 0:ze.plan_id)),dt=async()=>{if(!I.trim())return;const Ke=await u.mutateAsync({name:I,description:V});Ke&&$.length>0&&await y.mutateAsync({planId:Ke.id,items:$}),Je()},fe=async()=>{!I.trim()||!E||(await p.mutateAsync({id:E,name:I,description:V}),await y.mutateAsync({planId:E,items:$}),Je())},Ve=Ke=>{var Ze;L(Ke.id),O(Ke.name),q(Ke.description||""),U(((Ze=Ke.items)==null?void 0:Ze.map(Et=>({month_number:Et.month_number,action_type_id:Et.action_type_id,default_script_id:Et.default_script_id||void 0,notes:Et.notes||void 0})))||[]),C(!0)},Je=()=>{C(!1),L(null),O(""),q(""),U([])},at=(Ke,Ze)=>{X(Ze)},Ae=(Ke,Ze,Et)=>{U($t=>[...$t.filter(Ps=>Ps.month_number!==Ke),{month_number:Ke,action_type_id:Ze,default_script_id:Et}]),Y(null),X(null)},Ye=Ke=>{U(Ze=>Ze.filter(Et=>Et.month_number!==Ke))},We=async()=>{if(!ae.trim()||!pe.trim()||!J)return;const Ke=await _.mutateAsync({actionTypeId:J,title:ae,scriptBody:pe,emailSubject:he||void 0,tone:je||void 0});Ke&&se!==null&&Ae(se,J,Ke.id),ie(!1),oe(""),_e(""),we(""),Ue("")},ot=J?i==null?void 0:i.filter(Ke=>Ke.action_type_id===J&&Ke.active):[],Ge=Ke=>q7e[Ke||"Phone"]||Pn,et=Ke=>q7e[Ke||"Users"]||lr;return e.jsxs(Es,{title:"Touchpoint Plans",description:"Assign plans to your contact groups",children:[e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Touchpoint Plans"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(xl,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(K,{onClick:()=>C(!0),className:"w-full sm:w-auto",children:[e.jsx(Us,{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 Ze=et(Ke.icon),Et=(o==null?void 0:o[Ke.id])||0,$t=Me(Ke.id),Yt=n==null?void 0:n.find(zs=>zs.id===($t==null?void 0:$t.plan_id)),Ps=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 ${Ps?"border-primary bg-primary/5 ring-2 ring-primary":"hover:bg-accent"} `,children:[e.jsx(Ze,{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:[Et," contacts"]})]}),Yt?e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:[e.jsx(ti,{className:"h-3 w-3 mr-1"}),Yt.name.split(" ")[0]]}):e.jsx(Qe,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},Ke.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:N&&qe?e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[(()=>{const Ke=et(qe.icon);return e.jsx(Ke,{className:"h-5 w-5"})})(),qe.name," Touchpoint Plan"]}),e.jsxs(hr,{children:["Choose a plan for your ",qe.name," contacts"]})]}),e.jsxs(Re,{className:"space-y-6",children:[ve&&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(ti,{className:"h-4 w-4 text-green-500"}),"Currently using: ",ve.name]}),ve.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:ve.description})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Fe(ve.id,N),children:"Disable"})]}),ve.items&&ve.items.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:o0e.map((Ke,Ze)=>{var Ps,zs;const Et=((Ps=ve.items)==null?void 0:Ps.filter(Zs=>Zs.month_number===Ze+1))||[],$t=(zs=Et[0])==null?void 0:zs.action_type,Yt=$t?Ge($t.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${Et.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:Ke}),Yt&&e.jsx(Yt,{className:"h-4 w-4 mx-auto mt-1",style:{color:($t==null?void 0:$t.color)||"#3B82F6"}})]},Ze)})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:ve?"Switch to a Different Plan":"Choose a Plan"}),Le.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"}),Le.map(Ke=>{var Et;const Ze=(ve==null?void 0:ve.id)===Ke.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${Ze?"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:[((Et=Ke.items)==null?void 0:Et.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Duplicate as my own plan",disabled:b.isPending,onClick:()=>{const $t=`${Ke.name} (Copy)`;b.mutate({sourcePlanId:Ke.id,newName:$t})},children:e.jsx(Ya,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:Ze?"outline":"default",disabled:Ze||d.isPending,onClick:()=>Fe(Ke.id,N),children:Ze?"Active":"Use This"})]})]},Ke.id)})]}),Ne.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),Ne.map(Ke=>{var Et;const Ze=(ve==null?void 0:ve.id)===Ke.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${Ze?"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:[((Et=Ke.items)==null?void 0:Et.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>Ve(Ke),children:e.jsx(Dy,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>x.mutate(Ke.id),children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})}),e.jsx(K,{size:"sm",variant:Ze?"outline":"default",disabled:Ze||d.isPending,onClick:()=>Fe(Ke.id,N),children:Ze?"Active":"Use This"})]})]},Ke.id)})]}),Le.length===0&&Ne.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(Pe,{children:e.jsxs(Re,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(on,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"Select a contact group to view and assign plans"})]})})})]}),e.jsx(Pe,{className:"bg-muted/50",children:e.jsx(Re,{className:"py-4",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"How it works:"})," When you assign a plan to a contact group, those contacts will appear in your daily suggested actions based on the plan's schedule."]})})})]}),e.jsx(fs,{open:k,onOpenChange:Ke=>{Ke?C(!0):Je()},children:e.jsxs(ms,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(bs,{children:E?"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(xe,{htmlFor:"plan-name",children:"Plan Name"}),e.jsx(De,{id:"plan-name",value:I,onChange:Ke=>O(Ke.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(vr,{id:"plan-description",value:V,onChange:Ke=>q(Ke.target.value),placeholder:"Describe your plan...",rows:2})]})]}),e.jsxs("div",{children:[e.jsx(xe,{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:o0e.map((Ke,Ze)=>{const Et=Ze+1,$t=$.find(zs=>zs.month_number===Et),Yt=$t?l==null?void 0:l.find(zs=>zs.id===$t.action_type_id):null,Ps=Yt?Ge(Yt.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>Y(se===Et?null:Et),className:` w-full p-3 rounded-lg border text-center transition-all ${$t?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${se===Et?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:Ke}),Ps?e.jsx(Ps,{className:"h-5 w-5 mx-auto mt-1",style:{color:(Yt==null?void 0:Yt.color)||"#3B82F6"}}):e.jsx(Us,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),$t&&e.jsx("button",{type:"button",onClick:zs=>{zs.stopPropagation(),Ye(Et)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(Sr,{className:"h-3 w-3"})})]},Ze)})}),se!==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 ",o0e[se-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(Ke=>Ke.active).map(Ke=>{const Ze=Ge(Ke.icon);return e.jsxs("button",{type:"button",onClick:()=>at(se,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(Ze,{className:"h-4 w-4",style:{color:Ke.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:Ke.name})]},Ke.id)})})]}),se!==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:()=>X(null),children:[e.jsx(xl,{className:"h-4 w-4 mr-1"})," Back"]})]}),e.jsxs("div",{className:"space-y-2 max-h-[300px] overflow-y-auto pr-1",children:[e.jsx("button",{type:"button",onClick:()=>Ae(se,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:()=>Ae(se,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(Qe,{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:()=>ie(!0),className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed bg-background hover:bg-accent transition-colors text-left",children:[e.jsx(Us,{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(En,{children:[e.jsx(K,{variant:"outline",onClick:Je,children:"Cancel"}),e.jsxs(K,{onClick:E?fe:dt,disabled:!I.trim()||u.isPending||p.isPending,children:[e.jsx(_c,{className:"h-4 w-4 mr-2"}),E?"Save Changes":"Create Plan"]})]})]})}),e.jsx(fs,{open:ce,onOpenChange:ie,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(xe,{htmlFor:"script-title",children:"Script Title"}),e.jsx(De,{id:"script-title",value:ae,onChange:Ke=>oe(Ke.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs(Bs,{value:je,onValueChange:Ue,children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select tone..."})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"friendly",children:"Friendly"}),e.jsx(vt,{value:"professional",children:"Professional"}),e.jsx(vt,{value:"casual",children:"Casual"}),e.jsx(vt,{value:"formal",children:"Formal"})]})]})]}),((xt=(ht=l==null?void 0:l.find(Ke=>Ke.id===J))==null?void 0:ht.name)==null?void 0:xt.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(De,{id:"script-email-subject",value:he,onChange:Ke=>we(Ke.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script-body",children:"Script Content"}),e.jsx(vr,{id:"script-body",value:pe,onChange:Ke=>_e(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(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>ie(!1),children:"Cancel"}),e.jsxs(K,{onClick:We,disabled:!ae.trim()||!pe.trim()||_.isPending,children:[e.jsx(_c,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}function qbs(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 Xat="popby_geocode_cache_v1";function Ubs(){try{return JSON.parse(localStorage.getItem(Xat)||"{}")}catch{return{}}}function Vbs(t){try{localStorage.setItem(Xat,JSON.stringify(t))}catch{}}function Hbs({contacts:t,onLogPopby:s}){const[r,n]=S.useState(null),[a,o]=S.useState("idle"),[l,i]=S.useState(5),[d,u]=S.useState(""),[p,x]=S.useState(new Map),[y,_]=S.useState(!1);S.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=S.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})};S.useEffect(()=>{if(!d||!r||b.length===0)return;let C=!1;const E=Ubs(),L=new Map;b.forEach(O=>{const V=[O.address,O.city,O.state,O.zip].filter(Boolean).join("|").toLowerCase();E[V]&&L.set(O.id,E[V])}),x(new Map(L));const I=b.filter(O=>!([O.address,O.city,O.state,O.zip].filter(Boolean).join("|").toLowerCase()in E));if(I.length!==0)return _(!0),(async()=>{const O=[...I],V=async()=>{var q,$;for(;O.length&&!C;){const U=O.shift(),se=[U.address,U.city,U.state,U.zip].filter(Boolean),Y=se.join("|").toLowerCase(),J=se.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[ie,ae]=ce.features[0].center;E[Y]={lat:ae,lng:ie},L.set(U.id,{lat:ae,lng:ie})}else E[Y]=null}catch{}}};await Promise.all([V(),V(),V(),V()]),C||(Vbs(E),x(new Map(L)),_(!1))})(),()=>{C=!0}},[d,r,b]);const w=S.useMemo(()=>{if(!r)return[];const C=[];return b.forEach(E=>{const L=p.get(E.id);if(!L)return;const I=qbs(r.lat,r.lng,L.lat,L.lng);I<=l&&C.push({...E,distanceMiles:I,lat:L.lat,lng:L.lng})}),C.sort((E,L)=>E.distanceMiles-L.distanceMiles)},[r,b,p,l]),k=C=>{const L=/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(L,"_blank","noopener")};return e.jsxs(Pe,{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(Ot,{className:"flex items-center gap-2 text-lg",children:[e.jsx(CM,{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(Bs,{value:String(l),onValueChange:C=>i(Number(C)),children:[e.jsx(Rs,{className:"w-[110px] h-9",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"2",children:"2 miles"}),e.jsx(vt,{value:"5",children:"5 miles"}),e.jsx(vt,{value:"10",children:"10 miles"}),e.jsx(vt,{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(oo,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(CM,{className:"h-4 w-4 mr-1"}),a==="ok"?"Refresh":"Use my location"]})]})]})}),e.jsxs(Re,{className:"space-y-3",children:[a==="idle"&&e.jsxs("div",{className:"text-center py-6 text-sm text-muted-foreground",children:[e.jsx(Da,{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(Lo,{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(Ns,{className:"h-14 w-full"}),e.jsx(Ns,{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(Qe,{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(oo,{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(Qe,{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(Qe,{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(Pn,{className:"h-4 w-4"})})}),e.jsx(K,{size:"icon",variant:"ghost",onClick:()=>k(C),className:"h-9 w-9",title:"Directions",children:e.jsx(jL,{className:"h-4 w-4"})}),e.jsxs(K,{size:"sm",onClick:()=>s(C),children:[e.jsx(Ui,{className:"h-4 w-4 mr-1"}),"Log"]})]})]},C.id))})]})]})]})}const Gbs="0dde5abb-0005-4c8c-a471-30d0cbc9e280",Wbs=[{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 Kbs(){const t=_r(),s=$at(),{data:r}=f_s(),{data:n}=jf(),{data:a}=LSe(),{data:o}=jme(90),{data:l}=qh(),i=__s(),d=y_s(),u=g_s(),p=v_s(),{data:x=[],isLoading:y}=gt({queryKey:["popby-templates"],queryFn:async()=>{const{data:ce,error:ie}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",Gbs).order("publish_date",{ascending:!1});if(ie)throw ie;const{data:ae}=await G.from("template_likes").select("template_id"),{data:oe}=await G.from("template_comments").select("template_id"),pe=new Map;ae==null||ae.forEach(he=>{pe.set(he.template_id,(pe.get(he.template_id)||0)+1)});const _e=new Map;return oe==null||oe.forEach(he=>{_e.set(he.template_id,(_e.get(he.template_id)||0)+1)}),(ce||[]).map(he=>({...he,likesCount:pe.get(he.id)||0,commentsCount:_e.get(he.id)||0}))}}),_=ce=>{const ie=l==null?void 0:l.find(ae=>ae.id===ce);return ie?`${ie.first_name} ${ie.last_name||""}`.trim():"Unknown"},b=ce=>{if(!ce)return null;const ie=r==null?void 0:r.find(ae=>ae.id===ce);return(ie==null?void 0:ie.name)||null},[N,w]=S.useState(null),[k,C]=S.useState(!1),[E,L]=S.useState(!1),[I,O]=S.useState(!1),[V,q]=S.useState({popby_item_id:"",notes:""}),[$,U]=S.useState({name:"",description:""}),se=async()=>{N&&(await d.mutateAsync({contact_id:N.id,popby_item_id:V.popby_item_id||void 0,notes:V.notes||void 0}),C(!1),w(null),q({popby_item_id:"",notes:""}))},Y=async()=>{$.name.trim()&&(await u.mutateAsync({name:$.name.trim(),description:$.description.trim()||void 0}),O(!1),U({name:"",description:""}))},J=async(ce,ie)=>{await p.mutateAsync({relationship_type_id:ce,frequency_days:parseInt(ie)})},X=ce=>{var ae;const ie=a==null?void 0:a.find(oe=>oe.relationship_type_id===ce);return((ae=ie==null?void 0:ie.frequency_days)==null?void 0:ae.toString())||"90"};return e.jsx(Es,{title:"Popbys",description:"Drop off gifts to stay top of mind",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Popbys"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{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(Da,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(K,{variant:"outline",onClick:()=>L(!0),children:[e.jsx(ko,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(K,{variant:"outline",onClick:()=>O(!0),children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(ia,{defaultValue:"due",children:[e.jsxs(ea,{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(Hbs,{contacts:s||[],onLogPopby:ce=>{w(ce),C(!0)}}),!s||s.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(Ui,{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(Pe,{className:"hover:shadow-md transition-shadow",children:e.jsx(Re,{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(Qe,{variant:"destructive",className:"text-xs",children:[ce.daysOverdue,"+ days overdue"]}),ce.daysSinceLastPopby===null&&e.jsx(Qe,{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(Da,{className:"h-3 w-3"}),ce.city||ce.address]}),ce.tags&&ce.tags.length>0&&e.jsx("span",{children:ce.tags.map(ie=>{var ae;return(ae=ie.relationship_type)==null?void 0:ae.name}).join(", ")})]}),ce.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",ps(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(Pn,{className:"h-4 w-4"})})}),e.jsxs(K,{size:"sm",onClick:()=>{w(ce),C(!0)},children:[e.jsx(ti,{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(Pe,{children:e.jsxs(Re,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(ln,{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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx(Re,{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(Ui,{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(Qe,{variant:"secondary",className:"text-xs",children:b(ce.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ps(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(Pe,{children:e.jsx(Re,{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(Ui,{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(Qe,{variant:"secondary",className:"mt-2 text-xs",children:"Shared"})]})]})})},ce.id)),e.jsx(Pe,{className:"border-dashed cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>O(!0),children:e.jsx(Re,{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(Us,{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:[x.length," template",x.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,ie)=>e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsx(Ns,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(Ns,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ns,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ns,{className:"h-5 w-16"}),e.jsx(Ns,{className:"h-5 w-20"})]})]})},ie))}),!y&&x.length===0&&e.jsx(Pe,{children:e.jsxs(Re,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(nl,{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&&x.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:x.map(ce=>e.jsxs(Pe,{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(Re,{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:Kde(ce.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(Qe,{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(Fu,{className:"h-3.5 w-3.5"}),ce.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vc,{className:"h-3.5 w-3.5"}),ce.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:ie=>{ie.stopPropagation(),t(`/templates/${ce.id}`)},children:[e.jsx(Kr,{className:"h-4 w-4"}),"View Template"]})]})]},ce.id))})]})]}),e.jsx(fs,{open:k,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(xe,{children:"Popby Item (optional)"}),e.jsxs(Bs,{value:V.popby_item_id,onValueChange:ce=>q(ie=>({...ie,popby_item_id:ce})),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select a popby item..."})}),e.jsx(Os,{children:r==null?void 0:r.map(ce=>e.jsx(vt,{value:ce.id,children:ce.name},ce.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Notes (optional)"}),e.jsx(vr,{placeholder:"Any notes about this popby...",value:V.notes,onChange:ce=>q(ie=>({...ie,notes:ce.target.value}))})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(K,{onClick:se,disabled:d.isPending,children:"Log Popby"})]})]})}),e.jsx(fs,{open:E,onOpenChange:L,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(xe,{className:"font-medium",children:ce.name}),e.jsxs(Bs,{value:X(ce.id),onValueChange:ie=>J(ce.id,ie),children:[e.jsx(Rs,{className:"w-[180px]",children:e.jsx(qs,{})}),e.jsx(Os,{children:Wbs.map(ie=>e.jsx(vt,{value:ie.value,children:ie.label},ie.value))})]})]},ce.id))]}),e.jsx(En,{children:e.jsx(K,{onClick:()=>L(!1),children:"Done"})})]})}),e.jsx(fs,{open:I,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(xe,{children:"Name *"}),e.jsx(De,{placeholder:"e.g., Homemade cookies",value:$.name,onChange:ce=>U(ie=>({...ie,name:ce.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(vr,{placeholder:"Optional description...",value:$.description,onChange:ce=>U(ie=>({...ie,description:ce.target.value}))})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(K,{onClick:Y,disabled:!$.name.trim()||u.isPending,children:"Add Item"})]})]})})]})})}const Zbs=bC({property_address:Wl().min(1,"Property address is required"),city:Wl().optional(),state:Wl().optional(),zip:Wl().optional(),transaction_type:qWe(["buyer","seller"]),close_date:Wl().min(1,"Close date is required"),sale_price:ZL().min(0,"Sale price must be positive"),commission_amount:ZL().optional(),lead_source_id:Wl().optional(),client_type_id:Wl().optional(),contact_id:Wl().optional(),notes:Wl().optional(),is_win:JCt()});function Qat({open:t,onOpenChange:s,transaction:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(""),[i,d]=S.useState(!1),[u,p]=S.useState(""),x=she(),y=XLt(),{data:_}=XA(),{data:b}=jf(),{data:N}=qh(),w=ehe(),k=nke(),{data:C}=rhe(),E=(C==null?void 0:C.show_commission)??!0,L=Hue({resolver:Gue(Zbs),defaultValues:{property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:new Date().toISOString().split("T")[0],sale_price:0,commission_amount:void 0,lead_source_id:void 0,client_type_id:void 0,contact_id:void 0,notes:"",is_win:!1}});S.useEffect(()=>{r?L.reset({property_address:r.property_address,city:r.city||"",state:r.state||"",zip:r.zip||"",transaction_type:r.transaction_type,close_date:r.close_date,sale_price:Number(r.sale_price),commission_amount:r.commission_amount?Number(r.commission_amount):void 0,lead_source_id:r.lead_source_id||void 0,client_type_id:r.client_type_id||void 0,contact_id:r.contact_id||void 0,notes:r.notes||"",is_win:r.is_win}):L.reset({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:new Date().toISOString().split("T")[0],sale_price:0,commission_amount:void 0,lead_source_id:void 0,client_type_id:void 0,contact_id:void 0,notes:"",is_win:!1})},[r,L]);const I=async $=>{const U={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,...U}):await x.mutateAsync(U),s(!1)},O=async()=>{if(!o.trim())return;const[$,...U]=o.trim().split(" "),se=U.join(" ")||null,Y=await w.mutateAsync({first_name:$,last_name:se,tagIds:[]});Y&&(L.setValue("contact_id",Y.id),l(""),d(!1),a(!1))},V=async()=>{if(!u.trim())return;const $=await k.mutateAsync(u.trim());$&&(L.setValue("lead_source_id",$.id),p(""))},q=N==null?void 0:N.find($=>$.id===L.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(ui,{className:"max-h-[70vh] pr-4",children:e.jsx(Wue,{...L,children:e.jsxs("form",{onSubmit:L.handleSubmit(I),className:"space-y-4",children:[e.jsx(Ec,{control:L.control,name:"property_address",render:({field:$})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Property Address *"}),e.jsx(hc,{children:e.jsx(De,{placeholder:"123 Main St",...$})}),e.jsx(vm,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Ec,{control:L.control,name:"city",render:({field:$})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"City"}),e.jsx(hc,{children:e.jsx(De,{placeholder:"City",...$})})]})}),e.jsx(Ec,{control:L.control,name:"state",render:({field:$})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"State"}),e.jsx(hc,{children:e.jsx(De,{placeholder:"TX",...$})})]})}),e.jsx(Ec,{control:L.control,name:"zip",render:({field:$})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Zip"}),e.jsx(hc,{children:e.jsx(De,{placeholder:"75001",...$})})]})})]}),e.jsx(Ec,{control:L.control,name:"transaction_type",render:({field:$})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Transaction Type *"}),e.jsxs(Bs,{onValueChange:$.onChange,value:$.value,children:[e.jsx(hc,{children:e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select type"})})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"buyer",children:"Buyer"}),e.jsx(vt,{value:"seller",children:"Seller"})]})]}),e.jsx(vm,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Ec,{control:L.control,name:"close_date",render:({field:$})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Close Date *"}),e.jsx(hc,{children:e.jsx(De,{type:"date",...$})}),e.jsx(vm,{})]})}),e.jsx(Ec,{control:L.control,name:"sale_price",render:({field:$})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Sale Price *"}),e.jsx(hc,{children:e.jsx(De,{type:"number",placeholder:"0",...$,onChange:U=>$.onChange(Number(U.target.value))})}),e.jsx(vm,{})]})})]}),E&&e.jsx(Ec,{control:L.control,name:"commission_amount",render:({field:$})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Commission"}),e.jsx(hc,{children:e.jsx(De,{type:"number",placeholder:"0",...$,value:$.value??"",onChange:U=>$.onChange(U.target.value?Number(U.target.value):void 0)})})]})}),e.jsx(Ec,{control:L.control,name:"lead_source_id",render:({field:$})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Lead Source"}),e.jsxs(Bs,{onValueChange:$.onChange,value:$.value||"",children:[e.jsx(hc,{children:e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select source"})})}),e.jsx(Os,{children:_==null?void 0:_.map(U=>e.jsx(vt,{value:U.id,children:U.name},U.id))})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{placeholder:"Add custom source...",value:u,onChange:$=>p($.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:V,disabled:!u.trim(),children:e.jsx(Us,{className:"h-4 w-4"})})]}),e.jsx(Ec,{control:L.control,name:"client_type_id",render:({field:$})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Client Type"}),e.jsxs(Bs,{onValueChange:$.onChange,value:$.value||"",children:[e.jsx(hc,{children:e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select client type"})})}),e.jsx(Os,{children:b==null?void 0:b.map(U=>e.jsx(vt,{value:U.id,children:U.name},U.id))})]})]})}),e.jsx(Ec,{control:L.control,name:"contact_id",render:({field:$})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Client Contact"}),e.jsxs(xo,{open:n,onOpenChange:a,children:[e.jsx(go,{asChild:!0,children:e.jsx(hc,{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(gx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs(lo,{className:"w-full p-0",align:"start",children:[e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search contacts..."}),e.jsxs(Mx,{children:[e.jsx(Tx,{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(Us,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),e.jsx(Ax,{children:N==null?void 0:N.map(U=>e.jsxs(lp,{value:`${U.first_name} ${U.last_name||""}`,onSelect:()=>{$.onChange(U.id),a(!1)},children:[e.jsx(Jn,{className:Rt("mr-2 h-4 w-4",U.id===$.value?"opacity-100":"opacity-0")}),U.first_name," ",U.last_name||""]},U.id))})]})]}),i&&e.jsxs("div",{className:"p-2 border-t space-y-2",children:[e.jsx(De,{placeholder:"Enter contact name...",value:o,onChange:U=>l(U.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(Ec,{control:L.control,name:"notes",render:({field:$})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Notes"}),e.jsx(hc,{children:e.jsx(vr,{placeholder:"Any notes about this transaction...",...$})})]})}),e.jsx(Ec,{control:L.control,name:"is_win",render:({field:$})=>e.jsxs(dc,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(uc,{children:"Mark as Win 🏆"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),e.jsx(hc,{children:e.jsx(Er,{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:x.isPending||y.isPending,children:[r?"Update":"Add"," Transaction"]})]})]})})})]})})}function FSe({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=S.useState(null),[i,d]=S.useState(null),[u,p]=S.useState(""),[x,y]=S.useState("all"),[_,b]=S.useState("all"),[N,w]=S.useState("all"),[k,C]=S.useState(!1),E=QLt(),L=she(),{data:I}=XA();jf();const O=vE(),V=U=>{const{id:se,created_at:Y,updated_at:J,lead_source:X,client_type:ce,contact:ie,...ae}=U;L.mutate(ae)},q=()=>{i&&(E.mutate(i),d(null))},$=t.filter(U=>{var ie,ae,oe,pe;const se=u===""||U.property_address.toLowerCase().includes(u.toLowerCase())||((ae=(ie=U.contact)==null?void 0:ie.first_name)==null?void 0:ae.toLowerCase().includes(u.toLowerCase()))||((pe=(oe=U.contact)==null?void 0:oe.last_name)==null?void 0:pe.toLowerCase().includes(u.toLowerCase())),Y=x==="all"||U.transaction_type===x,J=_==="all"||U.lead_source_id===_,X=N==="all"||U.client_type_id===N,ce=!k||U.is_win;return se&&Y&&J&&X&&ce});return r?e.jsx(Pe,{children:e.jsx(Re,{className:"p-6 space-y-4",children:[1,2,3].map(U=>e.jsx(Ns,{className:"h-16 w-full"},U))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{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(Ot,{children:["Transactions (",$.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search...",value:u,onChange:U=>p(U.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(Bs,{value:x,onValueChange:y,children:[e.jsx(Rs,{className:"w-[100px]",children:e.jsx(qs,{placeholder:"Type"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Types"}),e.jsx(vt,{value:"buyer",children:"Buyer"}),e.jsx(vt,{value:"seller",children:"Seller"})]})]}),e.jsxs(Bs,{value:_,onValueChange:b,children:[e.jsx(Rs,{className:"w-[130px]",children:e.jsx(qs,{placeholder:"Lead Source"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Sources"}),I==null?void 0:I.map(U=>e.jsx(vt,{value:U.id,children:U.name},U.id))]})]}),e.jsxs(K,{variant:k?"default":"outline",size:"sm",onClick:()=>C(!k),children:[e.jsx(ec,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(Re,{children:$.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No transactions found"}):O?e.jsx("div",{className:"space-y-3",children:$.map(U=>e.jsxs(Pe,{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:U.property_address}),U.is_win&&e.jsx(ec,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[U.city,U.state?`, ${U.state}`:""]})]}),e.jsx(Qe,{variant:U.transaction_type==="buyer"?"default":"secondary",children:U.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: "}),CEe(U.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),kl(U.sale_price)]}),s&&U.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),kl(U.commission_amount)]}),U.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),U.lead_source.name]}),U.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),U.contact.first_name," ",U.contact.last_name]}),n&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent: "}),n[U.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(U),children:e.jsx(Gc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>V(U),children:e.jsx(Ya,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(U.id),children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]})]},U.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:$.map(U=>{var se;return e.jsxs(Ms,{children:[n&&e.jsx(ut,{className:"font-medium text-sm",children:n[U.owner_user_id]||"Unknown"}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[U.is_win&&e.jsx(ec,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:U.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[U.city,U.state?`, ${U.state}`:""]})]})]})}),e.jsx(ut,{children:e.jsx(Qe,{variant:U.transaction_type==="buyer"?"default":"secondary",children:U.transaction_type})}),e.jsx(ut,{children:CEe(U.close_date)}),e.jsx(ut,{children:kl(U.sale_price)}),s&&e.jsx(ut,{children:U.commission_amount?kl(U.commission_amount):"-"}),e.jsx(ut,{children:((se=U.lead_source)==null?void 0:se.name)||"-"}),e.jsx(ut,{children:U.contact?`${U.contact.first_name} ${U.contact.last_name||""}`.trim():"-"}),!a&&e.jsx(ut,{children:e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(ax,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",children:[e.jsxs(va,{onClick:()=>l(U),children:[e.jsx(Gc,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(va,{onClick:()=>V(U),children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(va,{onClick:()=>d(U.id),className:"text-destructive",children:[e.jsx(gr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},U.id)})})]})})})]}),e.jsx(Qat,{open:!!o,onOpenChange:U=>!U&&l(null),transaction:o||void 0}),e.jsx(tc,{open:!!i,onOpenChange:U=>!U&&d(null),children:e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Delete Transaction?"}),e.jsx(Pl,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:q,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function Jat({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,k=o/12*100,C=b>=k?"ahead":b>=k*.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,x=y=>{switch(y){case"ahead":return e.jsxs(Qe,{className:"bg-green-500 text-white",children:[e.jsx(Yo,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(Qe,{variant:"secondary",children:[e.jsx(Yy,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(Qe,{variant:"destructive",children:[e.jsx(gS,{className:"h-3 w-3 mr-1"}),"Behind"]});default:return null}};return!t.transactions_goal&&!t.volume_goal&&!t.gci_goal?null:e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rh,{className:"h-5 w-5 text-primary"}),e.jsxs(Ot,{children:[r," Goals Progress"]})]})}),e.jsx(Re,{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"}),x(d.status)]}),e.jsx(gi,{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"}),x(u.status)]}),e.jsx(gi,{value:u.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[kl(s.totalVolume,!0)," of ",kl(t.volume_goal,!0)]}),e.jsxs("span",{children:[Math.round(u.percent),"%"]})]}),u.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",kl(u.pace,!0),"/month"]})]}),n&&t.gci_goal&&p&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"GCI"}),x(p.status)]}),e.jsx(gi,{value:p.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[kl(s.totalCommission,!0)," of ",kl(t.gci_goal,!0)]}),e.jsxs("span",{children:[Math.round(p.percent),"%"]})]}),p.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",kl(p.pace,!0),"/month"]})]})]})})]})}const Ybs={light:"",dark:".dark"},eit=S.createContext(null);function tit(){const t=S.useContext(eit);if(!t)throw new Error("useChart must be used within a ");return t}const sit=S.forwardRef(({id:t,className:s,children:r,config:n,...a},o)=>{const l=S.useId(),i=`chart-${t||l.replace(/:/g,"")}`;return e.jsx(eit.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(Xbs,{id:i,config:n}),e.jsx(QM,{children:r})]})})});sit.displayName="Chart";const Xbs=({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(Ybs).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},rit=S.forwardRef(({active:t,payload:s,className:r,indicator:n="dot",hideLabel:a=!1,hideIndicator:o=!1,label:l,labelFormatter:i,labelClassName:d,formatter:u,color:p,nameKey:x,labelKey:y},_)=>{const{config:b}=tit(),N=S.useMemo(()=>{var I;if(a||!(s!=null&&s.length))return null;const[k]=s,C=`${y||k.dataKey||k.name||"value"}`,E=Mwe(b,k,C),L=!y&&typeof l=="string"?((I=b[l])==null?void 0:I.label)||l:E==null?void 0:E.label;return i?e.jsx("div",{className:Rt("font-medium",d),children:i(L,s)}):L?e.jsx("div",{className:Rt("font-medium",d),children:L}):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((k,C)=>{const E=`${x||k.name||k.dataKey||"value"}`,L=Mwe(b,k,E),I=p||k.payload.fill||k.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&&(k==null?void 0:k.value)!==void 0&&k.name?u(k.value,k.name,k,C,k.payload):e.jsxs(e.Fragment,{children:[L!=null&&L.icon?e.jsx(L.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":I,"--color-border":I}}),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:(L==null?void 0:L.label)||k.name})]}),k.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:k.value.toLocaleString()})]})]})},k.dataKey)})})]})});rit.displayName="ChartTooltip";const Qbs=S.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=tit();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=Mwe(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});Qbs.displayName="ChartLegend";function Mwe(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 g9=["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 zSe({stats:t,year:s}){const r=t.transactionsByMonth.some(a=>a.count>0),n=t.leadSourceBreakdown.length>0;return!r&&!n?e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{className:"overflow-hidden",children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Transactions by Month"})}),e.jsx(Re,{className:"overflow-hidden",children:e.jsx(sit,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(QM,{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(cC,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(dC,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(ep,{content:e.jsx(rit,{})}),e.jsx(y1,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Re,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(QM,{width:"100%",height:"100%",children:e.jsxs(jat,{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(lO,{fill:g9[o%g9.length]},`cell-${o}`))}),e.jsx(ep,{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:g9[o%g9.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function Jbs(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=Qje(s,n,new Date);if(y1e(a))return ps(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(y1e(n))return ps(n,"yyyy-MM-dd")}catch{}return null}const ews=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function tws({open:t,onOpenChange:s}){const[r,n]=S.useState([]),[a,o]=S.useState(!1),[l,i]=S.useState(0),{data:d}=XA(),{data:u}=jf(),p=she(),x=()=>{const k=ews.join(","),C=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),E=`${k} ${C}`,L=new Blob([E],{type:"text/csv"}),I=URL.createObjectURL(L),O=document.createElement("a");O.href=I,O.download="transaction-import-template.csv",O.click(),URL.revokeObjectURL(I)},y=k=>{const C=k.split(` `).filter(L=>L.trim());if(C.length<2)return[];const E=C[0].split(",").map(L=>L.trim().toLowerCase().replace(/['"]/g,""));return C.slice(1).map((L,I)=>{var ae,oe,pe,_e;const O=[];let V="",q=!1;for(const he of L)he==='"'?q=!q:he===","&&!q?(O.push(V.trim()),V=""):V+=he;O.push(V.trim());const $=he=>{var je;const we=E.indexOf(he);return we>=0?(je=O[we])==null?void 0:je.replace(/^["']|["']$/g,"").trim():""},U=(ae=$("transaction_type"))==null?void 0:ae.toLowerCase(),se=(oe=$("sale_price"))==null?void 0:oe.replace(/[$,]/g,""),Y=(pe=$("commission_amount"))==null?void 0:pe.replace(/[$,]/g,""),J=(_e=$("is_win"))==null?void 0:_e.toLowerCase(),X=$("close_date"),ce=Jbs(X);let ie;return $("property_address")?["buyer","seller"].includes(U)?ce?(!se||isNaN(Number(se)))&&(ie="Invalid sale price"):ie=`Invalid date format: "${X}" - use MM/DD/YYYY or YYYY-MM-DD`:ie='Transaction type must be "buyer" or "seller"':ie="Missing property address",{property_address:$("property_address"),city:$("city"),state:$("state"),zip:$("zip"),transaction_type:U==="seller"?"seller":"buyer",close_date:ce||"",sale_price:Number(se)||0,commission_amount:Y?Number(Y):null,lead_source_name:$("lead_source"),client_type_name:$("client_type"),is_win:["yes","true","1"].includes(J),notes:$("notes"),error:ie}})},_=k=>{var L;const C=(L=k.target.files)==null?void 0:L[0];if(!C)return;const E=new FileReader;E.onload=I=>{var q;const O=(q=I.target)==null?void 0:q.result,V=y(O);n(V)},E.readAsText(C)},b=async()=>{const k=r.filter(L=>!L.error);if(k.length===0){me.error("No valid transactions to import");return}o(!0),i(0);let C=0,E=0;for(let L=0;Lq.name.toLowerCase()===I.lead_source_name.toLowerCase()),V=u==null?void 0:u.find(q=>q.name.toLowerCase()===I.client_type_name.toLowerCase());await p.mutateAsync({property_address:I.property_address,city:I.city||null,state:I.state||null,zip:I.zip||null,transaction_type:I.transaction_type,close_date:I.close_date,sale_price:I.sale_price,commission_amount:I.commission_amount,lead_source_id:(O==null?void 0:O.id)||null,client_type_id:(V==null?void 0:V.id)||null,contact_id:null,notes:I.notes||null,is_win:I.is_win}),C++}catch(O){E++,console.error("Failed to import transaction:",O)}i(Math.round((L+1)/k.length*100))}o(!1),C>0&&me.success(`Imported ${C} transaction${C>1?"s":""}`),E>0&&me.error(`Failed to import ${E} transaction${E>1?"s":""}`),n([]),s(!1)},N=r.filter(k=>!k.error).length,w=r.filter(k=>k.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(Ir,{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:x,children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Template"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"csv-file",children:"Upload CSV File"}),e.jsx(De,{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(Qe,{variant:"outline",children:[r.length," rows found"]}),N>0&&e.jsxs(Qe,{className:"bg-green-500 text-white",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),N," valid"]}),w>0&&e.jsxs(Qe,{variant:"destructive",children:[e.jsx(Lo,{className:"h-3 w-3 mr-1"}),w," errors"]})]}),e.jsx(ui,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((k,C)=>e.jsxs("div",{className:`p-2 rounded text-sm ${k.error?"bg-destructive/10":"bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:k.property_address||"(no address)"}),e.jsx(Qe,{variant:k.transaction_type==="buyer"?"default":"secondary",children:k.transaction_type})]}),e.jsxs("div",{className:"text-muted-foreground",children:[k.close_date," • $",k.sale_price.toLocaleString()]}),k.error&&e.jsx(a4e,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(i4e,{className:"text-xs",children:k.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($a,{className:"h-4 w-4 mr-2"}),"Import ",N," Transaction",N!==1?"s":""]})]})]})]})})}const sws=bC({transactions_goal:ZL().min(0).optional(),volume_goal:ZL().min(0).optional(),gci_goal:ZL().min(0).optional()});function rws({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=JLt(),{data:o}=rhe(),l=(o==null?void 0:o.show_commission)??!0,i=Hue({resolver:Gue(sws),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});S.useEffect(()=>{n?i.reset({transactions_goal:n.transactions_goal??void 0,volume_goal:n.volume_goal?Number(n.volume_goal):void 0,gci_goal:n.gci_goal?Number(n.gci_goal):void 0}):i.reset({transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0})},[n,i,t]);const d=async u=>{await a.mutateAsync({year:r,transactions_goal:u.transactions_goal??null,volume_goal:u.volume_goal??null,gci_goal:l?u.gci_goal??null:null}),s(!1)};return e.jsx(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(Ir,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(Wue,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(d),className:"space-y-4",children:[e.jsx(Ec,{control:i.control,name:"transactions_goal",render:({field:u})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Transactions Goal"}),e.jsx(hc,{children:e.jsx(De,{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(Kie,{children:"Total number of deals you want to close"}),e.jsx(vm,{})]})}),e.jsx(Ec,{control:i.control,name:"volume_goal",render:({field:u})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"Volume Goal ($)"}),e.jsx(hc,{children:e.jsx(De,{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(Kie,{children:"Total sales volume you want to achieve"}),e.jsx(vm,{})]})}),l&&e.jsx(Ec,{control:i.control,name:"gci_goal",render:({field:u})=>e.jsxs(dc,{children:[e.jsx(uc,{children:"GCI Goal ($)"}),e.jsx(hc,{children:e.jsx(De,{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(Kie,{children:"Gross commission income target"}),e.jsx(vm,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:a.isPending,children:"Save Goals"})]})]})})]})})}function BSe({transactions:t,isLoading:s}){const r=S.useRef(null),n=S.useRef(null),a=S.useRef([]),o=S.useRef(null),{isAdmin:l}=Fs(),[i,d]=S.useState(""),[u,p]=S.useState(!0),[x,y]=S.useState(0),[_,b]=S.useState(!1),N=t.filter(k=>k.latitude!=null&&k.longitude!=null),w=t.filter(k=>k.latitude==null||k.longitude==null);return S.useEffect(()=>{(async()=>{p(!0);try{const{data:C}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();C!=null&&C.value&&d(C.value)}catch(C){console.error("Error fetching mapbox token:",C)}p(!1)})()},[]),S.useEffect(()=>{if(!i||w.length===0||_)return;(async()=>{var E;b(!0);let C=0;for(const L of w){const I=[L.property_address,L.city,L.state,L.zip].filter(Boolean).join(", ");if(I)try{const V=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(I)}.json?access_token=${i}&limit=1`)).json();if((E=V.features)!=null&&E[0]){const[q,$]=V.features[0].center;await G.from("scorecard_transactions").update({latitude:$,longitude:q}).eq("id",L.id),L.latitude=$,L.longitude=q,C++}}catch(O){console.error("Geocode error:",O)}}y(C),b(!1)})()},[i,t]),S.useEffect(()=>{if(!r.current||!i||n.current)return;xc.accessToken=i;const k=t.filter(L=>L.latitude!=null&&L.longitude!=null);let C=[-98.5795,39.8283],E=4;if(k.length>0){const L=k.reduce((O,V)=>O+V.longitude,0)/k.length,I=k.reduce((O,V)=>O+V.latitude,0)/k.length;C=[L,I],E=k.length===1?12:10}return n.current=new xc.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:E,center:C}),n.current.addControl(new xc.NavigationControl,"top-right"),()=>{var L;(L=n.current)==null||L.remove(),n.current=null}},[i]),S.useEffect(()=>{var C;if(!n.current||!i)return;a.current.forEach(E=>E.remove()),a.current=[],(C=o.current)==null||C.remove();const k=t.filter(E=>E.latitude!=null&&E.longitude!=null);if(k.forEach(E=>{var $;const L=E.transaction_type==="buyer",I=L?"#3B82F6":"#10B981",O=document.createElement("div");O.className="cursor-pointer",O.innerHTML=`
${L?'':''}
`;const V=new xc.Popup({offset:25,closeButton:!0}).setHTML(`
${E.property_address}
${E.city?`
${E.city}${E.state?", "+E.state:""} ${E.zip||""}
`:""}
${L?"Buyer":"Seller"} $${Number(E.sale_price).toLocaleString()}
Closed: ${ml(E.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${($=E.lead_source)!=null&&$.name?" · "+E.lead_source.name:""}
${E.contact?`
Client: ${E.contact.first_name} ${E.contact.last_name||""}
`:""}
`),q=new xc.Marker(O).setLngLat([E.longitude,E.latitude]).setPopup(V).addTo(n.current);a.current.push(q)}),k.length>1){const E=new xc.LngLatBounds;k.forEach(L=>E.extend([L.longitude,L.latitude])),n.current.fitBounds(E,{padding:60,maxZoom:13})}else k.length===1&&n.current.flyTo({center:[k[0].longitude,k[0].latitude],zoom:12})},[t,i,_]),u||s?e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(Da,{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(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(Lo,{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 nit=()=>{const{data:t}=Px();return gt({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"})},nws=t=>{const{data:s}=Px(),{data:r}=nit();return gt({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 aws(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 iws(t,s){return t?t.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2):s[0].toUpperCase()}function ows({year:t}){var y;const{data:s,isLoading:r}=nit(),{data:n,isLoading:a}=nws(t),o=_r(),l=r||a,{aggregate:i,memberStats:d,topPerformer:u,agentNameMap:p,teamChartStats:x}=S.useMemo(()=>{if(!s||!n)return{aggregate:null,memberStats:[],topPerformer:null,agentNameMap:{},teamChartStats:null};const _=s.map(U=>aws(U,n));_.sort((U,se)=>se.totalVolume-U.totalVolume);const b={};s.forEach(U=>{b[U.id]=U.name||U.email});const N=n.length,w=n.reduce((U,se)=>U+Number(se.sale_price),0),k=n.reduce((U,se)=>U+(Number(se.commission_amount)||0),0),C=n.filter(U=>U.transaction_type==="buyer").length,E=n.filter(U=>U.transaction_type==="seller").length,L={};n.forEach(U=>{var Y;const se=((Y=U.lead_source)==null?void 0:Y.name)||"Unknown";L[se]=(L[se]||0)+1});const I=Object.entries(L).sort((U,se)=>se[1]-U[1])[0],O={};n.forEach(U=>{const se=ml(U.close_date).toLocaleString("default",{month:"short"});O[se]=(O[se]||0)+1});const q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(U=>({month:U,count:O[U]||0})),$=Object.entries(L).map(([U,se])=>({name:U,count:se})).sort((U,se)=>se.count-U.count);return{aggregate:{totalTxns:N,buyerCount:C,sellerCount:E,totalVolume:w,avgPrice:N>0?w/N:0,totalGCI:k,topSource:I?{name:I[0],count:I[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(Ns,{className:"h-24"},_))}),e.jsx(Ns,{className:"h-64"})]}):!i||d.length===0?e.jsx(Pe,{className:"py-12",children:e.jsxs(Re,{className:"text-center space-y-2",children:[e.jsx(lr,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(lr,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(yc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Team Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:kl(i.totalVolume,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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:kl(i.avgPrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(yc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Team GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:kl(i.totalGCI,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ec,{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(Pe,{className:"border-primary/30 bg-primary/5",children:e.jsxs(Re,{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(Vi,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground",children:["Top Performer — ",t]}),e.jsx("p",{className:"text-lg font-bold",children:u.member.name||u.member.email})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.totalTransactions," deals"]}),e.jsx("p",{className:"font-semibold",children:kl(u.totalVolume,!0)})]})]})}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"Member Performance"})}),e.jsx(Re,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:d.map((_,b)=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[b===0&&_.totalTransactions>0&&e.jsx(Vi,{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(Ta,{src:_.member.avatar_url||void 0}),e.jsx(_n,{className:"text-xs",children:iws(_.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(ut,{className:"text-center font-semibold",children:_.totalTransactions}),e.jsxs(ut,{className:"text-center text-sm",children:[_.buyerCount," / ",_.sellerCount]}),e.jsx(ut,{className:"text-right font-medium",children:kl(_.totalVolume,!0)}),e.jsx(ut,{className:"text-right text-sm",children:kl(_.averagePrice,!0)}),e.jsx(ut,{className:"text-right font-medium",children:kl(_.totalGCI,!0)}),e.jsx(ut,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>o(`/mission-control/scorecard/${_.member.id}`),children:e.jsx(wn,{className:"h-4 w-4"})})})]},_.member.id))})]})})})]}),e.jsxs(ia,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(ea,{children:[e.jsxs(ls,{value:"transactions",children:[e.jsx(Dh,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(ls,{value:"charts",children:[e.jsx(to,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(ls,{value:"map",children:[e.jsx(Da,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(js,{value:"transactions",children:e.jsx(FSe,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:p,readOnly:!0})}),e.jsx(js,{value:"charts",children:x&&e.jsx(zSe,{stats:x,year:t})}),e.jsx(js,{value:"map",children:e.jsx(BSe,{transactions:n||[],isLoading:a})})]})]})}const ait=new Date().getFullYear(),U7e=Array.from({length:10},(t,s)=>ait-s);function lws(){var U;const[t,s]=S.useState(ait),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(!1),[p,x]=S.useState("my"),{data:y}=Px(),_=(y==null?void 0:y.role)==="team_leader",{data:b,isLoading:N}=ake(t),{yearStats:w,lifetimeStats:k,isLoading:C,showCommission:E}=EXe(t),{data:L,isLoading:I}=AXe(t),{data:O}=rhe(),V=e8t(),q=()=>{if(!b||b.length===0)return;const se=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...E?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],Y=b.map(ae=>{var oe,pe;return[ae.property_address,ae.city||"",ae.state||"",ae.zip||"",ae.transaction_type,ae.close_date,ae.sale_price,...E?[ae.commission_amount||""]:[],((oe=ae.lead_source)==null?void 0:oe.name)||"",((pe=ae.client_type)==null?void 0:pe.name)||"",ae.contact?`${ae.contact.first_name} ${ae.contact.last_name||""}`.trim():"",ae.is_win?"Yes":"No",ae.notes||""]}),J=[se,...Y].map(ae=>ae.map(oe=>`"${String(oe).replace(/"/g,'""')}"`).join(",")).join(` `),X=new Blob([J],{type:"text/csv"}),ce=URL.createObjectURL(X),ie=document.createElement("a");ie.href=ce,ie.download=`transactions-${t}.csv`,ie.click(),URL.revokeObjectURL(ce)},$=!b||b.length===0;return e.jsxs(Es,{title:"Scorecard",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Scorecard"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500/50 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),_&&e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 w-fit",children:[e.jsx(K,{variant:p==="my"?"default":"ghost",size:"sm",onClick:()=>x("my"),className:"h-8",children:"My Scorecard"}),e.jsxs(K,{variant:p==="team"?"default":"ghost",size:"sm",onClick:()=>x("team"),className:"h-8",children:[e.jsx(lr,{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(Bs,{value:String(t),onValueChange:se=>s(Number(se)),children:[e.jsx(Rs,{className:"w-[120px]",children:e.jsx(qs,{})}),e.jsx(Os,{children:U7e.map(se=>e.jsx(vt,{value:String(se),children:se},se))})]})]}),e.jsx(ows,{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(Bs,{value:String(t),onValueChange:se=>s(Number(se)),children:[e.jsx(Rs,{className:"w-[120px]",children:e.jsx(qs,{})}),e.jsx(Os,{children:U7e.map(se=>e.jsx(vt,{value:String(se),children:se},se))})]}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(!d),children:e.jsx(ko,{className:"h-4 w-4"})})]})]}),d&&e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(Ot,{className:"text-lg",children:"Settings"})}),e.jsx(Re,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(xe,{children:"Show Commission"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display commission fields and include in stats"})]}),e.jsx(Er,{checked:(O==null?void 0:O.show_commission)??!0,onCheckedChange:se=>V.mutate({show_commission:se})})]})})]}),$&&!N?e.jsx(Pe,{className:"py-12",children:e.jsxs(Re,{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(to,{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(Us,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx($a,{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(Us,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(Rh,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx($a,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(K,{variant:"outline",onClick:q,disabled:$,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(Pe,{children:e.jsxs(Re,{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:[k.totalTransactions," lifetime"]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(lr,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(yc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:kl(w.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[kl(k.totalVolume,!0)," lifetime"]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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:kl(w.averagePrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ec,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((U=w.topLeadSource)==null?void 0:U.name)||"-"}),w.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w.topLeadSource.count," deals"]})]})}),E&&e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(yc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:kl(w.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[kl(k.totalCommission,!0)," lifetime"]})]})}),E&&w.totalNetToAgent>0&&w.totalNetToAgent!==w.totalCommission&&e.jsx(Pe,{children:e.jsxs(Re,{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(yc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Net to Agent"})]}),e.jsx("p",{className:"text-2xl font-bold text-teal-600 dark:text-teal-400",children:kl(w.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[kl(k.totalNetToAgent,!0)," lifetime"]})]})})]}),L&&e.jsx(Jat,{goals:L,stats:w,year:t,showCommission:E}),e.jsxs(ia,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(ea,{children:[e.jsx(ls,{value:"transactions",children:"Transactions"}),e.jsx(ls,{value:"charts",children:"Charts"}),e.jsxs(ls,{value:"map",children:[e.jsx(Da,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(js,{value:"transactions",children:e.jsx(FSe,{transactions:b||[],showCommission:E,isLoading:N})}),e.jsx(js,{value:"charts",children:e.jsx(zSe,{stats:w,year:t})}),e.jsx(js,{value:"map",children:e.jsx(BSe,{transactions:b||[],isLoading:N})})]})]})]})]}),e.jsx(Qat,{open:r,onOpenChange:n}),e.jsx(tws,{open:a,onOpenChange:o}),e.jsx(rws,{open:l,onOpenChange:i,year:t,existingGoals:L})]})}function iit({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=Fs(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,x]=S.useState(!1);S.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:w,error:k}=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(k)throw k;if(w&&w.share_token)i(w);else if(w&&!w.share_token){const{data:C,error:E}=await G.from("listing_shares").update({share_type:"referral_link"}).eq("id",w.id).select("id, share_token, click_count, lead_count").single();if(E)throw E;i(C)}else{const{data:C,error:E}=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(E)throw E;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),x(!0),me.success("Link copied to clipboard!"),setTimeout(()=>x(!1),2e3)}catch{me.error("Failed to copy link")}},b=N=>{const w=encodeURIComponent(y),k=encodeURIComponent(`Check out this listing: ${a}`);switch(N){case"email":window.open(`mailto:?subject=${k}&body=${w}`);break;case"text":window.open(`sms:?body=${k}%20${w}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${w}`,"_blank");break}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx($r,{className:"h-5 w-5 text-amber-500"}),"Share & Earn Leads"]}),e.jsx(Ir,{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(xe,{children:"Your Referral Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{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(Jn,{className:"h-4 w-4"}):e.jsx(Ya,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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(rr,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("text"),disabled:d,children:[e.jsx(ki,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("facebook"),disabled:d,children:[e.jsx(uu,{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(xe,{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(wn,{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(lr,{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 cws={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},dws={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},uws={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function y9({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var N,w;const{user:o}=Fs(),{data:l}=NXe(t.id),i=jXe(),[d,u]=S.useState(!1),p=k=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(k),x=((N=t.photos)==null?void 0:N.find(k=>k.is_primary))||((w=t.photos)==null?void 0:w[0]),y=(o==null?void 0:o.id)===t.agent_id,_=async k=>{k.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=k=>{if(k.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(Pe,{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:[x?e.jsx("img",{src:x.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(s0,{className:"h-12 w-12"})}),e.jsx(Qe,{className:`absolute top-2 left-2 ${cws[t.status]} text-white border-0`,children:dws[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(Hn,{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($r,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(iit,{open:d,onOpenChange:u,listingId:t.id,listingSlug:t.slug||null,listingTitle:t.property_address||`${t.city}, ${t.state}`}),e.jsxs(Re,{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(Qe,{variant:"outline",className:"text-xs",children:[e.jsx(lr,{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(Da,{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(Wy,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(rf,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(s0,{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(Qe,{variant:"secondary",className:"text-xs",children:uws[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(wn,{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:k=>{k.stopPropagation(),r()},children:[e.jsx(Gc,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(K,{variant:"destructive",size:"sm",onClick:k=>{k.stopPropagation(),n()},children:e.jsx(gr,{className:"h-4 w-4"})})]})]})]})}const hws=[{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"}],mws=[{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 pws({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(Ot,{className:"text-lg",children:"Filters"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Clear All"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Sr,{className:"h-4 w-4"})})]})]}),e.jsxs(Re,{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(xe,{children:"Status"}),e.jsxs(Bs,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"All statuses"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Statuses"}),hws.map(a=>e.jsx(vt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Property Type"}),e.jsxs(Bs,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"All types"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Types"}),mws.map(a=>e.jsx(vt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Min Price"}),e.jsx(De,{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(xe,{children:"Max Price"}),e.jsx(De,{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(xe,{children:"Open to Referrals Only"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),e.jsx(Er,{checked:t.openToReferrals||!1,onCheckedChange:a=>s({...t,openToReferrals:a||void 0})})]})]})]})}function fws({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(Vi,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(Xv,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(ec,{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(Qe,{variant:l===0?"default":"secondary",children:[o.count," ",a]})]},o.agentId))});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Vi,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),e.jsx(Re,{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(Xv,{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(Vi,{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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Community Leaderboard"})}),e.jsx(Re,{children:e.jsxs(ia,{defaultValue:"sharers",children:[e.jsxs(ea,{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 V7e={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},H7e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function xws(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function gws({listings:t,isLoading:s}){const r=_r(),n=S.useRef(null),a=S.useRef(null),o=S.useRef([]),{isAdmin:l}=Fs(),[i,d]=S.useState(""),[u,p]=S.useState(!0),[x,y]=S.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 S.useEffect(()=>{(async()=>{p(!0);try{const{data:w}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();w!=null&&w.value&&d(w.value)}catch(w){console.error("Error fetching mapbox token:",w)}p(!1)})()},[]),S.useEffect(()=>{if(!i||b.length===0||x)return;(async()=>{var w;y(!0);for(const k of b){const C=[k.property_address,k.city,k.state].filter(Boolean).join(", ");if(C)try{const L=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(C)}.json?access_token=${i}&limit=1`)).json();if((w=L.features)!=null&&w[0]){const[I,O]=L.features[0].center;await G.from("listings").update({latitude:O,longitude:I}).eq("id",k.id),k.latitude=O,k.longitude=I}}catch(E){console.error("Geocode error:",E)}}y(!1)})()},[i,t]),S.useEffect(()=>{if(!n.current||!i||a.current)return;xc.accessToken=i;const N=t.filter(C=>C.latitude!=null&&C.longitude!=null);let w=[-98.5795,39.8283],k=4;if(N.length>0){const C=N.reduce((L,I)=>L+I.longitude,0)/N.length,E=N.reduce((L,I)=>L+I.latitude,0)/N.length;w=[C,E],k=N.length===1?12:10}return a.current=new xc.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:k,center:w}),a.current.addControl(new xc.NavigationControl,"top-right"),()=>{var C;(C=a.current)==null||C.remove(),a.current=null}},[i]),S.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(w=>w.remove()),o.current=[];const N=t.filter(w=>w.latitude!=null&&w.longitude!=null);if(N.forEach(w=>{var O,V,q;const k=V7e[w.status]||"#10B981",C=((O=w.photos)==null?void 0:O.find($=>$.is_primary))||((V=w.photos)==null?void 0:V[0]),E=document.createElement("div");E.className="cursor-pointer",E.innerHTML=`
`;const L=new xc.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${C!=null&&C.photo_url?``:""}
${xws(w.price)}
${w.property_address||""}
${w.city}, ${w.state}
${H7e[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 →
`),I=new xc.Marker(E).setLngLat([w.longitude,w.latitude]).setPopup(L).addTo(a.current);o.current.push(I)}),N.length>1){const w=new xc.LngLatBounds;N.forEach(k=>w.extend([k.longitude,k.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,x]),S.useEffect(()=>(window.__navigateToListing__=N=>{r(`/mission-control/listings/${N}`)},()=>{delete window.__navigateToListing__}),[r]),u||s?e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(Da,{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(V7e).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:H7e[N]})]},N)),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[_.length," of ",t.length," mapped",x&&" · Geocoding..."]})]}),e.jsx("div",{ref:n,className:"w-full h-[60vh] rounded-lg shadow-lg border"})]}):e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(Lo,{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 yws(){var $,U,se,Y,J,X,ce,ie;const t=_r(),{brokerageId:s}=Fs(),{data:r,isLoading:n}=yXe(),[a,o]=S.useState("feed"),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,x]=S.useState({sortBy:"newest"}),{data:y,isLoading:_}=vXe({...p,city:d||p.city}),{data:b,isLoading:N}=RLt(),{data:w,isLoading:k}=_Xe(),{data:C,isLoading:E}=BLt(),{data:L,isLoading:I}=ULt(),{data:O}=qLt(),V=wXe(),q=async ae=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await V.mutateAsync(ae),me.success("Listing deleted successfully")}catch{me.error("Failed to delete listing")}};return n?e.jsx(Es,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})})}):r?e.jsx(Es,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Listing Exchange"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Us,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-emerald-500/10 rounded-lg",children:e.jsx(H4,{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(Pe,{children:e.jsxs(Re,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(lr,{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)+(((U=C==null?void 0:C.received)==null?void 0:U.length)||0)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Referrals"})]})]})})]}),e.jsxs(ia,{value:a,onValueChange:o,children:[e.jsxs(ea,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by city or neighborhood...",value:d,onChange:ae=>u(ae.target.value),className:"pl-9"})]}),e.jsxs(Bs,{value:p.sortBy,onValueChange:ae=>x({...p,sortBy:ae}),children:[e.jsx(Rs,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"Sort by"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"newest",children:"Newest First"}),e.jsx(vt,{value:"updated",children:"Recently Updated"}),e.jsx(vt,{value:"price_asc",children:"Price: Low to High"}),e.jsx(vt,{value:"price_desc",children:"Price: High to Low"})]})]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!l),children:[e.jsx(Eg,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(pws,{filters:p,onFiltersChange:x,onClose:()=>i(!1)}),_?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((ae,oe)=>e.jsxs(Pe,{children:[e.jsx(Ns,{className:"h-48 w-full"}),e.jsxs(Re,{className:"p-4 space-y-2",children:[e.jsx(Ns,{className:"h-5 w-3/4"}),e.jsx(Ns,{className:"h-4 w-1/2"}),e.jsx(Ns,{className:"h-4 w-1/4"})]})]},oe))}):(y==null?void 0:y.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{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(Us,{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(ae=>e.jsx(y9,{listing:ae,onClick:()=>t(`/mission-control/listings/${ae.id}`)},ae.id))})]}),e.jsx(js,{value:"my-listings",className:"space-y-4",children:k?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ae,oe)=>e.jsxs(Pe,{children:[e.jsx(Ns,{className:"h-48 w-full"}),e.jsxs(Re,{className:"p-4 space-y-2",children:[e.jsx(Ns,{className:"h-5 w-3/4"}),e.jsx(Ns,{className:"h-4 w-1/2"})]})]},oe))}):(w==null?void 0:w.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(H4,{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(Us,{className:"h-4 w-4 mr-2"}),"Add Your First Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w==null?void 0:w.map(ae=>e.jsx(y9,{listing:ae,showActions:!0,onClick:()=>t(`/mission-control/listings/${ae.id}`),onEdit:()=>t(`/mission-control/listings/${ae.id}/edit`),onDelete:()=>q(ae.id)},ae.id))})}),e.jsx(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((ae,oe)=>e.jsxs(Pe,{children:[e.jsx(Ns,{className:"h-48 w-full"}),e.jsxs(Re,{className:"p-4 space-y-2",children:[e.jsx(Ns,{className:"h-5 w-3/4"}),e.jsx(Ns,{className:"h-4 w-1/2"})]})]},oe))}):(b==null?void 0:b.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{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(ae=>e.jsx(y9,{listing:ae.listing,onClick:()=>t(`/mission-control/listings/${ae.listing.id}`)},ae.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 (",((se=C==null?void 0:C.sent)==null?void 0:se.length)||0,")"]}),((Y=C==null?void 0:C.sent)==null?void 0:Y.length)===0?e.jsx(Pe,{children:e.jsx(Re,{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(ae=>{var oe,pe;return e.jsx(Pe,{children:e.jsx(Re,{className:"p-4",children:e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:ae.buyer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((oe=ae.listing)==null?void 0:oe.property_address)||((pe=ae.listing)==null?void 0:pe.city)})]}),e.jsx(Qe,{variant:ae.status==="closed"?"default":"secondary",children:ae.status.replace("_"," ")})]})})},ae.id)})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(lr,{className:"h-4 w-4"}),"Referrals Received (",((X=C==null?void 0:C.received)==null?void 0:X.length)||0,")"]}),((ce=C==null?void 0:C.received)==null?void 0:ce.length)===0?e.jsx(Pe,{children:e.jsx(Re,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(ie=C==null?void 0:C.received)==null?void 0:ie.map(ae=>{var oe;return e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:ae.buyer_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(oe=ae.sender)==null?void 0:oe.name]})]}),e.jsx(Qe,{variant:ae.status==="closed"?"default":"secondary",children:ae.status.replace("_"," ")})]}),e.jsx(K,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>t(`/mission-control/listings/${ae.listing_id}`),children:"View Listing"})]})},ae.id)})})]})]})}),s&&e.jsx(js,{value:"brokerage",className:"space-y-4",children:I?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ae,oe)=>e.jsxs(Pe,{children:[e.jsx(Ns,{className:"h-48 w-full"}),e.jsxs(Re,{className:"p-4 space-y-2",children:[e.jsx(Ns,{className:"h-5 w-3/4"}),e.jsx(Ns,{className:"h-4 w-1/2"})]})]},oe))}):(L==null?void 0:L.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(H4,{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(Us,{className:"h-4 w-4 mr-2"}),"Add a Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:L==null?void 0:L.map(ae=>e.jsx(y9,{listing:ae,onClick:()=>t(`/mission-control/listings/${ae.id}`)},ae.id))})}),e.jsx(js,{value:"map",children:e.jsx(gws,{listings:y||[],isLoading:_})}),e.jsx(js,{value:"leaderboard",children:e.jsx(fws,{leaderboard:O})})]})]})}):e.jsx(Es,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Pe,{children:e.jsxs(Re,{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 vws(t){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}const _ws={single_family:"Single Family Home",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury Home",commercial:"Commercial",other:"Property"};function bws({open:t,onOpenChange:s,listing:r}){const{user:n}=Fs(),{data:a=[],isLoading:o}=qh(),{data:l=[]}=jf(),[i,d]=S.useState(""),[u,p]=S.useState("all"),[x,y]=S.useState(new Set),[_,b]=S.useState(!1),[N,w]=S.useState(null);S.useEffect(()=>{t||(d(""),p("all"),y(new Set),b(!1))},[t]),S.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 k=S.useMemo(()=>a.filter(q=>q.email),[a]),C=S.useMemo(()=>{let q=k;if(u!=="all"&&(q=q.filter($=>{var U;return(U=$.tags)==null?void 0:U.some(se=>se.relationship_type_id===u)})),i.trim()){const $=i.toLowerCase();q=q.filter(U=>`${U.first_name||""} ${U.last_name||""}`.toLowerCase().includes($)||(U.email||"").toLowerCase().includes($))}return q},[k,i,u]),E=()=>{x.size===C.length?y(new Set):y(new Set(C.map(q=>q.id)))},L=q=>{const $=new Set(x);$.has(q)?$.delete(q):$.add(q),y($)},I=S.useMemo(()=>k.filter(q=>x.has(q.id)).map(q=>({id:q.id,first_name:q.first_name||"there",last_name:q.last_name,email:q.email})),[k,x]),{defaultSubject:O,defaultBody:V}=S.useMemo(()=>{var he,we,je,Ue;const q=r.property_address||`${r.city}, ${r.state}`,$=vws(r.price),U=_ws[r.property_type]||"home",se=r.bedrooms?`${r.bedrooms} bed`:"",Y=r.bathrooms?`${r.bathrooms} bath`:"",J=r.square_footage?`${r.square_footage.toLocaleString()} sqft`:"",X=[se,Y,J].filter(Boolean).join(" • "),ce=`https://listings.relevelup.com/${r.slug||r.id}`,ie=((we=(he=r.photos)==null?void 0:he.find(Te=>Te.is_primary))==null?void 0:we.photo_url)||((Ue=(je=r.photos)==null?void 0:je[0])==null?void 0:Ue.photo_url)||"",oe={active:"Just Listed",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"}[r.status]||"New Listing",pe=`${oe}: ${q} — ${$}`,_e=`

Hi {{first_name}},

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

${ie?` ${q} `:""}
${oe}

${$}

${q}

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

${X?`

${X} • ${U}

`:""} 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:pe,defaultBody:_e}},[r]);return _?e.jsx(T1,{open:_,onOpenChange:q=>{b(q),q||s(!1)},bulkContacts:I,defaultSubject:O,defaultBody:V,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($r,{className:"h-5 w-5 text-amber-500"}),"Email this listing to your sphere"]}),e.jsx(Ir,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search contacts...",value:i,onChange:q=>d(q.target.value),className:"pl-9"})]}),e.jsxs(Bs,{value:u,onValueChange:p,children:[e.jsx(Rs,{className:"sm:w-[180px]",children:e.jsx(qs,{placeholder:"Filter by tag"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All contacts"}),l.map(q=>e.jsx(vt,{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:E,className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(Ki,{checked:C.length>0&&x.size===C.length,className:"pointer-events-none"}),e.jsx("span",{children:x.size===C.length&&C.length>0?"Deselect all":`Select all (${C.length})`})]}),e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(lr,{className:"h-3 w-3"}),x.size," selected"]})]}),e.jsx(ui,{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(_s,{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:k.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(Ki,{checked:x.has(q.id),onCheckedChange:()=>L(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 U;return e.jsx(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:(U=$.relationship_type)==null?void 0:U.name},$.id)})})]},q.id))})}),e.jsx(wo,{}),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:x.size===0,className:"gap-2",children:[e.jsx(rr,{className:"h-4 w-4"}),"Compose Email (",x.size,")"]})]})]})]})})}function cx(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 Cme(){const t=ja();return gt({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 oit(){const t=ja(),s=Jt();return It({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 Mme(){const t=ja();return gt({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 lit(){const t=ja(),s=Jt();return It({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 cit(){const t=Jt();return It({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 wws(){const t=Jt();return It({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 jws(){const t=Jt();return It({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 Nws(t){return gt({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 kws(){const t=Jt();return It({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 Sws(t){return gt({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 Cws(){const t=Jt();return It({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 Mws(){const t=Jt();return It({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 Tws(){const t=ja();return gt({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+(cx(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+(cx(d)||0)*u},0),ytdWonDeals:l.length,ytdWonGCI:l.reduce((i,d)=>i+(d.expected_commission||0),0),ytdWonNet:l.reduce((i,d)=>i+(cx(d)||0),0),projectedAnnualNet:l.reduce((i,d)=>i+(cx(d)||0),0)+n.reduce((i,d)=>{const u=(d.probability??50)/100;return i+(cx(d)||0)*u},0)}},enabled:!!t})}function Aws(t){const s=ja();return gt({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 Ews(){const t=Jt();return It({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 Pws(){const t=Jt();return It({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 Iws({listing:t}){const s=_r(),[r,n]=S.useState(""),[a,o]=S.useState(!1),{data:l,isLoading:i}=Aws(t.id),{data:d,isLoading:u}=Cme(),{data:p,isLoading:x}=Mme(),y=oit(),_=Ews(),b=Pws(),N=lit(),w=(p==null?void 0:p.filter(I=>!I.listing_id))||[],k=I=>{if(!(d!=null&&d.length))return null;switch(I){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 I=k(t.status);await N.mutateAsync({deal_name:t.property_address?`${t.property_address}, ${t.city}`:`${t.city}, ${t.state}`,deal_type:"seller",stage_id:(I==null?void 0:I.id)||null,listing_id:t.id,property_address:t.property_address,city:t.city,state:t.state,expected_price:t.price,expected_commission:t.price*.03,commission_percentage:3,priority:"medium",probability:50}),me.success("Deal created and linked to listing!")}catch(I){console.error("Failed to create deal:",I),me.error("Failed to create deal")}finally{o(!1)}},E=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")}},L=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(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ky,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsx(Re,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(_s,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(Pe,{className:"border-primary/20 bg-primary/5",children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{className:"flex items-center gap-2 text-base",children:[e.jsx(Do,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),e.jsxs(Re,{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(Qe,{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(ei,{className:"h-3 w-3 ml-1"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:L,disabled:b.isPending,children:b.isPending?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(vS,{className:"h-4 w-4"})})]})]})]}):e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ky,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs(Re,{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(_s,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Us,{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(Bs,{value:r,onValueChange:n,children:[e.jsx(Rs,{className:"flex-1 text-sm",children:e.jsx(qs,{placeholder:"Link to existing deal..."})}),e.jsx(Os,{children:w.map(I=>e.jsx(vt,{value:I.id,children:I.deal_name},I.id))})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:E,disabled:!r||_.isPending,children:_.isPending?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(Do,{className:"h-4 w-4"})})]})]})]})]})}const Lws={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Dws={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},G7e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Rws(){var ce,ie,ae,oe,pe,_e,he,we,je;const{listingId:t}=co(),s=_r(),{user:r}=Fs(),{data:n,isLoading:a}=bXe(t||""),{data:o}=NXe(t||""),{data:l}=FLt(t||""),i=jXe(),d=OLt(),u=zLt(),p=wXe(),x=$Lt(),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.useState(!1),[C,E]=S.useState(!1),[L,I]=S.useState(null),[O,V]=S.useState({buyerName:"",buyerType:"",notes:""}),q=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),$=Ue=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Ue),U=async Ue=>{const Te=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,Me=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:Ue});try{switch(Ue){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(`${Me} ${Te}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(Me)}&body=${encodeURIComponent(`Check out this listing: ${Te}`)}`);break}}catch(Fe){console.error("Share error:",Fe),me.error("Failed to share")}},se=async()=>{try{await p.mutateAsync(n.id),me.success("Listing deleted"),s("/mission-control/listings")}catch{me.error("Failed to delete listing")}},Y=async()=>{if(!O.buyerName.trim()){me.error("Please enter buyer name");return}try{await x.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),V({buyerName:"",buyerType:"",notes:""})}catch{me.error("Failed to send referral")}},J=Ue=>{var ze,ve;const Te=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,Me=$((n==null?void 0:n.price)||0),Fe=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Le=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",Ne=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",qe=[Fe,Le,Ne].filter(Boolean).join(" | ");switch(Ue){case"just_listed":return`🏡 JUST LISTED! ${Te} ${Me} ${qe} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(ze=n==null?void 0:n.city)==null?void 0:ze.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${Te} Now ${Me}! ${qe} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${G7e[(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! ${qe} DM me for details! 📩 #ComingSoon #RealEstate #${(ve=n==null?void 0:n.city)==null?void 0:ve.replace(/\s/g,"")}`;default:return""}};if(a)return e.jsx(Es,{title:"Listing",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ns,{className:"h-10 w-32"}),e.jsx(Ns,{className:"h-[400px] w-full"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsx(Ns,{className:"h-48"}),e.jsx(Ns,{className:"h-48"}),e.jsx(Ns,{className:"h-48"})]})]})});if(!n)return e.jsx(Es,{title:"Listing Not Found",description:"",children:e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing could not be found."}),e.jsx(K,{onClick:()=>s("/mission-control/listings"),children:"Back to Listings"})]})})});const X=((ce=n.photos)==null?void 0:ce.find(Ue=>Ue.is_primary))||((ie=n.photos)==null?void 0:ie[0]);return e.jsxs(Es,{title:"",description:"",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/mission-control/listings"),children:[e.jsx(Fa,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>X&&I(X.photo_url),children:X?e.jsx("img",{src:X.photo_url,alt:"Primary",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No photos"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:(ae=n.photos)==null?void 0:ae.slice(1,5).map((Ue,Te)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>I(Ue.photo_url),children:e.jsx("img",{src:Ue.photo_url,alt:`Photo ${Te+2}`,className:"w-full h-full object-cover"})},Ue.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(Pe,{children:e.jsxs(Re,{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(Qe,{className:`${Lws[n.status]} text-white border-0`,children:Dws[n.status]}),n.is_featured&&e.jsxs(Qe,{variant:"outline",className:"border-amber-500 text-amber-500",children:[e.jsx(Hn,{className:"h-3 w-3 mr-1 fill-amber-500"}),"Featured"]}),n.open_to_referrals&&e.jsxs(Qe,{variant:"outline",children:[e.jsx(lr,{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(Da,{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(Gv,{className:"h-4 w-4"}):e.jsx(Sm,{className:"h-4 w-4"})}),!q&&e.jsxs(K,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>k(!0),children:[e.jsx($r,{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(va,{onClick:()=>U("copy"),children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(va,{onClick:()=>U("facebook"),children:[e.jsx(uu,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(va,{onClick:()=>U("text"),children:[e.jsx(ki,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(va,{onClick:()=>U("email"),children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),q&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>E(!0),className:"gap-2",children:[e.jsx(rr,{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(gr,{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(Wy,{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(rf,{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(s0,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.square_footage.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sq Ft"})]}),n.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(on,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.year_built}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"pt-4 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Qe,{variant:"secondary",children:[e.jsx(pa,{className:"h-3 w-3 mr-1"}),G7e[n.property_type]]}),n.lot_size&&e.jsxs(Qe,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(Qe,{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(wn,{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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"Share Content"})}),e.jsx(Re,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(Ue=>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:[Ue.replace("_"," ")," Caption"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(J(Ue)),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(Ue)})]},Ue))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"Listing Agent"})}),e.jsxs(Re,{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:((pe=(oe=n.agent)==null?void 0:oe.name)==null?void 0:pe.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((_e=n.agent)==null?void 0:_e.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:((je=n.agent)==null?void 0:je.email)&&e.jsx(K,{variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`mailto:${n.agent.email}`,children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),q&&e.jsx(Iws,{listing:n}),!q&&n.open_to_referrals&&e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs(Re,{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:!!L,onOpenChange:()=>I(null),children:e.jsx(ms,{className:"max-w-4xl",children:e.jsx("img",{src:L||"",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(Ir,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:se,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(Ir,{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(xe,{children:"Buyer Name *"}),e.jsx(De,{value:O.buyerName,onChange:Ue=>V({...O,buyerName:Ue.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Buyer Type"}),e.jsxs(Bs,{value:O.buyerType,onValueChange:Ue=>V({...O,buyerType:Ue}),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select type"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"first_time",children:"First-Time Buyer"}),e.jsx(vt,{value:"investor",children:"Investor"}),e.jsx(vt,{value:"relocating",children:"Relocating"}),e.jsx(vt,{value:"upgrade",children:"Upgrading"}),e.jsx(vt,{value:"downsize",children:"Downsizing"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Notes"}),e.jsx(vr,{value:O.notes,onChange:Ue=>V({...O,notes:Ue.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>N(!1),children:"Cancel"}),e.jsx(K,{onClick:Y,disabled:x.isPending,children:x.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(iit,{open:w,onOpenChange:k,listingId:(n==null?void 0:n.id)||"",listingSlug:(n==null?void 0:n.slug)||null,listingTitle:(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`}),n&&e.jsx(bws,{open:C,onOpenChange:E,listing:n})]})}function Ows({onImport:t}){const[s,r]=S.useState(""),[n,a]=S.useState([]),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(null),x=S.useRef(),y=S.useRef(null);S.useEffect(()=>{const C=E=>{y.current&&!y.current.contains(E.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:E,error:L}=await G.functions.invoke("mls-listing-search",{body:{query:C}});if(L)throw L;a((E==null?void 0:E.listings)||[]),d(!0)}catch(E){console.error("MLS search error:",E),a([])}finally{l(!1)}},b=C=>{r(C),x.current&&clearTimeout(x.current),x.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()}`:"",k=C=>{const E=(C||"").toLowerCase();return E.includes("single")||E.includes("detached")?"Single Family":E.includes("condo")?"Condo":E.includes("town")?"Townhouse":E.includes("land")||E.includes("lot")?"Land":E.includes("multi")?"Multi-Family":E.includes("commercial")?"Commercial":C||"Other"};return e.jsxs(Pe,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs(Ot,{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(Re,{children:e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{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(_s,{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(Da,{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(Wy,{className:"h-3 w-3"})," ",C.bedrooms]}),C.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(rf,{className:"h-3 w-3"})," ",C.bathrooms]}),C.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(uS,{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(Qe,{variant:"outline",className:"text-[10px]",children:k(C.propertyType)}),C.photos.length>0&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[C.photos.length," photos"]})]})]},C.mlsNumber))})]})})]})}function Fws({photo:t,onRemove:s,onSetPrimary:r}){const{attributes:n,listeners:a,setNodeRef:o,transform:l,transition:i,isDragging:d}=j4e({id:t.id}),u={transform:sC.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(hu,{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(Hn,{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 zws({photos:t,uploading:s,onUpload:r,onRemove:n,onReorder:a,onSetPrimary:o}){const l=f4e(pce(rO,{activationConstraint:{distance:5}})),i=[...t].sort((u,p)=>(u.sort_order??0)-(p.sort_order??0)),d=u=>{const{active:p,over:x}=u;if(!x||p.id===x.id)return;const y=i.findIndex(k=>k.id===p.id),_=i.findIndex(k=>k.id===x.id),b=[...i],[N]=b.splice(y,1);b.splice(_,0,N);const w=b.map((k,C)=>({...k,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(_4e,{sensors:l,collisionDetection:x4e,onDragEnd:d,children:e.jsx(w4e,{items:i.map(u=>u.id),strategy:nO,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[i.map(u=>e.jsx(Fws,{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(_s,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx($a,{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 Bws({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=_r(),{user:a}=Fs(),[o,l]=S.useState(!1),[i,d]=S.useState([]),[u,p]=S.useState(!1),[x,y]=S.useState(null),[_,b]=S.useState({});S.useEffect(()=>{t&&a?N():y(null)},[t,a]);const N=async()=>{if(!t)return;const{data:$,error:U}=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();!U&&$&&(y($),w($))},w=async $=>{try{const{data:U,error:se}=await G.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:$.bunny_video_id,isAgentVideo:!0}});!se&&(U!=null&&U.thumbnailUrl)&&b(Y=>({...Y,[$.id]:{thumbnailUrl:U.thumbnailUrl}}))}catch(U){console.warn("Failed to get signed URL",U)}},k=async()=>{if(a){p(!0);try{const{data:$,error:U}=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(U)throw U;d($||[]),$!=null&&$.length&&C($)}catch($){console.error("Error fetching videos:",$),me.error("Failed to load videos")}finally{p(!1)}}},C=async $=>{var U;try{const se=$.map(ie=>ie.bunny_video_id),{data:Y,error:J}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:se,isAgentVideo:!0}});if(J)throw J;const X=(Y==null?void 0:Y.assets)||{},ce={};for(const ie of $)(U=X[ie.bunny_video_id])!=null&&U.thumbnailUrl&&(ce[ie.id]={thumbnailUrl:X[ie.bunny_video_id].thumbnailUrl});b(ie=>({...ie,...ce}))}catch(se){console.warn("Failed to bulk-fetch signed URLs",se)}},E=()=>{l(!0),k()},L=$=>{s($.id),y($),l(!1),me.success("Video selected")},I=()=>{s(null),y(null)},O=()=>{const $=r?`/mission-control/listings/${r}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent($)}`)},V=$=>{if(!$)return"0:00";const U=Math.floor($/60),se=$%60;return`${U}:${se.toString().padStart(2,"0")}`},q=$=>{var U;return((U=_[$.id])==null?void 0:U.thumbnailUrl)||$.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[x?e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(Re,{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(x)?e.jsx("img",{src:q(x),alt:x.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(Tn,{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(So,{className:"h-6 w-6 text-white fill-white"})}),x.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:V(x.duration_seconds)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:x.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:E,children:"Change"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:I,className:"text-destructive hover:text-destructive",children:e.jsx(Sr,{className:"h-4 w-4"})})]})]})})}):e.jsx(Pe,{className:"border-dashed",children:e.jsx(Re,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Tn,{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:E,className:"gap-2",children:[e.jsx(kM,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(K,{type:"button",variant:"outline",onClick:O,className:"gap-2",children:[e.jsx(xx,{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(kM,{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(_s,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Tn,{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(xx,{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:()=>L($),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(Tn,{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(So,{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:V($.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(xx,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const $ws=[{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"}],qws=[{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 Uws({id:t,url:s,index:r,onRemove:n}){const{attributes:a,listeners:o,setNodeRef:l,transform:i,transition:d,isDragging:u}=j4e({id:t}),p={transform:sC.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(hu,{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(Hn,{className:"h-2.5 w-2.5 fill-current"})," Primary"]})]})}function Vws({photoUrls:t,pendingPhotos:s,onRemove:r,onReorder:n,uploading:a,onUpload:o}){const l=f4e(pce(rO,{activationConstraint:{distance:5}})),i=t.map((u,p)=>`pending-${p}`),d=u=>{const{active:p,over:x}=u;if(!x||p.id===x.id)return;const y=i.indexOf(p.id),_=i.indexOf(x.id),b=[...t],N=[...s],[w]=b.splice(y,1),[k]=N.splice(y,1);b.splice(_,0,w),N.splice(_,0,k),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(_4e,{sensors:l,collisionDetection:x4e,onDragEnd:d,children:e.jsx(w4e,{items:i,strategy:nO,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[t.map((u,p)=>e.jsx(Uws,{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(_s,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx($a,{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 W7e(){const{listingId:t}=co(),[s]=Nc(),r=s.get("brokerage"),n=_r(),{user:a}=Fs(),{hasLeadSite:o}=ZA(),l=!!t&&t!=="new",i=!!r&&!l,[d,u]=S.useState([]),{data:p,isLoading:x}=bXe(l?t:""),y=TLt(),_=ALt(),b=ELt(),N=PLt(),w=ILt(),k=LLt(),C=DLt(),{data:E=[]}=gt({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}),[L,I]=S.useState(""),[O,V]=S.useState(!1),[q,$]=S.useState([]),[U,se]=S.useState([]),[Y,J]=S.useState({property_address:"",city:"",state:"",neighborhood:"",price:"",property_type:"single_family",status:"active",bedrooms:"",bathrooms:"",square_footage:"",lot_size:"",year_built:"",has_hoa:!1,description:"",agent_notes:"",agent_notes_public:!1,mls_link:"",video_link:"",video_id:null,allow_sharing:!0,open_to_referrals:!0,open_to_social_promotion:!0,share_with_brokerage:!1,is_public:!0});S.useEffect(()=>{var he,we,je,Ue,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:((je=p.bathrooms)==null?void 0:je.toString())||"",square_footage:((Ue=p.square_footage)==null?void 0:Ue.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 X=he=>{var Te,Me;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"},je=(he.propertyType||"").toLowerCase(),Ue=((Te=Object.entries(we).find(([Fe])=>je.includes(Fe)))==null?void 0:Te[1])||"other";J(Fe=>({...Fe,property_address:he.address||Fe.property_address,city:he.city||Fe.city,state:he.state||Fe.state,price:he.price?String(he.price):Fe.price,property_type:Ue,bedrooms:he.bedrooms?String(he.bedrooms):Fe.bedrooms,bathrooms:he.bathrooms?String(he.bathrooms):Fe.bathrooms,square_footage:he.sqft?String(he.sqft):Fe.square_footage,lot_size:he.lotSize?String(he.lotSize):Fe.lot_size,year_built:he.yearBuilt?String(he.yearBuilt):Fe.year_built,description:he.description||Fe.description})),((Me=he.photos)==null?void 0:Me.length)>0&&(u(he.photos),U.forEach(Fe=>URL.revokeObjectURL(Fe)),$([]),se([]))},ce=he=>{if(!he)return;const we=Array.from(he);$(Ue=>[...Ue,...we]);const je=we.map(Ue=>URL.createObjectURL(Ue));se(Ue=>[...Ue,...je])},ie=he=>{URL.revokeObjectURL(U[he]),$(we=>we.filter((je,Ue)=>Ue!==he)),se(we=>we.filter((je,Ue)=>Ue!==he))},ae=async he=>{var we;if(!(!he||!p)){V(!0);try{for(const je of Array.from(he)){const Ue=je.name.split(".").pop(),Te=`${a==null?void 0:a.id}/${p.id}/${Date.now()}.${Ue}`,{error:Me}=await G.storage.from("listing-photos").upload(Te,je);if(Me)throw Me;const{data:{publicUrl:Fe}}=G.storage.from("listing-photos").getPublicUrl(Te);await N.mutateAsync({listingId:p.id,photoUrl:Fe,isPrimary:!((we=p.photos)!=null&&we.length)})}me.success("Photos uploaded!")}catch(je){console.error("Upload error:",je),me.error("Failed to upload photos")}finally{V(!1)}}},oe=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")}},_e=async he=>{if(he.preventDefault(),!Y.city.trim()||!Y.state.trim()||!Y.price){me.error("Please fill in required fields (City, State, Price)");return}if(i&&!L){me.error("Please select an agent to assign this listing to");return}try{const we={property_address:Y.property_address||null,city:Y.city,state:Y.state,neighborhood:Y.neighborhood||null,price:Number(Y.price),property_type:Y.property_type,status:Y.status,bedrooms:Y.bedrooms?Number(Y.bedrooms):null,bathrooms:Y.bathrooms?Number(Y.bathrooms):null,square_footage:Y.square_footage?Number(Y.square_footage):null,lot_size:Y.lot_size||null,year_built:Y.year_built?Number(Y.year_built):null,has_hoa:Y.has_hoa,description:Y.description||null,agent_notes:Y.agent_notes||null,agent_notes_public:Y.agent_notes_public,mls_link:Y.mls_link||null,video_link:Y.video_link||null,video_id:Y.video_id||null,allow_sharing:Y.allow_sharing,open_to_referrals:Y.open_to_referrals,open_to_social_promotion:Y.open_to_social_promotion,share_with_brokerage:Y.share_with_brokerage,is_public:Y.is_public};if(l)await b.mutateAsync({id:t,...we}),me.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{V(!0);let je;if(i&&L?je=await _.mutateAsync({agentId:L,...we}):je=await y.mutateAsync(we),q.length>0)try{await oe(je.id),U.forEach(Ue=>URL.revokeObjectURL(Ue)),$([]),se([])}catch(Ue){console.error("Photo upload error:",Ue),me.error("Listing created but some photos failed to upload")}if(d.length>0)try{for(let Ue=0;Uen(i?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(Fa,{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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Assign to Agent *"})}),e.jsxs(Re,{children:[e.jsxs(Bs,{value:L,onValueChange:I,children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select an agent..."})}),e.jsx(Os,{children:E.map(he=>e.jsx(vt,{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(Ows,{onImport:X}),d.length>0&&e.jsxs(Pe,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs(Ot,{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(Re,{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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Property Details"})}),e.jsx(Re,{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(xe,{children:"Property Address"}),e.jsx(De,{value:Y.property_address,onChange:he=>J({...Y,property_address:he.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"City *"}),e.jsx(De,{value:Y.city,onChange:he=>J({...Y,city:he.target.value}),placeholder:"City",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"State *"}),e.jsx(De,{value:Y.state,onChange:he=>J({...Y,state:he.target.value}),placeholder:"State",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Neighborhood"}),e.jsx(De,{value:Y.neighborhood,onChange:he=>J({...Y,neighborhood:he.target.value}),placeholder:"Neighborhood"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Price *"}),e.jsx(De,{type:"number",value:Y.price,onChange:he=>J({...Y,price:he.target.value}),placeholder:"500000",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Property Type"}),e.jsxs(Bs,{value:Y.property_type,onValueChange:he=>J({...Y,property_type:he}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:qws.map(he=>e.jsx(vt,{value:he.value,children:he.label},he.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Status"}),e.jsxs(Bs,{value:Y.status,onValueChange:he=>J({...Y,status:he}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:$ws.map(he=>e.jsx(vt,{value:he.value,children:he.label},he.value))})]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Property Specs (Optional)"})}),e.jsx(Re,{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(xe,{children:"Bedrooms"}),e.jsx(De,{type:"number",value:Y.bedrooms,onChange:he=>J({...Y,bedrooms:he.target.value}),placeholder:"3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Bathrooms"}),e.jsx(De,{type:"number",step:"0.5",value:Y.bathrooms,onChange:he=>J({...Y,bathrooms:he.target.value}),placeholder:"2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Sq Ft"}),e.jsx(De,{type:"number",value:Y.square_footage,onChange:he=>J({...Y,square_footage:he.target.value}),placeholder:"2000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Lot Size"}),e.jsx(De,{value:Y.lot_size,onChange:he=>J({...Y,lot_size:he.target.value}),placeholder:"0.25 acres"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Year Built"}),e.jsx(De,{type:"number",value:Y.year_built,onChange:he=>J({...Y,year_built:he.target.value}),placeholder:"2005"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(Er,{checked:Y.has_hoa,onCheckedChange:he=>J({...Y,has_hoa:he})}),e.jsx(xe,{children:"Has HOA"})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Description & Links"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(vr,{value:Y.description,onChange:he=>J({...Y,description:he.target.value}),placeholder:"Tell the story of this property...",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Agent Notes"}),e.jsx(vr,{value:Y.agent_notes,onChange:he=>J({...Y,agent_notes:he.target.value}),placeholder:"Notes for other agents...",rows:2}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Er,{checked:Y.agent_notes_public,onCheckedChange:he=>J({...Y,agent_notes_public:he})}),e.jsx(xe,{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(xe,{children:"MLS Link"}),e.jsx(De,{value:Y.mls_link,onChange:he=>J({...Y,mls_link:he.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Video Link"}),e.jsx(De,{value:Y.video_link,onChange:he=>J({...Y,video_link:he.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(Re,{children:e.jsx(Bws,{selectedVideoId:Y.video_id,onVideoSelect:he=>J({...Y,video_id:he}),listingId:l?t:void 0})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Photos"})}),e.jsx(Re,{children:l&&(p!=null&&p.photos)?e.jsx(zws,{photos:p.photos,uploading:O,onUpload:he=>ae(he),onRemove:he=>pe(he),onReorder:he=>{k.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(Vws,{photoUrls:U,onRemove:ie,onReorder:(he,we)=>{se(he),$(we)},pendingPhotos:q,uploading:O,onUpload:ce})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Sharing & Collaboration"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Allow Sharing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Other agents can share this listing"})]}),e.jsx(Er,{checked:Y.allow_sharing,onCheckedChange:he=>J({...Y,allow_sharing:he})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Open to Referrals"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept buyer referrals"})]}),e.jsx(Er,{checked:Y.open_to_referrals,onCheckedChange:he=>J({...Y,open_to_referrals:he})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Social Promotion"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be promoted on social media"})]}),e.jsx(Er,{checked:Y.open_to_social_promotion,onCheckedChange:he=>J({...Y,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(xe,{children:"Share with Brokerage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),e.jsx(Er,{checked:Y.share_with_brokerage,onCheckedChange:he=>J({...Y,share_with_brokerage:he})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Make Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Publish on listings.relevelup.com to get leads"})]}),e.jsx(Er,{checked:Y.is_public,onCheckedChange:he=>J({...Y,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(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):l?"Update Listing":"Create Listing"})]})]})]})})}let Zm=null;function Hws(){if(Zm)return Zm;try{const t=document.createElement("canvas"),s=t.getContext("webgl2")||t.getContext("webgl");if(!s)return Zm={canRunVirtualBg:!1,reason:"WebGL is not supported on this device"},Zm;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 Zm={canRunVirtualBg:!1,reason:"Your device uses a software renderer which may cause lag",renderer:n},Zm;const i=performance;return i.memory&&i.memory.jsHeapSizeLimit<256*1024*1024?(Zm={canRunVirtualBg:!1,reason:"Limited device memory detected",renderer:n},Zm):navigator.hardwareConcurrency&&navigator.hardwareConcurrency<2?(Zm={canRunVirtualBg:!1,reason:"Single-core device detected — virtual backgrounds may cause lag",renderer:n},Zm):(Zm={canRunVirtualBg:!0,renderer:n},Zm)}catch{return Zm={canRunVirtualBg:!0},Zm}}const Gws=[{type:"none",label:"Off"},{type:"blur",label:"Blur"}];function Wws({value:t,onChange:s,isLoading:r=!1,disabled:n=!1,className:a}){const o=S.useRef(null),[l,i]=S.useState(!1),[d]=S.useState(()=>Hws()),u=!d.canRunVirtualBg,{data:p=[],refetch:x}=gt({queryKey:["video-backgrounds"],queryFn:async()=>{const{data:{user:w}}=await G.auth.getUser();if(!w)return[];const{data:k,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),[]):k||[]}}),y=p.map(w=>({type:"image",label:w.name,imageUrl:w.image_url,thumbnail:w.thumbnail_url||w.image_url})),_=[...Gws,...y],b=w=>w.type!==t.type?!1:w.type==="image"?w.imageUrl===t.imageUrl:!0,N=async w=>{var C;const k=(C=w.target.files)==null?void 0:C[0];if(k){if(!k.type.startsWith("image/")){me.error("Please select an image file");return}if(k.size>5*1024*1024){me.error("Image must be under 5MB");return}i(!0);try{const{data:{user:E}}=await G.auth.getUser();if(!E)throw new Error("Not authenticated");const L=k.name.split(".").pop()||"jpg",I=`${E.id}/${crypto.randomUUID()}.${L}`,{error:O}=await G.storage.from("video-backgrounds").upload(I,k,{contentType:k.type});if(O)throw O;const{data:V}=G.storage.from("video-backgrounds").getPublicUrl(I),q=V.publicUrl,{error:$}=await G.from("video_backgrounds").insert({name:k.name.replace(/\.[^.]+$/,""),image_url:q,thumbnail_url:q,category:"custom",is_stock:!1,user_id:E.id});if($)throw $;await x(),s({type:"image",imageUrl:q,blurRadius:15}),me.success("Background uploaded!")}catch(E){console.error("Upload error:",E),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(_s,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"Loading…"})]}),_.map((w,k)=>{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(sL,{className:"h-4 w-4 text-muted-foreground"}),w.type==="blur"&&e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-primary/20 to-primary/40 flex items-center justify-center",children:e.jsx("span",{className:"text-[10px] font-medium text-primary",children:"Blur"})}),w.type==="image"&&w.thumbnail&&e.jsx("img",{src:w.thumbnail,alt:w.label,className:"w-full h-full object-cover"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-14",children:w.label})]},`${w.type}-${w.imageUrl||k}`)}),e.jsxs("button",{type:"button",disabled:n||l,onClick:()=>{var w;return(w=o.current)==null?void 0:w.click()},className: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(_s,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(Us,{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(uL,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Mirror"})]})]})]})}var fA=typeof self<"u"?self:{};function dit(t,s){e:{for(var r=["CLOSURE_FLAGS"],n=fA,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 hit(t){fA.setTimeout(()=>{throw t},0)}var Twe,Xws=dit(610401301,!1),Z7e=dit(748402147,!0);function Y7e(){var t=fA.navigator;return t&&(t=t.userAgent)?t:""}const X7e=fA.navigator;function Tme(t){return Tme[" "](t),t}Twe=X7e&&X7e.userAgentData||null,Tme[" "]=function(){};const mit={};let FI=null;function Qws(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),x!=64&&(l(p<<4&240|x>>2),y!=64&&l(x<<6&192|y))}}(t,function(o){n[a++]=o}),a!==r?n.subarray(0,a):n}function pit(){if(!FI){FI={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),s=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const n=t.concat(s[r].split(""));mit[r]=n;for(let a=0;a0)&&(Y7e().indexOf("Trident")!=-1||Y7e().indexOf("MSIE")!=-1))&&typeof btoa=="function";const Q7e=/[-_.]/g,e2s={"-":"+",_:"/",".":"="};function t2s(t){return e2s[t]||""}function xit(t){if(!fit)return Qws(t);t=Q7e.test(t)?t.replace(Q7e,t2s):t,t=atob(t);const s=new Uint8Array(t.length);for(let r=0;r=s||(r[t]=n+1,yit(t=Error(),"incident"),hit(t))}}function _E(){return typeof BigInt=="function"}var bE=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 n2s=C0("jas",void 0,!0),J7e=C0(void 0,"0di"),xI=C0(void 0,"1oa"),mf=C0(void 0,Symbol()),a2s=C0(void 0,"0ub"),i2s=C0(void 0,"0ubs"),Ewe=C0(void 0,"0ubsb"),o2s=C0(void 0,"0actk"),yA=C0("m_m","Pa",!0),eze=C0();const vit={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},_it=Object.defineProperties,_a=bE?n2s:"Ga";var TC;const tze=[];function vO(t,s){bE||_a in t||_it(t,vit),t[_a]|=s}function gu(t,s){bE||_a in t||_it(t,vit),t[_a]=s}function _O(t){return vO(t,34),t}function aR(t){return vO(t,8192),t}gu(tze,7),TC=Object.freeze(tze);var vA={};function gf(t,s){return s===void 0?t.h!==hC&&!!(2&(0|t.v[_a])):!!(2&s)&&t.h!==hC}const hC={};function USe(t,s){if(t!=null){if(typeof t=="string")t=t?new c0(t,xA):uC();else if(t.constructor!==c0)if($Se(t))t=t.length?new c0(new Uint8Array(t),xA):uC();else{if(!s)throw Error();t=void 0}}return t}class sze{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 l2s=Object.freeze({});function bit(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"),rze=Ame(t=>typeof t=="string"),d2s=Ame(t=>typeof t=="boolean"),Eme=typeof fA.BigInt=="function"&&typeof fA.BigInt(0)=="bigint";function pf(t){var s=t;if(rze(s)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(s))throw Error(String(s))}else if(c2s(s)&&!Number.isSafeInteger(s))throw Error(String(s));return Eme?BigInt(t):t=d2s(t)?t?"1":"0":rze(t)?t.trim()||"0":String(t)}var Pwe=Ame(t=>Eme?t>=h2s&&t<=p2s:t[0]==="-"?nze(t,u2s):nze(t,m2s));const u2s=Number.MIN_SAFE_INTEGER.toString(),h2s=Eme?BigInt(Number.MIN_SAFE_INTEGER):void 0,m2s=Number.MAX_SAFE_INTEGER.toString(),p2s=Eme?BigInt(Number.MAX_SAFE_INTEGER):void 0;function nze(t,s){if(t.length>s.length)return!1;if(t.lengtha)return!1;if(n>>0;Ic=s,Rd=(t-s)/4294967296>>>0}function _A(t){if(t<0){aze(-t);const[s,r]=GSe(Ic,Rd);Ic=s>>>0,Rd=r>>>0}else aze(t)}function VSe(t){const s=x2s||(x2s=new DataView(new ArrayBuffer(8)));s.setFloat32(0,+t,!0),Rd=0,Ic=s.getUint32(0,!0)}function jit(t,s){const r=4294967296*s+(t>>>0);return Number.isSafeInteger(r)?r:iR(t,s)}function g2s(t,s){return pf(_E()?BigInt.asUintN(64,(BigInt(s>>>0)<>>0)):iR(t,s))}function Nit(t,s){return _E()?pf(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(s))<>>=0,(s>>>=0)<=2097151)var r=""+(4294967296*s+t);else _E()?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+ize(r)+ize(t));return r}function ize(t){return t=String(t),"0000000".slice(t.length)+t}function HSe(t,s){if(2147483648&s)if(_E())t=""+(BigInt(0|s)<>>0));else{const[r,n]=GSe(t,s);t="-"+iR(r,n)}else t=iR(t,s);return t}function Pme(t){if(t.length<16)_A(Number(t));else if(_E())t=BigInt(t),Ic=Number(t&BigInt(4294967295))>>>0,Rd=Number(t>>BigInt(32)&BigInt(4294967295));else{const s=+(t[0]==="-");Rd=Ic=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,Ic=1e6*Ic+o,Ic>=4294967296&&(Rd+=Math.trunc(Ic/4294967296),Rd>>>=0,Ic>>>=0)}if(s){const[n,a]=GSe(Ic,Rd);Ic=n,Rd=a}}}function GSe(t,s){return s=~s,t?t=1+~t:s+=1,[t,s]}function Rg(t){return Array.prototype.slice.call(t)}const bO=typeof BigInt=="function"?BigInt.asIntN:void 0,y2s=typeof BigInt=="function"?BigInt.asUintN:void 0,mC=Number.isSafeInteger,Ime=Number.isFinite,bA=Math.trunc,v2s=pf(0);function zI(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 Vy(t){return t==null||typeof t=="number"?t:t==="NaN"||t==="Infinity"||t==="-Infinity"?Number(t):void 0}function oR(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 kit(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0}const _2s=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function wO(t){switch(typeof t){case"bigint":return!0;case"number":return Ime(t);case"string":return _2s.test(t);default:return!1}}function jE(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Ime(t)?0|t:void 0}function Sit(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Ime(t)?t>>>0:void 0}function Cit(t){const s=t.length;return(t[0]==="-"?s<20||s===20&&t<="-9223372036854775808":s<19||s===19&&t<="9223372036854775807")?t:(Pme(t),HSe(Ic,Rd))}function WSe(t){if(t=bA(t),!mC(t)){_A(t);var s=Ic,r=Rd;(t=2147483648&r)&&(r=~r>>>0,(s=1+~s>>>0)==0&&(r=r+1>>>0)),t=typeof(s=jit(s,r))=="number"?t?-s:s:t?"-"+s:s}return t}function Mit(t){var s=bA(Number(t));return mC(s)?String(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),Cit(t))}function Tit(t){var s=bA(Number(t));return mC(s)?pf(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),_E()?pf(bO(64,BigInt(t))):pf(Cit(t)))}function Ait(t){return mC(t)?t=pf(WSe(t)):(t=bA(t),mC(t)?t=String(t):(_A(t),t=HSe(Ic,Rd)),t=pf(t)),t}function vde(t){const s=typeof t;return t==null?t:s==="bigint"?pf(bO(64,t)):wO(t)?s==="string"?Tit(t):Ait(t):void 0}function Eit(t){if(typeof t!="string")throw Error();return t}function jO(t){if(t!=null&&typeof t!="string")throw Error();return t}function mh(t){return t==null||typeof t=="string"?t:void 0}function KSe(t,s,r,n){return t!=null&&t[yA]===vA?t:Array.isArray(t)?((n=(r=0|t[_a])|32&n|2&n)!==r&&gu(t,n),new s(t)):(r?2&n?((t=s[J7e])||(_O((t=new s).v),t=s[J7e]=t),s=t):s=new s:s=void 0,s)}function b2s(t,s,r){if(s)e:{if(!wO(s=t))throw Awe("int64");switch(typeof s){case"string":s=Tit(s);break e;case"bigint":s=pf(bO(64,s));break e;default:s=Ait(s)}}else s=vde(t);return(t=s)==null?r?v2s:void 0:t}const w2s={};let j2s=function(){try{return Tme(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class c0e{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 N2s=j2s?(Object.setPrototypeOf(c0e.prototype,Map.prototype),Object.defineProperties(c0e.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),c0e):class extends Map{constructor(){super()}};function oze(t){return t}function d0e(t){if(2&t.J)throw Error("Cannot mutate an immutable Map")}var v1=class extends N2s{constructor(t,s,r=oze,n=oze){super(),this.J=0|t[_a],this.K=s,this.S=r,this.fa=this.K?k2s:n;for(let a=0;a{t.call(s,a.get(n),n,a)}):super.forEach(t,s)}set(t,s){return d0e(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 k2s(t,s,r,n,a,o){return t=KSe(t,n,r,o),a&&(t=YSe(t)),t}function S2s(t){return[t,this.get(t)]}let C2s;function lze(){return C2s||(C2s=new v1(_O([]),void 0,void 0,void 0,w2s))}function Lme(t){return mf?t[mf]:void 0}function _de(t,s){for(const r in t)!isNaN(r)&&s(t,+r,t[r])}v1.prototype.toJSON=void 0;var Iwe=class{};const M2s={Ka:!0};function T2s(t,s){s<100||gA(i2s,1)}function Dme(t,s,r,n){const a=n!==void 0;n=!!n;var o,l=mf;!a&&bE&&l&&(o=t[l])&&_de(o,T2s),l=[];var i=t.length;let d;o=4294967295;let u=!1;const p=!!(64&s),x=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-x+x)),s=void 0;for(var y=0;y=o){const b=y-x;(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+x){b[w]=Rg(k)}),b.da=_.da,b}(t)),l}function A2s(t){return t[0]=lR(t[0]),t[1]=lR(t[1]),t}function lR(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return Pwe(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var s=0|t[_a];return t.length===0&&1&s?void 0:Dme(t,s,lR)}if(t!=null&&t[yA]===vA)return Pit(t);if(t instanceof c0){if((s=t.g)==null)t="";else if(typeof s=="string")t=s;else{if(fit){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 v1?t=t.size!==0?t.V(A2s):void 0:void 0}return t}let E2s,P2s;function Pit(t){return Dme(t=t.v,0|t[_a],lR)}function TS(t,s){return Iit(t,s[0],s[1])}function Iit(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[_a],Z7e&&1&a)throw Error("rfarr");if(2048&a&&!(2&a)&&function(){if(Z7e)throw Error("carr");gA(o2s,5)}(),256&a)throw Error("farr");if(64&a)return(a|n)!==a&&gu(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 gu(t,64|a|n),t}function I2s(t,s){if(typeof t!="object")return t;if(Array.isArray(t)){var r=0|t[_a];return t.length===0&&1&r?void 0:cze(t,r,s)}if(t!=null&&t[yA]===vA)return dze(t);if(t instanceof v1){if(2&(s=t.J))return t;if(!t.size)return;if(r=_O(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){SE(t),fu(t=t.v,0|t[_a],s,r,n)}function fu(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[_a]))>>14&1023||536870912)?n!=null&&(t[l+(a?0:-1)]={[r]:n}):t[o]=n),s)}function k4(){return l2s===void 0?2:4}function S4(t,s,r,n,a){let o=t.v,l=0|o[_a];n=gf(t,l)?1:n,a=!!a||n===3,n===2&&kE(t)&&(o=t.v,l=0|o[_a]);let i=(t=QSe(o,s))===TC?7:0|t[_a],d=JSe(i,l);var u=!(4&d);if(u){4&d&&(t=Rg(t),i=0,d=ES(d,l),l=fu(o,l,s,t));let p=0,x=0;for(;p{const i=KSe(l,r,!1,s);return o=i!==l&&i!=null,i}))!=null)return o&&!gf(n)&&AC(t,s),n}function No(t,s,r,n){let a=t.v,o=0|a[_a];if((s=zit(a,o,s,r,n))==null)return s;if(o=0|a[_a],!gf(t,o)){const l=YSe(s);l!==s&&(kE(t)&&(a=t.v,o=0|a[_a]),o=fu(a,o,r,s=l,n),AC(a,o))}return s}function Bit(t,s,r,n,a,o,l,i){var d=gf(t,r);o=d?1:o,l=!!l||o===3,d=i&&!d,(o===2||d)&&kE(t)&&(r=0|(s=t.v)[_a]);var u=(t=QSe(s,a))===TC?7:0|t[_a],p=JSe(u,r);if(i=!(4&p)){var x=t,y=r;const _=!!(2&p);_&&(y|=2);let b=!_,N=!0,w=0,k=0;for(;w32)for(a|=(127&r)>>4,o=3;o<32&&128&r;o+=7)r=l[i++],a|=(127&r)<>>0,a>>>0);throw Error()}function iCe(t){let s=0,r=t.g;const n=r+10,a=t.h;for(;r>>0}function wde(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],PS(t,t.g+4),t=2*((a=(n<<0|a<<8|o<<16|s<<24)>>>0)>>31)+1,n=a>>>23&255,a&=8388607,n==255?a?NaN:t*(1/0):n==0?1401298464324817e-60*t*a:t*Math.pow(2,n-150)*(a+8388608)}function L2s(t){return rw(t)}function PS(t,s){if(t.g=s,s>t.l)throw Error()}function qit(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 Uit(t,s){if(s==0)return uC();var r=qit(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):f2s?t.slice(r,s):new Uint8Array(t.subarray(r,s))),r.length==0?uC():new c0(r,xA)}var uze=[];function Vit(t,s,r,n){if(jde.length){const a=jde.pop();return a.o(n),a.g.init(t,s,r,n),a}return new D2s(t,s,r,n)}function Hit(t){t.g.clear(),t.l=-1,t.h=-1,jde.length<100&&jde.push(t)}function Git(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 aoe(t){switch(t.h){case 0:t.h!=0?aoe(t):iCe(t.g);break;case 1:PS(t=t.g,t.g+8);break;case 2:if(t.h!=2)aoe(t);else{var s=y0(t.g);PS(t=t.g,t.g+s)}break;case 5:PS(t=t.g,t.g+4);break;case 3:for(s=t.l;;){if(!Git(t))throw Error();if(t.h==4){if(t.l!=s)throw Error();break}aoe(t)}break;default:throw Error()}}function NO(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 oCe(t){var s=y0(t.g),r=qit(t=t.g,s);if(t=t.h,Kws){var n,a=t;(n=l0e)||(n=l0e=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(v9===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),v9=!0}catch{v9=!1}}throw!v9&&(l0e=void 0),i}}else{s=(o=r)+s,r=[];let i,d=null;for(;o=s?B2():(i=t[o++],l<194||(192&i)!=128?(o--,B2()):r.push((31&l)<<6|63&i)):l<240?o>=s-1?B2():(i=t[o++],(192&i)!=128||l===224&&i<160||l===237&&i>=160||(192&(n=t[o++]))!=128?(o--,B2()):r.push((15&l)<<12|(63&i)<<6|63&n)):l<=244?o>=s-2?B2():(i=t[o++],(192&i)!=128||i-144+(l<<28)>>30||(192&(n=t[o++]))!=128||(192&(a=t[o++]))!=128?(o--,B2()):(l=(7&l)<<18|(63&i)<<12|(63&n)<<6|63&a,l-=65536,r.push(55296+(l>>10&1023),56320+(1023&l)))):B2(),r.length>=8192&&(d=K7e(d,r),r.length=0)}o=K7e(d,r)}return o}function Wit(t){const s=y0(t.g);return Uit(t.g,s)}function Ome(t,s,r){var n=y0(t.g);for(n=t.g.g+n;t.g.g>>0,this.g=s>>>0}};let R2s;function mze(t){return t?/^-?\d+$/.test(t)?(Pme(t),new Dwe(Ic,Rd)):null:O2s||(O2s=new Dwe(0,0))}var Dwe=class{constructor(t,s){this.h=t>>>0,this.g=s>>>0}};let O2s;function tT(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 ME(t,s){for(;s>127;)t.g.push(127&s|128),s>>>=7;t.g.push(s)}function Fme(t,s){if(s>=0)ME(t,s);else{for(let r=0;r<9;r++)t.g.push(127&s|128),s>>=7;t.g.push(1)}}function lCe(t){var s=Ic;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 wA(t,s){s.length!==0&&(t.l.push(s),t.h+=s.length)}function Ox(t,s,r){ME(t.g,8*s+r)}function cCe(t,s){return Ox(t,s,2),s=t.g.end(),wA(t,s),s.push(t.h),s}function dCe(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 zme(t,s,r){Ox(t,s,2),ME(t.g,r.length),wA(t,t.g.end()),wA(t,r)}function Nde(t,s,r,n){r!=null&&(s=cCe(t,s),n(r,t),dCe(t,s))}function M0(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var uCe=M0(),Kit=M0(),hCe=M0(),mCe=M0(),pCe=M0(),Zit=M0(),F2s=M0(),Bme=M0(),Yit=M0(),Xit=M0();function T0(t,s,r){var n=t.v;mf&&mf in n&&(n=n[mf])&&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 ba=class{constructor(t,s){this.v=Iit(t,s,void 0,2048)}toJSON(){return Pit(this)}j(){var a;var t=vjs,s=this.v,r=t.g,n=mf;if(bE&&n&&((a=s[n])==null?void 0:a[r])!=null&&gA(a2s,3),s=t.g,eze&&mf&&eze===void 0&&(n=(r=this.v)[mf])&&(n=n.da))try{n(r,s,M2s)}catch(o){hit(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[_a];return XSe(this,t,s)?ZSe(this,t,!0):new this.constructor(NE(t,s,!1))}};ba.prototype[yA]=vA,ba.prototype.toString=function(){return this.v.toString()};var TE=class{constructor(t,s,r){this.g=t,this.h=s,t=uCe,this.l=!!t&&r===t||!1}};function $me(t,s){return new TE(t,s,uCe)}function Qit(t,s,r,n,a){Nde(t,r,sot(s,n),a)}const z2s=$me(function(t,s,r,n,a){return t.h===2&&(NO(t,sCe(s,n,r),a),!0)},Qit),B2s=$me(function(t,s,r,n,a){return t.h===2&&(NO(t,sCe(s,n,r),a),!0)},Qit);var qme=Symbol(),Ume=Symbol(),Rwe=Symbol(),pze=Symbol(),fze=Symbol();let Jit,eot;function EC(t,s,r,n){var a=n[t];if(a)return a;(a={}).qa=n,a.T=function(x){switch(typeof x){case"boolean":return E2s||(E2s=[0,void 0,!0]);case"number":return x>0?void 0:x===0?P2s||(P2s=[0,void 0]):[-x,void 0];case"string":return[0,x];case"object":return x}}(n[0]);var o=n[1];let l=1;o&&o.constructor===Object&&(a.ba=o,typeof(o=n[++l])=="function"&&(a.ma=!0,Jit??(Jit=o),eot??(eot=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 xCe(t,s,r,n,a){const o=r.g;let l,i;t[s]=(d,u,p)=>o(d,u,p,i||(i=EC(Ume,fCe,xCe,n).T),l||(l=gCe(n)),a)}function gCe(t){let s=t[Rwe];if(s!=null)return s;const r=EC(Ume,fCe,xCe,t);return s=r.ma?(n,a)=>Jit(n,a,r):(n,a)=>{for(;Git(a)&&a.h!=4;){var o=a.l,l=r[o];if(l==null){var i=r.ba;i&&(i=i[o])&&(i=q2s(i))!=null&&(l=r[o]=i)}if(l==null||!l(a,n,o)){if(l=(i=a).m,aoe(i),i.ha)var d=void 0;else d=i.g.g-l,i.g.g=l,d=Uit(i.g,d);l=void 0,i=n,d&&((l=i[mf]??(i[mf]=new Iwe))[o]??(l[o]=[])).push(d)}}return(n=Lme(n))&&(n.da=r.qa[fze]),!0},t[Rwe]=s,t[fze]=$2s.bind(t),s}function $2s(t,s,r,n){var a=this[Ume];const o=this[Rwe],l=TS(void 0,a.T),i=Lme(t);if(i){var d=!1,u=a.ba;if(u){if(a=(p,x,y)=>{if(y.length!==0)if(u[x])for(const _ of y){p=Vit(_);try{d=!0,o(l,p)}finally{Hit(p)}}else n==null||n(t,x,y)},s==null)_de(i,a);else if(i!=null){const p=i[s];p&&a(i,s,p)}if(d){let p=0|t[_a];if(2&p&&2048&p&&!(r!=null&&r.Ka))throw Error();const x=wE(p),y=(_,b)=>{if(_1(t,_,x)!=null){if((r==null?void 0:r.Qa)===1)return;throw Error()}b!=null&&(p=fu(t,p,_,b,x)),delete i[_]};s==null?bit(l,0|l[_a],(_,b)=>{y(_,b)}):y(s,_1(l,s,x))}}}}function q2s(t){const s=(t=tot(t))[0].g;if(t=t[1]){const r=gCe(t),n=EC(Ume,fCe,xCe,t).T;return(a,o,l)=>s(a,o,l,n,r)}return s}function Vme(t,s,r){t[s]=r.h}function Hme(t,s,r,n){let a,o;const l=r.h;t[s]=(i,d,u)=>l(i,d,u,o||(o=EC(qme,Vme,Hme,n).T),a||(a=rot(n)))}function rot(t){let s=t[pze];if(!s){const r=EC(qme,Vme,Hme,t);s=(n,a)=>not(n,a,r),t[pze]=s}return s}function not(t,s,r){bit(t,0|t[_a],(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=tot(d))[0].h;if(d=d[1]){const p=rot(d),x=EC(qme,Vme,Hme,d).T;d=l.ma?eot(x,p):(y,_,b)=>u(y,_,b,x,p)}else d=u;return l[i]=d}}(r,n);o?o(s,a,n):n<500||gA(Ewe,3)}}),(t=Lme(t))&&_de(t,(n,a,o)=>{for(wA(s,s.g.end()),n=0;n{Nde(t,r,TS([l,o],n),a)});else if(Array.isArray(s)){for(let o=0;o>BigInt(32))),tT(t.g,r.h,r.g);break;default:r=mze(s),tT(t.g,r.h,r.g)}}function oot(t,s,r){(s=jE(s))!=null&&s!=null&&(Ox(t,r,0),Fme(t.g,s))}function lot(t,s,r){(s=kit(s))!=null&&(Ox(t,r,0),t.g.g.push(s?1:0))}function cot(t,s,r){(s=mh(s))!=null&&zme(t,r,uit(s))}function dot(t,s,r,n,a){Nde(t,r,sot(s,n),a)}function uot(t,s,r){(s=s==null||typeof s=="string"||s instanceof c0?s:void 0)!=null&&zme(t,r,nCe(s,!0).buffer)}function hot(t,s,r){(s=Sit(s))!=null&&s!=null&&(Ox(t,r,0),ME(t.g,s))}function mot(t,s,r){return(t.h===5||t.h===2)&&(s=CE(s,0|s[_a],r),t.h==2?Ome(t,wde,s):s.push(wde(t.g)),!0)}var zd=Gh(function(t,s,r){return t.h===5&&(Wh(s,r,wde(t.g)),!0)},aot,Bme),H2s=EE(mot,function(t,s,r){if((s=AE(Vy,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"))||(Pme(n),n=iR(Ic,Rd))),n;if(a==="number")return(n=bA(n))>=0&&mC(n)||(_A(n),n=jit(Ic,Rd)),n}}(s),s!=null&&(typeof s=="string"&&hze(s),s!=null))switch(Ox(t,r,0),typeof s){case"number":t=t.g,_A(s),tT(t,Ic,Rd);break;case"bigint":r=BigInt.asUintN(64,s),r=new Lwe(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),tT(t.g,r.h,r.g);break;default:r=hze(s),tT(t.g,r.h,r.g)}},F2s),cu=Gh(function(t,s,r){return t.h===0&&(Wh(s,r,rw(t.g)),!0)},oot,mCe),kO=EE(function(t,s,r){return(t.h===0||t.h===2)&&(s=CE(s,0|s[_a],r),t.h==2?Ome(t,rw,s):s.push(rw(t.g)),!0)},function(t,s,r){if((s=AE(jE,s))!=null&&s.length){r=cCe(t,r);for(let n=0;n{{const o={ea:!0};n&&Object.assign(o,n),r=Vit(r,void 0,void 0,o);try{const l=new t,i=l.v;gCe(s)(i,r);var a=l}finally{Hit(r)}}return a}}function Gme(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}}}};not(this.v,s,EC(qme,Vme,Hme,t)),wA(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=yze.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r}()),t=(s=m0e)?s.createScriptURL(t):t,new class{constructor(r){this.g=r}toString(){return this.g+""}}(t)}function _9(t,...s){if(s.length===0)return vze(t[0]);let r=t[0];for(let n=0;n({index:mx(n,1)??0??-1,score:ud(n,2)??0,categoryName:mh(Rc(n,3))??""??"",displayName:mh(Rc(n,4))??""??""})),headIndex:s,headName:r}}function jjs(t){const s={classifications:b1(t,njs,1).map(r=>{var n;return SCe(((n=No(r,wot,4))==null?void 0:n.g())??[],mx(r,2)??0,mh(Rc(r,3))??"")})};return function(r){return r==null?r:typeof r=="bigint"?(Pwe(r)?r=Number(r):(r=bO(64,r),r=Pwe(r)?Number(r):String(r)),r):wO(r)?typeof r=="number"?WSe(r):Mit(r):void 0}(Rc(t,2,void 0,void 0,vde))!=null&&(s.timestampMs=Zot(Rc(t,2,void 0,void 0,vde)??Lit)),s}function Yot(t){var l,i;var s=S4(t,3,Vy,k4()),r=S4(t,2,jE,k4()),n=S4(t,1,mh,k4()),a=S4(t,9,mh,k4());const o={categories:[],keypoints:[]};for(let d=0;ds>127?s-256:s)}function Eze(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 Pze(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 Jot(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 ka(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 Ize(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]=Jot(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 Lze(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 by(t,s,r){t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[s]=r}function v_(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)}}D5.forVisionTasks=function(t,s=!1){return w9("vision",t??_9``,s)},D5.forTextTasks=function(t,s=!1){return w9("text",t??_9``,s)},D5.forGenAiTasks=function(t,s=!1){return w9("genai",t??_9``,s)},D5.forAudioTasks=function(t,s=!1){return w9("audio",t??_9``,s)},D5.isSimdSupported=function(t=!1){return Xot(t)};async function kjs(t,s,r,n){return t=await(async(a,o,l,i,d)=>{if(o&&await Pze(o),!self.ModuleFactory||l&&(await Pze(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 x0e(t,s){const r=No(t.baseOptions,kde,1)||new kde;typeof s=="string"?(sl(r,2,jO(s)),sl(r,1)):s instanceof Uint8Array&&(sl(r,1,USe(s,!1)),sl(r,2)),Va(t.baseOptions,0,1,r)}function Dze(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 Yme(t,s){t.B=new Np,yf(t.B,2,"PassThroughCalculator"),bc(t.B,"free_memory"),io(t.B,"free_memory_unused_out"),zc(s,"free_memory"),Fx(s,t.B)}function jA(t,s){bc(t.B,s),io(t.B,s+"_unused_out")}function Xme(t){t.g.addBoolToStream(!0,"free_memory",t.C)}var $we=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=No(this.baseOptions,kde,1))!=null&&a.g()||(o=No(this.baseOptions,kde,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 x=No(u.baseOptions,Sze,3);if(!x){var y=x=new Sze,_=new _ze;N8(y,4,ioe,_)}"delegate"in p&&(p.delegate==="GPU"?(p=x,y=new X2s,N8(p,2,ioe,y)):(p=x,y=new _ze,N8(p,4,ioe,y))),Va(u.baseOptions,0,3,x)}(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),x0e(this,"/model.dat"),this.m(),this.L()});if(d.modelAssetBuffer instanceof Uint8Array)x0e(this,d.modelAssetBuffer);else if(d.modelAssetBuffer)return async function(u){const p=[];for(var x=0;;){const{done:y,value:_}=await u.read();if(y)break;p.push(_),x+=_.length}if(p.length===0)return new Uint8Array(0);if(p.length===1)return p[0];u=new Uint8Array(x),x=0;for(const y of p)u.set(y,x),x+=y.length;return u}(d.modelAssetBuffer).then(u=>{x0e(this,u),this.m(),this.L()})}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let t;if(this.g.ca(s=>{t=Q2s(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,Dze(this)}finishProcessing(){this.g.finishProcessing(),Dze(this)}close(){this.B=void 0,this.g.closeGraph()}};function Bb(t,s){if(!t)throw Error(`Unable to obtain required WebGL resource: ${s}`);return t}$we.prototype.close=$we.prototype.close;class Sjs{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 Rze(t,s,r){const n=t.g;if(r=Bb(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 Oze(t,s){const r=t.g,n=Bb(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(n);const a=Bb(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=Bb(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 Sjs(r,n,a,o)}function CCe(t,s){if(t.g){if(s!==t.g)throw Error("Cannot change GL context once initialized")}else t.g=s}function Cjs(t,s,r,n){return CCe(t,s),t.h||(t.m(),t.D()),r?(t.u||(t.u=Oze(t,!0)),r=t.u):(t.A||(t.A=Oze(t,!1)),r=t.A),s.useProgram(t.h),r.bind(),t.l(),t=n(),r.g.bindVertexArray(null),t}function elt(t,s,r){return CCe(t,s),t=Bb(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 tlt(t,s,r){CCe(t,s),t.B||(t.B=Bb(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 Mjs(t){var s;(s=t.g)==null||s.bindFramebuffer(t.g.FRAMEBUFFER,null)}var slt=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=Bb(t.createProgram(),"Failed to create WebGL program"),this.X=Rze(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=Rze(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 Dv(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 qwe(t){var s=Dv(t,1);if(!s){if(s=Dv(t,0))s=new Float32Array(s).map(n=>n/255);else{s=new Float32Array(t.width*t.height);const n=NA(t);var r=MCe(t);if(tlt(r,n,rlt(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 qwe(this)}N(){return rlt(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=NA(this),a=MCe(this);n.activeTexture(n.TEXTURE1),r=elt(a,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);const o=nlt(this);n.texImage2D(n.TEXTURE_2D,0,o,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),tlt(a,n,r),Cjs(a,n,!1,()=>{alt(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),Uwe(this)}),Mjs(a),Uwe(this)}}t.push(r)}return new Tu(t,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&NA(this).deleteTexture(Dv(this,2)),Fze=-1}};Tu.prototype.close=Tu.prototype.close,Tu.prototype.clone=Tu.prototype.clone,Tu.prototype.getAsWebGLTexture=Tu.prototype.N,Tu.prototype.getAsFloat32Array=Tu.prototype.ia,Tu.prototype.getAsUint8Array=Tu.prototype.ja,Tu.prototype.hasWebGLTexture=Tu.prototype.R,Tu.prototype.hasFloat32Array=Tu.prototype.ka,Tu.prototype.hasUint8Array=Tu.prototype.Fa;var Fze=250;function Kg(...t){return t.map(([s,r])=>({start:s,end:r}))}const Tjs=function(t){return class extends t{Ja(){this.i._registerModelResourcesGraphService()}}}((zze=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:Qot()?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?'),ka(this,n||"input_audio",o=>{ka(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){by(this,"__graph_config__",s=>{t(s)}),ka(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),ka(this,n,l=>{this.i._addAudioToInputStream(this.g,s,r,l,a)})}addGpuBufferToStream(t,s,r){ka(this,s,n=>{const[a,o]=Ize(this,t,n);this.i._addBoundTextureToStream(n,a,o,r)})}addBoolToStream(t,s,r){ka(this,s,n=>{this.i._addBoolToInputStream(t,n,r)})}addDoubleToStream(t,s,r){ka(this,s,n=>{this.i._addDoubleToInputStream(t,n,r)})}addFloatToStream(t,s,r){ka(this,s,n=>{this.i._addFloatToInputStream(t,n,r)})}addIntToStream(t,s,r){ka(this,s,n=>{this.i._addIntToInputStream(t,n,r)})}addUintToStream(t,s,r){ka(this,s,n=>{this.i._addUintToInputStream(t,n,r)})}addStringToStream(t,s,r){ka(this,s,n=>{ka(this,t,a=>{this.i._addStringToInputStream(a,n,r)})})}addStringRecordToStream(t,s,r){ka(this,s,n=>{Lze(this,Object.keys(t),a=>{Lze(this,Object.values(t),o=>{this.i._addFlatHashMapToInputStream(a,o,Object.keys(t).length,n,r)})})})}addProtoToStream(t,s,r,n){ka(this,r,a=>{ka(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){ka(this,t,r=>{this.i._addEmptyPacketToInputStream(r,s)})}addBoolVectorToStream(t,s,r){ka(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){ka(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){ka(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){ka(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){ka(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){ka(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)ka(this,o,l=>{this.i._addStringVectorEntry(a,l)});this.i._addStringVectorToInputStream(a,n,r)})}addBoolToInputSidePacket(t,s){ka(this,s,r=>{this.i._addBoolToInputSidePacket(t,r)})}addDoubleToInputSidePacket(t,s){ka(this,s,r=>{this.i._addDoubleToInputSidePacket(t,r)})}addFloatToInputSidePacket(t,s){ka(this,s,r=>{this.i._addFloatToInputSidePacket(t,r)})}addIntToInputSidePacket(t,s){ka(this,s,r=>{this.i._addIntToInputSidePacket(t,r)})}addUintToInputSidePacket(t,s){ka(this,s,r=>{this.i._addUintToInputSidePacket(t,r)})}addStringToInputSidePacket(t,s){ka(this,s,r=>{ka(this,t,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(t,s,r){ka(this,r,n=>{ka(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){ka(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){ka(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){ka(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){ka(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){ka(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){ka(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)ka(this,a,o=>{this.i._addStringVectorEntry(n,o)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(t,s){by(this,t,s),ka(this,t,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(t,s){v_(this,t,s),ka(this,t,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(t,s){by(this,t,s),ka(this,t,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(t,s){v_(this,t,s),ka(this,t,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(t,s){by(this,t,s),ka(this,t,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(t,s){v_(this,t,s),ka(this,t,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(t,s){by(this,t,s),ka(this,t,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(t,s){v_(this,t,s),ka(this,t,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(t,s){by(this,t,s),ka(this,t,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(t,s){v_(this,t,s),ka(this,t,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(t,s){by(this,t,s),ka(this,t,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(t,s){v_(this,t,s),ka(this,t,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(t,s,r){by(this,t,s),ka(this,t,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(t,s,r){v_(this,t,s),ka(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?'),by(this,t,(n,a)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),s(n,a)}),ka(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 zze{get ga(){return this.i}pa(t,s,r){ka(this,s,n=>{const[a,o]=Ize(this,t,n);this.ga._addBoundTextureAsImageToStream(n,a,o,r)})}Z(t,s){by(this,t,s),ka(this,t,r=>{this.ga._attachImageListener(r)})}aa(t,s){v_(this,t,s),ka(this,t,r=>{this.ga._attachImageVectorListener(r)})}}));var zze,Zg=class extends Tjs{};async function yo(t,s,r){return async function(n,a,o,l){return kjs(n,a,o,l)}(t,r.canvas??(Qot()?void 0:document.createElement("canvas")),s,r)}function ilt(t,s,r,n){if(t.U){const o=new Cot;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].");Ia(o,1,(a.left+a.right)/2),Ia(o,2,(a.top+a.bottom)/2),Ia(o,4,a.right-a.left),Ia(o,3,a.bottom-a.top)}else Ia(o,1,.5),Ia(o,2,.5),Ia(o,4,1),Ia(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(Ia(o,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[l,i]=Jot(s);r=ud(o,3)*i/l,a=ud(o,4)*l/i,Ia(o,4,r),Ia(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 Yg(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'.");ilt(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'.");ilt(t,s,r,n)}function kA(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 Tu([a],r,!1,t.g.i.canvas,t.P,o,s),n?t.clone():t}var vf=class extends $we{constructor(t,s,r,n){super(t),this.g=t,this.X=s,this.U=r,this.oa=n,this.P=new slt}l(t,s=!0){if("runningMode"in t&&sl(this.baseOptions,2,oR(!!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()}};vf.prototype.close=vf.prototype.close;var Gf=class extends vf{constructor(t,s){super(new Zg(t,s),"image_in","norm_rect_in",!1),this.j={detections:[]},Va(t=this.h=new Kme,0,1,s=new ad),Ia(this.h,2,.5),Ia(this.h,3,.3)}get baseOptions(){return No(this.h,ad,1)}set baseOptions(t){Va(this.h,0,1,t)}o(t){return"minDetectionConfidence"in t&&Ia(this.h,2,t.minDetectionConfidence??.5),"minSuppressionThreshold"in t&&Ia(this.h,3,t.minSuppressionThreshold??.3),this.l(t)}F(t,s){return this.j={detections:[]},Yg(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},E0(this,t,r,s),this.j}m(){var t=new kf;zc(t,"image_in"),zc(t,"norm_rect_in"),Io(t,"detections");const s=new Nf;T0(s,djs,this.h);const r=new Np;yf(r,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),bc(r,"IMAGE:image_in"),bc(r,"NORM_RECT:norm_rect_in"),io(r,"DETECTIONS:detections"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Not(o),this.j.detections.push(Yot(n));aa(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{aa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Gf.prototype.detectForVideo=Gf.prototype.G,Gf.prototype.detect=Gf.prototype.F,Gf.prototype.setOptions=Gf.prototype.o,Gf.createFromModelPath=async function(t,s){return yo(Gf,t,{baseOptions:{modelAssetPath:s}})},Gf.createFromModelBuffer=function(t,s){return yo(Gf,t,{baseOptions:{modelAssetBuffer:s}})},Gf.createFromOptions=function(t,s){return yo(Gf,t,s)};var TCe=Kg([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]),ACe=Kg([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]),ECe=Kg([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),olt=Kg([474,475],[475,476],[476,477],[477,474]),PCe=Kg([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]),ICe=Kg([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),llt=Kg([469,470],[470,471],[471,472],[472,469]),LCe=Kg([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]),clt=[...TCe,...ACe,...ECe,...PCe,...ICe,...LCe],dlt=Kg([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 Bze(t){t.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var Uc=class extends vf{constructor(t,s){super(new Zg(t,s),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,Va(t=this.h=new Pot,0,1,s=new ad),this.A=new Eot,Va(this.h,0,3,this.A),this.u=new Kme,Va(this.h,0,2,this.u),w1(this.u,4,1),Ia(this.u,2,.5),Ia(this.A,2,.5),Ia(this.h,4,.5)}get baseOptions(){return No(this.h,ad,1)}set baseOptions(t){Va(this.h,0,1,t)}o(t){return"numFaces"in t&&w1(this.u,4,t.numFaces??1),"minFaceDetectionConfidence"in t&&Ia(this.u,2,t.minFaceDetectionConfidence??.5),"minTrackingConfidence"in t&&Ia(this.h,4,t.minTrackingConfidence??.5),"minFacePresenceConfidence"in t&&Ia(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 Bze(this),Yg(this,t,s),this.j}G(t,s,r){return Bze(this),E0(this,t,r,s),this.j}m(){var t=new kf;zc(t,"image_in"),zc(t,"norm_rect"),Io(t,"face_landmarks");const s=new Nf;T0(s,hjs,this.h);const r=new Np;yf(r,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),bc(r,"IMAGE:image_in"),bc(r,"NORM_RECT:norm_rect"),io(r,"NORM_LANDMARKS:face_landmarks"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("face_landmarks",(n,a)=>{for(const o of n)n=SO(o),this.j.faceLandmarks.push(Zme(n));aa(this,a)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{aa(this,n)}),this.outputFaceBlendshapes&&(Io(t,"blendshapes"),io(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,a)=>{if(this.outputFaceBlendshapes)for(const o of n)n=Wme(o),this.j.faceBlendshapes.push(SCe(n.g()??[]));aa(this,a)}),this.g.attachEmptyPacketListener("blendshapes",n=>{aa(this,n)})),this.outputFacialTransformationMatrixes&&(Io(t,"face_geometry"),io(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,a)=>{if(this.outputFacialTransformationMatrixes)for(const o of n)(n=No(n=ujs(o),sjs,2))&&this.j.facialTransformationMatrixes.push({rows:mx(n,1)??0??0,columns:mx(n,2)??0??0,data:S4(n,3,Vy,k4()).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 yo(Uc,t,{baseOptions:{modelAssetPath:s}})},Uc.createFromModelBuffer=function(t,s){return yo(Uc,t,{baseOptions:{modelAssetBuffer:s}})},Uc.createFromOptions=function(t,s){return yo(Uc,t,s)},Uc.FACE_LANDMARKS_LIPS=TCe,Uc.FACE_LANDMARKS_LEFT_EYE=ACe,Uc.FACE_LANDMARKS_LEFT_EYEBROW=ECe,Uc.FACE_LANDMARKS_LEFT_IRIS=olt,Uc.FACE_LANDMARKS_RIGHT_EYE=PCe,Uc.FACE_LANDMARKS_RIGHT_EYEBROW=ICe,Uc.FACE_LANDMARKS_RIGHT_IRIS=llt,Uc.FACE_LANDMARKS_FACE_OVAL=LCe,Uc.FACE_LANDMARKS_CONTOURS=clt,Uc.FACE_LANDMARKS_TESSELATION=dlt;var DCe=Kg([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 $ze(t){t.gestures=[],t.landmarks=[],t.worldLandmarks=[],t.handedness=[]}function qze(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 Uze(t,s=!0){const r=[];for(const a of t){var n=Wme(a);t=[];for(const o of n.g())n=s&&mx(o,1)!=null?mx(o,1)??0:-1,t.push({score:ud(o,2)??0,index:n,categoryName:mh(Rc(o,3))??""??"",displayName:mh(Rc(o,4))??""??""});r.push(t)}return r}var Op=class extends vf{constructor(t,s){super(new Zg(t,s),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Va(t=this.j=new Dot,0,1,s=new ad),this.u=new wCe,Va(this.j,0,2,this.u),this.D=new bCe,Va(this.u,0,3,this.D),this.A=new Lot,Va(this.u,0,2,this.A),this.h=new mjs,Va(this.j,0,3,this.h),Ia(this.A,2,.5),Ia(this.u,4,.5),Ia(this.D,2,.5)}get baseOptions(){return No(this.j,ad,1)}set baseOptions(t){Va(this.j,0,1,t)}o(t){var a,o,l,i;if(w1(this.A,3,t.numHands??1),"minHandDetectionConfidence"in t&&Ia(this.A,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Ia(this.u,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Ia(this.D,2,t.minHandPresenceConfidence??.5),t.cannedGesturesClassifierOptions){var s=new N5,r=s,n=Bwe(t.cannedGesturesClassifierOptions,(a=No(this.h,N5,3))==null?void 0:a.l());Va(r,0,2,n),Va(this.h,0,3,s)}else t.cannedGesturesClassifierOptions===void 0&&((o=No(this.h,N5,3))==null||o.g());return t.customGesturesClassifierOptions?(Va(r=s=new N5,0,2,n=Bwe(t.customGesturesClassifierOptions,(l=No(this.h,N5,4))==null?void 0:l.l())),Va(this.h,0,4,s)):t.customGesturesClassifierOptions===void 0&&((i=No(this.h,N5,4))==null||i.g()),this.l(t)}Ha(t,s){return $ze(this),Yg(this,t,s),qze(this)}Ia(t,s,r){return $ze(this),E0(this,t,r,s),qze(this)}m(){var t=new kf;zc(t,"image_in"),zc(t,"norm_rect"),Io(t,"hand_gestures"),Io(t,"hand_landmarks"),Io(t,"world_hand_landmarks"),Io(t,"handedness");const s=new Nf;T0(s,pjs,this.j);const r=new Np;yf(r,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),bc(r,"IMAGE:image_in"),bc(r,"NORM_RECT:norm_rect"),io(r,"HAND_GESTURES:hand_gestures"),io(r,"LANDMARKS:hand_landmarks"),io(r,"WORLD_LANDMARKS:world_hand_landmarks"),io(r,"HANDEDNESS:handedness"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n){n=SO(o);const l=[];for(const i of b1(n,Sot,1))l.push({x:ud(i,1)??0,y:ud(i,2)??0,z:ud(i,3)??0,visibility:ud(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=sT(o);const l=[];for(const i of b1(n,kot,1))l.push({x:ud(i,1)??0,y:ud(i,2)??0,z:ud(i,3)??0,visibility:ud(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(...Uze(n,!1)),aa(this,a)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{aa(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{this.handedness.push(...Uze(n)),aa(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{aa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function Vze(t){return{landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handednesses:t.handedness,handedness:t.handedness}}Op.prototype.recognizeForVideo=Op.prototype.Ia,Op.prototype.recognize=Op.prototype.Ha,Op.prototype.setOptions=Op.prototype.o,Op.createFromModelPath=function(t,s){return yo(Op,t,{baseOptions:{modelAssetPath:s}})},Op.createFromModelBuffer=function(t,s){return yo(Op,t,{baseOptions:{modelAssetBuffer:s}})},Op.createFromOptions=function(t,s){return yo(Op,t,s)},Op.HAND_CONNECTIONS=DCe;var Fp=class extends vf{constructor(t,s){super(new Zg(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Va(t=this.h=new wCe,0,1,s=new ad),this.u=new bCe,Va(this.h,0,3,this.u),this.j=new Lot,Va(this.h,0,2,this.j),w1(this.j,3,1),Ia(this.j,2,.5),Ia(this.u,2,.5),Ia(this.h,4,.5)}get baseOptions(){return No(this.h,ad,1)}set baseOptions(t){Va(this.h,0,1,t)}o(t){return"numHands"in t&&w1(this.j,3,t.numHands??1),"minHandDetectionConfidence"in t&&Ia(this.j,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Ia(this.h,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Ia(this.u,2,t.minHandPresenceConfidence??.5),this.l(t)}F(t,s){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Yg(this,t,s),Vze(this)}G(t,s,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],E0(this,t,r,s),Vze(this)}m(){var t=new kf;zc(t,"image_in"),zc(t,"norm_rect"),Io(t,"hand_landmarks"),Io(t,"world_hand_landmarks"),Io(t,"handedness");const s=new Nf;T0(s,fjs,this.h);const r=new Np;yf(r,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),bc(r,"IMAGE:image_in"),bc(r,"NORM_RECT:norm_rect"),io(r,"LANDMARKS:hand_landmarks"),io(r,"WORLD_LANDMARKS:world_hand_landmarks"),io(r,"HANDEDNESS:handedness"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n)n=SO(o),this.landmarks.push(Zme(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=sT(o),this.worldLandmarks.push(S8(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=Wme(d);const u=[];for(const p of n.g())u.push({score:ud(p,2)??0,index:mx(p,1)??0??-1,categoryName:mh(Rc(p,3))??""??"",displayName:mh(Rc(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)}};Fp.prototype.detectForVideo=Fp.prototype.G,Fp.prototype.detect=Fp.prototype.F,Fp.prototype.setOptions=Fp.prototype.o,Fp.createFromModelPath=function(t,s){return yo(Fp,t,{baseOptions:{modelAssetPath:s}})},Fp.createFromModelBuffer=function(t,s){return yo(Fp,t,{baseOptions:{modelAssetBuffer:s}})},Fp.createFromOptions=function(t,s){return yo(Fp,t,s)},Fp.HAND_CONNECTIONS=DCe;var ult=Kg([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 Hze(t){t.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function Gze(t){try{if(!t.D)return t.h;t.D(t.h)}finally{Xme(t)}}function N9(t,s){t=SO(t),s.push(Zme(t))}var lc=class extends vf{constructor(t,s){super(new Zg(t,s),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,Va(t=this.j=new Bot,0,1,s=new ad),this.I=new bCe,Va(this.j,0,2,this.I),this.W=new xjs,Va(this.j,0,3,this.W),this.u=new Kme,Va(this.j,0,4,this.u),this.O=new Eot,Va(this.j,0,5,this.O),this.A=new Fot,Va(this.j,0,6,this.A),this.M=new zot,Va(this.j,0,7,this.M),Ia(this.u,2,.5),Ia(this.u,3,.3),Ia(this.O,2,.5),Ia(this.A,2,.5),Ia(this.A,3,.3),Ia(this.M,2,.5),Ia(this.I,2,.5)}get baseOptions(){return No(this.j,ad,1)}set baseOptions(t){Va(this.j,0,1,t)}o(t){return"minFaceDetectionConfidence"in t&&Ia(this.u,2,t.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in t&&Ia(this.u,3,t.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in t&&Ia(this.O,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"minPoseDetectionConfidence"in t&&Ia(this.A,2,t.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in t&&Ia(this.A,3,t.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in t&&Ia(this.M,2,t.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in t&&(this.outputPoseSegmentationMasks=!!t.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in t&&Ia(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,Hze(this),Yg(this,t,n),Gze(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:n,Hze(this),E0(this,t,a,s),Gze(this)}m(){var t=new kf;zc(t,"input_frames_image"),Io(t,"pose_landmarks"),Io(t,"pose_world_landmarks"),Io(t,"face_landmarks"),Io(t,"left_hand_landmarks"),Io(t,"left_hand_world_landmarks"),Io(t,"right_hand_landmarks"),Io(t,"right_hand_world_landmarks");const s=new Nf,r=new xze;yf(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,Dme(o,0,lR));else{if(!(typeof o=="string"||o instanceof c0||$Se(o)))throw Error("invalid value in Any.value field: "+o+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");z_(a,2,USe(o,!1),uC())}}(r,this.j.g());const n=new Np;yf(n,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),rCe(n,8,xze,r),bc(n,"IMAGE:input_frames_image"),io(n,"POSE_LANDMARKS:pose_landmarks"),io(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),io(n,"FACE_LANDMARKS:face_landmarks"),io(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),io(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),io(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),io(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(s),Fx(t,n),Yme(this,t),this.g.attachProtoListener("pose_landmarks",(a,o)=>{N9(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=sT(a),l.push(S8(a)),aa(this,o)}),this.g.attachEmptyPacketListener("pose_world_landmarks",a=>{aa(this,a)}),this.outputPoseSegmentationMasks&&(io(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),jA(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",(a,o)=>{this.h.poseSegmentationMasks=[kA(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)=>{N9(a,this.h.faceLandmarks),aa(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",a=>{aa(this,a)}),this.outputFaceBlendshapes&&(Io(t,"extra_blendshapes"),io(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(a,o)=>{var l=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(a=Wme(a),l.push(SCe(a.g()??[]))),aa(this,o)}),this.g.attachEmptyPacketListener("extra_blendshapes",a=>{aa(this,a)})),this.g.attachProtoListener("left_hand_landmarks",(a,o)=>{N9(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=sT(a),l.push(S8(a)),aa(this,o)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",a=>{aa(this,a)}),this.g.attachProtoListener("right_hand_landmarks",(a,o)=>{N9(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=sT(a),l.push(S8(a)),aa(this,o)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",a=>{aa(this,a)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};lc.prototype.detectForVideo=lc.prototype.G,lc.prototype.detect=lc.prototype.F,lc.prototype.setOptions=lc.prototype.o,lc.createFromModelPath=function(t,s){return yo(lc,t,{baseOptions:{modelAssetPath:s}})},lc.createFromModelBuffer=function(t,s){return yo(lc,t,{baseOptions:{modelAssetBuffer:s}})},lc.createFromOptions=function(t,s){return yo(lc,t,s)},lc.HAND_CONNECTIONS=DCe,lc.POSE_CONNECTIONS=ult,lc.FACE_LANDMARKS_LIPS=TCe,lc.FACE_LANDMARKS_LEFT_EYE=ACe,lc.FACE_LANDMARKS_LEFT_EYEBROW=ECe,lc.FACE_LANDMARKS_LEFT_IRIS=olt,lc.FACE_LANDMARKS_RIGHT_EYE=PCe,lc.FACE_LANDMARKS_RIGHT_EYEBROW=ICe,lc.FACE_LANDMARKS_RIGHT_IRIS=llt,lc.FACE_LANDMARKS_FACE_OVAL=LCe,lc.FACE_LANDMARKS_CONTOURS=clt,lc.FACE_LANDMARKS_TESSELATION=dlt;var Wf=class extends vf{constructor(t,s){super(new Zg(t,s),"input_image","norm_rect",!0),this.j={classifications:[]},Va(t=this.h=new $ot,0,1,s=new ad)}get baseOptions(){return No(this.h,ad,1)}set baseOptions(t){Va(this.h,0,1,t)}o(t){return Va(this.h,0,2,Bwe(t,No(this.h,vCe,2))),this.l(t)}sa(t,s){return this.j={classifications:[]},Yg(this,t,s),this.j}ta(t,s,r){return this.j={classifications:[]},E0(this,t,r,s),this.j}m(){var t=new kf;zc(t,"input_image"),zc(t,"norm_rect"),Io(t,"classifications");const s=new Nf;T0(s,gjs,this.h);const r=new Np;yf(r,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),bc(r,"IMAGE:input_image"),bc(r,"NORM_RECT:norm_rect"),io(r,"CLASSIFICATIONS:classifications"),r.o(s),Fx(t,r),this.g.attachProtoListener("classifications",(n,a)=>{this.j=jjs(ajs(n)),aa(this,a)}),this.g.attachEmptyPacketListener("classifications",n=>{aa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Wf.prototype.classifyForVideo=Wf.prototype.ta,Wf.prototype.classify=Wf.prototype.sa,Wf.prototype.setOptions=Wf.prototype.o,Wf.createFromModelPath=function(t,s){return yo(Wf,t,{baseOptions:{modelAssetPath:s}})},Wf.createFromModelBuffer=function(t,s){return yo(Wf,t,{baseOptions:{modelAssetBuffer:s}})},Wf.createFromOptions=function(t,s){return yo(Wf,t,s)};var zp=class extends vf{constructor(t,s){super(new Zg(t,s),"image_in","norm_rect",!0),this.h=new qot,this.embeddings={embeddings:[]},Va(t=this.h,0,1,s=new ad)}get baseOptions(){return No(this.h,ad,1)}set baseOptions(t){Va(this.h,0,1,t)}o(t){var s=this.h,r=No(this.h,kze,2);return r=r?r.clone():new kze,t.l2Normalize!==void 0?sl(r,1,oR(t.l2Normalize)):"l2Normalize"in t&&sl(r,1),t.quantize!==void 0?sl(r,2,oR(t.quantize)):"quantize"in t&&sl(r,2),Va(s,0,2,r),this.l(t)}za(t,s){return Yg(this,t,s),this.embeddings}Aa(t,s,r){return E0(this,t,r,s),this.embeddings}m(){var t=new kf;zc(t,"image_in"),zc(t,"norm_rect"),Io(t,"embeddings_out");const s=new Nf;T0(s,yjs,this.h);const r=new Np;yf(r,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),bc(r,"IMAGE:image_in"),bc(r,"NORM_RECT:norm_rect"),io(r,"EMBEDDINGS:embeddings_out"),r.o(s),Fx(t,r),this.g.attachProtoListener("embeddings_out",(n,a)=>{n=ljs(n),this.embeddings=function(o){return{embeddings:b1(o,ojs,1).map(l=>{var u,p;const i={headIndex:mx(l,3)??0??-1,headName:mh(Rc(l,4))??""??""};var d=l.v;return zit(d,0|d[_a],Nze,u0e(l,1))!==void 0?(l=S4(l=No(l,Nze,u0e(l,1),void 0),1,Vy,k4()),i.floatEmbedding=l.slice()):(d=new Uint8Array(0),i.quantizedEmbedding=((p=(u=No(l,ijs,u0e(l,2),void 0))==null?void 0:u.na())==null?void 0:p.h())??d),i}),timestampMs:Zot(Rc(o,2,void 0,void 0,vde)??Lit)}}(n),aa(this,a)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{aa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};zp.cosineSimilarity=function(t,s){if(t.floatEmbedding&&s.floatEmbedding)t=Eze(t.floatEmbedding,s.floatEmbedding);else{if(!t.quantizedEmbedding||!s.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=Eze(Aze(t.quantizedEmbedding),Aze(s.quantizedEmbedding))}return t},zp.prototype.embedForVideo=zp.prototype.Aa,zp.prototype.embed=zp.prototype.za,zp.prototype.setOptions=zp.prototype.o,zp.createFromModelPath=function(t,s){return yo(zp,t,{baseOptions:{modelAssetPath:s}})},zp.createFromModelBuffer=function(t,s){return yo(zp,t,{baseOptions:{modelAssetBuffer:s}})},zp.createFromOptions=function(t,s){return yo(zp,t,s)};var Vwe=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 Ajs(t){var r,n;const s=function(a){return b1(a,Np,1)}(t.ca()).filter(a=>(mh(Rc(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=No(s[0],Nf,7))==null?void 0:r.j())==null?void 0:n.g())??new Map).forEach((a,o)=>{t.u[Number(o)]=mh(Rc(a,1))??""})}function Wze(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function Kze(t){try{const s=new Vwe(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return s;t.j(s)}finally{Xme(t)}}Vwe.prototype.close=Vwe.prototype.close;var cm=class extends vf{constructor(t,s){super(new Zg(t,s),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new kCe,this.A=new Uot,Va(this.h,0,3,this.A),Va(t=this.h,0,1,s=new ad)}get baseOptions(){return No(this.h,ad,1)}set baseOptions(t){Va(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?sl(this.h,2,jO(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(){Ajs(this)}segment(t,s,r){const n=typeof s!="function"?s:{};return this.j=typeof s=="function"?s:r,Wze(this),Yg(this,t,n),Kze(this)}La(t,s,r,n){const a=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,Wze(this),E0(this,t,a,s),Kze(this)}Da(){return this.u}m(){var t=new kf;zc(t,"image_in"),zc(t,"norm_rect");const s=new Nf;T0(s,Hot,this.h);const r=new Np;yf(r,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),bc(r,"IMAGE:image_in"),bc(r,"NORM_RECT:norm_rect"),r.o(s),Fx(t,r),Yme(this,t),this.outputConfidenceMasks&&(Io(t,"confidence_masks"),io(r,"CONFIDENCE_MASKS:confidence_masks"),jA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>kA(this,o,!0,!this.j)),aa(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],aa(this,n)})),this.outputCategoryMask&&(Io(t,"category_mask"),io(r,"CATEGORY_MASK:category_mask"),jA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=kA(this,n,!1,!this.j),aa(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,aa(this,n)})),Io(t,"quality_scores"),io(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)}};cm.prototype.getLabels=cm.prototype.Da,cm.prototype.segmentForVideo=cm.prototype.La,cm.prototype.segment=cm.prototype.segment,cm.prototype.setOptions=cm.prototype.o,cm.createFromModelPath=function(t,s){return yo(cm,t,{baseOptions:{modelAssetPath:s}})},cm.createFromModelBuffer=function(t,s){return yo(cm,t,{baseOptions:{modelAssetBuffer:s}})},cm.createFromOptions=function(t,s){return yo(cm,t,s)};var Hwe=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()}};Hwe.prototype.close=Hwe.prototype.close;var wy=class extends vf{constructor(t,s){super(new Zg(t,s),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new kCe,this.u=new Uot,Va(this.h,0,3,this.u),Va(t=this.h,0,1,s=new ad)}get baseOptions(){return No(this.h,ad,1)}set baseOptions(t){Va(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 Got,s.keypoint&&s.scribble)throw Error("Cannot provide both keypoint and scribble.");if(s.keypoint){var o=new f0e;z_(o,3,oR(!0),!1),z_(o,1,zI(s.keypoint.x),0),z_(o,2,zI(s.keypoint.y),0),N8(n,1,zwe,o)}else{if(!s.scribble)throw Error("Must provide either a keypoint or a scribble.");{const i=new _js;for(o of s.scribble)z_(s=new f0e,3,oR(!0),!1),z_(s,1,zI(o.x),0),z_(s,2,zI(o.y),0),rCe(i,1,f0e,s);N8(n,2,zwe,i)}}this.g.addProtoToStream(n.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",r),Yg(this,t,a);e:{try{const i=new Hwe(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=i;break e}this.j(i)}finally{Xme(this)}l=void 0}return l}m(){var t=new kf;zc(t,"image_in"),zc(t,"roi_in"),zc(t,"norm_rect_in");const s=new Nf;T0(s,Hot,this.h);const r=new Np;yf(r,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),bc(r,"IMAGE:image_in"),bc(r,"ROI:roi_in"),bc(r,"NORM_RECT:norm_rect_in"),r.o(s),Fx(t,r),Yme(this,t),this.outputConfidenceMasks&&(Io(t,"confidence_masks"),io(r,"CONFIDENCE_MASKS:confidence_masks"),jA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>kA(this,o,!0,!this.j)),aa(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],aa(this,n)})),this.outputCategoryMask&&(Io(t,"category_mask"),io(r,"CATEGORY_MASK:category_mask"),jA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=kA(this,n,!1,!this.j),aa(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,aa(this,n)})),Io(t,"quality_scores"),io(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)}};wy.prototype.segment=wy.prototype.segment,wy.prototype.setOptions=wy.prototype.o,wy.createFromModelPath=function(t,s){return yo(wy,t,{baseOptions:{modelAssetPath:s}})},wy.createFromModelBuffer=function(t,s){return yo(wy,t,{baseOptions:{modelAssetBuffer:s}})},wy.createFromOptions=function(t,s){return yo(wy,t,s)};var Kf=class extends vf{constructor(t,s){super(new Zg(t,s),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},Va(t=this.h=new Wot,0,1,s=new ad)}get baseOptions(){return No(this.h,ad,1)}set baseOptions(t){Va(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?sl(this.h,2,jO(t.displayNamesLocale)):"displayNamesLocale"in t&&sl(this.h,2),t.maxResults!==void 0?w1(this.h,3,t.maxResults):"maxResults"in t&&sl(this.h,3),t.scoreThreshold!==void 0?Ia(this.h,4,t.scoreThreshold):"scoreThreshold"in t&&sl(this.h,4),t.categoryAllowlist!==void 0?bde(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&sl(this.h,5),t.categoryDenylist!==void 0?bde(this.h,6,t.categoryDenylist):"categoryDenylist"in t&&sl(this.h,6),this.l(t)}F(t,s){return this.j={detections:[]},Yg(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},E0(this,t,r,s),this.j}m(){var t=new kf;zc(t,"input_frame_gpu"),zc(t,"norm_rect"),Io(t,"detections");const s=new Nf;T0(s,bjs,this.h);const r=new Np;yf(r,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),bc(r,"IMAGE:input_frame_gpu"),bc(r,"NORM_RECT:norm_rect"),io(r,"DETECTIONS:detections"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Not(o),this.j.detections.push(Yot(n));aa(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{aa(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Kf.prototype.detectForVideo=Kf.prototype.G,Kf.prototype.detect=Kf.prototype.F,Kf.prototype.setOptions=Kf.prototype.o,Kf.createFromModelPath=async function(t,s){return yo(Kf,t,{baseOptions:{modelAssetPath:s}})},Kf.createFromModelBuffer=function(t,s){return yo(Kf,t,{baseOptions:{modelAssetBuffer:s}})},Kf.createFromOptions=function(t,s){return yo(Kf,t,s)};var Gwe=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 Zze(t){t.landmarks=[],t.worldLandmarks=[],t.segmentationMasks=void 0}function Yze(t){try{const s=new Gwe(t.landmarks,t.worldLandmarks,t.segmentationMasks);if(!t.u)return s;t.u(s)}finally{Xme(t)}}Gwe.prototype.close=Gwe.prototype.close;var Bp=class extends vf{constructor(t,s){super(new Zg(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,Va(t=this.h=new Kot,0,1,s=new ad),this.A=new zot,Va(this.h,0,3,this.A),this.j=new Fot,Va(this.h,0,2,this.j),w1(this.j,4,1),Ia(this.j,2,.5),Ia(this.A,2,.5),Ia(this.h,4,.5)}get baseOptions(){return No(this.h,ad,1)}set baseOptions(t){Va(this.h,0,1,t)}o(t){return"numPoses"in t&&w1(this.j,4,t.numPoses??1),"minPoseDetectionConfidence"in t&&Ia(this.j,2,t.minPoseDetectionConfidence??.5),"minTrackingConfidence"in t&&Ia(this.h,4,t.minTrackingConfidence??.5),"minPosePresenceConfidence"in t&&Ia(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,Zze(this),Yg(this,t,n),Yze(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:n,Zze(this),E0(this,t,a,s),Yze(this)}m(){var t=new kf;zc(t,"image_in"),zc(t,"norm_rect"),Io(t,"normalized_landmarks"),Io(t,"world_landmarks"),Io(t,"segmentation_masks");const s=new Nf;T0(s,wjs,this.h);const r=new Np;yf(r,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),bc(r,"IMAGE:image_in"),bc(r,"NORM_RECT:norm_rect"),io(r,"NORM_LANDMARKS:normalized_landmarks"),io(r,"WORLD_LANDMARKS:world_landmarks"),r.o(s),Fx(t,r),Yme(this,t),this.g.attachProtoVectorListener("normalized_landmarks",(n,a)=>{this.landmarks=[];for(const o of n)n=SO(o),this.landmarks.push(Zme(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=sT(o),this.worldLandmarks.push(S8(n));aa(this,a)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],aa(this,n)}),this.outputSegmentationMasks&&(io(r,"SEGMENTATION_MASK:segmentation_masks"),jA(this,"segmentation_masks"),this.g.aa("segmentation_masks",(n,a)=>{this.segmentationMasks=n.map(o=>kA(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)}};Bp.prototype.detectForVideo=Bp.prototype.G,Bp.prototype.detect=Bp.prototype.F,Bp.prototype.setOptions=Bp.prototype.o,Bp.createFromModelPath=function(t,s){return yo(Bp,t,{baseOptions:{modelAssetPath:s}})},Bp.createFromModelBuffer=function(t,s){return yo(Bp,t,{baseOptions:{modelAssetBuffer:s}})},Bp.createFromOptions=function(t,s){return yo(Bp,t,s)},Bp.POSE_CONNECTIONS=ult;let C4=null,BI=null;async function Ejs(){return C4||BI||(BI=(async()=>{const t=await D5.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm");return C4=await cm.createFromOptions(t,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/image_segmenter/selfie_multiclass_256x256/float32/latest/selfie_multiclass_256x256.tflite",delegate:"GPU"},runningMode:"VIDEO",outputCategoryMask:!1,outputConfidenceMasks:!0}),C4})(),BI)}function Pjs(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(x,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 x=Math.min(p,n-1)-Math.max(u+1,0)+1;s[d*r+l]=i/x}}}function Ijs(){C4&&(C4.close(),C4=null,BI=null)}function Ljs(t,s){const r=S.useRef(null),n=S.useRef(null),a=S.useRef(null),o=S.useRef(null),l=S.useRef(0),i=S.useRef(0),[d,u]=S.useState(null),[p,x]=S.useState(!1),[y,_]=S.useState(null),b=s.type!=="none"&&t!==null;return S.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]),S.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]),S.useEffect(()=>{if(!b){u(null),_(null);return}let N=!1;return(async()=>{x(!0),_(null);try{const k=await Ejs();if(N)return;x(!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 E=C.videoWidth||640,L=C.videoHeight||480,I=r.current;if(!I)return;I.width=E,I.height=L;const O=I.getContext("2d",{willReadFrequently:!1});n.current||(n.current=document.createElement("canvas"));const V=n.current;V.width=E,V.height=L;const q=V.getContext("2d",{willReadFrequently:!0}),$=document.createElement("canvas");$.width=E,$.height=L;const U=$.getContext("2d"),se=I.captureStream(30);((t==null?void 0:t.getAudioTracks())||[]).forEach(we=>se.addTrack(we)),N||u(se);const J=s.blurRadius??15,X=s.mirror??!1,ce=new Float32Array(E*L),ie=new Float32Array(E*L),ae=new Float32Array(E*L);let oe=!1;const pe=4,_e=.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 je=a.current;if(je.readyState<2){l.current=requestAnimationFrame(he);return}try{const Te=k.segmentForVideo(je,we).confidenceMasks;if(Te&&Te.length>0){ie.fill(0);for(let Le=1;Leqe?(dt=Le.height*qe,ze=(Le.width-dt)/2):(fe=Le.width/qe,ve=(Le.height-fe)/2),O.drawImage(Le,ze,ve,dt,fe,0,0,E,L)}q.clearRect(0,0,E,L),q.drawImage(je,0,0,E,L);const Me=q.getImageData(0,0,E,L),Fe=Me.data;for(let Le=0;Le{N=!0,l.current&&cancelAnimationFrame(l.current),u(null)}},[b,s.type,s.blurRadius,s.imageUrl,t]),S.useEffect(()=>()=>{Ijs()},[]),{canvasRef:r,compositedStream:d,isLoading:p,isActive:b,error:y}}function Qme({maxDurationSeconds:t=600,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=S.useRef(null),i=S.useRef(null),d=S.useRef(null),[u,p]=S.useState(null),x=S.useRef([]),y=S.useRef(null),_=S.useRef(null),b=S.useRef(null),N=S.useRef(null),w=vE(),[k,C]=S.useState("camera"),E=S.useRef(null),L=S.useRef(null),I=S.useRef(null),O=S.useRef(null),V=S.useRef(null),[q,$]=S.useState(!0),[U,se]=S.useState(!0),[Y,J]=S.useState(null),[X,ce]=S.useState(!1),[ie,ae]=S.useState(!1),[oe,pe]=S.useState(null),[_e,he]=S.useState(null),[we,je]=S.useState(0),[Ue,Te]=S.useState("user"),[Me,Fe]=S.useState(0),[Le,Ne]=S.useState(!1),[qe,ze]=S.useState(!0),[ve,dt]=S.useState(null),[fe,Ve]=S.useState(!1),[Je,at]=S.useState(null),Ae=S.useRef(null),[Ye,We]=S.useState(()=>{try{const tr=localStorage.getItem("video-bg-config");if(tr)return JSON.parse(tr)}catch{}return{type:"none"}});S.useEffect(()=>{try{localStorage.setItem("video-bg-config",JSON.stringify(Ye))}catch{}},[Ye]);const{canvasRef:ot,compositedStream:Ge,isLoading:et,isActive:ht,error:xt}=Ljs(u,Ye),Ke=S.useRef(r);Ke.current=r;const Ze=S.useCallback(tr=>{$(tr)},[]),Et=S.useRef(q),$t=S.useCallback(()=>{I.current&&(cancelAnimationFrame(I.current),I.current=null),E.current&&(E.current.getTracks().forEach(tr=>tr.stop()),E.current=null),O.current&&(O.current.getTracks().forEach(tr=>tr.stop()),O.current=null),V.current&&(V.current.srcObject=null,V.current=null)},[]),Yt=S.useCallback(async()=>{var tr;try{const cr=await navigator.mediaDevices.getDisplayMedia({video:{width:{ideal:1920},height:{ideal:1080}},audio:!0});E.current=cr;let cn=null;try{cn=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 rn=null;if(!cn)try{rn=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{console.warn("[VideoRecorder] No mic audio")}const jn=cr.getVideoTracks()[0],ni=jn.getSettings(),rs=ni.width||1920,Bn=ni.height||1080,mn=document.createElement("canvas");mn.width=rs,mn.height=Bn,L.current=mn;const Fr=mn.getContext("2d");let Kt=null;cn&&(Kt=document.createElement("video"),Kt.srcObject=cn,Kt.muted=!0,Kt.playsInline=!0,Kt.autoplay=!0,await Kt.play(),V.current=Kt);const jr=document.createElement("video");jr.srcObject=cr,jr.muted=!0,jr.playsInline=!0,jr.autoplay=!0,await jr.play();const zr=()=>{if(Fr.drawImage(jr,0,0,rs,Bn),Kt&&Kt.readyState>=2){const Xe=Math.round(rs*.2),_t=Math.round(Xe*(Kt.videoHeight/Kt.videoWidth||.75)),bt=rs-Xe-20,Mt=Bn-_t-20,Ht=12;Fr.save(),Fr.beginPath(),Fr.moveTo(bt+Ht,Mt),Fr.lineTo(bt+Xe-Ht,Mt),Fr.quadraticCurveTo(bt+Xe,Mt,bt+Xe,Mt+Ht),Fr.lineTo(bt+Xe,Mt+_t-Ht),Fr.quadraticCurveTo(bt+Xe,Mt+_t,bt+Xe-Ht,Mt+_t),Fr.lineTo(bt+Ht,Mt+_t),Fr.quadraticCurveTo(bt,Mt+_t,bt,Mt+_t-Ht),Fr.lineTo(bt,Mt+Ht),Fr.quadraticCurveTo(bt,Mt,bt+Ht,Mt),Fr.closePath(),Fr.clip(),Fr.translate(bt+Xe,Mt),Fr.scale(-1,1),Fr.drawImage(Kt,0,0,Xe,_t),Fr.restore(),Fr.strokeStyle="rgba(255,255,255,0.6)",Fr.lineWidth=2,Fr.beginPath(),Fr.moveTo(bt+Ht,Mt),Fr.lineTo(bt+Xe-Ht,Mt),Fr.quadraticCurveTo(bt+Xe,Mt,bt+Xe,Mt+Ht),Fr.lineTo(bt+Xe,Mt+_t-Ht),Fr.quadraticCurveTo(bt+Xe,Mt+_t,bt+Xe-Ht,Mt+_t),Fr.lineTo(bt+Ht,Mt+_t),Fr.quadraticCurveTo(bt,Mt+_t,bt,Mt+_t-Ht),Fr.lineTo(bt,Mt+Ht),Fr.quadraticCurveTo(bt,Mt,bt+Ht,Mt),Fr.closePath(),Fr.stroke()}I.current=requestAnimationFrame(zr)};zr();const fa=mn.captureStream(30),qt=[],Se=cr.getAudioTracks();if(Se.length&&qt.push(...Se),cn){const Xe=cn.getAudioTracks();Xe.length&&qt.push(...Xe)}else rn&&qt.push(...rn.getAudioTracks());const Oe=new MediaStream([...fa.getVideoTracks(),...qt]);return O.current=Oe,jn.onended=()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),$t()},Oe}catch(cr){return console.error("[VideoRecorder] Screen capture error:",cr),cr.name!=="NotAllowedError"&&((tr=Ke.current)==null||tr.call(Ke,"Failed to start screen capture: "+(cr.message||"Unknown error"))),null}},[$t]),Ps=S.useCallback(async()=>{var cr,cn;se(!0),dt(null);const tr=w&&q;console.log("[VideoRecorder] initCamera start",{isMobile:w,usePortraitMode:q,shouldBePortrait:tr,facingMode:Ue});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(Bn=>Bn.stop()));const rn=w&&tr?{facingMode:{ideal:Ue},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:Ue},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",rn);const jn=await navigator.mediaDevices.getUserMedia({video:rn,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),jn.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");d.current=jn,p(jn),J(!0);const rs=jn.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",rs.width,"x",rs.height),l.current){const Bn=l.current;Bn.srcObject=jn,Bn.muted=!0,Bn.playsInline=!0,Bn.autoplay=!0,Bn.setAttribute("muted",""),Bn.setAttribute("playsinline",""),Bn.setAttribute("autoplay","");try{(cr=Bn.load)==null||cr.call(Bn)}catch(Fr){console.warn("[VideoRecorder] videoEl.load failed",Fr)}const mn=async()=>{try{return await Bn.play(),console.log("[VideoRecorder] preview play ok"),Ve(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:Bn.readyState,videoWidth:Bn.videoWidth,videoHeight:Bn.videoHeight})},300),!0}catch(Fr){return console.warn("[VideoRecorder] preview play blocked",Fr),Ve(!0),!1}};await new Promise(Fr=>{let Kt=!1;const jr=()=>{Kt||(Kt=!0,Fr())},zr=()=>{mn().finally(jr)};Bn.onloadedmetadata=zr,Bn.onloadeddata=zr,setTimeout(jr,1500)})}try{_.current=new AudioContext;const Bn=_.current.createMediaStreamSource(jn);b.current=_.current.createAnalyser(),b.current.fftSize=256,Bn.connect(b.current);const mn=()=>{if(b.current){const Fr=new Uint8Array(b.current.frequencyBinCount);b.current.getByteFrequencyData(Fr);const Kt=Fr.reduce((jr,zr)=>jr+zr)/Fr.length;Fe(Math.min(100,Kt/128*100))}N.current=requestAnimationFrame(mn)};mn()}catch(Bn){console.warn("Audio context not available:",Bn)}}catch(rn){console.error("Camera initialization error:",rn),J(!1);let jn="Failed to access camera or microphone.";rn.name==="NotAllowedError"?jn="Camera permission denied. Please allow camera access in your browser settings.":rn.name==="NotFoundError"?jn="No camera found. Please connect a camera and try again.":rn.name==="NotReadableError"?jn="Camera is in use by another application. Please close other apps using the camera.":rn.message&&(jn=rn.message),dt(jn),(cn=Ke.current)==null||cn.call(Ke,jn)}finally{se(!1)}},[Ue,w,q]);S.useEffect(()=>{Et.current!==q&&Y&&!X&&!_e&&(Et.current=q,Ps())},[q,Y,X,_e,Ps]),S.useEffect(()=>(Ps(),()=>{d.current&&d.current.getTracks().forEach(tr=>tr.stop()),y.current&&clearInterval(y.current),N.current&&cancelAnimationFrame(N.current),_.current&&_.current.close(),Ae.current&&clearInterval(Ae.current),_e&&URL.revokeObjectURL(_e),$t()}),[Ps,_e]),S.useEffect(()=>{if(U||Y!==!0||_e)return;const tr=d.current,cr=l.current;!tr||!cr||ht||(cr.srcObject!==tr&&(cr.srcObject=tr,cr.muted=!0,cr.playsInline=!0,cr.autoplay=!0,cr.setAttribute("muted",""),cr.setAttribute("playsinline",""),cr.setAttribute("autoplay","")),cr.play().then(()=>Ve(!1)).catch(cn=>{Ve(!0),console.warn("Live preview play blocked on mount:",cn)}))},[Y,U,_e,ht]),S.useEffect(()=>{n==null||n(X)},[X,n]);const zs=S.useCallback(async()=>{if(_e)return;const tr=l.current;if(tr)try{await tr.play(),Ve(!1)}catch(cr){Ve(!0),console.warn("Live preview still blocked (needs user gesture):",cr)}},[_e]),Zs=S.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),y.current&&(clearInterval(y.current),y.current=null),$t(),ce(!1),ae(!1)},[$t]),Dr=S.useCallback(async()=>{let tr=null;if(k==="screen"){if(tr=await Yt(),!tr)return}else tr=ht&&Ge?Ge:d.current;if(!tr)return;zs(),x.current=[],je(0);const cn=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"].find(jn=>MediaRecorder.isTypeSupported(jn)),rn=new MediaRecorder(tr,cn?{mimeType:cn,videoBitsPerSecond:k==="screen"?4e6:25e5}:{videoBitsPerSecond:k==="screen"?4e6:25e5});rn.ondataavailable=jn=>{jn.data.size>0&&x.current.push(jn.data)},rn.onstop=()=>{var Bn;const jn=rn.mimeType||cn||((Bn=x.current[0])==null?void 0:Bn.type)||"video/webm",ni=new Blob(x.current,{type:jn});pe(ni);const rs=URL.createObjectURL(ni);he(rs)},i.current=rn,rn.start(100),ce(!0),y.current=setInterval(()=>{je(jn=>jn>=t-1?(Zs(),t):jn+1)},1e3)},[zs,t,Zs,ht,Ge,k,Yt]),zt=S.useCallback(()=>{Ae.current&&(clearInterval(Ae.current),Ae.current=null),at(3);let tr=3;Ae.current=setInterval(()=>{tr-=1,tr<=0?(Ae.current&&clearInterval(Ae.current),Ae.current=null,at(null),Dr()):at(tr)},1e3)},[Dr]),$s=S.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),ae(!0),y.current&&clearInterval(y.current))},[]),kr=S.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),ae(!1),y.current=setInterval(()=>{je(tr=>tr>=t-1?(Zs(),t):tr+1)},1e3))},[t,Zs]),Xs=S.useCallback(()=>{_e&&URL.revokeObjectURL(_e),pe(null),he(null),je(0),Ne(!1),ze(!0),l.current&&d.current&&!ht&&(l.current.srcObject=d.current,l.current.muted=!0,zs())},[zs,_e,ht]),ir=S.useCallback(()=>{Te(tr=>tr==="user"?"environment":"user")},[]),Or=S.useCallback(()=>{oe&&s(oe,we)},[oe,we,s]),Vn=S.useCallback(()=>{l.current&&_e&&(Le?l.current.pause():(ze(!1),l.current.muted=!1,l.current.play()),Ne(!Le))},[_e,Le]);S.useEffect(()=>{if(!_e)return;const tr=l.current;if(!tr)return;ze(!1),tr.pause(),tr.removeAttribute("src"),tr.srcObject=null,tr.load(),tr.src=_e,tr.currentTime=0,tr.playsInline=!0,tr.muted=!1,tr.onended=()=>Ne(!1);const cr=()=>{var jn;const cn=tr.error,rn=cn?`Recorded video failed to play (code ${cn.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",cn),(jn=Ke.current)==null||jn.call(Ke,rn)};return tr.addEventListener("error",cr),tr.load(),()=>{tr.removeEventListener("error",cr)}},[_e]);const Qr=tr=>{const cr=Math.floor(tr/60),cn=tr%60;return`${cr}:${cn.toString().padStart(2,"0")}`},Gr=k==="screen"?"aspect-video":w&&q?"aspect-[9/16]":"aspect-video";return U?e.jsx("div",{className:Rt("flex items-center justify-center bg-black rounded-lg",Gr,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(_s,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):Y===!1?e.jsx("div",{className:Rt("flex items-center justify-center bg-black rounded-lg",Gr,a),children:e.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[e.jsx(Lo,{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:ve||"Please allow camera and microphone access to record videos."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(K,{onClick:()=>Ps(),variant:"secondary",className:"w-full",children:[e.jsx(oo,{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:[!X&&!_e&&e.jsxs("div",{className:"flex items-center justify-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsxs(K,{variant:k==="camera"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>C("camera"),children:[e.jsx(xx,{className:"h-4 w-4"}),"Camera"]}),e.jsxs(K,{variant:k==="screen"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>C("screen"),children:[e.jsx(iS,{className:"h-4 w-4"}),"Screen"]})]}),k==="camera"&&!X&&!_e&&e.jsx(Wws,{value:Ye,onChange:We,isLoading:et,disabled:X}),k==="camera"&&w&&!X&&!_e&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(oS,{className:Rt("h-4 w-4",q?"text-muted-foreground":"text-primary")}),e.jsx(xe,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),e.jsx(Er,{id:"orientation-toggle",checked:q,onCheckedChange:Ze}),e.jsx(xe,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(t0,{className:Rt("h-4 w-4",q?"text-primary":"text-muted-foreground")})]}),k==="screen"&&!X&&!_e&&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(iS,{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:()=>{zs()},children:[e.jsx("video",{ref:l,src:_e??void 0,className:Rt("w-full bg-black",q&&!_e?"object-contain":"object-cover",Gr,!_e&&Ue==="user"!==(Ye.mirror??!1)&&"scale-x-[-1]",ht&&!_e&&"hidden"),playsInline:!0,controls:!!_e,muted:_e?qe:!0,autoPlay:!_e},_e??"live"),ht&&!_e&&e.jsx("canvas",{ref:ot,className:Rt("w-full bg-black",q?"object-contain":"object-cover",Gr,Ue==="user"!==(Ye.mirror??!1)&&"scale-x-[-1]")}),ht&&et&&!_e&&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(_s,{className:"h-8 w-8 animate-spin mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Loading virtual background…"})]})}),!_e&&fe&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:e.jsx(K,{type:"button",variant:"secondary",onClick:()=>void zs(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!_e&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),Je!==null&&!_e&&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:Je},Je),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),X&&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",ie?"bg-yellow-500":"bg-red-500 animate-pulse")}),e.jsxs("span",{className:"text-white text-sm font-medium",children:[Qr(we)," / ",Qr(t)]})]}),X&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(gi,{value:we/t*100,className:"h-1 rounded-none"})}),!_e&&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(wL,{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:`${Me}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:_e?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:Xs,children:[e.jsx(oo,{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:Vn,children:Le?e.jsx(uh,{className:"h-5 w-5"}):e.jsx(So,{className:"h-5 w-5"})}),e.jsxs(K,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:Or,children:[e.jsx(Jn,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[k==="camera"?e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:ir,disabled:X||Je!==null,children:e.jsx(Jy,{className:"h-5 w-5"})}):e.jsx("div",{className:"h-12 w-12"}),!X&&Je===null?e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:k==="screen"?Dr:zt,children:k==="screen"?e.jsx(iS,{className:"h-6 w-6"}):e.jsx(Tn,{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:ie?kr:$s,children:ie?e.jsx(So,{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:Zs,children:e.jsx(s0,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const hlt="teleprompter_settings",g0e={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function Djs(){try{const t=localStorage.getItem(hlt);return t?{...g0e,...JSON.parse(t)}:g0e}catch{return g0e}}function Rjs(t){try{localStorage.setItem(hlt,JSON.stringify(t))}catch{}}function mlt({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=S.useRef(null),d=S.useRef(null),u=S.useRef(0),p=S.useRef(0),[x,y]=S.useState(Djs),{scrollSpeed:_,fontSize:b,lineHeight:N,opacity:w,position:k,isMirrored:C}=x,E=S.useCallback((Y,J)=>{y(X=>{const ce={...X,[Y]:J};return Rjs(ce),ce})},[]),[L,I]=S.useState(!1),[O,V]=S.useState(null),q=S.useCallback(Y=>{if(!i.current)return;u.current===0&&(u.current=Y);const J=Y-u.current;u.current=Y,p.current+=_*J/1e3;const X=Math.floor(p.current);X>0&&(i.current.scrollTop+=X,p.current-=X);const{scrollTop:ce,scrollHeight:ie,clientHeight:ae}=i.current;if(ce+ae>=ie){I(!1);return}d.current=requestAnimationFrame(q)},[_]);S.useEffect(()=>(L?(u.current=0,p.current=0,d.current=requestAnimationFrame(q)):d.current&&cancelAnimationFrame(d.current),()=>{d.current&&cancelAnimationFrame(d.current)}),[L,q]),S.useEffect(()=>{if(n&&s)if(i.current&&(i.current.scrollTop=0),a){V(3);let Y=3;const J=setInterval(()=>{Y-=1,Y<=0?(clearInterval(J),V(null),o==null||o(),I(!0)):V(Y)},1e3);return()=>clearInterval(J)}else setTimeout(()=>I(!0),100);else n||(I(!1),V(null))},[n,s,a,o]);const $=S.useCallback(()=>{i.current&&(i.current.scrollTop=0),I(!1)},[]),U=S.useCallback(()=>{I(Y=>!Y)},[]);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(wn,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const se={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",se[k],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(xo,{children:[e.jsx(go,{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(ko,{className:"h-4 w-4"})})}),e.jsx(lo,{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(xe,{className:"text-xs",children:"Scroll Speed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:_})]}),e.jsx(Cg,{value:[_],onValueChange:([Y])=>E("scrollSpeed",Y),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(xe,{className:"text-xs",children:"Font Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[b,"px"]})]}),e.jsx(Cg,{value:[b],onValueChange:([Y])=>E("fontSize",Y),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(xe,{className:"text-xs",children:"Line Spacing"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:N.toFixed(1)})]}),e.jsx(Cg,{value:[N*10],onValueChange:([Y])=>E("lineHeight",Y/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(xe,{className:"text-xs",children:"Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(w*100),"%"]})]}),e.jsx(Cg,{value:[w*100],onValueChange:([Y])=>E("opacity",Y/100),min:30,max:100,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{className:"text-xs",children:"Position"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:k==="top"?"default":"outline",size:"sm",onClick:()=>E("position","top"),children:e.jsx(nf,{className:"h-4 w-4"})}),e.jsx(K,{variant:k==="center"?"default":"outline",size:"sm",onClick:()=>E("position","center"),children:e.jsx(Yy,{className:"h-4 w-4"})}),e.jsx(K,{variant:k==="bottom"?"default":"outline",size:"sm",onClick:()=>E("position","bottom"),children:e.jsx(Oi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-xs",children:"Mirror Mode"}),e.jsx(Er,{checked:C,onCheckedChange:Y=>E("isMirrored",Y)})]})]})})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:U,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:L?e.jsx(uh,{className:"h-4 w-4"}):e.jsx(So,{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(Jy,{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(mp,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function Ojs({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=wa(),[o,l]=S.useState(""),[i,d]=S.useState(null),[u,p]=S.useState("levelup"),{data:x,isLoading:y}=dbs(),{data:_,isLoading:b}=ubs(),{data:N,isLoading:w}=hbs(),k=mbs(),C=S.useMemo(()=>_?_.filter(V=>{const q=!o||V.title.toLowerCase().includes(o.toLowerCase())||V.script_text.toLowerCase().includes(o.toLowerCase())||V.tags.some(U=>U.toLowerCase().includes(o.toLowerCase())),$=!i||V.category_id===i;return q&&$}):[],[_,o,i]),E=S.useMemo(()=>N?N.filter(V=>!o||V.title.toLowerCase().includes(o.toLowerCase())||V.script_text.toLowerCase().includes(o.toLowerCase())):[],[N,o]),L=V=>{t({title:V.title,text:V.script_text})},I=async V=>{try{await k.mutateAsync(V),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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search scripts...",value:o,onChange:V=>l(V.target.value),className:"pl-9"})]})}),e.jsxs(ia,{value:u,onValueChange:V=>p(V),className:"flex-1 flex flex-col",children:[e.jsxs(ea,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(ls,{value:"levelup",children:[e.jsx(fn,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(ls,{value:"my-scripts",children:[e.jsx(fx,{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(Qe,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>d(null),children:"All"}),x==null?void 0:x.map(V=>e.jsx(Qe,{variant:i===V.id?"default":"outline",className:"cursor-pointer",onClick:()=>d(V.id),children:V.name},V.id))]}),e.jsx(ui,{className:"flex-1 max-h-[50vh]",children:O?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(_s,{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(fn,{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(V=>e.jsxs(Pe,{className:Rt("cursor-pointer hover:bg-accent/50 transition-colors",r===V.id&&"ring-2 ring-primary"),onClick:()=>L(V),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(Ot,{className:"text-sm font-medium truncate",children:V.title}),V.category&&e.jsx(Qe,{variant:"secondary",className:"mt-1 text-xs",children:V.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(),I(V)},children:e.jsx(fx,{className:"h-4 w-4"})}),e.jsx(Sa,{className:"h-4 w-4 text-muted-foreground"})]})]})}),e.jsx(Re,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:V.script_text})})]},V.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(Us,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),e.jsx(ui,{className:"flex-1 max-h-[50vh]",children:w?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(_s,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):E.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(fx,{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:E.map(V=>e.jsxs(Pe,{className:Rt("cursor-pointer hover:bg-accent/50 transition-colors",r===V.id&&"ring-2 ring-primary"),onClick:()=>L(V),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(Ot,{className:"text-sm font-medium truncate",children:V.title}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:V.is_custom?e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(Sa,{className:"h-4 w-4 text-muted-foreground ml-2"})]})}),e.jsx(Re,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:V.script_text})})]},V.id))})})]})]})]})}function Fjs({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=S.useState(()=>{const i=UM(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(xe,{className:"text-sm font-medium",children:"Share Page Template"}),n&&e.jsx(_s,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:AIt.map(i=>{const d=EIt(i.id),u=a.has(i.id),p=d.some(x=>x.id===t);return e.jsxs(of,{open:u,onOpenChange:()=>l(i.id),children:[e.jsxs(lf,{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(Oi,{className:Rt("h-4 w-4 text-muted-foreground transition-transform",u&&"rotate-180")})]}),e.jsx(cf,{className:"pt-2",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:d.map(x=>{const y=t===x.id;return e.jsxs("button",{type:"button",onClick:()=>s(x.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(Jn,{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:x.icon}),e.jsx("span",{className:"text-sm font-medium truncate",children:x.name})]})]},x.id)})})})]},i.id)})}),r&&t!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Will show: "',UM(t).headerText(r),'"']})]})}function plt({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=S.useState(r.page_template||"default"),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[x,y]=S.useState(r.page_template||"default"),[_,b]=S.useState([]),[N,w]=S.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[k,C]=S.useState(!1),[E,L]=S.useState(!1),I=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";S.useEffect(()=>{t&&_.length===0&&O()},[t]);const O=async()=>{L(!0);try{const{data:ce,error:ie}=await G.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ie)throw ie;const ae=(ce||[]).map(oe=>({id:oe.id,name:[oe.first_name,oe.last_name].filter(Boolean).join(" ")||"Unnamed",email:oe.email||null}));b(ae)}catch(ce){console.error("Failed to fetch contacts:",ce)}finally{L(!1)}},V=async ce=>{w(ce),C(!1),d(!0);try{const{error:ie}=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(ie)throw ie;me.success(ce?`Assigned to ${ce.name}`:"Contact removed"),a==null||a()}catch(ie){console.error("Failed to update contact:",ie),me.error("Failed to update contact")}finally{d(!1)}},q=async ce=>{l(ce),d(!0);try{const{error:ie}=await G.from("agent_videos").update({page_template:ce}).eq("id",r.id);if(ie)throw ie;y(ce),me.success("Template saved!"),a==null||a()}catch(ie){console.error("Failed to save template:",ie),me.error("Failed to save template"),l(x)}finally{d(!1)}},$=(N==null?void 0:N.name)||null,U=()=>{const ce=r.title||"Video Message",ie=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:r.thumbnail_url||"";return``},se=async()=>{if(!r.thumbnail_url){me.error("Video thumbnail not available yet");return}const ce=U(),ie=`Watch: ${r.title||"Video Message"} ${I}`;try{const ae=new Blob([ce],{type:"text/html"}),oe=new Blob([ie],{type:"text/plain"}),pe=new ClipboardItem({"text/html":ae,"text/plain":oe});await navigator.clipboard.write([pe]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(ie+` `+ce),me.success("Copied! Paste into your email.")}},Y=async()=>{await navigator.clipboard.writeText(I),p(!0),me.success("Share link copied!"),setTimeout(()=>p(!1),2e3)},J=()=>{const ie=UM(o).headerText($),ae=o==="default"?`Check out this video: ${I}`:`${ie} Check out this special video: ${I}`;window.open(`sms:?body=${encodeURIComponent(ae)}`,"_self")},X=()=>{const ce=UM(o),ie=ce.headerText($),ae=o==="default"?r.title||"Video Message":ie,oe=`${ce.subText} Watch the video: ${I}`,pe=N!=null&&N.email?encodeURIComponent(N.email):"";window.open(`mailto:${pe}?subject=${encodeURIComponent(ae)}&body=${encodeURIComponent(oe)}`,"_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(fo,{className:"h-5 w-5"}),"Share Video"]}),e.jsx(Ir,{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(xe,{className:"text-sm font-medium",children:"Personalize for Contact (Optional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(xo,{open:k,onOpenChange:C,children:[e.jsx(go,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":k,className:"flex-1 justify-between",disabled:i,children:[N?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ti,{className:"h-4 w-4 text-muted-foreground"}),N.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(gx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(lo,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search contacts..."}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:E?"Loading...":"No contacts found."}),e.jsx(Ax,{children:_.map(ce=>e.jsxs(lp,{value:ce.name,onSelect:()=>V(ce),children:[e.jsx(Jn,{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:()=>V(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: "',UM(o).headerText(N.name),'"']})]}),e.jsx(Fjs,{selectedTemplate:o,onSelect:q,contactName:$,saving:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Share Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:I,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:Y,variant:u?"default":"outline",className:"shrink-0 gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Jn,{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(xe,{children:"Share for Email"}),e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:se,children:[e.jsx(Wo,{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(xe,{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(ki,{className:"h-4 w-4"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:X,children:[e.jsx(rr,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(En,{children:e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function zjs(){var Ae;const t=_r(),[s]=Nc(),{toast:r}=wa(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:d,storage:u}=Zat(),{data:p}=qh(),x=MC(),y=ybs(),[_,b]=S.useState("record"),[N,w]=S.useState(""),[k,C]=S.useState(!1),[E,L]=S.useState(!1),[I,O]=S.useState(!1),[V,q]=S.useState(null),[$,U]=S.useState(0),[se,Y]=S.useState(0),[J,X]=S.useState(null),[ce,ie]=S.useState(null),[ae,oe]=S.useState(n||""),[pe,_e]=S.useState(""),[he,we]=S.useState(""),[je,Ue]=S.useState(null),[Te,Me]=S.useState(null),[Fe,Le]=S.useState(null),[Ne,qe]=S.useState(!1),ze=S.useCallback(async(Ye,We)=>{q(Ye),b("uploading");try{const{videoId:ot,uploadUrl:Ge}=await xO(pe||"Quick Video Touch");X(ot);const{apiKey:et}=await gO(ot),ht=new XMLHttpRequest;ht.upload.onprogress=Et=>{Et.lengthComputable&&U(Et.loaded/Et.total*100)},await new Promise((Et,$t)=>{ht.onload=()=>{ht.status>=200&&ht.status<300?Et():$t(new Error(`Upload failed: ${ht.status}`))},ht.onerror=()=>$t(new Error("Upload failed")),ht.open("PUT",Ge),ht.setRequestHeader("AccessKey",et),ht.send(Ye)}),b("processing");let xt=0;const Ke=Date.now(),Ze=90*1e3;for(;xt<4;){if(await new Promise($t=>setTimeout($t,3e3)),Date.now()-Ke>Ze){const $t=Ye.size/1048576,Yt=`https://iframe.mediadelivery.net/play/${ot}/${ot}`;await x.mutateAsync({bunny_video_id:ot,playback_url:Yt,file_size_mb:$t,title:pe||"Quick Video Touch",notes:he||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 Et=await pA(ot);if(xt=Et.status,Y(Et.encodeProgress||0),xt===4)ie({playbackUrl:Et.directPlayUrl,thumbnailUrl:Et.thumbnailUrl,previewUrl:Et.previewUrl||null,duration:Et.length||We,fileSizeMb:(Et.storageSize||Ye.size)/(1024*1024)});else if(xt===5||xt===6)throw new Error("Video processing failed")}b("details")}catch(ot){console.error("Upload error:",ot),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),b("record")}},[pe,r]),ve=async()=>{if(!(!J||!ce))try{const Ye=ae&&ae!=="none"?ae:null,We=await x.mutateAsync({bunny_video_id:J,contact_id:Ye,playback_url:ce.playbackUrl,thumbnail_url:ce.thumbnailUrl,preview_url:ce.previewUrl,duration_seconds:ce.duration,file_size_mb:ce.fileSizeMb,title:pe||"Quick Video Touch",notes:he,task_id:a||null,status:"ready"});Ue(We.id),Me(We.share_token||null),Ye&&await y.mutateAsync({contactId:Ye,videoId:We.id,notes:he}),r({title:"Video saved successfully!"}),b("share")}catch(Ye){console.error("Save video error:",Ye),r({title:"Failed to save video",description:(Ye==null?void 0:Ye.message)||"Please try again.",variant:"destructive"})}},dt=(Ye,We)=>{navigator.clipboard.writeText(We),Le(Ye),setTimeout(()=>Le(null),2e3),r({title:"Copied to clipboard!"})},fe=()=>Te?`https://video.relevelup.com/${Te}`:(ce==null?void 0:ce.playbackUrl)||"",Ve=()=>{const Ye=p==null?void 0:p.find(ht=>ht.id===ae),We=Ye?`${Ye.first_name}`:"",ot=(Ye==null?void 0:Ye.phone)||"",Ge=(Ye==null?void 0:Ye.email)||"",et=fe();return{text:`Hey${We?` ${We}`:""}! I recorded a quick video for you: ${et}`,link:et,contactPhone:ot,contactEmail:Ge}},Je=()=>{const{text:Ye,contactPhone:We}=Ve(),ot=We?`sms:${We}?body=${encodeURIComponent(Ye)}`:`sms:?body=${encodeURIComponent(Ye)}`;window.open(ot,"_self")},at=()=>{const{link:Ye,contactEmail:We}=Ve(),ot="Check out this video",Ge=`I recorded a quick video for you: ${Ye}`,et=We?`mailto:${We}?subject=${encodeURIComponent(ot)}&body=${encodeURIComponent(Ge)}`:`mailto:?subject=${encodeURIComponent(ot)}&body=${encodeURIComponent(Ge)}`;window.open(et,"_self")};return o?e.jsx(Es,{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(Fa,{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(fn,{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"]})]})]})]}),_==="record"&&e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsx(Qme,{maxDurationSeconds:600,onRecordingComplete:ze,onRecordingStateChange:O,className:"w-full",teleprompterContent:k&&N&&e.jsx(mlt,{text:N,isVisible:k,onToggleVisibility:()=>C(!1),isRecording:I,startCountdown:!1})}),!k&&N&&e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>C(!0),children:[e.jsx(fn,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Pe,{className:"lg:col-span-1",children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx(vr,{placeholder:"Type or paste your script here...",value:N,onChange:Ye=>w(Ye.target.value),rows:6}),e.jsxs(GA,{open:E,onOpenChange:L,children:[e.jsx(DNe,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full",children:[e.jsx(fn,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(wC,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(WA,{className:"p-4 border-b",children:e.jsx(KA,{children:"Select a Script"})}),e.jsx(Ojs,{onSelectScript:Ye=>{w(Ye.text),L(!1),C(!0)},className:"h-[calc(100vh-80px)]"})]})]}),N&&e.jsx(K,{className:"w-full",onClick:()=>C(!0),children:"Use Script"})]})]})]}),_==="uploading"&&e.jsx(Pe,{className:"max-w-md mx-auto",children:e.jsxs(Re,{className:"pt-6 text-center",children:[e.jsx($a,{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(gi,{value:$,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[$.toFixed(0),"%"]})]})}),_==="processing"&&e.jsx(Pe,{className:"max-w-md mx-auto",children:e.jsxs(Re,{className:"pt-6 text-center space-y-4",children:[e.jsx(_s,{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(gi,{value:se,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[se.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.`})]})}),_==="details"&&e.jsxs(Pe,{className:"max-w-lg mx-auto",children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Video Details"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Title"}),e.jsx(De,{value:pe,onChange:Ye=>_e(Ye.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Attach to Contact (Optional)"}),e.jsxs(Bs,{value:ae,onValueChange:oe,children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"No contact - use anywhere"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(fo,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),p==null?void 0:p.map(Ye=>e.jsx(vt,{value:Ye.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ti,{className:"h-4 w-4"}),Ye.first_name," ",Ye.last_name]})},Ye.id))]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Notes"}),e.jsx(vr,{value:he,onChange:Ye=>we(Ye.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(K,{className:"w-full",onClick:ve,disabled:x.isPending,children:[x.isPending&&e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),_==="share"&&e.jsxs(Pe,{className:"max-w-lg mx-auto",children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Jn,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Share your video with one click:"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs(K,{variant:"outline",className:"justify-start",onClick:Je,children:[e.jsx(ki,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:at,children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>dt("link",Ve().link),children:[e.jsx(fo,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Fe==="link"&&e.jsx(Jn,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>qe(!0),children:[e.jsx(Dl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),children:"View Library"}),e.jsx(K,{onClick:()=>{b("record"),q(null),X(null),ie(null)},children:"Record Another"})]})]})]}),je&&Te&&e.jsx(plt,{open:Ne,onOpenChange:qe,video:{id:je,share_token:Te,title:pe||null,contact_id:ae||null,thumbnail_url:(ce==null?void 0:ce.thumbnailUrl)||null},contactName:((Ae=p==null?void 0:p.find(Ye=>Ye.id===ae))==null?void 0:Ae.first_name)||null})]})}):e.jsx(Es,{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 Bjs({open:t,onOpenChange:s}){const{data:r}=qh(),{data:n}=Sme(),a=MC(),o=S.useRef(null),[l,i]=S.useState(null),[d,u]=S.useState(""),[p,x]=S.useState(""),[y,_]=S.useState(""),[b,N]=S.useState(!1),[w,k]=S.useState(0),[C,E]=S.useState("idle"),L=(n==null?void 0:n.total_storage_mb)||0,O=((n==null?void 0:n.max_storage_mb)||1024)-L,V=se=>{var X;const Y=(X=se.target.files)==null?void 0:X[0];if(!Y)return;if(!Y.type.startsWith("video/")){me.error("Please select a video file");return}const J=Y.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(Y),d||u(Y.name.replace(/\.[^/.]+$/,""))},q=async()=>{if(!l){me.error("Please select a video file");return}N(!0),k(0),E("creating");try{const{data:se,error:Y}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:d||l.name,isAgentVideo:!0}});if(Y)throw new Error(Y.message);const{videoId:J,libraryId:X}=se;E("uploading");const{data:ce,error:ie}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:J,isAgentVideo:!0}});if(ie)throw new Error(ie.message);await new Promise((pe,_e)=>{const he=new XMLHttpRequest;he.upload.addEventListener("progress",we=>{if(we.lengthComputable){const je=Math.round(we.loaded/we.total*100);k(je)}}),he.addEventListener("load",()=>{he.status>=200&&he.status<300?pe():_e(new Error(`Upload failed with status ${he.status}`))}),he.addEventListener("error",()=>_e(new Error("Upload failed"))),he.open("PUT",ce.uploadUrl),he.setRequestHeader("AccessKey",ce.apiKey),he.send(l)}),E("processing");const ae=l.size/(1024*1024),oe=`https://iframe.mediadelivery.net/embed/${X}/${J}`;await a.mutateAsync({bunny_video_id:J,playback_url:oe,file_size_mb:ae,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(se){console.error("Upload error:",se),me.error(se instanceof Error?se.message:"Failed to upload video")}finally{N(!1),E("idle")}},$=()=>{b||(i(null),u(""),x(""),_(""),k(0),E("idle"),s(!1))},U=()=>{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(Ir,{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(xe,{children:"Video File"}),l?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(Tn,{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:se=>{se.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 se;return(se=o.current)==null?void 0:se.click()},children:[e.jsx($a,{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:V,disabled:b})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title"}),e.jsx(De,{id:"title",value:d,onChange:se=>u(se.target.value),placeholder:"Enter video title",disabled:b})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Associate with Contact (optional)"}),e.jsxs(Bs,{value:y||"__none__",onValueChange:se=>_(se==="__none__"?"":se),disabled:b,children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select a contact"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(se=>e.jsxs(vt,{value:se.id,children:[se.first_name," ",se.last_name||""]},se.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(vr,{id:"notes",value:p,onChange:se=>x(se.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(_s,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:U()})]}),e.jsx(gi,{value:C==="uploading"?w:C==="processing"?100:10})]})]}),e.jsxs(En,{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(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx($a,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function $js(t){return gt({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 qjs(){const{user:t}=Fs();return gt({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 Ujs(){const{user:t}=Fs();return gt({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 Vjs(){const{user:t}=Fs(),s=Jt();return It({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 Hjs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=open`}function Gjs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=click`}function Wjs({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=S.useState([]),[d,u]=S.useState(null),[p,x]=S.useState(!1),[y,_]=S.useState(!1),[b,N]=S.useState(""),[w,k]=S.useState(""),[C,E]=S.useState(""),[L,I]=S.useState(!1),O=Vjs(),V=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";S.useEffect(()=>{t&&l.length===0&&U()},[t]),S.useEffect(()=>{if(t&&(k(`I recorded a video for you — ${$}`),E("Hey! I recorded a quick video just for you. Click below to watch it:"),u(null),N(""),r.contact_id)){const ie=l.find(ae=>ae.id===r.contact_id);ie&&(u(ie),N(ie.email||""))}},[t,r.contact_id,l]);const U=async()=>{_(!0);try{const{data:ie,error:ae}=await G.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ae)throw ae;i(ie||[])}catch{console.error("Failed to fetch contacts")}finally{_(!1)}},se=ie=>{u(ie),x(!1),N(ie.email||""),E(`Hey ${ie.first_name}! I recorded a quick video just for you. Click below to watch it:`),k(`I recorded a video for you — ${$}`)},Y=()=>{u(null),N(""),E("Hey! I recorded a quick video just for you. Click below to watch it:")},J=ie=>`${ie.first_name} ${ie.last_name||""}`.trim(),X=ie=>{const ae=C.split(/\n\n+/).map(_e=>`

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

`).join(""),oe=ie?Gjs(ie):V,pe=ie?``:"";return`
${ae}

▶ Watch Video

${pe}
`},ce=async()=>{if(!b){me.error("Please enter a recipient email");return}if(!V){me.error("Video does not have a share link");return}I(!0);try{let ie;try{const _e=d?J(d):b.split("@")[0];ie=(await O.mutateAsync({video_id:r.id,recipient_email:b,recipient_name:_e,contact_id:(d==null?void 0:d.id)||null,sent_via:"gmail"})).share_token}catch(_e){console.warn("Failed to create tracking record, sending without tracking:",_e)}const ae=X(ie),{data:oe,error:pe}=await G.functions.invoke("gmail-send",{body:{to:b,subject:w,body:ae,contactId:(d==null?void 0:d.id)||null}});if(pe)throw pe;if(!(oe!=null&&oe.success))throw new Error((oe==null?void 0:oe.error)||"Failed to send");me.success("Video email sent!"),s(!1),o==null||o()}catch(ie){console.error("Gmail send error:",ie),me.error("Failed to send: "+(ie instanceof Error?ie.message:"Unknown error"))}finally{I(!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(rr,{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(xe,{children:"Send to Contact"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(xo,{open:p,onOpenChange:x,children:[e.jsx(go,{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(Ti,{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(gx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(lo,{className:"w-[350px] p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search contacts..."}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:y?"Loading...":"No contacts found."}),e.jsx(Ax,{children:l.filter(ie=>ie.email).map(ie=>e.jsxs(lp,{value:`${ie.first_name} ${ie.last_name||""} ${ie.email||""}`,onSelect:()=>se(ie),children:[e.jsx(Jn,{className:Rt("mr-2 h-4 w-4",(d==null?void 0:d.id)===ie.id?"opacity-100":"opacity-0")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:J(ie)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ie.email})]})]},ie.id))})]})]})})]}),d&&e.jsx(K,{variant:"ghost",size:"icon",onClick:Y,className:"shrink-0",children:e.jsx(Sr,{className:"h-4 w-4"})})]})]}),!d&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{htmlFor:"video-to",children:"Or type email address"}),e.jsx(De,{id:"video-to",value:b,onChange:ie=>N(ie.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(wo,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{htmlFor:"video-subject",children:"Subject"}),e.jsx(De,{id:"video-subject",value:w,onChange:ie=>k(ie.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(vr,{id:"video-message",value:C,onChange:ie=>E(ie.target.value),rows:4,className:"resize-y"})]}),e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3 space-y-2",children:[e.jsx(xe,{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(So,{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(So,{className:"h-5 w-5 text-primary ml-0.5"})})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Recipients will see the thumbnail with a play button. Clicking opens the video page."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),disabled:L,children:"Cancel"}),e.jsxs(K,{onClick:ce,disabled:L||!b||!w,className:"gap-2",children:[L?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(An,{className:"h-4 w-4"}),L?"Sending...":"Send Video Email"]})]})]})]})})}const Kjs=()=>{const{user:t}=Fs();return gt({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 Zjs({recipient:t}){return t.watched_at?e.jsxs(Qe,{className:"bg-emerald-100 text-emerald-800 text-[10px]",children:[e.jsx(So,{className:"h-2.5 w-2.5 mr-0.5"}),"Watched"]}):t.clicked_at?e.jsxs(Qe,{className:"bg-blue-100 text-blue-800 text-[10px]",children:[e.jsx(nu,{className:"h-2.5 w-2.5 mr-0.5"}),"Clicked"]}):t.opened_at?e.jsxs(Qe,{className:"bg-amber-100 text-amber-800 text-[10px]",children:[e.jsx(wn,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(Qe,{variant:"outline",className:"text-[10px]",children:[e.jsx(An,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]})}function Yjs({open:t,onOpenChange:s,videoId:r,videoTitle:n}){const{data:a=[],isLoading:o}=$js(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(to,{className:"h-5 w-5"}),"Send Analytics: ",n]})}),o?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((l,i)=>e.jsx(Ns,{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(ui,{className:"h-[400px]",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Nt,{children:"Recipient"}),e.jsx(Nt,{children:"Status"}),e.jsx(Nt,{children:"Sent"}),e.jsx(Nt,{children:"Last Activity"})]})}),e.jsx(Dn,{children:a.map(l=>e.jsxs(Ms,{children:[e.jsx(ut,{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(ut,{children:e.jsx(Zjs,{recipient:l})}),e.jsx(ut,{className:"text-xs text-muted-foreground",children:ps(new Date(l.sent_at),"MMM d, h:mm a")}),e.jsx(ut,{className:"text-xs text-muted-foreground",children:l.last_activity_at?gl(new Date(l.last_activity_at),{addSuffix:!0}):"—"})]},l.id))})]})})]})]})})}function Xjs(){const{data:t,isLoading:s}=qjs(),{data:r=[],isLoading:n}=Ujs(),[a,o]=S.useState(null),l=s||n,i=r.reduce((d,u)=>{const p=u.agent_videos,x=(p==null?void 0:p.id)||u.video_id;return d[x]||(d[x]={videoId:x,title:(p==null?void 0:p.title)||"Untitled",thumbnailUrl:p==null?void 0:p.thumbnail_url,recipients:[]}),d[x].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(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ns,{className:"h-4 w-20"})}),e.jsx(Re,{children:e.jsx(Ns,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx(An,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(t==null?void 0:t.totalSent)||0})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(wn,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(nu,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(hr,{children:"Click a video to see individual recipient tracking"})]}),e.jsx(Re,{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(x=>x.opened_at).length,p=d.recipients.filter(x=>x.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:x=>{const y=x.currentTarget;y.style.display="none",y.parentElement.innerHTML='
'}}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(Tn,{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(An,{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(wn,{className:"h-3 w-3"})," ",u]}),e.jsxs("span",{className:"text-xs text-blue-600 flex items-center gap-1",children:[e.jsx(nu,{className:"h-3 w-3"})," ",p]})]})]}),e.jsx(Yo,{className:"h-4 w-4 text-muted-foreground"})]},d.videoId)})})})]}),e.jsx(Yjs,{open:!!a,onOpenChange:d=>!d&&o(null),videoId:(a==null?void 0:a.id)||null,videoTitle:(a==null?void 0:a.title)||""})]})}function Qjs({previewSrc:t,thumbnailSrc:s,alt:r,isHovered:n}){const[a,o]=S.useState(!1),[l,i]=S.useState(!1),d=n&&t&&!a,u=s&&!l;return!u&&!d?e.jsx("div",{className:"w-full h-full flex items-center justify-center absolute inset-0 bg-muted",children:e.jsx(Tn,{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 Jjs({video:t,previewSrc:s,thumbnailSrc:r,onOpen:n,onDelete:a,onRename:o,onNavigateToContact:l,onGetEmbedCode:i,onCopyEmailHtml:d,onEmbedToCrm:u,onShareWithTemplate:p,onSendViaGmail:x,isGmailConnected:y,getContactName:_,getShareUrl:b,copyToClipboard:N,formatDuration:w}){const[k,C]=S.useState(!1);return e.jsxs(Pe,{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(Qjs,{previewSrc:s,thumbnailSrc:r,alt:t.title||"Video preview",isHovered:k}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("div",{className:"w-12 h-12 rounded-full bg-white/90 flex items-center justify-center",children:e.jsx(So,{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(Qe,{variant:t.status==="processing"?"secondary":"destructive",className:"absolute top-2 left-2",children:t.status})]}),e.jsx(Re,{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(Ti,{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(ln,{className:"h-3 w-3"}),e.jsx("span",{children:ps(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(wn,{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:E=>{E.stopPropagation(),x==null||x()},children:[e.jsx(rr,{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(Ti,{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(ln,{className:"h-3 w-3"}),e.jsx("span",{children:ps(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(wn,{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:E=>E.stopPropagation(),children:e.jsx(ax,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",className:"bg-popover",children:[e.jsxs(va,{onClick:E=>{E.stopPropagation(),n()},children:[e.jsx(wn,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(Zb,{}),e.jsxs(va,{onClick:E=>{E.stopPropagation(),p()},children:[e.jsx(Dl,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(va,{onClick:E=>{E.stopPropagation(),N(b(t),"Share link")},children:[e.jsx(fo,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(va,{onClick:E=>{E.stopPropagation(),i()},children:[e.jsx(G4,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(va,{onClick:E=>{E.stopPropagation(),d()},children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(va,{onClick:E=>{E.stopPropagation(),u()},children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),y&&t.share_token&&e.jsxs(va,{onClick:E=>{E.stopPropagation(),x==null||x()},children:[e.jsx(An,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(va,{onClick:E=>{E.stopPropagation(),o()},children:[e.jsx(ga,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(Zb,{}),t.contact_id&&e.jsxs(va,{onClick:E=>{E.stopPropagation(),l()},children:[e.jsx(Ti,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(va,{onClick:E=>{E.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(gr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function eNs(){var Ze,Et;const t=_r(),{data:s,isLoading:r,refetch:n}=pbs(),{data:a}=Sme(),{data:o}=qh(),l=gbs(),i=xbs(),{isGmailConnected:d,gmailEmail:u}=jp(),{data:p}=Px(),{data:x=[],isLoading:y}=Kjs(),[_,b]=S.useState("my"),[N,w]=S.useState(""),[k,C]=S.useState(null),[E,L]=S.useState(!1),[I,O]=S.useState(!1),[V,q]=S.useState(!1),[$,U]=S.useState(!1),[se,Y]=S.useState(!1),[J,X]=S.useState(""),[ce,ie]=S.useState(!1),[ae,oe]=S.useState(!1),[pe,_e]=S.useState(!1),[he,we]=S.useState(!1),[je,Ue]=S.useState(""),[Te,Me]=S.useState({}),Fe=$t=>{if(!$t)return"Unassigned";const Yt=o==null?void 0:o.find(Ps=>Ps.id===$t);return Yt?`${Yt.first_name} ${Yt.last_name||""}`.trim():"Unknown"},Le=$t=>{if(!$t)return"0:00";const Yt=Math.floor($t/60),Ps=$t%60;return`${Yt}:${Ps.toString().padStart(2,"0")}`},Ne=s==null?void 0:s.filter($t=>{if(!N)return!0;const Yt=Fe($t.contact_id).toLowerCase(),Ps=($t.title||"").toLowerCase(),zs=($t.notes||"").toLowerCase();return Yt.includes(N.toLowerCase())||Ps.includes(N.toLowerCase())||zs.includes(N.toLowerCase())}),[qe,ze]=S.useState(!1);S.useEffect(()=>{if(qe)return;(async()=>{if(!(s!=null&&s.length))return;const Yt=s.filter(zs=>zs.status==="processing"&&zs.bunny_video_id);if(!Yt.length)return;let Ps=!1;for(const zs of Yt)try{const{data:Zs,error:Dr}=await G.functions.invoke("bunny-upload",{body:{action:"status",videoId:zs.bunny_video_id,isAgentVideo:!0}});if(Dr||!Zs)continue;Zs.status===4&&(await G.from("agent_videos").update({status:"ready",playback_url:Zs.directPlayUrl,thumbnail_url:Zs.thumbnailUrl,preview_url:Zs.previewUrl,duration_seconds:Zs.length||zs.duration_seconds,updated_at:new Date().toISOString()}).eq("id",zs.id),Ps=!0)}catch(Zs){console.warn("Reconcile check failed for video",zs.id,Zs)}ze(!0),Ps&&n()})()},[s,qe,n]),S.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const Yt=s.filter(zt=>(zt==null?void 0:zt.bunny_video_id)&&!Te[zt.id]);if(!Yt.length)return;const Ps=Yt.map(zt=>zt.bunny_video_id),{data:zs,error:Zs}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Ps,isAgentVideo:!0}});if(Zs)throw Zs;const Dr=(zs==null?void 0:zs.assets)||{};Me(zt=>{const $s={...zt};for(const kr of Yt)Dr[kr.bunny_video_id]&&($s[kr.id]={previewUrl:Dr[kr.bunny_video_id].previewUrl,thumbnailUrl:Dr[kr.bunny_video_id].thumbnailUrl});return $s})})().catch(Yt=>console.warn("Failed to load signed Bunny asset URLs",Yt))},[s,Te]);const ve=(a==null?void 0:a.total_storage_mb)||0,dt=(a==null?void 0:a.max_storage_mb)||1024,fe=ve/dt*100,Ve=fe>=80,Je=fe>=100,at=async($t,Yt)=>{await navigator.clipboard.writeText($t),me.success(`${Yt} copied to clipboard`)},Ae=$t=>$t.share_token?`https://video.relevelup.com/${$t.share_token}`:$t.playback_url||"",Ye=$t=>{const Yt=Ae($t),Ps=o==null?void 0:o.find(kr=>kr.id===$t.contact_id),zs=Fe($t.contact_id),Zs=zs!=="Unassigned"?zs.split(" ")[0]:"",Dr=(Ps==null?void 0:Ps.phone)||"",zt=`Hey${Zs?` ${Zs}`:""}! I recorded a quick video message for you. Check it out: ${Yt}`,$s=Dr?`sms:${Dr}?body=${encodeURIComponent(zt)}`:`sms:?body=${encodeURIComponent(zt)}`;window.open($s,"_self")},We=$t=>{const Yt=o==null?void 0:o.find($s=>$s.id===$t.contact_id),Ps=(Yt==null?void 0:Yt.email)||"",zs=Ae($t),Zs="Check out this video",Dr=`I recorded a quick video for you: ${zs}`,zt=Ps?`mailto:${Ps}?subject=${encodeURIComponent(Zs)}&body=${encodeURIComponent(Dr)}`:`mailto:?subject=${encodeURIComponent(Zs)}&body=${encodeURIComponent(Dr)}`;window.open(zt,"_self")},ot=$t=>{var Zs;const Yt=Ae($t),Ps=$t.title||"Video Message",zs=$t.share_token?`https://video.relevelup.com/thumb/${$t.share_token}`:((Zs=Te[$t.id])==null?void 0:Zs.thumbnailUrl)||$t.thumbnail_url||"";return``},Ge=async $t=>{if(!$t.thumbnail_url&&!$t.share_token){me.error("Video thumbnail not available yet");return}const Yt=ot($t),Ps=Ae($t),zs=`Watch: ${$t.title||"Video Message"} ${Ps}`;try{const Zs=new Blob([Yt],{type:"text/html"}),Dr=new Blob([zs],{type:"text/plain"}),zt=new ClipboardItem({"text/html":Zs,"text/plain":Dr});await navigator.clipboard.write([zt]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(zs+` `+Yt),me.success("Copied! Paste into your email.")}},et=async $t=>{try{me.loading("Preparing download...",{id:"download"});const{data:Yt,error:Ps}=await G.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:$t.bunny_video_id,isAgentVideo:!0}});if(Ps||!(Yt!=null&&Yt.downloadUrl))throw new Error((Ps==null?void 0:Ps.message)||"Failed to get download URL");const Zs=`${(($t.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,Dr=await fetch(Yt.downloadUrl);if(!Dr.ok)throw new Error("Failed to fetch video file");const zt=await Dr.blob(),$s=URL.createObjectURL(zt),kr=document.createElement("a");kr.href=$s,kr.download=Zs,kr.rel="noreferrer",document.body.appendChild(kr),kr.click(),kr.remove(),URL.revokeObjectURL($s),me.success("Download started",{id:"download"})}catch(Yt){console.error("Download error:",Yt),me.error("Could not force download (your browser may block it).",{id:"download"})}},ht=async $t=>{C($t),ie(!0),X(""),Y(!0);try{const{data:Yt,error:Ps}=await G.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:$t.bunny_video_id,title:$t.title,isAgentVideo:!0,shareToken:$t.share_token}});if(Ps||!(Yt!=null&&Yt.html))throw new Error("Failed to generate CRM embed code");X(Yt.html)}catch(Yt){console.error("CRM embed error:",Yt),me.error("Failed to generate CRM embed code"),Y(!1)}finally{ie(!1)}},xt=$t=>{C($t),L(!0)},Ke=async()=>{if(k)try{await l.mutateAsync({id:k.id,bunnyVideoId:k.bunny_video_id,hardDelete:!0}),O(!1),C(null),me.success("Video deleted successfully")}catch{me.error("Failed to delete video")}};return e.jsx(Es,{title:"Video Library",description:"Manage your video touches",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Video Library"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage and share your video touches"})]}),e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5 ml-2",children:[e.jsx("button",{onClick:()=>b("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${_==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Videos"}),p&&((Ze=p.team)==null?void 0:Ze.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(lr,{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(to,{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($a,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Record New Video"]})]})]}),_==="team"?e.jsx(tNs,{videos:x,isLoading:y,searchTerm:N,setSearchTerm:w}):_==="analytics"?e.jsx(Xjs,{}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:Ve?"border-amber-500":Je?"border-destructive":"",children:e.jsxs(Re,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(pL,{className:`h-5 w-5 ${Je?"text-destructive":Ve?"text-amber-500":"text-muted-foreground"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:"Storage Used"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[ve.toFixed(1)," MB / ",dt>=1024?`${(dt/1024).toFixed(0)} GB`:`${dt} MB`]})]}),e.jsx(gi,{value:Math.min(fe,100),className:`h-2 ${Je?"[&>div]:bg-destructive":Ve?"[&>div]:bg-amber-500":""}`})]}),Ve&&!Je&&e.jsxs(Qe,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(Lo,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),Je&&e.jsxs(Qe,{variant:"destructive",children:[e.jsx(Lo,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),Je&&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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search videos by contact, title, or notes...",value:N,onChange:$t=>w($t.target.value),className:"pl-10"})]}),r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):(Ne==null?void 0:Ne.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(Tn,{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(Us,{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:Ne==null?void 0:Ne.map($t=>{var Yt,Ps;return e.jsx(Jjs,{video:$t,previewSrc:(Yt=Te[$t.id])==null?void 0:Yt.previewUrl,thumbnailSrc:(Ps=Te[$t.id])==null?void 0:Ps.thumbnailUrl,onOpen:()=>xt($t),onDelete:()=>{C($t),O(!0)},onRename:()=>{C($t),Ue($t.title||""),we(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${$t.contact_id}`),onGetEmbedCode:()=>{C($t),U(!0)},onCopyEmailHtml:()=>Ge($t),onEmbedToCrm:()=>ht($t),onShareWithTemplate:()=>{C($t),oe(!0)},onSendViaGmail:()=>{C($t),_e(!0)},isGmailConnected:d,getContactName:Fe,getShareUrl:Ae,copyToClipboard:at,formatDuration:Le},$t.id)})}),e.jsx(fs,{open:E,onOpenChange:L,children:e.jsxs(ms,{className:"max-w-2xl",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:(k==null?void 0:k.title)||"Video Preview"}),e.jsx(Ir,{children:(k==null?void 0:k.contact_id)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ti,{className:"h-3 w-3"}),Fe(k.contact_id)]})})]}),k&&e.jsxs("div",{className:"space-y-4",children:[k.status==="processing"?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-6 bg-muted/50 rounded-lg border border-dashed border-border text-center space-y-4",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(_s,{className:"h-8 w-8 text-primary animate-spin"})})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Video is still processing"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:"Your video is being encoded and will be ready shortly. This usually takes 1–3 minutes. Check back soon!"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(!1),n()},children:[e.jsx(oo,{className:"h-4 w-4 mr-2"}),"Refresh Library"]})]}):e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:k.playback_url?(()=>{let $t=k.playback_url;return $t.includes("iframe.mediadelivery.net/play/")&&($t=$t.replace("/play/","/embed/"),$t+=($t.includes("?")?"&":"?")+"autoplay=false&responsive=true"),$t.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:$t,title:k.title||"Video preview",className:"absolute top-0 left-0 w-full h-full rounded-lg",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsx("video",{src:k.playback_url,controls:!0,playsInline:!0,preload:"metadata",poster:k.thumbnail_url||void 0,className:"absolute top-0 left-0 w-full h-full rounded-lg object-cover",onError:()=>me.error("Video preview failed to load")},k.playback_url)})():e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-muted rounded-lg",children:[e.jsx(Tn,{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:()=>Ye(k),children:[e.jsx(ki,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!d&&e.jsxs(K,{variant:"outline",onClick:()=>We(k),children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>at(Ae(k),"Share link"),children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ge(k),children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(K,{variant:"outline",onClick:()=>et(k),children:[e.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>{L(!1),ht(k)},children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(K,{variant:"outline",onClick:()=>{L(!1),oe(!0)},children:[e.jsx(Dl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),d&&(k==null?void 0:k.share_token)&&e.jsxs(K,{variant:"outline",onClick:()=>{L(!1),_e(!0)},children:[e.jsx(An,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]})]}),e.jsx("div",{className:"flex justify-end pt-2 border-t",children:e.jsxs(K,{variant:"destructive",onClick:()=>{L(!1),O(!0)},children:[e.jsx(gr,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(fs,{open:I,onOpenChange:O,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Delete Video"}),e.jsx(Ir,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),e.jsxs(En,{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(Bjs,{open:V,onOpenChange:q}),e.jsx(fs,{open:$,onOpenChange:U,children:e.jsxs(ms,{className:"sm:max-w-lg",children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Embed Video"}),e.jsx(Ir,{children:"Copy this code to embed the video on your website."})]}),k&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Embed Code"}),e.jsx(vr,{readOnly:!0,rows:5,value:``,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{className:"flex-1",onClick:()=>{const $t=``;at($t,"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."})]})]})}),k&&e.jsx(plt,{open:ae,onOpenChange:oe,video:k,contactName:Fe(k.contact_id)}),k&&e.jsx(Wjs,{open:pe,onOpenChange:_e,video:k,gmailEmail:u,signedThumbnailUrl:(Et=Te[k.id])==null?void 0:Et.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(Ir,{children:"Enter a new title for this video."})]}),e.jsx(De,{value:je,onChange:$t=>Ue($t.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:$t=>{$t.key==="Enter"&&je.trim()&&i.mutate({id:k.id,title:je.trim()},{onSuccess:()=>{me.success("Video renamed"),we(!1)}})}}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>we(!1),children:"Cancel"}),e.jsx(K,{disabled:!je.trim()||i.isPending,onClick:()=>{i.mutate({id:k.id,title:je.trim()},{onSuccess:()=>{me.success("Video renamed"),we(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(fs,{open:se,onOpenChange:Y,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(Ir,{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(_s,{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(xe,{children:"CRM Email HTML"}),e.jsx(vr,{readOnly:!0,rows:12,value:J,className:"font-mono text-xs"})]}),e.jsxs(K,{className:"w-full",onClick:()=>{at(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 tNs({videos:t,isLoading:s,searchTerm:r,setSearchTerm:n}){const a=S.useMemo(()=>{if(!r)return t;const i=r.toLowerCase();return t.filter(d=>(d.title||"").toLowerCase().includes(i)||(d.owner_name||"").toLowerCase().includes(i)||(d.recipient_name||"").toLowerCase().includes(i))},[t,r]),o=S.useMemo(()=>{const i=new Map;return a.forEach(d=>{const u=i.get(d.owner_user_id);u?u.videos.push(d):i.set(d.owner_user_id,{name:d.owner_name,avatar:d.owner_avatar_url,videos:[d]})}),Array.from(i.entries())},[a]),l=i=>{if(!i)return"0:00";const d=Math.floor(i/60),u=i%60;return`${d}:${u.toString().padStart(2,"0")}`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{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(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(lr,{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(Ta,{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(Qe,{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(Pe,{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(Tn,{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(Re,{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(Ti,{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(wn,{className:"h-3 w-3"}),u.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ln,{className:"h-3 w-3"}),ps(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const sNs=()=>{const{user:t}=Fs();return gt({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})},Xze=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function rNs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=sNs(),[a,o]=S.useState(""),[l,i]=S.useState("all"),d=S.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:Xze[N%Xze.length]}),N++)}),b},[r]),u=S.useMemo(()=>Array.from(d.entries()).map(([b,N])=>({id:b,...N})),[d]),p=S.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 k,C,E,L;return w.deal_name.toLowerCase().includes(N)||((k=w.contact_name)==null?void 0:k.toLowerCase().includes(N))||((C=w.property_address)==null?void 0:C.toLowerCase().includes(N))||((E=w.city)==null?void 0:E.toLowerCase().includes(N))||((L=w.owner_name)==null?void 0:L.toLowerCase().includes(N))})}return b},[r,a,l]),x=S.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 k=b.get(w);k.deals.push(N),k.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(lr,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search deals...",value:a,onChange:b=>o(b.target.value),className:"pl-9"})]}),e.jsxs(Bs,{value:l,onValueChange:i,children:[e.jsx(Rs,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"All Members"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Members"}),u.map(b=>e.jsx(vt,{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(Ns,{className:"h-12 w-full mb-2 rounded-lg"}),e.jsx(Ns,{className:"h-24 w-full mb-2 rounded-lg"}),e.jsx(Ns,{className:"h-24 w-full rounded-lg"})]},b))}):x.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(lr,{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:x.map(b=>{const N=b.icon&&sje[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(Qe,{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(ui,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:b.deals.map(w=>{const k=d.get(w.owner_user_id);return e.jsx(nNs,{deal:w,ownerColor:(k==null?void 0:k.color)||"#888",ownerName:(k==null?void 0:k.name)||"Unknown",ownerAvatar:(k==null?void 0:k.avatar)||null,formatPrice:_},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 ",x.length," stage",x.length!==1?"s":""," from ",u.length," member",u.length!==1?"s":""]})]})})}function nNs({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(Ta,{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(Qe,{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(yc,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:a(t.sale_price)})]})]})}function aNs({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(lr,{className:"h-4 w-4 shrink-0 text-primary"}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs font-semibold flex-1 text-left",children:"Team"}),o>0&&e.jsx("span",{className:"text-[10px] bg-primary text-primary-foreground rounded-full px-1.5 py-0.5",children:o}),e.jsx(xl,{className:"h-3 w-3 text-muted-foreground"})]}),!n&&o>0&&e.jsx("span",{className:"absolute -top-1 -right-1 text-[9px] bg-primary text-primary-foreground rounded-full w-4 h-4 flex items-center justify-center",children:o})]})}),n?e.jsxs(ui,{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(Ta,{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(Er,{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(Ta,{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 Qze=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function iNs(){const t=ja(),{data:s}=Px(),r=(s==null?void 0:s.role)==="team_leader",n=s==null?void 0:s.teamId,a=gt({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,x)=>({id:p.id,name:p.name||"Unknown",avatar_url:p.avatar_url,color:Qze[x%Qze.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function oNs(t){return gt({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 lNs(){const t=ja();return gt({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 flt({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=S.useState(!1),l=t.find(d=>d.id===s),i=d=>{d.id!==s&&r(d.id,d.name),o(!1)};return e.jsxs(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(Sa,{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&&sje[d.icon]||sd,p=d.id===s;return e.jsxs(va,{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(Jn,{className:"h-4 w-4 text-primary"})]},d.id)})})]})}const cNs={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"}},dNs={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 xlt({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var C,E;const d=vE(),u=cNs[t.deal_type],p=dNs[t.priority],x=S.useMemo(()=>t.target_close_date?Bg(ml(t.target_close_date),new Date):null,[t.target_close_date]),y=x!==null&&x<0,_=x!==null&&x<=7&&x>=0,b=S.useMemo(()=>{var O;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const L=((O=t.listing)==null?void 0:O.created_at)||t.listing_date;if(!L)return null;const I=t.contract_date?ml(t.contract_date):new Date;return Bg(I,ml(L))},[t]),N=l&&!t.scorecard_transaction_id,w=!!t.scorecard_transaction_id,k=L=>L?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(L):null;return e.jsx(Pe,{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(Re,{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(Ta,{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(Qe,{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],(E=t.contact.last_name)==null?void 0:E[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(Vi,{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(Qn,{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(gM,{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(yc,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:k(t.expected_price)}),t.expected_commission&&e.jsxs("span",{className:"text-muted-foreground",children:["• ",k(t.expected_commission)," GCI"]}),(()=>{const L=cx(t);return L!==null&&L!==t.expected_commission?e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:["• ",k(L)," Net"]}):null})()]}),e.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className: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(flt,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(L,I)=>a(t.id,L,I)}):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(Lo,{className:"h-3 w-3"}):e.jsx(on,{className:"h-3 w-3"}),e.jsx("span",{children:y?`${Math.abs(x)}d overdue`:_?`${x}d left`:ps(ml(t.target_close_date),"MMM d")})]}):null]})]})})}function uNs({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:d=!1,getOwnerInfo:u}){const p=S.useRef(null),x=s.reduce((w,k)=>w+(k.expected_price||0),0),y=s.reduce((w,k)=>w+(k.expected_commission||0),0),_=s.reduce((w,k)=>w+(cx(k)||0),0),b=w=>w>=1e6?`$${(w/1e6).toFixed(1)}M`:w>=1e3?`$${(w/1e3).toFixed(0)}K`:`$${w.toFixed(0)}`,N=t.icon&&sje[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(Qe,{variant:"secondary",className:"text-xs font-medium px-2",children:s.length})]}),x>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(x)}),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(ui,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(w=>e.jsx("div",{draggable:!0,onDragStart:k=>{k.dataTransfer.effectAllowed="move",a(w.id,t.id)},children:e.jsx(xlt,{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(Us,{className:"h-4 w-4 mr-2"}),"Add Deal"]})})]})}function hNs({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:Rh,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Weighted GCI",value:r((t==null?void 0:t.weightedGCI)||0),icon:EL,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:qL,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:aL,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(Pe,{className:"animate-pulse",children:e.jsx(Re,{className:"p-4",children:e.jsx("div",{className:"h-10 bg-muted rounded"})})},a))}):e.jsx(N1,{children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:n.map(a=>{const o=e.jsx(Pe,{className:"border-border/50 hover:shadow-sm transition-shadow",children:e.jsx(Re,{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(Yl,{children:[e.jsx(Xl,{asChild:!0,children:o}),e.jsx(Cl,{children:e.jsx("p",{children:a.tooltip})})]},a.label):o})})})}function mNs({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=Fs(),[a,o]=S.useState(t.portal_enabled);if(!n)return e.jsxs("div",{className:"border rounded-lg p-4 opacity-60",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($r,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(Qe,{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(of,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(lf,{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($r,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(Qe,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(Oi,{className:Rt("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(cf,{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(xe,{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(Er,{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(xe,{className:"text-sm font-medium",children:"Portal Visibility"}),e.jsxs(YNe,{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(gle,{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(gle,{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(Ki,{id:"require_onboarding",checked:t.require_onboarding,onCheckedChange:i=>l({require_onboarding:!!i}),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx(xe,{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(Ki,{id:"allow_spouse",checked:t.allow_spouse,onCheckedChange:i=>l({allow_spouse:!!i})}),e.jsx(xe,{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(xe,{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(xe,{className:"text-xs text-muted-foreground",children:"Client Full Name"}),e.jsx(De,{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(xe,{className:"text-xs text-muted-foreground",children:"Email"}),e.jsx(De,{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(xe,{className:"text-xs text-muted-foreground",children:"Phone"}),e.jsx(De,{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(xe,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),e.jsxs(Bs,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"email",children:"Email"}),e.jsxs(vt,{value:"sms",disabled:!t.client_phone,children:["SMS ",!t.client_phone&&"(add phone first)"]})]})]})]})]})]})]})]})})]})})}const pNs=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],fNs=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function xNs({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=Cme(),{data:o}=qh(),{data:l}=_Xe(),i=ehe(),d=lit(),u=cit(),p=OSe(),[x,y]=S.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[_,b]=S.useState(""),[N,w]=S.useState(!1),[k,C]=S.useState(!1),[E,L]=S.useState({first_name:"",last_name:"",email:"",phone:""}),I=(l==null?void 0:l.filter(J=>((r==null?void 0:r.listing_id)===J.id,!0)))||[],[O,V]=S.useState({deal_name:"",deal_type:"buyer",stage_id:"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",brokerage_split_pct:"",team_split_pct:"",referral_fee_pct:"",franchise_fee_pct:"",transaction_fee:"",commission_calc_method:"standard",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""});S.useEffect(()=>{var J,X,ce,ie,ae,oe,pe,_e;t&&(r?(V({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:((X=r.commission_percentage)==null?void 0:X.toString())||"3",brokerage_split_pct:((ce=r.brokerage_split_pct)==null?void 0:ce.toString())||"",team_split_pct:((ie=r.team_split_pct)==null?void 0:ie.toString())||"",referral_fee_pct:((ae=r.referral_fee_pct)==null?void 0:ae.toString())||"",franchise_fee_pct:((oe=r.franchise_fee_pct)==null?void 0:oe.toString())||"",transaction_fee:((pe=r.transaction_fee)==null?void 0:pe.toString())||"",commission_calc_method:r.commission_calc_method||"standard",target_close_date:r.target_close_date?ml(r.target_close_date):void 0,contract_date:r.contract_date?ml(r.contract_date):void 0,listing_date:r.listing_date?ml(r.listing_date):void 0,priority:r.priority,probability:r.probability.toString(),notes:r.notes||""}),r.contact&&b(`${r.contact.first_name} ${r.contact.last_name}`)):(V({deal_name:"",deal_type:"buyer",stage_id:n||((_e=a==null?void 0:a[0])==null?void 0:_e.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,ie,ae;const X=_.toLowerCase();return((ce=J.first_name)==null?void 0:ce.toLowerCase().includes(X))||((ie=J.last_name)==null?void 0:ie.toLowerCase().includes(X))||((ae=J.email)==null?void 0:ae.toLowerCase().includes(X))}).slice(0,5),$=()=>{const J=parseFloat(O.expected_price)||0,X=parseFloat(O.commission_percentage)||0;return J*(X/100)},U=()=>{const J=$();if(!J)return null;const X=parseFloat(O.brokerage_split_pct)||0,ce=parseFloat(O.team_split_pct)||0,ie=parseFloat(O.referral_fee_pct)||0,ae=parseFloat(O.franchise_fee_pct)||0,oe=parseFloat(O.transaction_fee)||0;if(O.commission_calc_method==="referral_first"){let _e=J;ie&&(_e-=J*ie/100);let he=_e;return X&&(he-=_e*X/100),ce&&(he-=J*ce/100),ae&&(he-=J*ae/100),oe&&(he-=oe),Math.max(0,he)}let pe=J;return X&&(pe=pe*((100-X)/100)),ce&&(pe=pe*((100-ce)/100)),ie&&(pe=pe-J*ie/100),ae&&(pe=pe-J*ae/100),oe&&(pe=pe-oe),Math.max(0,pe)},se=async J=>{var X,ce,ie;if(J.preventDefault(),!O.deal_name.trim()){me.error("Please enter a deal name");return}try{const ae={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:((X=O.target_close_date)==null?void 0:X.toISOString().split("T")[0])||null,contract_date:((ce=O.contract_date)==null?void 0:ce.toISOString().split("T")[0])||null,listing_date:((ie=O.listing_date)==null?void 0:ie.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,...ae}),me.success("Deal updated successfully");else{const oe=await d.mutateAsync(ae);if(me.success("Deal created successfully"),x.portal_enabled&&(oe!=null&&oe.id))try{await p.mutateAsync({deal_id:oe.id,visibility:x.visibility,require_onboarding:x.require_onboarding,allow_spouse:x.allow_spouse,client_name:x.client_name||null,client_email:x.client_email||null,client_phone:x.client_phone||null,invite_method:x.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")}},Y=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(Ir,{children:r?"Update the deal details below.":"Enter the details for your new deal."})]}),e.jsxs("form",{onSubmit:se,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(xe,{htmlFor:"deal_name",children:"Deal Name *"}),e.jsx(De,{id:"deal_name",value:O.deal_name,onChange:J=>V(X=>({...X,deal_name:J.target.value})),placeholder:"e.g., Smith Family - 123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Deal Type"}),e.jsxs(Bs,{value:O.deal_type,onValueChange:J=>V(X=>({...X,deal_type:J})),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:pNs.map(J=>e.jsx(vt,{value:J.value,children:J.label},J.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Stage"}),e.jsxs(Bs,{value:O.stage_id||"none",onValueChange:J=>V(X=>({...X,stage_id:J==="none"?"":J})),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select stage"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"No Stage"}),a==null?void 0:a.map(J=>e.jsx(vt,{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(xe,{children:"Link to Contact"}),e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{value:_,onChange:J=>{b(J.target.value),w(!0),C(!1),J.target.value||V(X=>({...X,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:()=>{V(X=>({...X,contact_id:J.id})),b(`${J.first_name} ${J.last_name}`),w(!1)},children:[e.jsx(Ti,{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+/);L({first_name:J[0]||"",last_name:J.slice(1).join(" ")||"",email:"",phone:""}),C(!0),w(!1)},children:[e.jsx(al,{className:"h-4 w-4"}),e.jsxs("span",{children:['Create new contact "',_.trim(),'"']})]})]})]}),k&&e.jsxs("div",{className:"border rounded-lg p-3 space-y-3 bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(al,{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(De,{placeholder:"First name *",value:E.first_name,onChange:J=>L(X=>({...X,first_name:J.target.value})),className:"h-8 text-sm"}),e.jsx(De,{placeholder:"Last name",value:E.last_name,onChange:J=>L(X=>({...X,last_name:J.target.value})),className:"h-8 text-sm"}),e.jsx(De,{placeholder:"Email",type:"email",value:E.email,onChange:J=>L(X=>({...X,email:J.target.value})),className:"h-8 text-sm"}),e.jsx(De,{placeholder:"Phone",type:"tel",value:E.phone,onChange:J=>L(X=>({...X,phone:J.target.value})),className:"h-8 text-sm"})]}),e.jsx(K,{type:"button",size:"sm",className:"w-full h-8",disabled:!E.first_name.trim()||i.isPending,onClick:async()=>{try{const J=await i.mutateAsync({first_name:E.first_name.trim(),last_name:E.last_name.trim()||null,email:E.email.trim()||null,phone:E.phone.trim()||null});J&&(V(X=>({...X,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(_s,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(al,{className:"h-3.5 w-3.5 mr-1"})," Add & Link Contact"]})})]})]}),I.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(Do,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),e.jsxs(Bs,{value:O.listing_id||"none",onValueChange:J=>{const X=J==="none"?"":J,ce=I.find(ie=>ie.id===X);V(ce?ie=>{var ae;return{...ie,listing_id:X,deal_type:"seller",property_address:ce.property_address||ie.property_address,city:ce.city||ie.city,state:ce.state||ie.state,expected_price:((ae=ce.price)==null?void 0:ae.toString())||ie.expected_price}}:ie=>({...ie,listing_id:X}))},children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select a listing to sync status..."})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"None"}),I.map(J=>e.jsx(vt,{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(xe,{htmlFor:"property_address",children:"Address"}),e.jsx(De,{id:"property_address",value:O.property_address,onChange:J=>V(X=>({...X,property_address:J.target.value})),placeholder:"123 Main Street"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"city",children:"City"}),e.jsx(De,{id:"city",value:O.city,onChange:J=>V(X=>({...X,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(xe,{htmlFor:"state",children:"State"}),e.jsx(De,{id:"state",value:O.state,onChange:J=>V(X=>({...X,state:J.target.value})),maxLength:2,placeholder:"TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"zip_code",children:"ZIP"}),e.jsx(De,{id:"zip_code",value:O.zip_code,onChange:J=>V(X=>({...X,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(xe,{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(De,{id:"expected_price",type:"number",value:O.expected_price,onChange:J=>V(X=>({...X,expected_price:J.target.value})),className:"pl-7",placeholder:"500000"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"commission_percentage",children:"Commission %"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{id:"commission_percentage",type:"number",step:"0.1",value:O.commission_percentage,onChange:J=>V(X=>({...X,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(xe,{children:"Expected GCI"}),e.jsx(De,{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(xe,{className:"text-xs whitespace-nowrap",children:"Calculation Method:"}),e.jsxs(Bs,{value:O.commission_calc_method,onValueChange:J=>V(X=>({...X,commission_calc_method:J})),children:[e.jsx(Rs,{className:"h-7 text-xs",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"standard",children:"Standard (all splits on GCI)"}),e.jsx(vt,{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(xe,{className:"text-xs",children:"Brokerage Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{type:"number",step:"1",min:"0",max:"100",value:O.brokerage_split_pct,onChange:J=>V(X=>({...X,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(xe,{className:"text-xs",children:"Team Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{type:"number",step:"1",min:"0",max:"100",value:O.team_split_pct,onChange:J=>V(X=>({...X,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(xe,{className:"text-xs",children:"Referral Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{type:"number",step:"1",min:"0",max:"100",value:O.referral_fee_pct,onChange:J=>V(X=>({...X,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(xe,{className:"text-xs",children:"Franchise Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{type:"number",step:"1",min:"0",max:"100",value:O.franchise_fee_pct,onChange:J=>V(X=>({...X,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(xe,{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(De,{type:"number",step:"1",min:"0",value:O.transaction_fee,onChange:J=>V(X=>({...X,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(xe,{className:"text-xs",children:"Net to Agent"}),e.jsx(De,{value:U()?`$${Math.round(U()).toLocaleString()}`:"-",disabled:!0,className:"bg-muted h-8 text-sm font-semibold"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Dates & Status"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Target Close Date"}),e.jsxs(xo,{children:[e.jsx(go,{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(on,{className:"mr-2 h-4 w-4"}),O.target_close_date?ps(O.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(lo,{className:"w-auto p-0",align:"start",children:e.jsx(df,{mode:"single",selected:O.target_close_date,onSelect:J=>V(X=>({...X,target_close_date:J})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Contract Date"}),e.jsxs(xo,{children:[e.jsx(go,{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(on,{className:"mr-2 h-4 w-4"}),O.contract_date?ps(O.contract_date,"PPP"):"Pick a date"]})}),e.jsx(lo,{className:"w-auto p-0",align:"start",children:e.jsx(df,{mode:"single",selected:O.contract_date,onSelect:J=>V(X=>({...X,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(xe,{children:"Listing Date (for Days on Market)"}),e.jsxs(xo,{children:[e.jsx(go,{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(on,{className:"mr-2 h-4 w-4"}),O.listing_date?ps(O.listing_date,"PPP"):"Pick a date"]})}),e.jsx(lo,{className:"w-auto p-0",align:"start",children:e.jsx(df,{mode:"single",selected:O.listing_date,onSelect:J=>V(X=>({...X,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(xe,{children:"Priority"}),e.jsxs(Bs,{value:O.priority,onValueChange:J=>V(X=>({...X,priority:J})),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:fNs.map(J=>e.jsx(vt,{value:J.value,children:J.label},J.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Win Probability"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{type:"number",min:"0",max:"100",value:O.probability,onChange:J=>V(X=>({...X,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(xe,{htmlFor:"notes",children:"Notes"}),e.jsx(vr,{id:"notes",value:O.notes,onChange:J=>V(X=>({...X,notes:J.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(mNs,{formData:x,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:Y,children:[Y&&e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function gNs({dealId:t}){const s=ja(),r=Jt(),[n,a]=S.useState(""),[o,l]=S.useState(!1),{data:i=[]}=gt({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=[]}=gt({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(k=>k.tag))].sort()},enabled:!!s}),u=It({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=It({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]})}}),x=()=>{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(Qe,{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(Us,{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(De,{value:n,onChange:b=>a(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),x()),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:x,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 yNs(t){return gt({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 vNs(){const t=ja(),s=Jt();return It({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 _Ns(){const t=Jt();return It({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 bNs(){const t=Jt();return It({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 wNs(t){const{data:s,error:r}=await G.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const Jze={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function jNs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Nbs(),a=kbs(),o=Sbs(),l=Cbs(),[i,d]=S.useState(!1),[u,p]=S.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[x,y]=S.useState(""),_=async()=>{if(u.question_text.trim())try{await a.mutateAsync({question_text:u.question_text.trim(),field_type:u.field_type,options:u.field_type==="dropdown"?u.options:[],is_required:u.is_required,sort_order:((r==null?void 0:r.length)||0)+1}),p({question_text:"",field_type:"text",options:[],is_required:!1}),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,E)=>{try{await o.mutateAsync({id:C,is_required:E})}catch{me.error("Failed to update question")}},w=()=>{x.trim()&&(p(C=>({...C,options:[...C.options,x.trim()]})),y(""))},k=C=>{p(E=>({...E,options:E.options.filter((L,I)=>I!==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(ui,{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(_s,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),r==null?void 0:r.map(C=>{var E;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(hu,{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(Qe,{variant:"secondary",className:"text-xs",children:Jze[C.field_type]||C.field_type}),C.is_required&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Required"})]}),C.field_type==="dropdown"&&((E=C.options)==null?void 0:E.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(Er,{checked:C.is_required,onCheckedChange:L=>N(C.id,L),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(gr,{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(xe,{className:"text-sm font-medium",children:"Question"}),e.jsx(De,{value:u.question_text,onChange:C=>p(E=>({...E,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(xe,{className:"text-sm font-medium",children:"Answer Type"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(Jze).map(([C,E])=>e.jsx("button",{type:"button",onClick:()=>p(L=>({...L,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:E},C))})]}),u.field_type==="dropdown"&&e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Options"}),e.jsxs("div",{className:"space-y-1.5 mt-1.5",children:[u.options.map((C,E)=>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:()=>k(E),className:"text-muted-foreground hover:text-destructive",children:e.jsx(Sr,{className:"h-3.5 w-3.5"})})]},E)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:x,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:!x.trim(),className:"h-8",children:e.jsx(Us,{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(Er,{checked:u.is_required,onCheckedChange:C=>p(E=>({...E,is_required:C}))}),e.jsx(xe,{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(_s,{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(Us,{className:"h-4 w-4 mr-1"})," Add Question"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Done"})]})]})})}function NNs({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=S.useState(""),[i,d]=S.useState(!1),{data:u,isLoading:p}=gt({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}),x=S.useMemo(()=>!n||!u?null:u.find(b=>b.id===n),[n,u]),y=S.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]),_=S.useMemo(()=>{if(!u||!o.trim())return[];const b=o.toLowerCase();return u.filter(N=>{var k,C,E,L;const w=N.deal_pipeline;return((k=N.client_name)==null?void 0:k.toLowerCase().includes(b))||((C=N.client_email)==null?void 0:C.toLowerCase().includes(b))||((E=w==null?void 0:w.deal_name)==null?void 0:E.toLowerCase().includes(b))||((L=w==null?void 0:w.property_address)==null?void 0:L.toLowerCase().includes(b))})},[u,o]);if(n){const b=x==null?void 0:x.deal_pipeline;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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:(x==null?void 0:x.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(vS,{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(xe,{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(Qe,{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(an,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{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(_s,{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(Qe,{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 RCe({userId:t,onSelect:s,triggerLabel:r="Library",triggerSize:n="sm",triggerVariant:a="outline",triggerClassName:o}){const[l,i]=S.useState(!1),[d,u]=S.useState([]),[p,x]=S.useState(!1),[y,_]=S.useState("");S.useEffect(()=>{!l||!t||(x(!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||[]),x(!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(pi,{asChild:!0,children:e.jsxs(K,{variant:a,size:n,className:o||"gap-1.5 shrink-0",children:[e.jsx(tu,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{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(Ns,{className:"h-16 w-full"}),e.jsx(Ns,{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 k=w.currentTarget.parentElement;if(k){w.currentTarget.remove();const C=document.createElement("span");C.innerHTML="🎬",C.className="text-lg",k.appendChild(C)}}}):e.jsx(Tn,{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 OCe({contactId:t,onVideoReady:s}){const[r,n]=S.useState(!1),[a,o]=S.useState("record"),[l,i]=S.useState(0),[d,u]=S.useState(0),p=MC(),x=()=>{o("record"),i(0),u(0)},y=b=>{!b&&(a==="uploading"||a==="processing")||(n(b),b||x())},_=S.useCallback(async(b,N)=>{o("uploading");try{const w="Card Video",{videoId:k,libraryId:C}=await xO(w),{uploadUrl:E,apiKey:L}=await gO(k),I=new XMLHttpRequest;I.upload.onprogress=Y=>{Y.lengthComputable&&i(Y.loaded/Y.total*100)},await new Promise((Y,J)=>{I.onload=()=>I.status>=200&&I.status<300?Y():J(new Error("Upload failed")),I.onerror=()=>J(new Error("Upload failed")),I.open("PUT",E),I.setRequestHeader("AccessKey",L),I.send(b)}),o("processing");let O=0;const V=Date.now(),q=9e4,$=`https://iframe.mediadelivery.net/embed/${C}/${k}`;for(;O<4;){if(await new Promise(J=>setTimeout(J,3e3)),Date.now()-V>q){const J=b.size/1048576;await p.mutateAsync({bunny_video_id:k,playback_url:`https://iframe.mediadelivery.net/play/${C}/${k}`,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),x()},1500);return}const Y=await pA(k);if(O=Y.status,u(Y.encodeProgress||0),O===5||O===6)throw new Error("Video processing failed")}const U=await pA(k),se=(U.storageSize||b.size)/(1024*1024);await p.mutateAsync({bunny_video_id:k,contact_id:t||void 0,playback_url:U.directPlayUrl||$,thumbnail_url:U.thumbnailUrl,preview_url:U.previewUrl||null,duration_seconds:U.length||N,file_size_mb:se,title:w,status:"ready",touch_type:"video"}),s($),me.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),x()},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(pi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 w-full",children:[e.jsx(Tn,{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(Qme,{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(_s,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),e.jsx(gi,{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(_s,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),e.jsx(gi,{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(ti,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}const kNs=t=>`portal-settings-draft:${t}`;function glt({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=yO(),[o,l]=S.useState(!1),i=S.useMemo(()=>kNs(r.id),[r.id]),[d,u]=S.useState(!1),[p,x]=S.useState(r.next_step_text||""),[y,_]=S.useState(r.next_step_video_url||""),[b,N]=S.useState(r.inspection_date||""),[w,k]=S.useState(r.appraisal_date||""),[C,E]=S.useState(r.welcome_message||""),[L,I]=S.useState(r.review_url||""),[O,V]=S.useState(r.show_post_close_tips),[q,$]=S.useState(r.notify_client),[U,se]=S.useState(r.require_onboarding),[Y,J]=S.useState(r.allow_spouse),[X,ce]=S.useState(r.visibility),[ie,ae]=S.useState(r.stage_mapping||[]),[oe,pe]=S.useState(null),[_e,he]=S.useState(r.linked_portal_id||null),we=()=>{x(r.next_step_text||""),_(r.next_step_video_url||""),N(r.inspection_date||""),k(r.appraisal_date||""),E(r.welcome_message||""),I(r.review_url||""),V(r.show_post_close_tips),$(r.notify_client),se(r.require_onboarding),J(r.allow_spouse),ce(r.visibility),ae(r.stage_mapping||[]),he(r.linked_portal_id||null)};S.useEffect(()=>{u(!1);const Ne=localStorage.getItem(i);if(Ne)try{const qe=JSON.parse(Ne);x(qe.nextStepText||""),_(qe.nextStepVideo||""),N(qe.inspectionDate||""),k(qe.appraisalDate||""),E(qe.welcomeMessage||""),I(qe.reviewUrl||""),V(!!qe.showPostClose),$(!!qe.notifyClient),se(!!qe.requireOnboarding),J(!!qe.allowSpouse),ce(qe.visibility||r.visibility),ae(qe.stageMapping||[]),he(qe.linkedPortalId??null),u(!0);return}catch{localStorage.removeItem(i)}we(),u(!0)},[i,r]),S.useEffect(()=>{if(!d)return;const Ne={nextStepText:p,nextStepVideo:y,inspectionDate:b,appraisalDate:w,welcomeMessage:C,reviewUrl:L,showPostClose:O,notifyClient:q,requireOnboarding:U,allowSpouse:Y,visibility:X,stageMapping:ie,linkedPortalId:_e};p!==(r.next_step_text||"")||y!==(r.next_step_video_url||"")||b!==(r.inspection_date||"")||w!==(r.appraisal_date||"")||C!==(r.welcome_message||"")||L!==(r.review_url||"")||O!==r.show_post_close_tips||q!==r.notify_client||U!==r.require_onboarding||Y!==r.allow_spouse||X!==r.visibility||JSON.stringify(ie)!==JSON.stringify(r.stage_mapping||[])||_e!==(r.linked_portal_id||null)?localStorage.setItem(i,JSON.stringify(Ne)):localStorage.removeItem(i)},[p,y,b,w,C,L,O,q,U,Y,X,ie,_e,i,d,r]);const je=()=>{localStorage.removeItem(i),we()},Ue=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:L||null,show_post_close_tips:O,notify_client:q,require_onboarding:U,allow_spouse:Y,visibility:X,stage_mapping:ie.length>0?ie:null,linked_portal_id:_e});const Ne=r.linked_portal_id;_e&&_e!==Ne&&await G.from("client_portals").update({linked_portal_id:r.id}).eq("id",_e),!_e&&Ne&&await G.from("client_portals").update({linked_portal_id:null}).eq("id",Ne),localStorage.removeItem(i),me.success("Portal settings saved"),s(!1)}catch{me.error("Failed to save settings")}},Te=()=>{ae([...ie,{label:""}])},Me=Ne=>{ae(ie.filter((qe,ze)=>ze!==Ne)),oe===Ne&&pe(null)},Fe=(Ne,qe,ze)=>{const ve=[...ie];ve[Ne]={...ve[Ne],[qe]:ze},ae(ve)},Le=()=>{const qe=LNe(null).map(ze=>({label:ze.label,description:ze.description,stageId:void 0}));ae(qe)};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(ia,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(ea,{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(ui,{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(xe,{className:"text-sm font-medium",children:"Visibility"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Public portals appear without restrictions"})]}),e.jsx("div",{className:"flex gap-1",children:["private","public"].map(Ne=>e.jsx("button",{onClick:()=>ce(Ne),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${X===Ne?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:Ne.charAt(0).toUpperCase()+Ne.slice(1)},Ne))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{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(Er,{checked:U,onCheckedChange:se})]}),U&&e.jsxs("div",{className:"flex items-center justify-between pl-4 border-l-2 border-primary/20",children:[e.jsxs("div",{children:[e.jsx(xe,{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(xe,{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(Er,{checked:Y,onCheckedChange:J})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{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(Er,{checked:O,onCheckedChange:V})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{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(Er,{checked:q,onCheckedChange:$})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(NNs,{portalId:r.id,ownerId:n,clientEmail:r.client_email,linkedPortalId:_e,onLink:he})}),e.jsx("div",{children:e.jsx(De,{type:"date",value:b,onChange:Ne=>N(Ne.target.value),className:"mt-1"})}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Appraisal Date"}),e.jsx(De,{type:"date",value:w,onChange:Ne=>k(Ne.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(xe,{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:Le,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.'}),ie.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:Le,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:ie.map((Ne,qe)=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hu,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(De,{value:Ne.label,onChange:ze=>Fe(qe,"label",ze.target.value),placeholder:`Stage ${qe+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:()=>pe(oe===qe?null:qe),children:oe===qe?"Less":"More"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>Me(qe),children:e.jsx(gr,{className:"h-3.5 w-3.5"})})]}),oe===qe&&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(xe,{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("textarea",{value:Ne.description||"",onChange:ze=>Fe(qe,"description",ze.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(xe,{className:"text-xs text-muted-foreground",children:"Video"}),Ne.video_url?e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 text-xs text-muted-foreground truncate bg-muted/50 rounded px-2 py-1.5 border border-input",children:Ne.video_url.length>40?Ne.video_url.slice(0,40)+"...":Ne.video_url}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>Fe(qe,"video_url",""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(OCe,{onVideoReady:ze=>Fe(qe,"video_url",ze)}),e.jsx(RCe,{userId:n,onSelect:ze=>Fe(qe,"video_url",ze),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 ze=prompt("Paste a YouTube or Loom URL:");ze&&Fe(qe,"video_url",ze)},children:[e.jsx(fo,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},qe))}),ie.length>0&&e.jsxs(K,{variant:"outline",size:"sm",onClick:Te,className:"mt-2 text-xs w-full",children:[e.jsx(Us,{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(xe,{className:"text-sm font-medium",children:"Welcome Message"}),e.jsx("textarea",{value:C,onChange:Ne=>E(Ne.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Welcome! Here's everything you need for your transaction."})]}),e.jsxs("div",{children:[e.jsx(xe,{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:Ne=>x(Ne.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"We're waiting on the inspection report..."})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Next Step Video (optional)"}),e.jsx(De,{value:y,onChange:Ne=>_(Ne.target.value),className:"mt-1",placeholder:"YouTube or Loom URL"})]}),e.jsxs("div",{children:[e.jsx(xe,{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(De,{value:L,onChange:Ne=>I(Ne.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:je,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:Ue,disabled:a.isPending,children:[a.isPending?e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(_c,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})]})}),e.jsx(jNs,{open:o,onOpenChange:l})]})}const SNs=t=>`portal-update-draft:${t}`;function ylt({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const o=S.useMemo(()=>SNs(r),[r]),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,x]=S.useState(""),[y,_]=S.useState(!1),[b,N]=S.useState(a??!1),[w,k]=S.useState(!1),C=Yat();S.useEffect(()=>{k(!1);const I=localStorage.getItem(o);if(I)try{const O=JSON.parse(I);i(O.title||""),u(O.content||""),x(O.videoUrl||""),_(!!O.isStageChange),N(typeof O.sendNotification=="boolean"?O.sendNotification:a??!1),k(!0);return}catch{localStorage.removeItem(o)}i(""),u(""),x(""),_(!1),N(a??!1),k(!0)},[o,a]),S.useEffect(()=>{if(!w)return;const I={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(I)):localStorage.removeItem(o)},[l,d,p,y,b,w,o,a]);const E=()=>{localStorage.removeItem(o),i(""),u(""),x(""),_(!1),N(a??!1)},L=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 I=a1(n);await G.functions.invoke("send-portal-notification",{body:{portal_id:r,update_title:l.trim(),update_content:d.trim()||null,portal_url:I}}),me.success("Update posted & client notified")}catch(I){console.error("Notification failed:",I),me.success("Update posted (notification failed to send)")}else me.success("Update posted to portal");E(),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(xe,{className:"text-sm font-medium",children:"Title *"}),e.jsx(De,{value:l,onChange:I=>i(I.target.value),className:"mt-1",placeholder:"Inspection cleared!"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Message"}),e.jsx("textarea",{value:d,onChange:I=>u(I.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Everything looked great during the inspection..."})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Video URL (optional)"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(De,{value:p,onChange:I=>x(I.target.value),className:"pl-9",placeholder:"YouTube or Loom link"}),e.jsx(Tn,{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(Sm,{className:"h-3 w-3"}):e.jsx(Gv,{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:E,children:"Clear Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(K,{onClick:L,disabled:!l.trim()||C.isPending,children:[C.isPending?e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(An,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})]})})}function vlt({open:t,onOpenChange:s,portal:r,dealName:n}){const a=yO(),{isGmailConnected:o,gmailEmail:l}=jp(),[i,d]=S.useState(r.client_name||""),[u,p]=S.useState(r.client_email||""),[x,y]=S.useState(!1),[_,b]=S.useState(!1),N=a1(r.slug),w=i.split(" ")[0]||"there",k=`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!`,E=()=>{navigator.clipboard.writeText(N),b(!0),setTimeout(()=>b(!1),2e3),me.success("Portal link copied!")},L=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:k,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)}},I=()=>{const O=encodeURIComponent(k),V=encodeURIComponent(C);window.open(`mailto:${u}?subject=${O}&body=${V}`,"_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(xe,{className:"text-sm font-medium",children:"Client Name"}),e.jsx(De,{value:i,onChange:O=>d(O.target.value),className:"mt-1",placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Client Email"}),e.jsx(De,{type:"email",value:u,onChange:O=>p(O.target.value),className:"mt-1",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(xe,{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:E,className:"shrink-0",children:_?e.jsx(Jn,{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:L,disabled:x||!u.trim(),className:"w-full",children:[x?e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Send via Gmail (",l,")"]}):e.jsxs(K,{onClick:I,disabled:!u.trim(),className:"w-full",variant:"outline",children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(K,{variant:"ghost",onClick:E,className:"w-full text-muted-foreground",children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function CNs({deal:t}){const{isAdmin:s,user:r}=Fs(),{data:n,isLoading:a}=_bs(t.id),o=OSe(),l=yO(),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[x,y]=S.useState(!1),[_,b]=S.useState(!1),N=`portal-management-ui:${t.id}`;if(S.useEffect(()=>{const O=sessionStorage.getItem(N);if(O)try{const V=JSON.parse(O);p(!!V.settingsOpen),y(!!V.composerOpen),b(!!V.inviteOpen)}catch{sessionStorage.removeItem(N)}},[N]),S.useEffect(()=>{u||x||_?sessionStorage.setItem(N,JSON.stringify({settingsOpen:u,composerOpen:x,inviteOpen:_})):sessionStorage.removeItem(N)},[u,x,_,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($r,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(_s,{className:"h-3 w-3 animate-spin ml-auto"})]})});const w=async()=>{var O,V;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:((V=t.contact)==null?void 0:V.phone)||void 0}),me.success("Client portal enabled!")}catch{me.error("Failed to create portal")}finally{d(!1)}},k=async O=>{if(n)try{await l.mutateAsync({id:n.id,is_enabled:O}),me.success(O?"Portal enabled":"Portal disabled")}catch{me.error("Failed to update portal")}},C=()=>{if(!n)return;const O=a1(n.slug);navigator.clipboard.writeText(O),me.success("Portal link copied!")},E=()=>{if(!n)return;const O=a1(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($r,{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(_s,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx($r,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const L=a1(n.slug),I=(r==null?void 0:r.id)||"";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($r,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(Qe,{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(Er,{checked:n.is_enabled,onCheckedChange:k})]}),e.jsxs("div",{className:"space-y-1.5 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Visibility:"}),e.jsx(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:n.visibility==="private"?"Private":"Public"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Onboarding:"}),e.jsx("span",{className:"text-foreground",children:n.require_onboarding?"Required":"Disabled"})]}),n.client_name&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Client:"}),e.jsx("span",{className:"text-foreground",children:n.client_name})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-md p-2 mb-3",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:L})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick: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:E,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(An,{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(AM,{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(ko,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),e.jsx(glt,{open:u,onOpenChange:p,portal:n,dealOwnerId:I}),e.jsx(ylt,{open:x,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 MNs=["Client","Co-Buyer","Co-Seller","Spouse","Lender","Title Company","Inspector","Appraiser","Attorney","Contractor","Other"];function TNs(t){return gt({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 ANs(){const t=Jt();return It({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 ENs(){const t=Jt();return It({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 PNs({dealId:t,primaryContactId:s}){const r=_r(),{data:n,isLoading:a}=TNs(t),{data:o}=qh(),l=ANs(),i=ENs(),[d,u]=S.useState(!1),[p,x]=S.useState(""),[y,_]=S.useState("Client"),b=new Set((n==null?void 0:n.map(E=>E.contact_id))||[]);s&&b.add(s);const N=o==null?void 0:o.filter(E=>{var I,O,V;if(b.has(E.id))return!1;if(!p.trim())return!0;const L=p.toLowerCase();return((I=E.first_name)==null?void 0:I.toLowerCase().includes(L))||((O=E.last_name)==null?void 0:O.toLowerCase().includes(L))||((V=E.email)==null?void 0:V.toLowerCase().includes(L))}).slice(0,8),w=E=>{l.mutate({dealId:t,contactId:E,role:y}),u(!1),x("")},k=E=>{i.mutate({id:E,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(lr,{className:"h-4 w-4"}),"Additional Contacts"]})}),e.jsxs(xo,{open:d,onOpenChange:u,children:[e.jsx(go,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"w-full text-muted-foreground",children:[e.jsx(Us,{className:"h-3.5 w-3.5 mr-1"}),"Link a contact (lender, spouse, vendor...)"]})}),e.jsx(lo,{className:"w-80 p-3",align:"start",children:e.jsx(e9e,{search:p,setSearch:x,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(lr,{className:"h-4 w-4"}),"Linked Contacts",n&&n.length>0&&e.jsx(Qe,{variant:"secondary",className:"text-[10px] px-1.5",children:n.length})]}),e.jsxs(xo,{open:d,onOpenChange:u,children:[e.jsx(go,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx(Us,{className:"h-3.5 w-3.5"})})}),e.jsx(lo,{className:"w-80 p-3",align:"end",children:e.jsx(e9e,{search:p,setSearch:x,selectedRole:y,setSelectedRole:_,filteredContacts:N,onAdd:w})})]})]}),e.jsx("div",{className:"space-y-1.5",children:n==null?void 0:n.map(E=>{var L,I,O,V,q,$,U,se;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:[(I=(L=E.contact)==null?void 0:L.first_name)==null?void 0:I[0],(V=(O=E.contact)==null?void 0:O.last_name)==null?void 0:V[0]]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("button",{onClick:()=>r(`/mission-control/contacts/${E.contact_id}`),className:"text-sm font-medium hover:underline text-primary truncate block",children:[(q=E.contact)==null?void 0:q.first_name," ",($=E.contact)==null?void 0:$.last_name]})}),e.jsx(Qe,{variant:"outline",className:`text-[10px] px-1.5 py-0 shrink-0 ${C[E.role]||C.Other}`,children:E.role}),e.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[((U=E.contact)==null?void 0:U.phone)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`tel:${E.contact.phone}`,children:e.jsx(Pn,{className:"h-3 w-3"})})}),((se=E.contact)==null?void 0:se.email)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`mailto:${E.contact.email}`,children:e.jsx(rr,{className:"h-3 w-3"})})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>k(E.id),children:e.jsx(gr,{className:"h-3 w-3"})})]})]},E.id)})})]})}function e9e({search:t,setSearch:s,selectedRole:r,setSelectedRole:n,filteredContacts:a,onAdd:o}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs(Bs,{value:r,onValueChange:n,children:[e.jsx(Rs,{className:"h-8 text-sm",children:e.jsx(qs,{placeholder:"Role"})}),e.jsx(Os,{children:MNs.map(l=>e.jsx(vt,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{value:t,onChange:l=>s(l.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(ui,{className:"max-h-40",children:a&&a.length>0?e.jsx("div",{className:"space-y-0.5",children:a.map(l=>e.jsxs("button",{onClick:()=>o(l.id),className:"w-full text-left px-2 py-1.5 rounded hover:bg-accent transition-colors",children:[e.jsxs("div",{className:"text-sm font-medium truncate",children:[l.first_name," ",l.last_name]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[l.phone,l.email].filter(Boolean).join(" · ")||"No contact info"})]},l.id))}):e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:t?"No contacts found":"Type to search"})})]})}const INs={buyer:{label:"Buyer",color:"bg-blue-500/10 text-blue-600 border-blue-200"},seller:{label:"Seller",color:"bg-emerald-500/10 text-emerald-600 border-emerald-200"},dual:{label:"Dual",color:"bg-purple-500/10 text-purple-600 border-purple-200"},referral:{label:"Referral",color:"bg-orange-500/10 text-orange-600 border-orange-200"},lease:{label:"Lease",color:"bg-cyan-500/10 text-cyan-600 border-cyan-200"}},LNs={note:ki,call:Pn,email:rr,meeting:on,stage_change:Kr,task_completed:Qn,document:Mn,system:ln};function DNs({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var Fe,Le;const{data:l,isLoading:i}=Nws((t==null?void 0:t.id)||""),{data:d,isLoading:u}=Sws((t==null?void 0:t.id)||""),p=kws(),x=Mws(),y=Cws(),_=jws(),{data:b,isLoading:N}=yNs((t==null?void 0:t.id)||""),w=vNs(),k=_Ns(),C=bNs(),E=S.useRef(null),[L,I]=S.useState(""),[O,V]=S.useState(""),[q,$]=S.useState(!1),[U,se]=S.useState(!1);if(!t)return null;const Y=INs[t.deal_type],J=(()=>{var ze;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const Ne=((ze=t.listing)==null?void 0:ze.created_at)||t.listing_date;if(!Ne)return null;const qe=t.contract_date?ml(t.contract_date):new Date;return Bg(qe,ml(Ne))})(),X=Ne=>Ne?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Ne):"-",ce=async()=>{if(L.trim())try{await p.mutateAsync({deal_id:t.id,activity_type:"note",title:"Note added",description:L}),I(""),me.success("Note added")}catch{me.error("Failed to add note")}},ie=async()=>{if(O.trim())try{await x.mutateAsync({deal_id:t.id,title:O,sort_order:((d==null?void 0:d.length)||0)+1}),V(""),me.success("Task added")}catch{me.error("Failed to add task")}},ae=async(Ne,qe)=>{try{await y.mutateAsync({id:Ne,is_completed:qe,deal_id:t.id})}catch{me.error("Failed to update task")}},oe=async()=>{try{await _.mutateAsync(t.id),me.success("Deal deleted"),r(!1)}catch{me.error("Failed to delete deal")}},pe=(d==null?void 0:d.filter(Ne=>Ne.is_completed).length)||0,_e=(d==null?void 0:d.length)||0,he=(b==null?void 0:b.length)||0,we=Ne=>Ne<1024?`${Ne} B`:Ne<1024*1024?`${(Ne/1024).toFixed(1)} KB`:`${(Ne/(1024*1024)).toFixed(1)} MB`,je=Ne=>Ne?Ne.startsWith("image/")?Wo:Ne.includes("pdf")?fn:bM:bM,Ue=async Ne=>{const qe=Ne.target.files;if(!(!qe||!t)){se(!0);try{for(const ze of Array.from(qe)){if(ze.size>20*1024*1024){me.error(`${ze.name} exceeds 20MB limit`);continue}await w.mutateAsync({dealId:t.id,file:ze})}me.success("File(s) uploaded")}catch{me.error("Failed to upload file")}finally{se(!1),E.current&&(E.current.value="")}}},Te=async(Ne,qe)=>{if(t)try{await k.mutateAsync({fileId:Ne,storagePath:qe,dealId:t.id}),me.success("File deleted")}catch{me.error("Failed to delete file")}},Me=async(Ne,qe)=>{try{const ze=await wNs(Ne),ve=document.createElement("a");ve.href=ze,ve.download=qe,ve.target="_blank",document.body.appendChild(ve),ve.click(),document.body.removeChild(ve)}catch{me.error("Failed to download file")}};return e.jsxs(e.Fragment,{children:[e.jsx(GA,{open:s,onOpenChange:r,children:e.jsxs(wC,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(WA,{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(Qe,{variant:"outline",className:Rt("text-xs",Y.color),children:Y.label}),e.jsxs(Qe,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx(KA,{className:"text-xl",children:t.deal_name}),e.jsx("div",{className:"mt-2",children:e.jsx(gNs,{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(gr,{className:"h-4 w-4"})})]})]})}),e.jsx(ui,{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:[(Fe=t.contact.first_name)==null?void 0:Fe[0],(Le=t.contact.last_name)==null?void 0:Le[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(Pn,{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(rr,{className:"h-4 w-4"})})})]})]}),e.jsx(PNs,{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:X(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:X(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?` (${X(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:X(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:X(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(Vi,{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(Qn,{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(on,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",ps(ml(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(yc,{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(CNs,{deal:t}),e.jsxs(ia,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(ea,{className:"w-full grid grid-cols-3",children:[e.jsxs(ls,{value:"tasks",className:"gap-1",children:[e.jsx(Qn,{className:"h-4 w-4"}),"Tasks ",_e>0&&`(${pe}/${_e})`]}),e.jsxs(ls,{value:"files",className:"gap-1",children:[e.jsx(lS,{className:"h-4 w-4"}),"Files ",he>0&&`(${he})`]}),e.jsxs(ls,{value:"activity",className:"gap-1",children:[e.jsx(ln,{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(De,{placeholder:"Add a new task...",value:O,onChange:Ne=>V(Ne.target.value),onKeyDown:Ne=>Ne.key==="Enter"&&ie()}),e.jsx(K,{onClick:ie,disabled:!O.trim(),children:e.jsx(Us,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[d==null?void 0:d.map(Ne=>e.jsxs("div",{className:Rt("flex items-center gap-3 p-3 rounded-lg border transition-colors",Ne.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx(Ki,{checked:Ne.is_completed,onCheckedChange:qe=>ae(Ne.id,!!qe)}),e.jsx("span",{className:Rt("flex-1 text-sm",Ne.is_completed&&"line-through text-muted-foreground"),children:Ne.title}),Ne.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ps(new Date(Ne.due_date),"MMM d")})]},Ne.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:E,className:"hidden",multiple:!0,onChange:Ue,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 Ne;return(Ne=E.current)==null?void 0:Ne.click()},disabled:U,children:[U?e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx($a,{className:"h-4 w-4 mr-2"}),U?"Uploading...":"Upload Files"]}),e.jsxs("div",{className:"space-y-2",children:[b==null?void 0:b.map(Ne=>{const qe=je(Ne.file_type);return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-background",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center shrink-0",children:e.jsx(qe,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Ne.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[we(Ne.file_size)," · ",ps(new Date(Ne.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(N1,{children:e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${Ne.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>C.mutate({fileId:Ne.id,visible:!Ne.visible_on_portal,dealId:t.id}),children:Ne.visible_on_portal?e.jsx(wn,{className:"h-4 w-4"}):e.jsx(mp,{className:"h-4 w-4"})})}),e.jsx(Cl,{side:"top",children:Ne.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Me(Ne.storage_path,Ne.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(Ne.id,Ne.storage_path),children:e.jsx(Sr,{className:"h-4 w-4"})})]})]},Ne.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(vr,{placeholder:"Add a note...",value:L,onChange:Ne=>I(Ne.target.value),rows:2}),e.jsxs(K,{onClick:ce,disabled:!L.trim(),size:"sm",className:"w-full",children:[e.jsx(An,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(Ne=>{const qe=LNs[Ne.activity_type]||ln;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center shrink-0",children:e.jsx(qe,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:Ne.title}),Ne.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:Ne.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:gl(new Date(Ne.created_at),{addSuffix:!0})})]})]},Ne.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(tc,{open:q,onOpenChange:$,children:e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Delete Deal?"}),e.jsxs(Pl,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:oe,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function RNs({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=she(),o=cit(),{data:l}=XA(),{data:i}=jf(),[d,u]=S.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:ps(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});S.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||ps(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")}},x=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(Vi,{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(Ir,{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(xe,{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(De,{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(xe,{htmlFor:"city",children:"City"}),e.jsx(De,{id:"city",value:d.city,onChange:y=>u(_=>({..._,city:y.target.value})),placeholder:"City"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"state",children:"State"}),e.jsx(De,{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(xe,{htmlFor:"zip",children:"Zip"}),e.jsx(De,{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(xe,{children:"Transaction Type *"}),e.jsxs(Bs,{value:d.transaction_type,onValueChange:y=>u(_=>({..._,transaction_type:y})),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"buyer",children:"Buyer"}),e.jsx(vt,{value:"seller",children:"Seller"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{htmlFor:"close_date",className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4 text-muted-foreground"}),"Close Date *"]}),e.jsx(De,{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(xe,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[e.jsx(yc,{className:"h-4 w-4 text-muted-foreground"}),"Sale Price *"]}),e.jsx(De,{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:x(d.sale_price)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[e.jsx(EM,{className:"h-4 w-4 text-muted-foreground"}),"GCI (Commission)"]}),e.jsx(De,{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:x(d.commission_amount)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Lead Source"}),e.jsxs(Bs,{value:d.lead_source_id,onValueChange:y=>u(_=>({..._,lead_source_id:y})),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select source"})}),e.jsx(Os,{children:l==null?void 0:l.map(y=>e.jsx(vt,{value:y.id,children:y.name},y.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Client Type"}),e.jsxs(Bs,{value:d.client_type_id,onValueChange:y=>u(_=>({..._,client_type_id:y})),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select type"})}),e.jsx(Os,{children:i==null?void 0:i.map(y=>e.jsx(vt,{value:y.id,children:y.name},y.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"notes",children:"Notes"}),e.jsx(vr,{id:"notes",value:d.notes,onChange:y=>u(_=>({..._,notes:y.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(En,{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(ei,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const ONs={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"}},t9e={urgent:0,high:1,medium:2,low:3};function FNs({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=S.useState("target_close_date"),[l,i]=S.useState("asc"),d=_=>{a===_?i(b=>b==="asc"?"desc":"asc"):(o(_),i("asc"))},u=S.useMemo(()=>[...t].sort((_,b)=>{var w,k;let N=0;switch(a){case"deal_name":N=_.deal_name.localeCompare(b.deal_name);break;case"stage":{const C=((w=s.find(L=>L.id===_.stage_id))==null?void 0:w.sort_order)||0,E=((k=s.find(L=>L.id===b.stage_id))==null?void 0:k.sort_order)||0;N=C-E;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?ml(_.target_close_date).getTime():1/0,E=b.target_close_date?ml(b.target_close_date).getTime():1/0;N=C-E;break}case"priority":N=t9e[_.priority]-t9e[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(_):"—",x=_=>_?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(du,{className:"ml-2 h-4 w-4"}):e.jsx(Ph,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:u.map(_=>{x(_.stage_id);const b=ONs[_.deal_type],N=_.target_close_date?Bg(ml(_.target_close_date),new Date):null,w=N!==null&&N<0,k=N!==null&&N<=7&&N>=0;return e.jsxs(Ms,{className:Rt("cursor-pointer hover:bg-muted/50 transition-colors",w&&"bg-red-50/50"),onClick:()=>r(_),children:[e.jsx(ut,{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(ut,{onClick:C=>C.stopPropagation(),children:e.jsx(flt,{stages:s,currentStageId:_.stage_id||"",onStageSelect:(C,E)=>n(_.id,C,E)})}),e.jsx(ut,{children:e.jsx(Qe,{variant:"outline",className:Rt("text-xs",b.color),children:b.label})}),e.jsx(ut,{children:e.jsx("span",{className:"font-medium",children:p(_.expected_price)})}),e.jsx(ut,{children:e.jsx("span",{className:"text-emerald-600",children:p(_.expected_commission)})}),e.jsx(ut,{children:_.target_close_date?e.jsxs("div",{className:Rt("flex items-center gap-1 text-sm",w&&"text-red-600",k&&!w&&"text-amber-600"),children:[w&&e.jsx(Lo,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:ps(ml(_.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ut,{children:e.jsx(Qe,{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 zNs(){const t=ja();return gt({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 BNs(t){const s=ja();return gt({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 $Ns(){const t=ja(),s=Jt();return It({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 qNs(){const t=Jt();return It({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 UNs(){const t=Jt();return It({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 FCe(){const t=Jt();return It({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 VNs(){const t=Jt();return It({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 HNs(t){const s=ja();return gt({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 GNs(){const t=ja(),s=Jt();return It({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 WNs(){const t=Jt();return It({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 KNs(){const t=ja(),s=Jt();return It({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(x=>x.title)),d=a.filter(x=>!i.has(x.title)).map((x,y)=>({owner_user_id:t,deal_id:r,stage_id:n,title:x.title,description:x.description,priority:x.priority,due_date:x.default_due_offset_days?new Date(Date.now()+x.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 ZNs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function YNs({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:d,isLoading:u}=BNs(t?r:void 0),p=VNs(),x=KNs(),[y,_]=S.useState(new Set),[b,N]=S.useState(!1),w=(d||[]).filter(L=>L.status!=="done");S.useEffect(()=>{w.length>0&&_(new Set(w.map(L=>L.id)))},[d]);const k=L=>{_(I=>{const O=new Set(I);return O.has(L)?O.delete(L):O.add(L),O})},C=async()=>{N(!0);try{const L=Array.from(y);L.length>0&&await p.mutateAsync(L),await i(),await x.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(L){console.error("Stage move failed:",L),me.error((L==null?void 0:L.message)||"Failed to move deal. Please try again.")}finally{N(!1)}},E=async()=>{N(!0);try{await i(),await x.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(L){console.error("Stage move (skip) failed:",L),me.error((L==null?void 0:L.message)||"Failed to move deal. Please try again.")}finally{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(Ir,{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(Qe,{variant:"outline",className:"text-sm",children:a}),e.jsx(ei,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Qe,{className:"text-sm bg-primary",children:o})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(_s,{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(ui,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:w.map(L=>e.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-muted/50 cursor-pointer transition-colors",children:[e.jsx(Ki,{checked:y.has(L.id),onCheckedChange:()=>k(L.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[ZNs[L.priority]," ",L.title]}),L.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full",style:{backgroundColor:L.stage.color+"20",color:L.stage.color},children:L.stage.name})]},L.id))})}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>{y.size===w.length?_(new Set):_(new Set(w.map(L=>L.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:E,disabled:b,children:"Skip"}),e.jsxs(K,{size:"sm",onClick:C,disabled:b,children:[b&&e.jsx(_s,{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(Qn,{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(_s,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function XNs(){const t=ja();return gt({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 QNs({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const d=OSe(),u=yO(),p=bbs(),x=wbs(),[y,_]=S.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 I=>{if(n)try{await u.mutateAsync({id:n.id,is_enabled:I}),me.success(I?"Portal enabled":"Portal disabled")}catch{me.error("Failed to update portal")}},k=()=>{n&&(navigator.clipboard.writeText(a1(n.slug)),me.success("Link copied!"))},C=()=>{n&&window.open(a1(n.slug),"_blank")},E=async()=>{if(n)try{await p.mutateAsync(n.id),me.success("Portal archived")}catch{me.error("Failed to archive portal")}},L=async()=>{if(n)try{await x.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(Qe,{variant:"outline",className:"text-[10px] bg-muted text-muted-foreground",children:"Archived"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:L,className:"text-xs gap-1",children:[e.jsx(JI,{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(gr,{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(Qe,{variant:"outline",className:n.is_enabled?"text-[10px] bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-[10px] bg-muted text-muted-foreground",children:n.is_enabled?"Active":"Disabled"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:k,title:"Copy link",children:e.jsx(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(An,{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(AM,{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(ko,{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(ix,{className:"h-3.5 w-3.5"})})}),e.jsx(jd,{align:"end",children:e.jsxs(va,{onClick:E,children:[e.jsx(pM,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx(Er,{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(_s,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx($r,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function JNs(){const{data:t,isLoading:s}=Mme(),{data:r,isLoading:n}=XNs(),[a,o]=S.useState(""),[l,i]=S.useState("all"),d=jbs(),[u,p]=S.useState(null),[x,y]=S.useState(null),[_,b]=S.useState(null),[N,w]=S.useState(null),k=ja(),C=s||n,E=new Map;r==null||r.forEach(U=>E.set(U.deal_id,U));const I=[...(t||[]).filter(U=>{var ce,ie,ae,oe,pe;const se=E.get(U.id),Y=a.toLowerCase(),J=!Y||U.deal_name.toLowerCase().includes(Y)||((ie=(ce=U.contact)==null?void 0:ce.first_name)==null?void 0:ie.toLowerCase().includes(Y))||((oe=(ae=U.contact)==null?void 0:ae.last_name)==null?void 0:oe.toLowerCase().includes(Y))||((pe=se==null?void 0:se.client_name)==null?void 0:pe.toLowerCase().includes(Y));let X=!0;return l==="active"?X=!!(se!=null&&se.is_enabled)&&!(se!=null&&se.archived_at):l==="disabled"?X=!!se&&!se.is_enabled&&!se.archived_at:l==="archived"?X=!!(se!=null&&se.archived_at):l==="none"?X=!se:l==="all"&&(X=!(se!=null&&se.archived_at)||!se),J&&X})].sort((U,se)=>{const Y=E.get(U.id),J=E.get(se.id);if(Y!=null&&Y.archived_at&&!(J!=null&&J.archived_at))return 1;if(!(Y!=null&&Y.archived_at)&&(J!=null&&J.archived_at)||Y&&!J)return-1;if(!Y&&J)return 1;if(Y&&J){if(Y.is_enabled&&!J.is_enabled)return-1;if(!Y.is_enabled&&J.is_enabled)return 1}return 0}),O=(r==null?void 0:r.filter(U=>!U.archived_at).length)||0,V=(r==null?void 0:r.filter(U=>U.is_enabled&&!U.archived_at).length)||0,q=(r==null?void 0:r.filter(U=>U.archived_at).length)||0,$=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(_s,{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($r,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-medium",children:[O," Portals"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:[V," active · ",O-V," 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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search deals or clients...",value:a,onChange:U=>o(U.target.value),className:"pl-9 pr-8"}),a&&e.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(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(U=>e.jsx(K,{variant:l===U?"secondary":"ghost",size:"sm",onClick:()=>i(U),className:"text-xs px-3 capitalize",children:U==="none"?"No Portal":U},U))})]}),e.jsx(ui,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[I.map(U=>{const se=E.get(U.id)||null,Y=U.contact?`${U.contact.first_name||""} ${U.contact.last_name||""}`.trim():"";return e.jsx(QNs,{dealId:U.id,dealName:U.deal_name,contactName:Y,portal:se,onSettingsOpen:p,onComposerOpen:J=>y(J),onInviteOpen:(J,X)=>b({portal:J,dealName:X}),onDeleteConfirm:w},U.id)}),I.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 bg-muted rounded-full flex items-center justify-center",children:e.jsx($r,{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(glt,{open:!!u,onOpenChange:U=>!U&&p(null),portal:u,dealOwnerId:k||""}),x&&e.jsx(ylt,{open:!!x,onOpenChange:U=>!U&&y(null),portalId:x.id,portalSlug:x.slug,notifyClient:x.notify_client}),_&&e.jsx(vlt,{open:!!_,onOpenChange:U=>!U&&b(null),portal:_.portal,dealName:_.dealName}),e.jsx(tc,{open:!!N,onOpenChange:U=>!U&&w(null),children:e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Permanently delete this portal?"}),e.jsx(Pl,{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(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:$,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class eks extends S.Component{constructor(s){super(s),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,r){console.error("DealPipeline error:",s,r)}render(){return this.state.hasError?e.jsx(Es,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center h-[60vh] gap-4 text-center px-4",children:[e.jsx("div",{className:"w-16 h-16 bg-destructive/10 rounded-full flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"⚠️"})}),e.jsx("h2",{className:"text-xl font-semibold",children:"Something went wrong"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"There was an error in the deal pipeline. Click below to try again."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>this.setState({hasError:!1,error:null}),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md text-sm font-medium hover:bg-primary/90",children:"Try Again"}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 border border-border rounded-md text-sm font-medium hover:bg-muted",children:"Refresh Page"})]})]})}):this.props.children}}const gI="deal-pipeline-detail-sheet";function tks(){var kr;const t=vE(),{data:s,isLoading:r}=Cme(),{data:n,isLoading:a,refetch:o}=Mme(),{data:l,isLoading:i}=Tws(),d=oit(),u=wws(),[p,x]=S.useState("board"),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.useState(null),[C,E]=S.useState(null),[L,I]=S.useState(null),[O,V]=S.useState(null),[q,$]=S.useState(!1),[U,se]=S.useState(null),[Y,J]=S.useState(""),[X,ce]=S.useState("all"),[ie,ae]=S.useState("all"),{data:oe}=lNs(),[pe,_e]=S.useState(!1),[he,we]=S.useState(!1),[je,Ue]=S.useState(new Set),Te=S.useRef(!1),[Me,Fe]=S.useState(null),{data:Le}=Px(),{isTeamLeader:Ne,teamMembers:qe}=iNs(),ze=S.useMemo(()=>Array.from(je),[je]),{data:ve}=oNs(ze),dt=S.useMemo(()=>{const Xs=new Map;return qe.forEach(ir=>Xs.set(ir.id,{name:ir.name,avatar_url:ir.avatar_url,color:ir.color})),Xs},[qe]),fe=S.useCallback(Xs=>Xs.owner_user_id&&dt.get(Xs.owner_user_id)||null,[dt]),Ve=S.useCallback(Xs=>{Ue(ir=>{const Or=new Set(ir);return Or.has(Xs)?Or.delete(Xs):Or.add(Xs),Or})},[]);S.useEffect(()=>{!r&&s&&s.length===0&&d.mutate()},[r,s]);const[Je,at]=Nc(),Ae=S.useRef(!1);S.useEffect(()=>{const Xs=Je.get("deal");if(Xs&&n&&n.length>0&&!Ae.current){const ir=n.find(Or=>Or.id===Xs);ir&&(Ae.current=!0,k(ir),N(!0),Je.delete("deal"),at(Je,{replace:!0}))}},[n,Je]);const Ye=S.useMemo(()=>{if(!ve||!s)return[];const Xs=new Map(s.map(ir=>[ir.name,ir.id]));return ve.map(ir=>{const Or=ir._stage_name&&Xs.get(ir._stage_name)||null;return{...ir,stage_id:Or||ir.stage_id}})},[ve,s]),We=S.useMemo(()=>[...n||[],...Ye],[n,Ye]);S.useEffect(()=>{if(Te.current||We.length===0)return;Te.current=!0;const Xs=sessionStorage.getItem(gI);if(Xs)try{const ir=JSON.parse(Xs);if(!ir.open||!ir.dealId)return;const Or=We.find(Vn=>Vn.id===ir.dealId);Or&&(k(Or),N(!0))}catch{sessionStorage.removeItem(gI)}},[We]),S.useEffect(()=>{b&&(w!=null&&w.id)?sessionStorage.setItem(gI,JSON.stringify({dealId:w.id,open:!0})):sessionStorage.removeItem(gI)},[b,w==null?void 0:w.id]);const ot=(oe==null?void 0:oe.byDeal)||{},Ge=(oe==null?void 0:oe.unique)||[],et=We.filter(Xs=>{var tr,cr,cn,rn,jn,ni;const ir=Y.toLowerCase(),Or=ot[Xs.id]||[],Vn=!ir||Xs.deal_name.toLowerCase().includes(ir)||((cr=(tr=Xs.contact)==null?void 0:tr.first_name)==null?void 0:cr.toLowerCase().includes(ir))||((rn=(cn=Xs.contact)==null?void 0:cn.last_name)==null?void 0:rn.toLowerCase().includes(ir))||((jn=Xs.property_address)==null?void 0:jn.toLowerCase().includes(ir))||((ni=Xs.city)==null?void 0:ni.toLowerCase().includes(ir))||Or.some(rs=>rs.toLowerCase().includes(ir)),Qr=X==="all"||Xs.deal_type===X,Gr=ie==="all"||Or.includes(ie);return Vn&&Qr&&Gr}),ht=S.useMemo(()=>{if(!s)return l||null;const Xs=new Set(s.filter(tr=>tr.is_won_stage).map(tr=>tr.id)),ir=new Set(s.filter(tr=>tr.is_lost_stage).map(tr=>tr.id)),Or=We.filter(tr=>tr.stage_id&&!Xs.has(tr.stage_id)&&!ir.has(tr.stage_id)),Vn=We.filter(tr=>tr.stage_id&&Xs.has(tr.stage_id)),Qr=new Date().getFullYear(),Gr=Vn.filter(tr=>tr.actual_close_date?new Date(tr.actual_close_date).getFullYear()===Qr:!0);return{totalDeals:We.length,activeDeals:Or.length,wonDeals:Vn.length,pipelineValue:Or.reduce((tr,cr)=>tr+(cr.expected_price||0),0),expectedCommission:Or.reduce((tr,cr)=>tr+(cr.expected_commission||0),0),expectedNetToAgent:Or.reduce((tr,cr)=>tr+(cx(cr)||0),0),wonValue:Vn.reduce((tr,cr)=>tr+(cr.expected_price||0),0),weightedGCI:Or.reduce((tr,cr)=>tr+(cr.expected_commission||0)*((cr.probability??50)/100),0),weightedNet:Or.reduce((tr,cr)=>tr+(cx(cr)||0)*((cr.probability??50)/100),0),ytdWonDeals:Gr.length,ytdWonGCI:Gr.reduce((tr,cr)=>tr+(cr.expected_commission||0),0),ytdWonNet:Gr.reduce((tr,cr)=>tr+(cx(cr)||0),0),projectedAnnualNet:Gr.reduce((tr,cr)=>tr+(cx(cr)||0),0)+Or.reduce((tr,cr)=>tr+(cx(cr)||0)*((cr.probability??50)/100),0)}},[We,s,l]),xt=Xs=>{k(Xs),N(!0)},Ke=Xs=>{E(Xs||null),k(null),_(!0)},Ze=Xs=>{k(Xs),N(!1),_(!0)},Et=Xs=>{N(Xs),Xs||sessionStorage.removeItem(gI)},$t=(Xs,ir)=>{I(Xs)},Yt=(Xs,ir)=>{Xs.preventDefault(),Xs.dataTransfer.dropEffect="move",V(ir)},Ps=async(Xs,ir)=>{if(Xs.preventDefault(),V(null),!L)return;const Or=n==null?void 0:n.find(Gr=>Gr.id===L),Vn=s==null?void 0:s.find(Gr=>Gr.id===ir),Qr=s==null?void 0:s.find(Gr=>Gr.id===(Or==null?void 0:Or.stage_id));if(!Or||!Vn||Or.stage_id===ir){I(null);return}Fe({dealId:L,dealName:Or.deal_name,fromStageName:(Qr==null?void 0:Qr.name)||"Unknown",toStageName:Vn.name,toStageId:ir,isWonStage:Vn.is_won_stage,deal:Or}),I(null)},zs=async()=>{if(!Me)return;const{dealId:Xs,toStageId:ir,toStageName:Or,isWonStage:Vn,deal:Qr}=Me;if(await u.mutateAsync({dealId:Xs,stageId:ir,stageName:Or}),me.success(`Moved to ${Or}`),Vn&&!Qr.scorecard_transaction_id){const Gr={...Qr,stage_id:ir};se(Gr),$(!0)}},Zs=S.useCallback(async(Xs,ir,Or)=>{const Vn=n==null?void 0:n.find(tr=>tr.id===Xs),Qr=s==null?void 0:s.find(tr=>tr.id===ir),Gr=s==null?void 0:s.find(tr=>tr.id===(Vn==null?void 0:Vn.stage_id));!Vn||!Qr||Vn.stage_id===ir||Fe({dealId:Xs,dealName:Vn.deal_name,fromStageName:(Gr==null?void 0:Gr.name)||"Unknown",toStageName:Or,toStageId:ir,isWonStage:Qr.is_won_stage,deal:Vn})},[n,s]),Dr=Xs=>et.filter(ir=>ir.stage_id===Xs),zt=r||a,$s=t?"list":p;return e.jsxs(Es,{children:[e.jsxs("div",{className:"flex flex-col h-[calc(100vh-4rem)]",children:[e.jsxs("div",{className:"shrink-0 p-4 md:p-6 pb-0 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Deal Pipeline"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Track and manage your active deals"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>o(),className:"shrink-0",children:e.jsx(oo,{className:"h-4 w-4"})}),!t&&e.jsx(N1,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:e.jsxs(K,{variant:p==="board"?"secondary":"ghost",size:"sm",onClick:()=>x("board"),className:"px-3 gap-1.5",children:[e.jsx(fp,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(Cl,{children:"Kanban board view"})]}),e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:e.jsxs(K,{variant:p==="list"?"secondary":"ghost",size:"sm",onClick:()=>x("list"),className:"px-3 gap-1.5",children:[e.jsx(Dh,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(Cl,{children:"Grouped list view"})]}),e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:e.jsxs(K,{variant:p==="table"?"secondary":"ghost",size:"sm",onClick:()=>x("table"),className:"px-3 gap-1.5",children:[e.jsx(IM,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(Cl,{children:"Sortable table view"})]}),e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:e.jsxs(K,{variant:p==="portals"?"secondary":"ghost",size:"sm",onClick:()=>x("portals"),className:"px-3 gap-1.5",children:[e.jsx($r,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(Cl,{children:"Client portal management"})]})]})}),Le&&!Ne&&e.jsxs(K,{variant:"outline",onClick:()=>_e(!0),children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(K,{onClick:()=>Ke(),children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),$s!=="portals"&&e.jsx(hNs,{stats:ht,isLoading:i}),$s!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search deals, contacts, addresses, tags...",value:Y,onChange:Xs=>J(Xs.target.value),className:"pl-9 pr-8"}),Y&&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(Bs,{value:X,onValueChange:ce,children:[e.jsx(Rs,{className:"w-[140px]",children:e.jsx(qs,{placeholder:"All Types"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Types"}),e.jsx(vt,{value:"buyer",children:"Buyer"}),e.jsx(vt,{value:"seller",children:"Seller"}),e.jsx(vt,{value:"dual",children:"Dual"}),e.jsx(vt,{value:"referral",children:"Referral"}),e.jsx(vt,{value:"lease",children:"Lease"})]})]}),e.jsxs(Bs,{value:ie,onValueChange:ae,children:[e.jsxs(Rs,{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(Os,{className:"max-h-[300px]",children:[e.jsx(vt,{value:"all",children:"All Tags"}),Ge.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No tags yet"}),Ge.map(Xs=>e.jsx(vt,{value:Xs,children:Xs},Xs))]})]}),ie!=="all"&&e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(hh,{className:"h-3 w-3"}),ie,e.jsx("button",{onClick:()=>ae("all"),className:"ml-1 hover:text-foreground","aria-label":"Clear tag filter",children:e.jsx(Sr,{className:"h-3 w-3"})})]}),(Y||X!=="all"||ie!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[et.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[Ne&&!t&&qe.length>0&&e.jsx(aNs,{members:qe,enabledMembers:je,onToggleMember:Ve,isOpen:he,onToggleOpen:()=>we(Xs=>!Xs)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:zt?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(Xs=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(Ns,{className:"h-full rounded-xl"})},Xs))}):$s==="board"?e.jsxs(ui,{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(Xs=>e.jsx(uNs,{stage:Xs,deals:Dr(Xs.id),onDealClick:xt,onAddDeal:Ke,onDragStart:$t,onDragOver:Yt,onDrop:Ps,isDragOver:O===Xs.id,isWonStage:Xs.is_won_stage,getOwnerInfo:fe},Xs.id))}),e.jsx(Due,{orientation:"horizontal"})]}):$s==="table"?e.jsx(ui,{className:"h-full",children:e.jsx(FNs,{deals:et,stages:s||[],onDealClick:xt,onStageChange:Zs})}):$s==="portals"?e.jsx(JNs,{}):e.jsx(ui,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(Xs=>{const ir=Dr(Xs.id);return ir.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:Xs.color}}),e.jsx("h3",{className:"font-semibold",children:Xs.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",ir.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:ir.map(Or=>e.jsx(xlt,{deal:Or,onClick:()=>xt(Or),stages:s,onStageChange:Zs,showStagePicker:!0,isWonStage:Xs.is_won_stage,ownerInfo:fe(Or)},Or.id))})]},Xs.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(fp,{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(Us,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&et.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(an,{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(xNs,{open:y,onOpenChange:_,deal:w,defaultStageId:C}),e.jsx(DNs,{deal:w,open:b,onOpenChange:Et,onEdit:Ze,isWonStage:w?(kr=s==null?void 0:s.find(Xs=>Xs.id===w.stage_id))==null?void 0:kr.is_won_stage:!1,onAddToScorecard:Xs=>{se(Xs),$(!0),N(!1)}}),e.jsx(RNs,{open:q,onOpenChange:$,deal:U,onComplete:()=>{o(),se(null)}}),Me&&e.jsx(YNs,{open:!!Me,onOpenChange:Xs=>{Xs||Fe(null)},dealId:Me.dealId,dealName:Me.dealName,fromStageName:Me.fromStageName,toStageName:Me.toStageName,toStageId:Me.toStageId,onConfirm:zs}),e.jsx(rNs,{open:pe,onOpenChange:_e})]})}function sks(){return e.jsx(eks,{children:e.jsx(tks,{})})}function _lt({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var J;const o=$Ns(),l=qNs(),{data:i}=Mme(),d=ja(),{data:u}=gt({queryKey:["contacts-for-tasks",d],queryFn:async()=>{if(!d)return[];const{data:X,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 X},enabled:!!d&&t}),[p,x]=S.useState(""),[y,_]=S.useState(""),[b,N]=S.useState("none"),[w,k]=S.useState("none"),[C,E]=S.useState("medium"),[L,I]=S.useState("todo"),[O,V]=S.useState(),[q,$]=S.useState(!1),[U,se]=S.useState(!1);S.useEffect(()=>{r?(x(r.title),_(r.description||""),N(r.deal_id||"none"),k(r.contact_id||"none"),E(r.priority),I(r.status),V(r.due_date?xm(r.due_date):void 0)):(x(""),_(""),N(n||"none"),k("none"),E("medium"),I("todo"),V(void 0))},[r,t,n]);const Y=async()=>{if(!p.trim()){me.error("Task title is required");return}try{const X={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:L,due_date:O?ps(O,"yyyy-MM-dd"):null};r?(await l.mutateAsync({id:r.id,...X}),me.success("Task updated")):(await o.mutateAsync(X),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(xe,{children:"Title *"}),e.jsx(De,{value:p,onChange:X=>x(X.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(vr,{value:y,onChange:X=>_(X.target.value),placeholder:"Optional details...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Priority"}),e.jsxs(Bs,{value:C,onValueChange:X=>E(X),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"low",children:"🟢 Low"}),e.jsx(vt,{value:"medium",children:"🟡 Medium"}),e.jsx(vt,{value:"high",children:"🟠 High"}),e.jsx(vt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Status"}),e.jsxs(Bs,{value:L,onValueChange:X=>I(X),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"todo",children:"To Do"}),e.jsx(vt,{value:"in_progress",children:"In Progress"}),e.jsx(vt,{value:"done",children:"Done"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Due Date"}),e.jsxs(xo,{children:[e.jsx(go,{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(on,{className:"mr-2 h-4 w-4"}),O?ps(O,"PPP"):"Pick a date"]})}),e.jsx(lo,{className:"w-auto p-0",align:"start",children:e.jsx(df,{mode:"single",selected:O,onSelect:V,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Link to Deal"}),e.jsxs(xo,{open:q,onOpenChange:$,children:[e.jsx(go,{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(pa,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),b!=="none"?((J=i==null?void 0:i.find(X=>X.id===b))==null?void 0:J.deal_name)||"Select deal":"No Deal"]}),e.jsx(gx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(lo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search deals..."}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:"No deals found."}),e.jsxs(Ax,{children:[e.jsxs(lp,{value:"no-deal",onSelect:()=>{N("none"),$(!1)},children:[e.jsx(Jn,{className:Rt("mr-2 h-4 w-4",b==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(X=>e.jsxs(lp,{value:X.deal_name,onSelect:()=>{N(X.id),$(!1)},children:[e.jsx(Jn,{className:Rt("mr-2 h-4 w-4",b===X.id?"opacity-100":"opacity-0")}),X.deal_name]},X.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Link to Contact"}),e.jsxs(xo,{open:U,onOpenChange:se,children:[e.jsx(go,{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(Ti,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),w!=="none"?(()=>{const X=u==null?void 0:u.find(ce=>ce.id===w);return X?`${X.first_name} ${X.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(gx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(lo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search contacts..."}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:"No contacts found."}),e.jsxs(Ax,{children:[e.jsxs(lp,{value:"no-contact",onSelect:()=>{k("none"),se(!1)},children:[e.jsx(Jn,{className:Rt("mr-2 h-4 w-4",w==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(X=>e.jsxs(lp,{value:`${X.first_name} ${X.last_name}`,onSelect:()=>{k(X.id),se(!1)},children:[e.jsx(Jn,{className:Rt("mr-2 h-4 w-4",w===X.id?"opacity-100":"opacity-0")}),X.first_name," ",X.last_name]},X.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:Y,disabled:o.isPending||l.isPending,children:r?"Save Changes":"Create Task"})]})]})]})})}const rks={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 nks({tasks:t}){const s=FCe(),r=UNs(),n=_r(),[a,o]=S.useState(null),l=async p=>{const x=p.status==="done"?"todo":"done";try{await s.mutateAsync({id:p.id,status:x})}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(Qn,{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 x=d.get(p.deal.id)||{dealName:p.deal.deal_name,tasks:[]};x.tasks.push(p),d.set(p.deal.id,x)}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(s9e,{task:p,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:x=>n(`/mission-control/pipeline?deal=${x}`)},p.id))]}),Array.from(d.entries()).map(([p,x])=>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(pa,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:x.dealName}),e.jsxs(Qe,{variant:"secondary",className:"ml-auto text-xs",children:[x.tasks.filter(y=>y.status==="done").length,"/",x.tasks.length]}),e.jsx(Sa,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),x.tasks.map(y=>e.jsx(s9e,{task:y,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:_=>n(`/mission-control/pipeline?deal=${_}`)},y.id))]},p)),a&&e.jsx(_lt,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function s9e({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&r0(xm(t.due_date))&&!au(xm(t.due_date)),i=!o&&t.due_date&&au(xm(t.due_date)),d=rks[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(Qn,{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(Ti,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]})]}),e.jsxs(Qe,{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(ln,{className:"h-3 w-3"}),ps(xm(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(gr,{className:"h-3.5 w-3.5 text-destructive"})})]})]})}const aks=[{status:"todo",label:"To Do",icon:sd,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:sp,color:"border-t-blue-500"},{status:"done",label:"Done",icon:Qn,color:"border-t-emerald-500"}],iks={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function oks({tasks:t}){const s=FCe(),r=S.useMemo(()=>{const o={todo:[],in_progress:[],done:[]};return t.forEach(l=>o[l.status].push(l)),o},[t]),n=(o,l)=>{o.dataTransfer.setData("taskId",l)},a=async(o,l)=>{o.preventDefault();const i=o.dataTransfer.getData("taskId");if(!i)return;const d=t.find(u=>u.id===i);if(!(!d||d.status===l))try{await s.mutateAsync({id:i,status:l})}catch{me.error("Failed to move task")}};return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:aks.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(Qe,{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(lks,{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 lks({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&r0(xm(t.due_date))&&!au(xm(t.due_date)),a=!r&&t.due_date&&au(xm(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:iks[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(pa,{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(Ti,{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(ln,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",ps(xm(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 r9e={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function cks({tasks:t}){const[s,r]=S.useState(new Date),n=FCe(),a=pc(s),o=ex(s),l=zh(a),i=Aue(o),d=f4t({start:l,end:i}),u=S.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=S.useMemo(()=>t.filter(y=>!y.due_date),[t]),x=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(m4(s,1)),children:e.jsx(xl,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:ps(s,"MMMM yyyy")}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(Am(s,1)),children:e.jsx(Sa,{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 _=ps(y,"yyyy-MM-dd"),b=u.get(_)||[],N=Pue(y,s),w=au(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:ps(y,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[b.slice(0,3).map(k=>e.jsxs("button",{onClick:()=>x(k),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",k.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[k.status==="done"?e.jsx(Qn,{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:[r9e[k.priority]," ",k.title]})]},k.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:()=>x(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(Qn,{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:[r9e[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 dks={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function uks({open:t,onOpenChange:s,stages:r}){var k;const[n,a]=S.useState(((k=r[0])==null?void 0:k.id)||""),{data:o,isLoading:l}=HNs(n||void 0),i=GNs(),d=WNs(),[u,p]=S.useState(""),[x,y]=S.useState("medium"),[_,b]=S.useState(""),N=async()=>{if(!(!u.trim()||!n))try{await i.mutateAsync({stage_id:n,title:u.trim(),priority:x,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(dL,{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(xe,{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(ui,{className:"max-h-[250px]",children:e.jsxs("div",{className:"space-y-1.5",children:[o==null?void 0:o.map((C,E)=>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:dks[C.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:C.title}),C.default_due_offset_days&&e.jsxs(Qe,{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(gr,{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(xe,{className:"text-xs text-muted-foreground",children:"Add Template Task"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{placeholder:"Task title...",value:u,onChange:C=>p(C.target.value),className:"flex-1",onKeyDown:C=>C.key==="Enter"&&N()}),e.jsxs(Bs,{value:x,onValueChange:C=>y(C),children:[e.jsx(Rs,{className:"w-[100px]",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"low",children:"🟢 Low"}),e.jsx(vt,{value:"medium",children:"🟡 Med"}),e.jsx(vt,{value:"high",children:"🟠 High"}),e.jsx(vt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(xe,{className:"text-xs",children:"Due offset (days from entering stage)"}),e.jsx(De,{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(Us,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function hks(){const{data:t,isLoading:s}=zNs(),{data:r}=Cme(),[n,a]=S.useState("list"),[o,l]=S.useState(""),[i,d]=S.useState("active"),[u,p]=S.useState("all"),[x,y]=S.useState("all"),[_,b]=S.useState(!1),[N,w]=S.useState(!1),k=S.useMemo(()=>{if(!t)return[];const L=new Map;return t.forEach(I=>{I.deal&&L.set(I.deal.id,I.deal.deal_name)}),Array.from(L,([I,O])=>({id:I,name:O}))},[t]),C=S.useMemo(()=>t?t.filter(L=>{var U,se,Y,J;const I=o.toLowerCase(),O=!I||L.title.toLowerCase().includes(I)||((se=(U=L.deal)==null?void 0:U.deal_name)==null?void 0:se.toLowerCase().includes(I))||`${((Y=L.contact)==null?void 0:Y.first_name)||""} ${((J=L.contact)==null?void 0:J.last_name)||""}`.toLowerCase().includes(I),V=i==="all"||i==="active"&&L.status!=="done"||i==="todo"&&L.status==="todo"||i==="in_progress"&&L.status==="in_progress"||i==="done"&&L.status==="done"||i==="overdue"&&L.status!=="done"&&L.due_date&&r0(xm(L.due_date))&&!au(xm(L.due_date)),q=u==="all"||L.priority===u,$=x==="all"||x==="no_deal"&&!L.deal_id||L.deal_id===x;return O&&V&&q&&$}):[],[t,o,i,u,x]),E=S.useMemo(()=>{if(!t)return{total:0,overdue:0,dueToday:0,dueThisWeek:0,completed:0};const L=t.filter(I=>I.status!=="done");return{total:L.length,overdue:L.filter(I=>I.due_date&&r0(xm(I.due_date))&&!au(xm(I.due_date))).length,dueToday:L.filter(I=>I.due_date&&au(xm(I.due_date))).length,dueThisWeek:L.filter(I=>I.due_date&&uCt(xm(I.due_date))).length,completed:t.filter(I=>I.status==="done").length}},[t]);return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-6 max-w-[1600px] mx-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage tasks across deals and contacts"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>w(!0),children:[e.jsx(Eg,{className:"h-4 w-4 mr-1"}),"Templates"]}),e.jsxs(K,{size:"sm",onClick:()=>b(!0),children:[e.jsx(Us,{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(Dh,{className:"h-3.5 w-3.5"}),"Active"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:E.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:E.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(ln,{className:"h-3.5 w-3.5"}),"Due Today"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:E.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:E.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(Qn,{className:"h-3.5 w-3.5"}),"Completed"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:E.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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search tasks...",value:o,onChange:L=>l(L.target.value),className:"pl-9"})]}),e.jsxs(Bs,{value:u,onValueChange:p,children:[e.jsx(Rs,{className:"w-[130px]",children:e.jsx(qs,{placeholder:"Priority"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Priorities"}),e.jsx(vt,{value:"urgent",children:"🔴 Urgent"}),e.jsx(vt,{value:"high",children:"🟠 High"}),e.jsx(vt,{value:"medium",children:"🟡 Medium"}),e.jsx(vt,{value:"low",children:"🟢 Low"})]})]}),e.jsxs(Bs,{value:x,onValueChange:y,children:[e.jsx(Rs,{className:"w-[160px]",children:e.jsx(qs,{placeholder:"Deal"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Deals"}),e.jsx(vt,{value:"no_deal",children:"No Deal"}),k.map(L=>e.jsx(vt,{value:L.id,children:L.name},L.id))]})]}),e.jsxs("div",{className:"flex items-center border rounded-lg p-0.5 ml-auto",children:[e.jsx("button",{onClick:()=>a("list"),className:`p-1.5 rounded-md transition-colors ${n==="list"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(Dh,{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(Ky,{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(nks,{tasks:C}),n==="kanban"&&e.jsx(oks,{tasks:C}),n==="calendar"&&e.jsx(cks,{tasks:C})]}),e.jsx(_lt,{open:_,onOpenChange:b}),e.jsx(uks,{open:N,onOpenChange:w,stages:r||[]})]})})}const Wwe=[{value:"video_intro",label:"Video Intro",icon:Tn,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:bL,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"}],mks=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],pks={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function blt({cardId:t}){const{data:s,isLoading:r}=lkt(t),n=ckt(),a=dkt(),o=ukt(),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,x]=S.useState(null);if(r)return e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ns,{className:"h-16 w-full"}),e.jsx(Ns,{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:pks[d]||{}},{onSuccess:()=>{i(!1),u("")}})},_=C=>{a.mutate({id:C.id,is_visible:!C.is_visible})},b=(C,E)=>{if(!s)return;const L=s.findIndex(V=>V.id===C.id),I=E==="up"?L-1:L+1;if(I<0||I>=s.length)return;const O=s[I];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,E)=>{a.mutate({id:C.id,config:E},{onSuccess:()=>x(null)})},k=C=>Wwe.find(E=>E.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(Us,{className:"h-4 w-4 mr-1"})," Add Block"]})]}):e.jsxs(e.Fragment,{children:[s.map((C,E)=>{const L=k(C.block_type),I=(L==null?void 0:L.icon)||hh;return e.jsx(Pe,{className:C.is_visible?"":"opacity-50",children:e.jsx(Re,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hu,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx(I,{className:"h-4 w-4 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs",children:(L==null?void 0:L.label)||C.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:fks(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:E===0,children:e.jsx(du,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(C,"down"),disabled:E===s.length-1,children:e.jsx(Ph,{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(wn,{className:"h-3 w-3"}):e.jsx(mp,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>x(C),children:"Edit"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>N(C),children:e.jsx(gr,{className:"h-3 w-3"})})]})]})})},C.id)}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>i(!0),children:[e.jsx(Us,{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:Wwe.map(C=>{const E=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(E,{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(En,{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(xks,{block:p,onSave:C=>w(p,C),onClose:()=>x(null)})]})}function fks(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 xks({block:t,onSave:s,onClose:r}){const[n,a]=S.useState(t.config),o=Wwe.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(gks,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx(yks,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(vks,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx(_ks,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(bks,{config:n,onChange:a}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(K,{onClick:()=>s(n),children:"Save"})]})]})})}function gks({config:t,onChange:s,cardId:r}){var _,b;const[n,a]=S.useState(""),[o,l]=S.useState((_=t.video_url)!=null&&_.includes("youtube")||(b=t.video_url)!=null&&b.includes("youtu.be")?"youtube":"library"),{data:i}=gt({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}=gt({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())))||[],x=t.bunny_video_id,y=N=>{var E;const w=(E=N.playback_url)==null?void 0:E.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(ia,{value:o,onValueChange:l,children:[e.jsxs(ea,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search videos...",value:n,onChange:N=>a(N.target.value),className:"pl-9"})]}),e.jsx(ui,{className:"h-[240px]",children:u?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ns,{className:"h-14 w-full"}),e.jsx(Ns,{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 ${x===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 k;w.currentTarget.style.display="none",(k=w.currentTarget.nextElementSibling)==null||k.classList.remove("hidden")}}):null,e.jsx("div",{className:`h-10 w-16 rounded bg-muted flex items-center justify-center flex-shrink-0 ${N.thumbnail_url?"hidden":""}`,children:e.jsx(Tn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:N.title||"Untitled Video"}),x===N.bunny_video_id&&e.jsx(Jn,{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(xe,{children:"YouTube URL"}),e.jsx(De,{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 yks({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(Pe,{children:e.jsxs(Re,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(xe,{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(gr,{className:"h-3 w-3"})})]}),e.jsx(De,{placeholder:"Client name",value:l.name,onChange:d=>n(i,"name",d.target.value)}),e.jsx(De,{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(Us,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function vks({config:t,onChange:s}){const r=t.tags||[],[n,a]=S.useState(""),o=i=>{s({...t,tags:r.includes(i)?r.filter(d=>d!==i):[...r,i]})},l=()=>{n.trim()&&!r.includes(n.trim())&&(s({...t,tags:[...r,n.trim()]}),a(""))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm mb-2 block",children:"Preset Specialties"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:mks.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(xe,{className:"text-sm mb-2 block",children:"Custom Tag"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{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(xe,{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 _ks({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(De,{placeholder:"Button label",value:l.label,onChange:d=>n(i,"label",d.target.value)}),e.jsx(De,{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(gr,{className:"h-3 w-3"})})]},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(Us,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const n9e=[{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 bks({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=n9e.filter(d=>!r.find(u=>u.platform===d.value)),i=d=>{const u=g1e[d],p=n9e.find(x=>x.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(De,{placeholder:`Your ${p.label} profile URL`,value:d.url,onChange:x=>a(u,x.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(gr,{className:"h-3.5 w-3.5"})})]},u)})}),l.length>0&&e.jsxs("div",{children:[e.jsx(xe,{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=g1e[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 wks=Object.defineProperty,Sde=Object.getOwnPropertySymbols,wlt=Object.prototype.hasOwnProperty,jlt=Object.prototype.propertyIsEnumerable,a9e=(t,s,r)=>s in t?wks(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,Kwe=(t,s)=>{for(var r in s||(s={}))wlt.call(s,r)&&a9e(t,r,s[r]);if(Sde)for(var r of Sde(s))jlt.call(s,r)&&a9e(t,r,s[r]);return t},Zwe=(t,s)=>{var r={};for(var n in t)wlt.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Sde)for(var n of Sde(t))s.indexOf(n)<0&&jlt.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var pC;(t=>{const s=class $i{constructor(d,u,p,x){if(this.version=d,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],d<$i.MIN_VERSION||d>$i.MAX_VERSION)throw new RangeError("Version value out of range");if(x<-1||x>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 E=$i.getNumDataCodewords(b,u)*8,L=l.getTotalBits(d,b);if(L<=E){N=L;break}if(b>=x)throw new RangeError("Data too long")}for(const E of[$i.Ecc.MEDIUM,$i.Ecc.QUARTILE,$i.Ecc.HIGH])_&&N<=$i.getNumDataCodewords(b,E)*8&&(u=E);let w=[];for(const E of d){r(E.mode.modeBits,4,w),r(E.numChars,E.mode.numCharCountBits(b),w);for(const L of E.getData())w.push(L)}a(w.length==N);const k=$i.getNumDataCodewords(b,u)*8;a(w.length<=k),r(0,Math.min(4,k-w.length),w),r(0,(8-w.length%8)%8,w),a(w.length%8==0);for(let E=236;w.lengthC[L>>>3]|=E<<7-(L&7)),new $i(b,u,C,y)}getModule(d,u){return 0<=d&&d>>9)*1335;const x=(u<<10|p)^21522;a(x>>>15==0);for(let y=0;y<=5;y++)this.setFunctionModule(8,y,n(x,y));this.setFunctionModule(8,7,n(x,6)),this.setFunctionModule(8,8,n(x,7)),this.setFunctionModule(7,8,n(x,8));for(let y=9;y<15;y++)this.setFunctionModule(14-y,8,n(x,y));for(let y=0;y<8;y++)this.setFunctionModule(this.size-1-y,8,n(x,y));for(let y=8;y<15;y++)this.setFunctionModule(8,this.size-15+y,n(x,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 x=n(u,p),y=this.size-11+p%3,_=Math.floor(p/3);this.setFunctionModule(y,_,x),this.setFunctionModule(_,y,x)}}drawFinderPattern(d,u){for(let p=-4;p<=4;p++)for(let x=-4;x<=4;x++){const y=Math.max(Math.abs(x),Math.abs(p)),_=d+x,b=u+p;0<=_&&_{(E!=N-y||I>=b)&&C.push(L[E])});return a(C.length==_),C}drawCodewords(d){if(d.length!=Math.floor($i.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 x=0;x>>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)*$i.PENALTY_N3),_=this.modules[y][w],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,N)*$i.PENALTY_N3}for(let y=0;y5&&d++):(this.finderPenaltyAddHistory(b,N),_||(d+=this.finderPenaltyCountPatterns(N)*$i.PENALTY_N3),_=this.modules[w][y],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,N)*$i.PENALTY_N3}for(let y=0;y_+(b?1:0),u);const p=this.size*this.size,x=Math.ceil(Math.abs(u*20-p*10)/p)-1;return a(0<=x&&x<=9),d+=x*$i.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 x=this.size-7;p.length$i.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($i.getNumRawDataModules(d)/8)-$i.ECC_CODEWORDS_PER_BLOCK[u.ordinal][d]*$i.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 x=0;x0);for(const x of d){const y=x^p.shift();p.push(0),u.forEach((_,b)=>p[b]^=$i.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 x=7;x>=0;x--)p=p<<1^(p>>>7)*285,p^=(u>>>x&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={}))})(pC||(pC={}));(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={}))})(pC||(pC={}));var oM=pC;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var jks={L:oM.QrCode.Ecc.LOW,M:oM.QrCode.Ecc.MEDIUM,Q:oM.QrCode.Ecc.QUARTILE,H:oM.QrCode.Ecc.HIGH},Nlt=128,klt="L",Slt="#FFFFFF",Clt="#000000",Mlt=!1,Tlt=1,Nks=4,kks=0,Sks=.1;function Alt(t,s=0){const r=[];return t.forEach(function(n,a){let o=null;n.forEach(function(l,i){if(!l&&o!==null){r.push(`M${o+s} ${a+s}h${i-o}v1H${o+s}z`),o=null;return}if(i===n.length-1){if(!l)return;o===null?r.push(`M${i+s},${a+s} h1v1H${i+s}z`):r.push(`M${o+s},${a+s} h${i+1-o}v1H${o+s}z`);return}l&&o===null&&(o=i)})}),r.join("")}function Elt(t,s){return t.slice().map((r,n)=>n=s.y+s.h?r:r.map((a,o)=>o=s.x+s.w?a:!1))}function Cks(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*Sks),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,x=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),k=Math.ceil(d+p-N);y={x:b,y:N,w,h:k}}const _=n.crossOrigin;return{x:u,y:p,h:d,w:i,excavation:y,opacity:x,crossOrigin:_}}function Mks(t,s){return s!=null?Math.max(Math.floor(s),0):t?Nks:kks}function Plt({value:t,level:s,minVersion:r,includeMargin:n,marginSize:a,imageSettings:o,size:l,boostLevel:i}){let d=ft.useMemo(()=>{const b=(Array.isArray(t)?t:[t]).reduce((N,w)=>(N.push(...oM.QrSegment.makeSegments(w)),N),[]);return oM.QrCode.encodeSegments(b,jks[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:u,margin:p,numCells:x,calculatedImageSettings:y}=ft.useMemo(()=>{let _=d.getModules();const b=Mks(n,a),N=_.length+b*2,w=Cks(_,l,b,o);return{cells:_,margin:b,numCells:N,calculatedImageSettings:w}},[d,l,o,n,a]);return{qrcode:d,margin:p,cells:u,numCells:x,calculatedImageSettings:y}}var Tks=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Aks=ft.forwardRef(function(s,r){const n=s,{value:a,size:o=Nlt,level:l=klt,bgColor:i=Slt,fgColor:d=Clt,includeMargin:u=Mlt,minVersion:p=Tlt,boostLevel:x,marginSize:y,imageSettings:_}=n,N=Zwe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:w}=N,k=Zwe(N,["style"]),C=_==null?void 0:_.src,E=ft.useRef(null),L=ft.useRef(null),I=ft.useCallback(X=>{E.current=X,typeof r=="function"?r(X):r&&(r.current=X)},[r]),[O,V]=ft.useState(!1),{margin:q,cells:$,numCells:U,calculatedImageSettings:se}=Plt({value:a,level:l,minVersion:p,boostLevel:x,includeMargin:u,marginSize:y,imageSettings:_,size:o});ft.useEffect(()=>{if(E.current!=null){const X=E.current,ce=X.getContext("2d");if(!ce)return;let ie=$;const ae=L.current,oe=se!=null&&ae!==null&&ae.complete&&ae.naturalHeight!==0&&ae.naturalWidth!==0;oe&&se.excavation!=null&&(ie=Elt($,se.excavation));const pe=window.devicePixelRatio||1;X.height=X.width=o*pe;const _e=o/U*pe;ce.scale(_e,_e),ce.fillStyle=i,ce.fillRect(0,0,U,U),ce.fillStyle=d,Tks?ce.fill(new Path2D(Alt(ie,q))):$.forEach(function(he,we){he.forEach(function(je,Ue){je&&ce.fillRect(Ue+q,we+q,1,1)})}),se&&(ce.globalAlpha=se.opacity),oe&&ce.drawImage(ae,se.x+q,se.y+q,se.w,se.h)}}),ft.useEffect(()=>{V(!1)},[C]);const Y=Kwe({height:o,width:o},w);let J=null;return C!=null&&(J=ft.createElement("img",{src:C,key:C,style:{display:"none"},onLoad:()=>{V(!0)},ref:L,crossOrigin:se==null?void 0:se.crossOrigin})),ft.createElement(ft.Fragment,null,ft.createElement("canvas",Kwe({style:Y,height:o,width:o,ref:I,role:"img"},k)),J)});Aks.displayName="QRCodeCanvas";var CO=ft.forwardRef(function(s,r){const n=s,{value:a,size:o=Nlt,level:l=klt,bgColor:i=Slt,fgColor:d=Clt,includeMargin:u=Mlt,minVersion:p=Tlt,boostLevel:x,title:y,marginSize:_,imageSettings:b}=n,N=Zwe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:w,cells:k,numCells:C,calculatedImageSettings:E}=Plt({value:a,level:l,minVersion:p,boostLevel:x,includeMargin:u,marginSize:_,imageSettings:b,size:o});let L=k,I=null;b!=null&&E!=null&&(E.excavation!=null&&(L=Elt(k,E.excavation)),I=ft.createElement("image",{href:b.src,height:E.h,width:E.w,x:E.x+w,y:E.y+w,preserveAspectRatio:"none",opacity:E.opacity,crossOrigin:E.crossOrigin}));const O=Alt(L,w);return ft.createElement("svg",Kwe({height:o,width:o,viewBox:`0 0 ${C} ${C}`,ref:r,role:"img"},N),!!y&&ft.createElement("title",null,y),ft.createElement("path",{fill:i,d:`M0,0 h${C}v${C}H0z`,shapeRendering:"crispEdges"}),ft.createElement("path",{fill:d,d:O,shapeRendering:"crispEdges"}),I)});CO.displayName="QRCodeSVG";function Eks({slug:t,agentName:s}){const r=S.useRef(null),n=`https://cards.relevelup.com/${t}`,a=S.useCallback(()=>{var x;const o=(x=r.current)==null?void 0:x.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(xe,{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(CO,{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 y0e(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 Pks(){const{user:t}=Fs(),{data:s,isLoading:r}=akt(t==null?void 0:t.id),n=vE(),[a,o]=S.useState(null),l=S.useMemo(()=>a||(s?y0e(s):null),[a,s]);if(r)return e.jsx(Es,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 space-y-4",children:[e.jsx(Ns,{className:"h-8 w-48"}),e.jsx(Ns,{className:"h-32 w-full"}),e.jsx(Ns,{className:"h-32 w-full"})]})});if(!s)return e.jsx(Es,{children:e.jsx(Lks,{userId:t==null?void 0:t.id})});const i=l||y0e(s),d=u=>{o(p=>{const x=p||y0e(s);return typeof u=="function"?u(x):u})};return e.jsx(Es,{children:e.jsxs("div",{className:"flex gap-6 items-start",children:[e.jsxs("div",{className:`${n?"w-full":"flex-1 min-w-0"} max-w-2xl p-4 space-y-6 animate-fade-in`,children:[e.jsx(Dks,{card:s}),e.jsx(zks,{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(oS,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:"Live Preview"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(Iks,{card:s,form:i})})]})})]})})}function Iks({card:t,form:s}){const{data:r}=gt({queryKey:["card-preview-profile",t.user_id],queryFn:async()=>{const{data:a}=await G.from("profiles").select("name, email, phone, avatar_url, brokerage_id").eq("id",t.user_id).single();let o=(a==null?void 0:a.avatar_url)||null;if(!o){const{data:l}=await G.storage.from("avatars").list(`${t.user_id}`);if(l&&l.length>0){const{data:i}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${l[0].name}`);o=`${i.publicUrl}?t=${Date.now()}`}}return{...a,avatar_url:o}}}),n=S.useMemo(()=>({...t,is_published:s.is_published,theme:s.theme,title:s.title||null,positioning_statement:s.positioning_statement||null,bio:s.bio||null,review_snippet:s.review_snippet||null,review_source_url:s.review_source_url||null,booking_url:s.booking_url||null,custom_cta_label:s.custom_cta_label||null,custom_cta_url:t.custom_cta_url,show_photo:s.show_photo,show_bio:s.show_bio,show_video:t.show_video,show_credentials:s.show_credentials,show_social_links:s.show_social_links,show_save_contact:s.show_save_contact,show_leave_review:s.show_leave_review,show_refer_friend:s.show_refer_friend,brokerage_display_name:s.brokerage_display_name||null,brokerage_logo_url:s.brokerage_logo_url||null,brokerage_logo_size:s.brokerage_logo_size,team_name:s.team_name||null,team_logo_url:s.team_logo_url||null,team_logo_size:s.team_logo_size,display_email:s.display_email||null,social_links:t.social_links||[],profile:{name:(r==null?void 0:r.name)||null,email:s.display_email||(r==null?void 0:r.email)||null,phone:(r==null?void 0:r.phone)||null,brokerage_id:(r==null?void 0:r.brokerage_id)||null},brokerage_name:s.brokerage_display_name||null,avatar_url:(r==null?void 0:r.avatar_url)||null}),[t,s,r]);return e.jsx("div",{className:"transform scale-[0.85] origin-top",children:e.jsx(Uje,{card:n})})}function Lks({userId:t}){var d;const[s,r]=S.useState(""),n=mWe(),{data:a}=gt({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:Oh,title:"Lead Capture",desc:"Collect leads automatically"},{icon:Ou,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:Dl,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($r,{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(Pe,{className:"shadow-lg border-2",children:[e.jsxs(Lt,{className:"text-center pb-2",children:[e.jsx(Ot,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(hr,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),e.jsxs(Re,{className:"p-6 pt-2 space-y-5",children:[e.jsxs("div",{children:[e.jsx(xe,{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(De,{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($r,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function Dks({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(Qe,{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 Rks({userId:t}){const s=Jt(),r=S.useRef(null),[n,a]=S.useState(!1),[o,l]=S.useState(""),{data:i,isLoading:d}=gt({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:se}=await G.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let Y=(se==null?void 0:se.avatar_url)||null;if(!Y){const{data:J}=await G.storage.from("avatars").list(`${t}`);if(J&&J.length>0){const{data:X}=G.storage.from("avatars").getPublicUrl(`${t}/${J[0].name}`);Y=`${X.publicUrl}?t=${Date.now()}`,await G.from("profiles").update({avatar_url:Y}).eq("id",t)}}return{...se,avatar_url:Y}}}),[u,p]=S.useState(null),[x,y]=S.useState(null),[_,b]=S.useState(null),[N,w]=S.useState(!1),k=u??(i==null?void 0:i.name)??"",C=x??(i==null?void 0:i.phone)??"",E=_??(i==null?void 0:i.email)??"",L=i==null?void 0:i.avatar_url,I=((i==null?void 0:i.name)||"A").split(" ").map(se=>se[0]).join("").toUpperCase().slice(0,2),O=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),V=It({mutationFn:async se=>{const{error:Y}=await G.from("profiles").update(se).eq("id",t);if(Y)throw Y},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 se={};if(u!==null&&u!==(i==null?void 0:i.name)&&(se.name=u),x!==null&&x!==(i==null?void 0:i.phone)&&(se.phone=x||null),_!==null&&_!==(i==null?void 0:i.email)&&(se.email=_),Object.keys(se).length===0){me.info("No changes to save");return}V.mutate(se)},$=se=>{var X;const Y=(X=se.target.files)==null?void 0:X[0];if(!Y)return;if(!Y.type.startsWith("image/")){me.error("Please select an image file");return}const J=new FileReader;J.onloadend=()=>{l(J.result),a(!0)},J.readAsDataURL(Y),se.target.value=""},U=async se=>{w(!0);try{const{data:Y}=await G.storage.from("avatars").list(`${t}`);Y&&Y.length>0&&await G.storage.from("avatars").remove(Y.map(ae=>`${t}/${ae.name}`));const J=`${t}/avatar.jpg`,{error:X}=await G.storage.from("avatars").upload(J,se,{upsert:!0,contentType:"image/jpeg"});if(X)throw X;const{data:ce}=G.storage.from("avatars").getPublicUrl(J),ie=ce.publicUrl+"?t="+Date.now();await G.from("profiles").update({avatar_url:ie}).eq("id",t),s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),me.success("Photo updated!")}catch{me.error("Failed to upload photo")}finally{w(!1)}};return d?e.jsx(Ns,{className:"h-32 w-full rounded-xl"}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:O?"border-amber-300 dark:border-amber-700":"",children:e.jsxs(Re,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(xe,{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(Lo,{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 se;return(se=r.current)==null?void 0:se.click()},children:[e.jsxs(vn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx(Ta,{src:L||void 0,alt:k}),e.jsx(_n,{className:"text-lg font-semibold bg-primary/10 text-primary",children:I})]}),e.jsx("div",{className:"absolute inset-0 bg-black/40 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(xx,{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...":L?"Tap to change photo":"Add a profile photo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This photo appears on your card, profile, and community posts"})]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),e.jsx(De,{value:k,onChange:se=>p(se.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(xe,{className:"text-xs font-medium text-muted-foreground",children:"Phone Number"}),e.jsx(De,{value:C,onChange:se=>y(se.target.value),placeholder:"(555) 123-4567",className:"h-10",type:"tel"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium text-muted-foreground",children:"Email"}),e.jsx(De,{value:E,onChange:se=>b(se.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:q,disabled:V.isPending,className:"w-full",children:V.isPending?"Saving...":"Update Profile Info"})]})}),e.jsx(Yke,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:U,aspectRatio:1})]})}function Oks({form:t,setForm:s,userId:r}){const[n,a]=S.useState(null),[o,l]=S.useState(t.brokerage_logo_url?"logo":"name"),[i,d]=S.useState(t.team_logo_url?"logo":"name"),u=_=>{l(_),s(_==="name"?b=>({...b,brokerage_logo_url:""}):b=>({...b,brokerage_display_name:""}))},p=_=>{d(_),s(_==="name"?b=>({...b,team_logo_url:""}):b=>({...b,team_name:""}))},x=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 k=N.name.split(".").pop()||"png",E=`${r}/${b==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${k}`,{error:L}=await G.storage.from("card-logos").upload(E,N,{upsert:!0});if(L)throw L;const{data:I}=G.storage.from("card-logos").getPublicUrl(E),O=I.publicUrl+"?t="+Date.now();s(b==="brokerage_logo_url"?V=>({...V,[b]:O,brokerage_display_name:""}):V=>({...V,[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(Pe,{children:e.jsxs(Re,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(xe,{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(xe,{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(xe,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Name"}),e.jsx(De,{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(xe,{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(xx,{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:_=>x(_,"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(xe,{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(Cg,{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(xe,{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(xe,{className:"text-xs font-medium text-muted-foreground",children:"Team Name"}),e.jsx(De,{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(xe,{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(xx,{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:_=>x(_,"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(xe,{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(Cg,{value:[t.team_logo_size||56],onValueChange:([_])=>s(b=>({...b,team_logo_size:_})),min:24,max:120,step:4})]})]})]})]})})}function Fks({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(xe,{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(Dl,{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(De,{value:n[i],onChange:p=>{const x=p.target.value;/^#[0-9a-fA-F]{0,6}$/.test(x)&&a(i,x)},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 zks({card:t,form:s,setForm:r}){var N;const n=pWe(),a=Jt(),{data:o}=fWe(t.id),[l,i]=S.useState(t.slug),[d,u]=S.useState(!1),[p,x]=S.useState("idle"),y=S.useRef(JSON.stringify(s)),_=S.useRef(null);S.useEffect(()=>{const w=JSON.stringify(s);if(w!==y.current)return _.current&&clearTimeout(_.current),_.current=setTimeout(()=>{x("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,x("saved"),setTimeout(()=>x("idle"),2e3)},onError:()=>x("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:k}=await G.from("agent_cards").select("id").eq("slug",w).neq("id",t.id).maybeSingle();if(k){me.error("This URL is already taken. Try another one.");return}const{error: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(ia,{defaultValue:"content",children:[e.jsxs(ea,{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(yx,{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(wn,{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(Oh,{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(Xy,{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(Tm,{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(Rks,{userId:t.user_id}),e.jsx(Oks,{form:s,setForm:r,userId:t.user_id}),e.jsx(Pe,{children:e.jsxs(Re,{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(xe,{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(Er,{checked:s.is_published,onCheckedChange:w=>r(k=>({...k,is_published:w}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{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(De,{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(xe,{className:"text-sm font-medium",children:"Card Email (Override)"}),e.jsx(De,{value:s.display_email,onChange:w=>r(k=>({...k,display_email:w.target.value})),placeholder:"you@yourbusiness.com",className:"h-11",type:"email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional — use a different email on your card instead of your sign-in email."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Theme"}),e.jsxs(Bs,{value:s.theme,onValueChange:w=>r(k=>({...k,theme:w})),children:[e.jsx(Rs,{className:"h-11",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"standard",children:"✨ Standard — Modern & Clean"}),e.jsx(vt,{value:"luxury",children:"🌙 Luxury — Dark & Gold"}),e.jsx(vt,{value:"bold",children:"🔥 Bold — Vibrant & Punchy"}),e.jsx(vt,{value:"classic",children:"📋 Classic — Professional"})]})]})]}),s.theme==="bold"&&e.jsx(Fks,{form:s,setForm:r}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Title / Tagline"}),e.jsx(De,{value:s.title,onChange:w=>r(k=>({...k,title:w.target.value})),placeholder:"e.g. Luxury Real Estate Specialist",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown below your name on the card"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Positioning Statement"}),e.jsx(De,{value:s.positioning_statement,onChange:w=>r(k=>({...k,positioning_statement:w.target.value})),placeholder:"Your home journey, handled with care.",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Bio"}),e.jsx(vr,{value:s.bio,onChange:w=>r(k=>({...k,bio:w.target.value})),placeholder:"A short intro about you and what makes you different...",rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Review Snippet"}),e.jsx(De,{value:s.review_snippet,onChange:w=>r(k=>({...k,review_snippet:w.target.value})),placeholder:"Best agent we've ever worked with...",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Review Source URL"}),e.jsx(De,{value:s.review_source_url,onChange:w=>r(k=>({...k,review_source_url:w.target.value})),placeholder:"https://g.page/your-business/review",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Booking URL"}),e.jsx(De,{value:s.booking_url,onChange:w=>r(k=>({...k,booking_url:w.target.value})),placeholder:"https://calendly.com/your-link",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty to show a built-in lead form instead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Custom CTA Label"}),e.jsx(De,{value:s.custom_cta_label,onChange:w=>r(k=>({...k,custom_cta_label:w.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx(js,{value:"sections",className:"mt-4",children:e.jsx(Pe,{children:e.jsx(Re,{className:"p-5 divide-y",children:[{key:"show_photo",label:"Photo",desc:"Uses the photo from your Profile Info above"},{key:"show_bio",label:"Bio Section",desc:"Display your bio on the card"},{key:"show_credentials",label:"Credentials",desc:"Show star rating and reviews"},{key:"show_social_links",label:"Social Links",desc:"Display your social media links"},{key:"show_save_contact",label:"Save Contact",desc:"Let visitors save you as a contact"},{key:"show_leave_review",label:"Leave Review",desc:"Link to your review page"},{key:"show_refer_friend",label:"Refer a Friend",desc:"Enable referral submissions"}].map(({key:w,label:k,desc: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(xe,{className:"text-sm font-medium",children:k}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C})]}),e.jsx(Er,{checked:s[w],onCheckedChange:E=>r(L=>({...L,[w]:E}))})]},w))})})}),e.jsx(js,{value:"blocks",className:"mt-4",children:e.jsx(blt,{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:wn,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:Tm,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:al,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(w=>e.jsx(Pe,{className:"overflow-hidden",children:e.jsxs(Re,{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(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(Ot,{className:"text-base",children:"Recent Leads"})}),e.jsx(Re,{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(Qe,{variant:"secondary",className:"text-xs",children:w.intent})]},w.id))})]}),(!o||o.leads.length===0)&&e.jsx(Pe,{children:e.jsxs(Re,{className:"p-8 text-center",children:[e.jsx(Tm,{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(Pe,{children:e.jsx(Re,{className:"p-6",children:e.jsx(Eks,{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 Bks(){const t=Jt(),[s,r]=S.useState(""),[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState(!1),[x,y]=S.useState(!1),[_,b]=S.useState(null),[N,w]=S.useState(null),[k,C]=S.useState(0),{data:E,isLoading:L}=gt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:J,error:X}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(X)throw X;return J}}),I=It({mutationFn:async J=>{const{data:X,error:ce}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:J}});if(ce)throw ce;if(X!=null&&X.error)throw new Error(X.error);return X},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),r(""),me.success("BoldTrail connected successfully!")},onError:J=>{me.error(J.message||"Failed to connect BoldTrail")}}),O=It({mutationFn:async()=>{const{data:J,error:X}=await G.functions.invoke("boldtrail-sync",{body:{action:"disconnect"}});if(X)throw X;return J},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),me.success("BoldTrail disconnected")},onError:()=>me.error("Failed to disconnect")}),V=It({mutationFn:async J=>{const{data:X,error:ce}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:J}});if(ce)throw ce;if(X!=null&&X.error)throw new Error(X.error);return X},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),me.success("Sync direction saved")},onError:J=>{me.error(J.message||"Failed to save sync direction")}}),q=It({mutationFn:async()=>{const{data:J,error:X}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(X)throw X;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")}}),$=It({mutationFn:async()=>{w("Initializing sync..."),C(5);const{data:J,error:X}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:Y}});if(X)throw X;if(J!=null&&J.error)throw new Error(J.error);const ce=J;let ie=ce.sync_log_id,ae=ce.next_phase,oe=ce.next_offset;const pe=ce.push_total||0,_e=ce.pull_total||0,he=pe+_e;let we=0,je=0;for(;ae!=="finalize";){ae==="push"?(w(`Pushing contacts to BoldTrail... (${we}/${pe})`),C(he>0?we/he*100:0)):ae==="pull"&&(w(`Pulling contacts from BoldTrail... (${je}/${_e})`),C(he>0?(pe+je)/he*100:0));const{data:Me,error:Fe}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:ae,offset:oe,sync_log_id:ie,sync_direction:Y}});if(Fe)throw Fe;if(Me!=null&&Me.error)throw new Error(Me.error);const Le=Me;we+=Le.chunk_pushed||0,je+=Le.chunk_pulled||0,Le.progress&&w(Le.progress),ae==="pull"&&_e>0?C(Math.min(95,je/_e*100)):ae==="push"&&pe>0&&C(Math.min(95,we/pe*100)),ae=Le.next_phase,oe=Le.next_offset}w("Finalizing sync..."),C(95);const{data:Ue,error:Te}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:ie,sync_direction:Y}});if(Te)throw Te;return C(100),Ue},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")}}),U=E==null?void 0:E.connected,se=(E==null?void 0:E.sync_direction)||"bidirectional",Y=_??se;return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{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(Ot,{className:"text-lg flex items-center gap-2",children:["BoldTrail",U&&e.jsx(Qe,{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(sp,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(hr,{children:"Sync contacts bidirectionally between Agent OS and your BoldTrail (kvCORE) CRM."})]})]})}),e.jsx(Re,{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(ti,{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(ti,{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(ti,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Syncs name, email, phone, address, notes, and lead source"})]}),U?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsx("div",{className:"rounded-lg border p-3 space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"BoldTrail Connected"}),(E==null?void 0:E.last_sync_at)&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sync: ",new Date(E.last_sync_at).toLocaleString(),E.last_sync_status&&e.jsx(Qe,{variant:E.last_sync_status==="success"?"default":"secondary",className:"ml-2 text-[10px]",children:E.last_sync_status})]}),(E==null?void 0:E.boldtrail_contact_count)!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[E.boldtrail_contact_count," contacts in BoldTrail"]}),(E==null?void 0:E.last_sync_message)&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:E.last_sync_message})]}),e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Disconnect BoldTrail?"}),e.jsx(Pl,{children:"This will remove your API token. Previously synced contacts will remain in both systems."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{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(kwe,{value:se,onChange:J=>V.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(oo,{className:"h-4 w-4 animate-spin"}):e.jsx(wn,{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(De,{type:"password",placeholder:"Paste your BoldTrail API token",value:s,onChange:J=>r(J.target.value),className:"flex-1"}),e.jsxs(K,{onClick:()=>I.mutate(s),disabled:!s||s.length<10||I.isPending,children:[I.isPending?e.jsx(oo,{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(Ir,{children:"Review what will happen when you sync your contacts."})]}),i&&(()=>{const J=Y==="pull_only"?0:i.to_push,X=Y==="push_only"?0:i.to_pull;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(kwe,{value:Y,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 ${Y==="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(du,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${Y==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:X}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Ph,{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(lr,{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(gi,{value:k||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:N||"Sync in progress..."})]}),J>0&&e.jsxs(of,{open:u,onOpenChange:p,children:[e.jsx(lf,{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(du,{className:"h-3 w-3 text-emerald-600"}),J," contacts to push to BoldTrail"]}),e.jsx(Oi,{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`})]})}),e.jsx(cf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.push_preview.map((ce,ie)=>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})]},ie)),i.to_push>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",i.to_push-20," more"]})]})})]}),X>0&&e.jsxs(of,{open:x,onOpenChange:y,children:[e.jsx(lf,{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(Ph,{className:"h-3 w-3 text-blue-600"}),X," contacts to pull from BoldTrail"]}),e.jsx(Oi,{className:`h-3 w-3 transition-transform ${x?"rotate-180":""}`})]})}),e.jsx(cf,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.pull_preview.map((ce,ie)=>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})]},ie)),i.to_pull>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",i.to_pull-20," more"]})]})})]}),J===0&&X===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&&X===0,className:"gap-2",children:[$.isPending?e.jsx(oo,{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 Ilt(){const t=_r(),[s,r]=S.useState(""),[n,a]=S.useState(""),[o,l]=S.useState("Test from ReLevelUp"),[i,d]=S.useState(!1),{data:u,isLoading:p}=gt({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()}}),x=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(Pe,{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(rr,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Amazon SES — Mass Email"}),e.jsx(hr,{children:"Send bulk email campaigns via Amazon SES"})]})]}),e.jsx(Qe,{variant:y?"default":"secondary",children:p?"Checking...":y?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ti,{className:"h-3 w-3"})," Connected"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Lo,{className:"h-3 w-3"})," Not Configured"]})})]})}),y&&e.jsxs(Re,{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(xe,{className:"text-xs",children:"From Email"}),e.jsx(De,{placeholder:"notifications@mail.relevelup.com",value:n,onChange:_=>a(_.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs",children:"To Email"}),e.jsx(De,{placeholder:"your@email.com",value:s,onChange:_=>r(_.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs",children:"Subject"}),e.jsx(De,{value:o,onChange:_=>l(_.target.value),className:"text-sm"})]})]}),e.jsxs(K,{onClick:x,disabled:i,size:"sm",children:[i?e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(An,{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(Re,{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 $ks(){var b,N,w,k;const{user:t}=Fs(),s=Jt(),[r,n]=S.useState(!1),[a,o]=S.useState(""),[l,i]=S.useState(""),{data:d}=gt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:C,error:E}=await G.from("mass_email_settings").select("*").eq("user_id",t.id).maybeSingle();if(E)throw E;return C}}),{data:u}=gt({queryKey:["agent-profile-email",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:C,error:E}=await G.from("profiles").select("email, name").eq("id",t.id).single();if(E)throw E;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())||"",x=((w=d==null?void 0:d.display_name)==null?void 0:w.trim())||((k=u==null?void 0:u.name)==null?void 0:k.trim())||"";S.useEffect(()=>{r||(o(p),i(x))},[r,p,x]);const y=It({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:E}=await G.from("mass_email_settings").update(C).eq("user_id",t.id);if(E)throw E}else{const{error:E}=await G.from("mass_email_settings").insert({user_id:t.id,...C});if(E)throw E}},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(Pe,{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(An,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Mass Email",_?e.jsxs(Qe,{variant:"default",className:"text-xs bg-green-600",children:[e.jsx(ti,{className:"h-3 w-3 mr-1"})," Set Up"]}):e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"Setup Required"})]}),e.jsx(hr,{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(Re,{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:x||"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(ga,{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(xe,{className:"text-xs",children:"Display Name"}),e.jsx(De,{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(xe,{className:"text-xs",children:"Reply-To Email *"}),e.jsx(De,{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(_c,{className:"h-4 w-4 mr-1"})," Save"]}),r&&e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{n(!1),o(p),i(x)},children:[e.jsx(Sr,{className:"h-4 w-4 mr-1"})," Cancel"]})]})]})})]})}function qks(){const{isAdmin:t}=Fs(),s=Jt(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(!1),{data:d,isLoading:u}=gt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:L,error:I}=await G.from("gmail_integrations").select("*").maybeSingle();if(I)throw I;return L}}),{data:p}=gt({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:L}}=await G.auth.getUser();if(!L)return[];const{data:I,error:O}=await G.from("social_accounts").select("*").eq("user_id",L.id).order("created_at",{ascending:!1});if(O)throw O;return I}}),x=async()=>{n(!0);try{const{data:L,error:I}=await G.functions.invoke("gmail-oauth",{body:{action:"get_auth_url"}});if(I)throw I;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get authorization URL")}catch(L){console.error("Gmail OAuth error:",L),me.error("Failed to start Gmail connection"),n(!1)}},y=async()=>{o(!0);try{const{data:L,error:I}=await G.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(I)throw I;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get authorization URL")}catch(L){console.error("Meta OAuth error:",L),me.error("Failed to start connection. Make sure Meta App credentials are configured."),o(!1)}},_=async()=>{i(!0);try{const{data:L,error:I}=await G.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(I)throw I;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(L){console.error("LinkedIn OAuth error:",L),me.error("Failed to start LinkedIn connection. Please try again."),i(!1)}},b=It({mutationFn:async L=>{const{error:I}=await G.from("gmail_integrations").delete().eq("id",L);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["gmail-integration"]}),me.success("Gmail disconnected")},onError:()=>{me.error("Failed to disconnect Gmail")}}),N=It({mutationFn:async L=>{const{error:I}=await G.from("social_accounts").delete().eq("id",L);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["social-accounts"]}),me.success("Account disconnected")},onError:()=>{me.error("Failed to disconnect account")}}),w=!!(d!=null&&d.is_active),k=(p==null?void 0:p.filter(L=>L.platform==="facebook"))||[],C=(p==null?void 0:p.filter(L=>L.platform==="instagram"))||[],E=(p==null?void 0:p.filter(L=>L.platform==="linkedin"))||[];return e.jsx(Es,{children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6 animate-fade-in",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Integrations"}),e.jsx("p",{className:"text-muted-foreground",children:"Connect third-party services to supercharge your Agent OS workflow."})]}),e.jsxs(Pe,{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(rr,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Gmail",w&&e.jsx(Qe,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(hr,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx(Re,{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(ti,{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(ti,{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(ti,{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(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Disconnect Gmail?"}),e.jsx(Pl,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:()=>b.mutate(d.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:x,disabled:r||u,children:[r?e.jsx(oo,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(rr,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx(ei,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Pe,{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(uu,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Facebook",t?k.length>0?e.jsx(Qe,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(yd,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(hr,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs(Re,{className:"space-y-3",children:[k.length>0&&e.jsx("div",{className:"space-y-2",children:k.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(vn,{className:"h-8 w-8",children:[e.jsx(Ta,{src:L.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(uu,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.page_name||L.platform_username||"Facebook Page"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Facebook Page"})]})]}),e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Disconnect Facebook?"}),e.jsx(Pl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:()=>N.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}),e.jsxs(K,{onClick:y,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(oo,{className:"h-4 w-4 animate-spin"}):e.jsx(Us,{className:"h-4 w-4"}),"Connect Facebook Page"]})]})]}),e.jsxs(Pe,{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(mu,{className:"h-5 w-5 text-pink-600"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Instagram",t?C.length>0?e.jsx(Qe,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(yd,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(hr,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(Re,{className:"space-y-3",children:[C.length>0&&e.jsx("div",{className:"space-y-2",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-8 w-8",children:[e.jsx(Ta,{src:L.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(mu,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:["@",L.platform_username||"Instagram Account"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Instagram account"})]})]}),e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Disconnect Instagram?"}),e.jsx(Pl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:()=>N.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}),e.jsxs(K,{onClick:y,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(oo,{className:"h-4 w-4 animate-spin"}):e.jsx(Us,{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(Pe,{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(xp,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?E.length>0?e.jsx(Qe,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(yd,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(hr,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs(Re,{className:"space-y-3",children:[E.length>0&&e.jsx("div",{className:"space-y-2",children:E.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-8 w-8",children:[e.jsx(Ta,{src:L.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(xp,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.platform_username||"LinkedIn Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected LinkedIn profile"})]})]}),e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Disconnect LinkedIn?"}),e.jsx(Pl,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:()=>N.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}),e.jsxs(K,{onClick:_,disabled:l,variant:"outline",className:"gap-2",children:[l?e.jsx(oo,{className:"h-4 w-4 animate-spin"}):e.jsx(Us,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]}),e.jsx(Bks,{}),e.jsx($ks,{}),t&&e.jsx(Ilt,{})]})})}function Uks(){const[t]=Nc(),s=_r(),[r,n]=S.useState("loading"),[a,o]=S.useState("Connecting your Gmail account...");return S.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),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:x,error:y}=await G.functions.invoke("gmail-oauth",{body:{action:"exchange_code",code:i,state:p}});if(y)throw y;if(x!=null&&x.success)n("success"),o(x.message||"Gmail connected successfully!"),me.success("Gmail connected!");else throw new Error((x==null?void 0:x.error)||"Unknown error")}catch(x){console.error("Gmail OAuth callback error:",x),n("error"),o(x instanceof Error?x.message:"Failed to connect Gmail"),me.error("Failed to connect: "+(x instanceof Error?x.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Pe,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(_s,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(ti,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Zl,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ot,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(hr,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function Vks(){const t=_r();return S.useEffect(()=>{const s=setTimeout(()=>{t("/mission-control/integrations",{replace:!0})},1500);return()=>clearTimeout(s)},[t]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Finishing Canva connection…"})]})})}function Hks(){const[t]=Nc(),s=_r(),[r,n]=S.useState("loading"),[a,o]=S.useState("Processing your connection...");return S.useEffect(()=>{(async()=>{var x;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 ${((x=y.accounts)==null?void 0:x.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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(_s,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(ti,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Zl,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ot,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(hr,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const Llt=new Date().getFullYear(),Gks=Array.from({length:5},(t,s)=>Llt-s);function Wks(){const[t,s]=S.useState(Llt),r=_r(),{data:n,isLoading:a}=t8t();return a?e.jsx(Es,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ns,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(Ns,{className:"h-24"},o))}),e.jsx(Ns,{className:"h-96"})]})}):e.jsx(Es,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Scorecard Admin"}),e.jsx("p",{className:"text-muted-foreground",children:"View agent performance and scorecards"})]}),e.jsxs(Bs,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(Rs,{className:"w-[120px]",children:e.jsx(qs,{})}),e.jsx(Os,{children:Gks.map(o=>e.jsx(vt,{value:String(o),children:o},o))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(lr,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(to,{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(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"Agents with Scorecards"}),e.jsx(hr,{children:"Click to view individual agent scorecards"})]}),e.jsx(Re,{children:!n||n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(to,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Nt,{children:"Agent"}),e.jsx(Nt,{children:"Email"}),e.jsx(Nt,{className:"text-right",children:"Actions"})]})}),e.jsx(Dn,{children:n.map(o=>e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:o.name}),e.jsx(ut,{className:"text-muted-foreground",children:o.email}),e.jsx(ut,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r(`/admin/scorecard/${o.id}`),children:[e.jsx(wn,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const Dlt=new Date().getFullYear(),Kks=Array.from({length:10},(t,s)=>Dlt-s);function i9e(){var N;const{userId:t}=co(),s=_r(),n=Ol().pathname.startsWith("/mission-control"),[a,o]=S.useState(Dlt),{data:l,isLoading:i}=gt({queryKey:["agent-profile",t],queryFn:async()=>{const{data:w,error:k}=await G.from("profiles").select("id, name, email").eq("id",t).single();if(k)throw k;return w},enabled:!!t}),{data:d,isLoading:u}=ake(a,t),{yearStats:p,lifetimeStats:x,isLoading:y,showCommission:_}=EXe(a,t),{data:b}=AXe(a,t);return i?e.jsx(Es,{title:"Agent Scorecard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ns,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(w=>e.jsx(Ns,{className:"h-24"},w))})]})}):e.jsx(Es,{title:`${l==null?void 0:l.name}'s Scorecard`,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s(n?"/mission-control/scorecard":"/admin/scorecard"),children:e.jsx(Fa,{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(Bs,{value:String(a),onValueChange:w=>o(Number(w)),children:[e.jsx(Rs,{className:"w-[120px]",children:e.jsx(qs,{})}),e.jsx(Os,{children:Kks.map(w=>e.jsx(vt,{value:String(w),children:w},w))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[e.jsx(Pe,{children:e.jsxs(Re,{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:[x.totalTransactions," lifetime"]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(lr,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(yc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:kl(p.totalVolume,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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:kl(p.averagePrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ec,{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:((N=p.topLeadSource)==null?void 0:N.name)||"-"})]})})]}),b&&e.jsx(Jat,{goals:b,stats:p,year:a,showCommission:_}),e.jsxs(ia,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(ea,{children:[e.jsx(ls,{value:"transactions",children:"Transactions"}),e.jsx(ls,{value:"charts",children:"Charts"}),e.jsxs(ls,{value:"map",children:[e.jsx(Da,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(js,{value:"transactions",children:e.jsx(FSe,{transactions:d||[],showCommission:_,isLoading:u})}),e.jsx(js,{value:"charts",children:e.jsx(zSe,{stats:p,year:a})}),e.jsx(js,{value:"map",children:e.jsx(BSe,{transactions:d||[],isLoading:u})})]})]})})}function Zks(){const t=Jt(),[s,r]=S.useState(""),[n,a]=S.useState("all");GZe();const{data:o,refetch:l}=gt({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:L}=await G.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(L==null?void 0:L.enabled)??!1}}),{data:i,isLoading:d}=gt({queryKey:["admin-listings"],queryFn:async()=>{const{data:L,error:I}=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(I)throw I;return L}}),{data:u}=gt({queryKey:["admin-listing-stats"],queryFn:async()=>{const{data:L}=await G.from("listings").select("id, is_approved, status"),{data:I}=await G.from("listing_shares").select("id"),{data:O}=await G.from("listing_views").select("id");return{total:(L==null?void 0:L.length)||0,pending:(L==null?void 0:L.filter(V=>!V.is_approved).length)||0,active:(L==null?void 0:L.filter(V=>V.status==="active").length)||0,totalShares:(I==null?void 0:I.length)||0,totalViews:(O==null?void 0:O.length)||0}}}),p=async(L,I,O="submit_url")=>{try{const{data:{session:V}}=await G.auth.getSession();if(!V)return;const{data:q,error:$}=await G.functions.invoke("google-indexing",{body:{action:O,listing_id:L,listing_slug:I}});if($)throw $;if((q==null?void 0:q.configured)===!1)return;q!=null&&q.success&&me.success("Submitted to Google for indexing")}catch(V){console.error("Google indexing submission failed:",V)}},x=It({mutationFn:async()=>{const{data:{session:L}}=await G.auth.getSession();if(!L)throw new Error("Not authenticated");const{data:I,error:O}=await G.functions.invoke("google-indexing",{body:{action:"submit_all"}});if(O)throw O;return I},onSuccess:L=>{if((L==null?void 0:L.configured)===!1){me.error("Google Indexing API not configured. Add the GOOGLE_INDEXING_SERVICE_ACCOUNT secret.");return}me.success(`Submitted ${(L==null?void 0:L.succeeded)||0} URLs to Google (${(L==null?void 0:L.failed)||0} failed)`)},onError:L=>{me.error("Failed to submit to Google"),console.error(L)}}),y=It({mutationFn:async({id:L,approved:I,slug:O})=>{const{error:V}=await G.from("listings").update({is_approved:I}).eq("id",L);if(V)throw V;return{id:L,approved:I,slug:O}},onSuccess:L=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),me.success(L.approved?"Listing approved":"Listing unapproved"),L.approved?p(L.id,L.slug||null,"submit_url"):p(L.id,L.slug||null,"remove_url")}}),_=It({mutationFn:async({id:L,featured:I})=>{const{error:O}=await G.from("listings").update({is_featured:I}).eq("id",L);if(O)throw O},onSuccess:(L,{featured:I})=>{t.invalidateQueries({queryKey:["admin-listings"]}),me.success(I?"Listing featured":"Listing unfeatured")}}),b=It({mutationFn:async L=>{const{error:I}=await G.from("listings").delete().eq("id",L);if(I)throw I},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),me.success("Listing deleted")}}),N=It({mutationFn:async L=>{const{error:I}=await G.from("feature_flags").update({enabled:L}).eq("key","listing_exchange_enabled");if(I)throw I},onSuccess:()=>{l(),me.success("Feature flag updated")}}),w=o??!1,k=i==null?void 0:i.filter(L=>{var V,q,$,U;const I=((V=L.city)==null?void 0:V.toLowerCase().includes(s.toLowerCase()))||(($=(q=L.agent)==null?void 0:q.name)==null?void 0:$.toLowerCase().includes(s.toLowerCase()))||((U=L.property_address)==null?void 0:U.toLowerCase().includes(s.toLowerCase())),O=n==="all"||n==="pending"&&!L.is_approved||n==="approved"&&L.is_approved;return I&&O}),C=L=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(L),E=L=>{const I={active:"bg-green-500/10 text-green-600 border-green-200",coming_soon:"bg-blue-500/10 text-blue-600 border-blue-200",price_improvement:"bg-amber-500/10 text-amber-600 border-amber-200",under_contract:"bg-purple-500/10 text-purple-600 border-purple-200",sold:"bg-gray-500/10 text-gray-600 border-gray-200"};return I[L]||I.active};return e.jsx(Es,{title:"Listing Exchange Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Listing Exchange"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage community listings"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,className:"gap-2",children:[x.isPending?e.jsx(_s,{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(Er,{checked:w,onCheckedChange:L=>N.mutate(L)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(lr,{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(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wn,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsx(Re,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by city, address, or agent...",value:s,onChange:L=>r(L.target.value),className:"pl-9"})]}),e.jsx(ia,{value:n,onValueChange:L=>a(L),children:e.jsxs(ea,{children:[e.jsx(ls,{value:"all",children:"All"}),e.jsx(ls,{value:"pending",children:"Pending"}),e.jsx(ls,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{children:["Listings (",(k==null?void 0:k.length)||0,")"]})}),e.jsx(Re,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:d?e.jsx(Ms,{children:e.jsx(ut,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(k==null?void 0:k.length)===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):k==null?void 0:k.map(L=>{var I,O,V,q,$;return e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[(O=(I=L.photos)==null?void 0:I[0])!=null&&O.photo_url?e.jsx("img",{src:L.photos[0].photo_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(pa,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.property_address||`${L.city}, ${L.state}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(V=L.property_type)==null?void 0:V.replace("_"," ")})]})]})}),e.jsx(ut,{children:e.jsx("p",{className:"text-sm",children:((q=L.agent)==null?void 0:q.name)||"Unknown"})}),e.jsx(ut,{className:"font-medium",children:C(L.price)}),e.jsx(ut,{children:e.jsx(Qe,{variant:"outline",className:E(L.status),children:($=L.status)==null?void 0:$.replace("_"," ")})}),e.jsx(ut,{className:"text-center",children:e.jsx(Er,{checked:L.is_approved??!1,onCheckedChange:U=>y.mutate({id:L.id,approved:U,slug:L.slug})})}),e.jsx(ut,{className:"text-center",children:e.jsx(Er,{checked:L.is_featured??!1,onCheckedChange:U=>_.mutate({id:L.id,featured:U})})}),e.jsx(ut,{children:L.view_count||0}),e.jsx(ut,{children:L.share_count||0}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:ps(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(ut,{children:e.jsxs(Ud,{children:[e.jsx(Vd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(ix,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",children:[e.jsxs(va,{onClick:()=>window.open(`/mission-control/listings/${L.id}`,"_blank"),children:[e.jsx(wn,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(va,{onClick:()=>_.mutate({id:L.id,featured:!L.is_featured}),children:[e.jsx(Hn,{className:"h-4 w-4 mr-2"}),L.is_featured?"Unfeature":"Feature"]}),e.jsxs(va,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&b.mutate(L.id)},children:[e.jsx(Sr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},L.id)})})]})})})]})]})})}const Yks=()=>{var x,y;const[t,s]=S.useState(""),[r,n]=S.useState(null),{data:a,isLoading:o}=gt({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(E=>E.id===C.user_id))||null}))}}),l=a==null?void 0:a.filter(_=>{var N,w,k,C,E;const b=t.toLowerCase();return((w=(N=_.profiles)==null?void 0:N.name)==null?void 0:w.toLowerCase().includes(b))||((C=(k=_.profiles)==null?void 0:k.email)==null?void 0:C.toLowerCase().includes(b))||((E=_.review_text)==null?void 0:E.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(Hn,{className:Rt("h-4 w-4",_>=b?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},b))});return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{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(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(hr,{children:"Total Reviews"}),e.jsx(Ot,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(hr,{children:"Average Rating"}),e.jsxs(Ot,{className:"flex items-center gap-2 text-3xl",children:[i,e.jsx(Hn,{className:"h-6 w-6 fill-yellow-400 text-yellow-400"})]})]})}),e.jsx(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(hr,{children:"5-Star Reviews"}),e.jsx(Ot,{className:"text-3xl",children:(d==null?void 0:d[5])||0})]})}),e.jsx(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(hr,{children:"Posted to Google"}),e.jsxs(Ot,{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(an,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name, email, or review...",value:t,onChange:_=>s(_.target.value),className:"pl-9"})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:o?e.jsx(Ms,{children:e.jsx(ut,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(Ms,{children:e.jsx(ut,{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(Ms,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>n(_),children:[e.jsx(ut,{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(ut,{children:p(_.rating)}),e.jsx(ut,{className:"hidden md:table-cell max-w-xs",children:e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:_.review_text||"-"})}),e.jsx(ut,{children:_.posted_to_google?e.jsx(Qe,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(Qe,{variant:"outline",children:"No"})}),e.jsx(ut,{className:"text-sm text-muted-foreground",children:ps(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:((x=r.profiles)==null?void 0:x.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(rr,{className:"h-3 w-3"}),r.profiles.email]})]}),e.jsxs("div",{className:"text-right",children:[p(r.rating),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r.rating," out of 5 stars"]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Review"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:r.review_text||"No written review provided."})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(on,{className:"h-4 w-4"}),ps(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(Qe,{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(Qe,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},Xks=[{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"}],Qks=Array.from({length:24},(t,s)=>({value:String(s),label:s===0?"12:00 AM":s<12?`${s}:00 AM`:s===12?"12:00 PM":`${s-12}:00 PM`}));function Jks(){const t=Jt(),{user:s}=Fs(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(!1),{data:d,isLoading:u}=gt({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:x}=gt({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}=gt({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}=gt({queryKey:["digest-queue-status"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const[$,U,se,Y]=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:U.count||0,sent:se.count||0,failed:Y.count||0,total:($.count||0)+(U.count||0)+(se.count||0)+(Y.count||0)}},refetchInterval:5e3});S.useEffect(()=>{if(_&&(_.pending>0||_.processing>0)){const q=setInterval(()=>{b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})},5e3);return()=>clearInterval(q)}},[_,b,t]);const{data:N=0}=gt({queryKey:["digest-today-failed-count"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const{count:$,error:U}=await G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString());if(U)throw U;return $||0}}),w=It({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)}}),k=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,$,U,se,Y,J;if(!(s!=null&&s.email)){me.error("No email found for your account");return}o(!0);try{const{data:X,error:ce}=await G.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(ce)throw ce;const ie=X==null?void 0:X.resendId,ae=X==null?void 0:X.resendDetails,oe=ae==null?void 0:ae.status,pe=((q=ae==null?void 0:ae.body)==null?void 0:q.status)||((U=($=ae==null?void 0:ae.body)==null?void 0:$.data)==null?void 0:U.status),_e=((Y=(se=ae==null?void 0:ae.body)==null?void 0:se.error)==null?void 0:Y.message)||((J=ae==null?void 0:ae.body)==null?void 0:J.message);me.success(ie?`Preview accepted by email provider (id: ${ie})${oe?`, status check: ${oe}`:""}${pe?`, provider: ${pe}`:""}${_e?` (${_e})`:""}. Check spam/promotions—delivery can take a few minutes.`:"Preview accepted by email provider. Check spam/promotions—delivery can take a few minutes.")}catch(X){me.error("Failed to send preview: "+X.message)}finally{o(!1)}},E=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)}},L=_!=null&&_.total?Math.round((_.sent+_.failed)/_.total*100):0,I=((_==null?void 0:_.pending)||0)>0||((_==null?void 0:_.processing)||0)>0,{data:O}=gt({queryKey:["digest-delivery-stats"],queryFn:async()=>{var J,X;const q=new Date;q.setUTCHours(0,0,0,0);const[$,U,se,Y]=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:U.count||0,agentOsEngaged:se.count||0,lastSent:((X=(J=Y.data)==null?void 0:J[0])==null?void 0:X.sent_at)||null}},refetchInterval:I?5e3:!1}),V={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(Es,{title:"Weekly Digest",description:"Manage automated weekly email digests",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-32 bg-muted rounded-lg"}),e.jsx("div",{className:"h-64 bg-muted rounded-lg"})]})}):e.jsx(Es,{title:"Weekly Digest",description:"Configure and manage automated weekly email digests for members",children:e.jsxs(ia,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(ea,{children:[e.jsxs(ls,{value:"settings",className:"flex items-center gap-2",children:[e.jsx(ko,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(ls,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs(js,{value:"settings",className:"space-y-6",children:[I&&_&&e.jsx(Pe,{className:"border-primary/50 bg-primary/5",children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(_s,{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:[L,"%"]})]}),e.jsx(gi,{value:L,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Processing ~80 emails per minute. Estimated time remaining: ~",Math.ceil(_.pending/80)," min"]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(Pe,{children:e.jsx(Re,{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(lr,{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(Pe,{children:e.jsx(Re,{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(Qn,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:V.totalSent}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Delivered"})]})]})})}),e.jsx(Pe,{children:e.jsx(Re,{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(Zl,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:V.totalFailed}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed"})]})]})})}),e.jsx(Pe,{children:e.jsx(Re,{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(ln,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:V.lastSent?ps(new Date(V.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(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(ln,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(hr,{children:"Configure when the digest is sent"})]}),e.jsxs(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Enable Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Send automated weekly emails to members"})]}),e.jsx(Er,{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(xe,{children:"Cron Frequency"}),e.jsxs(Bs,{value:(d==null?void 0:d.cron_frequency)||"daily",onValueChange:q=>w.mutate({cron_frequency:q}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"daily",children:"Daily (runs once at selected time)"}),e.jsx(vt,{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(xe,{children:"Day of Week"}),e.jsxs(Bs,{value:String(d==null?void 0:d.send_day),onValueChange:q=>w.mutate({send_day:parseInt(q)}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:Xks.map(q=>e.jsx(vt,{value:q.value,children:q.label},q.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Time (UTC)"}),e.jsxs(Bs,{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(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:Qks.map(q=>e.jsx(vt,{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(wn,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(K,{onClick:k,disabled:r,className:"flex-1",children:[e.jsx(An,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),N>0&&e.jsxs(K,{onClick:E,disabled:l,variant:"outline",className:"w-full",children:[e.jsx(oo,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${N} Failed`]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(hr,{children:"Choose what to include in the digest"})]}),e.jsxs(Re,{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(fn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{children:"New Resources"})]}),e.jsx(Er,{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(lr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{children:"Community Highlights"})]}),e.jsx(Er,{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(to,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{children:"Agent OS Stats"})]}),e.jsx(Er,{checked:d==null?void 0:d.include_agent_os_stats,onCheckedChange:q=>w.mutate({include_agent_os_stats:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{children:"Upcoming Events"})]}),e.jsx(Er,{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(Rh,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{children:"Goals Progress"})]}),e.jsx(Er,{checked:d==null?void 0:d.include_goals_progress,onCheckedChange:q=>w.mutate({include_goals_progress:q})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"Custom Introduction"}),e.jsx(hr,{children:"Personalize the intro message (optional)"})]}),e.jsx(Re,{children:e.jsx(vr,{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(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(rr,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(hr,{children:"Recent digest emails sent to members"})]}),e.jsx(Re,{children:x?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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:p.map(q=>e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:q.email_sent_to}),e.jsx(ut,{children:ps(new Date(q.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(ut,{children:e.jsx(Qe,{variant:q.delivery_status==="sent"?"default":"destructive",children:q.delivery_status})}),e.jsx(ut,{children:q.resources_count}),e.jsx(ut,{children:q.has_agent_os_activity?e.jsx(Qe,{variant:"secondary",children:"Active"}):e.jsx(Qe,{variant:"outline",children:"Not Started"})})]},q.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(rr,{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 e4s={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 t4s(){var we,je,Ue;const t=Jt(),[s,r]=S.useState(""),[n,a]=S.useState(null),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(""),[x,y]=S.useState(""),[_,b]=S.useState(!0),[N,w]=S.useState(!1),[k,C]=S.useState(""),[E,L]=S.useState(null),{data:I,isLoading:O}=gt({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:Te,error:Me}=await G.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Me)throw Me;const Fe=(Te==null?void 0:Te.map(qe=>qe.user_id))||[],{data:Le}=await G.from("profiles").select("id, name, email").in("id",Fe),Ne=new Map((Le==null?void 0:Le.map(qe=>[qe.id,{name:qe.name,email:qe.email}]))||[]);return Te==null?void 0:Te.map(qe=>({...qe,profile:Ne.get(qe.user_id)||null}))}}),{data:V}=gt({queryKey:["all-profiles-for-points",I],queryFn:async()=>{const Me=[];let Fe=0;for(;;){const{data:Le,error:Ne}=await G.from("profiles").select("id, name, email").order("name").range(Fe,Fe+1e3-1);if(Ne)throw Ne;if(Me.push(...Le),!Le||Le.length<1e3)break;Fe+=1e3}return Me}}),$=((V==null?void 0:V.filter(Te=>!(I!=null&&I.some(Me=>Me.user_id===Te.id))))||[]).filter(Te=>{var Fe,Le;if(!k)return!0;const Me=k.toLowerCase();return((Fe=Te.name)==null?void 0:Fe.toLowerCase().includes(Me))||((Le=Te.email)==null?void 0:Le.toLowerCase().includes(Me))}),{data:U,isLoading:se}=gt({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Te,error:Me}=await G.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Me)throw Me;return Te},enabled:!!(n!=null&&n.user_id)&&i}),{data:Y}=gt({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Te,error:Me}=await G.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Me)throw Me;return Te},enabled:!!(n!=null&&n.user_id)}),J=It({mutationFn:async({userId:Te,points:Me,reason:Fe})=>{const{error:Le}=await G.from("agent_points").insert({user_id:Te,points:Me,reason:Fe});if(Le)throw Le;const{data:Ne}=await G.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",Te).maybeSingle(),qe=((Ne==null?void 0:Ne.total_points)||0)+Me,ze=((Ne==null?void 0:Ne.spendable_points)||0)+Me,{error:ve}=await G.from("agent_attendance_stats").upsert({user_id:Te,total_points:Math.max(0,qe),spendable_points:Math.max(0,ze),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(ve)throw ve},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")}}),X=()=>{if(!n||!u||!x){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:x})},ce=()=>{if(!E||!u||!x){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:E.id,points:Te,reason:x},{onSuccess:()=>{w(!1),L(null),C("")}})},ie=(Te,Me)=>{a(Te),b(Me),l(!0)},ae=Te=>{a(Te),d(!0)},oe=I==null?void 0:I.filter(Te=>{var Ne,qe,ze,ve;const Me=((qe=(Ne=Te.profile)==null?void 0:Ne.name)==null?void 0:qe.toLowerCase())||"",Fe=((ve=(ze=Te.profile)==null?void 0:ze.email)==null?void 0:ve.toLowerCase())||"",Le=s.toLowerCase();return Me.includes(Le)||Fe.includes(Le)}),pe=(I==null?void 0:I.reduce((Te,Me)=>Te+Me.total_points,0))||0,_e=(I==null?void 0:I.length)||0,he=_e>0?Math.round(pe/_e):0;return O?e.jsx(Es,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ns,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(Te=>e.jsx(Ns,{className:"h-24"},Te))}),e.jsx(Ns,{className:"h-96"})]})}):e.jsx(Es,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Agent Points Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Track, view, and manage agent gamification points"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(lr,{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:_e}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Vi,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Points"})]}),e.jsx("p",{className:"text-2xl font-bold",children:pe.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search agents...",value:s,onChange:Te=>r(Te.target.value),className:"pl-10"})]}),e.jsxs(K,{onClick:()=>w(!0),children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"Agent Leaderboard"}),e.jsx(hr,{children:"All agents with their points, events, and streaks"})]}),e.jsx(Re,{children:!oe||oe.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 agents with points yet"})]}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:oe.map((Te,Me)=>{var Fe,Le,Ne,qe;return e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:Me<3?e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${Me===0?"bg-yellow-100 text-yellow-700":Me===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:Me+1}):e.jsx("span",{className:"text-muted-foreground",children:Me+1})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(vn,{className:"h-8 w-8",children:e.jsx(_n,{children:((Le=(Fe=Te.profile)==null?void 0:Fe.name)==null?void 0:Le.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Ne=Te.profile)==null?void 0:Ne.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(qe=Te.profile)==null?void 0:qe.email})]})]})}),e.jsx(ut,{className:"text-center",children:e.jsxs(Qe,{variant:"secondary",className:"font-bold",children:[e.jsx(Hn,{className:"h-3 w-3 mr-1"}),Te.total_points]})}),e.jsx(ut,{className:"text-center",children:e.jsxs(Qe,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(Ui,{className:"h-3 w-3 mr-1"}),Te.spendable_points||0]})}),e.jsx(ut,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(on,{className:"h-3 w-3 text-muted-foreground"}),Te.total_events_attended]})}),e.jsx(ut,{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(ut,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie(Te,!0),title:"Award points",children:e.jsx(Us,{className:"h-4 w-4 text-green-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie(Te,!1),title:"Deduct points",children:e.jsx(Yy,{className:"h-4 w-4 text-red-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ae(Te),title:"View history",children:e.jsx(NM,{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(Ir,{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(xe,{htmlFor:"points",children:"Points Amount"}),e.jsx(De,{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(xe,{htmlFor:"reason",children:"Reason"}),e.jsx(vr,{id:"reason",placeholder:"Enter reason for this adjustment...",value:x,onChange:Te=>y(Te.target.value)})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:X,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: ",(je=n==null?void 0:n.profile)==null?void 0:je.name]}),e.jsx(Ir,{children:"View all point transactions and badges for this agent"})]}),e.jsxs(ia,{defaultValue:"history",className:"w-full",children:[e.jsxs(ea,{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:se?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(Te=>e.jsx(Ns,{className:"h-12"},Te))}):!U||U.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(NM,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No point history yet"})]}):e.jsx("div",{className:"max-h-80 overflow-y-auto space-y-2",children:U.map(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:ps(new Date(Te.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(Qe,{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:!Y||Y.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ec,{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:Y.map(Te=>e.jsxs("div",{className:`p-3 rounded-lg ${e4s[Te.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ec,{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 ",ps(new Date(Te.earned_at),"MMM d, yyyy")]})]},Te.id))})})]})]})}),e.jsx(fs,{open:N,onOpenChange:Te=>{w(Te),Te||(L(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(Ir,{children:"Select an agent who doesn't have points yet and award them points"})]}),e.jsx("div",{className:"space-y-4 py-4",children:E?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:((Ue=E.name)==null?void 0:Ue.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:E.name||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:E.email})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>L(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"new-points",children:"Points Amount"}),e.jsx(De,{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(xe,{htmlFor:"new-reason",children:"Reason"}),e.jsx(vr,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:x,onChange:Te=>y(Te.target.value)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Search Agent"}),e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or email...",value:k,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(lr,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:k?"No matching agents found":"All agents already have points"})]}):$.slice(0,20).map(Te=>{var Me;return e.jsxs("button",{onClick:()=>L(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:((Me=Te.name)==null?void 0:Me.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:Te.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Te.email})]})]},Te.id)})})]})}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),E&&e.jsxs(K,{onClick:ce,disabled:J.isPending,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function s4s(){const{data:t,isLoading:s}=nkt(),[r,n]=S.useState(null),[a,o]=S.useState(!1),[l,i]=S.useState(""),[d,u]=S.useState("all"),[p,x]=S.useState("newest"),[y,_]=S.useState("table"),b=S.useMemo(()=>(t==null?void 0:t.map(E=>E.user_id))||[],[t]),N=S.useMemo(()=>(t==null?void 0:t.map(E=>E.id))||[],[t]),{data:w}=gt({queryKey:["card-profiles-lookup",b],queryFn:async()=>{if(b.length===0)return{};const{data:E}=await G.from("profiles").select("id, name, email").in("id",b),L={};return E==null||E.forEach(I=>{L[I.id]={name:I.name||"",email:I.email||""}}),L},enabled:b.length>0}),{data:k}=gt({queryKey:["card-stats-all",N],queryFn:async()=>{if(N.length===0)return{};const E={};N.forEach(O=>{E[O]={views:0,leads:0}});const{data:L}=await G.from("agent_card_interactions").select("card_id").in("card_id",N).eq("interaction_type","card_view");L==null||L.forEach(O=>{E[O.card_id]&&E[O.card_id].views++});const{data:I}=await G.from("agent_card_leads").select("card_id").in("card_id",N);return I==null||I.forEach(O=>{E[O.card_id]&&E[O.card_id].leads++}),E},enabled:N.length>0}),C=S.useMemo(()=>{if(!t)return[];let E=[...t];if(d==="live"?E=E.filter(L=>L.is_published):d==="draft"&&(E=E.filter(L=>!L.is_published)),l.trim()){const L=l.toLowerCase();E=E.filter(I=>{var V,q;const O=w==null?void 0:w[I.user_id];return I.slug.toLowerCase().includes(L)||((V=O==null?void 0:O.name)==null?void 0:V.toLowerCase().includes(L))||((q=O==null?void 0:O.email)==null?void 0:q.toLowerCase().includes(L))})}return p==="newest"?E.sort((L,I)=>new Date(I.created_at).getTime()-new Date(L.created_at).getTime()):p==="oldest"?E.sort((L,I)=>new Date(L.created_at).getTime()-new Date(I.created_at).getTime()):p==="name"?E.sort((L,I)=>{var O,V;return(((O=w==null?void 0:w[L.user_id])==null?void 0:O.name)||"").localeCompare(((V=w==null?void 0:w[I.user_id])==null?void 0:V.name)||"")}):p==="slug"?E.sort((L,I)=>L.slug.localeCompare(I.slug)):p==="views_desc"?E.sort((L,I)=>{var O,V;return(((O=k==null?void 0:k[I.id])==null?void 0:O.views)||0)-(((V=k==null?void 0:k[L.id])==null?void 0:V.views)||0)}):p==="views_asc"?E.sort((L,I)=>{var O,V;return(((O=k==null?void 0:k[L.id])==null?void 0:O.views)||0)-(((V=k==null?void 0:k[I.id])==null?void 0:V.views)||0)}):p==="leads_desc"?E.sort((L,I)=>{var O,V;return(((O=k==null?void 0:k[I.id])==null?void 0:O.leads)||0)-(((V=k==null?void 0:k[L.id])==null?void 0:V.leads)||0)}):p==="leads_asc"&&E.sort((L,I)=>{var O,V;return(((O=k==null?void 0:k[L.id])==null?void 0:O.leads)||0)-(((V=k==null?void 0:k[I.id])==null?void 0:V.leads)||0)}),E},[t,d,l,p,w]);return e.jsxs(Es,{title:"Digital Agent Cards",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Digital Agent Cards"}),e.jsx("p",{className:"text-muted-foreground",children:"Create and manage agent digital business cards"})]}),e.jsxs(K,{onClick:()=>o(!0),children:[e.jsx(Us,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name, email, or slug...",value:l,onChange:E=>i(E.target.value),className:"pl-9"})]}),e.jsxs(Bs,{value:d,onValueChange:u,children:[e.jsx(Rs,{className:"w-full sm:w-36",children:e.jsx(qs,{placeholder:"Status"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Status"}),e.jsx(vt,{value:"live",children:"Live"}),e.jsx(vt,{value:"draft",children:"Draft"})]})]}),e.jsxs(Bs,{value:p,onValueChange:x,children:[e.jsx(Rs,{className:"w-full sm:w-44",children:e.jsx(qs,{placeholder:"Sort by"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"newest",children:"Newest First"}),e.jsx(vt,{value:"oldest",children:"Oldest First"}),e.jsx(vt,{value:"name",children:"Name A–Z"}),e.jsx(vt,{value:"slug",children:"Slug A–Z"}),e.jsx(vt,{value:"views_desc",children:"Most Views"}),e.jsx(vt,{value:"views_asc",children:"Fewest Views"}),e.jsx(vt,{value:"leads_desc",children:"Most Leads"}),e.jsx(vt,{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(IM,{className:"h-4 w-4"})}),e.jsx(K,{variant:y==="grid"?"default":"ghost",size:"sm",onClick:()=>_("grid"),className:"rounded-l-none",children:e.jsx(fp,{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(E=>e.jsx(Ns,{className:"h-48"},E))}):C.length>0?y==="table"?e.jsx(r4s,{cards:C,cardProfiles:w,cardStats:k,onEdit:n,sortBy:p,setSortBy:x}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:C.map(E=>e.jsx(n4s,{card:E,onEdit:()=>n(E),stats:k==null?void 0:k[E.id]},E.id))}):t&&t.length>0?e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(an,{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(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(lr,{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(Us,{className:"h-4 w-4 mr-2"}),"Create Card"]})]})})]}),e.jsx(a4s,{open:a,onOpenChange:o}),r&&e.jsx(i4s,{card:r,open:!!r,onOpenChange:E=>!E&&n(null)})]})}function r4s({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(Ph,{className:"h-3 w-3"}):a===`${d}_asc`?e.jsx(du,{className:"h-3 w-3"}):e.jsx(td,{className:"h-3 w-3 opacity-40"});return e.jsx(Pe,{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(du,{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],x=`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(Qe,{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(ga,{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(x),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:x,target:"_blank",rel:"noopener noreferrer",children:e.jsx(Kr,{className:"h-3.5 w-3.5"})})})]})})]},d.id)})})]})})})}function n4s({card:t,onEdit:s,stats:r}){const[n,a]=S.useState(null);S.useEffect(()=>{(async()=>{const{data:d}=await G.from("profiles").select("name").eq("id",t.user_id).single();let u=null;try{const{data:p}=await G.storage.from("avatars").list(`${t.user_id}`);if(p&&p.length>0){const{data:x}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${p[0].name}`);u=x.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(Pe,{children:e.jsxs(Re,{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(Ta,{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(Qe,{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(wn,{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(lr,{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(ga,{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 a4s({open:t,onOpenChange:s}){const[r,n]=S.useState(""),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState(!1),p=mWe(),x=l.trim(),{data:y}=gt({queryKey:["profiles-search-for-cards",x],queryFn:async()=>{let C=G.from("profiles").select("id, name, email").order("name").limit(50);x.length>=2&&(C=C.or(`name.ilike.%${x}%,email.ilike.%${x}%`));const{data:E}=await C;return E||[]},enabled:t}),[_,b]=S.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("")}})},k=C=>{var L;n(C),u(!1);const E=y==null?void 0:y.find(I=>I.id===C);E&&(b(E),o(((L=E.name)==null?void 0:L.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(Ir,{children:"Select an agent and set their card URL slug."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Agent"}),e.jsxs(xo,{open:d,onOpenChange:u,children:[e.jsx(go,{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(gx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(lo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Sx,{shouldFilter:!1,children:[e.jsx(Cx,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:"No agents found."}),e.jsx(Ax,{children:(y||[]).map(C=>e.jsxs(lp,{value:C.id,onSelect:k,children:[e.jsx(Jn,{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(xe,{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(De,{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 i4s({card:t,open:s,onOpenChange:r}){const n=pWe(),{data:a}=fWe(t.id),o=Jt(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,x]=S.useState(!1),[y,_]=S.useState(""),[b,N]=S.useState(t.slug),[w,k]=S.useState(!1),[C,E]=S.useState({is_published:t.is_published,theme:t.theme,title:t.title||"",positioning_statement:t.positioning_statement||"",bio:t.bio||"",review_snippet:t.review_snippet||"",review_source_url:t.review_source_url||"",booking_url:t.booking_url||"",custom_cta_label:t.custom_cta_label||"",custom_cta_url:t.custom_cta_url||"",show_photo:t.show_photo,show_bio:t.show_bio,show_credentials:t.show_credentials,show_social_links:t.show_social_links,show_save_contact:t.show_save_contact,show_leave_review:t.show_leave_review,show_refer_friend:t.show_refer_friend,brokerage_display_name:t.brokerage_display_name||"",brokerage_logo_url:t.brokerage_logo_url||"",brokerage_logo_size:t.brokerage_logo_size||56,team_name:t.team_name||"",team_logo_url:t.team_logo_url||"",team_logo_size:t.team_logo_size||56});S.useEffect(()=>{s&&(async()=>{try{const{data:U}=await G.storage.from("avatars").list(`${t.user_id}`);if(U&&U.length>0){const{data:se}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${U[0].name}`);i(`${se.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const L=$=>{var Y;const U=(Y=$.target.files)==null?void 0:Y[0];if(!U)return;if(!U.type.startsWith("image/")){me.error("Please select an image file");return}if(U.size>5*1024*1024){me.error("Image must be under 5MB");return}const se=new FileReader;se.onloadend=()=>{_(se.result),x(!0)},se.readAsDataURL(U),$.target.value=""},I=async $=>{u(!0);try{const{data:U}=await G.storage.from("avatars").list(`${t.user_id}`);U&&U.length>0&&await G.storage.from("avatars").remove(U.map(ce=>`${t.user_id}/${ce.name}`));const se=`${t.user_id}/avatar.jpg`,{error:Y}=await G.storage.from("avatars").upload(se,$,{upsert:!0,contentType:"image/jpeg"});if(Y)throw Y;const{data:J}=G.storage.from("avatars").getPublicUrl(se),X=`${J.publicUrl}?t=${Date.now()}`;i(X),await G.from("profiles").update({avatar_url:X}).eq("id",t.user_id),o.invalidateQueries({queryKey:["agent-card-public"]}),me.success("Photo updated!")}catch(U){me.error(U.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}k(!0);try{const{data:U}=await G.from("agent_cards").select("id").eq("slug",$).neq("id",t.id).maybeSingle();if(U){me.error("This URL is already taken. Try another one.");return}const{error:se}=await G.from("agent_cards").update({slug:$}).eq("id",t.id);if(se)throw se;N($),o.invalidateQueries({queryKey:["agent-cards-admin"]}),me.success("Card address updated!")}catch{me.error("Failed to update card address")}finally{k(!1)}},V=async($,U)=>{var Y;const se=(Y=$.target.files)==null?void 0:Y[0];if(se){if(!se.type.startsWith("image/")){me.error("Please select an image file");return}try{const J=se.name.split(".").pop()||"png",X=U==="brokerage_logo_url"?"brokerage-logo":"team-logo",ce=`${t.user_id}/${X}.${J}`,{error:ie}=await G.storage.from("card-logos").upload(ce,se,{upsert:!0});if(ie)throw ie;const{data:ae}=G.storage.from("card-logos").getPublicUrl(ce),oe=ae.publicUrl+"?t="+Date.now();E(U==="brokerage_logo_url"?pe=>({...pe,[U]:oe,brokerage_display_name:""}):pe=>({...pe,[U]:oe,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(Ir,{children:["/card/",t.slug]})]}),e.jsxs(ia,{defaultValue:"content",children:[e.jsxs(ea,{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(xe,{children:"Published"}),e.jsx(Er,{checked:C.is_published,onCheckedChange:$=>E(U=>({...U,is_published:$}))})]}),e.jsxs("div",{children:[e.jsx(xe,{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(Ta,{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:L,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(_s,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx($a,{className:"h-3 w-3 mr-1"}),"Change Photo"]})})})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{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(De,{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(xe,{children:"Theme"}),e.jsxs(Bs,{value:C.theme,onValueChange:$=>E(U=>({...U,theme:$})),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"standard",children:"✨ Standard (Modern Clean)"}),e.jsx(vt,{value:"luxury",children:"🌙 Luxury (Dark & Gold)"}),e.jsx(vt,{value:"bold",children:"🔥 Bold (Vibrant & Punchy)"}),e.jsx(vt,{value:"classic",children:"📋 Classic (Professional)"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Title / Tagline"}),e.jsx(De,{value:C.title,onChange:$=>E(U=>({...U,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(xe,{children:"Positioning Statement"}),e.jsx(De,{value:C.positioning_statement,onChange:$=>E(U=>({...U,positioning_statement:$.target.value})),placeholder:"Your home journey, handled with care."})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Bio"}),e.jsx(vr,{value:C.bio,onChange:$=>E(U=>({...U,bio:$.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Review Snippet"}),e.jsx(De,{value:C.review_snippet,onChange:$=>E(U=>({...U,review_snippet:$.target.value})),placeholder:"Best agent we've ever worked with..."})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Review Source URL"}),e.jsx(De,{value:C.review_source_url,onChange:$=>E(U=>({...U,review_source_url:$.target.value})),placeholder:"https://g.page/your-business/review"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Booking URL (optional — if empty, shows lead form)"}),e.jsx(De,{value:C.booking_url,onChange:$=>E(U=>({...U,booking_url:$.target.value})),placeholder:"https://calendly.com/your-link"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Custom CTA Label (optional)"}),e.jsx(De,{value:C.custom_cta_label,onChange:$=>E(U=>({...U,custom_cta_label:$.target.value})),placeholder:"Book a Call"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Custom CTA URL (optional)"}),e.jsx(De,{value:C.custom_cta_url,onChange:$=>E(U=>({...U,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(xe,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{value:C.brokerage_display_name,onChange:$=>E(U=>({...U,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:()=>E($=>({...$,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($a,{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:$=>V($,"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(xe,{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(Cg,{value:[C.brokerage_logo_size||56],onValueChange:([$])=>E(U=>({...U,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(xe,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{value:C.team_name,onChange:$=>E(U=>({...U,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:()=>E($=>({...$,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($a,{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:$=>V($,"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(xe,{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(Cg,{value:[C.team_logo_size||56],onValueChange:([$])=>E(U=>({...U,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:U,hint:se})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(xe,{children:U}),se&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[se," ",$==="show_photo"&&e.jsx("a",{href:"/profile",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:"Update Profile"})]})]}),e.jsx(Er,{checked:C[$],onCheckedChange:Y=>E(J=>({...J,[$]:Y}))})]},$))}),e.jsx(js,{value:"blocks",className:"mt-4",children:e.jsx(blt,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{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(Qe,{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(Yke,{open:p,onClose:()=>x(!1),imageSrc:y,onCropComplete:I,aspectRatio:1})]})}const rT={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"},zCe={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 BCe(t=!0){return gt({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 o4s(){const t=Jt();return It({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 l4s(){const t=Jt();return It({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 c4s(){const t=Jt();return It({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 Rlt(t,s=!0){return gt({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 d4s(t){return gt({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 u4s(){const t=Jt();return It({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 h4s(){const t=Jt();return It({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 m4s(){const t=Jt();return It({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 p4s(){const t=Jt();return It({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 f4s(){const t=Jt();return It({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 x4s(){const t=Jt();return It({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 g4s(){const t=Jt();return It({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 y4s(){const t=Jt();return It({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 v4s(){const t=Jt();return It({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 _4s(t){const{isAdmin:s}=Fs();return gt({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 b4s(){const{user:t}=Fs();return gt({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 w4s(t){return gt({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 j4s(){const t=Jt(),{user:s}=Fs();return It({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 N4s(){const t=Jt();return It({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 k4s(){const t=Jt();return It({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 S4s(){const t=Jt();return It({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 C4s(){const{data:t,isLoading:s}=BCe(!1),r=o4s(),n=l4s(),a=c4s(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),x=()=>{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),x()},b=async N=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(N)};return s?e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ns,{className:"h-8 w-48"})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(N=>e.jsx(Ns,{className:"h-12 w-full"},N))})})]}):e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{children:"Categories"}),e.jsxs(fs,{open:o,onOpenChange:N=>{l(N),N||x()},children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Us,{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(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{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(xe,{htmlFor:"description",children:"Description"}),e.jsx(vr,{id:"description",value:u.description,onChange:N=>p({...u,description:N.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"image_url",children:"Image URL"}),e.jsx(De,{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(xe,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(De,{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(Er,{id:"is_active",checked:u.is_active,onCheckedChange:N=>p({...u,is_active:N})}),e.jsx(xe,{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(Re,{children:t&&t.length>0?e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:t.map(N=>e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium",children:N.name}),e.jsx(ut,{className:"max-w-xs truncate",children:N.description}),e.jsx(ut,{children:N.sort_order}),e.jsx(ut,{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(ut,{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(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(N.id),disabled:a.isPending,children:e.jsx(gr,{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 M4s(){var he,we;const{data:t,isLoading:s}=Rlt(void 0,!1),{data:r}=BCe(!1),n=u4s(),a=h4s(),o=m4s(),l=p4s(),i=f4s(),d=x4s(),u=g4s(),p=y4s(),x=v4s(),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.useState(!1),[C,E]=S.useState(null),[L,I]=S.useState(null),[O,V]=S.useState(!1),[q,$]=S.useState({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),[U,se]=S.useState({name:"",price_adjustment:0}),[Y,J]=S.useState(""),X=()=>{$({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),E(null)},ce=je=>{E(je),$({name:je.name,description:je.description||"",base_price:Number(je.base_price),shipping_fee:Number(je.shipping_fee),category_id:je.category_id||"",allow_artwork_upload:je.allow_artwork_upload,requires_proof_approval:je.requires_proof_approval,is_active:je.is_active,sort_order:je.sort_order}),_(!0)},ie=async je=>{je.preventDefault();const Ue={...q,category_id:q.category_id||null};C?await a.mutateAsync({id:C.id,...Ue}):await n.mutateAsync(Ue),_(!1),X()},ae=async je=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(je)},oe=async je=>{if(!L||!je.target.files||je.target.files.length===0)return;V(!0);const Ue=je.target.files[0],Te=Ue.name.split(".").pop(),Me=`products/${L.id}/${Date.now()}.${Te}`;try{const{error:Fe}=await G.storage.from("marketplace").upload(Me,Ue);if(Fe)throw Fe;const{data:{publicUrl:Le}}=G.storage.from("marketplace").getPublicUrl(Me);await l.mutateAsync({product_id:L.id,image_url:Le,is_primary:!L.images||L.images.length===0}),me.success("Image uploaded successfully")}catch(Fe){me.error("Failed to upload image: "+Fe.message)}finally{V(!1)}},pe=async je=>{je.preventDefault(),L&&(await u.mutateAsync({product_id:L.id,name:U.name,price_adjustment:U.price_adjustment}),se({name:"",price_adjustment:0}))},_e=async()=>{!L||!Y||(await x.mutateAsync({productId:L.id,videoUrl:Y}),J(""))};return s?e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ns,{className:"h-8 w-48"})}),e.jsx(Re,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(je=>e.jsx(Ns,{className:"h-64 w-full"},je))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{children:"Products"}),e.jsxs(fs,{open:y,onOpenChange:je=>{_(je),je||X()},children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Us,{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:ie,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Product Name"}),e.jsx(De,{id:"name",value:q.name,onChange:je=>$({...q,name:je.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"category",children:"Category"}),e.jsxs(Bs,{value:q.category_id,onValueChange:je=>$({...q,category_id:je}),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select category"})}),e.jsx(Os,{children:r==null?void 0:r.map(je=>e.jsx(vt,{value:je.id,children:je.name},je.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(vr,{id:"description",value:q.description,onChange:je=>$({...q,description:je.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(xe,{htmlFor:"base_price",children:"Base Price ($)"}),e.jsx(De,{id:"base_price",type:"number",step:"0.01",min:"0",value:q.base_price,onChange:je=>$({...q,base_price:parseFloat(je.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),e.jsx(De,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:q.shipping_fee,onChange:je=>$({...q,shipping_fee:parseFloat(je.target.value)||0})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(De,{id:"sort_order",type:"number",value:q.sort_order,onChange:je=>$({...q,sort_order:parseInt(je.target.value)||0})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Er,{id:"allow_artwork_upload",checked:q.allow_artwork_upload,onCheckedChange:je=>$({...q,allow_artwork_upload:je})}),e.jsx(xe,{htmlFor:"allow_artwork_upload",children:"Allow customer to upload artwork"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Er,{id:"requires_proof_approval",checked:q.requires_proof_approval,onCheckedChange:je=>$({...q,requires_proof_approval:je})}),e.jsx(xe,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Er,{id:"is_active",checked:q.is_active,onCheckedChange:je=>$({...q,is_active:je})}),e.jsx(xe,{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(Re,{children:t&&t.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(je=>{var Ue,Te;return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[je.images&&je.images.length>0?e.jsx("img",{src:((Ue=je.images.find(Me=>Me.is_primary))==null?void 0:Ue.image_url)||je.images[0].image_url,alt:je.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"}),!je.is_active&&e.jsx(Qe,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),e.jsxs(Re,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1",children:je.name}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:((Te=je.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(je.base_price).toFixed(2)]}),Number(je.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["+$",Number(je.shipping_fee).toFixed(2)," shipping"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[je.allow_artwork_upload&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),je.requires_proof_approval&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Proof Required"}),je.variants&&je.variants.length>0&&e.jsxs(Qe,{variant:"outline",className:"text-xs",children:[je.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ce(je),children:[e.jsx(ga,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{I(je),N(!0)},children:[e.jsx(Yv,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{I(je),k(!0)},children:[e.jsx(hh,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ae(je.id),children:e.jsx(gr,{className:"h-3 w-3 text-destructive"})})]})]})]},je.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 - ",L==null?void 0:L.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-4",children:(he=L==null?void 0:L.images)==null?void 0:he.map(je=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:je.image_url,alt:"",className:"w-full aspect-square object-cover rounded-lg"}),je.is_primary&&e.jsx(Qe,{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:[!je.is_primary&&e.jsx(K,{variant:"secondary",size:"icon",onClick:async()=>{var Ue;await d.mutateAsync({imageId:je.id,productId:L.id}),I({...L,images:(Ue=L.images)==null?void 0:Ue.map(Te=>({...Te,is_primary:Te.id===je.id}))})},disabled:d.isPending,title:"Set as primary",children:e.jsx(Hn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"destructive",size:"icon",onClick:async()=>{var Te;await i.mutateAsync({id:je.id,productId:L.id});const Ue=t==null?void 0:t.find(Me=>Me.id===L.id);Ue&&I({...Ue,images:(Te=Ue.images)==null?void 0:Te.filter(Me=>Me.id!==je.id)})},disabled:i.isPending,children:e.jsx(gr,{className:"h-4 w-4"})})]})]},je.id))}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:oe,className:"hidden",id:"image-upload",disabled:O}),e.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer",children:[e.jsx(Yv,{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(xe,{children:"Product Video (optional)"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(De,{placeholder:"Enter video URL (YouTube, Vimeo, etc.)",value:Y,onChange:je=>J(je.target.value)}),e.jsxs(K,{onClick:_e,disabled:!Y,children:[e.jsx(Tn,{className:"h-4 w-4 mr-2"}),"Set Video"]})]}),(L==null?void 0:L.video)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Current video: ",L.video.video_url]})]})]})]})}),e.jsx(fs,{open:w,onOpenChange:k,children:e.jsxs(ms,{children:[e.jsx(ks,{children:e.jsxs(bs,{children:["Manage Variants - ",L==null?void 0:L.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:pe,className:"flex gap-2",children:[e.jsx(De,{placeholder:"Variant name (e.g., 500 count)",value:U.name,onChange:je=>se({...U,name:je.target.value}),required:!0}),e.jsx(De,{type:"number",step:"0.01",placeholder:"Price adj.",value:U.price_adjustment,onChange:je=>se({...U,price_adjustment:parseFloat(je.target.value)||0}),className:"w-32"}),e.jsx(K,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(we=L==null?void 0:L.variants)==null?void 0:we.map(je=>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:je.name}),e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:[Number(je.price_adjustment)>=0?"+":"","$",Number(je.price_adjustment).toFixed(2)]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutateAsync({id:je.id,productId:L.id}),children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]},je.id)),(!(L!=null&&L.variants)||L.variants.length===0)&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:'No variants yet. Add variants like "250 count", "500 count", etc.'})]})]})]})})]})}const T4s=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function A4s(){var N,w,k;const{data:t,isLoading:s}=_4s(),r=j4s(),n=N4s(),[a,o]=S.useState(null),[l,i]=S.useState(!1),[d,u]=S.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[p,x]=S.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,E)=>{if(!a||!C.target.files||C.target.files.length===0)return;x(!0);const L=C.target.files[0],I=L.name.split(".").pop(),O=`proofs/${a.id}/${E}/${Date.now()}.${I}`;try{const{error:V}=await G.storage.from("marketplace").upload(O,L);if(V)throw V;const{data:{publicUrl:q}}=G.storage.from("marketplace").getPublicUrl(O);await n.mutateAsync({itemId:E,proofUrl:q,orderId:a.id}),me.success("Proof uploaded successfully")}catch(V){me.error("Failed to upload proof: "+V.message)}finally{x(!1)}};return s?e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ns,{className:"h-8 w-48"})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(C=>e.jsx(Ns,{className:"h-16 w-full"},C))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Orders"})}),e.jsx(Re,{children:t&&t.length>0?e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:t.map(C=>{var E,L;return e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-mono",children:C.order_number}),e.jsx(ut,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((E=C.user)==null?void 0:E.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(L=C.user)==null?void 0:L.email})]})}),e.jsx(ut,{children:ps(new Date(C.created_at),"MMM d, yyyy")}),e.jsxs(ut,{className:"font-bold",children:["$",Number(C.total).toFixed(2)]}),e.jsx(ut,{children:e.jsx(Qe,{className:zCe[C.status],children:rT[C.status]})}),e.jsx(ut,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>y(C),children:[e.jsx(wn,{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:(k=a.items)==null?void 0:k.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(Qe,{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:E=>b(E,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($a,{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(xe,{children:"Status"}),e.jsxs(Bs,{value:d.status,onValueChange:C=>u({...d,status:C}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:T4s.map(C=>e.jsx(vt,{value:C,children:rT[C]},C))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Tracking Number"}),e.jsx(De,{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(xe,{children:"Tracking URL"}),e.jsx(De,{value:d.trackingUrl,onChange:C=>u({...d,trackingUrl:C.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Notes (optional)"}),e.jsx(vr,{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(nl,{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(Qe,{variant:"outline",children:rT[C.status]}),C.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:C.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:ps(new Date(C.created_at),"MMM d, h:mm a")})]},C.id))})]})]})]})})]})}function E4s(){const[t,s]=S.useState("products"),r=_r();return e.jsx(Es,{title:"Marketplace Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Marketplace Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage products, categories, and orders"})]}),e.jsxs(K,{variant:"outline",onClick:()=>r("/marketplace"),children:[e.jsx(Kr,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(ia,{value:t,onValueChange:s,children:[e.jsxs(ea,{className:"grid w-full grid-cols-3",children:[e.jsxs(ls,{value:"products",className:"flex items-center gap-2",children:[e.jsx(nl,{className:"h-4 w-4"}),"Products"]}),e.jsxs(ls,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(Mm,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(ls,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(op,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(js,{value:"products",children:e.jsx(M4s,{})}),e.jsx(js,{value:"categories",children:e.jsx(C4s,{})}),e.jsx(js,{value:"orders",children:e.jsx(A4s,{})})]})]})})}function Olt(){return gt({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 P4s(t){return gt({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 I4s(t){return gt({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 L4s(t){return gt({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 D4s(){return gt({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 R4s(t){return gt({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 O4s(){const t=Jt();return It({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 F4s(){const t=Jt();return It({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 z4s(){const t=Jt();return It({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 B4s(){const t=Jt();return It({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 $4s(){const t=Jt();return It({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 q4s(){const t=Jt();return It({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 U4s(){const t=Jt();return It({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 V4s(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function v0e(t,s){const r=V4s(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 Flt(){return gt({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 H4s(){const t=Jt();return It({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 G4s(){const{user:t}=Fs(),[s,r]=S.useState("items"),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState(""),[u,p]=S.useState(""),[x,y]=S.useState(""),[_,b]=S.useState(null),[N,w]=S.useState(!1),[k,C]=S.useState(null),[E,L]=S.useState(""),[I,O]=S.useState(""),[V,q]=S.useState(null),[$,U]=S.useState(""),[se,Y]=S.useState("file"),[J,X]=S.useState(""),[ce,ie]=S.useState(""),[ae,oe]=S.useState(""),[pe,_e]=S.useState(!0),[he,we]=S.useState(null),[je,Ue]=S.useState(!1),[Te,Me]=S.useState(!1),Fe=S.useRef(null),Le=S.useRef(null),{data:Ne,isLoading:qe}=Olt(),{data:ze,isLoading:ve}=P4s(),{data:dt,isLoading:fe}=D4s(),{data:Ve,isLoading:Je}=Flt(),at=F4s(),Ae=z4s(),Ye=B4s(),We=$4s(),ot=q4s(),Ge=U4s(),et=H4s(),[ht,xt]=S.useState({}),Ke=zt=>{zt?(l(zt),d(zt.name),p(zt.description||""),y(zt.icon||"")):(l(null),d(""),p(""),y("")),a(!0)},Ze=async()=>{if(!i.trim()){me.error("Please enter a category name");return}try{o?(await Ae.mutateAsync({id:o.id,name:i,description:u||null,icon:x||null}),me.success("Category updated successfully")):(await at.mutateAsync({name:i,description:u||null,icon:x||null,sort_order:((Ne==null?void 0:Ne.length)||0)+1}),me.success("Category created successfully")),a(!1)}catch(zt){console.error("Error saving category:",zt),me.error("Failed to save category")}},Et=async()=>{if(_)try{await Ye.mutateAsync(_),me.success("Category deleted successfully"),b(null)}catch(zt){console.error("Error deleting category:",zt),me.error("Failed to delete category")}},$t=zt=>{var $s;zt?(C(zt),L(zt.name),O(zt.description||""),q(zt.category_id),U(zt.points_cost.toString()),Y(zt.item_type),X(zt.file_url||""),ie(zt.preview_image_url||""),oe((($s=zt.max_quantity)==null?void 0:$s.toString())||""),_e(zt.is_active)):(C(null),L(""),O(""),q(null),U(""),Y("file"),X(""),ie(""),oe(""),_e(!0)),w(!0)},Yt=async(zt,$s)=>{$s==="file"?Ue(!0):Me(!0);try{const kr=zt.name.split(".").pop(),Xs=`${Date.now()}-${Math.random().toString(36).substring(7)}.${kr}`,ir=`${$s==="file"?"items":"previews"}/${Xs}`,{error:Or}=await G.storage.from("reward-store").upload(ir,zt);if(Or)throw Or;const{data:{publicUrl:Vn}}=G.storage.from("reward-store").getPublicUrl(ir);$s==="file"?X(Vn):ie(Vn),me.success("File uploaded successfully")}catch(kr){console.error("Error uploading file:",kr),me.error("Failed to upload file")}finally{$s==="file"?Ue(!1):Me(!1)}},Ps=async()=>{if(!E.trim()){me.error("Please enter an item name");return}if(!$||parseInt($)<0){me.error("Please enter a valid points cost");return}try{const zt={name:E,description:I||null,category_id:V,points_cost:parseInt($),item_type:se,file_url:J||null,preview_image_url:ce||null,max_quantity:ae?parseInt(ae):null,current_quantity:ae?parseInt(ae):null,is_active:pe,created_by:t==null?void 0:t.id};k?(await ot.mutateAsync({id:k.id,...zt,current_quantity:k.max_quantity!==(ae?parseInt(ae):null)?ae?parseInt(ae):null:k.current_quantity}),me.success("Item updated successfully")):(await We.mutateAsync(zt),me.success("Item created successfully")),w(!1)}catch(zt){console.error("Error saving item:",zt),me.error("Failed to save item")}},zs=async()=>{if(he)try{await Ge.mutateAsync(he),me.success("Item deleted successfully"),we(null)}catch(zt){console.error("Error deleting item:",zt),me.error("Failed to delete item")}},Zs=async(zt,$s)=>{const kr=ht[zt];if(kr===void 0||kr===$s.toString())return;const Xs=parseInt(kr);if(isNaN(Xs)||Xs<0){me.error("Please enter a valid positive number");return}try{await et.mutateAsync({id:zt,points:Xs}),me.success("Points updated successfully"),xt(ir=>{const Or={...ir};return delete Or[zt],Or})}catch(ir){console.error("Error updating points:",ir),me.error("Failed to update points")}};return qe||ve||fe||Je?e.jsx(Es,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ns,{className:"h-8 w-64"}),e.jsx(Ns,{className:"h-96"})]})}):e.jsxs(Es,{title:"Reward Store",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Reward Store Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage store items that agents can purchase with their points"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(nl,{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:(ze==null?void 0:ze.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(ze==null?void 0:ze.filter(zt=>zt.is_active).length)||0," active"]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Mm,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(Ne==null?void 0:Ne.length)||0})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Hn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg. Cost"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[ze&&ze.length>0?Math.round(ze.reduce((zt,$s)=>zt+$s.points_cost,0)/ze.length):0," pts"]})]})})]}),e.jsxs(ia,{value:s,onValueChange:r,children:[e.jsxs(ea,{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(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Store Items"}),e.jsx(hr,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(K,{onClick:()=>$t(),children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx(Re,{children:!ze||ze.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ui,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:ze.map(zt=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[zt.preview_image_url?e.jsx("img",{src:zt.preview_image_url,alt:zt.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(Ui,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:zt.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:zt.description||"No description"})]})]})}),e.jsx(ut,{children:zt.category?e.jsx(Qe,{variant:"outline",children:zt.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ut,{className:"text-center",children:e.jsxs(Qe,{variant:"secondary",className:"font-bold",children:[e.jsx(Hn,{className:"h-3 w-3 mr-1"}),zt.points_cost]})}),e.jsx(ut,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[zt.item_type==="file"?e.jsx(fn,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(fo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:zt.item_type})]})}),e.jsx(ut,{className:"text-center",children:zt.max_quantity!==null?e.jsxs("span",{className:zt.current_quantity===0?"text-red-500":"",children:[zt.current_quantity,"/",zt.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(ut,{className:"text-center",children:e.jsx(Qe,{variant:zt.is_active?"default":"secondary",children:zt.is_active?"Active":"Inactive"})}),e.jsx(ut,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>$t(zt),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>we(zt.id),children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]})})]},zt.id))})]})})]})}),e.jsx(js,{value:"categories",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Categories"}),e.jsx(hr,{children:"Organize your store items into categories"})]}),e.jsxs(K,{onClick:()=>Ke(),children:[e.jsx(Us,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Re,{children:!Ne||Ne.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Mm,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No categories yet. Add your first category!"})]}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:Ne.map(zt=>e.jsxs(Ms,{children:[e.jsxs(ut,{className:"font-medium",children:[zt.icon&&e.jsx("span",{className:"mr-2",children:zt.icon}),zt.name]}),e.jsx(ut,{className:"text-muted-foreground",children:zt.description||"—"}),e.jsx(ut,{className:"text-center",children:(ze==null?void 0:ze.filter($s=>$s.category_id===zt.id).length)||0}),e.jsx(ut,{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(zt),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(zt.id),children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})})]})})]},zt.id))})]})})]})}),e.jsx(js,{value:"purchases",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(op,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(hr,{children:"View all reward redemptions by agents"})]}),e.jsx(Re,{children:!dt||dt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(op,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No purchases yet."})]}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:dt.map(zt=>{var $s,kr,Xs,ir;return e.jsxs(Ms,{children:[e.jsx(ut,{className:"text-muted-foreground",children:ps(new Date(zt.purchased_at),"MMM d, yyyy 'at' h:mm a")}),e.jsx(ut,{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(Ti,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:(($s=zt.user)==null?void 0:$s.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((kr=zt.user)==null?void 0:kr.email)||"—"})]})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(Xs=zt.item)!=null&&Xs.preview_image_url?e.jsx("img",{src:zt.item.preview_image_url,alt:zt.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(Ui,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((ir=zt.item)==null?void 0:ir.name)||"Deleted item"})]})}),e.jsx(ut,{className:"text-center",children:e.jsxs(Qe,{variant:"secondary",className:"font-bold",children:[e.jsx(Hn,{className:"h-3 w-3 mr-1"}),zt.points_spent]})})]},zt.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(Ir,{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(xe,{htmlFor:"categoryName",children:"Name"}),e.jsx(De,{id:"categoryName",value:i,onChange:zt=>d(zt.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(vr,{id:"categoryDescription",value:u,onChange:zt=>p(zt.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(De,{id:"categoryIcon",value:x,onChange:zt=>y(zt.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{onClick:Ze,disabled:at.isPending||Ae.isPending,children:at.isPending||Ae.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:k?"Edit Item":"Add Item"}),e.jsx(Ir,{children:k?"Update the item details":"Create a new reward item for agents to purchase"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"itemName",children:"Name *"}),e.jsx(De,{id:"itemName",value:E,onChange:zt=>L(zt.target.value),placeholder:"e.g., Premium Template Pack"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"itemDescription",children:"Description"}),e.jsx(vr,{id:"itemDescription",value:I,onChange:zt=>O(zt.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(xe,{htmlFor:"itemCategory",children:"Category"}),e.jsxs(Bs,{value:V||"none",onValueChange:zt=>q(zt==="none"?null:zt),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select category"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"No category"}),Ne==null?void 0:Ne.map(zt=>e.jsxs(vt,{value:zt.id,children:[zt.icon&&`${zt.icon} `,zt.name]},zt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(De,{id:"itemPointsCost",type:"number",min:"0",value:$,onChange:zt=>U(zt.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(xe,{htmlFor:"itemType",children:"Type"}),e.jsxs(Bs,{value:se,onValueChange:Y,children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"file",children:"File Download"}),e.jsx(vt,{value:"link",children:"External Link"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),e.jsx(De,{id:"itemMaxQuantity",type:"number",min:"1",value:ae,onChange:zt=>oe(zt.target.value),placeholder:"Leave empty for unlimited"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"File / Link URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:J,onChange:zt=>X(zt.target.value),placeholder:se==="file"?"Upload a file or paste URL":"Paste external link"}),se==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var zt;return(zt=Fe.current)==null?void 0:zt.click()},disabled:je,children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx("input",{ref:Fe,type:"file",className:"hidden",onChange:zt=>{var kr;const $s=(kr=zt.target.files)==null?void 0:kr[0];$s&&Yt($s,"file")}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Preview Image"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:ce,onChange:zt=>ie(zt.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var zt;return(zt=Le.current)==null?void 0:zt.click()},disabled:Te,children:e.jsx(Wo,{className:"h-4 w-4"})}),e.jsx("input",{ref:Le,type:"file",accept:"image/*",className:"hidden",onChange:zt=>{var kr;const $s=(kr=zt.target.files)==null?void 0:kr[0];$s&&Yt($s,"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(Er,{id:"itemIsActive",checked:pe,onCheckedChange:_e}),e.jsx(xe,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(K,{onClick:Ps,disabled:We.isPending||ot.isPending,children:We.isPending||ot.isPending?"Saving...":"Save"})]})]})}),e.jsx(tc,{open:!!_,onOpenChange:()=>b(null),children:e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Delete Category"}),e.jsx(Pl,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:Et,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(tc,{open:!!he,onOpenChange:()=>we(null),children:e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Delete Item"}),e.jsx(Pl,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:zs,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Pe,{className:"mt-4",children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ko,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(Ot,{children:"Point Reward Settings"}),e.jsx(hr,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx(Re,{children:!Ve||Ve.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ko,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No point settings configured."})]}):e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:Ve.map(zt=>e.jsxs(Ms,{children:[e.jsx(ut,{children:e.jsx("p",{className:"font-medium",children:zt.action_name})}),e.jsx(ut,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:zt.description})}),e.jsx(ut,{className:"text-center",children:e.jsx(De,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:ht[zt.id]??zt.points.toString(),onChange:$s=>xt(kr=>({...kr,[zt.id]:$s.target.value}))})}),e.jsx(ut,{className:"text-right",children:e.jsx(K,{size:"sm",variant:"outline",disabled:ht[zt.id]===void 0||ht[zt.id]===zt.points.toString()||et.isPending,onClick:()=>Zs(zt.id,zt.points),children:e.jsx(_c,{className:"h-4 w-4"})})})]},zt.id))})]})})]})]})}const o9e=()=>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"})]}),l9e=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function W4s(){const t=Jt(),[s,r]=S.useState(!1),[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:u,isLoading:p}=gt({queryKey:["canva-integration"],queryFn:async()=>{const{data:C,error:E}=await G.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(E)throw E;return C}}),{data:x}=gt({queryKey:["brokerages-list"],queryFn:async()=>{const{data:C,error:E}=await G.from("brokerages").select("id, name").order("name");if(E)throw E;return C}}),{data:y}=gt({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:C,error:E}=await G.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(E)throw E;return C}}),_=async()=>{var C;r(!0);try{const{data:E}=await G.auth.getSession(),L=(C=E==null?void 0:E.session)==null?void 0:C.access_token;if(!L)throw new Error("Not authenticated");const V=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${L}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"get_auth_url"})}),q=await V.json();if(!V.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 U=Y=>{var J,X;Y.origin===window.location.origin&&(((J=Y.data)==null?void 0:J.type)==="canva-oauth-success"?(window.removeEventListener("message",U),me.success("Canva connected successfully!"),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1)):((X=Y.data)==null?void 0:X.type)==="canva-oauth-error"&&(window.removeEventListener("message",U),me.error("Canva connection failed: "+(Y.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",U);const se=setInterval(()=>{$.closed&&(clearInterval(se),window.removeEventListener("message",U),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(E){console.error("Canva connect error:",E);const L=(E==null?void 0:E.message)||"";L.includes("CANVA_CLIENT_ID")?me.error("Canva app credentials not configured yet."):me.error(L||"Failed to start Canva connection"),r(!1)}},b=It({mutationFn:async C=>{var $;const{data:E}=await G.auth.getSession(),L=($=E==null?void 0:E.session)==null?void 0:$.access_token;if(!L)throw new Error("Not authenticated");const V=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${L}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"disconnect",integrationId:C})}),q=await V.json();if(!V.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=It({mutationFn:async C=>{const{error:E}=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(E)throw E},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=It({mutationFn:async C=>{const{error:E}=await G.from("canva_brokerage_folders").delete().eq("id",C);if(E)throw E},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),me.success("Folder removed")},onError:()=>me.error("Failed to remove folder")}),k=!!u;return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{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(o9e,{})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Canva Connect",k&&e.jsx(Qe,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(hr,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx(Re,{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(ti,{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(ti,{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(ti,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"Multiple folders per brokerage (templates, brand assets, listings)"})]}),e.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-muted border border-dashed",children:[e.jsx("p",{className:"text-xs font-medium text-foreground mb-1",children:"Canva App Redirect URL"}),e.jsx("code",{className:"text-xs text-muted-foreground break-all select-all",children:"https://dashboard.relevelup.com/canva-callback.html"})]}),k?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:u.canva_team_id?`Team: ${u.canva_team_id}`:"Canva Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u.expires_at?`Token expires ${new Date(u.expires_at).toLocaleDateString()}`:"Platform integration active"})]}),e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Disconnect Canva?"}),e.jsx(Pl,{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(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{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(Mm,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",y&&y.length>0&&e.jsx(Qe,{variant:"secondary",className:"text-xs",children:y.length})]}),n?e.jsx(nf,{className:"h-4 w-4"}):e.jsx(Oi,{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 E,L;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-muted/50 text-sm",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",children:C.folder_name}),e.jsx(Qe,{variant:"outline",className:"text-xs shrink-0",children:((E=l9e.find(I=>I.value===C.folder_type))==null?void 0:E.label)||C.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(L=C.brokerages)==null?void 0:L.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(Us,{className:"h-3.5 w-3.5"}),"Add Folder Mapping"]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:_,disabled:s||p,children:[s?e.jsx(oo,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx("div",{className:"mr-2",children:e.jsx(o9e,{})}),"Connect Canva",e.jsx(ei,{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(xe,{children:"Brokerage"}),e.jsxs(Bs,{value:i.brokerage_id,onValueChange:C=>d(E=>({...E,brokerage_id:C})),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select a brokerage…"})}),e.jsx(Os,{children:x==null?void 0:x.map(C=>e.jsx(vt,{value:C.id,children:C.name},C.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Canva Folder ID"}),e.jsx(De,{placeholder:"e.g. FABCdef123456",value:i.folder_id,onChange:C=>d(E=>({...E,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(xe,{children:"Folder Display Name"}),e.jsx(De,{placeholder:"e.g. Brand Templates 2024",value:i.folder_name,onChange:C=>d(E=>({...E,folder_name:C.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Folder Type"}),e.jsxs(Bs,{value:i.folder_type,onValueChange:C=>d(E=>({...E,folder_type:C})),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:l9e.map(C=>e.jsx(vt,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(xe,{children:["Description ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(De,{placeholder:"What's in this folder?",value:i.description,onChange:C=>d(E=>({...E,description:C.target.value}))})]})]}),e.jsxs(En,{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(oo,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function K4s(){return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(Uu,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx(W4s,{}),e.jsx(Ilt,{})]})})}const Z4s={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 yI(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function Y4s(){var se,Y,J,X,ce;const t=Jt(),[s,r]=S.useState("Test Push"),[n,a]=S.useState("Testing web push notification"),[o,l]=S.useState("/community"),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[x,y]=S.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[_,b]=S.useState(null),[N,w]=S.useState(null),{data:k,isLoading:C}=gt({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:ie,error:ae}=await G.from("push_notification_settings").select("*").order("setting_key");if(ae)throw ae;return ie}}),{data:E,isLoading:L}=gt({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:ie,error:ae}=await G.from("push_subscriptions").select("*",{count:"exact",head:!0});if(ae)throw ae;return{totalSubscriptions:ie||0}}}),I=It({mutationFn:async({settingKey:ie,isEnabled:ae})=>{const{error:oe}=await G.from("push_notification_settings").update({is_enabled:ae}).eq("setting_key",ie);if(oe)throw oe},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),me.success("Notification setting updated")},onError:ie=>{me.error("Failed to update setting: "+ie.message)}}),O=S.useMemo(()=>{var ie,ae;return x.isSupported?`perm=${x.permission??"unknown"} · controller=${x.controllerPresent?"yes":"no"} · sw=${((ie=x.serviceWorker)==null?void 0:ie.activeState)??"unknown"} · sub=${(ae=x.subscription)!=null&&ae.endpoint?"yes":"no"}`:"Push not supported in this browser."},[x]);S.useEffect(()=>{let ie=!0;const ae=async()=>{var he,we,je,Ue,Te,Me,Fe;const pe="serviceWorker"in navigator&&"PushManager"in window,_e={isSupported:pe,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((he=navigator.serviceWorker)!=null&&he.controller)};if(!pe){ie&&y(_e);return}try{const{data:Le,error:Ne}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(Ne)throw Ne;_e.vapidPublicKey=Le==null?void 0:Le.vapidPublicKey;const ze=(await navigator.serviceWorker.getRegistrations()).find(ve=>{var fe,Ve,Je;return(((fe=ve.active)==null?void 0:fe.scriptURL)||((Ve=ve.waiting)==null?void 0:Ve.scriptURL)||((Je=ve.installing)==null?void 0:Je.scriptURL)||"").includes("/sw.js")});if(ze){_e.pushWorkerScriptUrl=((we=ze.active)==null?void 0:we.scriptURL)||((je=ze.waiting)==null?void 0:je.scriptURL)||((Ue=ze.installing)==null?void 0:Ue.scriptURL),_e.serviceWorker={scope:ze.scope,activeState:(Te=ze.active)==null?void 0:Te.state};const ve=await ze.pushManager.getSubscription();if(ve){const dt=ve.toJSON();_e.subscription={endpoint:dt.endpoint,p256dh:(Me=dt.keys)==null?void 0:Me.p256dh,auth:(Fe=dt.keys)==null?void 0:Fe.auth}}}}catch(Le){_e.error=(Le==null?void 0:Le.message)||String(Le)}ie&&y(_e)};ae();const oe=window.setInterval(ae,4e3);return()=>{ie=!1,window.clearInterval(oe)}},[]);const V=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(ie){me.error(`Local notification failed: ${(ie==null?void 0:ie.message)||String(ie)}`)}},q=async()=>{d(!0),b(null);try{const{data:ie,error:ae}=await G.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(ae)throw ae;b({sent:ie==null?void 0:ie.sent,failed:ie==null?void 0:ie.failed,expiredCleaned:ie==null?void 0:ie.expiredCleaned,vapidPublicKey:ie==null?void 0:ie.vapidPublicKey}),(ie==null?void 0:ie.sent)>0?me.success(`Test notification sent to ${ie.sent} subscriber(s)`):(ie==null?void 0:ie.failed)>0?me.warning(`Notification failed for ${ie.failed} subscriber(s). ${ie.expired||0} expired subscriptions cleaned up.`):me.info("No active subscriptions to send to")}catch(ie){console.error("Error sending test notification:",ie),b({error:(ie==null?void 0:ie.message)||String(ie)}),me.error("Failed to send test notification: "+(ie.message||"Unknown error"))}finally{d(!1)}},$=async()=>{p(!0),w(null);try{const{data:ie,error:ae}=await G.functions.invoke("generate-vapid-keys",{body:{}});if(ae)throw ae;const oe=ie==null?void 0:ie.publicKey,pe=ie==null?void 0:ie.privateKey;if(!oe||!pe)throw new Error("generate-vapid-keys did not return keys");w({publicKey:oe,privateKey:pe}),me.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(ie){console.error("Error generating VAPID keys:",ie),me.error("Failed to generate VAPID keys: "+((ie==null?void 0:ie.message)||"Unknown error"))}finally{p(!1)}},U=It({mutationFn:async()=>{const{error:ie}=await G.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(ie)throw ie},onSuccess:()=>{me.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:ie=>{me.error("Failed to clear subscriptions: "+ie.message)}});return e.jsx(Es,{title:"Notification Settings",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(hr,{children:"Current active push notification subscriptions"})]}),e.jsx(Re,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-4xl font-bold",children:L?"...":(E==null?void 0:E.totalSubscriptions)||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(ko,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(hr,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(Re,{children:C?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:k==null?void 0:k.map(ie=>{const ae=Z4s[ie.setting_key]||{label:ie.setting_key,icon:"🔔"};return e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:ae.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ae.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ie.description})]})]}),e.jsx(Er,{checked:ie.is_enabled,onCheckedChange:oe=>I.mutate({settingKey:ie.setting_key,isEnabled:oe}),disabled:I.isPending})]},ie.id)})})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Sm,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(hr,{children:"Send a test push notification to all subscribed users"})]}),e.jsxs(Re,{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}),x.error&&e.jsx("div",{className:"mt-2 text-destructive",children:x.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:x.vapidPublicKey?yI(x.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: ",(se=x.serviceWorker)!=null&&se.scope?yI(x.serviceWorker.scope,24,8):"none"]}),e.jsxs("div",{children:["active: ",((Y=x.serviceWorker)==null?void 0:Y.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=x.subscription)!=null&&J.endpoint?yI(x.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(X=x.subscription)!=null&&X.p256dh?yI(x.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(ce=x.subscription)!=null&&ce.auth?yI(x.subscription.auth,22,10):"none"]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(K,{variant:"outline",onClick:V,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(xe,{htmlFor:"test-title",children:"Notification Title"}),e.jsx(De,{id:"test-title",value:s,onChange:ie=>r(ie.target.value),placeholder:"Enter notification title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"test-body",children:"Notification Body"}),e.jsx(vr,{id:"test-body",value:n,onChange:ie=>a(ie.target.value),placeholder:"Enter notification message",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"test-url",children:"Click URL (optional)"}),e.jsx(De,{id:"test-url",value:o,onChange:ie=>l(ie.target.value),placeholder:"/community or full URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Where users will be taken when they click the notification"})]}),e.jsxs(K,{onClick:q,disabled:i||!s||!n,className:"w-full sm:w-auto",children:[e.jsx(An,{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(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(gr,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(hr,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs(Re,{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:()=>U.mutate(),disabled:U.isPending,children:[e.jsx(gr,{className:"h-4 w-4 mr-2"}),U.isPending?"Clearing...":"Clear All Subscriptions"]}),e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"VAPID key rotation helper"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:"If you suspect the backend public/private keys don’t match, generate a fresh pair, update backend secrets, then clear subscriptions and have users re-enable push."}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:e.jsx(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 X4s(){const{toast:t}=wa(),[s,r]=S.useState([]),[n,a]=S.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=S.useState(!0),{sortKey:i,sortDirection:d,handleSort:u,sortData:p}=QR("presentation_count","desc"),x=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});S.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(I=>I.owner_user_id),{data:k,error:C}=await G.from("profiles").select("id, name, email, avatar_url").in("id",w);if(C)throw C;const E=new Map((k==null?void 0:k.map(I=>[I.id,I]))||[]),L=b.map(I=>{const O=E.get(I.owner_user_id);return{owner_user_id:I.owner_user_id,name:(O==null?void 0:O.name)||"Unknown",email:(O==null?void 0:O.email)||"",avatar_url:(O==null?void 0:O.avatar_url)||null,presentation_count:Number(I.presentation_count),total_views:Number(I.total_views),total_leads:Number(I.total_leads),total_cta_clicks:Number(I.total_cta_clicks)}});r(L),r(L),a({totalPresentations:L.reduce((I,O)=>I+O.presentation_count,0),totalViews:L.reduce((I,O)=>I+O.total_views,0),totalLeads:L.reduce((I,O)=>I+O.total_leads,0),totalCtaClicks:L.reduce((I,O)=>I+O.total_cta_clicks,0),agentsUsing:L.length})}catch(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:lr,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:Pg,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:wn,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:al,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:Tm,color:"text-rose-600"}];return e.jsx(Es,{title:"Presentation Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Presentation Analytics"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Track Smart Presentations usage and engagement across all agents"})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:_.map(b=>e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:b.label}),e.jsx(b.icon,{className:`h-4 w-4 ${b.color}`})]}),e.jsx(Re,{children:o?e.jsx(Ns,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:b.value.toLocaleString()})})]},b.label))}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Yo,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Re,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((b,N)=>e.jsx(Ns,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:x.map(b=>{var w,k;const N=b.total_views>0?(b.total_leads/b.total_views*100).toFixed(1):"0.0";return e.jsxs(Ms,{children:[e.jsx(ut,{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:((k=(w=b.name)==null?void 0:w.charAt(0))==null?void 0:k.toUpperCase())||"?"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:b.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:b.email})]})]})}),e.jsx(ut,{className:"text-center font-medium",children:b.presentation_count}),e.jsx(ut,{className:"text-center",children:b.total_views.toLocaleString()}),e.jsx(ut,{className:"text-center",children:b.total_leads>0?e.jsx(Qe,{variant:"secondary",children:b.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ut,{className:"text-center",children:b.total_cta_clicks}),e.jsx(ut,{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 Q4s(){const{toast:t}=wa(),[s,r]=S.useState([]),[n,a]=S.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=S.useState(!0);S.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:u,error:p}=await G.rpc("get_admin_guest_book_stats");if(p)throw p;if(!u||u.length===0){l(!1);return}const x=u.map(w=>w.agent_id),{data:y,error:_}=await G.from("profiles").select("id, name, email, avatar_url").in("id",x);if(_)throw _;const b=new Map((y==null?void 0:y.map(w=>[w.id,w]))||[]),N=u.map(w=>{const k=b.get(w.agent_id);return{agent_id:w.agent_id,name:(k==null?void 0:k.name)||"Unknown",email:(k==null?void 0:k.email)||"",avatar_url:(k==null?void 0:k.avatar_url)||null,open_house_count:Number(w.open_house_count),total_visitors:Number(w.total_visitors),total_leads:Number(w.total_leads),active_count:Number(w.active_count)}});N.sort((w,k)=>k.total_visitors-w.total_visitors),r(N),a({totalOpenHouses:N.reduce((w,k)=>w+k.open_house_count,0),totalVisitors:N.reduce((w,k)=>w+k.total_visitors,0),totalLeads:N.reduce((w,k)=>w+k.total_leads,0),activeOpenHouses:N.reduce((w,k)=>w+k.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:lr,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:Mn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:ti,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:wn,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:al,color:"text-rose-600"}];return e.jsx(Es,{title:"Guest Book Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Guest Book Analytics"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Track open house sign-in usage and lead generation across all agents"})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:d.map(u=>e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:u.label}),e.jsx(u.icon,{className:`h-4 w-4 ${u.color}`})]}),e.jsx(Re,{children:o?e.jsx(Ns,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:u.value.toLocaleString()})})]},u.label))}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Yo,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Re,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((u,p)=>e.jsx(Ns,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:s.map(u=>{var x,y;const p=u.total_visitors>0?(u.total_leads/u.total_visitors*100).toFixed(1):"0.0";return e.jsxs(Ms,{children:[e.jsx(ut,{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=(x=u.name)==null?void 0:x.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(ut,{className:"text-center font-medium",children:u.open_house_count}),e.jsx(ut,{className:"text-center",children:u.active_count>0?e.jsx(Qe,{variant:"secondary",className:"bg-emerald-100 text-emerald-700",children:u.active_count}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ut,{className:"text-center",children:u.total_visitors.toLocaleString()}),e.jsx(ut,{className:"text-center",children:u.total_leads>0?e.jsx(Qe,{variant:"secondary",children:u.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ut,{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 J4s(){const[t]=Nc(),s=_r(),[r,n]=S.useState("loading"),[a,o]=S.useState("Processing connection...");return S.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),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:x,error:y}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p}});if(y)throw y;if(x!=null&&x.success)n("success"),o(x.message||"Accounts connected successfully!"),me.success(x.message||"Social accounts connected!");else throw new Error((x==null?void 0:x.error)||"Failed to connect accounts")}catch(x){console.error("Callback error:",x),n("error"),o(x.message||"Failed to complete connection"),me.error(x.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(Pe,{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(_s,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(ti,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(Zl,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(Ot,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(hr,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function eSs(){const t=Jt(),[s,r]=S.useState(""),[n,a]=S.useState(""),[o,l]=S.useState([]),i=S.useRef(null),{data:d,isLoading:u}=gt({queryKey:["prospect-emails"],queryFn:async()=>{const{data:w,error:k}=await G.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(k)throw k;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},x=It({mutationFn:async w=>{const{data:k,error:C}=await G.functions.invoke("send-prospect-email",{body:{emails:w}});if(C)throw C;return k},onSuccess:w=>{t.invalidateQueries({queryKey:["prospect-emails"]}),me.success(`${w.sent} email${w.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:w=>{me.error("Failed to send: "+w.message)}}),y=It({mutationFn:async()=>{var E,L;const{data:{user:w}}=await G.auth.getUser();if(!(w!=null&&w.email))throw new Error("Could not get your email");const{data:k,error:C}=await G.functions.invoke("send-prospect-email",{body:{emails:[{email:w.email,first_name:(L=(E=w.user_metadata)==null?void 0:E.name)==null?void 0:L.split(" ")[0]}],test_mode:!0}});if(C)throw C;return k},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(k=>k.email.toLowerCase()===s.trim().toLowerCase())){me.error("This email has already been prospected");return}x.mutate([{email:s.trim(),first_name:n.trim()||void 0}])},b=w=>{var E;const k=(E=w.target.files)==null?void 0:E[0];if(!k)return;const C=new FileReader;C.onload=L=>{var $,U;const O=(($=L.target)==null?void 0:$.result).split(` `).filter(se=>se.trim()),V=[],q=(U=O[0])!=null&&U.toLowerCase().includes("email")?1:0;for(let se=q;sece.trim().replace(/"/g,"")),J=Y[0],X=Y[1];J&&J.includes("@")&&V.push({email:J,first_name:X||void 0})}l(V),me.success(`${V.length} entries loaded from CSV`)},C.readAsText(k),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()))||[]),k=o.filter(C=>!w.has(C.email.toLowerCase()));if(k.length===0){me.error("All emails have already been prospected");return}k.lengthy.mutate(),disabled:y.isPending,className:"gap-2 ml-4 shrink-0",children:[y.isPending?e.jsx(_s,{className:"h-3 w-3 animate-spin"}):e.jsx(rr,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),e.jsx(Re,{children:e.jsxs(ia,{defaultValue:"single",children:[e.jsxs(ea,{className:"mb-4",children:[e.jsxs(ls,{value:"single",children:[e.jsx(An,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(ls,{value:"bulk",children:[e.jsx($a,{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(xe,{htmlFor:"prospect-email",className:"sr-only",children:"Email"}),e.jsx(De,{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(xe,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),e.jsx(De,{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:x.isPending,className:"gap-2",children:[x.isPending?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(An,{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(fn,{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(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(lr,{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,k)=>e.jsxs("div",{className:"text-muted-foreground",children:[w.email,w.first_name?` — ${w.first_name}`:""]},k)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(K,{onClick:N,disabled:x.isPending,className:"gap-2",children:[x.isPending?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(An,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(rr,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(hr,{children:"Track all sent invitations and their conversion status"})]}),e.jsx(Re,{children:u?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((w,k)=>e.jsx(Ns,{className:"h-12 w-full"},k))}):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:ps(new Date(w.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:w.status==="converted"?e.jsxs(Qe,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[e.jsx(Qn,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(ln,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.converted_at?ps(new Date(w.converted_at),"MMM d, yyyy"):"—"})]},w.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Rh,{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 Jme(t){const s=Jt(),{toast:r}=wa(),n=gt({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=gt({queryKey:["recruit-prospects",t],queryFn:async()=>{if(!t)return[];const d=1e3;let u=[],p=0,x=!0;for(;x;){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),x=y.length===d,p+=d}return u},enabled:!!t}),o=It({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:x,error:y}=await G.from("recruit_prospects").insert(p).select().single();if(y)throw y;return x},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect added"})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),l=It({mutationFn:async({id:d,...u})=>{const{data:p,error:x}=await G.from("recruit_prospects").update({...u,updated_at:new Date().toISOString()}).eq("id",d).select().single();if(x)throw x;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),i=It({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 tSs(t){const s=Jt(),{toast:r}=wa(),n=gt({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=It({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 zlt({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=S.useState(c9e(n,r)),d=p=>x=>i(y=>({...y,[p]:x.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(ia,{defaultValue:"basic",className:"w-full",children:[e.jsxs(ea,{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(xe,{children:"First Name *"}),e.jsx(De,{required:!0,value:l.first_name,onChange:d("first_name")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Last Name"}),e.jsx(De,{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(xe,{children:"Email"}),e.jsx(De,{type:"email",value:l.email,onChange:d("email")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Phone"}),e.jsx(De,{value:l.phone,onChange:d("phone")})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Current Brokerage"}),e.jsx(De,{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(xe,{children:"License #"}),e.jsx(De,{value:l.license_number,onChange:d("license_number")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Experience (years)"}),e.jsx(De,{type:"number",min:"0",value:l.experience_years,onChange:d("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Address"}),e.jsx(De,{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(xe,{children:"City"}),e.jsx(De,{value:l.city,onChange:d("city")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"State"}),e.jsx(De,{value:l.state,onChange:d("state")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Zip"}),e.jsx(De,{value:l.zip_code,onChange:d("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Pipeline Stage"}),e.jsxs(Bs,{value:l.stage_id,onValueChange:p=>i(x=>({...x,stage_id:p})),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:r.map(p=>e.jsx(vt,{value:p.id,children:p.name},p.id))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Referred By"}),e.jsx(De,{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(xe,{children:"Annual Production Volume"}),e.jsx(De,{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(xe,{children:"Last Year Volume"}),e.jsx(De,{placeholder:"e.g. $8.2M",value:l.last_year_volume,onChange:d("last_year_volume")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Last Year Transactions"}),e.jsx(De,{type:"number",min:"0",placeholder:"e.g. 24",value:l.last_year_transactions,onChange:d("last_year_transactions")})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Avg Sale Price"}),e.jsx(De,{placeholder:"e.g. $350K",value:l.avg_sale_price,onChange:d("avg_sale_price")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Specialties / Niche"}),e.jsx(De,{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(xe,{children:"LinkedIn URL"}),e.jsx(De,{type:"url",placeholder:"https://linkedin.com/in/...",value:l.linkedin_url,onChange:d("linkedin_url")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Website URL"}),e.jsx(De,{type:"url",placeholder:"https://...",value:l.website_url,onChange:d("website_url")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Instagram Handle"}),e.jsx(De,{placeholder:"@handle",value:l.instagram_handle,onChange:d("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Facebook URL"}),e.jsx(De,{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(xe,{children:"Birthday"}),e.jsx(De,{type:"date",value:l.birthday,onChange:d("birthday")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Spouse / Partner Name"}),e.jsx(De,{value:l.spouse_name,onChange:d("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Interests / Hobbies"}),e.jsx(De,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:d("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Notes"}),e.jsx(vr,{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 Ywe=[{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 sSs(t){return gt({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 rSs(t){return gt({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 nSs(){const t=Jt(),{toast:s}=wa();return It({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 Blt(){const t=Jt();return It({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 $lt(t){return gt({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 aSs(){const t=Jt(),{toast:s}=wa();return It({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 iSs(){const t=Jt();return It({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 oSs({prospectId:t,prospectName:s,brokerageId:r}){var $;const{data:n=[],isLoading:a}=rSs(t),{data:o=[]}=$lt(r),l=nSs(),i=MC(),d=Blt(),[u,p]=S.useState("idle"),[x,y]=S.useState(0),[_,b]=S.useState(0),[N,w]=S.useState(""),[k,C]=S.useState(""),[E,L]=S.useState(!1),I=(($=o.find(U=>U.id===N))==null?void 0:$.script_text)||"",O=()=>{p("idle"),y(0),b(0),w(""),C("")},V=S.useCallback(async(U,se)=>{p("uploading");try{const Y=`Recruiting: ${s}`,{videoId:J,libraryId:X}=await xO(Y),{uploadUrl:ce,apiKey:ie}=await gO(J),ae=new XMLHttpRequest;ae.upload.onprogress=Te=>{Te.lengthComputable&&y(Te.loaded/Te.total*100)},await new Promise((Te,Me)=>{ae.onload=()=>ae.status>=200&&ae.status<300?Te():Me(new Error("Upload failed")),ae.onerror=()=>Me(new Error("Upload failed")),ae.open("PUT",ce),ae.setRequestHeader("AccessKey",ie),ae.send(U)}),p("processing");let oe=0;const pe=Date.now(),_e=9e4,he=`https://iframe.mediadelivery.net/embed/${X}/${J}`;for(;oe<4&&(await new Promise(Me=>setTimeout(Me,3e3)),!(Date.now()-pe>_e));){const Te=await pA(J);if(oe=Te.status,b(Te.encodeProgress||0),oe===5||oe===6)throw new Error("Video processing failed")}const we=await pA(J),je=(we.storageSize||U.size)/(1024*1024),Ue=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||se,file_size_mb:je,title:Y,status:oe>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:Ue.id,brokerage_id:r,message:k||void 0}),p("done"),me.success("Video recorded and linked to prospect!"),setTimeout(()=>{L(!1),O()},1500)}catch(Y){me.error(Y.message||"Failed to upload video"),p("record")}},[t,s,r,k,i,l]),q=U=>{U&&(navigator.clipboard.writeText(`${window.location.origin}/recruit-video/${U}`),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(Tn,{className:"h-4 w-4"})," Video Outreach"]}),e.jsxs(fs,{open:E,onOpenChange:U=>{!U&&(u==="uploading"||u==="processing")||(L(U),U||O())},children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>p("script"),children:[e.jsx(Us,{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(xe,{className:"text-xs",children:"Choose a Script (optional)"}),e.jsxs(Bs,{value:N,onValueChange:w,children:[e.jsx(Rs,{className:"mt-1",children:e.jsx(qs,{placeholder:"No script — speak freely"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"none",children:"No script"}),o.map(U=>{var se;return e.jsx(vt,{value:U.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[U.title,e.jsx(Qe,{variant:"outline",className:"text-[9px] ml-1",children:(se=Ywe.find(Y=>Y.value===U.category))==null?void 0:se.label})]})},U.id)})]})]}),I&&e.jsx("div",{className:"mt-2 p-3 bg-muted/50 rounded-md text-sm max-h-32 overflow-y-auto whitespace-pre-wrap",children:I})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Personal Message (shown on landing page)"}),e.jsx(vr,{value:k,onChange:U=>C(U.target.value),placeholder:`Hi ${s.split(" ")[0]}, I'd love to chat about what we're building here...`,rows:3,className:"mt-1"})]}),e.jsxs(K,{onClick:()=>p("record"),className:"w-full",children:[e.jsx(Tn,{className:"h-4 w-4 mr-2"})," Start Recording"]})]}),u==="record"&&e.jsx(Qme,{maxDurationSeconds:600,onRecordingComplete:V,teleprompterContent:I||void 0}),u==="uploading"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Uploading video…"}),e.jsx(gi,{value:x,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(x),"%"]})]}),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(gi,{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(So,{className:"h-6 w-6 text-emerald-600"})}),e.jsx("p",{className:"font-medium text-emerald-600",children:"Video ready!"})]})]})]})]}),a?e.jsx("div",{className:"text-center py-4",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent mx-auto"})}):n.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No videos sent yet"}):e.jsx("div",{className:"space-y-2",children:n.map(U=>{var se,Y;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:(se=U.video)!=null&&se.thumbnail_url?e.jsx("img",{src:U.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(Tn,{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:((Y=U.video)==null?void 0:Y.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[U.view_count>0?e.jsxs(Qe,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(wn,{className:"h-2.5 w-2.5 mr-0.5"}),U.view_count]}):U.sent_at?e.jsxs(Qe,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(An,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(Qe,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(ln,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ps(new Date(U.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(U.share_token),children:e.jsx(Ya,{className:"h-3 w-3"})}),!U.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>d.mutate({id:U.id,sent_via:"email"}),children:e.jsx(An,{className:"h-3 w-3"})})]})]},U.id)})})]})}function lSs(t){return gt({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 d9e=[{value:"call",label:"Phone Call",icon:Pn},{value:"email",label:"Email",icon:rr},{value:"text",label:"Text Message",icon:ki},{value:"meeting",label:"Meeting",icon:on},{value:"note",label:"Note",icon:fn},{value:"campaign_email",label:"Campaign Email",icon:An}];function $p({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 k9({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 Ul({label:t,value:s,onChange:r,type:n="text",placeholder:a}){return e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:t}),e.jsx(De,{type:n,value:s,onChange:o=>r(o.target.value),placeholder:a,className:"mt-1 h-8 text-sm"})]})}function qlt({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:d}=tSs((t==null?void 0:t.id)||null),{data:u=[]}=lSs((t==null?void 0:t.id)||null),[p,x]=S.useState({type:"note",title:"",description:""}),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.useState({});if(!t)return null;const C=()=>{var Y,J;k({first_name:t.first_name||"",last_name:t.last_name||"",email:t.email||"",phone:t.phone||"",current_brokerage:t.current_brokerage||"",license_number:t.license_number||"",experience_years:((Y=t.experience_years)==null?void 0:Y.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)},E=()=>{const Y={id:t.id};for(const[J,X]of Object.entries(w))J==="experience_years"||J==="last_year_transactions"?Y[J]=X?parseInt(X):null:Y[J]=X||null;o(Y),N(!1)},L=()=>N(!1),I=Y=>J=>k(X=>({...X,[Y]:J})),O=()=>{p.title.trim()&&(d.mutate({prospect_id:t.id,activity_type:p.type,title:p.title,description:p.description||null}),x({type:"note",title:"",description:""}),_(!1))},V=s.find(Y=>Y.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,U=t.linkedin_url||t.website_url||t.instagram_handle||t.facebook_url,se=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(GA,{open:n,onOpenChange:Y=>{Y||N(!1),a(Y)},children:e.jsx(wC,{className:"w-full sm:max-w-lg p-0",children:e.jsx(ui,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(WA,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(KA,{className:"text-xl",children:[t.first_name," ",t.last_name]}),V&&e.jsx(Qe,{variant:"outline",style:{borderColor:V.color,color:V.color},className:"mt-1",children:V.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:L,children:e.jsx(Sr,{className:"h-4 w-4"})}),e.jsx(K,{variant:"default",size:"icon",onClick:E,children:e.jsx(_c,{className:"h-4 w-4"})})]}):e.jsx(K,{variant:"ghost",size:"icon",onClick:C,title:"Edit prospect",children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Delete prospect?"}),e.jsx(Pl,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{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(rr,{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(Pn,{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(Da,{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(xe,{className:"text-xs text-muted-foreground",children:"Move to Stage"}),e.jsxs(Bs,{value:t.stage_id||"",onValueChange:Y=>o({id:t.id,stage_id:Y}),children:[e.jsx(Rs,{className:"mt-1",children:e.jsx(qs,{})}),e.jsx(Os,{children:s.map(Y=>e.jsx(vt,{value:Y.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:Y.color}}),Y.name]})},Y.id))})]})]}),e.jsxs(ia,{defaultValue:"details",className:"w-full",children:[e.jsxs(ea,{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(Ul,{label:"First Name",value:w.first_name,onChange:I("first_name")}),e.jsx(Ul,{label:"Last Name",value:w.last_name,onChange:I("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Ul,{label:"Email",value:w.email,onChange:I("email"),type:"email"}),e.jsx(Ul,{label:"Phone",value:w.phone,onChange:I("phone")})]}),e.jsx(Ul,{label:"Current Brokerage",value:w.current_brokerage,onChange:I("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Ul,{label:"License #",value:w.license_number,onChange:I("license_number")}),e.jsx(Ul,{label:"Experience (years)",value:w.experience_years,onChange:I("experience_years"),type:"number"})]}),e.jsx(Ul,{label:"Address",value:w.address,onChange:I("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(Ul,{label:"City",value:w.city,onChange:I("city")}),e.jsx(Ul,{label:"State",value:w.state,onChange:I("state")}),e.jsx(Ul,{label:"Zip",value:w.zip_code,onChange:I("zip_code")})]}),e.jsx(Ul,{label:"Source",value:w.source,onChange:I("source")}),e.jsx(Ul,{label:"Referred By",value:w.referred_by,onChange:I("referred_by")}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Notes"}),e.jsx(vr,{value:w.notes,onChange:Y=>k(J=>({...J,notes:Y.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(js,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(Ul,{label:"Annual Production",value:w.annual_production,onChange:I("annual_production"),placeholder:"e.g. $5M"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Ul,{label:"Last Year Volume",value:w.last_year_volume,onChange:I("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(Ul,{label:"Last Year Transactions",value:w.last_year_transactions,onChange:I("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(Ul,{label:"Avg Sale Price",value:w.avg_sale_price,onChange:I("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(Ul,{label:"Specialties / Niche",value:w.specialties,onChange:I("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(js,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(Ul,{label:"LinkedIn URL",value:w.linkedin_url,onChange:I("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(Ul,{label:"Website URL",value:w.website_url,onChange:I("website_url"),type:"url",placeholder:"https://..."}),e.jsx(Ul,{label:"Instagram Handle",value:w.instagram_handle,onChange:I("instagram_handle"),placeholder:"@handle"}),e.jsx(Ul,{label:"Facebook URL",value:w.facebook_url,onChange:I("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs(js,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(Ul,{label:"Birthday",value:w.birthday,onChange:I("birthday"),type:"date"}),e.jsx(Ul,{label:"Spouse / Partner",value:w.spouse_name,onChange:I("spouse_name")}),e.jsx(Ul,{label:"Interests / Hobbies",value:w.interests,onChange:I("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($p,{label:"Current Brokerage",value:t.current_brokerage}),e.jsx($p,{label:"License #",value:t.license_number}),e.jsx($p,{label:"Experience",value:t.experience_years!=null?`${t.experience_years} years`:null}),e.jsx($p,{label:"Referred By",value:t.referred_by}),e.jsx($p,{label:"Source",value:t.source})]}),t.notes&&e.jsxs("div",{className:"mt-3",children:[e.jsx(xe,{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($p,{label:"Annual Production",value:t.annual_production}),e.jsx($p,{label:"Last Year Volume",value:t.last_year_volume}),e.jsx($p,{label:"Last Year Transactions",value:t.last_year_transactions}),e.jsx($p,{label:"Avg Sale Price",value:t.avg_sale_price}),e.jsx($p,{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:U?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k9,{label:"LinkedIn",url:t.linkedin_url,icon:xp}),e.jsx(k9,{label:"Website",url:t.website_url,icon:gd}),t.instagram_handle&&e.jsx(k9,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:mu}),e.jsx(k9,{label:"Facebook",url:t.facebook_url,icon:uu})]}):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:se?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx($p,{label:"Birthday",value:t.birthday?ps(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:Ui}),e.jsx($p,{label:"Spouse / Partner",value:t.spouse_name,icon:Za}),e.jsx("div",{className:"col-span-2",children:e.jsx($p,{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(oSs,{prospectId:t.id,prospectName:`${t.first_name} ${t.last_name||""}`,brokerageId:r}),e.jsx(wo,{}),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(Us,{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(Bs,{value:p.type,onValueChange:Y=>x(J=>({...J,type:Y})),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:d9e.map(Y=>e.jsx(vt,{value:Y.value,children:Y.label},Y.value))})]}),e.jsx(De,{placeholder:"Subject / Title",value:p.title,onChange:Y=>x(J=>({...J,title:Y.target.value}))}),e.jsx(vr,{placeholder:"Details (optional)",value:p.description,onChange:Y=>x(J=>({...J,description:Y.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 Y=[...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,X)=>new Date(X.date).getTime()-new Date(J.date).getTime());return Y.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"}):Y.map(J=>{if(J.type==="manual"){const ce=J.data,ie=d9e.find(oe=>oe.value===ce.activity_type),ae=(ie==null?void 0:ie.icon)||fn;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(ae,{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:ps(new Date(ce.created_at),"MMM d, yyyy h:mm a")})]})]},`activity-${ce.id}`)}const X=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(An,{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 #",X.email_number]}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:X.subject}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1.5",children:[X.status==="failed"?e.jsx(Qe,{variant:"destructive",className:"text-[10px] px-1.5 py-0 h-4",children:"Failed"}):e.jsxs(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-green-500 text-green-600",children:[e.jsx(An,{className:"h-2.5 w-2.5 mr-0.5"})," Sent"]}),X.opened_at?e.jsxs(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-blue-500 text-blue-600",children:[e.jsx(wn,{className:"h-2.5 w-2.5 mr-0.5"})," Opened ",ps(new Date(X.opened_at),"MMM d, h:mm a")]}):X.status!=="failed"?e.jsx(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 text-muted-foreground",children:"Not opened"}):null,X.clicked_at&&e.jsxs(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-purple-500 text-purple-600",children:[e.jsx(nu,{className:"h-2.5 w-2.5 mr-0.5"})," Clicked ",ps(new Date(X.clicked_at),"MMM d, h:mm a")]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ps(new Date(X.sent_at||X.created_at),"MMM d, yyyy h:mm a")})]})]},`send-${X.id}`)})})()})]})]})})})})}const cSs=["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 Ult({open:t,onOpenChange:s,brokerageId:r,stages:n}){var U;const{toast:a}=wa(),o=Jt(),l=S.useRef(null),[i,d]=S.useState([]),[u,p]=S.useState([]),[x,y]=S.useState({}),[_,b]=S.useState(((U=n[0])==null?void 0:U.id)||""),[N,w]=S.useState(!1),[k,C]=S.useState("upload"),[E,L]=S.useState(0),I=()=>{d([]),p([]),y({}),C("upload"),L(0)},O=se=>{var X;const Y=(X=se.target.files)==null?void 0:X[0];if(!Y)return;const J=new FileReader;J.onload=ce=>{var we;const ae=((we=ce.target)==null?void 0:we.result).split(/\r?\n/).filter(je=>je.trim());if(ae.length<2){a({title:"Invalid CSV",description:"File must have a header row and at least one data row",variant:"destructive"});return}const oe=V(ae[0]);p(oe);const pe={},_e=new Set;oe.forEach((je,Ue)=>{const Te=je.toLowerCase().replace(/[^a-z0-9]/g,"");let Me=null;/^firstname$/.test(Te)||Te==="first"?Me="first_name":/^lastname$/.test(Te)||Te==="last"?Me="last_name":/^email$/.test(Te)||Te==="emailaddress"?Me="email":/^mobile$|^phone$|^cellphone$|^mobilephone$/.test(Te)?Me="phone":/officename|currentbrokerage|brokerage|company/.test(Te)?Me="current_brokerage":/membernumber|licensenumber|license/.test(Te)?Me="license_number":/experienceyears|yearsexperience/.test(Te)?Me="experience_years":/^totalvolume$|annualproduction/.test(Te)?Me="annual_production":/^address$/.test(Te)?Me="address":/^city$/.test(Te)?Me="city":/^state$/.test(Te)?Me="state":/^postalcode$|^zip$|^zipcode$/.test(Te)?Me="zip_code":/listsidevolume|lastyearvolume/.test(Te)?Me="last_year_volume":/^totalcount$|lastyeartransactions/.test(Te)?Me="last_year_transactions":/avgsaleprice|averageprice/.test(Te)?Me="avg_sale_price":/linkedin/.test(Te)?Me="linkedin_url":/website/.test(Te)?Me="website_url":/specialt/.test(Te)?Me="specialties":/referr/.test(Te)?Me="referred_by":/^notes$|^note$/.test(Te)&&(Me="notes"),Me&&!_e.has(Me)&&(pe[String(Ue)]=Me,_e.add(Me))}),y(pe);const he=ae.slice(1).map(je=>{const Ue=V(je),Te={};return oe.forEach((Me,Fe)=>{Te[String(Fe)]=Ue[Fe]||""}),Te});d(he),C("map")},J.readAsText(Y)},V=se=>{const Y=[];let J="",X=!1;for(const ce of se)ce==='"'?X=!X:ce===","&&!X?(Y.push(J.trim()),J=""):J+=ce;return Y.push(J.trim()),Y},q=async()=>{w(!0);try{const{data:{user:se}}=await G.auth.getUser();if(!se)throw new Error("Not authenticated");const Y=i.map(X=>{const ce={brokerage_id:r,created_by:se.id,stage_id:_,source:"csv_import",first_name:"Unknown"},ie=ce;return Object.entries(x).forEach(([ae,oe])=>{var _e;const pe=(_e=X[ae])==null?void 0:_e.trim();pe&&(oe==="experience_years"||oe==="last_year_transactions"?ie[oe]=parseInt(pe.replace(/[^0-9.-]/g,""))||null:oe==="annual_production"||oe==="last_year_volume"||oe==="avg_sale_price"?ie[oe]=pe.replace(/[^0-9.$,.-]/g,""):ie[oe]=pe)}),ce});let J=0;for(let X=0;X{const se=`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`,Y=new Blob([se],{type:"text/csv"}),J=URL.createObjectURL(Y),X=document.createElement("a");X.href=J,X.download="recruit-prospects-template.csv",X.click(),URL.revokeObjectURL(J)};return e.jsx(fs,{open:t,onOpenChange:se=>{se||I(),s(se)},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"})}),k==="upload"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx(Kv,{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 se;return(se=l.current)==null?void 0:se.click()},children:[e.jsx($a,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(K,{variant:"link",className:"text-xs",onClick:$,children:"Download CSV template"})]}),k==="map"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," rows found"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:"Import to stage:"}),e.jsxs(Bs,{value:_,onValueChange:b,children:[e.jsx(Rs,{className:"w-[180px]",children:e.jsx(qs,{})}),e.jsx(Os,{children:n.map(se=>e.jsx(vt,{value:se.id,children:se.name},se.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:u.map((se,Y)=>{var J;return e.jsxs(Ms,{children:[e.jsx(ut,{className:"font-medium text-xs",children:se}),e.jsx(ut,{children:e.jsxs(Bs,{value:x[String(Y)]||"skip",onValueChange:X=>y(ce=>({...ce,[String(Y)]:X==="skip"?"":X})),children:[e.jsx(Rs,{className:"h-8 text-xs",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"skip",children:"— Skip —"}),cSs.map(X=>e.jsx(vt,{value:X,children:X.replace(/_/g," ")},X))]})]})}),e.jsx(ut,{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:((J=i[0])==null?void 0:J[String(Y)])||"—"})]},Y)})})]})}),!Object.values(x).includes("first_name")&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-sm",children:[e.jsx(Lo,{className:"h-4 w-4"}),' Map at least "first name" to proceed']}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>{I()},children:"Back"}),e.jsx(K,{onClick:q,disabled:N||!Object.values(x).includes("first_name"),children:N?"Importing...":`Import ${i.length} Prospects`})]})]}),k==="done"&&e.jsxs("div",{className:"text-center py-6 space-y-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-green-500/10 flex items-center justify-center mx-auto",children:e.jsx(Jn,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[E," prospects imported successfully!"]}),e.jsx(K,{onClick:()=>{I(),s(!1)},children:"Close"})]})]})})}function Vlt({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=Jme(t),[i,d]=S.useState(!1),[u,p]=S.useState(),[x,y]=S.useState(null),[_,b]=S.useState(!1),[N,w]=S.useState(!1),[k,C]=S.useState(null);if(n)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});const E=$=>r.filter(U=>U.stage_id===$),L=($,U)=>{C(U),$.dataTransfer.effectAllowed="move"},I=$=>{$.preventDefault(),$.dataTransfer.dropEffect="move"},O=($,U)=>{$.preventDefault(),k&&(o.mutate({id:k,stage_id:U}),C(null))},V=$=>{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($a,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>{p(void 0),d(!0)},children:[e.jsx(Us,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs(ui,{className:"w-full",children:[e.jsx("div",{className:"flex gap-4 pb-4",style:{minWidth:s.length*300},children:s.map($=>{const U=E($.id);return e.jsxs("div",{className:"w-[280px] flex-shrink-0 flex flex-col",onDragOver:I,onDrop:se=>O(se,$.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(Qe,{variant:"secondary",className:"text-xs h-5 px-1.5",children:U.length})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>V($.id),children:e.jsx(Us,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"space-y-2 min-h-[200px] bg-muted/30 rounded-lg p-2",children:U.map(se=>e.jsx(Pe,{className:"p-3 cursor-pointer hover:shadow-md transition-shadow border-l-4 group",style:{borderLeftColor:$.color},draggable:!0,onDragStart:Y=>L(Y,se.id),onClick:()=>q(se),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(hu,{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(Ti,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-sm truncate",children:[se.first_name," ",se.last_name]})]}),se.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(pa,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:se.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[se.email&&e.jsx(rr,{className:"h-3 w-3 text-muted-foreground"}),se.phone&&e.jsx(Pn,{className:"h-3 w-3 text-muted-foreground"}),se.experience_years!=null&&e.jsxs(Qe,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[se.experience_years,"yr"]})]})]})]})},se.id))})]},$.id)})}),e.jsx(Due,{orientation:"horizontal"})]}),e.jsx(zlt,{open:i,onOpenChange:d,stages:s,defaultStageId:u,onSubmit:$=>a.mutate($),isSubmitting:a.isPending}),e.jsx(qlt,{prospect:x,stages:s,brokerageId:t,open:_,onOpenChange:b,onUpdate:$=>{o.mutate($),y(U=>U?{...U,...$}:null)},onDelete:$=>l.mutate($)}),e.jsx(Ult,{open:N,onOpenChange:w,brokerageId:t,stages:s})]})}function Cde({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=Jme(t),{user:i}=Fs(),d=Jt(),[u,p]=S.useState(!1),[x,y]=S.useState(null),[_,b]=S.useState(!1),[N,w]=S.useState(!1),[k,C]=S.useState(""),[E,L]=S.useState("all"),[I,O]=S.useState("all"),[V,q]=S.useState("all"),[$,U]=S.useState(null),[se,Y]=S.useState("asc"),[J,X]=S.useState(new Set),[ce,ie]=S.useState(!1),[ae,oe]=S.useState(""),pe=S.useMemo(()=>{const ve=new Set;return r.forEach(dt=>{dt.current_brokerage&&ve.add(dt.current_brokerage)}),Array.from(ve).sort()},[r]),{data:_e=[]}=gt({queryKey:["recruit-campaigns-list",t],queryFn:async()=>{const{data:ve,error:dt}=await G.from("recruit_campaigns").select("id, name, warmth_level").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("name");if(dt)throw dt;return ve}}),{data:he=[]}=gt({queryKey:["recruit-campaign-assignments-lookup",t],queryFn:async()=>{let dt=[],fe=0;for(;;){const{data:Ve,error:Je}=await G.from("recruit_campaign_assignments").select("prospect_id, campaign_id, status").eq("brokerage_id",t).range(fe,fe+1e3-1);if(Je)throw Je;if(dt=dt.concat(Ve??[]),!Ve||Ve.length<1e3)break;fe+=1e3}return dt}}),we=S.useMemo(()=>{const ve=new Map;return he.forEach(dt=>{ve.has(dt.prospect_id)||ve.set(dt.prospect_id,new Set),ve.get(dt.prospect_id).add(dt.campaign_id)}),ve},[he]),je=ve=>{$===ve?Y(dt=>dt==="asc"?"desc":"asc"):(U(ve),Y("asc"))},Ue=({column:ve})=>$!==ve?e.jsx(td,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):se==="asc"?e.jsx(du,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(Ph,{className:"h-3.5 w-3.5 ml-1 text-primary"}),Te=ve=>s.find(dt=>dt.id===ve),Me=S.useMemo(()=>{let ve=r.filter(dt=>{var Ae,Ye,We;const fe=!k||`${dt.first_name} ${dt.last_name}`.toLowerCase().includes(k.toLowerCase())||((Ae=dt.email)==null?void 0:Ae.toLowerCase().includes(k.toLowerCase()))||((Ye=dt.current_brokerage)==null?void 0:Ye.toLowerCase().includes(k.toLowerCase())),Ve=E==="all"||dt.stage_id===E,Je=I==="all"||dt.current_brokerage===I;let at=!0;return V==="in_campaign"?at=we.has(dt.id):V==="not_in_campaign"?at=!we.has(dt.id):V!=="all"&&(at=((We=we.get(dt.id))==null?void 0:We.has(V))??!1),fe&&Ve&&Je&&at});return $&&(ve=[...ve].sort((dt,fe)=>{var Ae,Ye;let Ve=null,Je=null;switch($){case"name":Ve=`${dt.first_name} ${dt.last_name||""}`.toLowerCase(),Je=`${fe.first_name} ${fe.last_name||""}`.toLowerCase();break;case"stage":Ve=((Ae=Te(dt.stage_id))==null?void 0:Ae.sort_order)??999,Je=((Ye=Te(fe.stage_id))==null?void 0:Ye.sort_order)??999;break;case"brokerage":Ve=(dt.current_brokerage||"").toLowerCase(),Je=(fe.current_brokerage||"").toLowerCase();break;case"experience":Ve=dt.experience_years??-1,Je=fe.experience_years??-1;break;case"production":Ve=(dt.annual_production||"").toLowerCase(),Je=(fe.annual_production||"").toLowerCase();break;case"source":Ve=(dt.source||"").toLowerCase(),Je=(fe.source||"").toLowerCase();break;default:return 0}if(Ve===Je)return 0;if(Ve==null)return 1;if(Je==null)return-1;const at=Ve0&&Me.every(ve=>J.has(ve.id)),Le=Me.some(ve=>J.has(ve.id)),Ne=()=>{X(Fe?new Set:new Set(Me.map(ve=>ve.id)))},qe=ve=>{X(dt=>{const fe=new Set(dt);return fe.has(ve)?fe.delete(ve):fe.add(ve),fe})},ze=It({mutationFn:async()=>{if(!ae||!(i!=null&&i.id))throw new Error("Select a campaign");const ve=new Set(he.filter(Ve=>Ve.campaign_id===ae).map(Ve=>Ve.prospect_id)),dt=Array.from(J).filter(Ve=>!ve.has(Ve)).map(Ve=>({prospect_id:Ve,campaign_id:ae,brokerage_id:t,assigned_by:i.id,status:"active",current_email_number:0}));if(dt.length===0)throw new Error("All selected prospects are already in this campaign");const{error:fe}=await G.from("recruit_campaign_assignments").insert(dt);if(fe)throw fe;return dt.length},onSuccess:ve=>{me.success(`${ve} prospect(s) added to campaign`),ie(!1),X(new Set),oe(""),d.invalidateQueries({queryKey:["recruit-campaign-assignments-lookup"]})},onError:ve=>me.error(ve.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(an,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search prospects...",value:k,onChange:ve=>C(ve.target.value),className:"pl-8"})]}),e.jsxs("div",{className:"flex gap-2",children:[J.size>0&&e.jsxs(K,{variant:"secondary",onClick:()=>ie(!0),className:"gap-1.5",children:[e.jsx(An,{className:"h-4 w-4"})," Add ",J.size," to Campaign"]}),e.jsxs(K,{variant:"outline",onClick:()=>w(!0),children:[e.jsx($a,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>p(!0),children:[e.jsx(Us,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Eg,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(Bs,{value:E,onValueChange:L,children:[e.jsx(Rs,{className:"w-[160px] h-8 text-xs",children:e.jsx(qs,{placeholder:"All stages"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All stages"}),s.map(ve=>e.jsx(vt,{value:ve.id,children:ve.name},ve.id))]})]}),e.jsxs(Bs,{value:I,onValueChange:O,children:[e.jsxs(Rs,{className:"w-[200px] h-8 text-xs",children:[e.jsx(pa,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(qs,{placeholder:"All brokerages"})]}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All brokerages"}),pe.map(ve=>e.jsx(vt,{value:ve,children:ve},ve))]})]}),e.jsxs(Bs,{value:V,onValueChange:q,children:[e.jsxs(Rs,{className:"w-[200px] h-8 text-xs",children:[e.jsx(rr,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(qs,{placeholder:"Campaign status"})]}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All contacts"}),e.jsx(vt,{value:"in_campaign",children:"In any campaign"}),e.jsx(vt,{value:"not_in_campaign",children:"Not in any campaign"}),_e.map(ve=>e.jsxs(vt,{value:ve.id,children:["In: ",ve.name]},ve.id))]})]}),(E!=="all"||I!=="all"||V!=="all")&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 text-xs text-muted-foreground",onClick:()=>{L("all"),O("all"),q("all")},children:"Clear filters"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{children:[e.jsx(Nt,{className:"w-[40px]",children:e.jsx(Ki,{checked:Fe,onCheckedChange:Ne,"aria-label":"Select all",...Le&&!Fe?{"data-state":"indeterminate"}:{}})}),e.jsx(Nt,{className:"cursor-pointer select-none",onClick:()=>je("name"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Name ",e.jsx(Ue,{column:"name"})]})}),e.jsx(Nt,{className:"cursor-pointer select-none",onClick:()=>je("stage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Stage ",e.jsx(Ue,{column:"stage"})]})}),e.jsx(Nt,{className:"hidden md:table-cell cursor-pointer select-none",onClick:()=>je("brokerage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Brokerage ",e.jsx(Ue,{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:()=>je("experience"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Experience ",e.jsx(Ue,{column:"experience"})]})}),e.jsx(Nt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>je("production"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Production ",e.jsx(Ue,{column:"production"})]})}),e.jsx(Nt,{className:"hidden lg:table-cell",children:"Campaigns"}),e.jsx(Nt,{className:"w-[50px]"})]})}),e.jsx(Dn,{children:Me.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):Me.map(ve=>{const dt=Te(ve.stage_id),fe=we.get(ve.id),Ve=(fe==null?void 0:fe.size)??0;return e.jsxs(Ms,{className:"cursor-pointer",onClick:()=>{y(ve),b(!0)},children:[e.jsx(ut,{onClick:Je=>Je.stopPropagation(),children:e.jsx(Ki,{checked:J.has(ve.id),onCheckedChange:()=>qe(ve.id),"aria-label":`Select ${ve.first_name}`})}),e.jsxs(ut,{className:"font-medium",children:[ve.first_name," ",ve.last_name]}),e.jsx(ut,{children:dt?e.jsxs(Qe,{variant:"outline",className:"text-xs gap-1 whitespace-nowrap",style:{borderColor:dt.color,color:dt.color,backgroundColor:`${dt.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:dt.color}}),dt.name]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"—"})}),e.jsx(ut,{className:"hidden md:table-cell",children:ve.current_brokerage?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(pa,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:ve.current_brokerage})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ut,{className:"hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ve.email&&e.jsx(rr,{className:"h-3.5 w-3.5 text-muted-foreground"}),ve.phone&&e.jsx(Pn,{className:"h-3.5 w-3.5 text-muted-foreground"}),!ve.email&&!ve.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(ut,{className:"hidden lg:table-cell",children:ve.experience_years!=null?`${ve.experience_years} yr`:"—"}),e.jsx(ut,{className:"hidden lg:table-cell",children:ve.annual_production||"—"}),e.jsx(ut,{className:"hidden lg:table-cell",children:Ve>0?e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:[Ve," campaign",Ve>1?"s":""]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"None"})}),e.jsx(ut,{children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:Je=>{Je.stopPropagation(),l.mutate(ve.id)},children:e.jsx(gr,{className:"h-3.5 w-3.5"})})})]},ve.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 · "]}),Me.length," of ",r.length," prospects"]}),e.jsx(fs,{open:ce,onOpenChange:ie,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(xe,{children:"Campaign"}),e.jsxs(Bs,{value:ae,onValueChange:oe,children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select a campaign..."})}),e.jsx(Os,{children:_e.map(ve=>e.jsxs(vt,{value:ve.id,children:[ve.name," ",e.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",ve.warmth_level,")"]})]},ve.id))})]})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>ie(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>ze.mutate(),disabled:!ae||ze.isPending,children:ze.isPending?"Adding...":"Add to Campaign"})]})]})}),e.jsx(zlt,{open:u,onOpenChange:p,stages:s,onSubmit:ve=>a.mutate(ve),isSubmitting:a.isPending}),e.jsx(qlt,{prospect:x,stages:s,brokerageId:t,open:_,onOpenChange:b,onUpdate:ve=>{o.mutate(ve),y(dt=>dt?{...dt,...ve}:null)},onDelete:ve=>l.mutate(ve)}),e.jsx(Ult,{open:N,onOpenChange:w,brokerageId:t,stages:s})]})}function Hlt({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=Jme(t),a=S.useMemo(()=>{if(!s.length||!r.length)return null;const o=r.length,l=s.find(k=>k.name==="Signed"),i=s.find(k=>k.name==="Onboarded"),d=r.filter(k=>k.stage_id===(l==null?void 0:l.id)||k.stage_id===(i==null?void 0:i.id)).length,u=o>0?(d/o*100).toFixed(1):"0",p=new Date,x=o>0?Math.round(r.reduce((k,C)=>k+Bg(p,new Date(C.created_at)),0)/o):0,y=s.map(k=>({...k,count:r.filter(C=>C.stage_id===k.id).length})),_={};r.forEach(k=>{const C=k.source||"unknown";_[C]=(_[C]||0)+1});const b=Object.entries(_).sort((k,C)=>C[1]-k[1]),N=new Date;N.setDate(N.getDate()-30);const w=r.filter(k=>new Date(k.created_at)>=N).length;return{total:o,signed:d,conversionRate:u,avgDays:x,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(Pe,{children:e.jsx(Re,{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(lr,{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(Pe,{children:e.jsx(Re,{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(Pe,{children:e.jsx(Re,{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(ln,{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(Pe,{children:e.jsx(Re,{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(Rh,{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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx(Re,{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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Re,{className:"space-y-3",children:[a.bySrc.map(([o,l])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Qe,{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 u9e=[{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 Glt({brokerageId:t}){const{toast:s}=wa(),[r,n]=S.useState(null),[a,o]=S.useState(null),l=(d,u)=>{navigator.clipboard.writeText(d),n(u),s({title:"Copied to clipboard!"}),setTimeout(()=>n(null),2e3)},i=[...new Set(u9e.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(rr,{className:"h-4 w-4"})," ",d]}),u9e.filter(u=>u.category===d).map(u=>e.jsxs(Pe,{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(Ot,{className:"text-sm",children:u.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",u.subject]})]}),e.jsx(Qe,{variant:"secondary",className:"text-[10px]",children:u.category})]})}),a===u.id&&e.jsxs(Re,{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(Jn,{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(Jn,{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 h9e={call:Pn,email:rr,text:ki,meeting:on,note:fn};function Wlt({brokerageId:t}){const{data:s,isLoading:r}=gt({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,_])),x=Fie(new Date,30);return{recruiters:d.map(_=>{var C,E;const b=(l||[]).filter(L=>L.created_by===_),N=b.filter(L=>new Date(L.created_at)>=x),w={};N.forEach(L=>{w[L.activity_type]=(w[L.activity_type]||0)+1});const k=n.filter(L=>L.created_by===_).length;return{id:_,name:((C=p[_])==null?void 0:C.name)||"Unknown",email:((E=p[_])==null?void 0:E.email)||"",totalActivities:b.length,recentActivities:N.length,byType:w,prospectsCreated:k}}).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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Recruiter Leaderboard (Last 30 Days)"})}),e.jsx(Re,{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(Ti,{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=h9e[o]||fn;return e.jsxs(Qe,{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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Recent Activity"})}),e.jsx(Re,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=h9e[n.activity_type]||fn;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:ps(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 Klt({brokerageId:t}){const{toast:s}=wa(),r=Jt(),[n,a]=S.useState(!1),[o,l]=S.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:d}=gt({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:w,error:k}=await G.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(k)throw k;return w}}),u=[...new Set(i.map(w=>w.referred_by))],{data:p=[]}=gt({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}),x=Object.fromEntries(p.map(w=>[w.id,w])),y=It({mutationFn:async w=>{const{data:{user:k}}=await G.auth.getUser();if(!k)throw new Error("Not authenticated");const{error:C}=await G.from("recruit_referrals").insert({brokerage_id:t,referred_by:k.id,referee_first_name:w.first_name,referee_last_name:w.last_name||null,referee_email:w.email||null,referee_phone:w.phone||null,referee_current_brokerage:w.current_brokerage||null,notes:w.notes||null});if(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"})}),_=It({mutationFn:async({id:w,status:k,incentive_status:C})=>{const E={updated_at:new Date().toISOString()};k&&(E.status=k),C&&(E.incentive_status=C);const{error:L}=await G.from("recruit_referrals").update(E).eq("id",w);if(L)throw L},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),b=w=>w==="approved"||w==="signed"?e.jsx(Jn,{className:"h-3 w-3"}):w==="rejected"?e.jsx(Zl,{className:"h-3 w-3"}):e.jsx(ln,{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(Us,{className:"h-4 w-4 mr-2"})," Submit Referral"]})]}),i.length===0?e.jsxs(Pe,{className:"py-12 text-center",children:[e.jsx(al,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No referrals yet. Agents can refer potential recruits here."})]}):e.jsx("div",{className:"space-y-3",children:i.map(w=>{var k;return e.jsx(Pe,{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(Qe,{variant:"outline",className:N(w.status),children:[b(w.status)," ",w.status]}),w.incentive_status&&e.jsxs(Qe,{variant:"outline",className:N(w.incentive_status),children:[e.jsx(Ui,{className:"h-3 w-3 mr-1"})," ",w.incentive_status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[w.referee_email&&e.jsx("p",{children:w.referee_email}),w.referee_phone&&e.jsx("p",{children:w.referee_phone}),w.referee_current_brokerage&&e.jsxs("p",{children:["Currently at: ",w.referee_current_brokerage]}),e.jsxs("p",{children:["Referred by: ",((k=x[w.referred_by])==null?void 0:k.name)||"Unknown"," • ",ps(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(Bs,{value:w.status,onValueChange:C=>_.mutate({id:w.id,status:C}),children:[e.jsx(Rs,{className:"h-7 text-xs w-[110px]",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"pending",children:"Pending"}),e.jsx(vt,{value:"contacted",children:"Contacted"}),e.jsx(vt,{value:"approved",children:"Approved"}),e.jsx(vt,{value:"signed",children:"Signed"}),e.jsx(vt,{value:"rejected",children:"Rejected"})]})]}),e.jsxs(Bs,{value:w.incentive_status||"pending",onValueChange:C=>_.mutate({id:w.id,incentive_status:C}),children:[e.jsx(Rs,{className:"h-7 text-xs w-[100px]",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"pending",children:"Unpaid"}),e.jsx(vt,{value:"paid",children:"Paid"}),e.jsx(vt,{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(xe,{children:"First Name *"}),e.jsx(De,{required:!0,value:o.first_name,onChange:w=>l(k=>({...k,first_name:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Last Name"}),e.jsx(De,{value:o.last_name,onChange:w=>l(k=>({...k,last_name:w.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Email"}),e.jsx(De,{type:"email",value:o.email,onChange:w=>l(k=>({...k,email:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Phone"}),e.jsx(De,{value:o.phone,onChange:w=>l(k=>({...k,phone:w.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Current Brokerage"}),e.jsx(De,{value:o.current_brokerage,onChange:w=>l(k=>({...k,current_brokerage:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Notes"}),e.jsx(vr,{value:o.notes,onChange:w=>l(k=>({...k,notes:w.target.value})),rows:2})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:y.isPending,children:"Submit"})]})]})]})})]})}function Zlt({brokerageId:t}){const{toast:s}=wa(),r=Jt(),[n,a]=S.useState(!1),{data:o}=gt({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=[]}=gt({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=It({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=It({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)},x=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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Public Interest Form"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{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(Er,{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(Jn,{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(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"text-base",children:["Interest Submissions (",l.length,")"]})}),e.jsx(Re,{children:l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(al,{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(Qe,{variant:"outline",className:x(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(rr,{className:"h-3 w-3"}),y.email]}),y.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pn,{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:ps(new Date(y.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(Bs,{value:y.status,onValueChange:_=>d.mutate({id:y.id,status:_}),children:[e.jsx(Rs,{className:"h-7 text-xs w-[110px]",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"new",children:"New"}),e.jsx(vt,{value:"contacted",children:"Contacted"}),e.jsx(vt,{value:"converted",children:"Converted"}),e.jsx(vt,{value:"dismissed",children:"Dismissed"})]})]})]},y.id))})})]})]})}function Ylt({brokerageId:t}){const{toast:s}=wa(),r=Jt(),[n,a]=S.useState(!1),[o,l]=S.useState({prospect_id:"",title:"",description:"",due_date:ps(cl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,d]=S.useState("pending"),{data:u=[]}=gt({queryKey:["recruit-prospects-list",t],queryFn:async()=>{const{data:I,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 I}}),{data:p=[],isLoading:x}=gt({queryKey:["recruit-follow-ups",t],queryFn:async()=>{const I=u.map(q=>q.id);if(!I.length)return[];const{data:O,error:V}=await G.from("recruit_follow_ups").select("*").in("prospect_id",I).order("due_date");if(V)throw V;return O},enabled:u.length>0}),y=Object.fromEntries(u.map(I=>[I.id,I])),_=It({mutationFn:async I=>{const{data:{user:O}}=await G.auth.getUser();if(!O)throw new Error("Not authenticated");const{error:V}=await G.from("recruit_follow_ups").insert({prospect_id:I.prospect_id,assigned_to:O.id,title:I.title,description:I.description||null,due_date:new Date(I.due_date).toISOString()});if(V)throw V},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-follow-ups",t]}),s({title:"Follow-up scheduled"}),l({prospect_id:"",title:"",description:"",due_date:ps(cl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:I=>s({title:"Error",description:I.message,variant:"destructive"})}),b=It({mutationFn:async({id:I,completed:O})=>{const{error:V}=await G.from("recruit_follow_ups").update({completed_at:O?new Date().toISOString():null}).eq("id",I);if(V)throw V},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-follow-ups",t]})}),N=p.filter(I=>i==="pending"?!I.completed_at:i==="completed"?!!I.completed_at:!0),w=N.filter(I=>!I.completed_at&&r0(new Date(I.due_date))&&!au(new Date(I.due_date))),k=N.filter(I=>!I.completed_at&&au(new Date(I.due_date))),C=N.filter(I=>!I.completed_at&&!r0(new Date(I.due_date))&&!au(new Date(I.due_date))),E=N.filter(I=>!!I.completed_at),L=I=>{const O=y[I.prospect_id],V=!I.completed_at&&r0(new Date(I.due_date))&&!au(new Date(I.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Ki,{checked:!!I.completed_at,onCheckedChange:q=>b.mutate({id:I.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 ${I.completed_at?"line-through text-muted-foreground":""}`,children:I.title}),I.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:I.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[O&&e.jsxs(Qe,{variant:"secondary",className:"text-[10px]",children:[O.first_name," ",O.last_name]}),e.jsxs("span",{className:`flex items-center gap-1 ${V?"text-destructive font-medium":""}`,children:[V?e.jsx(Lo,{className:"h-3 w-3"}):e.jsx(on,{className:"h-3 w-3"}),ps(new Date(I.due_date),"MMM d, h:mm a")]}),I.is_automated&&e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:"Auto"})]})]})]},I.id)};return x?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex gap-2",children:["pending","completed","all"].map(I=>e.jsxs(K,{size:"sm",variant:i===I?"default":"outline",onClick:()=>d(I),className:"capitalize text-xs",children:[I," ",I==="pending"&&w.length+k.length+C.length>0&&`(${w.length+k.length+C.length})`]},I))}),e.jsxs(K,{size:"sm",onClick:()=>a(!0),children:[e.jsx(Us,{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(Lo,{className:"h-3.5 w-3.5"})," Overdue (",w.length,")"]}),w.map(L)]}),i!=="completed"&&k.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-600 flex items-center gap-1",children:[e.jsx(ln,{className:"h-3.5 w-3.5"})," Today (",k.length,")"]}),k.map(L)]}),i!=="completed"&&C.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(on,{className:"h-3.5 w-3.5"})," Upcoming (",C.length,")"]}),C.map(L)]}),i!=="pending"&&E.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(Jn,{className:"h-3.5 w-3.5"})," Completed (",E.length,")"]}),E.map(L)]}),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:I=>{I.preventDefault(),_.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Prospect *"}),e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",required:!0,value:o.prospect_id,onChange:I=>l(O=>({...O,prospect_id:I.target.value})),children:[e.jsx("option",{value:"",children:"Select prospect..."}),u.map(I=>e.jsxs("option",{value:I.id,children:[I.first_name," ",I.last_name]},I.id))]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Task *"}),e.jsx(De,{required:!0,value:o.title,onChange:I=>l(O=>({...O,title:I.target.value})),placeholder:"e.g. Follow-up call"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Details"}),e.jsx(vr,{value:o.description,onChange:I=>l(O=>({...O,description:I.target.value})),rows:2})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Due Date *"}),e.jsx(De,{type:"datetime-local",required:!0,value:o.due_date,onChange:I=>l(O=>({...O,due_date:I.target.value}))})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:_.isPending,children:"Schedule"})]})]})]})})]})}const dSs=[{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 Xlt({brokerageId:t}){const{toast:s}=wa(),r=Jt(),[n,a]=S.useState(null),{data:o,isLoading:l}=gt({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:w,error:k}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(k)throw k;return w}}),[i,d]=S.useState({brokerage_id:t,hero_headline:"Join Our Team",hero_subtext:"Take your real estate career to the next level.",hero_image_url:null,logo_url:null,primary_color:"#406E71",accent_color:"#2a4c64",benefits:dSs,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});S.useEffect(()=>{o&&d({id:o.id,brokerage_id:o.brokerage_id,hero_headline:o.hero_headline,hero_subtext:o.hero_subtext||"",hero_image_url:o.hero_image_url,logo_url:o.logo_url,primary_color:o.primary_color,accent_color:o.accent_color,benefits:o.benefits||[],testimonials:o.testimonials||[],gallery_images:o.gallery_images||[],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=It({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:k}=await G.from("recruit_landing_page_settings").update(w).eq("id",i.id);if(k)throw k}else{const{error:k}=await G.from("recruit_landing_page_settings").insert(w);if(k)throw k}},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-landing-settings",t]}),s({title:"Landing page saved!"})},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),p=async(w,k)=>{const C=w.name.split(".").pop(),E=`${t}/${k}-${Date.now()}.${C}`,{error:L}=await G.storage.from("recruit-landing").upload(E,w);if(L)throw L;const{data:{publicUrl:I}}=G.storage.from("recruit-landing").getPublicUrl(E);return I},x=async(w,k)=>{var E;const C=(E=w.target.files)==null?void 0:E[0];if(C){a(k);try{const L=await p(C,k);d(I=>({...I,[k]:L})),s({title:"Image uploaded!"})}catch(L){s({title:"Upload failed",description:L.message,variant:"destructive"})}finally{a(null)}}},y=async w=>{var C;const k=(C=w.target.files)==null?void 0:C[0];if(k){a("gallery");try{const E=await p(k,"gallery");d(L=>({...L,gallery_images:[...L.gallery_images,E]})),s({title:"Gallery image added!"})}catch(E){s({title:"Upload failed",description:E.message,variant:"destructive"})}finally{a(null)}}},_=async(w,k)=>{var E;const C=(E=w.target.files)==null?void 0:E[0];if(C){a(`testimonial-${k}`);try{const L=await p(C,`testimonial-${k}`);d(I=>{const O=[...I.testimonials];return O[k]={...O[k],photo_url:L},{...I,testimonials:O}})}catch(L){s({title:"Upload failed",description:L.message,variant:"destructive"})}finally{a(null)}}},{data:b}=gt({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:w,error:k}=await G.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(k)throw k;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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Branding"})}),e.jsx(Re,{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(xe,{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($a,{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=>x(w,"logo_url")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{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(k=>({...k,primary_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(De,{value:i.primary_color,onChange:w=>d(k=>({...k,primary_color:w.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{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(k=>({...k,accent_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(De,{value:i.accent_color,onChange:w=>d(k=>({...k,accent_color:w.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Hero Section"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Headline"}),e.jsx(De,{value:i.hero_headline,onChange:w=>d(k=>({...k,hero_headline:w.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Subtext"}),e.jsx(vr,{value:i.hero_subtext,onChange:w=>d(k=>({...k,hero_subtext:w.target.value})),rows:2,placeholder:"Take your career to the next level..."})]}),e.jsxs("div",{children:[e.jsx(xe,{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($a,{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=>x(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(gr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(w=>({...w,benefits:[...w.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx(Us,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Re,{className:"space-y-3",children:[i.benefits.map((w,k)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(hu,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(De,{value:w.icon,onChange:C=>{const E=[...i.benefits];E[k]={...w,icon:C.target.value},d(L=>({...L,benefits:E}))},className:"w-14 text-center"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(De,{value:w.title,onChange:C=>{const E=[...i.benefits];E[k]={...w,title:C.target.value},d(L=>({...L,benefits:E}))},placeholder:"Benefit title"}),e.jsx(De,{value:w.description,onChange:C=>{const E=[...i.benefits];E[k]={...w,description:C.target.value},d(L=>({...L,benefits:E}))},placeholder:"Short description"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(C=>({...C,benefits:C.benefits.filter((E,L)=>L!==k)})),children:e.jsx(gr,{className:"h-3.5 w-3.5 text-destructive"})})]},k)),i.benefits.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No benefits added yet"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{className:"text-base",children:"Testimonials"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(w=>({...w,testimonials:[...w.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx(Us,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Re,{className:"space-y-3",children:[i.testimonials.map((w,k)=>{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-${k}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:E=>_(E,k)})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(De,{value:w.name,onChange:E=>{const L=[...i.testimonials];L[k]={...w,name:E.target.value},d(I=>({...I,testimonials:L}))},placeholder:"Name"}),e.jsx(De,{value:w.role,onChange:E=>{const L=[...i.testimonials];L[k]={...w,role:E.target.value},d(I=>({...I,testimonials:L}))},placeholder:"Role / Title"})]}),e.jsx(vr,{value:w.quote,onChange:E=>{const L=[...i.testimonials];L[k]={...w,quote:E.target.value},d(I=>({...I,testimonials:L}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(E=>({...E,testimonials:E.testimonials.filter((L,I)=>I!==k)})),children:e.jsx(gr,{className:"h-3.5 w-3.5 text-destructive"})})]},k)}),i.testimonials.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No testimonials added yet"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{className:"text-base",children:"Team & Culture Gallery"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{size:"sm",variant:"outline",asChild:!0,disabled:n==="gallery",children:e.jsxs("span",{children:[e.jsx(Wo,{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(Re,{children:i.gallery_images.length>0?e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:i.gallery_images.map((w,k)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:w,alt:`Gallery ${k+1}`,className:"h-24 w-full object-cover rounded-lg"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(C=>({...C,gallery_images:C.gallery_images.filter((E,L)=>L!==k)})),children:e.jsx(gr,{className:"h-3 w-3"})})]},k))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No gallery images added yet"})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx($r,{className:"h-4 w-4 text-primary"})," Form Style & Trust"]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Application Form Style"}),e.jsxs(Bs,{value:i.form_style,onValueChange:w=>d(k=>({...k,form_style:w})),children:[e.jsx(Rs,{className:"mt-1.5",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"classic",children:"Classic — single-page form (all fields visible)"}),e.jsx(vt,{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(xe,{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(Er,{checked:i.confidential_messaging,onCheckedChange:w=>d(k=>({...k,confidential_messaging:w}))})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(xM,{className:"h-4 w-4 text-primary"})," Split & Income Calculator"]}),e.jsx(Er,{checked:i.calculator_enabled,onCheckedChange:w=>d(k=>({...k,calculator_enabled:w}))})]}),i.calculator_enabled&&e.jsxs(Re,{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(xe,{className:"text-xs",children:"Calculator Headline"}),e.jsx(De,{value:i.calculator_config.headline||"",onChange:w=>d(k=>({...k,calculator_config:{...k.calculator_config,headline:w.target.value}})),placeholder:"See What You Could Earn With Us"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Subtext"}),e.jsx(De,{value:i.calculator_config.subtext||"",onChange:w=>d(k=>({...k,calculator_config:{...k.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(xe,{className:"text-xs",children:"Your Split %"}),e.jsx(De,{type:"number",value:i.calculator_config.commission_split_pct??80,onChange:w=>d(k=>({...k,calculator_config:{...k.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(xe,{className:"text-xs",children:"Cap Amount ($)"}),e.jsx(De,{type:"number",value:i.calculator_config.cap_amount??16e3,onChange:w=>d(k=>({...k,calculator_config:{...k.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(xe,{className:"text-xs",children:"Monthly Fee ($)"}),e.jsx(De,{type:"number",value:i.calculator_config.monthly_fee??99,onChange:w=>d(k=>({...k,calculator_config:{...k.calculator_config,monthly_fee:parseFloat(w.target.value)||0}}))})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Per-Txn Fee ($)"}),e.jsx(De,{type:"number",value:i.calculator_config.transaction_fee??0,onChange:w=>d(k=>({...k,calculator_config:{...k.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(xe,{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(Er,{checked:i.calculator_config.show_email_capture!==!1,onCheckedChange:w=>d(k=>({...k,calculator_config:{...k.calculator_config,show_email_capture:w}}))})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Z4,{className:"h-4 w-4 text-primary"})," Lead Magnet (Gated PDF)"]}),e.jsx(Er,{checked:i.lead_magnet_enabled,onCheckedChange:w=>d(k=>({...k,lead_magnet_enabled:w}))})]}),i.lead_magnet_enabled&&e.jsxs(Re,{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(xe,{className:"text-xs",children:"Title"}),e.jsx(De,{value:i.lead_magnet_config.title||"",onChange:w=>d(k=>({...k,lead_magnet_config:{...k.lead_magnet_config,title:w.target.value}})),placeholder:"Get the Full Comp Plan PDF"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Description"}),e.jsx(vr,{rows:2,value:i.lead_magnet_config.description||"",onChange:w=>d(k=>({...k,lead_magnet_config:{...k.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(xe,{className:"text-xs",children:"Button Text"}),e.jsx(De,{value:i.lead_magnet_config.button_text||"",onChange:w=>d(k=>({...k,lead_magnet_config:{...k.lead_magnet_config,button_text:w.target.value}})),placeholder:"Email Me the PDF"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"PDF / File URL"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(De,{value:i.lead_magnet_config.pdf_url||"",onChange:w=>d(k=>({...k,lead_magnet_config:{...k.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($a,{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 k=(C=w.target.files)==null?void 0:C[0];if(k){a("lead_magnet_pdf");try{const E=await p(k,"lead-magnet");d(L=>({...L,lead_magnet_config:{...L.lead_magnet_config,pdf_url:E}})),s({title:"PDF uploaded!"})}catch(E){s({title:"Upload failed",description:E.message,variant:"destructive"})}finally{a(null)}}}})]})]})]})]})]})]}),e.jsx(uSs,{brokerageId:t}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:()=>u.mutate(),disabled:u.isPending,size:"lg",children:[e.jsx(_c,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Landing Page"]})})]})}function uSs({brokerageId:t}){const{data:s=[]}=gt({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(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{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(Re,{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:[ps(new Date(r.created_at),"MMM d, yyyy h:mm a")," · via ",r.source]})]})},r.id))})})]})}function hSs(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function mSs({video:t}){return t.cta_clicked_at?e.jsx(Qe,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(Qe,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(wn,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(Qe,{variant:"secondary",children:[e.jsx(An,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(Qe,{variant:"outline",children:[e.jsx(ln,{className:"h-3 w-3 mr-1"}),"Draft"]})}function Qlt({brokerageId:t}){const{data:s=[],isLoading:r}=sSs(t),{data:n=[]}=$lt(t),a=aSs(),o=iSs(),l=Blt(),[i,d]=S.useState(""),[u,p]=S.useState(!1),[x,y]=S.useState({title:"",script_text:"",category:"general"}),_=s.filter(C=>{var L,I,O,V;return i?`${((L=C.prospect)==null?void 0:L.first_name)||""} ${((I=C.prospect)==null?void 0:I.last_name)||""}`.toLowerCase().includes(i.toLowerCase())||((V=(O=C.video)==null?void 0:O.title)==null?void 0:V.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=S.useCallback(C=>{if(!C)return;const E=`${window.location.origin}/recruit-video/${C}`;navigator.clipboard.writeText(E),me.success("Share link copied")},[]),w=S.useCallback((C,E)=>{l.mutate({id:C,sent_via:E})},[l]),k=()=>{!x.title.trim()||!x.script_text.trim()||a.mutate({brokerage_id:t,...x},{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:Tn,color:"text-primary"},{label:"Sent",value:b.sent,icon:An,color:"text-blue-500"},{label:"Viewed",value:b.viewed,icon:wn,color:"text-amber-500"},{label:"CTA Clicked",value:b.ctaClicked,icon:Qn,color:"text-emerald-500"}].map(C=>e.jsx(Pe,{children:e.jsxs(Re,{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(ia,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(ea,{children:[e.jsxs(ls,{value:"videos",children:[e.jsx(Tn,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(ls,{value:"scripts",children:[e.jsx(fn,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(ls,{value:"analytics",children:[e.jsx(to,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(js,{value:"videos",children:e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ot,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or title...",value:i,onChange:C=>d(C.target.value),className:"pl-9"})]})]})}),e.jsx(Re,{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(Tn,{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 E,L,I,O,V,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:[(E=C.video)!=null&&E.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(Tn,{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:hSs(((L=C.video)==null?void 0:L.duration_seconds)??null)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"font-medium truncate",children:[(I=C.prospect)==null?void 0:I.first_name," ",(O=C.prospect)==null?void 0:O.last_name]}),e.jsx(mSs,{video:C})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:((V=C.video)==null?void 0:V.title)||"Untitled video"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ps(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(An,{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(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ot,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(fs,{open:u,onOpenChange:p,children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Us,{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(xe,{children:"Title"}),e.jsx(De,{value:x.title,onChange:C=>y(E=>({...E,title:C.target.value})),placeholder:"e.g., Why Switch to Our Brokerage"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Category"}),e.jsxs(Bs,{value:x.category,onValueChange:C=>y(E=>({...E,category:C})),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:Ywe.map(C=>e.jsx(vt,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Script"}),e.jsx(vr,{value:x.script_text,onChange:C=>y(E=>({...E,script_text:C.target.value})),placeholder:"Hi [Name], I noticed you've been doing great work at [Brokerage]...",rows:8})]}),e.jsx(K,{onClick:k,disabled:!x.title.trim()||!x.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx(Re,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(fn,{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 L;const E=((L=Ywe.find(I=>I.value===C.category))==null?void 0:L.label)||C.category;return e.jsx(Pe,{className:"relative group",children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Qe,{variant:"outline",className:"text-[10px] mb-2",children:E}),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(gr,{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(Qe,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},C.id)})})})]})}),e.jsx(js,{value:"analytics",children:e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"Engagement Funnel"})}),e.jsxs(Re,{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,E)=>E.view_count-C.view_count).slice(0,5).map(C=>{var E,L;return e.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded-md bg-muted/30",children:[e.jsxs("span",{className:"font-medium",children:[(E=C.prospect)==null?void 0:E.first_name," ",(L=C.prospect)==null?void 0:L.last_name]}),e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wn,{className:"h-3.5 w-3.5"})," ",C.view_count]}),C.cta_clicked_at&&e.jsx(Qn,{className:"h-4 w-4 text-emerald-500"})]})]},C.id)})})]})]})]})})]})]})}function Jlt({brokerageId:t}){const{toast:s}=wa(),r=Jt(),{stages:n,prospects:a}=Jme(t),[o,l]=S.useState(!1),[i,d]=S.useState({title:"",target_count:"10",target_stage_id:"",period_start:ps(new Date,"yyyy-MM-dd"),period_end:ps(new Date(new Date().getFullYear(),new Date().getMonth()+3,0),"yyyy-MM-dd")}),{data:u=[],isLoading:p}=gt({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}}),x=It({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=It({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(k=>k.id===b.target_stage_id);return{count:a.filter(k=>gg(new Date(k.created_at),{start:new Date(b.period_start),end:new Date(b.period_end)})?b.target_stage_id?k.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(Us,{className:"h-4 w-4 mr-1"})," New Goal"]})]}),u.length===0?e.jsxs(Pe,{className:"py-12 text-center",children:[e.jsx(Rh,{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),k=Math.min(100,N/b.target_count*100),C=gg(new Date,{start:new Date(b.period_start),end:new Date(b.period_end)});return e.jsxs(Pe,{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(Ot,{className:"text-sm",children:b.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ps(new Date(b.period_start),"MMM d")," – ",ps(new Date(b.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[C?e.jsx(Qe,{className:"text-[10px]",children:"Active"}):e.jsx(Qe,{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(gr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Re,{className:"space-y-2",children:[w&&e.jsxs(Qe,{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(gi,{value:k,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[k.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(),x.mutate(i)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Goal Title *"}),e.jsx(De,{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(xe,{children:"Target Count *"}),e.jsx(De,{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(xe,{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(xe,{children:"Start Date"}),e.jsx(De,{type:"date",required:!0,value:i.period_start,onChange:b=>d(N=>({...N,period_start:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"End Date"}),e.jsx(De,{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:x.isPending,children:"Create Goal"})]})]})]})})]})}const pSs={first_name:"Sarah",brokerage_name:"ABC Realty",city:"Austin",sender_name:"Jeremy"};function ect({email:t,mergeValues:s=pSs,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(Qe,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(ln,{className:"h-3 w-3"}),t.email_number===1?"Sent immediately":`Day ${t.delay_days}`]}),o.length>1&&e.jsxs(Qe,{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)}})})]})]})})}function $Ce({brokerageId:t}){const s=Jt(),[r,n]=S.useState({brokerage_id:t,sender_name:"LevelUp",sender_email:"recruiting@relevelup.com",reply_to_email:"",merge_fields:{city:"",broker_name:""}}),{data:a}=gt({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}=gt({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}});S.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=It({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(xe,{className:"text-xs",children:"Sender Display Name"}),e.jsx(De,{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(xe,{className:"text-xs",children:"Sender Email Address"}),e.jsx(De,{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"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs",children:"Reply-To Email (optional)"}),e.jsx(De,{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.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(xe,{className:"text-xs",children:"{{brokerage_name}}"}),e.jsx(De,{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(xe,{className:"text-xs",children:"{{city}}"}),e.jsx(De,{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(xe,{className:"text-xs",children:"{{sender_name}}"}),e.jsx(De,{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(_c,{className:"h-4 w-4 mr-1"})," Save Settings"]})]})}const fSs=$g.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",jc(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()}}}),m9e=[{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 Yu({onClick:t,active:s,disabled:r,icon:n,tooltip:a}){return e.jsxs(Yl,{children:[e.jsx(Xl,{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(Cl,{side:"bottom",className:"text-xs",children:a})]})}function xSs({content:t,onChange:s}){const r=Ike({extensions:[Dke.configure({heading:{levels:[1,2,3]}}),fSs,Hke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}}),Gke.configure({types:["heading","paragraph"]}),Wke,kat],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())}});S.useEffect(()=>{r&&t!==r.getHTML()&&r.commands.setContent(t)},[t,r]);const n=S.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=S.useCallback(o=>{r&&r.chain().focus().insertContent(`{{${o}}}`).run()},[r]);return r?e.jsx(N1,{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(Yu,{onClick:()=>r.chain().focus().toggleBold().run(),active:r.isActive("bold"),icon:V4,tooltip:"Bold"}),e.jsx(Yu,{onClick:()=>r.chain().focus().toggleItalic().run(),active:r.isActive("italic"),icon:J4,tooltip:"Italic"}),e.jsx(Yu,{onClick:()=>r.chain().focus().toggleUnderline().run(),active:r.isActive("underline"),icon:zL,tooltip:"Underline"}),e.jsx(Yu,{onClick:()=>r.chain().focus().toggleStrike().run(),active:r.isActive("strike"),icon:DL,tooltip:"Strikethrough"}),e.jsx(wo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Yu,{onClick:()=>r.chain().focus().toggleHeading({level:1}).run(),active:r.isActive("heading",{level:1}),icon:wM,tooltip:"Heading 1"}),e.jsx(Yu,{onClick:()=>r.chain().focus().toggleHeading({level:2}).run(),active:r.isActive("heading",{level:2}),icon:jM,tooltip:"Heading 2"}),e.jsx(Yu,{onClick:()=>r.chain().focus().toggleHeading({level:3}).run(),active:r.isActive("heading",{level:3}),icon:fL,tooltip:"Heading 3"}),e.jsx(wo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Yu,{onClick:()=>r.chain().focus().toggleBulletList().run(),active:r.isActive("bulletList"),icon:Dh,tooltip:"Bullet List"}),e.jsx(Yu,{onClick:()=>r.chain().focus().toggleOrderedList().run(),active:r.isActive("orderedList"),icon:Zy,tooltip:"Numbered List"}),e.jsx(Yu,{onClick:()=>r.chain().focus().toggleBlockquote().run(),active:r.isActive("blockquote"),icon:cS,tooltip:"Blockquote"}),e.jsx(Yu,{onClick:()=>r.chain().focus().setHorizontalRule().run(),icon:Yy,tooltip:"Divider"}),e.jsx(wo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Yu,{onClick:()=>r.chain().focus().setTextAlign("left").run(),active:r.isActive({textAlign:"left"}),icon:$4,tooltip:"Align Left"}),e.jsx(Yu,{onClick:()=>r.chain().focus().setTextAlign("center").run(),active:r.isActive({textAlign:"center"}),icon:B4,tooltip:"Align Center"}),e.jsx(Yu,{onClick:()=>r.chain().focus().setTextAlign("right").run(),active:r.isActive({textAlign:"right"}),icon:q4,tooltip:"Align Right"}),e.jsx(wo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Yu,{onClick:n,active:r.isActive("link"),icon:fo,tooltip:"Insert Link"}),e.jsx(wo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Yu,{onClick:()=>r.chain().focus().undo().run(),disabled:!r.can().undo(),icon:yS,tooltip:"Undo"}),e.jsx(Yu,{onClick:()=>r.chain().focus().redo().run(),disabled:!r.can().redo(),icon:dS,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(DM,{className:"h-3.5 w-3.5"}),"Merge Tags"]})}),e.jsx(jd,{align:"end",className:"w-56",children:m9e.map(o=>e.jsxs(va,{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(Eke,{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:"}),m9e.map(o=>e.jsx(Qe,{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 gSs({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(Ir,{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(An,{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(S9,{icon:rr,color:"text-blue-500",label:"Total Sent",value:n.sent.toLocaleString()}),e.jsx(S9,{icon:wn,color:"text-amber-500",label:"Opens",value:`${n.opened.toLocaleString()}`,sub:`${n.openRate.toFixed(1)}% open rate`}),e.jsx(S9,{icon:Tm,color:"text-green-500",label:"Clicks",value:`${n.clicked.toLocaleString()}`,sub:`${n.clickRate.toFixed(1)}% click rate`}),e.jsx(S9,{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(ln,{className:"h-3 w-3"})," Last sent: ",ps(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(Pe,{className:"overflow-hidden",children:e.jsxs(Re,{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(Qe,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(rr,{className:"h-2.5 w-2.5"})," ",a.sent_count.toLocaleString()," sent"]}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1 border-amber-500/30 text-amber-600",children:[e.jsx(wn,{className:"h-2.5 w-2.5"})," ",a.opened_count.toLocaleString()," (",o.toFixed(1),"%)"]}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1 border-green-500/30 text-green-600",children:[e.jsx(Tm,{className:"h-2.5 w-2.5"})," ",a.clicked_count.toLocaleString()," (",l.toFixed(1),"%)"]}),a.failed_count>0&&e.jsxs(Qe,{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 S9({icon:t,color:s,label:r,value:n,sub:a}){return e.jsx(Pe,{children:e.jsx(Re,{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 tct(t){return gt({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:zv,color:"text-blue-500",bg:"bg-blue-50 dark:bg-blue-950/30",label:"Cold — Curiosity"},warm:{icon:e1,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 sct({brokerageId:t}){var Fe,Le,Ne,qe;const{user:s}=Fs(),r=Jt(),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(null),[u,p]=S.useState(!1),[x,y]=S.useState(!1),[_,b]=S.useState("editor"),[N,w]=S.useState(null),[k,C]=S.useState(null),{data:E={}}=tct(t),[L,I]=S.useState({name:"",description:"",theme:"",goal:"",primary_cta:"Learn more",warmth_level:"warm",sender_name:"",sender_email:"",reply_to_email:""}),{data:O}=gt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:ze,error:ve}=await G.from("brokerages").select("name, city, state").eq("id",t).single();if(ve)throw ve;return ze}}),{data:V}=gt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:ze,error:ve}=await G.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(ve)throw ve;return ze}}),q={first_name:"Sarah",brokerage_name:((Fe=V==null?void 0:V.merge_fields)==null?void 0:Fe.brokerage_name)||(O==null?void 0:O.name)||"Your Brokerage",city:((Le=V==null?void 0:V.merge_fields)==null?void 0:Le.city)||(O==null?void 0:O.city)||"Your City",sender_name:((Ne=V==null?void 0:V.merge_fields)==null?void 0:Ne.sender_name)||(V==null?void 0:V.sender_name)||"Your Name"},$=ze=>ze.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:U=[],isLoading:se}=gt({queryKey:["recruit-campaigns",t],queryFn:async()=>{const{data:ze,error:ve}=await G.from("recruit_campaigns").select("*").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("sort_order");if(ve)throw ve;return ze}}),{data:Y={}}=gt({queryKey:["recruit-campaign-emails",t],enabled:U.length>0,queryFn:async()=>{const ze=U.map(Ve=>Ve.id),{data:ve,error:dt}=await G.from("recruit_campaign_emails").select("*").in("campaign_id",ze).order("email_number");if(dt)throw dt;const fe={};return ve.forEach(Ve=>{fe[Ve.campaign_id]||(fe[Ve.campaign_id]=[]),fe[Ve.campaign_id].push(Ve)}),fe}}),J=Object.values(Y).flat().map(ze=>ze.id),{data:X=[]}=gt({queryKey:["recruit-subject-overrides",t],enabled:J.length>0,queryFn:async()=>{const{data:ze,error:ve}=await G.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(ve)throw ve;return ze}}),ce={};X.forEach(ze=>{ce[ze.campaign_email_id]=ze.selected_subject_index});const ie=It({mutationFn:async({campaignEmailId:ze,selectedIndex:ve})=>{const{error:dt}=await G.from("recruit_brokerage_subject_overrides").upsert({brokerage_id:t,campaign_email_id:ze,selected_subject_index:ve,updated_at:new Date().toISOString()},{onConflict:"brokerage_id,campaign_email_id"});if(dt)throw dt},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-subject-overrides",t]}),me.success("Subject line updated for your brokerage")},onError:ze=>me.error(ze.message)}),ae=It({mutationFn:async ze=>{const{error:ve}=await G.from("recruit_campaign_emails").update({title:ze.title,subject_line:ze.subject_line,subject_line_options:ze.subject_line_options,body_html:ze.body_html,body_text:ze.body_text,delay_days:ze.delay_days,updated_at:new Date().toISOString()}).eq("id",ze.id);if(ve)throw ve},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email template saved!"),l(null)},onError:ze=>me.error(ze.message)}),oe=It({mutationFn:async()=>{const ze=L.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),{data:ve,error:dt}=await G.from("recruit_campaigns").insert({name:L.name,slug:ze,description:L.description||null,theme:L.theme||null,goal:L.goal||null,primary_cta:L.primary_cta||"Learn more",warmth_level:L.warmth_level,brokerage_id:t,created_by:s==null?void 0:s.id,sender_name:L.sender_name||null,sender_email:L.sender_email||null,reply_to_email:L.reply_to_email||null,is_active:!0,sort_order:U.length+1}).select().single();if(dt)throw dt;const fe=[{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:Ve}=await G.from("recruit_campaign_emails").insert(fe.map(Je=>({campaign_id:ve.id,...Je,body_html:"

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

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

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

",body_text:"",delay_days:fe+7,is_active:!0});if(Je)throw Je},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email added to campaign!")},onError:ze=>me.error(ze.message)}),he=It({mutationFn:async ze=>{const{error:ve}=await G.from("recruit_campaigns").delete().eq("id",ze);if(ve)throw ve},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Campaign deleted")},onError:ze=>me.error(ze.message)}),we=It({mutationFn:async ze=>{const{error:ve}=await G.from("recruit_campaign_emails").delete().eq("id",ze);if(ve)throw ve},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email removed from campaign")},onError:ze=>me.error(ze.message)}),je=It({mutationFn:async({emailId:ze,delay_days:ve})=>{const{error:dt}=await G.from("recruit_campaign_emails").update({delay_days:ve,updated_at:new Date().toISOString()}).eq("id",ze);if(dt)throw dt},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Send delay updated")},onError:ze=>me.error(ze.message)});if(se)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 Ue=U.filter(ze=>!ze.brokerage_id),Te=U.filter(ze=>ze.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(ko,{className:"h-4 w-4"})," Default Settings"]}),e.jsxs(K,{size:"sm",onClick:()=>y(!0),className:"gap-1.5",children:[e.jsx(Us,{className:"h-4 w-4"})," New Campaign"]})]})]}),e.jsx(Pe,{className:"border-primary/20 bg-primary/5",children:e.jsx(Re,{className:"py-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx($r,{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(ko,{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(xL,{className:"h-4 w-4"})," Your Custom Campaigns"]}),e.jsx("div",{className:"space-y-3",children:Te.map(ze=>Me(ze,!0))})]}),Ue.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($r,{className:"h-4 w-4"})," System Campaigns"]}),e.jsx("div",{className:"space-y-3",children:Ue.map(ze=>Me(ze,!1))})]}),U.length===0&&e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(rr,{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(Us,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})}),e.jsx(gSs,{open:!!k,onClose:()=>C(null),campaignName:(k==null?void 0:k.name)||"",stat:k&&E[k.id]||null}),i&&e.jsx(ect,{email:i,mergeValues:q,selectedSubjectIndex:ce[i.id],onClose:()=>d(null)}),e.jsx(fs,{open:!!o,onOpenChange:ze=>!ze&&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(X4,{className:"h-5 w-5 text-primary"}),"Edit Email #",o==null?void 0:o.email_number]}),e.jsx(Ir,{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(xe,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Title"}),e.jsx(De,{value:o.title,onChange:ze=>l({...o,title:ze.target.value}),className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Delay (days after previous)"}),e.jsx(De,{type:"number",min:0,max:90,value:o.delay_days,onChange:ze=>l({...o,delay_days:parseInt(ze.target.value)||7}),className:"h-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Subject Line"}),e.jsx(De,{value:o.subject_line,onChange:ze=>l({...o,subject_line:ze.target.value}),placeholder:"e.g. Hey {{first_name}}, quick question...",className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(xe,{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(vr,{value:((qe=o.subject_line_options)==null?void 0:qe.join(` `))||"",onChange:ze=>l({...o,subject_line_options:ze.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(xe,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Body"}),e.jsx(ia,{value:_,onValueChange:ze=>b(ze),children:e.jsxs(ea,{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(xSs,{content:o.body_html,onChange:ze=>l({...o,body_html:ze})}):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:()=>ae.mutate(o),disabled:ae.isPending,className:"gap-1.5",children:[e.jsx(_c,{className:"h-3.5 w-3.5"})," Save Changes"]})]})]})]})]})}),e.jsx(fs,{open:x,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(Us,{className:"h-5 w-5 text-primary"})," Create Custom Campaign"]}),e.jsx(Ir,{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(xe,{className:"text-xs font-medium",children:"Campaign Name *"}),e.jsx(De,{value:L.name,onChange:ze=>I({...L,name:ze.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(xe,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(Bs,{value:L.warmth_level,onValueChange:ze=>I({...L,warmth_level:ze}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"cold",children:"❄️ Cold — Curiosity"}),e.jsx(vt,{value:"warm",children:"☀️ Warm — Growth"}),e.jsx(vt,{value:"hot",children:"🔥 Hot — Private Invite"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium",children:"Primary CTA"}),e.jsx(De,{value:L.primary_cta,onChange:ze=>I({...L,primary_cta:ze.target.value}),placeholder:"Learn more"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium",children:"Description"}),e.jsx(vr,{value:L.description,onChange:ze=>I({...L,description:ze.target.value}),placeholder:"What is this campaign about?",rows:2})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium",children:"Goal"}),e.jsx(De,{value:L.goal,onChange:ze=>I({...L,goal:ze.target.value}),placeholder:"e.g. Convert warm leads to meetings"})]}),e.jsxs(of,{children:[e.jsx(lf,{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(rr,{className:"h-3.5 w-3.5"})," Email Settings Override"]}),e.jsx(Oi,{className:"h-3.5 w-3.5"})]})}),e.jsxs(cf,{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(xe,{className:"text-xs",children:"Sender Name"}),e.jsx(De,{value:L.sender_name,onChange:ze=>I({...L,sender_name:ze.target.value}),placeholder:"e.g. Jeremy at LevelUp"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs",children:"Sender Email"}),e.jsx(De,{value:L.sender_email,onChange:ze=>I({...L,sender_email:ze.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(xe,{className:"text-xs",children:"Reply-To Email"}),e.jsx(De,{value:L.reply_to_email,onChange:ze=>I({...L,reply_to_email:ze.target.value}),placeholder:"e.g. jeremy@mybrokerage.com"})]})]})]}),e.jsxs(K,{className:"w-full",disabled:!L.name.trim()||oe.isPending,onClick:()=>oe.mutate(),children:[e.jsx(Us,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})]})}),e.jsx(fs,{open:!!N,onOpenChange:ze=>!ze&&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(ko,{className:"h-5 w-5 text-primary"})," Campaign Email Settings"]}),e.jsx(Ir,{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(xe,{className:"text-xs font-medium",children:"Campaign Name"}),e.jsx(De,{value:N.name,onChange:ze=>w({...N,name:ze.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(Bs,{value:N.warmth_level,onValueChange:ze=>w({...N,warmth_level:ze}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"cold",children:"❄️ Cold"}),e.jsx(vt,{value:"warm",children:"☀️ Warm"}),e.jsx(vt,{value:"hot",children:"🔥 Hot"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium",children:"Goal"}),e.jsx(De,{value:N.goal||"",onChange:ze=>w({...N,goal:ze.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(rr,{className:"h-4 w-4 text-primary"})," Email Sender Override"]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs",children:"Sender Name"}),e.jsx(De,{value:N.sender_name||"",onChange:ze=>w({...N,sender_name:ze.target.value}),placeholder:"Uses brokerage default"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs",children:"Sender Email"}),e.jsx(De,{value:N.sender_email||"",onChange:ze=>w({...N,sender_email:ze.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(xe,{className:"text-xs",children:"Reply-To Email"}),e.jsx(De,{value:N.reply_to_email||"",onChange:ze=>w({...N,reply_to_email:ze.target.value}),placeholder:"Uses brokerage default"})]})]}),e.jsxs(K,{className:"w-full",onClick:()=>pe.mutate(N),disabled:pe.isPending,children:[e.jsx(_c,{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(Ir,{children:"These defaults apply to campaigns without their own overrides."})]}),e.jsx($Ce,{brokerageId:t})]})})]});function Me(ze,ve){const dt=p9e[ze.warmth_level]||p9e.cold,fe=dt.icon,Ve=Y[ze.id]||[],Je=n===ze.id,at=!!(ze.sender_name||ze.sender_email||ze.reply_to_email),Ae=E[ze.id];return e.jsxs(Pe,{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(Je?null:ze.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 ${dt.bg} flex items-center justify-center`,children:e.jsx(fe,{className:`h-5 w-5 ${dt.color}`})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[ze.name,e.jsx(Qe,{variant:ze.is_active?"default":"secondary",className:"text-[10px] px-1.5",children:ze.is_active?"Active":"Draft"}),ve&&e.jsx(Qe,{variant:"outline",className:"text-[10px] px-1.5",children:"Custom"}),at&&e.jsxs(Qe,{variant:"outline",className:"text-[10px] px-1.5 border-primary/30 text-primary",children:[e.jsx(rr,{className:"h-2.5 w-2.5 mr-0.5"})," Custom Sender"]})]}),e.jsx(hr,{className:"text-xs mt-0.5",children:ze.theme||ze.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:Ye=>{Ye.stopPropagation(),w({...ze})},children:e.jsx(ko,{className:"h-4 w-4 text-muted-foreground"})}),ve&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:Ye=>{Ye.stopPropagation(),confirm("Delete this campaign and all its emails? This cannot be undone.")&&he.mutate(ze.id)},children:e.jsx(gr,{className:"h-4 w-4"})}),Ae&&Ae.sent>0&&e.jsxs("div",{className:"hidden md:flex items-center gap-1.5",children:[e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1 font-medium",title:"Total emails sent",children:[e.jsx(rr,{className:"h-2.5 w-2.5"})," ",Ae.sent.toLocaleString()]}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1 border-amber-500/30 text-amber-600 font-medium",title:`${Ae.openRate.toFixed(1)}% open rate`,children:[e.jsx(wn,{className:"h-2.5 w-2.5"})," ",Ae.opened.toLocaleString()," (",Ae.openRate.toFixed(0),"%)"]}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1 border-green-500/30 text-green-600 font-medium",title:`${Ae.clickRate.toFixed(1)}% click rate`,children:[e.jsx(Tm,{className:"h-2.5 w-2.5"})," ",Ae.clicked.toLocaleString()," (",Ae.clickRate.toFixed(1),"%)"]})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 px-2 gap-1 text-xs",onClick:Ye=>{Ye.stopPropagation(),C(ze)},title:"View detailed engagement stats",children:[e.jsx(to,{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(rr,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:[Ve.length," emails"]})]}),e.jsx("div",{className:"h-7 w-7 rounded-md flex items-center justify-center",children:Je?e.jsx(nf,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Oi,{className:"h-4 w-4 text-muted-foreground"})})]})]})}),Je&&e.jsxs(Re,{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:ze.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:ze.primary_cta||"—"})]})]}),at&&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(rr,{className:"h-3 w-3"})," Campaign Sender Override"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs text-muted-foreground",children:[ze.sender_name&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Name:"})," ",ze.sender_name]}),ze.sender_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Email:"})," ",ze.sender_email]}),ze.reply_to_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Reply-To:"})," ",ze.reply_to_email]})]})]}),e.jsx("div",{className:"relative",children:Ve.map((Ye,We)=>{var ot,Ge;return e.jsxs("div",{className:"relative flex gap-4 pb-4 last:pb-0",children:[Weet.stopPropagation(),onBlur:et=>{const ht=parseInt(et.target.value)||0;ht!==Ye.delay_days&&je.mutate({emailId:Ye.id,delay_days:ht})},onKeyDown:et=>{et.key==="Enter"&&et.target.blur()}}),"days"]})]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ln,{className:"h-3 w-3"}),Ye.email_number===1?"Sent immediately":`Day ${Ye.delay_days}`]}),e.jsx("span",{className:"text-border",children:"•"}),e.jsxs("span",{className:"truncate",children:["Subject: ",$(((ot=Ye.subject_line_options)==null?void 0:ot.length)>0&&Ye.subject_line_options[ce[Ye.id]??0]||Ye.subject_line)]})]}),((Ge=Ye.subject_line_options)==null?void 0:Ge.length)>1&&e.jsx("div",{className:"mt-2",children:e.jsxs(Bs,{value:String(ce[Ye.id]??0),onValueChange:et=>ie.mutate({campaignEmailId:Ye.id,selectedIndex:parseInt(et)}),children:[e.jsx(Rs,{className:"h-7 text-xs w-full max-w-sm",children:e.jsx(qs,{placeholder:"Choose subject line"})}),e.jsx(Os,{children:Ye.subject_line_options.map((et,ht)=>e.jsxs(vt,{value:String(ht),className:"text-xs",children:[e.jsxs("span",{className:"font-medium mr-1.5",children:[ht===0?"Primary":`Alt ${ht}`,":"]}),$(et)]},ht))})]})})]}),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(Ye),children:e.jsx(wn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{l({...Ye}),b("editor")},children:e.jsx(ga,{className:"h-4 w-4"})}),ve&&Ve.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(Ye.id)},children:e.jsx(gr,{className:"h-4 w-4"})})]})]})})]},Ye.id)})}),ve&&e.jsxs(K,{variant:"outline",size:"sm",className:"w-full gap-1.5",onClick:()=>_e.mutate(ze.id),disabled:_e.isPending,children:[e.jsx(Us,{className:"h-3.5 w-3.5"})," Add Email to Sequence"]})]})]},ze.id)}}const f9e={active:{icon:So,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:ti,color:"bg-blue-500/10 text-blue-600",label:"Completed"},cancelled:{icon:Zl,color:"bg-red-500/10 text-red-600",label:"Cancelled"}},x9e={sent:{icon:rr,color:"text-blue-500"},opened:{icon:wn,color:"text-amber-500"},clicked:{icon:Tm,color:"text-green-500"},failed:{icon:Qc,color:"text-destructive"}};function rct({brokerageId:t}){var Fe,Le,Ne,qe,ze;const{user:s}=Fs(),r=Jt(),[n,a]=S.useState(!1),[o,l]=S.useState(""),[i,d]=S.useState(new Set),[u,p]=S.useState("assignments"),[x,y]=S.useState(null),[_,b]=S.useState(""),[N,w]=S.useState("all"),[k,C]=S.useState("all"),{data:E={}}=gt({queryKey:["recruit-campaign-emails-for-preview",t],queryFn:async()=>{const{data:ve,error:dt}=await G.from("recruit_campaign_emails").select("*").order("email_number");if(dt)throw dt;const fe={};return(ve??[]).forEach(Ve=>{fe[Ve.campaign_id]||(fe[Ve.campaign_id]=[]),fe[Ve.campaign_id].push(Ve)}),fe}}),{data:L}=gt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:ve,error:dt}=await G.from("brokerages").select("name, city, state").eq("id",t).single();if(dt)throw dt;return ve}}),{data:I}=gt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:ve,error:dt}=await G.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(dt)throw dt;return ve}}),{data:O=[]}=gt({queryKey:["recruit-subject-overrides",t],queryFn:async()=>{const{data:ve,error:dt}=await G.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(dt)throw dt;return ve}}),V={};O.forEach(ve=>{V[ve.campaign_email_id]=ve.selected_subject_index});const q={first_name:((Fe=x==null?void 0:x.prospect)==null?void 0:Fe.first_name)||"Sarah",brokerage_name:((Le=I==null?void 0:I.merge_fields)==null?void 0:Le.brokerage_name)||(L==null?void 0:L.name)||"Your Brokerage",city:((Ne=I==null?void 0:I.merge_fields)==null?void 0:Ne.city)||(L==null?void 0:L.city)||"Your City",sender_name:((qe=I==null?void 0:I.merge_fields)==null?void 0:qe.sender_name)||(I==null?void 0:I.sender_name)||"Your Name"},$=ve=>{const dt=E[ve.campaign_id]||[],fe=ve.current_email_number+1;return dt.find(Ve=>Ve.email_number===fe)||null},{data:U=[],isLoading:se}=gt({queryKey:["recruit-campaign-assignments",t],queryFn:async()=>{let dt=[],fe=0;for(;;){const{data:Ve,error:Je}=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(fe,fe+1e3-1);if(Je)throw Je;if(dt=dt.concat(Ve??[]),!Ve||Ve.length<1e3)break;fe+=1e3}return dt}}),{data:Y=[]}=gt({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{const{data:ve,error:dt}=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(dt)throw dt;return ve}}),{data:J=[]}=gt({queryKey:["recruit-campaigns"],queryFn:async()=>{const{data:ve,error:dt}=await G.from("recruit_campaigns").select("id, name, warmth_level").eq("is_active",!0).order("sort_order");if(dt)throw dt;return ve}}),{data:X=[]}=gt({queryKey:["recruit-prospects-for-assign",t],queryFn:async()=>{let dt=[],fe=0;for(;;){const{data:Ve,error:Je}=await G.from("recruit_prospects").select("id, first_name, last_name, email").eq("brokerage_id",t).order("first_name").range(fe,fe+1e3-1);if(Je)throw Je;if(dt=dt.concat(Ve??[]),!Ve||Ve.length<1e3)break;fe+=1e3}return dt}}),ce=new Set(U.map(ve=>`${ve.prospect_id}-${ve.campaign_id}`)),ie=It({mutationFn:async()=>{if(!o||i.size===0)throw new Error("Select a campaign and at least one prospect");const ve=new Date,dt=Array.from(i).filter(Ve=>!ce.has(`${Ve}-${o}`)).map(Ve=>({prospect_id:Ve,campaign_id:o,brokerage_id:t,assigned_by:s.id,status:"active",current_email_number:0,next_send_at:ve.toISOString(),started_at:ve.toISOString()}));if(dt.length===0)throw new Error("All selected prospects are already assigned to this campaign");const{error:fe}=await G.from("recruit_campaign_assignments").insert(dt);if(fe)throw fe},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),me.success(`Campaign assigned to ${i.size} prospect(s)!`),a(!1),l(""),d(new Set)},onError:ve=>me.error(ve.message)}),ae=It({mutationFn:async({id:ve,newStatus:dt})=>{const{error:fe}=await G.from("recruit_campaign_assignments").update({status:dt,updated_at:new Date().toISOString()}).eq("id",ve);if(fe)throw fe},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),me.success("Assignment updated")}}),oe=It({mutationFn:async()=>{const{data:ve,error:dt}=await G.functions.invoke("ses-recruit-drip",{body:{action:"process_drips"}});if(dt)throw dt;return ve},onSuccess:ve=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),r.invalidateQueries({queryKey:["recruit-campaign-sends",t]}),me.success(`Wave sent! ${ve.sent} emails delivered, ${ve.skipped} skipped, ${ve.failed} failed`)},onError:ve=>me.error(`Send failed: ${ve.message}`)}),pe=U.filter(ve=>ve.status==="active").length;U.filter(ve=>ve.status==="completed").length;const _e=U.filter(ve=>ve.status==="active"&&ve.next_send_at&&new Date(ve.next_send_at)<=new Date).length,{data:he={}}=tct(t),we=U.reduce((ve,dt)=>ve+Math.max(0,dt.current_email_number||0),0),je=Object.values(he).reduce((ve,dt)=>ve+dt.opened,0),Ue=Object.values(he).reduce((ve,dt)=>ve+dt.clicked,0);Object.values(he).reduce((ve,dt)=>ve+dt.failed,0);const Te=we>0?Math.round(je/we*100):0,Me=we>0?Ue/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:[_e>0&&e.jsxs(K,{variant:"outline",onClick:()=>oe.mutate(),disabled:oe.isPending,className:"border-amber-500/50 text-amber-600 hover:bg-amber-500/10",children:[e.jsx(Oh,{className:"h-4 w-4 mr-1"}),oe.isPending?"Sending...":`Send Next Wave (${_e})`]}),e.jsxs(K,{onClick:()=>a(!0),children:[e.jsx(An,{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(Pe,{children:e.jsxs(Re,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(lr,{className:"h-7 w-7 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:U.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Assigned"})]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(So,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:pe}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active"})]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(rr,{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(Pe,{children:e.jsxs(Re,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(wn,{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 (",je.toLocaleString(),")"]})]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(Tm,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[Me.toFixed(1),"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Click Rate (",Ue.toLocaleString(),")"]})]})]})})]}),e.jsxs(ia,{value:u,onValueChange:p,children:[e.jsxs(ea,{children:[e.jsxs(ls,{value:"assignments",children:["Active Drips (",pe,")"]}),e.jsxs(ls,{value:"history",children:["Send History (",we.toLocaleString(),")"]})]}),e.jsx(js,{value:"assignments",className:"mt-4",children:se?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"})}):U.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(An,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No 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:U.map(ve=>{var Ae,Ye,We,ot;const dt=f9e[ve.status]||f9e.active,fe=dt.icon,Je=(E[ve.campaign_id]||[]).length||4,at=$(ve);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(Qe,{className:`text-xs ${dt.color} border-0`,children:[e.jsx(fe,{className:"h-3 w-3 mr-1"}),dt.label]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(Ae=ve.prospect)==null?void 0:Ae.first_name," ",(Ye=ve.prospect)==null?void 0:Ye.last_name,e.jsx("span",{className:"text-muted-foreground font-normal ml-2",children:(We=ve.prospect)==null?void 0:We.email})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(ot=ve.campaign)==null?void 0:ot.name," · Email ",ve.current_email_number,"/",Je,ve.next_send_at&&ve.status==="active"&&e.jsxs(e.Fragment,{children:[" ","· ",e.jsx(ln,{className:"h-3 w-3 inline"})," Next: ",ps(new Date(ve.next_send_at),"MMM d, h:mm a"),new Date(ve.next_send_at)<=new Date&&e.jsx(Qe,{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:[at&&e.jsx(K,{variant:"ghost",size:"sm",title:"Preview next email",onClick:()=>y(ve),children:e.jsx(wn,{className:"h-3.5 w-3.5"})}),ve.status==="active"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ae.mutate({id:ve.id,newStatus:"paused"}),children:e.jsx(uh,{className:"h-3.5 w-3.5"})}),ve.status==="paused"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ae.mutate({id:ve.id,newStatus:"active"}),children:e.jsx(So,{className:"h-3.5 w-3.5"})}),(ve.status==="active"||ve.status==="paused")&&e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>ae.mutate({id:ve.id,newStatus:"cancelled"}),children:e.jsx(Zl,{className:"h-3.5 w-3.5"})})]})]},ve.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(Bs,{value:N,onValueChange:w,children:[e.jsx(Rs,{className:"w-[220px] h-8 text-xs",children:e.jsx(qs,{placeholder:"All campaigns"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All campaigns"}),J.map(ve=>e.jsx(vt,{value:ve.id,children:ve.name},ve.id))]})]}),e.jsxs(Bs,{value:k,onValueChange:C,children:[e.jsx(Rs,{className:"w-[160px] h-8 text-xs",children:e.jsx(qs,{placeholder:"All statuses"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All statuses"}),e.jsx(vt,{value:"sent",children:"Sent (no engagement)"}),e.jsx(vt,{value:"opened",children:"Opened"}),e.jsx(vt,{value:"clicked",children:"Clicked"})]})]}),(N!=="all"||k!=="all")&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 text-xs",onClick:()=>{w("all"),C("all")},children:"Clear"})]}),(()=>{var dt;const ve=Y.filter(fe=>{var Ve;return!(N!=="all"&&((Ve=fe.campaign_email)==null?void 0:Ve.campaign_id)!==N||k==="opened"&&!fe.opened_at||k==="clicked"&&!fe.clicked_at||k==="sent"&&(fe.opened_at||fe.clicked_at))});return ve.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(rr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:Y.length===0?"No emails sent yet":"No emails match these filters"}),e.jsx("p",{className:"text-sm",children:Y.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 ",ve.length," of ",Y.length," recent sends",N!=="all"&&` · ${(dt=J.find(fe=>fe.id===N))==null?void 0:dt.name}`]}),e.jsx("div",{className:"space-y-1",children:ve.map(fe=>{var Ae,Ye,We;const Ve=x9e[fe.status]||x9e.sent,Je=Ve.icon,at=(Ae=J.find(ot=>{var Ge;return ot.id===((Ge=fe.campaign_email)==null?void 0:Ge.campaign_id)}))==null?void 0:Ae.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(Je,{className:`h-4 w-4 flex-shrink-0 ${Ve.color}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm truncate",children:[(Ye=fe.prospect)==null?void 0:Ye.first_name," ",(We=fe.prospect)==null?void 0:We.last_name,e.jsxs("span",{className:"text-muted-foreground font-normal ml-2",children:["Email #",fe.email_number]}),at&&e.jsx(Qe,{variant:"outline",className:"ml-2 text-[10px] px-1.5 py-0 font-normal",children:at})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:fe.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-shrink-0",children:[fe.opened_at&&e.jsxs("span",{className:"flex items-center gap-1 text-amber-500",children:[e.jsx(wn,{className:"h-3 w-3"})," ",ps(new Date(fe.opened_at),"MMM d")]}),fe.clicked_at&&e.jsxs("span",{className:"flex items-center gap-1 text-green-500",children:[e.jsx(Tm,{className:"h-3 w-3"})," ",ps(new Date(fe.clicked_at),"MMM d")]}),e.jsx("span",{children:ps(new Date(fe.sent_at),"MMM d, h:mm a")})]})]},fe.id)})})]})})()]})]}),e.jsx(fs,{open:n,onOpenChange:ve=>{a(ve),ve||(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(Ir,{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(xe,{className:"text-sm font-medium",children:"1. Select Campaign"}),e.jsxs(Bs,{value:o,onValueChange:l,children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Choose a campaign..."})}),e.jsx(Os,{children:J.map(ve=>e.jsx(vt,{value:ve.id,children:ve.name},ve.id))})]})]}),o&&(()=>{const ve=_.toLowerCase(),dt=X.filter(Je=>`${Je.first_name} ${Je.last_name}`.toLowerCase().includes(ve)||Je.email.toLowerCase().includes(ve)),fe=dt.filter(Je=>!ce.has(`${Je.id}-${o}`)),Ve=fe.length>0&&fe.every(Je=>i.has(Je.id));return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{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(an,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or email...",value:_,onChange:Je=>b(Je.target.value),className:"pl-9 h-9"})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-9 whitespace-nowrap",onClick:()=>{if(Ve){const Je=new Set(i);fe.forEach(at=>Je.delete(at.id)),d(Je)}else{const Je=new Set(i);fe.forEach(at=>Je.add(at.id)),d(Je)}},children:[e.jsx(oL,{className:"h-3.5 w-3.5 mr-1"}),Ve?"Deselect All":`Select All (${fe.length})`]})]}),e.jsx("div",{className:"border rounded-lg max-h-60 overflow-y-auto divide-y",children:dt.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"}):dt.map(Je=>{const at=ce.has(`${Je.id}-${o}`);return e.jsxs("label",{className:`flex items-center gap-3 p-2.5 hover:bg-muted/50 cursor-pointer ${at?"opacity-40":""}`,children:[e.jsx(Ki,{checked:i.has(Je.id),disabled:at,onCheckedChange:Ae=>{const Ye=new Set(i);Ae?Ye.add(Je.id):Ye.delete(Je.id),d(Ye)}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[Je.first_name," ",Je.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Je.email})]}),at&&e.jsx(Qe,{variant:"outline",className:"text-[10px] shrink-0",children:"Already assigned"})]},Je.id)})}),dt.length>0&&e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Showing ",dt.length," of ",X.length," prospects",fe.length0&&e.jsx(Pe,{className:"bg-primary/5 border-primary/20",children:e.jsxs(Re,{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:(ze=J.find(ve=>ve.id===o))==null?void 0:ze.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(En,{className:"px-6 py-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>ie.mutate(),disabled:ie.isPending||!o||i.size===0,children:[e.jsx(An,{className:"h-4 w-4 mr-1"}),ie.isPending?"Assigning...":`Assign & Start (${i.size})`]})]})]})}),x&&(()=>{const ve=$(x);return ve?e.jsx(ect,{email:ve,mergeValues:q,selectedSubjectIndex:V[ve.id],onClose:()=>y(null)}):null})()]})}function nct({brokerageId:t}){const s=Jt(),[r,n]=S.useState([]),[a,o]=S.useState([]),[l,i]=S.useState(!1),d=S.useRef(!1),{data:u,isLoading:p}=gt({queryKey:["recruit-stages-editor",t],queryFn:async()=>{const{data:w,error:k}=await G.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(k)throw k;return w},enabled:!!t});S.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 x=It({mutationFn:async()=>{for(const C of a){const{error:E}=await G.from("recruit_pipeline_stages").delete().eq("id",C);if(E)throw E}const w=r.filter(C=>C.id&&!C.isNew),k=r.filter(C=>!C.id||C.isNew);for(const C of w){const{error:E}=await G.from("recruit_pipeline_stages").update({name:C.name,color:C.color,sort_order:C.sort_order}).eq("id",C.id);if(E)throw E}if(k.length>0){const{error:C}=await G.from("recruit_pipeline_stages").insert(k.map(E=>({brokerage_id:t,name:E.name,color:E.color,sort_order:E.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,k,C)=>{n(E=>E.map((L,I)=>I===w?{...L,[k]:C}:L)),i(!0)},_=()=>{const w=r.length>0?Math.max(...r.map(k=>k.sort_order)):0;n(k=>[...k,{name:"",color:"#6366f1",sort_order:w+1,isNew:!0}]),i(!0)},b=w=>{const k=r[w];k.id&&!k.isNew&&o(C=>[...C,k.id]),n(C=>C.filter((E,L)=>L!==w)),i(!0)},N=(w,k)=>{const C=w+k;if(C<0||C>=r.length)return;const E=[...r];[E[w],E[C]]=[E[C],E[w]],E.forEach((L,I)=>L.sort_order=I+1),n(E),i(!0)};return p?e.jsx("div",{className:"text-sm text-muted-foreground py-8 text-center",children:"Loading stages…"}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Pipeline Stages"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Customize the recruiting pipeline stages for this brokerage. Changes will apply to the Kanban board and all prospect tracking."})]}),e.jsx("div",{className:"space-y-2",children:r.map((w,k)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>N(k,-1),disabled:k===0,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▲"}),e.jsx("button",{type:"button",onClick:()=>N(k,1),disabled:k===r.length-1,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▼"})]}),e.jsx(hu,{className:"h-4 w-4 text-muted-foreground/50 shrink-0"}),e.jsx("input",{type:"color",value:w.color,onChange:C=>y(k,"color",C.target.value),className:"h-8 w-8 rounded cursor-pointer border-0 p-0 shrink-0"}),e.jsx(De,{value:w.name,onChange:C=>y(k,"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:k+1}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(k),className:"text-destructive hover:text-destructive shrink-0 h-8 w-8",children:e.jsx(gr,{className:"h-4 w-4"})})]},w.id||`new-${k}`))}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:_,className:"gap-1",children:[e.jsx(Us,{className:"h-4 w-4"})," Add Stage"]}),l&&e.jsxs(K,{size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,className:"gap-1",children:[e.jsx(_c,{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 ySs({brokerageId:t}){const{data:s=[],isLoading:r}=gt({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(mS,{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(Qe,{variant:"secondary",className:"text-base px-3 py-1",children:[s.length," total"]})]}),s.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(mS,{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(Pe,{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(Ot,{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(rr,{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(on,{className:"h-3 w-3"}),n.unsubscribed_at&&ps(new Date(n.unsubscribed_at),"MMM d, yyyy")]})]})}),n.unsubscribe_reason&&e.jsx(Re,{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 vSs(){var i;const[t,s]=S.useState(""),[r,n]=S.useState("board"),{data:a=[],isLoading:o}=gt({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(Es,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsx(Es,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"space-y-6",children:[a.length>1&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage:"}),e.jsxs(Bs,{value:l,onValueChange:s,children:[e.jsxs(Rs,{className:"w-[280px]",children:[e.jsx(pa,{className:"mr-2 h-4 w-4"}),e.jsx(qs,{placeholder:"Select brokerage"})]}),e.jsx(Os,{children:a.map(d=>e.jsx(vt,{value:d.id,children:d.name},d.id))})]})]}),l?e.jsxs(ia,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(ea,{className:"flex-wrap h-auto gap-1",children:[e.jsx(ls,{value:"pipeline",children:"Pipeline"}),e.jsxs(ls,{value:"contacts",children:[e.jsx(lr,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ls,{value:"video-outreach",children:[e.jsx(Tn,{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(rr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ls,{value:"drip-assignments",children:[e.jsx(An,{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(ko,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ls,{value:"pipeline-stages",children:[e.jsx(fS,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]}),e.jsxs(ls,{value:"unsubscribed",children:[e.jsx(mS,{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(fp,{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(LM,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(Vlt,{brokerageId:l}):e.jsx(Cde,{brokerageId:l})]}),e.jsx(js,{value:"contacts",children:e.jsx(Cde,{brokerageId:l})}),e.jsx(js,{value:"video-outreach",children:e.jsx(Qlt,{brokerageId:l})}),e.jsx(js,{value:"follow-ups",children:e.jsx(Ylt,{brokerageId:l})}),e.jsx(js,{value:"referrals",children:e.jsx(Klt,{brokerageId:l})}),e.jsx(js,{value:"interest",children:e.jsx(Zlt,{brokerageId:l})}),e.jsx(js,{value:"landing-page",children:e.jsx(Xlt,{brokerageId:l})}),e.jsx(js,{value:"goals",children:e.jsx(Jlt,{brokerageId:l})}),e.jsx(js,{value:"metrics",children:e.jsx(Hlt,{brokerageId:l})}),e.jsx(js,{value:"templates",children:e.jsx(Glt,{brokerageId:l})}),e.jsx(js,{value:"campaigns",children:e.jsx(sct,{brokerageId:l})}),e.jsx(js,{value:"drip-assignments",children:e.jsx(rct,{brokerageId:l})}),e.jsx(js,{value:"activity",children:e.jsx(Wlt,{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($Ce,{brokerageId:l})]})}),e.jsx(js,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(nct,{brokerageId:l})})}),e.jsx(js,{value:"unsubscribed",children:e.jsx(ySs,{brokerageId:l})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(pa,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function _Ss(){var l;const{managedBrokerages:t,selectedBrokerageId:s,setSelectedBrokerageId:r}=Fs(),[n,a]=S.useState("board"),o=s||((l=t[0])==null?void 0:l.id)||"";return t.length===0?e.jsx(Es,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(pa,{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(Es,{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(Bs,{value:o,onValueChange:r,children:[e.jsxs(Rs,{className:"w-[280px]",children:[e.jsx(pa,{className:"mr-2 h-4 w-4"}),e.jsx(qs,{placeholder:"Select brokerage"})]}),e.jsx(Os,{children:t.map(i=>e.jsx(vt,{value:i.id,children:i.name},i.id))})]})]}),o?e.jsxs(ia,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(ea,{className:"flex-wrap h-auto gap-1",children:[e.jsx(ls,{value:"pipeline",children:"Pipeline"}),e.jsxs(ls,{value:"contacts",children:[e.jsx(lr,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ls,{value:"video-outreach",children:[e.jsx(Tn,{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(rr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ls,{value:"drip-assignments",children:[e.jsx(An,{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(ko,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ls,{value:"pipeline-stages",children:[e.jsx(fS,{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(fp,{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(LM,{className:"h-3.5 w-3.5"})," Table"]})]})}),n==="board"?e.jsx(Vlt,{brokerageId:o}):e.jsx(Cde,{brokerageId:o})]}),e.jsx(js,{value:"contacts",children:e.jsx(Cde,{brokerageId:o})}),e.jsx(js,{value:"video-outreach",children:e.jsx(Qlt,{brokerageId:o})}),e.jsx(js,{value:"follow-ups",children:e.jsx(Ylt,{brokerageId:o})}),e.jsx(js,{value:"referrals",children:e.jsx(Klt,{brokerageId:o})}),e.jsx(js,{value:"interest",children:e.jsx(Zlt,{brokerageId:o})}),e.jsx(js,{value:"landing-page",children:e.jsx(Xlt,{brokerageId:o})}),e.jsx(js,{value:"goals",children:e.jsx(Jlt,{brokerageId:o})}),e.jsx(js,{value:"metrics",children:e.jsx(Hlt,{brokerageId:o})}),e.jsx(js,{value:"templates",children:e.jsx(Glt,{brokerageId:o})}),e.jsx(js,{value:"campaigns",children:e.jsx(sct,{brokerageId:o})}),e.jsx(js,{value:"drip-assignments",children:e.jsx(rct,{brokerageId:o})}),e.jsx(js,{value:"activity",children:e.jsx(Wlt,{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($Ce,{brokerageId:o})]})}),e.jsx(js,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(nct,{brokerageId:o})})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(pa,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found."})]})]})})}function bSs(){const[t,s]=S.useState(""),{data:r,isLoading:n}=gt({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||[],x=u||[],y=i.map(_=>{const b=p.filter(k=>k.brokerage_id===_.id),N=x.filter(k=>k.brokerage_id===_.id),w=b.length>0?b.reduce((k,C)=>C.created_at>k?C.created_at:k,b[0].created_at):null;return{brokerage_id:_.id,brokerage_name:_.name,total_items:b.length,videos:b.filter(k=>k.content_type==="video").length,pdfs:b.filter(k=>k.content_type==="pdf").length,links:b.filter(k=>k.content_type==="link"||k.content_type==="canva_link").length,events:b.filter(k=>k.content_type==="event").length,graphics:b.filter(k=>k.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(Es,{title:"Brokerage Content Activity",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Uu,{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(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Active Brokerages"})}),e.jsxs(Re,{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(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Content Items"})}),e.jsxs(Re,{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(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Brokerages"})}),e.jsxs(Re,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search brokerages...",value:t,onChange:i=>s(i.target.value),className:"pl-9"})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Tn,{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(fn,{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(Wo,{className:"h-3 w-3"})," Graphics"]})}),e.jsx(Nt,{className:"text-center",children:"Categories"}),e.jsx(Nt,{children:"Last Upload"})]})}),e.jsx(Dn,{children:n?e.jsx(Ms,{children:e.jsx(ut,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(Ms,{children:e.jsx(ut,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(Ms,{className:i.total_items===0?"opacity-50":"",children:[e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:i.brokerage_name})]})}),e.jsx(ut,{className:"text-center",children:i.total_items>0?e.jsx(Qe,{variant:"secondary",className:"font-bold",children:i.total_items}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ut,{className:"text-center",children:i.videos||"–"}),e.jsx(ut,{className:"text-center",children:i.pdfs||"–"}),e.jsx(ut,{className:"text-center",children:i.links||"–"}),e.jsx(ut,{className:"text-center",children:i.events||"–"}),e.jsx(ut,{className:"text-center",children:i.graphics||"–"}),e.jsx(ut,{className:"text-center",children:i.categories||"–"}),e.jsx(ut,{children:i.latest_item_date?e.jsx("span",{className:"text-sm text-muted-foreground",children:ps(new Date(i.latest_item_date),"MMM d, yyyy")}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},i.brokerage_id))})]})})})]})})}function wSs(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 jSs=(()=>{let t=0;const s=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${s()}${t}`)})();function $b(t){const s=[];for(let r=0,n=t.length;rqp||t.height>qp)&&(t.width>qp&&t.height>qp?t.width>t.height?(t.height*=qp/t.width,t.width=qp):(t.width*=qp/t.height,t.height=qp):t.width>qp?(t.height*=qp/t.width,t.width=qp):(t.width*=qp/t.height,t.height=qp))}function Tde(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 MSs(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(s=>`data:image/svg+xml;charset=utf-8,${s}`)}async function TSs(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),MSs(a)}const vp=(t,s)=>{if(t instanceof s)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===s.name||vp(r,s)};function ASs(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function ESs(t,s){return act(s).map(r=>{const n=t.getPropertyValue(r),a=t.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function PSs(t,s,r,n){const a=`.${t}:${s}`,o=r.cssText?ASs(r):ESs(r,n);return document.createTextNode(`${a}{${o}}`)}function g9e(t,s,r,n){const a=window.getComputedStyle(t,r),o=a.getPropertyValue("content");if(o===""||o==="none")return;const l=jSs();try{s.className=`${s.className} ${l}`}catch{return}const i=document.createElement("style");i.appendChild(PSs(l,r,a,n)),s.appendChild(i)}function ISs(t,s,r){g9e(t,s,":before",r),g9e(t,s,":after",r)}const y9e="application/font-woff",v9e="image/jpeg",LSs={woff:y9e,woff2:y9e,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:v9e,jpeg:v9e,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function DSs(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function qCe(t){const s=DSs(t).toLowerCase();return LSs[s]||""}function RSs(t){return t.split(/,/)[1]}function Xwe(t){return t.search(/^(data:)/)!==-1}function OSs(t,s){return`data:${s};base64,${t}`}async function oct(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 _0e={};function FSs(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 UCe(t,s,r){const n=FSs(t,s,r.includeQueryParams);if(_0e[n]!=null)return _0e[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await oct(t,r.fetchRequestInit,({res:l,result:i})=>(s||(s=l.headers.get("Content-Type")||""),RSs(i)));a=OSs(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 _0e[n]=a,a}async function zSs(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):Tde(s)}async function BSs(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 Tde(i)}const r=t.poster,n=qCe(r),a=await UCe(r,n,s);return Tde(a)}async function $Ss(t,s){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await epe(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function qSs(t,s){return vp(t,HTMLCanvasElement)?zSs(t):vp(t,HTMLVideoElement)?BSs(t,s):vp(t,HTMLIFrameElement)?$Ss(t,s):t.cloneNode(lct(t))}const USs=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",lct=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function VSs(t,s,r){var n,a;if(lct(s))return s;let o=[];return USs(t)&&t.assignedNodes?o=$b(t.assignedNodes()):vp(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?o=$b(t.contentDocument.body.childNodes):o=$b(((a=t.shadowRoot)!==null&&a!==void 0?a:t).childNodes),o.length===0||vp(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>epe(i,r)).then(d=>{d&&s.appendChild(d)}),Promise.resolve()),s}function HSs(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):act(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`),vp(t,HTMLIFrameElement)&&o==="display"&&l==="inline"&&(l="block"),o==="d"&&s.getAttribute("d")&&(l=`path(${s.getAttribute("d")})`),n.setProperty(o,l,a.getPropertyPriority(o))})}function GSs(t,s){vp(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),vp(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function WSs(t,s){if(vp(t,HTMLSelectElement)){const r=s,n=Array.from(r.children).find(a=>t.value===a.getAttribute("value"));n&&n.setAttribute("selected","")}}function KSs(t,s,r){return vp(s,Element)&&(HSs(t,s,r),ISs(t,s,r),GSs(t,s),WSs(t,s)),s}async function ZSs(t,s){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let o=0;oqSs(n,s)).then(n=>VSs(t,n,s)).then(n=>KSs(t,n,s)).then(n=>ZSs(n,s))}const cct=/url\((['"]?)([^'"]+?)\1\)/g,YSs=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,XSs=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function QSs(t){const s=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${s})(['"]?\\))`,"g")}function JSs(t){const s=[];return t.replace(cct,(r,n,a)=>(s.push(a),r)),s.filter(r=>!Xwe(r))}async function eCs(t,s,r,n,a){try{const o=r?wSs(s,r):s,l=qCe(s);let i;return a||(i=await UCe(o,l,n)),t.replace(QSs(s),`$1${i}$3`)}catch{}return t}function tCs(t,{preferredFontFormat:s}){return s?t.replace(XSs,r=>{for(;;){const[n,,a]=YSs.exec(r)||[];if(!a)return"";if(a===s)return`src: ${n};`}}):t}function dct(t){return t.search(cct)!==-1}async function uct(t,s,r){if(!dct(t))return t;const n=tCs(t,r);return JSs(n).reduce((o,l)=>o.then(i=>eCs(i,l,s,r)),Promise.resolve(n))}async function S5(t,s,r){var n;const a=(n=s.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(a){const o=await uct(a,null,r);return s.style.setProperty(t,o,s.style.getPropertyPriority(t)),!0}return!1}async function sCs(t,s){await S5("background",t,s)||await S5("background-image",t,s),await S5("mask",t,s)||await S5("-webkit-mask",t,s)||await S5("mask-image",t,s)||await S5("-webkit-mask-image",t,s)}async function rCs(t,s){const r=vp(t,HTMLImageElement);if(!(r&&!Xwe(t.src))&&!(vp(t,SVGImageElement)&&!Xwe(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await UCe(n,qCe(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 nCs(t,s){const n=$b(t.childNodes).map(a=>hct(a,s));await Promise.all(n).then(()=>t)}async function hct(t,s){vp(t,Element)&&(await sCs(t,s),await rCs(t,s),await nCs(t,s))}function aCs(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 _9e={};async function b9e(t){let s=_9e[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},_9e[t]=s,s}async function w9e(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),oct(i,s.fetchRequestInit,({result:d})=>(r=r.replace(l,`url(${d})`),[l,d]))});return Promise.all(o).then(()=>r)}function j9e(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 iCs(t,s){const r=[],n=[];return t.forEach(a=>{if("cssRules"in a)try{$b(a.cssRules||[]).forEach((o,l)=>{if(o.type===CSSRule.IMPORT_RULE){let i=l+1;const d=o.href,u=b9e(d).then(p=>w9e(p,s)).then(p=>j9e(p).forEach(x=>{try{a.insertRule(x,x.startsWith("@import")?i+=1:a.cssRules.length)}catch(y){console.error("Error inserting rule from remote css",{rule:x,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(b9e(a.href).then(i=>w9e(i,s)).then(i=>j9e(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{$b(a.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${a.href}`,o)}}),r))}function oCs(t){return t.filter(s=>s.type===CSSRule.FONT_FACE_RULE).filter(s=>dct(s.style.getPropertyValue("src")))}async function lCs(t,s){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=$b(t.ownerDocument.styleSheets),n=await iCs(r,s);return oCs(n)}function mct(t){return t.trim().replace(/["']/g,"")}function cCs(t){const s=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(o=>{s.add(mct(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(t),s}async function dCs(t,s){const r=await lCs(t,s),n=cCs(t);return(await Promise.all(r.filter(o=>n.has(mct(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return uct(o.cssText,l,s)}))).join(` `)}async function uCs(t,s){const r=s.fontEmbedCSS!=null?s.fontEmbedCSS:s.skipFonts?null:await dCs(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 hCs(t,s={}){const{width:r,height:n}=ict(t,s),a=await epe(t,s,!0);return await uCs(a,s),await hct(a,s),aCs(a,s),await TSs(a,r,n)}async function mCs(t,s={}){const{width:r,height:n}=ict(t,s),a=await hCs(t,s),o=await Tde(a),l=document.createElement("canvas"),i=l.getContext("2d"),d=s.pixelRatio||SSs(),u=s.canvasWidth||r,p=s.canvasHeight||n;return l.width=u*d,l.height=p*d,s.skipAutoScale||CSs(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 pCs(t,s={}){return(await mCs(t,s)).toDataURL()}const SA=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),tpe={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},C9={"instagram-square":{width:1080,height:1080},"instagram-story":{width:1080,height:1920},"facebook-post":{width:1200,height:630}},fCs=({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})]})]}),pct=ft.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var x;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=(x=t.photos)==null?void 0:x[a],u=tpe[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:SA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.028,color:"#C9A84C",marginBottom:l.w*.01},children:["Sold for ",SA(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(fCs,{branding:n,dim:l})]})]})]})});pct.displayName="LuxuryDarkTemplate";const xCs=({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})]})]}),fct=ft.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=tpe[s],p=r==="instagram-story",x=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:x?"row":"column"},children:[e.jsxs("div",{style:{width:x?"55%":"100%",height:x?"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*(x?.055:.065),fontWeight:800,lineHeight:1.1,color:y,marginBottom:l.w*.012},children:SA(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(xCs,{branding:n,dim:l,accentColor:y})]})]})});fct.displayName="ModernCleanTemplate";const gCs=({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})]})]}),xct=ft.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=tpe[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)"},x=[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:SA(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:x}),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(gCs,{branding:n,dim:l})]})]})]})});xct.displayName="BoldColorfulTemplate";const yCs=({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})]})]}),gct=ft.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var x;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=(x=t.photos)==null?void 0:x[a],u=tpe[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:SA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.02,color:"#8B7355",marginBottom:l.w*.01},children:["Sold: ",SA(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(yCs,{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"}})]})]})})});gct.displayName="EditorialTemplate";const vCs=[{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:"📉"}],N9e=[{value:"instagram-square",label:"Instagram Post",dimensions:"1080×1080",icon:e.jsx(mu,{className:"h-4 w-4"})},{value:"instagram-story",label:"Instagram Story",dimensions:"1080×1920",icon:e.jsx(mu,{className:"h-4 w-4"})},{value:"facebook-post",label:"Facebook Post",dimensions:"1200×630",icon:e.jsx(uu,{className:"h-4 w-4"})}],_Cs=[{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:"📰"}],k9e=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),S9e={"luxury-dark":pct,"modern-clean":fct,"bold-colorful":xct,editorial:gct};function bCs(){const[t,s]=S.useState(""),[r,n]=S.useState("address"),[a,o]=S.useState(!1),[l,i]=S.useState([]),[d,u]=S.useState(null),[p,x]=S.useState(0),[y,_]=S.useState("just-listed"),[b,N]=S.useState(["instagram-square"]),[w,k]=S.useState("luxury-dark"),[C,E]=S.useState(!1),[L,I]=S.useState(""),[O,V]=S.useState(""),[q,$]=S.useState(""),[U,se]=S.useState(!1),[Y,J]=S.useState(!1),[X,ce]=S.useState([]),[ie,ae]=S.useState("search"),oe=S.useRef({});S.useEffect(()=>{(async()=>{const{data:{user:Le}}=await G.auth.getUser();if(!Le)return;const{data:Ne}=await G.from("profiles").select("name, avatar_url, brokerages(name)").eq("id",Le.id).single();if(Ne){I(Ne.name||""),$(Ne.avatar_url||"");const qe=Ne.brokerages;V((qe==null?void 0:qe.name)||"")}})()},[]);const pe=async()=>{var Fe;if(t.trim()){o(!0),i([]);try{const{data:Le,error:Ne}=await G.functions.invoke("repliers-mls-search",{body:{searchType:r,query:t.trim()}});if(Ne)throw Ne;if(Le.error)throw new Error(Le.error);i(Le.listings||[]),((Fe=Le.listings)==null?void 0:Fe.length)===0&&me.info("No listings found. Try a different search.")}catch(Le){me.error(Le.message||"Search failed")}finally{o(!1)}}},_e=Fe=>{var Le;u(Fe),x(0),ae("customize"),Fe.soldDate||(Le=Fe.status)!=null&&Le.toLowerCase().includes("sold")?_("just-sold"):_("just-listed")},he=Fe=>{N(Le=>Le.includes(Fe)?Le.filter(Ne=>Ne!==Fe):[...Le,Fe])},we=S.useCallback(async()=>{if(!(!d||b.length===0)){se(!0),ce([]),ae("generate");try{await new Promise(Le=>setTimeout(Le,500));const Fe=[];for(const Le of b){const Ne=`${w}-${Le}`,qe=oe.current[Ne];if(!qe)continue;const ze=C9[Le],ve=await pCs(qe,{width:ze.width,height:ze.height,pixelRatio:1,cacheBust:!0,style:{transform:"none",transformOrigin:"top left"}});Fe.push({format:Le,imageUrl:ve})}ce(Fe),me.success(`Generated ${Fe.length} social post${Fe.length>1?"s":""}!`)}catch(Fe){me.error(Fe.message||"Generation failed")}finally{se(!1)}}},[d,b,w,p,C,L,O,q,y]),je=async()=>{if(!(!d||b.length===0)){se(!0),ce([]),ae("generate");try{const Fe={...d,photos:d.photos.length>0?[d.photos[p]]:[]},Le=[];for(const Ne of b){const{data:qe,error:ze}=await G.functions.invoke("generate-listing-social-post",{body:{listing:Fe,postType:y,format:Ne,branding:C?{enabled:!0,agentName:L,brokerage:O}:{enabled:!1}}});if(ze)throw ze;if(qe.error)throw new Error(qe.error);Le.push({format:Ne,imageUrl:qe.imageUrl})}ce(Le),me.success(`Generated ${Le.length} AI post${Le.length>1?"s":""}!`)}catch(Fe){me.error(Fe.message||"AI generation failed")}finally{se(!1)}}},Ue=()=>Y?je():we(),Te=(Fe,Le)=>{var qe;const Ne=document.createElement("a");Ne.href=Fe,Ne.download=`${((qe=d==null?void 0:d.address)==null?void 0:qe.replace(/\s+/g,"-"))||"listing"}-${y}-${Le}.png`,document.body.appendChild(Ne),Ne.click(),document.body.removeChild(Ne)},Me=d?{listing:d,postType:y,format:"instagram-square",branding:C?{enabled:!0,agentName:L,brokerage:O,agentPhotoUrl:q||void 0}:{enabled:!1},selectedPhotoIndex:p}:null;return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(Uu,{title:"Social Post Generator",description:"Search MLS listings and generate stunning social media posts"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsxs("button",{onClick:()=>ae("search"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ie==="search"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:[e.jsx(an,{className:"h-3.5 w-3.5"})," 1. Find Listing"]}),e.jsx(Sa,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("button",{onClick:()=>d&&ae("customize"),disabled:!d,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ie==="customize"?"bg-primary text-primary-foreground":d?"bg-muted text-muted-foreground hover:text-foreground":"bg-muted text-muted-foreground/50 cursor-not-allowed"}`,children:[e.jsx($r,{className:"h-3.5 w-3.5"})," 2. Customize"]}),e.jsx(Sa,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full ${ie==="generate"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground/50"}`,children:[e.jsx(Wo,{className:"h-3.5 w-3.5"})," 3. Generate"]})]}),ie==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(an,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(kXe,{})]}),e.jsx(hr,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx(ia,{value:r,onValueChange:Fe=>n(Fe),children:e.jsxs(ea,{children:[e.jsxs(ls,{value:"address",children:[e.jsx(Da,{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(De,{value:t,onChange:Fe=>s(Fe.target.value),placeholder:r==="mls"?"Enter MLS number...":"Enter property address...",className:"flex-1",onKeyDown:Fe=>Fe.key==="Enter"&&pe()}),e.jsxs(K,{onClick:pe,disabled:a||!t.trim(),children:[a?e.jsx(_s,{className:"h-4 w-4 animate-spin"}):e.jsx(an,{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((Fe,Le)=>{var Ne;return e.jsx(Pe,{className:"cursor-pointer hover:border-primary/50 hover:shadow-md transition-all group",onClick:()=>_e(Fe),children:e.jsx(Re,{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:(Ne=Fe.photos)!=null&&Ne[0]?e.jsx("img",{src:Fe.photos[0],alt:Fe.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:k9e(Fe.price)}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:Fe.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Fe.city,", ",Fe.state," ",Fe.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[Fe.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(U4,{className:"h-3 w-3"})," ",Fe.bedrooms]}),Fe.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(rf,{className:"h-3 w-3"})," ",Fe.bathrooms]}),Fe.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(yL,{className:"h-3 w-3"})," ",Fe.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:Fe.mlsNumber}),e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:Fe.status})]})]})]})})},Fe.mlsNumber||Le)})})]})]}),ie==="customize"&&d&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(Pe,{className:"lg:col-span-1",children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(Ot,{className:"text-base",children:"Selected Listing"})}),e.jsxs(Re,{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:()=>x(Fe=>Math.max(0,Fe-1)),disabled:p===0,children:e.jsx(xl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p+1," of ",d.photos.length]}),e.jsx(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>x(Fe=>Math.min(d.photos.length-1,Fe+1)),disabled:p===d.photos.length-1,children:e.jsx(Sa,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg",children:k9e(d.price)}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[d.city,", ",d.state," ",d.zip]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[d.bedrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.bedrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Beds"})]}),d.bathrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.bathrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Baths"})]}),d.sqft>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.sqft.toLocaleString()}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Sq Ft"})]})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{ae("search"),u(null)},children:[e.jsx(Jy,{className:"h-3.5 w-3.5 mr-1.5"})," Choose Different Listing"]})]})]}),e.jsxs(Pe,{className:"lg:col-span-2",children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx($r,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(hr,{children:"Choose template, post type, format, and branding"})]}),e.jsxs(Re,{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(Dl,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:Y?"AI Custom Generation":"Template-Based (Free)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Y?"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(Er,{checked:Y,onCheckedChange:J}),Y&&e.jsx(Ev,{className:"h-4 w-4 text-purple-500"})]})]}),!Y&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Dl,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:_Cs.map(Fe=>e.jsxs("button",{onClick:()=>k(Fe.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${w===Fe.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-2xl",children:Fe.preview}),e.jsx("span",{className:"text-sm font-medium",children:Fe.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:Fe.description})]},Fe.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Post Type"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:vCs.map(Fe=>e.jsxs("button",{onClick:()=>_(Fe.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm font-medium ${y===Fe.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-lg",children:Fe.icon})," ",Fe.label]},Fe.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Output Formats"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:N9e.map(Fe=>e.jsxs("button",{onClick:()=>he(Fe.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm ${b.includes(Fe.value)?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[Fe.icon,e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:Fe.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:Fe.dimensions})]})]},Fe.value))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(xe,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ti,{className:"h-4 w-4"})," Agent Branding"]}),e.jsx(Er,{checked:C,onCheckedChange:E})]}),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(xe,{className:"text-xs text-muted-foreground",children:"Agent Name"}),e.jsx(De,{value:L,onChange:Fe=>I(Fe.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs text-muted-foreground",children:"Brokerage (optional)"}),e.jsx(De,{value:O,onChange:Fe=>V(Fe.target.value),placeholder:"XYZ Realty"})]})]})]})]}),!Y&&Me&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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*(C9[b[0]||"instagram-square"].height/C9[b[0]||"instagram-square"].width)},children:(()=>{const Fe=S9e[w],Le=b[0]||"instagram-square";return e.jsx(Fe,{...Me,format:Le})})()})})]}),e.jsx(K,{onClick:Ue,disabled:b.length===0||U,size:"lg",className:"w-full gap-2",children:U?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-5 w-5 animate-spin"})," Generating ",b.length," post",b.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[Y?e.jsx(Ev,{className:"h-5 w-5"}):e.jsx($r,{className:"h-5 w-5"}),"Generate ",b.length," Social Post",b.length>1?"s":"",Y&&e.jsx(Qe,{variant:"outline",className:"ml-2 text-[10px]",children:"Uses Credits"})]})})]})]})]}),ie==="generate"&&e.jsxs("div",{className:"space-y-4",children:[U&&e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(_s,{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:Y?"AI is creating your unique designs":"Rendering templates to high-res images"})]})}),X.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Generated Posts"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ae("customize"),children:[e.jsx(Jy,{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:X.map((Fe,Le)=>{const Ne=N9e.find(qe=>qe.value===Fe.format);return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 p-1",children:e.jsx("img",{src:Fe.imageUrl,alt:`${Fe.format} social post`,className:"w-full rounded"})}),e.jsxs(Re,{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:[Ne==null?void 0:Ne.icon,e.jsx("span",{className:"text-sm font-medium",children:Ne==null?void 0:Ne.label})]}),e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:Ne==null?void 0:Ne.dimensions})]}),e.jsxs(K,{size:"sm",className:"w-full gap-1.5",onClick:()=>Te(Fe.imageUrl,Fe.format),children:[e.jsx(Xa,{className:"h-3.5 w-3.5"})," Download"]})]})]},Le)})})]})]}),ie==="generate"&&!Y&&d&&Me&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:b.map(Fe=>{const Le=S9e[w],Ne=C9[Fe];return e.jsx("div",{style:{width:Ne.width,height:Ne.height},children:e.jsx(Le,{ref:qe=>{oe.current[`${w}-${Fe}`]=qe},...Me,format:Fe})},`${w}-${Fe}`)})})]})})}function wCs(){return gt({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 jCs(t){return gt({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 NCs(){const t=Jt();return It({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 yct(){const t=Jt();return It({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 kCs(){const t=Jt();return It({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 SCs(){const t=Jt();return It({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 CCs(){const t=Jt();return It({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 MCs(){const t=Jt();return It({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 TCs(){const t=Jt();return It({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 ACs(){const t=Jt();return It({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 ECs(){const t=Jt();return It({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 PCs(){return gt({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 ICs(t){return gt({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 vct(t){return gt({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 LCs(){const t=Jt();return It({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 DCs(){const{user:t}=Fs(),s=_r(),{data:r,isLoading:n}=wCs(),a=NCs(),o=yct(),l=kCs(),[i,d]=S.useState(!1),[u,p]=S.useState(""),[x,y]=S.useState(""),[_,b]=S.useState(!0),N=async()=>{if(!(!u.trim()||!t))try{const C=await a.mutateAsync({title:u.trim(),description:x.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")}},k=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(Es,{title:"LevelUp U - Admin",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(Lh,{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(to,{className:"h-4 w-4 mr-2"}),"Analytics"]}),e.jsxs(K,{onClick:()=>d(!0),children:[e.jsx(Us,{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(Pe,{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,V;const E=((V=(O=C.modules)==null?void 0:O[0])==null?void 0:V.count)??0,L=C.access||[],I=L.length===0?"No access set":L.some(q=>q.access_type==="all")?"All agents":`${L.length} rule(s)`;return e.jsxs(Pe,{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(Ot,{className:"text-base truncate",children:C.title}),C.description&&e.jsx(hr,{className:"mt-1 line-clamp-2",children:C.description})]}),e.jsx(Qe,{variant:C.is_published?"default":"secondary",className:"ml-2 shrink-0",children:C.is_published?"Published":"Draft"})]})}),e.jsxs(Re,{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"}),E," module",E!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[C.is_sequential?e.jsx(Zy,{className:"h-3.5 w-3.5"}):e.jsx(pS,{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(lr,{className:"h-3.5 w-3.5"}),I]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsxs(K,{size:"sm",variant:"ghost",onClick:q=>{q.stopPropagation(),w(C)},children:[C.is_published?e.jsx(mp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(wn,{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(),k(C.id)},children:e.jsx(gr,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx(ei,{className:"h-4 w-4 text-muted-foreground"})]})]})]},C.id)})}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(Re,{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(Us,{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(Ir,{children:"Set up a new training course for your agents"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Course Title"}),e.jsx(De,{value:u,onChange:C=>p(C.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(vr,{value:x,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(Er,{checked:_,onCheckedChange:b})]})]}),e.jsxs(En,{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 RCs(){const{courseId:t}=co(),s=_r(),{data:r,isLoading:n}=jCs(t),a=yct(),o=SCs(),l=CCs(),i=MCs(),d=TCs(),u=ACs(),p=ECs(),{data:x}=gt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:Ge}=await G.from("brokerages").select("id, name").order("name");return Ge||[]}}),[y,_]=S.useState(null),[b,N]=S.useState(!1),[w,k]=S.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[C,E]=S.useState(null),[L,I]=S.useState({title:"",resource_type:"link",url:""}),[O,V]=S.useState(new Set),[q,$]=S.useState(null),[U,se]=S.useState(0),[Y,J]=S.useState(!1),X=S.useRef(null),ce=S.useRef(null),[ie,ae]=S.useState(!1),[oe,pe]=S.useState(""),[_e,he]=S.useState(""),[we,je]=S.useState(""),[Ue,Te]=S.useState(!1);if(n)return e.jsx(Es,{title:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})});if(!r)return e.jsx(Es,{title:"Course Not Found",children:e.jsxs("div",{className:"text-center py-20",children:[e.jsx("p",{className:"text-muted-foreground",children:"Course not found"}),e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>s("/admin/lms"),children:[e.jsx(Fa,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const Me=r.modules||[],Fe=r.access||[],Le=Fe.some(Ge=>Ge.access_type==="all"),Ne=Fe.filter(Ge=>Ge.access_type==="brokerage").map(Ge=>Ge.brokerage_id),qe=(x||[]).filter(Ge=>Ge.name.toLowerCase().includes(oe.toLowerCase())),ze=Ge=>{const et=new Set(O);et.has(Ge)?et.delete(Ge):et.add(Ge),V(et)},ve=async()=>{if(!q)return null;J(!0),se(0);try{const{data:Ge,error:et}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:q.name}});if(et)throw new Error(et.message);const{videoId:ht,libraryId:xt}=Ge,{data:Ke,error:Ze}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:ht,libraryId:xt}});if(Ze)throw new Error(Ze.message);const Et=new XMLHttpRequest;return await new Promise(($t,Yt)=>{Et.upload.onprogress=Ps=>{Ps.lengthComputable&&se(Math.round(Ps.loaded/Ps.total*100))},Et.onload=()=>Et.status>=200&&Et.status<300?$t():Yt(new Error(`Upload failed: ${Et.status}`)),Et.onerror=()=>Yt(new Error("Upload failed")),Et.open("PUT",Ke.uploadUrl),Et.setRequestHeader("AccessKey",Ke.apiKey),Et.send(q)}),`https://iframe.mediadelivery.net/embed/${xt}/${ht}`}catch(Ge){return console.error("Bunny upload error:",Ge),me.error("Video upload failed"),null}finally{J(!1),se(0)}},dt=async()=>{if(w.title.trim())try{let Ge=w.video_url.trim()||void 0;if(q){const et=await ve();if(!et)return;Ge=et}await o.mutateAsync({course_id:r.id,title:w.title.trim(),description:w.description.trim()||void 0,video_url:Ge,text_content:w.text_content.trim()||void 0,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):void 0,sort_order:Me.length}),me.success("Module added"),N(!1),k({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),$(null)}catch{me.error("Failed to add module")}},fe=async()=>{if(y)try{let Ge=w.video_url.trim()||null;if(q){const et=await ve();if(!et)return;Ge=et}await l.mutateAsync({id:y.id,title:w.title.trim(),description:w.description.trim()||null,video_url:Ge,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")}},Ve=async Ge=>{if(confirm("Delete this module?"))try{await i.mutateAsync(Ge),me.success("Module deleted")}catch{me.error("Failed to delete")}},Je=async Ge=>{if(L.title.trim())try{await d.mutateAsync({module_id:Ge,title:L.title.trim(),resource_type:L.resource_type,url:L.url.trim()||void 0}),me.success("Resource added"),E(null),I({title:"",resource_type:"link",url:""})}catch{me.error("Failed to add resource")}},at=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")}},Ae=async Ge=>{const et=Fe.filter(Ze=>Ze.access_type==="brokerage").map(Ze=>Ze.brokerage_id),ht=et.includes(Ge);let xt;ht?xt=et.filter(Ze=>Ze!==Ge):xt=[...et,Ge];const Ke=xt.map(Ze=>({access_type:"brokerage",brokerage_id:Ze}));try{await p.mutateAsync({courseId:r.id,accessRules:Ke}),me.success(ht?"Brokerage removed":"Brokerage added")}catch{me.error("Failed to update access")}},Ye=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[]}),me.success("Access cleared")}catch{me.error("Failed")}},We=async(Ge,et)=>{const ht=et==="up"?Ge-1:Ge+1;if(!(ht<0||ht>=Me.length))try{await Promise.all([l.mutateAsync({id:Me[Ge].id,sort_order:ht}),l.mutateAsync({id:Me[ht].id,sort_order:Ge})])}catch{me.error("Failed to reorder")}},ot=async()=>{try{await a.mutateAsync({id:r.id,title:_e,description:we||null}),me.success("Course updated"),Te(!1)}catch{me.error("Failed to update")}};return e.jsxs(Es,{title:r.title,children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/admin/lms"),children:e.jsx(Fa,{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(Qe,{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(Zy,{className:"h-3.5 w-3.5"}):e.jsx(pS,{className:"h-3.5 w-3.5"}),r.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{children:[Me.length," module",Me.length!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{he(r.title),je(r.description||""),Te(!0)},children:[e.jsx(ga,{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(mp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(wn,{className:"h-3.5 w-3.5 mr-1"}),r.is_published?"Unpublish":"Publish"]})]})]}),e.jsxs(ia,{defaultValue:"modules",className:"w-full",children:[e.jsxs(ea,{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:[Me.map((Ge,et)=>e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>ze(Ge.id),children:[e.jsx("span",{className:"flex items-center gap-1 text-muted-foreground",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("button",{onClick:ht=>{ht.stopPropagation(),We(et,"up")},disabled:et===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(nf,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:ht=>{ht.stopPropagation(),We(et,"down")},disabled:et===Me.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Oi,{className:"h-3.5 w-3.5"})})]})}),e.jsx(Qe,{variant:"outline",className:"shrink-0 font-mono text-xs",children:et+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:Ge.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[Ge.video_url&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Tn,{className:"h-3 w-3"})," Video"]}),Ge.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(fn,{className:"h-3 w-3"})," Text"]}),Ge.duration_minutes&&e.jsxs("span",{children:[Ge.duration_minutes," min"]}),Ge.resources&&Ge.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Do,{className:"h-3 w-3"})," ",Ge.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:ht=>{var xt;ht.stopPropagation(),_(Ge),k({title:Ge.title,description:Ge.description||"",video_url:Ge.video_url||"",text_content:Ge.text_content||"",duration_minutes:((xt=Ge.duration_minutes)==null?void 0:xt.toString())||""})},children:e.jsx(ga,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:ht=>{ht.stopPropagation(),Ve(Ge.id)},children:e.jsx(gr,{className:"h-3.5 w-3.5"})})]})]}),O.has(Ge.id)&&e.jsxs("div",{className:"border-t bg-muted/30 p-4 space-y-3",children:[Ge.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:Ge.description}),Ge.video_url&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Video: "}),e.jsx("a",{href:Ge.video_url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:Ge.video_url})]}),Ge.text_content&&e.jsx("div",{className:"text-sm bg-background rounded-md p-3 border max-h-40 overflow-auto whitespace-pre-wrap",children:Ge.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:()=>{E(Ge.id),I({title:"",resource_type:"link",url:""})},children:[e.jsx(Us,{className:"h-3 w-3 mr-1"})," Add Resource"]})]}),Ge.resources&&Ge.resources.length>0?e.jsx("div",{className:"space-y-1",children:Ge.resources.map(ht=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-background rounded p-2 border",children:[e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:ht.resource_type}),e.jsx("span",{className:"flex-1 truncate",children:ht.title}),ht.url&&e.jsx("a",{href:ht.url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline text-xs",children:"Open"}),e.jsx(K,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>u.mutateAsync(ht.id),children:e.jsx(Sr,{className:"h-3 w-3"})})]},ht.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},Ge.id)),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{N(!0),k({title:"",description:"",video_url:"",text_content:"",duration_minutes:""})},children:[e.jsx(Us,{className:"h-4 w-4 mr-2"})," Add Module"]})]}),e.jsx(js,{value:"access",className:"mt-6 space-y-4",children:e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(Re,{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",Le?"border-primary bg-primary/5":"border-muted hover:border-muted-foreground/30"),onClick:at,children:[e.jsx("div",{className:Rt("h-10 w-10 rounded-full flex items-center justify-center shrink-0",Le?"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(Er,{checked:Le,onCheckedChange:at})]}),!Le&&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:Ne.length===0?"No brokerages selected — agents won't see this course":`${Ne.length} brokerage${Ne.length!==1?"s":""} selected`})]}),Ne.length>0&&e.jsx(K,{size:"sm",variant:"ghost",className:"text-xs text-muted-foreground",onClick:Ye,children:"Clear all"})]}),e.jsx(De,{placeholder:"Search brokerages...",value:oe,onChange:Ge=>pe(Ge.target.value),className:"h-9"}),e.jsx("div",{className:"border rounded-lg divide-y max-h-[360px] overflow-auto",children:qe.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No brokerages found"}):qe.map(Ge=>{const et=Ne.includes(Ge.id);return e.jsxs("div",{className:Rt("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",et?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>Ae(Ge.id),children:[e.jsx("div",{className:Rt("h-5 w-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors",et?"bg-primary border-primary":"border-muted-foreground/30"),children:et&&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(pa,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:Ge.name}),et&&e.jsx(Qe,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},Ge.id)})})]})]})]})}),e.jsxs(js,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Course Thumbnail"})}),e.jsx(Re,{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(Yv,{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 Ge=>{var ht;const et=(ht=Ge.target.files)==null?void 0:ht[0];if(!(!et||!r)){ae(!0);try{const xt=et.name.split(".").pop(),Ke=`${r.id}/thumbnail.${xt}`,{error:Ze}=await G.storage.from("lms-thumbnails").upload(Ke,et,{upsert:!0});if(Ze)throw Ze;const{data:Et}=G.storage.from("lms-thumbnails").getPublicUrl(Ke),$t=`${Et.publicUrl}?t=${Date.now()}`;await a.mutateAsync({id:r.id,thumbnail_url:$t}),me.success("Thumbnail uploaded")}catch{me.error("Failed to upload thumbnail")}finally{ae(!1),ce.current&&(ce.current.value="")}}}}),e.jsxs(K,{variant:"outline",size:"sm",disabled:ie,onClick:()=>{var Ge;return(Ge=ce.current)==null?void 0:Ge.click()},children:[ie?e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx($a,{className:"h-4 w-4 mr-2"}),ie?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Course Settings"})}),e.jsxs(Re,{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(Er,{checked:r.is_sequential,onCheckedChange:Ge=>a.mutateAsync({id:r.id,is_sequential:Ge}).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(Er,{checked:r.is_published,onCheckedChange:Ge=>a.mutateAsync({id:r.id,is_published:Ge}).then(()=>me.success("Updated"))})]})]})]})]})]})]}),e.jsx(fs,{open:b||!!y,onOpenChange:Ge=>{Ge||(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(Ir,{children:"Configure the module content"})]}),e.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-auto",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Title"}),e.jsx(De,{value:w.title,onChange:Ge=>k(et=>({...et,title:Ge.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(vr,{value:w.description,onChange:Ge=>k(et=>({...et,description:Ge.target.value})),placeholder:"Brief description",rows:2})]}),e.jsxs("div",{children:[e.jsx(xe,{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 Ge;return(Ge=X.current)==null?void 0:Ge.click()},children:[e.jsx("input",{ref:X,type:"file",accept:"video/*",className:"hidden",onChange:Ge=>{var ht;const et=(ht=Ge.target.files)==null?void 0:ht[0];et&&($(et),k(xt=>({...xt,video_url:""})))}}),q?e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm",children:[e.jsx(Tn,{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:Ge=>{Ge.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($a,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Click to upload a video file"})]})]}),Y&&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(_s,{className:"h-3.5 w-3.5 animate-spin"}),e.jsxs("span",{children:["Uploading to Bunny.net... ",U,"%"]})]}),e.jsx(gi,{value:U,className:"h-1.5"})]}),!q&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"flex-1 h-px bg-border"}),e.jsx("span",{children:"or paste a URL"}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx(De,{value:w.video_url,onChange:Ge=>k(et=>({...et,video_url:Ge.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Text Content"}),e.jsx(vr,{value:w.text_content,onChange:Ge=>k(et=>({...et,text_content:Ge.target.value})),placeholder:"Additional text content, instructions, notes...",rows:4})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Duration (minutes)"}),e.jsx(De,{type:"number",value:w.duration_minutes,onChange:Ge=>k(et=>({...et,duration_minutes:Ge.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>{N(!1),_(null),$(null)},children:"Cancel"}),e.jsxs(K,{onClick:y?fe:dt,disabled:!w.title.trim()||Y,children:[Y?e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(_c,{className:"h-4 w-4 mr-2"}),Y?"Uploading...":y?"Save Changes":"Add Module"]})]})]})}),e.jsx(fs,{open:!!C,onOpenChange:Ge=>{Ge||E(null)},children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Add Resource"}),e.jsx(Ir,{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(xe,{children:"Title"}),e.jsx(De,{value:L.title,onChange:Ge=>I(et=>({...et,title:Ge.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Type"}),e.jsxs(Bs,{value:L.resource_type,onValueChange:Ge=>I(et=>({...et,resource_type:Ge})),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"link",children:"Link"}),e.jsx(vt,{value:"pdf",children:"PDF"}),e.jsx(vt,{value:"template",children:"Template"}),e.jsx(vt,{value:"worksheet",children:"Worksheet"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"URL"}),e.jsx(De,{value:L.url,onChange:Ge=>I(et=>({...et,url:Ge.target.value})),placeholder:"https://..."})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>E(null),children:"Cancel"}),e.jsx(K,{onClick:()=>C&&Je(C),disabled:!L.title.trim(),children:"Add Resource"})]})]})}),e.jsx(fs,{open:Ue,onOpenChange:Te,children:e.jsxs(ms,{children:[e.jsxs(ks,{children:[e.jsx(bs,{children:"Edit Course"}),e.jsx(Ir,{children:"Update the course title and description"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Title"}),e.jsx(De,{value:_e,onChange:Ge=>he(Ge.target.value)})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(vr,{value:we,onChange:Ge=>je(Ge.target.value),rows:3})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>Te(!1),children:"Cancel"}),e.jsx(K,{onClick:ot,disabled:!_e.trim(),children:"Save"})]})]})})]})}function OCs(){return gt({queryKey:["lms-stats-overview"],queryFn:async()=>{const{data:t,error:s}=await G.rpc("get_lms_stats");if(s)throw s;return t}})}function FCs(){return gt({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 zCs(t){return gt({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 BCs(){const t=_r(),{data:s,isLoading:r}=OCs(),{data:n,isLoading:a}=FCs(),[o,l]=S.useState(null),{data:i,isLoading:d}=zCs(o),[u,p]=S.useState(""),x=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:Qn,color:"text-emerald-500"},{label:"Enrolled Agents",value:(s==null?void 0:s.total_enrollments)??0,icon:lr,color:"text-blue-500"},{label:"Modules Completed",value:(s==null?void 0:s.total_completions)??0,icon:Vi,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:to,color:"text-rose-500"}];return e.jsx(Es,{title:"LevelUp U - Stats",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/admin/lms"),children:e.jsx(Fa,{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(Lh,{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(Pe,{className:Rt("transition-all",r&&"animate-pulse"),children:e.jsxs(Re,{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(to,{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(Pe,{className:"animate-pulse",children:e.jsx(Re,{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(Pe,{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(Re,{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(Qe,{variant:b.is_published?"default":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:b.is_published?"Live":"Draft"})]})}),e.jsx(Sa,{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(gi,{value:b.avg_completion_pct,className:"h-2"})]})]})},b.course_id)})}):e.jsx(Pe,{className:"border-dashed",children:e.jsx(Re,{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(Tb,{className:"h-5 w-5 text-primary"}),x?`Agent Progress — ${x.course_title}`:"Agent Progress"]}),o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{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(Pe,{className:"animate-pulse",children:e.jsx(Re,{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(Pe,{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(Re,{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(Ta,{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(Qe,{variant:"default",className:"text-[10px] px-1.5 py-0 bg-emerald-500 hover:bg-emerald-600 shrink-0",children:[e.jsx(Qn,{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(ln,{className:"h-3 w-3"}),ps(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(gi,{value:b.completion_pct,className:"h-1.5 mt-1"})]})]})})},b.user_id)})}):e.jsx(Pe,{className:"border-dashed",children:e.jsx(Re,{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(Pe,{className:"border-dashed",children:e.jsxs(Re,{className:"py-16 text-center",children:[e.jsx(lr,{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 $Cs(){const{user:t}=Fs(),s=_r(),{data:r,isLoading:n}=PCs();return e.jsx(Es,{title:"LevelUp U",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary/10 via-primary/5 to-background border p-8",children:[e.jsx("div",{className:"relative z-10",children:e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"h-12 w-12 rounded-xl bg-primary/15 flex items-center justify-center",children:e.jsx(Lh,{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(Pe,{className:"animate-pulse",children:e.jsxs(Re,{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(qCs,{course:a,userId:t==null?void 0:t.id,onClick:()=>s(`/levelup-u/${a.id}`)},a.id))}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(Re,{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 qCs({course:t,userId:s,onClick:r}){var i;const n=((i=t.modules)==null?void 0:i.length)??0,{data:a}=vct(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(Pe,{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(Lh,{className:"h-10 w-10 text-primary/40"})}),e.jsxs(Re,{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(Zy,{className:"h-3.5 w-3.5"}):e.jsx(pS,{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(gi,{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(Sa,{className:"h-3.5 w-3.5"})]})})]})]})}function UCs(){const{courseId:t}=co(),s=_r(),{user:r}=Fs(),{data:n,isLoading:a}=ICs(t),{data:o}=vct(t),l=LCs(),[i,d]=S.useState(null),u=(n==null?void 0:n.modules)||[],p=new Set((o==null?void 0:o.filter(C=>C.completed).map(C=>C.module_id))||[]),x=p.size,y=u.length>0?Math.round(x/u.length*100):0;S.useEffect(()=>{if(u.length>0&&!i){const C=u.find(E=>!p.has(E.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,E)=>{if(!(n!=null&&n.is_sequential)||E===0)return!1;for(let L=0;L{if(!(!_||!r||!t))try{await l.mutateAsync({courseId:t,moduleId:_.id,userId:r.id}),me.success("Module completed! 🎉"),b{const E=C.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(E)return`https://www.youtube.com/embed/${E[1]}`;const L=C.match(/vimeo\.com\/(\d+)/);if(L)return`https://player.vimeo.com/video/${L[1]}`;const I=C.match(/(?:iframe\.mediadelivery\.net|video\.bunnycdn\.com)\/(?:play|embed)\/(\d+)\/([a-f0-9-]+)/);return I?`https://iframe.mediadelivery.net/embed/${I[1]}/${I[2]}?responsive=true`:C};return a?e.jsx(Es,{title:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):n?e.jsx(Es,{title:n.title,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/levelup-u"),children:e.jsx(Fa,{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:[x,"/",u.length," completed"]}),e.jsxs("span",{children:[y,"%"]})]})]}),e.jsx("div",{className:"w-32",children:e.jsx(gi,{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(Pe,{className:"lg:sticky lg:top-4",children:e.jsxs(Re,{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(ui,{className:"max-h-[calc(100vh-280px)]",children:e.jsx("div",{className:"p-1",children:u.map((C,E)=>{const L=N(C,E),I=p.has(C.id),O=C.id===i;return e.jsxs("button",{disabled:L,onClick:()=>!L&&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",L&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"shrink-0",children:L?e.jsx(yd,{className:"h-4 w-4 text-muted-foreground"}):I?e.jsx(Qn,{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:[E+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(ln,{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(Pe,{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-video bg-black",children:e.jsx("iframe",{src:k(_.video_url),className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}),e.jsx(Pe,{children:e.jsxs(Re,{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(Qe,{className:"bg-green-500/15 text-green-600 border-green-500/30 shrink-0",children:[e.jsx(Qn,{className:"h-3.5 w-3.5 mr-1"})," Completed"]}):e.jsxs(K,{size:"sm",onClick:w,disabled:l.isPending,children:[e.jsx(Qn,{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(fn,{className:"h-4 w-4 text-red-500 shrink-0"}):C.resource_type==="template"?e.jsx(Lh,{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(Fa,{className:"h-3.5 w-3.5 mr-1"})," Previous"]}),bd(u[b+1].id),children:["Next ",e.jsx(Sa,{className:"h-3.5 w-3.5 ml-1"})]}):y===100&&e.jsx(Qe,{className:"bg-green-500/15 text-green-600 border-green-500/30 text-sm px-3 py-1.5",children:"🎉 Course Complete!"})]})]})})]}):e.jsx(Pe,{children:e.jsx(Re,{className:"flex items-center justify-center py-16 text-muted-foreground",children:"Select a module to begin"})})})]})]})}):e.jsx(Es,{title:"Not Found",children:e.jsxs("div",{className:"text-center py-20",children:[e.jsx("p",{className:"text-muted-foreground",children:"Course not found"}),e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>s("/levelup-u"),children:[e.jsx(Fa,{className:"h-4 w-4 mr-2"})," Back"]})]})})}function VCs({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(ei,{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 _f({children:t,className:s="",delay:r=0,direction:n="up"}){const a=S.useRef(null),o=vEt(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 HCs({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(_f,{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(_f,{delay:a*.1,children:e.jsxs("div",{className:"group relative p-8 rounded-2xl border border-gray-100 bg-white hover:border-transparent hover:shadow-2xl transition-all duration-500 h-full",children:[e.jsx("div",{className:"absolute inset-0 rounded-2xl opacity-0 group-hover:opacity-100 transition-opacity duration-500",style:{background:`linear-gradient(135deg, ${r}08, ${s}05)`}}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl flex items-center justify-center text-2xl mb-5 transition-transform duration-300 group-hover:scale-110",style:{backgroundColor:`${r}12`},children:n.icon}),e.jsx("h3",{className:"text-xl font-bold mb-3 tracking-tight",style:{color:s},children:n.title}),e.jsx("p",{className:"text-gray-500 leading-relaxed text-[15px]",children:n.description})]})]})},a))})]})})}function GCs({images:t,primaryColor:s,accentColor:r}){const[n,a]=S.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(_f,{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(lr,{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(_f,{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 WCs({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(_f,{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(_f,{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(cS,{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 KCs({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(_f,{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(_f,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"First Name *"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Last Name"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Email *"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Phone"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Current Brokerage"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"License #"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Years Experience"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Annual Production"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Why are you interested?"}),e.jsx(vr,{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(ei,{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(Ou,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Your information is confidential and will not be shared."})]})]})})]})]})}function ZCs({form:t,setForm:s,onSubmit:r,isPending:n,primaryColor:a,accentColor:o,showConfidentialBadges:l=!0}){const[i,d]=S.useState(1),[u,p]=S.useState(""),x=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(_f,{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(_f,{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,"/",x]})]}),e.jsxs(ENe,{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(ei,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"First Name *"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Last Name"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Email *"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Phone (preferred)"}),e.jsx(De,{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(Fa,{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(ei,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Current Brokerage"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Years Experience"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Annual Production"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Anything else?"}),e.jsx(vr,{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(Fa,{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(Jn,{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(Ou,{className:"h-3 w-3"})," Confidential"]}),e.jsxs("div",{className:"flex items-center gap-1 justify-center",children:[e.jsx(ki,{className:"h-3 w-3"})," Text first"]}),e.jsxs("div",{className:"flex items-center gap-1 justify-center",children:[e.jsx(Pn,{className:"h-3 w-3"})," No spam"]})]})]})})]})]})}function YCs({config:t,primaryColor:s,accentColor:r,brokerageId:n,brokerageName:a}){const{toast:o}=wa(),[l,i]=S.useState("250000"),[d,u]=S.useState("70"),[p,x]=S.useState("150"),[y,_]=S.useState(""),[b,N]=S.useState(!1),[w,k]=S.useState(!1),C=t.commission_split_pct??80,E=t.cap_amount??16e3,L=t.monthly_fee??99,I=t.transaction_fee??0,O=S.useMemo(()=>{const $=parseFloat(l)||0,U=parseFloat(d)||0,se=parseFloat(p)||0,Y=$*(U/100)-se*12,J=1-C/100,X=$*J,ce=Math.min(X,E),ie=$-ce-L*12-I,ae=ie-Y;return{currentNet:Y,newNet:ie,diff:ae}},[l,d,p,C,E,L,I]),V=$=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format($),q=async $=>{if($.preventDefault(),!!y){k(!0);try{const{error:U}=await G.from("recruit_lead_magnet_downloads").insert({brokerage_id:n,email:y,source:"calculator"});if(U)throw U;N(!0),o({title:"Sent!",description:"Check your email for the full breakdown."})}catch(U){o({title:"Error",description:U.message,variant:"destructive"})}finally{k(!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(_f,{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(_f,{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(xM,{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(xe,{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(De,{type:"number",value:l,onChange:$=>i($.target.value),className:"pl-7 h-11 text-base",placeholder:"250,000"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-gray-600 text-sm",children:"Your Current Commission Split (%)"}),e.jsx(De,{type:"number",value:d,onChange:$=>u($.target.value),className:"mt-1.5 h-11 text-base",placeholder:"70"})]}),e.jsxs("div",{children:[e.jsx(xe,{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(De,{type:"number",value:p,onChange:$=>x($.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:V(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:V(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?"+":"",V(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(De,{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(Jn,{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 XCs({config:t,primaryColor:s,accentColor:r,brokerageId:n}){const{toast:a}=wa(),[o,l]=S.useState(""),[i,d]=S.useState(""),[u,p]=S.useState(!1),[x,y]=S.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(_f,{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(Z4,{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(Jn,{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(De,{value:i,onChange:b=>d(b.target.value),placeholder:"First name (optional)",className:"h-11"}),e.jsx(De,{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:x,className:"w-full sm:w-auto h-12 px-6 text-white font-semibold",style:{background:`linear-gradient(135deg, ${s}, ${r})`},children:[e.jsx(Z4,{className:"h-4 w-4 mr-2"}),x?"Sending...":t.button_text||"Email Me the PDF"]})]})]})]})})})})})}function QCs(){const{slug:t}=co(),{toast:s}=wa(),[r,n]=S.useState(!1),[a,o]=S.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",experience_years:"",annual_production:"",license_number:"",why_interested:""});S.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(X=>X.style.display="none"))};$();const U=[setTimeout($,500),setTimeout($,1500),setTimeout($,3e3)],se=new MutationObserver($);return se.observe(document.body,{childList:!0,subtree:!0}),()=>{document.body.classList.remove("recruit-landing-page"),U.forEach(clearTimeout),se.disconnect()}},[]);const{data:l,isLoading:i,error:d}=gt({queryKey:["recruit-form-brokerage",t],queryFn:async()=>{const{data:$,error:U}=await G.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(U)throw U;return $},enabled:!!t}),{data:u}=gt({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:$,error:U}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",l.id).single();if(U&&U.code!=="PGRST116")throw U;return $},enabled:!!(l!=null&&l.id)}),p=It({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:U}=await G.from("recruit_interest_submissions").insert($);if(U)throw U;G.functions.invoke("recruit-lead-notify",{body:{lead:$,brokerage_id:l.id}}).catch(se=>console.error("Lead notification error:",se))},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(pa,{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 x=u,y=(x==null?void 0:x.primary_color)||"#406E71",_=(x==null?void 0:x.accent_color)||"#2a4c64",b=(x==null?void 0:x.benefits)||[],N=(x==null?void 0:x.testimonials)||[],w=(x==null?void 0:x.gallery_images)||[],k=(x==null?void 0:x.hero_headline)||`Join ${l.name}`,C=(x==null?void 0:x.hero_subtext)||"Take your real estate career to the next level with a brokerage that invests in your growth.",E=(x==null?void 0:x.calculator_enabled)===!0,L=(x==null?void 0:x.calculator_config)||{},I=(x==null?void 0:x.lead_magnet_enabled)===!0,O=(x==null?void 0:x.lead_magnet_config)||{},V=(x==null?void 0:x.form_style)||"classic",q=(x==null?void 0:x.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(Jn,{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:[(x==null?void 0:x.logo_url)&&e.jsx("img",{src:x.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(ei,{className:"h-3.5 w-3.5"})]})]})}),e.jsx(VCs,{headline:k,subtext:C,primaryColor:y,accentColor:_,heroImageUrl:x==null?void 0:x.hero_image_url,logoUrl:x==null?void 0:x.logo_url,brokerageName:l.name}),e.jsx(HCs,{benefits:b,accentColor:_,primaryColor:y}),e.jsx(GCs,{images:w,primaryColor:y,accentColor:_}),e.jsx(WCs,{testimonials:N,primaryColor:y,accentColor:_}),E&&e.jsx(YCs,{config:L,primaryColor:y,accentColor:_,brokerageId:l.id,brokerageName:l.name}),I&&e.jsx(XCs,{config:O,primaryColor:y,accentColor:_,brokerageId:l.id}),V==="multi_step"?e.jsx(ZCs,{form:a,setForm:o,onSubmit:()=>p.mutate(),isPending:p.isPending,primaryColor:y,accentColor:_,showConfidentialBadges:q}):e.jsx(KCs,{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 JCs(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 e3s(){var y,_,b,N;const{shareToken:t}=co(),s=S.useRef(!1),{data:r,isLoading:n,error:a}=gt({queryKey:["public-recruit-video",t],queryFn:async()=>{var I;if(!t)throw new Error("No token");const{data:w,error:k}=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(k)throw k;const{data:C}=await G.from("profiles").select("name, avatar_url, title").eq("id",(I=w.video)==null?void 0:I.owner_user_id).single(),{data:E}=await G.from("brokerages").select("name").eq("id",w.brokerage_id).single(),{data:L}=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:E,settings:L}},enabled:!!t});if(S.useEffect(()=>{var w;!((w=r==null?void 0:r.rv)!=null&&w.id)||s.current||(s.current=!0,G.rpc("log_recruit_video_view",{p_recruit_video_id:r.rv.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null}).then(()=>{}))},[(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",x=(b=o.video)!=null&&b.playback_url?JCs(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx(wc,{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})]}),x&&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:x,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(on,{className:"h-5 w-5 mr-2"})," Schedule a Conversation"]})})]}),e.jsx("footer",{className:"text-center py-6 text-xs text-muted-foreground",children:"Powered by LevelUp"})]})]})}const t3s="relzejiswnotikjgvjhz",C9e=`https://${t3s}.supabase.co/functions/v1/recruit-unsubscribe`;function s3s(){const[t]=Nc(),s=t.get("token")||"",[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,x]=S.useState({});S.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(k=>document.querySelectorAll(k).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()}},[]),S.useEffect(()=>{if(!s){x({error:"Missing unsubscribe token in link."}),n(!1);return}fetch(`${C9e}?token=${encodeURIComponent(s)}`).then(async _=>{const b=await _.json();if(!_.ok)throw new Error(b.error||"Lookup failed");x(b),b.already_unsubscribed&&i(!0)}).catch(_=>x({error:_.message||"Could not load status"})).finally(()=>n(!1))},[s]);const y=async()=>{o(!0);try{const _=await fetch(C9e,{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(_){x({...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(_s,{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(Lo,{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(Qn,{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(hS,{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(hS,{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(xe,{htmlFor:"reason",className:"text-xs text-slate-500",children:"Optional — what's the main reason? (helps us improve)"}),e.jsx(vr,{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(_s,{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 r3s(){const t=_r(),s=Jt(),{isAdmin:r}=Fs(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState(null),{data:u,isLoading:p}=gt({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:I},error:O}=await G.auth.getUser();if(O)throw O;if(!I)return[];const{data:V,error:q}=await G.from("social_accounts").select("*").eq("user_id",I.id).order("created_at",{ascending:!1});if(q)throw q;return V}}),x=It({mutationFn:async I=>{const{data:{user:O},error:V}=await G.auth.getUser();if(V)throw V;if(!O)throw new Error("Not authenticated");const{error:q}=await G.from("social_accounts").delete().eq("id",I).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:I,error:O}=await G.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(O)throw O;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get authorization URL")}catch(I){console.error("Meta OAuth error:",I),me.error("Failed to start connection. Please try again."),a(!1)}},_=async()=>{a(!0);try{const{data:I,error:O}=await G.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(O)throw O;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(I){console.error("LinkedIn OAuth error:",I),me.error("Failed to start LinkedIn connection. Please try again."),a(!1)}},b=async()=>{a(!0);try{const{data:I,error:O}=await G.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(O)throw O;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get Google authorization URL")}catch(I){console.error("Google OAuth error:",I),me.error("Failed to start Google connection. Please try again."),a(!1)}},N=(u==null?void 0:u.filter(I=>I.platform==="facebook"))||[],w=(u==null?void 0:u.filter(I=>I.platform==="instagram"))||[],k=(u==null?void 0:u.filter(I=>I.platform==="linkedin"))||[],C=(u==null?void 0:u.filter(I=>I.platform==="google_business"))||[],E=((u==null?void 0:u.length)||0)>0,L=async(I,O)=>{l(I),d(null);try{const{data:V,error:q}=await G.functions.invoke("meta-api-test",{body:{testType:"all",accountId:I}});if(q)throw q;d(V.results||[]),me.success(V.summary||"API tests completed")}catch(V){console.error("Meta API test error:",V),me.error("Failed to run API tests")}finally{l(null)}};return e.jsx(Es,{title:"Social Connections",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-pink-500 via-purple-500 to-blue-500 p-6 md:p-8 text-white",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzMiAyIDIgNC0yIDQtMiA0LTItMi0yLTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsxs(Qe,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx($r,{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(Fa,{className:"h-4 w-4"}),"Back to Social Swag"]}),!r&&e.jsx(Pe,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:e.jsxs(Re,{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(ln,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(Qe,{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:[E&&e.jsx(Pe,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsxs(Re,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(ti,{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(Pe,{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(uu,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Facebook"}),e.jsx(hr,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs(Re,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(oo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):N.length>0?e.jsx("div",{className:"space-y-3",children:N.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(vn,{className:"h-10 w-10",children:[e.jsx(Ta,{src:I.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(uu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:I.page_name||I.platform_username||"Facebook Page"}),e.jsx(Qe,{variant:I.is_active?"default":"secondary",className:"text-xs",children:I.is_active?"Connected":"Inactive"})]})]}),e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Disconnect Facebook?"}),e.jsx(Pl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:()=>x.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Facebook pages connected yet"}),e.jsxs(K,{onClick:y,disabled:n,className:"w-full gap-2",variant:N.length>0?"outline":"default",children:[n?e.jsx(oo,{className:"h-4 w-4 animate-spin"}):e.jsx(Us,{className:"h-4 w-4"}),N.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(Pe,{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(mu,{className:"h-6 w-6 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Instagram"}),e.jsx(hr,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs(Re,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(oo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?e.jsx("div",{className:"space-y-3",children:w.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(vn,{className:"h-10 w-10",children:[e.jsx(Ta,{src:I.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(mu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",I.platform_username||"Instagram Account"]}),e.jsx(Qe,{variant:I.is_active?"default":"secondary",className:"text-xs",children:I.is_active?"Connected":"Inactive"})]})]}),e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Disconnect Instagram?"}),e.jsx(Pl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:()=>x.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Instagram accounts connected yet"}),e.jsxs(K,{onClick:y,disabled:n,className:"w-full gap-2",variant:w.length>0?"outline":"default",children:[n?e.jsx(oo,{className:"h-4 w-4 animate-spin"}):e.jsx(Us,{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(Pe,{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(xp,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"LinkedIn"}),e.jsx(hr,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs(Re,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(oo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):k.length>0?e.jsx("div",{className:"space-y-3",children:k.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(vn,{className:"h-10 w-10",children:[e.jsx(Ta,{src:I.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(xp,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:I.platform_username||"LinkedIn Account"}),e.jsx(Qe,{variant:I.is_active?"default":"secondary",className:"text-xs",children:I.is_active?"Connected":"Inactive"})]})]}),e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Disconnect LinkedIn?"}),e.jsx(Pl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:()=>x.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No LinkedIn account connected yet"}),e.jsxs(K,{onClick:_,disabled:n,className:"w-full gap-2",variant:k.length>0?"outline":"default",children:[n?e.jsx(oo,{className:"h-4 w-4 animate-spin"}):e.jsx(Us,{className:"h-4 w-4"}),k.length>0?"Reconnect LinkedIn":"Connect LinkedIn"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Share content directly to your LinkedIn profile"})]})]}),e.jsxs(Pe,{className:`relative overflow-hidden ${r?"":"opacity-75"}`,children:[!r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(Qe,{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(Qe,{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(Da,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Google Business"}),e.jsx(hr,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs(Re,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(oo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):C.length>0?e.jsx("div",{className:"space-y-3",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-10 w-10",children:[e.jsx(Ta,{src:I.profile_picture_url||""}),e.jsx(_n,{children:e.jsx(Da,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:I.page_name||I.platform_username||"Google Business"}),e.jsx(Qe,{variant:I.is_active?"default":"secondary",className:"text-xs",children:I.is_active?"Connected":"Inactive"})]})]}),e.jsxs(tc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})}),e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Disconnect Google Business?"}),e.jsx(Pl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:()=>x.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:r?"No Google Business account connected yet":"Google Business Profile integration is coming soon!"}),e.jsxs(K,{onClick:r?b:void 0,disabled:!r||n,className:"w-full gap-2",variant:C.length>0?"outline":"default",children:[n?e.jsx(oo,{className:"h-4 w-4 animate-spin"}):e.jsx(Us,{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(Pe,{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(Nb,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(hr,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),e.jsxs(Re,{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(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(uu,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{className:"font-medium",children:I.page_name||"Facebook Page"})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>L(I.id),disabled:o===I.id,children:o===I.id?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Nb,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${I.id}`)),w.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(mu,{className:"h-5 w-5 text-pink-600"}),e.jsxs("span",{className:"font-medium",children:["@",I.platform_username||"Instagram"]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>L(I.id),disabled:o===I.id,children:o===I.id?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Nb,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-ig-${I.id}`))]}),i&&i.length>0&&e.jsxs("div",{className:"mt-4 rounded-lg border bg-background p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Test Results"}),e.jsx("div",{className:"space-y-2",children:i.map((I,O)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[I.status==="success"?e.jsx(Qn,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):I.status==="pending"?e.jsx(_s,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx(Zl,{className:"h-4 w-4 text-red-600 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-mono text-xs bg-muted px-1 rounded",children:I.test}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:I.details})]})]},O))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Note: Facebook posts are auto-deleted. Instagram posts will remain and should be manually deleted. Allow up to 24 hours for Meta to register the API calls."})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-lg",children:"How it works"})}),e.jsx(Re,{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 n3s(){const[t]=Nc(),s=_r(),[r,n]=S.useState("loading"),[a,o]=S.useState("Processing your connection...");return S.useEffect(()=>{(async()=>{var x;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 ${((x=y.accounts)==null?void 0:x.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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(_s,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(ti,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Zl,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ot,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(hr,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function a3s(){const[t]=Nc(),s=_r(),[r,n]=S.useState("loading"),[a,o]=S.useState("Connecting your Google Business Profile...");return S.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),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:x,error:y}=await G.functions.invoke("google-business-oauth",{body:{action:"exchange_code",code:i,state:p}});if(y)throw y;if(x!=null&&x.success)n("success"),o(x.message||"Successfully connected Google Business Profile!"),me.success("Google Business Profile connected!");else throw new Error((x==null?void 0:x.error)||"Unknown error")}catch(x){console.error("Google OAuth callback error:",x),n("error"),o(x instanceof Error?x.message:"Failed to connect Google Business Profile"),me.error("Failed to connect: "+(x instanceof Error?x.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Pe,{className:"w-full max-w-md",children:[e.jsxs(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(_s,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(ti,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Zl,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ot,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(hr,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function i3s(){const[t]=Nc(),s=_r(),[r,n]=S.useState("loading"),[a,o]=S.useState("Connecting your LinkedIn account...");return S.useEffect(()=>{(async()=>{var x;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 ${((x=y.accounts)==null?void 0:x.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(Pe,{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(_s,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(ti,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(Zl,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(Ot,{className:"flex items-center justify-center gap-2",children:[e.jsx(xp,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(hr,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function o3s(){const t=_r(),[s,r]=S.useState(null),{data:n,isLoading:a}=Rlt(s||void 0,!0),{data:o,isLoading:l}=BCe(!0),{cartItems:i}=Que(),d=i.reduce((p,x)=>p+x.quantity,0),u=p=>{t(`/marketplace/${p.id}`)};return a||l?e.jsx(Es,{title:"Marketplace",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[1,2,3].map(p=>e.jsx(Ns,{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(Ns,{className:"h-72 w-full"},p))})]})}):e.jsx(Es,{title:"Marketplace",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Marketplace"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Shop exclusive products for LevelUp members"})]}),e.jsxs(K,{variant:"outline",onClick:()=>t("/marketplace/cart"),className:"relative",children:[e.jsx(op,{className:"h-4 w-4 mr-2"}),"Cart",d>0&&e.jsx(Qe,{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 x;return e.jsxs(Pe,{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:((x=p.images.find(y=>y.is_primary))==null?void 0:x.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(nl,{className:"h-12 w-12 text-muted-foreground"})}),p.category&&e.jsx(Qe,{className:"absolute top-2 left-2",variant:"secondary",children:p.category.name})]}),e.jsxs(Re,{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(nl,{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 _ct=S.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));_ct.displayName="Breadcrumb";const bct=S.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}));bct.displayName="BreadcrumbList";const ooe=S.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:Rt("inline-flex items-center gap-1.5",t),...s}));ooe.displayName="BreadcrumbItem";const Qwe=S.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?X2e:"a";return e.jsx(a,{ref:n,className:Rt("transition-colors hover:text-foreground",s),...r})});Qwe.displayName="BreadcrumbLink";const wct=S.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}));wct.displayName="BreadcrumbPage";const Jwe=({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(Sa,{})});Jwe.displayName="BreadcrumbSeparator";function l3s(){var J,X;const{productId:t}=co(),s=_r(),{data:r,isLoading:n}=d4s(t||""),{addToCart:a,cartItems:o}=Que(),[l,i]=S.useState(null),[d,u]=S.useState(1),[p,x]=S.useState(0),[y,_]=S.useState(null),[b,N]=S.useState(!1),[w,k]=S.useState(!1),C=(J=r==null?void 0:r.variants)==null?void 0:J.find(ce=>ce.id===l),E=((X=r==null?void 0:r.variants)==null?void 0:X.filter(ce=>ce.is_active))||[],L=Number((r==null?void 0:r.base_price)||0),I=C?Number(C.price_adjustment):0,O=L+I,V=Number((r==null?void 0:r.shipping_fee)||0),q=o.reduce((ce,ie)=>ce+ie.quantity,0),$=async ce=>{if(!ce.target.files||ce.target.files.length===0)return;N(!0);const ie=ce.target.files[0],ae=ie.name.split(".").pop(),oe=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${ae}`;try{const{error:pe}=await G.storage.from("marketplace").upload(oe,ie);if(pe)throw pe;const{data:{publicUrl:_e}}=G.storage.from("marketplace").getPublicUrl(oe);_(_e),me.success("Artwork uploaded successfully")}catch(pe){me.error("Failed to upload artwork: "+pe.message)}finally{N(!1)}},U=()=>{if(r){if(E.length>0&&!l){me.error("Please select an option");return}a(r,C||void 0,d,y||void 0),k(!0),me.success("Added to cart!"),setTimeout(()=>k(!1),2e3)}},se=()=>{r!=null&&r.images&&x(ce=>(ce+1)%r.images.length)},Y=()=>{r!=null&&r.images&&x(ce=>(ce-1+r.images.length)%r.images.length)};return n?e.jsx(Es,{title:"Product",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsx(Ns,{className:"aspect-square w-full"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ns,{className:"h-8 w-3/4"}),e.jsx(Ns,{className:"h-6 w-1/4"}),e.jsx(Ns,{className:"h-24 w-full"}),e.jsx(Ns,{className:"h-12 w-full"})]})]})}):r?e.jsxs(Es,{title:r.name,children:[e.jsx(_ct,{className:"mb-6",children:e.jsxs(bct,{children:[e.jsx(ooe,{children:e.jsx(Qwe,{asChild:!0,children:e.jsx(ha,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(Jwe,{}),e.jsx(ooe,{children:e.jsx(Qwe,{asChild:!0,children:e.jsx(ha,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(Jwe,{}),e.jsx(ooe,{children:e.jsx(wct,{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:Y,children:e.jsx(xl,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:se,children:e.jsx(Sa,{className:"h-6 w-6"})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(nl,{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,ie)=>e.jsx("button",{onClick:()=>x(ie),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${ie===p?"border-primary":"border-transparent"}`,children:e.jsx("img",{src:ce.image_url,alt:"",className:"w-full h-full object-cover"})},ce.id))}),r.video&&e.jsx(Pe,{children:e.jsxs(Re,{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(Qe,{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)]}),V>0&&e.jsxs("span",{className:"text-muted-foreground",children:["+ $",V.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})}),E.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{children:"Select Option"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:E.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(xe,{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($a,{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(xe,{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(De,{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:U,disabled:w,children:w?e.jsxs(e.Fragment,{children:[e.jsx(Jn,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(op,{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(op,{className:"h-5 w-5"}),q>0&&e.jsx(Qe,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:q})]})]}),r.requires_proof_approval&&e.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-3 rounded-lg",children:"📋 This product requires proof approval before production. You'll receive a proof to review after your order is placed."})]})]})]}):e.jsx(Es,{title:"Product Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(nl,{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 c3s(){const t=_r(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:d}=Que(),[u,p]=S.useState(!1),[x,y]=S.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 k;return{product_id:w.product.id,variant_id:((k=w.variant)==null?void 0:k.id)||null,quantity:w.quantity,artwork_url:w.artworkUrl||null}}),notes:x.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(Es,{title:"Shopping Cart",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(e0,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your cart is empty"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Add some products to get started!"}),e.jsx(K,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Es,{title:"Shopping Cart",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[s.map(b=>{var N,w;return e.jsx(Pe,{children:e.jsx(Re,{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(k=>k.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(e0,{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 k;return r(b.product.id,(k=b.variant)==null?void 0:k.id)},children:e.jsx(gr,{className:"h-4 w-4 text-destructive"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return n(b.product.id,(k=b.variant)==null?void 0:k.id,b.quantity-1)},disabled:b.quantity<=1,children:e.jsx(Yy,{className:"h-3 w-3"})}),e.jsx(De,{type:"number",value:b.quantity,onChange:k=>{var C;return n(b.product.id,(C=b.variant)==null?void 0:C.id,parseInt(k.target.value)||1)},className:"w-14 h-8 text-center text-sm",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return n(b.product.id,(k=b.variant)==null?void 0:k.id,b.quantity+1)},children:e.jsx(Us,{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(Pe,{className:"sticky top-4",children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Order Summary"})}),e.jsxs(Re,{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(wo,{}),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(wo,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(vr,{id:"orderNotes",placeholder:"Add any special instructions, design notes, or comments for your order...",value:x,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(_s,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx(ei,{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 d3s(){const t=_r(),{data:s,isLoading:r}=b4s();return r?e.jsx(Es,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>e.jsx(Ns,{className:"h-32 w-full"},n))})}):!s||s.length===0?e.jsx(Es,{title:"My Orders",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(nl,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No orders yet"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Start shopping to see your orders here!"}),e.jsx(K,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Es,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:s.map(n=>{var a,o,l;return e.jsx(Pe,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>t(`/marketplace/orders/${n.id}`),children:e.jsxs(Re,{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:ps(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(Qe,{className:zCe[n.status],children:rT[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(Sa,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const M9e=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function u3s({currentStatus:t,statusHistory:s}){const r=M9e.indexOf(t);return e.jsx("div",{className:"space-y-3",children:M9e.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(Qn,{className:"h-4 w-4"}):i?e.jsx(ln,{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:rT[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ps(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function h3s(){var k;const{orderId:t}=co(),s=_r(),{data:r,isLoading:n,refetch:a}=w4s(t||""),o=k4s(),l=S4s(),[i,d]=S.useState(!1),[u,p]=S.useState(null),[x,y]=S.useState(""),[_,b]=S.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:x}),me.success("Revision requested"),d(!1),y(""),p(null),a()}catch{me.error("Failed to request revision")}finally{b(null)}}};return n?e.jsx(Es,{title:"Order Details",children:e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx(Ns,{className:"h-64 w-full"}),e.jsx(Ns,{className:"h-48 w-full"})]}),e.jsx(Ns,{className:"h-96 w-full"})]})}):r?e.jsxs(Es,{title:`Order ${r.order_number}`,children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{children:"Order Status"}),e.jsx(Qe,{className:zCe[r.status],children:rT[r.status]})]}),e.jsx(Re,{children:e.jsx(u3s,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Items"})}),e.jsx(Re,{className:"space-y-4",children:(k=r.items)==null?void 0:k.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(jb,{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(jb,{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(_s,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Fu,{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(RL,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),C.proof_status==="approved"&&e.jsxs(Qe,{className:"bg-green-100 text-green-800",children:[e.jsx(Qn,{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(Qe,{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(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(FL,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs(Re,{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(Pe,{className:"sticky top-4",children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Order Summary"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",ps(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(wo,{}),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(wo,{}),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(wo,{}),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(Ir,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(vr,{placeholder:"Describe the changes needed...",value:x,onChange:C=>y(C.target.value),rows:4}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{onClick:w,disabled:!x.trim()||_!==null,children:[_?e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Submit Request"]})]})]})})]}):e.jsx(Es,{title:"Order Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(nl,{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 m3s(){const t=_r(),[s]=Nc();return s.get("session_id"),S.useEffect(()=>{localStorage.removeItem("marketplace-cart")},[]),e.jsx(Es,{title:"Order Confirmed",children:e.jsx("div",{className:"max-w-lg mx-auto text-center py-8",children:e.jsx(Pe,{children:e.jsxs(Re,{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(Qn,{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(nl,{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(ei,{className:"h-4 w-4 ml-2"})]}),e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function p3s(){const{user:t}=Fs(),[s,r]=S.useState("store"),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(!1),[u,p]=S.useState(5),[x,y]=S.useState(""),[_,b]=S.useState(!1),[N,w]=S.useState(!1),[k,C]=S.useState(""),[E,L]=S.useState(null),[I,O]=S.useState(!1),{hasSubmittedReview:V,submitReview:q,markPostedToGoogle:$}=UYe(),{data:U}=Flt(),{data:se,isLoading:Y}=Olt(),{data:J,isLoading:X}=I4s(n),{data:ce,isLoading:ie}=L4s(t==null?void 0:t.id),{data:ae=0}=R4s(t==null?void 0:t.id),oe=O4s(),pe=new Set((ce==null?void 0:ce.map(Me=>Me.item_id))||[]),_e=async()=>{if(o)try{const Me=await oe.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(Me){me.error(Me.message||"Failed to purchase item")}},he=async()=>{if(!x.trim()){me.error("Please write a review");return}b(!0);const Me=await q(u,x);b(!1),Me.success?(me.success("Thank you for your review! You earned 25 points!"),C(x),w(!0),y(""),p(5)):me.error(Me.error||"Failed to submit review")},we=()=>{navigator.clipboard.writeText(k),me.success("Review copied to clipboard!")},je=()=>{$(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},Ue=()=>{w(!1),d(!1),C("")};return Y||X||ie?e.jsx(Es,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ns,{className:"h-24 w-full"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(Me=>e.jsx(Ns,{className:"h-64"},Me))})]})}):e.jsxs(Es,{title:"Reward Store",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Reward Store"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Redeem your points for exclusive rewards"})]}),e.jsx(Pe,{className:"bg-gradient-to-r from-primary/10 to-primary/5 border-primary/20",children:e.jsx(Re,{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(Hn,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your Spendable Points"}),e.jsx("p",{className:"text-3xl font-bold text-primary",children:ae.toLocaleString()})]})]}),e.jsxs("div",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Vi,{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(of,{open:I,onOpenChange:O,children:e.jsxs(Pe,{className:"border-primary/20",children:[e.jsx(lf,{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(Vi,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-base",children:"How to Earn Points"}),e.jsx(hr,{children:"See all the ways you can earn spendable points"})]})]}),I?e.jsx(nf,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(Oi,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(cf,{children:e.jsx(Re,{className:"pt-0",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[U==null?void 0:U.filter(Me=>Me.is_active).map(Me=>{const Fe=Le=>{switch(Le){case"event_attendance":return e.jsx(on,{className:"h-5 w-5"});case"leave_review":return e.jsx(Hn,{className:"h-5 w-5"});case"add_listing":return e.jsx(Mn,{className:"h-5 w-5"});case"first_contact":return e.jsx(lr,{className:"h-5 w-5"});case"first_video":return e.jsx(Tn,{className:"h-5 w-5"});case"first_community_post":return e.jsx(ki,{className:"h-5 w-5"});default:return e.jsx(Ui,{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:Fe(Me.action_key)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:Me.action_name}),Me.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Me.description})]}),e.jsxs(Qe,{variant:"secondary",className:"font-bold shrink-0",children:["+",Me.points]})]},Me.id)}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/20 flex items-center justify-center text-orange-500 shrink-0",children:e.jsx(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(Qe,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!V&&e.jsx(Pe,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:e.jsx(Re,{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(ki,{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(Hn,{className:"h-4 w-4 mr-2"}),"Leave Review"]})]})})}),e.jsxs(ia,{value:s,onValueChange:r,children:[e.jsxs(ea,{children:[e.jsxs(ls,{value:"store",className:"flex items-center gap-2",children:[e.jsx(e0,{className:"h-4 w-4"}),"Store"]}),e.jsxs(ls,{value:"my-rewards",className:"flex items-center gap-2",children:[e.jsx(nl,{className:"h-4 w-4"}),"My Rewards",ce&&ce.length>0&&e.jsx(Qe,{variant:"secondary",className:"ml-1",children:ce.length})]})]}),e.jsxs(js,{value:"store",className:"mt-6",children:[se&&se.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"}),se.map(Me=>e.jsxs(K,{variant:n===Me.id?"default":"outline",size:"sm",onClick:()=>a(Me.id),children:[Me.icon&&`${Me.icon} `,Me.name]},Me.id))]}),!J||J.length===0?e.jsx(Pe,{children:e.jsx(Re,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(Ui,{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(Me=>{const Fe=Me.item_type==="reelflow_credits",Le=!Fe&&pe.has(Me.id),Ne=!Fe&&Me.max_quantity!==null&&Me.current_quantity===0,qe=ae>=Me.points_cost;return e.jsxs(Pe,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${Le?"ring-2 ring-green-500/50 bg-green-500/5":""}`,onClick:()=>L(Me),children:[Me.preview_image_url?e.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[e.jsx("img",{src:Me.preview_image_url,alt:Me.name,className:"w-full h-full object-cover"}),Le&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Qe,{className:"bg-green-500 text-white",children:[e.jsx(Qn,{className:"h-3 w-3 mr-1"}),"Owned"]})}),Ne&&!Le&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(Qe,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(Ui,{className:"h-12 w-12 text-muted-foreground/50"}),Le&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Qe,{className:"bg-green-500 text-white",children:[e.jsx(Qn,{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(Ot,{className:"text-lg",children:Me.name}),e.jsxs(Qe,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(Hn,{className:"h-3 w-3 mr-1"}),Me.points_cost]})]}),Me.category&&e.jsxs(Qe,{variant:"outline",className:"w-fit",children:[Me.category.icon&&`${Me.category.icon} `,Me.category.name]})]}),e.jsxs(Re,{children:[e.jsx(hr,{className:"mb-4 line-clamp-2",children:Me.description||"No description available"}),Me.max_quantity!==null&&!Le&&!Fe&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Me.current_quantity," of ",Me.max_quantity," remaining"]}),Fe&&e.jsxs("p",{className:"text-xs text-violet-600 font-medium mb-3",children:["🎬 Grants ",Me.max_quantity," ReelFlow credits per purchase"]}),Le?e.jsx(K,{className:"w-full",onClick:ze=>{ze.stopPropagation(),Me.file_url&&v0e(Me.file_url,Me.name)},disabled:!Me.file_url,children:Me.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:ze=>{ze.stopPropagation(),l(Me)},disabled:Ne||!qe,children:Ne?"Sold Out":qe?e.jsxs(e.Fragment,{children:[e.jsx(e0,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Me.points_cost-ae} more pts`})]})]},Me.id)})})]}),e.jsx(js,{value:"my-rewards",className:"mt-6",children:!ce||ce.length===0?e.jsx(Pe,{children:e.jsx(Re,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(nl,{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(Me=>{var Fe,Le,Ne,qe,ze,ve,dt;return e.jsxs(Pe,{className:"overflow-hidden",children:[(Fe=Me.item)!=null&&Fe.preview_image_url?e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:e.jsx("img",{src:Me.item.preview_image_url,alt:((Le=Me.item)==null?void 0:Le.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(Ui,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(Lt,{className:"pb-2",children:[e.jsx(Ot,{className:"text-lg",children:((Ne=Me.item)==null?void 0:Ne.name)||"Unknown Item"}),e.jsxs(hr,{className:"text-xs",children:["Purchased for ",Me.points_spent," points • ",new Date(Me.purchased_at).toLocaleDateString()]})]}),e.jsx(Re,{children:((qe=Me.item)==null?void 0:qe.item_type)==="reelflow_credits"?e.jsxs(K,{className:"w-full",variant:"outline",disabled:!0,children:[e.jsx(Qn,{className:"h-4 w-4 mr-2 text-green-500"}),(ze=Me.item)==null?void 0:ze.max_quantity," Credits Applied"]}):e.jsx(K,{className:"w-full",onClick:()=>{var fe,Ve;(fe=Me.item)!=null&&fe.file_url&&v0e(Me.item.file_url,(Ve=Me.item)==null?void 0:Ve.name)},disabled:!((ve=Me.item)!=null&&ve.file_url),children:((dt=Me.item)==null?void 0:dt.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"]})})})]},Me.id)})})})]})]}),e.jsx(tc,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Confirm Purchase"}),e.jsxs(Pl,{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:[ae," points"]}),". After this purchase, you'll have"," ",e.jsxs("strong",{children:[ae-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{onClick:_e,disabled:oe.isPending,children:oe.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(fs,{open:i,onOpenChange:Me=>{!Me&&N?Ue():d(Me)},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(Qn,{className:"h-5 w-5 text-green-500"}),"Thank You for Your Review!"]}),e.jsx(Ir,{children:"Would you also share your review on Google? It helps other agents discover LevelUp!"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-muted p-4 rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your review:"}),e.jsxs("p",{className:"text-sm italic",children:['"',k,'"']})]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:we,children:[e.jsx(Ya,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(En,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(K,{variant:"outline",onClick:Ue,children:"Maybe Later"}),e.jsxs(K,{onClick:je,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(Ir,{children:"Share your experience with LevelUp and earn 25 spendable points!"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Rating"}),e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(Me=>e.jsx("button",{type:"button",onClick:()=>p(Me),className:"focus:outline-none",children:e.jsx(Hn,{className:`h-8 w-8 transition-colors ${u>=Me?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},Me))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),e.jsx(vr,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:x,onChange:Me=>y(Me.target.value),rows:4})]})]}),e.jsxs(En,{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:!!E,onOpenChange:()=>L(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==null?void 0:E.name,e.jsxs(Qe,{variant:"secondary",className:"font-bold",children:[e.jsx(Hn,{className:"h-3 w-3 mr-1"}),E==null?void 0:E.points_cost]})]}),(E==null?void 0:E.category)&&e.jsxs(Qe,{variant:"outline",className:"w-fit",children:[E.category.icon&&`${E.category.icon} `,E.category.name]})]}),(E==null?void 0:E.preview_image_url)&&e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted rounded-lg",children:e.jsx("img",{src:E.preview_image_url,alt:E.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:(E==null?void 0:E.description)||"No description available"}),(E==null?void 0:E.item_type)==="reelflow_credits"&&e.jsxs("p",{className:"text-sm text-violet-600 font-medium",children:["🎬 Grants ",E==null?void 0:E.max_quantity," ReelFlow credits per purchase"]}),(E==null?void 0:E.item_type)!=="reelflow_credits"&&(E==null?void 0:E.max_quantity)!==null&&!pe.has((E==null?void 0:E.id)||"")&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[E==null?void 0:E.current_quantity," of ",E==null?void 0:E.max_quantity," remaining"]})]}),e.jsx(En,{children:E&&E.item_type!=="reelflow_credits"&&pe.has(E.id)?e.jsx(K,{className:"w-full",onClick:()=>{E.file_url&&v0e(E.file_url,E.name)},disabled:!E.file_url,children:E.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&&e.jsx(K,{className:"w-full",onClick:()=>{L(null),l(E)},disabled:E.item_type!=="reelflow_credits"&&E.max_quantity!==null&&E.current_quantity===0||ae{const{user:t}=Fs(),s=Jt(),r=gt({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=gt({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=It({mutationFn:async u=>{const{data:p,error:x}=await G.from("smart_presentations").insert({owner_user_id:t.id,...u}).select().single();if(x)throw x;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),o=It({mutationFn:async({id:u,...p})=>{const{data:x,error:y}=await G.from("smart_presentations").update(p).eq("id",u).select().single();if(y)throw y;return x},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),l=It({mutationFn:async u=>{const{data:p,error:x}=await G.from("smart_presentations").update({status:"published",published_at:new Date().toISOString()}).eq("id",u).select().single();if(x)throw x;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),me.success("Presentation published!")}}),i=It({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=It({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}},f3s=()=>{const t=_r(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=jct(),o=i=>i.status==="draft"?e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(Qe,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(Qe,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(Qe,{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(Es,{title:"Smart Presentations",children:e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h1",{className:"text-2xl font-serif font-bold text-foreground",children:"Smart Presentations"})}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Create personalized, video-first presentations for your clients"})]}),e.jsxs(K,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(Us,{className:"h-4 w-4"}),"Create Presentation"]})]}),r?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(i=>e.jsx(Ns,{className:"h-20 w-full rounded-lg"},i))}):s.length===0?e.jsx(Pe,{children:e.jsxs(Re,{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(Pg,{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(Us,{className:"h-4 w-4"}),"Create Your First Presentation"]})]})}):e.jsx("div",{className:"space-y-3",children:s.map(i=>e.jsx(Pe,{className:"hover:shadow-sm transition-shadow",children:e.jsx(Re,{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(fn,{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 ",ps(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wn,{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(ax,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(va,{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(va,{onClick:()=>a.mutate(i),children:[e.jsx(fn,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(va,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(pM,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},T9e={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."}]},x3s=[{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 g3s(t){const s=T9e[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(T9e))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return x3s}function y3s({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=S.useState(!1),[o,l]=S.useState("script"),[i,d]=S.useState(0),[u,p]=S.useState(0),{canRecord:x}=Zat(),y=MC(),[_,b]=S.useState(""),[N,w]=S.useState(!1),[k,C]=S.useState(!0),[E,L]=S.useState(!1),[I,O]=S.useState(null),V=g3s(t),q=()=>{l("script"),d(0),p(0),b(""),w(!1),C(!0),L(!1),O(null)},$=X=>{!X&&(o==="uploading"||o==="processing")||(a(X),X||q())},U=X=>{O(X),b(V[X].text),w(!1)},se=()=>{l("record"),C(_.trim().length>0)},Y=()=>{b(""),C(!1),l("record")},J=S.useCallback(async(X,ce)=>{l("uploading");try{const ie=t||"Presentation Video",{videoId:ae,uploadUrl:oe,libraryId:pe}=await xO(ie),{apiKey:_e}=await gO(ae),he=new XMLHttpRequest;he.upload.onprogress=Me=>{Me.lengthComputable&&d(Me.loaded/Me.total*100)},await new Promise((Me,Fe)=>{he.onload=()=>he.status>=200&&he.status<300?Me():Fe(new Error("Upload failed")),he.onerror=()=>Fe(new Error("Upload failed")),he.open("PUT",oe),he.setRequestHeader("AccessKey",_e),he.send(X)}),l("processing");let we=0;const je=Date.now(),Ue=9e4;let Te=null;for(;we<4;){if(await new Promise(Fe=>setTimeout(Fe,3e3)),Date.now()-je>Ue){const Fe=X.size/1048576,Le=`https://iframe.mediadelivery.net/embed/${pe}/${ae}?responsive=true`;await y.mutateAsync({bunny_video_id:ae,playback_url:Le,file_size_mb:Fe,title:ie,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(Le),me.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Me=await pA(ae);if(we=Me.status,p(Me.encodeProgress||0),we===4)Te={playbackUrl:Me.directPlayUrl,thumbnailUrl:Me.thumbnailUrl,previewUrl:Me.previewUrl||null,duration:Me.length||ce,fileSizeMb:(Me.storageSize||X.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:ae,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:ie,status:"ready",touch_type:"presentation"}),r(Te.playbackUrl),me.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(ie){console.error("Recording upload error:",ie),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(pi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Record a video",children:[e.jsx(Tn,{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:V.map((X,ce)=>e.jsxs("button",{onClick:()=>U(ce),className:Rt("text-left p-3 rounded-lg border transition-all hover:bg-accent/50",I===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(fn,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:X.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:X.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(ga,{className:"h-3 w-3"}),"Edit"]})]}),N?e.jsx(vr,{value:_,onChange:X=>b(X.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(vr,{value:_,onChange:X=>{b(X.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:Y,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(K,{onClick:se,disabled:!1,children:_.trim()?"Continue with Script":"Continue Without Script"})]})]}),!x&&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(!k),className:"h-7 text-xs gap-1",children:[k?e.jsx(mp,{className:"h-3 w-3"}):e.jsx(wn,{className:"h-3 w-3"}),k?"Hide Script":"Show Script"]})]}),e.jsx(Qme,{maxDurationSeconds:600,onRecordingComplete:J,onRecordingStateChange:L,onError:X=>me.error(X),teleprompterContent:_.trim()?e.jsx(mlt,{text:_,isVisible:k,onToggleVisibility:()=>C(!k),isRecording:E,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(_s,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(gi,{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(_s,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(gi,{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(ti,{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 v3s({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState("idle"),[u,p]=S.useState(0),x=S.useRef(null),y=MC(),{data:_}=Sme(),b=(_==null?void 0:_.total_storage_mb)||0,w=((_==null?void 0:_.max_storage_mb)||1024)-b,k=()=>{l(null),d("idle"),p(0)},C=V=>{!V&&i!=="idle"&&i!=="done"||(a(V),V||k())},E=V=>{var U;const q=(U=V.target.files)==null?void 0:U[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)},L=S.useCallback(async()=>{if(o){d("creating"),p(0);try{const V=t||o.name,{data:q,error:$}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:V,isAgentVideo:!0}});if($)throw new Error($.message);const{videoId:U,libraryId:se}=q;d("uploading");const{data:Y,error:J}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:U,isAgentVideo:!0}});if(J)throw new Error(J.message);await new Promise((ie,ae)=>{const oe=new XMLHttpRequest;oe.upload.addEventListener("progress",pe=>{pe.lengthComputable&&p(Math.round(pe.loaded/pe.total*100))}),oe.addEventListener("load",()=>oe.status>=200&&oe.status<300?ie():ae(new Error(`Upload failed (${oe.status})`))),oe.addEventListener("error",()=>ae(new Error("Upload failed"))),oe.open("PUT",Y.uploadUrl),oe.setRequestHeader("AccessKey",Y.apiKey),oe.send(o)}),d("processing");const X=o.size/(1024*1024),ce=`https://iframe.mediadelivery.net/embed/${se}/${U}`;await y.mutateAsync({bunny_video_id:U,playback_url:ce,file_size_mb:X,title:V,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(V){console.error("Upload error:",V),me.error(V instanceof Error?V.message:"Failed to upload video"),d("idle")}}},[o,t,s,r,y]),I=()=>{switch(i){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${u}%`;case"processing":return"Saving video...";case"done":return"Done!";default:return""}},O=i!=="idle"&&i!=="done";return e.jsxs(fs,{open:n,onOpenChange:C,children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[e.jsx($a,{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(Tn,{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 V;return(V=x.current)==null?void 0:V.click()},children:[e.jsx($a,{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:x,type:"file",accept:"video/*",className:"hidden",onChange:E,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(_s,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:I()})]}),e.jsx(gi,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),disabled:O,children:"Cancel"}),e.jsx(K,{onClick:L,disabled:!o||O,children:O?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx($a,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const A9e=[{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"}],E9e=()=>{const t=_r(),{id:s}=co(),{user:r}=Fs(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=jct(),{isGmailConnected:d,gmailEmail:u}=jp(),[p,x]=S.useState(!1),[y,_]=S.useState("client"),[b,N]=S.useState(!1),[w,k]=S.useState(""),[C,E]=S.useState([]),[L,I]=S.useState(!1),[O,V]=S.useState(null),[q,$]=S.useState(!1),[U,se]=S.useState(""),[Y,J]=S.useState(""),[X,ce]=S.useState(""),[ie,ae]=S.useState("buyer"),[oe,pe]=S.useState(""),[_e,he]=S.useState(null),[we,je]=S.useState(""),[Ue,Te]=S.useState([]),[Me,Fe]=S.useState("schedule_call"),[Le,Ne]=S.useState("Schedule a Call"),[qe,ze]=S.useState(""),[ve,dt]=S.useState(""),[fe,Ve]=S.useState(null),[Je,at]=S.useState(s||null),[Ae,Ye]=S.useState(null),[We,ot]=S.useState(!1),Ge=async(zt,$s)=>{if(!r)return;const kr=5*1024*1024;if(zt.size>kr){me.error("Image must be under 5MB");return}if(!zt.type.startsWith("image/")){me.error("Please upload an image file");return}Ve($s);try{const Xs=zt.name.split(".").pop()||"jpg",ir=`${r.id}/${Date.now()}.${Xs}`,{error:Or}=await G.storage.from("listing-photos").upload(ir,zt);if(Or)throw Or;const{data:{publicUrl:Vn}}=G.storage.from("listing-photos").getPublicUrl(ir);Et($s,{image_url:Vn}),me.success("Image uploaded")}catch{me.error("Failed to upload image")}finally{Ve(null)}};S.useEffect(()=>{s&&et(s)},[s]);const et=async zt=>{const{data:$s,error:kr}=await G.from("smart_presentations").select("*").eq("id",zt).single();if(kr||!$s)return;const Xs=$s;if(N(!0),je(Xs.title),se(Xs.client_name||""),pe(Xs.property_address||""),Te(Xs.sections||[]),Fe(Xs.cta_type||"schedule_call"),Ne(Xs.cta_label||"Schedule a Call"),ze(Xs.cta_url||""),dt(Xs.heading||""),Ye(Xs.share_token),ot(Xs.status==="published"),at(Xs.id),_("builder"),Xs.contact_id){const{data:ir}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",Xs.contact_id).maybeSingle();ir&&(V(ir),J(ir.email||""),ce(ir.phone||""))}};S.useEffect(()=>{if(!r||w.length<1){E([]);return}const zt=setTimeout(async()=>{I(!0);const{data:$s}=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);E($s||[]),I(!1)},300);return()=>clearTimeout(zt)},[w,r]);const ht=zt=>{V(zt),se(`${zt.first_name} ${zt.last_name||""}`.trim()),J(zt.email||""),ce(zt.phone||""),$(!1)},xt=async()=>{if(!U.trim()){me.error("Client name is required");return}const zt=U.trim().split(" "),$s=zt[0],kr=zt.slice(1).join(" ")||null,{data:Xs,error:ir}=await G.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:$s,last_name:kr,email:Y||null,phone:X||null,lead_source:"Smart Presentation"}).select().single();if(ir){me.error("Failed to create client");return}V(Xs),me.success("Client created & saved to Agent OS"),_("template")},Ke=zt=>{he(zt);const $s=(zt.sections||[]).map(kr=>({...kr,is_visible:!0,video_url:"",text:""}));if(Te($s),je(zt.name+(U?` for ${U}`:"")),zt.cta_config){const kr=zt.cta_config;Fe(kr.type||"schedule_call"),Ne(kr.label||"Schedule a Call")}_("builder")},Ze=()=>{Te([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),je(U?`Presentation for ${U}`:"New Presentation"),_("builder")},Et=(zt,$s)=>{Te(kr=>kr.map((Xs,ir)=>ir===zt?{...Xs,...$s}:Xs))},$t=zt=>{Et(zt,{is_visible:!Ue[zt].is_visible})},Yt=()=>{Te(zt=>[...zt,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},Ps=zt=>{Te($s=>$s.filter((kr,Xs)=>Xs!==zt))},zs=async()=>{if(!we.trim()){me.error("Title is required");return}try{if(Je){const zt=await l.mutateAsync({id:Je,title:we,sections:Ue,client_name:U,property_address:oe||null,cta_type:Me,cta_label:Le,cta_url:qe||null,heading:ve||null});me.success("Saved")}else{const zt=await o.mutateAsync({title:we,contact_id:(O==null?void 0:O.id)||void 0,client_name:U,property_address:oe||void 0,template_id:(_e==null?void 0:_e.id)||void 0,sections:Ue,cta_type:Me,cta_label:Le,cta_url:qe||void 0,heading:ve||void 0});at(zt.id),Ye(zt.share_token),me.success("Presentation created!")}}catch(zt){console.error("Failed to save presentation:",zt);const $s=(zt==null?void 0:zt.message)||(zt==null?void 0:zt.toString())||"Unknown error";me.error(`Failed to save: ${$s}`)}},Zs=async()=>{try{await zs();const zt=Je;if(zt){const $s=await i.mutateAsync(zt);Ye($s.share_token),ot(!0),_("share")}}catch(zt){console.error("Failed to publish presentation:",zt),me.error(`Failed to publish: ${(zt==null?void 0:zt.message)||"Unknown error"}`)}},Dr=Ae?`https://presentations.relevelup.com/${Ae}`:"";return e.jsx(Es,{title:"Smart Presentations",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/mission-control/presentations"),children:e.jsx(Fa,{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((zt,$s)=>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===zt?"bg-primary text-primary-foreground":$s<["client","template","builder","share"].indexOf(y)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:$s<["client","template","builder","share"].indexOf(y)?e.jsx(Jn,{className:"h-4 w-4"}):$s+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:zt}),$s<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},zt))}),y==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{V(null),se(""),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(An,{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(ei,{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(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(an,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),e.jsxs(Re,{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or email...",value:w,onChange:zt=>k(zt.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[L&&e.jsx(Ns,{className:"h-12 w-full"}),C.map(zt=>e.jsxs("button",{onClick:()=>ht(zt),className:Rt("w-full text-left p-3 rounded-lg border transition-colors",(O==null?void 0:O.id)===zt.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[zt.first_name," ",zt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:zt.email||zt.phone||"No contact info"})]},zt.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&&!L&&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(ei,{className:"h-4 w-4"})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(al,{className:"h-4 w-4 text-muted-foreground"}),"Add New Client"]})}),e.jsxs(Re,{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(xe,{className:"text-xs",children:"Name *"}),e.jsx(De,{value:U,onChange:zt=>{se(zt.target.value),$(!0),V(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Email"}),e.jsx(De,{value:Y,onChange:zt=>J(zt.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Phone"}),e.jsx(De,{value:X,onChange:zt=>ce(zt.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Client Type"}),e.jsxs(Bs,{value:ie,onValueChange:ae,children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"buyer",children:"Buyer"}),e.jsx(vt,{value:"seller",children:"Seller"}),e.jsx(vt,{value:"recruit",children:"Recruit"}),e.jsx(vt,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Property Address"}),e.jsx(De,{value:oe,onChange:zt=>pe(zt.target.value),placeholder:"Optional"})]})]}),q&&U&&e.jsxs(K,{onClick:xt,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(ei,{className:"h-4 w-4"})]})]})]})]})]}),y==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(ia,{defaultValue:"system",children:[e.jsxs(ea,{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(zt=>e.jsx(Ns,{className:"h-32"},zt))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(zt=>!zt.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(zt=>!zt.is_system).map(zt=>e.jsx(P9e,{template:zt,onSelect:Ke},zt.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(zt=>zt.is_system).map(zt=>e.jsx(P9e,{template:zt,onSelect:Ke},zt.id))})}),e.jsx(js,{value:"blank",className:"mt-4",children:e.jsx(Pe,{children:e.jsxs(Re,{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:Ze,children:"Start from Scratch"})]})})})]}),e.jsxs(K,{variant:"outline",onClick:()=>_("client"),className:"gap-2",children:[e.jsx(Fa,{className:"h-4 w-4"}),"Back"]})]}),y==="builder"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Presentation Title"}),e.jsx(De,{value:we,onChange:zt=>je(zt.target.value)})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Page Heading"}),e.jsx(De,{value:ve,onChange:zt=>dt(zt.target.value),placeholder:U?`Welcome, ${U}!`:"e.g. Welcome! or Your Custom Listing Plan"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:['The main heading visitors see. Leave blank for "Welcome, ',"",'!"']})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Client Name"}),e.jsx(De,{value:U,onChange:zt=>se(zt.target.value)})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Property Address"}),e.jsx(De,{value:oe,onChange:zt=>pe(zt.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:Yt,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:Ue.map((zt,$s)=>e.jsx(Pe,{className:Rt(!zt.is_visible&&"opacity-50"),children:e.jsx(Re,{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(hu,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:zt.icon})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(De,{value:zt.title,onChange:kr=>Et($s,{title:kr.target.value}),className:"font-semibold border-none p-0 h-auto text-base focus-visible:ring-0 bg-transparent"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$t($s),children:zt.is_visible?e.jsx(wn,{className:"h-4 w-4"}):e.jsx(mp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ps($s),className:"text-destructive hover:text-destructive",children:e.jsx(gr,{className:"h-4 w-4"})})]})]}),e.jsx(De,{value:zt.description||"",onChange:kr=>Et($s,{description:kr.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(xe,{className:"text-xs",children:"Video URL"}),e.jsx(De,{value:zt.video_url||"",onChange:kr=>Et($s,{video_url:kr.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(y3s,{sectionTitle:zt.title,contactId:O==null?void 0:O.id,onVideoReady:kr=>Et($s,{video_url:kr})}),e.jsx(v3s,{sectionTitle:zt.title,contactId:O==null?void 0:O.id,onVideoReady:kr=>Et($s,{video_url:kr})}),e.jsx(RCe,{userId:r==null?void 0:r.id,onSelect:kr=>Et($s,{video_url:kr})})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),zt.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:zt.image_url,alt:"",className:"w-full max-h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>Et($s,{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:[fe===$s?e.jsx(_s,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(Yv,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:fe===$s?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:fe===$s,onChange:kr=>{var ir;const Xs=(ir=kr.target.files)==null?void 0:ir[0];Xs&&Ge(Xs,$s),kr.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Text (optional)"}),e.jsx(Gg,{content:zt.text||"",onChange:kr=>Et($s,{text:kr}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},$s))})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Call to Action"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"CTA Type"}),e.jsxs(Bs,{value:Me,onValueChange:zt=>{Fe(zt);const $s=A9e.find(kr=>kr.value===zt);$s&&Ne($s.label)},children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:A9e.map(zt=>e.jsx(vt,{value:zt.value,children:zt.label},zt.value))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Button Label"}),e.jsx(De,{value:Le,onChange:zt=>Ne(zt.target.value)})]}),e.jsxs("div",{children:[e.jsxs(xe,{children:["Link URL ",e.jsx("span",{className:"text-muted-foreground",children:"(optional — leave blank to show a lead capture form instead)"})]}),e.jsx(De,{value:qe,onChange:zt=>ze(zt.target.value),placeholder:"https://calendly.com/..."}),!qe&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Without a URL, clients will see a contact form — their info gets added to your contacts and you'll receive an email notification."})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[!b&&e.jsxs(K,{variant:"outline",onClick:()=>_("template"),className:"gap-2",children:[e.jsx(Fa,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(K,{variant:"outline",onClick:zs,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(K,{onClick:Zs,disabled:i.isPending,className:"gap-2",children:[e.jsx(An,{className:"h-4 w-4"}),We?"Update & Reshare":"Publish & Share"]})]})]})]}),y==="share"&&Ae&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{children:e.jsxs(Re,{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(Jn,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your Presentation is Live!"}),e.jsxs("p",{className:"text-muted-foreground mb-6 max-w-md",children:["Share this link with ",U||"your client",". You'll be notified when they view it."]}),e.jsxs("div",{className:"flex items-center gap-2 w-full max-w-lg",children:[e.jsx(De,{value:Dr,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(K,{onClick:()=>{navigator.clipboard.writeText(Dr),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 zt=`Hi ${U||""}! I put together something for you — check it out: ${Dr}`;navigator.clipboard.writeText(zt),me.success("Message copied!")},children:[e.jsx(ki,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{d?x(!0):window.open(`mailto:${Y||""}?subject=${encodeURIComponent(we)}&body=${encodeURIComponent(`Hi ${(O==null?void 0:O.first_name)||(U==null?void 0:U.split(" ")[0])||""}, I put together a personalized presentation for you: ${Dr} Looking forward to connecting!`)}`)},children:[e.jsx(rr,{className:"h-4 w-4"}),"Send Email"]})]}),d&&e.jsx(T1,{open:p,onOpenChange:x,contact:O?{id:O.id,first_name:O.first_name,last_name:O.last_name,email:Y||O.email||""}:Y?{id:"",first_name:(U==null?void 0:U.split(" ")[0])||"",last_name:(U==null?void 0:U.split(" ").slice(1).join(" "))||"",email:Y}:void 0,defaultSubject:we,defaultBody:`Hi ${(O==null?void 0:O.first_name)||(U==null?void 0:U.split(" ")[0])||""}, I put together a personalized presentation for you: ${Dr} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(K,{variant:"outline",onClick:()=>_("builder"),children:[e.jsx(Fa,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(K,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},P9e=({template:t,onSelect:s})=>e.jsx(Pe,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(Re,{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(Qe,{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"})]})}),_3s=()=>{var N;const{shareToken:t}=co(),[s,r]=S.useState(null),[n,a]=S.useState(!0),[o,l]=S.useState(0),[i,d]=S.useState(!1);S.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),S.useEffect(()=>{t&&u()},[t]);const u=async()=>{const{data:w,error:k}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(k||!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 E;if(C!=null&&C.brokerage_id){const{data:I}=await G.from("brokerages").select("name").eq("id",C.brokerage_id).single();E=(I==null?void 0:I.name)||void 0}let L=null;if(w.contact_id){const{data:I}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",w.contact_id).single();L=I}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:E,contact_name:L?[L.first_name,L.last_name].filter(Boolean).join(" "):void 0,contact_email:(L==null?void 0:L.email)||void 0,contact_phone:(L==null?void 0:L.phone)||void 0}),a(!1);try{await 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(Ns,{className:"h-12 w-3/4 mx-auto"}),e.jsx(Ns,{className:"h-64 w-full"}),e.jsx(Ns,{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 x=s.sections.filter(w=>w.is_visible!==!1),y=x[o],_=w=>{const k=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(k)return`https://www.youtube.com/embed/${k[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const L=w.replace("/play/","/embed/"),I=L.includes("?")?"&":"?";return`${L}${I}responsive=true`}if(w.includes("iframe.mediadelivery.net")){if(w.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const I=w.includes("?")?"&":"?";return`${w}${I}responsive=true`}return""}const C=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(C)return`https://www.loom.com/embed/${C[1]}`;const E=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return E?`https://iframe.mediadelivery.net/embed/${E[1]}/${E[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:x.map((w,k)=>e.jsx("button",{onClick:()=>l(k),className:Rt("w-full text-left p-4 rounded-xl border transition-all",o===k?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(k+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:w.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:w.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:w.description})]})]})},k))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),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(xWe,{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 b3s({openHouseId:t,enableSurvey:s,onToggleSurvey:r}){const{data:n,isLoading:a}=Bkt(t),o=Vkt(),l=Hkt(),i=Gkt(),d=Wkt(),[u,p]=S.useState(""),[x,y]=S.useState("rating"),_=async k=>{r(k),k&&(!n||n.length===0)&&await d.mutateAsync(t)},b=async()=>{if(!u.trim())return;const k=(n==null?void 0:n.reduce((C,E)=>Math.max(C,E.sort_order),0))??0;await o.mutateAsync({open_house_id:t,question_type:x,question_text:u.trim(),sort_order:k+1}),p("")},N=async k=>{await l.mutateAsync({id:k.id,open_house_id:t,is_active:!k.is_active})},w=async k=>{await i.mutateAsync({id:k.id,open_house_id:t})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(xe,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(wb,{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(Er,{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(_s,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:n==null?void 0:n.map(k=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-muted/20",children:[e.jsx(hu,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm truncate",children:k.question_text}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:k.question_type.replace("_"," ")})]}),e.jsx(Er,{checked:k.is_active,onCheckedChange:()=>N(k),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>w(k),children:e.jsx(gr,{className:"h-3.5 w-3.5"})})]},k.id))}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(xe,{className:"text-xs text-muted-foreground",children:"Add Question"}),e.jsx(De,{value:u,onChange:k=>p(k.target.value),placeholder:"e.g. How did you hear about this listing?",className:"mt-1 h-9 text-sm",onKeyDown:k=>k.key==="Enter"&&b()})]}),e.jsxs(Bs,{value:x,onValueChange:y,children:[e.jsx(Rs,{className:"w-28 h-9 text-xs",children:e.jsx(qs,{})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"rating",children:"Rating"}),e.jsx(vt,{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(Us,{className:"h-3.5 w-3.5"})})]})]})})]})}function w3s({open:t,onOpenChange:s,openHouse:r}){const n=yWe(),{user:a}=Fs(),o=S.useRef(null),[l,i]=S.useState(r.auto_forward_to_card??!1),[d,u]=S.useState(r.disclosure_pdf_url??""),[p,x]=S.useState(r.enable_survey??!1),[y,_]=S.useState(r.ask_visitor_intent??!0),[b,N]=S.useState(!1),[w,k]=S.useState(!1),C=async I=>{var U;const O=(U=I.target.files)==null?void 0:U[0];if(!O||!a)return;if(O.size>20*1024*1024){gn({title:"File must be under 20MB",variant:"destructive"});return}if(O.type!=="application/pdf"){gn({title:"Only PDF files are accepted",variant:"destructive"});return}N(!0);const V=`${a.id}/disclosures/${r.id}-${Date.now()}.pdf`,{error:q}=await G.storage.from("open-house-photos").upload(V,O,{upsert:!0});if(q){gn({title:"Upload failed",description:q.message,variant:"destructive"}),N(!1);return}const{data:$}=G.storage.from("open-house-photos").getPublicUrl(V);u($.publicUrl),N(!1),gn({title:"PDF uploaded!"})},E=()=>{u(""),o.current&&(o.current.value="")},L=async()=>{k(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:l,disclosure_pdf_url:d||null,enable_survey:p,ask_visitor_intent:y}),gn({title:"Settings saved!"}),s(!1)}catch{gn({title:"Failed to save",variant:"destructive"})}finally{k(!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(Ir,{className:"truncate",children:r.property_address})]}),e.jsxs("div",{className:"space-y-6 pt-2",children:[e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(xe,{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(Er,{checked:l,onCheckedChange:i})]})}),!l&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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:C,className:"hidden"}),d?e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:[e.jsx(fn,{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:E,children:e.jsx(Sr,{className:"h-4 w-4"})})]}):e.jsx("button",{type:"button",onClick:()=>{var I;return(I=o.current)==null?void 0:I.click()},disabled:b,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:b?e.jsx(_s,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx($a,{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(xe,{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(Er,{checked:y,onCheckedChange:_})]})}),e.jsx(b3s,{openHouseId:r.id,enableSurvey:p,onToggleSurvey:x}),e.jsx(K,{onClick:L,disabled:w,className:"w-full",children:w?"Saving...":"Save Settings"})]})]})})}const Nct={5:"Excellent",4:"Good",3:"Neutral",2:"Bad",1:"Very Bad"};function j3s({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:Nct[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 N3s({openHouseId:t}){const{data:s,isLoading:r}=Ukt(t),{data:n}=gWe(t),a=S.useMemo(()=>{const x={};return n==null||n.forEach(y=>{x[y.id]=y}),x},[n]);if(r||!s)return null;const{questions:o,responses:l}=s;if(o.length===0)return null;const i=o.filter(x=>x.question_type==="rating"),d=o.filter(x=>x.question_type!=="rating"),u=[...new Set(l.map(x=>x.visitor_id))],p=u.length;return p===0?e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(wb,{className:"h-4 w-4"}),"Survey Results"]})}),e.jsx(Re,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No survey responses yet."})})]}):e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(wb,{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(Re,{children:e.jsxs(ia,{defaultValue:"summary",children:[e.jsxs(ea,{className:"mb-4",children:[e.jsxs(ls,{value:"summary",className:"text-xs gap-1",children:[e.jsx(to,{className:"h-3.5 w-3.5"})," Summary"]}),e.jsxs(ls,{value:"individual",className:"text-xs gap-1",children:[e.jsx(Ti,{className:"h-3.5 w-3.5"})," Per Visitor"]})]}),e.jsxs(js,{value:"summary",className:"space-y-6",children:[i.map(x=>e.jsx(j3s,{question:x,responses:l},x.id)),d.map(x=>{const y=l.filter(_=>_.question_id===x.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:x.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)})})]},x.id)})]}),e.jsx(js,{value:"individual",className:"space-y-4",children:u.map(x=>{const y=a[x],_=l.filter(b=>b.visitor_id===x);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?Nct[b.rating_value]||b.rating_value:b.text_value})]},b.id):null})})]},x)})})]})})]})}const e2e="guestbook.relevelup.com";function k3s(){const{data:t,isLoading:s}=Rkt(),r=Okt(),n=yWe(),a=Fkt(),[o,l]=S.useState(!1),[i,d]=S.useState(null),{user:u}=Fs(),p=ja(),[x,y]=S.useState(null),[_,b]=S.useState(null),[N,w]=S.useState(!1),k=S.useRef(null),[C,E]=S.useState({property_address:"",city:"",state:"",zip:"",event_date:ps(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),L=q=>{var U;const $=(U=q.target.files)==null?void 0:U[0];if($){if($.size>5*1024*1024){gn({title:"Photo must be under 5MB",variant:"destructive"});return}y($),b(URL.createObjectURL($))}},I=()=>{y(null),b(null),k.current&&(k.current.value="")},O=async()=>{if(!C.property_address){gn({title:C.event_type==="community"?"Event name is required":"Address is required",variant:"destructive"});return}let q;if(x&&u){w(!0);const $=x.name.split(".").pop(),U=`${p}/${Date.now()}.${$}`,{error:se}=await G.storage.from("open-house-photos").upload(U,x,{upsert:!0});if(se){gn({title:"Photo upload failed",description:se.message,variant:"destructive"}),w(!1);return}const{data:Y}=G.storage.from("open-house-photos").getPublicUrl(U);q=Y.publicUrl,w(!1)}await r.mutateAsync({...C,photo_url:q}),l(!1),E({property_address:"",city:"",state:"",zip:"",event_date:ps(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),I()},V=q=>{navigator.clipboard.writeText(`https://${e2e}/${q}`),gn({title:"Link copied!"})};return e.jsxs(Es,{title:"Guest Book",children:[e.jsx(wc,{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(pi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Us,{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(Ir,{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:()=>E(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:()=>E(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(xe,{children:C.event_type==="community"?"Event Name *":"Property Address *"}),e.jsx(De,{value:C.property_address,onChange:q=>E($=>({...$,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(xe,{children:"City"}),e.jsx(De,{value:C.city,onChange:q=>E($=>({...$,city:q.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"State"}),e.jsx(De,{value:C.state,onChange:q=>E($=>({...$,state:q.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"ZIP"}),e.jsx(De,{value:C.zip,onChange:q=>E($=>({...$,zip:q.target.value})),placeholder:"78701"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Date"}),e.jsx(De,{type:"date",value:C.event_date,onChange:q=>E($=>({...$,event_date:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Start Time"}),e.jsx(De,{type:"time",value:C.start_time,onChange:q=>E($=>({...$,start_time:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"End Time"}),e.jsx(De,{type:"time",value:C.end_time,onChange:q=>E($=>({...$,end_time:q.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Welcome Message"}),e.jsx(vr,{value:C.agent_greeting,onChange:q=>E($=>({...$,agent_greeting:q.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(xe,{children:C.event_type==="community"?"Event Photo":"Property Photo"}),e.jsx("input",{ref:k,type:"file",accept:"image/*",onChange:L,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:I,className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white rounded-full p-1 transition-colors",children:e.jsx(Sr,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var q;return(q=k.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(Yv,{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(Pe,{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(S3s,{openHouse:q,isExpanded:i===q.id,onToggle:()=>d(i===q.id?null:q.id),onCopyLink:()=>V(q.slug||""),onToggleActive:()=>n.mutate({id:q.id,is_active:!q.is_active}),onDelete:()=>a.mutate(q.id)},q.id))}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(Re,{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(Xy,{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(Us,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function S3s({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=gWe(s?t.id:void 0),{data:i}=gt({queryKey:["agent-profile-flyer",t.agent_id],queryFn:async()=>{const{data:I,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 V=I.brokerages;return{...I,brokerage_name:(V==null?void 0:V.name)||null}},enabled:!!t.agent_id}),[d,u]=S.useState(!1),[p,x]=S.useState(!1),[y,_]=S.useState(!1),b=S.useRef(null),N=`https://${e2e}/${t.slug}`,w=I=>{if(!I)return"";const[O,V]=I.split(":"),q=parseInt(O),$=q>=12?"PM":"AM";return`${q>12?q-12:q||12}:${V} ${$}`},k=()=>{if(!(l!=null&&l.length))return;const I=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],O=l.map(se=>[se.first_name,se.last_name||"",se.email||"",se.phone||"",se.visitor_intent||"",se.wants_market_updates?"Yes":"No",(se.message||"").replace(/"/g,'""'),ps(new Date(se.created_at),"MM/dd/yyyy h:mm a")]),V=[I,...O].map(se=>se.map(Y=>`"${Y}"`).join(",")).join(` `),q=new Blob([V],{type:"text/csv"}),$=URL.createObjectURL(q),U=document.createElement("a");U.href=$,U.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,U.click(),URL.revokeObjectURL($)},C=S.useCallback(()=>{if(!b.current)return;const I=b.current.querySelector("svg");if(!I)return;const O=new XMLSerializer().serializeToString(I),V=document.createElement("canvas");V.width=1024,V.height=1024;const q=V.getContext("2d"),$=new Image;$.onload=()=>{q==null||q.drawImage($,0,0,1024,1024);const U=document.createElement("a");U.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-qr.png`,U.href=V.toDataURL("image/png"),U.click()},$.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O)))},[t.property_address]),E=S.useCallback(()=>{var ve;if(!b.current)return;const I=b.current.querySelector("svg");if(!I)return;const O=new XMLSerializer().serializeToString(I),V="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O))),q=ps(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):""}`:"",U=[t.city,t.state].filter(Boolean).join(", "),se=t.agent_greeting||"Welcome! Please sign in below.",Y=!!t.photo_url,J=!!i,X=Y||J,ce=Y&&J,ie=ce?"0.35in 0.75in 0.3in":"0.55in 0.75in 0.45in",ae=ce?"28px":"34px",oe=ce?"0.2in 0.75in":X?"0.3in 0.75in":"0.4in 0.75in",pe=X?"0.15in":"0.3in",_e=X?"0.15in":"0.3in",he=ce?"14px 36px":"22px 44px",we=ce?"20px":"24px",je=X?"0.2in":"0.35in",Ue=ce?"1.8in":"2.4in",Te=X?"0.15in":"0.3in",Me=ce?"140px":X?"160px":"200px",Fe=ce?"16px":"24px",Le=ce?"10px 20px":"16px 28px",Ne=ce?"44px":"56px",qe="0.15in",ze=window.open("","_blank");ze&&(ze.document.write(` Open House – ${t.property_address}
${t.event_type==="community"?"Community Event":"Open House"}
${t.property_address}
${U?`
${U}${t.zip?" "+t.zip:""}
`:""}
Date
${q}
${$?`
Time
${$}
`:""}
${se}
${i?`
${i.avatar_url?`${i.name}`:`
${((ve=i.name)==null?void 0:ve.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
`),ze.document.close(),setTimeout(()=>{ze.focus(),ze.print()},500))},[t,N,i]),L=async()=>{_(!0);try{const{error:I}=await G.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(I)throw I;gn({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(I){gn({title:"Failed to send",description:I.message,variant:"destructive"})}finally{_(!1)}};return e.jsxs(Pe,{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(Ot,{className:"text-base leading-snug break-words",children:t.property_address}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 flex-wrap",children:[e.jsx(Qe,{variant:t.is_active?"default":"secondary",className:"shrink-0 text-[11px]",children:t.is_active?"Active":"Inactive"}),t.agent_name&&e.jsxs(Qe,{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(Ti,{className:"h-3 w-3"}),t.agent_name]}),t.event_type==="community"&&e.jsxs(Qe,{variant:"outline",className:"shrink-0 gap-1 text-[11px]",children:[e.jsx(pa,{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(nf,{className:"h-4 w-4"}):e.jsx(Oi,{className:"h-4 w-4"})})]}),e.jsxs(hr,{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(Da,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ps(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(ln,{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(lr,{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(Xy,{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(Jv,{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(Xy,{className:"h-3.5 w-3.5"}),"QR"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>x(!0),title:"Settings",className:"shrink-0 h-8 text-xs",children:e.jsx(ko,{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(mp,{className:"h-3.5 w-3.5"}):e.jsx(wn,{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(gr,{className:"h-3.5 w-3.5"})})]})]})}),s&&e.jsxs(Re,{className:"pt-0",children:[e.jsx(wo,{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://",e2e,"/",t.slug]})]}),l!=null&&l.length?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:[l.length," Visitor",l.length!==1?"s":""]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:k,className:"h-7 text-xs gap-1",children:[e.jsx(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(I=>e.jsxs("tr",{className:"border-t border-border/50",children:[e.jsxs("td",{className:"p-2 font-medium",children:[I.first_name,I.last_name?` ${I.last_name}`:""]}),e.jsxs("td",{className:"p-2 text-muted-foreground hidden sm:table-cell",children:[I.email&&e.jsx("div",{className:"truncate max-w-[180px]",children:I.email}),I.phone&&e.jsx("div",{className:"text-xs",children:I.phone})]}),e.jsx("td",{className:"p-2 hidden md:table-cell",children:I.visitor_intent?e.jsx(Qe,{variant:"outline",className:"text-xs capitalize",children:I.visitor_intent}):I.partial_signin?e.jsx(Qe,{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:ps(new Date(I.created_at),"h:mm a")})]},I.id))})]})})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No visitors yet. Share the link to start collecting sign-ins!"}),t.enable_survey&&e.jsx("div",{className:"mt-4",children:e.jsx(N3s,{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(Ir,{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(CO,{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:E,children:[e.jsx(CL,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(K,{variant:"default",className:"w-full",onClick:L,disabled:y,children:[e.jsx(rr,{className:"h-4 w-4 mr-2"}),y?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(w3s,{open:p,onOpenChange:x,openHouse:t})]})}function C3s(){const{slug:t}=co();return t?e.jsx(UZe,{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 kct({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=Fs(),l=MC(),i=S.useRef(null),d=S.useRef(null),[u,p]=S.useState(!1),[x,y]=S.useState(!1),[_,b]=S.useState(0),N=async k=>{if(o){p(!0);try{const C=k.name.split(".").pop()||"jpg",E=`${o.id}/card-${Date.now()}.${C}`,{error:L}=await G.storage.from("listing-photos").upload(E,k);if(L)throw L;const{data:{publicUrl:I}}=G.storage.from("listing-photos").getPublicUrl(E);r(I),me.success("Photo uploaded")}catch(C){me.error(C.message||"Failed to upload photo")}finally{p(!1)}}},w=async k=>{if(o){if(k.size>500*1024*1024){me.error("Video must be under 500MB");return}y(!0),b(0);try{const{videoId:C,libraryId:E}=await xO(`Card Video - ${Date.now()}`),{uploadUrl:L,apiKey:I}=await gO(C);await new Promise((q,$)=>{const U=new XMLHttpRequest;U.upload.addEventListener("progress",se=>{se.lengthComputable&&b(Math.round(se.loaded/se.total*100))}),U.addEventListener("load",()=>{U.status>=200&&U.status<300?q():$(new Error("Upload failed"))}),U.addEventListener("error",()=>$(new Error("Upload failed"))),U.open("PUT",L),U.setRequestHeader("AccessKey",I),U.send(k)});const O=`https://iframe.mediadelivery.net/embed/${E}/${C}`;n(O);const V=parseFloat((k.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:C,playback_url:`https://iframe.mediadelivery.net/play/${E}/${C}`,file_size_mb:V,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(xe,{children:"Media (optional)"}),e.jsxs(ia,{defaultValue:"photo",className:"w-full",children:[e.jsxs(ea,{className:"grid w-full grid-cols-2",children:[e.jsxs(ls,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(Wo,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(ls,{value:"video",className:"gap-1.5 text-xs",children:[e.jsx(Tn,{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 k;return(k=i.current)==null?void 0:k.click()},disabled:u,className:"w-full h-32 border-2 border-dashed border-border rounded-lg flex flex-col items-center justify-center gap-2 text-muted-foreground hover:border-primary/40 hover:bg-accent/50 transition-colors",children:u?e.jsx(_s,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(xx,{className:"h-6 w-6"}),e.jsx("span",{className:"text-xs",children:"Upload a photo"})]})}),e.jsx("input",{ref:i,type:"file",accept:"image/*",className:"hidden",onChange:k=>{var E;const C=(E=k.target.files)==null?void 0:E[0];C&&N(C),k.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 k;return(k=d.current)==null?void 0:k.click()},disabled:x,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:x?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(_s,{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($a,{className:"h-6 w-6"}),e.jsx("span",{className:"text-xs",children:"Upload a video (max 500MB)"})]})}),!s&&!x&&e.jsx("div",{className:"mt-2",children:e.jsx(OCe,{contactId:a,onVideoReady:k=>n(k)})}),e.jsx("input",{ref:d,type:"file",accept:"video/*",className:"hidden",onChange:k=>{var E;const C=(E=k.target.files)==null?void 0:E[0];C&&w(C),k.target.value=""}}),e.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1.5 text-center",children:"Videos are also saved to your Video Library"})]})]})]})}const M3s=[{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 T3s({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:M3s.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 PE={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 I9e({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Fs(),d=Jt(),[u,p]=S.useState(!1),[x,y]=S.useState("type"),[_,b]=S.useState(""),[N,w]=S.useState(null),[k,C]=S.useState(!1),[E,L]=S.useState("home_anniversary"),[I,O]=S.useState(""),[V,q]=S.useState(""),[$,U]=S.useState(""),[se,Y]=S.useState(""),[J,X]=S.useState("elegant"),[ce,ie]=S.useState(null),[ae,oe]=S.useState(null),pe=S.useState(!1);!pe[0]&&t&&s&&(pe[1](!0),p(!0),L(s),r&&w(r),n&&O(n),a&&q(a),o&&U(o),y(n?"details":"contact"));const{data:_e}=gt({queryKey:["contacts-for-card",i==null?void 0:i.id,_],queryFn:async()=>{let qe=G.from("innercircle_contacts").select("id, first_name, last_name, address, city, state, home_anniversary, email, phone").eq("owner_user_id",i.id).order("first_name").limit(20);_&&(qe=qe.or(`first_name.ilike.%${_}%,last_name.ilike.%${_}%`));const{data:ze,error:ve}=await qe;if(ve)throw ve;return ze},enabled:!!(i!=null&&i.id)&&u}),{data:he}=gt({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:qe,error:ze}=await G.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(ze)throw ze;return qe},enabled:!!(i!=null&&i.id)}),we=qe=>{w(qe.id),O(`${qe.first_name}${qe.last_name?" "+qe.last_name:""}`),q([qe.address,qe.city,qe.state].filter(Boolean).join(", ")),U(qe.home_anniversary||""),y("details")},je=qe=>{L(qe),y("contact")},Ue=async()=>{var qe;if(!(!i||!he)){C(!0);try{const ze={owner_user_id:i.id,contact_id:N,card_type:E,template:J,recipient_name:I,property_address:V||null,home_anniversary_date:$||null,custom_message:se||null,property_photo_url:ce||null,video_url:ae||null,agent_name:he.name||"Agent",agent_photo_url:he.avatar_url,agent_phone:he.phone,agent_email:he.email,agent_brokerage:((qe=he.brokerage)==null?void 0:qe.name)||null},{error:ve}=await G.from("sendable_cards").insert(ze);if(ve)throw ve;me.success("Card created! Copy the link to share it."),d.invalidateQueries({queryKey:["sendable-cards"]}),Te()}catch(ze){me.error(ze.message||"Failed to create card")}finally{C(!1)}}},Te=()=>{p(!1),y("type"),L("home_anniversary"),b(""),w(null),O(""),q(""),U(""),Y(""),X("elegant"),ie(null),oe(null)},Me={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"},Fe=PE[E],Le=E==="home_anniversary",Ne=["home_anniversary","just_listed","just_sold"].includes(E);return e.jsxs(fs,{open:u,onOpenChange:qe=>{qe?p(!0):(Te(),l==null||l(!1))},children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Us,{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:x==="type"?"What type of card?":x==="contact"?`${Me[E]} — Choose a Contact`:`${Me[E]} — Customize`})}),x==="type"&&e.jsx(T3s,{onSelect:je}),x==="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(Fa,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search contacts...",value:_,onChange:qe=>b(qe.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[_e==null?void 0:_e.map(qe=>e.jsxs("button",{onClick:()=>we(qe),className:"w-full flex items-center gap-3 p-3 rounded-lg hover:bg-accent text-left transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Ti,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[qe.first_name," ",qe.last_name]}),qe.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(Mn,{className:"h-3 w-3"}),qe.address]})]}),qe.home_anniversary&&E==="home_anniversary"&&e.jsx("span",{className:"text-[10px] text-emerald-600 bg-emerald-500/10 px-2 py-0.5 rounded-full shrink-0",children:"Anniversary set"})]},qe.id)),(_e==null?void 0:_e.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"})})]}),x==="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(Fa,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Recipient Name"}),e.jsx(De,{value:I,onChange:qe=>O(qe.target.value),placeholder:"John & Jane Smith"})]}),Ne&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Property Address"}),e.jsx(De,{value:V,onChange:qe=>q(qe.target.value),placeholder:"123 Main St, Austin, TX"})]}),Le&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Home Anniversary Date"}),e.jsx(De,{type:"date",value:$,onChange:qe=>U(qe.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Personal Message (optional)"}),e.jsx(vr,{value:se,onChange:qe=>Y(qe.target.value),placeholder:Fe.defaultMessage,rows:3})]}),e.jsx(kct,{photoUrl:ce,videoUrl:ae,onPhotoChange:ie,onVideoChange:oe,contactId:N}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-5 gap-2",children:[{key:"elegant",label:"Elegant",gradient:"bg-gradient-to-br from-slate-100 to-blue-100 dark:from-slate-800 dark:to-slate-700"},{key:"bold",label:"Bold",gradient:"bg-gradient-to-br from-violet-500 to-fuchsia-500"},{key:"warm",label:"Warm",gradient:"bg-gradient-to-br from-amber-200 to-orange-300"},{key:"glass",label:"Glass",gradient:"bg-gradient-to-br from-slate-900 via-blue-900/50 to-slate-900 border border-white/10"},{key:"cinematic",label:"Cinema",gradient:"bg-gradient-to-br from-slate-950 via-blue-950 to-slate-950"}].map(({key:qe,label:ze,gradient:ve})=>e.jsxs("button",{onClick:()=>X(qe),className:`p-2 rounded-lg border-2 transition-all text-center ${J===qe?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-10 rounded-md mb-1.5 ${ve}`}),e.jsx("span",{className:"text-[10px] font-medium",children:ze})]},qe))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>y("contact"),className:"flex-1",children:"Back"}),e.jsx(K,{onClick:Ue,disabled:!I||k,className:"flex-1 gap-2",children:k?"Creating...":"Create Card"})]})]})]})]})}const A3s={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 E3s({card:t}){Fs();const{isGmailConnected:s}=jp(),r=Jt(),[n,a]=S.useState(!1),[o,l]=S.useState("");S.useEffect(()=>{n&&t.contact_id&&!o&&G.from("innercircle_contacts").select("email").eq("id",t.contact_id).maybeSingle().then(({data:b})=>{b!=null&&b.email&&l(b.email)})},[n,t.contact_id]);const i={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}!`},[d,u]=S.useState(i[t.card_type]||`A Special Card for ${t.recipient_name}!`),[p,x]=S.useState(""),y=`https://cardstudio.relevelup.com/c/${t.share_token}`,_=It({mutationFn:async()=>{var C;if(!o)throw new Error("Recipient email is required");const b=`
${p?`

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


`:""}

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

${t.property_address?`

${t.property_address}

`:""}
`,{data:N}=await G.auth.getSession(),w=(C=N==null?void 0:N.session)==null?void 0:C.access_token,k=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/gmail-send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${w}`},body:JSON.stringify({to:o,subject:d,body:b,contactId:t.contact_id||void 0})});if(!k.ok){const E=await k.json();throw new Error(E.error||"Failed to send")}return k.json()},onSuccess:async()=>{await G.from("sendable_cards").update({sent_at:new Date().toISOString(),sent_via:"gmail"}).eq("id",t.id),r.invalidateQueries({queryKey:["sendable-cards"]}),me.success(`Card sent to ${o}!`),a(!1)},onError:b=>{me.error(b.message||"Failed to send email")}});return s?e.jsxs(fs,{open:n,onOpenChange:a,children:[e.jsx(pi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(An,{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(xe,{children:"To"}),e.jsx(De,{type:"email",value:o,onChange:b=>l(b.target.value),placeholder:"recipient@email.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Subject"}),e.jsx(De,{value:d,onChange:b=>u(b.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Personal Note (optional)"}),e.jsx(vr,{value:p,onChange:b=>x(b.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:y})]}),e.jsx(K,{onClick:()=>_.mutate(),disabled:!o||_.isPending,className:"w-full gap-2",children:_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(An,{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(An,{className:"h-3 w-3"})})}function P3s({card:t}){const s=Jt(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(t.recipient_name),[d,u]=S.useState(t.property_address||""),[p,x]=S.useState(t.home_anniversary_date||""),[y,_]=S.useState(t.custom_message||""),[b,N]=S.useState(t.template),[w,k]=S.useState(t.property_photo_url),[C,E]=S.useState(t.video_url||null),L=O=>{O&&(i(t.recipient_name),u(t.property_address||""),x(t.home_anniversary_date||""),_(t.custom_message||""),N(t.template),k(t.property_photo_url),E(t.video_url||null)),n(O)},I=async()=>{if(!l.trim()){me.error("Recipient name is required");return}o(!0);try{const{error:O}=await 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:L,children:[e.jsx(pi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(ga,{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(xe,{children:"Recipient Name"}),e.jsx(De,{value:l,onChange:O=>i(O.target.value),placeholder:"John & Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Property Address"}),e.jsx(De,{value:d,onChange:O=>u(O.target.value),placeholder:"123 Main St, Austin, TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Home Anniversary Date"}),e.jsx(De,{type:"date",value:p,onChange:O=>x(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Personal Message (optional)"}),e.jsx(vr,{value:y,onChange:O=>_(O.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(kct,{photoUrl:w,videoUrl:C,onPhotoChange:k,onVideoChange:E,contactId:t.contact_id}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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:I,disabled:!l.trim()||a,className:"w-full gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function I3s(){const{user:t}=Fs(),s=Jt(),[r,n]=S.useState(""),[a,o]=Nc(),l=a.get("cardType"),i=a.get("contactId"),d=a.get("name"),u=a.get("address"),p=a.get("date"),x=!!l,{data:y,isLoading:_}=gt({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:E,error:L}=await G.from("sendable_cards").select("*").eq("owner_user_id",t.id).order("created_at",{ascending:!1});if(L)throw L;return E},enabled:!!(t!=null&&t.id)}),b=It({mutationFn:async E=>{const{error:L}=await G.from("sendable_cards").delete().eq("id",E);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),me.success("Card deleted")}}),N=E=>{const L=`https://cardstudio.relevelup.com/c/${E}`;navigator.clipboard.writeText(L),me.success("Share link copied!")},w=y==null?void 0:y.filter(E=>{var L;return!r||E.recipient_name.toLowerCase().includes(r.toLowerCase())||((L=E.property_address)==null?void 0:L.toLowerCase().includes(r.toLowerCase()))}),k={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(Es,{title:"Card Studio",children:e.jsxs("div",{className:"max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Card Studio"})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Create & send beautiful branded cards to your clients"})]}),e.jsx(I9e,{initialOpen:x,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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search cards...",value:r,onChange:E=>n(E.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(E=>e.jsx(Pe,{className:"animate-pulse",children:e.jsxs(Re,{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"})]})},E))}):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(E=>e.jsxs(Pe,{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 ${E.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":E.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:[E.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"})]}),E.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%)]"})]}),E.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:E.card_type==="home_anniversary"?"🏡":E.card_type==="birthday"?"🎂":E.card_type==="just_sold"?"🎉":E.card_type==="just_listed"?"🏠":E.card_type==="thank_you"?"💐":E.card_type==="congratulations"?"🏆":E.card_type==="holiday"?"🎄":E.card_type==="thinking_of_you"?"💭":"✉️"}),e.jsx("p",{className:`text-[10px] uppercase tracking-[0.2em] mb-1 ${E.template==="bold"?"text-white/70":"text-muted-foreground"}`,children:C[E.card_type]||E.card_type}),e.jsx("p",{className:`font-semibold text-base ${E.template==="bold"?"text-white":"text-foreground"}`,children:E.recipient_name}),E.property_address&&e.jsx("p",{className:`text-xs mt-1 ${E.template==="bold"?"text-white/60":"text-muted-foreground"}`,children:E.property_address})]}),e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(Qe,{variant:E.template==="bold"?"outline":"secondary",className:`text-[10px] ${E.template==="bold"?"border-white/30 text-white/80":""}`,children:k[E.template]||E.template})})]}),e.jsxs(Re,{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(wn,{className:"h-3 w-3"}),E.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:gl(new Date(E.created_at),{addSuffix:!0})})]}),E.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",ps(new Date(E.sent_at),"MMM d, yyyy")," via ",E.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(E.share_token),children:[e.jsx(Ya,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(P3s,{card:E}),e.jsx(E3s,{card:E}),e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${E.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(E.id),children:e.jsx(gr,{className:"h-3 w-3"})})]})]})]},E.id))}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(Re,{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(rr,{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(I9e,{initialOpen:x,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]})})]})})}function vI({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 L3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:x,videoUrl:y}=t,_=PE[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(vI,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(vI,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(vI,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(vI,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(vI,{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"}}),x&&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:x,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(Pn,{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(rr,{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 b0e({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 _I({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 L9e={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 D3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:x,videoUrl:y}=t,_=PE[s],b=L9e[s]||L9e.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(b0e,{delay:0,x:"10%",y:"10%",color:b.orbs[0],size:200}),e.jsx(b0e,{delay:1,x:"70%",y:"60%",color:b.orbs[1],size:180}),e.jsx(b0e,{delay:2,x:"50%",y:"20%",color:b.orbs[2],size:150}),e.jsx(_I,{delay:0,x:"20%",y:"25%"}),e.jsx(_I,{delay:.8,x:"75%",y:"15%"}),e.jsx(_I,{delay:1.6,x:"85%",y:"65%"}),e.jsx(_I,{delay:2.4,x:"10%",y:"75%"}),e.jsx(_I,{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]})]}),x&&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:x,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(Pn,{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(rr,{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 R3s({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 D9e={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 O3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:x,videoUrl:y}=t,_=PE[s],b=D9e[s]||D9e.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(R3s,{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(Da,{className:"h-3 w-3"}),n]})]}),x&&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:x,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(Pn,{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(rr,{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 M9({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 w0e({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 R9e={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 F3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:x,videoUrl:y}=t,_=PE[s],b=R9e[s]||R9e.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(M9,{delay:0,x:"5%",y:"10%",size:300,color:b.mesh[0]}),e.jsx(M9,{delay:2,x:"60%",y:"50%",size:250,color:b.mesh[1]}),e.jsx(M9,{delay:4,x:"30%",y:"70%",size:200,color:b.mesh[2]}),e.jsx(M9,{delay:1,x:"80%",y:"15%",size:180,color:b.mesh[0]}),e.jsx(w0e,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(w0e,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(w0e,{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(Da,{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"}}),x&&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:x,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(Pn,{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(rr,{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 j0e({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 T9({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 O9e={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 z3s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:x,videoUrl:y}=t,_=PE[s],b=O9e[s]||O9e.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(j0e,{delay:0,x:"20%",angle:15,color:b.stripe}),e.jsx(j0e,{delay:2,x:"75%",angle:-12,color:b.stripe}),e.jsx(j0e,{delay:4,x:"50%",angle:5,color:b.stripe}),e.jsx(T9,{delay:0,x:"30%"}),e.jsx(T9,{delay:1.5,x:"60%"}),e.jsx(T9,{delay:3,x:"45%"}),e.jsx(T9,{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(Da,{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"}})]}),x&&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:x,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(Pn,{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(rr,{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 Sct(){const{shareToken:t}=co(),{data:s,isLoading:r,error:n}=gt({queryKey:["public-sendable-card",t],queryFn:async()=>{const{data:l,error:i}=await G.from("sendable_cards").select("*").eq("share_token",t).single();if(i)throw i;return l},enabled:!!t});if(S.useEffect(()=>{t&&G.rpc("log_sendable_card_view",{p_share_token:t}).then(({error:l})=>{l&&console.error("Error tracking view:",l)})},[t]),r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"animate-pulse space-y-4 text-center",children:[e.jsx("div",{className:"h-8 w-48 bg-muted rounded mx-auto"}),e.jsx("div",{className:"h-4 w-32 bg-muted rounded mx-auto"})]})});if(n||!s)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Card not found"}),e.jsx("p",{className:"text-muted-foreground",children:"This card may have been removed or the link is invalid."})]})});const a=s.home_anniversary_date?Math.floor((Date.now()-ml(s.home_anniversary_date).getTime())/(365.25*24*60*60*1e3)):null,o={cardType:s.card_type||"home_anniversary",recipientName:s.recipient_name,propertyAddress:s.property_address,anniversaryYears:a,customMessage:s.custom_message,agentName:s.agent_name,agentPhotoUrl:s.agent_photo_url,agentPhone:s.agent_phone,agentEmail:s.agent_email,agentBrokerage:s.agent_brokerage,propertyPhotoUrl:s.property_photo_url,videoUrl:s.video_url||null};switch(s.template){case"bold":return e.jsx(D3s,{...o});case"warm":return e.jsx(O3s,{...o});case"glass":return e.jsx(F3s,{...o});case"cinematic":return e.jsx(z3s,{...o});case"elegant":default:return e.jsx(L3s,{...o})}}function B3s(){const t=ja();return gt({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 $3s(){const t=ja(),s=Jt();return It({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 q3s(){const t=_r(),{isGmailConnected:s,gmailEmail:r}=jp(),{data:n,isLoading:a}=B3s(),o=$3s(),[l,i]=S.useState(!1),[d,u]=S.useState(!0),[p,x]=S.useState(!1);S.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:x,children:[e.jsx(pi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(ko,{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(ko,{className:"h-5 w-5 text-primary"}),"Smart Drip Settings"]}),e.jsx(Ir,{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(rr,{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(Qe,{variant:"outline",className:"gap-1 text-emerald-600 border-emerald-200 bg-emerald-500/10 text-[10px]",children:[e.jsx(Qn,{className:"h-3 w-3"}),"Active"]}):e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs gap-1",onClick:()=>{x(!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(wo,{}),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(SL,{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(Er,{checked:l,onCheckedChange:y,disabled:a||o.isPending})]}),e.jsx(wo,{}),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(Dy,{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(Er,{checked:d,onCheckedChange:_,disabled:a||o.isPending})]}),d&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>{x(!1),t("/profile")},children:[e.jsx(Dy,{className:"h-3 w-3 mr-1"}),"Edit your email signature in Profile settings"]})]})]})]})}function U3s(){const t=ja();return gt({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 V3s(){const t=ja();return gt({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 H3s(){const t=ja(),s=Jt();return It({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 G3s(){const t=Jt();return It({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 W3s(){const t=Jt();return It({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 K3s(){const t=ja(),s=Jt();return It({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 Z3s=[{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 Y3s({open:t,onOpenChange:s,campaignId:r,campaignName:n}){const{data:a,isLoading:o}=F_s(r||void 0),l=B_s(),i=Hat(),d=async(x,y)=>{try{await l.mutateAsync({id:x,status:y}),me.success(`Enrollment ${y}`)}catch{me.error("Failed to update")}},u=async x=>{if(r)try{const y=await i.mutateAsync({campaignId:r,contactIds:[x]});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=x=>{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(Qe,{variant:"outline",className:`text-[10px] capitalize ${y[x]||""}`,children:x})};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(lr,{className:"h-4 w-4 text-primary"}),"Enrollments — ",n||"Campaign"]}),e.jsx(Ir,{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(x=>e.jsx(Ns,{className:"h-14"},x))}):!a||a.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(lr,{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(x=>{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=x.contact)==null?void 0:y.first_name," ",(_=x.contact)==null?void 0:_.last_name]}),p(x.status)]}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground mt-0.5",children:[((b=x.contact)==null?void 0:b.email)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(rr,{className:"h-2.5 w-2.5"})," ",x.contact.email]}),e.jsxs("span",{children:["Step ",x.current_step]}),x.next_send_at&&x.status==="active"&&e.jsxs("span",{children:["Next: ",ps(new Date(x.next_send_at),"MMM d, h:mma")]}),x.exit_reason&&e.jsxs("span",{children:["Exit: ",x.exit_reason]})]})]}),x.status==="active"&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>d(x.id,"paused"),title:"Pause",children:e.jsx(uh,{className:"h-3.5 w-3.5"})}),x.status==="paused"&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>d(x.id,"active"),title:"Resume",children:e.jsx(So,{className:"h-3.5 w-3.5"})}),(x.status==="active"||x.status==="paused")&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>d(x.id,"exited"),title:"Exit",children:e.jsx(Sr,{className:"h-3.5 w-3.5 text-destructive"})}),(x.status==="exited"||x.status==="completed")&&((N=x.contact)==null?void 0:N.id)&&e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-[11px] gap-1",onClick:()=>u(x.contact.id),disabled:i.isPending,children:[e.jsx(Jy,{className:"h-3 w-3"}),"Re-enroll"]})]},x.id)})})})})]})})}function X3s(){var C;const{data:t,isLoading:s}=DSe(),r=L_s(),n=I_s(),a=Uat(),[o,l]=S.useState(null),[i,d]=S.useState(!1),[u,p]=S.useState(null),[x,y]=S.useState(null),_=(t||[]).filter(E=>!E.is_starter),b=(t||[]).filter(E=>E.is_starter),N=async E=>{try{await r.mutateAsync(E),me.success("Campaign added to your library — customize and activate it!"),l(null)}catch(L){me.error(L.message||"Failed to copy campaign")}},w=async E=>{try{await a.mutateAsync({id:E.id,is_active:!E.is_active}),me.success(E.is_active?"Campaign paused":"Campaign activated")}catch{me.error("Failed to update")}},k=async E=>{if(confirm("Delete this campaign? Active enrollments will be removed."))try{await n.mutateAsync(E),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(E=>e.jsx(Ns,{className:"h-44 rounded-xl"},E))}):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(Q4,{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(Rh,{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(An,{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(lr,{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(Us,{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($r,{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(Us,{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(E=>e.jsx(Q3s,{campaign:E,onPreview:()=>l(E.id),onToggleActive:()=>w(E),onDelete:()=>k(E.id),onEdit:()=>{p(E.id),d(!0)},onViewEnrollments:()=>y(E.id)},E.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($r,{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(Qe,{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(E=>e.jsx(J3s,{campaign:E,onPreview:()=>l(E.id)},E.id))})]}),e.jsx(e5s,{campaignId:o,open:!!o,onOpenChange:E=>!E&&l(null),onClone:N,isCloning:r.isPending,onEdit:E=>{l(null),p(E),d(!0)}}),e.jsx(Gat,{open:i,onOpenChange:d,campaignId:u}),e.jsx(Y3s,{open:!!x,onOpenChange:E=>!E&&y(null),campaignId:x,campaignName:(C=_.find(E=>E.id===x))==null?void 0:C.name})]})}function Q3s({campaign:t,onPreview:s,onToggleActive:r,onDelete:n,onEdit:a,onViewEnrollments:o}){const i=z_s(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(Qe,{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(Qe,{variant:"outline",className:"text-[9px] mt-2",children:Nme[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(ga,{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 J3s({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(Qe,{className:"absolute top-2 right-2 bg-white/90 text-foreground hover:bg-white text-[10px]",children:[e.jsx($r,{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(Qe,{variant:"outline",className:"text-[9px] mt-2",children:Nme[t.category]})]})]})}function e5s({campaignId:t,open:s,onOpenChange:r,onClone:n,isCloning:a,onEdit:o}){const{data:l}=DSe(),{data:i}=Vat(t||void 0),[d,u]=S.useState(new Set),p=l==null?void 0:l.find(_=>_.id===t);if(!p)return null;const x=_=>{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",k=_.anchor_offset_days||0;return k===0?`On their ${w}`:k<0?`${Math.abs(k)} days before ${w}`:`${k} 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(Ir,{className:"text-white/90 mt-1",children:p.description}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx(Qe,{className:"bg-white/20 text-white border-white/20 hover:bg-white/20",children:Nme[p.category]}),e.jsxs(Qe,{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}),bx(_.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(on,{className:"h-3 w-3"}):e.jsx(ln,{className:"h-3 w-3"}),e.jsx("span",{children:y(_,b)}),e.jsx("span",{children:"·"}),e.jsx(rr,{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(En,{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(ga,{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(_s,{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 t5s(){const t=ja(),s=_r(),{isGmailConnected:r,gmailEmail:n,isLoading:a}=jp(),{data:o,isLoading:l}=U3s(),{data:i,isLoading:d}=V3s(),u=H3s(),p=G3s(),x=W3s(),y=K3s(),[_,b]=S.useState(null),[N,w]=S.useState(null),k=(o==null?void 0:o.filter($=>!$.is_starter&&$.owner_user_id===t))||[],C=(o==null?void 0:o.filter($=>$.is_starter))||[],E=$=>k.filter(U=>U.stage_id===$),L=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")}},I=async $=>{try{const U=i==null?void 0:i.find(se=>se.id===$);await u.mutateAsync({stage_id:$,title:`${(U==null?void 0:U.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 x.mutateAsync($),me.success("Template deleted")}catch{me.error("Failed to delete")}},V=async $=>{if(!i||i.length===0){me.error("No pipeline stages found");return}const U=i[0].id;try{await y.mutateAsync({templateId:$,stageId:U}),me.success("Template copied to your drips!")}catch{me.error("Failed to copy template")}},q=l||d;return e.jsx(Es,{children:e.jsxs("div",{className:"container max-w-4xl mx-auto py-6 px-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oh,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Smart Drips"}),e.jsx(Qe,{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(q3s,{})]}),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(Q4,{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(rr,{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(Q4,{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(rr,{className:"h-3 w-3 mr-1.5"}),"Connect Gmail"]})]})]})),e.jsxs(ia,{defaultValue:"my-drips",children:[e.jsxs(ea,{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(Qe,{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(Qe,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:C.length})]})]}),e.jsx(js,{value:"campaigns",children:e.jsx(X3s,{})}),e.jsx(js,{value:"my-drips",children:q?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map($=>e.jsx(Ns,{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(Oh,{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 U=E($.id),se=_===$.id,Y=U.some(J=>J.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>b(se?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}),U.length>0&&e.jsxs(Qe,{variant:"outline",className:`text-[10px] ${Y?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[U.length," drip",U.length!==1?"s":"",Y&&" · Active"]}),se?e.jsx(Oi,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Sa,{className:"h-4 w-4 text-muted-foreground"})]}),se&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:U.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:()=>I($.id),disabled:u.isPending,children:[e.jsx(Us,{className:"h-3.5 w-3.5 mr-1.5"}),"Create Drip"]})]}):e.jsxs(e.Fragment,{children:[U.map(J=>e.jsx(F9e,{template:J,isEditing:N===J.id,onToggleEdit:()=>w(N===J.id?null:J.id),onToggleEnabled:()=>L(J),onUpdate:X=>p.mutateAsync({id:J.id,...X}),onDelete:()=>O(J.id),userId:t||""},J.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>I($.id),children:[e.jsx(Us,{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 U=E($.id),se=_===$.id,Y=U.some(J=>J.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden mb-2",children:[e.jsxs("button",{onClick:()=>b(se?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}),U.length>0&&e.jsxs(Qe,{variant:"outline",className:`text-[10px] ${Y?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[U.length," drip",U.length!==1?"s":"",Y&&" · Active"]}),se?e.jsx(Oi,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Sa,{className:"h-4 w-4 text-muted-foreground"})]}),se&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:U.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:()=>I($.id),disabled:u.isPending,children:[e.jsx(Us,{className:"h-3.5 w-3.5 mr-1.5"})," Create Drip"]})]}):e.jsxs(e.Fragment,{children:[U.map(J=>e.jsx(F9e,{template:J,isEditing:N===J.id,onToggleEdit:()=>w(N===J.id?null:J.id),onToggleEnabled:()=>L(J),onUpdate:X=>p.mutateAsync({id:J.id,...X}),onDelete:()=>O(J.id),userId:t||""},J.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>I($.id),children:[e.jsx(Us,{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($r,{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(s5s,{template:$,onCopy:()=>V($.id),isCopying:y.isPending},$.id))})})]})]})})}function F9e({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,d]=S.useState(t.title),[u,p]=S.useState(t.subject),[x,y]=S.useState(t.body),[_,b]=S.useState(t.video_url||""),[N,w]=S.useState(t.channel),[k,C]=S.useState(t.delay_type),[E,L]=S.useState(t.delay_minutes),[I,O]=S.useState(!1),V=async()=>{O(!0);try{await a({title:i,subject:u,body:x,video_url:_||null,channel:N,delay_type:k,delay_minutes:E}),me.success("Drip saved"),r()}catch{me.error("Failed to save")}finally{O(!1)}},q=$=>{y(U=>U+$)};return e.jsxs("div",{className:"border rounded-lg bg-background overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",role:"button",onClick:r,children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.title||"Untitled drip"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.channel==="sms"?e.jsx(ki,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(rr,{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(Tn,{className:"h-3 w-3 text-primary"})]})]}),e.jsx(Er,{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(xe,{className:"text-xs font-medium",children:"Title (internal)"}),e.jsx(De,{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(xe,{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(ki,{className:"h-3 w-3"}):e.jsx(rr,{className:"h-3 w-3"}),$==="sms"?"SMS":"Email"]},$))})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(xe,{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 ${k==="instant"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:"Instant"}),e.jsxs("button",{onClick:()=>C("scheduled"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${k==="scheduled"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[e.jsx(ln,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),k==="scheduled"&&e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs font-medium",children:"Delay"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(De,{type:"number",min:1,value:E>=60?Math.round(E/60):E,onChange:$=>{const U=parseInt($.target.value)||0;L(E>=60?U*60:U)},className:"h-8 w-20 text-sm"}),e.jsx("div",{className:"flex gap-1",children:[{label:"Minutes",mins:E<60?E:30},{label:"Hours",mins:E>=60?E:60},{label:"Days",mins:E>=1440?E:1440}].map($=>e.jsx("button",{className:`px-2 py-1 rounded text-xs border transition-colors ${$.label==="Minutes"&&E<60||$.label==="Hours"&&E>=60&&E<1440||$.label==="Days"&&E>=1440?"bg-primary/10 text-primary border-primary/30":"text-muted-foreground border-input"}`,onClick:()=>{$.label==="Minutes"?L(30):$.label==="Hours"?L(60):L(1440)},children:$.label},$.label))})]})]}),N==="email"&&e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs font-medium",children:"Subject Line"}),e.jsx(De,{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(xe,{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..."}),Z3s.map($=>e.jsx("option",{value:$.key,children:$.label},$.key))]})]})]}),e.jsx("textarea",{value:x,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(xe,{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(Tn,{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(OCe,{onVideoReady:$=>b($)}),e.jsx(RCe,{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(fo,{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(gr,{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:V,disabled:I,children:I?"Saving...":"Save Drip"})]})]})]})]})}function s5s({template:t,onCopy:s,isCopying:r}){const[n,a]=S.useState(!1),o=t.body.replace(/<[^>]+>/g,""),l=t.deal_type==="buyer"?"Buyer":t.deal_type==="seller"?"Seller":null,i=t.delay_type==="instant"?"Sends instantly":t.delay_minutes>=1440?`Sends after ${Math.round(t.delay_minutes/1440)} day${Math.round(t.delay_minutes/1440)!==1?"s":""}`:t.delay_minutes>=60?`Sends after ${Math.round(t.delay_minutes/60)} hour${Math.round(t.delay_minutes/60)!==1?"s":""}`:`Sends after ${t.delay_minutes} min`;return e.jsxs("div",{className:"border rounded-xl overflow-hidden transition-all hover:shadow-sm",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-start gap-3 p-4 text-left hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm",children:t.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:t.subject}),!n&&e.jsx("p",{className:"text-xs text-muted-foreground/70 line-clamp-1 mt-1",children:o})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 pt-0.5",children:[l&&e.jsx(Qe,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:l}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1",children:[t.channel==="sms"?e.jsx(ki,{className:"h-3 w-3"}):e.jsx(rr,{className:"h-3 w-3"}),t.channel==="sms"?"SMS":"Email"]}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(ln,{className:"h-3 w-3"}),t.delay_type==="instant"?"Instant":i.replace("Sends ","")]}),n?e.jsx(Oi,{className:"h-4 w-4 text-muted-foreground ml-1"}):e.jsx(Sa,{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(ln,{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 Cct=()=>{const t=Ol();return S.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",t.pathname)},[t.pathname]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-100",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),e.jsx("p",{className:"mb-4 text-xl text-gray-600",children:"Oops! Page not found"}),e.jsx("a",{href:"/",className:"text-blue-500 underline hover:text-blue-700",children:"Return to Home"})]})})};function r5s(){return S.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs($oe,{children:[e.jsx(ys,{path:"/c/:shareToken",element:e.jsx(Sct,{})}),e.jsx(ys,{path:"*",element:e.jsx(Cct,{})})]})}const N0e={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function Mct({slugOverride:t}){const s=co(),r=t||s.slug,[n,a]=S.useState("types"),[o,l]=S.useState(null),[i,d]=S.useState(null),[u,p]=S.useState(null),[x,y]=S.useState(new Date),[_,b]=S.useState({name:"",email:"",phone:"",message:""}),[N,w]=S.useState(!1),{data:k,isLoading:C}=gt({queryKey:["public-booking-settings",r],queryFn:async()=>{const{data:X,error:ce}=await G.from("agent_booking_settings").select("*").eq("slug",r).eq("is_active",!0).single();if(ce)throw ce;return X},enabled:!!r}),{data:E}=gt({queryKey:["public-booking-profile",k==null?void 0:k.user_id],queryFn:async()=>{const{data:X,error:ce}=await G.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",k.user_id).single();if(ce)throw ce;return X},enabled:!!(k!=null&&k.user_id)}),{data:L=[]}=gt({queryKey:["public-booking-types",k==null?void 0:k.user_id],queryFn:async()=>{const{data:X,error:ce}=await G.from("agent_booking_types").select("id, name, description, duration_minutes, color, icon, qualification_enabled").eq("user_id",k.user_id).eq("is_active",!0).order("sort_order");if(ce)throw ce;return X},enabled:!!(k!=null&&k.user_id)}),{data:I=[]}=gt({queryKey:["public-availability",k==null?void 0:k.user_id],queryFn:async()=>{const{data:X,error:ce}=await G.from("agent_availability_slots").select("day_of_week, start_time, end_time").eq("user_id",k.user_id).eq("is_active",!0);if(ce)throw ce;return X},enabled:!!(k!=null&&k.user_id)}),{data:O=[]}=gt({queryKey:["public-blocked-dates",k==null?void 0:k.user_id],queryFn:async()=>{const{data:X,error:ce}=await G.from("agent_blocked_dates").select("blocked_date").eq("user_id",k.user_id);if(ce)throw ce;return X.map(ie=>ie.blocked_date)},enabled:!!(k!=null&&k.user_id)}),{data:V=[]}=gt({queryKey:["public-existing-bookings",k==null?void 0:k.user_id,i],queryFn:async()=>{if(!i)return[];const X=ps(i,"yyyy-MM-dd"),{data:ce,error:ie}=await G.from("bookings").select("start_time, end_time").eq("agent_user_id",k.user_id).eq("booking_date",X).eq("status","confirmed");if(ie)throw ie;return ce},enabled:!!(k!=null&&k.user_id)&&!!i}),q=S.useMemo(()=>[...new Set(I.map(X=>X.day_of_week))],[I]),$=X=>{const ce=Em(new Date),ie=cl(ce,(k==null?void 0:k.max_advance_days)||30),ae=cl(ce,0);return GS(X,ae)||HS(X,ie)||O.includes(ps(X,"yyyy-MM-dd"))?!1:q.includes(X.getDay())},U=S.useMemo(()=>{if(!i||!o||!k)return[];const X=I.filter(_e=>_e.day_of_week===i.getDay()),ce=o.duration_minutes,ie=k.buffer_minutes||0,ae=[],oe=new Date,pe=(k.min_notice_hours||2)*60*60*1e3;for(const _e of X){const[he,we]=_e.start_time.split(":").map(Number),[je,Ue]=_e.end_time.split(":").map(Number);let Te=KL(WL(i,he),we);const Me=KL(WL(i,je),Ue);for(;Z5(Te,ce)<=Me;){const Fe=ps(Te,"HH:mm"),Le=ps(Z5(Te,ce),"HH:mm");Te.getTime()-oe.getTime()>=pe&&(V.some(qe=>{const ze=qe.start_time.slice(0,5),ve=qe.end_time.slice(0,5);return Feze})||ae.push(Fe)),Te=Z5(Te,ce+ie)}}return ae},[i,o,I,k,V]),se=S.useMemo(()=>{const X=x.getFullYear(),ce=x.getMonth(),ie=new Date(X,ce,1),ae=new Date(X,ce+1,0),oe=ie.getDay(),pe=[];for(let _e=0;_e{if(!(!o||!i||!u||!_.name||!k)){w(!0);try{const X=ps(Z5(KL(WL(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:k.user_id,booking_type_id:o.id,booking_date:ps(i,"yyyy-MM-dd"),start_time:u,end_time:X,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:k.user_id,guestName:_.name,guestEmail:_.email||null,guestPhone:_.phone||null,guestMessage:_.message||null,bookingTypeName:o.name,bookingDate:ps(i,"yyyy-MM-dd"),startTime:u,endTime:X,durationMinutes:o.duration_minutes,meetingLink:k.meeting_link||null}}).catch(ie=>console.error("Booking notify error:",ie)),a("confirmed")}catch(X){me.error("Failed to book: "+X.message)}finally{w(!1)}}},J=X=>{const[ce,ie]=X.split(":").map(Number),ae=ce>=12?"PM":"AM";return`${ce%12||12}:${ie.toString().padStart(2,"0")} ${ae}`};return C?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-[#406E71] border-t-transparent"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading booking page..."})]})}):k?e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8]",children:[e.jsx("div",{className:"h-1.5 bg-gradient-to-r from-[#406E71] via-[#5a9a9d] to-[#2a4c64]"}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-6 sm:py-10",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden mb-6",children:[e.jsx("div",{className:"relative bg-gradient-to-r from-[#406E71] to-[#2a4c64] px-6 pt-6 pb-12",children:e.jsxs("div",{className:"absolute inset-0 opacity-10",children:[e.jsx("div",{className:"absolute top-2 right-8 w-20 h-20 rounded-full border-2 border-white/30"}),e.jsx("div",{className:"absolute bottom-4 left-12 w-10 h-10 rounded-full border border-white/20"})]})}),e.jsx("div",{className:"relative -mt-10 px-6",children:e.jsxs("div",{className:"flex items-end gap-4",children:[E!=null&&E.avatar_url?e.jsx("img",{src:E.avatar_url,alt:(E==null?void 0:E.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(Ti,{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:(E==null?void 0:E.name)||"Agent"}),(E==null?void 0:E.title)&&e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:E.title})]})]})}),e.jsxs("div",{className:"px-6 py-4 flex flex-wrap gap-2",children:[(E==null?void 0:E.phone)&&e.jsxs("a",{href:`tel:${E.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(Pn,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:E.phone}),e.jsx("span",{className:"sm:hidden",children:"Call"})]}),(E==null?void 0:E.email)&&e.jsxs("a",{href:`mailto:${E.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(rr,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:E.email}),e.jsx("span",{className:"sm:hidden",children:"Email"})]})]})]}),e.jsx("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden",children:e.jsxs("div",{className:"p-5 sm:p-6",children:[n==="types"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800",children:"Select a meeting type"}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Choose the type of meeting you'd like to schedule"})]}),e.jsx("div",{className:"space-y-2.5",children:L.map(X=>e.jsx("button",{onClick:()=>{l(X),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:X.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:N0e[X.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:X.name}),X.description&&e.jsx("p",{className:"text-xs text-slate-500 mt-0.5 line-clamp-2",children:X.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(ln,{className:"h-3 w-3"}),X.duration_minutes,"m"]})]})})},X.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(Fa,{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:N0e[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(ln,{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:ps(x,"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(x.getFullYear(),x.getMonth()-1)),children:e.jsx(xl,{className:"h-4 w-4"})}),e.jsx("button",{className:"h-8 w-8 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100 hover:text-slate-800 transition-colors",onClick:()=>y(new Date(x.getFullYear(),x.getMonth()+1)),children:e.jsx(Sa,{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(X=>e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-semibold py-2",children:X},X)),se.map((X,ce)=>{if(!X)return e.jsx("div",{},`pad-${ce}`);const ie=$(X),ae=i&&rl(X,i),oe=rl(X,new Date);return e.jsx("button",{disabled:!ie,onClick:()=>{d(X),p(null)},className:`h-10 w-10 mx-auto rounded-xl text-sm font-medium transition-all duration-150 ${ae?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-105":ie?"hover:bg-[#406E71]/10 text-slate-700 hover:text-[#406E71]":"text-slate-200 cursor-not-allowed"} ${oe&&!ae?"ring-1 ring-[#406E71]/40":""}`,children:X.getDate()},X.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:ps(i,"EEEE, MMMM d")})]}),U.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(ln,{className:"h-8 w-8 text-slate-300 mx-auto"}),e.jsx("p",{className:"text-sm text-slate-400",children:"No available times on this day"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Try selecting a different date"})]}):e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2 max-h-52 overflow-y-auto pr-1 custom-scrollbar",children:U.map(X=>{const ce=u===X;return e.jsx("button",{onClick:()=>p(X),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(X)},X)})}),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(Fa,{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:N0e[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]"}),ps(i,"EEE, MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ln,{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(xe,{className:"text-xs font-semibold text-slate-700",children:"Full Name *"}),e.jsx(De,{value:_.name,onChange:X=>b({..._,name:X.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(xe,{className:"text-xs font-semibold text-slate-700",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(De,{type:"email",value:_.email,onChange:X=>b({..._,email:X.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(xe,{className:"text-xs font-semibold text-slate-700",children:"Phone"}),e.jsxs("div",{className:"relative",children:[e.jsx(Pn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(De,{type:"tel",value:_.phone,onChange:X=>b({..._,phone:X.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(xe,{className:"text-xs font-semibold text-slate-700",children:"Message (optional)"}),e.jsx(vr,{value:_.message,onChange:X=>b({..._,message:X.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:Y,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(Qn,{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 ",(E==null?void 0:E.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&&ps(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."}),((E==null?void 0:E.phone)||(E==null?void 0:E.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:[(E==null?void 0:E.phone)&&e.jsxs("a",{href:`tel:${E.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(Pn,{className:"h-3.5 w-3.5"})," Call"]}),(E==null?void 0:E.email)&&e.jsxs("a",{href:`mailto:${E.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(rr,{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 n5s(){const s=Ol().pathname.slice(1).split("/")[0];return S.useEffect(()=>{document.body.classList.add("booking-page");const r=()=>{['[id*="lc_text_widget"]','[id*="lc_text-widget"]','[class*="lc-text-widget"]','[class*="lc_text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("booking-page"),n.forEach(clearTimeout)}},[]),s?e.jsx(Mct,{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 a5s(){const s=Ol().pathname.slice(1);return S.useEffect(()=>{document.body.classList.add("connect-page");const r=()=>{['[id*="lc_text_widget"]','[id*="lc_text-widget"]','[class*="lc-text-widget"]','[class*="lc_text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("connect-page"),n.forEach(clearTimeout)}},[]),!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-slate-100 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Connect"}),e.jsx("p",{className:"text-slate-500",children:"Stay connected with your real estate professional."}),e.jsx("p",{className:"text-slate-400 text-sm mt-2",children:"Visit a specific agent link to get started."})]})}):e.jsx(iXe,{slugOverride:s})}function Tct({slugOverride:t}){const{slug:s}=co(),r=t||s,[n,a]=S.useState(!1),[o,l]=S.useState({}),[i,d]=S.useState(0),[u,p]=S.useState(!1),{data:x,isLoading:y}=gt({queryKey:["public-landing-page",r],queryFn:async()=>{const{data:V,error:q}=await G.from("landing_pages").select("*").eq("slug",r).eq("is_published",!0).single();if(q)throw q;return V},enabled:!!r}),{data:_=[]}=gt({queryKey:["public-landing-page-fields",x==null?void 0:x.id],queryFn:async()=>{const{data:V,error:q}=await G.from("landing_page_fields").select("*").eq("page_id",x.id).order("sort_order");if(q)throw q;return V},enabled:!!(x!=null&&x.id)});S.useEffect(()=>{x!=null&&x.id&&G.from("landing_pages").update({view_count:(x.view_count||0)+1}).eq("id",x.id).then(()=>{})},[x==null?void 0:x.id]);const b=It({mutationFn:async()=>{const V=_.find(X=>X.field_type==="text"&&X.label.toLowerCase().includes("name")),q=_.find(X=>X.field_type==="email"),$=_.find(X=>X.field_type==="phone"),U=V?String(o[V.label]||""):null,se=q?String(o[q.label]||""):null,Y=$?String(o[$.label]||""):null,{error:J}=await G.from("landing_page_submissions").insert([{page_id:x.id,answers:JSON.parse(JSON.stringify(o)),contact_name:U,contact_email:se,contact_phone:Y,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:x.id,contact_name:U,contact_email:se,contact_phone:Y,answers:o}}).catch(X=>console.error("Landing page lead notification error:",X))},onSuccess:()=>a(!0)}),N=V=>{V.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(!x)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=x.primary_color||"#406E71",k=x.accent_color||"#2a4c64",C=x,E=x.page_type==="lead_magnet",L=x.page_type==="just_listed"||x.page_type==="just_sold",I=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}, ${k})`},children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-8 max-w-md mx-4 text-center",children:[e.jsx(Qn,{className:"h-16 w-16 mx-auto mb-4",style:{color:w}}),e.jsx("h2",{className:"text-2xl font-bold mb-2",children:E?"Your download is ready!":"Submitted!"}),e.jsx("p",{className:"text-gray-600",children:x.success_message}),E&&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"]}),x.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:x.agent_name}),x.agent_phone&&e.jsxs("a",{href:`tel:${x.agent_phone}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(Pn,{className:"h-3 w-3"})," ",x.agent_phone]}),x.agent_email&&e.jsxs("a",{href:`mailto:${x.agent_email}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(rr,{className:"h-3 w-3"})," ",x.agent_email]})]})]})});if(L){const V=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&&I.length>0&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/95 flex items-center justify-center",onClick:()=>p(!1),children:[e.jsx("button",{onClick:()=>p(!1),className:"absolute top-4 right-4 text-white/80 hover:text-white z-10",children:e.jsx(Sr,{className:"h-8 w-8"})}),e.jsx("button",{onClick:q=>{q.stopPropagation(),d($=>$===0?I.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(xl,{className:"h-6 w-6"})}),e.jsx("img",{src:I[i],alt:`Property photo ${i+1}`,className:"max-h-[90vh] max-w-[90vw] object-contain rounded-lg",onClick:q=>q.stopPropagation()}),e.jsx("button",{onClick:q=>{q.stopPropagation(),d($=>$===I.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(Sa,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 text-white/70 text-sm",children:[i+1," / ",I.length]})]}),I.length>0&&e.jsxs("div",{className:"relative max-w-6xl mx-auto px-4 pt-6",children:[e.jsx("div",{className:"absolute top-10 left-8 z-10 px-4 py-1.5 rounded-full text-white font-bold text-sm uppercase tracking-wider shadow-lg",style:{backgroundColor:C.property_status==="just_sold"?"#e74c3c":w},children:C.property_status==="just_sold"?"🎉 Just Sold":"🏡 Just Listed"}),I.length===1?e.jsxs("div",{className:"rounded-2xl overflow-hidden cursor-pointer group",onClick:()=>{d(0),p(!0)},children:[e.jsx("img",{src:I[0],alt:"Property",className:"w-full h-[50vh] object-cover group-hover:scale-105 transition-transform duration-500"}),e.jsxs("div",{className:"absolute bottom-4 right-4 bg-black/60 text-white px-3 py-1.5 rounded-lg text-sm flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(Ab,{className:"h-4 w-4"})," View"]})]}):I.length===2?e.jsx("div",{className:"grid grid-cols-2 gap-2 rounded-2xl overflow-hidden",children:I.slice(0,2).map((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:I[0],alt:"Property main",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),I.slice(1,5).map((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&&I.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center text-white font-bold text-lg",children:["+",I.length-5," more"]})]},$))]}),I.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(Ab,{className:"h-4 w-4"})," View all ",I.length," photos"]})]}),I.length===0&&e.jsx("div",{className:"relative py-16 px-4",style:{background:x.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${x.hero_image_url}) center/cover`:`linear-gradient(135deg, ${w}, ${k})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[x.logo_url&&e.jsx("img",{src:x.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:x.hero_headline}),x.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:x.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:V(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(Da,{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(Wy,{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(rf,{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(uS,{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!"}),x.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-5 pb-4 border-b",children:[x.agent_photo_url&&e.jsx("img",{src:x.agent_photo_url,alt:x.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:x.agent_name}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-xs text-gray-500",children:[x.agent_phone&&e.jsxs("a",{href:`tel:${x.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Pn,{className:"h-3 w-3"})," ",x.agent_phone]}),x.agent_email&&e.jsxs("a",{href:`mailto:${x.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(rr,{className:"h-3 w-3"})," ",x.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:N,className:"space-y-3",children:[_.map(q=>e.jsxs("div",{children:[e.jsxs(xe,{className:"text-xs font-medium",children:[q.label,q.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),z9e(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:x.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${x.hero_image_url}) center/cover`:`linear-gradient(135deg, ${w}, ${k})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[x.logo_url&&e.jsx("img",{src:x.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:x.hero_headline}),x.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:x.hero_subtext}),E&&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:[E&&e.jsx("p",{className:"text-sm text-gray-500 mb-4 text-center",children:"Fill out the form below to get your free download!"}),x.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-6 pb-4 border-b",children:[x.agent_photo_url&&e.jsx("img",{src:x.agent_photo_url,alt:x.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:x.agent_name}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-500",children:[x.agent_phone&&e.jsxs("a",{href:`tel:${x.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Pn,{className:"h-3 w-3"})," ",x.agent_phone]}),x.agent_email&&e.jsxs("a",{href:`mailto:${x.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(rr,{className:"h-3 w-3"})," ",x.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[_.map(V=>e.jsxs("div",{children:[e.jsxs(xe,{className:"text-sm font-medium",children:[V.label,V.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),z9e(V,o,l)]},V.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},disabled:b.isPending,children:b.isPending?"Submitting...":E?"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 z9e(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(De,{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(vr,{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(Bs,{value:String(a),onValueChange:l=>r(i=>({...i,[t.label]:l})),children:[e.jsx(Rs,{className:"mt-1",children:e.jsx(qs,{placeholder:"Select..."})}),e.jsx(Os,{children:o.map(l=>e.jsx(vt,{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(Ki,{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(Er,{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(De,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),className:"mt-1"})}}function i5s(){const s=Ol().pathname.slice(1).split("/")[0];return S.useEffect(()=>{document.body.classList.add("landing-page-public");const r=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("landing-page-public"),n.forEach(clearTimeout)}},[]),s?e.jsx(Tct,{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 o5s=[{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}],KTs={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"},ZTs={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"},B9e={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 YTs(t){return B9e[t]||B9e.basic}function l5s(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:o5s,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 c5s(){const s=window.location.hostname.match(/^([^.]+)\.thelocalmove\.com$/i);return s?s[1]:null}function d5s(){const t=c5s(),{data:s,isLoading:r,error:n}=gt({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:x}=await G.from("team_members").select("team_id, teams(avatar_url, name)").eq("user_id",a.agent_id).limit(1).maybeSingle();x&&((p=x.teams)!=null&&p.avatar_url)&&(i=x.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(x=>x&&typeof x=="object"&&x.text).map(x=>({name:String(x.name||"Client"),text:String(x.text),rating:typeof x.rating=="number"?x.rating:5,location:x.location?String(x.location):void 0})):[],seoMetaTitle:a.seo_meta_title||null,seoMetaDescription:a.seo_meta_description||null},u=l5s(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 u5s(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 Act=S.createContext(null);function spe(){const t=S.useContext(Act);if(!t)throw new Error("useLeadSiteAuth must be used within LeadSiteAuthProvider");return t}function h5s({siteConfig:t,children:s}){const[r,n]=S.useState(null),[a,o]=S.useState(null),[l,i]=S.useState(!0);S.useEffect(()=>{const{data:{subscription:x}}=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)}),()=>x.unsubscribe()},[t.id]);const d=S.useCallback(async x=>{const y=x.email.toLowerCase().trim(),_=x.phone.replace(/\D/g,""),{data:b,error:N}=await G.auth.signUp({email:y,password:_,options:{data:{full_name:x.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:x.name.trim(),phone:x.phone.trim()});w&&console.warn("Consumer profile insert error:",w);const{error:k}=await G.from("lead_site_leads").insert({lead_site_id:t.id,name:x.name.trim(),email:y,phone:x.phone.trim(),message:"Created account on website",source_page:window.location.pathname,lead_type:"website_registration",metadata:{registered:!0,has_account:!0}});k&&console.error("Lead insert error (CRM sync may not trigger):",k),u5s(t.id,{name:x.name.trim(),email:y,phone:x.phone.trim(),lead_type:"website_registration",message:"Created account on website",source_page:window.location.pathname})}},[t.id]),u=S.useCallback(async(x,y)=>{const _=y.replace(/\D/g,""),{error:b}=await G.auth.signInWithPassword({email:x.toLowerCase().trim(),password:_});if(b)throw b},[]),p=S.useCallback(async()=>{await G.auth.signOut(),n(null),o(null)},[]);return e.jsx(Act.Provider,{value:{user:r,profile:a,isLoading:l,signUp:d,signIn:u,signOut:p},children:s})}function VCe({open:t,mode:s,siteConfig:r,onComplete:n,onSkip:a,theme:o="default",accentColor:l}){var J;const{signUp:i,signIn:d}=spe(),[u,p]=S.useState(!1),[x,y]=S.useState(""),[_,b]=S.useState(""),[N,w]=S.useState(""),[k,C]=S.useState(!1),[E,L]=S.useState(""),I=s==="required",O=o==="luxury",V=l||(O?"#c9a96e":"#2563eb"),q=((J=r.agent)==null?void 0:J.full_name)||"the agent",$={borderColor:`${V}66`,"--tw-ring-color":`${V}66`},U=async X=>{var ie;if(X.preventDefault(),L(""),!_.trim()||!N.trim()){L("Email and phone number are required.");return}if(!u&&!x.trim()){L("Name is required.");return}if(N.replace(/\D/g,"").length<7){L("Please enter a valid phone number.");return}C(!0);try{u?await d(_,N):await i({name:x,email:_,phone:N}),n()}catch(ae){(ie=ae==null?void 0:ae.message)!=null&&ie.includes("Invalid login")?L("Invalid email or phone number. Please try again."):L((ae==null?void 0:ae.message)||"Something went wrong. Please try again.")}finally{C(!1)}},se=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",Y=O?$:void 0;return e.jsx(fs,{open:t,onOpenChange:I?void 0:X=>{X||a()},children:e.jsxs(ms,{className:`sm:max-w-md ${O?"border-white/10 bg-[#f7f1e7] text-[#201915]":""}`,onPointerDownOutside:I?X=>X.preventDefault():void 0,onEscapeKeyDown:I?X=>X.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":I?"Create a Free Account to Continue":"Save Your Search & Get Updates"}),e.jsx(Ir,{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:U,className:"space-y-3 mt-2",children:[!u&&e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:x,onChange:X=>y(X.target.value),className:se,style:Y}),e.jsx("input",{type:"email",required:!0,placeholder:"Email address",value:_,onChange:X=>b(X.target.value),className:se,style:Y}),e.jsxs("div",{children:[e.jsx("input",{type:"tel",required:!0,placeholder:"Phone number",value:N,onChange:X=>w(X.target.value),className:se,style:Y}),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"})]}),E&&e.jsx("p",{className:"text-red-600 text-sm",children:E}),e.jsx("button",{type:"submit",disabled:k,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:V}:void 0,children:k?u?"Signing in...":"Creating account...":u?"Sign In":"Create Account"}),e.jsx("button",{type:"button",onClick:()=>{p(!u),L("")},className:"w-full text-center text-sm hover:opacity-80 transition-opacity",style:{color:V},children:u?"Don't have an account? Sign up":"Already have an account? Sign in"}),!I&&!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 HCe({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(E=>E.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(E=>E.toUpperCase()))],x=t.testimonials||[],y=x.length?{"@type":"AggregateRating",ratingValue:(x.reduce((E,L)=>E+(L.rating||5),0)/x.length).toFixed(1),reviewCount:x.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(E=>{const[L,I]=E.split(/,\s*/);return{"@type":"City",name:L,...I&&{containedInPlace:{"@type":"State",name:I}}}})},...y&&{aggregateRating:y},...x.length&&{review:x.slice(0,10).map(E=>({"@type":"Review",author:{"@type":"Person",name:E.name},reviewBody:E.text,reviewRating:{"@type":"Rating",ratingValue:E.rating||5,bestRating:5,worstRating:1},...E.location&&{locationCreated:{"@type":"Place",name:E.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(E=>({"@type":"EducationalOccupationalCredential",credentialCategory:"designation",name:E}))},...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"}},k=[{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:k.map((E,L)=>({"@type":"SiteNavigationElement",position:L+1,name:E.name,description:E.description,url:`${n}${E.path}`}))};return e.jsxs(wc,{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 XTs({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(wc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function QTs({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(wc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function m5s({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(wc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(s)})})}function JTs({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(wc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(d)})})}function GCe({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)||[],x=[...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.`},...x.length?[{question:`What real estate designations does ${r} hold?`,answer:`${r} holds the following professional designations: ${x.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(m5s,{faqs:y})}const $9e="ls_visitor_geo",p5s=1e3*60*60;function f5s(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 x5s(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 g5s(){try{const t=localStorage.getItem($9e);if(t){const s=JSON.parse(t);if(Date.now()-s.ts{o.current||(o.current=!0,g5s().then(l=>{a.current=l}))},[]),S.useEffect(()=>{if(!(t!=null&&t.id))return;const l=r.pathname;if(l===n.current)return;n.current=l;const i=f5s(l),d=x5s(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:x})=>{x&&console.error("[PageTracking] insert failed:",x.message)})},[r.pathname,t==null?void 0:t.id,s])}const y5s=3e4;function KCe(t,s){const r=Ol(),n=S.useRef(null),a=S.useRef(null),o=S.useRef(0),l=r.pathname,i=v5s(l),d=_5s(l,i),u=i==="listing"&&l.split("/listing/")[1]||null;S.useEffect(()=>{if(!(t!=null&&t.id)||!s)return;i==="listing"&&(o.current+=1);const p=localStorage.getItem(`ls_visitor_fp_${t.id}`)||null,x=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 x(),a.current&&clearInterval(a.current),a.current=setInterval(x,y5s),()=>{a.current&&clearInterval(a.current)}},[t==null?void 0:t.id,s,l]),S.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 v5s(t){return t==="/"?"home":t==="/search"?"search":t.startsWith("/listing/")?"listing":t.startsWith("/homes-for-sale-in-")?"city":"other"}function _5s(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 b5s({children:t,siteConfig:s}){var _e,he,we,je,Ue,Te,Me,Fe,Le;const r=Ol(),n=_r(),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(!1),[p,x]=S.useState([]),[y,_]=S.useState([]),[b,N]=S.useState(null),w=S.useRef(null),k=S.useRef(null),{user:C,profile:E,signOut:L}=spe();WCe(s,C==null?void 0:C.id),KCe(s,C==null?void 0:C.id);const I=((_e=s.agent)==null?void 0:_e.full_name)||"Agent",O=s.siteTitle||`${I} Real Estate`,V=r.pathname==="/search",q=r.pathname==="/",$=s.leadRegistrationMode!=="disabled";S.useEffect(()=>{(async()=>{const{data:qe}=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});x(qe||[])})()},[s.id]),S.useEffect(()=>{(async()=>{const{data:qe}=await G.from("lead_site_menu_items").select("*").eq("site_id",s.id).eq("is_visible",!0).order("sort_order",{ascending:!0});_(qe||[])})()},[s.id]),S.useEffect(()=>{const Ne=qe=>{w.current&&!w.current.contains(qe.target)&&u(!1),k.current&&!k.current.contains(qe.target)&&N(null)};return document.addEventListener("mousedown",Ne),()=>document.removeEventListener("mousedown",Ne)},[]);const U=y.length>0,Y=U?[]:[{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(Ne=>!Ne.parent_id),X=Ne=>y.filter(qe=>qe.parent_id===Ne),ce=q?"bg-transparent text-white":"bg-white/95 backdrop-blur text-gray-900 border-b border-gray-100 shadow-sm",ie=s.siteTitle||`${I} - Real Estate`,ae=s.siteTagline||`Browse homes and listings with ${I}`,oe=s.ogImageUrl||((he=s.agent)==null?void 0:he.avatar_url)||"",pe=`https://${s.subdomainSlug||""}.thelocalmove.com`;return e.jsxs("div",{className:`flex flex-col ${V?"h-screen overflow-hidden":"min-h-screen"} bg-white`,children:[e.jsx(HCe,{siteConfig:s,pagePath:r.pathname}),e.jsx(GCe,{siteConfig:s}),e.jsxs(wc,{children:[e.jsx("title",{children:ie}),e.jsx("meta",{name:"description",content:ae}),e.jsx("meta",{property:"og:title",content:ie}),e.jsx("meta",{property:"og:description",content:ae}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:pe+r.pathname}),oe&&e.jsx("meta",{property:"og:image",content:oe}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:ie}),e.jsx("meta",{name:"twitter:description",content:ae}),oe&&e.jsx("meta",{name:"twitter:image",content:oe}),s.faviconUrl&&e.jsx("link",{rel:"icon",href:s.faviconUrl,type:"image/png"}),e.jsx("link",{rel:"canonical",href:`${pe}${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(ha,{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:I,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:[Y.map(Ne=>e.jsx(ha,{to:Ne.to,className:`px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${r.pathname===Ne.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:Ne.label},Ne.to)),U&&J.map(Ne=>{if(Ne.item_type==="dropdown"){const qe=X(Ne.id);return e.jsxs("div",{ref:k,className:"relative",children:[e.jsxs("button",{onClick:()=>N(b===Ne.id?null:Ne.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:[Ne.label," ",e.jsx(Oi,{className:`h-3.5 w-3.5 transition-transform ${b===Ne.id?"rotate-180":""}`})]}),b===Ne.id&&qe.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:qe.map(ze=>e.jsx(A9,{item:ze,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"},ze.id))})]},Ne.id)}return e.jsx(A9,{item:Ne,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"}`},Ne.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(Oi,{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(Ne=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${Ne.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:Ne.city_name},Ne.city_slug))})]}),C?e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsxs(ha,{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(ha,{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(Ti,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:((je=E==null?void 0:E.name)==null?void 0:je.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(aS,{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:[Y.map(Ne=>e.jsx(ha,{to:Ne.to,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===Ne.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:Ne.label},Ne.to)),U&&J.map(Ne=>{if(Ne.item_type==="dropdown"){const qe=X(Ne.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:Ne.label}),qe.map(ze=>e.jsx(A9,{item:ze,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"}`},ze.id))]},Ne.id)}return e.jsx(A9,{item:Ne,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"}`},Ne.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(Ne=>e.jsx(ha,{to:`/homes-for-sale-in-${Ne.city_slug}`,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===`/homes-for-sale-in-${Ne.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:Ne.city_name},Ne.city_slug))]}),C?e.jsxs(e.Fragment,{children:[e.jsx(ha,{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 L(),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}),!V&&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:[((Ue=s.agent)==null?void 0:Ue.avatar_url)&&e.jsx("img",{src:s.agent.avatar_url,alt:I,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:I}),e.jsx("p",{className:"text-sm text-gray-500",children:((Te=s.agent)==null?void 0:Te.title)||"Real Estate Professional"})]})]}),((Me=s.agent)==null?void 0:Me.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(Pn,{className:"h-3.5 w-3.5"})," ",s.agent.phone]})}),((Fe=s.agent)==null?void 0:Fe.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(rr,{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:Y.map(Ne=>e.jsx("li",{children:e.jsx(ha,{to:Ne.to,className:"hover:text-white transition-colors",children:Ne.label})},Ne.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(ha,{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:[I," · ",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()," ",I,". Powered by LevelUp."]})]})]})]})}),!V&&((Le=s.agent)==null?void 0:Le.avatar_url)&&e.jsx(w5s,{agent:s.agent}),l&&e.jsx(VCe,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1)})]})}function w5s({agent:t}){var a;const[s,r]=S.useState(!1),n=_r();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(Pn,{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(rr,{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 A9({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(ha,{to:n,className:s,onClick:r,children:t.label})}function j5s({children:t,siteConfig:s}){var pe,_e,he,we,je,Ue,Te;const r=Ol(),n=_r(),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(!1),[p,x]=S.useState([]),[y,_]=S.useState(!1),b=S.useRef(null),{user:N,profile:w,signOut:k}=spe();WCe(s,N==null?void 0:N.id),KCe(s,N==null?void 0:N.id);const C=((pe=s.agent)==null?void 0:pe.full_name)||"Agent",E=s.siteTitle||`${C} Real Estate`,L=s.brokerageLegalName?`${C} | ${s.brokerageLegalName}`:C,I=Me=>{if(!Me)return Me;const Fe=C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Le=new RegExp(`^\\s*${Fe}\\s*[|\\-–—:]\\s*`,"i");return Me.replace(Le,"").trim()},O=E&&E!==`${C} Real Estate`?E:null,V=O?I(O):null,q=V&&V.toLowerCase()!==C.toLowerCase()?V:null,$=r.pathname==="/search",U=r.pathname==="/",se=s.leadRegistrationMode!=="disabled",Y="#c9a96e";S.useEffect(()=>{const Me=()=>_(window.scrollY>80);return window.addEventListener("scroll",Me,{passive:!0}),()=>window.removeEventListener("scroll",Me)},[]),S.useEffect(()=>{(async()=>{const{data:Fe}=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});x(Fe||[])})()},[s.id]),S.useEffect(()=>{const Me=Fe=>{b.current&&!b.current.contains(Fe.target)&&u(!1)};return document.addEventListener("mousedown",Me),()=>document.removeEventListener("mousedown",Me)},[]);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"}],X=s.siteTitle||`${C} - Real Estate`,ce=s.siteTagline||`Browse homes and listings with ${C}`,ie=s.ogImageUrl||((_e=s.agent)==null?void 0:_e.avatar_url)||"",ae=`https://${s.subdomainSlug||""}.thelocalmove.com`,oe=U?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(HCe,{siteConfig:s,pagePath:r.pathname}),e.jsx(GCe,{siteConfig:s}),e.jsxs(wc,{children:[e.jsx("title",{children:X}),e.jsx("meta",{name:"description",content:ce}),e.jsx("meta",{property:"og:title",content:X}),e.jsx("meta",{property:"og:description",content:ce}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:ae+r.pathname}),ie&&e.jsx("meta",{property:"og:image",content:ie}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:X}),e.jsx("meta",{name:"twitter:description",content:ce}),ie&&e.jsx("meta",{name:"twitter:image",content:ie}),s.faviconUrl&&e.jsx("link",{rel:"icon",href:s.faviconUrl,type:"image/png"}),e.jsx("link",{rel:"canonical",href:`${ae}${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:`${U?"fixed":"sticky"} top-0 left-0 right-0 z-50 transition-all duration-500 ${oe}`,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(ha,{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:L}),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(Me=>e.jsx(ha,{to:Me.to,className:`px-4 py-2 text-xs tracking-[0.15em] uppercase transition-colors duration-300 ${r.pathname===Me.to?"text-white":"text-white/40 hover:text-white"}`,children:Me.label},Me.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(Oi,{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(Me=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${Me.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:Me.city_name},Me.city_slug))})]}),N?e.jsxs("div",{className:"flex items-center gap-1 ml-3",children:[e.jsxs(ha,{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(ha,{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(Ti,{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"})]})]}):se?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(Me=>e.jsx(ha,{to:Me.to,onClick:()=>o(!1),className:`block px-3 py-3 text-xs tracking-[0.2em] uppercase transition-colors ${r.pathname===Me.to?"text-white":"text-white/40 hover:text-white"}`,children:Me.label},Me.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:Y},children:"Cities"}),p.map(Me=>e.jsx(ha,{to:`/homes-for-sale-in-${Me.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:Me.city_name},Me.city_slug))]}),N?e.jsxs(e.Fragment,{children:[e.jsx(ha,{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 k(),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"})]}):se?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"}),((je=s.agent)==null?void 0:je.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(Pn,{className:"h-3.5 w-3.5"})," ",s.agent.phone]}),((Ue=s.agent)==null?void 0:Ue.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(rr,{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:Y},children:"Quick Links"}),e.jsx("ul",{className:"space-y-3",children:J.map(Me=>e.jsx("li",{children:e.jsx(ha,{to:Me.to,className:"text-xs tracking-wider uppercase text-white/30 hover:text-white transition-colors",children:Me.label})},Me.to))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs tracking-[0.3em] uppercase mb-6",style:{color:Y},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(ha,{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(N5s,{agent:s.agent,accentColor:Y}),l&&e.jsx(VCe,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1),theme:"luxury",accentColor:Y})]})}function N5s({agent:t,accentColor:s}){var o;const[r,n]=S.useState(!1),a=_r();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(Pn,{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(rr,{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 bI="#2c1810",jy="#b8860b";function k5s({children:t,siteConfig:s}){var q,$,U;const r=Ol();_r();const[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState([]),[x,y]=S.useState(!1),_=S.useRef(null),{user:b,profile:N,signOut:w}=spe();WCe(s,b==null?void 0:b.id),KCe(s,b==null?void 0:b.id);const k=((q=s.agent)==null?void 0:q.full_name)||"Agent",C=s.siteTitle||`${k} Land & Ranch`,E=r.pathname==="/",L=s.leadRegistrationMode!=="disabled";S.useEffect(()=>{const se=()=>y(window.scrollY>80);return window.addEventListener("scroll",se,{passive:!0}),()=>window.removeEventListener("scroll",se)},[]),S.useEffect(()=>{(async()=>{const{data:Y}=await G.from("lead_site_city_pages").select("city_name, city_slug").eq("site_id",s.id).eq("is_published",!0).order("sort_order");Y&&p(Y)})()},[s.id]),S.useEffect(()=>{const se=Y=>{_.current&&!_.current.contains(Y.target)&&d(!1)};return document.addEventListener("mousedown",se),()=>document.removeEventListener("mousedown",se)},[]);const I=[{label:"Home",path:"/"},{label:"Search Properties",path:"/search"},{label:"About",path:"/about"},{label:"Contact",path:"/contact"}],O=x||!E?"bg-white/95 backdrop-blur-md shadow-sm":"bg-transparent",V=x||!E?bI:"#ffffff";return e.jsxs("div",{className:"min-h-screen",style:{fontFamily:"'Lora', Georgia, serif"},children:[e.jsxs(wc,{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(HCe,{siteConfig:s}),e.jsx(GCe,{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(ha,{to:"/",className:"flex items-center gap-2.5",children:[e.jsx(vM,{className:"w-7 h-7",style:{color:jy}}),e.jsx("span",{className:"text-lg font-bold tracking-wide",style:{color:V,fontFamily:"'Playfair Display', Georgia, serif"},children:C})]}),e.jsxs("nav",{className:"hidden md:flex items-center gap-1",children:[I.map(se=>e.jsx(ha,{to:se.path,className:"px-4 py-2 text-sm font-medium tracking-wide uppercase transition-colors hover:opacity-80",style:{color:r.pathname===se.path?jy:V},children:se.label},se.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:V},children:["Areas ",e.jsx(Oi,{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(se=>e.jsx(ha,{to:`/homes-for-sale-in-${se.city_slug}`,className:"block px-4 py-2.5 text-sm hover:bg-gray-50 transition-colors",style:{color:bI},onClick:()=>d(!1),children:se.city_name},se.city_slug))})]}),b?e.jsx("div",{className:"flex items-center gap-2 ml-3",children:e.jsxs(ha,{to:"/account",className:"px-4 py-2 text-sm font-medium rounded-full border-2 transition-all hover:scale-105",style:{borderColor:jy,color:V},children:[e.jsx(Ti,{className:"w-4 h-4 inline mr-1.5"}),(N==null?void 0:N.name)||"Account"]})}):L?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:jy},children:"Sign In"}):null]}),e.jsx("button",{onClick:()=>a(!n),className:"md:hidden p-2",style:{color:V},children:n?e.jsx(Sr,{className:"w-6 h-6"}):e.jsx(aS,{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:[I.map(se=>e.jsx(ha,{to:se.path,className:"block px-4 py-3 text-base font-medium rounded-lg hover:bg-gray-50 transition-colors",style:{color:r.pathname===se.path?jy:bI},onClick:()=>a(!1),children:se.label},se.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(se=>e.jsx(ha,{to:`/homes-for-sale-in-${se.city_slug}`,className:"block px-4 py-2.5 text-sm rounded-lg hover:bg-gray-50",style:{color:bI},onClick:()=>a(!1),children:se.city_name},se.city_slug))]}),!b&&L&&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:jy},children:"Sign In"})]})})]}),e.jsx("main",{children:t}),e.jsx("footer",{className:"py-16 px-4",style:{backgroundColor:bI},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(vM,{className:"w-6 h-6",style:{color:jy}}),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:I.map(se=>e.jsx(ha,{to:se.path,className:"block text-white/60 hover:text-white text-sm transition-colors",children:se.label},se.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(Pn,{className:"w-4 h-4",style:{color:jy}}),s.agent.phone]}),((U=s.agent)==null?void 0:U.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(rr,{className:"w-4 h-4",style:{color:jy}}),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:jy}})]})]})}),o&&e.jsx(VCe,{open:o,mode:s.leadRegistrationMode==="required"?"required":"optional",siteConfig:s,onSkip:()=>l(!1),onComplete:()=>l(!1)})]})}const S5s=S.lazy(()=>Ha(()=>import("./LeadSiteHome-DaesDA5v.js"),__vite__mapDeps([0,1,2,3]))),C5s=S.lazy(()=>Ha(()=>import("./LeadSiteLuxuryHome-CGbhROvc.js"),__vite__mapDeps([4,2,3]))),M5s=S.lazy(()=>Ha(()=>import("./LeadSiteLandRanchHome-IS8Aiui3.js"),__vite__mapDeps([5,1,2,3]))),T5s=S.lazy(()=>Ha(()=>import("./LeadSiteSearch-Wkz4kH4m.js"),__vite__mapDeps([6,1,7,3,8]))),A5s=S.lazy(()=>Ha(()=>import("./LeadSiteLuxurySearch-DOAWShdx.js"),__vite__mapDeps([9,1,7,3,8]))),E5s=S.lazy(()=>Ha(()=>import("./LeadSiteListingDetail-BeLYyT6v.js"),__vite__mapDeps([10,11,3]))),P5s=S.lazy(()=>Ha(()=>import("./LeadSiteLuxuryListingDetail-Cnr4nowm.js"),__vite__mapDeps([12,11,3]))),I5s=S.lazy(()=>Ha(()=>import("./LeadSiteAbout-B0x65wI9.js"),[])),L5s=S.lazy(()=>Ha(()=>import("./LeadSiteLuxuryAbout-DQ0BnESp.js"),[])),D5s=S.lazy(()=>Ha(()=>import("./LeadSiteContact-CXMiPQS7.js"),[])),R5s=S.lazy(()=>Ha(()=>import("./LeadSiteLuxuryContact-Bjyaf8qk.js"),[])),O5s=S.lazy(()=>Ha(()=>import("./LeadSiteConsumerDashboard-DbyAXZ4Z.js"),[])),q9e=S.lazy(()=>Ha(()=>import("./LeadSiteBlog-Dq3BK8Ec.js"),[])),F5s=S.lazy(()=>Ha(()=>import("./LeadSiteCommunity-CYaKYlFO.js"),[])),z5s=S.lazy(()=>Ha(()=>import("./LeadSiteSellers-XpPk-Fux.js"),[])),B5s=S.lazy(()=>Ha(()=>import("./LeadSiteCityPage-CUvZM_Li.js"),__vite__mapDeps([13,3,8]))),$5s=S.lazy(()=>Ha(()=>import("./LeadSiteCustomPage-VRxRJaFP.js"),[]));function q5s(){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 U5s(){const{siteConfig:t,themeConfig:s,isLoading:r,error:n}=d5s();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?k5s:a?j5s:b5s,i=o?e.jsx(M5s,{siteConfig:t,themeConfig:s??void 0}):a?e.jsx(C5s,{siteConfig:t,themeConfig:s??void 0}):e.jsx(S5s,{siteConfig:t,themeConfig:s??void 0});return e.jsx(h5s,{siteConfig:t,children:e.jsx(l,{siteConfig:t,children:e.jsx(S.Suspense,{fallback:e.jsx(q5s,{}),children:e.jsxs($oe,{children:[e.jsx(ys,{path:"/",element:i}),e.jsx(ys,{path:"/search",element:a?e.jsx(A5s,{siteConfig:t}):e.jsx(T5s,{siteConfig:t})}),e.jsx(ys,{path:"/listing/:mlsNumber",element:a?e.jsx(P5s,{siteConfig:t}):e.jsx(E5s,{siteConfig:t})}),e.jsx(ys,{path:"/about",element:a?e.jsx(L5s,{siteConfig:t}):e.jsx(I5s,{siteConfig:t})}),e.jsx(ys,{path:"/contact",element:a?e.jsx(R5s,{siteConfig:t}):e.jsx(D5s,{siteConfig:t})}),e.jsx(ys,{path:"/account",element:e.jsx(O5s,{siteConfig:t})}),e.jsx(ys,{path:"/blog",element:e.jsx(q9e,{siteConfig:t,isLuxury:a})}),e.jsx(ys,{path:"/blog/:slug",element:e.jsx(q9e,{siteConfig:t,isLuxury:a})}),e.jsx(ys,{path:"/sell",element:e.jsx(z5s,{siteConfig:t,themeConfig:s??void 0,isLuxury:a})}),e.jsx(ys,{path:"/community",element:e.jsx(F5s,{siteConfig:t,isLuxury:a})}),e.jsx(ys,{path:"/p/:pageSlug",element:e.jsx($5s,{siteConfig:t})}),e.jsx(ys,{path:"/*",element:e.jsx(V5s,{siteConfig:t})})]})})})})}function V5s({siteConfig:t}){const r=Ol().pathname.match(/^\/homes-for-sale-in-(.+)$/);return r?e.jsx(B5s,{siteConfig:t,citySlugOverride:r[1]}):null}const H5s=({team:t,onSelect:s})=>{const{data:r}=gt({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(Pe,{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(Ot,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(hr,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(Qe,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(lr,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs(Re,{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(Ta,{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(Cm,{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(Ou,{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(Qe,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(Qe,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(Qe,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},G5s=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Fs(),l=o||(a.length>0?a[0].id:n),i=s?void 0:l||void 0,{teams:d,isLoading:u,createTeam:p,updateTeam:x,deleteTeam:y,addMember:_,removeMember:b,updateMemberRole:N}=NC(i),[w,k]=S.useState(!1),[C,E]=S.useState(null),{data:L}=gt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:V,error:q}=await G.from("brokerages").select("id, name").order("name");if(q)throw q;return V||[]},enabled:s}),{data:I}=gt({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:V,error:q}=await G.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if(q)throw q;return V||[]},enabled:!!l}),O=async V=>{const q=V.brokerage_id||l||null,$=await p.mutateAsync({name:V.name,brokerage_id:q,description:V.description});if(V.leaderId&&V.leaderId!=="none"&&await _.mutateAsync({team_id:$.id,user_id:V.leaderId,role:"team_leader"}),V.memberIds)for(const U of V.memberIds)await _.mutateAsync({team_id:$.id,user_id:U,role:"team_member"});k(!1)};return!r&&!s?e.jsx(Es,{title:"Teams",description:"Team Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(lr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground",children:"You need brokerage manager access to manage teams."})]})}):e.jsx(Es,{title:"Teams",description:"Create and manage teams within your brokerage",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Teams"}),e.jsx("p",{className:"text-muted-foreground",children:"Organize your agents into teams with leaders and shared resources."})]}),e.jsxs(K,{onClick:()=>k(!0),children:[e.jsx(Us,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(ctt,{open:w,onOpenChange:k,onCreateTeam:O,isCreating:p.isPending,brokerageAgents:I||[],isAdmin:s,allBrokerages:L,activeBrokerageId:l}),u&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(V=>e.jsx(Pe,{children:e.jsxs(Re,{className:"p-6",children:[e.jsx(Ns,{className:"h-5 w-32 mb-3"}),e.jsx(Ns,{className:"h-4 w-48 mb-4"}),e.jsx(Ns,{className:"h-8 w-full"})]})},V))}),!u&&d.length===0&&!C&&e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(lr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first team to organize agents and share resources."}),e.jsxs(K,{onClick:()=>k(!0),children:[e.jsx(Us,{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(V=>e.jsx(H5s,{team:V,onSelect:()=>E(V)},V.id))}),C&&e.jsx(ltt,{team:C,brokerageAgents:I||[],onBack:()=>E(null),onUpdate:V=>x.mutateAsync({id:C.id,...V}).then(q=>E(q)),onAddMember:(V,q)=>_.mutateAsync({team_id:C.id,user_id:V,role:q}),onRemoveMember:V=>b.mutateAsync({team_id:C.id,member_id:V}),onUpdateRole:(V,q)=>N.mutateAsync({team_id:C.id,member_id:V,role:q}),onDeleteTeam:()=>y.mutate(C.id),isUpdating:x.isPending,isAddingMember:_.isPending})]})})},W5s=()=>{const{data:t,isLoading:s}=Px(),{useTeamMembers:r}=NC(),{data:n=[],isLoading:a}=r((t==null?void 0:t.teamId)||"");if(s)return e.jsx(Es,{title:"My Team",description:"Your team",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ns,{className:"h-8 w-48"}),e.jsx(Ns,{className:"h-40 w-full"})]})});if(!t)return e.jsx(Es,{title:"My Team",description:"Your team",children:e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(lr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Team Yet"}),e.jsx("p",{className:"text-muted-foreground",children:"You haven't been assigned to a team. Ask your brokerage manager to add you."})]})})});const o=t.team;return e.jsx(Es,{title:"My Team",description:o.name,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:o.name}),e.jsx(Qe,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(Cm,{className:"mr-1 h-3 w-3"})," Leader"]}):"Member"})]}),o.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:o.description})]}),e.jsxs(ia,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(ea,{className:"flex-wrap",children:[e.jsx(ls,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(ls,{value:"contacts",children:[e.jsx(K4,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(ls,{value:"lead-pond",children:[e.jsx(Ag,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(ls,{value:"shared-assets",children:[e.jsx(Mm,{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(Ns,{className:"h-16 w-full"},l))}):n.map(l=>{var i,d,u,p;return e.jsx(Pe,{children:e.jsxs(Re,{className:"flex items-center gap-3 p-4",children:[e.jsxs(vn,{className:"h-10 w-10",children:[e.jsx(Ta,{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(Qe,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(Cm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(Qe,{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(c4e,{})}),o.lead_pond_enabled&&e.jsx(js,{value:"lead-pond",className:"space-y-4",children:e.jsx(d4e,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(js,{value:"shared-assets",className:"space-y-4",children:e.jsx(ott,{teamId:t.teamId})})]})]})})};function K5s(){const{user:t}=Fs(),s=Jt(),r=gt({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await G.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(k)throw k;return w},enabled:!!t}),n=gt({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await G.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(k)throw k;return w},enabled:!!t}),a=gt({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await G.from("agent_availability_slots").select("*").eq("user_id",t.id).order("day_of_week").order("start_time");if(k)throw k;return w},enabled:!!t}),o=gt({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await G.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(k)throw k;return w},enabled:!!t}),l=gt({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await G.from("bookings").select("*, booking_type:agent_booking_types(*)").eq("agent_user_id",t.id).order("booking_date",{ascending:!1});if(k)throw k;return w},enabled:!!t}),i=It({mutationFn:async()=>{const{data:w,error:k}=await G.from("agent_booking_settings").insert({user_id:t.id,slug:""}).select().single();if(k)throw k;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:E}=await G.from("agent_booking_types").insert(C.map(O=>({...O,user_id:t.id})));if(E)throw E;const L=[1,2,3,4,5].map(O=>({user_id:t.id,day_of_week:O,start_time:"09:00",end_time:"17:00"})),{error:I}=await G.from("agent_availability_slots").insert(L);if(I)throw I;return w},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),s.invalidateQueries({queryKey:["booking-types"]}),s.invalidateQueries({queryKey:["availability-slots"]}),me.success("Scheduler set up successfully!")},onError:w=>me.error(w.message)}),d=It({mutationFn:async w=>{const{error:k}=await G.from("agent_booking_settings").update(w).eq("user_id",t.id);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),me.success("Settings updated")},onError:w=>me.error(w.message)}),u=It({mutationFn:async w=>{const k={...w,user_id:t.id};if(w.id){const{error:C}=await G.from("agent_booking_types").update(k).eq("id",w.id);if(C)throw C}else{const{error:C}=await G.from("agent_booking_types").insert(k);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),me.success("Booking type saved")},onError:w=>me.error(w.message)}),p=It({mutationFn:async w=>{const{error:k}=await G.from("agent_booking_types").delete().eq("id",w);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),me.success("Booking type deleted")},onError:w=>me.error(w.message)}),x=It({mutationFn:async w=>{const k={...w,user_id:t.id};if(w.id){const{error:C}=await G.from("agent_availability_slots").update(k).eq("id",w.id);if(C)throw C}else{const{error:C}=await G.from("agent_availability_slots").insert(k);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>me.error(w.message)}),y=It({mutationFn:async w=>{const{error:k}=await G.from("agent_availability_slots").delete().eq("id",w);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>me.error(w.message)}),_=It({mutationFn:async w=>{const{error:k}=await G.from("agent_blocked_dates").insert({...w,user_id:t.id});if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),me.success("Date blocked")},onError:w=>me.error(w.message)}),b=It({mutationFn:async w=>{const{error:k}=await G.from("agent_blocked_dates").delete().eq("id",w);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:w=>me.error(w.message)}),N=It({mutationFn:async({id:w,reason:k})=>{const{error:C}=await G.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:k}).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:x,deleteAvailability:y,addBlockedDate:_,removeBlockedDate:b,cancelBooking:N}}const U9e={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function Z5s({types:t,onSave:s,onDelete:r}){const[n,a]=S.useState(null),[o,l]=S.useState(!1),i=()=>{a({name:"",description:"",duration_minutes:30,color:"#3B82F6",icon:"Calendar",is_active:!0,qualification_enabled:!1}),l(!0)},d=p=>{a({...p}),l(!0)},u=()=>{n!=null&&n.name&&(s(n),l(!1),a(null))};return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Booking Types"}),e.jsx(hr,{children:"The meeting types prospects can book with you"})]}),e.jsxs(K,{onClick:i,size:"sm",children:[e.jsx(Us,{className:"h-4 w-4 mr-1"})," Add Type"]})]}),e.jsx(Re,{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:U9e[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(Qe,{variant:"secondary",className:"text-xs",children:"Inactive"}),p.qualification_enabled&&e.jsxs(Qe,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(_L,{className:"h-3 w-3"})," Qualifying"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ln,{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(ga,{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(gr,{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(xe,{children:"Name"}),e.jsx(De,{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(xe,{children:"Description"}),e.jsx(vr,{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(xe,{children:"Duration (minutes)"}),e.jsx(De,{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(xe,{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(De,{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(xe,{children:"Icon"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(U9e).map(([p,x])=>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:x},p))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Meeting Link Override (optional)"}),e.jsx(De,{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(xe,{children:"Pre-Qualification Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask qualifying questions before booking"})]}),e.jsx(Er,{checked:n.qualification_enabled||!1,onCheckedChange:p=>a({...n,qualification_enabled:p})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Active"}),e.jsx(Er,{checked:n.is_active??!0,onCheckedChange:p=>a({...n,is_active:p})})]})]}),e.jsxs(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:u,children:"Save"})]})]})})]})}const V9e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Y5s({slots:t,onSave:s,onDelete:r}){const[n,a]=S.useState(null),[o,l]=S.useState("09:00"),[i,d]=S.useState("17:00"),u=V9e.map((x,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(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(ln,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(hr,{children:"Set your available hours for each day"})]}),e.jsx(Re,{className:"space-y-2",children:V9e.map((x,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:x})}),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(De,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(N=b.start_time)==null?void 0:N.slice(0,5),onBlur:k=>s({id:b.id,start_time:k.target.value})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(De,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(w=b.end_time)==null?void 0:w.slice(0,5),onBlur:k=>s({id:b.id,end_time:k.target.value})}),e.jsx(Er,{checked:b.is_active,onCheckedChange:k=>s({id:b.id,is_active:k})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>r(b.id),children:e.jsx(gr,{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(De,{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(De,{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(Us,{className:"h-3 w-3 mr-1"})," Add hours"]})]})]},x)})})]})}const X5s={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 Q5s({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(Ti,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:o.guest_name}),e.jsx(Qe,{className:`text-xs ${X5s[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"}),ps(new Date(o.booking_date+"T00:00:00"),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ln,{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(rr,{className:"h-3 w-3"}),o.guest_email]}),o.guest_phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pn,{className:"h-3 w-3"}),o.guest_phone]})]}),o.booking_type&&e.jsx(Qe,{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(Zl,{className:"h-4 w-4 mr-1"})," Cancel"]})]},o.id)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ot,{children:"Upcoming Bookings"}),e.jsxs(hr,{children:[r.length," upcoming appointment",r.length!==1?"s":""]})]}),e.jsx(Re,{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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{children:"Past & Cancelled"})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function J5s({blockedDates:t,onAdd:s,onRemove:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(""),[i,d]=S.useState(""),u=()=>{o&&(s({blocked_date:o,reason:i||void 0}),a(!1),l(""),d(""))};return e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(iL,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(hr,{children:"Block specific dates (vacations, holidays, etc.)"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>a(!0),children:[e.jsx(Us,{className:"h-4 w-4 mr-1"})," Block Date"]})]}),e.jsxs(Re,{children:[n&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx(De,{type:"date",value:o,onChange:p=>l(p.target.value),className:"w-40"}),e.jsx(De,{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:ps(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 eMs(){const{settings:t,bookingTypes:s,availability:r,blockedDates:n,bookings:a,isLoading:o,initializeSettings:l,updateSettings:i,upsertBookingType:d,deleteBookingType:u,upsertAvailability:p,deleteAvailability:x,addBlockedDate:y,removeBlockedDate:_,cancelBooking:b}=K5s(),[N,w]=S.useState("");S.useState(15),N||t!=null&&t.meeting_link;const k=t!=null&&t.slug?`https://booking.relevelup.com/${t.slug}`:null;return o?e.jsx(Es,{children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):t?e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(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:[k&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(k),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:k,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(xe,{htmlFor:"scheduler-active",className:"text-sm",children:"Active"}),e.jsx(Er,{id:"scheduler-active",checked:t.is_active,onCheckedChange:C=>i.mutate({is_active:C})})]})]})]}),e.jsxs(ia,{defaultValue:"types",className:"space-y-4",children:[e.jsxs(ea,{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(C=>C.status==="confirmed").length>0&&e.jsx(Qe,{variant:"secondary",className:"ml-1.5 text-xs",children:a.filter(C=>C.status==="confirmed").length})]})]}),e.jsx(js,{value:"types",children:e.jsx(Z5s,{types:s,onSave:C=>d.mutate(C),onDelete:C=>u.mutate(C)})}),e.jsx(js,{value:"availability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Y5s,{slots:r,onSave:C=>p.mutate(C),onDelete:C=>x.mutate(C)}),e.jsx(J5s,{blockedDates:n,onAdd:C=>y.mutate(C),onRemove:C=>_.mutate(C)})]})}),e.jsx(js,{value:"settings",children:e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(IL,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(hr,{children:"Configure your booking page defaults"})]}),e.jsxs(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Booking Page URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{value:t.slug,readOnly:!0,className:"bg-muted"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>{k&&(navigator.clipboard.writeText(k),me.success("Copied!"))},children:e.jsx(Ya,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:k})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{htmlFor:"meeting-link",children:[e.jsx(Do,{className:"h-4 w-4 inline mr-1"}),"Default Meeting Link"]}),e.jsx(De,{id:"meeting-link",placeholder:"https://zoom.us/j/your-personal-link",defaultValue:t.meeting_link||"",onBlur:C=>i.mutate({meeting_link:C.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(xe,{children:"Buffer Between Meetings"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{type:"number",min:0,max:60,defaultValue:t.buffer_minutes,onBlur:C=>i.mutate({buffer_minutes:parseInt(C.target.value)||15})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"min"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Minimum Notice"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{type:"number",min:0,max:72,defaultValue:t.min_notice_hours,onBlur:C=>i.mutate({min_notice_hours:parseInt(C.target.value)||2})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"hours"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Max Advance Booking"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{type:"number",min:1,max:90,defaultValue:t.max_advance_days,onBlur:C=>i.mutate({max_advance_days:parseInt(C.target.value)||30})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"days"})]})]})]})]})]})}),e.jsx(js,{value:"bookings",children:e.jsx(Q5s,{bookings:a,onCancel:C=>b.mutate({id:C})})})]})]})}):e.jsx(Es,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 md:p-8 space-y-8",children:[e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-16 h-16 bg-primary/10 rounded-2xl flex items-center justify-center",children:e.jsx(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(Pe,{children:e.jsxs(Re,{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(C=>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:C.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:C.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.desc})]})]},C.title))}),e.jsx(wo,{}),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($r,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const H9e=[{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 tMs(){const{user:t}=Fs(),s=ja(),{toast:r}=wa(),n=_r(),a=Jt(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState(null),[x,y]=S.useState({title:"",description:"",page_type:"lead_capture"}),{data:_=[],isLoading:b}=gt({queryKey:["landing-pages",s],queryFn:async()=>{const{data:C,error:E}=await G.from("landing_pages").select("*").eq("user_id",s).order("created_at",{ascending:!1});if(E)throw E;return C},enabled:!!s}),N=It({mutationFn:async()=>{const C=x.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")+"-"+Date.now().toString(36),{data:E}=await G.from("profiles").select("name, phone, avatar_url, email").eq("id",s).single(),L=x.page_type==="just_listed"||x.page_type==="just_sold",{data:I,error:O}=await G.from("landing_pages").insert({user_id:s,title:x.title,description:x.description||null,page_type:x.page_type,slug:C,hero_headline:L?x.page_type==="just_listed"?"🏡 Just Listed":"🎉 Just Sold":x.page_type==="lead_magnet"?"📥 Free Download":x.title,agent_name:(E==null?void 0:E.name)||null,agent_phone:(E==null?void 0:E.phone)||null,agent_email:(E==null?void 0:E.email)||t.email||null,agent_photo_url:(E==null?void 0:E.avatar_url)||null,property_status:L?x.page_type.replace("just_",""):null}).select().single();if(O)throw O;const V=sMs(x.page_type);if(V.length>0){const{error:q}=await G.from("landing_page_fields").insert(V.map(($,U)=>({...$,page_id:I.id,sort_order:U})));if(q)throw q}return I},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=It({mutationFn:async C=>{const{error:E}=await G.from("landing_pages").delete().eq("id",C);if(E)throw E},onSuccess:()=>{a.invalidateQueries({queryKey:["landing-pages"]}),d(null),r({title:"Landing page deleted"})}}),k=C=>`https://pages.relevelup.com/${C}`;return e.jsxs(Es,{title:"Landing Pages",children:[e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Landing Pages"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Create branded lead capture pages for events, consultations, and more"})]}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(Us,{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(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(fn,{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(Us,{className:"h-4 w-4 mr-2"})," Create Landing Page"]})]})}):e.jsx("div",{className:"grid gap-4",children:_.map(C=>{var E;return e.jsx(Pe,{className:"hover:shadow-md transition-shadow",children:e.jsx(Re,{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(Qe,{variant:C.is_published?"default":"secondary",className:"text-[10px]",children:C.is_published?"Published":"Draft"}),e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:((E=H9e.find(L=>L.id===C.page_type))==null?void 0:E.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(wn,{className:"h-3 w-3"})," ",C.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(fn,{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(k(C.slug)),children:e.jsx(Xy,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(k(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:k(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(ax,{className:"h-4 w-4"})})}),e.jsxs(jd,{align:"end",children:[e.jsxs(va,{onClick:()=>n(`/mission-control/landing-pages/${C.id}`),children:[e.jsx(ga,{className:"h-3.5 w-3.5 mr-2"})," Edit"]}),e.jsxs(va,{onClick:()=>d(C.id),className:"text-destructive",children:[e.jsx(gr,{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(xe,{children:"Page Title"}),e.jsx(De,{value:x.title,onChange:C=>y(E=>({...E,title:C.target.value})),placeholder:"e.g. Veterans Home & Land Expo"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description (optional)"}),e.jsx(vr,{value:x.description,onChange:C=>y(E=>({...E,description:C.target.value})),placeholder:"Brief internal description...",rows:2})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Page Template"}),e.jsxs(Bs,{value:x.page_type,onValueChange:C=>y(E=>({...E,page_type:C})),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:H9e.map(C=>e.jsx(vt,{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(En,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>N.mutate(),disabled:!x.title.trim()||N.isPending,children:N.isPending?"Creating...":"Create Page"})]})]})}),e.jsx(tc,{open:!!i,onOpenChange:()=>d(null),children:e.jsxs(Ml,{children:[e.jsxs(Tl,{children:[e.jsx(El,{children:"Delete Landing Page?"}),e.jsx(Pl,{children:"This will permanently delete this page and all its submissions."})]}),e.jsxs(Al,{children:[e.jsx(Il,{children:"Cancel"}),e.jsx(pl,{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(CO,{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 sMs(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 rMs=[{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 nMs(){const{pageId:t}=co(),s=_r(),{user:r}=Fs(),n=ja(),{toast:a}=wa(),o=Jt(),[l,i]=S.useState(null),[d,u]=S.useState(!1),{data:p,isLoading:x}=gt({queryKey:["landing-page",t],queryFn:async()=>{const{data:ie,error:ae}=await G.from("landing_pages").select("*").eq("id",t).single();if(ae)throw ae;return ie},enabled:!!t}),{data:y=[],isLoading:_}=gt({queryKey:["landing-page-fields",t],queryFn:async()=>{const{data:ie,error:ae}=await G.from("landing_page_fields").select("*").eq("page_id",t).order("sort_order");if(ae)throw ae;return ie},enabled:!!t}),{data:b=[]}=gt({queryKey:["landing-page-submissions",t],queryFn:async()=>{const{data:ie,error:ae}=await G.from("landing_page_submissions").select("*").eq("page_id",t).order("created_at",{ascending:!1});if(ae)throw ae;return ie},enabled:!!t}),{data:N=[]}=gt({queryKey:["my-listings-for-pages",n],queryFn:async()=>{const{data:ie,error:ae}=await G.from("listings").select("id, property_address, city, state, price, bedrooms, bathrooms, square_footage, description, status").eq("agent_id",n).order("created_at",{ascending:!1});if(ae)throw ae;return ie},enabled:!!r&&((p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold")}),[w,k]=S.useState({title:"",hero_headline:"",hero_subtext:"",hero_image_url:null,logo_url:null,primary_color:"#406E71",accent_color:"#2a4c64",agent_name:"",agent_phone:"",agent_email:"",agent_photo_url:null,success_message:"Thank you! We'll be in touch soon.",is_published:!1,description:"",lead_magnet_file_url:null,lead_magnet_file_name:null,lead_magnet_external_url:null,listing_id:null,property_address:"",property_price:"",property_beds:"",property_baths:"",property_sqft:"",property_description:"",property_photos:[],property_status:"just_listed"}),[C,E]=S.useState([]);S.useEffect(()=>{p&&k({title:p.title,hero_headline:p.hero_headline,hero_subtext:p.hero_subtext||"",hero_image_url:p.hero_image_url,logo_url:p.logo_url,primary_color:p.primary_color,accent_color:p.accent_color,agent_name:p.agent_name||"",agent_phone:p.agent_phone||"",agent_email:p.agent_email||"",agent_photo_url:p.agent_photo_url,success_message:p.success_message||"Thank you! We'll be in touch soon.",is_published:p.is_published,description:p.description||"",lead_magnet_file_url:p.lead_magnet_file_url||null,lead_magnet_file_name:p.lead_magnet_file_name||null,lead_magnet_external_url:p.lead_magnet_external_url||null,listing_id:p.listing_id||null,property_address:p.property_address||"",property_price:p.property_price||"",property_beds:p.property_beds||"",property_baths:p.property_baths||"",property_sqft:p.property_sqft||"",property_description:p.property_description||"",property_photos:Array.isArray(p.property_photos)?p.property_photos:[],property_status:p.property_status||"just_listed"})},[p]),S.useEffect(()=>{y.length>0&&E(y.map(ie=>({id:ie.id,field_type:ie.field_type,label:ie.label,placeholder:ie.placeholder,is_required:ie.is_required,options:typeof ie.options=="string"?ie.options:ie.options?JSON.stringify(ie.options):null,sort_order:ie.sort_order})))},[y]);const L=It({mutationFn:async()=>{const{error:ie}=await G.from("landing_pages").update({title:w.title,hero_headline:w.hero_headline,hero_subtext:w.hero_subtext||null,hero_image_url:w.hero_image_url,logo_url:w.logo_url,primary_color:w.primary_color,accent_color:w.accent_color,agent_name:w.agent_name||null,agent_phone:w.agent_phone||null,agent_email:w.agent_email||null,agent_photo_url:w.agent_photo_url,success_message:w.success_message,is_published:w.is_published,description:w.description||null,lead_magnet_file_url:w.lead_magnet_file_url,lead_magnet_file_name:w.lead_magnet_file_name,lead_magnet_external_url:w.lead_magnet_external_url,listing_id:w.listing_id,property_address:w.property_address||null,property_price:w.property_price||null,property_beds:w.property_beds||null,property_baths:w.property_baths||null,property_sqft:w.property_sqft||null,property_description:w.property_description||null,property_photos:w.property_photos,property_status:w.property_status,updated_at:new Date().toISOString()}).eq("id",t);if(ie)throw ie;if(await G.from("landing_page_fields").delete().eq("page_id",t),C.length>0){const{error:ae}=await G.from("landing_page_fields").insert(C.map((oe,pe)=>({page_id:t,field_type:oe.field_type,label:oe.label,placeholder:oe.placeholder||null,is_required:oe.is_required,options:oe.options?JSON.parse(oe.options):null,sort_order:pe})));if(ae)throw ae}},onSuccess:()=>{o.invalidateQueries({queryKey:["landing-page",t]}),o.invalidateQueries({queryKey:["landing-page-fields",t]}),a({title:"Page saved!"})},onError:ie=>a({title:"Error",description:ie.message,variant:"destructive"})}),I=async(ie,ae)=>{const oe=ie.name.split(".").pop(),pe=`landing-pages/${r.id}/${ae}-${Date.now()}.${oe}`,{error:_e}=await G.storage.from("recruit-landing").upload(pe,ie);if(_e)throw _e;const{data:{publicUrl:he}}=G.storage.from("recruit-landing").getPublicUrl(pe);return he},O=async(ie,ae)=>{var pe;const oe=(pe=ie.target.files)==null?void 0:pe[0];if(oe){i(ae);try{const _e=await I(oe,ae);k(he=>({...he,[ae]:_e})),a({title:"Image uploaded!"})}catch(_e){a({title:"Upload failed",description:_e.message,variant:"destructive"})}finally{i(null)}}},V=async ie=>{var oe;const ae=(oe=ie.target.files)==null?void 0:oe[0];if(ae){i("lead_magnet");try{const pe=await I(ae,"lead-magnet");k(_e=>({..._e,lead_magnet_file_url:pe,lead_magnet_file_name:ae.name})),a({title:"File uploaded!"})}catch(pe){a({title:"Upload failed",description:pe.message,variant:"destructive"})}finally{i(null)}}},q=async ie=>{const ae=ie.target.files;if(!(!ae||ae.length===0)){i("property_photos");try{const oe=[];for(const pe of Array.from(ae)){const _e=await I(pe,"property-photo");oe.push(_e)}k(pe=>({...pe,property_photos:[...pe.property_photos,...oe]})),a({title:`${oe.length} photo(s) uploaded!`})}catch(oe){a({title:"Upload failed",description:oe.message,variant:"destructive"})}finally{i(null)}}},$=async ie=>{const ae=N.find(pe=>pe.id===ie);if(!ae)return;const{data:oe}=await G.from("listing_photos").select("photo_url").eq("listing_id",ie).order("sort_order");k(pe=>({...pe,listing_id:ie,property_address:ae.property_address||`${ae.city}, ${ae.state}`,property_price:ae.price?`$${ae.price.toLocaleString()}`:"",property_beds:ae.bedrooms?String(ae.bedrooms):"",property_baths:ae.bathrooms?String(ae.bathrooms):"",property_sqft:ae.square_footage?ae.square_footage.toLocaleString():"",property_description:ae.description||"",property_photos:(oe==null?void 0:oe.map(_e=>_e.photo_url))||pe.property_photos})),a({title:"Listing data imported!"})},U=()=>{E(ie=>[...ie,{field_type:"text",label:"",placeholder:"",is_required:!1,options:null,sort_order:ie.length}])},se=(ie,ae)=>{E(oe=>oe.map((pe,_e)=>_e===ie?{...pe,...ae}:pe))},Y=ie=>{E(ae=>ae.filter((oe,pe)=>pe!==ie))},J=p?`https://pages.relevelup.com/${p.slug}`:"",X=(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 x||_?e.jsx(Es,{title:"Loading...",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):p?e.jsxs(Es,{title: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(Fa,{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(Qe,{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(wn,{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(lr,{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(Xy,{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:()=>L.mutate(),disabled:L.isPending,children:[e.jsx(_c,{className:"h-4 w-4 mr-2"}),L.isPending?"Saving...":"Save"]})]})]}),e.jsxs(ia,{defaultValue:"design",children:[e.jsxs(ea,{children:[e.jsx(ls,{value:"design",children:"Design"}),X&&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(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Page Details"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Page Title (internal)"}),e.jsx(De,{value:w.title,onChange:ie=>k(ae=>({...ae,title:ie.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description (internal)"}),e.jsx(De,{value:w.description,onChange:ie=>k(ae=>({...ae,description:ie.target.value}))})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Hero Section"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Headline"}),e.jsx(De,{value:w.hero_headline,onChange:ie=>k(ae=>({...ae,hero_headline:ie.target.value})),placeholder:"Join us for..."})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Subtext"}),e.jsx(vr,{value:w.hero_subtext,onChange:ie=>k(ae=>({...ae,hero_subtext:ie.target.value})),rows:2,placeholder:"A brief description..."})]}),e.jsxs("div",{children:[e.jsx(xe,{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($a,{className:"h-3.5 w-3.5 mr-1"}),l==="hero_image_url"?"Uploading...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ie=>O(ie,"hero_image_url")})]}),w.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k(ie=>({...ie,hero_image_url:null})),children:e.jsx(gr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Branding"})}),e.jsxs(Re,{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(xe,{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($a,{className:"h-3.5 w-3.5 mr-1"}),l==="logo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ie=>O(ie,"logo_url")})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{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($a,{className:"h-3.5 w-3.5 mr-1"}),l==="agent_photo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ie=>O(ie,"agent_photo_url")})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:w.primary_color,onChange:ie=>k(ae=>({...ae,primary_color:ie.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(De,{value:w.primary_color,onChange:ie=>k(ae=>({...ae,primary_color:ie.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:w.accent_color,onChange:ie=>k(ae=>({...ae,accent_color:ie.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(De,{value:w.accent_color,onChange:ie=>k(ae=>({...ae,accent_color:ie.target.value})),className:"font-mono text-xs"})]})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Agent Info (shown on page)"})}),e.jsx(Re,{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(xe,{children:"Name"}),e.jsx(De,{value:w.agent_name,onChange:ie=>k(ae=>({...ae,agent_name:ie.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Phone"}),e.jsx(De,{value:w.agent_phone,onChange:ie=>k(ae=>({...ae,agent_phone:ie.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Email"}),e.jsx(De,{value:w.agent_email,onChange:ie=>k(ae=>({...ae,agent_email:ie.target.value}))})]})]})})]})]}),X&&e.jsx(js,{value:"lead_magnet",className:"space-y-4 mt-4",children:e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Xa,{className:"h-4 w-4"})," Giveaway File"]})}),e.jsxs(Re,{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(xe,{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(Qe,{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($a,{className:"h-3.5 w-3.5 mr-1"}),l==="lead_magnet"?"Uploading...":"Upload File"]})}),e.jsx("input",{type:"file",className:"hidden",onChange:V})]}),w.lead_magnet_file_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k(ie=>({...ie,lead_magnet_file_url:null,lead_magnet_file_name:null})),children:e.jsx(gr,{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(xe,{className:"flex items-center gap-1",children:[e.jsx(Do,{className:"h-3.5 w-3.5"})," External URL"]}),e.jsx(De,{value:w.lead_magnet_external_url||"",onChange:ie=>k(ae=>({...ae,lead_magnet_external_url:ie.target.value||null})),placeholder:"https://drive.google.com/... or https://dropbox.com/...",className:"mt-1"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Link to a file on Google Drive, Dropbox, or any URL"})]})]})]})}),ce&&e.jsxs(js,{value:"property",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Mn,{className:"h-4 w-4"})," Import from Listing Exchange"]})}),e.jsxs(Re,{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(Bs,{value:w.listing_id||"",onValueChange:ie=>$(ie),children:[e.jsx(Rs,{children:e.jsx(qs,{placeholder:"Select a listing to import..."})}),e.jsx(Os,{children:N.map(ie=>{var ae;return e.jsxs(vt,{value:ie.id,children:[ie.property_address||`${ie.city}, ${ie.state}`," — $",(ae=ie.price)==null?void 0:ae.toLocaleString()]},ie.id)})})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Property Information"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Property Address"}),e.jsx(De,{value:w.property_address,onChange:ie=>k(ae=>({...ae,property_address:ie.target.value})),placeholder:"123 Main St, City, State"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Price"}),e.jsx(De,{value:w.property_price,onChange:ie=>k(ae=>({...ae,property_price:ie.target.value})),placeholder:"$450,000"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Beds"}),e.jsx(De,{value:w.property_beds,onChange:ie=>k(ae=>({...ae,property_beds:ie.target.value})),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Baths"}),e.jsx(De,{value:w.property_baths,onChange:ie=>k(ae=>({...ae,property_baths:ie.target.value})),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Sq Ft"}),e.jsx(De,{value:w.property_sqft,onChange:ie=>k(ae=>({...ae,property_sqft:ie.target.value})),placeholder:"2,400"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(vr,{value:w.property_description,onChange:ie=>k(ae=>({...ae,property_description:ie.target.value})),rows:3,placeholder:"Beautiful home in a great neighborhood..."})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Property Photos"})}),e.jsxs(Re,{className:"space-y-4",children:[w.property_photos.length>0&&e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:w.property_photos.map((ie,ae)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:ie,alt:`Property ${ae+1}`,className:"h-24 w-full object-cover rounded"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>k(oe=>({...oe,property_photos:oe.property_photos.filter((pe,_e)=>_e!==ae)})),children:e.jsx(gr,{className:"h-3 w-3"})})]},ae))}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="property_photos",children:e.jsxs("span",{children:[e.jsx($a,{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:U,children:[e.jsx(Us,{className:"h-3.5 w-3.5 mr-1"})," Add Field"]})]}),C.length===0?e.jsx(Pe,{children:e.jsx(Re,{className:"py-8 text-center text-muted-foreground",children:"No fields yet. Add fields to build your form."})}):e.jsx("div",{className:"space-y-3",children:C.map((ie,ae)=>e.jsx(Pe,{children:e.jsx(Re,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(hu,{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(xe,{className:"text-xs",children:"Field Type"}),e.jsxs(Bs,{value:ie.field_type,onValueChange:oe=>se(ae,{field_type:oe}),children:[e.jsx(Rs,{children:e.jsx(qs,{})}),e.jsx(Os,{children:rMs.map(oe=>e.jsx(vt,{value:oe.value,children:oe.label},oe.value))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Label"}),e.jsx(De,{value:ie.label,onChange:oe=>se(ae,{label:oe.target.value}),placeholder:"e.g. Full Name"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Placeholder"}),e.jsx(De,{value:ie.placeholder||"",onChange:oe=>se(ae,{placeholder:oe.target.value}),placeholder:"Optional hint text"})]})]}),(ie.field_type==="select"||ie.field_type==="multiselect")&&e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Options (comma-separated)"}),e.jsx(De,{value:ie.options?(typeof ie.options=="string"?JSON.parse(ie.options):ie.options).join(", "):"",onChange:oe=>se(ae,{options:JSON.stringify(oe.target.value.split(",").map(pe=>pe.trim()).filter(Boolean))}),placeholder:"Option 1, Option 2, Option 3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Er,{checked:ie.is_required,onCheckedChange:oe=>se(ae,{is_required:oe})}),e.jsx(xe,{className:"text-xs",children:"Required"})]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Y(ae),children:e.jsx(gr,{className:"h-3.5 w-3.5 text-destructive"})})]})})},ae))})]}),e.jsx(js,{value:"submissions",className:"mt-4",children:b.length===0?e.jsx(Pe,{children:e.jsx(Re,{className:"py-12 text-center text-muted-foreground",children:"No submissions yet. Share your page to start collecting leads!"})}):e.jsx("div",{className:"space-y-3",children:b.map(ie=>e.jsx(Pe,{children:e.jsx(Re,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:ie.contact_name||"Anonymous"}),ie.synced_to_crm&&e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:"Synced"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground mt-0.5",children:[ie.contact_email&&e.jsx("span",{className:"mr-3",children:ie.contact_email}),ie.contact_phone&&e.jsx("span",{children:ie.contact_phone})]}),ie.answers&&typeof ie.answers=="object"&&e.jsx("div",{className:"mt-2 text-sm space-y-1",children:Object.entries(ie.answers).map(([ae,oe])=>e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-muted-foreground",children:[ae,":"]})," ",e.jsx("span",{children:String(oe)})]},ae))})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(ie.created_at).toLocaleDateString()})]})})},ie.id))})}),e.jsxs(js,{value:"settings",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Publishing"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this page publicly accessible"})]}),e.jsx(Er,{checked:w.is_published,onCheckedChange:ie=>k(ae=>({...ae,is_published:ie}))})]}),w.is_published&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Public URL:"}),e.jsx("code",{className:"text-xs ml-2 break-all",children:J})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ot,{className:"text-base",children:"Thank You Message"})}),e.jsx(Re,{children:e.jsx(vr,{value:w.success_message,onChange:ie=>k(ae=>({...ae,success_message:ie.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(CO,{value:J,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:J})]})]})})]}):e.jsx(Es,{title:"Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Page not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/mission-control/landing-pages"),children:"Go back"})]})})}function G9e({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(tL,{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(eL,{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(Yy,{className:"h-3 w-3"}),"0%"]})}const aMs={Phone:Pn,MessageSquare:ki,Mail:rr,Gift:Ui,PenTool:Sb,Video:Tn},W9e=["bg-primary","bg-emerald-500","bg-amber-500","bg-sky-500","bg-purple-500","bg-orange-500","bg-pink-500","bg-teal-500"];function iMs(){const t=_r(),{contactsWithScores:s,stats:r,isLoading:n}=nhe(),{data:a}=VR(365),{data:o}=ike(),{data:l}=UR(),i=rke(),d=S.useMemo(()=>{if(!a)return{touchesThisMonth:0,touchesLastMonth:0,touchTrend:0};const L=new Date,I=pc(L),O=ex(L),V=pc(m4(L,1)),q=ex(m4(L,1)),$=a.filter(Y=>gg(new Date(Y.completed_at),{start:I,end:O})).length,U=a.filter(Y=>gg(new Date(Y.completed_at),{start:V,end:q})).length,se=U>0?Math.round(($-U)/U*100):$>0?100:0;return{touchesThisMonth:$,touchesLastMonth:U,touchTrend:se}},[a]),u=S.useMemo(()=>{if(!a)return 0;const L=new Date,I=pc(L),O=ex(L);return new Set(a.filter(V=>gg(new Date(V.completed_at),{start:I,end:O})).map(V=>V.contact_id)).size},[a]),p=S.useMemo(()=>{if(!o)return{closedThisMonth:0,totalGCI:0};const L=new Date,I=pc(L),O=ex(L),V=o.filter(q=>q.close_date&&gg(ml(q.close_date),{start:I,end:O}));return{closedThisMonth:V.length,totalGCI:V.reduce((q,$)=>q+(Number($.commission_amount)||0),0)}},[o]),x=S.useMemo(()=>{if(!s.length)return{newThisMonth:0,newLastMonth:0,trend:0};const L=new Date,I=pc(L),O=pc(m4(L,1)),V=ex(m4(L,1)),q=s.filter(se=>new Date(se.created_at)>=I).length,$=s.filter(se=>gg(new Date(se.created_at),{start:O,end:V})).length,U=$>0?Math.round((q-$)/$*100):q>0?100:0;return{newThisMonth:q,newLastMonth:$,trend:U}},[s]),y=S.useMemo(()=>{if(!a||!l)return[];const L=new Date,I=pc(L),O=ex(L),V=a.filter(U=>gg(new Date(U.completed_at),{start:I,end:O})),q={};V.forEach(U=>{const se=U.action_type_id;q[se]=(q[se]||0)+1});const $=V.length||1;return l.filter(U=>q[U.id]).map(U=>({id:U.id,name:U.name,icon:U.icon,count:q[U.id]||0,percent:Math.round((q[U.id]||0)/$*100)})).sort((U,se)=>se.count-U.count)},[a,l]),_=S.useMemo(()=>[...s].filter(L=>L.relationshipScore.status==="at-risk"||L.relationshipScore.status==="cooling").sort((L,I)=>{const O=L.relationshipScore.daysSinceTouch??9999;return(I.relationshipScore.daysSinceTouch??9999)-O}).slice(0,5),[s]),b=S.useMemo(()=>{if(!a)return[];const L=new Date,I=pc(L),O=ex(L),V=new Set(a.filter(q=>gg(new Date(q.completed_at),{start:I,end:O})).map(q=>q.contact_id));return s.filter(q=>q.relationshipScore.status==="warm"&&V.has(q.id)&&q.relationshipScore.touchCountLast12Months>=2).sort((q,$)=>$.relationshipScore.score-q.relationshipScore.score).slice(0,5)},[s,a]),N=S.useMemo(()=>{if(!a)return{currentStreak:0,longestStreak:0};const L=new Set(a.map(se=>{const Y=new Date(se.completed_at);return`${Y.getFullYear()}-${Y.getMonth()}-${Y.getDate()}`})),I=new Date;I.setHours(0,0,0,0);let O=0,V=new Date(I);for(;L.has(`${V.getFullYear()}-${V.getMonth()}-${V.getDate()}`);)O++,V.setDate(V.getDate()-1);let q=0,$=0;if(Array.from(L).sort().length>0){const se=a.map(Y=>{const J=new Date(Y.completed_at);return J.setHours(0,0,0,0),J.getTime()}).filter((Y,J,X)=>X.indexOf(Y)===J).sort((Y,J)=>Y-J);$=1;for(let Y=1;Y[...s].sort((L,I)=>L.relationshipScore.score-I.relationshipScore.score),[s]),k=w.filter(L=>L.relationshipScore.status==="warm"),C=w.filter(L=>L.relationshipScore.status==="cooling"),E=w.filter(L=>L.relationshipScore.status==="at-risk");return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Relationship Scorecard"}),e.jsxs("p",{className:"text-muted-foreground",children:[ps(new Date,"MMMM yyyy")," — Your monthly relationship health report"]})]}),N.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:N.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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{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:d.touchesThisMonth}),e.jsx(G9e,{value:d.touchTrend})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["vs ",d.touchesLastMonth," last month"]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(lr,{className:"h-4 w-4"}),"Reached"]}),e.jsx("div",{className:"text-3xl font-bold",children:u}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["of ",r.total," contacts"]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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:x.newThisMonth}),e.jsx(G9e,{value:x.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(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Rh,{className:"h-4 w-4 text-primary"}),"Weekly Goal"]})}),e.jsxs(Re,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[i.actionsThisWeek," of ",i.weeklyGoal," touches"]}),e.jsxs("span",{className:"text-sm font-medium",children:[Math.round(i.progress),"%"]})]}),e.jsx(gi,{value:i.progress,className:"h-3"}),i.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(Vi,{className:"h-3 w-3"}),"Goal reached! 🎉"]}),i.progress<100&&i.progress>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[i.weeklyGoal-i.actionsThisWeek," more to hit your goal"]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(ch,{className:"h-4 w-4 text-orange-500"}),"Momentum"]})}),e.jsxs(Re,{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:N.currentStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"}),N.currentStreak>=7&&e.jsx("span",{className:"ml-1",children:"🔥"}),N.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:N.longestStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"})]})]}),N.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(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(ih,{className:"h-4 w-4"}),"How You're Reaching Out"]})}),e.jsx(Re,{children:y.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:y.slice(0,5).map((L,I)=>{const O=aMs[L.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(O,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:L.name})]}),e.jsxs("span",{className:"text-muted-foreground",children:[L.count," (",L.percent,"%)"]})]}),e.jsx(gi,{value:L.percent,className:Rt("h-1.5 bg-muted [&>div]:",W9e[I%W9e.length])})]},L.id)})})})]})]}),_.length>0&&e.jsxs(Pe,{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(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(Pn,{className:"h-5 w-5 text-primary"}),"Who to Reach Out to Today"]}),e.jsxs(Qe,{variant:"secondary",children:[_.length," contacts"]})]}),e.jsx(hr,{children:"These relationships need attention the most"})]}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-2",children:_.map(L=>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/${L.id}`),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(j8,{score:L.relationshipScore,showScore:!0,size:"sm",showTooltip:!1}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[L.first_name," ",L.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:L.relationshipScore.daysSinceTouch===null?"Never contacted":`Last touch ${L.relationshipScore.daysSinceTouch}d ago`})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[L.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`tel:${L.phone}`)},children:e.jsx(Pn,{className:"h-4 w-4"})}),L.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`mailto:${L.email}`)},children:e.jsx(rr,{className:"h-4 w-4"})}),e.jsx(Sa,{className:"h-4 w-4 text-muted-foreground"})]})]},L.id))})})]}),b.length>0&&e.jsxs(Pe,{className:"border-l-4 border-l-emerald-500",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(ec,{className:"h-5 w-5 text-emerald-500"}),"Biggest Wins This Month"]}),e.jsx(hr,{children:"Relationships you've successfully warmed up"})]}),e.jsx(Re,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:b.map(L=>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/${L.id}`),children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),e.jsxs("span",{className:"text-sm font-medium",children:[L.first_name," ",L.last_name]}),e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-bold",children:L.relationshipScore.score})]},L.id))})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Pe,{className:"border-l-4 border-l-emerald-500",children:e.jsxs(Re,{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(gi,{value:r.total?r.warm/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-emerald-500"})]})}),e.jsx(Pe,{className:"border-l-4 border-l-amber-500",children:e.jsxs(Re,{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(gi,{value:r.total?r.cooling/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-amber-500"})]})}),e.jsx(Pe,{className:"border-l-4 border-l-red-500",children:e.jsxs(Re,{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(gi,{value:r.total?r.atRisk/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-red-500"})]})})]}),e.jsx(Pe,{children:e.jsx(Re,{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(mL,{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:p.closedThisMonth})]})]}),p.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:["$",p.totalGCI.toLocaleString()]})]})]})})}),e.jsxs(ia,{defaultValue:"at-risk",children:[e.jsxs(ea,{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:E},{key:"cooling",contacts:C},{key:"warm",contacts:k}].map(({key:L,contacts:I})=>e.jsx(js,{value:L,children:e.jsx(Pe,{children:e.jsx(Re,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:I.slice(0,20).map(O=>e.jsxs(Ms,{className:"cursor-pointer",onClick:()=>t(`/mission-control/contacts/${O.id}`),children:[e.jsxs(ut,{className:"font-medium",children:[O.first_name," ",O.last_name]}),e.jsx(ut,{className:"hidden md:table-cell text-muted-foreground",children:O.relationshipScore.daysSinceTouch===null?"Never":O.relationshipScore.daysSinceTouch===0?"Today":`${O.relationshipScore.daysSinceTouch}d ago`}),e.jsx(ut,{className:"hidden md:table-cell",children:O.relationshipScore.touchCountLast12Months}),e.jsx(ut,{children:e.jsx(j8,{score:O.relationshipScore,showScore:!0})}),e.jsx(ut,{children:e.jsx(Sa,{className:"h-4 w-4 text-muted-foreground"})})]},O.id))})]})})})},L))]})]})})}function oMs(){const{user:t}=Fs();return gt({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 lMs(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 $I=[{key:"email",label:"Missing Email",icon:rr,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:Pn,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:Da,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 R5(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 cMs({contact:t,onClose:s}){const r=tke(),[n,a]=S.useState({email:t.email||"",phone:t.phone||"",address:t.address||"",birthday:t.birthday||"",home_anniversary:t.home_anniversary||""}),o=async()=>{r.mutate({id:t.id,...n},{onSuccess:()=>s()})},l=$I.filter(i=>i.fieldKey&&i.check(t));return e.jsx(GA,{open:!0,onOpenChange:()=>s(),children:e.jsxs(wC,{className:"sm:max-w-md overflow-y-auto",children:[e.jsxs(WA,{children:[e.jsxs(KA,{children:["Quick Edit — ",t.first_name," ",t.last_name]}),e.jsxs(KZe,{children:["Fill in missing fields to improve this contact's completeness (",R5(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(Qe,{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(xe,{className:"flex items-center gap-1.5",children:[e.jsx(rr,{className:"h-3.5 w-3.5"})," Email"]}),e.jsx(De,{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(xe,{className:"flex items-center gap-1.5",children:[e.jsx(Pn,{className:"h-3.5 w-3.5"})," Phone"]}),e.jsx(De,{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(xe,{className:"flex items-center gap-1.5",children:[e.jsx(Da,{className:"h-3.5 w-3.5"})," Address"]}),e.jsx(De,{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(xe,{className:"flex items-center gap-1.5",children:[e.jsx(lh,{className:"h-3.5 w-3.5"})," Birthday"]}),e.jsx(De,{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(xe,{className:"flex items-center gap-1.5",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," Home Anniversary"]}),e.jsx(De,{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(_c,{className:"h-4 w-4 mr-1.5"}),r.isPending?"Saving...":"Save Changes"]}),e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"})]})]})]})})}const k0e="Quick favor — can you update your info? 🙏",K9e=`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 dMs(){const t=_r(),{data:s,isLoading:r}=qh(),{data:n}=jf(),{intakePage:a}=wme(),{isGmailConnected:o,gmailEmail:l}=jp(),{data:i}=oMs(),[d,u]=S.useState("blocked"),[p,x]=S.useState("all"),[y,_]=S.useState(null),[b,N]=S.useState(!1),[w,k]=S.useState(!1),[C,E]=S.useState(null),[L,I]=S.useState([]),[O,V]=S.useState(""),[q,$]=S.useState(""),U=S.useMemo(()=>s?p==="all"?s:s.filter(Le=>{var Ne;return(Ne=Le.tags)==null?void 0:Ne.some(qe=>qe.relationship_type_id===p)}):[],[s,p]),se=S.useMemo(()=>U.filter(Le=>!Le.email&&!Le.phone),[U]),Y=S.useMemo(()=>{if(!U.length)return{overallCompleteness:0,fullyComplete:0,contactsByGap:{}};const Le={};Le.blocked=se,$I.forEach(ve=>{Le[ve.key]=U.filter(ve.check)});const Ne=U.map(R5),qe=U.length>0?Math.round(Ne.reduce((ve,dt)=>ve+dt,0)/U.length):0,ze=Ne.filter(ve=>ve===100).length;return{contactsByGap:Le,overallCompleteness:qe,fullyComplete:ze}},[U,se]),J=S.useMemo(()=>{if(!s||s.length===0)return null;const Le=pc(m4(new Date,1)),Ne=s.filter(dt=>new Date(dt.created_at)dt+fe,0)/Ne.length),ze=Y.overallCompleteness,ve=ze-qe;return{oldCompleteness:qe,currentCompleteness:ze,diff:ve,oldCount:Ne.length}},[s,Y.overallCompleteness]),X=U.length,ce=S.useCallback(()=>{var Je;const Le=Y.contactsByGap[d];if(!(Le!=null&&Le.length))return;const Ne=d==="blocked"?"Outreach Blocked":((Je=$I.find(at=>at.key===d))==null?void 0:Je.label)||d,qe=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Completeness %"],ze=Le.map(at=>[at.first_name,at.last_name||"",at.email||"",at.phone||"",at.address||"",at.birthday||"",at.home_anniversary||"",R5(at).toString()]),ve=[qe.join(","),...ze.map(at=>at.map(Ae=>`"${Ae.replace(/"/g,'""')}"`).join(","))].join(` `),dt=new Blob([ve],{type:"text/csv"}),fe=URL.createObjectURL(dt),Ve=document.createElement("a");Ve.href=fe,Ve.download=`sphere-gaps-${Ne.toLowerCase().replace(/\s+/g,"-")}-${ps(new Date,"yyyy-MM-dd")}.csv`,Ve.click(),URL.revokeObjectURL(fe),gn({title:`Exported ${Le.length} contacts to CSV`})},[Y.contactsByGap,d]),ie=S.useCallback(async Le=>{if(!a)return null;try{const{data:Ne,error:qe}=await G.from("contact_intake_tokens").insert({contact_id:Le,intake_page_id:a.id}).select("token").single();if(qe)throw qe;return Ne.token}catch{return null}},[a]),ae=S.useCallback(Le=>a?`https://contacts.relevelup.com/${a.slug}?t=${Le}`:"",[a]),oe=S.useCallback(async Le=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Ne=await ie(Le);Ne?(await navigator.clipboard.writeText(ae(Ne)),me.success("Update link copied!")):me.error("Failed to generate link")},[a,ie,ae,t]),pe=S.useCallback(async Le=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}if(!Le.email){me.error("This contact has no email address");return}const Ne=await ie(Le.id);if(!Ne){me.error("Failed to generate link");return}const qe=ae(Ne),ze=K9e.replace("{{update_link}}",qe).replace(/\{\{first_name\}\}/g,Le.first_name).replace(/\{\{last_name\}\}/g,Le.last_name||""),ve=k0e.replace(/\{\{first_name\}\}/g,Le.first_name).replace(/\{\{last_name\}\}/g,Le.last_name||"");if(o)E({id:Le.id,first_name:Le.first_name,last_name:Le.last_name,email:Le.email}),I([]),V(ve),$(ze),k(!0);else{const dt=encodeURIComponent(k0e.replace("{{first_name}}",Le.first_name)),fe=encodeURIComponent(ze.replace(/\{\{first_name\}\}/g,Le.first_name));window.location.href=`mailto:${Le.email}?subject=${dt}&body=${fe}`}},[a,ie,ae,o,t]),_e=S.useCallback(async Le=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Ne=Le.filter(ve=>ve.email);if(!Ne.length){me.error("No contacts with email addresses in this group");return}const qe=new Set((i||[]).map(ve=>ve.contact_id)),ze=Ne.filter(ve=>!qe.has(ve.id));if(ze.length===0){me.info(`All ${Ne.length} contacts with email have already been sent this update request.`);return}if(ze.lengthYe.id),intake_page_id:a.id}});if(dt)throw dt;const fe=typeof ve=="string"?JSON.parse(ve):ve,Ve=Array.isArray(fe)?fe:Array.isArray(fe==null?void 0:fe.tokens)?fe.tokens:[],Je=new Map(Ve.filter(Ye=>(Ye==null?void 0:Ye.contact_id)&&(Ye==null?void 0:Ye.token)).map(Ye=>[Ye.contact_id,Ye.token]));if(Je.size===0&&(await Promise.all(Ne.map(async We=>({contactId:We.id,token:await ie(We.id)})))).forEach(({contactId:We,token:ot})=>{ot&&Je.set(We,ot)}),Je.size===0){me.error("Failed to generate update links. Please try again.");return}const at=ze.filter(Ye=>Je.has(Ye.id)).map(Ye=>({id:Ye.id,first_name:Ye.first_name,last_name:Ye.last_name,email:Ye.email,updateLink:ae(Je.get(Ye.id))})),Ae=K9e;E(null),I(at),V(k0e),$(Ae),k(!0),me.success(`Ready to email ${at.length} contacts`)}catch{me.error("Failed to generate links")}finally{N(!1)}},[a,o,ae,ie,t]),we=[{key:"blocked",label:"Outreach Blocked",icon:Cv,color:"text-destructive",description:"Missing BOTH email AND phone — completely unreachable"},...$I].find(Le=>Le.key===d),je=Y.contactsByGap[d]||[],Ue=je.filter(Le=>Le.email).length,Te=new Set((i||[]).map(Le=>Le.contact_id)),Me=je.filter(Le=>Le.email&&Te.has(Le.id)).length,Fe=Ue-Me;return e.jsxs(Es,{children:[e.jsxs("div",{className:"space-y-6 p-4 md:p-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Sphere Gaps Analyzer"}),e.jsx("p",{className:"text-muted-foreground",children:"Find missing info in your database to maximize your outreach potential"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Eg,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(Bs,{value:p,onValueChange:x,children:[e.jsx(Rs,{className:"w-[180px]",children:e.jsx(qs,{placeholder:"Filter by tag"})}),e.jsxs(Os,{children:[e.jsx(vt,{value:"all",children:"All Contacts"}),n==null?void 0:n.map(Le=>e.jsx(vt,{value:Le.id,children:Le.name},Le.id))]})]})]})]}),e.jsx(Pe,{children:e.jsxs(Re,{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:[Y.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:[Y.fullyComplete," ",e.jsxs("span",{className:"text-base font-normal text-muted-foreground",children:["/ ",X]})]})]})]}),e.jsx(gi,{value:Y.overallCompleteness,className:"h-3"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:Y.overallCompleteness>=80?"🎉 Great job! Your database is well maintained.":Y.overallCompleteness>=50?"⚡ Good start — fill in the gaps below to unlock more outreach channels.":"🔍 Your database needs attention. Start with emails and phone numbers."})]})}),se.length>0&&e.jsx(Pe,{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(Re,{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:se.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:$I.map(Le=>{var dt;const Ne=((dt=Y.contactsByGap[Le.key])==null?void 0:dt.length)||0,qe=X>0?Math.round(Ne/X*100):0,ze=Le.icon,ve=d===Le.key;return e.jsx(Pe,{className:Rt("cursor-pointer transition-all hover:shadow-md",ve&&"ring-2 ring-primary"),onClick:()=>u(Le.key),children:e.jsxs(Re,{className:"pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ze,{className:Rt("h-5 w-5",Le.color)}),e.jsx("span",{className:"text-sm font-medium",children:Le.label})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-2xl font-bold",children:Ne}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[qe,"% of contacts"]})]}),e.jsx(gi,{value:100-qe,className:"mt-2 h-1.5"})]})},Le.key)})}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{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(Qe,{variant:"secondary",children:[je.length," contacts"]}),Me>0&&e.jsxs(Qe,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(Qn,{className:"h-3 w-3"}),Me," already emailed"]}),je.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"]}),Fe>0&&a&&e.jsxs(K,{size:"sm",onClick:()=>_e(je),disabled:b,className:"gap-1.5",children:[b?e.jsx(_s,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(An,{className:"h-3.5 w-3.5"}),"Email ",Fe," Update Links"]})]})]})]}),e.jsx(hr,{children:we==null?void 0:we.description})]}),e.jsx(Re,{className:"p-0",children:je.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(Qn,{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(In,{children:[e.jsx(Ln,{children:e.jsxs(Ms,{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(Dn,{children:je.map(Le=>{const Ne=lMs(i,Le.id);return e.jsxs(Ms,{children:[e.jsx(ut,{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/${Le.id}`),children:[Le.first_name," ",Le.last_name]}),!Le.email&&!Le.phone&&d!=="blocked"&&e.jsx(Qe,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Blocked"}),Ne&&e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:e.jsxs(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0 gap-1 text-muted-foreground border-muted",children:[e.jsx(rr,{className:"h-2.5 w-2.5"}),gl(new Date(Ne),{addSuffix:!0})]})}),e.jsxs(Cl,{children:["Last bulk emailed ",ps(new Date(Ne),"MMM d, yyyy h:mm a")]})]})]})}),e.jsx(ut,{className:"hidden md:table-cell text-muted-foreground",children:Le.email||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(ut,{className:"hidden md:table-cell text-muted-foreground",children:Le.phone||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gi,{value:R5(Le),className:"h-2 w-16"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[R5(Le),"%"]})]})}),e.jsx(ut,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>_(Le),children:e.jsx(Tv,{className:"h-3.5 w-3.5"})})}),e.jsx(Cl,{children:"Quick edit"})]}),(Le.email||Le.phone)&&a&&e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>oe(Le.id),children:e.jsx(Ya,{className:"h-3.5 w-3.5"})})}),e.jsx(Cl,{children:"Copy update link"})]}),Le.email&&a&&e.jsxs(Yl,{children:[e.jsx(Xl,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>pe(Le),children:e.jsx(rr,{className:"h-3.5 w-3.5"})})}),e.jsx(Cl,{children:"Email update link"})]})]})})]},Le.id)})})]})})]})]}),y&&e.jsx(cMs,{contact:y,onClose:()=>_(null)}),e.jsx(T1,{open:w,onOpenChange:k,contact:C||void 0,bulkContacts:L.length>0?L:void 0,defaultSubject:O,defaultBody:q,gmailEmail:l})]})}function uMs(){const{user:t}=Fs(),{intakePage:s,isLoading:r,createPage:n,updatePage:a,submissions:o,loadingSubmissions:l}=wme(),[i,d]=S.useState(""),[u,p]=S.useState(""),[x,y]=S.useState(!1);S.useEffect(()=>{s&&p(s.welcome_message||"")},[s]),S.useEffect(()=>{if(t!=null&&t.email&&!s){const E=t.email.split("@")[0];d(E.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(Pe,{children:e.jsx(Re,{className:"p-6 flex items-center justify-center",children:e.jsx(_s,{className:"h-5 w-5 animate-spin text-muted-foreground"})})});if(!s)return e.jsxs(Pe,{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(Ot,{children:"Connect Page"}),e.jsx(hr,{children:"Create a public link to capture contact info from new leads or update existing contacts"})]})]})}),e.jsx(Re,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{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(De,{value:i,onChange:E=>d(E.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(_s,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Connect Page"]})]})})]});const N=o.filter(E=>!E.is_processed),w=o.filter(E=>E.is_processed),k=N.length,C=(E,L)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:[E.first_name," ",E.last_name||""]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[E.email&&e.jsx("span",{children:E.email}),E.phone&&e.jsx("span",{children:E.phone})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[E.real_estate_interest&&E.real_estate_interest!=="not_now"&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:E.real_estate_interest==="buying"?"🏠 Buying":E.real_estate_interest==="selling"?"📋 Selling":E.real_estate_interest==="both"?"🔄 Both":E.real_estate_interest}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ln,{className:"h-3 w-3"}),ps(new Date(E.created_at),"MMM d")]}),L&&e.jsx(Qn,{className:"h-4 w-4 text-emerald-500"})]})]},E.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{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(Ot,{children:"Connect Page"}),e.jsx(hr,{children:"Share this link to capture contact info"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{htmlFor:"active-toggle",className:"text-sm text-muted-foreground",children:"Active"}),e.jsx(Er,{id:"active-toggle",checked:s.is_active,onCheckedChange:E=>a.mutate({is_active:E})})]})]})}),e.jsxs(Re,{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(xe,{children:"Welcome Message"}),x?e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsx("textarea",{value:u,onChange:E=>p(E.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(Pe,{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(lr,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-base",children:"New Submissions"}),k>0&&e.jsxs(hr,{children:[k," awaiting sync"]})]})]}),k>0&&e.jsxs(K,{size:"sm",onClick:async()=>{try{const{data:E,error:L}=await G.functions.invoke("process-intake-submissions",{body:{action:"process_all"}});if(L)throw L;me.success(`Synced ${E.processed} contacts to your CRM!`)}catch{me.error("Failed to sync")}},className:"gap-1.5",children:["Sync ",k," to CRM"]})]})}),e.jsx(Re,{children:l?e.jsx(_s,{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(E=>C(E,!1))})})]}),w.length>0&&e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Qn,{className:"h-5 w-5 text-emerald-500"}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-base",children:"Synced to CRM"}),e.jsxs(hr,{children:[w.length," contacts already in your database"]})]})]})}),e.jsx(Re,{children:e.jsxs("div",{className:"space-y-3",children:[w.slice(0,10).map(E=>C(E,!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 hMs(){return e.jsx(Es,{children:e.jsxs("div",{className:"max-w-3xl mx-auto py-8 px-4",children:[e.jsx("h1",{className:"text-2xl font-bold mb-6",children:"Connect Page"}),e.jsx(uMs,{})]})})}const mMs={property_view:{label:"Viewed Listing",icon:wn,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:al,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"}},pMs={home:"🏠",search:"🔍",listing:"🏡",city:"🌆",sell:"💰",blog:"📝",dashboard:"📊",other:"📄"};function fMs({locations:t}){const s=S.useRef(null),r=S.useRef(null),[n,a]=S.useState(null);return S.useEffect(()=>{G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle().then(({data:o})=>{o!=null&&o.value&&a(o.value)})},[]),S.useEffect(()=>{if(!(!s.current||!n||r.current))return xc.accessToken=n,r.current=new xc.Map({container:s.current,style:"mapbox://styles/mapbox/light-v11",zoom:3.5,center:[-98.5795,39.8283],interactive:!0}),r.current.addControl(new xc.NavigationControl,"top-right"),()=>{var o;(o=r.current)==null||o.remove(),r.current=null}},[n]),S.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 xc.Marker({element:u,anchor:"center"}).setLngLat([l.lng,l.lat]).setPopup(new xc.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 xc.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(nS,{className:"h-5 w-5 mr-2"})," Map not configured"]})}function Ect(){var I,O,V,q;const{user:t}=Fs(),s=_r(),{isGmailConnected:r,gmailEmail:n}=jp(),[a,o]=S.useState("all"),[l,i]=S.useState("30"),[d,u]=S.useState(""),[p,x]=S.useState(!1),[y,_]=S.useState(null),{data:b,isLoading:N}=gt({queryKey:["lead-site-activity-full",t==null?void 0:t.id,l],queryFn:async()=>{const{data:$,error:U}=await G.rpc("get_lead_site_activity_full",{_user_id:t.id,_days:parseInt(l)});if(U)throw U;const se=$;return{...se,visitor_locations:((se==null?void 0:se.visitor_locations)||[]).map(Y=>({...Y,lat:Number(Y.lat),lng:Number(Y.lng),visitor_count:Number(Y.visitor_count??Y.visit_count??0)}))}},enabled:!!t,refetchInterval:6e4}),w=S.useMemo(()=>{if(!(b!=null&&b.activities))return[];let $=b.activities;if(a!=="all"&&($=$.filter(U=>U.activity_type===a)),d){const U=d.toLowerCase();$=$.filter(se=>{var Y,J,X,ce,ie;return((Y=se.visitor_name)==null?void 0:Y.toLowerCase().includes(U))||((J=se.visitor_email)==null?void 0:J.toLowerCase().includes(U))||((X=se.mls_number)==null?void 0:X.includes(U))||((ce=se.property_address)==null?void 0:ce.toLowerCase().includes(U))||((ie=se.lead_type)==null?void 0:ie.toLowerCase().includes(U))})}return $},[b==null?void 0:b.activities,a,d]),k=b==null?void 0:b.subdomain,C=$=>k?`https://${k}.thelocalmove.com/listing/${$}`:null,E=b==null?void 0:b.stats,L=$=>{if($.visitor_email)if(r){const U=($.visitor_name||"").split(" ");_({id:$.contact_id||"",first_name:U[0]||"",last_name:U.slice(1).join(" ")||null,email:$.visitor_email}),x(!0)}else window.location.href=`mailto:${$.visitor_email}`};return!(b!=null&&b.has_site)&&!N?e.jsx(Es,{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(Es,{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(Fa,{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"]},$))})]}),E&&e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{label:"Page Views",value:E.total_page_views,sub:E.page_views_7d,icon:fn,color:"text-violet-600 dark:text-violet-400",bg:"bg-violet-500/10"},{label:"Listing Views",value:E.total_views,sub:E.views_7d,icon:wn,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-500/10"},{label:"New Leads",value:E.total_leads,sub:E.leads_7d,icon:al,color:"text-emerald-600 dark:text-emerald-400",bg:"bg-emerald-500/10"},{label:"Saved Listings",value:E.total_saved,sub:E.saved_7d,icon:Za,color:"text-rose-600 dark:text-rose-400",bg:"bg-rose-500/10"}].map($=>e.jsx(Pe,{children:e.jsxs(Re,{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(ia,{defaultValue:"overview",className:"space-y-4",children:[e.jsxs(ea,{children:[e.jsxs(ls,{value:"overview",className:"gap-1.5",children:[e.jsx(to,{className:"h-4 w-4"})," Overview"]}),e.jsxs(ls,{value:"leads",className:"gap-1.5",children:[e.jsx(Oh,{className:"h-4 w-4"})," Lead Inbox"]}),e.jsxs(ls,{value:"map",className:"gap-1.5",children:[e.jsx(nS,{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(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Yo,{className:"h-4 w-4 text-primary"}),"Most Viewed Listings"]})}),e.jsx(Re,{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(($,U)=>{const se=C($.mls_number);return e.jsxs("a",{href:se||"#",target:"_blank",rel:"noopener noreferrer",onClick:Y=>{se||Y.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:U+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:gl(new Date($.last_viewed),{addSuffix:!0})})]}),e.jsxs(Qe,{variant:"secondary",className:"shrink-0 text-xs",children:[$.view_count," view",$.view_count!==1?"s":""]}),se&&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(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4 text-primary"}),"Most Visited Pages"]})}),e.jsx(Re,{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(fn,{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(($,U)=>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:U+1}),e.jsx("span",{className:"text-lg w-8 text-center",children:pMs[$.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(Qe,{variant:"secondary",className:"shrink-0 text-xs capitalize",children:$.page_type}),e.jsx(Qe,{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(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Da,{className:"h-4 w-4 text-primary"}),"Where Visitors Are Browsing From"]})}),e.jsx(Re,{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(Da,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{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:((I=b==null?void 0:b.activities)==null?void 0:I.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:((V=b==null?void 0:b.activities)==null?void 0:V.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(Qe,{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(Pe,{children:e.jsxs(Re,{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(($,U)=>{const se=mMs[$.activity_type],Y=se.icon,J=gl(new Date($.occurred_at),{addSuffix:!0}),X=$.visitor_name&&$.visitor_name!=="Site Visitor";return e.jsx(Pe,{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(Re,{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(Y,{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:[X?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(Qe,{variant:"outline",className:`text-[10px] shrink-0 ${se.badgeClass}`,children:se.label}),$.lead_type&&e.jsx(Qe,{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(Da,{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(ln,{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:()=>L($),children:e.jsx(rr,{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(Pn,{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(ki,{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(Sa,{className:"h-4 w-4"})})]})]})})},`${$.activity_type}-${$.occurred_at}-${U}`)})})]}),e.jsxs(js,{value:"map",className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(nS,{className:"h-4 w-4 text-primary"}),"Visitor Locations",(b==null?void 0:b.visitor_locations)&&b.visitor_locations.length>0&&e.jsxs(Qe,{variant:"secondary",className:"text-xs ml-2",children:[b.visitor_locations.reduce(($,U)=>$+U.visitor_count,0)," visitors from ",b.visitor_locations.length," cities"]})]})}),e.jsx(Re,{className:"pt-0",children:e.jsx("div",{className:"h-[450px] rounded-xl overflow-hidden border",children:e.jsx(fMs,{locations:(b==null?void 0:b.visitor_locations)||[]})})})]}),(b==null?void 0:b.visitor_locations)&&b.visitor_locations.length>0&&e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(Ot,{className:"text-base",children:"Location Breakdown"})}),e.jsx(Re,{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(Da,{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(T1,{open:p,onOpenChange:x,contact:y,gmailEmail:n})]})}const xMs=Object.freeze(Object.defineProperty({__proto__:null,default:Ect},Symbol.toStringTag,{value:"Module"})),gMs=S.lazy(()=>Ha(()=>import("./MobileAgentApp-Z9KQIU67.js"),[])),yMs=S.lazy(()=>Ha(()=>import("./PostcardManager-CkLKvV8Q.js"),__vite__mapDeps([14,15]))),vMs=S.lazy(()=>Ha(()=>import("./HomeReelManager-DozNkTux.js"),[])),_Ms=S.lazy(()=>Ha(()=>import("./AdminCredits-DAqOnuJ8.js"),[])),bMs=S.lazy(()=>Ha(()=>import("./DirectMail-C5ZmPrXe.js").then(t=>t.D),__vite__mapDeps([16,15]))),wMs=S.lazy(()=>Ha(()=>import("./InnerCirclePopbyMap-rPL7zTuY.js"),[])),jMs=S.lazy(()=>Ha(()=>import("./LiveVisitorFeed-Cv9GIEy2.js"),[])),NMs=S.lazy(()=>Ha(()=>import("./LeadSites-CKQuAdhY.js"),[])),Z9e=S.lazy(()=>Ha(()=>import("./LeadSiteEditor-diR5mQes.js"),__vite__mapDeps([17,18,19]))),kMs=S.lazy(()=>Ha(()=>import("./AdminLeadSiteThemes-DivzmJqf.js"),__vite__mapDeps([20,18]))),SMs=S.lazy(()=>Ha(()=>import("./AdminMlsFeeds-LEhziMj0.js"),[])),CMs=S.lazy(()=>Ha(()=>import("./AdminLeadSiteAnalytics-DkTyjtOe.js"),[])),MMs=S.lazy(()=>Ha(()=>import("./AdminWebsiteInterests-BpCmyyL8.js"),[])),TMs=S.lazy(()=>Ha(()=>import("./AdminMlsFeeTracker-BE2xS0EQ.js"),[])),AMs=S.lazy(()=>Ha(()=>import("./MLSListings-BBFoLWYj.js"),[])),EMs=S.lazy(()=>Ha(()=>import("./MLSListingDetail-BHLAEse8.js"),[])),PMs=S.lazy(()=>Ha(()=>import("./MarketReportPage-BEVvf8Rv.js"),[]));S.lazy(()=>Ha(()=>Promise.resolve().then(()=>xMs),void 0));const IMs=S.lazy(()=>Ha(()=>import("./EmailCampaigns-CaswYTTi.js"),[])),LMs=S.lazy(()=>Ha(()=>import("./EmailCampaignComposer-i4EycNbA.js"),__vite__mapDeps([21,22]))),DMs=S.lazy(()=>Ha(()=>import("./EmailCampaignDetail-DabfYitN.js"),[])),RMs=S.lazy(()=>Ha(()=>import("./SharedCampaignTemplates-CNl6Fj4z.js"),__vite__mapDeps([23,24,22]))),OMs=S.lazy(()=>Ha(()=>import("./AgentTemplates-Cei_4jdh.js"),__vite__mapDeps([25,24,22]))),Y9e=S.lazy(()=>Ha(()=>import("./TheLocalMoveHome-C68SePJl.js"),__vite__mapDeps([26,27]))),X9e=S.lazy(()=>Ha(()=>import("./TheLocalMoveGetStarted-Bj3_dYUl.js"),__vite__mapDeps([28,27]))),Q9e=S.lazy(()=>Ha(()=>import("./TheLocalMoveCheckout-CHrrKNH_.js"),[])),J9e=S.lazy(()=>Ha(()=>import("./TheLocalMoveCheckoutSuccess-v8YgOQQd.js"),[])),FMs=S.lazy(()=>Ha(()=>import("./AdminWebsiteOrders-hr6_Spt5.js"),[])),zMs=new ovt({defaultOptions:{queries:{refetchOnWindowFocus:!1,staleTime:5*60*1e3}}}),BMs=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},$Ms=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},qMs=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},UMs=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},VMs=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},HMs=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},GMs=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},WMs=()=>{const t=window.location.hostname;return t==="contacts.relevelup.com"||t.startsWith("contacts.")},KMs=()=>{const t=window.location.hostname;return t==="pages.relevelup.com"||t.startsWith("pages.")},Pct=()=>{const t=window.location.hostname;return t==="thelocalmove.com"||t==="www.thelocalmove.com"},ZMs=()=>window.location.hostname.endsWith(".thelocalmove.com")&&!Pct(),YMs=()=>e.jsx(hvt,{client:zMs,children:e.jsx(uVe,{children:e.jsxs(N1,{children:[e.jsx(Bgt,{}),e.jsx(yyt,{}),e.jsx(w1t,{children:e.jsx(pwt,{children:e.jsx(fwt,{children:e.jsxs(gwt,{children:[e.jsx(xwt,{}),e.jsx(Yjt,{}),e.jsx(hNt,{}),HMs()?e.jsx(r5s,{}):$Ms()?e.jsx(Ekt,{}):BMs()?e.jsx(JNt,{}):qMs()?e.jsx(Lkt,{}):UMs()?e.jsx(wEt,{}):VMs()?e.jsx(zEt,{}):GMs()?e.jsx(n5s,{}):WMs()?e.jsx(a5s,{}):KMs()?e.jsx(i5s,{}):Pct()?e.jsxs($oe,{children:[e.jsx(ys,{path:"/get-started",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(X9e,{})})}),e.jsx(ys,{path:"/checkout",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(Q9e,{})})}),e.jsx(ys,{path:"/checkout/success",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(J9e,{})})}),e.jsx(ys,{path:"/privacy-policy",element:e.jsx(TIe,{})}),e.jsx(ys,{path:"/terms-of-service",element:e.jsx(AIe,{})}),e.jsx(ys,{path:"*",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(Y9e,{})})})]}):ZMs()?e.jsx(U5s,{}):e.jsxs($oe,{children:[e.jsx(ys,{path:"/",element:e.jsx(KEt,{})}),e.jsx(ys,{path:"/the-local-move",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(Y9e,{})})}),e.jsx(ys,{path:"/get-started",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(X9e,{})})}),e.jsx(ys,{path:"/local-move/checkout",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(Q9e,{})})}),e.jsx(ys,{path:"/local-move/checkout/success",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(J9e,{})})}),e.jsx(ys,{path:"/privacy-policy",element:e.jsx(TIe,{})}),e.jsx(ys,{path:"/terms-of-service",element:e.jsx(AIe,{})}),e.jsx(ys,{path:"/data-deletion",element:e.jsx(ZEt,{})}),e.jsx(ys,{path:"/public/listings",element:e.jsx(cWe,{})}),e.jsx(ys,{path:"/public/listing/:slugOrId",element:e.jsx(zIt,{})}),e.jsx(ys,{path:"/card/:slug",element:e.jsx(BIt,{})}),e.jsx(ys,{path:"/join-brokerage/:slug",element:e.jsx(QCs,{})}),e.jsx(ys,{path:"/recruit-unsubscribe",element:e.jsx(s3s,{})}),e.jsx(ys,{path:"/recruit-video/:shareToken",element:e.jsx(e3s,{})}),e.jsx(ys,{path:"/connect/:slug",element:e.jsx(iXe,{})}),e.jsx(ys,{path:"/auth",element:e.jsx(XEt,{})}),e.jsx(ys,{path:"/subscription-success",element:e.jsx(QEt,{})}),e.jsx(ys,{path:"/subscription",element:e.jsx(ar,{children:e.jsx(H6t,{})})}),e.jsxs(ys,{path:"/share/video",element:e.jsx(PIt,{}),children:[e.jsx(ys,{path:":shareToken",element:e.jsx(eLe,{})}),e.jsx(ys,{path:":shareToken/r/:recipientToken",element:e.jsx(eLe,{})})]}),e.jsx(ys,{path:"/p/:shareToken",element:e.jsx(_3s,{})}),e.jsx(ys,{path:"/portal/:slug",element:e.jsx(C3s,{})}),e.jsx(ys,{path:"/og/video/:token",element:e.jsx(IIt,{})}),e.jsx(ys,{path:"/setup-brokerage",element:e.jsx(ar,{children:e.jsx(G6t,{})})}),e.jsx(ys,{path:"/claim-account",element:e.jsx(XIe,{})}),e.jsx(ys,{path:"/claim",element:e.jsx(XIe,{})}),e.jsx(ys,{path:"/join",element:e.jsx(W6t,{})}),e.jsx(ys,{path:"/trial",element:e.jsx(nIt,{})}),e.jsx(ys,{path:"/trial/success",element:e.jsx(aIt,{})}),e.jsx(ys,{path:"/dashboard",element:e.jsx(ar,{children:e.jsx(o8t,{})})}),e.jsx(ys,{path:"/profile",element:e.jsx(ar,{children:e.jsx(QBt,{})})}),e.jsx(ys,{path:"/apps",element:e.jsx(ar,{children:e.jsx(c$t,{})})}),e.jsx(ys,{path:"/admin",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(J8e,{})})}),e.jsx(ys,{path:"/admin/dashboard",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(J8e,{})})}),e.jsx(ys,{path:"/admin/apps",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(YUt,{})})}),e.jsx(ys,{path:"/admin/members",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(nVt,{})})}),e.jsx(ys,{path:"/admin/invite-codes",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(aVt,{})})}),e.jsx(ys,{path:"/admin/events",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(uVt,{})})}),e.jsx(ys,{path:"/events",element:e.jsx(ar,{children:e.jsx(a$t,{})})}),e.jsx(ys,{path:"/events/:eventId",element:e.jsx(ar,{children:e.jsx(o$t,{})})}),e.jsx(ys,{path:"/templates",element:e.jsx(ar,{children:e.jsx(d$t,{})})}),e.jsx(ys,{path:"/templates/:templateId",element:e.jsx(ar,{children:e.jsx(p$t,{})})}),e.jsx(ys,{path:"/admin/templates",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(mVt,{})})}),e.jsx(ys,{path:"/academy",element:e.jsx(ar,{children:e.jsx(f$t,{})})}),e.jsx(ys,{path:"/academy/:videoId",element:e.jsx(ar,{children:e.jsx(g$t,{})})}),e.jsx(ys,{path:"/admin/academy",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(fVt,{})})}),e.jsx(ys,{path:"/toolbox",element:e.jsx(ar,{children:e.jsx(y$t,{})})}),e.jsx(ys,{path:"/toolbox/:kitId",element:e.jsx(ar,{children:e.jsx(v$t,{})})}),e.jsx(ys,{path:"/admin/toolbox",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(xVt,{})})}),e.jsx(ys,{path:"/social-swag",element:e.jsx(ar,{children:e.jsx(_$t,{})})}),e.jsx(ys,{path:"/social-swag-2",element:e.jsx(ar,{children:e.jsx(yUt,{})})}),e.jsx(ys,{path:"/social-swag/:swagId",element:e.jsx(ar,{children:e.jsx(vUt,{})})}),e.jsx(ys,{path:"/social-connections",element:e.jsx(ar,{children:e.jsx(r3s,{})})}),e.jsx(ys,{path:"/social-connections/callback",element:e.jsx(ar,{children:e.jsx(n3s,{})})}),e.jsx(ys,{path:"/social-connections/linkedin-callback",element:e.jsx(ar,{children:e.jsx(i3s,{})})}),e.jsx(ys,{path:"/social-connections/google-callback",element:e.jsx(ar,{children:e.jsx(a3s,{})})}),e.jsx(ys,{path:"/admin/social-swag",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(gVt,{})})}),e.jsx(ys,{path:"/admin/social-swag-2",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(tGt,{})})}),e.jsx(ys,{path:"/community",element:e.jsx(ar,{children:e.jsx(FUt,{})})}),e.jsx(ys,{path:"/support",element:e.jsx(ar,{children:e.jsx(zUt,{})})}),e.jsx(ys,{path:"/admin/community",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(sGt,{})})}),e.jsx(ys,{path:"/admin/support-tickets",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Rvs,{})})}),e.jsx(ys,{path:"/admin/email-templates",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Fvs,{})})}),e.jsx(ys,{path:"/admin/agent-email-templates",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(zvs,{})})}),e.jsx(ys,{path:"/admin/analytics",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Ivs,{})})}),e.jsx(ys,{path:"/admin/brokerage-resources",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Lvs,{})})}),e.jsx(ys,{path:"/admin/dashboard-management",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Dvs,{})})}),e.jsx(ys,{path:"/brokerage/dashboard",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(Xvs,{})})}),e.jsx(ys,{path:"/brokerage/teams",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(G5s,{})})}),e.jsx(ys,{path:"/brokerage/recruiting",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(_Ss,{})})}),e.jsx(ys,{path:"/my-team",element:e.jsx(ar,{children:e.jsx(W5s,{})})}),e.jsx(ys,{path:"/my-brokerage",element:e.jsx(ar,{children:e.jsx(r1s,{})})}),e.jsx(ys,{path:"/brokerage-content",element:e.jsx(ar,{children:e.jsx(c1s,{})})}),e.jsx(ys,{path:"/brokerage-content/:contentId",element:e.jsx(ar,{children:e.jsx(p1s,{})})}),e.jsx(ys,{path:"/brokerage-resources",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(HUt,{})})}),e.jsx(ys,{path:"/brokerage-resources/:resourceId",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(GUt,{})})}),e.jsx(ys,{path:"/newsletters",element:e.jsx(ar,{children:e.jsx(f1s,{})})}),e.jsx(ys,{path:"/newsletters/:id",element:e.jsx(ar,{children:e.jsx(g1s,{})})}),e.jsx(ys,{path:"/wishlist",element:e.jsx(ar,{children:e.jsx(_1s,{})})}),e.jsx(ys,{path:"/wishlist/:itemId",element:e.jsx(ar,{children:e.jsx(b1s,{})})}),e.jsx(ys,{path:"/admin/wishlist",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(w1s,{})})}),e.jsx(ys,{path:"/admin/levelup-brief",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(j1s,{})})}),e.jsx(ys,{path:"/admin/newsletters",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(v1s,{})})}),e.jsx(ys,{path:"/admin/additional-services",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(N1s,{})})}),e.jsx(ys,{path:"/admin/discounts",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(k1s,{})})}),e.jsx(ys,{path:"/admin/subscriptions",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(S1s,{})})}),e.jsx(ys,{path:"/admin/referrals",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(C1s,{})})}),e.jsx(ys,{path:"/admin/prospector",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(eSs,{})})}),e.jsx(ys,{path:"/admin/recruiting",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(vSs,{})})}),e.jsx(ys,{path:"/admin/beta/social-post-generator",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(bCs,{})})}),e.jsx(ys,{path:"/admin/credits",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(_Ms,{})})})}),e.jsx(ys,{path:"/admin/beta/postcard-manager",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(yMs,{})})})}),e.jsx(ys,{path:"/admin/beta/homereel",element:e.jsx(ar,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(vMs,{})})})}),e.jsx(ys,{path:"/admin/lms",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(DCs,{})})}),e.jsx(ys,{path:"/admin/lms/stats",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(BCs,{})})}),e.jsx(ys,{path:"/admin/lms/:courseId",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(RCs,{})})}),e.jsx(ys,{path:"/levelup-u",element:e.jsx(ar,{children:e.jsx($Cs,{})})}),e.jsx(ys,{path:"/levelup-u/:courseId",element:e.jsx(ar,{children:e.jsx(UCs,{})})}),e.jsx(ys,{path:"/admin/brokerage-content-activity",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(bSs,{})})}),e.jsx(ys,{path:"/admin/onboarding-checklist",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(T1s,{})})}),e.jsx(ys,{path:"/admin/marketplace",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(E4s,{})})}),e.jsx(ys,{path:"/admin/agent-points",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(t4s,{})})}),e.jsx(ys,{path:"/admin/reward-store",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(G4s,{})})}),e.jsx(ys,{path:"/admin/integrations",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(K4s,{})})}),e.jsx(ys,{path:"/admin/integrations/callback",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(J4s,{})})}),e.jsx(ys,{path:"/admin/email-campaigns",element:e.jsx(ar,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(IMs,{})})})}),e.jsx(ys,{path:"/admin/email-campaigns/templates",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(RMs,{})})})}),e.jsx(ys,{path:"/email-campaigns/templates",element:e.jsx(ar,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(OMs,{})})})}),e.jsx(ys,{path:"/admin/email-campaigns/new",element:e.jsx(ar,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(LMs,{})})})}),e.jsx(ys,{path:"/admin/email-campaigns/:id",element:e.jsx(ar,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(DMs,{})})})}),e.jsx(ys,{path:"/reward-store",element:e.jsx(ar,{children:e.jsx(p3s,{})})}),e.jsx(ys,{path:"/additional-services",element:e.jsx(ar,{children:e.jsx(B1s,{})})}),e.jsx(ys,{path:"/additional-services/:serviceId",element:e.jsx(ar,{children:e.jsx($1s,{})})}),e.jsx(ys,{path:"/ai-toolkit",element:e.jsx(ar,{children:e.jsx(q1s,{})})}),e.jsx(ys,{path:"/mission-control",element:e.jsx(ar,{children:e.jsx(o_s,{})})}),e.jsx(ys,{path:"/mission-control/contacts",element:e.jsx(ar,{children:e.jsx(obs,{})})}),e.jsx(ys,{path:"/mission-control/contacts/:contactId",element:e.jsx(ar,{children:e.jsx(Bbs,{})})}),e.jsx(ys,{path:"/mission-control/plans",element:e.jsx(ar,{children:e.jsx($bs,{})})}),e.jsx(ys,{path:"/mission-control/popbys",element:e.jsx(ar,{children:e.jsx(Kbs,{})})}),e.jsx(ys,{path:"/mission-control/popbys/map",element:e.jsx(ar,{children:e.jsx(wMs,{})})}),e.jsx(ys,{path:"/admin/notification-settings",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Y4s,{})})}),e.jsx(ys,{path:"/admin/agent-os",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(E1s,{})})}),e.jsx(ys,{path:"/mission-control/listings",element:e.jsx(ar,{children:e.jsx(yws,{})})}),e.jsx(ys,{path:"/mission-control/listings/new",element:e.jsx(ar,{children:e.jsx(W7e,{})})}),e.jsx(ys,{path:"/mission-control/listings/:listingId",element:e.jsx(ar,{children:e.jsx(Rws,{})})}),e.jsx(ys,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(ar,{children:e.jsx(W7e,{})})}),e.jsx(ys,{path:"/admin/listing-exchange",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Zks,{})})}),e.jsx(ys,{path:"/mission-control/pipeline",element:e.jsx(ar,{children:e.jsx(sks,{})})}),e.jsx(ys,{path:"/mission-control/tasks",element:e.jsx(ar,{children:e.jsx(hks,{})})}),e.jsx(ys,{path:"/mission-control/my-card",element:e.jsx(ar,{children:e.jsx(Pks,{})})}),e.jsx(ys,{path:"/mission-control/integrations",element:e.jsx(ar,{children:e.jsx(qks,{})})}),e.jsx(ys,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(ar,{children:e.jsx(Uks,{})})}),e.jsx(ys,{path:"/mission-control/integrations/canva/callback",element:e.jsx(Vks,{})}),e.jsx(ys,{path:"/mission-control/integrations/meta/callback",element:e.jsx(ar,{children:e.jsx(Hks,{})})}),e.jsx(ys,{path:"/mission-control/scorecard",element:e.jsx(ar,{children:e.jsx(lws,{})})}),e.jsx(ys,{path:"/admin/scorecard",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Wks,{})})}),e.jsx(ys,{path:"/admin/scorecard/:userId",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(i9e,{})})}),e.jsx(ys,{path:"/mission-control/scorecard/:userId",element:e.jsx(ar,{children:e.jsx(i9e,{})})}),e.jsx(ys,{path:"/mission-control/relationship-scorecard",element:e.jsx(ar,{children:e.jsx(iMs,{})})}),e.jsx(ys,{path:"/mission-control/sphere-gaps",element:e.jsx(ar,{children:e.jsx(dMs,{})})}),e.jsx(ys,{path:"/mission-control/website-activity",element:e.jsx(ar,{children:e.jsx(Ect,{})})}),e.jsx(ys,{path:"/mission-control/connect-page",element:e.jsx(ar,{children:e.jsx(hMs,{})})}),e.jsx(ys,{path:"/admin/membership-reviews",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Yks,{})})}),e.jsx(ys,{path:"/admin/weekly-digest",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Jks,{})})}),e.jsx(ys,{path:"/mission-control/video/record",element:e.jsx(ar,{children:e.jsx(zjs,{})})}),e.jsx(ys,{path:"/mission-control/video-library",element:e.jsx(ar,{children:e.jsx(eNs,{})})}),e.jsx(ys,{path:"/marketplace",element:e.jsx(ar,{children:e.jsx(o3s,{})})}),e.jsx(ys,{path:"/marketplace/:productId",element:e.jsx(ar,{children:e.jsx(l3s,{})})}),e.jsx(ys,{path:"/marketplace/cart",element:e.jsx(ar,{children:e.jsx(c3s,{})})}),e.jsx(ys,{path:"/marketplace/orders",element:e.jsx(ar,{children:e.jsx(d3s,{})})}),e.jsx(ys,{path:"/marketplace/orders/:orderId",element:e.jsx(ar,{children:e.jsx(h3s,{})})}),e.jsx(ys,{path:"/marketplace/success",element:e.jsx(ar,{children:e.jsx(m3s,{})})}),e.jsx(ys,{path:"/admin/agent-cards",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(s4s,{})})}),e.jsx(ys,{path:"/admin/presentation-analytics",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(X4s,{})})}),e.jsx(ys,{path:"/admin/guest-book-analytics",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Q4s,{})})}),e.jsx(ys,{path:"/mission-control/smart-drips",element:e.jsx(ar,{children:e.jsx(t5s,{})})}),e.jsx(ys,{path:"/mission-control/direct-mail",element:e.jsx(ar,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(bMs,{})})})}),e.jsx(ys,{path:"/mission-control/presentations",element:e.jsx(ar,{children:e.jsx(f3s,{})})}),e.jsx(ys,{path:"/mission-control/presentations/new",element:e.jsx(ar,{children:e.jsx(E9e,{})})}),e.jsx(ys,{path:"/mission-control/presentations/:id",element:e.jsx(ar,{children:e.jsx(E9e,{})})}),e.jsx(ys,{path:"/mission-control/guest-book",element:e.jsx(ar,{children:e.jsx(k3s,{})})}),e.jsx(ys,{path:"/mission-control/guest-book/live/:id",element:e.jsx(ar,{children:e.jsx(jMs,{})})}),e.jsx(ys,{path:"/guestbook/:slug",element:e.jsx(UWe,{})}),e.jsx(ys,{path:"/mission-control/card-studio",element:e.jsx(ar,{children:e.jsx(I3s,{})})}),e.jsx(ys,{path:"/mission-control/scheduler",element:e.jsx(ar,{children:e.jsx(eMs,{})})}),e.jsx(ys,{path:"/c/:shareToken",element:e.jsx(Sct,{})}),e.jsx(ys,{path:"/book/:slug",element:e.jsx(Mct,{})}),e.jsx(ys,{path:"/page/:slug",element:e.jsx(Tct,{})}),e.jsx(ys,{path:"/mission-control/landing-pages",element:e.jsx(ar,{children:e.jsx(tMs,{})})}),e.jsx(ys,{path:"/mission-control/landing-pages/:pageId",element:e.jsx(ar,{children:e.jsx(nMs,{})})}),e.jsx(ys,{path:"/my-website/:siteId/edit",element:e.jsx(ar,{children:e.jsx(S.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(Z9e,{})})})}),e.jsx(ys,{path:"/my-website/mls-listings",element:e.jsx(ar,{children:e.jsx(S.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(AMs,{})})})}),e.jsx(ys,{path:"/my-website/mls-listings/:mlsId",element:e.jsx(ar,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(EMs,{})})})}),e.jsx(ys,{path:"/my-website/market-report",element:e.jsx(ar,{children:e.jsx(S.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(PMs,{})})})}),e.jsx(ys,{path:"/admin/lead-sites",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(NMs,{})})})}),e.jsx(ys,{path:"/admin/lead-sites/themes",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(S.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(kMs,{})})})}),e.jsx(ys,{path:"/admin/lead-sites/:siteId/edit",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(S.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(Z9e,{})})})}),e.jsx(ys,{path:"/admin/mls-feeds",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(SMs,{})})})}),e.jsx(ys,{path:"/admin/lead-site-analytics",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(S.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(CMs,{})})})}),e.jsx(ys,{path:"/admin/website-interests",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(S.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(MMs,{})})})}),e.jsx(ys,{path:"/admin/website-orders",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(S.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(FMs,{})})})}),e.jsx(ys,{path:"/admin/mls-fee-tracker",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(TMs,{})})})}),e.jsx(ys,{path:"/m/*",element:e.jsx(S.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(gMs,{})})}),e.jsx(ys,{path:"*",element:e.jsx(Cct,{})})]}),")"]})})})})]})})}),Vp=window.location.hostname,XMs=Vp.includes("lovable.app")||Vp.includes("lovableproject.com"),QMs=(()=>{try{return window.self!==window.top}catch{return!0}})(),JMs=Vp.startsWith("cards.")||Vp.startsWith("cardstudio.")||Vp.startsWith("listings.")||Vp.startsWith("presentations.")||Vp.startsWith("guestbook.")||Vp.startsWith("clients.")||Vp.startsWith("booking.")||Vp.startsWith("contacts.")||Vp.startsWith("pages.")||Vp.endsWith(".thelocalmove.com")&&!Vp.startsWith("dashboard.");var dBe;XMs||QMs||JMs?((dBe=navigator.serviceWorker)==null||dBe.getRegistrations().then(t=>{t.forEach(s=>s.unregister())}),"caches"in window&&caches.keys().then(t=>t.forEach(s=>caches.delete(s)))):"serviceWorker"in navigator&&Ha(async()=>{const{registerSW:t}=await import("./virtual_pwa-register-BwnMmbpm.js");return{registerSW:t}},[]).then(({registerSW:t})=>{t({onNeedRefresh(){},onOfflineReady(){}})});jqe(document.getElementById("root")).render(e.jsx(YMs,{}));export{co as $,Us as A,Fa as B,to as C,Ih as D,wn as E,ga as F,Da as G,Mn as H,IY as I,on as J,CEe as K,Za as L,ki as M,Yxe as N,m1t as O,Pn as P,kme as Q,G_s as R,ko as S,hh as T,lr as U,Wat as V,Z_s as W,Sr as X,RSe as Y,Jn as Z,Ha as _,_r as a,_c as a$,jp as a0,It as a1,gd as a2,An as a3,T1 as a4,Yo as a5,fS as a6,_s as a7,Wy as a8,rf as a9,Ln as aA,Ms as aB,Nt as aC,Dn as aD,ut as aE,Qe as aF,Er as aG,fs as aH,ms as aI,ks as aJ,bs as aK,xe as aL,De as aM,Bs as aN,Rs as aO,qs as aP,Os as aQ,vt as aR,En as aS,_Ts as aT,ps as aU,Ui as aV,vr as aW,Wo as aX,wae as aY,$4 as aZ,pa as a_,yL as aa,vd as ab,qU as ac,oX as ad,ch as ae,zv as af,Ag as ag,xl as ah,Kr as ai,Sm as aj,MM as ak,$oe as al,ys as am,Pe as an,Lt as ao,Ot as ap,yc as aq,hr as ar,Re as as,ia as at,ea as au,ls as av,nl as aw,js as ax,K as ay,In as az,Fs as b,N1 as b$,Ya as b0,gr as b1,Es as b2,sS as b3,pi as b4,$a as b5,$r as b6,Nb as b7,NJ as b8,uh as b9,OV as bA,j4e as bB,sC as bC,hu as bD,Yl as bE,Xl as bF,Hv as bG,Cl as bH,xse as bI,xo as bJ,go as bK,lo as bL,ui as bM,lL as bN,Qn as bO,Lo as bP,yJ as bQ,hJ as bR,rL as bS,Uu as bT,NM as bU,fn as bV,SV as bW,qL as bX,yx as bY,Ir as bZ,$j as b_,So as ba,Yae as bb,Cg as bc,Ev as bd,gi as be,Xa as bf,kM as bg,oo as bh,tu as bi,Tn as bj,t0 as bk,oS as bl,Yy as bm,z6t as bn,vn as bo,Ta as bp,_n as bq,f4e as br,pce as bs,y4e as bt,rO as bu,ire as bv,_4e as bw,x4e as bx,w4e as by,UTs as bz,Rt as c,aS as c$,FL as c0,Qc as c1,CL as c2,Ki as c3,gn as c4,apt as c5,so as c6,ft as c7,x_s as c8,f_s as c9,nS as cA,rJ as cB,Cm as cC,Ou as cD,gZ as cE,du as cF,Ph as cG,b4e as cH,Mv as cI,VTs as cJ,KTs as cK,ZTs as cL,mp as cM,YTs as cN,QHt as cO,Hn as cP,dh as cQ,Wv as cR,xx as cS,Mb as cT,md as cU,Ud as cV,Vd as cW,jd as cX,sje as cY,va as cZ,IL as c_,y_s as ca,xc as cb,CM as cc,jL as cd,ti as ce,wTs as cf,gWe as cg,NTs as ch,kTs as ci,STs as cj,Jv as ck,ENe as cl,Do as cm,ur as cn,Tb as co,GA as cp,wC as cq,WA as cr,KA as cs,Ure as ct,Dl as cu,gx as cv,SL as cw,Jee as cx,Vre as cy,X4 as cz,Nc as d,Oh as d$,o5s as d0,al as d1,pp as d2,cL as d3,fx as d4,td as d5,ESe as d6,Xy as d7,wo as d8,uu as d9,Hke as dA,g9t as dB,Gke as dC,kat as dD,Wke as dE,V4 as dF,J4 as dG,wM as dH,jM as dI,Dh as dJ,Zy as dK,B4 as dL,q4 as dM,fo as dN,yS as dO,dS as dP,Eke as dQ,wa as dR,wc as dS,K4 as dT,Rh as dU,fj as dV,wb as dW,tS as dX,nL as dY,jW as dZ,ite as d_,_ae as da,CO as db,ei as dc,Mm as dd,ja as de,G4 as df,lS as dg,df as dh,QM as di,jat as dj,S0 as dk,lO as dl,ep as dm,wat as dn,cC as dp,dC as dq,y1 as dr,nu as ds,sL as dt,uS as du,Tv as dv,xne as dw,H4 as dx,Ike as dy,Dke as dz,gt as e,yd as e0,Xj as e1,hS as e2,Qy as e3,cS as e4,vM as e5,vEt as e6,jvt as e7,spe as e8,iq as e9,VCe as ea,u5s as eb,QTs as ec,XTs as ed,nW as ee,One as ef,oie as eg,xM as eh,ec as ei,JTs as ej,HCe as ek,EM as el,m5s as em,ha as en,an as f,ZA as g,s_s as h,Sa as i,e as j,rr as k,Jt as l,A6t as m,gl as n,Ti as o,ln as p,ehe as q,S as r,G as s,jf as t,Ol as u,XA as v,ip as w,nf as x,Oi as y,me as z};