const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Admin-DIOrS4A5.js","assets/use-mobile-B4AYTJP0.js","assets/upload-z5aaoftB.js","assets/undo-2-OFabWKPH.js","assets/constructNow-BCdyUc4Z.js","assets/inbox-Cz1Qxh_L.js","assets/ellipsis-vertical-C5BuCcFp.js","assets/eachDayOfInterval-DKuhEh3l.js","assets/startOfQuarter-9Zw6-XCt.js","assets/wifi-C16VBtSL.js","assets/circle-check-big-Bi-n18Io.js","assets/PageHead-ClkMLdM9.js","assets/Admin-CDBrs1qw.css","assets/CustomerProfile-Ty27TGIi.js","assets/newspaper-B8w4-TIU.js","assets/copy-Pl-GyXyl.js","assets/shopping-bag-LZMmTOgk.js","assets/CustomerEngagement-CUXvGTKn.js","assets/customerAggregates-BN7lP9Yd.js","assets/differenceInDays-D3ygku1O.js","assets/AcceptInvitation-DpazuymM.js","assets/Install-JMZEM7vK.js","assets/DayLinkView-Daz5IXPb.js","assets/DayLinkView-CmdbBGGq.css","assets/SupportPortal-CLl-ehNG.js","assets/CollapsibleSection-CU4jsdJ8.js","assets/SupportChips-mX6VF8MA.js","assets/formatDistanceToNow-DqKjSQmI.js","assets/supportRows-BAMLrlh4.css","assets/supportSession-BZl__ezU.js","assets/supportNotify-IeWhz6wd.js","assets/useSupportPortal-DRhfYcv3.js","assets/SupportTicketPage-DWGSRiaM.js","assets/Landing-hvOQYUt-.js","assets/SectionLabel-DvHH20YF.js","assets/calendar-clock-BREH9lS2.js","assets/user-cog-BO6zj3H7.js","assets/plug-CQX4P2PM.js","assets/menu-BQEELFWZ.js","assets/FAQSection-DAvaUTT5.js","assets/accordion-1NfldtED.js","assets/index-Czl5M9qu.js","assets/CTASection-B5zFP3iv.js","assets/Features-DPddZM08.js","assets/FeatureDetail-Dplz5eLu.js","assets/Pricing-DR4W2MbH.js","assets/About-Jd8yCnzW.js","assets/EditorialImage-CGvclzzZ.js","assets/Contact-l0b5fv3p.js","assets/MarketingBlog-CYdU2QMb.js","assets/MarketingBlogPost-DyoVbrav.js","assets/Privacy-BkT86iL3.js","assets/NieuwsbriefWeb-Cp717jsZ.js","assets/Voorwaarden-B8gsFgsJ.js","assets/Verwerkersovereenkomst-BM5j3Ahp.js","assets/SiteLayout-Yuj2VlH1.js","assets/linkedin-CIBtOJOY.js","assets/SiteHome-DCkv13t5.js","assets/SiteServices-De6XQ9T2.js","assets/SiteTeam-D6KhFZqg.js","assets/SiteBlog-Bp5SZq_x.js","assets/SiteBlogPost-P0UQlzs9.js","assets/SiteContact-C9npDlkn.js","assets/PortalHome-DVnP9f57.js"])))=>i.map(i=>d[i]); var lI=Object.defineProperty;var y_=e=>{throw TypeError(e)};var cI=(e,t,n)=>t in e?lI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ge=(e,t,n)=>cI(e,typeof t!="symbol"?t+"":t,n),Xp=(e,t,n)=>t.has(e)||y_("Cannot "+n);var D=(e,t,n)=>(Xp(e,t,"read from private field"),n?n.call(e):t.get(e)),Re=(e,t,n)=>t.has(e)?y_("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ye=(e,t,n,r)=>(Xp(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),qe=(e,t,n)=>(Xp(e,t,"access private method"),n);var Jd=(e,t,n,r)=>({set _(s){ye(e,t,s,n)},get _(){return D(e,t,r)}});function uI(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();var Zre=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function dI(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var n=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}),n}var gE={exports:{}},Cm={},yE={exports:{}},Xe={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var wd=Symbol.for("react.element"),fI=Symbol.for("react.portal"),hI=Symbol.for("react.fragment"),mI=Symbol.for("react.strict_mode"),pI=Symbol.for("react.profiler"),gI=Symbol.for("react.provider"),yI=Symbol.for("react.context"),vI=Symbol.for("react.forward_ref"),xI=Symbol.for("react.suspense"),wI=Symbol.for("react.memo"),bI=Symbol.for("react.lazy"),v_=Symbol.iterator;function _I(e){return e===null||typeof e!="object"?null:(e=v_&&e[v_]||e["@@iterator"],typeof e=="function"?e:null)}var vE={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},xE=Object.assign,wE={};function yc(e,t,n){this.props=e,this.context=t,this.refs=wE,this.updater=n||vE}yc.prototype.isReactComponent={};yc.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=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,e,t,"setState")};yc.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function bE(){}bE.prototype=yc.prototype;function Gx(e,t,n){this.props=e,this.context=t,this.refs=wE,this.updater=n||vE}var Yx=Gx.prototype=new bE;Yx.constructor=Gx;xE(Yx,yc.prototype);Yx.isPureReactComponent=!0;var x_=Array.isArray,_E=Object.prototype.hasOwnProperty,Qx={current:null},kE={key:!0,ref:!0,__self:!0,__source:!0};function jE(e,t,n){var r,s={},a=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(a=""+t.key),t)_E.call(t,r)&&!kE.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1>>1,oe=C[ie];if(0>>1;ies(ue,W))kes(L,ue)?(C[ie]=L,C[ke]=W,ie=ke):(C[ie]=ue,C[re]=W,ie=re);else if(kes(L,W))C[ie]=L,C[ke]=W,ie=ke;else break e}}return F}function s(C,F){var W=C.sortIndex-F.sortIndex;return W!==0?W:C.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,f=null,h=3,m=!1,v=!1,w=!1,y=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function b(C){for(var F=n(u);F!==null;){if(F.callback===null)r(u);else if(F.startTime<=C)r(u),F.sortIndex=F.expirationTime,t(c,F);else break;F=n(u)}}function _(C){if(w=!1,b(C),!v)if(n(c)!==null)v=!0,V(j);else{var F=n(u);F!==null&&M(_,F.startTime-C)}}function j(C,F){v=!1,w&&(w=!1,x(E),E=-1),m=!0;var W=h;try{for(b(F),f=n(c);f!==null&&(!(f.expirationTime>F)||C&&!z());){var ie=f.callback;if(typeof ie=="function"){f.callback=null,h=f.priorityLevel;var oe=ie(f.expirationTime<=F);F=e.unstable_now(),typeof oe=="function"?f.callback=oe:f===n(c)&&r(c),b(F)}else r(c);f=n(c)}if(f!==null)var ce=!0;else{var re=n(u);re!==null&&M(_,re.startTime-F),ce=!1}return ce}finally{f=null,h=W,m=!1}}var k=!1,S=null,E=-1,N=5,O=-1;function z(){return!(e.unstable_now()-OC||125ie?(C.sortIndex=W,t(u,C),n(c)===null&&C===n(u)&&(w?(x(E),E=-1):w=!0,M(_,W-ie))):(C.sortIndex=oe,t(c,C),v||m||(v=!0,V(j))),C},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(C){var F=h;return function(){var W=h;h=F;try{return C.apply(this,arguments)}finally{h=W}}}})(TE);CE.exports=TE;var OI=CE.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 MI=p,Tr=OI;function ae(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Oy=Object.prototype.hasOwnProperty,DI=/^[: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]*$/,b_={},__={};function II(e){return Oy.call(__,e)?!0:Oy.call(b_,e)?!1:DI.test(e)?__[e]=!0:(b_[e]=!0,!1)}function LI(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function $I(e,t,n,r){if(t===null||typeof t>"u"||LI(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Zn(e,t,n,r,s,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var Tn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Tn[e]=new Zn(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Tn[t]=new Zn(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Tn[e]=new Zn(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Tn[e]=new Zn(e,2,!1,e,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(e){Tn[e]=new Zn(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Tn[e]=new Zn(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Tn[e]=new Zn(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Tn[e]=new Zn(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Tn[e]=new Zn(e,5,!1,e.toLowerCase(),null,!1,!1)});var Jx=/[\-:]([a-z])/g;function ew(e){return e[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(e){var t=e.replace(Jx,ew);Tn[t]=new Zn(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Jx,ew);Tn[t]=new Zn(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Jx,ew);Tn[t]=new Zn(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Tn[e]=new Zn(e,1,!1,e.toLowerCase(),null,!1,!1)});Tn.xlinkHref=new Zn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Tn[e]=new Zn(e,1,!1,e.toLowerCase(),null,!0,!0)});function tw(e,t,n,r){var s=Tn.hasOwnProperty(t)?Tn[t]:null;(s!==null?s.type!==0:r||!(2l||s[o]!==a[l]){var c=` `+s[o].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=o&&0<=l);break}}}finally{eg=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?au(e):""}function FI(e){switch(e.tag){case 5:return au(e.type);case 16:return au("Lazy");case 13:return au("Suspense");case 19:return au("SuspenseList");case 0:case 2:case 15:return e=tg(e.type,!1),e;case 11:return e=tg(e.type.render,!1),e;case 1:return e=tg(e.type,!0),e;default:return""}}function Ly(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case ll:return"Fragment";case il:return"Portal";case My:return"Profiler";case nw:return"StrictMode";case Dy:return"Suspense";case Iy:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case RE:return(e.displayName||"Context")+".Consumer";case AE:return(e._context.displayName||"Context")+".Provider";case rw:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case sw:return t=e.displayName||null,t!==null?t:Ly(e.type)||"Memo";case Ia:t=e._payload,e=e._init;try{return Ly(e(t))}catch{}}return null}function zI(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ly(t);case 8:return t===nw?"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 t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function yo(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ME(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function BI(e){var t=ME(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(o){r=""+o,a.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function nf(e){e._valueTracker||(e._valueTracker=BI(e))}function DE(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=ME(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function _h(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function $y(e,t){var n=t.checked;return Ft({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function j_(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=yo(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function IE(e,t){t=t.checked,t!=null&&tw(e,"checked",t,!1)}function Fy(e,t){IE(e,t);var n=yo(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?zy(e,t.type,n):t.hasOwnProperty("defaultValue")&&zy(e,t.type,yo(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function S_(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function zy(e,t,n){(t!=="number"||_h(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ou=Array.isArray;function _l(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=rf.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Du(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var gu={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},UI=["Webkit","ms","Moz","O"];Object.keys(gu).forEach(function(e){UI.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),gu[t]=gu[e]})});function zE(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||gu.hasOwnProperty(e)&&gu[e]?(""+t).trim():t+"px"}function BE(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=zE(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var VI=Ft({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 Vy(e,t){if(t){if(VI[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(ae(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(ae(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(ae(61))}if(t.style!=null&&typeof t.style!="object")throw Error(ae(62))}}function Wy(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){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 Hy=null;function aw(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var qy=null,kl=null,jl=null;function C_(e){if(e=kd(e)){if(typeof qy!="function")throw Error(ae(280));var t=e.stateNode;t&&(t=Om(t),qy(e.stateNode,e.type,t))}}function UE(e){kl?jl?jl.push(e):jl=[e]:kl=e}function VE(){if(kl){var e=kl,t=jl;if(jl=kl=null,C_(e),t)for(e=0;e>>=0,e===0?32:31-(eL(e)/tL|0)|0}var sf=64,af=4194304;function iu(e){switch(e&-e){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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Eh(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var l=o&~s;l!==0?r=iu(l):(a&=o,a!==0&&(r=iu(a)))}else o=n&~s,o!==0?r=iu(o):a!==0&&(r=iu(a));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,a=t&-t,s>=a||s===16&&(a&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function bd(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-ps(t),e[t]=n}function aL(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=vu),L_=" ",$_=!1;function cN(e,t){switch(e){case"keyup":return OL.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function uN(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var cl=!1;function DL(e,t){switch(e){case"compositionend":return uN(t);case"keypress":return t.which!==32?null:($_=!0,L_);case"textInput":return e=t.data,e===L_&&$_?null:e;default:return null}}function IL(e,t){if(cl)return e==="compositionend"||!hw&&cN(e,t)?(e=iN(),th=uw=Za=null,cl=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=U_(n)}}function mN(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?mN(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function pN(){for(var e=window,t=_h();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=_h(e.document)}return t}function mw(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function HL(e){var t=pN(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&mN(n.ownerDocument.documentElement,n)){if(r!==null&&mw(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,a=Math.min(r.start,s);r=r.end===void 0?a:Math.min(r.end,s),!e.extend&&a>r&&(s=r,r=a,a=s),s=V_(n,a);var o=V_(n,r);s&&o&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,ul=null,Zy=null,wu=null,Jy=!1;function W_(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Jy||ul==null||ul!==_h(r)||(r=ul,"selectionStart"in r&&mw(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),wu&&Bu(wu,r)||(wu=r,r=Th(Zy,"onSelect"),0hl||(e.current=av[hl],av[hl]=null,hl--)}function jt(e,t){hl++,av[hl]=e.current,e.current=t}var vo={},In=No(vo),pr=No(!1),di=vo;function Yl(e,t){var n=e.type.contextTypes;if(!n)return vo;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},a;for(a in n)s[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function gr(e){return e=e.childContextTypes,e!=null}function Ah(){Pt(pr),Pt(In)}function X_(e,t,n){if(In.current!==vo)throw Error(ae(168));jt(In,t),jt(pr,n)}function jN(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(ae(108,zI(e)||"Unknown",s));return Ft({},n,r)}function Rh(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||vo,di=In.current,jt(In,e),jt(pr,pr.current),!0}function Z_(e,t,n){var r=e.stateNode;if(!r)throw Error(ae(169));n?(e=jN(e,t,di),r.__reactInternalMemoizedMergedChildContext=e,Pt(pr),Pt(In),jt(In,e)):Pt(pr),jt(pr,n)}var ia=null,Mm=!1,pg=!1;function SN(e){ia===null?ia=[e]:ia.push(e)}function r4(e){Mm=!0,SN(e)}function Co(){if(!pg&&ia!==null){pg=!0;var e=0,t=vt;try{var n=ia;for(vt=1;e>=o,s-=o,fa=1<<32-ps(t)+s|n<E?(N=S,S=null):N=S.sibling;var O=h(x,S,b[E],_);if(O===null){S===null&&(S=N);break}e&&S&&O.alternate===null&&t(x,S),g=a(O,g,E),k===null?j=O:k.sibling=O,k=O,S=N}if(E===b.length)return n(x,S),At&&Fo(x,E),j;if(S===null){for(;EE?(N=S,S=null):N=S.sibling;var z=h(x,S,O.value,_);if(z===null){S===null&&(S=N);break}e&&S&&z.alternate===null&&t(x,S),g=a(z,g,E),k===null?j=z:k.sibling=z,k=z,S=N}if(O.done)return n(x,S),At&&Fo(x,E),j;if(S===null){for(;!O.done;E++,O=b.next())O=f(x,O.value,_),O!==null&&(g=a(O,g,E),k===null?j=O:k.sibling=O,k=O);return At&&Fo(x,E),j}for(S=r(x,S);!O.done;E++,O=b.next())O=m(S,x,E,O.value,_),O!==null&&(e&&O.alternate!==null&&S.delete(O.key===null?E:O.key),g=a(O,g,E),k===null?j=O:k.sibling=O,k=O);return e&&S.forEach(function(T){return t(x,T)}),At&&Fo(x,E),j}function y(x,g,b,_){if(typeof b=="object"&&b!==null&&b.type===ll&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case tf:e:{for(var j=b.key,k=g;k!==null;){if(k.key===j){if(j=b.type,j===ll){if(k.tag===7){n(x,k.sibling),g=s(k,b.props.children),g.return=x,x=g;break e}}else if(k.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===Ia&&tk(j)===k.type){n(x,k.sibling),g=s(k,b.props),g.ref=Hc(x,k,b),g.return=x,x=g;break e}n(x,k);break}else t(x,k);k=k.sibling}b.type===ll?(g=ci(b.props.children,x.mode,_,b.key),g.return=x,x=g):(_=ch(b.type,b.key,b.props,null,x.mode,_),_.ref=Hc(x,g,b),_.return=x,x=_)}return o(x);case il:e:{for(k=b.key;g!==null;){if(g.key===k)if(g.tag===4&&g.stateNode.containerInfo===b.containerInfo&&g.stateNode.implementation===b.implementation){n(x,g.sibling),g=s(g,b.children||[]),g.return=x,x=g;break e}else{n(x,g);break}else t(x,g);g=g.sibling}g=kg(b,x.mode,_),g.return=x,x=g}return o(x);case Ia:return k=b._init,y(x,g,k(b._payload),_)}if(ou(b))return v(x,g,b,_);if(zc(b))return w(x,g,b,_);hf(x,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,g!==null&&g.tag===6?(n(x,g.sibling),g=s(g,b),g.return=x,x=g):(n(x,g),g=_g(b,x.mode,_),g.return=x,x=g),o(x)):n(x,g)}return y}var Xl=TN(!0),PN=TN(!1),Dh=No(null),Ih=null,gl=null,vw=null;function xw(){vw=gl=Ih=null}function ww(e){var t=Dh.current;Pt(Dh),e._currentValue=t}function lv(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function El(e,t){Ih=e,vw=gl=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(hr=!0),e.firstContext=null)}function Hr(e){var t=e._currentValue;if(vw!==e)if(e={context:e,memoizedValue:t,next:null},gl===null){if(Ih===null)throw Error(ae(308));gl=e,Ih.dependencies={lanes:0,firstContext:e}}else gl=gl.next=e;return t}var Go=null;function bw(e){Go===null?Go=[e]:Go.push(e)}function AN(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,bw(t)):(n.next=s.next,s.next=n),t.interleaved=n,va(e,r)}function va(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var La=!1;function _w(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function RN(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function ma(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function oo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,rt&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,va(e,n)}return s=r.interleaved,s===null?(t.next=t,bw(r)):(t.next=s.next,s.next=t),r.interleaved=t,va(e,n)}function rh(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,iw(e,n)}}function nk(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?s=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?s=a=t:a=a.next=t}else s=a=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Lh(e,t,n,r){var s=e.updateQueue;La=!1;var a=s.firstBaseUpdate,o=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,u=c.next;c.next=null,o===null?a=u:o.next=u,o=c;var d=e.alternate;d!==null&&(d=d.updateQueue,l=d.lastBaseUpdate,l!==o&&(l===null?d.firstBaseUpdate=u:l.next=u,d.lastBaseUpdate=c))}if(a!==null){var f=s.baseState;o=0,d=u=c=null,l=a;do{var h=l.lane,m=l.eventTime;if((r&h)===h){d!==null&&(d=d.next={eventTime:m,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var v=e,w=l;switch(h=t,m=n,w.tag){case 1:if(v=w.payload,typeof v=="function"){f=v.call(m,f,h);break e}f=v;break e;case 3:v.flags=v.flags&-65537|128;case 0:if(v=w.payload,h=typeof v=="function"?v.call(m,f,h):v,h==null)break e;f=Ft({},f,h);break e;case 2:La=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,h=s.effects,h===null?s.effects=[l]:h.push(l))}else m={eventTime:m,lane:h,tag:l.tag,payload:l.payload,callback:l.callback,next:null},d===null?(u=d=m,c=f):d=d.next=m,o|=h;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;h=l,l=h.next,h.next=null,s.lastBaseUpdate=h,s.shared.pending=null}}while(!0);if(d===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,t=s.shared.interleaved,t!==null){s=t;do o|=s.lane,s=s.next;while(s!==t)}else a===null&&(s.shared.lanes=0);mi|=o,e.lanes=o,e.memoizedState=f}}function rk(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=yg.transition;yg.transition={};try{e(!1),t()}finally{vt=n,yg.transition=r}}function YN(){return qr().memoizedState}function i4(e,t,n){var r=lo(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},QN(e))XN(t,n);else if(n=AN(e,t,n,r),n!==null){var s=Gn();gs(n,e,r,s),ZN(n,t,r)}}function l4(e,t,n){var r=lo(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(QN(e))XN(t,s);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,l=a(o,n);if(s.hasEagerState=!0,s.eagerState=l,ys(l,o)){var c=t.interleaved;c===null?(s.next=s,bw(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=AN(e,t,s,r),n!==null&&(s=Gn(),gs(n,e,r,s),ZN(n,t,r))}}function QN(e){var t=e.alternate;return e===Lt||t!==null&&t===Lt}function XN(e,t){bu=Fh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ZN(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,iw(e,n)}}var zh={readContext:Hr,useCallback:An,useContext:An,useEffect:An,useImperativeHandle:An,useInsertionEffect:An,useLayoutEffect:An,useMemo:An,useReducer:An,useRef:An,useState:An,useDebugValue:An,useDeferredValue:An,useTransition:An,useMutableSource:An,useSyncExternalStore:An,useId:An,unstable_isNewReconciler:!1},c4={readContext:Hr,useCallback:function(e,t){return Ns().memoizedState=[e,t===void 0?null:t],e},useContext:Hr,useEffect:ak,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ah(4194308,4,WN.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ah(4194308,4,e,t)},useInsertionEffect:function(e,t){return ah(4,2,e,t)},useMemo:function(e,t){var n=Ns();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ns();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=i4.bind(null,Lt,e),[r.memoizedState,e]},useRef:function(e){var t=Ns();return e={current:e},t.memoizedState=e},useState:sk,useDebugValue:Pw,useDeferredValue:function(e){return Ns().memoizedState=e},useTransition:function(){var e=sk(!1),t=e[0];return e=o4.bind(null,e[1]),Ns().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Lt,s=Ns();if(At){if(n===void 0)throw Error(ae(407));n=n()}else{if(n=t(),kn===null)throw Error(ae(349));hi&30||IN(r,t,n)}s.memoizedState=n;var a={value:n,getSnapshot:t};return s.queue=a,ak($N.bind(null,r,a,e),[e]),r.flags|=2048,Yu(9,LN.bind(null,r,a,n,t),void 0,null),n},useId:function(){var e=Ns(),t=kn.identifierPrefix;if(At){var n=ha,r=fa;n=(r&~(1<<32-ps(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Ku++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Rs]=t,e[Wu]=r,lC(e,t,!1,!1),t.stateNode=e;e:{switch(o=Wy(n,r),n){case"dialog":Ct("cancel",e),Ct("close",e),s=r;break;case"iframe":case"object":case"embed":Ct("load",e),s=r;break;case"video":case"audio":for(s=0;sec&&(t.flags|=128,r=!0,qc(a,!1),t.lanes=4194304)}else{if(!r)if(e=$h(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),qc(a,!0),a.tail===null&&a.tailMode==="hidden"&&!o.alternate&&!At)return Rn(t),null}else 2*Gt()-a.renderingStartTime>ec&&n!==1073741824&&(t.flags|=128,r=!0,qc(a,!1),t.lanes=4194304);a.isBackwards?(o.sibling=t.child,t.child=o):(n=a.last,n!==null?n.sibling=o:t.child=o,a.last=o)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=Gt(),t.sibling=null,n=Mt.current,jt(Mt,r?n&1|2:n&1),t):(Rn(t),null);case 22:case 23:return Iw(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?wr&1073741824&&(Rn(t),t.subtreeFlags&6&&(t.flags|=8192)):Rn(t),null;case 24:return null;case 25:return null}throw Error(ae(156,t.tag))}function y4(e,t){switch(gw(t),t.tag){case 1:return gr(t.type)&&Ah(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Zl(),Pt(pr),Pt(In),Sw(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return jw(t),null;case 13:if(Pt(Mt),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(ae(340));Ql()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Pt(Mt),null;case 4:return Zl(),null;case 10:return ww(t.type._context),null;case 22:case 23:return Iw(),null;case 24:return null;default:return null}}var pf=!1,Dn=!1,v4=typeof WeakSet=="function"?WeakSet:Set,be=null;function yl(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Vt(e,t,r)}else n.current=null}function yv(e,t,n){try{n()}catch(r){Vt(e,t,r)}}var gk=!1;function x4(e,t){if(ev=Nh,e=pN(),mw(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break e}var o=0,l=-1,c=-1,u=0,d=0,f=e,h=null;t:for(;;){for(var m;f!==n||s!==0&&f.nodeType!==3||(l=o+s),f!==a||r!==0&&f.nodeType!==3||(c=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(m=f.firstChild)!==null;)h=f,f=m;for(;;){if(f===e)break t;if(h===n&&++u===s&&(l=o),h===a&&++d===r&&(c=o),(m=f.nextSibling)!==null)break;f=h,h=f.parentNode}f=m}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(tv={focusedElem:e,selectionRange:n},Nh=!1,be=t;be!==null;)if(t=be,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,be=e;else for(;be!==null;){t=be;try{var v=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var w=v.memoizedProps,y=v.memoizedState,x=t.stateNode,g=x.getSnapshotBeforeUpdate(t.elementType===t.type?w:as(t.type,w),y);x.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var b=t.stateNode.containerInfo;b.nodeType===1?b.textContent="":b.nodeType===9&&b.documentElement&&b.removeChild(b.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(ae(163))}}catch(_){Vt(t,t.return,_)}if(e=t.sibling,e!==null){e.return=t.return,be=e;break}be=t.return}return v=gk,gk=!1,v}function _u(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var a=s.destroy;s.destroy=void 0,a!==void 0&&yv(t,n,a)}s=s.next}while(s!==r)}}function Lm(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function vv(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function dC(e){var t=e.alternate;t!==null&&(e.alternate=null,dC(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Rs],delete t[Wu],delete t[sv],delete t[t4],delete t[n4])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function fC(e){return e.tag===5||e.tag===3||e.tag===4}function yk(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||fC(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function xv(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ph));else if(r!==4&&(e=e.child,e!==null))for(xv(e,t,n),e=e.sibling;e!==null;)xv(e,t,n),e=e.sibling}function wv(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(wv(e,t,n),e=e.sibling;e!==null;)wv(e,t,n),e=e.sibling}var En=null,cs=!1;function Ca(e,t,n){for(n=n.child;n!==null;)hC(e,t,n),n=n.sibling}function hC(e,t,n){if(Bs&&typeof Bs.onCommitFiberUnmount=="function")try{Bs.onCommitFiberUnmount(Tm,n)}catch{}switch(n.tag){case 5:Dn||yl(n,t);case 6:var r=En,s=cs;En=null,Ca(e,t,n),En=r,cs=s,En!==null&&(cs?(e=En,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):En.removeChild(n.stateNode));break;case 18:En!==null&&(cs?(e=En,n=n.stateNode,e.nodeType===8?mg(e.parentNode,n):e.nodeType===1&&mg(e,n),Fu(e)):mg(En,n.stateNode));break;case 4:r=En,s=cs,En=n.stateNode.containerInfo,cs=!0,Ca(e,t,n),En=r,cs=s;break;case 0:case 11:case 14:case 15:if(!Dn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var a=s,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&yv(n,t,o),s=s.next}while(s!==r)}Ca(e,t,n);break;case 1:if(!Dn&&(yl(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Vt(n,t,l)}Ca(e,t,n);break;case 21:Ca(e,t,n);break;case 22:n.mode&1?(Dn=(r=Dn)||n.memoizedState!==null,Ca(e,t,n),Dn=r):Ca(e,t,n);break;default:Ca(e,t,n)}}function vk(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new v4),t.forEach(function(r){var s=C4.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function es(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=o),r&=~a}if(r=s,r=Gt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*b4(r/1960))-r,10e?16:e,Ja===null)var r=!1;else{if(e=Ja,Ja=null,Vh=0,rt&6)throw Error(ae(331));var s=rt;for(rt|=4,be=e.current;be!==null;){var a=be,o=a.child;if(be.flags&16){var l=a.deletions;if(l!==null){for(var c=0;cGt()-Mw?li(e,0):Ow|=n),yr(e,t)}function bC(e,t){t===0&&(e.mode&1?(t=af,af<<=1,!(af&130023424)&&(af=4194304)):t=1);var n=Gn();e=va(e,t),e!==null&&(bd(e,t,n),yr(e,n))}function N4(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),bC(e,n)}function C4(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(ae(314))}r!==null&&r.delete(t),bC(e,n)}var _C;_C=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||pr.current)hr=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return hr=!1,p4(e,t,n);hr=!!(e.flags&131072)}else hr=!1,At&&t.flags&1048576&&EN(t,Mh,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;oh(e,t),e=t.pendingProps;var s=Yl(t,In.current);El(t,n),s=Nw(null,t,r,e,s,n);var a=Cw();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,gr(r)?(a=!0,Rh(t)):a=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,_w(t),s.updater=Im,t.stateNode=s,s._reactInternals=t,uv(t,r,e,n),t=hv(null,t,r,!0,a,n)):(t.tag=0,At&&a&&pw(t),Vn(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(oh(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=P4(r),e=as(r,e),s){case 0:t=fv(null,t,r,e,n);break e;case 1:t=hk(null,t,r,e,n);break e;case 11:t=dk(null,t,r,e,n);break e;case 14:t=fk(null,t,r,as(r.type,e),n);break e}throw Error(ae(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:as(r,s),fv(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:as(r,s),hk(e,t,r,s,n);case 3:e:{if(aC(t),e===null)throw Error(ae(387));r=t.pendingProps,a=t.memoizedState,s=a.element,RN(e,t),Lh(t,r,null,n);var o=t.memoizedState;if(r=o.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){s=Jl(Error(ae(423)),t),t=mk(e,t,r,n,s);break e}else if(r!==s){s=Jl(Error(ae(424)),t),t=mk(e,t,r,n,s);break e}else for(Er=ao(t.stateNode.containerInfo.firstChild),Nr=t,At=!0,fs=null,n=PN(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ql(),r===s){t=xa(e,t,n);break e}Vn(e,t,r,n)}t=t.child}return t;case 5:return ON(t),e===null&&iv(t),r=t.type,s=t.pendingProps,a=e!==null?e.memoizedProps:null,o=s.children,nv(r,s)?o=null:a!==null&&nv(r,a)&&(t.flags|=32),sC(e,t),Vn(e,t,o,n),t.child;case 6:return e===null&&iv(t),null;case 13:return oC(e,t,n);case 4:return kw(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Xl(t,null,r,n):Vn(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:as(r,s),dk(e,t,r,s,n);case 7:return Vn(e,t,t.pendingProps,n),t.child;case 8:return Vn(e,t,t.pendingProps.children,n),t.child;case 12:return Vn(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,a=t.memoizedProps,o=s.value,jt(Dh,r._currentValue),r._currentValue=o,a!==null)if(ys(a.value,o)){if(a.children===s.children&&!pr.current){t=xa(e,t,n);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var l=a.dependencies;if(l!==null){o=a.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(a.tag===1){c=ma(-1,n&-n),c.tag=2;var u=a.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),lv(a.return,n,t),l.lanes|=n;break}c=c.next}}else if(a.tag===10)o=a.type===t.type?null:a.child;else if(a.tag===18){if(o=a.return,o===null)throw Error(ae(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),lv(o,n,t),o=a.sibling}else o=a.child;if(o!==null)o.return=a;else for(o=a;o!==null;){if(o===t){o=null;break}if(a=o.sibling,a!==null){a.return=o.return,o=a;break}o=o.return}a=o}Vn(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,El(t,n),s=Hr(s),r=r(s),t.flags|=1,Vn(e,t,r,n),t.child;case 14:return r=t.type,s=as(r,t.pendingProps),s=as(r.type,s),fk(e,t,r,s,n);case 15:return nC(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:as(r,s),oh(e,t),t.tag=1,gr(r)?(e=!0,Rh(t)):e=!1,El(t,n),JN(t,r,s),uv(t,r,s,n),hv(null,t,r,!0,e,n);case 19:return iC(e,t,n);case 22:return rC(e,t,n)}throw Error(ae(156,t.tag))};function kC(e,t){return QE(e,t)}function T4(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Br(e,t,n,r){return new T4(e,t,n,r)}function $w(e){return e=e.prototype,!(!e||!e.isReactComponent)}function P4(e){if(typeof e=="function")return $w(e)?1:0;if(e!=null){if(e=e.$$typeof,e===rw)return 11;if(e===sw)return 14}return 2}function co(e,t){var n=e.alternate;return n===null?(n=Br(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function ch(e,t,n,r,s,a){var o=2;if(r=e,typeof e=="function")$w(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case ll:return ci(n.children,s,a,t);case nw:o=8,s|=8;break;case My:return e=Br(12,n,t,s|2),e.elementType=My,e.lanes=a,e;case Dy:return e=Br(13,n,t,s),e.elementType=Dy,e.lanes=a,e;case Iy:return e=Br(19,n,t,s),e.elementType=Iy,e.lanes=a,e;case OE:return Fm(n,s,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case AE:o=10;break e;case RE:o=9;break e;case rw:o=11;break e;case sw:o=14;break e;case Ia:o=16,r=null;break e}throw Error(ae(130,e==null?e:typeof e,""))}return t=Br(o,n,t,s),t.elementType=e,t.type=r,t.lanes=a,t}function ci(e,t,n,r){return e=Br(7,e,r,t),e.lanes=n,e}function Fm(e,t,n,r){return e=Br(22,e,r,t),e.elementType=OE,e.lanes=n,e.stateNode={isHidden:!1},e}function _g(e,t,n){return e=Br(6,e,null,t),e.lanes=n,e}function kg(e,t,n){return t=Br(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function A4(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=rg(0),this.expirationTimes=rg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rg(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Fw(e,t,n,r,s,a,o,l,c){return e=new A4(e,t,n,l,c),t===1?(t=1,a===!0&&(t|=8)):t=0,a=Br(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},_w(a),e}function R4(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(NC)}catch(e){console.error(e)}}NC(),NE.exports=Rr;var Pi=NE.exports;const CC=pE(Pi);var TC,Ek=Pi;TC=Ek.createRoot,Ek.hydrateRoot;var L4=e=>{switch(e){case"success":return z4;case"info":return U4;case"warning":return B4;case"error":return V4;default:return null}},$4=Array(12).fill(0),F4=({visible:e,className:t})=>X.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},X.createElement("div",{className:"sonner-spinner"},$4.map((n,r)=>X.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),z4=X.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},X.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"})),B4=X.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},X.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"})),U4=X.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},X.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"})),V4=X.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},X.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"})),W4=X.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"},X.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),X.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),H4=()=>{let[e,t]=X.useState(document.hidden);return X.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Sv=1,q4=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,s=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Sv++,a=this.toasts.find(l=>l.id===s),o=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),a?this.toasts=this.toasts.map(l=>l.id===s?(this.publish({...l,...e,id:s,title:n}),{...l,...e,id:s,dismissible:o,title:n}):l):this.addToast({title:n,...r,dismissible:o,id:s}),s},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),s=n!==void 0,a,o=r.then(async c=>{if(a=["resolve",c],X.isValidElement(c))s=!1,this.create({id:n,type:"default",message:c});else if(G4(c)&&!c.ok){s=!1;let u=typeof t.error=="function"?await t.error(`HTTP error! status: ${c.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${c.status}`):t.description;this.create({id:n,type:"error",message:u,description:d})}else if(t.success!==void 0){s=!1;let u=typeof t.success=="function"?await t.success(c):t.success,d=typeof t.description=="function"?await t.description(c):t.description;this.create({id:n,type:"success",message:u,description:d})}}).catch(async c=>{if(a=["reject",c],t.error!==void 0){s=!1;let u=typeof t.error=="function"?await t.error(c):t.error,d=typeof t.description=="function"?await t.description(c):t.description;this.create({id:n,type:"error",message:u,description:d})}}).finally(()=>{var c;s&&(this.dismiss(n),n=void 0),(c=t.finally)==null||c.call(t)}),l=()=>new Promise((c,u)=>o.then(()=>a[0]==="reject"?u(a[1]):c(a[1])).catch(u));return typeof n!="string"&&typeof n!="number"?{unwrap:l}:Object.assign(n,{unwrap:l})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Sv++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},lr=new q4,K4=(e,t)=>{let n=(t==null?void 0:t.id)||Sv++;return lr.addToast({title:e,...t,id:n}),n},G4=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",Y4=K4,Q4=()=>lr.toasts,X4=()=>lr.getActiveToasts(),K=Object.assign(Y4,{success:lr.success,info:lr.info,warning:lr.warning,error:lr.error,custom:lr.custom,message:lr.message,promise:lr.promise,dismiss:lr.dismiss,loading:lr.loading},{getHistory:Q4,getToasts:X4});function Z4(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}Z4(`: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 vf(e){return e.label!==void 0}var J4=3,e3="32px",t3="16px",Nk=4e3,n3=356,r3=14,s3=20,a3=200;function ts(...e){return e.filter(Boolean).join(" ")}function o3(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var i3=e=>{var t,n,r,s,a,o,l,c,u,d,f;let{invert:h,toast:m,unstyled:v,interacting:w,setHeights:y,visibleToasts:x,heights:g,index:b,toasts:_,expanded:j,removeToast:k,defaultRichColors:S,closeButton:E,style:N,cancelButtonStyle:O,actionButtonStyle:z,className:T="",descriptionClassName:I="",duration:P,position:H,gap:V,loadingIcon:M,expandByDefault:C,classNames:F,icons:W,closeButtonAriaLabel:ie="Close toast",pauseWhenPageIsHidden:oe}=e,[ce,re]=X.useState(null),[ue,ke]=X.useState(null),[L,Q]=X.useState(!1),[fe,ee]=X.useState(!1),[je,Ee]=X.useState(!1),[te,_e]=X.useState(!1),[Me,Ue]=X.useState(!1),[ct,Rt]=X.useState(0),[Et,A]=X.useState(0),$=X.useRef(m.duration||P||Nk),q=X.useRef(null),de=X.useRef(null),G=b===0,U=b+1<=x,Z=m.type,pe=m.dismissible!==!1,Be=m.className||"",at=m.descriptionClassName||"",vn=X.useMemo(()=>g.findIndex(Oe=>Oe.toastId===m.id)||0,[g,m.id]),Jt=X.useMemo(()=>{var Oe;return(Oe=m.closeButton)!=null?Oe:E},[m.closeButton,E]),$n=X.useMemo(()=>m.duration||P||Nk,[m.duration,P]),er=X.useRef(0),jn=X.useRef(0),Js=X.useRef(0),tr=X.useRef(null),[nr,Qr]=H.split("-"),Ii=X.useMemo(()=>g.reduce((Oe,ht,_t)=>_t>=vn?Oe:Oe+ht.height,0),[g,vn]),Li=H4(),Hp=m.invert||h,Do=Z==="loading";jn.current=X.useMemo(()=>vn*V+Ii,[vn,Ii]),X.useEffect(()=>{$.current=$n},[$n]),X.useEffect(()=>{Q(!0)},[]),X.useEffect(()=>{let Oe=de.current;if(Oe){let ht=Oe.getBoundingClientRect().height;return A(ht),y(_t=>[{toastId:m.id,height:ht,position:m.position},..._t]),()=>y(_t=>_t.filter(ut=>ut.toastId!==m.id))}},[y,m.id]),X.useLayoutEffect(()=>{if(!L)return;let Oe=de.current,ht=Oe.style.height;Oe.style.height="auto";let _t=Oe.getBoundingClientRect().height;Oe.style.height=ht,A(_t),y(ut=>ut.find(xn=>xn.toastId===m.id)?ut.map(xn=>xn.toastId===m.id?{...xn,height:_t}:xn):[{toastId:m.id,height:_t,position:m.position},...ut])},[L,m.title,m.description,y,m.id]);let Mr=X.useCallback(()=>{ee(!0),Rt(jn.current),y(Oe=>Oe.filter(ht=>ht.toastId!==m.id)),setTimeout(()=>{k(m)},a3)},[m,k,y,jn]);X.useEffect(()=>{if(m.promise&&Z==="loading"||m.duration===1/0||m.type==="loading")return;let Oe;return j||w||oe&&Li?(()=>{if(Js.current{var ht;(ht=m.onAutoClose)==null||ht.call(m,m),Mr()},$.current)),()=>clearTimeout(Oe)},[j,w,m,Z,oe,Li,Mr]),X.useEffect(()=>{m.delete&&Mr()},[Mr,m.delete]);function qp(){var Oe,ht,_t;return W!=null&&W.loading?X.createElement("div",{className:ts(F==null?void 0:F.loader,(Oe=m==null?void 0:m.classNames)==null?void 0:Oe.loader,"sonner-loader"),"data-visible":Z==="loading"},W.loading):M?X.createElement("div",{className:ts(F==null?void 0:F.loader,(ht=m==null?void 0:m.classNames)==null?void 0:ht.loader,"sonner-loader"),"data-visible":Z==="loading"},M):X.createElement(F4,{className:ts(F==null?void 0:F.loader,(_t=m==null?void 0:m.classNames)==null?void 0:_t.loader),visible:Z==="loading"})}return X.createElement("li",{tabIndex:0,ref:de,className:ts(T,Be,F==null?void 0:F.toast,(t=m==null?void 0:m.classNames)==null?void 0:t.toast,F==null?void 0:F.default,F==null?void 0:F[Z],(n=m==null?void 0:m.classNames)==null?void 0:n[Z]),"data-sonner-toast":"","data-rich-colors":(r=m.richColors)!=null?r:S,"data-styled":!(m.jsx||m.unstyled||v),"data-mounted":L,"data-promise":!!m.promise,"data-swiped":Me,"data-removed":fe,"data-visible":U,"data-y-position":nr,"data-x-position":Qr,"data-index":b,"data-front":G,"data-swiping":je,"data-dismissible":pe,"data-type":Z,"data-invert":Hp,"data-swipe-out":te,"data-swipe-direction":ue,"data-expanded":!!(j||C&&L),style:{"--index":b,"--toasts-before":b,"--z-index":_.length-b,"--offset":`${fe?ct:jn.current}px`,"--initial-height":C?"auto":`${Et}px`,...N,...m.style},onDragEnd:()=>{Ee(!1),re(null),tr.current=null},onPointerDown:Oe=>{Do||!pe||(q.current=new Date,Rt(jn.current),Oe.target.setPointerCapture(Oe.pointerId),Oe.target.tagName!=="BUTTON"&&(Ee(!0),tr.current={x:Oe.clientX,y:Oe.clientY}))},onPointerUp:()=>{var Oe,ht,_t,ut;if(te||!pe)return;tr.current=null;let xn=Number(((Oe=de.current)==null?void 0:Oe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ks=Number(((ht=de.current)==null?void 0:ht.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),js=new Date().getTime()-((_t=q.current)==null?void 0:_t.getTime()),Fn=ce==="x"?xn:ks,Xr=Math.abs(Fn)/js;if(Math.abs(Fn)>=s3||Xr>.11){Rt(jn.current),(ut=m.onDismiss)==null||ut.call(m,m),ke(ce==="x"?xn>0?"right":"left":ks>0?"down":"up"),Mr(),_e(!0),Ue(!1);return}Ee(!1),re(null)},onPointerMove:Oe=>{var ht,_t,ut,xn;if(!tr.current||!pe||((ht=window.getSelection())==null?void 0:ht.toString().length)>0)return;let ks=Oe.clientY-tr.current.y,js=Oe.clientX-tr.current.x,Fn=(_t=e.swipeDirections)!=null?_t:o3(H);!ce&&(Math.abs(js)>1||Math.abs(ks)>1)&&re(Math.abs(js)>Math.abs(ks)?"x":"y");let Xr={x:0,y:0};ce==="y"?(Fn.includes("top")||Fn.includes("bottom"))&&(Fn.includes("top")&&ks<0||Fn.includes("bottom")&&ks>0)&&(Xr.y=ks):ce==="x"&&(Fn.includes("left")||Fn.includes("right"))&&(Fn.includes("left")&&js<0||Fn.includes("right")&&js>0)&&(Xr.x=js),(Math.abs(Xr.x)>0||Math.abs(Xr.y)>0)&&Ue(!0),(ut=de.current)==null||ut.style.setProperty("--swipe-amount-x",`${Xr.x}px`),(xn=de.current)==null||xn.style.setProperty("--swipe-amount-y",`${Xr.y}px`)}},Jt&&!m.jsx?X.createElement("button",{"aria-label":ie,"data-disabled":Do,"data-close-button":!0,onClick:Do||!pe?()=>{}:()=>{var Oe;Mr(),(Oe=m.onDismiss)==null||Oe.call(m,m)},className:ts(F==null?void 0:F.closeButton,(s=m==null?void 0:m.classNames)==null?void 0:s.closeButton)},(a=W==null?void 0:W.close)!=null?a:W4):null,m.jsx||p.isValidElement(m.title)?m.jsx?m.jsx:typeof m.title=="function"?m.title():m.title:X.createElement(X.Fragment,null,Z||m.icon||m.promise?X.createElement("div",{"data-icon":"",className:ts(F==null?void 0:F.icon,(o=m==null?void 0:m.classNames)==null?void 0:o.icon)},m.promise||m.type==="loading"&&!m.icon?m.icon||qp():null,m.type!=="loading"?m.icon||(W==null?void 0:W[Z])||L4(Z):null):null,X.createElement("div",{"data-content":"",className:ts(F==null?void 0:F.content,(l=m==null?void 0:m.classNames)==null?void 0:l.content)},X.createElement("div",{"data-title":"",className:ts(F==null?void 0:F.title,(c=m==null?void 0:m.classNames)==null?void 0:c.title)},typeof m.title=="function"?m.title():m.title),m.description?X.createElement("div",{"data-description":"",className:ts(I,at,F==null?void 0:F.description,(u=m==null?void 0:m.classNames)==null?void 0:u.description)},typeof m.description=="function"?m.description():m.description):null),p.isValidElement(m.cancel)?m.cancel:m.cancel&&vf(m.cancel)?X.createElement("button",{"data-button":!0,"data-cancel":!0,style:m.cancelButtonStyle||O,onClick:Oe=>{var ht,_t;vf(m.cancel)&&pe&&((_t=(ht=m.cancel).onClick)==null||_t.call(ht,Oe),Mr())},className:ts(F==null?void 0:F.cancelButton,(d=m==null?void 0:m.classNames)==null?void 0:d.cancelButton)},m.cancel.label):null,p.isValidElement(m.action)?m.action:m.action&&vf(m.action)?X.createElement("button",{"data-button":!0,"data-action":!0,style:m.actionButtonStyle||z,onClick:Oe=>{var ht,_t;vf(m.action)&&((_t=(ht=m.action).onClick)==null||_t.call(ht,Oe),!Oe.defaultPrevented&&Mr())},className:ts(F==null?void 0:F.actionButton,(f=m==null?void 0:m.classNames)==null?void 0:f.actionButton)},m.action.label):null))};function Ck(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function l3(e,t){let n={};return[e,t].forEach((r,s)=>{let a=s===1,o=a?"--mobile-offset":"--offset",l=a?t3:e3;function c(u){["top","right","bottom","left"].forEach(d=>{n[`${o}-${d}`]=typeof u=="number"?`${u}px`:u})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(u=>{r[u]===void 0?n[`${o}-${u}`]=l:n[`${o}-${u}`]=typeof r[u]=="number"?`${r[u]}px`:r[u]}):c(l)}),n}var c3=p.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:s=["altKey","KeyT"],expand:a,closeButton:o,className:l,offset:c,mobileOffset:u,theme:d="light",richColors:f,duration:h,style:m,visibleToasts:v=J4,toastOptions:w,dir:y=Ck(),gap:x=r3,loadingIcon:g,icons:b,containerAriaLabel:_="Notifications",pauseWhenPageIsHidden:j}=e,[k,S]=X.useState([]),E=X.useMemo(()=>Array.from(new Set([r].concat(k.filter(oe=>oe.position).map(oe=>oe.position)))),[k,r]),[N,O]=X.useState([]),[z,T]=X.useState(!1),[I,P]=X.useState(!1),[H,V]=X.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),M=X.useRef(null),C=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=X.useRef(null),W=X.useRef(!1),ie=X.useCallback(oe=>{S(ce=>{var re;return(re=ce.find(ue=>ue.id===oe.id))!=null&&re.delete||lr.dismiss(oe.id),ce.filter(({id:ue})=>ue!==oe.id)})},[]);return X.useEffect(()=>lr.subscribe(oe=>{if(oe.dismiss){S(ce=>ce.map(re=>re.id===oe.id?{...re,delete:!0}:re));return}setTimeout(()=>{CC.flushSync(()=>{S(ce=>{let re=ce.findIndex(ue=>ue.id===oe.id);return re!==-1?[...ce.slice(0,re),{...ce[re],...oe},...ce.slice(re+1)]:[oe,...ce]})})})}),[]),X.useEffect(()=>{if(d!=="system"){V(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?V("dark"):V("light")),typeof window>"u")return;let oe=window.matchMedia("(prefers-color-scheme: dark)");try{oe.addEventListener("change",({matches:ce})=>{V(ce?"dark":"light")})}catch{oe.addListener(({matches:re})=>{try{V(re?"dark":"light")}catch(ue){console.error(ue)}})}},[d]),X.useEffect(()=>{k.length<=1&&T(!1)},[k]),X.useEffect(()=>{let oe=ce=>{var re,ue;s.every(ke=>ce[ke]||ce.code===ke)&&(T(!0),(re=M.current)==null||re.focus()),ce.code==="Escape"&&(document.activeElement===M.current||(ue=M.current)!=null&&ue.contains(document.activeElement))&&T(!1)};return document.addEventListener("keydown",oe),()=>document.removeEventListener("keydown",oe)},[s]),X.useEffect(()=>{if(M.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,W.current=!1)}},[M.current]),X.createElement("section",{ref:t,"aria-label":`${_} ${C}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},E.map((oe,ce)=>{var re;let[ue,ke]=oe.split("-");return k.length?X.createElement("ol",{key:oe,dir:y==="auto"?Ck():y,tabIndex:-1,ref:M,className:l,"data-sonner-toaster":!0,"data-theme":H,"data-y-position":ue,"data-lifted":z&&k.length>1&&!a,"data-x-position":ke,style:{"--front-toast-height":`${((re=N[0])==null?void 0:re.height)||0}px`,"--width":`${n3}px`,"--gap":`${x}px`,...m,...l3(c,u)},onBlur:L=>{W.current&&!L.currentTarget.contains(L.relatedTarget)&&(W.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:L=>{L.target instanceof HTMLElement&&L.target.dataset.dismissible==="false"||W.current||(W.current=!0,F.current=L.relatedTarget)},onMouseEnter:()=>T(!0),onMouseMove:()=>T(!0),onMouseLeave:()=>{I||T(!1)},onDragEnd:()=>T(!1),onPointerDown:L=>{L.target instanceof HTMLElement&&L.target.dataset.dismissible==="false"||P(!0)},onPointerUp:()=>P(!1)},k.filter(L=>!L.position&&ce===0||L.position===oe).map((L,Q)=>{var fe,ee;return X.createElement(i3,{key:L.id,icons:b,index:Q,toast:L,defaultRichColors:f,duration:(fe=w==null?void 0:w.duration)!=null?fe:h,className:w==null?void 0:w.className,descriptionClassName:w==null?void 0:w.descriptionClassName,invert:n,visibleToasts:v,closeButton:(ee=w==null?void 0:w.closeButton)!=null?ee:o,interacting:I,position:oe,style:w==null?void 0:w.style,unstyled:w==null?void 0:w.unstyled,classNames:w==null?void 0:w.classNames,cancelButtonStyle:w==null?void 0:w.cancelButtonStyle,actionButtonStyle:w==null?void 0:w.actionButtonStyle,removeToast:ie,toasts:k.filter(je=>je.position==L.position),heights:N.filter(je=>je.position==L.position),setHeights:O,expandByDefault:a,gap:x,loadingIcon:g,expanded:z,pauseWhenPageIsHidden:j,swipeDirections:e.swipeDirections})})):null}))}),qh={},u3=()=>{window.va||(window.va=function(...t){window.vaq||(window.vaq=[]),window.vaq.push(t)})},d3="@vercel/analytics",f3="2.0.1";function PC(){return typeof window<"u"}function AC(){try{const e="production"}catch{}return"production"}function h3(e="auto"){if(e==="auto"){window.vam=AC();return}window.vam=e}function m3(){return(PC()?window.vam:AC())||"production"}function Vw(){return m3()==="development"}function p3(e){return e.scriptSrc?xl(e.scriptSrc):Vw()?"https://va.vercel-scripts.com/v1/script.debug.js":e.basePath?xl(`${e.basePath}/insights/script.js`):"/_vercel/insights/script.js"}function g3(e,t){var n;let r=e;if(t)try{r={...(n=JSON.parse(t))==null?void 0:n.analytics,...e}}catch{}h3(r.mode);const s={sdkn:d3+(r.framework?`/${r.framework}`:""),sdkv:f3};return r.disableAutoTrack&&(s.disableAutoTrack="1"),r.viewEndpoint&&(s.viewEndpoint=xl(r.viewEndpoint)),r.eventEndpoint&&(s.eventEndpoint=xl(r.eventEndpoint)),r.sessionEndpoint&&(s.sessionEndpoint=xl(r.sessionEndpoint)),Vw()&&r.debug===!1&&(s.debug="false"),r.dsn&&(s.dsn=r.dsn),r.endpoint?s.endpoint=r.endpoint:r.basePath&&(s.endpoint=xl(`${r.basePath}/insights`)),{beforeSend:r.beforeSend,src:p3(r),dataset:s}}function xl(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?e:`/${e}`}function y3(e={debug:!0},t){var n;if(!PC())return;const{beforeSend:r,src:s,dataset:a}=g3(e,t);if(u3(),r&&((n=window.va)==null||n.call(window,"beforeSend",r)),document.head.querySelector(`script[src*="${s}"]`))return;const o=document.createElement("script");o.src=s;for(const[l,c]of Object.entries(a))o.dataset[l]=c;o.defer=!0,o.onerror=()=>{const l=Vw()?"Please check if any ad blockers are enabled and try again.":"Be sure to enable Web Analytics for your project and deploy again. See https://vercel.com/docs/analytics/quickstart for more information.";console.log(`[Vercel Web Analytics] Failed to load script from ${s}. ${l}`)},document.head.appendChild(o)}function v3({route:e,path:t}){var n;(n=window.va)==null||n.call(window,"pageview",{route:e,path:t})}function x3(){if(!(typeof process>"u"||typeof qh>"u"))return qh.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}function w3(){if(!(typeof process>"u"||typeof qh>"u"))return qh.REACT_APP_VERCEL_OBSERVABILITY_CLIENT_CONFIG}function b3(e){return p.useEffect(()=>{var t;e.beforeSend&&((t=window.va)==null||t.call(window,"beforeSend",e.beforeSend))},[e.beforeSend]),p.useEffect(()=>{y3({framework:e.framework||"react",basePath:e.basePath??x3(),...e.route!==void 0&&{disableAutoTrack:!0},...e},e.configString??w3())},[]),p.useEffect(()=>{e.route&&e.path&&v3({route:e.route,path:e.path})},[e.route,e.path]),null}const _3="modulepreload",k3=function(e){return"/"+e},Tk={},lt=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));s=Promise.allSettled(n.map(c=>{if(c=k3(c),c in Tk)return;Tk[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":_3,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((h,m)=>{f.addEventListener("load",h),f.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return s.then(o=>{for(const l of o||[])l.status==="rejected"&&a(l.reason);return t().catch(a)})},j3=1,S3=1e6;let jg=0;function E3(){return jg=(jg+1)%Number.MAX_SAFE_INTEGER,jg.toString()}const Sg=new Map,Pk=e=>{if(Sg.has(e))return;const t=setTimeout(()=>{Sg.delete(e),Su({type:"REMOVE_TOAST",toastId:e})},S3);Sg.set(e,t)},N3=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,j3)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Pk(n):e.toasts.forEach(r=>{Pk(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},uh=[];let dh={toasts:[]};function Su(e){dh=N3(dh,e),uh.forEach(t=>{t(dh)})}function C3({...e}){const t=E3(),n=s=>Su({type:"UPDATE_TOAST",toast:{...s,id:t}}),r=()=>Su({type:"DISMISS_TOAST",toastId:t});return Su({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:s=>{s||r()}}}),{id:t,dismiss:r,update:n}}function Ww(){const[e,t]=p.useState(dh);return p.useEffect(()=>(uh.push(t),()=>{const n=uh.indexOf(t);n>-1&&uh.splice(n,1)}),[e]),{...e,toast:C3,dismiss:n=>Su({type:"DISMISS_TOAST",toastId:n})}}function xe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e==null||e(s),n===!1||!s.defaultPrevented)return t==null?void 0:t(s)}}function Ak(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function RC(...e){return t=>{let n=!1;const r=e.map(s=>{const a=Ak(s,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let s=0;s{const{children:o,...l}=a,c=p.useMemo(()=>l,Object.values(l));return i.jsx(n.Provider,{value:c,children:o})};r.displayName=e+"Provider";function s(a){const o=p.useContext(n);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,s]}function Ln(e,t=[]){let n=[];function r(a,o){const l=p.createContext(o),c=n.length;n=[...n,o];const u=f=>{var x;const{scope:h,children:m,...v}=f,w=((x=h==null?void 0:h[e])==null?void 0:x[c])||l,y=p.useMemo(()=>v,Object.values(v));return i.jsx(w.Provider,{value:y,children:m})};u.displayName=a+"Provider";function d(f,h){var w;const m=((w=h==null?void 0:h[e])==null?void 0:w[c])||l,v=p.useContext(m);if(v)return v;if(o!==void 0)return o;throw new Error(`\`${f}\` must be used within \`${a}\``)}return[u,d]}const s=()=>{const a=n.map(o=>p.createContext(o));return function(l){const c=(l==null?void 0:l[e])||a;return p.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return s.scopeName=e,[r,P3(s,...t)]}function P3(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const o=r.reduce((l,{useScope:c,scopeName:u})=>{const f=c(a)[`__scope${u}`];return{...l,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}function gi(e){const t=A3(e),n=p.forwardRef((r,s)=>{const{children:a,...o}=r,l=p.Children.toArray(a),c=l.find(R3);if(c){const u=c.props.children,d=l.map(f=>f===c?p.Children.count(u)>1?p.Children.only(null):p.isValidElement(u)?u.props.children:null:f);return i.jsx(t,{...o,ref:s,children:p.isValidElement(u)?p.cloneElement(u,void 0,d):null})}return i.jsx(t,{...o,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}var OC=gi("Slot");function A3(e){const t=p.forwardRef((n,r)=>{const{children:s,...a}=n;if(p.isValidElement(s)){const o=M3(s),l=O3(a,s.props);return s.type!==p.Fragment&&(l.ref=r?RC(r,o):o),p.cloneElement(s,l)}return p.Children.count(s)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var MC=Symbol("radix.slottable");function DC(e){const t=({children:n})=>i.jsx(i.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=MC,t}function R3(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===MC}function O3(e,t){const n={...t};for(const r in t){const s=e[r],a=t[r];/^on[A-Z]/.test(r)?s&&a?n[r]=(...l)=>{const c=a(...l);return s(...l),c}:s&&(n[r]=s):r==="style"?n[r]={...s,...a}:r==="className"&&(n[r]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function M3(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Hw(e){const t=e+"CollectionProvider",[n,r]=Ln(t),[s,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:y,children:x}=w,g=X.useRef(null),b=X.useRef(new Map).current;return i.jsx(s,{scope:y,itemMap:b,collectionRef:g,children:x})};o.displayName=t;const l=e+"CollectionSlot",c=gi(l),u=X.forwardRef((w,y)=>{const{scope:x,children:g}=w,b=a(l,x),_=ze(y,b.collectionRef);return i.jsx(c,{ref:_,children:g})});u.displayName=l;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=gi(d),m=X.forwardRef((w,y)=>{const{scope:x,children:g,...b}=w,_=X.useRef(null),j=ze(y,_),k=a(d,x);return X.useEffect(()=>(k.itemMap.set(_,{ref:_,...b}),()=>void k.itemMap.delete(_))),i.jsx(h,{[f]:"",ref:j,children:g})});m.displayName=d;function v(w){const y=a(e+"CollectionConsumer",w);return X.useCallback(()=>{const g=y.collectionRef.current;if(!g)return[];const b=Array.from(g.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((k,S)=>b.indexOf(k.ref.current)-b.indexOf(S.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:o,Slot:u,ItemSlot:m},v,r]}var D3=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Te=D3.reduce((e,t)=>{const n=gi(`Primitive.${t}`),r=p.forwardRef((s,a)=>{const{asChild:o,...l}=s,c=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(c,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function IC(e,t){e&&Pi.flushSync(()=>e.dispatchEvent(t))}function on(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function I3(e,t=globalThis==null?void 0:globalThis.document){const n=on(e);p.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var L3="DismissableLayer",Ev="dismissableLayer.update",$3="dismissableLayer.pointerDownOutside",F3="dismissableLayer.focusOutside",Rk,LC=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),wc=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...c}=e,u=p.useContext(LC),[d,f]=p.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=p.useState({}),v=ze(t,S=>f(S)),w=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=w.indexOf(y),g=d?w.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,_=g>=x,j=B3(S=>{const E=S.target,N=[...u.branches].some(O=>O.contains(E));!_||N||(s==null||s(S),o==null||o(S),S.defaultPrevented||l==null||l())},h),k=U3(S=>{const E=S.target;[...u.branches].some(O=>O.contains(E))||(a==null||a(S),o==null||o(S),S.defaultPrevented||l==null||l())},h);return I3(S=>{g===u.layers.size-1&&(r==null||r(S),!S.defaultPrevented&&l&&(S.preventDefault(),l()))},h),p.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Rk=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Ok(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Rk)}},[d,h,n,u]),p.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Ok())},[d,u]),p.useEffect(()=>{const S=()=>m({});return document.addEventListener(Ev,S),()=>document.removeEventListener(Ev,S)},[]),i.jsx(Te.div,{...c,ref:v,style:{pointerEvents:b?_?"auto":"none":void 0,...e.style},onFocusCapture:xe(e.onFocusCapture,k.onFocusCapture),onBlurCapture:xe(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:xe(e.onPointerDownCapture,j.onPointerDownCapture)})});wc.displayName=L3;var z3="DismissableLayerBranch",$C=p.forwardRef((e,t)=>{const n=p.useContext(LC),r=p.useRef(null),s=ze(t,r);return p.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),i.jsx(Te.div,{...e,ref:s})});$C.displayName=z3;function B3(e,t=globalThis==null?void 0:globalThis.document){const n=on(e),r=p.useRef(!1),s=p.useRef(()=>{});return p.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){FC($3,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=c,t.addEventListener("click",s.current,{once:!0})):c()}else t.removeEventListener("click",s.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function U3(e,t=globalThis==null?void 0:globalThis.document){const n=on(e),r=p.useRef(!1);return p.useEffect(()=>{const s=a=>{a.target&&!r.current&&FC(F3,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Ok(){const e=new CustomEvent(Ev);document.dispatchEvent(e)}function FC(e,t,n,{discrete:r}){const s=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?IC(s,a):s.dispatchEvent(a)}var V3=wc,W3=$C,Zt=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},H3="Portal",Sd=p.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[s,a]=p.useState(!1);Zt(()=>a(!0),[]);const o=n||s&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return o?CC.createPortal(i.jsx(Te.div,{...r,ref:t}),o):null});Sd.displayName=H3;function q3(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Jn=e=>{const{present:t,children:n}=e,r=K3(t),s=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),a=ze(r.ref,G3(s));return typeof n=="function"||r.isPresent?p.cloneElement(s,{ref:a}):null};Jn.displayName="Presence";function K3(e){const[t,n]=p.useState(),r=p.useRef(null),s=p.useRef(e),a=p.useRef("none"),o=e?"mounted":"unmounted",[l,c]=q3(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const u=xf(r.current);a.current=l==="mounted"?u:"none"},[l]),Zt(()=>{const u=r.current,d=s.current;if(d!==e){const h=a.current,m=xf(u);e?c("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,c]),Zt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const w=xf(r.current).includes(m.animationName);if(m.target===t&&w&&(c("ANIMATION_END"),!s.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=m=>{m.target===t&&(a.current=xf(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:p.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function xf(e){return(e==null?void 0:e.animationName)||"none"}function G3(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Y3=Zx[" useInsertionEffect ".trim().toString()]||Zt;function vs({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[s,a,o]=Q3({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:s;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const f=d.current;f!==l&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${l?"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.`),d.current=l},[l,r])}const u=p.useCallback(d=>{var f;if(l){const h=X3(d)?d(e):d;h!==e&&((f=o.current)==null||f.call(o,h))}else a(d)},[l,e,a,o]);return[c,u]}function Q3({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),s=p.useRef(n),a=p.useRef(t);return Y3(()=>{a.current=t},[t]),p.useEffect(()=>{var o;s.current!==n&&((o=a.current)==null||o.call(a,n),s.current=n)},[n,s]),[n,r,a]}function X3(e){return typeof e=="function"}var zC=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"}),Z3="VisuallyHidden",Wm=p.forwardRef((e,t)=>i.jsx(Te.span,{...e,ref:t,style:{...zC,...e.style}}));Wm.displayName=Z3;var J3=Wm,qw="ToastProvider",[Kw,e5,t5]=Hw("Toast"),[BC]=Ln("Toast",[t5]),[n5,Hm]=BC(qw),UC=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:s="right",swipeThreshold:a=50,children:o}=e,[l,c]=p.useState(null),[u,d]=p.useState(0),f=p.useRef(!1),h=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${qw}\`. Expected non-empty \`string\`.`),i.jsx(Kw.Provider,{scope:t,children:i.jsx(n5,{scope:t,label:n,duration:r,swipeDirection:s,swipeThreshold:a,toastCount:u,viewport:l,onViewportChange:c,onToastAdd:p.useCallback(()=>d(m=>m+1),[]),onToastRemove:p.useCallback(()=>d(m=>m-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:h,children:o})})};UC.displayName=qw;var VC="ToastViewport",r5=["F8"],Nv="toast.viewportPause",Cv="toast.viewportResume",WC=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=r5,label:s="Notifications ({hotkey})",...a}=e,o=Hm(VC,n),l=e5(n),c=p.useRef(null),u=p.useRef(null),d=p.useRef(null),f=p.useRef(null),h=ze(t,f,o.onViewportChange),m=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=o.toastCount>0;p.useEffect(()=>{const y=x=>{var b;r.length!==0&&r.every(_=>x[_]||x.code===_)&&((b=f.current)==null||b.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[r]),p.useEffect(()=>{const y=c.current,x=f.current;if(v&&y&&x){const g=()=>{if(!o.isClosePausedRef.current){const k=new CustomEvent(Nv);x.dispatchEvent(k),o.isClosePausedRef.current=!0}},b=()=>{if(o.isClosePausedRef.current){const k=new CustomEvent(Cv);x.dispatchEvent(k),o.isClosePausedRef.current=!1}},_=k=>{!y.contains(k.relatedTarget)&&b()},j=()=>{y.contains(document.activeElement)||b()};return y.addEventListener("focusin",g),y.addEventListener("focusout",_),y.addEventListener("pointermove",g),y.addEventListener("pointerleave",j),window.addEventListener("blur",g),window.addEventListener("focus",b),()=>{y.removeEventListener("focusin",g),y.removeEventListener("focusout",_),y.removeEventListener("pointermove",g),y.removeEventListener("pointerleave",j),window.removeEventListener("blur",g),window.removeEventListener("focus",b)}}},[v,o.isClosePausedRef]);const w=p.useCallback(({tabbingDirection:y})=>{const g=l().map(b=>{const _=b.ref.current,j=[_,...g5(_)];return y==="forwards"?j:j.reverse()});return(y==="forwards"?g.reverse():g).flat()},[l]);return p.useEffect(()=>{const y=f.current;if(y){const x=g=>{var j,k,S;const b=g.altKey||g.ctrlKey||g.metaKey;if(g.key==="Tab"&&!b){const E=document.activeElement,N=g.shiftKey;if(g.target===y&&N){(j=u.current)==null||j.focus();return}const T=w({tabbingDirection:N?"backwards":"forwards"}),I=T.findIndex(P=>P===E);Eg(T.slice(I+1))?g.preventDefault():N?(k=u.current)==null||k.focus():(S=d.current)==null||S.focus()}};return y.addEventListener("keydown",x),()=>y.removeEventListener("keydown",x)}},[l,w]),i.jsxs(W3,{ref:c,role:"region","aria-label":s.replace("{hotkey}",m),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&i.jsx(Tv,{ref:u,onFocusFromOutsideViewport:()=>{const y=w({tabbingDirection:"forwards"});Eg(y)}}),i.jsx(Kw.Slot,{scope:n,children:i.jsx(Te.ol,{tabIndex:-1,...a,ref:h})}),v&&i.jsx(Tv,{ref:d,onFocusFromOutsideViewport:()=>{const y=w({tabbingDirection:"backwards"});Eg(y)}})]})});WC.displayName=VC;var HC="ToastFocusProxy",Tv=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...s}=e,a=Hm(HC,n);return i.jsx(Wm,{"aria-hidden":!0,tabIndex:0,...s,ref:t,style:{position:"fixed"},onFocus:o=>{var u;const l=o.relatedTarget;!((u=a.viewport)!=null&&u.contains(l))&&r()}})});Tv.displayName=HC;var Ed="Toast",s5="toast.swipeStart",a5="toast.swipeMove",o5="toast.swipeCancel",i5="toast.swipeEnd",qC=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:s,onOpenChange:a,...o}=e,[l,c]=vs({prop:r,defaultProp:s??!0,onChange:a,caller:Ed});return i.jsx(Jn,{present:n||l,children:i.jsx(u5,{open:l,...o,ref:t,onClose:()=>c(!1),onPause:on(e.onPause),onResume:on(e.onResume),onSwipeStart:xe(e.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:xe(e.onSwipeMove,u=>{const{x:d,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:xe(e.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:xe(e.onSwipeEnd,u=>{const{x:d,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),c(!1)})})})});qC.displayName=Ed;var[l5,c5]=BC(Ed,{onClose(){}}),u5=p.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:s,open:a,onClose:o,onEscapeKeyDown:l,onPause:c,onResume:u,onSwipeStart:d,onSwipeMove:f,onSwipeCancel:h,onSwipeEnd:m,...v}=e,w=Hm(Ed,n),[y,x]=p.useState(null),g=ze(t,P=>x(P)),b=p.useRef(null),_=p.useRef(null),j=s||w.duration,k=p.useRef(0),S=p.useRef(j),E=p.useRef(0),{onToastAdd:N,onToastRemove:O}=w,z=on(()=>{var H;(y==null?void 0:y.contains(document.activeElement))&&((H=w.viewport)==null||H.focus()),o()}),T=p.useCallback(P=>{!P||P===1/0||(window.clearTimeout(E.current),k.current=new Date().getTime(),E.current=window.setTimeout(z,P))},[z]);p.useEffect(()=>{const P=w.viewport;if(P){const H=()=>{T(S.current),u==null||u()},V=()=>{const M=new Date().getTime()-k.current;S.current=S.current-M,window.clearTimeout(E.current),c==null||c()};return P.addEventListener(Nv,V),P.addEventListener(Cv,H),()=>{P.removeEventListener(Nv,V),P.removeEventListener(Cv,H)}}},[w.viewport,j,c,u,T]),p.useEffect(()=>{a&&!w.isClosePausedRef.current&&T(j)},[a,j,w.isClosePausedRef,T]),p.useEffect(()=>(N(),()=>O()),[N,O]);const I=p.useMemo(()=>y?JC(y):null,[y]);return w.viewport?i.jsxs(i.Fragment,{children:[I&&i.jsx(d5,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:I}),i.jsx(l5,{scope:n,onClose:z,children:Pi.createPortal(i.jsx(Kw.ItemSlot,{scope:n,children:i.jsx(V3,{asChild:!0,onEscapeKeyDown:xe(l,()=>{w.isFocusedToastEscapeKeyDownRef.current||z(),w.isFocusedToastEscapeKeyDownRef.current=!1}),children:i.jsx(Te.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":a?"open":"closed","data-swipe-direction":w.swipeDirection,...v,ref:g,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:xe(e.onKeyDown,P=>{P.key==="Escape"&&(l==null||l(P.nativeEvent),P.nativeEvent.defaultPrevented||(w.isFocusedToastEscapeKeyDownRef.current=!0,z()))}),onPointerDown:xe(e.onPointerDown,P=>{P.button===0&&(b.current={x:P.clientX,y:P.clientY})}),onPointerMove:xe(e.onPointerMove,P=>{if(!b.current)return;const H=P.clientX-b.current.x,V=P.clientY-b.current.y,M=!!_.current,C=["left","right"].includes(w.swipeDirection),F=["left","up"].includes(w.swipeDirection)?Math.min:Math.max,W=C?F(0,H):0,ie=C?0:F(0,V),oe=P.pointerType==="touch"?10:2,ce={x:W,y:ie},re={originalEvent:P,delta:ce};M?(_.current=ce,wf(a5,f,re,{discrete:!1})):Mk(ce,w.swipeDirection,oe)?(_.current=ce,wf(s5,d,re,{discrete:!1}),P.target.setPointerCapture(P.pointerId)):(Math.abs(H)>oe||Math.abs(V)>oe)&&(b.current=null)}),onPointerUp:xe(e.onPointerUp,P=>{const H=_.current,V=P.target;if(V.hasPointerCapture(P.pointerId)&&V.releasePointerCapture(P.pointerId),_.current=null,b.current=null,H){const M=P.currentTarget,C={originalEvent:P,delta:H};Mk(H,w.swipeDirection,w.swipeThreshold)?wf(i5,m,C,{discrete:!0}):wf(o5,h,C,{discrete:!0}),M.addEventListener("click",F=>F.preventDefault(),{once:!0})}})})})}),w.viewport)})]}):null}),d5=e=>{const{__scopeToast:t,children:n,...r}=e,s=Hm(Ed,t),[a,o]=p.useState(!1),[l,c]=p.useState(!1);return m5(()=>o(!0)),p.useEffect(()=>{const u=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(u)},[]),l?null:i.jsx(Sd,{asChild:!0,children:i.jsx(Wm,{...r,children:a&&i.jsxs(i.Fragment,{children:[s.label," ",n]})})})},f5="ToastTitle",KC=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return i.jsx(Te.div,{...r,ref:t})});KC.displayName=f5;var h5="ToastDescription",GC=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return i.jsx(Te.div,{...r,ref:t})});GC.displayName=h5;var YC="ToastAction",QC=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?i.jsx(ZC,{altText:n,asChild:!0,children:i.jsx(Gw,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${YC}\`. Expected non-empty \`string\`.`),null)});QC.displayName=YC;var XC="ToastClose",Gw=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,s=c5(XC,n);return i.jsx(ZC,{asChild:!0,children:i.jsx(Te.button,{type:"button",...r,ref:t,onClick:xe(e.onClick,s.onClose)})})});Gw.displayName=XC;var ZC=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...s}=e;return i.jsx(Te.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...s,ref:t})});function JC(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),p5(r)){const s=r.ariaHidden||r.hidden||r.style.display==="none",a=r.dataset.radixToastAnnounceExclude==="";if(!s)if(a){const o=r.dataset.radixToastAnnounceAlt;o&&t.push(o)}else t.push(...JC(r))}}),t}function wf(e,t,n,{discrete:r}){const s=n.originalEvent.currentTarget,a=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?IC(s,a):s.dispatchEvent(a)}var Mk=(e,t,n=0)=>{const r=Math.abs(e.x),s=Math.abs(e.y),a=r>s;return t==="left"||t==="right"?a&&r>n:!a&&s>n};function m5(e=()=>{}){const t=on(e);Zt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function p5(e){return e.nodeType===e.ELEMENT_NODE}function g5(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Eg(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var y5=UC,eT=WC,tT=qC,nT=KC,rT=GC,sT=QC,aT=Gw;function oT(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;ttypeof e=="boolean"?`${e}`:e===0?"0":e,Ik=iT,bc=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Ik(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:s,defaultVariants:a}=t,o=Object.keys(s).map(u=>{const d=n==null?void 0:n[u],f=a==null?void 0:a[u];if(d===null)return null;const h=Dk(d)||Dk(f);return s[u][h]}),l=n&&Object.entries(n).reduce((u,d)=>{let[f,h]=d;return h===void 0||(u[f]=h),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:f,className:h,...m}=d;return Object.entries(m).every(v=>{let[w,y]=v;return Array.isArray(y)?y.includes({...a,...l}[w]):{...a,...l}[w]===y})?[...u,f,h]:u},[]);return Ik(e,o,c,n==null?void 0:n.class,n==null?void 0:n.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 v5=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),lT=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).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 x5={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 w5=p.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:o,...l},c)=>p.createElement("svg",{ref:c,...x5,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:lT("lucide",s),...l},[...o.map(([u,d])=>p.createElement(u,d)),...Array.isArray(a)?a:[a]]));/** * @license lucide-react v0.462.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=(e,t)=>{const n=p.forwardRef(({className:r,...s},a)=>p.createElement(w5,{ref:a,iconNode:t,className:lT(`lucide-${v5(e)}`,r),...s}));return n.displayName=`${e}`,n};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b5=se("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 Yw=se("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 Lk=se("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 cT=se("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 _5=se("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 k5=se("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 $k=se("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 j5=se("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 qm=se("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 _c=se("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 Pv=se("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 Km=se("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 Wt=se("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 uT=se("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 wl=se("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 dT=se("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 kc=se("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 Qw=se("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 fT=se("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 Gm=se("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 hT=se("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 Xw=se("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 yi=se("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 S5=se("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 Zw=se("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 Fk=se("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 To=se("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 E5=se("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 N5=se("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 zk=se("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 C5=se("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 T5=se("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 P5=se("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 A5=se("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 Ym=se("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 Eu=se("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 R5=se("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 O5=se("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 M5=se("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 D5=se("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 Nd=se("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 I5=se("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 L5=se("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 $5=se("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 F5=se("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 Bk=se("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 Kh=se("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 z5=se("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 yn=se("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 B5=se("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 Xu=se("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 uo=se("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 xo=se("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 U5=se("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 mT=se("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 pT=se("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 V5=se("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 W5=se("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 Cd=se("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 H5=se("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 gT=se("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 q5=se("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 Ai=se("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 K5=se("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 jc=se("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 Zu=se("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 qs=se("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 G5=se("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 Y5=se("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 bf=se("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 Q5=se("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 X5=se("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 Z5=se("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 yT=se("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 J5=se("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 Uk=se("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 e$=se("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 t$=se("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 n$=se("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 r$=se("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 s$=se("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 a$=se("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 o$=se("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 i$=se("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 Gh=se("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 Jw=se("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 l$=se("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 Vr=se("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 e0=se("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 vr=se("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 Wr=se("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 c$=se("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 fo=se("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 Sa=se("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 Ju=se("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"}]]),t0="-",u$=e=>{const t=f$(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const l=o.split(t0);return l[0]===""&&l.length!==1&&l.shift(),vT(l,t)||d$(o)},getConflictingClassGroupIds:(o,l)=>{const c=n[o]||[];return l&&r[o]?[...c,...r[o]]:c}}},vT=(e,t)=>{var o;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),s=r?vT(e.slice(1),r):void 0;if(s)return s;if(t.validators.length===0)return;const a=e.join(t0);return(o=t.validators.find(({validator:l})=>l(a)))==null?void 0:o.classGroupId},Vk=/^\[(.+)\]$/,d$=e=>{if(Vk.test(e)){const t=Vk.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},f$=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return m$(Object.entries(e.classGroups),n).forEach(([a,o])=>{Av(o,r,a,t)}),r},Av=(e,t,n,r)=>{e.forEach(s=>{if(typeof s=="string"){const a=s===""?t:Wk(t,s);a.classGroupId=n;return}if(typeof s=="function"){if(h$(s)){Av(s(r),t,n,r);return}t.validators.push({validator:s,classGroupId:n});return}Object.entries(s).forEach(([a,o])=>{Av(o,Wk(t,a),n,r)})})},Wk=(e,t)=>{let n=e;return t.split(t0).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},h$=e=>e.isThemeGetter,m$=(e,t)=>t?e.map(([n,r])=>{const s=r.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([o,l])=>[t+o,l])):a);return[n,s]}):e,p$=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const s=(a,o)=>{n.set(a,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let o=n.get(a);if(o!==void 0)return o;if((o=r.get(a))!==void 0)return s(a,o),o},set(a,o){n.has(a)?n.set(a,o):s(a,o)}}},xT="!",g$=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,s=t[0],a=t.length,o=l=>{const c=[];let u=0,d=0,f;for(let y=0;yd?f-d:void 0;return{modifiers:c,hasImportantModifier:m,baseClassName:v,maybePostfixModifierPosition:w}};return n?l=>n({className:l,parseClassName:o}):o},y$=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},v$=e=>({cache:p$(e.cacheSize),parseClassName:g$(e),...u$(e)}),x$=/\s+/,w$=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s}=t,a=[],o=e.trim().split(x$);let l="";for(let c=o.length-1;c>=0;c-=1){const u=o[c],{modifiers:d,hasImportantModifier:f,baseClassName:h,maybePostfixModifierPosition:m}=n(u);let v=!!m,w=r(v?h.substring(0,m):h);if(!w){if(!v){l=u+(l.length>0?" "+l:l);continue}if(w=r(h),!w){l=u+(l.length>0?" "+l:l);continue}v=!1}const y=y$(d).join(":"),x=f?y+xT:y,g=x+w;if(a.includes(g))continue;a.push(g);const b=s(w,v);for(let _=0;_0?" "+l:l)}return l};function b$(){let e=0,t,n,r="";for(;e{if(typeof e=="string")return e;let t,n="";for(let r=0;rf(d),e());return n=v$(u),r=n.cache.get,s=n.cache.set,a=l,l(c)}function l(c){const u=r(c);if(u)return u;const d=w$(c,n);return s(c,d),d}return function(){return a(b$.apply(null,arguments))}}const Nt=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},bT=/^\[(?:([a-z-]+):)?(.+)\]$/i,k$=/^\d+\/\d+$/,j$=new Set(["px","full","screen"]),S$=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,E$=/\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$/,N$=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,C$=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,T$=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ta=e=>Cl(e)||j$.has(e)||k$.test(e),Ta=e=>Sc(e,"length",L$),Cl=e=>!!e&&!Number.isNaN(Number(e)),Ng=e=>Sc(e,"number",Cl),Gc=e=>!!e&&Number.isInteger(Number(e)),P$=e=>e.endsWith("%")&&Cl(e.slice(0,-1)),Ve=e=>bT.test(e),Pa=e=>S$.test(e),A$=new Set(["length","size","percentage"]),R$=e=>Sc(e,A$,_T),O$=e=>Sc(e,"position",_T),M$=new Set(["image","url"]),D$=e=>Sc(e,M$,F$),I$=e=>Sc(e,"",$$),Yc=()=>!0,Sc=(e,t,n)=>{const r=bT.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},L$=e=>E$.test(e)&&!N$.test(e),_T=()=>!1,$$=e=>C$.test(e),F$=e=>T$.test(e),z$=()=>{const e=Nt("colors"),t=Nt("spacing"),n=Nt("blur"),r=Nt("brightness"),s=Nt("borderColor"),a=Nt("borderRadius"),o=Nt("borderSpacing"),l=Nt("borderWidth"),c=Nt("contrast"),u=Nt("grayscale"),d=Nt("hueRotate"),f=Nt("invert"),h=Nt("gap"),m=Nt("gradientColorStops"),v=Nt("gradientColorStopPositions"),w=Nt("inset"),y=Nt("margin"),x=Nt("opacity"),g=Nt("padding"),b=Nt("saturate"),_=Nt("scale"),j=Nt("sepia"),k=Nt("skew"),S=Nt("space"),E=Nt("translate"),N=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],z=()=>["auto",Ve,t],T=()=>[Ve,t],I=()=>["",ta,Ta],P=()=>["auto",Cl,Ve],H=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],V=()=>["solid","dashed","dotted","double","none"],M=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],C=()=>["start","end","center","between","around","evenly","stretch"],F=()=>["","0",Ve],W=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ie=()=>[Cl,Ve];return{cacheSize:500,separator:":",theme:{colors:[Yc],spacing:[ta,Ta],blur:["none","",Pa,Ve],brightness:ie(),borderColor:[e],borderRadius:["none","","full",Pa,Ve],borderSpacing:T(),borderWidth:I(),contrast:ie(),grayscale:F(),hueRotate:ie(),invert:F(),gap:T(),gradientColorStops:[e],gradientColorStopPositions:[P$,Ta],inset:z(),margin:z(),opacity:ie(),padding:T(),saturate:ie(),scale:ie(),sepia:F(),skew:ie(),space:T(),translate:T()},classGroups:{aspect:[{aspect:["auto","square","video",Ve]}],container:["container"],columns:[{columns:[Pa]}],"break-after":[{"break-after":W()}],"break-before":[{"break-before":W()}],"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:[...H(),Ve]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Gc,Ve]}],basis:[{basis:z()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Ve]}],grow:[{grow:F()}],shrink:[{shrink:F()}],order:[{order:["first","last","none",Gc,Ve]}],"grid-cols":[{"grid-cols":[Yc]}],"col-start-end":[{col:["auto",{span:["full",Gc,Ve]},Ve]}],"col-start":[{"col-start":P()}],"col-end":[{"col-end":P()}],"grid-rows":[{"grid-rows":[Yc]}],"row-start-end":[{row:["auto",{span:[Gc,Ve]},Ve]}],"row-start":[{"row-start":P()}],"row-end":[{"row-end":P()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Ve]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Ve]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...C()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...C(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...C(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[g]}],px:[{px:[g]}],py:[{py:[g]}],ps:[{ps:[g]}],pe:[{pe:[g]}],pt:[{pt:[g]}],pr:[{pr:[g]}],pb:[{pb:[g]}],pl:[{pl:[g]}],m:[{m:[y]}],mx:[{mx:[y]}],my:[{my:[y]}],ms:[{ms:[y]}],me:[{me:[y]}],mt:[{mt:[y]}],mr:[{mr:[y]}],mb:[{mb:[y]}],ml:[{ml:[y]}],"space-x":[{"space-x":[S]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[S]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Ve,t]}],"min-w":[{"min-w":[Ve,t,"min","max","fit"]}],"max-w":[{"max-w":[Ve,t,"none","full","min","max","fit","prose",{screen:[Pa]},Pa]}],h:[{h:[Ve,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Ve,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Ve,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Ve,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Pa,Ta]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Ng]}],"font-family":[{font:[Yc]}],"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",Ve]}],"line-clamp":[{"line-clamp":["none",Cl,Ng]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ta,Ve]}],"list-image":[{"list-image":["none",Ve]}],"list-style-type":[{list:["none","disc","decimal",Ve]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[x]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[x]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...V(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",ta,Ta]}],"underline-offset":[{"underline-offset":["auto",ta,Ve]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ve]}],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",Ve]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[x]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...H(),O$]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",R$]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},D$]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[v]}],"gradient-via-pos":[{via:[v]}],"gradient-to-pos":[{to:[v]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[x]}],"border-style":[{border:[...V(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[x]}],"divide-style":[{divide:V()}],"border-color":[{border:[s]}],"border-color-x":[{"border-x":[s]}],"border-color-y":[{"border-y":[s]}],"border-color-s":[{"border-s":[s]}],"border-color-e":[{"border-e":[s]}],"border-color-t":[{"border-t":[s]}],"border-color-r":[{"border-r":[s]}],"border-color-b":[{"border-b":[s]}],"border-color-l":[{"border-l":[s]}],"divide-color":[{divide:[s]}],"outline-style":[{outline:["",...V()]}],"outline-offset":[{"outline-offset":[ta,Ve]}],"outline-w":[{outline:[ta,Ta]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:I()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[x]}],"ring-offset-w":[{"ring-offset":[ta,Ta]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Pa,I$]}],"shadow-color":[{shadow:[Yc]}],opacity:[{opacity:[x]}],"mix-blend":[{"mix-blend":[...M(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":M()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",Pa,Ve]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[f]}],saturate:[{saturate:[b]}],sepia:[{sepia:[j]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[x]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[j]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Ve]}],duration:[{duration:ie()}],ease:[{ease:["linear","in","out","in-out",Ve]}],delay:[{delay:ie()}],animate:[{animate:["none","spin","ping","pulse","bounce",Ve]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[_]}],"scale-x":[{"scale-x":[_]}],"scale-y":[{"scale-y":[_]}],rotate:[{rotate:[Gc,Ve]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[k]}],"skew-y":[{"skew-y":[k]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Ve]}],accent:[{accent:["auto",e]}],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",Ve]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"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",Ve]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[ta,Ta,Ng]}],stroke:[{stroke:[e,"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"]}}},B$=_$(z$);function Y(...e){return B$(iT(e))}const U$=y5,kT=p.forwardRef(({className:e,...t},n)=>i.jsx(eT,{ref:n,className:Y("fixed top-0 z-[140] 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]",e),...t}));kT.displayName=eT.displayName;const V$=bc("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"}}),jT=p.forwardRef(({className:e,variant:t,...n},r)=>i.jsx(tT,{ref:r,className:Y(V$({variant:t}),e),...n}));jT.displayName=tT.displayName;const W$=p.forwardRef(({className:e,...t},n)=>i.jsx(sT,{ref:n,className:Y("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-0 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",e),...t}));W$.displayName=sT.displayName;const ST=p.forwardRef(({className:e,...t},n)=>i.jsx(aT,{ref:n,className:Y("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",e),"toast-close":"",...t,children:i.jsx(Sa,{className:"h-4 w-4"})}));ST.displayName=aT.displayName;const ET=p.forwardRef(({className:e,...t},n)=>i.jsx(nT,{ref:n,className:Y("text-sm font-semibold",e),...t}));ET.displayName=nT.displayName;const NT=p.forwardRef(({className:e,...t},n)=>i.jsx(rT,{ref:n,className:Y("text-sm opacity-90",e),...t}));NT.displayName=rT.displayName;function H$(){const{toasts:e}=Ww();return i.jsxs(U$,{children:[e.map(function({id:t,title:n,description:r,action:s,...a}){return i.jsxs(jT,{...a,children:[i.jsxs("div",{className:"grid gap-1",children:[n&&i.jsx(ET,{children:n}),r&&i.jsx(NT,{children:r})]}),s,i.jsx(ST,{})]},t)}),i.jsx(kT,{})]})}var Yh=["light","dark"],n0="(prefers-color-scheme: dark)",q$=typeof window>"u",r0=p.createContext(void 0),K$={setTheme:e=>{},themes:[]},CT=()=>{var e;return(e=p.useContext(r0))!=null?e:K$},G$=e=>p.useContext(r0)?e.children:p.createElement(Q$,{...e}),Y$=["light","dark"],Q$=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:n=!0,enableColorScheme:r=!0,storageKey:s="theme",themes:a=Y$,defaultTheme:o=n?"system":"light",attribute:l="data-theme",value:c,children:u,nonce:d})=>{let[f,h]=p.useState(()=>Hk(s,o)),[m,v]=p.useState(()=>Hk(s)),w=c?Object.values(c):a,y=p.useCallback(_=>{let j=_;if(!j)return;_==="system"&&n&&(j=qk());let k=c?c[j]:j,S=t?Z$():null,E=document.documentElement;if(l==="class"?(E.classList.remove(...w),k&&E.classList.add(k)):k?E.setAttribute(l,k):E.removeAttribute(l),r){let N=Yh.includes(o)?o:null,O=Yh.includes(j)?j:N;E.style.colorScheme=O}S==null||S()},[]),x=p.useCallback(_=>{let j=typeof _=="function"?_(_):_;h(j);try{localStorage.setItem(s,j)}catch{}},[e]),g=p.useCallback(_=>{let j=qk(_);v(j),f==="system"&&n&&!e&&y("system")},[f,e]);p.useEffect(()=>{let _=window.matchMedia(n0);return _.addListener(g),g(_),()=>_.removeListener(g)},[g]),p.useEffect(()=>{let _=j=>{if(j.key!==s)return;let k=j.newValue||o;x(k)};return window.addEventListener("storage",_),()=>window.removeEventListener("storage",_)},[x]),p.useEffect(()=>{y(e??f)},[e,f]);let b=p.useMemo(()=>({theme:f,setTheme:x,forcedTheme:e,resolvedTheme:f==="system"?m:f,themes:n?[...a,"system"]:a,systemTheme:n?m:void 0}),[f,x,e,m,n,a]);return p.createElement(r0.Provider,{value:b},p.createElement(X$,{forcedTheme:e,disableTransitionOnChange:t,enableSystem:n,enableColorScheme:r,storageKey:s,themes:a,defaultTheme:o,attribute:l,value:c,children:u,attrs:w,nonce:d}),u)},X$=p.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:s,defaultTheme:a,value:o,attrs:l,nonce:c})=>{let u=a==="system",d=n==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${l.map(v=>`'${v}'`).join(",")})`};`:`var d=document.documentElement,n='${n}',s='setAttribute';`,f=s?Yh.includes(a)&&a?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${a}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",h=(v,w=!1,y=!0)=>{let x=o?o[v]:v,g=w?v+"|| ''":`'${x}'`,b="";return s&&y&&!w&&Yh.includes(v)&&(b+=`d.style.colorScheme = '${v}';`),n==="class"?w||x?b+=`c.add(${g})`:b+="null":x&&(b+=`d[s](n,${g})`),b},m=e?`!function(){${d}${h(e)}}()`:r?`!function(){try{${d}var e=localStorage.getItem('${t}');if('system'===e||(!e&&${u})){var t='${n0}',m=window.matchMedia(t);if(m.media!==t||m.matches){${h("dark")}}else{${h("light")}}}else if(e){${o?`var x=${JSON.stringify(o)};`:""}${h(o?"x[e]":"e",!0)}}${u?"":"else{"+h(a,!1,!1)+"}"}${f}}catch(e){}}()`:`!function(){try{${d}var e=localStorage.getItem('${t}');if(e){${o?`var x=${JSON.stringify(o)};`:""}${h(o?"x[e]":"e",!0)}}else{${h(a,!1,!1)};}${f}}catch(t){}}();`;return p.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:m}})}),Hk=(e,t)=>{if(q$)return;let n;try{n=localStorage.getItem(e)||void 0}catch{}return n||t},Z$=()=>{let e=document.createElement("style");return e.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(e),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(e)},1)}},qk=e=>(e||(e=window.matchMedia(n0)),e.matches?"dark":"light");const J$=({...e})=>{const{theme:t="system"}=CT();return i.jsx(c3,{theme:t,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"}},...e})};var eF=Zx[" useId ".trim().toString()]||(()=>{}),tF=0;function Vs(e){const[t,n]=p.useState(eF());return Zt(()=>{n(r=>r??String(tF++))},[e]),t?`radix-${t}`:""}const nF=["top","right","bottom","left"],wo=Math.min,_r=Math.max,Qh=Math.round,_f=Math.floor,Ws=e=>({x:e,y:e}),rF={left:"right",right:"left",bottom:"top",top:"bottom"},sF={start:"end",end:"start"};function Rv(e,t,n){return _r(e,wo(t,n))}function wa(e,t){return typeof e=="function"?e(t):e}function ba(e){return e.split("-")[0]}function Ec(e){return e.split("-")[1]}function s0(e){return e==="x"?"y":"x"}function a0(e){return e==="y"?"height":"width"}const aF=new Set(["top","bottom"]);function $s(e){return aF.has(ba(e))?"y":"x"}function o0(e){return s0($s(e))}function oF(e,t,n){n===void 0&&(n=!1);const r=Ec(e),s=o0(e),a=a0(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(o=Xh(o)),[o,Xh(o)]}function iF(e){const t=Xh(e);return[Ov(e),t,Ov(t)]}function Ov(e){return e.replace(/start|end/g,t=>sF[t])}const Kk=["left","right"],Gk=["right","left"],lF=["top","bottom"],cF=["bottom","top"];function uF(e,t,n){switch(e){case"top":case"bottom":return n?t?Gk:Kk:t?Kk:Gk;case"left":case"right":return t?lF:cF;default:return[]}}function dF(e,t,n,r){const s=Ec(e);let a=uF(ba(e),n==="start",r);return s&&(a=a.map(o=>o+"-"+s),t&&(a=a.concat(a.map(Ov)))),a}function Xh(e){return e.replace(/left|right|bottom|top/g,t=>rF[t])}function fF(e){return{top:0,right:0,bottom:0,left:0,...e}}function TT(e){return typeof e!="number"?fF(e):{top:e,right:e,bottom:e,left:e}}function Zh(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function Yk(e,t,n){let{reference:r,floating:s}=e;const a=$s(t),o=o0(t),l=a0(o),c=ba(t),u=a==="y",d=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,h=r[l]/2-s[l]/2;let m;switch(c){case"top":m={x:d,y:r.y-s.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-s.width,y:f};break;default:m={x:r.x,y:r.y}}switch(Ec(t)){case"start":m[o]-=h*(n&&u?-1:1);break;case"end":m[o]+=h*(n&&u?-1:1);break}return m}const hF=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:a=[],platform:o}=n,l=a.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t));let u=await o.getElementRects({reference:e,floating:t,strategy:s}),{x:d,y:f}=Yk(u,r,c),h=r,m={},v=0;for(let w=0;w({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:a,platform:o,elements:l,middlewareData:c}=t,{element:u,padding:d=0}=wa(e,t)||{};if(u==null)return{};const f=TT(d),h={x:n,y:r},m=o0(s),v=a0(m),w=await o.getDimensions(u),y=m==="y",x=y?"top":"left",g=y?"bottom":"right",b=y?"clientHeight":"clientWidth",_=a.reference[v]+a.reference[m]-h[m]-a.floating[v],j=h[m]-a.reference[m],k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let S=k?k[b]:0;(!S||!await(o.isElement==null?void 0:o.isElement(k)))&&(S=l.floating[b]||a.floating[v]);const E=_/2-j/2,N=S/2-w[v]/2-1,O=wo(f[x],N),z=wo(f[g],N),T=O,I=S-w[v]-z,P=S/2-w[v]/2+E,H=Rv(T,P,I),V=!c.arrow&&Ec(s)!=null&&P!==H&&a.reference[v]/2-(PP<=0)){var z,T;const P=(((z=a.flip)==null?void 0:z.index)||0)+1,H=S[P];if(H&&(!(f==="alignment"?g!==$s(H):!1)||O.every(C=>C.overflows[0]>0&&$s(C.placement)===g)))return{data:{index:P,overflows:O},reset:{placement:H}};let V=(T=O.filter(M=>M.overflows[0]<=0).sort((M,C)=>M.overflows[1]-C.overflows[1])[0])==null?void 0:T.placement;if(!V)switch(m){case"bestFit":{var I;const M=(I=O.filter(C=>{if(k){const F=$s(C.placement);return F===g||F==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(F=>F>0).reduce((F,W)=>F+W,0)]).sort((C,F)=>C[1]-F[1])[0])==null?void 0:I[0];M&&(V=M);break}case"initialPlacement":V=l;break}if(s!==V)return{reset:{placement:V}}}return{}}}};function Qk(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Xk(e){return nF.some(t=>e[t]>=0)}const gF=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...s}=wa(e,t);switch(r){case"referenceHidden":{const a=await ed(t,{...s,elementContext:"reference"}),o=Qk(a,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:Xk(o)}}}case"escaped":{const a=await ed(t,{...s,altBoundary:!0}),o=Qk(a,n.floating);return{data:{escapedOffsets:o,escaped:Xk(o)}}}default:return{}}}}},PT=new Set(["left","top"]);async function yF(e,t){const{placement:n,platform:r,elements:s}=e,a=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=ba(n),l=Ec(n),c=$s(n)==="y",u=PT.has(o)?-1:1,d=a&&c?-1:1,f=wa(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof v=="number"&&(m=l==="end"?v*-1:v),c?{x:m*d,y:h*u}:{x:h*u,y:m*d}}const vF=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:a,placement:o,middlewareData:l}=t,c=await yF(t,e);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:a+c.y,data:{...c,placement:o}}}}},xF=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s}=t,{mainAxis:a=!0,crossAxis:o=!1,limiter:l={fn:y=>{let{x,y:g}=y;return{x,y:g}}},...c}=wa(e,t),u={x:n,y:r},d=await ed(t,c),f=$s(ba(s)),h=s0(f);let m=u[h],v=u[f];if(a){const y=h==="y"?"top":"left",x=h==="y"?"bottom":"right",g=m+d[y],b=m-d[x];m=Rv(g,m,b)}if(o){const y=f==="y"?"top":"left",x=f==="y"?"bottom":"right",g=v+d[y],b=v-d[x];v=Rv(g,v,b)}const w=l.fn({...t,[h]:m,[f]:v});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[h]:a,[f]:o}}}}}},wF=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:a,middlewareData:o}=t,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=wa(e,t),d={x:n,y:r},f=$s(s),h=s0(f);let m=d[h],v=d[f];const w=wa(l,t),y=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(c){const b=h==="y"?"height":"width",_=a.reference[h]-a.floating[b]+y.mainAxis,j=a.reference[h]+a.reference[b]-y.mainAxis;m<_?m=_:m>j&&(m=j)}if(u){var x,g;const b=h==="y"?"width":"height",_=PT.has(ba(s)),j=a.reference[f]-a.floating[b]+(_&&((x=o.offset)==null?void 0:x[f])||0)+(_?0:y.crossAxis),k=a.reference[f]+a.reference[b]+(_?0:((g=o.offset)==null?void 0:g[f])||0)-(_?y.crossAxis:0);vk&&(v=k)}return{[h]:m,[f]:v}}}},bF=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:a,platform:o,elements:l}=t,{apply:c=()=>{},...u}=wa(e,t),d=await ed(t,u),f=ba(s),h=Ec(s),m=$s(s)==="y",{width:v,height:w}=a.floating;let y,x;f==="top"||f==="bottom"?(y=f,x=h===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(x=f,y=h==="end"?"top":"bottom");const g=w-d.top-d.bottom,b=v-d.left-d.right,_=wo(w-d[y],g),j=wo(v-d[x],b),k=!t.middlewareData.shift;let S=_,E=j;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(E=b),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(S=g),k&&!h){const O=_r(d.left,0),z=_r(d.right,0),T=_r(d.top,0),I=_r(d.bottom,0);m?E=v-2*(O!==0||z!==0?O+z:_r(d.left,d.right)):S=w-2*(T!==0||I!==0?T+I:_r(d.top,d.bottom))}await c({...t,availableWidth:E,availableHeight:S});const N=await o.getDimensions(l.floating);return v!==N.width||w!==N.height?{reset:{rects:!0}}:{}}}};function Qm(){return typeof window<"u"}function Nc(e){return AT(e)?(e.nodeName||"").toLowerCase():"#document"}function Cr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Gs(e){var t;return(t=(AT(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function AT(e){return Qm()?e instanceof Node||e instanceof Cr(e).Node:!1}function xs(e){return Qm()?e instanceof Element||e instanceof Cr(e).Element:!1}function Ks(e){return Qm()?e instanceof HTMLElement||e instanceof Cr(e).HTMLElement:!1}function Zk(e){return!Qm()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Cr(e).ShadowRoot}const _F=new Set(["inline","contents"]);function Td(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=ws(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!_F.has(s)}const kF=new Set(["table","td","th"]);function jF(e){return kF.has(Nc(e))}const SF=[":popover-open",":modal"];function Xm(e){return SF.some(t=>{try{return e.matches(t)}catch{return!1}})}const EF=["transform","translate","scale","rotate","perspective"],NF=["transform","translate","scale","rotate","perspective","filter"],CF=["paint","layout","strict","content"];function i0(e){const t=l0(),n=xs(e)?ws(e):e;return EF.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||NF.some(r=>(n.willChange||"").includes(r))||CF.some(r=>(n.contain||"").includes(r))}function TF(e){let t=bo(e);for(;Ks(t)&&!tc(t);){if(i0(t))return t;if(Xm(t))return null;t=bo(t)}return null}function l0(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const PF=new Set(["html","body","#document"]);function tc(e){return PF.has(Nc(e))}function ws(e){return Cr(e).getComputedStyle(e)}function Zm(e){return xs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function bo(e){if(Nc(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Zk(e)&&e.host||Gs(e);return Zk(t)?t.host:t}function RT(e){const t=bo(e);return tc(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ks(t)&&Td(t)?t:RT(t)}function td(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=RT(e),a=s===((r=e.ownerDocument)==null?void 0:r.body),o=Cr(s);if(a){const l=Mv(o);return t.concat(o,o.visualViewport||[],Td(s)?s:[],l&&n?td(l):[])}return t.concat(s,td(s,[],n))}function Mv(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function OT(e){const t=ws(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=Ks(e),a=s?e.offsetWidth:n,o=s?e.offsetHeight:r,l=Qh(n)!==a||Qh(r)!==o;return l&&(n=a,r=o),{width:n,height:r,$:l}}function c0(e){return xs(e)?e:e.contextElement}function Tl(e){const t=c0(e);if(!Ks(t))return Ws(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:a}=OT(t);let o=(a?Qh(n.width):n.width)/r,l=(a?Qh(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const AF=Ws(0);function MT(e){const t=Cr(e);return!l0()||!t.visualViewport?AF:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function RF(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Cr(e)?!1:t}function vi(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),a=c0(e);let o=Ws(1);t&&(r?xs(r)&&(o=Tl(r)):o=Tl(e));const l=RF(a,n,r)?MT(a):Ws(0);let c=(s.left+l.x)/o.x,u=(s.top+l.y)/o.y,d=s.width/o.x,f=s.height/o.y;if(a){const h=Cr(a),m=r&&xs(r)?Cr(r):r;let v=h,w=Mv(v);for(;w&&r&&m!==v;){const y=Tl(w),x=w.getBoundingClientRect(),g=ws(w),b=x.left+(w.clientLeft+parseFloat(g.paddingLeft))*y.x,_=x.top+(w.clientTop+parseFloat(g.paddingTop))*y.y;c*=y.x,u*=y.y,d*=y.x,f*=y.y,c+=b,u+=_,v=Cr(w),w=Mv(v)}}return Zh({width:d,height:f,x:c,y:u})}function u0(e,t){const n=Zm(e).scrollLeft;return t?t.left+n:vi(Gs(e)).left+n}function DT(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),s=r.left+t.scrollLeft-(n?0:u0(e,r)),a=r.top+t.scrollTop;return{x:s,y:a}}function OF(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const a=s==="fixed",o=Gs(r),l=t?Xm(t.floating):!1;if(r===o||l&&a)return n;let c={scrollLeft:0,scrollTop:0},u=Ws(1);const d=Ws(0),f=Ks(r);if((f||!f&&!a)&&((Nc(r)!=="body"||Td(o))&&(c=Zm(r)),Ks(r))){const m=vi(r);u=Tl(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=o&&!f&&!a?DT(o,c,!0):Ws(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function MF(e){return Array.from(e.getClientRects())}function DF(e){const t=Gs(e),n=Zm(e),r=e.ownerDocument.body,s=_r(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=_r(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+u0(e);const l=-n.scrollTop;return ws(r).direction==="rtl"&&(o+=_r(t.clientWidth,r.clientWidth)-s),{width:s,height:a,x:o,y:l}}function IF(e,t){const n=Cr(e),r=Gs(e),s=n.visualViewport;let a=r.clientWidth,o=r.clientHeight,l=0,c=0;if(s){a=s.width,o=s.height;const u=l0();(!u||u&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}return{width:a,height:o,x:l,y:c}}const LF=new Set(["absolute","fixed"]);function $F(e,t){const n=vi(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,a=Ks(e)?Tl(e):Ws(1),o=e.clientWidth*a.x,l=e.clientHeight*a.y,c=s*a.x,u=r*a.y;return{width:o,height:l,x:c,y:u}}function Jk(e,t,n){let r;if(t==="viewport")r=IF(e,n);else if(t==="document")r=DF(Gs(e));else if(xs(t))r=$F(t,n);else{const s=MT(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Zh(r)}function IT(e,t){const n=bo(e);return n===t||!xs(n)||tc(n)?!1:ws(n).position==="fixed"||IT(n,t)}function FF(e,t){const n=t.get(e);if(n)return n;let r=td(e,[],!1).filter(l=>xs(l)&&Nc(l)!=="body"),s=null;const a=ws(e).position==="fixed";let o=a?bo(e):e;for(;xs(o)&&!tc(o);){const l=ws(o),c=i0(o);!c&&l.position==="fixed"&&(s=null),(a?!c&&!s:!c&&l.position==="static"&&!!s&&LF.has(s.position)||Td(o)&&!c&&IT(e,o))?r=r.filter(d=>d!==o):s=l,o=bo(o)}return t.set(e,r),r}function zF(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const o=[...n==="clippingAncestors"?Xm(t)?[]:FF(t,this._c):[].concat(n),r],l=o[0],c=o.reduce((u,d)=>{const f=Jk(t,d,s);return u.top=_r(f.top,u.top),u.right=wo(f.right,u.right),u.bottom=wo(f.bottom,u.bottom),u.left=_r(f.left,u.left),u},Jk(t,l,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function BF(e){const{width:t,height:n}=OT(e);return{width:t,height:n}}function UF(e,t,n){const r=Ks(t),s=Gs(t),a=n==="fixed",o=vi(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const c=Ws(0);function u(){c.x=u0(s)}if(r||!r&&!a)if((Nc(t)!=="body"||Td(s))&&(l=Zm(t)),r){const m=vi(t,!0,a,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else s&&u();a&&!r&&s&&u();const d=s&&!r&&!a?DT(s,l):Ws(0),f=o.left+l.scrollLeft-c.x-d.x,h=o.top+l.scrollTop-c.y-d.y;return{x:f,y:h,width:o.width,height:o.height}}function Cg(e){return ws(e).position==="static"}function e1(e,t){if(!Ks(e)||ws(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Gs(e)===n&&(n=n.ownerDocument.body),n}function LT(e,t){const n=Cr(e);if(Xm(e))return n;if(!Ks(e)){let s=bo(e);for(;s&&!tc(s);){if(xs(s)&&!Cg(s))return s;s=bo(s)}return n}let r=e1(e,t);for(;r&&jF(r)&&Cg(r);)r=e1(r,t);return r&&tc(r)&&Cg(r)&&!i0(r)?n:r||TF(e)||n}const VF=async function(e){const t=this.getOffsetParent||LT,n=this.getDimensions,r=await n(e.floating);return{reference:UF(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function WF(e){return ws(e).direction==="rtl"}const HF={convertOffsetParentRelativeRectToViewportRelativeRect:OF,getDocumentElement:Gs,getClippingRect:zF,getOffsetParent:LT,getElementRects:VF,getClientRects:MF,getDimensions:BF,getScale:Tl,isElement:xs,isRTL:WF};function $T(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qF(e,t){let n=null,r;const s=Gs(e);function a(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function o(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),a();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:m}=u;if(l||t(),!h||!m)return;const v=_f(f),w=_f(s.clientWidth-(d+h)),y=_f(s.clientHeight-(f+m)),x=_f(d),b={rootMargin:-v+"px "+-w+"px "+-y+"px "+-x+"px",threshold:_r(0,wo(1,c))||1};let _=!0;function j(k){const S=k[0].intersectionRatio;if(S!==c){if(!_)return o();S?o(!1,S):r=setTimeout(()=>{o(!1,1e-7)},1e3)}S===1&&!$T(u,e.getBoundingClientRect())&&o(),_=!1}try{n=new IntersectionObserver(j,{...b,root:s.ownerDocument})}catch{n=new IntersectionObserver(j,b)}n.observe(e)}return o(!0),a}function KF(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=c0(e),d=s||a?[...u?td(u):[],...td(t)]:[];d.forEach(x=>{s&&x.addEventListener("scroll",n,{passive:!0}),a&&x.addEventListener("resize",n)});const f=u&&l?qF(u,n):null;let h=-1,m=null;o&&(m=new ResizeObserver(x=>{let[g]=x;g&&g.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var b;(b=m)==null||b.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let v,w=c?vi(e):null;c&&y();function y(){const x=vi(e);w&&!$T(w,x)&&n(),w=x,v=requestAnimationFrame(y)}return n(),()=>{var x;d.forEach(g=>{s&&g.removeEventListener("scroll",n),a&&g.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(v)}}const GF=vF,YF=xF,QF=pF,XF=bF,ZF=gF,t1=mF,JF=wF,ez=(e,t,n)=>{const r=new Map,s={platform:HF,...n},a={...s.platform,_c:r};return hF(e,t,{...s,platform:a})};var tz=typeof document<"u",nz=function(){},fh=tz?p.useLayoutEffect:nz;function Jh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Jh(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const a=s[r];if(!(a==="_owner"&&e.$$typeof)&&!Jh(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function FT(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function n1(e,t){const n=FT(e);return Math.round(t*n)/n}function Tg(e){const t=p.useRef(e);return fh(()=>{t.current=e}),t}function rz(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:a,floating:o}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[d,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);Jh(h,r)||m(r);const[v,w]=p.useState(null),[y,x]=p.useState(null),g=p.useCallback(C=>{C!==k.current&&(k.current=C,w(C))},[]),b=p.useCallback(C=>{C!==S.current&&(S.current=C,x(C))},[]),_=a||v,j=o||y,k=p.useRef(null),S=p.useRef(null),E=p.useRef(d),N=c!=null,O=Tg(c),z=Tg(s),T=Tg(u),I=p.useCallback(()=>{if(!k.current||!S.current)return;const C={placement:t,strategy:n,middleware:h};z.current&&(C.platform=z.current),ez(k.current,S.current,C).then(F=>{const W={...F,isPositioned:T.current!==!1};P.current&&!Jh(E.current,W)&&(E.current=W,Pi.flushSync(()=>{f(W)}))})},[h,t,n,z,T]);fh(()=>{u===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,f(C=>({...C,isPositioned:!1})))},[u]);const P=p.useRef(!1);fh(()=>(P.current=!0,()=>{P.current=!1}),[]),fh(()=>{if(_&&(k.current=_),j&&(S.current=j),_&&j){if(O.current)return O.current(_,j,I);I()}},[_,j,I,O,N]);const H=p.useMemo(()=>({reference:k,floating:S,setReference:g,setFloating:b}),[g,b]),V=p.useMemo(()=>({reference:_,floating:j}),[_,j]),M=p.useMemo(()=>{const C={position:n,left:0,top:0};if(!V.floating)return C;const F=n1(V.floating,d.x),W=n1(V.floating,d.y);return l?{...C,transform:"translate("+F+"px, "+W+"px)",...FT(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:W}},[n,l,V.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:I,refs:H,elements:V,floatingStyles:M}),[d,I,H,V,M])}const sz=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:s}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?t1({element:r.current,padding:s}).fn(n):{}:r?t1({element:r,padding:s}).fn(n):{}}}},az=(e,t)=>({...GF(e),options:[e,t]}),oz=(e,t)=>({...YF(e),options:[e,t]}),iz=(e,t)=>({...JF(e),options:[e,t]}),lz=(e,t)=>({...QF(e),options:[e,t]}),cz=(e,t)=>({...XF(e),options:[e,t]}),uz=(e,t)=>({...ZF(e),options:[e,t]}),dz=(e,t)=>({...sz(e),options:[e,t]});var fz="Arrow",zT=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:s=5,...a}=e;return i.jsx(Te.svg,{...a,ref:t,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:i.jsx("polygon",{points:"0,0 30,0 15,10"})})});zT.displayName=fz;var hz=zT;function Jm(e){const[t,n]=p.useState(void 0);return Zt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const a=s[0];let o,l;if("borderBoxSize"in a){const c=a.borderBoxSize,u=Array.isArray(c)?c[0]:c;o=u.inlineSize,l=u.blockSize}else o=e.offsetWidth,l=e.offsetHeight;n({width:o,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var d0="Popper",[BT,Cc]=Ln(d0),[mz,UT]=BT(d0),VT=e=>{const{__scopePopper:t,children:n}=e,[r,s]=p.useState(null);return i.jsx(mz,{scope:t,anchor:r,onAnchorChange:s,children:n})};VT.displayName=d0;var WT="PopperAnchor",HT=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,a=UT(WT,n),o=p.useRef(null),l=ze(t,o);return p.useEffect(()=>{a.onAnchorChange((r==null?void 0:r.current)||o.current)}),r?null:i.jsx(Te.div,{...s,ref:l})});HT.displayName=WT;var f0="PopperContent",[pz,gz]=BT(f0),qT=p.forwardRef((e,t)=>{var L,Q,fe,ee,je,Ee;const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:a="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:v,...w}=e,y=UT(f0,n),[x,g]=p.useState(null),b=ze(t,te=>g(te)),[_,j]=p.useState(null),k=Jm(_),S=(k==null?void 0:k.width)??0,E=(k==null?void 0:k.height)??0,N=r+(a!=="center"?"-"+a:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},z=Array.isArray(u)?u:[u],T=z.length>0,I={padding:O,boundary:z.filter(vz),altBoundary:T},{refs:P,floatingStyles:H,placement:V,isPositioned:M,middlewareData:C}=rz({strategy:"fixed",placement:N,whileElementsMounted:(...te)=>KF(...te,{animationFrame:m==="always"}),elements:{reference:y.anchor},middleware:[az({mainAxis:s+E,alignmentAxis:o}),c&&oz({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?iz():void 0,...I}),c&&lz({...I}),cz({...I,apply:({elements:te,rects:_e,availableWidth:Me,availableHeight:Ue})=>{const{width:ct,height:Rt}=_e.reference,Et=te.floating.style;Et.setProperty("--radix-popper-available-width",`${Me}px`),Et.setProperty("--radix-popper-available-height",`${Ue}px`),Et.setProperty("--radix-popper-anchor-width",`${ct}px`),Et.setProperty("--radix-popper-anchor-height",`${Rt}px`)}}),_&&dz({element:_,padding:l}),xz({arrowWidth:S,arrowHeight:E}),h&&uz({strategy:"referenceHidden",...I})]}),[F,W]=YT(V),ie=on(v);Zt(()=>{M&&(ie==null||ie())},[M,ie]);const oe=(L=C.arrow)==null?void 0:L.x,ce=(Q=C.arrow)==null?void 0:Q.y,re=((fe=C.arrow)==null?void 0:fe.centerOffset)!==0,[ue,ke]=p.useState();return Zt(()=>{x&&ke(window.getComputedStyle(x).zIndex)},[x]),i.jsx("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:M?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ue,"--radix-popper-transform-origin":[(ee=C.transformOrigin)==null?void 0:ee.x,(je=C.transformOrigin)==null?void 0:je.y].join(" "),...((Ee=C.hide)==null?void 0:Ee.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:i.jsx(pz,{scope:n,placedSide:F,onArrowChange:j,arrowX:oe,arrowY:ce,shouldHideArrow:re,children:i.jsx(Te.div,{"data-side":F,"data-align":W,...w,ref:b,style:{...w.style,animation:M?void 0:"none"}})})})});qT.displayName=f0;var KT="PopperArrow",yz={top:"bottom",right:"left",bottom:"top",left:"right"},GT=p.forwardRef(function(t,n){const{__scopePopper:r,...s}=t,a=gz(KT,r),o=yz[a.placedSide];return i.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:i.jsx(hz,{...s,ref:n,style:{...s.style,display:"block"}})})});GT.displayName=KT;function vz(e){return e!==null}var xz=e=>({name:"transformOrigin",options:e,fn(t){var y,x,g;const{placement:n,rects:r,middlewareData:s}=t,o=((y=s.arrow)==null?void 0:y.centerOffset)!==0,l=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[u,d]=YT(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=s.arrow)==null?void 0:x.x)??0)+l/2,m=(((g=s.arrow)==null?void 0:g.y)??0)+c/2;let v="",w="";return u==="bottom"?(v=o?f:`${h}px`,w=`${-c}px`):u==="top"?(v=o?f:`${h}px`,w=`${r.floating.height+c}px`):u==="right"?(v=`${-c}px`,w=o?f:`${m}px`):u==="left"&&(v=`${r.floating.width+c}px`,w=o?f:`${m}px`),{data:{x:v,y:w}}}});function YT(e){const[t,n="center"]=e.split("-");return[t,n]}var h0=VT,ep=HT,m0=qT,p0=GT,[tp]=Ln("Tooltip",[Cc]),np=Cc(),QT="TooltipProvider",wz=700,Dv="tooltip.open",[bz,g0]=tp(QT),XT=e=>{const{__scopeTooltip:t,delayDuration:n=wz,skipDelayDuration:r=300,disableHoverableContent:s=!1,children:a}=e,o=p.useRef(!0),l=p.useRef(!1),c=p.useRef(0);return p.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),i.jsx(bz,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:p.useCallback(u=>{l.current=u},[]),disableHoverableContent:s,children:a})};XT.displayName=QT;var nd="Tooltip",[_z,rp]=tp(nd),ZT=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:s,onOpenChange:a,disableHoverableContent:o,delayDuration:l}=e,c=g0(nd,e.__scopeTooltip),u=np(t),[d,f]=p.useState(null),h=Vs(),m=p.useRef(0),v=o??c.disableHoverableContent,w=l??c.delayDuration,y=p.useRef(!1),[x,g]=vs({prop:r,defaultProp:s??!1,onChange:S=>{S?(c.onOpen(),document.dispatchEvent(new CustomEvent(Dv))):c.onClose(),a==null||a(S)},caller:nd}),b=p.useMemo(()=>x?y.current?"delayed-open":"instant-open":"closed",[x]),_=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,y.current=!1,g(!0)},[g]),j=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,g(!1)},[g]),k=p.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{y.current=!0,g(!0),m.current=0},w)},[w,g]);return p.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),i.jsx(h0,{...u,children:i.jsx(_z,{scope:t,contentId:h,open:x,stateAttribute:b,trigger:d,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?k():_()},[c.isOpenDelayedRef,k,_]),onTriggerLeave:p.useCallback(()=>{v?j():(window.clearTimeout(m.current),m.current=0)},[j,v]),onOpen:_,onClose:j,disableHoverableContent:v,children:n})})};ZT.displayName=nd;var Iv="TooltipTrigger",JT=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,s=rp(Iv,n),a=g0(Iv,n),o=np(n),l=p.useRef(null),c=ze(t,l,s.onTriggerChange),u=p.useRef(!1),d=p.useRef(!1),f=p.useCallback(()=>u.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),i.jsx(ep,{asChild:!0,...o,children:i.jsx(Te.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...r,ref:c,onPointerMove:xe(e.onPointerMove,h=>{h.pointerType!=="touch"&&!d.current&&!a.isPointerInTransitRef.current&&(s.onTriggerEnter(),d.current=!0)}),onPointerLeave:xe(e.onPointerLeave,()=>{s.onTriggerLeave(),d.current=!1}),onPointerDown:xe(e.onPointerDown,()=>{s.open&&s.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:xe(e.onFocus,()=>{u.current||s.onOpen()}),onBlur:xe(e.onBlur,s.onClose),onClick:xe(e.onClick,s.onClose)})})});JT.displayName=Iv;var kz="TooltipPortal",[Jre,jz]=tp(kz,{forceMount:void 0}),nc="TooltipContent",e2=p.forwardRef((e,t)=>{const n=jz(nc,e.__scopeTooltip),{forceMount:r=n.forceMount,side:s="top",...a}=e,o=rp(nc,e.__scopeTooltip);return i.jsx(Jn,{present:r||o.open,children:o.disableHoverableContent?i.jsx(t2,{side:s,...a,ref:t}):i.jsx(Sz,{side:s,...a,ref:t})})}),Sz=p.forwardRef((e,t)=>{const n=rp(nc,e.__scopeTooltip),r=g0(nc,e.__scopeTooltip),s=p.useRef(null),a=ze(t,s),[o,l]=p.useState(null),{trigger:c,onClose:u}=n,d=s.current,{onPointerInTransitChange:f}=r,h=p.useCallback(()=>{l(null),f(!1)},[f]),m=p.useCallback((v,w)=>{const y=v.currentTarget,x={x:v.clientX,y:v.clientY},g=Pz(x,y.getBoundingClientRect()),b=Az(x,g),_=Rz(w.getBoundingClientRect()),j=Mz([...b,..._]);l(j),f(!0)},[f]);return p.useEffect(()=>()=>h(),[h]),p.useEffect(()=>{if(c&&d){const v=y=>m(y,d),w=y=>m(y,c);return c.addEventListener("pointerleave",v),d.addEventListener("pointerleave",w),()=>{c.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",w)}}},[c,d,m,h]),p.useEffect(()=>{if(o){const v=w=>{const y=w.target,x={x:w.clientX,y:w.clientY},g=(c==null?void 0:c.contains(y))||(d==null?void 0:d.contains(y)),b=!Oz(x,o);g?h():b&&(h(),u())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,d,o,u,h]),i.jsx(t2,{...e,ref:a})}),[Ez,Nz]=tp(nd,{isInside:!1}),Cz=DC("TooltipContent"),t2=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":s,onEscapeKeyDown:a,onPointerDownOutside:o,...l}=e,c=rp(nc,n),u=np(n),{onClose:d}=c;return p.useEffect(()=>(document.addEventListener(Dv,d),()=>document.removeEventListener(Dv,d)),[d]),p.useEffect(()=>{if(c.trigger){const f=h=>{const m=h.target;m!=null&&m.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),i.jsx(wc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:i.jsxs(m0,{"data-state":c.stateAttribute,...u,...l,ref:t,style:{...l.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:[i.jsx(Cz,{children:r}),i.jsx(Ez,{scope:n,isInside:!0,children:i.jsx(J3,{id:c.contentId,role:"tooltip",children:s||r})})]})})});e2.displayName=nc;var n2="TooltipArrow",Tz=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,s=np(n);return Nz(n2,n).isInside?null:i.jsx(p0,{...s,...r,ref:t})});Tz.displayName=n2;function Pz(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),s=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,s,a)){case a:return"left";case s:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Az(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Rz(e){const{top:t,right:n,bottom:r,left:s}=e;return[{x:s,y:t},{x:n,y:t},{x:n,y:r},{x:s,y:r}]}function Oz(e,t){const{x:n,y:r}=e;let s=!1;for(let a=0,o=t.length-1;ar!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(s=!s)}return s}function Mz(e){const t=e.slice();return t.sort((n,r)=>n.xr.x?1:n.yr.y?1:0),Dz(t)}function Dz(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r=2;){const a=t[t.length-1],o=t[t.length-2];if((a.x-o.x)*(s.y-o.y)>=(a.y-o.y)*(s.x-o.x))t.pop();else break}t.push(s)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const s=e[r];for(;n.length>=2;){const a=n[n.length-1],o=n[n.length-2];if((a.x-o.x)*(s.y-o.y)>=(a.y-o.y)*(s.x-o.x))n.pop();else break}n.push(s)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Iz=XT,Lz=ZT,$z=JT,r2=e2;const s2=Iz,Fz=Lz,zz=$z,a2=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(r2,{ref:r,sideOffset:t,className:Y("z-[130] 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",e),...n}));a2.displayName=r2.displayName;var Tc=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},xi=typeof window>"u"||"Deno"in globalThis;function Nn(){}function Bz(e,t){return typeof e=="function"?e(t):e}function Lv(e){return typeof e=="number"&&e>=0&&e!==1/0}function o2(e,t){return Math.max(e+(t||0)-Date.now(),0)}function ho(e,t){return typeof e=="function"?e(t):e}function Lr(e,t){return typeof e=="function"?e(t):e}function r1(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:a,queryKey:o,stale:l}=e;if(o){if(r){if(t.queryHash!==y0(o,t.options))return!1}else if(!rd(t.queryKey,o))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||s&&s!==t.state.fetchStatus||a&&!a(t))}function s1(e,t){const{exact:n,status:r,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(wi(t.options.mutationKey)!==wi(a))return!1}else if(!rd(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function y0(e,t){return((t==null?void 0:t.queryKeyHashFn)||wi)(e)}function wi(e){return JSON.stringify(e,(t,n)=>$v(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function rd(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>rd(e[n],t[n])):!1}function i2(e,t){if(e===t)return e;const n=a1(e)&&a1(t);if(n||$v(e)&&$v(t)){const r=n?e:Object.keys(e),s=r.length,a=n?t:Object.keys(t),o=a.length,l=n?[]:{},c=new Set(r);let u=0;for(let d=0;d{setTimeout(t,e)})}function Fv(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?i2(e,t):t}function Vz(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Wz(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var v0=Symbol();function l2(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===v0?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function c2(e,t){return typeof e=="function"?e(...t):!!e}var Jo,Ua,Il,tE,Hz=(tE=class extends Tc{constructor(){super();Re(this,Jo);Re(this,Ua);Re(this,Il);ye(this,Il,t=>{if(!xi&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){D(this,Ua)||this.setEventListener(D(this,Il))}onUnsubscribe(){var t;this.hasListeners()||((t=D(this,Ua))==null||t.call(this),ye(this,Ua,void 0))}setEventListener(t){var n;ye(this,Il,t),(n=D(this,Ua))==null||n.call(this),ye(this,Ua,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){D(this,Jo)!==t&&(ye(this,Jo,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof D(this,Jo)=="boolean"?D(this,Jo):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Jo=new WeakMap,Ua=new WeakMap,Il=new WeakMap,tE),x0=new Hz,Ll,Va,$l,nE,qz=(nE=class extends Tc{constructor(){super();Re(this,Ll,!0);Re(this,Va);Re(this,$l);ye(this,$l,t=>{if(!xi&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){D(this,Va)||this.setEventListener(D(this,$l))}onUnsubscribe(){var t;this.hasListeners()||((t=D(this,Va))==null||t.call(this),ye(this,Va,void 0))}setEventListener(t){var n;ye(this,$l,t),(n=D(this,Va))==null||n.call(this),ye(this,Va,t(this.setOnline.bind(this)))}setOnline(t){D(this,Ll)!==t&&(ye(this,Ll,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return D(this,Ll)}},Ll=new WeakMap,Va=new WeakMap,$l=new WeakMap,nE),tm=new qz;function zv(){let e,t;const n=new Promise((s,a)=>{e=s,t=a});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}function Kz(e){var n;let t;if((n=e.then(r=>(t=r,r),Nn))==null||n.catch(Nn),t!==void 0)return{data:t}}function Gz(e){return Math.min(1e3*2**e,3e4)}function u2(e){return(e??"online")==="online"?tm.isOnline():!0}var d2=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Pg(e){return e instanceof d2}function f2(e){let t=!1,n=0,r=!1,s;const a=zv(),o=w=>{var y;r||(h(new d2(w)),(y=e.abort)==null||y.call(e))},l=()=>{t=!0},c=()=>{t=!1},u=()=>x0.isFocused()&&(e.networkMode==="always"||tm.isOnline())&&e.canRun(),d=()=>u2(e.networkMode)&&e.canRun(),f=w=>{var y;r||(r=!0,(y=e.onSuccess)==null||y.call(e,w),s==null||s(),a.resolve(w))},h=w=>{var y;r||(r=!0,(y=e.onError)==null||y.call(e,w),s==null||s(),a.reject(w))},m=()=>new Promise(w=>{var y;s=x=>{(r||u())&&w(x)},(y=e.onPause)==null||y.call(e)}).then(()=>{var w;s=void 0,r||(w=e.onContinue)==null||w.call(e)}),v=()=>{if(r)return;let w;const y=n===0?e.initialPromise:void 0;try{w=y??e.fn()}catch(x){w=Promise.reject(x)}Promise.resolve(w).then(f).catch(x=>{var k;if(r)return;const g=e.retry??(xi?0:3),b=e.retryDelay??Gz,_=typeof b=="function"?b(n,x):b,j=g===!0||typeof g=="number"&&nu()?void 0:m()).then(()=>{t?h(x):v()})})};return{promise:a,cancel:o,continue:()=>(s==null||s(),a),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?v():m().then(v),a)}}var Yz=e=>setTimeout(e,0);function Qz(){let e=[],t=0,n=l=>{l()},r=l=>{l()},s=Yz;const a=l=>{t?e.push(l):s(()=>{n(l)})},o=()=>{const l=e;e=[],l.length&&s(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{s=l}}}var sn=Qz(),ei,rE,h2=(rE=class{constructor(){Re(this,ei)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Lv(this.gcTime)&&ye(this,ei,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(xi?1/0:5*60*1e3))}clearGcTimeout(){D(this,ei)&&(clearTimeout(D(this,ei)),ye(this,ei,void 0))}},ei=new WeakMap,rE),Fl,ti,Ir,ni,Mn,gd,ri,is,sa,sE,Xz=(sE=class extends h2{constructor(t){super();Re(this,is);Re(this,Fl);Re(this,ti);Re(this,Ir);Re(this,ni);Re(this,Mn);Re(this,gd);Re(this,ri);ye(this,ri,!1),ye(this,gd,t.defaultOptions),this.setOptions(t.options),this.observers=[],ye(this,ni,t.client),ye(this,Ir,D(this,ni).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ye(this,Fl,Zz(this.options)),this.state=t.state??D(this,Fl),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=D(this,Mn))==null?void 0:t.promise}setOptions(t){this.options={...D(this,gd),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&D(this,Ir).remove(this)}setData(t,n){const r=Fv(this.state.data,t,this.options);return qe(this,is,sa).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){qe(this,is,sa).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=D(this,Mn))==null?void 0:r.promise;return(s=D(this,Mn))==null||s.cancel(t),n?n.then(Nn).catch(Nn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(D(this,Fl))}isActive(){return this.observers.some(t=>Lr(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===v0||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>ho(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!o2(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=D(this,Mn))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=D(this,Mn))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),D(this,Ir).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(D(this,Mn)&&(D(this,ri)?D(this,Mn).cancel({revert:!0}):D(this,Mn).cancelRetry()),this.scheduleGc()),D(this,Ir).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||qe(this,is,sa).call(this,{type:"invalidate"})}fetch(t,n){var u,d,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(D(this,Mn))return D(this,Mn).continueRetry(),D(this,Mn).promise}if(t&&this.setOptions(t),!this.options.queryFn){const h=this.observers.find(m=>m.options.queryFn);h&&this.setOptions(h.options)}const r=new AbortController,s=h=>{Object.defineProperty(h,"signal",{enumerable:!0,get:()=>(ye(this,ri,!0),r.signal)})},a=()=>{const h=l2(this.options,n),v=(()=>{const w={client:D(this,ni),queryKey:this.queryKey,meta:this.meta};return s(w),w})();return ye(this,ri,!1),this.options.persister?this.options.persister(h,v,this):h(v)},l=(()=>{const h={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:D(this,ni),state:this.state,fetchFn:a};return s(h),h})();(u=this.options.behavior)==null||u.onFetch(l,this),ye(this,ti,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&qe(this,is,sa).call(this,{type:"fetch",meta:(f=l.fetchOptions)==null?void 0:f.meta});const c=h=>{var m,v,w,y;Pg(h)&&h.silent||qe(this,is,sa).call(this,{type:"error",error:h}),Pg(h)||((v=(m=D(this,Ir).config).onError)==null||v.call(m,h,this),(y=(w=D(this,Ir).config).onSettled)==null||y.call(w,this.state.data,h,this)),this.scheduleGc()};return ye(this,Mn,f2({initialPromise:n==null?void 0:n.initialPromise,fn:l.fetchFn,abort:r.abort.bind(r),onSuccess:h=>{var m,v,w,y;if(h===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(h)}catch(x){c(x);return}(v=(m=D(this,Ir).config).onSuccess)==null||v.call(m,h,this),(y=(w=D(this,Ir).config).onSettled)==null||y.call(w,h,this.state.error,this),this.scheduleGc()},onError:c,onFail:(h,m)=>{qe(this,is,sa).call(this,{type:"failed",failureCount:h,error:m})},onPause:()=>{qe(this,is,sa).call(this,{type:"pause"})},onContinue:()=>{qe(this,is,sa).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0})),D(this,Mn).start()}},Fl=new WeakMap,ti=new WeakMap,Ir=new WeakMap,ni=new WeakMap,Mn=new WeakMap,gd=new WeakMap,ri=new WeakMap,is=new WeakSet,sa=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...m2(r.data,this.options),fetchMeta:t.meta??null};case"success":return ye(this,ti,void 0),{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const s=t.error;return Pg(s)&&s.revert&&D(this,ti)?{...D(this,ti),fetchStatus:"idle"}:{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),sn.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),D(this,Ir).notify({query:this,type:"updated",action:t})})},sE);function m2(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:u2(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Zz(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Ts,aE,Jz=(aE=class extends Tc{constructor(t={}){super();Re(this,Ts);this.config=t,ye(this,Ts,new Map)}build(t,n,r){const s=n.queryKey,a=n.queryHash??y0(s,n);let o=this.get(a);return o||(o=new Xz({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){D(this,Ts).has(t.queryHash)||(D(this,Ts).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=D(this,Ts).get(t.queryHash);n&&(t.destroy(),n===t&&D(this,Ts).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){sn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return D(this,Ts).get(t)}getAll(){return[...D(this,Ts).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>r1(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>r1(t,r)):n}notify(t){sn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){sn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){sn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ts=new WeakMap,aE),Ps,Bn,si,As,Oa,oE,e6=(oE=class extends h2{constructor(t){super();Re(this,As);Re(this,Ps);Re(this,Bn);Re(this,si);this.mutationId=t.mutationId,ye(this,Bn,t.mutationCache),ye(this,Ps,[]),this.state=t.state||p2(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){D(this,Ps).includes(t)||(D(this,Ps).push(t),this.clearGcTimeout(),D(this,Bn).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ye(this,Ps,D(this,Ps).filter(n=>n!==t)),this.scheduleGc(),D(this,Bn).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){D(this,Ps).length||(this.state.status==="pending"?this.scheduleGc():D(this,Bn).remove(this))}continue(){var t;return((t=D(this,si))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var a,o,l,c,u,d,f,h,m,v,w,y,x,g,b,_,j,k,S,E;const n=()=>{qe(this,As,Oa).call(this,{type:"continue"})};ye(this,si,f2({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(N,O)=>{qe(this,As,Oa).call(this,{type:"failed",failureCount:N,error:O})},onPause:()=>{qe(this,As,Oa).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>D(this,Bn).canRun(this)}));const r=this.state.status==="pending",s=!D(this,si).canStart();try{if(r)n();else{qe(this,As,Oa).call(this,{type:"pending",variables:t,isPaused:s}),await((o=(a=D(this,Bn).config).onMutate)==null?void 0:o.call(a,t,this));const O=await((c=(l=this.options).onMutate)==null?void 0:c.call(l,t));O!==this.state.context&&qe(this,As,Oa).call(this,{type:"pending",context:O,variables:t,isPaused:s})}const N=await D(this,si).start();return await((d=(u=D(this,Bn).config).onSuccess)==null?void 0:d.call(u,N,t,this.state.context,this)),await((h=(f=this.options).onSuccess)==null?void 0:h.call(f,N,t,this.state.context)),await((v=(m=D(this,Bn).config).onSettled)==null?void 0:v.call(m,N,null,this.state.variables,this.state.context,this)),await((y=(w=this.options).onSettled)==null?void 0:y.call(w,N,null,t,this.state.context)),qe(this,As,Oa).call(this,{type:"success",data:N}),N}catch(N){try{throw await((g=(x=D(this,Bn).config).onError)==null?void 0:g.call(x,N,t,this.state.context,this)),await((_=(b=this.options).onError)==null?void 0:_.call(b,N,t,this.state.context)),await((k=(j=D(this,Bn).config).onSettled)==null?void 0:k.call(j,void 0,N,this.state.variables,this.state.context,this)),await((E=(S=this.options).onSettled)==null?void 0:E.call(S,void 0,N,t,this.state.context)),N}finally{qe(this,As,Oa).call(this,{type:"error",error:N})}}finally{D(this,Bn).runNext(this)}}},Ps=new WeakMap,Bn=new WeakMap,si=new WeakMap,As=new WeakSet,Oa=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),sn.batch(()=>{D(this,Ps).forEach(r=>{r.onMutationUpdate(t)}),D(this,Bn).notify({mutation:this,type:"updated",action:t})})},oE);function p2(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ca,ls,yd,iE,t6=(iE=class extends Tc{constructor(t={}){super();Re(this,ca);Re(this,ls);Re(this,yd);this.config=t,ye(this,ca,new Set),ye(this,ls,new Map),ye(this,yd,0)}build(t,n,r){const s=new e6({mutationCache:this,mutationId:++Jd(this,yd)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){D(this,ca).add(t);const n=kf(t);if(typeof n=="string"){const r=D(this,ls).get(n);r?r.push(t):D(this,ls).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(D(this,ca).delete(t)){const n=kf(t);if(typeof n=="string"){const r=D(this,ls).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&D(this,ls).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=kf(t);if(typeof n=="string"){const r=D(this,ls).get(n),s=r==null?void 0:r.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=kf(t);if(typeof n=="string"){const s=(r=D(this,ls).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){sn.batch(()=>{D(this,ca).forEach(t=>{this.notify({type:"removed",mutation:t})}),D(this,ca).clear(),D(this,ls).clear()})}getAll(){return Array.from(D(this,ca))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>s1(n,r))}findAll(t={}){return this.getAll().filter(n=>s1(t,n))}notify(t){sn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return sn.batch(()=>Promise.all(t.map(n=>n.continue().catch(Nn))))}},ca=new WeakMap,ls=new WeakMap,yd=new WeakMap,iE);function kf(e){var t;return(t=e.options.scope)==null?void 0:t.id}function i1(e){return{onFetch:(t,n)=>{var d,f,h,m,v;const r=t.options,s=(h=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:h.direction,a=((m=t.state.data)==null?void 0:m.pages)||[],o=((v=t.state.data)==null?void 0:v.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let w=!1;const y=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(t.signal.aborted?w=!0:t.signal.addEventListener("abort",()=>{w=!0}),t.signal)})},x=l2(t.options,t.fetchOptions),g=async(b,_,j)=>{if(w)return Promise.reject();if(_==null&&b.pages.length)return Promise.resolve(b);const S=(()=>{const z={client:t.client,queryKey:t.queryKey,pageParam:_,direction:j?"backward":"forward",meta:t.options.meta};return y(z),z})(),E=await x(S),{maxPages:N}=t.options,O=j?Wz:Vz;return{pages:O(b.pages,E,N),pageParams:O(b.pageParams,_,N)}};if(s&&a.length){const b=s==="backward",_=b?g2:Bv,j={pages:a,pageParams:o},k=_(r,j);l=await g(j,k,b)}else{const b=e??a.length;do{const _=c===0?o[0]??r.initialPageParam:Bv(r,l);if(c>0&&_==null)break;l=await g(l,_),c++}while(c{var w,y;return(y=(w=t.options).persister)==null?void 0:y.call(w,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Bv(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function g2(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}function ese(e,t){return t?Bv(e,t)!=null:!1}function tse(e,t){return!t||!e.getPreviousPageParam?!1:g2(e,t)!=null}var Ut,Wa,Ha,zl,Bl,qa,Ul,Vl,lE,n6=(lE=class{constructor(e={}){Re(this,Ut);Re(this,Wa);Re(this,Ha);Re(this,zl);Re(this,Bl);Re(this,qa);Re(this,Ul);Re(this,Vl);ye(this,Ut,e.queryCache||new Jz),ye(this,Wa,e.mutationCache||new t6),ye(this,Ha,e.defaultOptions||{}),ye(this,zl,new Map),ye(this,Bl,new Map),ye(this,qa,0)}mount(){Jd(this,qa)._++,D(this,qa)===1&&(ye(this,Ul,x0.subscribe(async e=>{e&&(await this.resumePausedMutations(),D(this,Ut).onFocus())})),ye(this,Vl,tm.subscribe(async e=>{e&&(await this.resumePausedMutations(),D(this,Ut).onOnline())})))}unmount(){var e,t;Jd(this,qa)._--,D(this,qa)===0&&((e=D(this,Ul))==null||e.call(this),ye(this,Ul,void 0),(t=D(this,Vl))==null||t.call(this),ye(this,Vl,void 0))}isFetching(e){return D(this,Ut).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return D(this,Wa).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=D(this,Ut).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=D(this,Ut).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(ho(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return D(this,Ut).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=D(this,Ut).get(r.queryHash),a=s==null?void 0:s.state.data,o=Bz(t,a);if(o!==void 0)return D(this,Ut).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return sn.batch(()=>D(this,Ut).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=D(this,Ut).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=D(this,Ut);sn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=D(this,Ut);return sn.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=sn.batch(()=>D(this,Ut).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Nn).catch(Nn)}invalidateQueries(e,t={}){return sn.batch(()=>(D(this,Ut).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=sn.batch(()=>D(this,Ut).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,n);return n.throwOnError||(a=a.catch(Nn)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Nn)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=D(this,Ut).build(this,t);return n.isStaleByTime(ho(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Nn).catch(Nn)}fetchInfiniteQuery(e){return e.behavior=i1(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Nn).catch(Nn)}ensureInfiniteQueryData(e){return e.behavior=i1(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return tm.isOnline()?D(this,Wa).resumePausedMutations():Promise.resolve()}getQueryCache(){return D(this,Ut)}getMutationCache(){return D(this,Wa)}getDefaultOptions(){return D(this,Ha)}setDefaultOptions(e){ye(this,Ha,e)}setQueryDefaults(e,t){D(this,zl).set(wi(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...D(this,zl).values()],n={};return t.forEach(r=>{rd(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){D(this,Bl).set(wi(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...D(this,Bl).values()],n={};return t.forEach(r=>{rd(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...D(this,Ha).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=y0(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===v0&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...D(this,Ha).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){D(this,Ut).clear(),D(this,Wa).clear()}},Ut=new WeakMap,Wa=new WeakMap,Ha=new WeakMap,zl=new WeakMap,Bl=new WeakMap,qa=new WeakMap,Ul=new WeakMap,Vl=new WeakMap,lE),ar,Ze,vd,Un,ai,Wl,Ka,Ga,xd,Hl,ql,oi,ii,Ya,Kl,pt,cu,Uv,Vv,Wv,Hv,qv,Kv,Gv,y2,cE,r6=(cE=class extends Tc{constructor(t,n){super();Re(this,pt);Re(this,ar);Re(this,Ze);Re(this,vd);Re(this,Un);Re(this,ai);Re(this,Wl);Re(this,Ka);Re(this,Ga);Re(this,xd);Re(this,Hl);Re(this,ql);Re(this,oi);Re(this,ii);Re(this,Ya);Re(this,Kl,new Set);this.options=n,ye(this,ar,t),ye(this,Ga,null),ye(this,Ka,zv()),this.options.experimental_prefetchInRender||D(this,Ka).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(D(this,Ze).addObserver(this),l1(D(this,Ze),this.options)?qe(this,pt,cu).call(this):this.updateResult(),qe(this,pt,Hv).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Yv(D(this,Ze),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Yv(D(this,Ze),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,qe(this,pt,qv).call(this),qe(this,pt,Kv).call(this),D(this,Ze).removeObserver(this)}setOptions(t){const n=this.options,r=D(this,Ze);if(this.options=D(this,ar).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Lr(this.options.enabled,D(this,Ze))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");qe(this,pt,Gv).call(this),D(this,Ze).setOptions(this.options),n._defaulted&&!em(this.options,n)&&D(this,ar).getQueryCache().notify({type:"observerOptionsUpdated",query:D(this,Ze),observer:this});const s=this.hasListeners();s&&c1(D(this,Ze),r,this.options,n)&&qe(this,pt,cu).call(this),this.updateResult(),s&&(D(this,Ze)!==r||Lr(this.options.enabled,D(this,Ze))!==Lr(n.enabled,D(this,Ze))||ho(this.options.staleTime,D(this,Ze))!==ho(n.staleTime,D(this,Ze)))&&qe(this,pt,Uv).call(this);const a=qe(this,pt,Vv).call(this);s&&(D(this,Ze)!==r||Lr(this.options.enabled,D(this,Ze))!==Lr(n.enabled,D(this,Ze))||a!==D(this,Ya))&&qe(this,pt,Wv).call(this,a)}getOptimisticResult(t){const n=D(this,ar).getQueryCache().build(D(this,ar),t),r=this.createResult(n,t);return a6(this,r)&&(ye(this,Un,r),ye(this,Wl,this.options),ye(this,ai,D(this,Ze).state)),r}getCurrentResult(){return D(this,Un)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),Reflect.get(r,s))})}trackProp(t){D(this,Kl).add(t)}getCurrentQuery(){return D(this,Ze)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=D(this,ar).defaultQueryOptions(t),r=D(this,ar).getQueryCache().build(D(this,ar),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return qe(this,pt,cu).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),D(this,Un)))}createResult(t,n){var N;const r=D(this,Ze),s=this.options,a=D(this,Un),o=D(this,ai),l=D(this,Wl),u=t!==r?t.state:D(this,vd),{state:d}=t;let f={...d},h=!1,m;if(n._optimisticResults){const O=this.hasListeners(),z=!O&&l1(t,n),T=O&&c1(t,r,n,s);(z||T)&&(f={...f,...m2(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:v,errorUpdatedAt:w,status:y}=f;m=f.data;let x=!1;if(n.placeholderData!==void 0&&m===void 0&&y==="pending"){let O;a!=null&&a.isPlaceholderData&&n.placeholderData===(l==null?void 0:l.placeholderData)?(O=a.data,x=!0):O=typeof n.placeholderData=="function"?n.placeholderData((N=D(this,ql))==null?void 0:N.state.data,D(this,ql)):n.placeholderData,O!==void 0&&(y="success",m=Fv(a==null?void 0:a.data,O,n),h=!0)}if(n.select&&m!==void 0&&!x)if(a&&m===(o==null?void 0:o.data)&&n.select===D(this,xd))m=D(this,Hl);else try{ye(this,xd,n.select),m=n.select(m),m=Fv(a==null?void 0:a.data,m,n),ye(this,Hl,m),ye(this,Ga,null)}catch(O){ye(this,Ga,O)}D(this,Ga)&&(v=D(this,Ga),m=D(this,Hl),w=Date.now(),y="error");const g=f.fetchStatus==="fetching",b=y==="pending",_=y==="error",j=b&&g,k=m!==void 0,E={status:y,fetchStatus:f.fetchStatus,isPending:b,isSuccess:y==="success",isError:_,isInitialLoading:j,isLoading:j,data:m,dataUpdatedAt:f.dataUpdatedAt,error:v,errorUpdatedAt:w,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:g,isRefetching:g&&!b,isLoadingError:_&&!k,isPaused:f.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:_&&k,isStale:w0(t,n),refetch:this.refetch,promise:D(this,Ka),isEnabled:Lr(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=I=>{E.status==="error"?I.reject(E.error):E.data!==void 0&&I.resolve(E.data)},z=()=>{const I=ye(this,Ka,E.promise=zv());O(I)},T=D(this,Ka);switch(T.status){case"pending":t.queryHash===r.queryHash&&O(T);break;case"fulfilled":(E.status==="error"||E.data!==T.value)&&z();break;case"rejected":(E.status!=="error"||E.error!==T.reason)&&z();break}}return E}updateResult(){const t=D(this,Un),n=this.createResult(D(this,Ze),this.options);if(ye(this,ai,D(this,Ze).state),ye(this,Wl,this.options),D(this,ai).data!==void 0&&ye(this,ql,D(this,Ze)),em(n,t))return;ye(this,Un,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!D(this,Kl).size)return!0;const o=new Set(a??D(this,Kl));return this.options.throwOnError&&o.add("error"),Object.keys(D(this,Un)).some(l=>{const c=l;return D(this,Un)[c]!==t[c]&&o.has(c)})};qe(this,pt,y2).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&qe(this,pt,Hv).call(this)}},ar=new WeakMap,Ze=new WeakMap,vd=new WeakMap,Un=new WeakMap,ai=new WeakMap,Wl=new WeakMap,Ka=new WeakMap,Ga=new WeakMap,xd=new WeakMap,Hl=new WeakMap,ql=new WeakMap,oi=new WeakMap,ii=new WeakMap,Ya=new WeakMap,Kl=new WeakMap,pt=new WeakSet,cu=function(t){qe(this,pt,Gv).call(this);let n=D(this,Ze).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Nn)),n},Uv=function(){qe(this,pt,qv).call(this);const t=ho(this.options.staleTime,D(this,Ze));if(xi||D(this,Un).isStale||!Lv(t))return;const r=o2(D(this,Un).dataUpdatedAt,t)+1;ye(this,oi,setTimeout(()=>{D(this,Un).isStale||this.updateResult()},r))},Vv=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(D(this,Ze)):this.options.refetchInterval)??!1},Wv=function(t){qe(this,pt,Kv).call(this),ye(this,Ya,t),!(xi||Lr(this.options.enabled,D(this,Ze))===!1||!Lv(D(this,Ya))||D(this,Ya)===0)&&ye(this,ii,setInterval(()=>{(this.options.refetchIntervalInBackground||x0.isFocused())&&qe(this,pt,cu).call(this)},D(this,Ya)))},Hv=function(){qe(this,pt,Uv).call(this),qe(this,pt,Wv).call(this,qe(this,pt,Vv).call(this))},qv=function(){D(this,oi)&&(clearTimeout(D(this,oi)),ye(this,oi,void 0))},Kv=function(){D(this,ii)&&(clearInterval(D(this,ii)),ye(this,ii,void 0))},Gv=function(){const t=D(this,ar).getQueryCache().build(D(this,ar),this.options);if(t===D(this,Ze))return;const n=D(this,Ze);ye(this,Ze,t),ye(this,vd,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},y2=function(t){sn.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(D(this,Un))}),D(this,ar).getQueryCache().notify({query:D(this,Ze),type:"observerResultsUpdated"})})},cE);function s6(e,t){return Lr(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function l1(e,t){return s6(e,t)||e.state.data!==void 0&&Yv(e,t,t.refetchOnMount)}function Yv(e,t,n){if(Lr(t.enabled,e)!==!1&&ho(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&w0(e,t)}return!1}function c1(e,t,n,r){return(e!==t||Lr(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&w0(e,n)}function w0(e,t){return Lr(t.enabled,e)!==!1&&e.isStaleByTime(ho(t.staleTime,e))}function a6(e,t){return!em(e.getCurrentResult(),t)}var Qa,Xa,or,ua,pa,hh,Qv,uE,o6=(uE=class extends Tc{constructor(n,r){super();Re(this,pa);Re(this,Qa);Re(this,Xa);Re(this,or);Re(this,ua);ye(this,Qa,n),this.setOptions(r),this.bindMethods(),qe(this,pa,hh).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=D(this,Qa).defaultMutationOptions(n),em(this.options,r)||D(this,Qa).getMutationCache().notify({type:"observerOptionsUpdated",mutation:D(this,or),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&wi(r.mutationKey)!==wi(this.options.mutationKey)?this.reset():((s=D(this,or))==null?void 0:s.state.status)==="pending"&&D(this,or).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=D(this,or))==null||n.removeObserver(this)}onMutationUpdate(n){qe(this,pa,hh).call(this),qe(this,pa,Qv).call(this,n)}getCurrentResult(){return D(this,Xa)}reset(){var n;(n=D(this,or))==null||n.removeObserver(this),ye(this,or,void 0),qe(this,pa,hh).call(this),qe(this,pa,Qv).call(this)}mutate(n,r){var s;return ye(this,ua,r),(s=D(this,or))==null||s.removeObserver(this),ye(this,or,D(this,Qa).getMutationCache().build(D(this,Qa),this.options)),D(this,or).addObserver(this),D(this,or).execute(n)}},Qa=new WeakMap,Xa=new WeakMap,or=new WeakMap,ua=new WeakMap,pa=new WeakSet,hh=function(){var r;const n=((r=D(this,or))==null?void 0:r.state)??p2();ye(this,Xa,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Qv=function(n){sn.batch(()=>{var r,s,a,o,l,c,u,d;if(D(this,ua)&&this.hasListeners()){const f=D(this,Xa).variables,h=D(this,Xa).context;(n==null?void 0:n.type)==="success"?((s=(r=D(this,ua)).onSuccess)==null||s.call(r,n.data,f,h),(o=(a=D(this,ua)).onSettled)==null||o.call(a,n.data,null,f,h)):(n==null?void 0:n.type)==="error"&&((c=(l=D(this,ua)).onError)==null||c.call(l,n.error,f,h),(d=(u=D(this,ua)).onSettled)==null||d.call(u,void 0,n.error,f,h))}this.listeners.forEach(f=>{f(D(this,Xa))})})},uE);function v2(e){return e}function i6(e){return{mutationKey:e.options.mutationKey,state:e.state,...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:e.meta}}}function l6(e,t,n){var r;return{dehydratedAt:Date.now(),state:{...e.state,...e.state.data!==void 0&&{data:t(e.state.data)}},queryKey:e.queryKey,queryHash:e.queryHash,...e.state.status==="pending"&&{promise:(r=e.promise)==null?void 0:r.then(t).catch(s=>n(s)?Promise.reject(new Error("redacted")):Promise.reject(s))},...e.meta&&{meta:e.meta}}}function c6(e){return e.state.isPaused}function u6(e){return e.state.status==="success"}function d6(e){return!0}function f6(e,t={}){var c,u,d,f;const n=t.shouldDehydrateMutation??((c=e.getDefaultOptions().dehydrate)==null?void 0:c.shouldDehydrateMutation)??c6,r=e.getMutationCache().getAll().flatMap(h=>n(h)?[i6(h)]:[]),s=t.shouldDehydrateQuery??((u=e.getDefaultOptions().dehydrate)==null?void 0:u.shouldDehydrateQuery)??u6,a=t.shouldRedactErrors??((d=e.getDefaultOptions().dehydrate)==null?void 0:d.shouldRedactErrors)??d6,o=t.serializeData??((f=e.getDefaultOptions().dehydrate)==null?void 0:f.serializeData)??v2,l=e.getQueryCache().getAll().flatMap(h=>s(h)?[l6(h,o,a)]:[]);return{mutations:r,queries:l}}function h6(e,t,n){var c;if(typeof t!="object"||t===null)return;const r=e.getMutationCache(),s=e.getQueryCache(),a=((c=e.getDefaultOptions().hydrate)==null?void 0:c.deserializeData)??v2,o=t.mutations||[],l=t.queries||[];o.forEach(({state:u,...d})=>{var f,h;r.build(e,{...(f=e.getDefaultOptions().hydrate)==null?void 0:f.mutations,...(h=n==null?void 0:n.defaultOptions)==null?void 0:h.mutations,...d},u)}),l.forEach(({queryKey:u,state:d,queryHash:f,meta:h,promise:m,dehydratedAt:v})=>{var j,k;const w=m?Kz(m):void 0,y=d.data===void 0?w==null?void 0:w.data:d.data,x=y===void 0?y:a(y);let g=s.get(f);const b=(g==null?void 0:g.state.status)==="pending",_=(g==null?void 0:g.state.fetchStatus)==="fetching";if(g){const S=w&&v!==void 0&&v>g.state.dataUpdatedAt;if(d.dataUpdatedAt>g.state.dataUpdatedAt||S){const{fetchStatus:E,...N}=d;g.setState({...N,data:x})}}else g=s.build(e,{...(j=e.getDefaultOptions().hydrate)==null?void 0:j.queries,...(k=n==null?void 0:n.defaultOptions)==null?void 0:k.queries,queryKey:u,queryHash:f,meta:h},{...d,data:x,fetchStatus:"idle",status:x!==void 0?"success":d.status});m&&!b&&!_&&(v===void 0||v>g.state.dataUpdatedAt)&&g.fetch(void 0,{initialPromise:Promise.resolve(m).then(a)})})}var x2=p.createContext(void 0),Ge=e=>{const t=p.useContext(x2);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},m6=({client:e,children:t})=>(p.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),i.jsx(x2.Provider,{value:e,children:t})),w2=p.createContext(!1),p6=()=>p.useContext(w2);w2.Provider;function g6(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var y6=p.createContext(g6()),v6=()=>p.useContext(y6),x6=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},w6=e=>{p.useEffect(()=>{e.clearReset()},[e])},b6=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||c2(n,[e.error,r])),_6=e=>{if(e.suspense){const t=r=>r==="static"?r:Math.max(r??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...r)=>t(n(...r)):t(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},k6=(e,t)=>e.isLoading&&e.isFetching&&!t,j6=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,u1=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function S6(e,t,n){var f,h,m,v,w;const r=p6(),s=v6(),a=Ge(),o=a.defaultQueryOptions(e);(h=(f=a.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||h.call(f,o),o._optimisticResults=r?"isRestoring":"optimistic",_6(o),x6(o,s),w6(s);const l=!a.getQueryCache().get(o.queryHash),[c]=p.useState(()=>new t(a,o)),u=c.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(p.useSyncExternalStore(p.useCallback(y=>{const x=d?c.subscribe(sn.batchCalls(y)):Nn;return c.updateResult(),x},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),p.useEffect(()=>{c.setOptions(o)},[o,c]),j6(o,u))throw u1(o,c,s);if(b6({result:u,errorResetBoundary:s,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;if((v=(m=a.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||v.call(m,o,u),o.experimental_prefetchInRender&&!xi&&k6(u,r)){const y=l?u1(o,c,s):(w=a.getQueryCache().get(o.queryHash))==null?void 0:w.promise;y==null||y.catch(Nn).finally(()=>{c.updateResult()})}return o.notifyOnChangeProps?u:c.trackResult(u)}function xt(e,t){return S6(e,r6)}function E6(e,t){const n=Ge(),r=n.getQueryCache();return p.useSyncExternalStore(p.useCallback(s=>r.subscribe(sn.batchCalls(s)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}function Ke(e,t){const n=Ge(),[r]=p.useState(()=>new o6(n,e));p.useEffect(()=>{r.setOptions(e)},[r,e]);const s=p.useSyncExternalStore(p.useCallback(o=>r.subscribe(sn.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=p.useCallback((o,l)=>{r.mutate(o,l).catch(Nn)},[r]);if(s.error&&c2(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}var Xv=function(e,t){return Xv=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},Xv(e,t)};function b2(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Xv(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var zr=function(){return zr=Object.assign||function(t){for(var n,r=1,s=arguments.length;r=0;l--)(o=e[l])&&(a=(s<3?o(a):s>3?o(t,n,a):o(t,n))||a);return s>3&&a&&Object.defineProperty(t,n,a),a}function k2(e,t){return function(n,r){t(n,r,e)}}function j2(e,t,n,r,s,a){function o(x){if(x!==void 0&&typeof x!="function")throw new TypeError("Function expected");return x}for(var l=r.kind,c=l==="getter"?"get":l==="setter"?"set":"value",u=!t&&e?r.static?e:e.prototype:null,d=t||(u?Object.getOwnPropertyDescriptor(u,r.name):{}),f,h=!1,m=n.length-1;m>=0;m--){var v={};for(var w in r)v[w]=w==="access"?{}:r[w];for(var w in r.access)v.access[w]=r.access[w];v.addInitializer=function(x){if(h)throw new TypeError("Cannot add initializers after decoration has completed");a.push(o(x||null))};var y=(0,n[m])(l==="accessor"?{get:d.get,set:d.set}:d[c],v);if(l==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(f=o(y.get))&&(d.get=f),(f=o(y.set))&&(d.set=f),(f=o(y.init))&&s.unshift(f)}else(f=o(y))&&(l==="field"?s.unshift(f):d[c]=f)}u&&Object.defineProperty(u,r.name,d),h=!0}function S2(e,t,n){for(var r=arguments.length>2,s=0;s0&&a[a.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function b0(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,a=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)a.push(s.value)}catch(l){o={error:l}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function A2(){for(var e=[],t=0;t1||c(m,w)})},v&&(s[m]=v(s[m])))}function c(m,v){try{u(r[m](v))}catch(w){h(a[0][3],w)}}function u(m){m.value instanceof rc?Promise.resolve(m.value.v).then(d,f):h(a[0][2],m)}function d(m){c("next",m)}function f(m){c("throw",m)}function h(m,v){m(v),a.shift(),a.length&&c(a[0][0],a[0][1])}}function M2(e){var t,n;return t={},r("next"),r("throw",function(s){throw s}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(s,a){t[s]=e[s]?function(o){return(n=!n)?{value:rc(e[s](o)),done:!1}:a?a(o):o}:a}}function D2(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof nm=="function"?nm(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(a){n[a]=e[a]&&function(o){return new Promise(function(l,c){o=e[a](o),s(l,c,o.done,o.value)})}}function s(a,o,l,c){Promise.resolve(c).then(function(u){a({value:u,done:l})},o)}}function I2(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var N6=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},Zv=function(e){return Zv=Object.getOwnPropertyNames||function(t){var n=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[n.length]=r);return n},Zv(e)};function L2(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=Zv(e),r=0;re?(...t)=>e(...t):(...t)=>fetch(...t);class k0 extends Error{constructor(t,n="FunctionsError",r){super(t),this.name=n,this.context=r}}class d1 extends k0{constructor(t){super("Failed to send a request to the Edge Function","FunctionsFetchError",t)}}class f1 extends k0{constructor(t){super("Relay Error invoking the Edge Function","FunctionsRelayError",t)}}class h1 extends k0{constructor(t){super("Edge Function returned a non-2xx status code","FunctionsHttpError",t)}}var Jv;(function(e){e.Any="any",e.ApNortheast1="ap-northeast-1",e.ApNortheast2="ap-northeast-2",e.ApSouth1="ap-south-1",e.ApSoutheast1="ap-southeast-1",e.ApSoutheast2="ap-southeast-2",e.CaCentral1="ca-central-1",e.EuCentral1="eu-central-1",e.EuWest1="eu-west-1",e.EuWest2="eu-west-2",e.EuWest3="eu-west-3",e.SaEast1="sa-east-1",e.UsEast1="us-east-1",e.UsWest1="us-west-1",e.UsWest2="us-west-2"})(Jv||(Jv={}));class R6{constructor(t,{headers:n={},customFetch:r,region:s=Jv.Any}={}){this.url=t,this.headers=n,this.region=s,this.fetch=A6(r)}setAuth(t){this.headers.Authorization=`Bearer ${t}`}invoke(t){return Ce(this,arguments,void 0,function*(n,r={}){var s;try{const{headers:a,method:o,body:l,signal:c}=r;let u={},{region:d}=r;d||(d=this.region);const f=new URL(`${this.url}/${n}`);d&&d!=="any"&&(u["x-region"]=d,f.searchParams.set("forceFunctionRegion",d));let h;l&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)?typeof Blob<"u"&&l instanceof Blob||l instanceof ArrayBuffer?(u["Content-Type"]="application/octet-stream",h=l):typeof l=="string"?(u["Content-Type"]="text/plain",h=l):typeof FormData<"u"&&l instanceof FormData?h=l:(u["Content-Type"]="application/json",h=JSON.stringify(l)):h=l;const m=yield this.fetch(f.toString(),{method:o||"POST",headers:Object.assign(Object.assign(Object.assign({},u),this.headers),a),body:h,signal:c}).catch(x=>{throw x.name==="AbortError"?x:new d1(x)}),v=m.headers.get("x-relay-error");if(v&&v==="true")throw new f1(m);if(!m.ok)throw new h1(m);let w=((s=m.headers.get("Content-Type"))!==null&&s!==void 0?s:"text/plain").split(";")[0].trim(),y;return w==="application/json"?y=yield m.json():w==="application/octet-stream"||w==="application/pdf"?y=yield m.blob():w==="text/event-stream"?y=m:w==="multipart/form-data"?y=yield m.formData():y=yield m.text(),{data:y,error:null,response:m}}catch(a){return a instanceof Error&&a.name==="AbortError"?{data:null,error:new d1(a)}:{data:null,error:a,response:a instanceof h1||a instanceof f1?a.context:void 0}}})}}var fr={};const Pc=dI(P6);var jf={},Sf={},Ef={},Nf={},Cf={},Tf={},m1;function H2(){if(m1)return Tf;m1=1,Object.defineProperty(Tf,"__esModule",{value:!0});class e extends Error{constructor(n){super(n.message),this.name="PostgrestError",this.details=n.details,this.hint=n.hint,this.code=n.code}}return Tf.default=e,Tf}var p1;function q2(){if(p1)return Cf;p1=1,Object.defineProperty(Cf,"__esModule",{value:!0});const t=Pc.__importDefault(H2());class n{constructor(s){var a,o;this.shouldThrowOnError=!1,this.method=s.method,this.url=s.url,this.headers=new Headers(s.headers),this.schema=s.schema,this.body=s.body,this.shouldThrowOnError=(a=s.shouldThrowOnError)!==null&&a!==void 0?a:!1,this.signal=s.signal,this.isMaybeSingle=(o=s.isMaybeSingle)!==null&&o!==void 0?o:!1,s.fetch?this.fetch=s.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(s,a){return this.headers=new Headers(this.headers),this.headers.set(s,a),this}then(s,a){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const o=this.fetch;let l=o(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async c=>{var u,d,f,h;let m=null,v=null,w=null,y=c.status,x=c.statusText;if(c.ok){if(this.method!=="HEAD"){const j=await c.text();j===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((u=this.headers.get("Accept"))===null||u===void 0)&&u.includes("application/vnd.pgrst.plan+text"))?v=j:v=JSON.parse(j))}const b=(d=this.headers.get("Prefer"))===null||d===void 0?void 0:d.match(/count=(exact|planned|estimated)/),_=(f=c.headers.get("content-range"))===null||f===void 0?void 0:f.split("/");b&&_&&_.length>1&&(w=parseInt(_[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(v)&&(v.length>1?(m={code:"PGRST116",details:`Results contain ${v.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},v=null,w=null,y=406,x="Not Acceptable"):v.length===1?v=v[0]:v=null)}else{const b=await c.text();try{m=JSON.parse(b),Array.isArray(m)&&c.status===404&&(v=[],m=null,y=200,x="OK")}catch{c.status===404&&b===""?(y=204,x="No Content"):m={message:b}}if(m&&this.isMaybeSingle&&(!((h=m==null?void 0:m.details)===null||h===void 0)&&h.includes("0 rows"))&&(m=null,y=200,x="OK"),m&&this.shouldThrowOnError)throw new t.default(m)}return{error:m,data:v,count:w,status:y,statusText:x}});return this.shouldThrowOnError||(l=l.catch(c=>{var u,d,f;return{error:{message:`${(u=c==null?void 0:c.name)!==null&&u!==void 0?u:"FetchError"}: ${c==null?void 0:c.message}`,details:`${(d=c==null?void 0:c.stack)!==null&&d!==void 0?d:""}`,hint:"",code:`${(f=c==null?void 0:c.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),l.then(s,a)}returns(){return this}overrideTypes(){return this}}return Cf.default=n,Cf}var g1;function K2(){if(g1)return Nf;g1=1,Object.defineProperty(Nf,"__esModule",{value:!0});const t=Pc.__importDefault(q2());class n extends t.default{select(s){let a=!1;const o=(s??"*").split("").map(l=>/\s/.test(l)&&!a?"":(l==='"'&&(a=!a),l)).join("");return this.url.searchParams.set("select",o),this.headers.append("Prefer","return=representation"),this}order(s,{ascending:a=!0,nullsFirst:o,foreignTable:l,referencedTable:c=l}={}){const u=c?`${c}.order`:"order",d=this.url.searchParams.get(u);return this.url.searchParams.set(u,`${d?`${d},`:""}${s}.${a?"asc":"desc"}${o===void 0?"":o?".nullsfirst":".nullslast"}`),this}limit(s,{foreignTable:a,referencedTable:o=a}={}){const l=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(l,`${s}`),this}range(s,a,{foreignTable:o,referencedTable:l=o}={}){const c=typeof l>"u"?"offset":`${l}.offset`,u=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(c,`${s}`),this.url.searchParams.set(u,`${a-s+1}`),this}abortSignal(s){return this.signal=s,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:s=!1,verbose:a=!1,settings:o=!1,buffers:l=!1,wal:c=!1,format:u="text"}={}){var d;const f=[s?"analyze":null,a?"verbose":null,o?"settings":null,l?"buffers":null,c?"wal":null].filter(Boolean).join("|"),h=(d=this.headers.get("Accept"))!==null&&d!==void 0?d:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${h}"; options=${f};`),u==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(s){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${s}`),this}}return Nf.default=n,Nf}var y1;function j0(){if(y1)return Ef;y1=1,Object.defineProperty(Ef,"__esModule",{value:!0});const t=Pc.__importDefault(K2()),n=new RegExp("[,()]");class r extends t.default{eq(a,o){return this.url.searchParams.append(a,`eq.${o}`),this}neq(a,o){return this.url.searchParams.append(a,`neq.${o}`),this}gt(a,o){return this.url.searchParams.append(a,`gt.${o}`),this}gte(a,o){return this.url.searchParams.append(a,`gte.${o}`),this}lt(a,o){return this.url.searchParams.append(a,`lt.${o}`),this}lte(a,o){return this.url.searchParams.append(a,`lte.${o}`),this}like(a,o){return this.url.searchParams.append(a,`like.${o}`),this}likeAllOf(a,o){return this.url.searchParams.append(a,`like(all).{${o.join(",")}}`),this}likeAnyOf(a,o){return this.url.searchParams.append(a,`like(any).{${o.join(",")}}`),this}ilike(a,o){return this.url.searchParams.append(a,`ilike.${o}`),this}ilikeAllOf(a,o){return this.url.searchParams.append(a,`ilike(all).{${o.join(",")}}`),this}ilikeAnyOf(a,o){return this.url.searchParams.append(a,`ilike(any).{${o.join(",")}}`),this}is(a,o){return this.url.searchParams.append(a,`is.${o}`),this}in(a,o){const l=Array.from(new Set(o)).map(c=>typeof c=="string"&&n.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(a,`in.(${l})`),this}contains(a,o){return typeof o=="string"?this.url.searchParams.append(a,`cs.${o}`):Array.isArray(o)?this.url.searchParams.append(a,`cs.{${o.join(",")}}`):this.url.searchParams.append(a,`cs.${JSON.stringify(o)}`),this}containedBy(a,o){return typeof o=="string"?this.url.searchParams.append(a,`cd.${o}`):Array.isArray(o)?this.url.searchParams.append(a,`cd.{${o.join(",")}}`):this.url.searchParams.append(a,`cd.${JSON.stringify(o)}`),this}rangeGt(a,o){return this.url.searchParams.append(a,`sr.${o}`),this}rangeGte(a,o){return this.url.searchParams.append(a,`nxl.${o}`),this}rangeLt(a,o){return this.url.searchParams.append(a,`sl.${o}`),this}rangeLte(a,o){return this.url.searchParams.append(a,`nxr.${o}`),this}rangeAdjacent(a,o){return this.url.searchParams.append(a,`adj.${o}`),this}overlaps(a,o){return typeof o=="string"?this.url.searchParams.append(a,`ov.${o}`):this.url.searchParams.append(a,`ov.{${o.join(",")}}`),this}textSearch(a,o,{config:l,type:c}={}){let u="";c==="plain"?u="pl":c==="phrase"?u="ph":c==="websearch"&&(u="w");const d=l===void 0?"":`(${l})`;return this.url.searchParams.append(a,`${u}fts${d}.${o}`),this}match(a){return Object.entries(a).forEach(([o,l])=>{this.url.searchParams.append(o,`eq.${l}`)}),this}not(a,o,l){return this.url.searchParams.append(a,`not.${o}.${l}`),this}or(a,{foreignTable:o,referencedTable:l=o}={}){const c=l?`${l}.or`:"or";return this.url.searchParams.append(c,`(${a})`),this}filter(a,o,l){return this.url.searchParams.append(a,`${o}.${l}`),this}}return Ef.default=r,Ef}var v1;function G2(){if(v1)return Sf;v1=1,Object.defineProperty(Sf,"__esModule",{value:!0});const t=Pc.__importDefault(j0());class n{constructor(s,{headers:a={},schema:o,fetch:l}){this.url=s,this.headers=new Headers(a),this.schema=o,this.fetch=l}select(s,a){const{head:o=!1,count:l}=a??{},c=o?"HEAD":"GET";let u=!1;const d=(s??"*").split("").map(f=>/\s/.test(f)&&!u?"":(f==='"'&&(u=!u),f)).join("");return this.url.searchParams.set("select",d),l&&this.headers.append("Prefer",`count=${l}`),new t.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(s,{count:a,defaultToNull:o=!0}={}){var l;const c="POST";if(a&&this.headers.append("Prefer",`count=${a}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(s)){const u=s.reduce((d,f)=>d.concat(Object.keys(f)),[]);if(u.length>0){const d=[...new Set(u)].map(f=>`"${f}"`);this.url.searchParams.set("columns",d.join(","))}}return new t.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(s,{onConflict:a,ignoreDuplicates:o=!1,count:l,defaultToNull:c=!0}={}){var u;const d="POST";if(this.headers.append("Prefer",`resolution=${o?"ignore":"merge"}-duplicates`),a!==void 0&&this.url.searchParams.set("on_conflict",a),l&&this.headers.append("Prefer",`count=${l}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(s)){const f=s.reduce((h,m)=>h.concat(Object.keys(m)),[]);if(f.length>0){const h=[...new Set(f)].map(m=>`"${m}"`);this.url.searchParams.set("columns",h.join(","))}}return new t.default({method:d,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}update(s,{count:a}={}){var o;const l="PATCH";return a&&this.headers.append("Prefer",`count=${a}`),new t.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}delete({count:s}={}){var a;const o="DELETE";return s&&this.headers.append("Prefer",`count=${s}`),new t.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}}return Sf.default=n,Sf}var x1;function O6(){if(x1)return jf;x1=1,Object.defineProperty(jf,"__esModule",{value:!0});const e=Pc,t=e.__importDefault(G2()),n=e.__importDefault(j0());class r{constructor(a,{headers:o={},schema:l,fetch:c}={}){this.url=a,this.headers=new Headers(o),this.schemaName=l,this.fetch=c}from(a){const o=new URL(`${this.url}/${a}`);return new t.default(o,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(a){return new r(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,o={},{head:l=!1,get:c=!1,count:u}={}){var d;let f;const h=new URL(`${this.url}/rpc/${a}`);let m;l||c?(f=l?"HEAD":"GET",Object.entries(o).filter(([w,y])=>y!==void 0).map(([w,y])=>[w,Array.isArray(y)?`{${y.join(",")}}`:`${y}`]).forEach(([w,y])=>{h.searchParams.append(w,y)})):(f="POST",m=o);const v=new Headers(this.headers);return u&&v.set("Prefer",`count=${u}`),new n.default({method:f,url:h,headers:v,schema:this.schemaName,body:m,fetch:(d=this.fetch)!==null&&d!==void 0?d:fetch})}}return jf.default=r,jf}Object.defineProperty(fr,"__esModule",{value:!0});var Y2=fr.PostgrestError=aP=fr.PostgrestBuilder=rP=fr.PostgrestTransformBuilder=tP=fr.PostgrestFilterBuilder=J2=fr.PostgrestQueryBuilder=X2=fr.PostgrestClient=void 0;const Ac=Pc,Q2=Ac.__importDefault(O6());var X2=fr.PostgrestClient=Q2.default;const Z2=Ac.__importDefault(G2());var J2=fr.PostgrestQueryBuilder=Z2.default;const eP=Ac.__importDefault(j0());var tP=fr.PostgrestFilterBuilder=eP.default;const nP=Ac.__importDefault(K2());var rP=fr.PostgrestTransformBuilder=nP.default;const sP=Ac.__importDefault(q2());var aP=fr.PostgrestBuilder=sP.default;const oP=Ac.__importDefault(H2());Y2=fr.PostgrestError=oP.default;var iP=fr.default={PostgrestClient:Q2.default,PostgrestQueryBuilder:Z2.default,PostgrestFilterBuilder:eP.default,PostgrestTransformBuilder:nP.default,PostgrestBuilder:sP.default,PostgrestError:oP.default};const M6=Object.freeze(Object.defineProperty({__proto__:null,get PostgrestBuilder(){return aP},get PostgrestClient(){return X2},get PostgrestError(){return Y2},get PostgrestFilterBuilder(){return tP},get PostgrestQueryBuilder(){return J2},get PostgrestTransformBuilder(){return rP},default:iP},Symbol.toStringTag,{value:"Module"})),{PostgrestClient:D6,PostgrestQueryBuilder:rse,PostgrestFilterBuilder:sse,PostgrestTransformBuilder:ase,PostgrestBuilder:ose,PostgrestError:ise}=iP||M6;class I6{static detectEnvironment(){var t;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((t=navigator.userAgent)===null||t===void 0)&&t.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"){const n=process.versions;if(n&&n.node){const r=n.node,s=parseInt(r.replace(/^v/,"").split(".")[0]);return s>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${s} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${s} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option: import ws from "ws" new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const t=this.detectEnvironment();if(t.constructor)return t.constructor;let n=t.error||"WebSocket not supported in this environment.";throw t.workaround&&(n+=` Suggested solution: ${t.workaround}`),new Error(n)}static createWebSocket(t,n){const r=this.getWebSocketConstructor();return new r(t,n)}static isWebSocketSupported(){try{const t=this.detectEnvironment();return t.type==="native"||t.type==="ws"}catch{return!1}}}const L6="2.80.0",$6=`realtime-js/${L6}`,F6="1.0.0",ex=1e4,z6=1e3,B6=100;var Nu;(function(e){e[e.connecting=0]="connecting",e[e.open=1]="open",e[e.closing=2]="closing",e[e.closed=3]="closed"})(Nu||(Nu={}));var dn;(function(e){e.closed="closed",e.errored="errored",e.joined="joined",e.joining="joining",e.leaving="leaving"})(dn||(dn={}));var us;(function(e){e.close="phx_close",e.error="phx_error",e.join="phx_join",e.reply="phx_reply",e.leave="phx_leave",e.access_token="access_token"})(us||(us={}));var tx;(function(e){e.websocket="websocket"})(tx||(tx={}));var Wo;(function(e){e.Connecting="connecting",e.Open="open",e.Closing="closing",e.Closed="closed"})(Wo||(Wo={}));class U6{constructor(){this.HEADER_LENGTH=1}decode(t,n){return t.constructor===ArrayBuffer?n(this._binaryDecode(t)):n(typeof t=="string"?JSON.parse(t):{})}_binaryDecode(t){const n=new DataView(t),r=new TextDecoder;return this._decodeBroadcast(t,n,r)}_decodeBroadcast(t,n,r){const s=n.getUint8(1),a=n.getUint8(2);let o=this.HEADER_LENGTH+2;const l=r.decode(t.slice(o,o+s));o=o+s;const c=r.decode(t.slice(o,o+a));o=o+a;const u=JSON.parse(r.decode(t.slice(o,t.byteLength)));return{ref:null,topic:l,event:c,payload:u}}}class lP{constructor(t,n){this.callback=t,this.timerCalc=n,this.timer=void 0,this.tries=0,this.callback=t,this.timerCalc=n}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var kt;(function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"})(kt||(kt={}));const w1=(e,t,n={})=>{var r;const s=(r=n.skipTypes)!==null&&r!==void 0?r:[];return t?Object.keys(t).reduce((a,o)=>(a[o]=V6(o,e,t,s),a),{}):{}},V6=(e,t,n,r)=>{const s=t.find(l=>l.name===e),a=s==null?void 0:s.type,o=n[e];return a&&!r.includes(a)?cP(a,o):nx(o)},cP=(e,t)=>{if(e.charAt(0)==="_"){const n=e.slice(1,e.length);return K6(t,n)}switch(e){case kt.bool:return W6(t);case kt.float4:case kt.float8:case kt.int2:case kt.int4:case kt.int8:case kt.numeric:case kt.oid:return H6(t);case kt.json:case kt.jsonb:return q6(t);case kt.timestamp:return G6(t);case kt.abstime:case kt.date:case kt.daterange:case kt.int4range:case kt.int8range:case kt.money:case kt.reltime:case kt.text:case kt.time:case kt.timestamptz:case kt.timetz:case kt.tsrange:case kt.tstzrange:return nx(t);default:return nx(t)}},nx=e=>e,W6=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},H6=e=>{if(typeof e=="string"){const t=parseFloat(e);if(!Number.isNaN(t))return t}return e},q6=e=>{if(typeof e=="string")try{return JSON.parse(e)}catch(t){return console.log(`JSON parse error: ${t}`),e}return e},K6=(e,t)=>{if(typeof e!="string")return e;const n=e.length-1,r=e[n];if(e[0]==="{"&&r==="}"){let a;const o=e.slice(1,n);try{a=JSON.parse("["+o+"]")}catch{a=o?o.split(","):[]}return a.map(l=>cP(t,l))}return e},G6=e=>typeof e=="string"?e.replace(" ","T"):e,uP=e=>{const t=new URL(e);return t.protocol=t.protocol.replace(/^ws/i,"http"),t.pathname=t.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),t.pathname===""||t.pathname==="/"?t.pathname="/api/broadcast":t.pathname=t.pathname+"/api/broadcast",t.href};class Ag{constructor(t,n,r={},s=ex){this.channel=t,this.event=n,this.payload=r,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(t){this.timeout=t,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(t){this.payload=Object.assign(Object.assign({},this.payload),t)}receive(t,n){var r;return this._hasReceived(t)&&n((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:t,callback:n}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const t=n=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=n,this._matchReceive(n)};this.channel._on(this.refEvent,{},t),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(t,n){this.refEvent&&this.channel._trigger(this.refEvent,{status:t,response:n})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:t,response:n}){this.recHooks.filter(r=>r.status===t).forEach(r=>r.callback(n))}_hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}}var b1;(function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"})(b1||(b1={}));class Cu{constructor(t,n){this.channel=t,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=(n==null?void 0:n.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},s=>{const{onJoin:a,onLeave:o,onSync:l}=this.caller;this.joinRef=this.channel._joinRef(),this.state=Cu.syncState(this.state,s,a,o),this.pendingDiffs.forEach(c=>{this.state=Cu.syncDiff(this.state,c,a,o)}),this.pendingDiffs=[],l()}),this.channel._on(r.diff,{},s=>{const{onJoin:a,onLeave:o,onSync:l}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=Cu.syncDiff(this.state,s,a,o),l())}),this.onJoin((s,a,o)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:a,newPresences:o})}),this.onLeave((s,a,o)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:a,leftPresences:o})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(t,n,r,s){const a=this.cloneDeep(t),o=this.transformState(n),l={},c={};return this.map(a,(u,d)=>{o[u]||(c[u]=d)}),this.map(o,(u,d)=>{const f=a[u];if(f){const h=d.map(y=>y.presence_ref),m=f.map(y=>y.presence_ref),v=d.filter(y=>m.indexOf(y.presence_ref)<0),w=f.filter(y=>h.indexOf(y.presence_ref)<0);v.length>0&&(l[u]=v),w.length>0&&(c[u]=w)}else l[u]=d}),this.syncDiff(a,{joins:l,leaves:c},r,s)}static syncDiff(t,n,r,s){const{joins:a,leaves:o}={joins:this.transformState(n.joins),leaves:this.transformState(n.leaves)};return r||(r=()=>{}),s||(s=()=>{}),this.map(a,(l,c)=>{var u;const d=(u=t[l])!==null&&u!==void 0?u:[];if(t[l]=this.cloneDeep(c),d.length>0){const f=t[l].map(m=>m.presence_ref),h=d.filter(m=>f.indexOf(m.presence_ref)<0);t[l].unshift(...h)}r(l,d,c)}),this.map(o,(l,c)=>{let u=t[l];if(!u)return;const d=c.map(f=>f.presence_ref);u=u.filter(f=>d.indexOf(f.presence_ref)<0),t[l]=u,s(l,u,c),u.length===0&&delete t[l]}),t}static map(t,n){return Object.getOwnPropertyNames(t).map(r=>n(r,t[r]))}static transformState(t){return t=this.cloneDeep(t),Object.getOwnPropertyNames(t).reduce((n,r)=>{const s=t[r];return"metas"in s?n[r]=s.metas.map(a=>(a.presence_ref=a.phx_ref,delete a.phx_ref,delete a.phx_ref_prev,a)):n[r]=s,n},{})}static cloneDeep(t){return JSON.parse(JSON.stringify(t))}onJoin(t){this.caller.onJoin=t}onLeave(t){this.caller.onLeave=t}onSync(t){this.caller.onSync=t}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var _1;(function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"})(_1||(_1={}));var Tu;(function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"})(Tu||(Tu={}));var oa;(function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"})(oa||(oa={}));class S0{constructor(t,n={config:{}},r){var s,a;if(this.topic=t,this.params=n,this.socket=r,this.bindings={},this.state=dn.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=t.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},n.config),this.timeout=this.socket.timeout,this.joinPush=new Ag(this,us.join,this.params,this.timeout),this.rejoinTimer=new lP(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=dn.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(o=>o.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=dn.closed,this.socket._remove(this)}),this._onError(o=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,o),this.state=dn.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=dn.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",o=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,o),this.state=dn.errored,this.rejoinTimer.scheduleTimeout())}),this._on(us.reply,{},(o,l)=>{this._trigger(this._replyEventName(l),o)}),this.presence=new Cu(this),this.broadcastEndpointURL=uP(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((a=(s=this.params.config)===null||s===void 0?void 0:s.broadcast)===null||a===void 0)&&a.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(t,n=this.timeout){var r,s,a;if(this.socket.isConnected()||this.socket.connect(),this.state==dn.closed){const{config:{broadcast:o,presence:l,private:c}}=this.params,u=(s=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(m=>m.filter))!==null&&s!==void 0?s:[],d=!!this.bindings[Tu.PRESENCE]&&this.bindings[Tu.PRESENCE].length>0||((a=this.params.config.presence)===null||a===void 0?void 0:a.enabled)===!0,f={},h={broadcast:o,presence:Object.assign(Object.assign({},l),{enabled:d}),postgres_changes:u,private:c};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this._onError(m=>t==null?void 0:t(oa.CHANNEL_ERROR,m)),this._onClose(()=>t==null?void 0:t(oa.CLOSED)),this.updateJoinPayload(Object.assign({config:h},f)),this.joinedOnce=!0,this._rejoin(n),this.joinPush.receive("ok",async({postgres_changes:m})=>{var v;if(this.socket.setAuth(),m===void 0){t==null||t(oa.SUBSCRIBED);return}else{const w=this.bindings.postgres_changes,y=(v=w==null?void 0:w.length)!==null&&v!==void 0?v:0,x=[];for(let g=0;g{this.state=dn.errored,t==null||t(oa.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(m).join(", ")||"error")))}).receive("timeout",()=>{t==null||t(oa.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(t,n={}){return await this.send({type:"presence",event:"track",payload:t},n.timeout||this.timeout)}async untrack(t={}){return await this.send({type:"presence",event:"untrack"},t)}on(t,n,r){return this.state===dn.joined&&t===Tu.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(t,n,r)}async httpSend(t,n,r={}){var s;const a=this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"";if(n==null)return Promise.reject("Payload is required for httpSend()");const o={method:"POST",headers:{Authorization:a,apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:t,payload:n,private:this.private}]})},l=await this._fetchWithTimeout(this.broadcastEndpointURL,o,(s=r.timeout)!==null&&s!==void 0?s:this.timeout);if(l.status===202)return{success:!0};let c=l.statusText;try{const u=await l.json();c=u.error||u.message||c}catch{}return Promise.reject(new Error(c))}async send(t,n={}){var r,s;if(!this._canPush()&&t.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:a,payload:o}=t,c={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:a,payload:o,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(r=n.timeout)!==null&&r!==void 0?r:this.timeout);return await((s=u.body)===null||s===void 0?void 0:s.cancel()),u.ok?"ok":"error"}catch(u){return u.name==="AbortError"?"timed out":"error"}}else return new Promise(a=>{var o,l,c;const u=this._push(t.type,t,n.timeout||this.timeout);t.type==="broadcast"&&!(!((c=(l=(o=this.params)===null||o===void 0?void 0:o.config)===null||l===void 0?void 0:l.broadcast)===null||c===void 0)&&c.ack)&&a("ok"),u.receive("ok",()=>a("ok")),u.receive("error",()=>a("error")),u.receive("timeout",()=>a("timed out"))})}updateJoinPayload(t){this.joinPush.updatePayload(t)}unsubscribe(t=this.timeout){this.state=dn.leaving;const n=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(us.close,"leave",this._joinRef())};this.joinPush.destroy();let r=null;return new Promise(s=>{r=new Ag(this,us.leave,{},t),r.receive("ok",()=>{n(),s("ok")}).receive("timeout",()=>{n(),s("timed out")}).receive("error",()=>{s("error")}),r.send(),this._canPush()||r.trigger("ok",{})}).finally(()=>{r==null||r.destroy()})}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=dn.closed,this.bindings={}}async _fetchWithTimeout(t,n,r){const s=new AbortController,a=setTimeout(()=>s.abort(),r),o=await this.socket.fetch(t,Object.assign(Object.assign({},n),{signal:s.signal}));return clearTimeout(a),o}_push(t,n,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${t}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new Ag(this,t,n,r);return this._canPush()?s.send():this._addToPushBuffer(s),s}_addToPushBuffer(t){if(t.startTimeout(),this.pushBuffer.push(t),this.pushBuffer.length>B6){const n=this.pushBuffer.shift();n&&(n.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${n.event}`,n.payload))}}_onMessage(t,n,r){return n}_isMember(t){return this.topic===t}_joinRef(){return this.joinPush.ref}_trigger(t,n,r){var s,a;const o=t.toLocaleLowerCase(),{close:l,error:c,leave:u,join:d}=us;if(r&&[l,c,u,d].indexOf(o)>=0&&r!==this._joinRef())return;let h=this._onMessage(o,n,r);if(n&&!h)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(m=>{var v,w,y;return((v=m.filter)===null||v===void 0?void 0:v.event)==="*"||((y=(w=m.filter)===null||w===void 0?void 0:w.event)===null||y===void 0?void 0:y.toLocaleLowerCase())===o}).map(m=>m.callback(h,r)):(a=this.bindings[o])===null||a===void 0||a.filter(m=>{var v,w,y,x,g,b;if(["broadcast","presence","postgres_changes"].includes(o))if("id"in m){const _=m.id,j=(v=m.filter)===null||v===void 0?void 0:v.event;return _&&((w=n.ids)===null||w===void 0?void 0:w.includes(_))&&(j==="*"||(j==null?void 0:j.toLocaleLowerCase())===((y=n.data)===null||y===void 0?void 0:y.type.toLocaleLowerCase()))}else{const _=(g=(x=m==null?void 0:m.filter)===null||x===void 0?void 0:x.event)===null||g===void 0?void 0:g.toLocaleLowerCase();return _==="*"||_===((b=n==null?void 0:n.event)===null||b===void 0?void 0:b.toLocaleLowerCase())}else return m.type.toLocaleLowerCase()===o}).map(m=>{if(typeof h=="object"&&"ids"in h){const v=h.data,{schema:w,table:y,commit_timestamp:x,type:g,errors:b}=v;h=Object.assign(Object.assign({},{schema:w,table:y,commit_timestamp:x,eventType:g,new:{},old:{},errors:b}),this._getPayloadRecords(v))}m.callback(h,r)})}_isClosed(){return this.state===dn.closed}_isJoined(){return this.state===dn.joined}_isJoining(){return this.state===dn.joining}_isLeaving(){return this.state===dn.leaving}_replyEventName(t){return`chan_reply_${t}`}_on(t,n,r){const s=t.toLocaleLowerCase(),a={type:s,filter:n,callback:r};return this.bindings[s]?this.bindings[s].push(a):this.bindings[s]=[a],this}_off(t,n){const r=t.toLocaleLowerCase();return this.bindings[r]&&(this.bindings[r]=this.bindings[r].filter(s=>{var a;return!(((a=s.type)===null||a===void 0?void 0:a.toLocaleLowerCase())===r&&S0.isEqual(s.filter,n))})),this}static isEqual(t,n){if(Object.keys(t).length!==Object.keys(n).length)return!1;for(const r in t)if(t[r]!==n[r])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(t){this._on(us.close,{},t)}_onError(t){this._on(us.error,{},n=>t(n))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(t=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=dn.joining,this.joinPush.resend(t))}_getPayloadRecords(t){const n={new:{},old:{}};return(t.type==="INSERT"||t.type==="UPDATE")&&(n.new=w1(t.columns,t.record)),(t.type==="UPDATE"||t.type==="DELETE")&&(n.old=w1(t.columns,t.old_record)),n}}const Rg=()=>{},Pf={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},Y6=[1e3,2e3,5e3,1e4],Q6=1e4,X6=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class Z6{constructor(t,n){var r;if(this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=ex,this.transport=null,this.heartbeatIntervalMs=Pf.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=Rg,this.ref=0,this.reconnectTimer=null,this.logger=Rg,this.conn=null,this.sendBuffer=[],this.serializer=new U6,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=s=>s?(...a)=>s(...a):(...a)=>fetch(...a),!(!((r=n==null?void 0:n.params)===null||r===void 0)&&r.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=n.params.apikey,this.endPoint=`${t}/${tx.websocket}`,this.httpEndpoint=uP(t),this._initializeOptions(n),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(n==null?void 0:n.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=I6.createWebSocket(this.endpointURL())}catch(t){this._setConnectionState("disconnected");const n=t.message;throw n.includes("Node.js")?new Error(`${n} To use Realtime in Node.js, you need to provide a WebSocket implementation: Option 1: Use Node.js 22+ which has native WebSocket support Option 2: Install and provide the "ws" package: npm install ws import ws from "ws" const client = new RealtimeClient(url, { ...options, transport: ws })`):new Error(`WebSocket not available: ${n}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:F6}))}disconnect(t,n){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const r=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(r),this._setConnectionState("disconnected")},t?this.conn.close(t,n??""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(t){const n=await t.unsubscribe();return this.channels.length===0&&this.disconnect(),n}async removeAllChannels(){const t=await Promise.all(this.channels.map(n=>n.unsubscribe()));return this.channels=[],this.disconnect(),t}log(t,n,r){this.logger(t,n,r)}connectionState(){switch(this.conn&&this.conn.readyState){case Nu.connecting:return Wo.Connecting;case Nu.open:return Wo.Open;case Nu.closing:return Wo.Closing;default:return Wo.Closed}}isConnected(){return this.connectionState()===Wo.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(t,n={config:{}}){const r=`realtime:${t}`,s=this.getChannels().find(a=>a.topic===r);if(s)return s;{const a=new S0(`realtime:${t}`,n,this);return this.channels.push(a),a}}push(t){const{topic:n,event:r,payload:s,ref:a}=t,o=()=>{this.encode(t,l=>{var c;(c=this.conn)===null||c===void 0||c.send(l)})};this.log("push",`${n} ${r} (${a})`,s),this.isConnected()?o():this.sendBuffer.push(o)}async setAuth(t=null){this._authPromise=this._performAuth(t);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var t;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(n){this.log("error","error in heartbeat callback",n)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(n){this.log("error","error in heartbeat callback",n)}this._wasManualDisconnect=!1,(t=this.conn)===null||t===void 0||t.close(z6,"heartbeat timeout"),setTimeout(()=>{var n;this.isConnected()||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout()},Pf.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(n){this.log("error","error in heartbeat callback",n)}this._setAuthSafely("heartbeat")}onHeartbeat(t){this.heartbeatCallback=t}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}_makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}_leaveOpenTopic(t){let n=this.channels.find(r=>r.topic===t&&(r._isJoined()||r._isJoining()));n&&(this.log("transport",`leaving duplicate topic "${t}"`),n.unsubscribe())}_remove(t){this.channels=this.channels.filter(n=>n.topic!==t.topic)}_onConnMessage(t){this.decode(t.data,n=>{if(n.topic==="phoenix"&&n.event==="phx_reply")try{this.heartbeatCallback(n.payload.status==="ok"?"ok":"error")}catch(u){this.log("error","error in heartbeat callback",u)}n.ref&&n.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:r,event:s,payload:a,ref:o}=n,l=o?`(${o})`:"",c=a.status||"";this.log("receive",`${c} ${r} ${s} ${l}`.trim(),a),this.channels.filter(u=>u._isMember(r)).forEach(u=>u._trigger(s,a,o)),this._triggerStateCallbacks("message",n)})}_clearTimer(t){var n;t==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):t==="reconnect"&&((n=this.reconnectTimer)===null||n===void 0||n.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=t=>this._onConnError(t),this.conn.onmessage=t=>this._onConnMessage(t),this.conn.onclose=t=>this._onConnClose(t))}_teardownConnection(){this.conn&&(this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null),this._clearAllTimers(),this.channels.forEach(t=>t.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const t=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(t),this.workerRef.onerror=n=>{this.log("worker","worker error",n.message),this.workerRef.terminate()},this.workerRef.onmessage=n=>{n.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(t){var n;this._setConnectionState("disconnected"),this.log("transport","close",t),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout(),this._triggerStateCallbacks("close",t)}_onConnError(t){this._setConnectionState("disconnected"),this.log("transport",`${t}`),this._triggerChanError(),this._triggerStateCallbacks("error",t)}_triggerChanError(){this.channels.forEach(t=>t._trigger(us.error))}_appendParams(t,n){if(Object.keys(n).length===0)return t;const r=t.match(/\?/)?"&":"?",s=new URLSearchParams(n);return`${t}${r}${s}`}_workerObjectUrl(t){let n;if(t)n=t;else{const r=new Blob([X6],{type:"application/javascript"});n=URL.createObjectURL(r)}return n}_setConnectionState(t,n=!1){this._connectionState=t,t==="connecting"?this._wasManualDisconnect=!1:t==="disconnecting"&&(this._wasManualDisconnect=n)}async _performAuth(t=null){let n;t?n=t:this.accessToken?n=await this.accessToken():n=this.accessTokenValue,this.accessTokenValue!=n&&(this.accessTokenValue=n,this.channels.forEach(r=>{const s={access_token:n,version:$6};n&&r.updateJoinPayload(s),r.joinedOnce&&r._isJoined()&&r._push(us.access_token,{access_token:n})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(t="general"){this.setAuth().catch(n=>{this.log("error",`error setting auth in ${t}`,n)})}_triggerStateCallbacks(t,n){try{this.stateChangeCallbacks[t].forEach(r=>{try{r(n)}catch(s){this.log("error",`error in ${t} callback`,s)}})}catch(r){this.log("error",`error triggering ${t} callbacks`,r)}}_setupReconnectionTimer(){this.reconnectTimer=new lP(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},Pf.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(t){var n,r,s,a,o,l,c,u,d;if(this.transport=(n=t==null?void 0:t.transport)!==null&&n!==void 0?n:null,this.timeout=(r=t==null?void 0:t.timeout)!==null&&r!==void 0?r:ex,this.heartbeatIntervalMs=(s=t==null?void 0:t.heartbeatIntervalMs)!==null&&s!==void 0?s:Pf.HEARTBEAT_INTERVAL,this.worker=(a=t==null?void 0:t.worker)!==null&&a!==void 0?a:!1,this.accessToken=(o=t==null?void 0:t.accessToken)!==null&&o!==void 0?o:null,this.heartbeatCallback=(l=t==null?void 0:t.heartbeatCallback)!==null&&l!==void 0?l:Rg,t!=null&&t.params&&(this.params=t.params),t!=null&&t.logger&&(this.logger=t.logger),(t!=null&&t.logLevel||t!=null&&t.log_level)&&(this.logLevel=t.logLevel||t.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(c=t==null?void 0:t.reconnectAfterMs)!==null&&c!==void 0?c:f=>Y6[f-1]||Q6,this.encode=(u=t==null?void 0:t.encode)!==null&&u!==void 0?u:(f,h)=>h(JSON.stringify(f)),this.decode=(d=t==null?void 0:t.decode)!==null&&d!==void 0?d:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=t==null?void 0:t.workerUrl}}}class E0 extends Error{constructor(t){super(t),this.__isStorageError=!0,this.name="StorageError"}}function Ot(e){return typeof e=="object"&&e!==null&&"__isStorageError"in e}class J6 extends E0{constructor(t,n,r){super(t),this.name="StorageApiError",this.status=n,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class rx extends E0{constructor(t,n){super(t),this.name="StorageUnknownError",this.originalError=n}}const N0=e=>e?(...t)=>e(...t):(...t)=>fetch(...t),eB=()=>Response,sx=e=>{if(Array.isArray(e))return e.map(n=>sx(n));if(typeof e=="function"||e!==Object(e))return e;const t={};return Object.entries(e).forEach(([n,r])=>{const s=n.replace(/([-_][a-z])/gi,a=>a.toUpperCase().replace(/[-_]/g,""));t[s]=sx(r)}),t},tB=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Og=e=>{var t;return e.msg||e.message||e.error_description||(typeof e.error=="string"?e.error:(t=e.error)===null||t===void 0?void 0:t.message)||JSON.stringify(e)},nB=(e,t,n)=>Ce(void 0,void 0,void 0,function*(){const r=yield eB();e instanceof r&&!(n!=null&&n.noResolveJson)?e.json().then(s=>{const a=e.status||500,o=(s==null?void 0:s.statusCode)||a+"";t(new J6(Og(s),a,o))}).catch(s=>{t(new rx(Og(s),s))}):t(new rx(Og(e),e))}),rB=(e,t,n,r)=>{const s={method:e,headers:(t==null?void 0:t.headers)||{}};return e==="GET"||!r?s:(tB(r)?(s.headers=Object.assign({"Content-Type":"application/json"},t==null?void 0:t.headers),s.body=JSON.stringify(r)):s.body=r,t!=null&&t.duplex&&(s.duplex=t.duplex),Object.assign(Object.assign({},s),n))};function Pd(e,t,n,r,s,a){return Ce(this,void 0,void 0,function*(){return new Promise((o,l)=>{e(n,rB(t,r,s,a)).then(c=>{if(!c.ok)throw c;return r!=null&&r.noResolveJson?c:c.json()}).then(c=>o(c)).catch(c=>nB(c,l,r))})})}function sd(e,t,n,r){return Ce(this,void 0,void 0,function*(){return Pd(e,"GET",t,n,r)})}function os(e,t,n,r,s){return Ce(this,void 0,void 0,function*(){return Pd(e,"POST",t,r,s,n)})}function ax(e,t,n,r,s){return Ce(this,void 0,void 0,function*(){return Pd(e,"PUT",t,r,s,n)})}function sB(e,t,n,r){return Ce(this,void 0,void 0,function*(){return Pd(e,"HEAD",t,Object.assign(Object.assign({},n),{noResolveJson:!0}),r)})}function C0(e,t,n,r,s){return Ce(this,void 0,void 0,function*(){return Pd(e,"DELETE",t,r,s,n)})}class aB{constructor(t,n){this.downloadFn=t,this.shouldThrowOnError=n}then(t,n){return this.execute().then(t,n)}execute(){return Ce(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(t){if(this.shouldThrowOnError)throw t;if(Ot(t))return{data:null,error:t};throw t}})}}var dP;class oB{constructor(t,n){this.downloadFn=t,this.shouldThrowOnError=n,this[dP]="BlobDownloadBuilder",this.promise=null}asStream(){return new aB(this.downloadFn,this.shouldThrowOnError)}then(t,n){return this.getPromise().then(t,n)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}execute(){return Ce(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(t){if(this.shouldThrowOnError)throw t;if(Ot(t))return{data:null,error:t};throw t}})}}dP=Symbol.toStringTag;const iB={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},k1={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class lB{constructor(t,n={},r,s){this.shouldThrowOnError=!1,this.url=t,this.headers=n,this.bucketId=r,this.fetch=N0(s)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(t,n,r,s){return Ce(this,void 0,void 0,function*(){try{let a;const o=Object.assign(Object.assign({},k1),s);let l=Object.assign(Object.assign({},this.headers),t==="POST"&&{"x-upsert":String(o.upsert)});const c=o.metadata;typeof Blob<"u"&&r instanceof Blob?(a=new FormData,a.append("cacheControl",o.cacheControl),c&&a.append("metadata",this.encodeMetadata(c)),a.append("",r)):typeof FormData<"u"&&r instanceof FormData?(a=r,a.has("cacheControl")||a.append("cacheControl",o.cacheControl),c&&!a.has("metadata")&&a.append("metadata",this.encodeMetadata(c))):(a=r,l["cache-control"]=`max-age=${o.cacheControl}`,l["content-type"]=o.contentType,c&&(l["x-metadata"]=this.toBase64(this.encodeMetadata(c))),(typeof ReadableStream<"u"&&a instanceof ReadableStream||a&&typeof a=="object"&&"pipe"in a&&typeof a.pipe=="function")&&!o.duplex&&(o.duplex="half")),s!=null&&s.headers&&(l=Object.assign(Object.assign({},l),s.headers));const u=this._removeEmptyFolders(n),d=this._getFinalPath(u),f=yield(t=="PUT"?ax:os)(this.fetch,`${this.url}/object/${d}`,a,Object.assign({headers:l},o!=null&&o.duplex?{duplex:o.duplex}:{}));return{data:{path:u,id:f.Id,fullPath:f.Key},error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Ot(a))return{data:null,error:a};throw a}})}upload(t,n,r){return Ce(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",t,n,r)})}uploadToSignedUrl(t,n,r,s){return Ce(this,void 0,void 0,function*(){const a=this._removeEmptyFolders(t),o=this._getFinalPath(a),l=new URL(this.url+`/object/upload/sign/${o}`);l.searchParams.set("token",n);try{let c;const u=Object.assign({upsert:k1.upsert},s),d=Object.assign(Object.assign({},this.headers),{"x-upsert":String(u.upsert)});typeof Blob<"u"&&r instanceof Blob?(c=new FormData,c.append("cacheControl",u.cacheControl),c.append("",r)):typeof FormData<"u"&&r instanceof FormData?(c=r,c.append("cacheControl",u.cacheControl)):(c=r,d["cache-control"]=`max-age=${u.cacheControl}`,d["content-type"]=u.contentType);const f=yield ax(this.fetch,l.toString(),c,{headers:d});return{data:{path:a,fullPath:f.Key},error:null}}catch(c){if(this.shouldThrowOnError)throw c;if(Ot(c))return{data:null,error:c};throw c}})}createSignedUploadUrl(t,n){return Ce(this,void 0,void 0,function*(){try{let r=this._getFinalPath(t);const s=Object.assign({},this.headers);n!=null&&n.upsert&&(s["x-upsert"]="true");const a=yield os(this.fetch,`${this.url}/object/upload/sign/${r}`,{},{headers:s}),o=new URL(this.url+a.url),l=o.searchParams.get("token");if(!l)throw new E0("No token returned by API");return{data:{signedUrl:o.toString(),path:t,token:l},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Ot(r))return{data:null,error:r};throw r}})}update(t,n,r){return Ce(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",t,n,r)})}move(t,n,r){return Ce(this,void 0,void 0,function*(){try{return{data:yield os(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:t,destinationKey:n,destinationBucket:r==null?void 0:r.destinationBucket},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Ot(s))return{data:null,error:s};throw s}})}copy(t,n,r){return Ce(this,void 0,void 0,function*(){try{return{data:{path:(yield os(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:t,destinationKey:n,destinationBucket:r==null?void 0:r.destinationBucket},{headers:this.headers})).Key},error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Ot(s))return{data:null,error:s};throw s}})}createSignedUrl(t,n,r){return Ce(this,void 0,void 0,function*(){try{let s=this._getFinalPath(t),a=yield os(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:n},r!=null&&r.transform?{transform:r.transform}:{}),{headers:this.headers});const o=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return a={signedUrl:encodeURI(`${this.url}${a.signedURL}${o}`)},{data:a,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Ot(s))return{data:null,error:s};throw s}})}createSignedUrls(t,n,r){return Ce(this,void 0,void 0,function*(){try{const s=yield os(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:n,paths:t},{headers:this.headers}),a=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return{data:s.map(o=>Object.assign(Object.assign({},o),{signedUrl:o.signedURL?encodeURI(`${this.url}${o.signedURL}${a}`):null})),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Ot(s))return{data:null,error:s};throw s}})}download(t,n){const s=typeof(n==null?void 0:n.transform)<"u"?"render/image/authenticated":"object",a=this.transformOptsToQueryString((n==null?void 0:n.transform)||{}),o=a?`?${a}`:"",l=this._getFinalPath(t),c=()=>sd(this.fetch,`${this.url}/${s}/${l}${o}`,{headers:this.headers,noResolveJson:!0});return new oB(c,this.shouldThrowOnError)}info(t){return Ce(this,void 0,void 0,function*(){const n=this._getFinalPath(t);try{const r=yield sd(this.fetch,`${this.url}/object/info/${n}`,{headers:this.headers});return{data:sx(r),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Ot(r))return{data:null,error:r};throw r}})}exists(t){return Ce(this,void 0,void 0,function*(){const n=this._getFinalPath(t);try{return yield sB(this.fetch,`${this.url}/object/${n}`,{headers:this.headers}),{data:!0,error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Ot(r)&&r instanceof rx){const s=r.originalError;if([400,404].includes(s==null?void 0:s.status))return{data:!1,error:r}}throw r}})}getPublicUrl(t,n){const r=this._getFinalPath(t),s=[],a=n!=null&&n.download?`download=${n.download===!0?"":n.download}`:"";a!==""&&s.push(a);const l=typeof(n==null?void 0:n.transform)<"u"?"render/image":"object",c=this.transformOptsToQueryString((n==null?void 0:n.transform)||{});c!==""&&s.push(c);let u=s.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${l}/public/${r}${u}`)}}}remove(t){return Ce(this,void 0,void 0,function*(){try{return{data:yield C0(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:t},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Ot(n))return{data:null,error:n};throw n}})}list(t,n,r){return Ce(this,void 0,void 0,function*(){try{const s=Object.assign(Object.assign(Object.assign({},iB),n),{prefix:t||""});return{data:yield os(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},r),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Ot(s))return{data:null,error:s};throw s}})}listV2(t,n){return Ce(this,void 0,void 0,function*(){try{const r=Object.assign({},t);return{data:yield os(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,r,{headers:this.headers},n),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Ot(r))return{data:null,error:r};throw r}})}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(t){const n=[];return t.width&&n.push(`width=${t.width}`),t.height&&n.push(`height=${t.height}`),t.resize&&n.push(`resize=${t.resize}`),t.format&&n.push(`format=${t.format}`),t.quality&&n.push(`quality=${t.quality}`),n.join("&")}}const fP="2.80.0",hP={"X-Client-Info":`storage-js/${fP}`};class cB{constructor(t,n={},r,s){this.shouldThrowOnError=!1;const a=new URL(t);s!=null&&s.useNewHostname&&/supabase\.(co|in|red)$/.test(a.hostname)&&!a.hostname.includes("storage.supabase.")&&(a.hostname=a.hostname.replace("supabase.","storage.supabase.")),this.url=a.href.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},hP),n),this.fetch=N0(r)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(t){return Ce(this,void 0,void 0,function*(){try{const n=this.listBucketOptionsToQueryString(t);return{data:yield sd(this.fetch,`${this.url}/bucket${n}`,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Ot(n))return{data:null,error:n};throw n}})}getBucket(t){return Ce(this,void 0,void 0,function*(){try{return{data:yield sd(this.fetch,`${this.url}/bucket/${t}`,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Ot(n))return{data:null,error:n};throw n}})}createBucket(t){return Ce(this,arguments,void 0,function*(n,r={public:!1}){try{return{data:yield os(this.fetch,`${this.url}/bucket`,{id:n,name:n,type:r.type,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Ot(s))return{data:null,error:s};throw s}})}updateBucket(t,n){return Ce(this,void 0,void 0,function*(){try{return{data:yield ax(this.fetch,`${this.url}/bucket/${t}`,{id:t,name:t,public:n.public,file_size_limit:n.fileSizeLimit,allowed_mime_types:n.allowedMimeTypes},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Ot(r))return{data:null,error:r};throw r}})}emptyBucket(t){return Ce(this,void 0,void 0,function*(){try{return{data:yield os(this.fetch,`${this.url}/bucket/${t}/empty`,{},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Ot(n))return{data:null,error:n};throw n}})}deleteBucket(t){return Ce(this,void 0,void 0,function*(){try{return{data:yield C0(this.fetch,`${this.url}/bucket/${t}`,{},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Ot(n))return{data:null,error:n};throw n}})}listBucketOptionsToQueryString(t){const n={};return t&&("limit"in t&&(n.limit=String(t.limit)),"offset"in t&&(n.offset=String(t.offset)),t.search&&(n.search=t.search),t.sortColumn&&(n.sortColumn=t.sortColumn),t.sortOrder&&(n.sortOrder=t.sortOrder)),Object.keys(n).length>0?"?"+new URLSearchParams(n).toString():""}}class uB{constructor(t,n={},r){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},hP),n),this.fetch=N0(r)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(t){return Ce(this,void 0,void 0,function*(){try{return{data:yield os(this.fetch,`${this.url}/bucket`,{name:t},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Ot(n))return{data:null,error:n};throw n}})}listBuckets(t){return Ce(this,void 0,void 0,function*(){try{const n=new URLSearchParams;(t==null?void 0:t.limit)!==void 0&&n.set("limit",t.limit.toString()),(t==null?void 0:t.offset)!==void 0&&n.set("offset",t.offset.toString()),t!=null&&t.sortColumn&&n.set("sortColumn",t.sortColumn),t!=null&&t.sortOrder&&n.set("sortOrder",t.sortOrder),t!=null&&t.search&&n.set("search",t.search);const r=n.toString(),s=r?`${this.url}/bucket?${r}`:`${this.url}/bucket`;return{data:yield sd(this.fetch,s,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Ot(n))return{data:null,error:n};throw n}})}deleteBucket(t){return Ce(this,void 0,void 0,function*(){try{return{data:yield C0(this.fetch,`${this.url}/bucket/${t}`,{},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Ot(n))return{data:null,error:n};throw n}})}}const T0={"X-Client-Info":`storage-js/${fP}`,"Content-Type":"application/json"};class mP extends Error{constructor(t){super(t),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function kr(e){return typeof e=="object"&&e!==null&&"__isStorageVectorsError"in e}class Mg extends mP{constructor(t,n,r){super(t),this.name="StorageVectorsApiError",this.status=n,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class dB extends mP{constructor(t,n){super(t),this.name="StorageVectorsUnknownError",this.originalError=n}}var j1;(function(e){e.InternalError="InternalError",e.S3VectorConflictException="S3VectorConflictException",e.S3VectorNotFoundException="S3VectorNotFoundException",e.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",e.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",e.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(j1||(j1={}));const P0=e=>e?(...t)=>e(...t):(...t)=>fetch(...t),fB=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},S1=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),hB=(e,t,n)=>Ce(void 0,void 0,void 0,function*(){if(e&&typeof e=="object"&&"status"in e&&"ok"in e&&typeof e.status=="number"&&!(n!=null&&n.noResolveJson)){const s=e.status||500,a=e;if(typeof a.json=="function")a.json().then(o=>{const l=(o==null?void 0:o.statusCode)||(o==null?void 0:o.code)||s+"";t(new Mg(S1(o),s,l))}).catch(()=>{const o=s+"",l=a.statusText||`HTTP ${s} error`;t(new Mg(l,s,o))});else{const o=s+"",l=a.statusText||`HTTP ${s} error`;t(new Mg(l,s,o))}}else t(new dB(S1(e),e))}),mB=(e,t,n,r)=>{const s={method:e,headers:(t==null?void 0:t.headers)||{}};return r?(fB(r)?(s.headers=Object.assign({"Content-Type":"application/json"},t==null?void 0:t.headers),s.body=JSON.stringify(r)):s.body=r,Object.assign(Object.assign({},s),n)):s};function pB(e,t,n,r,s,a){return Ce(this,void 0,void 0,function*(){return new Promise((o,l)=>{e(n,mB(t,r,s,a)).then(c=>{if(!c.ok)throw c;if(r!=null&&r.noResolveJson)return c;const u=c.headers.get("content-type");return!u||!u.includes("application/json")?{}:c.json()}).then(c=>o(c)).catch(c=>hB(c,l,r))})})}function jr(e,t,n,r,s){return Ce(this,void 0,void 0,function*(){return pB(e,"POST",t,r,s,n)})}class gB{constructor(t,n={},r){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},T0),n),this.fetch=P0(r)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(t){return Ce(this,void 0,void 0,function*(){try{return{data:(yield jr(this.fetch,`${this.url}/CreateIndex`,t,{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(kr(n))return{data:null,error:n};throw n}})}getIndex(t,n){return Ce(this,void 0,void 0,function*(){try{return{data:yield jr(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:t,indexName:n},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(kr(r))return{data:null,error:r};throw r}})}listIndexes(t){return Ce(this,void 0,void 0,function*(){try{return{data:yield jr(this.fetch,`${this.url}/ListIndexes`,t,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(kr(n))return{data:null,error:n};throw n}})}deleteIndex(t,n){return Ce(this,void 0,void 0,function*(){try{return{data:(yield jr(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:t,indexName:n},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(kr(r))return{data:null,error:r};throw r}})}}class yB{constructor(t,n={},r){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},T0),n),this.fetch=P0(r)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(t){return Ce(this,void 0,void 0,function*(){try{if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return{data:(yield jr(this.fetch,`${this.url}/PutVectors`,t,{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(kr(n))return{data:null,error:n};throw n}})}getVectors(t){return Ce(this,void 0,void 0,function*(){try{return{data:yield jr(this.fetch,`${this.url}/GetVectors`,t,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(kr(n))return{data:null,error:n};throw n}})}listVectors(t){return Ce(this,void 0,void 0,function*(){try{if(t.segmentCount!==void 0){if(t.segmentCount<1||t.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(t.segmentIndex!==void 0&&(t.segmentIndex<0||t.segmentIndex>=t.segmentCount))throw new Error(`segmentIndex must be between 0 and ${t.segmentCount-1}`)}return{data:yield jr(this.fetch,`${this.url}/ListVectors`,t,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(kr(n))return{data:null,error:n};throw n}})}queryVectors(t){return Ce(this,void 0,void 0,function*(){try{return{data:yield jr(this.fetch,`${this.url}/QueryVectors`,t,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(kr(n))return{data:null,error:n};throw n}})}deleteVectors(t){return Ce(this,void 0,void 0,function*(){try{if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return{data:(yield jr(this.fetch,`${this.url}/DeleteVectors`,t,{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(kr(n))return{data:null,error:n};throw n}})}}class vB{constructor(t,n={},r){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},T0),n),this.fetch=P0(r)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(t){return Ce(this,void 0,void 0,function*(){try{return{data:(yield jr(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(kr(n))return{data:null,error:n};throw n}})}getBucket(t){return Ce(this,void 0,void 0,function*(){try{return{data:yield jr(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:t},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(kr(n))return{data:null,error:n};throw n}})}listBuckets(){return Ce(this,arguments,void 0,function*(t={}){try{return{data:yield jr(this.fetch,`${this.url}/ListVectorBuckets`,t,{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(kr(n))return{data:null,error:n};throw n}})}deleteBucket(t){return Ce(this,void 0,void 0,function*(){try{return{data:(yield jr(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(kr(n))return{data:null,error:n};throw n}})}}class xB extends vB{constructor(t,n={}){super(t,n.headers||{},n.fetch)}from(t){return new wB(this.url,this.headers,t,this.fetch)}}class wB extends gB{constructor(t,n,r,s){super(t,n,s),this.vectorBucketName=r}createIndex(t){const n=Object.create(null,{createIndex:{get:()=>super.createIndex}});return Ce(this,void 0,void 0,function*(){return n.createIndex.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName}))})}listIndexes(){const t=Object.create(null,{listIndexes:{get:()=>super.listIndexes}});return Ce(this,arguments,void 0,function*(n={}){return t.listIndexes.call(this,Object.assign(Object.assign({},n),{vectorBucketName:this.vectorBucketName}))})}getIndex(t){const n=Object.create(null,{getIndex:{get:()=>super.getIndex}});return Ce(this,void 0,void 0,function*(){return n.getIndex.call(this,this.vectorBucketName,t)})}deleteIndex(t){const n=Object.create(null,{deleteIndex:{get:()=>super.deleteIndex}});return Ce(this,void 0,void 0,function*(){return n.deleteIndex.call(this,this.vectorBucketName,t)})}index(t){return new bB(this.url,this.headers,this.vectorBucketName,t,this.fetch)}}class bB extends yB{constructor(t,n,r,s,a){super(t,n,a),this.vectorBucketName=r,this.indexName=s}putVectors(t){const n=Object.create(null,{putVectors:{get:()=>super.putVectors}});return Ce(this,void 0,void 0,function*(){return n.putVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}getVectors(t){const n=Object.create(null,{getVectors:{get:()=>super.getVectors}});return Ce(this,void 0,void 0,function*(){return n.getVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}listVectors(){const t=Object.create(null,{listVectors:{get:()=>super.listVectors}});return Ce(this,arguments,void 0,function*(n={}){return t.listVectors.call(this,Object.assign(Object.assign({},n),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}queryVectors(t){const n=Object.create(null,{queryVectors:{get:()=>super.queryVectors}});return Ce(this,void 0,void 0,function*(){return n.queryVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}deleteVectors(t){const n=Object.create(null,{deleteVectors:{get:()=>super.deleteVectors}});return Ce(this,void 0,void 0,function*(){return n.deleteVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class _B extends cB{constructor(t,n={},r,s){super(t,n,r,s)}from(t){return new lB(this.url,this.headers,t,this.fetch)}get vectors(){return new xB(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new uB(this.url+"/iceberg",this.headers,this.fetch)}}const kB="2.80.0";let uu="";typeof Deno<"u"?uu="deno":typeof document<"u"?uu="web":typeof navigator<"u"&&navigator.product==="ReactNative"?uu="react-native":uu="node";const jB={"X-Client-Info":`supabase-js-${uu}/${kB}`},SB={headers:jB},EB={schema:"public"},NB={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},CB={},TB=e=>e?(...t)=>e(...t):(...t)=>fetch(...t),PB=()=>Headers,AB=(e,t,n)=>{const r=TB(n),s=PB();return async(a,o)=>{var l;const c=(l=await t())!==null&&l!==void 0?l:e;let u=new s(o==null?void 0:o.headers);return u.has("apikey")||u.set("apikey",e),u.has("Authorization")||u.set("Authorization",`Bearer ${c}`),r(a,Object.assign(Object.assign({},o),{headers:u}))}};function RB(e){return e.endsWith("/")?e:e+"/"}function OB(e,t){var n,r;const{db:s,auth:a,realtime:o,global:l}=e,{db:c,auth:u,realtime:d,global:f}=t,h={db:Object.assign(Object.assign({},c),s),auth:Object.assign(Object.assign({},u),a),realtime:Object.assign(Object.assign({},d),o),storage:{},global:Object.assign(Object.assign(Object.assign({},f),l),{headers:Object.assign(Object.assign({},(n=f==null?void 0:f.headers)!==null&&n!==void 0?n:{}),(r=l==null?void 0:l.headers)!==null&&r!==void 0?r:{})}),accessToken:async()=>""};return e.accessToken?h.accessToken=e.accessToken:delete h.accessToken,h}function MB(e){const t=e==null?void 0:e.trim();if(!t)throw new Error("supabaseUrl is required.");if(!t.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(RB(t))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const pP="2.80.0",nl=30*1e3,ox=3,Dg=ox*nl,DB="http://localhost:9999",IB="supabase.auth.token",LB={"X-Client-Info":`gotrue-js/${pP}`},ix="X-Supabase-Api-Version",gP={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},$B=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,FB=10*60*1e3;class ad extends Error{constructor(t,n,r){super(t),this.__isAuthError=!0,this.name="AuthError",this.status=n,this.code=r}}function Pe(e){return typeof e=="object"&&e!==null&&"__isAuthError"in e}class zB extends ad{constructor(t,n,r){super(t,n,r),this.name="AuthApiError",this.status=n,this.code=r}}function BB(e){return Pe(e)&&e.name==="AuthApiError"}class Ho extends ad{constructor(t,n){super(t),this.name="AuthUnknownError",this.originalError=n}}class Ao extends ad{constructor(t,n,r,s){super(t,r,s),this.name=n,this.status=r}}class ns extends Ao{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function UB(e){return Pe(e)&&e.name==="AuthSessionMissingError"}class Fi extends Ao{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Af extends Ao{constructor(t){super(t,"AuthInvalidCredentialsError",400,void 0)}}class Rf extends Ao{constructor(t,n=null){super(t,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function VB(e){return Pe(e)&&e.name==="AuthImplicitGrantRedirectError"}class E1 extends Ao{constructor(t,n=null){super(t,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class lx extends Ao{constructor(t,n){super(t,"AuthRetryableFetchError",n,void 0)}}function Ig(e){return Pe(e)&&e.name==="AuthRetryableFetchError"}class N1 extends Ao{constructor(t,n,r){super(t,"AuthWeakPasswordError",n,"weak_password"),this.reasons=r}}class cx extends Ao{constructor(t){super(t,"AuthInvalidJwtError",400,"invalid_jwt")}}const rm="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),C1=` \r=`.split(""),WB=(()=>{const e=new Array(128);for(let t=0;t=6;){const r=t.queue>>t.queuedBits-6&63;n(rm[r]),t.queuedBits-=6}else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;){const r=t.queue>>t.queuedBits-6&63;n(rm[r]),t.queuedBits-=6}}function yP(e,t,n){const r=WB[e];if(r>-1)for(t.queue=t.queue<<6|r,t.queuedBits+=6;t.queuedBits>=8;)n(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else{if(r===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}}function P1(e){const t=[],n=o=>{t.push(String.fromCodePoint(o))},r={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},a=o=>{KB(o,r,n)};for(let o=0;o>6),t(128|e&63);return}else if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|e&63);return}else if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|e&63);return}throw new Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}function qB(e,t){for(let n=0;n55295&&r<=56319){const s=(r-55296)*1024&65535;r=(e.charCodeAt(n+1)-56320&65535|s)+65536,n+=1}HB(r,t)}}function KB(e,t,n){if(t.utf8seq===0){if(e<=127){n(e);return}for(let r=1;r<6;r+=1)if(!(e>>7-r&1)){t.utf8seq=r;break}if(t.utf8seq===2)t.codepoint=e&31;else if(t.utf8seq===3)t.codepoint=e&15;else if(t.utf8seq===4)t.codepoint=e&7;else throw new Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw new Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|e&63,t.utf8seq-=1,t.utf8seq===0&&n(t.codepoint)}}function Pl(e){const t=[],n={queue:0,queuedBits:0},r=s=>{t.push(s)};for(let s=0;st.push(n)),new Uint8Array(t)}function Qo(e){const t=[],n={queue:0,queuedBits:0},r=s=>{t.push(s)};return e.forEach(s=>T1(s,n,r)),T1(null,n,r),t.join("")}function YB(e){return Math.round(Date.now()/1e3)+e}function QB(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}const On=()=>typeof window<"u"&&typeof document<"u",Lo={tested:!1,writable:!1},vP=()=>{if(!On())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Lo.tested)return Lo.writable;const e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),Lo.tested=!0,Lo.writable=!0}catch{Lo.tested=!0,Lo.writable=!1}return Lo.writable};function XB(e){const t={},n=new URL(e);if(n.hash&&n.hash[0]==="#")try{new URLSearchParams(n.hash.substring(1)).forEach((s,a)=>{t[a]=s})}catch{}return n.searchParams.forEach((r,s)=>{t[s]=r}),t}const xP=e=>e?(...t)=>e(...t):(...t)=>fetch(...t),ZB=e=>typeof e=="object"&&e!==null&&"status"in e&&"ok"in e&&"json"in e&&typeof e.json=="function",rl=async(e,t,n)=>{await e.setItem(t,JSON.stringify(n))},$o=async(e,t)=>{const n=await e.getItem(t);if(!n)return null;try{return JSON.parse(n)}catch{return n}},Aa=async(e,t)=>{await e.removeItem(t)};class ap{constructor(){this.promise=new ap.promiseConstructor((t,n)=>{this.resolve=t,this.reject=n})}}ap.promiseConstructor=Promise;function Lg(e){const t=e.split(".");if(t.length!==3)throw new cx("Invalid JWT structure");for(let r=0;r{setTimeout(()=>t(null),e)})}function e8(e,t){return new Promise((r,s)=>{(async()=>{for(let a=0;a<1/0;a++)try{const o=await e(a);if(!t(a,null,o)){r(o);return}}catch(o){if(!t(a,o)){s(o);return}}})()})}function t8(e){return("0"+e.toString(16)).substr(-2)}function n8(){const t=new Uint32Array(56);if(typeof crypto>"u"){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=n.length;let s="";for(let a=0;a<56;a++)s+=n.charAt(Math.floor(Math.random()*r));return s}return crypto.getRandomValues(t),Array.from(t,t8).join("")}async function r8(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n),s=new Uint8Array(r);return Array.from(s).map(a=>String.fromCharCode(a)).join("")}async function s8(e){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."),e;const n=await r8(e);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function zi(e,t,n=!1){const r=n8();let s=r;n&&(s+="/PASSWORD_RECOVERY"),await rl(e,`${t}-code-verifier`,s);const a=await s8(r);return[a,r===a?"plain":"s256"]}const a8=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function o8(e){const t=e.headers.get(ix);if(!t||!t.match(a8))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch{return null}}function i8(e){if(!e)throw new Error("Missing exp claim");const t=Math.floor(Date.now()/1e3);if(e<=t)throw new Error("JWT has expired")}function l8(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const c8=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Bi(e){if(!c8.test(e))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function $g(){const e={};return new Proxy(e,{get:(t,n)=>{if(n==="__isUserNotAvailableProxy")return!0;if(typeof n=="symbol"){const r=n.toString();if(r==="Symbol(Symbol.toPrimitive)"||r==="Symbol(Symbol.toStringTag)"||r==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${n}" property of the session object is not supported. Please use getUser() instead.`)},set:(t,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(t,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function u8(e,t){return new Proxy(e,{get:(n,r,s)=>{if(r==="__isInsecureUserWarningProxy")return!0;if(typeof r=="symbol"){const a=r.toString();if(a==="Symbol(Symbol.toPrimitive)"||a==="Symbol(Symbol.toStringTag)"||a==="Symbol(util.inspect.custom)"||a==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(n,r,s)}return!t.value&&typeof r=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),t.value=!0),Reflect.get(n,r,s)}})}function A1(e){return JSON.parse(JSON.stringify(e))}const Bo=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),d8=[502,503,504];async function R1(e){var t;if(!ZB(e))throw new lx(Bo(e),0);if(d8.includes(e.status))throw new lx(Bo(e),e.status);let n;try{n=await e.json()}catch(a){throw new Ho(Bo(a),a)}let r;const s=o8(e);if(s&&s.getTime()>=gP["2024-01-01"].timestamp&&typeof n=="object"&&n&&typeof n.code=="string"?r=n.code:typeof n=="object"&&n&&typeof n.error_code=="string"&&(r=n.error_code),r){if(r==="weak_password")throw new N1(Bo(n),e.status,((t=n.weak_password)===null||t===void 0?void 0:t.reasons)||[]);if(r==="session_not_found")throw new ns}else if(typeof n=="object"&&n&&typeof n.weak_password=="object"&&n.weak_password&&Array.isArray(n.weak_password.reasons)&&n.weak_password.reasons.length&&n.weak_password.reasons.reduce((a,o)=>a&&typeof o=="string",!0))throw new N1(Bo(n),e.status,n.weak_password.reasons);throw new zB(Bo(n),e.status||500,r)}const f8=(e,t,n,r)=>{const s={method:e,headers:(t==null?void 0:t.headers)||{}};return e==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},t==null?void 0:t.headers),s.body=JSON.stringify(r),Object.assign(Object.assign({},s),n))};async function De(e,t,n,r){var s;const a=Object.assign({},r==null?void 0:r.headers);a[ix]||(a[ix]=gP["2024-01-01"].name),r!=null&&r.jwt&&(a.Authorization=`Bearer ${r.jwt}`);const o=(s=r==null?void 0:r.query)!==null&&s!==void 0?s:{};r!=null&&r.redirectTo&&(o.redirect_to=r.redirectTo);const l=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",c=await h8(e,t,n+l,{headers:a,noResolveJson:r==null?void 0:r.noResolveJson},{},r==null?void 0:r.body);return r!=null&&r.xform?r==null?void 0:r.xform(c):{data:Object.assign({},c),error:null}}async function h8(e,t,n,r,s,a){const o=f8(t,r,s,a);let l;try{l=await e(n,Object.assign({},o))}catch(c){throw console.error(c),new lx(Bo(c),0)}if(l.ok||await R1(l),r!=null&&r.noResolveJson)return l;try{return await l.json()}catch(c){await R1(c)}}function rs(e){var t;let n=null;g8(e)&&(n=Object.assign({},e),e.expires_at||(n.expires_at=YB(e.expires_in)));const r=(t=e.user)!==null&&t!==void 0?t:e;return{data:{session:n,user:r},error:null}}function O1(e){const t=rs(e);return!t.error&&e.weak_password&&typeof e.weak_password=="object"&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&typeof e.weak_password.message=="string"&&e.weak_password.reasons.reduce((n,r)=>n&&typeof r=="string",!0)&&(t.data.weak_password=e.weak_password),t}function Ba(e){var t;return{data:{user:(t=e.user)!==null&&t!==void 0?t:e},error:null}}function m8(e){return{data:e,error:null}}function p8(e){const{action_link:t,email_otp:n,hashed_token:r,redirect_to:s,verification_type:a}=e,o=Po(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),l={action_link:t,email_otp:n,hashed_token:r,redirect_to:s,verification_type:a},c=Object.assign({},o);return{data:{properties:l,user:c},error:null}}function M1(e){return e}function g8(e){return e.access_token&&e.refresh_token&&e.expires_in}const Fg=["global","local","others"];class y8{constructor({url:t="",headers:n={},fetch:r}){this.url=t,this.headers=n,this.fetch=xP(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(t,n=Fg[0]){if(Fg.indexOf(n)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${Fg.join(", ")}`);try{return await De(this.fetch,"POST",`${this.url}/logout?scope=${n}`,{headers:this.headers,jwt:t,noResolveJson:!0}),{data:null,error:null}}catch(r){if(Pe(r))return{data:null,error:r};throw r}}async inviteUserByEmail(t,n={}){try{return await De(this.fetch,"POST",`${this.url}/invite`,{body:{email:t,data:n.data},headers:this.headers,redirectTo:n.redirectTo,xform:Ba})}catch(r){if(Pe(r))return{data:{user:null},error:r};throw r}}async generateLink(t){try{const{options:n}=t,r=Po(t,["options"]),s=Object.assign(Object.assign({},r),n);return"newEmail"in r&&(s.new_email=r==null?void 0:r.newEmail,delete s.newEmail),await De(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:p8,redirectTo:n==null?void 0:n.redirectTo})}catch(n){if(Pe(n))return{data:{properties:null,user:null},error:n};throw n}}async createUser(t){try{return await De(this.fetch,"POST",`${this.url}/admin/users`,{body:t,headers:this.headers,xform:Ba})}catch(n){if(Pe(n))return{data:{user:null},error:n};throw n}}async listUsers(t){var n,r,s,a,o,l,c;try{const u={nextPage:null,lastPage:0,total:0},d=await De(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=t==null?void 0:t.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(a=(s=t==null?void 0:t.perPage)===null||s===void 0?void 0:s.toString())!==null&&a!==void 0?a:""},xform:M1});if(d.error)throw d.error;const f=await d.json(),h=(o=d.headers.get("x-total-count"))!==null&&o!==void 0?o:0,m=(c=(l=d.headers.get("link"))===null||l===void 0?void 0:l.split(","))!==null&&c!==void 0?c:[];return m.length>0&&(m.forEach(v=>{const w=parseInt(v.split(";")[0].split("=")[1].substring(0,1)),y=JSON.parse(v.split(";")[1].split("=")[1]);u[`${y}Page`]=w}),u.total=parseInt(h)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Pe(u))return{data:{users:[]},error:u};throw u}}async getUserById(t){Bi(t);try{return await De(this.fetch,"GET",`${this.url}/admin/users/${t}`,{headers:this.headers,xform:Ba})}catch(n){if(Pe(n))return{data:{user:null},error:n};throw n}}async updateUserById(t,n){Bi(t);try{return await De(this.fetch,"PUT",`${this.url}/admin/users/${t}`,{body:n,headers:this.headers,xform:Ba})}catch(r){if(Pe(r))return{data:{user:null},error:r};throw r}}async deleteUser(t,n=!1){Bi(t);try{return await De(this.fetch,"DELETE",`${this.url}/admin/users/${t}`,{headers:this.headers,body:{should_soft_delete:n},xform:Ba})}catch(r){if(Pe(r))return{data:{user:null},error:r};throw r}}async _listFactors(t){Bi(t.userId);try{const{data:n,error:r}=await De(this.fetch,"GET",`${this.url}/admin/users/${t.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:n,error:r}}catch(n){if(Pe(n))return{data:null,error:n};throw n}}async _deleteFactor(t){Bi(t.userId),Bi(t.id);try{return{data:await De(this.fetch,"DELETE",`${this.url}/admin/users/${t.userId}/factors/${t.id}`,{headers:this.headers}),error:null}}catch(n){if(Pe(n))return{data:null,error:n};throw n}}async _listOAuthClients(t){var n,r,s,a,o,l,c;try{const u={nextPage:null,lastPage:0,total:0},d=await De(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=t==null?void 0:t.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(a=(s=t==null?void 0:t.perPage)===null||s===void 0?void 0:s.toString())!==null&&a!==void 0?a:""},xform:M1});if(d.error)throw d.error;const f=await d.json(),h=(o=d.headers.get("x-total-count"))!==null&&o!==void 0?o:0,m=(c=(l=d.headers.get("link"))===null||l===void 0?void 0:l.split(","))!==null&&c!==void 0?c:[];return m.length>0&&(m.forEach(v=>{const w=parseInt(v.split(";")[0].split("=")[1].substring(0,1)),y=JSON.parse(v.split(";")[1].split("=")[1]);u[`${y}Page`]=w}),u.total=parseInt(h)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Pe(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(t){try{return await De(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:t,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Pe(n))return{data:null,error:n};throw n}}async _getOAuthClient(t){try{return await De(this.fetch,"GET",`${this.url}/admin/oauth/clients/${t}`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Pe(n))return{data:null,error:n};throw n}}async _updateOAuthClient(t,n){try{return await De(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${t}`,{body:n,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Pe(r))return{data:null,error:r};throw r}}async _deleteOAuthClient(t){try{return await De(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${t}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Pe(n))return{data:null,error:n};throw n}}async _regenerateOAuthClientSecret(t){try{return await De(this.fetch,"POST",`${this.url}/admin/oauth/clients/${t}/regenerate_secret`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Pe(n))return{data:null,error:n};throw n}}}function D1(e={}){return{getItem:t=>e[t]||null,setItem:(t,n)=>{e[t]=n},removeItem:t=>{delete e[t]}}}const Ui={debug:!!(globalThis&&vP()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class wP extends Error{constructor(t){super(t),this.isAcquireTimeout=!0}}class v8 extends wP{}async function x8(e,t,n){Ui.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);const r=new globalThis.AbortController;return t>0&&setTimeout(()=>{r.abort(),Ui.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,t===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async s=>{if(s){Ui.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,s.name);try{return await n()}finally{Ui.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,s.name)}}else{if(t===0)throw Ui.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new v8(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(Ui.debug)try{const a=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(a,null," "))}catch(a){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",a)}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 n()}}))}function w8(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function bP(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw new Error(`@supabase/auth-js: Address "${e}" is invalid.`);return e.toLowerCase()}function b8(e){return parseInt(e,16)}function _8(e){const t=new TextEncoder().encode(e);return"0x"+Array.from(t,r=>r.toString(16).padStart(2,"0")).join("")}function k8(e){var t;const{chainId:n,domain:r,expirationTime:s,issuedAt:a=new Date,nonce:o,notBefore:l,requestId:c,resources:u,scheme:d,uri:f,version:h}=e;{if(!Number.isInteger(n))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${n}`);if(!r)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(o&&o.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${o}`);if(!f)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(h!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${h}`);if(!((t=e.statement)===null||t===void 0)&&t.includes(` `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${e.statement}`)}const m=bP(e.address),v=d?`${d}://${r}`:r,w=e.statement?`${e.statement} `:"",y=`${v} wants you to sign in with your Ethereum account: ${m} ${w}`;let x=`URI: ${f} Version: ${h} Chain ID: ${n}${o?` Nonce: ${o}`:""} Issued At: ${a.toISOString()}`;if(s&&(x+=` Expiration Time: ${s.toISOString()}`),l&&(x+=` Not Before: ${l.toISOString()}`),c&&(x+=` Request ID: ${c}`),u){let g=` Resources:`;for(const b of u){if(!b||typeof b!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${b}`);g+=` - ${b}`}x+=g}return`${y} ${x}`}class nn extends Error{constructor({message:t,code:n,cause:r,name:s}){var a;super(t,{cause:r}),this.__isWebAuthnError=!0,this.name=(a=s??(r instanceof Error?r.name:void 0))!==null&&a!==void 0?a:"Unknown Error",this.code=n}}class sm extends nn{constructor(t,n){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:n,message:t}),this.name="WebAuthnUnknownError",this.originalError=n}}function j8({error:e,options:t}){var n,r,s;const{publicKey:a}=t;if(!a)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new nn({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if(e.name==="ConstraintError"){if(((n=a.authenticatorSelection)===null||n===void 0?void 0:n.requireResidentKey)===!0)return new nn({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if(t.mediation==="conditional"&&((r=a.authenticatorSelection)===null||r===void 0?void 0:r.userVerification)==="required")return new nn({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});if(((s=a.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new nn({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else{if(e.name==="InvalidStateError")return new nn({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});if(e.name==="NotAllowedError")return new nn({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="NotSupportedError")return a.pubKeyCredParams.filter(l=>l.type==="public-key").length===0?new nn({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}):new nn({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});if(e.name==="SecurityError"){const o=window.location.hostname;if(_P(o)){if(a.rp.id!==o)return new nn({message:`The RP ID "${a.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new nn({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="TypeError"){if(a.user.id.byteLength<1||a.user.id.byteLength>64)return new nn({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if(e.name==="UnknownError")return new nn({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return new nn({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}function S8({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new nn({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if(e.name==="NotAllowedError")return new nn({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="SecurityError"){const r=window.location.hostname;if(_P(r)){if(n.rpId!==r)return new nn({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new nn({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="UnknownError")return new nn({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return new nn({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}class E8{createNewAbortSignal(){if(this.controller){const n=new Error("Cancelling existing WebAuthn API call for new one");n.name="AbortError",this.controller.abort(n)}const t=new AbortController;return this.controller=t,t.signal}cancelCeremony(){if(this.controller){const t=new Error("Manually cancelling existing WebAuthn API call");t.name="AbortError",this.controller.abort(t),this.controller=void 0}}}const N8=new E8;function C8(e){if(!e)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(e);const{challenge:t,user:n,excludeCredentials:r}=e,s=Po(e,["challenge","user","excludeCredentials"]),a=Pl(t).buffer,o=Object.assign(Object.assign({},n),{id:Pl(n.id).buffer}),l=Object.assign(Object.assign({},s),{challenge:a,user:o});if(r&&r.length>0){l.excludeCredentials=new Array(r.length);for(let c=0;c0){a.allowCredentials=new Array(n.length);for(let o=0;os!==null&&typeof s=="object"&&!Array.isArray(s),n=s=>s instanceof ArrayBuffer||ArrayBuffer.isView(s),r={};for(const s of e)if(s)for(const a in s){const o=s[a];if(o!==void 0)if(Array.isArray(o))r[a]=o;else if(n(o))r[a]=o;else if(t(o)){const l=r[a];t(l)?r[a]=am(l,o):r[a]=am(o)}else r[a]=o}return r}function I8(e,t){return am(M8,e,t||{})}function L8(e,t){return am(D8,e,t||{})}class $8{constructor(t){this.client=t,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(t){return this.client.mfa.enroll(Object.assign(Object.assign({},t),{factorType:"webauthn"}))}async _challenge({factorId:t,webauthn:n,friendlyName:r,signal:s},a){try{const{data:o,error:l}=await this.client.mfa.challenge({factorId:t,webauthn:n});if(!o)return{data:null,error:l};const c=s??N8.createNewAbortSignal();if(o.webauthn.type==="create"){const{user:u}=o.webauthn.credential_options.publicKey;u.name||(u.name=`${u.id}:${r}`),u.displayName||(u.displayName=u.name)}switch(o.webauthn.type){case"create":{const u=I8(o.webauthn.credential_options.publicKey,a==null?void 0:a.create),{data:d,error:f}=await R8({publicKey:u,signal:c});return d?{data:{factorId:t,challengeId:o.id,webauthn:{type:o.webauthn.type,credential_response:d}},error:null}:{data:null,error:f}}case"request":{const u=L8(o.webauthn.credential_options.publicKey,a==null?void 0:a.request),{data:d,error:f}=await O8(Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:u,signal:c}));return d?{data:{factorId:t,challengeId:o.id,webauthn:{type:o.webauthn.type,credential_response:d}},error:null}:{data:null,error:f}}}}catch(o){return Pe(o)?{data:null,error:o}:{data:null,error:new Ho("Unexpected error in challenge",o)}}}async _verify({challengeId:t,factorId:n,webauthn:r}){return this.client.mfa.verify({factorId:n,challengeId:t,webauthn:r})}async _authenticate({factorId:t,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:s}},a){if(!n)return{data:null,error:new ad("rpId is required for WebAuthn authentication")};try{if(!I1())return{data:null,error:new Ho("Browser does not support WebAuthn",null)};const{data:o,error:l}=await this.challenge({factorId:t,webauthn:{rpId:n,rpOrigins:r},signal:s},{request:a});if(!o)return{data:null,error:l};const{webauthn:c}=o;return this._verify({factorId:t,challengeId:o.challengeId,webauthn:{type:c.type,rpId:n,rpOrigins:r,credential_response:c.credential_response}})}catch(o){return Pe(o)?{data:null,error:o}:{data:null,error:new Ho("Unexpected error in authenticate",o)}}}async _register({friendlyName:t,rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:s},a){if(!n)return{data:null,error:new ad("rpId is required for WebAuthn registration")};try{if(!I1())return{data:null,error:new Ho("Browser does not support WebAuthn",null)};const{data:o,error:l}=await this._enroll({friendlyName:t});if(!o)return await this.client.mfa.listFactors().then(d=>{var f;return(f=d.data)===null||f===void 0?void 0:f.all.find(h=>h.factor_type==="webauthn"&&h.friendly_name===t&&h.status!=="unverified")}).then(d=>d?this.client.mfa.unenroll({factorId:d==null?void 0:d.id}):void 0),{data:null,error:l};const{data:c,error:u}=await this._challenge({factorId:o.id,friendlyName:o.friendly_name,webauthn:{rpId:n,rpOrigins:r},signal:s},{create:a});return c?this._verify({factorId:o.id,challengeId:c.challengeId,webauthn:{rpId:n,rpOrigins:r,type:c.webauthn.type,credential_response:c.webauthn.credential_response}}):{data:null,error:u}}catch(o){return Pe(o)?{data:null,error:o}:{data:null,error:new Ho("Unexpected error in register",o)}}}}w8();const F8={url:DB,storageKey:IB,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:LB,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1};async function L1(e,t,n){return await n()}const Vi={};class od{get jwks(){var t,n;return(n=(t=Vi[this.storageKey])===null||t===void 0?void 0:t.jwks)!==null&&n!==void 0?n:{keys:[]}}set jwks(t){Vi[this.storageKey]=Object.assign(Object.assign({},Vi[this.storageKey]),{jwks:t})}get jwks_cached_at(){var t,n;return(n=(t=Vi[this.storageKey])===null||t===void 0?void 0:t.cachedAt)!==null&&n!==void 0?n:Number.MIN_SAFE_INTEGER}set jwks_cached_at(t){Vi[this.storageKey]=Object.assign(Object.assign({},Vi[this.storageKey]),{cachedAt:t})}constructor(t){var n,r,s;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const a=Object.assign(Object.assign({},F8),t);if(this.storageKey=a.storageKey,this.instanceID=(n=od.nextInstanceID[this.storageKey])!==null&&n!==void 0?n:0,od.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!a.debug,typeof a.debug=="function"&&(this.logger=a.debug),this.instanceID>0&&On()){const o=`${this._logPrefix()} 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.`;console.warn(o),this.logDebugMessages&&console.trace(o)}if(this.persistSession=a.persistSession,this.autoRefreshToken=a.autoRefreshToken,this.admin=new y8({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=xP(a.fetch),this.lock=a.lock||L1,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,this.throwOnError=a.throwOnError,a.lock?this.lock=a.lock:On()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=x8:this.lock=L1,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new $8(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this)},this.persistSession?(a.storage?this.storage=a.storage:vP()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=D1(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=D1(this.memoryStorage)),On()&&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)}(s=this.broadcastChannel)===null||s===void 0||s.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()}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(t){if(this.throwOnError&&t&&t.error)throw t.error;return t}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${pP}) ${new Date().toISOString()}`}_debug(...t){return this.logDebugMessages&&this.logger(this._logPrefix(),...t),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 t;try{let n={},r="none";if(On()&&(n=XB(window.location.href),this._isImplicitGrantCallback(n)?r="implicit":await this._isPKCECallback(n)&&(r="pkce")),On()&&this.detectSessionInUrl&&r!=="none"){const{data:s,error:a}=await this._getSessionFromURL(n,r);if(a){if(this._debug("#_initialize()","error detecting session from URL",a),VB(a)){const c=(t=a.details)===null||t===void 0?void 0:t.code;if(c==="identity_already_exists"||c==="identity_not_found"||c==="single_identity_not_deletable")return{error:a}}return await this._removeSession(),{error:a}}const{session:o,redirectType:l}=s;return this._debug("#_initialize()","detected session in URL",o,"redirect type",l),await this._saveSession(o),setTimeout(async()=>{l==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(n){return Pe(n)?this._returnResult({error:n}):this._returnResult({error:new Ho("Unexpected error during initialization",n)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(t){var n,r,s;try{const a=await De(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(n=t==null?void 0:t.options)===null||n===void 0?void 0:n.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(s=t==null?void 0:t.options)===null||s===void 0?void 0:s.captchaToken}},xform:rs}),{data:o,error:l}=a;if(l||!o)return this._returnResult({data:{user:null,session:null},error:l});const c=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",c)),this._returnResult({data:{user:u,session:c},error:null})}catch(a){if(Pe(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async signUp(t){var n,r,s;try{let a;if("email"in t){const{email:d,password:f,options:h}=t;let m=null,v=null;this.flowType==="pkce"&&([m,v]=await zi(this.storage,this.storageKey)),a=await De(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:h==null?void 0:h.emailRedirectTo,body:{email:d,password:f,data:(n=h==null?void 0:h.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken},code_challenge:m,code_challenge_method:v},xform:rs})}else if("phone"in t){const{phone:d,password:f,options:h}=t;a=await De(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:d,password:f,data:(r=h==null?void 0:h.data)!==null&&r!==void 0?r:{},channel:(s=h==null?void 0:h.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:rs})}else throw new Af("You must provide either an email or phone number and a password");const{data:o,error:l}=a;if(l||!o)return this._returnResult({data:{user:null,session:null},error:l});const c=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",c)),this._returnResult({data:{user:u,session:c},error:null})}catch(a){if(Pe(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async signInWithPassword(t){try{let n;if("email"in t){const{email:a,password:o,options:l}=t;n=await De(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:a,password:o,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:O1})}else if("phone"in t){const{phone:a,password:o,options:l}=t;n=await De(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:a,password:o,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:O1})}else throw new Af("You must provide either an email or phone number and a password");const{data:r,error:s}=n;if(s)return this._returnResult({data:{user:null,session:null},error:s});if(!r||!r.session||!r.user){const a=new Fi;return this._returnResult({data:{user:null,session:null},error:a})}return r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:s})}catch(n){if(Pe(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithOAuth(t){var n,r,s,a;return await this._handleProviderSignIn(t.provider,{redirectTo:(n=t.options)===null||n===void 0?void 0:n.redirectTo,scopes:(r=t.options)===null||r===void 0?void 0:r.scopes,queryParams:(s=t.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(a=t.options)===null||a===void 0?void 0:a.skipBrowserRedirect})}async exchangeCodeForSession(t){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(t))}async signInWithWeb3(t){const{chain:n}=t;switch(n){case"ethereum":return await this.signInWithEthereum(t);case"solana":return await this.signInWithSolana(t);default:throw new Error(`@supabase/auth-js: Unsupported chain "${n}"`)}}async signInWithEthereum(t){var n,r,s,a,o,l,c,u,d,f,h;let m,v;if("message"in t)m=t.message,v=t.signature;else{const{chain:w,wallet:y,statement:x,options:g}=t;let b;if(On())if(typeof y=="object")b=y;else{const N=window;if("ethereum"in N&&typeof N.ethereum=="object"&&"request"in N.ethereum&&typeof N.ethereum.request=="function")b=N.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof y!="object"||!(g!=null&&g.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");b=y}const _=new URL((n=g==null?void 0:g.url)!==null&&n!==void 0?n:window.location.href),j=await b.request({method:"eth_requestAccounts"}).then(N=>N).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!j||j.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const k=bP(j[0]);let S=(r=g==null?void 0:g.signInWithEthereum)===null||r===void 0?void 0:r.chainId;if(!S){const N=await b.request({method:"eth_chainId"});S=b8(N)}const E={domain:_.host,address:k,statement:x,uri:_.href,version:"1",chainId:S,nonce:(s=g==null?void 0:g.signInWithEthereum)===null||s===void 0?void 0:s.nonce,issuedAt:(o=(a=g==null?void 0:g.signInWithEthereum)===null||a===void 0?void 0:a.issuedAt)!==null&&o!==void 0?o:new Date,expirationTime:(l=g==null?void 0:g.signInWithEthereum)===null||l===void 0?void 0:l.expirationTime,notBefore:(c=g==null?void 0:g.signInWithEthereum)===null||c===void 0?void 0:c.notBefore,requestId:(u=g==null?void 0:g.signInWithEthereum)===null||u===void 0?void 0:u.requestId,resources:(d=g==null?void 0:g.signInWithEthereum)===null||d===void 0?void 0:d.resources};m=k8(E),v=await b.request({method:"personal_sign",params:[_8(m),k]})}try{const{data:w,error:y}=await De(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:m,signature:v},!((f=t.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(h=t.options)===null||h===void 0?void 0:h.captchaToken}}:null),xform:rs});if(y)throw y;if(!w||!w.session||!w.user){const x=new Fi;return this._returnResult({data:{user:null,session:null},error:x})}return w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),this._returnResult({data:Object.assign({},w),error:y})}catch(w){if(Pe(w))return this._returnResult({data:{user:null,session:null},error:w});throw w}}async signInWithSolana(t){var n,r,s,a,o,l,c,u,d,f,h,m;let v,w;if("message"in t)v=t.message,w=t.signature;else{const{chain:y,wallet:x,statement:g,options:b}=t;let _;if(On())if(typeof x=="object")_=x;else{const k=window;if("solana"in k&&typeof k.solana=="object"&&("signIn"in k.solana&&typeof k.solana.signIn=="function"||"signMessage"in k.solana&&typeof k.solana.signMessage=="function"))_=k.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof x!="object"||!(b!=null&&b.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");_=x}const j=new URL((n=b==null?void 0:b.url)!==null&&n!==void 0?n:window.location.href);if("signIn"in _&&_.signIn){const k=await _.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},b==null?void 0:b.signInWithSolana),{version:"1",domain:j.host,uri:j.href}),g?{statement:g}:null));let S;if(Array.isArray(k)&&k[0]&&typeof k[0]=="object")S=k[0];else if(k&&typeof k=="object"&&"signedMessage"in k&&"signature"in k)S=k;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in S&&"signature"in S&&(typeof S.signedMessage=="string"||S.signedMessage instanceof Uint8Array)&&S.signature instanceof Uint8Array)v=typeof S.signedMessage=="string"?S.signedMessage:new TextDecoder().decode(S.signedMessage),w=S.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in _)||typeof _.signMessage!="function"||!("publicKey"in _)||typeof _!="object"||!_.publicKey||!("toBase58"in _.publicKey)||typeof _.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");v=[`${j.host} wants you to sign in with your Solana account:`,_.publicKey.toBase58(),...g?["",g,""]:[""],"Version: 1",`URI: ${j.href}`,`Issued At: ${(s=(r=b==null?void 0:b.signInWithSolana)===null||r===void 0?void 0:r.issuedAt)!==null&&s!==void 0?s:new Date().toISOString()}`,...!((a=b==null?void 0:b.signInWithSolana)===null||a===void 0)&&a.notBefore?[`Not Before: ${b.signInWithSolana.notBefore}`]:[],...!((o=b==null?void 0:b.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${b.signInWithSolana.expirationTime}`]:[],...!((l=b==null?void 0:b.signInWithSolana)===null||l===void 0)&&l.chainId?[`Chain ID: ${b.signInWithSolana.chainId}`]:[],...!((c=b==null?void 0:b.signInWithSolana)===null||c===void 0)&&c.nonce?[`Nonce: ${b.signInWithSolana.nonce}`]:[],...!((u=b==null?void 0:b.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${b.signInWithSolana.requestId}`]:[],...!((f=(d=b==null?void 0:b.signInWithSolana)===null||d===void 0?void 0:d.resources)===null||f===void 0)&&f.length?["Resources",...b.signInWithSolana.resources.map(S=>`- ${S}`)]:[]].join(` `);const k=await _.signMessage(new TextEncoder().encode(v),"utf8");if(!k||!(k instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");w=k}}try{const{data:y,error:x}=await De(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:v,signature:Qo(w)},!((h=t.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(m=t.options)===null||m===void 0?void 0:m.captchaToken}}:null),xform:rs});if(x)throw x;if(!y||!y.session||!y.user){const g=new Fi;return this._returnResult({data:{user:null,session:null},error:g})}return y.session&&(await this._saveSession(y.session),await this._notifyAllSubscribers("SIGNED_IN",y.session)),this._returnResult({data:Object.assign({},y),error:x})}catch(y){if(Pe(y))return this._returnResult({data:{user:null,session:null},error:y});throw y}}async _exchangeCodeForSession(t){const n=await $o(this.storage,`${this.storageKey}-code-verifier`),[r,s]=(n??"").split("/");try{const{data:a,error:o}=await De(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:t,code_verifier:r},xform:rs});if(await Aa(this.storage,`${this.storageKey}-code-verifier`),o)throw o;if(!a||!a.session||!a.user){const l=new Fi;return this._returnResult({data:{user:null,session:null,redirectType:null},error:l})}return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),this._returnResult({data:Object.assign(Object.assign({},a),{redirectType:s??null}),error:o})}catch(a){if(Pe(a))return this._returnResult({data:{user:null,session:null,redirectType:null},error:a});throw a}}async signInWithIdToken(t){try{const{options:n,provider:r,token:s,access_token:a,nonce:o}=t,l=await De(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:a,nonce:o,gotrue_meta_security:{captcha_token:n==null?void 0:n.captchaToken}},xform:rs}),{data:c,error:u}=l;if(u)return this._returnResult({data:{user:null,session:null},error:u});if(!c||!c.session||!c.user){const d=new Fi;return this._returnResult({data:{user:null,session:null},error:d})}return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",c.session)),this._returnResult({data:c,error:u})}catch(n){if(Pe(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithOtp(t){var n,r,s,a,o;try{if("email"in t){const{email:l,options:c}=t;let u=null,d=null;this.flowType==="pkce"&&([u,d]=await zi(this.storage,this.storageKey));const{error:f}=await De(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:l,data:(n=c==null?void 0:c.data)!==null&&n!==void 0?n:{},create_user:(r=c==null?void 0:c.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},code_challenge:u,code_challenge_method:d},redirectTo:c==null?void 0:c.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:f})}if("phone"in t){const{phone:l,options:c}=t,{data:u,error:d}=await De(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:l,data:(s=c==null?void 0:c.data)!==null&&s!==void 0?s:{},create_user:(a=c==null?void 0:c.shouldCreateUser)!==null&&a!==void 0?a:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},channel:(o=c==null?void 0:c.channel)!==null&&o!==void 0?o:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:d})}throw new Af("You must provide either an email or phone number.")}catch(l){if(Pe(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async verifyOtp(t){var n,r;try{let s,a;"options"in t&&(s=(n=t.options)===null||n===void 0?void 0:n.redirectTo,a=(r=t.options)===null||r===void 0?void 0:r.captchaToken);const{data:o,error:l}=await De(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},t),{gotrue_meta_security:{captcha_token:a}}),redirectTo:s,xform:rs});if(l)throw l;if(!o)throw new Error("An error occurred on token verification.");const c=o.session,u=o.user;return c!=null&&c.access_token&&(await this._saveSession(c),await this._notifyAllSubscribers(t.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",c)),this._returnResult({data:{user:u,session:c},error:null})}catch(s){if(Pe(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithSSO(t){var n,r,s;try{let a=null,o=null;this.flowType==="pkce"&&([a,o]=await zi(this.storage,this.storageKey));const l=await De(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in t?{provider_id:t.providerId}:null),"domain"in t?{domain:t.domain}:null),{redirect_to:(r=(n=t.options)===null||n===void 0?void 0:n.redirectTo)!==null&&r!==void 0?r:void 0}),!((s=t==null?void 0:t.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:t.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:o}),headers:this.headers,xform:m8});return this._returnResult(l)}catch(a){if(Pe(a))return this._returnResult({data:null,error:a});throw a}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async t=>{const{data:{session:n},error:r}=t;if(r)throw r;if(!n)throw new ns;const{error:s}=await De(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:n.access_token});return this._returnResult({data:{user:null,session:null},error:s})})}catch(t){if(Pe(t))return this._returnResult({data:{user:null,session:null},error:t});throw t}}async resend(t){try{const n=`${this.url}/resend`;if("email"in t){const{email:r,type:s,options:a}=t,{error:o}=await De(this.fetch,"POST",n,{headers:this.headers,body:{email:r,type:s,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},redirectTo:a==null?void 0:a.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}else if("phone"in t){const{phone:r,type:s,options:a}=t,{data:o,error:l}=await De(this.fetch,"POST",n,{headers:this.headers,body:{phone:r,type:s,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:l})}throw new Af("You must provide either an email or phone number and a type")}catch(n){if(Pe(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async n=>n))}async _acquireLock(t,n){this._debug("#_acquireLock","begin",t);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await r,await n()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,t,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=n();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await r}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(t){this._debug("#_useSession","begin");try{const n=await this.__loadSession();return await t(n)}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 t=null;const n=await $o(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",n),n!==null&&(this._isValidSession(n)?t=n:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!t)return{data:{session:null},error:null};const r=t.expires_at?t.expires_at*1e3-Date.now()await this._getUser()))}async _getUser(t){try{return t?await De(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:t,xform:Ba}):await this._useSession(async n=>{var r,s,a;const{data:o,error:l}=n;if(l)throw l;return!(!((r=o.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new ns}:await De(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(a=(s=o.session)===null||s===void 0?void 0:s.access_token)!==null&&a!==void 0?a:void 0,xform:Ba})})}catch(n){if(Pe(n))return UB(n)&&(await this._removeSession(),await Aa(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:n});throw n}}async updateUser(t,n={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(t,n))}async _updateUser(t,n={}){try{return await this._useSession(async r=>{const{data:s,error:a}=r;if(a)throw a;if(!s.session)throw new ns;const o=s.session;let l=null,c=null;this.flowType==="pkce"&&t.email!=null&&([l,c]=await zi(this.storage,this.storageKey));const{data:u,error:d}=await De(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:n==null?void 0:n.emailRedirectTo,body:Object.assign(Object.assign({},t),{code_challenge:l,code_challenge_method:c}),jwt:o.access_token,xform:Ba});if(d)throw d;return o.user=u.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),this._returnResult({data:{user:o.user},error:null})})}catch(r){if(Pe(r))return this._returnResult({data:{user:null},error:r});throw r}}async setSession(t){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(t))}async _setSession(t){try{if(!t.access_token||!t.refresh_token)throw new ns;const n=Date.now()/1e3;let r=n,s=!0,a=null;const{payload:o}=Lg(t.access_token);if(o.exp&&(r=o.exp,s=r<=n),s){const{data:l,error:c}=await this._callRefreshToken(t.refresh_token);if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!l)return{data:{user:null,session:null},error:null};a=l}else{const{data:l,error:c}=await this._getUser(t.access_token);if(c)throw c;a={access_token:t.access_token,refresh_token:t.refresh_token,user:l.user,token_type:"bearer",expires_in:r-n,expires_at:r},await this._saveSession(a),await this._notifyAllSubscribers("SIGNED_IN",a)}return this._returnResult({data:{user:a.user,session:a},error:null})}catch(n){if(Pe(n))return this._returnResult({data:{session:null,user:null},error:n});throw n}}async refreshSession(t){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(t))}async _refreshSession(t){try{return await this._useSession(async n=>{var r;if(!t){const{data:o,error:l}=n;if(l)throw l;t=(r=o.session)!==null&&r!==void 0?r:void 0}if(!(t!=null&&t.refresh_token))throw new ns;const{data:s,error:a}=await this._callRefreshToken(t.refresh_token);return a?this._returnResult({data:{user:null,session:null},error:a}):s?this._returnResult({data:{user:s.user,session:s},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(n){if(Pe(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async _getSessionFromURL(t,n){try{if(!On())throw new Rf("No browser detected.");if(t.error||t.error_description||t.error_code)throw new Rf(t.error_description||"Error in URL with unspecified error_description",{error:t.error||"unspecified_error",code:t.error_code||"unspecified_code"});switch(n){case"implicit":if(this.flowType==="pkce")throw new E1("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Rf("Not a valid implicit grant flow url.");break;default:}if(n==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!t.code)throw new E1("No code detected.");const{data:g,error:b}=await this._exchangeCodeForSession(t.code);if(b)throw b;const _=new URL(window.location.href);return _.searchParams.delete("code"),window.history.replaceState(window.history.state,"",_.toString()),{data:{session:g.session,redirectType:null},error:null}}const{provider_token:r,provider_refresh_token:s,access_token:a,refresh_token:o,expires_in:l,expires_at:c,token_type:u}=t;if(!a||!l||!o||!u)throw new Rf("No session defined in URL");const d=Math.round(Date.now()/1e3),f=parseInt(l);let h=d+f;c&&(h=parseInt(c));const m=h-d;m*1e3<=nl&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${m}s, should have been closer to ${f}s`);const v=h-f;d-v>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",v,h,d):d-v<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",v,h,d);const{data:w,error:y}=await this._getUser(a);if(y)throw y;const x={provider_token:r,provider_refresh_token:s,access_token:a,expires_in:f,expires_at:h,refresh_token:o,token_type:u,user:w.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:x,redirectType:t.type},error:null})}catch(r){if(Pe(r))return this._returnResult({data:{session:null,redirectType:null},error:r});throw r}}_isImplicitGrantCallback(t){return!!(t.access_token||t.error_description)}async _isPKCECallback(t){const n=await $o(this.storage,`${this.storageKey}-code-verifier`);return!!(t.code&&n)}async signOut(t={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(t))}async _signOut({scope:t}={scope:"global"}){return await this._useSession(async n=>{var r;const{data:s,error:a}=n;if(a)return this._returnResult({error:a});const o=(r=s.session)===null||r===void 0?void 0:r.access_token;if(o){const{error:l}=await this.admin.signOut(o,t);if(l&&!(BB(l)&&(l.status===404||l.status===401||l.status===403)))return this._returnResult({error:l})}return t!=="others"&&(await this._removeSession(),await Aa(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(t){const n=QB(),r={id:n,callback:t,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",n),this.stateChangeEmitters.delete(n)}};return this._debug("#onAuthStateChange()","registered callback with id",n),this.stateChangeEmitters.set(n,r),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(n)})))(),{data:{subscription:r}}}async _emitInitialSession(t){return await this._useSession(async n=>{var r,s;try{const{data:{session:a},error:o}=n;if(o)throw o;await((r=this.stateChangeEmitters.get(t))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",a)),this._debug("INITIAL_SESSION","callback id",t,"session",a)}catch(a){await((s=this.stateChangeEmitters.get(t))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",t,"error",a),console.error(a)}})}async resetPasswordForEmail(t,n={}){let r=null,s=null;this.flowType==="pkce"&&([r,s]=await zi(this.storage,this.storageKey,!0));try{return await De(this.fetch,"POST",`${this.url}/recover`,{body:{email:t,code_challenge:r,code_challenge_method:s,gotrue_meta_security:{captcha_token:n.captchaToken}},headers:this.headers,redirectTo:n.redirectTo})}catch(a){if(Pe(a))return this._returnResult({data:null,error:a});throw a}}async getUserIdentities(){var t;try{const{data:n,error:r}=await this.getUser();if(r)throw r;return this._returnResult({data:{identities:(t=n.user.identities)!==null&&t!==void 0?t:[]},error:null})}catch(n){if(Pe(n))return this._returnResult({data:null,error:n});throw n}}async linkIdentity(t){return"token"in t?this.linkIdentityIdToken(t):this.linkIdentityOAuth(t)}async linkIdentityOAuth(t){var n;try{const{data:r,error:s}=await this._useSession(async a=>{var o,l,c,u,d;const{data:f,error:h}=a;if(h)throw h;const m=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,t.provider,{redirectTo:(o=t.options)===null||o===void 0?void 0:o.redirectTo,scopes:(l=t.options)===null||l===void 0?void 0:l.scopes,queryParams:(c=t.options)===null||c===void 0?void 0:c.queryParams,skipBrowserRedirect:!0});return await De(this.fetch,"GET",m,{headers:this.headers,jwt:(d=(u=f.session)===null||u===void 0?void 0:u.access_token)!==null&&d!==void 0?d:void 0})});if(s)throw s;return On()&&!(!((n=t.options)===null||n===void 0)&&n.skipBrowserRedirect)&&window.location.assign(r==null?void 0:r.url),this._returnResult({data:{provider:t.provider,url:r==null?void 0:r.url},error:null})}catch(r){if(Pe(r))return this._returnResult({data:{provider:t.provider,url:null},error:r});throw r}}async linkIdentityIdToken(t){return await this._useSession(async n=>{var r;try{const{error:s,data:{session:a}}=n;if(s)throw s;const{options:o,provider:l,token:c,access_token:u,nonce:d}=t,f=await De(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(r=a==null?void 0:a.access_token)!==null&&r!==void 0?r:void 0,body:{provider:l,id_token:c,access_token:u,nonce:d,link_identity:!0,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:rs}),{data:h,error:m}=f;return m?this._returnResult({data:{user:null,session:null},error:m}):!h||!h.session||!h.user?this._returnResult({data:{user:null,session:null},error:new Fi}):(h.session&&(await this._saveSession(h.session),await this._notifyAllSubscribers("USER_UPDATED",h.session)),this._returnResult({data:h,error:m}))}catch(s){if(Pe(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}})}async unlinkIdentity(t){try{return await this._useSession(async n=>{var r,s;const{data:a,error:o}=n;if(o)throw o;return await De(this.fetch,"DELETE",`${this.url}/user/identities/${t.identity_id}`,{headers:this.headers,jwt:(s=(r=a.session)===null||r===void 0?void 0:r.access_token)!==null&&s!==void 0?s:void 0})})}catch(n){if(Pe(n))return this._returnResult({data:null,error:n});throw n}}async _refreshAccessToken(t){const n=`#_refreshAccessToken(${t.substring(0,5)}...)`;this._debug(n,"begin");try{const r=Date.now();return await e8(async s=>(s>0&&await JB(200*Math.pow(2,s-1)),this._debug(n,"refreshing attempt",s),await De(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:t},headers:this.headers,xform:rs})),(s,a)=>{const o=200*Math.pow(2,s);return a&&Ig(a)&&Date.now()+o-r{try{await l.callback(t,n)}catch(c){a.push(c)}});if(await Promise.all(o),a.length>0){for(let l=0;lthis._autoRefreshTokenTick(),nl);this.autoRefreshTicker=t,t&&typeof t=="object"&&typeof t.unref=="function"?t.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(t),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const t=this.autoRefreshTicker;this.autoRefreshTicker=null,t&&clearInterval(t)}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 t=Date.now();try{return await this._useSession(async n=>{const{data:{session:r}}=n;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((r.expires_at*1e3-t)/nl);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${nl}ms, refresh threshold is ${ox} ticks`),s<=ox&&await this._callRefreshToken(r.refresh_token)})}catch(n){console.error("Auto refresh tick failed with error. This is likely a transient error.",n)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(t){if(t.isAcquireTimeout||t instanceof wP)this._debug("auto refresh token tick lock not available");else throw t}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!On()||!(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(t){console.error("_handleVisibilityChange",t)}}async _onVisibilityChanged(t){const n=`#_onVisibilityChanged(${t})`;this._debug(n,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),t||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(n,"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(t,n,r){const s=[`provider=${encodeURIComponent(n)}`];if(r!=null&&r.redirectTo&&s.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r!=null&&r.scopes&&s.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[a,o]=await zi(this.storage,this.storageKey),l=new URLSearchParams({code_challenge:`${encodeURIComponent(a)}`,code_challenge_method:`${encodeURIComponent(o)}`});s.push(l.toString())}if(r!=null&&r.queryParams){const a=new URLSearchParams(r.queryParams);s.push(a.toString())}return r!=null&&r.skipBrowserRedirect&&s.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${t}?${s.join("&")}`}async _unenroll(t){try{return await this._useSession(async n=>{var r;const{data:s,error:a}=n;return a?this._returnResult({data:null,error:a}):await De(this.fetch,"DELETE",`${this.url}/factors/${t.factorId}`,{headers:this.headers,jwt:(r=s==null?void 0:s.session)===null||r===void 0?void 0:r.access_token})})}catch(n){if(Pe(n))return this._returnResult({data:null,error:n});throw n}}async _enroll(t){try{return await this._useSession(async n=>{var r,s;const{data:a,error:o}=n;if(o)return this._returnResult({data:null,error:o});const l=Object.assign({friendly_name:t.friendlyName,factor_type:t.factorType},t.factorType==="phone"?{phone:t.phone}:t.factorType==="totp"?{issuer:t.issuer}:{}),{data:c,error:u}=await De(this.fetch,"POST",`${this.url}/factors`,{body:l,headers:this.headers,jwt:(r=a==null?void 0:a.session)===null||r===void 0?void 0:r.access_token});return u?this._returnResult({data:null,error:u}):(t.factorType==="totp"&&c.type==="totp"&&(!((s=c==null?void 0:c.totp)===null||s===void 0)&&s.qr_code)&&(c.totp.qr_code=`data:image/svg+xml;utf-8,${c.totp.qr_code}`),this._returnResult({data:c,error:null}))})}catch(n){if(Pe(n))return this._returnResult({data:null,error:n});throw n}}async _verify(t){return this._acquireLock(-1,async()=>{try{return await this._useSession(async n=>{var r;const{data:s,error:a}=n;if(a)return this._returnResult({data:null,error:a});const o=Object.assign({challenge_id:t.challengeId},"webauthn"in t?{webauthn:Object.assign(Object.assign({},t.webauthn),{credential_response:t.webauthn.type==="create"?P8(t.webauthn.credential_response):A8(t.webauthn.credential_response)})}:{code:t.code}),{data:l,error:c}=await De(this.fetch,"POST",`${this.url}/factors/${t.factorId}/verify`,{body:o,headers:this.headers,jwt:(r=s==null?void 0:s.session)===null||r===void 0?void 0:r.access_token});return c?this._returnResult({data:null,error:c}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+l.expires_in},l)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",l),this._returnResult({data:l,error:c}))})}catch(n){if(Pe(n))return this._returnResult({data:null,error:n});throw n}})}async _challenge(t){return this._acquireLock(-1,async()=>{try{return await this._useSession(async n=>{var r;const{data:s,error:a}=n;if(a)return this._returnResult({data:null,error:a});const o=await De(this.fetch,"POST",`${this.url}/factors/${t.factorId}/challenge`,{body:t,headers:this.headers,jwt:(r=s==null?void 0:s.session)===null||r===void 0?void 0:r.access_token});if(o.error)return o;const{data:l}=o;if(l.type!=="webauthn")return{data:l,error:null};switch(l.webauthn.type){case"create":return{data:Object.assign(Object.assign({},l),{webauthn:Object.assign(Object.assign({},l.webauthn),{credential_options:Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:C8(l.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},l),{webauthn:Object.assign(Object.assign({},l.webauthn),{credential_options:Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:T8(l.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(n){if(Pe(n))return this._returnResult({data:null,error:n});throw n}})}async _challengeAndVerify(t){const{data:n,error:r}=await this._challenge({factorId:t.factorId});return r?this._returnResult({data:null,error:r}):await this._verify({factorId:t.factorId,challengeId:n.id,code:t.code})}async _listFactors(){var t;const{data:{user:n},error:r}=await this.getUser();if(r)return{data:null,error:r};const s={all:[],phone:[],totp:[],webauthn:[]};for(const a of(t=n==null?void 0:n.factors)!==null&&t!==void 0?t:[])s.all.push(a),a.status==="verified"&&s[a.factor_type].push(a);return{data:s,error:null}}async _getAuthenticatorAssuranceLevel(){var t,n;const{data:{session:r},error:s}=await this.getSession();if(s)return this._returnResult({data:null,error:s});if(!r)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:a}=Lg(r.access_token);let o=null;a.aal&&(o=a.aal);let l=o;((n=(t=r.user.factors)===null||t===void 0?void 0:t.filter(d=>d.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(l="aal2");const u=a.amr||[];return{data:{currentLevel:o,nextLevel:l,currentAuthenticationMethods:u},error:null}}async _getAuthorizationDetails(t){try{return await this._useSession(async n=>{const{data:{session:r},error:s}=n;return s?this._returnResult({data:null,error:s}):r?await De(this.fetch,"GET",`${this.url}/oauth/authorizations/${t}`,{headers:this.headers,jwt:r.access_token,xform:a=>({data:a,error:null})}):this._returnResult({data:null,error:new ns})})}catch(n){if(Pe(n))return this._returnResult({data:null,error:n});throw n}}async _approveAuthorization(t,n){try{return await this._useSession(async r=>{const{data:{session:s},error:a}=r;if(a)return this._returnResult({data:null,error:a});if(!s)return this._returnResult({data:null,error:new ns});const o=await De(this.fetch,"POST",`${this.url}/oauth/authorizations/${t}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"approve"},xform:l=>({data:l,error:null})});return o.data&&o.data.redirect_url&&On()&&!(n!=null&&n.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(r){if(Pe(r))return this._returnResult({data:null,error:r});throw r}}async _denyAuthorization(t,n){try{return await this._useSession(async r=>{const{data:{session:s},error:a}=r;if(a)return this._returnResult({data:null,error:a});if(!s)return this._returnResult({data:null,error:new ns});const o=await De(this.fetch,"POST",`${this.url}/oauth/authorizations/${t}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"deny"},xform:l=>({data:l,error:null})});return o.data&&o.data.redirect_url&&On()&&!(n!=null&&n.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(r){if(Pe(r))return this._returnResult({data:null,error:r});throw r}}async fetchJwk(t,n={keys:[]}){let r=n.keys.find(l=>l.kid===t);if(r)return r;const s=Date.now();if(r=this.jwks.keys.find(l=>l.kid===t),r&&this.jwks_cached_at+FB>s)return r;const{data:a,error:o}=await De(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!a.keys||a.keys.length===0||(this.jwks=a,this.jwks_cached_at=s,r=a.keys.find(l=>l.kid===t),!r)?null:r}async getClaims(t,n={}){try{let r=t;if(!r){const{data:m,error:v}=await this.getSession();if(v||!m.session)return this._returnResult({data:null,error:v});r=m.session.access_token}const{header:s,payload:a,signature:o,raw:{header:l,payload:c}}=Lg(r);n!=null&&n.allowExpired||i8(a.exp);const u=!s.alg||s.alg.startsWith("HS")||!s.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(s.kid,n!=null&&n.keys?{keys:n.keys}:n==null?void 0:n.jwks);if(!u){const{error:m}=await this.getUser(r);if(m)throw m;return{data:{claims:a,header:s,signature:o},error:null}}const d=l8(s.alg),f=await crypto.subtle.importKey("jwk",u,d,!0,["verify"]);if(!await crypto.subtle.verify(d,f,o,GB(`${l}.${c}`)))throw new cx("Invalid JWT signature");return{data:{claims:a,header:s,signature:o},error:null}}catch(r){if(Pe(r))return this._returnResult({data:null,error:r});throw r}}}od.nextInstanceID={};const z8=od;class B8 extends z8{constructor(t){super(t)}}class U8{constructor(t,n,r){var s,a,o;this.supabaseUrl=t,this.supabaseKey=n;const l=MB(t);if(!n)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",l),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",l),this.storageUrl=new URL("storage/v1",l),this.functionsUrl=new URL("functions/v1",l);const c=`sb-${l.hostname.split(".")[0]}-auth-token`,u={db:EB,realtime:CB,auth:Object.assign(Object.assign({},NB),{storageKey:c}),global:SB},d=OB(r??{},u);this.storageKey=(s=d.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(a=d.global.headers)!==null&&a!==void 0?a:{},d.accessToken?(this.accessToken=d.accessToken,this.auth=new Proxy({},{get:(f,h)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(h)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((o=d.auth)!==null&&o!==void 0?o:{},this.headers,d.global.fetch),this.fetch=AB(n,this._getAccessToken.bind(this),d.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},d.realtime)),this.rest=new D6(new URL("rest/v1",l).href,{headers:this.headers,schema:d.db.schema,fetch:this.fetch}),this.storage=new _B(this.storageUrl.href,this.headers,this.fetch,r==null?void 0:r.storage),d.accessToken||this._listenForAuthEvents()}get functions(){return new R6(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,n={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,n,r)}channel(t,n={config:{}}){return this.realtime.channel(t,n)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t,n;if(this.accessToken)return await this.accessToken();const{data:r}=await this.auth.getSession();return(n=(t=r.session)===null||t===void 0?void 0:t.access_token)!==null&&n!==void 0?n:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:n,detectSessionInUrl:r,storage:s,userStorage:a,storageKey:o,flowType:l,lock:c,debug:u,throwOnError:d},f,h){const m={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new B8({url:this.authUrl.href,headers:Object.assign(Object.assign({},m),f),storageKey:o,autoRefreshToken:t,persistSession:n,detectSessionInUrl:r,storage:s,userStorage:a,flowType:l,lock:c,debug:u,throwOnError:d,fetch:h,hasCustomAuthorizationHeader:Object.keys(this.headers).some(v=>v.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new Z6(this.realtimeUrl.href,Object.assign(Object.assign({},t),{params:Object.assign({apikey:this.supabaseKey},t==null?void 0:t.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((n,r)=>{this._handleTokenChanged(n,"CLIENT",r==null?void 0:r.access_token)})}_handleTokenChanged(t,n,r){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),n=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const V8=(e,t,n)=>new U8(e,t,n);function W8(){if(typeof window<"u"||typeof process>"u")return!1;const e=process.version;if(e==null)return!1;const t=e.match(/^v(\d+)\./);return t?parseInt(t[1],10)<=18:!1}W8()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const H8="planpilot-auth",sc="kv",q8=1,du=new Map;function K8(){du.clear()}function kP(){return new Promise((e,t)=>{const n=indexedDB.open(H8,q8);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(sc)||r.createObjectStore(sc)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function G8(e,t){const n=await kP();return new Promise((r,s)=>{const l=n.transaction(sc,"readwrite").objectStore(sc).put(t,e);l.onsuccess=()=>r(),l.onerror=()=>s(l.error)})}async function Y8(e){const t=await kP();return new Promise((n,r)=>{const o=t.transaction(sc,"readwrite").objectStore(sc).delete(e);o.onsuccess=()=>n(),o.onerror=()=>r(o.error)})}function zg(){try{const e="__ls_test__";return localStorage.setItem(e,"1"),localStorage.removeItem(e),!0}catch{return!1}}const Q8={getItem(e){const t=du.get(e);if(t)return t;if(zg())try{const n=localStorage.getItem(e);if(n)return du.set(e,n),n}catch{}return null},setItem(e,t){if(du.set(e,t),zg())try{localStorage.setItem(e,t)}catch(n){console.error("[AuthStorage] localStorage write failed:",n)}G8(e,t).catch(()=>{})},removeItem(e){if(du.delete(e),zg())try{localStorage.removeItem(e)}catch{}Y8(e).catch(()=>{})}},X8="https://agcoliuqqeiycdzeiera.supabase.co",Z8="sb_publishable_oKVumtpr-fBxh9Vp_U8mJw_qh6KXUN7",B=V8(X8,Z8,{auth:{storage:Q8,persistSession:!0,autoRefreshToken:!0}}),Al="handtekening",jP="progress";function J8(e){const t=e.checklistTotaal===0||e.checklistAf>=e.checklistTotaal,n=e.fotos+e.fotosInWachtrij,r=[];e.checklistTotaal>0&&r.push({key:"checklist",label:"Checklist",hint:`${e.checklistAf} van ${e.checklistTotaal} afgevinkt`,klaar:t,verplicht:!0}),r.push({key:"fotos",label:"Foto's",hint:n===0?"Minstens één foto van het werk":`${n} toegevoegd`,klaar:n>0,verplicht:!0}),r.push({key:"handtekening",label:"Handtekening",hint:e.heeftHandtekening?"Getekend":"Mag ook zonder",klaar:e.heeftHandtekening,verplicht:!1});const s=r.filter(o=>o.verplicht),a=[];if(e.gegevensOnbekend)return a.push("Gegevens zijn nog niet geladen"),{stappen:r,gedaan:s.filter(o=>o.klaar).length,totaal:s.length,kanAfronden:!1,blokkades:a};if(!t){const o=e.checklistTotaal-e.checklistAf;a.push(o===1?"Er staat nog één checklistregel open":`Er staan nog ${o} checklistregels open`)}return n===0&&a.push("Voeg minstens één foto toe"),e.ontbrekendeVerplichteVelden.length>0&&a.push(`Kantoor moet nog invullen: ${e.ontbrekendeVerplichteVelden.join(", ")}`),{stappen:r,gedaan:s.filter(o=>o.klaar).length,totaal:s.length,kanAfronden:a.length===0,blokkades:a}}const Es=1024*1024,eU={avatar:{maxSizeBytes:5*Es,allowedMimeTypes:["image/jpeg","image/png","image/webp"],allowedExtensions:["jpg","jpeg","png","webp"]},customerPhoto:{maxSizeBytes:8*Es,allowedMimeTypes:["image/jpeg","image/png","image/webp"],allowedExtensions:["jpg","jpeg","png","webp"]},staffPhoto:{maxSizeBytes:8*Es,allowedMimeTypes:["image/jpeg","image/png","image/webp"],allowedExtensions:["jpg","jpeg","png","webp"]},projectPhoto:{maxSizeBytes:10*Es,allowedMimeTypes:["image/jpeg","image/png","image/webp"],allowedExtensions:["jpg","jpeg","png","webp"]},projectDocument:{maxSizeBytes:15*Es,allowedMimeTypes:["application/pdf","image/jpeg","image/png","image/webp","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],allowedExtensions:["pdf","jpg","jpeg","png","webp","doc","docx"]},richTextImage:{maxSizeBytes:5*Es,allowedMimeTypes:["image/jpeg","image/png","image/webp"],allowedExtensions:["jpg","jpeg","png","webp"]},galleryImage:{maxSizeBytes:5*Es,allowedMimeTypes:["image/jpeg","image/png","image/webp","image/avif"],allowedExtensions:["jpg","jpeg","png","webp","avif"]},newsletterImage:{maxSizeBytes:2*Es,allowedMimeTypes:["image/jpeg","image/png"],allowedExtensions:["jpg","jpeg","png"]},intakeUpload:{maxSizeBytes:25*Es,allowedMimeTypes:["image/jpeg","image/png","image/webp","image/heic","image/heif","application/pdf","image/tiff","application/postscript","application/illustrator","application/eps","application/octet-stream",""],allowedExtensions:["jpg","jpeg","png","webp","heic","pdf","tiff","tif","eps","ai"]}},tU=e=>(e.split(".").pop()||"").toLowerCase();function Ad(e,t){const n=eU[t],r=tU(e.name);return n.allowedMimeTypes.includes(e.type)?n.allowedExtensions.includes(r)?e.size>n.maxSizeBytes?{valid:!1,error:`Bestand is te groot (max ${Math.round(n.maxSizeBytes/Es)}MB).`}:{valid:!0}:{valid:!1,error:"Bestandsextensie niet toegestaan."}:{valid:!1,error:"Bestandstype niet toegestaan."}}const nU=["jpg","jpeg","png","webp"],rU=3,sU=15*60*1e3,$1=[5e3,15e3,6e4,5*6e4,sU],aU={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",webp:"image/webp"},F1={"image/jpeg":"jpg","image/jpg":"jpg","image/png":"png","image/webp":"webp"};function A0(e){return[...e].sort((t,n)=>t.createdAt!==n.createdAt?t.createdAt-n.createdAt:t.idn.id?1:0)}function op(e,t){const n=(e??"").trim().toLowerCase().replace(/^\.+/,"");if(nU.includes(n))return n;const r=(t??"").trim().toLowerCase().split(";")[0];return F1[r]?F1[r]:"jpg"}function oU(e){return aU[op(e)]}function iU(e){const t=op(e.ext);return`${e.organizationId}/${e.projectId}/${e.id}.${t}`}function lU(e){const t=Number.isFinite(e)?Math.floor(e):1,n=Math.min(Math.max(t,1),$1.length)-1;return $1[n]}function ux(e,t=Date.now()){return e.nextAttemptAt?e.nextAttemptAt<=t:!0}function cU(e,t){return A0(e.filter(n=>n.projectId===t))}function uU(e,t=Date.now()){let n=0;for(const r of e)r.attemptsn.id!==t.id&&n.projectId===t.projectId&&dU(n.kind))}function hU(e,t=Date.now()){return A0(e).filter(n=>ux(n,t)&&!fU(e,n))}const mU="nexus-afronden-queue",pU=1,_o="items",gU=3e4,yU=5e3,vU="project-photos",xU="nexus-afronden-queue-flush",z1={42501:"Je staat niet meer op deze opdracht. Vraag kantoor om dit op te pakken.",23503:"Deze opdracht bestaat niet meer. Vraag kantoor om dit op te pakken."},wU="23505";class dx extends Error{constructor(t){super(t),this.reden=t,this.name="PermanenteQueueFout"}}class R0 extends Error{constructor(t){super(t),this.melding=t,this.name="TijdelijkeQueueFout"}}const fx=new Set;let gn=[],Bg=!1,id=!1,bi=Rl(),om=null,ld=new Set,Ma={items:gn,flushing:id,online:bi,laatsteAfgekeurd:om,afgekeurdeIds:ld};function bU(){return typeof indexedDB<"u"}function _U(){return typeof window<"u"}function Rl(){return typeof navigator>"u"?!0:navigator.onLine!==!1}function ui(){if(!(Ma.items===gn&&Ma.flushing===id&&Ma.online===bi&&Ma.laatsteAfgekeurd===om&&Ma.afgekeurdeIds===ld)){Ma={items:gn,flushing:id,online:bi,laatsteAfgekeurd:om,afgekeurdeIds:ld};for(const e of fx)try{e(Ma)}catch{}}}function ac(e){gn=A0(e),ui()}let Of=null;function O0(){return bU()?Of||(Of=new Promise(e=>{let t=!1;const n=setTimeout(()=>{console.warn("[AfrondenQueue] IndexedDB opent niet; wachtrij draait alleen in het geheugen"),r(null)},yU),r=s=>{t||(t=!0,clearTimeout(n),e(s))};try{const s=indexedDB.open(mU,pU);s.onupgradeneeded=()=>{const a=s.result;a.objectStoreNames.contains(_o)||a.createObjectStore(_o,{keyPath:"id"})},s.onsuccess=()=>r(s.result),s.onerror=()=>r(null),s.onblocked=()=>r(null)}catch{r(null)}}),Of):Promise.resolve(null)}async function kU(){const e=await O0();return e?new Promise(t=>{const n=r=>{console.warn("[AfrondenQueue] bewaarde wachtrij niet gelezen",{melding:I0(r)}),t([])};try{const r=e.transaction(_o,"readonly"),s=r.objectStore(_o).getAll();s.onsuccess=()=>t(s.result??[]),s.onerror=()=>n(s.error),r.onabort=()=>n(r.error),r.onerror=()=>n(r.error)}catch(r){n(r)}}):[]}async function M0(e){const t=await O0();if(t)return new Promise((n,r)=>{try{const s=t.transaction(_o,"readwrite"),a=s.objectStore(_o).put(e);a.onerror=()=>r(a.error??new Error("idb-put")),s.onabort=()=>r(s.error??new Error("idb-put-abort")),s.onerror=()=>r(s.error??new Error("idb-put-error")),s.oncomplete=()=>n()}catch(s){r(s)}})}async function SP(e){const t=await O0();if(t)return new Promise((n,r)=>{try{const s=t.transaction(_o,"readwrite"),a=s.objectStore(_o).delete(e);a.onerror=()=>r(a.error??new Error("idb-delete")),s.onabort=()=>r(s.error??new Error("idb-delete-abort")),s.onerror=()=>r(s.error??new Error("idb-delete-error")),s.oncomplete=()=>n()}catch(s){r(s)}})}async function ip(e,t){try{await e()}catch(n){console.warn("[AfrondenQueue] lokale opslag bijwerken lukte niet",{waar:t,melding:I0(n)})}}let Ug=null;function D0(){return Ug||(Ug=kU().then(e=>{const t=new Map;for(const n of e)t.set(n.id,n);for(const n of gn)t.set(n.id,n);ac([...t.values()])}).catch(()=>{})),Ug}function I0(e){if(e instanceof R0)return e.melding;if(!Rl())return"Geen verbinding.";const t=e==null?void 0:e.code;if(typeof t=="string"&&/^[A-Za-z0-9_]{1,20}$/.test(t))return`Versturen lukte niet (code ${t}).`;const n=e==null?void 0:e.statusCode;return typeof n=="number"&&Number.isInteger(n)&&n>=100&&n<=599?`Versturen lukte niet (status ${n}).`:typeof n=="string"&&/^[0-9]{3}$/.test(n)?`Versturen lukte niet (status ${n}).`:"Versturen lukte niet."}const jU=/failed to fetch|networkerror|network error|network request failed|fetcherror|load failed|connection|timeout|timed out/i;function SU(e){if(e instanceof R0)return"server";if(!Rl())return"verbinding";const t=e==null?void 0:e.name;if(t==="AbortError"||t==="TimeoutError"||t==="NetworkError")return"verbinding";const n=e==null?void 0:e.code;if(typeof n=="string"&&/^[A-Za-z0-9_]{1,20}$/.test(n))return"server";const r=e==null?void 0:e.statusCode;if(typeof r=="number"||typeof r=="string")return"server";if(e instanceof TypeError)return"verbinding";const s=e==null?void 0:e.message;return typeof s=="string"&&jU.test(s)?"verbinding":"server"}function EU(e){if(e instanceof dx)return e.reden;const t=e==null?void 0:e.code;return typeof t=="string"&&z1[t]?z1[t]:null}async function NU(e){const t=e.blob;if(!t)throw new dx("Het bestand bij deze actie is niet meer beschikbaar.");const n=op(e.ext,t.type),r=iU({...e,ext:n}),s=`${e.id}.${n}`,a=t.type==="image/jpg"?"image/jpeg":t.type,o=new File([t],s,{type:a||oU(n)}),l=Ad(o,"projectPhoto");if(l.valid===!1)throw new dx(l.error);const{error:c}=await B.storage.from(vU).upload(r,o,{upsert:!0});if(c)throw c;const{data:u,error:d}=await B.from("project_photos").select("id").eq("organization_id",e.organizationId).eq("project_id",e.projectId).eq("storage_path",r).limit(1);if(d)throw d;if(u&&u.length>0)return;const{error:f}=await B.from("project_photos").insert({project_id:e.projectId,staff_id:e.staffId,photo_url:"",storage_path:r,photo_type:e.photoType??(e.kind==="handtekening"?Al:jP),description:e.description??null,organization_id:e.organizationId,uploaded_at:new Date(e.createdAt).toISOString()});if(f){if(f.code===wU)return;throw f}}async function CU(e){const{data:t,error:n}=await B.from("projects").update({status:"completed",updated_at:new Date().toISOString()}).eq("id",e.projectId).eq("organization_id",e.organizationId).select("id");if(n)throw n;if(!t||t.length===0)throw new R0("De opdracht kon niet op afgerond gezet worden. Vraag kantoor om dit op te pakken.")}async function B1(e){await ip(()=>SP(e),"verwijderen"),ac(gn.filter(t=>t.id!==e))}async function TU(e,t,n){const r=e.attempts+1,s={...e,attempts:r,lastError:t,lastErrorSoort:n,nextAttemptAt:Date.now()+lU(r)};await ip(()=>M0(s),"pogingen bijwerken"),ac(gn.map(a=>a.id===e.id?s:a))}async function PU(e){try{return e.kind==="afronden"?await CU(e):await NU(e),await B1(e.id),!0}catch(t){const n=EU(t);if(n)return om={id:e.id,kind:e.kind,projectId:e.projectId,reden:n,at:Date.now()},ld=new Set(ld).add(e.id),await B1(e.id),ui(),!0;const r=I0(t),s=SU(t);return console.warn("[AfrondenQueue] item nog niet verstuurd",{kind:e.kind,melding:r,soort:s}),await TU(e,r,s),!1}}let U1=0;function AU(){const e=Math.max(Date.now(),U1+1);return U1=e,e}function RU(){const e=typeof crypto<"u"?crypto:void 0;return e&&typeof e.randomUUID=="function"?e.randomUUID():`q-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}async function OU(e){try{return new Blob([await e.arrayBuffer()],{type:e.type})}catch{throw new Error("Het bestand kon niet gelezen worden.")}}async function Vg(e){await D0();const t=e.blob?await OU(e.blob):void 0;if(e.kind==="handtekening"){const r=gn.filter(s=>s.kind==="handtekening"&&s.projectId===e.projectId);for(const s of r)await ip(()=>SP(s.id),"oude handtekening opruimen");if(r.length>0){const s=new Set(r.map(a=>a.id));ac(gn.filter(a=>!s.has(a.id)))}}const n={id:RU(),kind:e.kind,projectId:e.projectId,organizationId:e.organizationId,staffId:e.staffId,blob:t,ext:t?op(e.ext,t.type):e.ext,photoType:e.photoType??null,description:e.description??null,createdAt:AU(),attempts:0,lastError:null};return await M0(n),ac([...gn,n]),oc(),n.id}function MU(){if(typeof navigator>"u")return;const e=navigator.locks;if(!(!e||typeof e.request!="function"))return e}async function EP(e){if(!Bg){Bg=!0;try{const t=MU();if(!t){await e();return}await t.request(xU,{ifAvailable:!0},async n=>{n&&await e()})}finally{Bg=!1}}}async function oc(){await EP(async()=>{try{if(await D0(),bi=Rl(),ui(),!bi||gn.length===0)return;id=!0,ui();let e=gn.length+2;for(;e>0&&(e-=1,!!Rl());){const t=hU(gn,Date.now());if(t.length===0)break;let n=!1;for(const r of t){if(!gn.some(a=>a.id===r.id))continue;if(await PU(r)&&(n=!0),!Rl())break}if(!n)break}}finally{id=!1,ui()}})}function DU(e){return fx.add(e),()=>{fx.delete(e)}}function V1(){return Ma}let Mf=0,Wg=[];function W1(){bi=!0,ui(),oc()}function H1(){bi=!1,ui()}function q1(){typeof document>"u"||document.visibilityState==="visible"&&oc()}function IU(){if(!_U())return()=>{};if(Mf+=1,Mf===1){window.addEventListener("online",W1),window.addEventListener("offline",H1),typeof document<"u"&&document.addEventListener("visibilitychange",q1);const t=window.setInterval(()=>{gn.length>0&&oc()},gU);Wg=[()=>window.removeEventListener("online",W1),()=>window.removeEventListener("offline",H1),()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",q1)},()=>window.clearInterval(t)],oc()}let e=!1;return()=>{if(!e&&(e=!0,Mf-=1,Mf===0)){for(const t of Wg)t();Wg=[]}}}async function LU(){await D0(),await EP(async()=>{const e=gn.filter(t=>!ux(t,Date.now())).map(t=>t.id);for(const t of e){const n=gn.find(s=>s.id===t);if(!n||ux(n,Date.now()))continue;const r={...n,nextAttemptAt:void 0};await ip(()=>M0(r),"wachttijd wissen"),gn.some(s=>s.id===t)&&ac(gn.map(s=>s.id===t?r:s))}}),await oc()}function NP(e){const t=p.useSyncExternalStore(DU,V1,V1),n=p.useMemo(()=>e?cU(t.items,e):t.items,[t.items,e]),r=p.useMemo(()=>uU(n,Date.now()),[n]);return{items:n,total:r.total,wachtend:r.wachtend,mislukt:r.mislukt,flushing:t.flushing,online:t.online,retry:LU,laatsteAfgekeurd:t.laatsteAfgekeurd??null,afgekeurdeIds:t.afgekeurdeIds}}const CP=new Set(["planner-range-board","planner-day-board","planned-tasks"]),$U=new Set(["tenant_owner","tenant_staff"]),FU=24*60*60*1e3,zU=2e3,L0="nexus-planner-cache",hx="snapshots",K1="laatste-stand";function G1(e){if(e.state.status!=="success")return!1;const t=Array.isArray(e.queryKey)?e.queryKey[0]:void 0;return typeof t=="string"&&CP.has(t)}function BU(e){if(!Array.isArray(e))return!1;const t=e[0];return typeof t=="string"&&CP.has(t)}function UU(e){return Array.isArray(e)&&e.some(t=>typeof t=="string"&&$U.has(t))}function VU(){return new Promise((e,t)=>{const n=indexedDB.open(L0,1);n.onupgradeneeded=()=>{n.result.createObjectStore(hx)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function Hg(e,t){const n=await VU();try{return await new Promise((r,s)=>{const a=n.transaction(hx,e),o=t(a.objectStore(hx));a.oncomplete=()=>r(o.result),a.onerror=()=>s(a.error),a.onabort=()=>s(a.error)})}finally{n.close()}}const WU={async read(){if(typeof indexedDB>"u")return null;const e=await Hg("readonly",n=>n.get(K1));if(!e||typeof e!="object")return null;const t=e;return typeof t.userId!="string"||typeof t.storedAt!="number"||!t.state||!Array.isArray(t.state.queries)?null:t},async write(e){typeof indexedDB>"u"||await Hg("readwrite",t=>t.put(e,K1))},async clear(){typeof indexedDB>"u"||await Hg("readwrite",e=>e.clear())}};function HU(e,t=WU){let n=null,r=!1,s=null,a=!1,o=Promise.resolve();const l=m=>(o=o.then(m,m),o);async function c(m){r||(r=!0,await l(async()=>{try{const v=await t.read();if(!v)return;if(v.userId!==m){await t.clear();return}const w=Math.max(0,...v.state.queries.map(x=>x.state.dataUpdatedAt??0)),y=Date.now()-w;if(y<0||y>FU){await t.clear();return}h6(e,{mutations:[],queries:v.state.queries.filter(x=>BU(x.queryKey))})}catch{}}))}async function u(){const m=n;if(!m)return;const v=e.getQueryData(["user-roles",m]);if(!UU(v))return;const w=f6(e,{shouldDehydrateQuery:y=>{if(!G1(y))return!1;const[x,g]=y.queryKey;return x==="planner-range-board"||x==="planner-day-board"?g===m:!0},shouldDehydrateMutation:()=>!1});w.queries.length!==0&&await l(async()=>{if(n===m)try{await t.write({userId:m,storedAt:Date.now(),state:w})}catch{}})}function d(){s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,u()},zU)}const f=e.getQueryCache().subscribe(m=>{a||!m.query||!G1(m.query)||d()}),{data:h}=B.auth.onAuthStateChange((m,v)=>{var y;if(a)return;if(m==="SIGNED_OUT"){n=null,s!==null&&(clearTimeout(s),s=null),l(()=>t.clear().catch(()=>{}));return}const w=((y=v==null?void 0:v.user)==null?void 0:y.id)??null;w&&(n&&n!==w&&l(()=>t.clear().catch(()=>{})),n=w,c(w))});return()=>{a=!0,s!==null&&clearTimeout(s),f(),h.subscription.unsubscribe()}}async function $0(){if("caches"in window)try{const e=await caches.keys();await Promise.all(e.map(t=>caches.delete(t)))}catch{}try{const e=[];for(let t=0;tlocalStorage.removeItem(t))}catch{}if("indexedDB"in window)for(const e of["planpilot-auth",L0])try{const t=indexedDB.deleteDatabase(e);await new Promise(n=>{t.onsuccess=()=>n(),t.onerror=()=>n(),t.onblocked=()=>n()})}catch{}if("serviceWorker"in navigator)try{const e=await navigator.serviceWorker.getRegistrations();await Promise.all(e.map(t=>t.unregister()))}catch{}window.location.href=window.location.origin+"?reset="+Date.now()}async function F0({mayWipe:e=!0}={}){var r;if(!("serviceWorker"in navigator))return;let t;try{t=await navigator.serviceWorker.getRegistrations()}catch{return}const n=(r=t.find(s=>s.waiting))==null?void 0:r.waiting;if(n){await new Promise(s=>{navigator.serviceWorker.addEventListener("controllerchange",()=>s(),{once:!0}),n.addEventListener("statechange",()=>{(n.state==="activated"||n.state==="redundant")&&s()}),setTimeout(s,5e3),n.postMessage({type:"SKIP_WAITING"})});return}if(e&&navigator.onLine!==!1){if("caches"in window)try{const s=await caches.keys();await Promise.all(s.map(a=>caches.delete(a)))}catch{}try{await Promise.all(t.map(s=>s.unregister()))}catch{}}}async function qU(){if("serviceWorker"in navigator&&navigator.onLine!==!1)try{const e=await navigator.serviceWorker.getRegistrations();if(e.length===0)return;if("caches"in window)try{const t=await caches.keys();await Promise.all(t.map(n=>caches.delete(n)))}catch{}await Promise.all(e.map(t=>t.unregister()))}catch{}}async function TP(){try{K8()}catch{}try{const e=[];for(let t=0;tlocalStorage.removeItem(t))}catch{}if("indexedDB"in window)for(const e of["planpilot-auth",L0])try{await new Promise(t=>{const n=indexedDB.deleteDatabase(e);n.onsuccess=()=>t(),n.onerror=()=>t(),n.onblocked=()=>t()})}catch{}}async function z0(e,t,n){try{await B.rpc("report_app_error",{p_context:e,p_message:t,p_detail:n??null,p_route:typeof window<"u"?window.location.pathname:null,p_app_host:typeof window<"u"?window.location.host:null,p_user_agent:typeof navigator<"u"?navigator.userAgent:null})}catch{}}function mx(e){if(!e)return"Onbekende fout";if(typeof e=="string")return e;if(e instanceof Error)return e.message;if(typeof e=="object"){const t=e,n=[];if(typeof t.name=="string"&&t.name&&n.push(t.name),typeof t.status=="number"&&n.push(`status ${t.status}`),typeof t.message=="string"&&t.message&&n.push(t.message),n.length>0)return n.join(" · ")}return"Onbekende fout"}async function lp(){let e=null;try{const{error:t}=await B.auth.signOut();if(!t)return{ok:!0};e=mx(t)}catch(t){e=mx(t)}try{await TP()}catch{}return z0("uitloggen","Uitloggen bij de server mislukt, sessie lokaal geforceerd gewist",e),{ok:!1,reason:e??"Onbekende fout"}}function B0(){window.location.assign("/auth")}const PP=p.createContext(void 0);function KU({children:e}){const[t,n]=p.useState(null),[r,s]=p.useState(null),[a,o]=p.useState(!0),[l,c]=p.useState(!1),u=Ge(),d=p.useRef(!1),f=p.useRef(!0),h=p.useRef(!0),m=p.useRef(null),v=p.useCallback((g,b)=>{f.current&&(s(g),n((g==null?void 0:g.user)??null),o(!1),h.current=!1,c(!0),m.current&&(clearTimeout(m.current),m.current=null),g&&b.includes("SIGNED_IN")&&(u.invalidateQueries({queryKey:["staff-projects"]}),u.invalidateQueries({queryKey:["current-staff-id"]})))},[u]),w=p.useCallback(async()=>{if(f.current)try{const{data:{session:g},error:b}=await B.auth.getSession();if(b)return;v(g,"refreshSession")}catch(g){console.error("Failed to refresh session:",g)}},[v]),y=p.useCallback(async()=>await lp(),[]);p.useEffect(()=>{f.current=!0,h.current=!0;const{data:{subscription:g}}=B.auth.onAuthStateChange((b,_)=>{setTimeout(()=>{f.current&&(v(_,`onAuthStateChange:${b}`),b==="SIGNED_OUT"&&u.clear())},0)});return d.current||(d.current=!0,B.auth.getSession().then(({data:{session:b},error:_})=>{if(f.current){if(_){o(!1),h.current=!1,c(!0);return}h.current&&v(b,"getSession")}})),m.current=setTimeout(()=>{f.current&&h.current&&(o(!1),h.current=!1,c(!0))},5e3),()=>{f.current=!1,g.unsubscribe(),m.current&&clearTimeout(m.current)}},[]);const x={user:t,session:r,loading:a,initialized:l,signOut:y,refreshSession:w};return i.jsx(PP.Provider,{value:x,children:e})}function Ht(){const e=p.useContext(PP);if(e===void 0)throw new Error("useAuth must be used within an AuthProvider");return e}function GU(){const{user:e}=Ht();return p.useEffect(()=>{if(e)return IU()},[e]),XU(),null}const AP="nexus-afronden-gemelde-afkeuring";function YU(){try{return window.sessionStorage.getItem(AP)}catch{return null}}function QU(e){try{window.sessionStorage.setItem(AP,e)}catch{}}function XU(){const{laatsteAfgekeurd:e}=NP(),t=p.useRef(null);p.useEffect(()=>{if(e&&t.current!==e.id){if(YU()===e.id){t.current=e.id;return}t.current=e.id,QU(e.id),K.error(ZU(e.kind,e.reden))}},[e])}function ZU(e,t){return e==="handtekening"?`De handtekening is niet opgeslagen: ${t}`:e==="photo"?`De foto is niet opgeslagen: ${t}`:`Dit is niet opgeslagen: ${t}`}const Y1=40,Pu=12,U0=1e4,JU=3e4,Df=/^[a-z][a-z0-9_]{0,39}$/,eV=/^[a-z][a-z0-9-]{0,39}$/;function tV(e){let t;try{t=new URL(e,"http://l").pathname}catch{return null}const n=t.match(/^\/rest\/v1\/rpc\/([^/]+)/);if(n)return Df.test(n[1])?`rpc:${n[1]}`:null;const r=t.match(/^\/rest\/v1\/([^/]+)/);if(r)return Df.test(r[1])?r[1]:null;const s=t.match(/^\/functions\/v1\/([^/]+)/);if(s)return Df.test(s[1].replace(/-/g,"_"))?`fn:${s[1]}`:null;const a=t.match(/^\/auth\/v1\/([^/]+)/);return a&&Df.test(a[1])?`auth:${a[1]}`:null}function nV(e,t){const n=t-U0,r=new Map;for(const s of e){if(s.op<=n||s.op>t)continue;const a=tV(s.url);a&&r.set(a,s.op)}return[...r.entries()].sort((s,a)=>s[1]-a[1]).slice(-8).map(([s])=>s)}function px(){return{aantallen:new Array(Pu).fill(0),mislukt:new Array(Pu).fill(0),secondes:new Array(Pu).fill(-1)}}function rV(e,t,n){if(!Number.isFinite(t)||t<0)return;const r=Math.floor(t/1e3),s=r%Pu;e.secondes[s]!==r&&(e.secondes[s]=r,e.aantallen[s]=0,e.mislukt[s]=0),e.aantallen[s]+=1,n&&(e.mislukt[s]+=1)}function sV(e,t){const n=Math.floor((t-U0)/1e3),r=Math.floor(t/1e3);let s=0,a=0;for(let o=0;o=n&&l<=r&&(s+=e.aantallen[o],a+=e.mislukt[o])}return{totaal:s,mislukt:a}}function aV(e,t){if(e===null)return null;const n=t-e;return n<0||n>JU?null:n}function oV(e){let t;try{t=new URLSearchParams(e)}catch{return null}const n=t.get("section")??t.get("tab");return n&&eV.test(n)?n:null}function iV(e){const t=e/6e4;return t<1?`${Math.round(e/1e3)} s`:t<60?`${Math.round(t)} min`:`${(t/60).toFixed(1).replace(".",",")} uur`}function lV(e){return(e/1e3).toFixed(1).replace(".",",")}function cV(e){const t=[],n=[];if(e.sectie&&n.push(`scherm ${e.sectie}`),n.push(`app ${iV(e.paginaOpenMs)} open`),n.push(e.sindsInteractieMs===null?"geen handeling vlak ervoor":`${lV(e.sindsInteractieMs)} s na een handeling`),t.push(n.join(" | ")),e.verkeer.totaal>0){const s=U0/1e3;let a=`${e.verkeer.totaal} verzoeken in de ${s} s ervoor`;e.verkeer.mislukt>0&&(a+=`, waarvan ${e.verkeer.mislukt} mislukt`),t.push(e.labels.length>0?`${a}: ${e.labels.join(", ")}`:a)}const r=[];return e.elementen!==null&&r.push(`${e.elementen} elementen`),e.geheugenMb!==null&&r.push(e.geheugenLimietMb!==null?`geheugen ${e.geheugenMb} van ${e.geheugenLimietMb} MB`:`geheugen ${e.geheugenMb} MB`),r.length>0&&t.push(r.join(" | ")),t.join(` `)}let Uo=[],mh=px(),ph=null,Wi=null;function uV(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():0}function dV(){if(typeof document>"u")return()=>{};Wi==null||Wi(),Uo=[],mh=px(),ph=null;const e=()=>{ph=uV()},t={capture:!0,passive:!0};document.addEventListener("pointerdown",e,t),document.addEventListener("keydown",e,t);let n=null;if(typeof PerformanceObserver<"u")try{n=new PerformanceObserver(s=>{for(const a of s.getEntries()){const o=a.startTime+a.duration,l=a.responseStatus;rV(mh,o,typeof l=="number"&&l>=400),Uo.push({op:o,url:a.name})}Uo.length>Y1&&(Uo=Uo.slice(-Y1))}),n.observe({type:"resource",buffered:!1})}catch{n=null}const r=()=>{Wi===r&&(Wi=null,n==null||n.disconnect(),document.removeEventListener("pointerdown",e,t),document.removeEventListener("keydown",e,t),Uo=[],mh=px(),ph=null)};return Wi=r,r}function fV(){if(typeof performance>"u")return{gebruikt:null,limiet:null};const e=performance.memory;if(!e)return{gebruikt:null,limiet:null};const t=n=>typeof n=="number"&&Number.isFinite(n)?Math.round(n/1048576):null;return{gebruikt:t(e.usedJSHeapSize),limiet:t(e.jsHeapSizeLimit)}}function hV(){if(typeof document>"u")return null;try{return document.getElementsByTagName("*").length}catch{return null}}function mV(e){const t=fV();return{paginaOpenMs:e,sindsInteractieMs:aV(ph,e),labels:nV(Uo,e),verkeer:sV(mh,e),elementen:hV(),geheugenMb:t.gebruikt,geheugenLimietMb:t.limiet,sectie:typeof window<"u"&&typeof window.location<"u"?oV(window.location.search):null}}const pV=3e3,gV=5e3,V0=1e4,yV=12e4,vV=1e4,xV=2e3,wV=5*60*1e3,bV=5,_V=60*60*1e3;function RP(e){return{gestartOp:e,venster:[],meldingen:[]}}function kV(e,t,n,r){return n!==t?RP(r):e}function jV(e){return!Number.isFinite(e.start)||!Number.isFinite(e.duur)||e.duur<=0?!1:e.duur<=yV}function SV(e,t){return t.startr.start+r.duur>n)}function CV(e,t){const n=t-V0;let r=0,s=0;for(const a of e){const o=Math.max(a.start,n),l=Math.min(a.start+a.duur,t);l>o&&(r+=l-o),a.duur>s&&(s=a.duur)}return{aantalTaken:e.length,geblokkeerdMs:r,langsteTaakMs:s}}function TV(e){return e.langsteTaakMs>=pV||e.geblokkeerdMs>=gV}function OP(e,t){const n=t-_V;return e.filter(r=>r>n)}function PV(e,t){const n=OP(e.meldingen,t);if(n.length>=bV)return!1;const r=n.length>0?n[n.length-1]:null;return r===null?!0:t-r>=wV}function AV(e,t,n){if(!jV(t))return{stand:e,melding:null};if(SV(e,t))return{stand:e,melding:null};if(!EV(t,n))return{stand:e,melding:null};const r=t.start+t.duur,s=[...NV(e.venster,r),t],a=CV(s,r),o={...e,venster:s};return TV(a)?PV(e,r)?{stand:{...e,venster:[],meldingen:[...OP(e.meldingen,r),r]},melding:a}:{stand:o,melding:null}:{stand:o,melding:null}}function RV(e){return Math.max(e.langsteTaakMs,e.geblokkeerdMs)}function If(e){return(e/1e3).toFixed(1).replace(".",",")}function OV(e){const t=V0/1e3;return{message:`De pagina stond ${If(RV(e))} seconden stil`,detail:e.aantalTaken===1?`1 lange taak van ${If(e.langsteTaakMs)} s`:`${e.aantalTaken} lange taken binnen een venster van ${t} s, samen ${If(e.geblokkeerdMs)} s geblokkeerd, langste ${If(e.langsteTaakMs)} s`}}let Lf=RP(0),Q1=null,qg={zichtbaar:!0,laatsteWisselOp:null},Hi=null;function X1(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():0}function MV(e){try{return cV(mV(e))}catch{return""}}function DV(){if(typeof PerformanceObserver>"u")return!1;const e=PerformanceObserver.supportedEntryTypes;return Array.isArray(e)&&e.includes("longtask")}function IV(e){if(typeof document>"u"||!DV())return()=>{};Hi==null||Hi(),Lf=kV(Lf,Q1,e,X1()),Q1=e,qg={zichtbaar:document.visibilityState==="visible",laatsteWisselOp:null};const t=()=>{qg={zichtbaar:document.visibilityState==="visible",laatsteWisselOp:X1()}};document.addEventListener("visibilitychange",t);const n=dV(),r=new PerformanceObserver(a=>{for(const o of a.getEntries()){const l=AV(Lf,{start:o.startTime,duur:o.duration},qg);if(Lf=l.stand,!l.melding)continue;const{message:c,detail:u}=OV(l.melding),d=MV(o.startTime);z0("scherm-bevroren",c,d?`${u} ${d}`:u).catch(()=>{})}}),s=()=>{Hi===s&&(Hi=null,r.disconnect(),n(),document.removeEventListener("visibilitychange",t))};try{r.observe({type:"longtask",buffered:!1})}catch{return n(),document.removeEventListener("visibilitychange",t),()=>{}}return Hi=s,s}function LV(){const{user:e}=Ht(),t=(e==null?void 0:e.id)??null;return p.useEffect(()=>{if(t)return IV(t)},[t]),null}/** * @remix-run/router v1.23.2 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function cd(){return cd=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function W0(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function FV(){return Math.random().toString(36).substr(2,8)}function J1(e,t){return{usr:e.state,key:e.key,idx:t}}function gx(e,t,n,r){return n===void 0&&(n=null),cd({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?Rc(t):t,{state:n,key:t&&t.key||r||FV()})}function im(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function Rc(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function zV(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:a=!1}=r,o=s.history,l=eo.Pop,c=null,u=d();u==null&&(u=0,o.replaceState(cd({},o.state,{idx:u}),""));function d(){return(o.state||{idx:null}).idx}function f(){l=eo.Pop;let y=d(),x=y==null?null:y-u;u=y,c&&c({action:l,location:w.location,delta:x})}function h(y,x){l=eo.Push;let g=gx(w.location,y,x);u=d()+1;let b=J1(g,u),_=w.createHref(g);try{o.pushState(b,"",_)}catch(j){if(j instanceof DOMException&&j.name==="DataCloneError")throw j;s.location.assign(_)}a&&c&&c({action:l,location:w.location,delta:1})}function m(y,x){l=eo.Replace;let g=gx(w.location,y,x);u=d();let b=J1(g,u),_=w.createHref(g);o.replaceState(b,"",_),a&&c&&c({action:l,location:w.location,delta:0})}function v(y){let x=s.location.origin!=="null"?s.location.origin:s.location.href,g=typeof y=="string"?y:im(y);return g=g.replace(/ $/,"%20"),$t(x,"No window.location.(origin|href) available to create URL for href: "+g),new URL(g,x)}let w={get action(){return l},get location(){return e(s,o)},listen(y){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(Z1,f),c=y,()=>{s.removeEventListener(Z1,f),c=null}},createHref(y){return t(s,y)},createURL:v,encodeLocation(y){let x=v(y);return{pathname:x.pathname,search:x.search,hash:x.hash}},push:h,replace:m,go(y){return o.go(y)}};return w}var ej;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(ej||(ej={}));function BV(e,t,n){return n===void 0&&(n="/"),UV(e,t,n)}function UV(e,t,n,r){let s=typeof t=="string"?Rc(t):t,a=ic(s.pathname||"/",n);if(a==null)return null;let o=MP(e);VV(o);let l=null;for(let c=0;l==null&&c{let c={relativePath:l===void 0?a.path||"":l,caseSensitive:a.caseSensitive===!0,childrenIndex:o,route:a};c.relativePath.startsWith("/")&&($t(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let u=mo([r,c.relativePath]),d=n.concat(c);a.children&&a.children.length>0&&($t(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),MP(a.children,t,d,u)),!(a.path==null&&!a.index)&&t.push({path:u,score:QV(u,a.index),routesMeta:d})};return e.forEach((a,o)=>{var l;if(a.path===""||!((l=a.path)!=null&&l.includes("?")))s(a,o);else for(let c of DP(a.path))s(a,o,c)}),t}function DP(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return s?[a,""]:[a];let o=DP(r.join("/")),l=[];return l.push(...o.map(c=>c===""?a:[a,c].join("/"))),s&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function VV(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:XV(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const WV=/^:[\w-]+$/,HV=3,qV=2,KV=1,GV=10,YV=-2,tj=e=>e==="*";function QV(e,t){let n=e.split("/"),r=n.length;return n.some(tj)&&(r+=YV),t&&(r+=qV),n.filter(s=>!tj(s)).reduce((s,a)=>s+(WV.test(a)?HV:a===""?KV:GV),r)}function XV(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function ZV(e,t,n){let{routesMeta:r}=e,s={},a="/",o=[];for(let l=0;l{let{paramName:h,isOptional:m}=d;if(h==="*"){let w=l[f]||"";o=a.slice(0,a.length-w.length).replace(/(.)\/+$/,"$1")}const v=l[f];return m&&!v?u[h]=void 0:u[h]=(v||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:o,pattern:e}}function JV(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),W0(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function e9(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return W0(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function ic(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const t9=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,n9=e=>t9.test(e);function r9(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?Rc(e):e,a;if(n)if(n9(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),W0(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?a=nj(n.substring(1),"/"):a=nj(n,t)}else a=t;return{pathname:a,search:o9(r),hash:i9(s)}}function nj(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function Kg(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function s9(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function H0(e,t){let n=s9(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function q0(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=Rc(e):(s=cd({},e),$t(!s.pathname||!s.pathname.includes("?"),Kg("?","pathname","search",s)),$t(!s.pathname||!s.pathname.includes("#"),Kg("#","pathname","hash",s)),$t(!s.search||!s.search.includes("#"),Kg("#","search","hash",s)));let a=e===""||s.pathname==="",o=a?"/":s.pathname,l;if(o==null)l=n;else{let f=t.length-1;if(!r&&o.startsWith("..")){let h=o.split("/");for(;h[0]==="..";)h.shift(),f-=1;s.pathname=h.join("/")}l=f>=0?t[f]:"/"}let c=r9(s,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const mo=e=>e.join("/").replace(/\/\/+/g,"/"),a9=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),o9=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,i9=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function l9(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const IP=["post","put","patch","delete"];new Set(IP);const c9=["get",...IP];new Set(c9);/** * React Router v6.30.3 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function ud(){return ud=Object.assign?Object.assign.bind():function(e){for(var t=1;t{l.current=!0}),p.useCallback(function(u,d){if(d===void 0&&(d={}),!l.current)return;if(typeof u=="number"){r.go(u);return}let f=q0(u,JSON.parse(o),a,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:mo([t,f.pathname])),(d.replace?r.replace:r.push)(f,d.state,d)},[t,r,o,a,e])}const zP=p.createContext(null);function lse(){return p.useContext(zP)}function f9(e){let t=p.useContext(Ys).outlet;return t&&p.createElement(zP.Provider,{value:e},t)}function dp(){let{matches:e}=p.useContext(Ys),t=e[e.length-1];return t?t.params:{}}function fp(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=p.useContext(Ea),{matches:s}=p.useContext(Ys),{pathname:a}=Qs(),o=JSON.stringify(H0(s,r.v7_relativeSplatPath));return p.useMemo(()=>q0(e,JSON.parse(o),a,n==="path"),[e,o,a,n])}function h9(e,t){return m9(e,t)}function m9(e,t,n,r){Oc()||$t(!1);let{navigator:s}=p.useContext(Ea),{matches:a}=p.useContext(Ys),o=a[a.length-1],l=o?o.params:{};o&&o.pathname;let c=o?o.pathnameBase:"/";o&&o.route;let u=Qs(),d;if(t){var f;let y=typeof t=="string"?Rc(t):t;c==="/"||(f=y.pathname)!=null&&f.startsWith(c)||$t(!1),d=y}else d=u;let h=d.pathname||"/",m=h;if(c!=="/"){let y=c.replace(/^\//,"").split("/");m="/"+h.replace(/^\//,"").split("/").slice(y.length).join("/")}let v=BV(e,{pathname:m}),w=x9(v&&v.map(y=>Object.assign({},y,{params:Object.assign({},l,y.params),pathname:mo([c,s.encodeLocation?s.encodeLocation(y.pathname).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?c:mo([c,s.encodeLocation?s.encodeLocation(y.pathnameBase).pathname:y.pathnameBase])})),a,n,r);return t&&w?p.createElement(up.Provider,{value:{location:ud({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:eo.Pop}},w):w}function p9(){let e=k9(),t=l9(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return p.createElement(p.Fragment,null,p.createElement("h2",null,"Unexpected Application Error!"),p.createElement("h3",{style:{fontStyle:"italic"}},t),n?p.createElement("pre",{style:s},n):null,null)}const g9=p.createElement(p9,null);class y9 extends p.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?p.createElement(Ys.Provider,{value:this.props.routeContext},p.createElement($P.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function v9(e){let{routeContext:t,match:n,children:r}=e,s=p.useContext(cp);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),p.createElement(Ys.Provider,{value:t},r)}function x9(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var a;if(!n)return null;if(n.errors)e=n.matches;else if((a=r)!=null&&a.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,l=(s=n)==null?void 0:s.errors;if(l!=null){let d=o.findIndex(f=>f.route.id&&(l==null?void 0:l[f.route.id])!==void 0);d>=0||$t(!1),o=o.slice(0,Math.min(o.length,d+1))}let c=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let d=0;d=0?o=o.slice(0,u+1):o=[o[0]];break}}}return o.reduceRight((d,f,h)=>{let m,v=!1,w=null,y=null;n&&(m=l&&f.route.id?l[f.route.id]:void 0,w=f.route.errorElement||g9,c&&(u<0&&h===0?(S9("route-fallback"),v=!0,y=null):u===h&&(v=!0,y=f.route.hydrateFallbackElement||null)));let x=t.concat(o.slice(0,h+1)),g=()=>{let b;return m?b=w:v?b=y:f.route.Component?b=p.createElement(f.route.Component,null):f.route.element?b=f.route.element:b=d,p.createElement(v9,{match:f,routeContext:{outlet:d,matches:x,isDataRoute:n!=null},children:b})};return n&&(f.route.ErrorBoundary||f.route.errorElement||h===0)?p.createElement(y9,{location:n.location,revalidation:n.revalidation,component:w,error:m,children:g(),routeContext:{outlet:null,matches:x,isDataRoute:!0}}):g()},null)}var BP=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(BP||{}),UP=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(UP||{});function w9(e){let t=p.useContext(cp);return t||$t(!1),t}function b9(e){let t=p.useContext(LP);return t||$t(!1),t}function _9(e){let t=p.useContext(Ys);return t||$t(!1),t}function VP(e){let t=_9(),n=t.matches[t.matches.length-1];return n.route.id||$t(!1),n.route.id}function k9(){var e;let t=p.useContext($P),n=b9(),r=VP();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function j9(){let{router:e}=w9(BP.UseNavigateStable),t=VP(UP.UseNavigateStable),n=p.useRef(!1);return FP(()=>{n.current=!0}),p.useCallback(function(s,a){a===void 0&&(a={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,ud({fromRouteId:t},a)))},[e,t])}const rj={};function S9(e,t,n){rj[e]||(rj[e]=!0)}function E9(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function hp(e){let{to:t,replace:n,state:r,relative:s}=e;Oc()||$t(!1);let{future:a,static:o}=p.useContext(Ea),{matches:l}=p.useContext(Ys),{pathname:c}=Qs(),u=Xs(),d=q0(t,H0(l,a.v7_relativeSplatPath),c,s==="path"),f=JSON.stringify(d);return p.useEffect(()=>u(JSON.parse(f),{replace:n,state:r,relative:s}),[u,f,s,n,r]),null}function cse(e){return f9(e.context)}function Fe(e){$t(!1)}function N9(e){let{basename:t="/",children:n=null,location:r,navigationType:s=eo.Pop,navigator:a,static:o=!1,future:l}=e;Oc()&&$t(!1);let c=t.replace(/^\/*/,"/"),u=p.useMemo(()=>({basename:c,navigator:a,static:o,future:ud({v7_relativeSplatPath:!1},l)}),[c,l,a,o]);typeof r=="string"&&(r=Rc(r));let{pathname:d="/",search:f="",hash:h="",state:m=null,key:v="default"}=r,w=p.useMemo(()=>{let y=ic(d,c);return y==null?null:{location:{pathname:y,search:f,hash:h,state:m,key:v},navigationType:s}},[c,d,f,h,m,v,s]);return w==null?null:p.createElement(Ea.Provider,{value:u},p.createElement(up.Provider,{children:n,value:w}))}function C9(e){let{children:t,location:n}=e;return h9(vx(t),n)}new Promise(()=>{});function vx(e,t){t===void 0&&(t=[]);let n=[];return p.Children.forEach(e,(r,s)=>{if(!p.isValidElement(r))return;let a=[...t,s];if(r.type===p.Fragment){n.push.apply(n,vx(r.props.children,a));return}r.type!==Fe&&$t(!1),!r.props.index||!r.props.children||$t(!1);let o={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=vx(r.props.children,a)),n.push(o)}),n}/** * React Router DOM v6.30.3 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function lm(){return lm=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function T9(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function P9(e,t){return e.button===0&&(!t||t==="_self")&&!T9(e)}function xx(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(s=>[n,s]):[[n,r]])},[]))}function A9(e,t){let n=xx(e);return t&&t.forEach((r,s)=>{n.has(s)||t.getAll(s).forEach(a=>{n.append(s,a)})}),n}const R9=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],O9=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],M9="6";try{window.__reactRouterVersion=M9}catch{}const D9=p.createContext({isTransitioning:!1}),I9="startTransition",sj=Zx[I9];function L9(e){let{basename:t,children:n,future:r,window:s}=e,a=p.useRef();a.current==null&&(a.current=$V({window:s,v5Compat:!0}));let o=a.current,[l,c]=p.useState({action:o.action,location:o.location}),{v7_startTransition:u}=r||{},d=p.useCallback(f=>{u&&sj?sj(()=>c(f)):c(f)},[c,u]);return p.useLayoutEffect(()=>o.listen(d),[o,d]),p.useEffect(()=>E9(r),[r]),p.createElement(N9,{basename:t,children:n,location:l.location,navigationType:l.action,navigator:o,future:r})}const $9=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",F9=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,la=p.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:a,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:f}=t,h=WP(t,R9),{basename:m}=p.useContext(Ea),v,w=!1;if(typeof u=="string"&&F9.test(u)&&(v=u,$9))try{let b=new URL(window.location.href),_=u.startsWith("//")?new URL(b.protocol+u):new URL(u),j=ic(_.pathname,m);_.origin===b.origin&&j!=null?u=j+_.search+_.hash:w=!0}catch{}let y=u9(u,{relative:s}),x=B9(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:s,viewTransition:f});function g(b){r&&r(b),b.defaultPrevented||x(b)}return p.createElement("a",lm({},h,{href:v||y,onClick:w||a?r:g,ref:n,target:c}))}),use=p.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:a="",end:o=!1,style:l,to:c,viewTransition:u,children:d}=t,f=WP(t,O9),h=fp(c,{relative:f.relative}),m=Qs(),v=p.useContext(LP),{navigator:w,basename:y}=p.useContext(Ea),x=v!=null&&U9(h)&&u===!0,g=w.encodeLocation?w.encodeLocation(h).pathname:h.pathname,b=m.pathname,_=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;s||(b=b.toLowerCase(),_=_?_.toLowerCase():null,g=g.toLowerCase()),_&&y&&(_=ic(_,y)||_);const j=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let k=b===g||!o&&b.startsWith(g)&&b.charAt(j)==="/",S=_!=null&&(_===g||!o&&_.startsWith(g)&&_.charAt(g.length)==="/"),E={isActive:k,isPending:S,isTransitioning:x},N=k?r:void 0,O;typeof a=="function"?O=a(E):O=[a,k?"active":null,S?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let z=typeof l=="function"?l(E):l;return p.createElement(la,lm({},f,{"aria-current":N,className:O,ref:n,style:z,to:c,viewTransition:u}),typeof d=="function"?d(E):d)});var wx;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(wx||(wx={}));var aj;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(aj||(aj={}));function z9(e){let t=p.useContext(cp);return t||$t(!1),t}function B9(e,t){let{target:n,replace:r,state:s,preventScrollReset:a,relative:o,viewTransition:l}=t===void 0?{}:t,c=Xs(),u=Qs(),d=fp(e,{relative:o});return p.useCallback(f=>{if(P9(f,n)){f.preventDefault();let h=r!==void 0?r:im(u)===im(d);c(e,{replace:h,state:s,preventScrollReset:a,relative:o,viewTransition:l})}},[u,c,d,r,s,n,e,a,o,l])}function HP(e){let t=p.useRef(xx(e)),n=p.useRef(!1),r=Qs(),s=p.useMemo(()=>A9(r.search,n.current?null:t.current),[r.search]),a=Xs(),o=p.useCallback((l,c)=>{const u=xx(typeof l=="function"?l(s):l);n.current=!0,a("?"+u,c)},[a,s]);return[s,o]}function U9(e,t){t===void 0&&(t={});let n=p.useContext(D9);n==null&&$t(!1);let{basename:r}=z9(wx.useViewTransitionState),s=fp(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=ic(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=ic(n.nextLocation.pathname,r)||n.nextLocation.pathname;return yx(s.pathname,o)!=null||yx(s.pathname,a)!=null}const V9=["app.nexusos.nl","app.staging.nexusos.nl","app.localhost"];function qP(e){return V9.includes(e.toLowerCase())}function KP(){var e;return typeof window>"u"?!1:(e=window.matchMedia)!=null&&e.call(window,"(display-mode: standalone)").matches?!0:window.navigator.standalone===!0}function W9({children:e,...t}){return i.jsx(G$,{attribute:"class",defaultTheme:"light",enableSystem:!1,disableTransitionOnChange:!0,...t,children:e})}const H9=/Failed to fetch dynamically imported module|Importing a module script failed|error loading dynamically imported module|Loading chunk [\d]+ failed|MIME type/i;function oj(e){return e?H9.test(String(e.message||e)):!1}class q9 extends X.Component{constructor(){super(...arguments);ge(this,"state",{error:null,recovering:!1});ge(this,"handleReset",async()=>{await $0()});ge(this,"handleRecover",async()=>{this.setState({recovering:!0}),await F0(),window.location.reload()})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){if(console.error("[ErrorBoundary]",n,r),oj(n))return;const s=(r.componentStack||"").split(` `).map(a=>a.trim()).filter(Boolean).slice(0,8).join(" < ");z0("scherm-crash",mx(n),s||null)}render(){var n;if(this.state.error){if(oj(this.state.error)){const r=navigator.onLine===!1;return i.jsx("div",{className:"flex flex-col items-center justify-center min-h-screen p-8 bg-background",children:i.jsxs("div",{className:"max-w-lg text-center space-y-4",children:[i.jsx("h1",{className:"text-2xl font-bold",children:r?"Geen verbinding":"Dit scherm kon niet laden"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:r?"Dit scherm staat nog niet op je toestel en er is nu geen internet om het op te halen. Probeer het zodra je weer verbinding hebt.":"De app is bijgewerkt en dit onderdeel hoort nog bij de vorige versie. Laad de pagina opnieuw om verder te gaan."}),i.jsx("div",{className:"flex justify-center",children:i.jsx("button",{onClick:this.handleRecover,disabled:this.state.recovering,className:"px-6 py-3 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors disabled:opacity-70",children:this.state.recovering?"Bezig met herstellen":r?"Opnieuw proberen":"Opnieuw laden"})}),i.jsxs("div",{className:"space-y-2 pt-2",children:[i.jsx("button",{onClick:this.handleReset,className:"px-4 py-2 bg-destructive text-destructive-foreground rounded-md hover:bg-destructive/90 transition-colors",children:"App resetten"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:'Blijft de app vastlopen? Klik op "App resetten" om alles te wissen. Je moet daarna opnieuw inloggen.'})]})]})})}return i.jsx("div",{className:"flex flex-col items-center justify-center min-h-screen p-8 bg-background",children:i.jsxs("div",{className:"max-w-lg text-center space-y-4",children:[i.jsx("h1",{className:"text-2xl font-bold text-destructive",children:"Er is een fout opgetreden"}),i.jsx("pre",{className:"text-sm text-muted-foreground bg-muted p-4 rounded-md overflow-auto text-left",children:String(((n=this.state.error)==null?void 0:n.message)||this.state.error)}),i.jsxs("div",{className:"flex gap-2 justify-center",children:[i.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",children:"Pagina herladen"}),i.jsx("button",{onClick:this.handleReset,className:"px-4 py-2 bg-destructive text-destructive-foreground rounded-md hover:bg-destructive/90 transition-colors",children:"App resetten"})]}),i.jsx("p",{className:"text-xs text-muted-foreground",children:'Blijft de app vastlopen? Klik op "App resetten" om alle cache en lokale data te wissen.'})]})})}return this.props.children}}const GP=p.createContext(void 0);function K9({children:e}){const{user:t,initialized:n}=Ht(),[r,s]=p.useState(null),[a,o]=p.useState(null),[l,c]=p.useState(null);p.useEffect(()=>{t?s({id:t.id,email:t.email}):(s(null),o(null),c(null))},[t==null?void 0:t.id,n]);const u=p.useCallback(async v=>{if(!r)return;if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v)){console.error("Impersonation denied: invalid user ID format");return}const{data:y}=await B.from("user_roles").select("role").eq("user_id",r.id).eq("role","super_admin").maybeSingle();if(!y){console.error("Impersonation denied: user is not a super_admin");return}try{const{data:x,error:g}=await B.from("profiles").select("id, full_name, email").eq("id",v).single();if(g||!x){console.error("Could not find user to impersonate:",g);return}const{data:b,error:_}=await B.from("user_roles").select("role").eq("user_id",v),{data:j,error:k}=await B.from("organization_members").select("role").eq("user_id",v).eq("is_active",!0),S=[];!_&&b&&S.push(...b.map(O=>O.role)),!k&&j&&j.forEach(O=>{S.includes(O.role)||S.push(O.role)});const{data:E,error:N}=await B.from("impersonation_logs").insert({super_admin_id:r.id,impersonated_user_id:v}).select("id").single();N?console.error("Could not log impersonation:",N):E&&c(E.id),o({id:x.id,full_name:x.full_name,email:x.email,roles:S})}catch(x){console.error("Error starting impersonation:",x)}},[r]),d=p.useCallback(async()=>{if(l)try{const{error:v}=await B.from("impersonation_logs").update({ended_at:new Date().toISOString()}).eq("id",l);v&&console.error("Failed to log impersonation end:",v)}catch(v){console.error("Error ending impersonation log:",v)}o(null),c(null)},[l]),f=p.useCallback(()=>(a==null?void 0:a.id)??(r==null?void 0:r.id)??null,[a,r]),h=p.useCallback(()=>{if(!a)return!1;const v=["super_admin","admin","tenant_owner","tenant_staff","staff"];return a.roles.some(w=>v.includes(w))},[a]),m={realUser:r,impersonatedUser:a,isImpersonating:a!==null,startImpersonation:u,stopImpersonation:d,getEffectiveUserId:f,isImpersonatedUserAdmin:h};return i.jsx(GP.Provider,{value:m,children:e})}function mp(){const e=p.useContext(GP);if(e===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return e}const YP=p.createContext(void 0);function G9({children:e}){const{user:t,initialized:n}=Ht(),[r,s]=p.useState(null),[a,o]=p.useState(null),[l,c]=p.useState([]),[u,d]=p.useState(!0),[f,h]=p.useState(null),[m,v]=p.useState(!1),w=async()=>{if(n)try{if(d(!0),h(null),!t){s(null),o(null),c([]),v(!1),d(!1);return}const{data:g}=await B.from("user_roles").select("role").eq("user_id",t.id).eq("role","super_admin").maybeSingle(),b=!!g;if(v(b),b){const{data:_,error:j}=await B.from("organizations").select("id, name, slug, logo_url, hero_image_url, branche, primary_color, secondary_color, contact_email, contact_phone, address, is_active, created_at").eq("is_active",!0).order("name");if(j)throw j;if(c(_||[]),_&&_.length>0&&!r){const k=_[0];s({id:k.id,name:k.name,slug:k.slug,logo_url:k.logo_url,hero_image_url:k.hero_image_url,branche:k.branche??"algemeen",primary_color:k.primary_color,secondary_color:k.secondary_color,contact_email:k.contact_email,contact_phone:k.contact_phone,address:k.address,is_active:k.is_active,created_at:k.created_at}),o("super_admin")}}else{const{data:_,error:j}=await B.from("organization_members").select(` organization_id, role, organizations!inner ( id, name, slug, branche, logo_url, hero_image_url, primary_color, secondary_color, contact_email, contact_phone, address, is_active, created_at ) `).eq("user_id",t.id).eq("is_active",!0).single();if(j)if(j.code==="PGRST116")s(null),o(null);else if(j.code==="PGRST118")console.warn("User belongs to multiple organizations, using first active membership"),s(null),o(null);else throw j;else if(_&&_.organizations){const k=_.organizations,S={id:k.id,name:k.name,slug:k.slug,logo_url:k.logo_url,hero_image_url:k.hero_image_url,branche:k.branche??"algemeen",primary_color:k.primary_color,secondary_color:k.secondary_color,contact_email:k.contact_email,contact_phone:k.contact_phone,address:k.address,is_active:k.is_active,created_at:k.created_at};s(S),o(_.role),c([S])}}}catch(g){console.error("Error fetching organization:",g),h(g instanceof Error?g.message:"Unknown error")}finally{d(!1)}},y=g=>{s(g)};p.useEffect(()=>{w()},[t==null?void 0:t.id,n]);const x={organization:r,userOrgRole:a,loading:u,error:f,organizations:l,setActiveOrganization:y,isSuperAdmin:m,refreshOrganization:w};return i.jsx(YP.Provider,{value:x,children:e})}function zt(){const e=p.useContext(YP);if(e===void 0)throw new Error("useOrganizationContext must be used within an OrganizationProvider");return e}const dd=bc("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md 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-0 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",cta:"bg-cta text-cta-foreground hover:bg-cta/90 shadow-sm"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),ne=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...s},a)=>{const o=r?OC:"button";return i.jsx(o,{className:Y(dd({variant:t,size:n,className:e})),ref:a,...s})});ne.displayName="Button";const Y9=bc("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",info:"border-transparent bg-status-info-bg text-status-info",action:"border-transparent bg-status-action-bg text-status-action",attention:"border-transparent bg-status-attention-bg text-status-attention",neutral:"border-transparent bg-status-neutral-bg text-status-neutral",accent:"border-transparent bg-accent text-accent-foreground",cta:"border-transparent bg-cta text-cta-foreground"}},defaultVariants:{variant:"default"}});function Qe({className:e,variant:t,...n}){return i.jsx("div",{className:Y(Y9({variant:t}),e),...n})}function Q9(e){return e.includes("super_admin")?{label:"Super Admin",icon:i.jsx(Uk,{className:"h-3 w-3 mr-1"}),colorClass:"bg-purple-100 text-purple-800 border-purple-300"}:e.includes("tenant_owner")?{label:"Eigenaar",icon:i.jsx(_c,{className:"h-3 w-3 mr-1"}),colorClass:"bg-blue-100 text-blue-800 border-blue-300"}:e.includes("tenant_staff")?{label:"Medewerker+",icon:i.jsx(Wr,{className:"h-3 w-3 mr-1"}),colorClass:"bg-indigo-100 text-indigo-800 border-indigo-300"}:e.includes("admin")?{label:"Admin",icon:i.jsx(Uk,{className:"h-3 w-3 mr-1"}),colorClass:"bg-blue-100 text-blue-800 border-blue-300"}:e.includes("staff")?{label:"Medewerker",icon:i.jsx(Wr,{className:"h-3 w-3 mr-1"}),colorClass:"bg-teal-100 text-teal-800 border-teal-300"}:{label:"Klant",icon:i.jsx(vr,{className:"h-3 w-3 mr-1"}),colorClass:"bg-green-100 text-green-800 border-green-300"}}function X9(){const{isImpersonating:e,impersonatedUser:t,stopImpersonation:n}=mp();if(!e||!t)return null;const r=Q9(t.roles);return i.jsxs("div",{className:"fixed top-0 left-0 right-0 z-[100] bg-amber-500 text-amber-950 px-4 py-2 flex items-center justify-between gap-4 shadow-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ym,{className:"h-5 w-5"}),i.jsxs("span",{className:"font-medium text-sm",children:["Je bekijkt de app als"," ",i.jsx("strong",{children:t.full_name}),i.jsxs("span",{className:"hidden sm:inline",children:[" (",t.email,")"]})]}),i.jsxs(Qe,{variant:"outline",className:`ml-2 ${r.colorClass}`,children:[r.icon,r.label]})]}),i.jsxs(ne,{size:"sm",variant:"outline",onClick:n,className:"bg-amber-50 border-amber-700 text-amber-900 hover:bg-amber-100 hover:text-amber-950",children:[i.jsx(Sa,{className:"h-4 w-4 mr-1"}),"Terug naar mijn account"]})]})}function Z9({children:e}){const t=Qs(),{orgSlug:n}=dp(),{loading:r,initialized:s,user:a}=Ht();if(r||!s)return i.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:i.jsxs("div",{className:"flex flex-col items-center gap-3",children:[i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"}),i.jsx("span",{className:"text-sm text-muted-foreground",children:"Laden..."})]})});if(!a){const o=n?`/${n}/auth`:"/auth";return i.jsx(hp,{to:o,replace:!0,state:{from:t.pathname}})}return i.jsx(i.Fragment,{children:e})}const J9=[],Rd=()=>{const{user:e,loading:t,initialized:n}=Ht(),r=e==null?void 0:e.id,{data:s,isSuccess:a,isError:o}=xt({queryKey:["user-roles",r],queryFn:async()=>{if(!r)return[];const{data:x,error:g}=await B.from("user_roles").select("role").eq("user_id",r);if(g)throw console.error("[useUserRole] Error fetching user roles:",g),g;return(x==null?void 0:x.map(b=>b.role))||[]},enabled:n&&!!e,staleTime:5*60*1e3,gcTime:30*60*1e3,networkMode:"always"}),l=s??J9,c=a||o,u=()=>l.includes("super_admin")?"super_admin":l.includes("admin")?"admin":l.includes("tenant_owner")?"tenant_owner":l.includes("tenant_staff")?"tenant_staff":l.includes("staff")?"staff":l.includes("customer")?"customer":l[0]||null,d=l.includes("super_admin"),f=l.includes("tenant_owner"),h=l.includes("tenant_staff"),m=l.includes("staff"),v=d||l.includes("admin")||f||h,w=n?!!e:null,y=t||!!e&&!c;return{role:u(),roles:l,loading:y,initialized:n&&(!e||c),hasSession:w,isAdmin:v,isSuperAdmin:d,isTenantOwner:f,isTenantStaff:h,isStaff:m}};function eW({children:e,requiredRole:t}){const{orgSlug:n}=dp(),{loading:r,initialized:s,isAdmin:a}=Rd();if(r||!s)return i.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:i.jsxs("div",{className:"flex flex-col items-center gap-3",children:[i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"}),i.jsx("span",{className:"text-sm text-muted-foreground",children:"Rechten controleren..."})]})});if(t==="admin"&&!a){const o=n?`/${n}/booking`:"/";return i.jsx(hp,{to:o,replace:!0})}return i.jsx(i.Fragment,{children:e})}function tW({children:e}){const{orgSlug:t}=dp(),{organization:n,loading:r,isSuperAdmin:s}=zt();return t?r?i.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:i.jsxs("div",{className:"flex flex-col items-center gap-3",children:[i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"}),i.jsx("span",{className:"text-sm text-muted-foreground",children:"Organisatie laden..."})]})}):!s&&n&&n.slug!==t?i.jsx(hp,{to:`/${n.slug}/admin`,replace:!0}):i.jsx(i.Fragment,{children:e}):i.jsx(i.Fragment,{children:e})}function nW(e){return!e||!e.startsWith("/")||e.startsWith("//")||e.includes("\\")?null:e}function bx(e,t){const{isAdmin:n,isSuperAdmin:r,isTenantOwner:s,isTenantStaff:a,role:o}=e;return r||n||s||a?t?`/${t}/admin`:"/admin":o==="staff"?"/dashboard":t?`/${t}/booking`:"/dashboard"}const Sr=({icon:e,label:t,active:n=!1,onClick:r,to:s})=>{const a=i.jsxs(i.Fragment,{children:[i.jsx("div",{className:Y("rounded-full p-2 transition-colors",n?"bg-nav-active-bg":""),children:i.jsx(e,{className:Y("h-5 w-5 transition-colors",n?"text-nav-active":"text-nav-muted hover:text-foreground"),strokeWidth:1.5})}),i.jsx("span",{className:Y("text-[10px] transition-colors",n?"text-nav-active font-medium":"text-nav-muted"),children:t})]}),o="flex flex-col items-center justify-center gap-0.5 min-w-[56px] py-2 px-2 transition-colors";return s?i.jsx(la,{to:s,className:o,children:a}):i.jsx("button",{onClick:r,className:o,children:a})},QP=({children:e,hidden:t=!1,alwaysVisible:n=!1,docked:r=!1})=>i.jsx("nav",{className:Y("bg-background/95 backdrop-blur-sm border-t border-border",r?"relative shrink-0":"fixed bottom-0 left-0 right-0 z-[100]",!n&&"md:hidden",!r&&"transition-transform duration-300 ease-in-out",!r&&(t?"translate-y-full":"translate-y-0")),style:{paddingBottom:"max(env(safe-area-inset-bottom, 0px), 12px)"},children:i.jsx("div",{className:"flex justify-around items-center h-16 px-1",children:e})}),pp=({user:e,isAdmin:t,onLogout:n})=>{const r=Qs(),s=a=>r.pathname===a;return i.jsxs(QP,{children:[i.jsx(Sr,{icon:Nd,label:"Home",to:"/",active:s("/")}),i.jsx(Sr,{icon:Wt,label:"Afspraak",to:"/booking",active:s("/booking")}),e&&i.jsx(Sr,{icon:vr,label:"Profiel",to:"/profile",active:s("/profile")}),e?i.jsx(Sr,{icon:Xu,label:"Uitloggen",onClick:n}):i.jsx(Sr,{icon:vr,label:"Inloggen",to:"/auth",active:s("/auth")})]})},cm={kappers_beauty:{project:"Afspraak",projects:"Afspraken",projectsShort:"Afspraken",appointment:"Afspraak",appointments:"Afspraken",service:"behandeling",services:"behandelingen",serviceExample:"Bijv. Knippen Dames",staffMember:"Kapper",staffMembers:"Kappers",staffBadge:"Kapper",staffCheckboxLabel:"Toon als kapper in boekingssysteem",maxStaff:"Max kappers",maxStaffDescription:"Maximum aantal kappers/stylisten",maxProjectsPerMonth:"Max afspraken/maand",maxProjectsPerMonthDescription:"Maximum afspraken per maand",planner:"Agenda",scheduler:"Agenda",customer:"Klant",customers:"Klanten",waitlist:"Wachtlijst",inventory:"Producten",task:"Taak",tasks:"Taken",demoProjectsLabel:"~50 afspraken (1 week terug + 3 weken vooruit)",mySalon:"Organisatie"},monteurs:{project:"Opdracht",projects:"Opdrachten",projectsShort:"Opdrachten",appointment:"Afspraak",appointments:"Afspraken",service:"dienst",services:"diensten",serviceExample:"Bijv. Airco plaatsen",staffMember:"Medewerker",staffMembers:"Medewerkers",staffBadge:"Monteur",staffCheckboxLabel:"Toon als monteur in planningssysteem",maxStaff:"Max personeel",maxStaffDescription:"Maximum aantal personeelsleden",maxProjectsPerMonth:"Max projecten/maand",maxProjectsPerMonthDescription:"Maximum projecten per maand",planner:"Planner",scheduler:"Planner",customer:"Klant",customers:"Klanten",waitlist:"Wachtlijst klanten",inventory:"Voorraad",task:"Taak",tasks:"Taken",demoProjectsLabel:"~50 projecten (1 week terug + 3 weken vooruit)",mySalon:"Organisatie"},algemeen:{project:"Project",projects:"Projecten",projectsShort:"Projecten",appointment:"Afspraak",appointments:"Afspraken",service:"dienst",services:"diensten",serviceExample:"Bijv. Onderhoudsbeurt",staffMember:"Medewerker",staffMembers:"Medewerkers",staffBadge:"Medewerker",staffCheckboxLabel:"Toon als medewerker in planningssysteem",maxStaff:"Max personeel",maxStaffDescription:"Maximum aantal personeelsleden",maxProjectsPerMonth:"Max projecten/maand",maxProjectsPerMonthDescription:"Maximum projecten per maand",planner:"Planner",scheduler:"Planner",customer:"Klant",customers:"Klanten",waitlist:"Wachtlijst",inventory:"Voorraad",task:"Taak",tasks:"Taken",demoProjectsLabel:"~50 projecten (1 week terug + 3 weken vooruit)",mySalon:"Organisatie"}};function rW(){const{organization:e}=zt(),t=(e==null?void 0:e.branche)||"algemeen";return{t:a=>{var o;return((o=cm[t])==null?void 0:o[a])??cm.algemeen[a]},branche:t,isKappersBranche:t==="kappers_beauty",isMonteurs:t==="monteurs"}}function lc(e,t){var n;return((n=cm[e])==null?void 0:n[t])??cm.algemeen[t]}function dse(e){return e.charAt(0).toUpperCase()+e.slice(1)}function fse(e){switch(e){case"monteurs":return"Monteurs";case"kappers_beauty":return"Kappers & Beauty";case"algemeen":return"Algemeen";default:return"Onbekend"}}const sW="claim_idempotency_key";async function Je({organizationId:e,scope:t,key:n,ttlSeconds:r=900}){const s=Math.min(86400,Math.max(30,r)),{data:a,error:o}=await B.rpc(sW,{p_organization_id:e,p_request_scope:t,p_idempotency_key:n,p_ttl_seconds:s});if(o)throw new Error(`Idempotency check mislukt: ${o.message}`);if(a!==!0)throw new Error("Deze actie is al verwerkt of nog in behandeling. Ververs en probeer opnieuw.")}const qo=[{key:"projects",label:"Projecten",description:"Projecten/Opdrachten beheer",defaultEnabled:!0},{key:"appointments",label:"Afspraken",description:"Afspraken systeem",defaultEnabled:!0},{key:"staff_management",label:"HR",description:"Personeel beheer",defaultEnabled:!0},{key:"customers",label:"Klanten",description:"Klanten beheer",defaultEnabled:!0},{key:"scheduler",label:"Planner",description:"Planning dashboard",defaultEnabled:!0},{key:"agenda",label:"Agenda",description:"Agenda-overzicht naast de planner",defaultEnabled:!1},{key:"templates",label:"Marketing",description:"Campagnes & email templates",defaultEnabled:!0},{key:"reports",label:"Rapportages",description:"Rapportages en statistieken",defaultEnabled:!0},{key:"payments",label:"Kassa",description:"Betalingen (Mollie)",defaultEnabled:!1},{key:"blog",label:"Blog",description:"Blog functionaliteit",defaultEnabled:!1},{key:"engagement",label:"Engagement",description:"Klant engagement tools",defaultEnabled:!1},{key:"socials",label:"Socials",description:"Social media integratie",defaultEnabled:!1},{key:"waitlist",label:"Wachtlijst",description:"Wachtlijst functie",defaultEnabled:!1},{key:"whatsapp",label:"Berichten",description:"WhatsApp integratie",defaultEnabled:!1},{key:"dashboard",label:"Dashboard",description:"Dashboard configuratie",defaultEnabled:!0},{key:"inventory",label:"Voorraad",description:"Voorraadbeheer en producten",defaultEnabled:!0},{key:"feedback",label:"Feedback",description:"Feedback & reviews",defaultEnabled:!1},{key:"database",label:"Database",description:"Database beheer",defaultEnabled:!0}];function aW(e){const[t,n]=p.useState([]),[r,s]=p.useState(!0),{toast:a}=Ww(),o=p.useCallback(async()=>{if(!e){n([]),s(!1);return}try{s(!0);const{data:d,error:f}=await B.from("organization_modules").select("*").eq("organization_id",e);if(f)throw f;n(d||[])}catch(d){console.error("Error fetching modules:",d),a({title:"Fout",description:"Kon modules niet ophalen",variant:"destructive"})}finally{s(!1)}},[e,a]);p.useEffect(()=>{o()},[o]);const l=p.useCallback(d=>{const f=t.find(h=>h.module_key===d);return(f==null?void 0:f.is_enabled)??!1},[t]),c=p.useCallback(async(d,f)=>{var h,m;if(e)try{const{data:v}=await B.auth.getUser(),w=(h=v.user)==null?void 0:h.id;await Je({organizationId:e,scope:"module-toggle",key:`${d}-${f}`});const{error:y}=await B.from("organization_modules").upsert({organization_id:e,module_key:d,is_enabled:f,enabled_at:f?new Date().toISOString():null,enabled_by:f?w:null},{onConflict:"organization_id,module_key"});if(y)throw y;await o(),a({title:f?"Module ingeschakeld":"Module uitgeschakeld",description:`${(m=qo.find(x=>x.key===d))==null?void 0:m.label} is ${f?"ingeschakeld":"uitgeschakeld"}`})}catch(v){console.error("Error toggling module:",v),a({title:"Fout",description:"Kon module niet wijzigen",variant:"destructive"})}},[e,o,a]),u=p.useCallback(async d=>{if(!e)return;const h=d?{kappers_beauty:{projects:!1,appointments:!0,staff_management:!0,customers:!0,scheduler:!0,templates:!0,reports:!0,payments:!0,blog:!1,engagement:!0,socials:!1,waitlist:!0,whatsapp:!1,dashboard:!0,inventory:!0},monteurs:{projects:!0,appointments:!1,staff_management:!0,customers:!0,scheduler:!0,templates:!0,reports:!0,payments:!0,blog:!1,engagement:!1,socials:!1,waitlist:!1,whatsapp:!1,dashboard:!0,inventory:!0},algemeen:{}}[d]:{};try{const m=qo.map(w=>{const y=h[w.key]!==void 0?h[w.key]:w.defaultEnabled;return{organization_id:e,module_key:w.key,is_enabled:y}});await Je({organizationId:e,scope:"modules-initialize",key:d??"algemeen"});const{error:v}=await B.from("organization_modules").upsert(m,{onConflict:"organization_id,module_key",ignoreDuplicates:!0});if(v)throw v;await o()}catch(m){console.error("Error initializing modules:",m)}},[e,o]);return{modules:t,loading:r,isModuleEnabled:l,toggleModule:c,initializeModules:u,refetch:o}}const oW=B,iW=["tenant_owner","tenant_staff","staff","customer"];function lW(e){return!!e&&iW.includes(e)}function cW(e){return e!=null&&e.show_on_mobile?e.mobile_position==="bottom_nav"?"bottom_nav":"settings_drawer":"hidden"}function XP(e){return(e==null?void 0:e.show_on_desktop)!==!1}function hse(e){return!!e.show_on_mobile||XP(e)}function uW(e){return{desktop:XP(e),telefoon:!!(e!=null&&e.show_on_mobile),positie:(e==null?void 0:e.mobile_position)==="bottom_nav"?"bottom_nav":"settings_drawer"}}function mse(e,t){const n=uW(e);return(e==null?void 0:e.show_on_mobile)===void 0&&t?{...n,telefoon:!0,positie:"bottom_nav"}:n}function pse(e,t,n){const r=e??{};return{...r,show_on_mobile:t.telefoon,mobile_position:t.positie,show_on_desktop:t.desktop,sort_order:r.sort_order??n}}function gse(e,t,n){const r=t.find(s=>s.moduleKey===e);return r?r.sortOrder:n+1}function dW(e){return!e.some(t=>{var n;return t.is_enabled&&((n=t.config)==null?void 0:n.show_on_mobile)!==void 0})}function fW(e,t){if(t.length===0)return e;const n=new Map;for(const s of t)n.set(s.module_key,s);const r=e.map(s=>{const a=n.get(s.module_key);return a?(n.delete(s.module_key),{...s,is_enabled:a.is_enabled,config:a.config}):s});for(const s of n.values())r.push({id:"",organization_id:"",module_key:s.module_key,is_enabled:s.is_enabled,enabled_at:null,enabled_by:null,config:s.config,created_at:"",updated_at:""});return r}function ZP(e,t){const[n,r]=p.useState([]),[s,a]=p.useState(!1),o=lW(t)?t:null,l=p.useCallback(async()=>{if(!e||!o){r([]),a(!1);return}a(!0);const{data:c,error:u}=await oW.from("organization_role_modules").select("module_key, is_enabled, config").eq("organization_id",e).eq("role",o);if(u){console.error("Rolweergave kon niet worden opgehaald"),r([]),a(!1);return}r(c||[]),a(!1)},[e,o]);return p.useEffect(()=>{l()},[l]),{roleModules:n,loading:s,refetch:l}}const Gg={scheduler:Wt,agenda:Km,customers:Wr,projects:Kh,payments:N5,reports:dT,staff_management:Wr,templates:uo,dashboard:Ju,inventory:Cd,blog:Eu,engagement:M5,socials:yT,waitlist:To},Yg={scheduler:{main:"appointments",sub:"agenda-v2"},agenda:{main:"appointments",sub:"agenda"},customers:{main:"customers",sub:"overview"},projects:{main:"admin",sub:"backlog"},payments:{main:"settings",sub:"payments"},reports:{main:"admin",sub:"rapportages"},staff_management:{main:"settings",sub:"medewerkers"},inventory:{main:"admin",sub:"inventory"},blog:{main:"admin",sub:"blog"},engagement:{main:"admin",sub:"engagement"},socials:{main:"admin",sub:"socials"},waitlist:{main:"admin",sub:"waitlist"}},Qc={kappers_beauty:{agenda:{display_name:"Agenda",is_enabled:!1},projects:{display_name:"Afspraken",is_enabled:!1},appointments:{display_name:"Agenda",is_enabled:!0},staff_management:{display_name:"HR",is_enabled:!0},customers:{display_name:"Klanten",is_enabled:!0},scheduler:{display_name:"Agenda",is_enabled:!0},templates:{display_name:"Marketing",is_enabled:!0},reports:{display_name:"Rapportages",is_enabled:!0},payments:{display_name:"Betalingen",is_enabled:!0},blog:{display_name:"Blog",is_enabled:!1},engagement:{display_name:"Engagement",is_enabled:!0},socials:{display_name:"Socials",is_enabled:!1},waitlist:{display_name:"Wachtlijst",is_enabled:!0},whatsapp:{display_name:"WhatsApp",is_enabled:!1},inventory:{display_name:"Producten",is_enabled:!0}},monteurs:{agenda:{display_name:"Agenda",is_enabled:!1},projects:{display_name:"Opdrachten",is_enabled:!0},appointments:{display_name:"Afspraken",is_enabled:!1},staff_management:{display_name:"HR",is_enabled:!0},customers:{display_name:"Klanten",is_enabled:!0},scheduler:{display_name:"Planner",is_enabled:!0},templates:{display_name:"Marketing",is_enabled:!0},reports:{display_name:"Rapportages",is_enabled:!0},payments:{display_name:"Betalingen",is_enabled:!0},blog:{display_name:"Blog",is_enabled:!1},engagement:{display_name:"Engagement",is_enabled:!1},socials:{display_name:"Socials",is_enabled:!1},waitlist:{display_name:"Wachtlijst klanten",is_enabled:!1},whatsapp:{display_name:"WhatsApp",is_enabled:!1},inventory:{display_name:"Voorraad",is_enabled:!0}},algemeen:{agenda:{display_name:"Agenda",is_enabled:!1}}},hW=2,Qg={kappers_beauty:[{moduleKey:"scheduler",position:"bottom_nav",sortOrder:1},{moduleKey:"customers",position:"bottom_nav",sortOrder:2}],monteurs:[{moduleKey:"scheduler",position:"bottom_nav",sortOrder:1},{moduleKey:"projects",position:"bottom_nav",sortOrder:2}],algemeen:[{moduleKey:"scheduler",position:"bottom_nav",sortOrder:1},{moduleKey:"customers",position:"bottom_nav",sortOrder:2}]},Xg={"agenda-v2":"scheduler",agenda:"agenda",backlog:"projects",customers:"customers",medewerkers:"staff_management",templates:"templates",communications:"templates",campagnes:"templates",acties:"dashboard",database:"database",demo:null,engagement:"engagement",payments:"payments",blog:"blog",beschikbaarheid:"staff_management",rapportages:"reports",waitlist:"waitlist",inventory:"inventory","inventory-v2":"inventory",tasks:null,sales:"payments",feedback:"feedback",socials:"socials",berichten:"whatsapp"},Zg=[{id:"super-admin",defaultLabel:"Organisaties",icon:_c,route:{main:"platform",sub:"super-admin"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:1},{id:"platform-nieuwsbrief",defaultLabel:"Nieuwsbrief",icon:uo,route:{main:"platform",sub:"platform-nieuwsbrief"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:1.5},{id:"platform-dashboard",defaultLabel:"Platform Dashboard",icon:l$,route:{main:"platform",sub:"platform-dashboard"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:2},{id:"platform-activiteit",defaultLabel:"Activiteit organisaties",icon:D5,route:{main:"platform",sub:"platform-activiteit"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:2.5},{id:"support",defaultLabel:"Support",icon:Bk,route:{main:"platform",sub:"support"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:2.6},{id:"platform-storingen",defaultLabel:"Storingen",icon:t$,route:{main:"platform",sub:"platform-storingen"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:2.7},{id:"impersonation-logs",defaultLabel:"Impersonation Logs",icon:Ym,route:{main:"platform",sub:"impersonation-logs"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:3},{id:"platform-database",defaultLabel:"Platform Database",icon:zk,route:{main:"platform",sub:"platform-database"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:4},{id:"api-koppelingen",defaultLabel:"API-koppelingen",icon:L5,route:{main:"platform",sub:"api-koppelingen"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:4.5},{id:"dashboard-config",defaultLabel:"Dashboard Config",icon:Ju,route:{main:"platform",sub:"dashboard-config"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:5},{id:"demo",defaultLabel:"Demo Data",icon:e0,route:{main:"admin",sub:"demo"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:6},{id:"backlog-board",defaultLabel:"Backlog Board",icon:F5,route:{main:"platform",sub:"backlog-board"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:10},{id:"contact-submissions",defaultLabel:"Demo Aanvragen",icon:uo,route:{main:"platform",sub:"contact-submissions"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:7},{id:"website-editor",defaultLabel:"Website Editor",icon:gT,route:{main:"platform",sub:"website-editor"},level:"platform",requiresSuperAdmin:!0,showOnDesktop:!0,sortOrder:8},{id:"mijn-salon",defaultLabel:"Organisatie",icon:a$,route:{main:"mijn-salon",sub:"mijn-salon"},level:"organization",showOnDesktop:!0,sortOrder:0},{id:"agenda-v2",moduleKey:"scheduler",defaultLabel:"Planner",icon:Wt,route:{main:"appointments",sub:"agenda-v2"},level:"organization",showOnDesktop:!0,sortOrder:2},{id:"agenda",moduleKey:"agenda",defaultLabel:"Agenda",icon:Km,route:{main:"appointments",sub:"agenda"},level:"organization",showOnDesktop:!0,sortOrder:3},{id:"backlog",moduleKey:"projects",defaultLabel:"Projecten",icon:Kh,route:{main:"admin",sub:"backlog"},level:"organization",showOnDesktop:!0,sortOrder:99},{id:"customers",moduleKey:"customers",defaultLabel:"Klanten",icon:Wr,route:{main:"customers",sub:"customers"},level:"organization",showOnDesktop:!0,sortOrder:3},{id:"medewerkers",moduleKey:"staff_management",defaultLabel:"HR",icon:qm,route:{main:"staff",sub:"medewerkers"},level:"organization",showOnDesktop:!0,sortOrder:4},{id:"communications",moduleKey:"templates",defaultLabel:"Marketing",icon:U5,route:{main:"communications",sub:"campagnes"},level:"organization",showOnDesktop:!0,sortOrder:5,submenu:[]},{id:"acties",moduleKey:"dashboard",defaultLabel:"Dashboard",icon:Ju,route:{main:"admin",sub:"acties"},level:"organization",showOnDesktop:!0,sortOrder:1},{id:"database",moduleKey:"database",defaultLabel:"Database",icon:zk,route:{main:"admin",sub:"database"},level:"organization",showOnDesktop:!0,sortOrder:7},{id:"inventory",moduleKey:"inventory",defaultLabel:"Voorraad",icon:Cd,route:{main:"admin",sub:"inventory"},level:"organization",showOnDesktop:!0,sortOrder:8},{id:"inventory-v2",moduleKey:"inventory",defaultLabel:"Voorraadbeheer v2",icon:j5,route:{main:"admin",sub:"inventory-v2"},level:"organization",showOnDesktop:!1,sortOrder:8.5},{id:"support-aanvragen",defaultLabel:"Support",icon:Bk,route:{main:"support-aanvragen",sub:"support-aanvragen"},level:"organization",showOnDesktop:!0,sortOrder:20},{id:"tasks",defaultLabel:"Taken",icon:Kh,route:{main:"admin",sub:"tasks"},level:"organization",showOnDesktop:!1,sortOrder:3},{id:"sales",moduleKey:"payments",defaultLabel:"Kassa",icon:e$,route:{main:"admin",sub:"sales"},level:"organization",showOnDesktop:!0,sortOrder:9},{id:"berichten",moduleKey:"whatsapp",defaultLabel:"Berichten",icon:mT,route:{main:"admin",sub:"berichten"},level:"organization",showOnDesktop:!0,sortOrder:13},{id:"rapportages",moduleKey:"reports",defaultLabel:"Rapportages",icon:dT,route:{main:"admin",sub:"rapportages"},level:"organization",showOnDesktop:!0,sortOrder:10},{id:"email-templates",defaultLabel:"E-mailtemplates",icon:uo,route:{main:"admin",sub:"email-templates"},level:"organization",showOnDesktop:!0,sortOrder:11},{id:"daily-digest",defaultLabel:"Dagreports",icon:i$,route:{main:"admin",sub:"daily-digest"},level:"organization",showOnDesktop:!0,sortOrder:11.5},{id:"socials",moduleKey:"socials",defaultLabel:"Socials",icon:yT,route:{main:"admin",sub:"socials"},level:"organization",showOnDesktop:!0,sortOrder:15},{id:"waitlist",moduleKey:"waitlist",defaultLabel:"Wachtlijst",icon:To,route:{main:"admin",sub:"waitlist"},level:"organization",showOnDesktop:!0,sortOrder:16}];function mW(e,t,n){const{organization:r,userOrgRole:s}=zt(),a=e||(r==null?void 0:r.id),o=aW(a),l=(t==null?void 0:t.modules)??o.modules,c=n!==void 0?n:s,{roleModules:u}=ZP(a,c),d=p.useMemo(()=>fW(l,u),[l,u]),f=p.useCallback(N=>{const O=u.find(z=>z.module_key===N);return O?O.is_enabled:((t==null?void 0:t.isModuleEnabled)??o.isModuleEnabled)(N)},[u,t,o]),{t:h}=rW(),m=(r==null?void 0:r.branche)||"algemeen",v=(N,O,z)=>{var T,I;return O||((I=(T=Qc[m])==null?void 0:T[N])==null?void 0:I.display_name)||z||N},w=(N,O)=>{var H;const z=Xg[N];if(!z)return O;const T=d.find(V=>V.module_key===z),I=T==null?void 0:T.config;if(I!=null&&I.display_name)return I.display_name;const P=(H=Qc[m])==null?void 0:H[z];return P!=null&&P.display_name?P.display_name:O},y=(N,O="desktop")=>{var H;const z=Xg[N];if(!z)return!0;const T=d.find(V=>V.module_key===z);if(T){if(!T.is_enabled)return!1;const V=T.config;return O==="mobile"?(V==null?void 0:V.show_on_mobile)!==void 0?V.show_on_mobile:Qg[m].some(C=>C.moduleKey===z):(V==null?void 0:V.show_on_desktop)!==!1}const I=(H=Qc[m])==null?void 0:H[z];if(I!==void 0)return I.is_enabled;const P=qo.find(V=>V.key===z);return(P==null?void 0:P.defaultEnabled)??!0},x=N=>y(N,"desktop"),g=N=>{const O=qo.find(z=>z.key===N);return(O==null?void 0:O.description)||""},b=()=>Zg.filter(N=>N.level==="platform"&&N.showOnDesktop).sort((N,O)=>N.sortOrder-O.sortOrder).map(N=>({...N,label:N.defaultLabel,effectiveSortOrder:N.sortOrder})),_=(N=!1,O=!1,z="desktop")=>{const T=["demo"],I=P=>{if(!P.moduleKey)return P.sortOrder;const H=d.find(M=>M.module_key===P.moduleKey),V=H==null?void 0:H.config;return(V==null?void 0:V.sort_order)??P.sortOrder};return Zg.filter(P=>P.level!=="organization"||!P.showOnDesktop?!1:P.id==="demo"?N:!(T.includes(P.id)&&O||P.moduleKey&&!y(P.id,z))).sort((P,H)=>I(P)-I(H)).map(P=>({...P,label:P.id==="mijn-salon"?h("mySalon"):P.id==="inventory-v2"?P.defaultLabel:P.moduleKey?w(P.id,P.defaultLabel):P.defaultLabel,effectiveSortOrder:I(P),...P.id==="mijn-salon"&&m==="monteurs"?{icon:_c}:{}}))},j=()=>{var O;const N=[];for(const z of d){if(!z.is_enabled)continue;const T=z.config,I=z.module_key;if(T!=null&&T.show_on_mobile&&(T==null?void 0:T.mobile_position)==="bottom_nav"){const P=Yg[I];if(P){const H=qo.find(V=>V.key===I);N.push({id:I,moduleKey:I,label:v(I,T==null?void 0:T.display_name,H==null?void 0:H.label),icon:Gg[I]||Wt,mainSection:P.main,subSection:P.sub,sortOrder:T.sort_order??99})}}}if(N.length===0&&dW(d)){const z=Qg[m];for(const T of z){if(T.position!=="bottom_nav"||!f(T.moduleKey))continue;const I=Yg[T.moduleKey];if(!I)continue;const P=qo.find(V=>V.key===T.moduleKey),H=(O=Qc[m])==null?void 0:O[T.moduleKey];N.push({id:T.moduleKey,moduleKey:T.moduleKey,label:(H==null?void 0:H.display_name)||(P==null?void 0:P.label)||T.moduleKey,icon:Gg[T.moduleKey]||Wt,mainSection:I.main,subSection:I.sub,sortOrder:T.sortOrder})}}return N.sort((z,T)=>z.sortOrder-T.sortOrder).slice(0,hW)};return{getMenuLabel:w,isMenuItemVisible:x,isMenuItemVisibleOnPlatform:y,getMenuSubtitle:g,getMobileNavItems:j,getSettingsDrawerItems:()=>{const N=[],O=j(),z=new Set(O.map(T=>T.moduleKey));for(const T of d){if(!T.is_enabled)continue;const I=T.config,P=T.module_key;if(!z.has(P)&&I!=null&&I.show_on_mobile&&(I==null?void 0:I.mobile_position)==="settings_drawer"){const H=Yg[P];if(H){const V=qo.find(M=>M.key===P);N.push({id:P,moduleKey:P,label:v(P,I==null?void 0:I.display_name,V==null?void 0:V.label),icon:Gg[P]||Wt,mainSection:H.main,subSection:H.sub,sortOrder:I.sort_order??99})}}}return N.sort((T,I)=>T.sortOrder-I.sortOrder)},getModuleMobileConfig:N=>{const O=d.find(P=>P.module_key===N),z=O==null?void 0:O.config;if((z==null?void 0:z.show_on_mobile)!==void 0)return{showOnMobile:z.show_on_mobile,position:z.mobile_position||"settings_drawer"};const I=Qg[m].find(P=>P.moduleKey===N);return{showOnMobile:!!I,position:(I==null?void 0:I.position)||"settings_drawer"}},getPlatformMenuItems:b,getOrganizationMenuItems:_,getPlatformSettingsItems:()=>Zg.filter(N=>N.level==="platform"&&N.requiresSuperAdmin).sort((N,O)=>N.sortOrder-O.sortOrder).map(N=>({...N,label:N.defaultLabel,effectiveSortOrder:N.sortOrder})),branche:m,BRANCHE_DEFAULTS:Qc,MENU_TO_MODULE_MAP:Xg}}function Xc({children:e}){return i.jsx("div",{className:"flex min-w-0 flex-1 justify-center",children:e})}const pW=({activeSection:e,onSectionChange:t,onCreate:n,hidden:r=!1})=>{const{organization:s}=zt(),{getMobileNavItems:a,isMenuItemVisible:o}=mW(s==null?void 0:s.id),l=a(),c=l[0],u=l[1],d=o("berichten"),f=!u&&d,h=["acties",...l.map(w=>w.subSection),...f?["berichten","whatsapp","email"]:[]],m=e==="meer"||!h.includes(e),v=()=>{if(n){n();return}t("appointments","agenda-v2")};return i.jsx("nav",{className:Y("fixed bottom-0 left-0 right-0 z-[100] border-t border-[var(--nx-border)] bg-[hsl(var(--sheet))] md:hidden","transition-[transform,opacity] duration-300 ease-in-out",r?"translate-y-full opacity-0 pointer-events-none":"translate-y-0 opacity-100"),style:{paddingBottom:"max(env(safe-area-inset-bottom, 0px), 12px)"},children:i.jsxs("div",{className:"flex h-16 items-center px-1",children:[i.jsx(Xc,{children:i.jsx(Sr,{icon:Nd,label:"Vandaag",active:e==="acties",onClick:()=>t("admin","acties")})}),c?i.jsx(Xc,{children:i.jsx(Sr,{icon:c.icon,label:c.label,active:e===c.subSection,onClick:()=>t(c.mainSection,c.subSection)})}):i.jsx("div",{className:"flex-1","aria-hidden":"true"}),i.jsx("div",{className:"flex w-[62px] shrink-0 items-center justify-center",children:i.jsx("button",{type:"button","aria-label":"Nieuw",onClick:v,className:"-mt-5 flex h-[46px] w-[46px] items-center justify-center rounded-full bg-[var(--nx-primary)] text-white transition-transform active:scale-95 [box-shadow:0_8px_20px_hsl(22_90%_40%_/_0.35)]",children:i.jsx(jc,{className:"h-[22px] w-[22px]",strokeWidth:2.6})})}),u?i.jsx(Xc,{children:i.jsx(Sr,{icon:u.icon,label:u.label,active:e===u.subSection,onClick:()=>t(u.mainSection,u.subSection)})}):f?i.jsx(Xc,{children:i.jsx(Sr,{icon:mT,label:"Berichten",active:e==="berichten"||e==="whatsapp"||e==="email",onClick:()=>t("admin","berichten")})}):i.jsx("div",{className:"flex-1","aria-hidden":"true"}),i.jsx(Xc,{children:i.jsx(Sr,{icon:T5,label:"Meer",active:m,onClick:()=>t("admin","meer")})})]})})},gW={sm:"max-w-3xl",md:"max-w-4xl",lg:"max-w-6xl",xl:"max-w-7xl",full:"max-w-full"},Xo=({children:e,className:t,size:n="xl"})=>i.jsx("div",{className:Y("container mx-auto","px-4 sm:px-6 lg:px-8",gW[n],t),children:e}),dt=p.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:Y("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));dt.displayName="Card";const ln=p.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:Y("flex flex-col space-y-1.5 p-6",e),...t}));ln.displayName="CardHeader";const cn=p.forwardRef(({className:e,...t},n)=>i.jsx("h3",{ref:n,className:Y("text-2xl font-semibold leading-none tracking-tight",e),...t}));cn.displayName="CardTitle";const Os=p.forwardRef(({className:e,...t},n)=>i.jsx("p",{ref:n,className:Y("text-sm text-muted-foreground",e),...t}));Os.displayName="CardDescription";const bt=p.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:Y("p-6 pt-0",e),...t}));bt.displayName="CardContent";const yW=p.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:Y("flex items-center p-6 pt-0",e),...t}));yW.displayName="CardFooter";const $f=({title:e,value:t,subtitle:n,icon:r,variant:s="default",onClick:a})=>{const o={default:"bg-card border-border",primary:"bg-primary/10 border-primary/20",success:"bg-green-500/10 border-green-500/20",warning:"bg-amber-500/10 border-amber-500/20"},l={default:"text-muted-foreground",primary:"text-primary",success:"text-green-600",warning:"text-amber-600"};return i.jsx(dt,{className:Y("border transition-all min-h-[88px]",o[s],a&&"cursor-pointer hover:shadow-md hover:scale-[1.02] active:scale-[0.98]"),onClick:a,children:i.jsx(bt,{className:"p-3 sm:p-4 lg:p-6",children:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-xs sm:text-sm font-medium text-muted-foreground truncate",children:e}),i.jsx("p",{className:"text-xl sm:text-2xl lg:text-3xl font-bold mt-0.5 sm:mt-1",children:t}),n&&i.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground mt-0.5 sm:mt-1 truncate",children:n})]}),i.jsx("div",{className:Y("p-1.5 sm:p-2 lg:p-3 rounded-full bg-background/50 shrink-0",l[s]),children:i.jsx(r,{className:"h-4 w-4 sm:h-5 sm:w-5 lg:h-6 lg:w-6"})})]})})})};function He(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function wt(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function mt(e,t){const n=He(e);return isNaN(t)?wt(e,NaN):(t&&n.setDate(n.getDate()+t),n)}function Pr(e,t){const n=He(e);if(isNaN(t))return wt(e,NaN);if(!t)return n;const r=n.getDate(),s=wt(e,n.getTime());s.setMonth(n.getMonth()+t+1,0);const a=s.getDate();return r>=a?s:(n.setFullYear(s.getFullYear(),s.getMonth(),r),n)}function vW(e){return He(e).getDay()===0}const K0=6048e5,xW=864e5,G0=6e4,Y0=36e5,wW=1e3,yse=43200,vse=1440;let bW={};function Ri(){return bW}function Pn(e,t){var l,c,u,d;const n=Ri(),r=(t==null?void 0:t.weekStartsOn)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,s=He(e),a=s.getDay(),o=(a=s.getTime()?n+1:t.getTime()>=o.getTime()?n:n-1}function _i(e){const t=He(e);return t.setHours(0,0,0,0),t}function cc(e){const t=He(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Fs(e,t){const n=_i(e),r=_i(t),s=+n-cc(n),a=+r-cc(r);return Math.round((s-a)/xW)}function _W(e){const t=JP(e),n=wt(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),_a(n)}function _x(e,t){const n=t*7;return mt(e,n)}function kW(e,t){return Pr(e,t*12)}function jW(e){let t;return e.forEach(function(n){const r=He(n);(t===void 0||t{const r=He(n);(!t||t>r||isNaN(+r))&&(t=r)}),t||new Date(NaN)}function mr(e,t){const n=_i(e),r=_i(t);return+n==+r}function Q0(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function EW(e){if(!Q0(e)&&typeof e!="number")return!1;const t=He(e);return!isNaN(Number(t))}function fd(e,t){const n=He(e),r=He(t),s=n.getFullYear()-r.getFullYear(),a=n.getMonth()-r.getMonth();return s*12+a}function NW(e,t,n){const r=Pn(e,n),s=Pn(t,n),a=+r-cc(r),o=+s-cc(s);return Math.round((a-o)/K0)}function gp(e){const t=He(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function Yn(e){const t=He(e);return t.setDate(1),t.setHours(0,0,0,0),t}function eA(e){const t=He(e),n=wt(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}function ko(e,t){var l,c,u,d;const n=Ri(),r=(t==null?void 0:t.weekStartsOn)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,s=He(e),a=s.getDay(),o=(a{let r;const s=CW[e];return typeof s=="string"?r=s:t===1?r=s.one:r=s.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function Ol(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const PW={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},AW={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},RW={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},OW={date:Ol({formats:PW,defaultWidth:"full"}),time:Ol({formats:AW,defaultWidth:"full"}),dateTime:Ol({formats:RW,defaultWidth:"full"})},MW={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},DW=(e,t,n,r)=>MW[e];function Ms(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let s;if(r==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,l=n!=null&&n.width?String(n.width):o;s=e.formattingValues[l]||e.formattingValues[o]}else{const o=e.defaultWidth,l=n!=null&&n.width?String(n.width):e.defaultWidth;s=e.values[l]||e.values[o]}const a=e.argumentCallback?e.argumentCallback(t):t;return s[a]}}const IW={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},LW={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},$W={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"]},FW={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"]},zW={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"}},BW={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"}},UW=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},VW={ordinalNumber:UW,era:Ms({values:IW,defaultWidth:"wide"}),quarter:Ms({values:LW,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ms({values:$W,defaultWidth:"wide"}),day:Ms({values:FW,defaultWidth:"wide"}),dayPeriod:Ms({values:zW,defaultWidth:"wide",formattingValues:BW,defaultFormattingWidth:"wide"})};function Ds(e){return(t,n={})=>{const r=n.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(s);if(!a)return null;const o=a[0],l=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(l)?HW(l,f=>f.test(o)):WW(l,f=>f.test(o));let u;u=e.valueCallback?e.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const d=t.slice(o.length);return{value:u,rest:d}}}function WW(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function HW(e,t){for(let n=0;n{const r=t.match(e.matchPattern);if(!r)return null;const s=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;const l=t.slice(s.length);return{value:o,rest:l}}}const qW=/^(\d+)(th|st|nd|rd)?/i,KW=/\d+/i,GW={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},YW={any:[/^b/i,/^(a|c)/i]},QW={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},XW={any:[/1/i,/2/i,/3/i,/4/i]},ZW={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},JW={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]},e7={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},t7={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]},n7={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},r7={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}},s7={ordinalNumber:nA({matchPattern:qW,parsePattern:KW,valueCallback:e=>parseInt(e,10)}),era:Ds({matchPatterns:GW,defaultMatchWidth:"wide",parsePatterns:YW,defaultParseWidth:"any"}),quarter:Ds({matchPatterns:QW,defaultMatchWidth:"wide",parsePatterns:XW,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Ds({matchPatterns:ZW,defaultMatchWidth:"wide",parsePatterns:JW,defaultParseWidth:"any"}),day:Ds({matchPatterns:e7,defaultMatchWidth:"wide",parsePatterns:t7,defaultParseWidth:"any"}),dayPeriod:Ds({matchPatterns:n7,defaultMatchWidth:"any",parsePatterns:r7,defaultParseWidth:"any"})},X0={code:"en-US",formatDistance:TW,formatLong:OW,formatRelative:DW,localize:VW,match:s7,options:{weekStartsOn:0,firstWeekContainsDate:1}};function a7(e){const t=He(e);return Fs(t,eA(t))+1}function Od(e){const t=He(e),n=+_a(t)-+_W(t);return Math.round(n/K0)+1}function Z0(e,t){var d,f,h,m;const n=He(e),r=n.getFullYear(),s=Ri(),a=(t==null?void 0:t.firstWeekContainsDate)??((f=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??s.firstWeekContainsDate??((m=(h=s.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??1,o=wt(e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);const l=Pn(o,t),c=wt(e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);const u=Pn(c,t);return n.getTime()>=l.getTime()?r+1:n.getTime()>=u.getTime()?r:r-1}function o7(e,t){var l,c,u,d;const n=Ri(),r=(t==null?void 0:t.firstWeekContainsDate)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.firstWeekContainsDate)??n.firstWeekContainsDate??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,s=Z0(e,t),a=wt(e,0);return a.setFullYear(s,0,r),a.setHours(0,0,0,0),Pn(a,t)}function yp(e,t){const n=He(e),r=+Pn(n,t)-+o7(n,t);return Math.round(r/K0)+1}function yt(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const Ra={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return yt(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):yt(n+1,2)},d(e,t){return yt(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return yt(e.getHours()%12||12,t.length)},H(e,t){return yt(e.getHours(),t.length)},m(e,t){return yt(e.getMinutes(),t.length)},s(e,t){return yt(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),s=Math.trunc(r*Math.pow(10,n-3));return yt(s,t.length)}},qi={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},ij={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),s=r>0?r:1-r;return n.ordinalNumber(s,{unit:"year"})}return Ra.y(e,t)},Y:function(e,t,n,r){const s=Z0(e,r),a=s>0?s:1-s;if(t==="YY"){const o=a%100;return yt(o,2)}return t==="Yo"?n.ordinalNumber(a,{unit:"year"}):yt(a,t.length)},R:function(e,t){const n=JP(e);return yt(n,t.length)},u:function(e,t){const n=e.getFullYear();return yt(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return yt(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return yt(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return Ra.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return yt(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const s=yp(e,r);return t==="wo"?n.ordinalNumber(s,{unit:"week"}):yt(s,t.length)},I:function(e,t,n){const r=Od(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):yt(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):Ra.d(e,t)},D:function(e,t,n){const r=a7(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):yt(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const s=e.getDay(),a=(s-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(a);case"ee":return yt(a,2);case"eo":return n.ordinalNumber(a,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});case"eeee":default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const s=e.getDay(),a=(s-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(a);case"cc":return yt(a,t.length);case"co":return n.ordinalNumber(a,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});case"cccc":default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),s=r===0?7:r;switch(t){case"i":return String(s);case"ii":return yt(s,t.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let s;switch(r===12?s=qi.noon:r===0?s=qi.midnight:s=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let s;switch(r>=17?s=qi.evening:r>=12?s=qi.afternoon:r>=4?s=qi.morning:s=qi.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Ra.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):Ra.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):yt(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):yt(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):Ra.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):Ra.s(e,t)},S:function(e,t){return Ra.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return cj(r);case"XXXX":case"XX":return Vo(r);case"XXXXX":case"XXX":default:return Vo(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return cj(r);case"xxxx":case"xx":return Vo(r);case"xxxxx":case"xxx":default:return Vo(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+lj(r,":");case"OOOO":default:return"GMT"+Vo(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+lj(r,":");case"zzzz":default:return"GMT"+Vo(r,":")}},t:function(e,t,n){const r=Math.trunc(e.getTime()/1e3);return yt(r,t.length)},T:function(e,t,n){const r=e.getTime();return yt(r,t.length)}};function lj(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=Math.trunc(r/60),a=r%60;return a===0?n+String(s):n+String(s)+t+yt(a,2)}function cj(e,t){return e%60===0?(e>0?"-":"+")+yt(Math.abs(e)/60,2):Vo(e,t)}function Vo(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=yt(Math.trunc(r/60),2),a=yt(r%60,2);return n+s+t+a}const uj=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},rA=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},i7=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],s=n[2];if(!s)return uj(e,t);let a;switch(r){case"P":a=t.dateTime({width:"short"});break;case"PP":a=t.dateTime({width:"medium"});break;case"PPP":a=t.dateTime({width:"long"});break;case"PPPP":default:a=t.dateTime({width:"full"});break}return a.replace("{{date}}",uj(r,t)).replace("{{time}}",rA(s,t))},kx={p:rA,P:i7},l7=/^D+$/,c7=/^Y+$/,u7=["D","DD","YY","YYYY"];function sA(e){return l7.test(e)}function aA(e){return c7.test(e)}function jx(e,t,n){const r=d7(e,t,n);if(console.warn(r),u7.includes(e))throw new RangeError(r)}function d7(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const f7=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,h7=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,m7=/^'([^]*?)'?$/,p7=/''/g,g7=/[a-zA-Z]/;function he(e,t,n){var d,f,h,m,v,w,y,x;const r=Ri(),s=(n==null?void 0:n.locale)??r.locale??X0,a=(n==null?void 0:n.firstWeekContainsDate)??((f=(d=n==null?void 0:n.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??r.firstWeekContainsDate??((m=(h=r.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??1,o=(n==null?void 0:n.weekStartsOn)??((w=(v=n==null?void 0:n.locale)==null?void 0:v.options)==null?void 0:w.weekStartsOn)??r.weekStartsOn??((x=(y=r.locale)==null?void 0:y.options)==null?void 0:x.weekStartsOn)??0,l=He(e);if(!EW(l))throw new RangeError("Invalid time value");let c=t.match(h7).map(g=>{const b=g[0];if(b==="p"||b==="P"){const _=kx[b];return _(g,s.formatLong)}return g}).join("").match(f7).map(g=>{if(g==="''")return{isToken:!1,value:"'"};const b=g[0];if(b==="'")return{isToken:!1,value:y7(g)};if(ij[b])return{isToken:!0,value:g};if(b.match(g7))throw new RangeError("Format string contains an unescaped latin alphabet character `"+b+"`");return{isToken:!1,value:g}});s.localize.preprocessor&&(c=s.localize.preprocessor(l,c));const u={firstWeekContainsDate:a,weekStartsOn:o,locale:s};return c.map(g=>{if(!g.isToken)return g.value;const b=g.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&aA(b)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&sA(b))&&jx(b,t,String(e));const _=ij[b[0]];return _(l,b,s.localize,u)}).join("")}function y7(e){const t=e.match(m7);return t?t[1].replace(p7,"'"):e}function v7(e){const t=He(e),n=t.getFullYear(),r=t.getMonth(),s=wt(e,0);return s.setFullYear(n,r+1,0),s.setHours(0,0,0,0),s.getDate()}function x7(){return Object.assign({},Ri())}function w7(e){let n=He(e).getDay();return n===0&&(n=7),n}function b7(e){return Math.trunc(+He(e)/1e3)}function _7(e){const t=He(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(0,0,0,0),t}function k7(e,t){return NW(_7(e),Yn(e),t)+1}function Sx(e,t){const n=He(e),r=He(t);return n.getTime()>r.getTime()}function J0(e,t){const n=He(e),r=He(t);return+n<+r}function j7(e,t){const n=t instanceof Date?wt(t,0):new t(0);return n.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),n.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),n}const S7=10;class oA{constructor(){ge(this,"subPriority",0)}validate(t,n){return!0}}class E7 extends oA{constructor(t,n,r,s,a){super(),this.value=t,this.validateValue=n,this.setValue=r,this.priority=s,a&&(this.subPriority=a)}validate(t,n){return this.validateValue(t,this.value,n)}set(t,n,r){return this.setValue(t,n,this.value,r)}}class N7 extends oA{constructor(){super(...arguments);ge(this,"priority",S7);ge(this,"subPriority",-1)}set(n,r){return r.timestampIsSet?n:wt(n,j7(n,Date))}}class ft{run(t,n,r,s){const a=this.parse(t,n,r,s);return a?{setter:new E7(a.value,this.validate,this.set,this.priority,this.subPriority),rest:a.rest}:null}validate(t,n,r){return!0}}class C7 extends ft{constructor(){super(...arguments);ge(this,"priority",140);ge(this,"incompatibleTokens",["R","u","t","T"])}parse(n,r,s){switch(r){case"G":case"GG":case"GGG":return s.era(n,{width:"abbreviated"})||s.era(n,{width:"narrow"});case"GGGGG":return s.era(n,{width:"narrow"});case"GGGG":default:return s.era(n,{width:"wide"})||s.era(n,{width:"abbreviated"})||s.era(n,{width:"narrow"})}}set(n,r,s){return r.era=s,n.setFullYear(s,0,1),n.setHours(0,0,0,0),n}}const Yt={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}/},Is={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 Qt(e,t){return e&&{value:t(e.value),rest:e.rest}}function It(e,t){const n=t.match(e);return n?{value:parseInt(n[0],10),rest:t.slice(n[0].length)}:null}function Ls(e,t){const n=t.match(e);if(!n)return null;if(n[0]==="Z")return{value:0,rest:t.slice(1)};const r=n[1]==="+"?1:-1,s=n[2]?parseInt(n[2],10):0,a=n[3]?parseInt(n[3],10):0,o=n[5]?parseInt(n[5],10):0;return{value:r*(s*Y0+a*G0+o*wW),rest:t.slice(n[0].length)}}function iA(e){return It(Yt.anyDigitsSigned,e)}function qt(e,t){switch(e){case 1:return It(Yt.singleDigit,t);case 2:return It(Yt.twoDigits,t);case 3:return It(Yt.threeDigits,t);case 4:return It(Yt.fourDigits,t);default:return It(new RegExp("^\\d{1,"+e+"}"),t)}}function um(e,t){switch(e){case 1:return It(Yt.singleDigitSigned,t);case 2:return It(Yt.twoDigitsSigned,t);case 3:return It(Yt.threeDigitsSigned,t);case 4:return It(Yt.fourDigitsSigned,t);default:return It(new RegExp("^-?\\d{1,"+e+"}"),t)}}function eb(e){switch(e){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 lA(e,t){const n=t>0,r=n?t:1-t;let s;if(r<=50)s=e||100;else{const a=r+50,o=Math.trunc(a/100)*100,l=e>=a%100;s=e+o-(l?100:0)}return n?s:1-s}function cA(e){return e%400===0||e%4===0&&e%100!==0}class T7 extends ft{constructor(){super(...arguments);ge(this,"priority",130);ge(this,"incompatibleTokens",["Y","R","u","w","I","i","e","c","t","T"])}parse(n,r,s){const a=o=>({year:o,isTwoDigitYear:r==="yy"});switch(r){case"y":return Qt(qt(4,n),a);case"yo":return Qt(s.ordinalNumber(n,{unit:"year"}),a);default:return Qt(qt(r.length,n),a)}}validate(n,r){return r.isTwoDigitYear||r.year>0}set(n,r,s){const a=n.getFullYear();if(s.isTwoDigitYear){const l=lA(s.year,a);return n.setFullYear(l,0,1),n.setHours(0,0,0,0),n}const o=!("era"in r)||r.era===1?s.year:1-s.year;return n.setFullYear(o,0,1),n.setHours(0,0,0,0),n}}class P7 extends ft{constructor(){super(...arguments);ge(this,"priority",130);ge(this,"incompatibleTokens",["y","R","u","Q","q","M","L","I","d","D","i","t","T"])}parse(n,r,s){const a=o=>({year:o,isTwoDigitYear:r==="YY"});switch(r){case"Y":return Qt(qt(4,n),a);case"Yo":return Qt(s.ordinalNumber(n,{unit:"year"}),a);default:return Qt(qt(r.length,n),a)}}validate(n,r){return r.isTwoDigitYear||r.year>0}set(n,r,s,a){const o=Z0(n,a);if(s.isTwoDigitYear){const c=lA(s.year,o);return n.setFullYear(c,0,a.firstWeekContainsDate),n.setHours(0,0,0,0),Pn(n,a)}const l=!("era"in r)||r.era===1?s.year:1-s.year;return n.setFullYear(l,0,a.firstWeekContainsDate),n.setHours(0,0,0,0),Pn(n,a)}}class A7 extends ft{constructor(){super(...arguments);ge(this,"priority",130);ge(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(n,r){return um(r==="R"?4:r.length,n)}set(n,r,s){const a=wt(n,0);return a.setFullYear(s,0,4),a.setHours(0,0,0,0),_a(a)}}class R7 extends ft{constructor(){super(...arguments);ge(this,"priority",130);ge(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(n,r){return um(r==="u"?4:r.length,n)}set(n,r,s){return n.setFullYear(s,0,1),n.setHours(0,0,0,0),n}}class O7 extends ft{constructor(){super(...arguments);ge(this,"priority",120);ge(this,"incompatibleTokens",["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"])}parse(n,r,s){switch(r){case"Q":case"QQ":return qt(r.length,n);case"Qo":return s.ordinalNumber(n,{unit:"quarter"});case"QQQ":return s.quarter(n,{width:"abbreviated",context:"formatting"})||s.quarter(n,{width:"narrow",context:"formatting"});case"QQQQQ":return s.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(n,{width:"wide",context:"formatting"})||s.quarter(n,{width:"abbreviated",context:"formatting"})||s.quarter(n,{width:"narrow",context:"formatting"})}}validate(n,r){return r>=1&&r<=4}set(n,r,s){return n.setMonth((s-1)*3,1),n.setHours(0,0,0,0),n}}class M7 extends ft{constructor(){super(...arguments);ge(this,"priority",120);ge(this,"incompatibleTokens",["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"])}parse(n,r,s){switch(r){case"q":case"qq":return qt(r.length,n);case"qo":return s.ordinalNumber(n,{unit:"quarter"});case"qqq":return s.quarter(n,{width:"abbreviated",context:"standalone"})||s.quarter(n,{width:"narrow",context:"standalone"});case"qqqqq":return s.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(n,{width:"wide",context:"standalone"})||s.quarter(n,{width:"abbreviated",context:"standalone"})||s.quarter(n,{width:"narrow",context:"standalone"})}}validate(n,r){return r>=1&&r<=4}set(n,r,s){return n.setMonth((s-1)*3,1),n.setHours(0,0,0,0),n}}class D7 extends ft{constructor(){super(...arguments);ge(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);ge(this,"priority",110)}parse(n,r,s){const a=o=>o-1;switch(r){case"M":return Qt(It(Yt.month,n),a);case"MM":return Qt(qt(2,n),a);case"Mo":return Qt(s.ordinalNumber(n,{unit:"month"}),a);case"MMM":return s.month(n,{width:"abbreviated",context:"formatting"})||s.month(n,{width:"narrow",context:"formatting"});case"MMMMM":return s.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(n,{width:"wide",context:"formatting"})||s.month(n,{width:"abbreviated",context:"formatting"})||s.month(n,{width:"narrow",context:"formatting"})}}validate(n,r){return r>=0&&r<=11}set(n,r,s){return n.setMonth(s,1),n.setHours(0,0,0,0),n}}class I7 extends ft{constructor(){super(...arguments);ge(this,"priority",110);ge(this,"incompatibleTokens",["Y","R","q","Q","M","w","I","D","i","e","c","t","T"])}parse(n,r,s){const a=o=>o-1;switch(r){case"L":return Qt(It(Yt.month,n),a);case"LL":return Qt(qt(2,n),a);case"Lo":return Qt(s.ordinalNumber(n,{unit:"month"}),a);case"LLL":return s.month(n,{width:"abbreviated",context:"standalone"})||s.month(n,{width:"narrow",context:"standalone"});case"LLLLL":return s.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(n,{width:"wide",context:"standalone"})||s.month(n,{width:"abbreviated",context:"standalone"})||s.month(n,{width:"narrow",context:"standalone"})}}validate(n,r){return r>=0&&r<=11}set(n,r,s){return n.setMonth(s,1),n.setHours(0,0,0,0),n}}function L7(e,t,n){const r=He(e),s=yp(r,n)-t;return r.setDate(r.getDate()-s*7),r}class $7 extends ft{constructor(){super(...arguments);ge(this,"priority",100);ge(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(n,r,s){switch(r){case"w":return It(Yt.week,n);case"wo":return s.ordinalNumber(n,{unit:"week"});default:return qt(r.length,n)}}validate(n,r){return r>=1&&r<=53}set(n,r,s,a){return Pn(L7(n,s,a),a)}}function F7(e,t){const n=He(e),r=Od(n)-t;return n.setDate(n.getDate()-r*7),n}class z7 extends ft{constructor(){super(...arguments);ge(this,"priority",100);ge(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"])}parse(n,r,s){switch(r){case"I":return It(Yt.week,n);case"Io":return s.ordinalNumber(n,{unit:"week"});default:return qt(r.length,n)}}validate(n,r){return r>=1&&r<=53}set(n,r,s){return _a(F7(n,s))}}const B7=[31,28,31,30,31,30,31,31,30,31,30,31],U7=[31,29,31,30,31,30,31,31,30,31,30,31];class V7 extends ft{constructor(){super(...arguments);ge(this,"priority",90);ge(this,"subPriority",1);ge(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(n,r,s){switch(r){case"d":return It(Yt.date,n);case"do":return s.ordinalNumber(n,{unit:"date"});default:return qt(r.length,n)}}validate(n,r){const s=n.getFullYear(),a=cA(s),o=n.getMonth();return a?r>=1&&r<=U7[o]:r>=1&&r<=B7[o]}set(n,r,s){return n.setDate(s),n.setHours(0,0,0,0),n}}class W7 extends ft{constructor(){super(...arguments);ge(this,"priority",90);ge(this,"subpriority",1);ge(this,"incompatibleTokens",["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"])}parse(n,r,s){switch(r){case"D":case"DD":return It(Yt.dayOfYear,n);case"Do":return s.ordinalNumber(n,{unit:"date"});default:return qt(r.length,n)}}validate(n,r){const s=n.getFullYear();return cA(s)?r>=1&&r<=366:r>=1&&r<=365}set(n,r,s){return n.setMonth(0,s),n.setHours(0,0,0,0),n}}function tb(e,t,n){var f,h,m,v;const r=Ri(),s=(n==null?void 0:n.weekStartsOn)??((h=(f=n==null?void 0:n.locale)==null?void 0:f.options)==null?void 0:h.weekStartsOn)??r.weekStartsOn??((v=(m=r.locale)==null?void 0:m.options)==null?void 0:v.weekStartsOn)??0,a=He(e),o=a.getDay(),c=(t%7+7)%7,u=7-s,d=t<0||t>6?t-(o+u)%7:(c+u)%7-(o+u)%7;return mt(a,d)}class H7 extends ft{constructor(){super(...arguments);ge(this,"priority",90);ge(this,"incompatibleTokens",["D","i","e","c","t","T"])}parse(n,r,s){switch(r){case"E":case"EE":case"EEE":return s.day(n,{width:"abbreviated",context:"formatting"})||s.day(n,{width:"short",context:"formatting"})||s.day(n,{width:"narrow",context:"formatting"});case"EEEEE":return s.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(n,{width:"short",context:"formatting"})||s.day(n,{width:"narrow",context:"formatting"});case"EEEE":default:return s.day(n,{width:"wide",context:"formatting"})||s.day(n,{width:"abbreviated",context:"formatting"})||s.day(n,{width:"short",context:"formatting"})||s.day(n,{width:"narrow",context:"formatting"})}}validate(n,r){return r>=0&&r<=6}set(n,r,s,a){return n=tb(n,s,a),n.setHours(0,0,0,0),n}}class q7 extends ft{constructor(){super(...arguments);ge(this,"priority",90);ge(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"])}parse(n,r,s,a){const o=l=>{const c=Math.floor((l-1)/7)*7;return(l+a.weekStartsOn+6)%7+c};switch(r){case"e":case"ee":return Qt(qt(r.length,n),o);case"eo":return Qt(s.ordinalNumber(n,{unit:"day"}),o);case"eee":return s.day(n,{width:"abbreviated",context:"formatting"})||s.day(n,{width:"short",context:"formatting"})||s.day(n,{width:"narrow",context:"formatting"});case"eeeee":return s.day(n,{width:"narrow",context:"formatting"});case"eeeeee":return s.day(n,{width:"short",context:"formatting"})||s.day(n,{width:"narrow",context:"formatting"});case"eeee":default:return s.day(n,{width:"wide",context:"formatting"})||s.day(n,{width:"abbreviated",context:"formatting"})||s.day(n,{width:"short",context:"formatting"})||s.day(n,{width:"narrow",context:"formatting"})}}validate(n,r){return r>=0&&r<=6}set(n,r,s,a){return n=tb(n,s,a),n.setHours(0,0,0,0),n}}class K7 extends ft{constructor(){super(...arguments);ge(this,"priority",90);ge(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"])}parse(n,r,s,a){const o=l=>{const c=Math.floor((l-1)/7)*7;return(l+a.weekStartsOn+6)%7+c};switch(r){case"c":case"cc":return Qt(qt(r.length,n),o);case"co":return Qt(s.ordinalNumber(n,{unit:"day"}),o);case"ccc":return s.day(n,{width:"abbreviated",context:"standalone"})||s.day(n,{width:"short",context:"standalone"})||s.day(n,{width:"narrow",context:"standalone"});case"ccccc":return s.day(n,{width:"narrow",context:"standalone"});case"cccccc":return s.day(n,{width:"short",context:"standalone"})||s.day(n,{width:"narrow",context:"standalone"});case"cccc":default:return s.day(n,{width:"wide",context:"standalone"})||s.day(n,{width:"abbreviated",context:"standalone"})||s.day(n,{width:"short",context:"standalone"})||s.day(n,{width:"narrow",context:"standalone"})}}validate(n,r){return r>=0&&r<=6}set(n,r,s,a){return n=tb(n,s,a),n.setHours(0,0,0,0),n}}function G7(e,t){const n=He(e),r=w7(n),s=t-r;return mt(n,s)}class Y7 extends ft{constructor(){super(...arguments);ge(this,"priority",90);ge(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"])}parse(n,r,s){const a=o=>o===0?7:o;switch(r){case"i":case"ii":return qt(r.length,n);case"io":return s.ordinalNumber(n,{unit:"day"});case"iii":return Qt(s.day(n,{width:"abbreviated",context:"formatting"})||s.day(n,{width:"short",context:"formatting"})||s.day(n,{width:"narrow",context:"formatting"}),a);case"iiiii":return Qt(s.day(n,{width:"narrow",context:"formatting"}),a);case"iiiiii":return Qt(s.day(n,{width:"short",context:"formatting"})||s.day(n,{width:"narrow",context:"formatting"}),a);case"iiii":default:return Qt(s.day(n,{width:"wide",context:"formatting"})||s.day(n,{width:"abbreviated",context:"formatting"})||s.day(n,{width:"short",context:"formatting"})||s.day(n,{width:"narrow",context:"formatting"}),a)}}validate(n,r){return r>=1&&r<=7}set(n,r,s){return n=G7(n,s),n.setHours(0,0,0,0),n}}class Q7 extends ft{constructor(){super(...arguments);ge(this,"priority",80);ge(this,"incompatibleTokens",["b","B","H","k","t","T"])}parse(n,r,s){switch(r){case"a":case"aa":case"aaa":return s.dayPeriod(n,{width:"abbreviated",context:"formatting"})||s.dayPeriod(n,{width:"narrow",context:"formatting"});case"aaaaa":return s.dayPeriod(n,{width:"narrow",context:"formatting"});case"aaaa":default:return s.dayPeriod(n,{width:"wide",context:"formatting"})||s.dayPeriod(n,{width:"abbreviated",context:"formatting"})||s.dayPeriod(n,{width:"narrow",context:"formatting"})}}set(n,r,s){return n.setHours(eb(s),0,0,0),n}}class X7 extends ft{constructor(){super(...arguments);ge(this,"priority",80);ge(this,"incompatibleTokens",["a","B","H","k","t","T"])}parse(n,r,s){switch(r){case"b":case"bb":case"bbb":return s.dayPeriod(n,{width:"abbreviated",context:"formatting"})||s.dayPeriod(n,{width:"narrow",context:"formatting"});case"bbbbb":return s.dayPeriod(n,{width:"narrow",context:"formatting"});case"bbbb":default:return s.dayPeriod(n,{width:"wide",context:"formatting"})||s.dayPeriod(n,{width:"abbreviated",context:"formatting"})||s.dayPeriod(n,{width:"narrow",context:"formatting"})}}set(n,r,s){return n.setHours(eb(s),0,0,0),n}}class Z7 extends ft{constructor(){super(...arguments);ge(this,"priority",80);ge(this,"incompatibleTokens",["a","b","t","T"])}parse(n,r,s){switch(r){case"B":case"BB":case"BBB":return s.dayPeriod(n,{width:"abbreviated",context:"formatting"})||s.dayPeriod(n,{width:"narrow",context:"formatting"});case"BBBBB":return s.dayPeriod(n,{width:"narrow",context:"formatting"});case"BBBB":default:return s.dayPeriod(n,{width:"wide",context:"formatting"})||s.dayPeriod(n,{width:"abbreviated",context:"formatting"})||s.dayPeriod(n,{width:"narrow",context:"formatting"})}}set(n,r,s){return n.setHours(eb(s),0,0,0),n}}class J7 extends ft{constructor(){super(...arguments);ge(this,"priority",70);ge(this,"incompatibleTokens",["H","K","k","t","T"])}parse(n,r,s){switch(r){case"h":return It(Yt.hour12h,n);case"ho":return s.ordinalNumber(n,{unit:"hour"});default:return qt(r.length,n)}}validate(n,r){return r>=1&&r<=12}set(n,r,s){const a=n.getHours()>=12;return a&&s<12?n.setHours(s+12,0,0,0):!a&&s===12?n.setHours(0,0,0,0):n.setHours(s,0,0,0),n}}class eH extends ft{constructor(){super(...arguments);ge(this,"priority",70);ge(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(n,r,s){switch(r){case"H":return It(Yt.hour23h,n);case"Ho":return s.ordinalNumber(n,{unit:"hour"});default:return qt(r.length,n)}}validate(n,r){return r>=0&&r<=23}set(n,r,s){return n.setHours(s,0,0,0),n}}class tH extends ft{constructor(){super(...arguments);ge(this,"priority",70);ge(this,"incompatibleTokens",["h","H","k","t","T"])}parse(n,r,s){switch(r){case"K":return It(Yt.hour11h,n);case"Ko":return s.ordinalNumber(n,{unit:"hour"});default:return qt(r.length,n)}}validate(n,r){return r>=0&&r<=11}set(n,r,s){return n.getHours()>=12&&s<12?n.setHours(s+12,0,0,0):n.setHours(s,0,0,0),n}}class nH extends ft{constructor(){super(...arguments);ge(this,"priority",70);ge(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(n,r,s){switch(r){case"k":return It(Yt.hour24h,n);case"ko":return s.ordinalNumber(n,{unit:"hour"});default:return qt(r.length,n)}}validate(n,r){return r>=1&&r<=24}set(n,r,s){const a=s<=24?s%24:s;return n.setHours(a,0,0,0),n}}class rH extends ft{constructor(){super(...arguments);ge(this,"priority",60);ge(this,"incompatibleTokens",["t","T"])}parse(n,r,s){switch(r){case"m":return It(Yt.minute,n);case"mo":return s.ordinalNumber(n,{unit:"minute"});default:return qt(r.length,n)}}validate(n,r){return r>=0&&r<=59}set(n,r,s){return n.setMinutes(s,0,0),n}}class sH extends ft{constructor(){super(...arguments);ge(this,"priority",50);ge(this,"incompatibleTokens",["t","T"])}parse(n,r,s){switch(r){case"s":return It(Yt.second,n);case"so":return s.ordinalNumber(n,{unit:"second"});default:return qt(r.length,n)}}validate(n,r){return r>=0&&r<=59}set(n,r,s){return n.setSeconds(s,0),n}}class aH extends ft{constructor(){super(...arguments);ge(this,"priority",30);ge(this,"incompatibleTokens",["t","T"])}parse(n,r){const s=a=>Math.trunc(a*Math.pow(10,-r.length+3));return Qt(qt(r.length,n),s)}set(n,r,s){return n.setMilliseconds(s),n}}class oH extends ft{constructor(){super(...arguments);ge(this,"priority",10);ge(this,"incompatibleTokens",["t","T","x"])}parse(n,r){switch(r){case"X":return Ls(Is.basicOptionalMinutes,n);case"XX":return Ls(Is.basic,n);case"XXXX":return Ls(Is.basicOptionalSeconds,n);case"XXXXX":return Ls(Is.extendedOptionalSeconds,n);case"XXX":default:return Ls(Is.extended,n)}}set(n,r,s){return r.timestampIsSet?n:wt(n,n.getTime()-cc(n)-s)}}class iH extends ft{constructor(){super(...arguments);ge(this,"priority",10);ge(this,"incompatibleTokens",["t","T","X"])}parse(n,r){switch(r){case"x":return Ls(Is.basicOptionalMinutes,n);case"xx":return Ls(Is.basic,n);case"xxxx":return Ls(Is.basicOptionalSeconds,n);case"xxxxx":return Ls(Is.extendedOptionalSeconds,n);case"xxx":default:return Ls(Is.extended,n)}}set(n,r,s){return r.timestampIsSet?n:wt(n,n.getTime()-cc(n)-s)}}class lH extends ft{constructor(){super(...arguments);ge(this,"priority",40);ge(this,"incompatibleTokens","*")}parse(n){return iA(n)}set(n,r,s){return[wt(n,s*1e3),{timestampIsSet:!0}]}}class cH extends ft{constructor(){super(...arguments);ge(this,"priority",20);ge(this,"incompatibleTokens","*")}parse(n){return iA(n)}set(n,r,s){return[wt(n,s),{timestampIsSet:!0}]}}const uH={G:new C7,y:new T7,Y:new P7,R:new A7,u:new R7,Q:new O7,q:new M7,M:new D7,L:new I7,w:new $7,I:new z7,d:new V7,D:new W7,E:new H7,e:new q7,c:new K7,i:new Y7,a:new Q7,b:new X7,B:new Z7,h:new J7,H:new eH,K:new tH,k:new nH,m:new rH,s:new sH,S:new aH,X:new oH,x:new iH,t:new lH,T:new cH},dH=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,fH=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,hH=/^'([^]*?)'?$/,mH=/''/g,pH=/\S/,gH=/[a-zA-Z]/;function uA(e,t,n,r){var w,y,x,g;const s=x7(),a=s.locale??X0,o=s.firstWeekContainsDate??((y=(w=s.locale)==null?void 0:w.options)==null?void 0:y.firstWeekContainsDate)??1,l=s.weekStartsOn??((g=(x=s.locale)==null?void 0:x.options)==null?void 0:g.weekStartsOn)??0;if(t==="")return e===""?He(n):wt(n,NaN);const c={firstWeekContainsDate:o,weekStartsOn:l,locale:a},u=[new N7],d=t.match(fH).map(b=>{const _=b[0];if(_ in kx){const j=kx[_];return j(b,a.formatLong)}return b}).join("").match(dH),f=[];for(let b of d){aA(b)&&jx(b,t,e),sA(b)&&jx(b,t,e);const _=b[0],j=uH[_];if(j){const{incompatibleTokens:k}=j;if(Array.isArray(k)){const E=f.find(N=>k.includes(N.token)||N.token===_);if(E)throw new RangeError(`The format string mustn't contain \`${E.fullToken}\` and \`${b}\` at the same time`)}else if(j.incompatibleTokens==="*"&&f.length>0)throw new RangeError(`The format string mustn't contain \`${b}\` and any other token at the same time`);f.push({token:_,fullToken:b});const S=j.run(e,b,a.match,c);if(!S)return wt(n,NaN);u.push(S.setter),e=S.rest}else{if(_.match(gH))throw new RangeError("Format string contains an unescaped latin alphabet character `"+_+"`");if(b==="''"?b="'":_==="'"&&(b=yH(b)),e.indexOf(b)===0)e=e.slice(b.length);else return wt(n,NaN)}}if(e.length>0&&pH.test(e))return wt(n,NaN);const h=u.map(b=>b.priority).sort((b,_)=>_-b).filter((b,_,j)=>j.indexOf(b)===_).map(b=>u.filter(_=>_.priority===b).sort((_,j)=>j.subPriority-_.subPriority)).map(b=>b[0]);let m=He(n);if(isNaN(m.getTime()))return wt(n,NaN);const v={};for(const b of h){if(!b.validate(m,c))return wt(n,NaN);const _=b.set(m,v,c);Array.isArray(_)?(m=_[0],Object.assign(v,_[1])):m=_}return wt(n,m)}function yH(e){return e.match(hH)[1].replace(mH,"'")}function vp(e,t){const n=He(e),r=He(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()}function vH(e,t){const n=He(e),r=He(t);return n.getFullYear()===r.getFullYear()}function Jg(e,t){return mt(e,-t)}function mn(e,t){const r=_H(e);let s;if(r.date){const c=kH(r.date,2);s=jH(c.restDateString,c.year)}if(!s||isNaN(s.getTime()))return new Date(NaN);const a=s.getTime();let o=0,l;if(r.time&&(o=SH(r.time),isNaN(o)))return new Date(NaN);if(r.timezone){if(l=EH(r.timezone),isNaN(l))return new Date(NaN)}else{const c=new Date(a+o),u=new Date(0);return u.setFullYear(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),u.setHours(c.getUTCHours(),c.getUTCMinutes(),c.getUTCSeconds(),c.getUTCMilliseconds()),u}return new Date(a+o+l)}const Ff={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},xH=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,wH=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,bH=/^([+-])(\d{2})(?::?(\d{2}))?$/;function _H(e){const t={},n=e.split(Ff.dateTimeDelimiter);let r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],Ff.timeZoneDelimiter.test(t.date)&&(t.date=e.split(Ff.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){const s=Ff.timezone.exec(r);s?(t.time=r.replace(s[1],""),t.timezone=s[1]):t.time=r}return t}function kH(e,t){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(n);if(!r)return{year:NaN,restDateString:""};const s=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?s:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function jH(e,t){if(t===null)return new Date(NaN);const n=e.match(xH);if(!n)return new Date(NaN);const r=!!n[4],s=Zc(n[1]),a=Zc(n[2])-1,o=Zc(n[3]),l=Zc(n[4]),c=Zc(n[5])-1;if(r)return AH(t,l,c)?NH(t,l,c):new Date(NaN);{const u=new Date(0);return!TH(t,a,o)||!PH(t,s)?new Date(NaN):(u.setUTCFullYear(t,a,Math.max(s,o)),u)}}function Zc(e){return e?parseInt(e):1}function SH(e){const t=e.match(wH);if(!t)return NaN;const n=ey(t[1]),r=ey(t[2]),s=ey(t[3]);return RH(n,r,s)?n*Y0+r*G0+s*1e3:NaN}function ey(e){return e&&parseFloat(e.replace(",","."))||0}function EH(e){if(e==="Z")return 0;const t=e.match(bH);if(!t)return 0;const n=t[1]==="+"?-1:1,r=parseInt(t[2]),s=t[3]&&parseInt(t[3])||0;return OH(r,s)?n*(r*Y0+s*G0):NaN}function NH(e,t,n){const r=new Date(0);r.setUTCFullYear(e,0,4);const s=r.getUTCDay()||7,a=(t-1)*7+n+1-s;return r.setUTCDate(r.getUTCDate()+a),r}const CH=[31,null,31,30,31,30,31,31,30,31,30,31];function dA(e){return e%400===0||e%4===0&&e%100!==0}function TH(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(CH[t]||(dA(e)?29:28))}function PH(e,t){return t>=1&&t<=(dA(e)?366:365)}function AH(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function RH(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function OH(e,t){return t>=0&&t<=59}function ty(e,t){const n=He(e),r=n.getFullYear(),s=n.getDate(),a=wt(e,0);a.setFullYear(r,t,15),a.setHours(0,0,0,0);const o=v7(a);return n.setMonth(t,Math.min(s,o)),n}function dj(e,t){const n=He(e);return isNaN(+n)?wt(e,NaN):(n.setFullYear(t),n)}function Dt({className:e,...t}){return i.jsx("div",{className:Y("animate-pulse rounded-md bg-muted",e),...t})}function MH(e,t,n,r){return xt({queryKey:["agenda-items",e,t,n,r],queryFn:async()=>{if(!e)return[];const s={_organization_id:e,_from:`${t}T00:00:00+00:00`,_to:`${n}T23:59:59+00:00`};r&&(s._staff_id=r);const{data:a,error:o}=await B.rpc("get_agenda_items",s);if(o)throw o;return a||[]},enabled:!!e})}const DH=({staffId:e,limit:t=8,title:n="Agenda Vandaag"})=>{const{organization:r}=zt(),s=he(new Date,"yyyy-MM-dd"),{data:a=[],isLoading:o}=MH(r==null?void 0:r.id,s,s,e),l=new Date,c=a.filter(h=>h.item_type==="task"&&h.status==="todo"&&new Date(h.end_at)!c.includes(h)).slice(0,t),d=h=>{if(h.item_type==="task")return i.jsxs(Qe,{variant:"accent",className:"text-[10px] sm:text-xs gap-1",children:[i.jsx(z5,{className:"h-2.5 w-2.5"}),"Taak"]});switch(h.status){case"confirmed":return i.jsx(Qe,{variant:"default",className:"bg-green-600 text-[10px] sm:text-xs",children:"Bevestigd"});case"pending":return i.jsx(Qe,{variant:"secondary",className:"text-[10px] sm:text-xs",children:"In afwachting"});case"completed":case"done":return i.jsx(Qe,{variant:"outline",className:"text-[10px] sm:text-xs",children:"Afgerond"});default:return null}},f=h=>{if(!h.start_at)return null;try{const m=new Date(h.start_at);return he(m,"HH:mm")}catch{return null}};return o?i.jsxs(dt,{children:[i.jsx(ln,{className:"px-3 sm:px-6",children:i.jsxs(cn,{className:"flex items-center gap-2 text-base sm:text-lg",children:[i.jsx(Wt,{className:"h-4 w-4 sm:h-5 sm:w-5"}),n]})}),i.jsx(bt,{className:"space-y-2 sm:space-y-3 px-3 sm:px-6",children:[...Array(3)].map((h,m)=>i.jsx(Dt,{className:"h-14 sm:h-16 w-full"},m))})]}):i.jsxs(dt,{children:[i.jsx(ln,{className:"pb-2 sm:pb-3 px-3 sm:px-6",children:i.jsxs(cn,{className:"flex items-center gap-2 text-base sm:text-lg",children:[i.jsx(Wt,{className:"h-4 w-4 sm:h-5 sm:w-5 text-primary"}),n]})}),i.jsxs(bt,{className:"px-3 sm:px-6",children:[c.length>0&&i.jsxs("div",{className:"mb-3",children:[i.jsxs("p",{className:"text-xs font-medium text-destructive flex items-center gap-1 mb-2",children:[i.jsx(Vr,{className:"h-3 w-3"}),"Achterstallig (",c.length,")"]}),i.jsx("div",{className:"space-y-1.5",children:c.map(h=>i.jsx(fj,{item:h,getStatusBadge:d,formatTime:f,staffId:e,isOverdue:!0},h.item_id))})]}),u.length===0&&c.length===0?i.jsxs("div",{className:"text-center py-4 sm:py-6 text-muted-foreground",children:[i.jsx(Wt,{className:"h-8 w-8 sm:h-10 sm:w-10 mx-auto mb-2 opacity-50"}),i.jsx("p",{className:"text-sm sm:text-base",children:"Geen items voor vandaag"})]}):i.jsx("div",{className:"space-y-2 sm:space-y-3",children:u.map(h=>i.jsx(fj,{item:h,getStatusBadge:d,formatTime:f,staffId:e},h.item_id))})]})]})};function fj({item:e,getStatusBadge:t,formatTime:n,staffId:r,isOverdue:s}){const a=n(e);return i.jsxs("div",{className:`flex flex-col sm:flex-row sm:items-start gap-2 sm:gap-3 p-2.5 sm:p-3 rounded-lg transition-colors ${s?"bg-destructive/10 border border-destructive/20":"bg-muted/50 hover:bg-muted"}`,children:[i.jsxs("div",{className:"flex sm:flex-col items-center sm:items-center gap-2 sm:gap-0 sm:min-w-[60px] sm:text-center",children:[a?i.jsxs("div",{className:"flex sm:flex-col items-center gap-1",children:[i.jsx(To,{className:"h-3 w-3 sm:h-4 sm:w-4 text-muted-foreground sm:mb-1"}),i.jsx("span",{className:"text-xs sm:text-sm font-medium",children:a})]}):i.jsx("span",{className:"text-xs sm:text-sm font-medium text-muted-foreground",children:"Hele dag"}),i.jsx("div",{className:"sm:hidden flex-shrink-0 ml-auto",children:t(e)})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"font-medium text-sm sm:text-base truncate",children:e.title||"Item"}),!r&&e.staff_name&&i.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-muted-foreground mt-0.5 sm:mt-1",children:[i.jsx(O5,{className:"h-2.5 w-2.5 sm:h-3 sm:w-3 shrink-0"}),i.jsx("span",{className:"truncate",children:e.staff_name})]})]}),i.jsx("div",{className:"hidden sm:block flex-shrink-0",children:t(e)})]})}const IH=({actions:e})=>{const t=Xs();return i.jsx("div",{className:"flex flex-wrap gap-1.5 sm:gap-2 lg:gap-3",children:e.map(n=>{const r=n.icon;return i.jsxs(ne,{variant:n.variant||"outline",onClick:()=>t(n.path),className:"flex items-center gap-1.5 sm:gap-2 h-9 sm:h-10 px-2.5 sm:px-4 text-xs sm:text-sm",children:[i.jsx(r,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"}),i.jsx("span",{className:"truncate",children:n.label})]},n.path)})})},LH={teal:"bg-[var(--nx-teal-soft)] text-[var(--nx-teal)]",orange:"bg-[var(--nx-primary-soft)] text-[var(--nx-primary-ink)]",aqua:"bg-[hsl(177_44%_92%)] text-[var(--nx-aqua-ink)]",red:"bg-[var(--nx-danger-soft)] text-[var(--nx-danger)]"};function $H({icon:e,tone:t="teal",value:n,label:r,delta:s,up:a,down:o,className:l}){return i.jsxs("div",{className:Y("flex flex-col gap-2 rounded-[14px] border border-[var(--nx-border)] bg-[var(--nx-card)] px-[18px] py-4 [box-shadow:var(--nx-sh-sm)]",l),children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{className:"text-[30px] font-bold leading-none text-[var(--nx-fg)]",style:{fontFamily:"var(--nx-display)"},children:n}),i.jsx("div",{className:Y("flex h-[34px] w-[34px] items-center justify-center rounded-[10px] [&_svg]:h-[18px] [&_svg]:w-[18px]",LH[t]),children:e})]}),r!=null&&i.jsx("div",{className:"text-[12px] font-medium text-[var(--nx-muted)]",children:r}),s&&i.jsx("div",{className:Y("text-[11.5px] font-semibold",a&&"text-[hsl(150_55%_34%)]",o&&"text-[var(--nx-danger)]",!a&&!o&&"text-[var(--nx-muted)]"),children:s})]})}function xse({children:e}){return i.jsx("div",{className:"grid grid-cols-2 gap-[14px] min-[1100px]:grid-cols-4",children:e})}function wse({className:e,children:t,...n}){return i.jsx("table",{className:Y("w-full border-separate border-spacing-0 text-[13px]","[&_thead_th]:whitespace-nowrap [&_thead_th]:border-b [&_thead_th]:border-[var(--nx-border)] [&_thead_th]:px-[18px] [&_thead_th]:py-[11px] [&_thead_th]:text-left [&_thead_th]:text-[10.5px] [&_thead_th]:font-bold [&_thead_th]:uppercase [&_thead_th]:tracking-[0.05em] [&_thead_th]:text-[var(--nx-muted)]","[&_tbody_td]:border-b [&_tbody_td]:border-[var(--nx-border)] [&_tbody_td]:px-[18px] [&_tbody_td]:py-[11px] [&_tbody_td]:align-middle [&_tbody_td]:text-[var(--nx-fg)]","[&_tbody_tr:last-child_td]:border-b-0","[&_tbody_tr:hover_td]:bg-[var(--nx-row-hover)]",e),...n,children:t})}function bse(e){return i.jsx("thead",{...e})}function _se(e){return i.jsx("tbody",{...e})}const FH=p.forwardRef((e,t)=>i.jsx("tr",{ref:t,...e}));FH.displayName="Tr";function kse({align:e,className:t,...n}){return i.jsx("th",{className:Y(e==="right"&&"!text-right",t),...n})}function jse({align:e,strong:t,muted:n,className:r,...s}){return i.jsx("td",{className:Y(e==="right"&&"text-right [font-variant-numeric:tabular-nums]",t&&"font-semibold text-[var(--nx-fg)]",n&&"text-[var(--nx-muted)]",r),...s})}const zH={ok:"bg-[hsl(150_45%_94%)] text-[hsl(150_55%_30%)]",warn:"bg-[var(--nx-primary-soft)] text-[var(--nx-primary-ink)]",bad:"bg-[var(--nx-danger-soft)] text-[var(--nx-danger)]",neutral:"bg-[hsl(40_18%_92%)] text-[var(--nx-muted)]",aqua:"bg-[hsl(177_44%_92%)] text-[var(--nx-aqua-ink)]"};function hj({tone:e,children:t,className:n}){return i.jsx("span",{className:Y("inline-flex items-center gap-[6px] whitespace-nowrap rounded-full px-[10px] py-[3px] text-[11.5px] font-semibold",zH[e],n),children:t})}var fA={exports:{}},hA={};/** * @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 uc=p;function BH(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var UH=typeof Object.is=="function"?Object.is:BH,VH=uc.useState,WH=uc.useEffect,HH=uc.useLayoutEffect,qH=uc.useDebugValue;function KH(e,t){var n=t(),r=VH({inst:{value:n,getSnapshot:t}}),s=r[0].inst,a=r[1];return HH(function(){s.value=n,s.getSnapshot=t,ny(s)&&a({inst:s})},[e,n,t]),WH(function(){return ny(s)&&a({inst:s}),e(function(){ny(s)&&a({inst:s})})},[e]),qH(n),n}function ny(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!UH(e,n)}catch{return!0}}function GH(e,t){return t()}var YH=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?GH:KH;hA.useSyncExternalStore=uc.useSyncExternalStore!==void 0?uc.useSyncExternalStore:YH;fA.exports=hA;var QH=fA.exports;function XH(){return QH.useSyncExternalStore(ZH,()=>!0,()=>!1)}function ZH(){return()=>{}}var nb="Avatar",[JH]=Ln(nb),[eq,mA]=JH(nb),pA=p.forwardRef((e,t)=>{const{__scopeAvatar:n,...r}=e,[s,a]=p.useState("idle");return i.jsx(eq,{scope:n,imageLoadingStatus:s,onImageLoadingStatusChange:a,children:i.jsx(Te.span,{...r,ref:t})})});pA.displayName=nb;var gA="AvatarImage",yA=p.forwardRef((e,t)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:s=()=>{},...a}=e,o=mA(gA,n),l=tq(r,a),c=on(u=>{s(u),o.onImageLoadingStatusChange(u)});return Zt(()=>{l!=="idle"&&c(l)},[l,c]),l==="loaded"?i.jsx(Te.img,{...a,ref:t,src:r}):null});yA.displayName=gA;var vA="AvatarFallback",xA=p.forwardRef((e,t)=>{const{__scopeAvatar:n,delayMs:r,...s}=e,a=mA(vA,n),[o,l]=p.useState(r===void 0);return p.useEffect(()=>{if(r!==void 0){const c=window.setTimeout(()=>l(!0),r);return()=>window.clearTimeout(c)}},[r]),o&&a.imageLoadingStatus!=="loaded"?i.jsx(Te.span,{...s,ref:t}):null});xA.displayName=vA;function mj(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function tq(e,{referrerPolicy:t,crossOrigin:n}){const r=XH(),s=p.useRef(null),a=r?(s.current||(s.current=new window.Image),s.current):null,[o,l]=p.useState(()=>mj(a,e));return Zt(()=>{l(mj(a,e))},[a,e]),Zt(()=>{const c=f=>()=>{l(f)};if(!a)return;const u=c("loaded"),d=c("error");return a.addEventListener("load",u),a.addEventListener("error",d),t&&(a.referrerPolicy=t),typeof n=="string"&&(a.crossOrigin=n),()=>{a.removeEventListener("load",u),a.removeEventListener("error",d)}},[a,n,t]),o}var wA=pA,bA=yA,_A=xA;const Md=p.forwardRef(({className:e,...t},n)=>i.jsx(wA,{ref:n,className:Y("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));Md.displayName=wA.displayName;const nq=p.forwardRef(({className:e,...t},n)=>i.jsx(bA,{ref:n,className:Y("aspect-square h-full w-full object-cover object-top",e),...t}));nq.displayName=bA.displayName;const Dd=p.forwardRef(({className:e,...t},n)=>i.jsx(_A,{ref:n,className:Y("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));Dd.displayName=_A.displayName;const rq={CV:{bg:"hsl(261 50% 92%)",text:"hsl(261 50% 38%)"},WP:{bg:"hsl(200 60% 90%)",text:"hsl(200 70% 32%)"},PV:{bg:"hsl(45 85% 88%)",text:"hsl(38 80% 32%)"},Dak:{bg:"hsl(22 75% 90%)",text:"hsl(22 75% 36%)"},Laadpaal:{bg:"hsl(150 45% 88%)",text:"hsl(150 55% 28%)"},Elektra:{bg:"hsl(280 45% 91%)",text:"hsl(280 50% 40%)"},Sanitair:{bg:"hsl(183 45% 88%)",text:"hsl(183 60% 26%)"},Airco:{bg:"hsl(190 55% 89%)",text:"hsl(190 65% 30%)"},VVW:{bg:"hsl(330 50% 91%)",text:"hsl(330 55% 40%)"},Onderhoud:{bg:"hsl(40 20% 88%)",text:"hsl(40 25% 35%)"},Inspectie:{bg:"hsl(40 20% 88%)",text:"hsl(40 25% 35%)"},Storing:{bg:"hsl(0 70% 92%)",text:"hsl(0 70% 38%)"}},sq={bg:"hsl(40 18% 90%)",text:"hsl(40 15% 40%)"};function aq(e){return rq[e]??sq}function Sse({label:e}){const t=aq(e);return i.jsx("span",{title:e,className:"max-w-[8rem] truncate rounded px-1.5 py-0.5 text-[10px] font-semibold leading-tight",style:{background:t.bg,color:t.text},children:e})}const oq={urgent:{dot:"hsl(0 72% 51%)",label:"Urgent"},important:{dot:"hsl(22 90% 50%)",label:"Belangrijk"}};function Ese({priority:e}){const t=e?oq[e]:void 0;return t?i.jsx("span",{title:t.label,"aria-label":t.label,className:"inline-block h-2 w-2 flex-shrink-0 rounded-full",style:{background:t.dot}}):null}const pj=[261,183,22,150,320,200,45,100,280,0];function kA(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}function jA(e){let t=0;for(let n=0;ntypeof s=="string"?{name:s}:s);return i.jsxs("div",{className:Y("flex items-center",n),children:[r.map((s,a)=>{const o=jA(s.id??s.name);return i.jsx(Md,{title:s.name,role:"img","aria-label":s.name,className:Y("h-6 w-6 ring-2 ring-[var(--pl-card)]",a>0&&"-ml-1.5"),style:{zIndex:r.length-a},children:i.jsx(Dd,{className:"text-[9px] font-semibold",style:{background:`hsl(${o} 45% 90%)`,color:`hsl(${o} 55% 32%)`},children:kA(s.name)})},s.id??`${s.name}-${a}`)}),t&&i.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),t()},title:"Medewerker toewijzen","aria-label":"Medewerker toewijzen",className:Y("inline-flex h-6 w-6 items-center justify-center rounded-full border border-dashed","border-[var(--pl-border-strong)] bg-[var(--pl-card)] text-[var(--pl-muted-fg)]","ring-2 ring-[var(--pl-card)] transition-colors hover:text-[var(--pl-foreground)] hover:border-[var(--pl-primary)]",r.length>0&&"-ml-1.5"),style:{zIndex:0},children:i.jsx(jc,{className:"h-3 w-3"})})]})}function iq({name:e,hue:t,size:n=26,className:r,title:s}){const a=t??jA(e);return i.jsx("span",{role:"img","aria-label":e,title:s??e,className:Y("inline-flex flex-shrink-0 items-center justify-center rounded-full font-bold",r),style:{width:n,height:n,fontSize:Math.round(n*.4),fontFamily:"var(--nx-display)",background:`hsl(${a} 55% 91%)`,color:`hsl(${a} 50% 34%)`},children:kA(e)})}var lq="Label",SA=p.forwardRef((e,t)=>i.jsx(Te.label,{...e,ref:t,onMouseDown:n=>{var s;n.target.closest("button, input, select, textarea")||((s=e.onMouseDown)==null||s.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));SA.displayName=lq;var EA=SA;const cq=bc("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Tt=p.forwardRef(({className:e,...t},n)=>i.jsx(EA,{ref:n,className:Y(cq(),e),...t}));Tt.displayName=EA.displayName;const uq={electricien:"Elektricien",monteur_allround:"Allround Monteur",dakmonteur:"Dakmonteur",bbl:"BBL",barber:"Barbier",colorist:"Colorist",kapper:"Kapper",stylist:"Stylist"},dq=()=>{const[e,t]=p.useState([]),[n,r]=p.useState(!0),[s,a]=p.useState(!1),[o,l]=p.useState(0),{organization:c}=zt();return p.useEffect(()=>{let u=!1;return(async()=>{if(!(c!=null&&c.id)){r(!1);return}r(!0),a(!1);const f=he(new Date,"yyyy-MM-dd"),{data:h,error:m}=await B.from("staff").select("id, name, specialization").eq("organization_id",c.id).eq("is_active",!0).eq("is_plannable",!0);if(u)return;if(m){console.error("Error fetching staff:",m),a(!0),r(!1);return}const{data:v,error:w}=await B.from("project_schedule_staff").select(` staff_id, schedule_entry:project_schedule_entries!inner ( scheduled_date, project:projects!inner ( id, status, organization_id ) ) `).eq("organization_id",c.id).eq("schedule_entry.scheduled_date",f);if(u)return;if(w){console.error("Error fetching schedule staff:",w),a(!0),r(!1);return}const y={};v&&v.forEach(j=>{const k=j.schedule_entry;k&&k.scheduled_date===f&&k.project&&k.project.organization_id===c.id&&k.project.status!=="cancelled"&&k.project.status!=="archived"&&(y[j.staff_id]=(y[j.staff_id]||0)+1)});const{data:x,error:g}=await B.from("staff_availability").select("staff_id").eq("organization_id",c.id).eq("date",f);if(u)return;if(g){console.error("Error fetching unavailability:",g),a(!0),r(!1);return}const b=new Set((x==null?void 0:x.map(j=>j.staff_id))||[]),_=(h||[]).map(j=>({id:j.id,name:j.name,specialization:j.specialization,todayAppointments:y[j.id]||0,isAvailable:!b.has(j.id)}));t(_),r(!1)})(),()=>{u=!0}},[c==null?void 0:c.id,o]),n?i.jsxs("div",{className:"overflow-hidden rounded-[14px] border border-[var(--nx-border)] bg-[var(--nx-card)] [box-shadow:var(--nx-sh-sm)]",children:[i.jsx("div",{className:"border-b border-[var(--nx-border)] px-[18px] py-[14px]",children:i.jsxs("h3",{className:"m-0 flex items-center gap-2 text-[14px] font-semibold text-[var(--nx-fg)]",style:{fontFamily:"var(--nx-display)"},children:[i.jsx(Wr,{className:"h-[18px] w-[18px]"}),"Team Vandaag"]})}),i.jsx("div",{className:"space-y-2 p-[18px] sm:space-y-3",children:[...Array(4)].map((u,d)=>i.jsx(Dt,{className:"h-12 w-full sm:h-14"},d))})]}):s?i.jsxs("div",{className:"overflow-hidden rounded-[14px] border border-[var(--nx-border)] bg-[var(--nx-card)] [box-shadow:var(--nx-sh-sm)]",children:[i.jsx("div",{className:"border-b border-[var(--nx-border)] px-[18px] py-[14px]",children:i.jsxs("h3",{className:"m-0 flex items-center gap-2 text-[14px] font-semibold text-[var(--nx-fg)]",style:{fontFamily:"var(--nx-display)"},children:[i.jsx(Wr,{className:"h-[18px] w-[18px]"}),"Team Vandaag"]})}),i.jsxs("div",{className:"space-y-3 p-[18px] text-center",children:[i.jsx("p",{className:"m-0 text-sm text-[var(--nx-muted)]",children:"De dagbezetting kon niet geladen worden. Wie er vandaag ingepland of afwezig is, is nu niet bekend."}),i.jsx("button",{type:"button",onClick:()=>l(u=>u+1),className:"rounded-md border border-[var(--nx-border)] px-3 py-1.5 text-sm text-[var(--nx-fg)] hover:bg-[var(--nx-bg)]",children:"Opnieuw proberen"})]})]}):i.jsxs("div",{className:"overflow-hidden rounded-[14px] border border-[var(--nx-border)] bg-[var(--nx-card)] [box-shadow:var(--nx-sh-sm)]",children:[i.jsx("div",{className:"border-b border-[var(--nx-border)] px-[18px] py-[14px]",children:i.jsxs("h3",{className:"m-0 flex items-center gap-2 text-[14px] font-semibold text-[var(--nx-fg)]",style:{fontFamily:"var(--nx-display)"},children:[i.jsx(Wr,{className:"h-[18px] w-[18px]"}),"Team Vandaag"]})}),i.jsx("div",{className:"p-[18px]",children:i.jsx("div",{className:"space-y-2 sm:space-y-3",children:e.map(u=>{const d=u.specialization?uq[u.specialization]:"Medewerker";return i.jsxs("div",{className:"flex flex-col gap-2 rounded-[10px] bg-[var(--nx-row-hover)] p-2.5 sm:flex-row sm:items-center sm:gap-3 sm:p-3",children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:gap-3",children:[i.jsx(iq,{name:u.name,size:40,className:"shrink-0"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"truncate text-[13.5px] font-medium text-[var(--nx-fg)] sm:text-[15px]",children:u.name}),i.jsx("p",{className:"truncate text-[11.5px] text-[var(--nx-muted)] sm:text-[13px]",children:d})]})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-12 sm:gap-2 sm:pl-0",children:[u.todayAppointments>0&&i.jsxs(hj,{tone:"neutral",children:[u.todayAppointments," klus",u.todayAppointments!==1?"sen":""]}),i.jsx(hj,{tone:u.isAvailable?"ok":"bad",children:u.isAvailable?"Beschikbaar":"Afwezig"})]})]},u.id)})})})]})};function gj(e){return e?e.length===5?`${e}:00`:e:""}function NA(e,t){const n=e.display_order??0,r=t.display_order??0;if(n!==r)return n-r;const s=gj(e.start_time),a=gj(t.start_time);if(s!==a)return s?a?s.localeCompare(a):-1:1;const o=e.name??"",l=t.name??"";if(o!==l)return o.localeCompare(l,"nl");const c=e.entry_id??"",u=t.entry_id??"";return cu?1:0}function CA(e,t){const n=e.vehicle_name??"",r=t.vehicle_name??"";if(n!==r)return n?r?n.localeCompare(r,"nl"):-1:1;const s=e.vehicle_id??"",a=t.vehicle_id??"";if(s!==a)return s?a?so.id!==t);let a=0;return s.forEach((o,l)=>{fq(o.start_time,r)<=n&&(a=l+1)}),a}async function TA(e,t){var v,w;let n=B.from("organization_members").select("id, organization_id").eq("user_id",e).eq("is_active",!0);t&&(n=n.eq("organization_id",t));const{data:r,error:s}=await n.order("created_at",{ascending:!1}).limit(1);if(s)throw new Error(`Failed to fetch organization member: ${s.message}`);if(!r||r.length===0)return null;const a=r[0].id,o=r[0].organization_id,{data:l,error:c}=await B.from("staff").select("id").eq("member_id",a).eq("is_active",!0).order("created_at",{ascending:!1}).limit(1);if(c)throw new Error(`Failed to fetch staff record: ${c.message}`);if(l&&l.length>0)return l[0].id;const{data:u}=await B.auth.getUser(),d=(w=(v=u==null?void 0:u.user)==null?void 0:v.email)==null?void 0:w.toLowerCase().trim();if(!d||!o)return null;const f=d.replace(/\\/g,"\\\\").replace(/[%_]/g,"\\$&"),{data:h,error:m}=await B.from("staff").select("id").eq("organization_id",o).eq("is_active",!0).ilike("email",f).order("created_at",{ascending:!1}).limit(1);if(m)throw new Error(`Failed to match staff by email: ${m.message}`);return h&&h.length>0?h[0].id:null}const hq=4e3;async function mq(e){const t=Array.from(new Set(e.map(a=>a.entry_id).filter(Boolean))).slice(0,200);if(t.length===0)return;let n=null,r;try{const a=B,o=new Promise(c=>{r=setTimeout(()=>c(null),hq)}),l=await Promise.race([a.rpc("get_staff_entry_context",{p_entry_ids:t}),o]);if(!l||l.error)return;n=l.data}catch{return}finally{r!==void 0&&clearTimeout(r)}if(!n||n.length===0)return;const s=new Map(n.map(a=>[a.entry_id,a]));for(const a of e){const o=s.get(a.entry_id);o&&(o.team_names&&o.team_names.length>0&&(a.team_members=o.team_names.map(l=>({id:l,name:l,level:null,role:null}))),o.vehicle_name&&(a.vehicle_id=o.vehicle_id,a.vehicle_name=o.vehicle_name,a.vehicle_license_plate=o.vehicle_license_plate))}}async function pq(e,t=!1){const n=await TA(e);if(!n)return{today:[],thisWeek:[],upcoming:[]};const{data:r,error:s}=await B.from("project_schedule_staff").select(` id, role, schedule_entry_id, entry:schedule_entry_id ( id, scheduled_date, slot_number, display_order, planned_hours, start_time, classification, vehicle_id, project_id, project:project_id ( *, project_staff ( staff_id, role, staff:staff_id ( id, name, level ) ), vehicles:vehicle_id ( id, name, license_plate ) ) ) `).eq("staff_id",n);if(s)throw new Error(`Failed to fetch schedule staff: ${s.message}`);if(!r||r.length===0)return{today:[],thisWeek:[],upcoming:[]};const a=new Date,o=he(a,"yyyy-MM-dd"),l=ko(a,{weekStartsOn:1}),c=he(l,"yyyy-MM-dd"),u={today:[],thisWeek:[],upcoming:[]};return r.forEach(d=>{var x;const f=d.entry;if(!f)return;const h=f.project;if(!h||h.status==="cancelled"||h.status==="archived"||!t&&h.status==="completed")return;const m=f.scheduled_date;if(!m||!t&&m{var b,_,j;return{id:((b=g.staff)==null?void 0:b.id)||"",name:((_=g.staff)==null?void 0:_.name)||"",level:((j=g.staff)==null?void 0:j.level)||null,role:g.role||null}}))||[],w=h.vehicles,y={id:h.id,entry_id:f.id,scheduled_date:m,slot_number:f.slot_number??null,display_order:typeof f.display_order=="number"?f.display_order:0,planned_hours:f.planned_hours,name:h.name,description:h.description_visible_to_monteur?h.description:null,description_visible_to_monteur:h.description_visible_to_monteur??!1,notes:h.notes,status:h.status,start_date:h.start_date,end_date:h.end_date,start_time:f.start_time,day_part:h.day_part,priority:h.priority,project_type:h.project_type,customer_classification:h.customer_classification,entry_classification:f.classification??null,customer_name:h.customer_name,customer_email:h.customer_email,customer_phone:h.customer_phone,customer_address:h.customer_address,customer_postal_code:h.customer_postal_code||null,customer_city:h.customer_city||null,customer_id:h.customer_id,organization_id:h.organization_id,service_id:h.service_id,selected_dates:h.selected_dates,extra_labels:h.extra_labels||null,project_number:h.project_number||null,custom_fields:h.custom_fields||null,vehicle_id:f.vehicle_id||h.vehicle_id||null,vehicle_name:(w==null?void 0:w.name)||null,vehicle_license_plate:(w==null?void 0:w.license_plate)||null,team_members:v};m===o?u.today.push(y):m<=c?u.thisWeek.push(y):u.upcoming.push(y)}),await mq([...u.today,...u.thisWeek,...u.upcoming]),u.today.sort(CA),u.thisWeek.sort(dm),u.upcoming.sort(dm),u}function rb(e,t){const{initialized:n,session:r}=Ht(),s=(t==null?void 0:t.includePast)===!0;return xt({queryKey:["staff-projects",e,s],queryFn:()=>pq(e,s),enabled:!!e&&n&&!!r,staleTime:1e3*60*5,retry:2,retryDelay:a=>Math.min(1e3*2**a,5e3)})}function xp(e,t){const{initialized:n,session:r}=Ht();return xt({queryKey:["current-staff-id",e,t??null],queryFn:()=>TA(e,t),enabled:!!e&&n&&!!r,staleTime:5*60*1e3,retry:2,retryDelay:s=>Math.min(1e3*2**s,5e3)})}const gq=" - ";function PA(e){const t=(e??"").trim();return/^\d{2}:\d{2}(:\d{2})?$/.test(t)?t.slice(0,5):null}function yq(e,t){const n=PA(e);if(!n||typeof t!="number"||!Number.isFinite(t)||t<=0)return null;const[r,s]=n.split(":").map(Number),a=r*60+s+Math.round(t*60),o=Math.floor(a/60)%24,l=a%60;return`${o.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`}function Id(e,t){const n=PA(e);if(!n)return null;const r=yq(n,t);return r?`${n}${gq}${r}`:n}const vq={new:{label:"Nieuwe klant",className:"bg-green-500/10 text-green-600 border-green-500/20"},vip:{label:"VIP",className:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20"},regular:{label:"Vaste klant",className:"bg-blue-500/10 text-blue-600 border-blue-500/20"},inactive:{label:"Inactief",className:"bg-gray-500/10 text-gray-600 border-gray-500/20"}},xq={ochtend:"Ochtend",middag:"Middag",hele_dag:"Hele dag",morning:"Ochtend",afternoon:"Middag",evening:"Avond",full_day:"Hele dag"};function wq({project:e,onCall:t,onNavigate:n,onBrief:r,onPrint:s,onClick:a}){var b,_,j;const o=e.customer_classification?vq[e.customer_classification]:null,l=Id(e.start_time,e.planned_hours)??(e.day_part&&xq[e.day_part]||null),c=!!o||(((b=e.extra_labels)==null?void 0:b.length)??0)>0,u=[e.customer_postal_code,e.customer_city].filter(Boolean).join(" "),d=((_=e.customer_address)==null?void 0:_.trim())||"",f=[d,u].filter(Boolean).join(", "),h=!!e.customer_phone,m=!!d,w=(()=>{const k=[...e.customer_address?e.customer_address.split(",").map(S=>S.trim()):[],u].filter(Boolean);return k.length>0?k:null})(),y=k=>{if(k.stopPropagation(),f){const S=encodeURIComponent(f),N=/iPad|iPhone|iPod/.test(navigator.userAgent)?`maps://maps.apple.com/?daddr=${S}`:`https://www.google.com/maps/dir/?api=1&destination=${S}`;window.open(N,"_blank")}n()},x=k=>{k.stopPropagation(),e.customer_phone&&window.open(`tel:${e.customer_phone}`,"_self"),t()},g=k=>{k.stopPropagation(),s()};return i.jsxs(dt,{className:"p-4 cursor-pointer hover:bg-muted/50 transition-colors active:scale-[0.98]",onClick:r,children:[(c||l)&&i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[o&&i.jsx(Qe,{variant:"outline",className:Y("text-[10px] font-medium",o.className),children:o.label}),(j=e.extra_labels)==null?void 0:j.map((k,S)=>i.jsx(Qe,{variant:"secondary",className:"text-[10px]",children:k},S))]}),l&&i.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[i.jsx(To,{className:"h-3.5 w-3.5"}),i.jsx("span",{children:l})]})]}),i.jsx("h3",{className:"font-semibold text-base mb-0.5",children:e.customer_name||e.name}),e.customer_city&&i.jsxs("p",{className:"text-sm text-muted-foreground mb-1 flex items-center gap-1",children:[i.jsx(xo,{className:"h-3.5 w-3.5"}),e.customer_city]}),w&&w.length>0&&i.jsx("div",{className:"text-sm text-muted-foreground mb-4",children:w.map((k,S)=>i.jsx("div",{children:k},S))}),i.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[i.jsxs("div",{className:"flex flex-wrap gap-2",children:[i.jsxs(ne,{variant:"outline",size:"sm",className:"h-9 gap-1.5 px-3",onClick:x,disabled:!h,children:[i.jsx(Ai,{className:"h-4 w-4"}),i.jsx("span",{className:"text-xs",children:"Bel"})]}),i.jsxs(ne,{variant:"outline",size:"sm",className:"h-9 gap-1.5 px-3",onClick:y,disabled:!m,children:[i.jsx(xo,{className:"h-4 w-4"}),i.jsx("span",{className:"text-xs",children:"Route"})]}),i.jsxs(ne,{variant:"outline",size:"sm",className:"h-9 gap-1.5 px-3",onClick:g,children:[i.jsx(Zu,{className:"h-4 w-4"}),i.jsx("span",{className:"text-xs",children:"Print"})]})]}),i.jsx(Gm,{className:"h-5 w-5 text-muted-foreground"})]})]})}const bq={lessThanXSeconds:{one:"minder dan een seconde",other:"minder dan {{count}} seconden"},xSeconds:{one:"1 seconde",other:"{{count}} seconden"},halfAMinute:"een halve minuut",lessThanXMinutes:{one:"minder dan een minuut",other:"minder dan {{count}} minuten"},xMinutes:{one:"een minuut",other:"{{count}} minuten"},aboutXHours:{one:"ongeveer 1 uur",other:"ongeveer {{count}} uur"},xHours:{one:"1 uur",other:"{{count}} uur"},xDays:{one:"1 dag",other:"{{count}} dagen"},aboutXWeeks:{one:"ongeveer 1 week",other:"ongeveer {{count}} weken"},xWeeks:{one:"1 week",other:"{{count}} weken"},aboutXMonths:{one:"ongeveer 1 maand",other:"ongeveer {{count}} maanden"},xMonths:{one:"1 maand",other:"{{count}} maanden"},aboutXYears:{one:"ongeveer 1 jaar",other:"ongeveer {{count}} jaar"},xYears:{one:"1 jaar",other:"{{count}} jaar"},overXYears:{one:"meer dan 1 jaar",other:"meer dan {{count}} jaar"},almostXYears:{one:"bijna 1 jaar",other:"bijna {{count}} jaar"}},_q=(e,t,n)=>{let r;const s=bq[e];return typeof s=="string"?r=s:t===1?r=s.one:r=s.other.replace("{{count}}",String(t)),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"over "+r:r+" geleden":r},kq={full:"EEEE d MMMM y",long:"d MMMM y",medium:"d MMM y",short:"dd-MM-y"},jq={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},Sq={full:"{{date}} 'om' {{time}}",long:"{{date}} 'om' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Eq={date:Ol({formats:kq,defaultWidth:"full"}),time:Ol({formats:jq,defaultWidth:"full"}),dateTime:Ol({formats:Sq,defaultWidth:"full"})},Nq={lastWeek:"'afgelopen' eeee 'om' p",yesterday:"'gisteren om' p",today:"'vandaag om' p",tomorrow:"'morgen om' p",nextWeek:"eeee 'om' p",other:"P"},Cq=(e,t,n,r)=>Nq[e],Tq={narrow:["v.C.","n.C."],abbreviated:["v.Chr.","n.Chr."],wide:["voor Christus","na Christus"]},Pq={narrow:["1","2","3","4"],abbreviated:["K1","K2","K3","K4"],wide:["1e kwartaal","2e kwartaal","3e kwartaal","4e kwartaal"]},Aq={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["jan.","feb.","mrt.","apr.","mei","jun.","jul.","aug.","sep.","okt.","nov.","dec."],wide:["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"]},Rq={narrow:["Z","M","D","W","D","V","Z"],short:["zo","ma","di","wo","do","vr","za"],abbreviated:["zon","maa","din","woe","don","vri","zat"],wide:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"]},Oq={narrow:{am:"AM",pm:"PM",midnight:"middernacht",noon:"het middaguur",morning:"'s ochtends",afternoon:"'s middags",evening:"'s avonds",night:"'s nachts"},abbreviated:{am:"AM",pm:"PM",midnight:"middernacht",noon:"het middaguur",morning:"'s ochtends",afternoon:"'s middags",evening:"'s avonds",night:"'s nachts"},wide:{am:"AM",pm:"PM",midnight:"middernacht",noon:"het middaguur",morning:"'s ochtends",afternoon:"'s middags",evening:"'s avonds",night:"'s nachts"}},Mq=(e,t)=>Number(e)+"e",Dq={ordinalNumber:Mq,era:Ms({values:Tq,defaultWidth:"wide"}),quarter:Ms({values:Pq,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ms({values:Aq,defaultWidth:"wide"}),day:Ms({values:Rq,defaultWidth:"wide"}),dayPeriod:Ms({values:Oq,defaultWidth:"wide"})},Iq=/^(\d+)e?/i,Lq=/\d+/i,$q={narrow:/^([vn]\.? ?C\.?)/,abbreviated:/^([vn]\. ?Chr\.?)/,wide:/^((voor|na) Christus)/},Fq={any:[/^v/,/^n/]},zq={narrow:/^[1234]/i,abbreviated:/^K[1234]/i,wide:/^[1234]e kwartaal/i},Bq={any:[/1/i,/2/i,/3/i,/4/i]},Uq={narrow:/^[jfmasond]/i,abbreviated:/^(jan.|feb.|mrt.|apr.|mei|jun.|jul.|aug.|sep.|okt.|nov.|dec.)/i,wide:/^(januari|februari|maart|april|mei|juni|juli|augustus|september|oktober|november|december)/i},Vq={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:[/^jan/i,/^feb/i,/^m(r|a)/i,/^apr/i,/^mei/i,/^jun/i,/^jul/i,/^aug/i,/^sep/i,/^okt/i,/^nov/i,/^dec/i]},Wq={narrow:/^[zmdwv]/i,short:/^(zo|ma|di|wo|do|vr|za)/i,abbreviated:/^(zon|maa|din|woe|don|vri|zat)/i,wide:/^(zondag|maandag|dinsdag|woensdag|donderdag|vrijdag|zaterdag)/i},Hq={narrow:[/^z/i,/^m/i,/^d/i,/^w/i,/^d/i,/^v/i,/^z/i],any:[/^zo/i,/^ma/i,/^di/i,/^wo/i,/^do/i,/^vr/i,/^za/i]},qq={any:/^(am|pm|middernacht|het middaguur|'s (ochtends|middags|avonds|nachts))/i},Kq={any:{am:/^am/i,pm:/^pm/i,midnight:/^middernacht/i,noon:/^het middaguur/i,morning:/ochtend/i,afternoon:/middag/i,evening:/avond/i,night:/nacht/i}},Gq={ordinalNumber:nA({matchPattern:Iq,parsePattern:Lq,valueCallback:e=>parseInt(e,10)}),era:Ds({matchPatterns:$q,defaultMatchWidth:"wide",parsePatterns:Fq,defaultParseWidth:"any"}),quarter:Ds({matchPatterns:zq,defaultMatchWidth:"wide",parsePatterns:Bq,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Ds({matchPatterns:Uq,defaultMatchWidth:"wide",parsePatterns:Vq,defaultParseWidth:"any"}),day:Ds({matchPatterns:Wq,defaultMatchWidth:"wide",parsePatterns:Hq,defaultParseWidth:"any"}),dayPeriod:Ds({matchPatterns:qq,defaultMatchWidth:"any",parsePatterns:Kq,defaultParseWidth:"any"})},tt={code:"nl",formatDistance:_q,formatLong:Eq,formatRelative:Cq,localize:Dq,match:Gq,options:{weekStartsOn:1,firstWeekContainsDate:4}};var ry="focusScope.autoFocusOnMount",sy="focusScope.autoFocusOnUnmount",yj={bubbles:!1,cancelable:!0},Yq="FocusScope",wp=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...o}=e,[l,c]=p.useState(null),u=on(s),d=on(a),f=p.useRef(null),h=ze(t,w=>c(w)),m=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let w=function(b){if(m.paused||!l)return;const _=b.target;l.contains(_)?f.current=_:Da(f.current,{select:!0})},y=function(b){if(m.paused||!l)return;const _=b.relatedTarget;_!==null&&(l.contains(_)||Da(f.current,{select:!0}))},x=function(b){if(document.activeElement===document.body)for(const j of b)j.removedNodes.length>0&&Da(l)};document.addEventListener("focusin",w),document.addEventListener("focusout",y);const g=new MutationObserver(x);return l&&g.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",y),g.disconnect()}}},[r,l,m.paused]),p.useEffect(()=>{if(l){xj.add(m);const w=document.activeElement;if(!l.contains(w)){const x=new CustomEvent(ry,yj);l.addEventListener(ry,u),l.dispatchEvent(x),x.defaultPrevented||(Qq(tK(AA(l)),{select:!0}),document.activeElement===w&&Da(l))}return()=>{l.removeEventListener(ry,u),setTimeout(()=>{const x=new CustomEvent(sy,yj);l.addEventListener(sy,d),l.dispatchEvent(x),x.defaultPrevented||Da(w??document.body,{select:!0}),l.removeEventListener(sy,d),xj.remove(m)},0)}}},[l,u,d,m]);const v=p.useCallback(w=>{if(!n&&!r||m.paused)return;const y=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,x=document.activeElement;if(y&&x){const g=w.currentTarget,[b,_]=Xq(g);b&&_?!w.shiftKey&&x===_?(w.preventDefault(),n&&Da(b,{select:!0})):w.shiftKey&&x===b&&(w.preventDefault(),n&&Da(_,{select:!0})):x===g&&w.preventDefault()}},[n,r,m.paused]);return i.jsx(Te.div,{tabIndex:-1,...o,ref:h,onKeyDown:v})});wp.displayName=Yq;function Qq(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Da(r,{select:t}),document.activeElement!==n)return}function Xq(e){const t=AA(e),n=vj(t,e),r=vj(t.reverse(),e);return[n,r]}function AA(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function vj(e,t){for(const n of e)if(!Zq(n,{upTo:t}))return n}function Zq(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Jq(e){return e instanceof HTMLInputElement&&"select"in e}function Da(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Jq(e)&&t&&e.select()}}var xj=eK();function eK(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=wj(e,t),e.unshift(t)},remove(t){var n;e=wj(e,t),(n=e[0])==null||n.resume()}}}function wj(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function tK(e){return e.filter(t=>t.tagName!=="A")}var ay=0;function sb(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??bj()),document.body.insertAdjacentElement("beforeend",e[1]??bj()),ay++,()=>{ay===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ay--}},[])}function bj(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var gh="right-scroll-bar-position",yh="width-before-scroll-bar",nK="with-scroll-bars-hidden",rK="--removed-body-scroll-bar-size";function oy(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function sK(e,t){var n=p.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=t,n.facade}var aK=typeof window<"u"?p.useLayoutEffect:p.useEffect,_j=new WeakMap;function oK(e,t){var n=sK(null,function(r){return e.forEach(function(s){return oy(s,r)})});return aK(function(){var r=_j.get(n);if(r){var s=new Set(r),a=new Set(e),o=n.current;s.forEach(function(l){a.has(l)||oy(l,null)}),a.forEach(function(l){s.has(l)||oy(l,o)})}_j.set(n,e)},[e]),n}function iK(e){return e}function lK(e,t){t===void 0&&(t=iK);var n=[],r=!1,s={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var o=t(a,r);return n.push(o),function(){n=n.filter(function(l){return l!==o})}},assignSyncMedium:function(a){for(r=!0;n.length;){var o=n;n=[],o.forEach(a)}n={push:function(l){return a(l)},filter:function(){return n}}},assignMedium:function(a){r=!0;var o=[];if(n.length){var l=n;n=[],l.forEach(a),o=n}var c=function(){var d=o;o=[],d.forEach(a)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){o.push(d),u()},filter:function(d){return o=o.filter(d),n}}}};return s}function cK(e){e===void 0&&(e={});var t=lK(null);return t.options=zr({async:!0,ssr:!1},e),t}var RA=function(e){var t=e.sideCar,n=Po(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,zr({},n))};RA.isSideCarExport=!0;function uK(e,t){return e.useMedium(t),RA}var OA=cK(),iy=function(){},bp=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:iy,onWheelCapture:iy,onTouchMoveCapture:iy}),s=r[0],a=r[1],o=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,m=e.noRelative,v=e.noIsolation,w=e.inert,y=e.allowPinchZoom,x=e.as,g=x===void 0?"div":x,b=e.gapMode,_=Po(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=h,k=oK([n,t]),S=zr(zr({},_),s);return p.createElement(p.Fragment,null,d&&p.createElement(j,{sideCar:OA,removeScrollBar:u,shards:f,noRelative:m,noIsolation:v,inert:w,setCallbacks:a,allowPinchZoom:!!y,lockRef:n,gapMode:b}),o?p.cloneElement(p.Children.only(l),zr(zr({},S),{ref:k})):p.createElement(g,zr({},S,{className:c,ref:k}),l))});bp.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};bp.classNames={fullWidth:yh,zeroRight:gh};var dK=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function fK(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=dK();return t&&e.setAttribute("nonce",t),e}function hK(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function mK(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var pK=function(){var e=0,t=null;return{add:function(n){e==0&&(t=fK())&&(hK(t,n),mK(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},gK=function(){var e=pK();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},MA=function(){var e=gK(),t=function(n){var r=n.styles,s=n.dynamic;return e(r,s),null};return t},yK={left:0,top:0,right:0,gap:0},ly=function(e){return parseInt(e||"",10)||0},vK=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[ly(n),ly(r),ly(s)]},xK=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return yK;var t=vK(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},wK=MA(),Ml="data-scroll-locked",bK=function(e,t,n,r){var s=e.left,a=e.top,o=e.right,l=e.gap;return n===void 0&&(n="margin"),` .`.concat(nK,` { overflow: hidden `).concat(r,`; padding-right: `).concat(l,"px ").concat(r,`; } body[`).concat(Ml,`] { overflow: hidden `).concat(r,`; overscroll-behavior: contain; `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&` padding-left: `.concat(s,`px; padding-top: `).concat(a,`px; padding-right: `).concat(o,`px; margin-left:0; margin-top:0; margin-right: `).concat(l,"px ").concat(r,`; `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),` } .`).concat(gh,` { right: `).concat(l,"px ").concat(r,`; } .`).concat(yh,` { margin-right: `).concat(l,"px ").concat(r,`; } .`).concat(gh," .").concat(gh,` { right: 0 `).concat(r,`; } .`).concat(yh," .").concat(yh,` { margin-right: 0 `).concat(r,`; } body[`).concat(Ml,`] { `).concat(rK,": ").concat(l,`px; } `)},kj=function(){var e=parseInt(document.body.getAttribute(Ml)||"0",10);return isFinite(e)?e:0},_K=function(){p.useEffect(function(){return document.body.setAttribute(Ml,(kj()+1).toString()),function(){var e=kj()-1;e<=0?document.body.removeAttribute(Ml):document.body.setAttribute(Ml,e.toString())}},[])},kK=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,s=r===void 0?"margin":r;_K();var a=p.useMemo(function(){return xK(s)},[s]);return p.createElement(wK,{styles:bK(a,!t,s,n?"":"!important")})},Ex=!1;if(typeof window<"u")try{var zf=Object.defineProperty({},"passive",{get:function(){return Ex=!0,!0}});window.addEventListener("test",zf,zf),window.removeEventListener("test",zf,zf)}catch{Ex=!1}var Ki=Ex?{passive:!1}:!1,jK=function(e){return e.tagName==="TEXTAREA"},DA=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!jK(e)&&n[t]==="visible")},SK=function(e){return DA(e,"overflowY")},EK=function(e){return DA(e,"overflowX")},jj=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var s=IA(e,r);if(s){var a=LA(e,r),o=a[1],l=a[2];if(o>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},NK=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},CK=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},IA=function(e,t){return e==="v"?SK(t):EK(t)},LA=function(e,t){return e==="v"?NK(t):CK(t)},TK=function(e,t){return e==="h"&&t==="rtl"?-1:1},PK=function(e,t,n,r,s){var a=TK(e,window.getComputedStyle(t).direction),o=a*r,l=n.target,c=t.contains(l),u=!1,d=o>0,f=0,h=0;do{if(!l)break;var m=LA(e,l),v=m[0],w=m[1],y=m[2],x=w-y-a*v;(v||x)&&IA(e,l)&&(f+=x,h+=v);var g=l.parentNode;l=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},Bf=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Sj=function(e){return[e.deltaX,e.deltaY]},Ej=function(e){return e&&"current"in e?e.current:e},AK=function(e,t){return e[0]===t[0]&&e[1]===t[1]},RK=function(e){return` .block-interactivity-`.concat(e,` {pointer-events: none;} .allow-interactivity-`).concat(e,` {pointer-events: all;} `)},OK=0,Gi=[];function MK(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),s=p.useState(OK++)[0],a=p.useState(MA)[0],o=p.useRef(e);p.useEffect(function(){o.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var w=_0([e.lockRef.current],(e.shards||[]).map(Ej),!0).filter(Boolean);return w.forEach(function(y){return y.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),w.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var l=p.useCallback(function(w,y){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var x=Bf(w),g=n.current,b="deltaX"in w?w.deltaX:g[0]-x[0],_="deltaY"in w?w.deltaY:g[1]-x[1],j,k=w.target,S=Math.abs(b)>Math.abs(_)?"h":"v";if("touches"in w&&S==="h"&&k.type==="range")return!1;var E=jj(S,k);if(!E)return!0;if(E?j=S:(j=S==="v"?"h":"v",E=jj(S,k)),!E)return!1;if(!r.current&&"changedTouches"in w&&(b||_)&&(r.current=j),!j)return!0;var N=r.current||j;return PK(N,y,w,N==="h"?b:_)},[]),c=p.useCallback(function(w){var y=w;if(!(!Gi.length||Gi[Gi.length-1]!==a)){var x="deltaY"in y?Sj(y):Bf(y),g=t.current.filter(function(j){return j.name===y.type&&(j.target===y.target||y.target===j.shadowParent)&&AK(j.delta,x)})[0];if(g&&g.should){y.cancelable&&y.preventDefault();return}if(!g){var b=(o.current.shards||[]).map(Ej).filter(Boolean).filter(function(j){return j.contains(y.target)}),_=b.length>0?l(y,b[0]):!o.current.noIsolation;_&&y.cancelable&&y.preventDefault()}}},[]),u=p.useCallback(function(w,y,x,g){var b={name:w,delta:y,target:x,should:g,shadowParent:DK(x)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(_){return _!==b})},1)},[]),d=p.useCallback(function(w){n.current=Bf(w),r.current=void 0},[]),f=p.useCallback(function(w){u(w.type,Sj(w),w.target,l(w,e.lockRef.current))},[]),h=p.useCallback(function(w){u(w.type,Bf(w),w.target,l(w,e.lockRef.current))},[]);p.useEffect(function(){return Gi.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,Ki),document.addEventListener("touchmove",c,Ki),document.addEventListener("touchstart",d,Ki),function(){Gi=Gi.filter(function(w){return w!==a}),document.removeEventListener("wheel",c,Ki),document.removeEventListener("touchmove",c,Ki),document.removeEventListener("touchstart",d,Ki)}},[]);var m=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(a,{styles:RK(s)}):null,m?p.createElement(kK,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function DK(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const IK=uK(OA,MK);var _p=p.forwardRef(function(e,t){return p.createElement(bp,zr({},e,{ref:t,sideCar:IK}))});_p.classNames=bp.classNames;var LK=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Yi=new WeakMap,Uf=new WeakMap,Vf={},cy=0,$A=function(e){return e&&(e.host||$A(e.parentNode))},$K=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=$A(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},FK=function(e,t,n,r){var s=$K(t,Array.isArray(e)?e:[e]);Vf[n]||(Vf[n]=new WeakMap);var a=Vf[n],o=[],l=new Set,c=new Set(s),u=function(f){!f||l.has(f)||(l.add(f),u(f.parentNode))};s.forEach(u);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(l.has(h))d(h);else try{var m=h.getAttribute(r),v=m!==null&&m!=="false",w=(Yi.get(h)||0)+1,y=(a.get(h)||0)+1;Yi.set(h,w),a.set(h,y),o.push(h),w===1&&v&&Uf.set(h,!0),y===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return d(t),l.clear(),cy++,function(){o.forEach(function(f){var h=Yi.get(f)-1,m=a.get(f)-1;Yi.set(f,h),a.set(f,m),h||(Uf.has(f)||f.removeAttribute(r),Uf.delete(f)),m||f.removeAttribute(n)}),cy--,cy||(Yi=new WeakMap,Yi=new WeakMap,Uf=new WeakMap,Vf={})}},ab=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),s=LK(e);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live]"))),FK(r,s,n,"aria-hidden")):function(){return null}},kp="Dialog",[FA,zA]=Ln(kp),[zK,_s]=FA(kp),BA=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:s,onOpenChange:a,modal:o=!0}=e,l=p.useRef(null),c=p.useRef(null),[u,d]=vs({prop:r,defaultProp:s??!1,onChange:a,caller:kp});return i.jsx(zK,{scope:t,triggerRef:l,contentRef:c,contentId:Vs(),titleId:Vs(),descriptionId:Vs(),open:u,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:o,children:n})};BA.displayName=kp;var UA="DialogTrigger",VA=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=_s(UA,n),a=ze(t,s.triggerRef);return i.jsx(Te.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":lb(s.open),...r,ref:a,onClick:xe(e.onClick,s.onOpenToggle)})});VA.displayName=UA;var ob="DialogPortal",[BK,WA]=FA(ob,{forceMount:void 0}),HA=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:s}=e,a=_s(ob,t);return i.jsx(BK,{scope:t,forceMount:n,children:p.Children.map(r,o=>i.jsx(Jn,{present:n||a.open,children:i.jsx(Sd,{asChild:!0,container:s,children:o})}))})};HA.displayName=ob;var fm="DialogOverlay",qA=p.forwardRef((e,t)=>{const n=WA(fm,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,a=_s(fm,e.__scopeDialog);return a.modal?i.jsx(Jn,{present:r||a.open,children:i.jsx(VK,{...s,ref:t})}):null});qA.displayName=fm;var UK=gi("DialogOverlay.RemoveScroll"),VK=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=_s(fm,n);return i.jsx(_p,{as:UK,allowPinchZoom:!0,shards:[s.contentRef],children:i.jsx(Te.div,{"data-state":lb(s.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ki="DialogContent",KA=p.forwardRef((e,t)=>{const n=WA(ki,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,a=_s(ki,e.__scopeDialog);return i.jsx(Jn,{present:r||a.open,children:a.modal?i.jsx(WK,{...s,ref:t}):i.jsx(HK,{...s,ref:t})})});KA.displayName=ki;var WK=p.forwardRef((e,t)=>{const n=_s(ki,e.__scopeDialog),r=p.useRef(null),s=ze(t,n.contentRef,r);return p.useEffect(()=>{const a=r.current;if(a)return ab(a)},[]),i.jsx(GA,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xe(e.onCloseAutoFocus,a=>{var o;a.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:xe(e.onPointerDownOutside,a=>{const o=a.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&a.preventDefault()}),onFocusOutside:xe(e.onFocusOutside,a=>a.preventDefault())})}),HK=p.forwardRef((e,t)=>{const n=_s(ki,e.__scopeDialog),r=p.useRef(!1),s=p.useRef(!1);return i.jsx(GA,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:a=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=a.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),GA=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:a,...o}=e,l=_s(ki,n),c=p.useRef(null),u=ze(t,c);return sb(),i.jsxs(i.Fragment,{children:[i.jsx(wp,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:a,children:i.jsx(wc,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":lb(l.open),...o,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(KK,{titleId:l.titleId}),i.jsx(YK,{contentRef:c,descriptionId:l.descriptionId})]})]})}),ib="DialogTitle",YA=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=_s(ib,n);return i.jsx(Te.h2,{id:s.titleId,...r,ref:t})});YA.displayName=ib;var QA="DialogDescription",XA=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=_s(QA,n);return i.jsx(Te.p,{id:s.descriptionId,...r,ref:t})});XA.displayName=QA;var ZA="DialogClose",JA=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=_s(ZA,n);return i.jsx(Te.button,{type:"button",...r,ref:t,onClick:xe(e.onClick,()=>s.onOpenChange(!1))})});JA.displayName=ZA;function lb(e){return e?"open":"closed"}var eR="DialogTitleWarning",[qK,tR]=T3(eR,{contentName:ki,titleName:ib,docsSlug:"dialog"}),KK=({titleId:e})=>{const t=tR(eR),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},GK="DialogDescriptionWarning",YK=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${tR(GK).contentName}}.`;return p.useEffect(()=>{var a;const s=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},cb=BA,nR=VA,ub=HA,Ld=qA,$d=KA,Fd=YA,zd=XA,jp=JA;function rR(e,t){if(t==null||t(e),e.defaultPrevented)return;e.preventDefault();const n=e.currentTarget;n&&(n.contains(document.activeElement)||n.focus())}const Mc=cb,Tse=nR,QK=ub,sR=p.forwardRef(({className:e,...t},n)=>i.jsx(Ld,{ref:n,className:Y("fixed inset-0 z-[120] 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",e),...t}));sR.displayName=Ld.displayName;const Oi=p.forwardRef(({className:e,children:t,onOpenAutoFocus:n,...r},s)=>i.jsxs(QK,{children:[i.jsx(sR,{}),i.jsxs($d,{ref:s,onOpenAutoFocus:a=>rR(a,n),className:Y("fixed left-[50%] top-[50%] z-[120] 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 overflow-y-auto",e),...r,children:[t,i.jsxs(jp,{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-inset disabled:pointer-events-none",children:[i.jsx(Sa,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Oi.displayName=$d.displayName;const Bd=({className:e,...t})=>i.jsx("div",{className:Y("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Bd.displayName="DialogHeader";const Sp=({className:e,...t})=>i.jsx("div",{className:Y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Sp.displayName="DialogFooter";const Mi=p.forwardRef(({className:e,...t},n)=>i.jsx(Fd,{ref:n,className:Y("text-lg font-semibold leading-none tracking-tight",e),...t}));Mi.displayName=Fd.displayName;const Ud=p.forwardRef(({className:e,...t},n)=>i.jsx(zd,{ref:n,className:Y("text-sm text-muted-foreground",e),...t}));Ud.displayName=zd.displayName;var XK=p.createContext(void 0);function Vd(e){const t=p.useContext(XK);return e||t||"ltr"}function Nx(e,[t,n]){return Math.min(n,Math.max(t,e))}function ZK(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var db="ScrollArea",[aR]=Ln(db),[JK,Gr]=aR(db),oR=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:s,scrollHideDelay:a=600,...o}=e,[l,c]=p.useState(null),[u,d]=p.useState(null),[f,h]=p.useState(null),[m,v]=p.useState(null),[w,y]=p.useState(null),[x,g]=p.useState(0),[b,_]=p.useState(0),[j,k]=p.useState(!1),[S,E]=p.useState(!1),N=ze(t,z=>c(z)),O=Vd(s);return i.jsx(JK,{scope:n,type:r,dir:O,scrollHideDelay:a,scrollArea:l,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:m,onScrollbarXChange:v,scrollbarXEnabled:j,onScrollbarXEnabledChange:k,scrollbarY:w,onScrollbarYChange:y,scrollbarYEnabled:S,onScrollbarYEnabledChange:E,onCornerWidthChange:g,onCornerHeightChange:_,children:i.jsx(Te.div,{dir:O,...o,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":b+"px",...e.style}})})});oR.displayName=db;var iR="ScrollAreaViewport",lR=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:s,...a}=e,o=Gr(iR,n),l=p.useRef(null),c=ze(t,l,o.onViewportChange);return i.jsxs(i.Fragment,{children:[i.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:s}),i.jsx(Te.div,{"data-radix-scroll-area-viewport":"",...a,ref:c,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...e.style},children:i.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});lR.displayName=iR;var Zs="ScrollAreaScrollbar",fb=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=Gr(Zs,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=s,l=e.orientation==="horizontal";return p.useEffect(()=>(l?a(!0):o(!0),()=>{l?a(!1):o(!1)}),[l,a,o]),s.type==="hover"?i.jsx(eG,{...r,ref:t,forceMount:n}):s.type==="scroll"?i.jsx(tG,{...r,ref:t,forceMount:n}):s.type==="auto"?i.jsx(cR,{...r,ref:t,forceMount:n}):s.type==="always"?i.jsx(hb,{...r,ref:t}):null});fb.displayName=Zs;var eG=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=Gr(Zs,e.__scopeScrollArea),[a,o]=p.useState(!1);return p.useEffect(()=>{const l=s.scrollArea;let c=0;if(l){const u=()=>{window.clearTimeout(c),o(!0)},d=()=>{c=window.setTimeout(()=>o(!1),s.scrollHideDelay)};return l.addEventListener("pointerenter",u),l.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",u),l.removeEventListener("pointerleave",d)}}},[s.scrollArea,s.scrollHideDelay]),i.jsx(Jn,{present:n||a,children:i.jsx(cR,{"data-state":a?"visible":"hidden",...r,ref:t})})}),tG=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=Gr(Zs,e.__scopeScrollArea),a=e.orientation==="horizontal",o=Np(()=>c("SCROLL_END"),100),[l,c]=ZK("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 p.useEffect(()=>{if(l==="idle"){const u=window.setTimeout(()=>c("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(u)}},[l,s.scrollHideDelay,c]),p.useEffect(()=>{const u=s.viewport,d=a?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const m=u[d];f!==m&&(c("SCROLL"),o()),f=m};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[s.viewport,a,c,o]),i.jsx(Jn,{present:n||l!=="hidden",children:i.jsx(hb,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:xe(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:xe(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),cR=p.forwardRef((e,t)=>{const n=Gr(Zs,e.__scopeScrollArea),{forceMount:r,...s}=e,[a,o]=p.useState(!1),l=e.orientation==="horizontal",c=Np(()=>{if(n.viewport){const u=n.viewport.offsetWidth{const{orientation:n="vertical",...r}=e,s=Gr(Zs,e.__scopeScrollArea),a=p.useRef(null),o=p.useRef(0),[l,c]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=mR(l.viewport,l.content),d={...r,sizes:l,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:h=>a.current=h,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:h=>o.current=h};function f(h,m){return iG(h,o.current,l,m)}return n==="horizontal"?i.jsx(nG,{...d,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){const h=s.viewport.scrollLeft,m=Nj(h,l,s.dir);a.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:h=>{s.viewport&&(s.viewport.scrollLeft=h)},onDragScroll:h=>{s.viewport&&(s.viewport.scrollLeft=f(h,s.dir))}}):n==="vertical"?i.jsx(rG,{...d,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){const h=s.viewport.scrollTop,m=Nj(h,l);a.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:h=>{s.viewport&&(s.viewport.scrollTop=h)},onDragScroll:h=>{s.viewport&&(s.viewport.scrollTop=f(h))}}):null}),nG=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...s}=e,a=Gr(Zs,e.__scopeScrollArea),[o,l]=p.useState(),c=p.useRef(null),u=ze(t,c,a.onScrollbarXChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),i.jsx(dR,{"data-orientation":"horizontal",...s,ref:u,sizes:n,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Ep(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(a.viewport){const h=a.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),gR(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:mm(o.paddingLeft),paddingEnd:mm(o.paddingRight)}})}})}),rG=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...s}=e,a=Gr(Zs,e.__scopeScrollArea),[o,l]=p.useState(),c=p.useRef(null),u=ze(t,c,a.onScrollbarYChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),i.jsx(dR,{"data-orientation":"vertical",...s,ref:u,sizes:n,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Ep(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(a.viewport){const h=a.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),gR(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:mm(o.paddingTop),paddingEnd:mm(o.paddingBottom)}})}})}),[sG,uR]=aR(Zs),dR=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:s,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,m=Gr(Zs,n),[v,w]=p.useState(null),y=ze(t,N=>w(N)),x=p.useRef(null),g=p.useRef(""),b=m.viewport,_=r.content-r.viewport,j=on(d),k=on(c),S=Np(f,10);function E(N){if(x.current){const O=N.clientX-x.current.left,z=N.clientY-x.current.top;u({x:O,y:z})}}return p.useEffect(()=>{const N=O=>{const z=O.target;(v==null?void 0:v.contains(z))&&j(O,_)};return document.addEventListener("wheel",N,{passive:!1}),()=>document.removeEventListener("wheel",N,{passive:!1})},[b,v,_,j]),p.useEffect(k,[r,k]),dc(v,S),dc(m.content,S),i.jsx(sG,{scope:n,scrollbar:v,hasThumb:s,onThumbChange:on(a),onThumbPointerUp:on(o),onThumbPositionChange:k,onThumbPointerDown:on(l),children:i.jsx(Te.div,{...h,ref:y,style:{position:"absolute",...h.style},onPointerDown:xe(e.onPointerDown,N=>{N.button===0&&(N.target.setPointerCapture(N.pointerId),x.current=v.getBoundingClientRect(),g.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),E(N))}),onPointerMove:xe(e.onPointerMove,E),onPointerUp:xe(e.onPointerUp,N=>{const O=N.target;O.hasPointerCapture(N.pointerId)&&O.releasePointerCapture(N.pointerId),document.body.style.webkitUserSelect=g.current,m.viewport&&(m.viewport.style.scrollBehavior=""),x.current=null})})})}),hm="ScrollAreaThumb",fR=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=uR(hm,e.__scopeScrollArea);return i.jsx(Jn,{present:n||s.hasThumb,children:i.jsx(aG,{ref:t,...r})})}),aG=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...s}=e,a=Gr(hm,n),o=uR(hm,n),{onThumbPositionChange:l}=o,c=ze(t,f=>o.onThumbChange(f)),u=p.useRef(void 0),d=Np(()=>{u.current&&(u.current(),u.current=void 0)},100);return p.useEffect(()=>{const f=a.viewport;if(f){const h=()=>{if(d(),!u.current){const m=lG(f,l);u.current=m,l()}};return l(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[a.viewport,d,l]),i.jsx(Te.div,{"data-state":o.hasThumb?"visible":"hidden",...s,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:xe(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),v=f.clientX-m.left,w=f.clientY-m.top;o.onThumbPointerDown({x:v,y:w})}),onPointerUp:xe(e.onPointerUp,o.onThumbPointerUp)})});fR.displayName=hm;var mb="ScrollAreaCorner",hR=p.forwardRef((e,t)=>{const n=Gr(mb,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?i.jsx(oG,{...e,ref:t}):null});hR.displayName=mb;var oG=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,s=Gr(mb,n),[a,o]=p.useState(0),[l,c]=p.useState(0),u=!!(a&&l);return dc(s.scrollbarX,()=>{var f;const d=((f=s.scrollbarX)==null?void 0:f.offsetHeight)||0;s.onCornerHeightChange(d),c(d)}),dc(s.scrollbarY,()=>{var f;const d=((f=s.scrollbarY)==null?void 0:f.offsetWidth)||0;s.onCornerWidthChange(d),o(d)}),u?i.jsx(Te.div,{...r,ref:t,style:{width:a,height:l,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function mm(e){return e?parseInt(e,10):0}function mR(e,t){const n=e/t;return isNaN(n)?0:n}function Ep(e){const t=mR(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function iG(e,t,n,r="ltr"){const s=Ep(n),a=s/2,o=t||a,l=s-o,c=n.scrollbar.paddingStart+o,u=n.scrollbar.size-n.scrollbar.paddingEnd-l,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return pR([c,u],f)(e)}function Nj(e,t,n="ltr"){const r=Ep(t),s=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-s,o=t.content-t.viewport,l=a-r,c=n==="ltr"?[0,o]:[o*-1,0],u=Nx(e,c);return pR([0,o],[0,l])(u)}function pR(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function gR(e,t){return e>0&&e{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function s(){const a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,l=n.top!==a.top;(o||l)&&t(),n=a,r=window.requestAnimationFrame(s)}(),()=>window.cancelAnimationFrame(r)};function Np(e,t){const n=on(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function dc(e,t){const n=on(t);Zt(()=>{let r=0;if(e){const s=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return s.observe(e),()=>{window.cancelAnimationFrame(r),s.unobserve(e)}}},[e,n])}var yR=oR,cG=lR,uG=hR;const vR=p.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(yR,{className:Y("relative overflow-hidden",e),...n,children:[i.jsx(cG,{ref:r,className:"h-full w-full rounded-[inherit]",children:t}),i.jsx(xR,{}),i.jsx(uG,{})]}));vR.displayName=yR.displayName;const xR=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>i.jsx(fb,{ref:r,orientation:t,className:Y("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:i.jsx(fR,{className:"relative flex-1 rounded-full bg-border"})}));xR.displayName=fb.displayName;var dG="Separator",Cj="horizontal",fG=["horizontal","vertical"],wR=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=Cj,...s}=e,a=hG(r)?r:Cj,l=n?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return i.jsx(Te.div,{"data-orientation":a,...l,...s,ref:t})});wR.displayName=dG;function hG(e){return fG.includes(e)}var bR=wR;const _R=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},s)=>i.jsx(bR,{ref:s,decorative:n,orientation:t,className:Y("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));_R.displayName=bR.displayName;const uy=new Set;async function pb(e,t){if(uy.has(e))throw new Error("Deze actie is al bezig. Wacht even.");uy.add(e);try{return await t()}finally{uy.delete(e)}}const mG="project-photos",pG=60*60,gG=50*60*1e3,vh=new Map;function yG(){vh.clear()}async function vG(e,t=Date.now()){const n=Array.from(new Set(e.filter(a=>!!a)));if(n.length===0)return new Map;const r=n.filter(a=>{const o=vh.get(a);return!o||t-o.signedAtMs>=gG});if(r.length>0)try{const{data:a,error:o}=await B.storage.from(mG).createSignedUrls(r,pG);if(o)throw new Error(o.message||"onbekende fout van storage");for(const l of a??[])l!=null&&l.path&&l.signedUrl&&vh.set(l.path,{url:l.signedUrl,signedAtMs:t})}catch(a){const o=a instanceof Error?a.message:String(a);console.warn(`Kon ${r.length} foto-URL(s) niet ondertekenen: ${o}`)}const s=new Map;for(const a of n){const o=vh.get(a);o&&s.set(a,o.url)}return s}let xG=null;var dE;try{xG=((dE=B.auth.onAuthStateChange(e=>{e==="SIGNED_OUT"&&yG()}).data)==null?void 0:dE.subscription)??null}catch{}function wG(e,t){const n=e[1];return Array.isArray(n)&&n.includes(t)}function bG(e,t){if(!e)return!1;for(const n of e.values())if(n.some(r=>r.id===t))return!0;return!1}function kR(e,t){if(!e)return e;let n=!1;const r=new Map;for(const[s,a]of e){const o=a.findIndex(c=>c.id===t);if(o===-1){r.set(s,a);continue}n=!0;const l=[...a.slice(0,o),...a.slice(o+1)];l.length>0&&r.set(s,l)}return n?r:e}function _G(e,t){if(!e)return e;if(!t.visibleOnPlanner)return kR(e,t.noteId);let n=!1;const r=new Map;for(const[s,a]of e){const o=a.findIndex(c=>c.id===t.noteId);if(o===-1){r.set(s,a);continue}n=!0;const l=a.slice();l[o]={...l[o],content:t.content},r.set(s,l)}return n?r:e}const Au=["planner-visible-notes"];async function jR(e){await e.cancelQueries({queryKey:Au})}async function kG(e,t){await jR(e),e.setQueriesData({queryKey:Au},n=>kR(n,t))}async function jG(e,t){await jR(e);const n=e.getQueriesData({queryKey:Au}),r=n.some(([,a])=>bG(a,t.noteId)),s=n.some(([a])=>wG(a,t.projectId));e.setQueriesData({queryKey:Au},a=>_G(a,t)),!r&&t.visibleOnPlanner&&s&&e.invalidateQueries({queryKey:Au})}async function SG(e){const[t,n,r]=await Promise.all([B.from("project_photos").select(` *, staff:staff_id (name) `).eq("project_id",e).order("uploaded_at",{ascending:!1}),B.from("project_checklist_items").select("*").eq("project_id",e).order("sort_order",{ascending:!0}),B.from("project_notes").select(` *, staff:staff_id (name) `).eq("project_id",e).order("created_at",{ascending:!1})]),s=t.error??n.error??r.error;if(s)throw s;const a=(t.data||[]).map(u=>{var d;return{id:u.id,photo_url:u.photo_url,storage_path:u.storage_path??null,photo_type:u.photo_type,description:u.description,uploaded_at:u.uploaded_at,staff_id:u.staff_id,staff_name:(d=u.staff)==null?void 0:d.name}}),o=a.map(u=>u.storage_path).filter(u=>!!u);if(o.length>0){const u=await vG(o);for(const d of a)if(d.storage_path){const f=u.get(d.storage_path);f&&(d.photo_url=f)}}const l=(n.data||[]).map(u=>({id:u.id,description:u.description,is_completed:u.is_completed,completed_by:u.completed_by,completed_at:u.completed_at,sort_order:u.sort_order,classification_key:u.classification_key??null,item_type:u.item_type==="meerwerk"?"meerwerk":"handeling",meerwerk_note:u.meerwerk_note??null})),c=(r.data||[]).map(u=>{var d;return{id:u.id,content:u.content,note_type:u.note_type,created_at:u.created_at,staff_id:u.staff_id,staff_name:(d=u.staff)==null?void 0:d.name,is_private:u.is_private,visible_on_planner:u.visible_on_planner,customer_id:u.customer_id,scheduled_date:u.scheduled_date}});return{photos:a,checklist:l,notes:c}}function SR(e){return xt({queryKey:["project-details-assets",e],queryFn:()=>SG(e),enabled:!!e})}function EG(){const e=Ge();return Ke({mutationFn:async({projectId:t,status:n})=>{const{error:r}=await B.from("projects").update({status:n,updated_at:new Date().toISOString()}).eq("id",t);if(r)throw r},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["staff-projects"]}),e.invalidateQueries({queryKey:["project-details-assets",n.projectId]}),K.success("Status bijgewerkt")},onError:t=>{console.error("Error updating status:",t),K.error("Kon status niet bijwerken")}})}function ER(){const e=Ge();return Ke({mutationFn:async({itemId:t,isCompleted:n,staffId:r,organizationId:s})=>{if(!s)throw new Error("Geen organisatiecontext gevonden voor deze checklist-regel");const a=n?new Date().toISOString():null,{error:o}=await B.from("project_checklist_items").update({is_completed:n,completed_by:n?r:null,completed_at:a}).eq("id",t).eq("organization_id",s);if(o)throw o;return{completedAt:a}},onSuccess:(t,n)=>{e.setQueriesData({queryKey:["project-details-assets"]},r=>{if(!r)return r;const s=r.checklist.findIndex(o=>o.id===n.itemId);if(s===-1)return r;const a=r.checklist.slice();return a[s]={...a[s],is_completed:n.isCompleted,completed_by:n.isCompleted?n.staffId:null,completed_at:(t==null?void 0:t.completedAt)??null},{...r,checklist:a}})},onError:t=>{console.error("Error toggling checklist item:",t),e.invalidateQueries({queryKey:["project-details-assets"]}),K.error("Kon item niet bijwerken")}})}function Pse(){const e=Ge();return Ke({mutationFn:async({projectId:t,organizationId:n,description:r,classificationKey:s,itemType:a,sortOrder:o})=>{const l=r.trim();if(!l)throw new Error("Omschrijving is leeg");await Je({organizationId:n,scope:"checklist-item-add",key:`${t}:${l}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const{error:c}=await B.from("project_checklist_items").insert({project_id:t,organization_id:n,description:l,classification_key:s,item_type:a,sort_order:o,is_completed:!1});if(c)throw c},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["project-details-assets",n.projectId]}),K.success("Regel toegevoegd")},onError:t=>{console.error("Error adding checklist item:",t),K.error("Kon regel niet toevoegen")}})}function Ase(){const e=Ge();return Ke({mutationFn:async({itemId:t,organizationId:n})=>{await Je({organizationId:n,scope:"checklist-item-delete",key:t,ttlSeconds:30});const{error:r}=await B.from("project_checklist_items").delete().eq("id",t).eq("organization_id",n);if(r)throw r},onSuccess:()=>{e.invalidateQueries({queryKey:["project-details-assets"]}),e.invalidateQueries({queryKey:["invoice-ready-projects"]}),K.success("Regel verwijderd")},onError:t=>{console.error("Error deleting checklist item:",t),K.error("Kon regel niet verwijderen")}})}function NG(){const e=Ge();return Ke({mutationFn:async({itemId:t,note:n,organizationId:r})=>{await Je({organizationId:r,scope:"checklist-meerwerk-note",key:`${t}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const s=n.trim(),{error:a}=await B.from("project_checklist_items").update({meerwerk_note:s||null}).eq("id",t).eq("organization_id",r);if(a)throw a},onSuccess:()=>{e.invalidateQueries({queryKey:["project-details-assets"]}),e.invalidateQueries({queryKey:["invoice-ready-projects"]}),K.success("Meerwerk opgeslagen")},onError:t=>{console.error("Error updating meerwerk note:",t),K.error("Kon meerwerk niet opslaan")}})}function CG(){const e=Ge();return Ke({mutationFn:async({projectId:t,staffId:n,content:r,noteType:s,organizationId:a,isPrivate:o,visibleOnPlanner:l=!1,customerId:c=null,scheduledDate:u=null})=>{const d=o?!1:l;a&&await Je({organizationId:a,scope:"project-note-add",key:`${t}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const{error:f}=await B.from("project_notes").insert({project_id:t,staff_id:n,content:r,note_type:s,organization_id:a,is_private:o,visible_on_planner:d,customer_id:c,scheduled_date:u});if(f)throw f;return{visibleOnPlanner:d}},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["project-details-assets",n.projectId]}),t!=null&&t.visibleOnPlanner&&e.invalidateQueries({queryKey:["planner-visible-notes"]}),K.success("Opmerking toegevoegd")},onError:t=>{console.error("Error adding note:",t),K.error("Kon opmerking niet toevoegen")}})}function Rse(){const e=Ge();return Ke({mutationFn:async({noteId:t,content:n,isPrivate:r,visibleOnPlanner:s,organizationId:a})=>{a&&await Je({organizationId:a,scope:"project-note-update",key:`${t}-${Date.now()}`});const o=r?!1:s,{error:l}=await B.from("project_notes").update({content:n,is_private:r,visible_on_planner:o}).eq("id",t);if(l)throw l;return{visibleOnPlanner:o}},onSuccess:async(t,n)=>{e.invalidateQueries({queryKey:["project-details-assets",n.projectId]}),await jG(e,{noteId:n.noteId,projectId:n.projectId,content:n.content,visibleOnPlanner:(t==null?void 0:t.visibleOnPlanner)??!1}),K.success("Opmerking bijgewerkt")},onError:t=>{console.error("Error updating note:",t),K.error("Kon opmerking niet bijwerken")}})}function Ose(){const e=Ge();return Ke({mutationFn:async({noteId:t,organizationId:n})=>{n&&await Je({organizationId:n,scope:"project-note-delete",key:`${t}-${Date.now()}`});const{error:r}=await B.from("project_notes").delete().eq("id",t);if(r)throw r},onSuccess:async(t,n)=>{e.invalidateQueries({queryKey:["project-details-assets",n.projectId]}),await kG(e,n.noteId),K.success("Opmerking verwijderd")},onError:t=>{console.error("Error deleting note:",t),K.error("Kon opmerking niet verwijderen")}})}function TG(){const e=Ge();return Ke({mutationFn:async({projectId:t,staffId:n,file:r,photoType:s,description:a,organizationId:o})=>{const l=Ad(r,"projectPhoto");if(l.valid===!1)throw new Error(l.error);if(!o)throw new Error("Geen organisatiecontext gevonden voor foto upload.");const c=`project-photo:${t}:${r.name}:${r.size}`;return pb(c,async()=>{await Je({organizationId:o,scope:"project-photo-upload",key:c});const u=r.name.split(".").pop(),d=`${o}/${t}/${Date.now()}.${u}`,{error:f}=await B.storage.from("project-photos").upload(d,r);if(f)throw f;const{error:h}=await B.from("project_photos").insert({project_id:t,staff_id:n,photo_url:"",storage_path:d,photo_type:s,description:a,organization_id:o});if(h)throw h;return d})},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["project-details-assets",n.projectId]}),K.success("Foto geüpload")},onError:t=>{console.error("Error uploading photo:",t),K.error("Kon foto niet uploaden")}})}const Tj=[{value:"onderweg",label:"Onderweg",icon:wl,color:"bg-blue-500 hover:bg-blue-600 text-white",activeColor:"bg-blue-600 ring-2 ring-blue-300"},{value:"ter_plaatse",label:"Ter plaatse",icon:xo,color:"bg-amber-500 hover:bg-amber-600 text-white",activeColor:"bg-amber-600 ring-2 ring-amber-300"},{value:"completed",label:"Voltooid",icon:yi,color:"bg-green-500 hover:bg-green-600 text-white",activeColor:"bg-green-600 ring-2 ring-green-300"},{value:"not_completed",label:"Niet af",icon:S5,color:"bg-gray-500 hover:bg-gray-600 text-white",activeColor:"bg-gray-600 ring-2 ring-gray-300"},{value:"cancelled",label:"Geannuleerd",icon:_5,color:"bg-red-500 hover:bg-red-600 text-white",activeColor:"bg-red-600 ring-2 ring-red-300"},{value:"material_needed",label:"Materiaal nodig",icon:Cd,color:"bg-orange-500 hover:bg-orange-600 text-white",activeColor:"bg-orange-600 ring-2 ring-orange-300"},{value:"problem",label:"Probleem",icon:Vr,color:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",activeColor:"bg-destructive ring-2 ring-destructive/30"}];function PG({currentStatus:e,onStatusChange:t,isLoading:n,hideCompleted:r}){const s=r?Tj.filter(a=>a.value!=="completed"):Tj;return i.jsxs("div",{className:"space-y-3",children:[i.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Status"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:s.map(a=>{const o=a.icon,l=e===a.value;return i.jsxs(ne,{size:"sm",disabled:n,onClick:()=>t(a.value),className:Y("gap-2 transition-all",l?a.activeColor:a.color),children:[i.jsx(o,{className:"h-4 w-4"}),a.label]},a.value)})})]})}function AG({name:e,phone:t,email:n,address:r}){const s=()=>{t&&(window.location.href=`tel:${t}`)},a=()=>{if(r){const o=encodeURIComponent(r);window.open(`https://www.google.com/maps/dir/?api=1&destination=${o}`,"_blank")}};return i.jsxs(dt,{children:[i.jsx(ln,{className:"pb-3",children:i.jsxs(cn,{className:"text-base font-medium flex items-center gap-2",children:[i.jsx(vr,{className:"h-4 w-4"}),"Klant"]})}),i.jsxs(bt,{className:"space-y-4",children:[e&&i.jsx("p",{className:"font-semibold text-lg text-foreground",children:e}),i.jsxs("div",{className:"space-y-3",children:[t&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ai,{className:"h-4 w-4 text-muted-foreground shrink-0"}),i.jsx("span",{className:"text-sm flex-1 min-w-0 truncate",children:t}),i.jsx(ne,{size:"sm",variant:"outline",onClick:s,className:"shrink-0",children:"Bellen"})]}),n&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(uo,{className:"h-4 w-4 text-muted-foreground shrink-0"}),i.jsx("a",{href:`mailto:${n}`,className:"text-sm flex-1 min-w-0 truncate hover:underline text-muted-foreground",children:n})]}),r&&i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(xo,{className:"h-4 w-4 text-muted-foreground shrink-0 mt-0.5"}),i.jsx("span",{className:"text-sm flex-1 min-w-0 text-muted-foreground",children:r}),i.jsxs(ne,{size:"sm",variant:"outline",onClick:a,className:"shrink-0 gap-1.5",children:[i.jsx(W5,{className:"h-3 w-3"}),"Navigeer"]})]})]}),!e&&!t&&!n&&!r&&i.jsx("p",{className:"text-sm text-muted-foreground italic",children:"Geen klantgegevens beschikbaar"})]})]})}const Di=p.forwardRef(({className:e,...t},n)=>i.jsx("textarea",{className:Y("flex min-h-[80px] w-full rounded-md border border-field-border bg-field px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground transition-[color,background-color,border-color,box-shadow] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:bg-[hsl(var(--field-focus))] focus-visible:shadow-[0_0_0_3px_hsl(var(--field-glow))] ring-inset disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Di.displayName="Textarea";function Mse(e,t,n,r){return e.filter(s=>s.service_id===t).slice().sort((s,a)=>s.sort_order-a.sort_order).map(s=>({project_id:n,organization_id:r,description:s.description,classification_key:s.classification_key,item_type:s.item_type,sort_order:s.sort_order,is_completed:!1}))}function RG(e){return e.normalize("NFC").replace(/\s+/g," ").trim().toLowerCase()}function Pj(e){return`${RG(e.description)}|${e.classification_key??""}|${e.item_type}`}function Dse(e,t){const n=new Set(t.map(Pj));return e.filter(r=>!n.has(Pj(r)))}function gb(e,t){return t===void 0||e===null?!0:e===t}function OG(e,t){const n=e.filter(r=>gb(r.classification_key,t));return{visible:n,completed:n.filter(r=>r.is_completed).length,total:n.length}}function NR({items:e,onToggle:t,isLoading:n,activeClassificationKey:r,organizationId:s,variant:a="card"}){const o=NG(),l=a==="plain",{visible:c,completed:u}=OG(e,r);if(c.length===0)return null;const d=(h,m)=>{const v=m.trim();v!==(h.meerwerk_note??"")&&s&&o.mutate({itemId:h.id,note:v,organizationId:s})},f=i.jsx("div",{className:"space-y-2",children:c.map(h=>i.jsxs("div",{className:"space-y-1",children:[i.jsxs("button",{onClick:()=>t(h.id,!h.is_completed),disabled:n,className:Y("w-full flex items-center gap-3 p-2 rounded-lg text-left","hover:bg-muted/50 transition-colors",h.is_completed&&"opacity-60"),children:[n?i.jsx(yn,{className:"h-5 w-5 animate-spin text-muted-foreground"}):h.is_completed?i.jsx(yi,{className:"h-5 w-5 text-green-500 shrink-0"}):i.jsx(Zw,{className:"h-5 w-5 text-muted-foreground shrink-0"}),i.jsx("span",{className:Y("text-sm flex-1",h.is_completed&&"line-through text-muted-foreground"),children:h.description})]}),h.item_type==="meerwerk"&&i.jsxs(i.Fragment,{children:[l&&h.meerwerk_note&&i.jsx("p",{"data-staff-print-only":!0,className:"ml-8 whitespace-pre-wrap text-sm text-muted-foreground",children:h.meerwerk_note}),i.jsx(Di,{className:"ml-8 w-[calc(100%-2rem)] text-sm",rows:2,placeholder:"Wat was het extra werk? Dit ziet kantoor bij het factureren.",defaultValue:h.meerwerk_note??"",disabled:!s||o.isPending,onBlur:m=>d(h,m.target.value),"data-staff-print-hide":l?"collapse":void 0})]})]},h.id))});return a==="plain"?i.jsxs("div",{className:"space-y-2",children:[i.jsxs("p",{className:"text-xs text-muted-foreground",children:[u," van ",c.length," afgevinkt"]}),f]}):i.jsxs(dt,{children:[i.jsx(ln,{className:"pb-3",children:i.jsxs(cn,{className:"text-base font-medium flex items-center justify-between",children:[i.jsx("span",{children:"Checklist"}),i.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:[u,"/",c.length]})]})}),i.jsx(bt,{children:f})]})}const dy={before:"Voor",progress:"Werk",after:"Na",problem:"Probleem"};function MG({photos:e,onUpload:t,isUploading:n}){const r=e.filter(f=>f.photo_type!==Al),[s,a]=p.useState(null),[o,l]=p.useState("progress"),c=p.useRef(null),u=f=>{var m;const h=(m=f.target.files)==null?void 0:m[0];h&&(t(h,o),f.target.value="")},d=f=>{var h;l(f),(h=c.current)==null||h.click()};return i.jsxs(i.Fragment,{children:[i.jsxs(dt,{children:[i.jsx(ln,{className:"pb-3",children:i.jsxs(cn,{className:"text-base font-medium flex items-center gap-2",children:[i.jsx(uT,{className:"h-4 w-4"}),"Foto's"]})}),i.jsxs(bt,{children:[i.jsx("input",{ref:c,type:"file",accept:"image/*",capture:"environment",className:"hidden",onChange:u}),i.jsx("div",{className:"flex gap-2 mb-4",children:["before","progress","after","problem"].map(f=>i.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>d(f),disabled:n,className:"gap-1",children:[n&&o===f?i.jsx(yn,{className:"h-3 w-3 animate-spin"}):i.jsx(jc,{className:"h-3 w-3"}),dy[f]]},f))}),r.length>0?i.jsx("div",{className:"grid grid-cols-3 gap-2",children:r.map(f=>i.jsxs("button",{onClick:()=>a(f),className:Y("relative aspect-square rounded-lg overflow-hidden","bg-muted hover:ring-2 ring-primary transition-all"),children:[i.jsx("img",{src:f.photo_url,alt:f.description||"Project foto",className:"w-full h-full object-cover"}),i.jsx("span",{className:"absolute bottom-1 left-1 text-xs bg-black/60 text-white px-1.5 py-0.5 rounded",children:dy[f.photo_type]||f.photo_type})]},f.id))}):i.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[i.jsx(I5,{className:"h-8 w-8 mb-2"}),i.jsx("p",{className:"text-sm",children:"Nog geen foto's"})]})]})]}),i.jsx(Mc,{open:!!s,onOpenChange:()=>a(null),children:i.jsxs(Oi,{className:"max-w-[95vw] max-h-[95vh] p-0 overflow-hidden",children:[i.jsx(Mi,{className:"sr-only",children:"Foto bekijken"}),s&&i.jsxs("div",{className:"relative",children:[i.jsx(ne,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 z-10 bg-black/50 hover:bg-black/70 text-white",onClick:()=>a(null),children:i.jsx(Sa,{className:"h-4 w-4"})}),i.jsx("img",{src:s.photo_url,alt:s.description||"Project foto",className:"w-full h-auto max-h-[90vh] object-contain"}),i.jsxs("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-white p-3",children:[i.jsx("p",{className:"text-sm font-medium",children:dy[s.photo_type]||s.photo_type}),s.staff_name&&i.jsxs("p",{className:"text-xs opacity-80",children:["Door ",s.staff_name]})]})]})]})})]})}function DG(e,t){const n=new Set(t.map(r=>r.id));return e.filter(r=>!n.has(r.id))}function IG(e,t){return e.filter(n=>n.kind==="photo"&&!t.has(n.id)).map(n=>n.id)}function LG(e,t){return!e||!t?!1:e.slice(e.lastIndexOf("/")+1).startsWith(`${t}.`)}function CR(e,t){return e.some(n=>LG(n.storage_path,t))}function $G(e,t){return e.filter(n=>!CR(t,n.id)).reverse()}function Aj(e,t,n,r){return e.filter(s=>CR(t,s.id)||n-s.sinds>=r).map(s=>s.id)}function FG(e,t,n){if(e.length===0)return null;const r=Math.min(...e.map(s=>s.sinds));return Math.max(0,r+n-t)}const zG=2e3,BG=1e4;function TR(e,t=zG,n=BG){return Math.max(0,Math.min(t,n-e))}function Ise(e){const t=p.useRef(e),n=p.useRef(null),r=p.useRef(null);return p.useEffect(()=>{t.current=e},[e]),p.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]),p.useCallback(()=>{const s=Date.now();r.current==null&&(r.current=s),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{n.current=null,r.current=null,t.current()},TR(s-r.current))},[])}function PR(e){return xt({queryKey:["custom-fields",e],queryFn:async()=>{if(!e)return[];const{data:t,error:n}=await B.from("organization_custom_fields").select("*").eq("organization_id",e).eq("is_active",!0).order("sort_order");if(n)throw n;return(t||[]).map(r=>({...r,field_options:r.field_options||[]}))},enabled:!!e})}function Lse(){const e=Ge();return Ke({mutationFn:async t=>{await Je({organizationId:t.organization_id,scope:"custom-field-create",key:`${t.field_name}-${t.field_type}`});const{data:n,error:r}=await B.from("organization_custom_fields").insert({...t,field_options:t.field_options||[]}).select().single();if(r)throw r;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["custom-fields"]}),K.success("Extra veld toegevoegd")},onError:t=>{console.error("Error creating custom field:",t),t.code==="23505"?K.error("Dit veld bestaat al"):K.error("Kon veld niet toevoegen")}})}function AR(e,t){return e.field_type==="checkbox"?t===!0:t==null?!1:String(t).trim()!==""}function $se(e,t,n){var f,h;const{data:r=[],isLoading:s}=PR(n?t??null:null),a=xt({queryKey:["project-completion-fields",e],queryFn:async()=>{const{data:m,error:v}=await B.from("projects").select("id, custom_fields").eq("id",e).single();if(v)throw v;return m},enabled:n&&!!e}),o=xt({queryKey:["project-completion-photos",e],queryFn:async()=>{const{count:m,error:v}=await B.from("project_photos").select("id",{count:"exact",head:!0}).eq("project_id",e).or(`photo_type.is.null,photo_type.neq.${Al}`);if(v)throw v;return m??0},enabled:n&&!!e}),l=xt({queryKey:["project-completion-materials",e],queryFn:async()=>{const{data:m,error:v}=await B.from("project_materials").select("id, quantity_used, is_returned, product:product_id (name)").eq("project_id",e).limit(200);if(v)throw v;return m||[]},enabled:n&&!!e}),c=((f=a.data)==null?void 0:f.custom_fields)??null,u=r.filter(m=>m.is_required).map(m=>{const v=c==null?void 0:c[m.field_name];return{field:m,value:v,isFilled:AR(m,v)}}),d=(l.data??[]).filter(m=>(m.quantity_used===null||m.quantity_used===void 0)&&!m.is_returned);return{isLoading:s||a.isLoading||o.isLoading||l.isLoading,isError:a.isError,requiredFieldChecks:u,projectCustomFields:c,photoCount:o.data??0,materialsTotal:((h=l.data)==null?void 0:h.length)??0,materialsWithoutUsage:d}}function Fse(){const e=Ge();return Ke({mutationFn:async({projectId:t,organizationId:n,currentCustomFields:r,updatedValues:s})=>{await Je({organizationId:n,scope:"project-completion-fields-save",key:`${t}:${JSON.stringify(s)}`,ttlSeconds:30});const a={...r??{},...s},{error:o}=await B.from("projects").update({custom_fields:a,updated_at:new Date().toISOString()}).eq("id",t).eq("organization_id",n);if(o)throw o},onSuccess:(t,{projectId:n})=>{e.invalidateQueries({queryKey:["project-completion-fields",n]}),e.invalidateQueries({queryKey:["project-details"]}),e.invalidateQueries({queryKey:["projects"]})},onError:t=>{console.error("Error saving completion fields:",t),K.error("Kon de ingevulde velden niet opslaan")}})}const ot=p.forwardRef(({className:e,type:t,...n},r)=>i.jsx("input",{type:t,className:Y("flex h-10 w-full rounded-md border border-field-border bg-field 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 transition-[color,background-color,border-color,box-shadow] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:bg-[hsl(var(--field-focus))] focus-visible:shadow-[0_0_0_3px_hsl(var(--field-glow))] ring-inset disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));ot.displayName="Input";const Wd=cb,UG=ub,RR=p.forwardRef(({className:e,...t},n)=>i.jsx(Ld,{className:Y("fixed inset-0 z-[120] 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",e),...t,ref:n}));RR.displayName=Ld.displayName;const VG=bc("fixed z-[120] 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 overflow-y-auto",{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"}}),Dc=p.forwardRef(({side:e="right",className:t,children:n,onOpenAutoFocus:r,...s},a)=>i.jsxs(UG,{children:[i.jsx(RR,{}),i.jsxs($d,{ref:a,onOpenAutoFocus:o=>rR(o,r),className:Y(VG({side:e}),t),...s,children:[n,i.jsxs(jp,{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-inset disabled:pointer-events-none",children:[i.jsx(Sa,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Dc.displayName=$d.displayName;const Ic=({className:e,...t})=>i.jsx("div",{className:Y("flex flex-col space-y-2 text-center sm:text-left",e),...t});Ic.displayName="SheetHeader";const WG=({className:e,...t})=>i.jsx("div",{className:Y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});WG.displayName="SheetFooter";const Lc=p.forwardRef(({className:e,...t},n)=>i.jsx(Fd,{ref:n,className:Y("text-lg font-semibold text-foreground",e),...t}));Lc.displayName=Fd.displayName;const yb=p.forwardRef(({className:e,...t},n)=>i.jsx(zd,{ref:n,className:Y("text-sm text-muted-foreground",e),...t}));yb.displayName=zd.displayName;const HG=2.2,qG="#1F1B18",KG="#FFFFFF",Rj="#A8A29B",GG=80,YG=60;function QG({open:e,onOpenChange:t,defaultNaam:n,onBevestig:r,isBezig:s}){const[a,o]=p.useState(""),[l,c]=p.useState(!1),[u,d]=p.useState(null),f=p.useRef(null),h=p.useRef(!1),m=p.useRef(null),v=p.useRef(null),w=p.useRef(!1),y=p.useRef(null),[x,g]=p.useState(0);p.useEffect(()=>{const M=window.visualViewport;if(!e||!M)return;const C=()=>{const F=window.innerHeight-M.height-M.offsetTop;g(F>GG?Math.round(F):0)};return C(),M.addEventListener("resize",C),M.addEventListener("scroll",C),()=>{M.removeEventListener("resize",C),M.removeEventListener("scroll",C),g(0)}},[e]);const b=p.useCallback(M=>{const C=M.getContext("2d");if(!C)return;const F=M.clientWidth>0?M.width/M.clientWidth:1,W=M.clientHeight>0?M.height/M.clientHeight:1;C.setTransform(F,0,0,W,0,0),C.lineWidth=HG,C.lineCap="round",C.lineJoin="round",C.strokeStyle=qG},[]),_=p.useCallback(M=>{const C=M.clientWidth,F=M.clientHeight;if(C===0||F===0)return!1;const W=window.devicePixelRatio||1;return M.width=Math.round(C*W),M.height=Math.round(F*W),b(M),!0},[b]),j=p.useCallback(()=>{y.current!==null&&(window.cancelAnimationFrame(y.current),y.current=null)},[]),k=p.useCallback(()=>{j();let M=YG;const C=()=>{y.current=null;const F=f.current;F&&(_(F)||(M-=1,!(M<=0)&&(y.current=window.requestAnimationFrame(C))))};C()},[_,j]);p.useEffect(()=>{if(!e){j(),h.current=!1,m.current=null,v.current=null,w.current=!1,c(!1),d(null);return}return c(!1),d(null),h.current=!1,m.current=null,v.current=null,w.current=!1,k(),()=>j()},[e,k,j]);const S=p.useCallback(M=>{if(f.current=M,!M){j();return}k()},[k,j]);p.useEffect(()=>{e&&o(n??"")},[e,n]);const E=(M,C)=>{const F=M.getBoundingClientRect();return{x:C.clientX-F.left,y:C.clientY-F.top}},N=M=>{const C=f.current;if(!C||s||v.current!==null)return;const F=C.getContext("2d");if(!F)return;C.setPointerCapture(M.pointerId),M.preventDefault(),b(C);const W=E(C,M);F.beginPath(),F.moveTo(W.x,W.y),F.lineTo(W.x,W.y),F.stroke(),m.current=W,h.current=!0,v.current=M.pointerId,c(!0),d(null)},O=M=>{if(!h.current||v.current!==M.pointerId)return;const C=f.current,F=m.current;if(!C||!F)return;const W=C.getContext("2d");if(!W)return;const ie=E(C,M);W.beginPath(),W.moveTo(F.x,F.y),W.lineTo(ie.x,ie.y),W.stroke(),m.current=ie},z=M=>{if(v.current!==M.pointerId)return;h.current=!1,m.current=null,v.current=null;const C=f.current;C!=null&&C.hasPointerCapture(M.pointerId)&&C.releasePointerCapture(M.pointerId)},T=()=>{const M=f.current;!M||s||(M.width=M.width,b(M),h.current=!1,m.current=null,v.current=null,c(!1),d(null))},I=a.trim().length>0,P=l&&I&&!s,H=async()=>{const M=f.current;if(!(!M||!P||w.current)){w.current=!0,d(null);try{const C=await new Promise(F=>{M.toBlob(W=>F(W),"image/png")});if(!C){d("De handtekening kon niet worden omgezet naar een afbeelding. Probeer het nog een keer, je tekening blijft staan.");return}await r(C,a.trim())}catch{d("Het bevestigen is niet gelukt. Controleer de verbinding en probeer het opnieuw.")}finally{w.current=!1}}},V=M=>{!M&&(s||w.current)||t(M)};return i.jsx(Wd,{open:e,onOpenChange:V,children:i.jsxs(Dc,{side:"bottom",style:{"--kb":`${x}px`},className:"bottom-[var(--kb)] max-h-[calc(92dvh-var(--kb))] rounded-t-2xl flex flex-col gap-0 p-0 !overflow-hidden",children:[i.jsxs(Ic,{className:"flex-none space-y-1 border-b p-4 text-left",children:[i.jsx(Lc,{className:"pr-10",children:"Handtekening klant"}),i.jsx(yb,{children:"De klant vult hier de naam in en tekent voor het werk dat is uitgevoerd."})]}),i.jsxs("div",{className:"flex-1 min-h-0 space-y-4 overflow-y-auto p-4 scrollbar-subtle",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Tt,{htmlFor:"handtekening-naam",children:"Naam"}),i.jsx(ot,{id:"handtekening-naam",value:a,onChange:M=>o(M.target.value),maxLength:120,autoComplete:"name",placeholder:"Naam van de klant",disabled:s})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"relative overflow-hidden rounded-xl border border-border",style:{background:KG},children:[i.jsx("canvas",{ref:S,role:"img","aria-label":"Tekenvlak voor de handtekening van de klant",className:"block h-52 w-full touch-none select-none",onPointerDown:N,onPointerMove:O,onPointerUp:z,onPointerCancel:z,onLostPointerCapture:z}),i.jsx("div",{className:"pointer-events-none absolute inset-x-4 bottom-8 h-px",style:{background:Rj}}),!l&&i.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center text-sm",style:{color:Rj},children:"Teken hier"})]}),i.jsx("div",{className:"flex justify-end",children:i.jsxs(ne,{type:"button",variant:"outline",className:"h-11 px-4",onClick:T,disabled:!l||s,children:[i.jsx(P5,{className:"h-4 w-4"}),"Wissen"]})})]})]}),i.jsxs("div",{className:"flex-none border-t p-4",style:{paddingBottom:"max(env(safe-area-inset-bottom, 0px), 16px)"},children:[u&&i.jsx("p",{className:"mb-3 text-sm text-destructive",role:"alert",children:u}),i.jsx(ne,{type:"button",className:"h-12 w-full text-base",onClick:H,disabled:!P,children:s?i.jsxs(i.Fragment,{children:[i.jsx(yn,{className:"h-4 w-4 animate-spin"}),"Bezig…"]}):"Bevestigen"})]})]})})}const XG=300,ZG=1e3,fy=3e4;function OR({projectId:e,organizationId:t,staffId:n,projectStatus:r,customerName:s,projectCustomFields:a,checklistItems:o,photos:l,gegevensGeladen:c}){const u=Ge(),d=p.useRef(null),[f,h]=p.useState(!1),[m,v]=p.useState(!1),[w,y]=p.useState(!1),[x,g]=p.useState(null),b=NP(e),{data:_=[],isLoading:j,isError:k}=PR(t),S=p.useMemo(()=>l.filter(te=>te.photo_type!==Al),[l]),E=p.useMemo(()=>l.find(te=>te.photo_type===Al)??null,[l]),N=b.items.filter(te=>te.kind==="photo"),O=b.items.filter(te=>te.kind==="handtekening"),z=O.length>0?O[O.length-1]:null,T=b.items.some(te=>te.kind==="afronden"),I=p.useRef(new Map),P=p.useRef([]),H=p.useRef([]),V=p.useRef(e),M=p.useRef(null),C=p.useRef(null),F=p.useRef(!1),[W,ie]=p.useState(0),oe=p.useCallback(()=>{M.current=null,C.current=null,u.invalidateQueries({queryKey:["project-details-assets",e]}),u.invalidateQueries({queryKey:["project-completion-photos",e]}),F.current&&(F.current=!1,u.invalidateQueries({queryKey:["staff-projects"]}))},[u,e]),ce=p.useCallback(te=>{if(te.length===0)return;const _e=new Set(te);for(const Me of _e){const Ue=I.current.get(Me);Ue&&URL.revokeObjectURL(Ue),I.current.delete(Me)}P.current=P.current.filter(Me=>!_e.has(Me.id)),ie(Me=>Me+1)},[]);p.useEffect(()=>{const te=b.items,_e=V.current!==e;V.current=e,_e&&(P.current=[]);const Me=te.map($=>({id:$.id,kind:$.kind})),Ue=_e?[]:DG(H.current,Me);H.current=Me;let ct=_e;const Rt=Date.now(),Et=IG(Ue,b.afgekeurdeIds).filter($=>I.current.has($));Et.length>0&&(P.current=[...P.current,...Et.map($=>({id:$,sinds:Rt}))],ct=!0);const A=new Set([...Me.map($=>$.id),...P.current.map($=>$.id)]);for(const[$,q]of Array.from(I.current))A.has($)||(URL.revokeObjectURL(q),I.current.delete($),ct=!0);for(const $ of te)!$.blob||I.current.has($.id)||(I.current.set($.id,URL.createObjectURL($.blob)),ct=!0);Ue.length>0&&(Ue.some($=>$.kind==="afronden")&&(F.current=!0),C.current==null&&(C.current=Rt),M.current&&clearTimeout(M.current),te.length===0?(M.current=null,oe()):M.current=setTimeout(oe,TR(Rt-C.current,XG,ZG))),ct&&ie($=>$+1)},[b.items,b.afgekeurdeIds,e,oe]),p.useEffect(()=>{const te=Aj(P.current,S,Date.now(),fy);if(te.length>0){ce(te);return}const _e=FG(P.current,Date.now(),fy);if(_e==null)return;const Me=setTimeout(()=>{ce(Aj(P.current,S,Date.now(),fy))},_e);return()=>clearTimeout(Me)},[W,S,ce]);const re=p.useRef(oe);p.useEffect(()=>{re.current=oe},[oe]),p.useEffect(()=>{const te=I.current;return()=>{M.current&&(clearTimeout(M.current),M.current=null,re.current());for(const _e of te.values())URL.revokeObjectURL(_e);te.clear(),P.current=[]}},[]);const ue=p.useMemo(()=>$G(P.current,S).map(te=>({id:te.id,url:I.current.get(te.id)})).filter(te=>!!te.url),[W,S]),ke=z?I.current.get(z.id):void 0,L=_.filter(te=>te.is_required).filter(te=>!AR(te,a==null?void 0:a[te.field_name])).map(te=>te.field_name),Q=J8({gegevensOnbekend:!c||j||k,checklistTotaal:o.length,checklistAf:o.filter(te=>te.is_completed).length,fotos:S.length,fotosInWachtrij:N.length+ue.length,heeftHandtekening:!!E||!!z,ontbrekendeVerplichteVelden:L}),fe=r==="completed"||T||x===e;p.useEffect(()=>{T&&g(e)},[T,e]);const ee=async te=>{var Ue;const _e=(Ue=te.target.files)==null?void 0:Ue[0];if(te.target.value="",!_e||!t)return;const Me=Ad(_e,"projectPhoto");if(Me.valid===!1){K.error(Me.error);return}try{await Vg({kind:"photo",projectId:e,organizationId:t,staffId:n,blob:_e,ext:nY(_e),description:null,photoType:jP})}catch{K.error("Kon de foto niet klaarzetten")}},je=async(te,_e)=>{if(t){y(!0);try{await Vg({kind:"handtekening",projectId:e,organizationId:t,staffId:n,blob:te,ext:"png",description:_e,photoType:Al}),h(!1)}finally{y(!1)}}},Ee=async()=>{if(!(!Q.kanAfronden||!t||m)){v(!0);try{await Vg({kind:"afronden",projectId:e,organizationId:t,staffId:n}),g(e)}catch{K.error("Kon de opdracht niet afronden")}finally{v(!1)}}};return t?i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("p",{className:"text-sm font-medium text-foreground",children:"Wat er nog moet"}),i.jsxs("span",{className:Y("rounded-full px-2.5 py-0.5 text-xs font-medium",Q.kanAfronden?"bg-status-info-bg text-status-info":"bg-muted text-muted-foreground"),children:[Q.gedaan," van ",Q.totaal]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[i.jsx("p",{className:"text-[13px] font-medium leading-[18px] text-foreground",children:"Foto’s van het werk"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:JG(S.length+N.length+ue.length)})]}),i.jsx("input",{ref:d,type:"file",accept:"image/*",capture:"environment",className:"hidden",onChange:ee,"data-staff-print-hide":"collapse"}),i.jsxs("div",{className:"flex flex-wrap items-start gap-2",children:[i.jsxs("button",{type:"button",onClick:()=>{var te;return(te=d.current)==null?void 0:te.click()},"data-staff-print-hide":"collapse",className:"flex h-20 w-20 flex-none flex-col items-center justify-center gap-1 rounded-xl border border-dashed border-border bg-muted/60 active:bg-muted",children:[i.jsx(uT,{className:"h-[22px] w-[22px] text-primary",strokeWidth:1.5}),i.jsx("span",{className:"text-[11px] font-medium leading-[14px] text-primary",children:"Foto maken"})]}),ue.map(te=>i.jsx("img",{src:te.url,alt:"Foto van het werk",className:"h-20 w-20 flex-none rounded-xl border border-border object-cover"},te.id)),S.map(te=>i.jsx("img",{src:te.photo_url,alt:te.description||"Foto van het werk",className:"h-20 w-20 flex-none rounded-xl border border-border object-cover"},te.id)),N.map(te=>{const _e=I.current.get(te.id);return i.jsxs("div",{className:"relative h-20 w-20 flex-none",children:[_e?i.jsx("img",{src:_e,alt:"Foto die nog verstuurd wordt",className:"h-full w-full rounded-xl border border-border object-cover opacity-70"}):i.jsx("div",{className:"h-full w-full rounded-xl border border-border bg-muted"}),i.jsx("span",{className:"absolute inset-x-1 bottom-1 rounded-md bg-black/60 px-1 py-0.5 text-center text-[10px] leading-[13px] text-white",children:"Wacht"})]},te.id)})]})]}),i.jsx("div",{className:"h-px bg-border"}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[i.jsx("p",{className:"text-[13px] font-medium leading-[18px] text-foreground",children:"Handtekening klant"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:E||z?"Getekend":"Mag ook zonder"})]}),E||z?i.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-border bg-card p-2.5",children:[(z?ke:E!=null&&E.photo_url)?i.jsx("img",{src:z?ke:E==null?void 0:E.photo_url,alt:"Handtekening van de klant",className:"h-10 w-24 flex-none object-contain"}):i.jsx("div",{className:"h-10 w-24 flex-none rounded-md bg-muted"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"truncate text-[13px] font-medium leading-[18px] text-foreground",children:(z?z.description:E==null?void 0:E.description)||"Handtekening"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:z?"Wordt verstuurd zodra je bereik hebt":eY((E==null?void 0:E.uploaded_at)??"")})]}),i.jsx("button",{type:"button",onClick:()=>h(!0),"data-staff-print-hide":"collapse",className:"-my-1.5 flex h-11 flex-none items-center px-3 text-xs font-medium text-primary",children:"Opnieuw"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",onClick:()=>h(!0),"data-staff-print-hide":"collapse",className:"flex h-[88px] w-full flex-col items-center justify-center gap-1.5 rounded-xl border border-dashed border-border bg-muted/60 active:bg-muted",children:[i.jsx(gT,{className:"h-[22px] w-[22px] text-muted-foreground",strokeWidth:1.5}),i.jsx("span",{className:"text-[13px] leading-[18px] text-muted-foreground",children:"Tik om te laten tekenen"})]}),i.jsxs("div",{"data-staff-print-only":!0,className:"pt-6",children:[i.jsx("div",{className:"h-6 border-b border-foreground/40"}),i.jsx("p",{className:"mt-1 text-[11px] leading-[14px] text-muted-foreground",children:"Naam en handtekening klant"})]})]})]}),fe?i.jsxs("div",{className:"flex min-h-12 items-center gap-3 rounded-[10px] bg-status-info-bg px-3.5 py-1.5",children:[i.jsx(yi,{className:"h-5 w-5 flex-none text-status-info",strokeWidth:2}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium leading-[18px] text-status-info",children:"Opdracht afgerond"}),i.jsx("p",{className:"text-xs leading-4 text-status-info/80",children:T?"Wordt verstuurd zodra je bereik hebt":"Kantoor ziet deze opdracht als afgerond"})]})]}):i.jsxs("div",{"data-staff-print-hide":"collapse",children:[i.jsxs(ne,{type:"button",onClick:Ee,disabled:!Q.kanAfronden||m,className:"h-12 w-full gap-2 text-[15px]",children:[m?i.jsx(yn,{className:"h-[18px] w-[18px] animate-spin"}):i.jsx(yi,{className:"h-[18px] w-[18px]",strokeWidth:2}),"Opdracht afronden"]}),Q.blokkades.length>0&&i.jsx("ul",{className:"mt-2 space-y-1 text-xs leading-4 text-status-attention",children:Q.blokkades.map(te=>i.jsx("li",{children:te},te))})]}),b.total>0&&i.jsxs("div",{"data-staff-print-hide":"collapse",className:Y("flex items-center justify-between gap-3 rounded-lg px-3 py-2 text-xs",b.mislukt>0?"bg-status-attention-bg text-status-attention":"bg-status-neutral-bg text-status-neutral"),children:[i.jsx("span",{className:"min-w-0",children:tY(b.total,b.mislukt)}),i.jsx("button",{type:"button",onClick:()=>void b.retry(),className:"-my-2 flex h-11 flex-none items-center px-2 font-medium underline underline-offset-2",children:b.flushing?"Bezig":"Nu proberen"})]}),i.jsx(QG,{open:f,onOpenChange:h,defaultNaam:s??"",onBevestig:je,isBezig:w})]}):i.jsx("div",{className:"rounded-xl border border-border bg-muted/50 p-3",children:i.jsx("p",{className:"text-[13px] leading-[18px] text-muted-foreground",children:"Afronden kan hier niet: deze opdracht hangt niet aan een organisatie. Meld het bij kantoor, zij kunnen dit rechtzetten."})})}function JG(e){return e===0?"Nog geen foto":e===1?"1 foto":`${e} foto’s`}function eY(e){try{const t=new Date(e);return`${he(t,"d MMMM yyyy",{locale:tt})} | ${he(t,"HH:mm")}`}catch{return""}}function tY(e,t){return t===0?e===1?"Wacht op bereik":`${e} dingen wachten op bereik`:t===1?e===1?"Versturen lukt nog niet":`1 van de ${e} lukt nog niet te versturen`:`${t} van de ${e} lukken nog niet te versturen`}function nY(e){var n;const t=(n=e.name.split(".").pop())==null?void 0:n.toLowerCase();return t&&/^[a-z0-9]{1,5}$/.test(t)?t:e.type==="image/png"?"png":"jpg"}const rY={general:"bg-muted text-muted-foreground",problem:"bg-destructive/10 text-destructive",material:"bg-orange-100 text-orange-700 dark:bg-orange-900/20 dark:text-orange-400",status_change:"bg-blue-100 text-blue-700 dark:bg-blue-900/20 dark:text-blue-400"},Oj={general:"Algemeen",problem:"Probleem",material:"Materiaal",status_change:"Status"};function sY({notes:e,onAddNote:t,isAdding:n}){const[r,s]=p.useState(""),[a,o]=p.useState("general"),l=()=>{r.trim()&&(t(r.trim(),a),s(""))},c=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),l())};return i.jsxs(dt,{children:[i.jsx(ln,{className:"pb-3",children:i.jsxs(cn,{className:"text-base font-medium flex items-center gap-2",children:[i.jsx(pT,{className:"h-4 w-4"}),"Opmerkingen"]})}),i.jsxs(bt,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"flex gap-1",children:["general","problem","material"].map(u=>i.jsx(ne,{size:"sm",variant:a===u?"default":"outline",onClick:()=>o(u),className:"text-xs h-7",children:Oj[u]},u))}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Di,{value:r,onChange:u=>s(u.target.value),onKeyDown:c,placeholder:"Schrijf een opmerking...",className:"min-h-[60px] resize-none",disabled:n}),i.jsx(ne,{size:"icon",onClick:l,disabled:!r.trim()||n,className:"shrink-0",children:n?i.jsx(yn,{className:"h-4 w-4 animate-spin"}):i.jsx(X5,{className:"h-4 w-4"})})]})]}),e.length>0?i.jsx("div",{className:"space-y-3 max-h-[300px] overflow-y-auto",children:e.map(u=>{const d=mn(u.created_at),f=he(d,"HH:mm",{locale:tt}),h=he(d,"d MMM",{locale:tt});return i.jsxs("div",{className:Y("p-3 rounded-lg border",u.note_type==="problem"&&"border-destructive/30 bg-destructive/5",u.note_type==="material"&&"border-orange-300/30 bg-orange-50/50 dark:bg-orange-900/10"),children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsxs("span",{className:"text-xs text-muted-foreground",children:[f," - ",h]}),u.staff_name&&i.jsx("span",{className:"text-xs font-medium",children:u.staff_name}),u.note_type!=="general"&&i.jsx(Qe,{variant:"secondary",className:Y("text-xs h-5",rY[u.note_type]),children:Oj[u.note_type]||u.note_type})]}),i.jsx("p",{className:"text-sm",children:u.content})]},u.id)})}):i.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Nog geen opmerkingen"})]})]})}const hy=[{key:"nieuwe_klant",label:"Nieuwe klant",labelShort:"🟢",color:"#22c55e",icon:"user-plus",sort_order:0},{key:"grote_klant",label:"Grote klant",labelShort:"🩷",color:"#ec4899",icon:"building-2",sort_order:1},{key:"service",label:"Service",labelShort:"🔵",color:"#3b82f6",icon:"wrench",sort_order:2},{key:"standaard_klant",label:"Standaard klant",labelShort:"🟡",color:"#eab308",icon:"user",sort_order:3}],aY=e=>{const t=e.toLowerCase();return t.includes("22c55e")||t.includes("16a34a")||t.includes("green")?"🟢":t.includes("ec4899")||t.includes("pink")?"🩷":t.includes("3b82f6")||t.includes("0ea5e9")||t.includes("blue")?"🔵":t.includes("eab308")||t.includes("yellow")?"🟡":t.includes("a855f7")||t.includes("8b5cf6")||t.includes("purple")?"🟣":t.includes("f97316")||t.includes("orange")?"🟠":t.includes("ef4444")||t.includes("red")?"🔴":"⚪"};function MR(e){const t=Ge(),{data:n=[],isLoading:r}=xt({queryKey:["organization-classifications",e],queryFn:async()=>{if(!e)return[];const{data:h,error:m}=await B.from("organization_classifications").select("*").eq("organization_id",e).order("sort_order");if(m)throw m;return h},enabled:!!e,staleTime:5*60*1e3}),s=n.length>0?n.map(h=>({...h,classification_key:h.classification_key,labelShort:aY(h.color),is_system_default:h.is_system_default,is_active:h.is_active})):hy.map(h=>({classification_key:h.key,label:h.label,labelShort:h.labelShort,color:h.color,icon:h.icon,sort_order:h.sort_order,is_system_default:!0,is_active:!0})),a=s.filter(h=>h.is_active),o=Ke({mutationFn:async()=>{if(!e)throw new Error("No organization");const{count:h}=await B.from("organization_classifications").select("*",{count:"exact",head:!0}).eq("organization_id",e);if(h&&h>0)throw new Error("Classifications already initialized");await Je({organizationId:e,scope:"classification-initialize-defaults",key:e,ttlSeconds:30});const{error:m}=await B.from("organization_classifications").insert(hy.map(v=>({organization_id:e,classification_key:v.key,label:v.label,color:v.color,icon:v.icon,sort_order:v.sort_order,is_system_default:!0,is_active:!0})));if(m)throw m},onSuccess:()=>{t.invalidateQueries({queryKey:["organization-classifications",e]}),K.success("Standaard classificaties toegevoegd")},onError:h=>{h.message.includes("already initialized")||K.error("Fout bij initialiseren classificaties")}}),l=Ke({mutationFn:async({label:h,color:m,icon:v})=>{if(!e)throw new Error("No organization");const w=h.toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,""),y=Math.max(...s.map(g=>g.sort_order),-1);await Je({organizationId:e,scope:"classification-add",key:`${w}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const{error:x}=await B.from("organization_classifications").insert({organization_id:e,classification_key:w,label:h.trim(),color:m,icon:v||"tag",sort_order:y+1,is_system_default:!1,is_active:!0});if(x)throw x.code==="23505"?new Error("Deze classificatie bestaat al"):x;return w},onSuccess:()=>{t.invalidateQueries({queryKey:["organization-classifications",e]}),K.success("Classificatie toegevoegd")},onError:h=>{K.error(h.message||"Fout bij toevoegen classificatie")}}),c=Ke({mutationFn:async({id:h,label:m,color:v,icon:w,is_active:y})=>{if(!e)throw new Error("No organization");const x={};m!==void 0&&(x.label=m.trim()),v!==void 0&&(x.color=v),w!==void 0&&(x.icon=w),y!==void 0&&(x.is_active=y),await Je({organizationId:e,scope:"classification-update",key:`${h}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const{error:g}=await B.from("organization_classifications").update(x).eq("id",h).eq("organization_id",e);if(g)throw g},onSuccess:()=>{t.invalidateQueries({queryKey:["organization-classifications",e]}),K.success("Classificatie bijgewerkt")},onError:h=>{h.message.includes("al verwerkt of nog in behandeling")?K.error(h.message):K.error("Fout bij bijwerken classificatie")}}),u=Ke({mutationFn:async h=>{if(!e)throw new Error("No organization");await Je({organizationId:e,scope:"classification-delete",key:h,ttlSeconds:30});const{error:m}=await B.from("organization_classifications").delete().eq("id",h).eq("organization_id",e).eq("is_system_default",!1);if(m)throw m},onSuccess:()=>{t.invalidateQueries({queryKey:["organization-classifications",e]}),K.success("Classificatie verwijderd")},onError:()=>{K.error("Fout bij verwijderen classificatie")}}),d=h=>{if(!h)return;const m=s.find(w=>w.classification_key===h);if(m)return m;const v=hy.find(w=>w.key===h);if(v)return{classification_key:v.key,label:v.label,labelShort:v.labelShort,color:v.color,icon:v.icon,sort_order:v.sort_order,is_system_default:!0,is_active:!0}},f=n.length>0;return{classifications:s,activeClassifications:a,isLoading:r,hasCustomClassifications:f,getClassification:d,initializeDefaults:()=>o.mutate(),addClassification:h=>l.mutate(h),addClassificationAsync:h=>l.mutateAsync(h),updateClassification:h=>c.mutate(h),deleteClassification:h=>u.mutate(h),isInitializing:o.isPending,isAdding:l.isPending,isUpdating:c.isPending,isDeleting:u.isPending}}const oY=e=>({"user-plus":e0,"building-2":_c,wrench:fo,user:vr,tag:Gh})[e]||Gh,bl={nieuwe_klant:{label:"Nieuwe klant",labelShort:"🟢",className:"bg-green-500 text-white hover:bg-green-600",cardClassName:"border-green-300 bg-green-50 dark:border-green-700 dark:bg-green-950/30",icon:i.jsx(e0,{className:"h-4 w-4"})},grote_klant:{label:"Grote klant",labelShort:"🩷",className:"bg-pink-500 text-white hover:bg-pink-600",cardClassName:"border-pink-300 bg-pink-50 dark:border-pink-700 dark:bg-pink-950/30",icon:i.jsx(_c,{className:"h-4 w-4"})},service:{label:"Service",labelShort:"🔵",className:"bg-blue-500 text-white hover:bg-blue-600",cardClassName:"border-blue-300 bg-blue-50 dark:border-blue-700 dark:bg-blue-950/30",icon:i.jsx(fo,{className:"h-4 w-4"})},standaard_klant:{label:"Standaard klant",labelShort:"🟡",className:"bg-yellow-500 text-white hover:bg-yellow-600",cardClassName:"border-yellow-300 bg-yellow-50 dark:border-yellow-700 dark:bg-yellow-950/30",icon:i.jsx(vr,{className:"h-4 w-4"})}},iY={cardClassName:"border-dashed border-muted-foreground/30 bg-background/50 dark:bg-background/20"},lY={"#22c55e":bl.nieuwe_klant.cardClassName,"#ec4899":bl.grote_klant.cardClassName,"#3b82f6":bl.service.cardClassName,"#eab308":bl.standaard_klant.cardClassName,"#a855f7":"border-purple-300 bg-purple-50 dark:border-purple-700 dark:bg-purple-950/30","#f97316":"border-orange-300 bg-orange-50 dark:border-orange-700 dark:bg-orange-950/30","#ef4444":"border-red-300 bg-red-50 dark:border-red-700 dark:bg-red-950/30","#6b7280":"border-gray-300 bg-gray-50 dark:border-gray-700 dark:bg-gray-800/50"},cY="20",uY="8c";function zse(e){if(!e)return{className:iY.cardClassName};const t=lY[e.toLowerCase()];return t?{className:t}:{className:"",style:{backgroundColor:`${e}${cY}`},accentBorderColor:`${e}${uY}`}}function dY({classification:e,showIcon:t=!1,showEmoji:n=!0,size:r="default",organizationId:s}){const{organization:a}=zt(),o=s||(a==null?void 0:a.id),{getClassification:l}=MR(o),c=l(e);let u,d,f,h=Gh;if(c)u=c.label,d=c.labelShort||"⚪",f=c.color,h=oY(c.icon);else{const m=bl[e]||bl.standaard_klant;u=m.label,d=m.labelShort,e==="nieuwe_klant"?f="#22c55e":e==="grote_klant"?f="#ec4899":e==="service"?f="#3b82f6":f="#eab308",h=vr}return i.jsxs(Qe,{className:`text-white ${r==="sm"?"text-[10px] px-1.5 py-0 h-4":"text-xs"}`,style:{backgroundColor:f},children:[t&&i.jsx(h,{className:"h-3 w-3 mr-1"}),n&&i.jsx("span",{className:"mr-1",children:d}),u]})}const Mj={implementatie:{label:"Implementatie",description:"Nieuwe installatie",className:"bg-muted text-muted-foreground",icon:null},service:{label:"Service",description:"Onderhoud en reparatie",className:"bg-teal-100 text-teal-700 dark:bg-teal-900/30 dark:text-teal-300",icon:i.jsx(fo,{className:"h-3 w-3"})},batterij:{label:"Batterij",description:"Batterij installatie",className:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",icon:i.jsx(k5,{className:"h-3 w-3"})},panelen_verwijderen:{label:"Panelen verwijderen",description:"Demontage zonnepanelen",className:"bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300",icon:i.jsx(Jw,{className:"h-3 w-3"})},installatie:{label:"Installatie",description:"Nieuwe installatie",className:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300",icon:i.jsx(Ju,{className:"h-3 w-3"})},reparatie:{label:"Reparatie",description:"Reparatiewerkzaamheden",className:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300",icon:i.jsx(fo,{className:"h-3 w-3"})},onderhoud:{label:"Onderhoud",description:"Onderhoudswerkzaamheden",className:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300",icon:i.jsx(fo,{className:"h-3 w-3"})},nieuwbouw:{label:"Nieuwbouw",description:"Nieuwbouwproject",className:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300",icon:i.jsx(qm,{className:"h-3 w-3"})},intern:{label:"Interne opdracht",description:"Eigen werk, zonder opdrachtgever",className:"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-300",icon:i.jsx(Nd,{className:"h-3 w-3"})}};function fY(e){const t=["bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300","bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300","bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300","bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-300","bg-indigo-100 text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-300","bg-cyan-100 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300","bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-300","bg-rose-100 text-rose-700 dark:bg-rose-900/30 dark:text-rose-300"];let n=0;for(let r=0;rr.toString(16).padStart(2,"0")).join("")}async function hY(e){const{data:t,error:n}=await B.from("organization_settings").select("*").eq("organization_id",e);if(n)throw n;return t||[]}function Hd(e){const{toast:t}=Ww(),n=Ge(),{data:r=[],isLoading:s,refetch:a}=xt({queryKey:["organization-settings",e],queryFn:()=>hY(e),enabled:!!e,staleTime:30*1e3,gcTime:30*60*1e3}),o=p.useCallback(f=>{const h=r.find(v=>v.setting_key===f);if(h)return h.setting_value;const m=Cp.find(v=>v.key===f);return(m==null?void 0:m.defaultValue)??null},[r]),l=Ke({mutationFn:async({settingKey:f,value:h})=>{var y;if(!e)throw new Error("No organization ID");await Je({organizationId:e,scope:"setting-upsert",key:`${f}:${await Ij(h)}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const{data:m}=await B.auth.getUser(),v=(y=m.user)==null?void 0:y.id,{error:w}=await B.from("organization_settings").upsert({organization_id:e,setting_key:f,setting_value:h,updated_by:v},{onConflict:"organization_id,setting_key"});if(w)throw w},onSuccess:(f,h)=>{n.invalidateQueries({queryKey:["organization-settings",e]}),h.silent||t({title:"Opgeslagen",description:"Instelling is bijgewerkt"})},onError:(f,h)=>{console.error("Error updating setting:",f),!(h!=null&&h.silentError)&&t({title:"Fout",description:"Kon instelling niet opslaan",variant:"destructive"})}}),c=Ke({mutationFn:async f=>{var x;if(!e)throw new Error("No organization ID");const h=await Ij(f.map(g=>[g.key,g.value]).sort(([g],[b])=>String(g).localeCompare(String(b))));await Je({organizationId:e,scope:"settings-batch-upsert",key:`${f.map(g=>g.key).sort().join(",")}:${h}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const{data:m}=await B.auth.getUser(),v=(x=m.user)==null?void 0:x.id,w=f.map(g=>({organization_id:e,setting_key:g.key,setting_value:g.value,updated_by:v})),{error:y}=await B.from("organization_settings").upsert(w,{onConflict:"organization_id,setting_key"});if(y)throw y},onSuccess:()=>{n.invalidateQueries({queryKey:["organization-settings",e]}),t({title:"Opgeslagen",description:"Instellingen zijn bijgewerkt"})},onError:f=>{console.error("Error updating settings:",f),t({title:"Fout",description:"Kon instellingen niet opslaan",variant:"destructive"})}}),u=p.useCallback(async(f,h,m)=>l.mutateAsync({settingKey:f,value:h,silent:m==null?void 0:m.silent,silentError:m==null?void 0:m.silentError}),[l]),d=p.useCallback(async f=>c.mutateAsync(f),[c]);return{settings:r,loading:s,getSetting:o,updateSetting:u,updateMultipleSettings:d,refetch:a}}const mY="project_detail_sections",wb=[{key:"details",label:"Details",description:"Klant, planning, team, voertuig, labels en omschrijving"},{key:"checklist",label:"Checklist",description:"De afvinklijst op de detailkaart, de opdrachtbrief en in de monteursapp"},{key:"materials",label:"Materialen",description:"Materiaallijst bij de opdracht"},{key:"offerteregels",label:"Offerteregels",description:"De regels uit de offerte"},{key:"documents",label:"Documenten",description:"Bijlagen en documenten bij de opdracht"},{key:"notes",label:"Notities",description:"Werknotities bij de opdracht"},{key:"afronden",label:"Afronden",description:"Foto's en handtekening onder de checklist, waarmee de monteur de opdracht sluit",staffOnly:!0}],pY=new Set(wb.map(e=>e.key)),DR=new Set(["afronden"]);function bb(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e)typeof n=="string"&&pY.has(n)&&t.add(n);return wb.map(n=>n.key).filter(n=>t.has(n))}function gY(e,t){const n=bb(e);return n.length===0?!DR.has(t):n.includes(t)}function yY(e){const t=bb(e);return t.length===0?wb.map(n=>n.key).filter(n=>!DR.has(n)):t}function Use(e,t){return e.some(n=>n===t)?t:e[0]??t}function _b(e){const{getSetting:t,loading:n}=Hd(e??void 0),r=t(mY),s=p.useMemo(()=>bb(r),[r]),a=p.useMemo(()=>yY(s),[s]),o=p.useCallback(l=>gY(s,l),[s]);return{sections:s,visible:a,isVisible:o,loading:n}}function IR({message:e,onRetry:t}){return i.jsxs("div",{role:"alert",className:"rounded-xl border border-amber-200 bg-amber-50 p-4 text-center",children:[i.jsx(Vr,{className:"mx-auto mb-2 h-7 w-7 text-amber-700","aria-hidden":"true"}),i.jsx("p",{className:"text-sm text-amber-900",children:e}),i.jsx(ne,{variant:"outline",size:"sm",className:"mt-3",onClick:t,children:"Opnieuw proberen"})]})}const vY={ochtend:"Ochtend (08:00 - 12:00)",middag:"Middag (12:00 - 17:00)",hele_dag:"Hele dag",morning:"Ochtend (08:00 - 12:00)",afternoon:"Middag (12:00 - 17:00)",full_day:"Hele dag"},xY=e=>e&&vY[e]||"Hele dag";function wY({project:e,userId:t,isOpen:n,onClose:r}){const{data:s,isLoading:a,isError:o,refetch:l}=SR(e==null?void 0:e.id),{data:c}=xp(t,(e==null?void 0:e.organization_id)??void 0),{isVisible:u,loading:d}=_b(e==null?void 0:e.organization_id),f=EG(),h=ER(),m=CG(),v=TG();if(!e)return null;const w=mn(e.scheduled_date),y=he(w,"EEEE d MMMM yyyy",{locale:tt}),g=[Id(e.start_time,e.planned_hours),xY(e.day_part)].filter(Boolean).join(" | "),b=S=>{f.mutate({projectId:e.id,status:S})},_=(S,E)=>{h.mutate({itemId:S,isCompleted:E,staffId:c||null,organizationId:e.organization_id})},j=(S,E)=>{m.mutate({projectId:e.id,staffId:c||null,content:S,noteType:E,organizationId:e.organization_id,isPrivate:!0})},k=(S,E)=>{v.mutate({projectId:e.id,staffId:c||null,file:S,photoType:E,organizationId:e.organization_id})};return i.jsx(Mc,{open:n,onOpenChange:S=>!S&&r(),children:i.jsxs(Oi,{className:"max-w-lg h-[100dvh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[i.jsx(Mi,{className:"sr-only",children:"Opdracht details"}),i.jsxs("div",{className:"flex items-center gap-3 p-4 border-b shrink-0 bg-background z-10",children:[i.jsx(ne,{variant:"ghost",size:"icon",onClick:r,children:i.jsx(Yw,{className:"h-5 w-5"})}),i.jsx("h2",{className:"font-semibold text-lg flex-1",children:"Opdracht Details"})]}),i.jsx(vR,{className:"flex-1 min-h-0",children:i.jsxs("div",{className:"p-4 space-y-4",children:[o&&i.jsx(IR,{message:"De gegevens van deze opdracht konden niet geladen worden. Checklist, notities en foto's zijn daarom niet zichtbaar.",onRetry:()=>l()}),i.jsx(PG,{currentStatus:e.status||"planned",onStatusChange:b,isLoading:f.isPending,hideCompleted:u("afronden")}),i.jsx(_R,{}),i.jsx(AG,{name:e.customer_name,phone:e.customer_phone,email:e.customer_email,address:e.customer_address}),i.jsxs(dt,{children:[i.jsx(ln,{className:"pb-3",children:i.jsx(cn,{className:"text-base font-medium",children:"Opdracht"})}),i.jsxs(bt,{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.priority&&e.priority!=="normal"&&i.jsx(xb,{priority:e.priority,size:"sm"}),e.customer_classification&&i.jsx(dY,{classification:e.customer_classification}),e.project_type&&i.jsx(vb,{type:e.project_type})]}),e.extra_labels&&e.extra_labels.length>0&&i.jsx("div",{className:"flex flex-wrap gap-1",children:e.extra_labels.map(S=>i.jsx(Qe,{variant:"secondary",className:"text-xs",children:S},S))}),i.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i.jsx(Wt,{className:"h-4 w-4"}),i.jsx("span",{className:"capitalize",children:y})]}),i.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i.jsx(To,{className:"h-4 w-4"}),i.jsx("span",{children:g})]}),e.notes&&i.jsxs("div",{className:"mt-3 p-3 bg-muted rounded-lg",children:[i.jsx("p",{className:"text-sm font-medium mb-1",children:"Notities:"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:e.notes})]})]})]}),e.team_members.length>0&&i.jsxs(dt,{children:[i.jsx(ln,{className:"pb-3",children:i.jsxs(cn,{className:"text-base font-medium flex items-center gap-2",children:[i.jsx(Wr,{className:"h-4 w-4"}),"Team"]})}),i.jsx(bt,{children:i.jsx("div",{className:"space-y-2",children:e.team_members.map(S=>i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Md,{className:"h-8 w-8",children:i.jsx(Dd,{className:"text-xs",children:S.name.split(" ").map(E=>E[0]).join("").toUpperCase()})}),i.jsx("div",{className:"flex-1",children:i.jsx("p",{className:"text-sm font-medium",children:S.name})}),S.level&&i.jsx(Qe,{variant:"outline",className:"text-xs capitalize",children:S.level})]},S.id))})})]}),s&&!d&&u("checklist")&&i.jsx(NR,{items:s.checklist,onToggle:_,isLoading:h.isPending,activeClassificationKey:e.entry_classification??e.customer_classification??null,organizationId:e.organization_id}),s&&!d&&u("afronden")&&i.jsxs(dt,{children:[i.jsx(ln,{className:"pb-3",children:i.jsxs(cn,{className:"text-base font-medium flex items-center gap-2",children:[i.jsx(cT,{className:"h-4 w-4",strokeWidth:1.5}),"Afronden"]})}),i.jsx(bt,{children:i.jsx(OR,{projectId:e.id,organizationId:e.organization_id,staffId:c||null,projectStatus:e.status,customerName:e.customer_name,projectCustomFields:e.custom_fields,checklistItems:u("checklist")?s.checklist.filter(S=>gb(S.classification_key,e.entry_classification??e.customer_classification??null)):[],photos:s.photos,gegevensGeladen:!a})})]}),s&&i.jsx(MG,{photos:s.photos,onUpload:k,isUploading:v.isPending}),s&&!d&&u("notes")&&i.jsx(sY,{notes:s.notes,onAddNote:j,isAdding:m.isPending})]})})]})})}function bY(e){return xt({queryKey:["project-materials",e],queryFn:async()=>{const{data:t,error:n}=await B.from("project_materials").select(` *, product:product_id (id, name, sku, quantity_in_stock, unit, category) `).eq("project_id",e);if(n)throw n;return t||[]},enabled:!!e})}function Vse(){const e=Ge();return Ke({mutationFn:async({projectId:t,productId:n,organizationId:r,quantity:s,usageType:a})=>{const{error:o}=await B.from("project_materials").insert({project_id:t,product_id:n,organization_id:r,quantity:s,usage_type:a});if(o)throw o},onSuccess:()=>{e.invalidateQueries({queryKey:["project-materials"]}),K.success("Materiaal toegevoegd")},onError:t=>{console.error("Error adding material:",t),K.error("Kon materiaal niet toevoegen")}})}function Wse(){const e=Ge();return Ke({mutationFn:async t=>{const{error:n}=await B.from("project_materials").delete().eq("id",t);if(n)throw n},onSuccess:()=>{e.invalidateQueries({queryKey:["project-materials"]}),K.success("Materiaal verwijderd")},onError:t=>{console.error("Error removing material:",t),K.error("Kon materiaal niet verwijderen")}})}function Hse(){const e=Ge();return Ke({mutationFn:async({materialId:t,updates:n})=>{const{error:r}=await B.from("project_materials").update({...n,updated_at:new Date().toISOString()}).eq("id",t);if(r)throw r},onSuccess:()=>{e.invalidateQueries({queryKey:["project-materials"]})},onError:t=>{console.error("Error updating material:",t),K.error("Kon materiaal niet bijwerken")}})}function qse(){const e=Ge();return Ke({mutationFn:async({materialId:t,productId:n,organizationId:r,oldQuantity:s,newQuantity:a})=>{const o=a-s;if(o===0)return;const{error:l}=await B.from("project_materials").update({quantity:a,updated_at:new Date().toISOString()}).eq("id",t);if(l)throw l;const{error:c}=await B.from("stock_movements").insert({organization_id:r,product_id:n,quantity:-o,movement_type:o>0?"project_reservation":"project_reservation_release",reference_type:"project_material",reference_id:t,notes:o>0?`${o} gereserveerd voor project`:`${Math.abs(o)} vrijgegeven van project`});if(c)throw c;const{data:u}=await B.from("products").select("quantity_in_stock").eq("id",n).single();u&&await B.from("products").update({quantity_in_stock:(u.quantity_in_stock||0)-o,updated_at:new Date().toISOString()}).eq("id",n)},onSuccess:()=>{e.invalidateQueries({queryKey:["project-materials"]}),e.invalidateQueries({queryKey:["products"]}),e.invalidateQueries({queryKey:["default-materials"]}),K.success("Hoeveelheid en voorraad bijgewerkt")},onError:t=>{console.error("Error saving material quantity:",t),K.error("Kon hoeveelheid niet opslaan")}})}function Kse(){const e=Ge();return Ke({mutationFn:async({materialId:t,isPicked:n,productId:r,quantity:s,usageType:a,organizationId:o})=>{const{error:l}=await B.from("project_materials").update({is_picked:n,picked_at:n?new Date().toISOString():null,updated_at:new Date().toISOString()}).eq("id",t);if(l)throw l;if(a==="consumable"){const{error:c}=await B.from("stock_movements").insert({organization_id:o,product_id:r,quantity:n?-s:s,movement_type:n?"project_pickup":"project_pickup_reversal",reference_type:"project_material",reference_id:t,notes:n?"Materiaal opgepakt voor project":"Materiaal teruggedraaid"});if(c)throw c;const{data:u}=await B.from("products").select("quantity_in_stock").eq("id",r).single();if(u){const d=(u.quantity_in_stock||0)+(n?-s:s);await B.from("products").update({quantity_in_stock:d,updated_at:new Date().toISOString()}).eq("id",r)}}if(a==="reusable"&&n){const{error:c}=await B.from("stock_movements").insert({organization_id:o,product_id:r,quantity:-s,movement_type:"project_reservation",reference_type:"project_material",reference_id:t,notes:"Materiaal gereserveerd voor project"});if(c)throw c;const{data:u}=await B.from("products").select("quantity_in_stock").eq("id",r).single();u&&await B.from("products").update({quantity_in_stock:(u.quantity_in_stock||0)-s,updated_at:new Date().toISOString()}).eq("id",r)}},onSuccess:()=>{e.invalidateQueries({queryKey:["project-materials"]}),e.invalidateQueries({queryKey:["products"]}),K.success("Materiaalstatus bijgewerkt")},onError:t=>{console.error("Error picking material:",t),K.error("Kon materiaalstatus niet bijwerken")}})}function Gse(){const e=Ge();return Ke({mutationFn:async({materialId:t,productId:n,quantity:r,organizationId:s})=>{const{error:a}=await B.from("project_materials").update({is_returned:!0,returned_at:new Date().toISOString(),updated_at:new Date().toISOString()}).eq("id",t);if(a)throw a;const{error:o}=await B.from("stock_movements").insert({organization_id:s,product_id:n,quantity:r,movement_type:"project_return",reference_type:"project_material",reference_id:t,notes:"Materiaal teruggebracht van project"});if(o)throw o;const{data:l}=await B.from("products").select("quantity_in_stock").eq("id",n).single();l&&await B.from("products").update({quantity_in_stock:(l.quantity_in_stock||0)+r,updated_at:new Date().toISOString()}).eq("id",n)},onSuccess:()=>{e.invalidateQueries({queryKey:["project-materials"]}),e.invalidateQueries({queryKey:["products"]}),K.success("Materiaal teruggebracht")},onError:t=>{console.error("Error returning material:",t),K.error("Kon terugboeking niet verwerken")}})}const my="Geen rechten om dit document aan te passen.";function _Y(e){return xt({queryKey:["project-documents",e],queryFn:async()=>{if(!e)return[];const{data:t,error:n}=await B.from("project_documents").select("id, project_id, organization_id, document_type, file_name, file_url, uploaded_by, uploaded_at, gripp_file_id, include_in_planner_print, filename, original_name, file_type, storage_path, visible_to_monteur").eq("project_id",e).order("uploaded_at",{ascending:!1});if(n)throw n;return t},enabled:!!e})}function Yse(){const e=Ge();return Ke({mutationFn:async({projectId:t,organizationId:n,file:r,documentType:s,uploadedBy:a})=>{const o=Ad(r,"projectDocument");if(o.valid===!1)throw new Error(o.error);if(!n)throw new Error("Geen organisatiecontext gevonden voor document upload.");const l=`project-document:${t}:${r.name}:${r.size}`;return pb(l,async()=>{await Je({organizationId:n,scope:"project-document-upload",key:l});const c=r.name.split(".").pop(),u=`${n}/${t}/${s}/${Date.now()}.${c}`,{error:d}=await B.storage.from("project-documents").upload(u,r);if(d)throw d;const{data:f,error:h}=await B.from("project_documents").insert({project_id:t,organization_id:n,document_type:s,file_name:r.name,file_url:"",storage_path:u,uploaded_by:a}).select().single();if(h)throw h;return f})},onSuccess:()=>{e.invalidateQueries({queryKey:["project-documents"]}),K.success("Document geüpload")},onError:t=>{console.error("Error uploading document:",t),K.error("Kon document niet uploaden")}})}function Qse(){const e=Ge();return Ke({mutationFn:async t=>{const{error:n}=await B.from("project_documents").delete().eq("id",t);if(n)throw n},onSuccess:()=>{e.invalidateQueries({queryKey:["project-documents"]}),K.success("Document verwijderd")},onError:t=>{console.error("Error deleting document:",t),K.error("Kon document niet verwijderen")}})}async function kY(e,t=!1){const{data:n,error:r}=await B.functions.invoke("download-gripp-file",{body:{projectDocumentId:e,forceDownload:t}});if(r)throw new Error(r.message||"Kon document niet openen.");const s=n;if(!(s!=null&&s.url))throw new Error("Downloadlink ontbreekt in antwoord.");return s}function jY(){return Ke({mutationFn:async e=>{const t=typeof e=="string"?{projectDocumentId:e}:e;return kY(t.projectDocumentId,t.forceDownload??!1)},onError:e=>{console.error("Error downloading project document:",e),K.error(e instanceof Error?e.message:"Kon document niet openen")}})}function Xse(){const e=Ge();return Ke({mutationFn:async({documentId:t,organizationId:n,visible:r})=>{await Je({organizationId:n,scope:"project-document-visibility",key:`${t}:${r}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const{data:s,error:a}=await B.from("project_documents").update({visible_to_monteur:r}).eq("id",t).select("id");if(a)throw a;if(!s||s.length===0)throw new Error(my)},onSuccess:()=>{e.invalidateQueries({queryKey:["project-documents"]})},onError:t=>{const n=t instanceof Error&&t.message===my;n||console.error("Toggle document visibility failed",t),K.error(n?my:"Kon zichtbaarheid niet wijzigen")}})}function Zse(){const e=Ge();return Ke({mutationFn:async({documentId:t,organizationId:n,include:r})=>{await Je({organizationId:n,scope:"project-document-planner-print",key:`${t}:${r}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const{error:s}=await B.rpc("toggle_project_document_planner_print",{_document_id:t,_include:r});if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["project-documents"]})},onError:()=>{K.error("Kon printselectie niet wijzigen")}})}function SY(e){return xt({queryKey:["project-lines",e],queryFn:async()=>{if(!e)return[];const{data:t,error:n}=await B.from("project_lines").select("id, project_id, organization_id, gripp_line_id, gripp_product_id, gripp_product_number, gripp_ledger_id, gripp_ledger_group, gripp_ledger_subgroup, description, subject, product_name, quantity, unit_name, selling_price, buying_price, line_hash, line_type, internal_note, sort_order, created_at").eq("project_id",e).order("sort_order",{ascending:!0}).limit(500);if(n)throw n;return t},enabled:!!e})}/*! @license DOMPurify 3.4.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.3/LICENSE */function Lj(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n2?r-2:0),a=2;a1?n-1:0),s=1;s"u"?null:un(BigInt.prototype.toString),Vj=typeof Symbol>"u"?null:un(Symbol.prototype.toString),Bt=un(Object.prototype.hasOwnProperty),Jc=un(Object.prototype.toString),Sn=un(RegExp.prototype.test),Wf=FY(TypeError);function un(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s2&&arguments[2]!==void 0?arguments[2]:fu;if($j&&$j(e,null),!zn(t))return e;let r=t.length;for(;r--;){let s=t[r];if(typeof s=="string"){const a=n(s);a!==s&&(AY(t)||(t[r]=a),s=a)}e[s]=!0}return e}function zY(e){for(let t=0;t/g),KY=Kr(/\${[\w\W]*/g),GY=Kr(/^data-[\-\w.\u00B7-\uFFFF]+$/),YY=Kr(/^aria-[\-\w]+$/),Gj=Kr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),QY=Kr(/^(?:\w+script|data):/i),XY=Kr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ZY=Kr(/^html$/i),JY=Kr(/^[a-z][.\w]*(-[.\w]+)+$/i),Ji={element:1,text:3,progressingInstruction:7,comment:8,document:9},eQ=function(){return typeof window>"u"?null:window},tQ=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Yj=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function FR(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:eQ();const t=Ae=>FR(Ae);if(t.version="3.4.3",t.removed=[],!e||!e.document||e.document.nodeType!==Ji.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,s=r.currentScript,a=e.DocumentFragment,o=e.HTMLTemplateElement,l=e.Node,c=e.Element,u=e.NodeFilter,d=e.NamedNodeMap,f=d===void 0?e.NamedNodeMap||e.MozNamedAttrMap:d,h=e.HTMLFormElement,m=e.DOMParser,v=e.trustedTypes,w=c.prototype,y=al(w,"cloneNode"),x=al(w,"remove"),g=al(w,"nextSibling"),b=al(w,"childNodes"),_=al(w,"parentNode");if(typeof o=="function"){const Ae=n.createElement("template");Ae.content&&Ae.content.ownerDocument&&(n=Ae.content.ownerDocument)}let j,k="";const S=n,E=S.implementation,N=S.createNodeIterator,O=S.createDocumentFragment,z=S.getElementsByTagName,T=r.importNode;let I=Yj();t.isSupported=typeof LR=="function"&&typeof _=="function"&&E&&E.createHTMLDocument!==void 0;const P=HY,H=qY,V=KY,M=GY,C=YY,F=QY,W=XY,ie=JY;let oe=Gj,ce=null;const re=We({},[...Wj,...gy,...yy,...vy,...Hj]);let ue=null;const ke=We({},[...qj,...xy,...Kj,...Hf]);let L=Object.seal(sl(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Q=null,fe=null;const ee=Object.seal(sl(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let je=!0,Ee=!0,te=!1,_e=!0,Me=!1,Ue=!0,ct=!1,Rt=!1,Et=!1,A=!1,$=!1,q=!1,de=!0,G=!1;const U="user-content-";let Z=!0,pe=!1,Be={},at=null;const vn=We({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Jt=null;const $n=We({},["audio","video","img","source","image","track"]);let er=null;const jn=We({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Js="http://www.w3.org/1998/Math/MathML",tr="http://www.w3.org/2000/svg",nr="http://www.w3.org/1999/xhtml";let Qr=nr,Ii=!1,Li=null;const Hp=We({},[Js,tr,nr],py);let Do=We({},["mi","mo","mn","ms","mtext"]),Mr=We({},["annotation-xml"]);const qp=We({},["title","style","font","a","script"]);let Oe=null;const ht=["application/xhtml+xml","text/html"],_t="text/html";let ut=null,xn=null;const ks=n.createElement("form"),js=function(R){return R instanceof RegExp||R instanceof Function},Fn=function(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(xn&&xn===R)return;(!R||typeof R!="object")&&(R={}),R=sr(R),Oe=ht.indexOf(R.PARSER_MEDIA_TYPE)===-1?_t:R.PARSER_MEDIA_TYPE,ut=Oe==="application/xhtml+xml"?py:fu,ce=Bt(R,"ALLOWED_TAGS")&&zn(R.ALLOWED_TAGS)?We({},R.ALLOWED_TAGS,ut):re,ue=Bt(R,"ALLOWED_ATTR")&&zn(R.ALLOWED_ATTR)?We({},R.ALLOWED_ATTR,ut):ke,Li=Bt(R,"ALLOWED_NAMESPACES")&&zn(R.ALLOWED_NAMESPACES)?We({},R.ALLOWED_NAMESPACES,py):Hp,er=Bt(R,"ADD_URI_SAFE_ATTR")&&zn(R.ADD_URI_SAFE_ATTR)?We(sr(jn),R.ADD_URI_SAFE_ATTR,ut):jn,Jt=Bt(R,"ADD_DATA_URI_TAGS")&&zn(R.ADD_DATA_URI_TAGS)?We(sr($n),R.ADD_DATA_URI_TAGS,ut):$n,at=Bt(R,"FORBID_CONTENTS")&&zn(R.FORBID_CONTENTS)?We({},R.FORBID_CONTENTS,ut):vn,Q=Bt(R,"FORBID_TAGS")&&zn(R.FORBID_TAGS)?We({},R.FORBID_TAGS,ut):sr({}),fe=Bt(R,"FORBID_ATTR")&&zn(R.FORBID_ATTR)?We({},R.FORBID_ATTR,ut):sr({}),Be=Bt(R,"USE_PROFILES")?R.USE_PROFILES&&typeof R.USE_PROFILES=="object"?sr(R.USE_PROFILES):R.USE_PROFILES:!1,je=R.ALLOW_ARIA_ATTR!==!1,Ee=R.ALLOW_DATA_ATTR!==!1,te=R.ALLOW_UNKNOWN_PROTOCOLS||!1,_e=R.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Me=R.SAFE_FOR_TEMPLATES||!1,Ue=R.SAFE_FOR_XML!==!1,ct=R.WHOLE_DOCUMENT||!1,A=R.RETURN_DOM||!1,$=R.RETURN_DOM_FRAGMENT||!1,q=R.RETURN_TRUSTED_TYPE||!1,Et=R.FORCE_BODY||!1,de=R.SANITIZE_DOM!==!1,G=R.SANITIZE_NAMED_PROPS||!1,Z=R.KEEP_CONTENT!==!1,pe=R.IN_PLACE||!1,oe=UY(R.ALLOWED_URI_REGEXP)?R.ALLOWED_URI_REGEXP:Gj,Qr=typeof R.NAMESPACE=="string"?R.NAMESPACE:nr,Do=Bt(R,"MATHML_TEXT_INTEGRATION_POINTS")&&R.MATHML_TEXT_INTEGRATION_POINTS&&typeof R.MATHML_TEXT_INTEGRATION_POINTS=="object"?sr(R.MATHML_TEXT_INTEGRATION_POINTS):We({},["mi","mo","mn","ms","mtext"]),Mr=Bt(R,"HTML_INTEGRATION_POINTS")&&R.HTML_INTEGRATION_POINTS&&typeof R.HTML_INTEGRATION_POINTS=="object"?sr(R.HTML_INTEGRATION_POINTS):We({},["annotation-xml"]);const J=Bt(R,"CUSTOM_ELEMENT_HANDLING")&&R.CUSTOM_ELEMENT_HANDLING&&typeof R.CUSTOM_ELEMENT_HANDLING=="object"?sr(R.CUSTOM_ELEMENT_HANDLING):sl(null);if(L=sl(null),Bt(J,"tagNameCheck")&&js(J.tagNameCheck)&&(L.tagNameCheck=J.tagNameCheck),Bt(J,"attributeNameCheck")&&js(J.attributeNameCheck)&&(L.attributeNameCheck=J.attributeNameCheck),Bt(J,"allowCustomizedBuiltInElements")&&typeof J.allowCustomizedBuiltInElements=="boolean"&&(L.allowCustomizedBuiltInElements=J.allowCustomizedBuiltInElements),Me&&(Ee=!1),$&&(A=!0),Be&&(ce=We({},Hj),ue=sl(null),Be.html===!0&&(We(ce,Wj),We(ue,qj)),Be.svg===!0&&(We(ce,gy),We(ue,xy),We(ue,Hf)),Be.svgFilters===!0&&(We(ce,yy),We(ue,xy),We(ue,Hf)),Be.mathMl===!0&&(We(ce,vy),We(ue,Kj),We(ue,Hf))),ee.tagCheck=null,ee.attributeCheck=null,Bt(R,"ADD_TAGS")&&(typeof R.ADD_TAGS=="function"?ee.tagCheck=R.ADD_TAGS:zn(R.ADD_TAGS)&&(ce===re&&(ce=sr(ce)),We(ce,R.ADD_TAGS,ut))),Bt(R,"ADD_ATTR")&&(typeof R.ADD_ATTR=="function"?ee.attributeCheck=R.ADD_ATTR:zn(R.ADD_ATTR)&&(ue===ke&&(ue=sr(ue)),We(ue,R.ADD_ATTR,ut))),Bt(R,"ADD_URI_SAFE_ATTR")&&zn(R.ADD_URI_SAFE_ATTR)&&We(er,R.ADD_URI_SAFE_ATTR,ut),Bt(R,"FORBID_CONTENTS")&&zn(R.FORBID_CONTENTS)&&(at===vn&&(at=sr(at)),We(at,R.FORBID_CONTENTS,ut)),Bt(R,"ADD_FORBID_CONTENTS")&&zn(R.ADD_FORBID_CONTENTS)&&(at===vn&&(at=sr(at)),We(at,R.ADD_FORBID_CONTENTS,ut)),Z&&(ce["#text"]=!0),ct&&We(ce,["html","head","body"]),ce.table&&(We(ce,["tbody"]),delete Q.tbody),R.TRUSTED_TYPES_POLICY){if(typeof R.TRUSTED_TYPES_POLICY.createHTML!="function")throw Wf('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof R.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Wf('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');j=R.TRUSTED_TYPES_POLICY,k=j.createHTML("")}else j===void 0&&(j=tQ(v,s)),j!==null&&typeof k=="string"&&(k=j.createHTML(""));Qn&&Qn(R),xn=R},Xr=We({},[...gy,...yy,...VY]),l_=We({},[...vy,...WY]),oI=function(R){let J=_(R);(!J||!J.tagName)&&(J={namespaceURI:Qr,tagName:"template"});const we=fu(R.tagName),nt=fu(J.tagName);return Li[R.namespaceURI]?R.namespaceURI===tr?J.namespaceURI===nr?we==="svg":J.namespaceURI===Js?we==="svg"&&(nt==="annotation-xml"||Do[nt]):!!Xr[we]:R.namespaceURI===Js?J.namespaceURI===nr?we==="math":J.namespaceURI===tr?we==="math"&&Mr[nt]:!!l_[we]:R.namespaceURI===nr?J.namespaceURI===tr&&!Mr[nt]||J.namespaceURI===Js&&!Do[nt]?!1:!l_[we]&&(qp[we]||!Xr[we]):!!(Oe==="application/xhtml+xml"&&Li[R.namespaceURI]):!1},Zr=function(R){Xi(t.removed,{element:R});try{_(R).removeChild(R)}catch{x(R)}},Io=function(R,J){try{Xi(t.removed,{attribute:J.getAttributeNode(R),from:J})}catch{Xi(t.removed,{attribute:null,from:J})}if(J.removeAttribute(R),R==="is")if(A||$)try{Zr(J)}catch{}else try{J.setAttribute(R,"")}catch{}},c_=function(R){let J=null,we=null;if(Et)R=""+R;else{const en=zj(R,/^[\r\n\t ]+/);we=en&&en[0]}Oe==="application/xhtml+xml"&&Qr===nr&&(R=''+R+"");const nt=j?j.createHTML(R):R;if(Qr===nr)try{J=new m().parseFromString(nt,Oe)}catch{}if(!J||!J.documentElement){J=E.createDocument(Qr,"template",null);try{J.documentElement.innerHTML=Ii?k:nt}catch{}}const wn=J.body||J.documentElement;return R&&we&&wn.insertBefore(n.createTextNode(we),wn.childNodes[0]||null),Qr===nr?z.call(J,ct?"html":"body")[0]:ct?J.documentElement:wn},u_=function(R){return N.call(R.ownerDocument||R,R,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Kp=function(R){return R instanceof h&&(typeof R.nodeName!="string"||typeof R.textContent!="string"||typeof R.removeChild!="function"||!(R.attributes instanceof f)||typeof R.removeAttribute!="function"||typeof R.setAttribute!="function"||typeof R.namespaceURI!="string"||typeof R.insertBefore!="function"||typeof R.hasChildNodes!="function")},Gp=function(R){return typeof l=="function"&&R instanceof l};function ea(Ae,R,J){Qi(Ae,we=>{we.call(t,R,J,xn)})}const d_=function(R){let J=null;if(ea(I.beforeSanitizeElements,R,null),Kp(R))return Zr(R),!0;const we=ut(R.nodeName);if(ea(I.uponSanitizeElement,R,{tagName:we,allowedTags:ce}),Ue&&R.hasChildNodes()&&!Gp(R.firstElementChild)&&Sn(/<[/\w!]/g,R.innerHTML)&&Sn(/<[/\w!]/g,R.textContent)||Ue&&R.namespaceURI===nr&&we==="style"&&Gp(R.firstElementChild)||R.nodeType===Ji.progressingInstruction||Ue&&R.nodeType===Ji.comment&&Sn(/<[/\w]/g,R.data))return Zr(R),!0;if(Q[we]||!(ee.tagCheck instanceof Function&&ee.tagCheck(we))&&!ce[we]){if(!Q[we]&&h_(we)&&(L.tagNameCheck instanceof RegExp&&Sn(L.tagNameCheck,we)||L.tagNameCheck instanceof Function&&L.tagNameCheck(we)))return!1;if(Z&&!at[we]){const nt=_(R)||R.parentNode,wn=b(R)||R.childNodes;if(wn&&nt){const en=wn.length;for(let rr=en-1;rr>=0;--rr){const Dr=y(wn[rr],!0);nt.insertBefore(Dr,g(R))}}}return Zr(R),!0}return R instanceof c&&!oI(R)||(we==="noscript"||we==="noembed"||we==="noframes")&&Sn(/<\/no(script|embed|frames)/i,R.innerHTML)?(Zr(R),!0):(Me&&R.nodeType===Ji.text&&(J=R.textContent,Qi([P,H,V],nt=>{J=Zi(J,nt," ")}),R.textContent!==J&&(Xi(t.removed,{element:R.cloneNode()}),R.textContent=J)),ea(I.afterSanitizeElements,R,null),!1)},f_=function(R,J,we){if(fe[J]||de&&(J==="id"||J==="name")&&(we in n||we in ks))return!1;const nt=ue[J]||ee.attributeCheck instanceof Function&&ee.attributeCheck(J,R);if(!(Ee&&!fe[J]&&Sn(M,J))){if(!(je&&Sn(C,J))){if(!nt||fe[J]){if(!(h_(R)&&(L.tagNameCheck instanceof RegExp&&Sn(L.tagNameCheck,R)||L.tagNameCheck instanceof Function&&L.tagNameCheck(R))&&(L.attributeNameCheck instanceof RegExp&&Sn(L.attributeNameCheck,J)||L.attributeNameCheck instanceof Function&&L.attributeNameCheck(J,R))||J==="is"&&L.allowCustomizedBuiltInElements&&(L.tagNameCheck instanceof RegExp&&Sn(L.tagNameCheck,we)||L.tagNameCheck instanceof Function&&L.tagNameCheck(we))))return!1}else if(!er[J]){if(!Sn(oe,Zi(we,W,""))){if(!((J==="src"||J==="xlink:href"||J==="href")&&R!=="script"&&Bj(we,"data:")===0&&Jt[R])){if(!(te&&!Sn(F,Zi(we,W,"")))){if(we)return!1}}}}}}return!0},iI=We({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),h_=function(R){return!iI[fu(R)]&&Sn(ie,R)},m_=function(R){ea(I.beforeSanitizeAttributes,R,null);const J=R.attributes;if(!J||Kp(R))return;const we={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ue,forceKeepAttr:void 0};let nt=J.length;for(;nt--;){const wn=J[nt],en=wn.name,rr=wn.namespaceURI,Dr=wn.value,Jr=ut(en),Qp=Dr;let bn=en==="value"?Qp:IY(Qp);if(we.attrName=Jr,we.attrValue=bn,we.keepAttr=!0,we.forceKeepAttr=void 0,ea(I.uponSanitizeAttribute,R,we),bn=we.attrValue,G&&(Jr==="id"||Jr==="name")&&Bj(bn,U)!==0&&(Io(en,R),bn=U+bn),Ue&&Sn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,bn)){Io(en,R);continue}if(Jr==="attributename"&&zj(bn,"href")){Io(en,R);continue}if(we.forceKeepAttr)continue;if(!we.keepAttr){Io(en,R);continue}if(!_e&&Sn(/\/>/i,bn)){Io(en,R);continue}Me&&Qi([P,H,V],g_=>{bn=Zi(bn,g_," ")});const p_=ut(R.nodeName);if(!f_(p_,Jr,bn)){Io(en,R);continue}if(j&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!rr)switch(v.getAttributeType(p_,Jr)){case"TrustedHTML":{bn=j.createHTML(bn);break}case"TrustedScriptURL":{bn=j.createScriptURL(bn);break}}if(bn!==Qp)try{rr?R.setAttributeNS(rr,en,bn):R.setAttribute(en,bn),Kp(R)?Zr(R):Fj(t.removed)}catch{Io(en,R)}}ea(I.afterSanitizeAttributes,R,null)},Yp=function(R){let J=null;const we=u_(R);for(ea(I.beforeSanitizeShadowDOM,R,null);J=we.nextNode();)ea(I.uponSanitizeShadowNode,J,null),d_(J),m_(J),J.content instanceof a&&Yp(J.content);ea(I.afterSanitizeShadowDOM,R,null)},Zd=function(R){if(R.nodeType===Ji.element&&R.shadowRoot instanceof a){const nt=R.shadowRoot;Zd(nt),Yp(nt)}const J=R.childNodes;if(!J)return;const we=[];Qi(J,nt=>{Xi(we,nt)});for(const nt of we)Zd(nt)};return t.sanitize=function(Ae){let R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},J=null,we=null,nt=null,wn=null;if(Ii=!Ae,Ii&&(Ae=""),typeof Ae!="string"&&!Gp(Ae)&&(Ae=BY(Ae),typeof Ae!="string"))throw Wf("dirty is not a string, aborting");if(!t.isSupported)return Ae;if(Rt||Fn(R),t.removed=[],typeof Ae=="string"&&(pe=!1),pe){const Dr=Ae.nodeName;if(typeof Dr=="string"){const Jr=ut(Dr);if(!ce[Jr]||Q[Jr])throw Wf("root node is forbidden and cannot be sanitized in-place")}Zd(Ae)}else if(Ae instanceof l)J=c_(""),we=J.ownerDocument.importNode(Ae,!0),we.nodeType===Ji.element&&we.nodeName==="BODY"||we.nodeName==="HTML"?J=we:J.appendChild(we),Zd(we);else{if(!A&&!Me&&!ct&&Ae.indexOf("<")===-1)return j&&q?j.createHTML(Ae):Ae;if(J=c_(Ae),!J)return A?null:q?k:""}J&&Et&&Zr(J.firstChild);const en=u_(pe?Ae:J);for(;nt=en.nextNode();)d_(nt),m_(nt),nt.content instanceof a&&Yp(nt.content);if(pe)return Ae;if(A){if(Me){J.normalize();let Dr=J.innerHTML;Qi([P,H,V],Jr=>{Dr=Zi(Dr,Jr," ")}),J.innerHTML=Dr}if($)for(wn=O.call(J.ownerDocument);J.firstChild;)wn.appendChild(J.firstChild);else wn=J;return(ue.shadowroot||ue.shadowrootmode)&&(wn=T.call(r,wn,!0)),wn}let rr=ct?J.outerHTML:J.innerHTML;return ct&&ce["!doctype"]&&J.ownerDocument&&J.ownerDocument.doctype&&J.ownerDocument.doctype.name&&Sn(ZY,J.ownerDocument.doctype.name)&&(rr=" `+rr),Me&&Qi([P,H,V],Dr=>{rr=Zi(rr,Dr," ")}),j&&q?j.createHTML(rr):rr},t.setConfig=function(){let Ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Fn(Ae),Rt=!0},t.clearConfig=function(){xn=null,Rt=!1},t.isValidAttribute=function(Ae,R,J){xn||Fn({});const we=ut(Ae),nt=ut(R);return f_(we,nt,J)},t.addHook=function(Ae,R){typeof R=="function"&&Xi(I[Ae],R)},t.removeHook=function(Ae,R){if(R!==void 0){const J=MY(I[Ae],R);return J===-1?void 0:DY(I[Ae],J,1)[0]}return Fj(I[Ae])},t.removeHooks=function(Ae){I[Ae]=[]},t.removeAllHooks=function(){I=Yj()},t}var Tp=FR();const Qj=new Set(["groep","group"]),nQ=2;function rQ(e){return e.gripp_product_id===nQ||e.gripp_product_id==null}function zR(e){var r,s;const t=(r=e.line_type)==null?void 0:r.trim().toLowerCase();if(t&&Qj.has(t))return!0;const n=(s=e.product_name)==null?void 0:s.trim().toLowerCase();return!!(n&&Qj.has(n)&&rQ(e))}function sQ(e){const t=[];let n={header:null,children:[]};for(const r of e)zR(r)?((n.header||n.children.length>0)&&t.push(n),n={header:r,children:[]}):n.children.push(r);return(n.header||n.children.length>0)&&t.push(n),t}function aQ(e){if(e.subject&&e.subject.trim().length>0)return e.subject;if(e.description&&e.description.trim().length>0){const t=e.description.replace(/<[^>]+>/g,"").trim();if(t.length>0)return t.length>80?`${t.slice(0,80)}…`:t}return"Groep"}const Xj="Overig";function oQ(e){const t=new Map;for(const n of e){const r=n.gripp_ledger_subgroup||Xj,s=n.gripp_ledger_group??null,a=t.get(r);a?(a.lines.push(n),!a.topGroup&&s&&(a.topGroup=s)):t.set(r,{subgroup:r,topGroup:s,isFallback:r===Xj,lines:[n]})}return Array.from(t.values()).sort((n,r)=>n.isFallback&&!r.isFallback?1:!n.isFallback&&r.isFallback?-1:n.subgroup.localeCompare(r.subgroup,"nl"))}function iQ({line:e}){const t=aQ(e),n=e.description||"";return i.jsxs("div",{className:"rounded-lg border-2 border-primary/30 bg-primary/5 p-3 space-y-2",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsx("span",{className:"font-bold text-sm",children:t}),e.quantity!=null&&i.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap shrink-0",children:[e.quantity,e.unit_name?` ${e.unit_name}`:""]})]}),n&&i.jsx("div",{className:"prose prose-sm max-w-none text-sm text-foreground/80 [&_p]:my-1 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0 [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0 [&_strong]:text-foreground",dangerouslySetInnerHTML:{__html:Tp.sanitize(n)}})]})}function Zj({line:e,isChild:t=!1}){const n=e.description||e.subject||"";return i.jsxs("div",{className:"rounded-lg border bg-card p-3 space-y-2"+(t?" ml-3 border-l-2 border-l-primary/30":""),children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsx("span",{className:"font-medium text-sm",children:e.product_name||"—"}),e.quantity!=null&&i.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap shrink-0",children:[e.quantity,e.unit_name?` ${e.unit_name}`:""]})]}),n&&i.jsx("div",{className:"prose prose-sm max-w-none text-sm text-muted-foreground [&_p]:my-1 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0 [&_ul]:my-1 [&_ol]:my-1 [&_strong]:text-foreground",dangerouslySetInnerHTML:{__html:Tp.sanitize(n)}})]})}function lQ({projectId:e}){const{data:t,isLoading:n}=SY(e),r=p.useMemo(()=>t?oQ(t):[],[t]);return n?i.jsx("div",{className:"flex items-center justify-center py-6",children:i.jsx(yn,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):!t||t.length===0?i.jsx("p",{className:"text-sm text-muted-foreground py-2",children:"Geen offerteregels gevonden."}):i.jsx("div",{className:"space-y-5",children:r.map(s=>{const a=sQ(s.lines),o=s.lines.filter(l=>!zR(l)).length;return i.jsxs("section",{className:"space-y-2",children:[i.jsxs("header",{className:"flex items-center gap-2",children:[i.jsx(Cd,{className:"h-4 w-4 text-muted-foreground shrink-0"}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("h3",{className:"font-semibold text-sm leading-tight truncate",children:s.subgroup}),s.topGroup&&!s.isFallback?i.jsx("p",{className:"text-[10px] text-muted-foreground/70 leading-tight truncate",children:s.topGroup}):null]}),i.jsxs("span",{className:"ml-auto text-[10px] text-muted-foreground/70 shrink-0",children:[o," regel",o===1?"":"s"]})]}),i.jsx("div",{className:"space-y-2",children:a.map((l,c)=>l.header?i.jsxs("div",{className:"space-y-2",children:[i.jsx(iQ,{line:l.header}),l.children.map(u=>i.jsx(Zj,{line:u,isChild:!0},u.id))]},l.header.id):i.jsx("div",{className:"space-y-2",children:l.children.map(u=>i.jsx(Zj,{line:u},u.id))},`loose-${c}`))})]},s.subgroup)})})}var BR="AlertDialog",[cQ]=Ln(BR,[zA]),Na=zA(),UR=e=>{const{__scopeAlertDialog:t,...n}=e,r=Na(t);return i.jsx(cb,{...r,...n,modal:!0})};UR.displayName=BR;var uQ="AlertDialogTrigger",VR=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=Na(n);return i.jsx(nR,{...s,...r,ref:t})});VR.displayName=uQ;var dQ="AlertDialogPortal",WR=e=>{const{__scopeAlertDialog:t,...n}=e,r=Na(t);return i.jsx(ub,{...r,...n})};WR.displayName=dQ;var fQ="AlertDialogOverlay",HR=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=Na(n);return i.jsx(Ld,{...s,...r,ref:t})});HR.displayName=fQ;var Dl="AlertDialogContent",[hQ,mQ]=cQ(Dl),pQ=DC("AlertDialogContent"),qR=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...s}=e,a=Na(n),o=p.useRef(null),l=ze(t,o),c=p.useRef(null);return i.jsx(qK,{contentName:Dl,titleName:KR,docsSlug:"alert-dialog",children:i.jsx(hQ,{scope:n,cancelRef:c,children:i.jsxs($d,{role:"alertdialog",...a,...s,ref:l,onOpenAutoFocus:xe(s.onOpenAutoFocus,u=>{var d;u.preventDefault(),(d=c.current)==null||d.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[i.jsx(pQ,{children:r}),i.jsx(yQ,{contentRef:o})]})})})});qR.displayName=Dl;var KR="AlertDialogTitle",GR=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=Na(n);return i.jsx(Fd,{...s,...r,ref:t})});GR.displayName=KR;var YR="AlertDialogDescription",QR=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=Na(n);return i.jsx(zd,{...s,...r,ref:t})});QR.displayName=YR;var gQ="AlertDialogAction",XR=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=Na(n);return i.jsx(jp,{...s,...r,ref:t})});XR.displayName=gQ;var ZR="AlertDialogCancel",JR=p.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:s}=mQ(ZR,n),a=Na(n),o=ze(t,s);return i.jsx(jp,{...a,...r,ref:o})});JR.displayName=ZR;var yQ=({contentRef:e})=>{const t=`\`${Dl}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${Dl}\` by passing a \`${YR}\` 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 \`${Dl}\`. 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 p.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},vQ=UR,xQ=VR,wQ=WR,eO=HR,tO=qR,nO=XR,rO=JR,sO=GR,aO=QR;const oO=vQ,Jse=xQ,bQ=wQ,iO=p.forwardRef(({className:e,...t},n)=>i.jsx(eO,{className:Y("fixed inset-0 z-[120] 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",e),...t,ref:n}));iO.displayName=eO.displayName;const kb=p.forwardRef(({className:e,...t},n)=>i.jsxs(bQ,{children:[i.jsx(iO,{}),i.jsx(tO,{ref:n,className:Y("fixed left-[50%] top-[50%] z-[120] 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",e),...t})]}));kb.displayName=tO.displayName;const jb=({className:e,...t})=>i.jsx("div",{className:Y("flex flex-col space-y-2 text-center sm:text-left",e),...t});jb.displayName="AlertDialogHeader";const Sb=({className:e,...t})=>i.jsx("div",{className:Y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Sb.displayName="AlertDialogFooter";const Eb=p.forwardRef(({className:e,...t},n)=>i.jsx(sO,{ref:n,className:Y("text-lg font-semibold",e),...t}));Eb.displayName=sO.displayName;const Nb=p.forwardRef(({className:e,...t},n)=>i.jsx(aO,{ref:n,className:Y("text-sm text-muted-foreground",e),...t}));Nb.displayName=aO.displayName;const Cb=p.forwardRef(({className:e,...t},n)=>i.jsx(nO,{ref:n,className:Y(dd(),e),...t}));Cb.displayName=nO.displayName;const Tb=p.forwardRef(({className:e,...t},n)=>i.jsx(rO,{ref:n,className:Y(dd({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));Tb.displayName=rO.displayName;const lO="id, project_id, schedule_entry_id, staff_id, user_id, started_at, ended_at, source, auto_closed, note",_Q=["Geen medewerker gekoppeld aan dit account.","Deze opdracht hoort niet bij jouw organisatie.","Je bent niet aan deze opdracht toegewezen.","De tijdklok staat uit voor deze organisatie.","Deze gegevens liggen vast"],kQ=[{match:"Deze tijdregistratie loopt niet (meer) of is niet van jou.",message:"Deze klok was al gestopt. De lijst is bijgewerkt."},{match:"uq_project_time_logs_one_running",message:"Er werd net al een klok gestart. Ververs en kijk waar hij loopt."}];function eu(e,t){const n=e instanceof Error?e.message:String(e??""),r=kQ.find(a=>n.includes(a.match));if(r)return r.message;const s=_Q.find(a=>n.includes(a));return s||(n.includes("al verwerkt of nog in behandeling")?n:t)}function jQ(e){const{initialized:t,session:n}=Ht();return xt({queryKey:["project-time-logs",e],queryFn:async()=>{const{data:r,error:s}=await B.from("project_time_logs").select(lO).eq("project_id",e).order("started_at",{ascending:!1}).limit(200);if(s)throw new Error(s.message);return r??[]},enabled:!!e&&t&&!!n,staleTime:30*1e3})}function SQ(){const{initialized:e,session:t,user:n}=Ht();return xt({queryKey:["running-time-log",n==null?void 0:n.id],queryFn:async()=>{const{data:r,error:s}=await B.from("project_time_logs").select(lO).eq("user_id",n.id).is("ended_at",null).order("started_at",{ascending:!1}).limit(1);if(s)throw new Error(s.message);const a=r??[];return a.length>0?a[0]:null},enabled:!!(n!=null&&n.id)&&e&&!!t,staleTime:30*1e3})}function EQ(e){const t=Ge(),{organization:n}=zt(),r=n==null?void 0:n.id,s=p.useCallback(()=>{t.invalidateQueries({queryKey:["project-time-logs"]}),t.invalidateQueries({queryKey:["running-time-log"]})},[t]),a=()=>{if(!r)throw new Error("Geen organisatie gevonden.");return r},o=Ke({mutationFn:async({scheduleEntryId:f})=>{const h=a();if(!e)throw new Error("Geen opdracht gevonden.");await Je({organizationId:h,scope:"time-log-start",key:`${e}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const{data:m,error:v}=await B.rpc("start_time_log",{p_project_id:e,p_schedule_entry_id:f??null});if(v)throw new Error(v.message);return m},onSuccess:()=>{s(),K.success("Tijd loopt")},onError:f=>{s(),K.error(eu(f,"Kon de tijd niet starten. Probeer het opnieuw."))}}),l=Ke({mutationFn:async({logId:f})=>{const h=a();await Je({organizationId:h,scope:"time-log-stop",key:`${f}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const{error:m}=await B.rpc("stop_time_log",{p_log_id:f});if(m)throw new Error(m.message)},onSuccess:()=>{s(),K.success("Tijd gestopt")},onError:f=>{s(),K.error(eu(f,"Kon de tijd niet stoppen. Probeer het opnieuw."))}}),c=Ke({mutationFn:async({logId:f,startedAt:h,endedAt:m,note:v})=>{const w=a();await Je({organizationId:w,scope:"time-log-correct",key:`${f}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const{error:y}=await B.from("project_time_logs").update({started_at:h,ended_at:m,...v!==void 0?{note:v}:{}}).eq("id",f);if(y)throw new Error(y.message)},onSuccess:()=>{s(),K.success("Tijd bijgewerkt")},onError:f=>{K.error(eu(f,"Kon de tijd niet bijwerken. Probeer het opnieuw."))}}),u=Ke({mutationFn:async({staffId:f,scheduleEntryId:h,startedAt:m,endedAt:v,note:w})=>{var _;const y=a();if(!e)throw new Error("Geen opdracht gevonden.");const{data:x}=await B.auth.getUser(),g=(_=x.user)==null?void 0:_.id;if(!g)throw new Error("Niet ingelogd.");await Je({organizationId:y,scope:"time-log-manual",key:`${e}:${m}:${v}`,ttlSeconds:30});const{error:b}=await B.from("project_time_logs").insert({organization_id:y,project_id:e,schedule_entry_id:h??null,staff_id:f,user_id:g,started_at:m,ended_at:v,source:"manual",note:w??null});if(b)throw new Error(b.message)},onSuccess:()=>{s(),K.success("Tijd toegevoegd")},onError:f=>{K.error(eu(f,"Kon de tijd niet toevoegen. Probeer het opnieuw."))}}),d=Ke({mutationFn:async({logId:f})=>{const h=a();await Je({organizationId:h,scope:"time-log-delete",key:`${f}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const{error:m}=await B.from("project_time_logs").delete().eq("id",f);if(m)throw new Error(m.message)},onSuccess:()=>{s(),K.success("Regel verwijderd")},onError:f=>{K.error(eu(f,"Kon de regel niet verwijderen. Probeer het opnieuw."))}});return{start:o,stop:l,correct:c,addManual:u,removeManual:d}}function Px(e,t){const n=Date.parse(e.started_at);if(Number.isNaN(n))return 0;const r=e.ended_at?Date.parse(e.ended_at):t;return Number.isNaN(r)||r<=n?0:Math.floor((r-n)/1e3)}function Jj(e,t){return e.reduce((n,r)=>n+Px(r,t),0)}function tu(e){const t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60);return`${n}:${String(r).padStart(2,"0")}`}function NQ(e){const t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0,n=Math.floor(t/3600),r=Math.floor(t%3600/60),s=t%60;return`${n}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function cO(e,t){const n=new Date(e);return Number.isNaN(n.getTime())?!1:n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}function CQ(e,t){return e.ended_at?!1:!cO(e.started_at,t)}function TQ({runningHere:e,runsElsewhere:t,myLogs:n,now:r,plannedHours:s,isBusy:a,hasError:o,onRetry:l,onStart:c,onStop:u,onEdit:d,onDelete:f,onAdd:h}){const m=r.getTime(),v=Jj(n,m),w=Jj(n.filter(x=>cO(x.started_at,r)),m),y=e?Px(e,m):0;return i.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"Tijd op deze opdracht"}),i.jsx("p",{className:Y("font-mono",e?"text-2xl text-primary":"text-3xl text-foreground"),children:e?NQ(y):tu(v)})]}),e?i.jsxs(ne,{size:"lg",variant:"destructive",className:"shrink-0 gap-2",disabled:a||o,onClick:()=>u(e.id),children:[a?i.jsx(yn,{className:"h-4 w-4 animate-spin"}):i.jsx(r$,{className:"h-4 w-4"}),a?"Bezig":"Stop"]}):i.jsxs(ne,{size:"lg",className:"shrink-0 gap-2",disabled:a||o,onClick:c,children:[a?i.jsx(yn,{className:"h-4 w-4 animate-spin"}):i.jsx(K5,{className:"h-4 w-4"}),a?"Bezig":"Start"]})]}),o&&i.jsxs("div",{className:"mt-3 rounded-md bg-muted/60 px-3 py-2",children:[i.jsxs("p",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[i.jsx(Vr,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),i.jsx("span",{children:"De tijdregistratie kon niet opgehaald worden. Zolang dat zo is kun je niet starten of stoppen, zodat er geen dubbele of afgeknipte sessies ontstaan."})]}),i.jsx(ne,{variant:"outline",size:"sm",className:"mt-2 h-8",onClick:l,children:"Opnieuw proberen"})]}),t&&i.jsxs("p",{className:"mt-3 flex items-start gap-2 rounded-md bg-muted/60 px-3 py-2 text-xs text-muted-foreground",children:[i.jsx(Vr,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),i.jsx("span",{children:"Je klok loopt nog op een andere opdracht. Als je hier start, wordt die gestopt."})]}),e&&CQ(e,r)&&i.jsxs("p",{className:"mt-3 flex items-start gap-2 rounded-md bg-muted/60 px-3 py-2 text-xs text-muted-foreground",children:[i.jsx(Vr,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),i.jsx("span",{children:"Deze klok loopt sinds een vorige dag. Controleer of dit klopt en stop hem."})]}),i.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 border-t pt-3 text-xs text-muted-foreground",children:[i.jsxs("span",{children:["Vandaag ",tu(w)]}),i.jsxs("span",{children:["Totaal ",tu(v)]}),s?i.jsxs("span",{children:["Gepland ",tu(s*3600)]}):null,i.jsxs(ne,{variant:"ghost",size:"sm",className:"ml-auto h-7 gap-1 px-2 text-xs",onClick:h,children:[i.jsx(jc,{className:"h-3.5 w-3.5"}),"Toevoegen"]})]}),n.length>0&&i.jsx("ul",{className:"mt-2 space-y-1",children:n.map(x=>i.jsxs("li",{className:"flex items-center gap-2 text-xs",children:[i.jsxs("span",{className:"tabular-nums text-muted-foreground",children:[he(new Date(x.started_at),"d MMM HH:mm",{locale:tt})," tot ",x.ended_at?he(new Date(x.ended_at),"HH:mm"):"loopt"]}),i.jsx("span",{className:"font-medium",children:tu(Px(x,m))}),x.auto_closed&&i.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px]",children:"auto afgesloten"}),x.source==="manual"&&i.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px]",children:"handmatig"}),i.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[x.ended_at&&i.jsx(ne,{variant:"ghost",size:"icon",className:"h-9 w-9",onClick:()=>d(x),"aria-label":"Tijd bijstellen",children:i.jsx(q5,{className:"h-4 w-4"})}),x.source==="manual"&&i.jsx(ne,{variant:"ghost",size:"icon",className:"h-9 w-9",onClick:()=>f(x.id),"aria-label":"Regel verwijderen",children:i.jsx(Jw,{className:"h-4 w-4"})})]})]},x.id))})]})}function eS(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function PQ({open:e,onOpenChange:t,log:n,defaultDate:r,isSaving:s,onSave:a}){const[o,l]=p.useState(""),[c,u]=p.useState(""),[d,f]=p.useState("");p.useEffect(()=>{if(!e)return;if(n){l(eS(n.started_at)),u(eS(n.ended_at)),f(n.note??"");return}const m=r??new Date().toISOString().slice(0,10);l(`${m}T08:00`),u(`${m}T16:00`),f("")},[e,n,r]);const h=()=>{if(!o||!c){K.error("Vul een begin- en eindtijd in.");return}const m=new Date(o),v=new Date(c);if(Number.isNaN(m.getTime())||Number.isNaN(v.getTime())){K.error("Die tijd kan ik niet lezen. Controleer de invoer.");return}if(v<=m){K.error("De eindtijd moet na de begintijd liggen.");return}a({startedAt:m.toISOString(),endedAt:v.toISOString(),note:d.trim()?d.trim():null})};return i.jsx(Mc,{open:e,onOpenChange:t,children:i.jsxs(Oi,{className:"sm:max-w-md",children:[i.jsxs(Bd,{children:[i.jsx(Mi,{children:n?"Tijd bijstellen":"Tijd toevoegen"}),i.jsx(Ud,{children:n?"Pas je eigen begin- en eindtijd aan.":"Voeg een sessie toe die je vergat te klokken."})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Tt,{htmlFor:"time-log-start",children:"Begin"}),i.jsx(ot,{id:"time-log-start",type:"datetime-local",value:o,onChange:m=>l(m.target.value)})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Tt,{htmlFor:"time-log-end",children:"Einde"}),i.jsx(ot,{id:"time-log-end",type:"datetime-local",value:c,onChange:m=>u(m.target.value)})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Tt,{htmlFor:"time-log-note",children:"Notitie"}),i.jsx(ot,{id:"time-log-note",value:d,onChange:m=>f(m.target.value),placeholder:"Waarom je dit aanpast"})]})]}),i.jsxs(Sp,{children:[i.jsx(ne,{variant:"outline",onClick:()=>t(!1),disabled:s,children:"Annuleren"}),i.jsx(ne,{onClick:h,disabled:s,children:"Opslaan"})]})]})})}const AQ=2e4,RQ=1e3;function OQ({projectId:e,scheduleEntryId:t,scheduledDate:n,plannedHours:r}){const{user:s}=Ht(),{organization:a}=zt(),{data:o}=xp(s==null?void 0:s.id,a==null?void 0:a.id),{getSetting:l,loading:c}=Hd(a==null?void 0:a.id),u=l("staff_time_clock_enabled")===!0,d=jQ(e),f=SQ(),{start:h,stop:m,correct:v,addManual:w,removeManual:y}=EQ(e),[x,g]=p.useState(()=>new Date),[b,_]=p.useState(null),[j,k]=p.useState(!1),[S,E]=p.useState(null),N=f.data??null,O=(N==null?void 0:N.project_id)===e,z=O?N:null,T=f.isError||d.isError,I=z?RQ:AQ;p.useEffect(()=>{const W=window.setInterval(()=>g(new Date),I);return()=>window.clearInterval(W)},[I]);const P=(z==null?void 0:z.started_at)??null,[H,V]=p.useState(0);p.useEffect(()=>{if(!P){V(0);return}const W=Date.parse(P);V(Number.isNaN(W)?0:Math.max(0,W-Date.now()))},[P]);const M=p.useMemo(()=>new Date(x.getTime()+H),[x,H]),C=p.useMemo(()=>(d.data??[]).filter(W=>W.user_id===(s==null?void 0:s.id)),[d.data,s==null?void 0:s.id]),F=W=>{if(b){v.mutate({logId:b.id,startedAt:W.startedAt,endedAt:W.endedAt,note:W.note},{onSuccess:()=>k(!1)});return}o&&w.mutate({staffId:o,scheduleEntryId:t,startedAt:W.startedAt,endedAt:W.endedAt,note:W.note},{onSuccess:()=>k(!1)})};return c||d.isLoading||f.isLoading?u?i.jsx(Dt,{className:"h-28 w-full rounded-lg"}):null:!u&&!z?null:i.jsxs("div",{className:"print:hidden",children:[i.jsx(TQ,{runningHere:z,runsElsewhere:!!N&&!O,myLogs:C,now:M,plannedHours:r,isBusy:h.isPending||m.isPending,hasError:T,onRetry:()=>{d.refetch(),f.refetch()},onStart:()=>h.mutate({scheduleEntryId:t}),onStop:W=>m.mutate({logId:W}),onEdit:W=>{_(W),k(!0)},onDelete:W=>E(W),onAdd:()=>{_(null),k(!0)}}),i.jsx(oO,{open:!!S,onOpenChange:W=>!W&&E(null),children:i.jsxs(kb,{children:[i.jsxs(jb,{children:[i.jsx(Eb,{children:"Regel verwijderen"}),i.jsx(Nb,{children:"Deze handmatig toegevoegde tijd wordt definitief verwijderd. Geklokte tijd kun je niet verwijderen, alleen bijstellen."})]}),i.jsxs(Sb,{children:[i.jsx(Tb,{children:"Annuleren"}),i.jsx(Cb,{onClick:()=>{S&&y.mutate({logId:S}),E(null)},children:"Verwijderen"})]})]})}),i.jsx(PQ,{open:j,onOpenChange:k,log:b,defaultDate:n,isSaving:v.isPending||w.isPending,onSave:F})]})}function Pp(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ap="Checkbox",[MQ]=Ln(Ap),[DQ,Pb]=MQ(Ap);function IQ(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:s,disabled:a,form:o,name:l,onCheckedChange:c,required:u,value:d="on",internal_do_not_use_render:f}=e,[h,m]=vs({prop:n,defaultProp:s??!1,onChange:c,caller:Ap}),[v,w]=p.useState(null),[y,x]=p.useState(null),g=p.useRef(!1),b=v?!!o||!!v.closest("form"):!0,_={checked:h,disabled:a,setChecked:m,control:v,setControl:w,name:l,form:o,value:d,hasConsumerStoppedPropagationRef:g,required:u,defaultChecked:po(s)?!1:s,isFormControl:b,bubbleInput:y,setBubbleInput:x};return i.jsx(DQ,{scope:t,..._,children:LQ(f)?f(_):r})}var uO="CheckboxTrigger",dO=p.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},s)=>{const{control:a,value:o,disabled:l,checked:c,required:u,setControl:d,setChecked:f,hasConsumerStoppedPropagationRef:h,isFormControl:m,bubbleInput:v}=Pb(uO,e),w=ze(s,d),y=p.useRef(c);return p.useEffect(()=>{const x=a==null?void 0:a.form;if(x){const g=()=>f(y.current);return x.addEventListener("reset",g),()=>x.removeEventListener("reset",g)}},[a,f]),i.jsx(Te.button,{type:"button",role:"checkbox","aria-checked":po(c)?"mixed":c,"aria-required":u,"data-state":gO(c),"data-disabled":l?"":void 0,disabled:l,value:o,...r,ref:w,onKeyDown:xe(t,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:xe(n,x=>{f(g=>po(g)?!0:!g),v&&m&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})})});dO.displayName=uO;var Ab=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:s,defaultChecked:a,required:o,disabled:l,value:c,onCheckedChange:u,form:d,...f}=e;return i.jsx(IQ,{__scopeCheckbox:n,checked:s,defaultChecked:a,disabled:l,required:o,onCheckedChange:u,name:r,form:d,value:c,internal_do_not_use_render:({isFormControl:h})=>i.jsxs(i.Fragment,{children:[i.jsx(dO,{...f,ref:t,__scopeCheckbox:n}),h&&i.jsx(pO,{__scopeCheckbox:n})]})})});Ab.displayName=Ap;var fO="CheckboxIndicator",hO=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...s}=e,a=Pb(fO,n);return i.jsx(Jn,{present:r||po(a.checked)||a.checked===!0,children:i.jsx(Te.span,{"data-state":gO(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});hO.displayName=fO;var mO="CheckboxBubbleInput",pO=p.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:s,checked:a,defaultChecked:o,required:l,disabled:c,name:u,value:d,form:f,bubbleInput:h,setBubbleInput:m}=Pb(mO,e),v=ze(n,m),w=Pp(a),y=Jm(r);p.useEffect(()=>{const g=h;if(!g)return;const b=window.HTMLInputElement.prototype,j=Object.getOwnPropertyDescriptor(b,"checked").set,k=!s.current;if(w!==a&&j){const S=new Event("click",{bubbles:k});g.indeterminate=po(a),j.call(g,po(a)?!1:a),g.dispatchEvent(S)}},[h,w,a,s]);const x=p.useRef(po(a)?!1:a);return i.jsx(Te.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??x.current,required:l,disabled:c,name:u,value:d,form:f,...t,tabIndex:-1,ref:v,style:{...t.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});pO.displayName=mO;function LQ(e){return typeof e=="function"}function po(e){return e==="indeterminate"}function gO(e){return po(e)?"indeterminate":e?"checked":"unchecked"}const ji=p.forwardRef(({className:e,...t},n)=>i.jsx(Ab,{ref:n,className:Y("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-0 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:i.jsx(hO,{className:Y("flex items-center justify-center text-current"),children:i.jsx(kc,{className:"h-4 w-4"})})}));ji.displayName=Ab.displayName;const $Q={gripp_import:"GRIPP",gripp_project_import:"GRIPP-opdracht",opdrachtbon:"Opdrachtbon",offerte:"Offerte",tekening:"Tekening",foto:"Foto",werkbon:"Werkbon",other:"Overig",overig:"Document"};function tS(e){return e.file_name||e.filename||e.original_name||"Onbekend bestand"}function FQ({open:e,onOpenChange:t,documents:n,onConfirm:r}){const[s,a]=p.useState(!0),[o,l]=p.useState({}),c=p.useRef(!1);p.useEffect(()=>{e&&!c.current&&(a(!0),l(Object.fromEntries(n.map(f=>[f.id,f.include_in_planner_print])))),c.current=e},[e,n]);const u=n.filter(f=>o[f.id]),d=!s&&u.length===0;return i.jsx(Mc,{open:e,onOpenChange:t,children:i.jsxs(Oi,{className:"max-w-[min(28rem,calc(100vw-2rem))]",children:[i.jsxs(Bd,{children:[i.jsxs(Mi,{className:"flex items-center gap-2",children:[i.jsx(Zu,{className:"h-5 w-5"}),"Printen"]}),i.jsx(Ud,{children:"Kies wat je wilt printen. Bijlages openen in een nieuw tabblad, de opdrachtbrief print direct."})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-lg border p-3",children:[i.jsx(ji,{checked:s,onCheckedChange:f=>a(f===!0),className:"mt-0.5","aria-label":"Opdrachtbrief meeprinten"}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"Opdrachtbrief"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"De volledige opdrachtbrief."})]})]}),n.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Bijlages"}),n.map(f=>i.jsxs("label",{className:"flex cursor-pointer items-center gap-3 rounded-lg border p-3",children:[i.jsx(ji,{checked:o[f.id]===!0,onCheckedChange:h=>l(m=>({...m,[f.id]:h===!0})),"aria-label":`${tS(f)} meeprinten`}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:tS(f)}),i.jsx(Qe,{variant:"outline",className:"shrink-0 text-xs",children:$Q[f.document_type]||f.document_type})]},f.id))]})]}),i.jsxs(Sp,{children:[i.jsx(ne,{variant:"outline",type:"button",onClick:()=>t(!1),children:"Annuleren"}),i.jsxs(ne,{type:"button",className:"gap-1.5",disabled:d,onClick:()=>r({includeBrief:s,selectedDocuments:u}),children:[i.jsx(Zu,{className:"h-4 w-4"}),"Printen"]})]})]})})}const zQ=/^[0-9]{4}$/;function eae(e){return zQ.test(e)}function yO(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,r]of Object.entries(e))typeof r=="string"&&r.trim().length>0&&(t[n]=r);return t}function BQ(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object"||Array.isArray(n))continue;const r=n,s=typeof r.key=="string"?r.key.trim():"",a=typeof r.label=="string"?r.label.trim():"",o=typeof r.color=="string"?r.color.trim():"";s.length===0||a.length===0||o.length===0||t.push({key:s,label:a,color:o})}return t}function tae(e){if(!e||typeof e!="object"||Array.isArray(e))return{ok:!1,error:"invalid_link"};const t=e;if(t.ok!==!0){const n=t.error;return n==="wrong_pin"||n==="locked"?{ok:!1,error:n}:{ok:!1,error:"invalid_link"}}return{ok:!0,data:{orgName:typeof t.org_name=="string"?t.org_name:"",orgLogoUrl:typeof t.org_logo_url=="string"&&t.org_logo_url.trim().length>0?t.org_logo_url:null,boardDate:typeof t.board_date=="string"?t.board_date:"",boardDateTomorrow:typeof t.board_date_tomorrow=="string"?t.board_date_tomorrow:"",slotLabels:yO(t.slot_labels),itemLabel:typeof t.item_label=="string"&&t.item_label.trim().length>0?t.item_label.trim():"Slot",classifications:BQ(t.classifications),rows:Array.isArray(t.entries)?t.entries:[],rowsTomorrow:Array.isArray(t.entries_tomorrow)?t.entries_tomorrow:[]}}}function nae(e){return`nexus-daylink-pin:${e}`}const UQ=["planner_mode","planner_item_label","planner_slot_custom_labels"],VQ={plannerMode:null,itemLabel:"Slot",slotLabels:{}};async function WQ(e){const{data:t,error:n}=await B.from("organization_settings").select("setting_key, setting_value").eq("organization_id",e).in("setting_key",UQ);if(n)throw n;const r=new Map((t??[]).map(o=>[o.setting_key,o.setting_value])),s=r.get("planner_mode"),a=r.get("planner_item_label");return{plannerMode:typeof s=="string"?s:null,itemLabel:typeof a=="string"&&a.trim().length>0?a.trim():"Slot",slotLabels:yO(r.get("planner_slot_custom_labels"))}}function vO(e){const{data:t}=xt({queryKey:["staff-planner-labels",e],queryFn:()=>WQ(e),enabled:!!e,staleTime:18e5,gcTime:36e5});return t??VQ}const HQ=!1,qQ={installation:"Installatie",maintenance:"Onderhoud",repair:"Reparatie",inspection:"Inspectie",consultation:"Advies",other:"Overig"},KQ={ochtend:"Ochtend (08:00 - 12:00)",middag:"Middag (13:00 - 17:00)",hele_dag:"Hele dag",morning:"Ochtend (08:00 - 12:00)",afternoon:"Middag (12:00 - 17:00)",evening:"Avond (17:00 - 21:00)",full_day:"Hele dag"},GQ={opdrachtbon:"Opdrachtbon",tekening:"Tekening",offerte:"Offerte",other:"Overig",gripp_import:"GRIPP",gripp_project_import:"GRIPP-opdracht"},YQ={general:"Algemeen",problem:"Probleem",progress:"Voortgang",internal:"Intern"};function xO({project:e,isOpen:t,onClose:n,autoPrint:r}){var ke;const{data:s,isLoading:a,isError:o,refetch:l}=bY(e==null?void 0:e.id),{data:c,isLoading:u,isError:d,refetch:f}=_Y(e==null?void 0:e.id),{data:h,isLoading:m,isError:v,refetch:w}=SR(e==null?void 0:e.id),y=o||d||v,{isVisible:x,loading:g}=_b(e==null?void 0:e.organization_id),b=E6({queryKey:["project-lines",e==null?void 0:e.id]})>0,_=()=>{document.body.classList.add("staff-printing"),window.print()};p.useEffect(()=>{const L=()=>document.body.classList.remove("staff-printing");return window.addEventListener("afterprint",L),()=>{window.removeEventListener("afterprint",L),document.body.classList.remove("staff-printing")}},[]);const j=p.useRef(null);p.useEffect(()=>{if(!t||!r||!(e!=null&&e.id)||j.current===e.id||g)return;const Q=a||u||m||b?8e3:250,fe=e.id,ee=window.setTimeout(()=>{j.current=fe,_()},Q);return()=>window.clearTimeout(ee)},[t,r,e==null?void 0:e.id,a,u,m,b,g]),p.useEffect(()=>{t||(j.current=null)},[t]);const k=jY(),[S,E]=p.useState(!1),{plannerMode:N,itemLabel:O,slotLabels:z}=vO((e==null?void 0:e.organization_id)??void 0),{user:T}=Ht(),{data:I}=xp(T==null?void 0:T.id,(e==null?void 0:e.organization_id)??void 0),P=ER();if(!e)return null;const H=((h==null?void 0:h.notes)||[]).filter(L=>L.is_private===!1),V=e.entry_classification??e.customer_classification??null,M=((h==null?void 0:h.checklist)||[]).filter(L=>gb(L.classification_key,V)),C=(L,Q)=>{P.mutate({itemId:L,isCompleted:Q,staffId:I||null,organizationId:e.organization_id})},F=L=>{try{return he(new Date(L),"EEEE d MMMM yyyy",{locale:tt})}catch{return L}},W=!e.vehicle_name&&N==="item"&&e.slot_number!=null?((ke=z[String(e.slot_number)])==null?void 0:ke.trim())||`${O} ${e.slot_number}`:null,ie=e.selected_dates||[],oe=ie.length>1,ce=Id(e.start_time,e.planned_hours)??(e.day_part&&KQ[e.day_part]||null),re=L=>{if(L.storage_path||L.gripp_file_id!=null){const Q=window.open("about:blank","_blank");k.mutateAsync({projectDocumentId:L.id}).then(fe=>{if(!(fe!=null&&fe.url)){Q&&Q.close();return}if(Q){Q.location.href=fe.url;try{Q.opener=null}catch{}}else window.location.href=fe.url}).catch(()=>{Q&&Q.close()});return}if(L.file_url){window.open(L.file_url,"_blank","noopener,noreferrer");return}K.error("Dit document heeft geen geldige link")},ue=({includeBrief:L,selectedDocuments:Q})=>{Q.forEach(fe=>re(fe)),E(!1),L&&window.setTimeout(()=>_(),150)};return i.jsxs(i.Fragment,{children:[i.jsx(Wd,{open:t,onOpenChange:L=>!L&&n(),children:i.jsxs(Dc,{side:"bottom",className:"max-h-[90vh] h-[90dvh] overflow-y-auto px-4 sm:px-6 max-w-full rounded-t-xl",children:[i.jsx(Ic,{className:"text-left pb-4","data-staff-print-hide":!0,children:i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs(Lc,{className:"flex items-center gap-2",children:[i.jsx(Eu,{className:"h-5 w-5"}),"Opdrachtbrief"]}),i.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>E(!0),className:"gap-1.5 mr-8",type:"button",disabled:g,children:[i.jsx(Zu,{className:"h-4 w-4"}),"Print"]})]})}),g?i.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"Laden…"}):i.jsxs("div",{className:"space-y-4 pb-24","data-staff-print-area":!0,children:[e.notes&&i.jsxs("div",{className:"flex gap-3 rounded-lg border border-status-attention/30 bg-status-attention-bg p-3 text-status-attention",children:[i.jsx(Vr,{className:"h-5 w-5 shrink-0 mt-0.5",strokeWidth:1.5}),i.jsxs("div",{className:"space-y-1 min-w-0",children:[i.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide",children:"Let op"}),i.jsx("p",{className:"text-sm whitespace-pre-wrap text-foreground",children:e.notes})]})]}),y&&i.jsx("div",{className:"print:hidden",children:i.jsx(IR,{message:"Een deel van deze opdrachtbrief kon niet geladen worden. Wat je hieronder mist, hoeft er dus niet te ontbreken.",onRetry:()=>{o&&l(),d&&f(),v&&w()}})}),i.jsx(OQ,{projectId:e.id,scheduleEntryId:e.entry_id,scheduledDate:e.scheduled_date,plannedHours:e.planned_hours}),i.jsxs("div",{className:"space-y-2",children:[e.name&&i.jsx("h2",{className:"text-lg font-semibold",children:e.name}),i.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-xs text-muted-foreground",children:[HQ,e.project_type&&i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"·"}),i.jsx("span",{children:qQ[e.project_type]||e.project_type})]})]})]}),x("details")&&i.jsx(xr,{title:"Klant",icon:i.jsx(vr,{className:"h-4 w-4",strokeWidth:1.5}),children:i.jsxs("div",{className:"space-y-1.5",children:[e.customer_name&&i.jsx("p",{className:"font-medium text-foreground",children:e.customer_name}),e.customer_phone&&i.jsx("a",{href:`tel:${e.customer_phone}`,className:"block text-sm text-muted-foreground hover:underline",children:e.customer_phone}),e.customer_email&&i.jsx("a",{href:`mailto:${e.customer_email}`,className:"block text-sm text-muted-foreground hover:underline",children:e.customer_email}),e.customer_address&&i.jsx("div",{className:"text-sm text-muted-foreground space-y-0.5",children:e.customer_address.split(",").map((L,Q)=>i.jsx("div",{children:L.trim()},Q))})]})}),x("details")&&i.jsx(xr,{title:"Planning",icon:i.jsx(Wt,{className:"h-4 w-4",strokeWidth:1.5}),children:i.jsxs("div",{className:"space-y-1",children:[i.jsx("div",{className:"text-sm capitalize",children:F(e.scheduled_date||e.start_date)}),e.end_date&&e.end_date>(e.scheduled_date||e.start_date)&&!oe&&i.jsxs("div",{className:"text-sm text-muted-foreground",children:["t/m ",i.jsx("span",{className:"capitalize",children:F(e.end_date)})]}),ce&&i.jsx("div",{className:"text-sm",children:ce}),oe&&i.jsxs("div",{className:"mt-2 pt-2 border-t",children:[i.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Meerdere dagen:"}),i.jsx("div",{className:"flex flex-wrap gap-1",children:ie.map((L,Q)=>i.jsx(Qe,{variant:"outline",className:"text-xs",children:he(new Date(L),"d MMM",{locale:tt})},Q))})]})]})}),x("details")&&e.team_members&&e.team_members.length>0&&i.jsx(xr,{title:"Team",icon:i.jsx(Wr,{className:"h-4 w-4",strokeWidth:1.5}),children:i.jsx("div",{className:"space-y-1.5",children:e.team_members.map(L=>i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx("span",{className:"font-medium",children:L.name}),L.role&&i.jsxs("span",{className:"text-muted-foreground",children:["(",L.role,")"]}),L.level&&i.jsx(Qe,{variant:"outline",className:"text-xs",children:L.level})]},L.id))})}),x("details")&&e.vehicle_name&&i.jsx(xr,{title:"Voertuig",icon:i.jsx(wl,{className:"h-4 w-4"}),children:i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(wl,{className:"h-3.5 w-3.5 text-muted-foreground"}),i.jsx("span",{children:e.vehicle_name}),e.vehicle_license_plate&&i.jsx(Qe,{variant:"outline",className:"font-mono text-xs",children:e.vehicle_license_plate})]})}),W&&i.jsx(xr,{title:O,icon:i.jsx(wl,{className:"h-4 w-4"}),children:i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx(wl,{className:"h-3.5 w-3.5 text-muted-foreground"}),i.jsx("span",{children:W})]})}),x("details")&&e.extra_labels&&e.extra_labels.length>0&&i.jsx(xr,{title:"Labels",icon:i.jsx(Gh,{className:"h-4 w-4"}),children:i.jsx("div",{className:"flex flex-wrap gap-2",children:e.extra_labels.map((L,Q)=>i.jsx(Qe,{variant:"action",children:L},Q))})}),x("notes")&&H.length>0&&i.jsx(xr,{title:"Werknotities",icon:i.jsx(pT,{className:"h-4 w-4",strokeWidth:1.5}),children:i.jsx("div",{className:"space-y-3",children:H.map(L=>i.jsxs("div",{className:"bg-status-action-bg rounded-lg p-3 space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[i.jsx("span",{children:he(new Date(L.created_at),"HH:mm - d MMM",{locale:tt})}),L.staff_name&&i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"·"}),i.jsx("span",{className:"font-medium",children:L.staff_name})]}),L.note_type&&L.note_type!=="general"&&i.jsx(Qe,{variant:"outline",className:"text-xs",children:YQ[L.note_type]||L.note_type})]}),i.jsx("p",{className:"text-sm whitespace-pre-wrap",children:L.content})]},L.id))})}),x("details")&&e.custom_fields&&Object.keys(e.custom_fields).length>0&&i.jsx(xr,{title:"Aanvullende gegevens",icon:i.jsx(Eu,{className:"h-4 w-4"}),children:i.jsx("div",{className:"space-y-2",children:Object.entries(e.custom_fields).map(([L,Q])=>i.jsxs("div",{className:"flex justify-between gap-4 text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:L}),i.jsx("span",{className:"font-medium text-right",children:typeof Q=="boolean"?Q?"Ja":"Nee":String(Q)})]},L))})}),x("details")&&e.description_visible_to_monteur&&e.description&&i.jsx(xr,{title:"Omschrijving",icon:i.jsx(Eu,{className:"h-4 w-4"}),children:i.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.description})}),x("checklist")&&M.length>0&&i.jsx(xr,{title:"Checklist",icon:i.jsx(Kh,{className:"h-4 w-4",strokeWidth:1.5}),children:i.jsx(NR,{items:M,onToggle:C,isLoading:P.isPending,activeClassificationKey:V,organizationId:e.organization_id,variant:"plain"})}),x("afronden")&&i.jsx(xr,{title:"Afronden",icon:i.jsx(cT,{className:"h-4 w-4",strokeWidth:1.5}),children:i.jsx(OR,{projectId:e.id,organizationId:e.organization_id,staffId:I||null,projectStatus:e.status,customerName:e.customer_name,projectCustomFields:e.custom_fields,checklistItems:x("checklist")?M:[],photos:(h==null?void 0:h.photos)??[],gegevensGeladen:!m&&h!==void 0})}),x("materials")&&s&&s.length>0&&i.jsx(xr,{title:"Materialen",icon:i.jsx(Cd,{className:"h-4 w-4"}),children:i.jsx("div",{className:"space-y-2",children:s.map(L=>{var Q,fe;return i.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[L.is_picked?i.jsx(yi,{className:"h-4 w-4 text-primary shrink-0"}):i.jsx(Zw,{className:"h-4 w-4 text-muted-foreground shrink-0"}),i.jsx("span",{className:"truncate font-medium",children:((Q=L.product)==null?void 0:Q.name)||"Onbekend"})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[i.jsxs("span",{className:"text-muted-foreground",children:[L.quantity," ",((fe=L.product)==null?void 0:fe.unit)||"st"]}),i.jsx(Qe,{variant:L.is_picked?"info":"neutral",className:"text-xs",children:L.is_picked?"Opgepakt":"Niet opgepakt"})]})]},L.id)})})}),x("documents")&&c&&c.length>0&&i.jsx(xr,{title:"Documenten",icon:i.jsx(H5,{className:"h-4 w-4",strokeWidth:1.5}),children:i.jsx("div",{className:"space-y-2",children:c.map(L=>{const Q=i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex items-center gap-2 min-w-0",children:i.jsx("span",{className:"truncate group-hover:underline",children:L.file_name})}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[i.jsx(Qe,{variant:"outline",className:"text-xs",children:GQ[L.document_type]||L.document_type}),i.jsx(A5,{className:"h-3.5 w-3.5 text-muted-foreground",strokeWidth:1.5})]})]}),fe="w-full flex items-center justify-between gap-2 text-sm p-2 rounded-lg hover:bg-muted/50 transition-colors group text-left";return L.file_url?i.jsx("a",{href:L.file_url,target:"_blank",rel:"noopener noreferrer","data-print-document-link":!0,className:fe,children:Q},L.id):i.jsx("button",{type:"button",onClick:()=>re(L),className:fe,children:Q},L.id)})})}),x("offerteregels")&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("h3",{className:"text-sm font-semibold",children:"Offerteregels"}),i.jsx(lQ,{projectId:e.id})]})]})]})}),i.jsx(FQ,{open:S,onOpenChange:E,documents:x("documents")?c??[]:[],onConfirm:ue})]})}function xr({title:e,icon:t,children:n}){return i.jsxs("div",{"data-print-section":!0,className:"space-y-3 rounded-xl border bg-card p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground uppercase tracking-wide",children:[t,e]}),n]})}function QQ({onRefresh:e,isRefreshing:t,showLogout:n}){const{organization:r}=zt(),{impersonatedUser:s,isImpersonating:a}=mp(),{session:o}=Ht(),l=Xs(),[c,u]=p.useState(""),d=async()=>{const v=await lp();if(!v.ok){K.error("Uitloggen ging niet vlekkeloos",{description:`Je bent op dit apparaat uitgelogd. Reden: ${v.reason}`}),B0();return}K.success("Je bent uitgelogd"),l("/auth",{replace:!0})},f=new Date,h=yp(f,{weekStartsOn:1}),m=()=>{const v=f.getHours();return v<12?"Goedemorgen":v<18?"Goedemiddag":"Goedenavond"};return p.useEffect(()=>{(async()=>{var w,y,x,g;if(a&&s){u(((w=s.full_name)==null?void 0:w.split(" ")[0])||"");return}if(o!=null&&o.user){const b=((y=o.user.user_metadata)==null?void 0:y.full_name)||((x=o.user.user_metadata)==null?void 0:x.name)||((g=o.user.email)==null?void 0:g.split("@")[0])||"";u(b.split(" ")[0])}})()},[o,a,s]),i.jsxs("div",{className:"relative px-4 pt-4 pb-20 -mx-4 -mt-4 bg-slate-600",style:{backgroundImage:r!=null&&r.hero_image_url?`url(${r.hero_image_url})`:void 0,backgroundSize:"cover",backgroundPosition:"center"},children:[i.jsx("div",{className:"absolute inset-0 bg-black/40"}),i.jsxs("div",{className:"relative z-10",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r!=null&&r.logo_url?i.jsx("img",{src:r.logo_url,alt:r.name||"Bedrijfslogo",className:"h-10 w-auto max-w-[120px] object-contain rounded bg-white/10 p-1"}):i.jsx("div",{className:"h-10 w-10 rounded-full bg-white/20 flex items-center justify-center",children:i.jsx(_c,{className:"h-5 w-5 text-white"})}),i.jsx("span",{className:"text-white/90 font-medium text-sm truncate",children:(r==null?void 0:r.name)||""})]}),i.jsx("img",{src:"/nexus-mark.svg",alt:"Nexus.OS",className:"h-7 w-7 flex-shrink-0 rounded-md bg-white/10 p-0.5"})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsxs("h1",{className:"text-2xl font-bold text-white",children:[m(),", ",c,"!"]}),i.jsxs("p",{className:"text-white/80",children:["Week ",h," • ",(r==null?void 0:r.name)||""]})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[e&&i.jsx(ne,{variant:"ghost",size:"icon",onClick:e,disabled:t,className:"text-white hover:bg-white/20",children:i.jsx(qs,{className:`h-5 w-5 ${t?"animate-spin":""}`})}),n&&!a&&i.jsx(ne,{variant:"ghost",size:"icon",onClick:d,className:"text-white hover:bg-white/20","aria-label":"Uitloggen",title:"Uitloggen",children:i.jsx(Xu,{className:"h-5 w-5"})})]})]})]})]})}function nS({slot:e,label:t,value:n,subtitle:r,icon:s,onClick:a,ariaLabel:o}){const l=e===1?"teal":e===2?"orange":"aqua",c=[t,r].filter(Boolean).join(" · ")||void 0;return i.jsx("button",{type:"button",onClick:a,"aria-label":o?`${n} ${o}`:void 0,className:"block h-full w-full text-left transition-transform hover:scale-[1.02] focus:outline-none focus-visible:[box-shadow:0_0_0_3px_var(--nx-primary-soft)] rounded-[14px]",children:i.jsx($H,{tone:l,icon:i.jsx(s,{}),value:n,label:c,className:"h-full"})})}function XQ(e){if(!e)return null;try{return he(mn(e),"d MMM",{locale:tt})}catch{return null}}function ZQ({request:e,onOpen:t,onPrint:n}){var m;const r=XQ(e.created_at),s=[e.customer_name,e.customer_city].filter(Boolean).join(" · "),a=[e.customer_postal_code,e.customer_city].filter(Boolean).join(" "),o=((m=e.customer_address)==null?void 0:m.trim())||"",l=[o,a].filter(Boolean).join(", "),c=!!e.customer_phone,u=!!o,d=v=>{if(v.stopPropagation(),!l)return;const w=encodeURIComponent(l),x=/iPad|iPhone|iPod/.test(navigator.userAgent)?`maps://maps.apple.com/?daddr=${w}`:`https://www.google.com/maps/dir/?api=1&destination=${w}`;window.open(x,"_blank")},f=v=>{v.stopPropagation(),e.customer_phone&&window.open(`tel:${e.customer_phone}`,"_self")},h=v=>{v.stopPropagation(),n()};return i.jsxs(dt,{className:"cursor-pointer p-4 transition-colors hover:bg-muted/50 active:scale-[0.98]",onClick:t,children:[i.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-1.5",children:[e.project_type&&i.jsx(vb,{type:e.project_type,size:"sm"}),e.priority&&e.priority!=="normal"&&i.jsx(xb,{priority:e.priority,size:"sm"})]}),i.jsx("h3",{className:"mb-0.5 text-base font-semibold",children:e.title||e.name}),s&&i.jsx("p",{className:"text-sm text-muted-foreground",children:s}),e.description&&i.jsx("div",{className:"prose prose-sm mt-2 line-clamp-3 max-w-none text-sm text-muted-foreground [&_p]:my-1 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0 [&_ul]:my-1 [&_ol]:my-1",dangerouslySetInnerHTML:{__html:Tp.sanitize(e.description)}}),r&&i.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:["Aangemeld ",r]}),i.jsxs("div",{className:"mt-4 flex items-center justify-between border-t pt-2",children:[i.jsxs("div",{className:"flex flex-wrap gap-2",children:[i.jsxs(ne,{variant:"outline",size:"sm",className:"h-9 gap-1.5 px-3",onClick:f,disabled:!c,children:[i.jsx(Ai,{className:"h-4 w-4"}),i.jsx("span",{className:"text-xs",children:"Bel"})]}),i.jsxs(ne,{variant:"outline",size:"sm",className:"h-9 gap-1.5 px-3",onClick:d,disabled:!u,children:[i.jsx(xo,{className:"h-4 w-4"}),i.jsx("span",{className:"text-xs",children:"Route"})]}),i.jsxs(ne,{variant:"outline",size:"sm",className:"h-9 gap-1.5 px-3",onClick:h,children:[i.jsx(Zu,{className:"h-4 w-4"}),i.jsx("span",{className:"text-xs",children:"Print"})]})]}),i.jsx(Gm,{className:"h-5 w-5 text-muted-foreground"})]})]})}function JQ(e){if(!e)return null;try{return he(mn(e),"d MMMM yyyy",{locale:tt})}catch{return null}}function eX({request:e,isOpen:t,onClose:n,onClaim:r,isClaiming:s,autoPrint:a}){var x;const o=()=>{document.body.classList.add("staff-printing"),window.print()};p.useEffect(()=>{const g=()=>document.body.classList.remove("staff-printing");return window.addEventListener("afterprint",g),()=>{window.removeEventListener("afterprint",g),document.body.classList.remove("staff-printing")}},[]);const l=p.useRef(null);if(p.useEffect(()=>{if(!t||!a||!(e!=null&&e.id)||l.current===e.id)return;const g=e.id,b=window.setTimeout(()=>{l.current=g,o()},250);return()=>window.clearTimeout(b)},[t,a,e==null?void 0:e.id]),p.useEffect(()=>{t||(l.current=null)},[t]),!e)return null;const c=JQ(e.created_at),u=[e.customer_postal_code,e.customer_city].filter(Boolean).join(" "),d=((x=e.customer_address)==null?void 0:x.trim())||"",f=[d,u].filter(Boolean).join(", "),h=!!e.customer_phone,m=!!d,v=[...d?d.split(",").map(g=>g.trim()):[],u].filter(Boolean),w=()=>{if(!f)return;const g=encodeURIComponent(f),_=/iPad|iPhone|iPod/.test(navigator.userAgent)?`maps://maps.apple.com/?daddr=${g}`:`https://www.google.com/maps/dir/?api=1&destination=${g}`;window.open(_,"_blank")},y=()=>{e.customer_phone&&window.open(`tel:${e.customer_phone}`,"_self")};return i.jsx(Wd,{open:t,onOpenChange:g=>!g&&n(),children:i.jsxs(Dc,{side:"bottom",className:"max-h-[85vh] overflow-y-auto rounded-t-xl px-4 sm:px-6 max-w-full",children:[i.jsx(Ic,{className:"pb-4 text-left","data-staff-print-hide":!0,children:i.jsxs(Lc,{className:"flex items-center gap-2 pr-8",children:[i.jsx(fo,{className:"h-5 w-5 shrink-0"}),"Serviceaanvraag"]})}),i.jsxs("div",{className:"space-y-4 pb-24","data-staff-print-area":!0,children:[i.jsx("h2",{className:"text-lg font-semibold",children:e.title||e.name}),i.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.project_type&&i.jsx(vb,{type:e.project_type,size:"sm"}),e.priority&&e.priority!=="normal"&&i.jsx(xb,{priority:e.priority,size:"sm"})]}),(e.customer_name||v.length>0)&&i.jsxs("div",{className:"space-y-1 rounded-xl border bg-card p-4",children:[e.customer_name&&i.jsx("p",{className:"font-medium",children:e.customer_name}),v.map((g,b)=>i.jsx("p",{className:"text-sm text-muted-foreground",children:g},b))]}),(h||m)&&i.jsxs("div",{className:"flex flex-wrap gap-2","data-staff-print-hide":!0,children:[h&&i.jsxs(ne,{variant:"outline",size:"sm",className:"h-9 gap-1.5 px-3",onClick:y,children:[i.jsx(Ai,{className:"h-4 w-4"}),i.jsx("span",{className:"text-xs",children:"Bel"})]}),m&&i.jsxs(ne,{variant:"outline",size:"sm",className:"h-9 gap-1.5 px-3",onClick:w,children:[i.jsx(xo,{className:"h-4 w-4"}),i.jsx("span",{className:"text-xs",children:"Route"})]})]}),e.description&&i.jsx("div",{className:"prose prose-sm max-w-none text-sm text-muted-foreground [&_p]:my-1 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0 [&_ul]:my-1 [&_ol]:my-1",dangerouslySetInnerHTML:{__html:Tp.sanitize(e.description)}}),c&&i.jsxs("p",{className:"text-xs text-muted-foreground",children:["Aangemeld ",c]}),i.jsx("div",{"data-staff-print-hide":!0,children:i.jsxs(ne,{className:"w-full gap-2",onClick:r,disabled:s,children:[s?i.jsx(yn,{className:"h-4 w-4 animate-spin"}):i.jsx(yi,{className:"h-4 w-4"}),"Oppakken"]})})]})]})})}const tX="planner_sidebar_service_types";function nX(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="string")continue;const r=n.trim();!r||t.includes(r)||t.push(r)}return t}async function rX(e){const{data:t,error:n}=await B.from("organization_settings").select("setting_value").eq("organization_id",e).eq("setting_key",tX).maybeSingle();if(n)throw n;return nX(t==null?void 0:t.setting_value)}async function sX(){const e=B,{data:t,error:n}=await e.rpc("get_open_service_projects");if(n)throw new Error(n.message||"get_open_service_projects faalde");return t??[]}const Rb="open-service-requests",wO="service-request-types";function aX(e){const{initialized:t,session:n}=Ht(),r=xt({queryKey:[wO,e],queryFn:()=>rX(e),enabled:!!e&&t&&!!n,staleTime:30*60*1e3,gcTime:60*60*1e3}),s=r.data??[],a=s.length>0,o=xt({queryKey:[Rb,e],queryFn:sX,enabled:!!e&&t&&!!n&&a,staleTime:1e3*60*2,retry:!1});return{serviceTypes:s,isEnabled:a,requests:o.data??[],isLoading:r.isLoading||a&&o.isLoading,isError:o.isError}}const oX="al verwerkt of nog in behandeling",iX="service-claim";function lX(e){const t=Ge();return Ke({mutationFn:async({projectId:n})=>{if(!e)throw new Error("Geen organisatie bekend");await Je({organizationId:e,scope:iX,key:`${n}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const r=B,{data:s,error:a}=await r.rpc("claim_service_project",{p_project_id:n});if(a)throw new Error("Oppakken mislukt");if(!s)throw new Error("Oppakken mislukt");return s},onSuccess:n=>{if(n.ok){K.success("Aanvraag opgepakt · hij staat vandaag in je planning"),t.invalidateQueries({queryKey:[Rb]}),t.invalidateQueries({queryKey:["staff-projects"]}),t.invalidateQueries({queryKey:["planner-day-board"]});return}if(n.error==="geen_koppeling"){K.error("Je account is niet aan een monteursprofiel gekoppeld · meld dit bij kantoor");return}K.warning("Deze aanvraag is net al opgepakt of ingepland · ververs de lijst")},onError:n=>{if(n.message.includes(oX)){K.info("Vorige poging wordt nog verwerkt · wacht even en probeer opnieuw");return}K.error("Oppakken mislukt · probeer het opnieuw")}})}function cX(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function bO(e){return e?e.slice(0,5):null}function uX(e){var t,n;return{entryId:e.entry_id,projectId:e.project_id,date:e.scheduled_date,title:((t=e.project_title)==null?void 0:t.trim())||((n=e.project_name)==null?void 0:n.trim())||"Opdracht",customerName:e.customer_name||null,customerCity:e.customer_city||null,slotNumber:e.slot_number??null,vehicleName:e.vehicle_name||null,teamNames:cX(e.team_names),classificationKey:e.classification_key||null,isMine:e.is_mine===!0,startTime:bO(e.start_time),plannedHours:null}}function dX(e){var t;return{entryId:e.entry_id,projectId:e.id,date:e.scheduled_date,title:((t=e.name)==null?void 0:t.trim())||"Opdracht",customerName:e.customer_name||null,customerCity:e.customer_city||null,slotNumber:e.slot_number??null,vehicleName:e.vehicle_name||null,teamNames:(e.team_members||[]).map(n=>n.name).filter(Boolean),classificationKey:e.customer_classification||null,isMine:!0,startTime:bO(e.start_time),plannedHours:e.planned_hours??null}}async function fX(e,t){const n=B,{data:r,error:s}=await n.rpc("get_planner_range_board",{p_start:e,p_end:t});if(s)throw new Error(s.message||"get_planner_range_board faalde");return(r??[]).map(uX)}function hX(e,t,n){const{initialized:r,session:s}=Ht();return xt({queryKey:["planner-range-board",e,t,n],queryFn:()=>fX(t,n),enabled:!!e&&r&&!!s,staleTime:1e3*60*2,retry:!1})}function mX(e){return e?e.slice(0,5):null}function pX(e){var t,n,r;return{entryId:e.entry_id,date:e.scheduled_date,startTime:mX(e.start_time),plannedHours:typeof e.planned_hours=="number"?e.planned_hours:null,slotNumber:typeof e.slot_number=="number"?e.slot_number:null,title:((t=e.project_title)==null?void 0:t.trim())||((n=e.project_name)==null?void 0:n.trim())||"Opdracht",projectType:e.project_type||null,classificationKey:e.classification_key||null,description:(r=e.description)!=null&&r.trim()?e.description:null,customerName:e.customer_name||null,customerPhone:e.customer_phone||null,customerAddress:e.customer_address||null,customerCity:e.customer_city||null,customerPostalCode:e.customer_postal_code||null,status:e.status||null,teamNames:Array.isArray(e.team_names)?e.team_names.filter(s=>typeof s=="string"&&s.trim().length>0):[],vehicleName:e.vehicle_name||null,vehicleLicensePlate:e.vehicle_license_plate||null}}function gX(e){const{initialized:t,session:n}=Ht();return xt({queryKey:["colleague-entry-brief",e],queryFn:async()=>{const r=B,{data:s,error:a}=await r.rpc("get_colleague_entry_brief",{p_entry_id:e});if(a)throw new Error(a.message||"get_colleague_entry_brief faalde");const o=(s??[])[0];return o?pX(o):null},enabled:!!e&&t&&!!n,staleTime:1e3*60,retry:!1})}function _O(e,t){return Id(e,t)}const yX={installation:"Installatie",maintenance:"Onderhoud",repair:"Reparatie",inspection:"Inspectie",consultation:"Advies",other:"Overig"},vX={planned:"Gepland",todo:"Te doen",onderweg:"Onderweg",ter_plaatse:"Ter plaatse",in_progress:"Bezig",material_needed:"Materiaal nodig",problem:"Probleem",completed:"Afgerond"};function nu({title:e,icon:t,children:n}){return i.jsxs("div",{className:"space-y-3 rounded-xl border bg-card p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium uppercase tracking-wide text-muted-foreground",children:[t,e]}),n]})}function xX({entryId:e,organizationId:t,isOpen:n,onClose:r}){const{data:s,isLoading:a,isError:o}=gX(n?e:null),{isVisible:l,loading:c}=_b(t),u=l("details"),d=s!=null&&s.projectType?yX[s.projectType]||s.projectType:null,f=s!=null&&s.status?vX[s.status]||s.status:null,h=[d,f].filter(Boolean).join(" | "),m=s!=null&&s.date?he(mn(s.date),"EEEE d MMMM yyyy",{locale:tt}):null,v=_O(s==null?void 0:s.startTime,s==null?void 0:s.plannedHours),w=[s==null?void 0:s.customerPostalCode,s==null?void 0:s.customerCity].filter(Boolean).join(" ");return i.jsx(Wd,{open:n,onOpenChange:y=>!y&&r(),children:i.jsxs(Dc,{side:"bottom",className:"max-h-[90vh] h-[90dvh] max-w-full overflow-y-auto rounded-t-xl px-4 sm:px-6",children:[i.jsx(Ic,{className:"pb-4 text-left",children:i.jsxs(Lc,{className:"flex items-center gap-2",children:[i.jsx(Ym,{className:"h-5 w-5"}),"Opdracht van een collega"]})}),a||c?i.jsxs("div",{className:"space-y-3 pb-24",children:[i.jsx(Dt,{className:"h-6 w-2/3"}),i.jsx(Dt,{className:"h-24 w-full rounded-xl"}),i.jsx(Dt,{className:"h-24 w-full rounded-xl"})]}):o?i.jsxs("div",{className:"px-2 py-10 text-center",children:[i.jsx(Vr,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground/50"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"De opdracht kon niet geladen worden. Probeer het zo nog eens."})]}):s?i.jsxs("div",{className:"space-y-4 pb-24",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("h2",{className:"text-lg font-semibold",children:s.title}),h&&i.jsx("p",{className:"text-xs text-muted-foreground",children:h}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"Je kijkt mee met een collega. Alleen lezen."})]}),!u&&i.jsx("p",{className:"rounded-md bg-muted/50 px-3 py-2 text-xs text-muted-foreground",children:"Deze organisatie toont de gegevens van een opdracht niet in de app."}),u&&(m||v)&&i.jsx(nu,{title:"Planning",icon:i.jsx(Wt,{className:"h-4 w-4",strokeWidth:1.5}),children:i.jsxs("div",{className:"space-y-1.5 text-sm",children:[m&&i.jsx("p",{className:"font-medium capitalize text-foreground",children:m}),v&&i.jsx("p",{className:"text-muted-foreground",children:v})]})}),u&&i.jsx(nu,{title:"Klant",icon:i.jsx(vr,{className:"h-4 w-4",strokeWidth:1.5}),children:i.jsxs("div",{className:"space-y-1.5",children:[s.customerName?i.jsx("p",{className:"font-medium text-foreground",children:s.customerName}):i.jsx("p",{className:"text-sm text-muted-foreground",children:"Geen klantnaam bekend"}),s.customerPhone&&i.jsx("a",{href:`tel:${s.customerPhone}`,className:"block text-sm text-muted-foreground hover:underline",children:s.customerPhone}),(s.customerAddress||w)&&i.jsxs("div",{className:"flex items-start gap-1.5 text-sm text-muted-foreground",children:[i.jsx(xo,{className:"mt-0.5 h-4 w-4 shrink-0",strokeWidth:1.5}),i.jsxs("span",{children:[s.customerAddress&&i.jsx("span",{className:"block",children:s.customerAddress}),w&&i.jsx("span",{className:"block",children:w})]})]})]})}),u&&s.teamNames.length>0&&i.jsx(nu,{title:"Team",icon:i.jsx(Wr,{className:"h-4 w-4",strokeWidth:1.5}),children:i.jsx("p",{className:"text-sm text-foreground",children:s.teamNames.join(" | ")})}),u&&s.vehicleName&&i.jsx(nu,{title:"Bus",icon:i.jsx(wl,{className:"h-4 w-4",strokeWidth:1.5}),children:i.jsxs("p",{className:"text-sm text-foreground",children:[s.vehicleName,s.vehicleLicensePlate&&i.jsxs("span",{className:"text-muted-foreground",children:[" | ",s.vehicleLicensePlate]})]})}),u&&s.description&&i.jsx(nu,{title:"Omschrijving",icon:i.jsx(Eu,{className:"h-4 w-4",strokeWidth:1.5}),children:i.jsx("p",{className:"whitespace-pre-wrap text-sm text-foreground",children:s.description})})]}):i.jsxs("div",{className:"px-2 py-10 text-center",children:[i.jsx(B5,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground/50"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Deze opdracht is niet voor jou opengesteld."})]})]})})}const wX="al verwerkt of nog in behandeling",bX="staff-eigen-opdracht",_X={geen_koppeling:"Je account is niet aan een monteursprofiel gekoppeld · meld dit bij kantoor",geen_titel:"Vul in wat er moet gebeuren",datum_buiten_bereik:"Kies een dag binnen het komende jaar",uren_buiten_bereik:"Vul een tijdsduur tussen een kwartier en 24 uur in",te_veel:"Je hebt vandaag al veel opdrachten aangemaakt · overleg met kantoor"};function kX(e){const t=Ge();return Ke({mutationFn:async n=>{if(!e)throw new Error("Geen organisatie bekend");await Je({organizationId:e,scope:bX,key:`${n.date}:${n.title.trim().toLowerCase()}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const r=B,{data:s,error:a}=await r.rpc("create_staff_internal_project",{p_title:n.title,p_description:n.description,p_date:n.date,p_hours:n.hours,p_start_time:n.startTime});if(a||!s)throw new Error("Opslaan mislukt");return s},onSuccess:n=>{if(n.ok){K.success("Opdracht staat in je agenda"),t.invalidateQueries({queryKey:["planner-range-board"]}),t.invalidateQueries({queryKey:["staff-projects"]}),t.invalidateQueries({queryKey:["planner-day-board"]});return}K.warning(_X[n.error??""]??"Opslaan lukte niet · controleer de gegevens")},onError:n=>{if(n.message.includes(wX)){K.info("Vorige poging wordt nog verwerkt · wacht even en probeer opnieuw");return}K.error("Opslaan mislukt · probeer het opnieuw")}})}const jX="08:00",rS=2;function SX({isOpen:e,onClose:t,defaultDate:n,onCreated:r}){const{organization:s}=zt(),{getSetting:a}=Hd(s==null?void 0:s.id),o=kX(s==null?void 0:s.id),l=(a("planner_mode")??"time")==="time",c=a("work_start_time")||jX,[u,d]=p.useState(""),[f,h]=p.useState(""),[m,v]=p.useState(n),[w,y]=p.useState(c),[x,g]=p.useState(String(rS));p.useEffect(()=>{e&&(d(""),h(""),v(n),y(c),g(String(rS)))},[e,n,c]);const b=Number(x.replace(",",".")),_=Number.isFinite(b)&&b>=.25&&b<=24,j=u.trim().length>0&&m.length>0&&_&&!o.isPending,k=()=>{j&&o.mutate({title:u.trim(),description:f.trim()||null,date:m,hours:b,startTime:l&&w||null},{onSuccess:S=>{S.ok&&(r(S.scheduled_date??m),t())}})};return i.jsx(Wd,{open:e,onOpenChange:S=>{S||t()},children:i.jsxs(Dc,{side:"bottom",className:"max-h-[90vh] overflow-y-auto rounded-t-xl px-4 pb-6 sm:px-6",children:[i.jsxs(Ic,{className:"text-left",children:[i.jsx(Lc,{children:"Zelf iets in de agenda zetten"}),i.jsx(yb,{children:"Dit wordt een interne opdracht op jouw naam. Zonder klant · de planner ziet hem op het planbord staan."})]}),i.jsxs("div",{className:"mt-4 space-y-4",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Tt,{htmlFor:"staff-project-title",children:"Wat moet er gebeuren?"}),i.jsx(ot,{id:"staff-project-title",value:u,onChange:S=>d(S.target.value),maxLength:120,placeholder:"Bijvoorbeeld: bus inruimen voor maandag",autoComplete:"off"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Tt,{htmlFor:"staff-project-description",children:"Toelichting"}),i.jsx(Di,{id:"staff-project-description",value:f,onChange:S=>h(S.target.value),maxLength:2e3,rows:3,placeholder:"Niet verplicht"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(Tt,{htmlFor:"staff-project-date",children:"Welke dag"}),i.jsx(ot,{id:"staff-project-date",type:"date",value:m,onChange:S=>v(S.target.value)}),m&&i.jsx("p",{className:"text-xs text-muted-foreground first-letter:uppercase",children:he(mn(m),"EEEE d MMMM yyyy",{locale:tt})})]}),i.jsxs("div",{className:"flex gap-3",children:[l&&i.jsxs("div",{className:"flex-1 space-y-1.5",children:[i.jsx(Tt,{htmlFor:"staff-project-time",children:"Vanaf"}),i.jsx(ot,{id:"staff-project-time",type:"time",value:w,onChange:S=>y(S.target.value)})]}),i.jsxs("div",{className:"flex-1 space-y-1.5",children:[i.jsx(Tt,{htmlFor:"staff-project-hours",children:"Hoe lang (uur)"}),i.jsx(ot,{id:"staff-project-hours",type:"number",inputMode:"decimal",step:"0.5",min:"0.25",max:"24",value:x,onChange:S=>g(S.target.value)})]})]}),i.jsxs("div",{className:"flex gap-2 pt-1",children:[i.jsx(ne,{variant:"outline",className:"flex-1",onClick:t,disabled:o.isPending,children:"Annuleren"}),i.jsx(ne,{className:"flex-1",onClick:k,disabled:!j,children:o.isPending?i.jsxs(i.Fragment,{children:[i.jsx(yn,{className:"mr-2 h-4 w-4 animate-spin"}),"Bezig…"]}):"In de agenda zetten"})]})]})]})})}function EX({label:e,onToday:t,onlyMine:n,onOnlyMineChange:r,isFetching:s,onRefresh:a}){return i.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",children:[i.jsx("span",{className:"min-w-0 flex-1 truncate text-base font-semibold first-letter:uppercase",children:e}),i.jsx(ne,{variant:n?"default":"outline",size:"sm",className:"h-8 shrink-0 px-2.5 text-xs",onClick:()=>r(!n),"aria-pressed":n,children:"Alleen ik"}),i.jsx(ne,{variant:"ghost",size:"sm",className:"h-8 shrink-0 px-2.5 text-xs",onClick:t,children:"Vandaag"}),i.jsx(ne,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:a,disabled:s,"aria-label":"Vernieuwen",children:i.jsx(qs,{className:Y("h-4 w-4",s&&"animate-spin")})})]})}function NX({entry:e,color:t,onOpen:n}){const r=!!n,s=e.vehicleName||(e.slotNumber!==null?`Slot ${e.slotNumber}`:null),a=[e.customerCity,s].filter(Boolean).join(" · "),o=e.teamNames.join(", "),l=_O(e.startTime,e.plannedHours),c=l===e.startTime?null:l,u=r?"button":"div";return i.jsxs(u,{type:r?"button":void 0,onClick:n,className:Y("flex w-full gap-3 rounded-lg border border-border/60 bg-card px-3 py-2 text-left transition-colors",e.isMine&&"border-primary/30 bg-primary/[0.03]",r&&"active:scale-[0.99] hover:bg-muted/40"),children:[i.jsxs("div",{className:"w-11 shrink-0 pt-0.5",children:[i.jsx("span",{className:"block text-sm font-medium tabular-nums leading-none",children:e.startTime??i.jsx("span",{className:"text-muted-foreground/40",children:"··"})}),i.jsx("span",{className:Y("mt-1.5 block h-[3px] w-7 rounded-full",!t.color&&"bg-muted-foreground/25"),style:t.color?{backgroundColor:t.color}:void 0,"aria-hidden":"true"})]}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"truncate text-sm font-medium",children:e.customerName||e.title}),a&&i.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:a}),o&&i.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:o}),c&&i.jsx("p",{className:"mt-1 text-xs tabular-nums text-muted-foreground/70",children:c})]}),i.jsxs("div",{className:"flex shrink-0 items-start gap-1.5 pt-0.5",children:[e.taskId&&i.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:"taak"}),e.isMine&&i.jsx("span",{className:"rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:"jij"}),r&&i.jsx(Gm,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"})]}),t.label&&i.jsxs("span",{className:"sr-only",children:["Classificatie: ",t.label]})]})}function CX(e,t={}){return e.taskId?e.isMine||!!t.canOpenTasks:e.isMine||!!t.canOpenProjects||!!t.canOpenColleagueBrief}function TX({day:e,entries:t,todayStr:n,onlyMine:r,resolveColor:s,onOpen:a,canOpenTasks:o=!1,canOpenProjects:l=!1,canOpenColleagueBrief:c=!1}){const u=mn(e),d=e===n,f=t.filter(v=>v.taskId).length,h=t.length-f,m=[h>0?`${h} ${h===1?"opdracht":"opdrachten"}`:null,f>0?`${f} ${f===1?"taak":"taken"}`:null].filter(Boolean).join(", ");return i.jsxs("div",{className:"pb-6",children:[i.jsxs("div",{className:"sticky top-0 z-10 flex items-baseline gap-2 bg-background px-4 pb-2 pt-3",children:[i.jsx("span",{className:Y("text-3xl font-semibold leading-none",d&&"text-primary"),children:he(u,"d")}),i.jsx("span",{className:"text-sm font-medium uppercase text-muted-foreground",children:he(u,"EEEEEE",{locale:tt})}),i.jsx("span",{className:"text-sm text-muted-foreground",children:he(u,"MMMM",{locale:tt})}),d&&i.jsx("span",{className:"text-xs font-medium text-primary",children:"vandaag"}),i.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:m})]}),t.length===0?i.jsxs("div",{className:"px-4 py-10 text-center",children:[i.jsx(Pv,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground/40"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:r?"Niets van jezelf op deze dag":"Niets op deze dag"})]}):i.jsx("div",{className:"space-y-2 px-4",children:t.map(v=>i.jsx(NX,{entry:v,color:s(v.classificationKey),onOpen:CX(v,{canOpenTasks:o,canOpenProjects:l,canOpenColleagueBrief:c})?()=>a(v):void 0},v.entryId))})]})}const PX=["ma","di","wo","do","vr","za","zo"],wy=58,AX=18,by=3;function RX({weeks:e,entriesByDate:t,selected:n,todayStr:r,month:s,scope:a,resolveColor:o,onSelectDay:l}){const c=Math.max(0,e.findIndex(h=>h.includes(n))),d=(a==="month"?e.length:a==="week"?1:0)*wy,f=a==="month"?0:c*wy;return i.jsxs("div",{className:"select-none px-2",children:[i.jsx("div",{className:"overflow-hidden transition-[height] duration-300 ease-out",style:{height:a==="day"?0:AX},children:i.jsxs("div",{className:"flex",children:[i.jsx("span",{className:"w-5 shrink-0","aria-hidden":"true"}),i.jsx("div",{className:"grid flex-1 grid-cols-7",children:PX.map(h=>i.jsx("div",{className:"text-center text-[11px] text-muted-foreground",children:h},h))})]})}),i.jsx("div",{className:"overflow-hidden transition-[height] duration-300 ease-out",style:{height:d},children:i.jsx("div",{className:"transition-transform duration-300 ease-out",style:{transform:`translateY(-${f}px)`},children:e.map(h=>i.jsxs("div",{className:"flex",style:{height:wy},children:[i.jsx("span",{className:"flex w-5 shrink-0 items-start justify-center pt-1 text-[10px] text-muted-foreground/70",children:Od(mn(h[0]))}),i.jsx("div",{className:"grid flex-1 grid-cols-7",children:h.map(m=>i.jsx(OX,{day:m,entries:t.get(m)??[],isSelected:m===n,isToday:m===r,inMonth:vp(mn(m),s),resolveColor:o,onSelect:l},m))})]},h[0]))})})]})}function OX({day:e,entries:t,isSelected:n,isToday:r,inMonth:s,resolveColor:a,onSelect:o}){const l=mn(e),c=t.filter(f=>f.taskId).length,u=t.length-c,d=[u>0?`${u} ${u===1?"opdracht":"opdrachten"}`:null,c>0?`${c} ${c===1?"taak":"taken"}`:null].filter(Boolean).join(", ")||"niets";return i.jsxs("button",{type:"button",onClick:()=>o(e),className:Y("mx-[1px] flex flex-col items-center rounded-lg px-0.5 pt-1 transition-colors",n&&"bg-muted ring-1 ring-foreground/25"),"aria-label":`${he(l,"EEEE d MMMM",{locale:tt})}, ${d}`,"aria-current":n?"date":void 0,children:[i.jsx("span",{className:Y("text-[13px] leading-none",s?"text-foreground":"text-muted-foreground/50",r&&"font-semibold text-primary"),children:he(l,"d")}),i.jsxs("span",{className:"mt-1.5 flex w-full flex-col items-stretch gap-[2px] overflow-hidden",children:[t.slice(0,by).map(f=>{const{color:h}=a(f.classificationKey);return i.jsx("span",{className:Y("h-[5px] shrink-0 rounded-sm",!h&&"bg-muted-foreground/30",f.isMine&&"ring-1 ring-primary/50"),style:h?{backgroundColor:h}:void 0},f.entryId)}),t.length>by&&i.jsxs("span",{className:"text-[9px] leading-none text-muted-foreground",children:["+",t.length-by]})]})]})}const MX=56,DX=36;function sS({onSwipe:e,allowVertical:t}){const n=p.useRef(null),r=p.useRef(!0),s=()=>{n.current=null};return{onTouchStart:a=>{if(a.touches.length!==1){s();return}const o=a.touches[0];n.current={x:o.clientX,y:o.clientY},r.current=t?t():!0},onTouchMove:a=>{a.touches.length!==1&&s()},onTouchEnd:a=>{const o=n.current;if(s(),!o)return;const l=a.changedTouches[0];if(!l)return;const c=l.clientX-o.x,u=l.clientY-o.y;if(Math.abs(c)>=Math.abs(u)){if(Math.abs(c){const r=t(n);return r?{color:r.color,label:r.label}:{color:null,label:null}},[t])}function LX(e,t){return e.filter(n=>!!n.planned_start_at).map(n=>{var l;const r=mn(n.planned_start_at),s=n.planned_end_at?mn(n.planned_end_at):null;let a=null;if(s){const c=(s.getTime()-r.getTime())/36e5;c>0&&c<=24&&(a=c)}const o=(n.staff_members??[]).map(c=>c==null?void 0:c.name).filter(c=>!!(c&&c.trim()));return{entryId:`taak-${n.id}`,projectId:n.id,date:he(r,"yyyy-MM-dd"),title:((l=n.title)==null?void 0:l.trim())||"Taak",customerName:null,customerCity:null,slotNumber:null,vehicleName:null,teamNames:o,classificationKey:null,isMine:(n.staff_members??[]).some(c=>(c==null?void 0:c.id)&&t.has(c.id)),startTime:he(r,"HH:mm"),plannedHours:a,taskId:n.id}})}function $X(e,t){return e.startTime&&t.startTime?e.startTimet.startTime?1:0:e.startTime?-1:t.startTime?1:0}const rae=["weekly","biweekly","monthly"],aS=200,sae={weekly:"Elke week",biweekly:"Om de week",monthly:"Elke maand"};function oS(e){return uA(`${e} 12:00`,"yyyy-MM-dd HH:mm",new Date)}function FX(e,t,n){if(!t||!n)return{dates:[e],capped:!1};const r=oS(e),s=oS(n);if(st==="weekly"?mt(r,l*7):t==="biweekly"?mt(r,l*14):Pr(r,l),o=[];for(let l=0;ls)return{dates:o,capped:!1};o.push(he(c,"yyyy-MM-dd"))}return{dates:o,capped:a(aS)<=s}}function zX(e){return/^([01]\d|2[0-3]):[0-5]\d$/.test(e)}function kO(e){if(!zX(e.startTime))throw new Error("Vul een geldige starttijd in, bijvoorbeeld 09:00.");const{dates:t,capped:n}=FX(e.startDate,e.rule,e.until),r=Math.max(e.durationMinutes,1);return{occurrences:t.map(a=>{const o=uA(`${a} ${e.startTime}`,"yyyy-MM-dd HH:mm",new Date),l=new Date(o.getTime()+r*6e4);return{date:a,plannedStartAt:o.toISOString(),plannedEndAt:l.toISOString()}}),capped:n}}function aae(e,t){if(!e||!t)return 60;const n=(new Date(t).getTime()-new Date(e).getTime())/6e4;return n>0?Math.round(n):60}function oae(e,t){if(!e||!t)return 0;const n=(new Date(t).getTime()-new Date(e).getTime())/36e5;return n>0?n:0}const jO="id, organization_id, title, description, owner_user_id, status, priority, task_category, counts_as_busy, deadline_at, planned_start_at, planned_end_at, recurrence_group_id, recurrence_rule, recurrence_until, created_by, created_at, updated_at",BX="task_staff(staff:staff_id(id, name, avatar_url))",Ob=`${jO}, ${BX}`,ur=B;function UX(e){const{task_staff:t,...n}=e,r=(t??[]).map(s=>(s==null?void 0:s.staff)??null).filter(s=>s!==null);return{...n,staff_members:r}}function Mb(e){return(e??[]).map(UX)}function iae(e={}){const{organization:t}=zt(),n=Ge(),r=t==null?void 0:t.id,{data:s,isLoading:a}=xt({queryKey:["tasks",r,e],queryFn:async()=>{var d;if(!r)return[];const o=e.staffId?`${jO}, task_staff!inner(staff:staff_id(id, name, avatar_url))`:Ob;let l=ur.from("tasks").select(o).eq("organization_id",r).order("priority",{ascending:!0}).order("deadline_at",{ascending:!0,nullsFirst:!1}).limit(500);(d=e.statusFilter)!=null&&d.length&&(l=l.in("status",e.statusFilter)),e.staffId&&(l=l.eq("task_staff.staff_id",e.staffId)),e.dateFrom&&(l=l.gte("planned_start_at",e.dateFrom)),e.dateTo&&(l=l.lte("planned_start_at",e.dateTo));const{data:c,error:u}=await l;if(u)throw u;return Mb(c)},enabled:!!r});return p.useEffect(()=>{if(!r)return;const o=B.channel(`tasks-${r}`).on("postgres_changes",{event:"*",schema:"public",table:"tasks",filter:`organization_id=eq.${r}`},()=>{n.invalidateQueries({queryKey:["tasks",r]})}).subscribe();return()=>{B.removeChannel(o)}},[r,n]),{tasks:s||[],isLoading:a}}function Rp(e){e.invalidateQueries({queryKey:["tasks"]}),e.invalidateQueries({queryKey:["tasks-backlog"]}),e.invalidateQueries({queryKey:["planned-tasks"]}),e.invalidateQueries({queryKey:["todo-tasks-sidebar"]})}async function VX(e,t,n){if(t.length===0||n.length===0)return;const r=t.flatMap(a=>n.map(o=>({organization_id:e,task_id:a,staff_id:o}))),{error:s}=await ur.from("task_staff").insert(r.map(a=>({...a,organization_id:e})));if(s)throw s}function lae(){const{organization:e}=zt(),t=Ge();return Ke({mutationFn:async n=>{if(!(e!=null&&e.id))throw new Error("No organization");const{data:{user:r}}=await B.auth.getUser();await Je({organizationId:e.id,scope:"task-create",key:`${e.id}:${(r==null?void 0:r.id)??"anon"}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const s=n.planning??null,a=s?kO({startDate:s.startDate,startTime:s.startTime,durationMinutes:s.durationMinutes,rule:s.recurrenceRule,until:s.recurrenceUntil}):{occurrences:[],capped:!1},o=!!(s!=null&&s.recurrenceRule)&&a.occurrences.length>1,l=o?crypto.randomUUID():null,c={organization_id:e.id,title:n.title,description:n.description||null,priority:n.priority||"normal",task_category:n.taskCategory||"zakelijk",counts_as_busy:n.countsAsBusy??!0,deadline_at:n.deadline_at||null,owner_user_id:r==null?void 0:r.id,created_by:r==null?void 0:r.id,status:"todo",recurrence_group_id:l,recurrence_rule:o?s.recurrenceRule:null,recurrence_until:o?s.recurrenceUntil:null},u=a.occurrences.length>0?a.occurrences.map(m=>({...c,planned_start_at:m.plannedStartAt,planned_end_at:m.plannedEndAt})):[{...c,planned_start_at:null,planned_end_at:null}],{data:d,error:f}=await ur.from("tasks").insert(u.map(m=>({...m,organization_id:e.id}))).select("id");if(f)throw f;const h=(d??[]).map(m=>m.id);try{await VX(e.id,h,n.staffIds??[])}catch(m){const v=m instanceof Error?m.message:"onbekende fout";throw new Error(`De taak is aangemaakt, maar het koppelen van medewerkers mislukte (${v}). Open de taak en zet de medewerkers erop.`)}return{ids:h,capped:a.capped}},onSuccess:()=>{Rp(t)}})}function cae(){const{organization:e}=zt(),t=Ge();return Ke({mutationFn:async n=>{const r=e==null?void 0:e.id;if(!r)throw new Error("No organization");const{id:s,scope:a="single",recurrenceGroupId:o,planning:l,staffIds:c,...u}=n,{data:{user:d}}=await B.auth.getUser();await Je({organizationId:r,scope:"task-update",key:`${s}:${(d==null?void 0:d.id)??"anon"}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const f={};u.title!==void 0&&(f.title=u.title),u.description!==void 0&&(f.description=u.description),u.priority!==void 0&&(f.priority=u.priority),u.taskCategory!==void 0&&(f.task_category=u.taskCategory),u.countsAsBusy!==void 0&&(f.counts_as_busy=u.countsAsBusy),u.status!==void 0&&(f.status=u.status),u.deadline_at!==void 0&&(f.deadline_at=u.deadline_at);const h=[];if(a==="series"&&o){if(Object.keys(f).length>0){const{error:y}=await ur.from("tasks").update(f).eq("organization_id",r).eq("recurrence_group_id",o);if(y)throw y}const{data:m,error:v}=await ur.from("tasks").select("id, planned_start_at").eq("organization_id",r).eq("recurrence_group_id",o);if(v)throw v;const w=m??[];if(h.push(...w.map(y=>y.id)),l){const y=w.filter(g=>g.planned_start_at).map(g=>{const b=new Date(g.planned_start_at),[_,j]=l.startTime.split(":").map(Number),k=new Date(b.getFullYear(),b.getMonth(),b.getDate(),_,j),S=new Date(k.getTime()+Math.max(l.durationMinutes,1)*6e4);return{id:g.id,start:k.toISOString(),end:S.toISOString()}});let x=0;for(let g=0;gur.from("tasks").update({planned_start_at:k.start,planned_end_at:k.end}).eq("organization_id",r).eq("id",k.id)));x+=_.filter(k=>!k.error).length;const j=_.find(k=>k.error);if(j!=null&&j.error)throw new Error(`De tijd is bij ${x} van de ${y.length} keren aangepast; de rest staat nog op de oude tijd. Sla nog een keer op om het af te maken.`)}}else if(l===null){const{error:y}=await ur.from("tasks").update({planned_start_at:null,planned_end_at:null}).eq("organization_id",r).eq("recurrence_group_id",o);if(y)throw y}}else{if(l){const m=kO({startDate:l.startDate,startTime:l.startTime,durationMinutes:l.durationMinutes,rule:null,until:null});f.planned_start_at=m.occurrences[0].plannedStartAt,f.planned_end_at=m.occurrences[0].plannedEndAt}else l===null&&(f.planned_start_at=null,f.planned_end_at=null);if(Object.keys(f).length>0){const{error:m}=await ur.from("tasks").update(f).eq("organization_id",r).eq("id",s);if(m)throw m}}if(c){const m=a==="series"&&h.length>0?h:[s];if(c.length>0){const y=m.flatMap(g=>c.map(b=>({organization_id:r,task_id:g,staff_id:b}))),{error:x}=await ur.from("task_staff").upsert(y.map(g=>({...g,organization_id:r})),{onConflict:"task_id,staff_id",ignoreDuplicates:!0});if(x)throw x}let v=ur.from("task_staff").delete().eq("organization_id",r).in("task_id",m);c.length>0&&(v=v.not("staff_id","in",`(${c.map(y=>`"${y}"`).join(",")})`));const{error:w}=await v;if(w)throw w}},onSuccess:()=>{Rp(t)}})}function uae(){const{organization:e}=zt(),t=Ge();return Ke({mutationFn:async({id:n,scope:r="single",recurrenceGroupId:s})=>{const a=e==null?void 0:e.id;if(!a)throw new Error("No organization");await Je({organizationId:a,scope:"task-delete",key:`${n}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});let o=ur.from("tasks").delete().eq("organization_id",a);o=r==="series"&&s?o.eq("recurrence_group_id",s):o.eq("id",n);const{error:l}=await o;if(l)throw l},onSuccess:()=>{Rp(t)}})}function dae(){const{organization:e}=zt(),t=Ge();return Ke({mutationFn:async({taskId:n,staffId:r})=>{const s=e==null?void 0:e.id;if(!s)throw new Error("No organization");await Je({organizationId:s,scope:"task-staff-assign",key:`${n}:${r}:${Math.floor(Date.now()/2e3)}`,ttlSeconds:30});const{error:a}=await ur.from("task_staff").insert({organization_id:s,task_id:n,staff_id:r});if(a)throw a.code==="23505"?new Error("Medewerker staat al op deze taak"):new Error("Kon de medewerker niet op deze taak zetten. Ververs de planner en probeer opnieuw.")},onSuccess:()=>{Rp(t)}})}function fae(){const{organization:e}=zt(),t=e==null?void 0:e.id;return xt({queryKey:["tasks-backlog",t],queryFn:async()=>{if(!t)return[];const n=new Date().toISOString(),{data:r,error:s}=await ur.from("tasks").select(Ob).eq("organization_id",t).in("status",["todo","in_progress"]).is("planned_start_at",null).not("deadline_at","is",null).lte("deadline_at",n).order("deadline_at",{ascending:!0}).order("priority",{ascending:!0}).limit(200);if(s)throw s;return Mb(r)},enabled:!!t})}function WX(e,t,n){return xt({queryKey:["planned-tasks",e,t,n],queryFn:async()=>{if(!e)return[];const r=he(mt(mn(t),-1),"yyyy-MM-dd"),s=he(mt(mn(n),1),"yyyy-MM-dd"),{data:a,error:o}=await ur.from("tasks").select(Ob).eq("organization_id",e).not("planned_start_at","is",null).gte("planned_start_at",`${r}T00:00:00`).lte("planned_start_at",`${s}T23:59:59`).neq("status","cancelled").order("planned_start_at",{ascending:!0}).limit(500);if(o)throw o;return Mb(a)},enabled:!!e})}function HX(e){if(!e||e.length===0)return{mode:"none",targetIds:new Set,hasAny:!1};if(e.some(n=>n.target_staff_id===null))return{mode:"all",targetIds:new Set,hasAny:!0};const t=new Set(e.map(n=>n.target_staff_id).filter(n=>typeof n=="string"&&n.length>0));return t.size===0?{mode:"none",targetIds:new Set,hasAny:!1}:{mode:"some",targetIds:t,hasAny:!0}}function hae(e,t){const n=e??[],r=n.filter(u=>u.target_staff_id===null),s=n.filter(u=>u.target_staff_id!==null);if(t.mode==="none")return{deleteIds:n.map(u=>u.id),insertTargets:[]};if(t.mode==="all")return{deleteIds:s.map(u=>u.id),insertTargets:r.length>0?[]:[null]};const a=new Set(t.targetIds.filter(u=>typeof u=="string"&&u.length>0)),o=new Set,l=[...r.map(u=>u.id)];for(const u of s){const d=u.target_staff_id;if(a.has(d)&&!o.has(d)){o.add(d);continue}l.push(u.id)}const c=[...a].filter(u=>!o.has(u));return{deleteIds:l,insertTargets:c}}function mae(e){return e.deleteIds.length===0&&e.insertTargets.length===0}const qX={mode:"none",targetIds:new Set,hasAny:!1};function KX(e,t,n){const{initialized:r,session:s}=Ht(),a=(n==null?void 0:n.enabled)!==!1,{data:o,isLoading:l}=xp(a?e:void 0,t),c=xt({queryKey:["agenda-open-rights",o,t],queryFn:async()=>{try{const{data:d,error:f}=await B.from("staff_agenda_access").select("id, target_staff_id").eq("staff_id",o).eq("organization_id",t).limit(500);return f?[]:d??[]}catch{return[]}},enabled:a&&!!o&&!!t&&r&&!!s,staleTime:5*60*1e3,retry:!1});return{rights:p.useMemo(()=>a?HX(c.data):qX,[a,c.data]),isLoading:a&&(l||c.isLoading)}}const qf={weekStartsOn:1};function Db(e,t){switch(e){case"day":return{start:t,end:t};case"week":return{start:Pn(t,qf),end:ko(t,qf)};case"month":return{start:Pn(Yn(t),qf),end:ko(gp(t),qf)}}}function iS(e){return e==="month"?"month":"day"}function SO(e,t,n){switch(e){case"day":return mt(t,n);case"week":return mt(t,n*7);case"month":return Pr(t,n)}}function Ib(e){return{start:mt(e,-365),end:mt(e,365)}}function GX(e,t,n=new Date){const r=Ib(n);return{start:er.end?r.end:t}}function YX(e,t,n,r=new Date){const{start:s,end:a}=Db(e,SO(e,t,n)),o=Ib(r);return s<=o.end&&a>=o.start}function lS(e,t,n,r=new Date){return YX(e,t,n,r)?SO(e,t,n):t}function cS(e,t=new Date){const n=Ib(t);return en.end?n.end:e}function QX(e,t){switch(e){case"day":return he(t,"EEEEEE d MMM",{locale:tt});case"week":return`week ${Od(t)} · ${he(t,"RRRR")}`;case"month":return he(t,"MMMM yyyy",{locale:tt})}}function XX(e){const{start:t,end:n}=Db("month",e),r=ZX(t,n),s=[];for(let a=0;anew Date),[v,w]=p.useState(!1),[y,x]=p.useState(null),[g,b]=p.useState(null),[_,j]=p.useState(!1),k=p.useRef(null),S=p.useMemo(()=>Kf(new Date),[]),E=Kf(h),N=p.useMemo(()=>XX(h),[h]),O=p.useMemo(()=>Db("month",h),[h]),z=p.useMemo(()=>GX(O.start,O.end),[O]),T=Kf(z.start),I=Kf(z.end),P=hX(e,T,I),H=rb(e,{includePast:!0}),{organization:V}=zt(),M=WX(s?V==null?void 0:V.id:null,T,I),C=!o,{rights:F}=KX(e,V==null?void 0:V.id,{enabled:C}),W=C&&F.hasAny,ie=P.isError,oe=P.isLoading||H.isLoading,ce=P.isFetching||H.isFetching||M.isFetching,re=P.isError&&H.isError,ue=p.useMemo(()=>H.data?[...H.data.today,...H.data.thisWeek,...H.data.upcoming]:[],[H.data]),ke=p.useMemo(()=>{const G=new Map;return ue.forEach(U=>{typeof U.planned_hours=="number"&&G.set(U.entry_id,U.planned_hours)}),G},[ue]),L=p.useMemo(()=>!ie&&P.data?P.data.map(G=>{if(!G.isMine)return G;const U=ke.get(G.entryId);return U===void 0?G:{...G,plannedHours:U}}):ie?ue.filter(G=>G.scheduled_date>=T&&G.scheduled_date<=I).sort(dm).map(dX):[],[ie,P.data,ue,ke,T,I]),Q=p.useMemo(()=>{const G=new Set;return ue.forEach(U=>{(U.team_members||[]).forEach(Z=>{Z!=null&&Z.id&&G.add(Z.id)})}),G},[ue]),fe=p.useMemo(()=>{var G;return!s||!((G=M.data)!=null&&G.length)?L:[...L,...LX(M.data,Q)]},[L,s,M.data,Q]),ee=p.useMemo(()=>v?fe.filter(G=>G.isMine):fe,[fe,v]),je=p.useMemo(()=>{const G=new Map;return ee.forEach(U=>{const Z=G.get(U.date);Z?Z.push(U):G.set(U.date,[U])}),G.forEach(U=>U.sort($X)),G},[ee]),Ee=je.get(E)??[],te=()=>{l.invalidateQueries({queryKey:["planner-range-board"]}),l.invalidateQueries({queryKey:["staff-projects"]})},_e=G=>{var Z;if(G.taskId){const pe=(Z=M.data)==null?void 0:Z.find(Be=>Be.id===G.taskId);pe&&(a==null||a(pe));return}if(!G.taskId&&o){o(G.projectId);return}if(!G.taskId&&W&&!G.isMine){b(G.entryId);return}const U=ue.find(pe=>pe.entry_id===G.entryId);if(!U){K.error(H.isFetching?"De gegevens worden nog geladen. Probeer het zo nog eens.":"Deze opdracht staat niet meer in jouw lijst.");return}x(U)},Me=G=>{m(cS(new Date(`${G}T00:00:00`)))},Ue=G=>{f.current=G,d(G)},ct=G=>{const U=_y.indexOf(f.current);Ue(_y[Math.min(Math.max(U+G,0),_y.length-1)])},Rt=G=>{switch(G){case"left":m(U=>lS(iS(f.current),U,1));break;case"right":m(U=>lS(iS(f.current),U,-1));break;case"up":ct(1);break;case"down":ct(-1);break}},Et=sS({onSwipe:Rt}),A=sS({onSwipe:Rt,allowVertical:()=>{var G;return(((G=k.current)==null?void 0:G.scrollTop)??0)<=0}}),$=u==="day",q=r!==void 0,de=q?"Iets inplannen":n?"Nieuwe opdracht":"Zelf iets in de agenda zetten";return i.jsxs("div",{className:"relative flex h-full flex-col",children:[i.jsx(EX,{label:QX(u,h),onToday:()=>m(new Date),onlyMine:v,onOnlyMineChange:w,isFetching:ce,onRefresh:te}),i.jsxs("div",{className:"shrink-0",style:{touchAction:"pan-y"},...Et,children:[i.jsx(RX,{weeks:N,entriesByDate:je,selected:E,todayStr:S,month:h,scope:u,resolveColor:c,onSelectDay:Me}),i.jsxs("button",{type:"button",onClick:()=>$?Ue("month"):ct(1),className:"flex w-full items-center justify-center gap-1 py-1.5 text-muted-foreground/60","aria-label":$?"Kalender tonen":"Kalender kleiner maken",children:[i.jsx("span",{className:"h-1 w-8 rounded-full bg-muted-foreground/25"}),$?i.jsx(Qw,{className:"h-3.5 w-3.5","aria-hidden":"true"}):i.jsx(hT,{className:"h-3.5 w-3.5","aria-hidden":"true"})]})]}),ie&&i.jsx("p",{className:"mx-4 mb-2 shrink-0 rounded-md bg-muted/50 px-3 py-2 text-xs text-muted-foreground",children:"Alleen jouw eigen opdrachten zichtbaar. Het volledige bord is nu niet beschikbaar."}),i.jsx("div",{ref:k,className:"min-h-0 flex-1 overflow-y-auto overscroll-contain border-t border-border/60",style:{touchAction:"pan-y"},...A,children:oe?i.jsx("div",{className:"space-y-2 px-4 pt-4",children:[1,2,3].map(G=>i.jsx(Dt,{className:"h-16 w-full rounded-md"},G))}):re?i.jsxs("div",{className:"px-4 py-10 text-center",children:[i.jsx(Vr,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground/50"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"De planning kon niet geladen worden. Dit betekent niet dat je niets hebt staan."}),i.jsx(ne,{variant:"outline",size:"sm",className:"mt-3",onClick:te,children:"Opnieuw proberen"})]}):i.jsx(TX,{day:E,entries:Ee,todayStr:S,onlyMine:v,resolveColor:c,onOpen:_e,canOpenTasks:!!a,canOpenProjects:!!o,canOpenColleagueBrief:W})}),t&&i.jsx(ne,{size:"icon",className:"absolute bottom-4 right-4 z-20 h-14 w-14 rounded-full shadow-lg shadow-primary/30",onClick:()=>n?n(E):j(!0),"aria-haspopup":q?"menu":void 0,"aria-expanded":q?r:void 0,"aria-label":de,children:i.jsx(jc,{className:"h-7 w-7"})}),t&&!n&&i.jsx(SX,{isOpen:_,onClose:()=>j(!1),defaultDate:E,onCreated:G=>m(cS(new Date(`${G}T00:00:00`)))}),i.jsx(xO,{project:y,isOpen:!!y,onClose:()=>x(null)}),i.jsx(xX,{entryId:g,organizationId:V==null?void 0:V.id,isOpen:!!g,onClose:()=>b(null)})]})}function Gf({children:e,nav:t,scrollable:n=!0}){return i.jsxs("div",{className:"flex h-[100dvh] flex-col overflow-hidden overscroll-none bg-background",children:[i.jsx("div",{className:Y("min-h-0 flex-1",n?"overflow-y-auto overscroll-contain":"overflow-hidden"),children:e}),t]})}const eZ={agenda:{label:"Agenda",icon:Km,tab:"agenda"}};function Yf({activeTab:e,onTabChange:t,items:n}){return i.jsxs(QP,{alwaysVisible:!0,docked:!0,children:[i.jsx(Sr,{icon:Nd,label:"Vandaag",active:e==="vandaag",onClick:()=>t("vandaag")}),n.map(r=>{const s=eZ[r];return s?i.jsx(Sr,{icon:s.icon,label:s.label,active:e===s.tab,onClick:()=>t(s.tab)},r):null}),i.jsx(Sr,{icon:vr,label:"Profiel",to:"/profile"})]})}const tZ=["agenda"];function nZ(e){return tZ.includes(e)}const rZ=2;function sZ(e,t){const n=e.filter(r=>nZ(r.module_key));return n.length>0?n.filter(r=>r.is_enabled).filter(r=>cW(r.config)==="bottom_nav").slice().sort((r,s)=>uS(r)-uS(s)).slice(0,rZ).map(r=>r.module_key):t==="agenda"?["agenda"]:[]}function uS(e){const t=e.config;return typeof(t==null?void 0:t.sort_order)=="number"?t.sort_order:99}function aZ({userId:e,userName:t,onNavigate:n}){var fe;const{organization:r}=zt(),{getSetting:s,loading:a}=Hd(r==null?void 0:r.id),{roleModules:o}=ZP(r==null?void 0:r.id,"staff"),l=sZ(o,s("staff_monteur_view")),c=l.length>0,[u,d]=p.useState("agenda"),f=c&&u==="agenda",{data:h,isLoading:m,error:v,isFetching:w}=rb(f?void 0:e),y=Ge(),{isEnabled:x,requests:g,isError:b}=aX(r==null?void 0:r.id),_=b?0:g.length,[j,k]=p.useState(null),[S,E]=p.useState(!1),[N,O]=p.useState(null),z=lX(r==null?void 0:r.id),T=z.isPending?((fe=z.variables)==null?void 0:fe.projectId)??null:null,I=()=>{const ee=N;ee&&z.mutate({projectId:ee.id},{onSettled:()=>O(null),onSuccess:je=>{je.ok&&(k(null),E(!1))}})},[P,H]=p.useState(null),[V,M]=p.useState(null),[C,F]=p.useState(!1),[W,ie]=p.useState(!1),[oe,ce]=p.useState("today"),re=oe==="service"&&!x?"today":oe,ue=async()=>{ie(!0),await y.invalidateQueries({queryKey:["staff-projects"]}),await y.invalidateQueries({queryKey:["planner-range-board"]}),await y.invalidateQueries({queryKey:[wO]}),await y.invalidateQueries({queryKey:[Rb]}),K.success("Opdrachten vernieuwd"),ie(!1)},ke=p.useMemo(()=>h?[...h.today,...h.thisWeek,...h.upcoming]:[],[h]),L=p.useMemo(()=>{const ee=new Date,je=he(ee,"yyyy-MM-dd"),Ee=he(mt(ee,1),"yyyy-MM-dd"),te=he(Pn(ee,{weekStartsOn:1}),"yyyy-MM-dd"),_e=he(ko(ee,{weekStartsOn:1}),"yyyy-MM-dd");return ke.filter(Me=>{const Ue=Me.scheduled_date;switch(re){case"today":return Ue===je;case"tomorrow":return Ue===Ee;case"week":return Ue>=te&&Ue<=_e;default:return!1}}).sort(dm)},[ke,re]),Q=p.useMemo(()=>{const ee=new Date,je=he(ee,"yyyy-MM-dd"),Ee=he(mt(ee,1),"yyyy-MM-dd"),te=he(Pn(ee,{weekStartsOn:1}),"yyyy-MM-dd"),_e=he(ko(ee,{weekStartsOn:1}),"yyyy-MM-dd");let Me=0,Ue=0,ct=0;return ke.forEach(Rt=>{const Et=Rt.scheduled_date;Et===je&&Me++,Et===Ee&&Ue++,Et>=te&&Et<=_e&&ct++}),{today:Me,tomorrow:Ue,week:ct}},[ke]);return a||m?i.jsx(Gf,{nav:c?i.jsx(Yf,{activeTab:"vandaag",onTabChange:d,items:l}):void 0,children:i.jsxs("div",{className:"px-4 pt-4 pb-6 space-y-6",children:[i.jsxs("div",{className:"bg-gradient-to-b from-slate-400 to-slate-600 px-4 pt-4 pb-10 -mx-4 -mt-4",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[i.jsx(Dt,{className:"h-10 w-10 rounded bg-white/20"}),i.jsx(Dt,{className:"h-4 w-24 bg-white/20"})]}),i.jsx(Dt,{className:"h-8 w-48 bg-white/20 mb-2"}),i.jsx(Dt,{className:"h-5 w-32 bg-white/20"})]}),i.jsxs("div",{className:"-mt-8 space-y-4",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Dt,{className:"h-9 w-24"}),i.jsx(Dt,{className:"h-9 w-24"}),i.jsx(Dt,{className:"h-9 w-20"})]}),[1,2,3].map(ee=>i.jsx(Dt,{className:"h-40 w-full rounded-lg"},ee))]})]})}):v?i.jsx(Gf,{nav:c?i.jsx(Yf,{activeTab:"vandaag",onTabChange:d,items:l}):void 0,children:i.jsx("div",{className:"p-4",children:i.jsx(dt,{children:i.jsxs(bt,{className:"p-6 text-center",children:[i.jsx("p",{className:"text-destructive mb-2",children:"Er is een fout opgetreden bij het laden van je opdrachten."}),i.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:v.message}),i.jsxs(ne,{variant:"outline",onClick:ue,disabled:W,children:[i.jsx(qs,{className:`h-4 w-4 mr-2 ${W?"animate-spin":""}`}),"Probeer opnieuw"]})]})})})}):f?i.jsx(Gf,{scrollable:!1,nav:i.jsx(Yf,{activeTab:"agenda",onTabChange:d,items:l}),children:i.jsx(JX,{userId:e})}):i.jsx(Gf,{nav:c?i.jsx(Yf,{activeTab:"vandaag",onTabChange:d,items:l}):void 0,children:i.jsxs("div",{className:"px-4 pt-4 pb-6",children:[i.jsx(QQ,{onRefresh:ue,isRefreshing:W||w,showLogout:!0}),i.jsxs("div",{className:"-mt-14 space-y-6 relative z-10",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(nS,{slot:1,ariaLabel:"opdrachten vandaag",value:Q.today,icon:Pv,onClick:()=>ce("today")}),i.jsx(nS,{slot:2,ariaLabel:"opdrachten morgen",value:Q.tomorrow,icon:To,onClick:()=>ce("tomorrow")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ne,{variant:re==="today"?"default":"outline",size:"sm",onClick:()=>ce("today"),className:"shrink-0",children:"Vandaag"}),i.jsx(ne,{variant:re==="tomorrow"?"default":"outline",size:"sm",onClick:()=>ce("tomorrow"),className:"shrink-0",children:"Morgen"}),x&&i.jsxs(ne,{variant:re==="service"?"default":"outline",size:"sm",onClick:()=>ce("service"),className:"shrink-0",children:["Service ",_>0&&`(${_})`]})]}),re==="service"?b?i.jsx(dt,{className:"border-0 bg-muted/30",children:i.jsxs(bt,{className:"py-8 text-center",children:[i.jsx(Vr,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),i.jsx("p",{className:"text-muted-foreground",children:"Kon de serviceaanvragen niet laden · probeer verversen"})]})}):g.length===0?i.jsx(dt,{className:"border-0 bg-muted/30",children:i.jsxs(bt,{className:"py-8 text-center",children:[i.jsx(fo,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),i.jsx("p",{className:"text-muted-foreground",children:"Geen open serviceaanvragen"})]})}):i.jsx("div",{className:"space-y-3",children:g.map(ee=>i.jsx(ZQ,{request:ee,onOpen:()=>{E(!1),k(ee)},onPrint:()=>{E(!0),k(ee)}},ee.id))}):L.length===0?i.jsx(dt,{className:"border-0 bg-muted/30",children:i.jsxs(bt,{className:"py-8 text-center",children:[i.jsx(Pv,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),i.jsxs("p",{className:"text-muted-foreground",children:["Geen opdrachten ",re==="today"?"vandaag":re==="tomorrow"?"morgen":"deze week"]})]})}):i.jsx("div",{className:"space-y-3",children:L.map(ee=>i.jsx(wq,{project:ee,onCall:()=>{},onNavigate:()=>{},onBrief:()=>{F(!1),M(ee)},onPrint:()=>{F(!0),M(ee)},onClick:()=>{F(!1),M(ee)}},ee.entry_id))})]}),i.jsx(wY,{project:P,userId:e,isOpen:!!P,onClose:()=>H(null)}),i.jsx(xO,{project:V,isOpen:!!V,onClose:()=>{M(null),F(!1)},autoPrint:C}),i.jsx(eX,{request:j,isOpen:!!j,onClose:()=>{k(null),E(!1)},onClaim:()=>{j&&O(j)},isClaiming:!!j&&T===j.id,autoPrint:S}),i.jsx(oO,{open:!!N,onOpenChange:ee=>{ee||O(null)},children:i.jsxs(kb,{children:[i.jsxs(jb,{children:[i.jsx(Eb,{children:"Deze aanvraag oppakken?"}),i.jsx(Nb,{children:"Hij wordt aan jou gekoppeld en komt vandaag in je planning."})]}),i.jsxs(Sb,{children:[i.jsx(Tb,{disabled:z.isPending,children:"Annuleren"}),i.jsx(Cb,{disabled:z.isPending,onClick:ee=>{ee.preventDefault(),I()},children:z.isPending?"Bezig…":"Oppakken"})]})]})})]})})}function dS(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function oZ(e){var t,n;return{entryId:e.entry_id,projectId:e.project_id,title:((t=e.project_title)==null?void 0:t.trim())||((n=e.project_name)==null?void 0:n.trim())||"Opdracht",customerName:e.customer_name||null,customerCity:e.customer_city||null,slotNumber:e.slot_number??null,vehicleId:e.vehicle_id??null,vehicleName:e.vehicle_name||null,vehicleLicensePlate:e.vehicle_license_plate||null,teamNames:dS(e.team_names),classificationKey:e.classification_key??null,extraLabels:dS(e.extra_labels),startTime:e.start_time??null,plannedHours:typeof e.planned_hours=="number"?e.planned_hours:null}}function iZ(e){var t;return{entryId:e.entry_id,projectId:e.id,title:((t=e.name)==null?void 0:t.trim())||"Opdracht",customerName:e.customer_name||null,customerCity:e.customer_city||null,slotNumber:e.slot_number??null,vehicleId:e.vehicle_id??null,vehicleName:e.vehicle_name||null,vehicleLicensePlate:e.vehicle_license_plate||null,teamNames:(e.team_members||[]).map(n=>n.name).filter(Boolean),classificationKey:null,extraLabels:[],startTime:e.start_time??null,plannedHours:e.planned_hours??null}}async function lZ(e){const t=B,{data:n,error:r}=await t.rpc("get_planner_day_board",{p_date:e});if(r)throw new Error(r.message||"get_planner_day_board faalde");return(n??[]).map(oZ)}function cZ(e,t){const{initialized:n,session:r}=Ht();return xt({queryKey:["planner-day-board",e,t],queryFn:()=>lZ(t),enabled:!!e&&n&&!!r,staleTime:1e3*60*2,retry:!1})}function uZ(e,t){var a,o;const n=new Map;for(const l of e){let c,u;if(l.vehicleId||l.vehicleName)c=l.vehicleId?`veh:${l.vehicleId}`:`vehname:${l.vehicleName}`,u={key:c,label:l.vehicleName||"Bus",licensePlate:l.vehicleLicensePlate,isVehicle:!0,vehicleName:l.vehicleName,slotNumber:null};else if(l.slotNumber!=null){c=`slot:${l.slotNumber}`;const f=(o=(a=t==null?void 0:t.slotLabels)==null?void 0:a[String(l.slotNumber)])==null?void 0:o.trim();u={key:c,label:f&&f.length>0?f:`${(t==null?void 0:t.itemLabel)??"Slot"} ${l.slotNumber}`,licensePlate:null,isVehicle:!1,vehicleName:null,slotNumber:l.slotNumber}}else c="overig",u={key:c,label:"Overig",licensePlate:null,isVehicle:!1,vehicleName:null,slotNumber:null};let d=n.get(c);d||(d={...u,entries:[]},n.set(c,d)),d.entries.push(l)}const r=Array.from(n.values()),s=l=>l.isVehicle?0:l.key==="overig"?2:1;return r.sort((l,c)=>{const u=s(l),d=s(c);return u!==d?u-d:l.isVehicle?(l.vehicleName||"").localeCompare(c.vehicleName||""):(l.slotNumber??0)-(c.slotNumber??0)}),r}function dZ({entry:e}){const t=Id(e.startTime,e.plannedHours);return i.jsxs("div",{className:"rounded-lg border bg-card p-2.5 shadow-sm",children:[t&&i.jsx("p",{className:"mb-1 text-sm font-bold leading-none tabular-nums",children:t}),i.jsx("p",{className:"text-[13px] font-semibold leading-snug",children:e.title}),e.customerName&&i.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.customerName}),e.customerCity&&i.jsx("p",{className:"truncate text-xs font-semibold text-foreground",children:e.customerCity}),e.teamNames.length>0&&i.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1",children:e.teamNames.map((n,r)=>i.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] text-muted-foreground",children:n},r))})]})}function fZ({entries:e,isLoading:t,emptyText:n="Geen opdrachten vandaag",slotLabels:r,itemLabel:s}){const a=p.useMemo(()=>uZ(e,{slotLabels:r,itemLabel:s}),[e,r,s]);return t?i.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Laden…"}):a.length===0?i.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:n}):i.jsx("div",{className:"flex-1 overflow-x-auto overflow-y-hidden",children:i.jsx("div",{className:"flex h-full gap-3 p-3",children:a.map(o=>i.jsxs("section",{className:"flex h-full w-[260px] shrink-0 flex-col",children:[i.jsxs("div",{className:"mb-2 shrink-0 border-b pb-1.5",children:[i.jsx("div",{className:"truncate text-sm font-semibold leading-tight",children:o.label}),o.licensePlate&&i.jsx("div",{className:"truncate font-mono text-[11px] uppercase text-muted-foreground",children:o.licensePlate})]}),i.jsx("div",{className:"flex-1 space-y-2 overflow-y-auto pr-0.5",children:o.entries.map(l=>i.jsx(dZ,{entry:l},l.entryId))})]},o.key))})})}function hZ({userId:e}){const t=Ge(),n=p.useMemo(()=>new Date,[]),r=he(n,"yyyy-MM-dd"),s=cZ(e,r),a=rb(e),{organization:o}=zt(),{slotLabels:l,itemLabel:c}=vO(o==null?void 0:o.id),u=s.isError,d=s.isLoading||u&&a.isLoading,f=p.useMemo(()=>!u&&s.data?s.data:u&&a.data?[...a.data.today,...a.data.thisWeek,...a.data.upcoming].filter(y=>y.scheduled_date===r).sort((y,x)=>NA({display_order:y.display_order,start_time:y.start_time,name:y.name,entry_id:y.entry_id},{display_order:x.display_order,start_time:x.start_time,name:x.name,entry_id:x.entry_id})).map(iZ):[],[u,s.data,a.data,r]),h=()=>{t.invalidateQueries({queryKey:["planner-day-board"]}),t.invalidateQueries({queryKey:["staff-projects"]})},m=he(n,"EEEE d MMMM yyyy",{locale:tt}),v=s.isFetching||u&&a.isFetching;return i.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-background",children:[i.jsxs("header",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b bg-card px-3",children:[i.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[i.jsx("h1",{className:"truncate text-sm font-semibold",children:m}),u&&i.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:"Alleen jouw eigen opdrachten zichtbaar"})]}),i.jsx("button",{type:"button",onClick:h,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted","aria-label":"Vernieuwen",children:i.jsx(qs,{className:Y("h-4 w-4",v&&"animate-spin")})})]}),i.jsx(fZ,{entries:f,isLoading:d,slotLabels:l,itemLabel:c})]})}const mZ="(orientation: landscape) and (max-width: 767px), (orientation: landscape) and (pointer: coarse) and (max-height: 767px)";function pZ(){const[e,t]=p.useState(!1);return p.useEffect(()=>{const n=window.matchMedia(mZ),r=()=>t(n.matches);r(),n.addEventListener("change",r);const s=()=>window.setTimeout(r,100);return window.addEventListener("resize",r),window.addEventListener("orientationchange",s),()=>{n.removeEventListener("change",r),window.removeEventListener("resize",r),window.removeEventListener("orientationchange",s)}},[]),e}function gZ({authInitialized:e,authLoading:t,hasUser:n,roleLoading:r,roleInitialized:s,orgLoading:a=!1}){const[o,l]=p.useState(!1),[c,u]=p.useState(!navigator.onLine),[d,f]=p.useState(!1),{refreshSession:h}=Ht();p.useEffect(()=>{const y=setTimeout(()=>{l(!0)},5e3);return()=>clearTimeout(y)},[]),p.useEffect(()=>{const y=()=>u(!1),x=()=>u(!0);return window.addEventListener("online",y),window.addEventListener("offline",x),()=>{window.removeEventListener("online",y),window.removeEventListener("offline",x)}},[]);const m=async()=>{f(!0);try{await h(),window.location.reload()}catch(y){console.error("[LoadingRecovery] Retry failed:",y),f(!1)}},v=async()=>{f(!0);try{await TP(),window.location.href="/auth"}catch(y){console.error("[LoadingRecovery] Auth reset failed:",y),f(!1)}},w=async()=>{f(!0);try{await $0()}catch(y){console.error("[LoadingRecovery] Full reset failed:",y),f(!1)}};return c?i.jsxs("div",{className:"flex flex-col items-center justify-center p-6 space-y-4 bg-muted/30 rounded-lg mx-4 mt-4",children:[i.jsx(c$,{className:"h-12 w-12 text-muted-foreground"}),i.jsxs("div",{className:"text-center",children:[i.jsx("h3",{className:"font-semibold text-foreground",children:"Je bent offline"}),i.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Controleer je internetverbinding en probeer opnieuw."})]}),i.jsxs(ne,{onClick:()=>window.location.reload(),disabled:d,children:[i.jsx(qs,{className:"h-4 w-4 mr-2"}),"Opnieuw proberen"]})]}):o?i.jsxs("div",{className:"flex flex-col items-center justify-center p-6 space-y-4 bg-muted/30 rounded-lg mx-4 mt-4",children:[i.jsx(Vr,{className:"h-10 w-10 text-warning"}),i.jsxs("div",{className:"text-center",children:[i.jsx("h3",{className:"font-semibold text-foreground",children:"App laadt langer dan verwacht"}),i.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Probeer een van onderstaande opties."})]}),i.jsxs("div",{className:"flex flex-col gap-2 w-full max-w-xs",children:[i.jsxs(ne,{onClick:m,disabled:d,variant:"default",className:"w-full",children:[i.jsx(qs,{className:`h-4 w-4 mr-2 ${d?"animate-spin":""}`}),"Opnieuw proberen"]}),i.jsxs(ne,{onClick:v,disabled:d,variant:"outline",className:"w-full",children:[i.jsx(Xu,{className:"h-4 w-4 mr-2"}),"Opnieuw inloggen"]}),i.jsxs(ne,{onClick:w,disabled:d,variant:"destructive",className:"w-full",children:[i.jsx(Jw,{className:"h-4 w-4 mr-2"}),"App volledig resetten"]})]}),i.jsxs("details",{className:"text-xs text-muted-foreground mt-4 w-full max-w-xs",children:[i.jsx("summary",{className:"cursor-pointer",children:"Technische details"}),i.jsxs("div",{className:"mt-2 p-2 bg-muted rounded text-left font-mono space-y-1",children:[i.jsxs("div",{children:["authInitialized: ",e?"✓":"✗"]}),i.jsxs("div",{children:["authLoading: ",t?"⏳":"✓"]}),i.jsxs("div",{children:["hasUser: ",n?"✓":"✗"]}),i.jsxs("div",{children:["roleLoading: ",r?"⏳":"✓"]}),i.jsxs("div",{children:["roleInitialized: ",s?"✓":"✗"]}),i.jsxs("div",{children:["orgLoading: ",a?"⏳":"✓"]})]})]})]}):null}const yZ=()=>{var S,E,N;const e=Xs(),{user:t,loading:n,initialized:r}=Ht(),{isAdmin:s,isSuperAdmin:a,isTenantOwner:o,isTenantStaff:l,role:c,loading:u,initialized:d}=Rd(),{organization:f,loading:h}=zt(),m=pZ(),[v,w]=p.useState({todayAppointments:0,weekAppointments:0,backlogCount:0,availableStaff:0}),[y,x]=p.useState(!0),g=n||!r;p.useEffect(()=>{if(!(!r||u||!t)&&(s||a||o||l)){const O=bx({isAdmin:s,isSuperAdmin:a,isTenantOwner:o,isTenantStaff:l,role:c});e(O,{replace:!0})}},[t,r,u,s,a,o,l,c,e]),p.useEffect(()=>{const O=async()=>{if(!t||!(f!=null&&f.id)){x(!1);return}const z=f.id,T=he(new Date,"yyyy-MM-dd"),I=he(new Date,"yyyy-MM-dd"),P=he(new Date(Date.now()+7*24*60*60*1e3),"yyyy-MM-dd");try{const{count:H}=await B.from("appointments").select("*",{count:"exact",head:!0}).eq("organization_id",z).eq("appointment_date",T).not("status","in",'("cancelled","no-show")'),{count:V}=await B.from("appointments").select("*",{count:"exact",head:!0}).eq("organization_id",z).gte("appointment_date",I).lte("appointment_date",P).not("status","in",'("cancelled","no-show")'),{count:M}=await B.from("projects").select("*",{count:"exact",head:!0}).eq("organization_id",z).eq("status","planned"),{data:C}=await B.from("staff").select("id").eq("organization_id",z).eq("is_active",!0),{data:F}=await B.from("staff_availability").select("staff_id").eq("organization_id",z).eq("date",T),W=new Set((F==null?void 0:F.map(oe=>oe.staff_id))||[]),ie=(C||[]).filter(oe=>!W.has(oe.id)).length;w({todayAppointments:H||0,weekAppointments:V||0,backlogCount:M||0,availableStaff:ie})}catch(H){console.error("Error fetching stats:",H)}x(!1)};t&&(f!=null&&f.id)&&O()},[t,f==null?void 0:f.id]);const{signOut:b}=Ht(),_=async()=>{const O=await b();if(!O.ok){K.error("Uitloggen ging niet vlekkeloos",{description:`Je bent op dit apparaat uitgelogd. Reden: ${O.reason}`}),B0();return}K.success("Uitgelogd"),e("/auth",{replace:!0})},j=()=>a?i.jsx(Qe,{className:"bg-purple-600",children:"Super Admin"}):o?i.jsx(Qe,{className:"bg-blue-600",children:"Eigenaar"}):l?i.jsx(Qe,{className:"bg-green-600",children:"Planner"}):c==="staff"?i.jsx(Qe,{className:"bg-amber-600",children:"Monteur"}):i.jsx(Qe,{variant:"secondary",children:"Gebruiker"}),k=()=>{const O=[{label:"Agenda",icon:Wt,path:"/admin",variant:"default"}];return s?[...O,{label:"Nieuwe Afspraak",icon:jc,path:"/admin?action=new",variant:"outline"},{label:"Backlog",icon:Fk,path:"/admin?section=backlog",variant:"outline"},{label:"Instellingen",icon:Z5,path:"/admin?section=account",variant:"outline"}]:O};return p.useEffect(()=>{!g&&!t&&e("/auth",{replace:!0})},[g,t,e]),!g&&!t?null:g||u&&!d?i.jsxs("div",{className:"min-h-screen bg-background",children:[i.jsx("nav",{className:"bg-card border-b",children:i.jsx(Xo,{children:i.jsxs("div",{className:"py-4 flex justify-between items-center",children:[i.jsx(Dt,{className:"h-8 w-48"}),i.jsx(Dt,{className:"h-10 w-24"})]})})}),i.jsxs(Xo,{className:"py-6 space-y-6",children:[i.jsx(Dt,{className:"h-12 w-64"}),i.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[...Array(4)].map((O,z)=>i.jsx(Dt,{className:"h-28"},z))}),i.jsx(gZ,{authInitialized:r,authLoading:n,hasUser:!!t,roleLoading:u,roleInitialized:d,orgLoading:h})]})]}):(((S=t==null?void 0:t.user_metadata)==null?void 0:S.role)==="staff"||c==="staff")&&t?m?i.jsx(hZ,{userId:t.id}):i.jsx(aZ,{userId:t.id,userName:((E=t.user_metadata)==null?void 0:E.full_name)||"Monteur"}):i.jsxs("div",{className:"min-h-screen pb-24 md:pb-0 bg-background",children:[i.jsx("nav",{className:"bg-card border-b sticky top-0 z-50",children:i.jsx(Xo,{children:i.jsxs("div",{className:"py-3 sm:py-4 flex justify-between items-center",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(qm,{className:"h-7 w-7 sm:h-8 sm:w-8 text-primary"}),i.jsx("span",{className:"text-lg sm:text-xl font-bold hidden sm:inline",children:"PlanPilot"})]}),i.jsxs("div",{className:"hidden md:flex gap-3 items-center",children:[i.jsxs(ne,{variant:"ghost",onClick:()=>e("/admin"),children:[i.jsx($5,{className:"mr-2 h-4 w-4"}),"Dashboard"]}),i.jsxs(ne,{variant:"outline",onClick:()=>e("/profile"),children:[i.jsx(vr,{className:"mr-2 h-4 w-4"}),"Profiel"]}),i.jsxs(ne,{variant:"outline",onClick:_,children:[i.jsx(Xu,{className:"mr-2 h-4 w-4"}),"Uitloggen"]})]}),i.jsx("div",{className:"md:hidden",children:i.jsx(ne,{variant:"ghost",size:"icon",onClick:_,children:i.jsx(Xu,{className:"h-5 w-5"})})})]})})}),i.jsx("main",{className:"py-6",children:i.jsxs(Xo,{className:"space-y-6",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[i.jsxs("div",{children:[i.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold",children:["Welkom terug",(N=t==null?void 0:t.user_metadata)!=null&&N.full_name?`, ${t.user_metadata.full_name}`:"","!"]}),i.jsx("p",{className:"text-muted-foreground",children:he(new Date,"EEEE d MMMM yyyy",{locale:tt})})]}),j()]}),i.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[i.jsx($f,{title:"Vandaag",value:y?"...":v.todayAppointments,subtitle:"geplande klussen",icon:Wt,variant:"primary",onClick:()=>e("/admin")}),i.jsx($f,{title:"Deze Week",value:y?"...":v.weekAppointments,subtitle:"geplande klussen",icon:To,onClick:()=>e("/admin")}),i.jsx($f,{title:"Backlog",value:y?"...":v.backlogCount,subtitle:"wachtend op planning",icon:Fk,variant:v.backlogCount>0?"warning":"default",onClick:()=>e("/admin?section=backlog")}),i.jsx($f,{title:"Beschikbaar",value:y?"...":v.availableStaff,subtitle:"technici vandaag",icon:Wr,variant:"success"})]}),i.jsxs("div",{children:[i.jsx("h2",{className:"text-lg font-semibold mb-3",children:"Snelle Acties"}),i.jsx(IH,{actions:k()})]}),i.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[!h&&i.jsx(DH,{}),!h&&s&&i.jsx(dq,{})]})]})}),s?i.jsx(pW,{activeSection:"",onSectionChange:()=>e("/admin"),onSettingsOpen:()=>e("/admin")}):i.jsx(pp,{user:t,isAdmin:!1,onLogout:_})]})};var ky="rovingFocusGroup.onEntryFocus",vZ={bubbles:!1,cancelable:!0},qd="RovingFocusGroup",[Ax,EO,xZ]=Hw(qd),[wZ,Op]=Ln(qd,[xZ]),[bZ,_Z]=wZ(qd),NO=p.forwardRef((e,t)=>i.jsx(Ax.Provider,{scope:e.__scopeRovingFocusGroup,children:i.jsx(Ax.Slot,{scope:e.__scopeRovingFocusGroup,children:i.jsx(kZ,{...e,ref:t})})}));NO.displayName=qd;var kZ=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:s=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=p.useRef(null),m=ze(t,h),v=Vd(a),[w,y]=vs({prop:o,defaultProp:l??null,onChange:c,caller:qd}),[x,g]=p.useState(!1),b=on(u),_=EO(n),j=p.useRef(!1),[k,S]=p.useState(0);return p.useEffect(()=>{const E=h.current;if(E)return E.addEventListener(ky,b),()=>E.removeEventListener(ky,b)},[b]),i.jsx(bZ,{scope:n,orientation:r,dir:v,loop:s,currentTabStopId:w,onItemFocus:p.useCallback(E=>y(E),[y]),onItemShiftTab:p.useCallback(()=>g(!0),[]),onFocusableItemAdd:p.useCallback(()=>S(E=>E+1),[]),onFocusableItemRemove:p.useCallback(()=>S(E=>E-1),[]),children:i.jsx(Te.div,{tabIndex:x||k===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:xe(e.onMouseDown,()=>{j.current=!0}),onFocus:xe(e.onFocus,E=>{const N=!j.current;if(E.target===E.currentTarget&&N&&!x){const O=new CustomEvent(ky,vZ);if(E.currentTarget.dispatchEvent(O),!O.defaultPrevented){const z=_().filter(V=>V.focusable),T=z.find(V=>V.active),I=z.find(V=>V.id===w),H=[T,I,...z].filter(Boolean).map(V=>V.ref.current);PO(H,d)}}j.current=!1}),onBlur:xe(e.onBlur,()=>g(!1))})})}),CO="RovingFocusGroupItem",TO=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:s=!1,tabStopId:a,children:o,...l}=e,c=Vs(),u=a||c,d=_Z(CO,n),f=d.currentTabStopId===u,h=EO(n),{onFocusableItemAdd:m,onFocusableItemRemove:v,currentTabStopId:w}=d;return p.useEffect(()=>{if(r)return m(),()=>v()},[r,m,v]),i.jsx(Ax.ItemSlot,{scope:n,id:u,focusable:r,active:s,children:i.jsx(Te.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...l,ref:t,onMouseDown:xe(e.onMouseDown,y=>{r?d.onItemFocus(u):y.preventDefault()}),onFocus:xe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:xe(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){d.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const x=EZ(y,d.orientation,d.dir);if(x!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let b=h().filter(_=>_.focusable).map(_=>_.ref.current);if(x==="last")b.reverse();else if(x==="prev"||x==="next"){x==="prev"&&b.reverse();const _=b.indexOf(y.currentTarget);b=d.loop?NZ(b,_+1):b.slice(_+1)}setTimeout(()=>PO(b))}}),children:typeof o=="function"?o({isCurrentTabStop:f,hasTabStop:w!=null}):o})})});TO.displayName=CO;var jZ={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function SZ(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function EZ(e,t,n){const r=SZ(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return jZ[r]}function PO(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function NZ(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var AO=NO,RO=TO,Mp="Tabs",[CZ]=Ln(Mp,[Op]),OO=Op(),[TZ,Lb]=CZ(Mp),MO=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:s,defaultValue:a,orientation:o="horizontal",dir:l,activationMode:c="automatic",...u}=e,d=Vd(l),[f,h]=vs({prop:r,onChange:s,defaultProp:a??"",caller:Mp});return i.jsx(TZ,{scope:n,baseId:Vs(),value:f,onValueChange:h,orientation:o,dir:d,activationMode:c,children:i.jsx(Te.div,{dir:d,"data-orientation":o,...u,ref:t})})});MO.displayName=Mp;var DO="TabsList",IO=p.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...s}=e,a=Lb(DO,n),o=OO(n);return i.jsx(AO,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:i.jsx(Te.div,{role:"tablist","aria-orientation":a.orientation,...s,ref:t})})});IO.displayName=DO;var LO="TabsTrigger",$O=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:s=!1,...a}=e,o=Lb(LO,n),l=OO(n),c=BO(o.baseId,r),u=UO(o.baseId,r),d=r===o.value;return i.jsx(RO,{asChild:!0,...l,focusable:!s,active:d,children:i.jsx(Te.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":u,"data-state":d?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:c,...a,ref:t,onMouseDown:xe(e.onMouseDown,f=>{!s&&f.button===0&&f.ctrlKey===!1?o.onValueChange(r):f.preventDefault()}),onKeyDown:xe(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&o.onValueChange(r)}),onFocus:xe(e.onFocus,()=>{const f=o.activationMode!=="manual";!d&&!s&&f&&o.onValueChange(r)})})})});$O.displayName=LO;var FO="TabsContent",zO=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:s,children:a,...o}=e,l=Lb(FO,n),c=BO(l.baseId,r),u=UO(l.baseId,r),d=r===l.value,f=p.useRef(d);return p.useEffect(()=>{const h=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(h)},[]),i.jsx(Jn,{present:s||d,children:({present:h})=>i.jsx(Te.div,{"data-state":d?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!h,id:u,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:h&&a})})});zO.displayName=FO;function BO(e,t){return`${e}-trigger-${t}`}function UO(e,t){return`${e}-content-${t}`}var PZ=MO,VO=IO,WO=$O,HO=zO;const AZ=PZ,qO=p.forwardRef(({className:e,...t},n)=>i.jsx(VO,{ref:n,className:Y("inline-flex h-10 items-center justify-center gap-1 text-muted-foreground",e),...t}));qO.displayName=VO.displayName;const Rx=p.forwardRef(({className:e,...t},n)=>i.jsx(WO,{ref:n,className:Y("inline-flex items-center justify-center whitespace-nowrap rounded-[10px] px-3.5 py-2 text-sm font-medium ring-offset-background transition-colors data-[state=active]:bg-[hsl(var(--subnav-active))] data-[state=active]:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-0 disabled:pointer-events-none disabled:opacity-50",e),...t}));Rx.displayName=WO.displayName;const Ox=p.forwardRef(({className:e,...t},n)=>i.jsx(HO,{ref:n,className:Y("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-0",e),...t}));Ox.displayName=HO.displayName;function RZ(){const[e,t]=p.useState(null),[n,r]=p.useState(!1),[s,a]=p.useState(!1),[o,l]=p.useState(!1);return p.useEffect(()=>{const u=window.matchMedia("(display-mode: standalone)").matches;a(u);const d=/iPad|iPhone|iPod/.test(navigator.userAgent);l(d);const f=h=>{h.preventDefault(),t(h),r(!0)};return window.addEventListener("beforeinstallprompt",f),()=>window.removeEventListener("beforeinstallprompt",f)},[]),{isInstallable:n,isInstalled:s,isIOS:o,promptInstall:async()=>{if(e){e.prompt();const{outcome:u}=await e.userChoice;u==="accepted"&&a(!0),t(null),r(!1)}}}}const OZ=({forceShow:e=!1,title:t="Download onze app",description:n="Sneller boeken, direct vanaf je telefoon"})=>{const{isInstallable:r,isInstalled:s,isIOS:a,promptInstall:o}=RZ(),[l,c]=p.useState(!1),[u,d]=p.useState(!1);p.useEffect(()=>{const h=localStorage.getItem("app-install-dismissed");if(h){const v=parseInt(h,10);Date.now()-v<7*24*60*60*1e3&&c(!0)}const m=setTimeout(()=>d(!0),2e3);return()=>clearTimeout(m)},[]);const f=()=>{c(!0),localStorage.setItem("app-install-dismissed",Date.now().toString())};return s||!e&&l||!u||!r&&!a?null:i.jsx("div",{className:"fixed bottom-20 md:bottom-4 left-4 right-4 z-50 md:left-auto md:right-4 md:max-w-sm animate-in slide-in-from-bottom-4 duration-500",children:i.jsxs("div",{className:"bg-gradient-to-r from-primary to-primary/80 text-primary-foreground rounded-2xl p-4 shadow-2xl relative",children:[i.jsx("button",{onClick:f,className:"absolute top-2 right-2 p-1.5 rounded-full hover:bg-white/20 transition-colors","aria-label":"Sluiten",children:i.jsx(Sa,{className:"h-4 w-4"})}),i.jsxs("div",{className:"flex items-center gap-4 pr-6",children:[i.jsx("div",{className:"w-14 h-14 bg-white/20 rounded-xl flex items-center justify-center flex-shrink-0",children:i.jsx(n$,{className:"h-7 w-7"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("h3",{className:"font-semibold text-lg",children:t}),a?i.jsxs("p",{className:"text-sm opacity-90 flex items-center gap-1 flex-wrap",children:["Tik op ",i.jsx(J5,{className:"h-4 w-4 inline-block"}),' en kies "Zet op beginscherm"']}):i.jsx("p",{className:"text-sm opacity-90",children:n})]})]}),!a&&r&&i.jsxs(ne,{onClick:o,variant:"secondary",className:"w-full mt-3",children:[i.jsx(C5,{className:"h-4 w-4 mr-2"}),"Installeer app"]})]})})},MZ={service:!0,staff:!0,preferred_time:!0,details:!0};function KO(e){if(!e||typeof e!="object")return{...MZ};const t=e;return{service:t.service!==!1,staff:t.staff!==!1,preferred_time:t.preferred_time!==!1,details:!0}}const GO=()=>{const{orgSlug:e}=dp(),[t,n]=p.useState(null),[r,s]=p.useState(!0),[a,o]=p.useState(null);return p.useEffect(()=>{(async()=>{if(!e){n(null),s(!1);return}try{s(!0),o(null);const{data:c,error:u}=await B.rpc("get_public_organization_by_slug",{org_slug:e});if(u){console.error("Error fetching org branding:",u),o("Kon organisatie niet laden"),n(null);return}if(c&&c.length>0){const d=c[0];n({id:d.id,name:d.name,slug:d.slug,logo_url:d.logo_url,primary_color:d.primary_color,secondary_color:d.secondary_color,hero_image_url:d.hero_image_url,is_active:d.is_active,booking_mode:d.booking_mode??"direct",booking_widget_steps:KO(d.booking_widget_steps),portal_login_required:d.portal_login_required===!0})}else n(null),o("Organisatie niet gevonden")}catch(c){console.error("Unexpected error fetching org branding:",c),o("Er ging iets mis"),n(null)}finally{s(!1)}})()},[e]),{branding:t,loading:r,error:a,orgSlug:e}};function $b(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function Fb(e){if(!e||e.trim()==="")return!0;const t=e.replace(/[\s\-().]/g,"");return/^(\+?\d{10,15}|0\d{9})$/.test(t)}function fS(e){return e.length<8?{valid:!1,message:"Wachtwoord moet minimaal 8 tekens zijn"}:/[A-Z]/.test(e)?/\d/.test(e)?{valid:!0,message:""}:{valid:!1,message:"Wachtwoord moet minimaal 1 cijfer bevatten"}:{valid:!1,message:"Wachtwoord moet minimaal 1 hoofdletter bevatten"}}function pae(e,t){return!e||e.trim()===""?{valid:!1,message:`${t} is verplicht`}:{valid:!0,message:""}}function hS(){const e=Xs(),[t]=HP(),n=nW(t.get("returnTo")),{user:r,session:s,loading:a,initialized:o}=Ht(),{role:l,loading:c,isAdmin:u,isSuperAdmin:d,isTenantOwner:f,isTenantStaff:h,initialized:m}=Rd(),{branding:v,loading:w,error:y,orgSlug:x}=GO(),g=(v==null?void 0:v.primary_color)||null,b=(v==null?void 0:v.secondary_color)||null,_=(v==null?void 0:v.name)||null,[j,k]=p.useState(!1),[S,E]=p.useState(!1),[N,O]=p.useState(!1),[z,T]=p.useState(""),[I,P]=p.useState(""),[H,V]=p.useState(!1),{resolvedTheme:M}=CT(),C="/nexus-mark.svg";p.useEffect(()=>{const re=setTimeout(()=>{o||V(!0)},8e3);return()=>clearTimeout(re)},[o]);const F=async()=>{K.info("App wordt gereset..."),await $0()};p.useEffect(()=>{const{data:{subscription:re}}=B.auth.onAuthStateChange(ue=>{ue==="PASSWORD_RECOVERY"&&O(!0)});return()=>re.unsubscribe()},[]),p.useEffect(()=>{if(!N&&r&&m&&!c){const re=n??bx({isAdmin:u,isSuperAdmin:d,isTenantOwner:f,isTenantStaff:h,role:l},x),ue=setTimeout(()=>{e(re,{replace:!0})},150);return()=>clearTimeout(ue)}},[r,c,m,u,l,e,N,x,n]),p.useEffect(()=>{if(!N&&r&&c){const re=setTimeout(()=>{const ue=n??bx({isAdmin:u,isSuperAdmin:d,isTenantOwner:f,isTenantStaff:h,role:l},x);e(ue,{replace:!0})},5e3);return()=>clearTimeout(re)}},[r,c,u,l,e,N,x,n]);const W=async re=>{re.preventDefault(),k(!0);const ue=new FormData(re.currentTarget),ke=ue.get("signup-email"),L=ue.get("signup-password"),Q=ue.get("signup-name"),fe=ue.get("signup-phone");if(!ke||!L||!Q){K.error("Vul alle verplichte velden in"),k(!1);return}if(!$b(ke)){K.error("Ongeldig e-mailadres"),k(!1);return}if(fe&&!Fb(fe)){K.error("Ongeldig telefoonnummer"),k(!1);return}const ee=fS(L);if(!ee.valid){K.error(ee.message),k(!1);return}const je=`${window.location.origin}/`,{data:Ee,error:te}=await B.auth.signUp({email:ke,password:L,options:{emailRedirectTo:je,data:{full_name:Q}}});if(te){te.message.includes("already registered")?K.error("Dit e-mailadres is al geregistreerd. Probeer in te loggen."):K.error(te.message),k(!1);return}if(Ee.user){const{error:_e}=await B.from("profiles").insert({id:Ee.user.id,email:ke,full_name:Q,phone:fe||null});_e&&console.error("Error creating profile:",_e);const{error:Me}=await B.from("user_roles").insert({user_id:Ee.user.id,role:"customer"});Me&&console.error("Error assigning role:",Me),K.success("Account aangemaakt! Je bent nu ingelogd.")}k(!1)},ie=async re=>{re.preventDefault(),k(!0);const ue=new FormData(re.currentTarget),ke=ue.get("signin-email"),L=ue.get("signin-password");if(!ke||!L){K.error("Vul alle velden in"),k(!1);return}try{const{data:Q,error:fe}=await B.auth.signInWithPassword({email:ke,password:L});if(fe){fe.message.includes("Invalid login credentials")?K.error("Onjuiste inloggegevens"):K.error(fe.message),k(!1);return}await new Promise(je=>setTimeout(je,1e3));const{data:{session:ee}}=await B.auth.getSession();if(!ee){K.error("Login gelukt, maar sessie kon niet worden opgeslagen. Probeer het opnieuw."),k(!1);return}K.success("Welkom terug!"),k(!1)}catch(Q){console.error("[Auth] Unexpected error during login:",Q),K.error("Er ging iets mis. Probeer het opnieuw."),k(!1)}},oe=async re=>{re.preventDefault(),k(!0);const ke=new FormData(re.currentTarget).get("reset-email");if(!ke){K.error("Vul je e-mailadres in"),k(!1);return}const L=`${window.location.origin}/auth`,{error:Q}=await B.auth.resetPasswordForEmail(ke,{redirectTo:L});if(Q){K.error(Q.message),k(!1);return}K.success("Bestaat er een account met dit adres, dan is de link onderweg. Blijft het stil, dan is er nog geen account en heb je een uitnodiging nodig.",{duration:8e3}),E(!1),k(!1)},ce=async re=>{if(re.preventDefault(),k(!0),z!==I){K.error("Wachtwoorden komen niet overeen"),k(!1);return}const ue=fS(z);if(!ue.valid){K.error(ue.message),k(!1);return}const{error:ke}=await B.auth.updateUser({password:z});if(ke){K.error(ke.message),k(!1);return}K.success("Wachtwoord succesvol gewijzigd!"),O(!1),T(""),P(""),k(!1)};return!w&&x&&y?i.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:i.jsxs(dt,{className:"w-full max-w-md",children:[i.jsxs(ln,{className:"text-center",children:[i.jsx("div",{className:"mx-auto mb-4 h-12 w-12 rounded-full bg-destructive/10 flex items-center justify-center",children:i.jsx(Xw,{className:"h-6 w-6 text-destructive"})}),i.jsx(cn,{children:"Organisatie niet gevonden"}),i.jsxs(Os,{children:['De organisatie "',x,'" bestaat niet of is niet actief.']})]}),i.jsx(bt,{className:"flex justify-center",children:i.jsx(ne,{onClick:()=>e("/auth"),children:"Ga naar algemene login"})})]})}):N?i.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:i.jsxs("div",{className:"w-full max-w-md",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("div",{className:"inline-flex items-center justify-center mb-4",children:i.jsx("img",{src:C,alt:"nexus os",width:48,height:48,className:"h-14 w-14 object-contain"})}),i.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Nieuw wachtwoord"}),i.jsx("p",{className:"text-muted-foreground mt-2",children:"Stel je nieuwe wachtwoord in"})]}),i.jsxs(dt,{children:[i.jsxs(ln,{children:[i.jsx(cn,{children:"Nieuw wachtwoord instellen"}),i.jsx(Os,{children:"Voer je nieuwe wachtwoord in"})]}),i.jsx(bt,{children:i.jsxs("form",{onSubmit:ce,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Tt,{htmlFor:"new-password",children:"Nieuw wachtwoord"}),i.jsx(ot,{id:"new-password",type:"password",placeholder:"••••••••",value:z,onChange:re=>T(re.target.value),required:!0,minLength:8}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"Minimaal 8 tekens, 1 hoofdletter en 1 cijfer"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Tt,{htmlFor:"confirm-password",children:"Bevestig wachtwoord"}),i.jsx(ot,{id:"confirm-password",type:"password",placeholder:"••••••••",value:I,onChange:re=>P(re.target.value),required:!0,minLength:8})]}),i.jsx(ne,{type:"submit",className:"w-full",disabled:j,style:g?{backgroundColor:g}:void 0,children:j?"Bezig...":"Wachtwoord opslaan"})]})})]})]})}):w&&x?i.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:i.jsxs("div",{className:"text-center space-y-4",children:[i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Laden..."})]})}):r||!o?i.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:i.jsxs("div",{className:"text-center space-y-4",children:[i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Even geduld..."}),H&&i.jsxs(ne,{variant:"outline",size:"sm",onClick:F,className:"mt-4",children:[i.jsx(G5,{className:"h-4 w-4 mr-2"}),"App resetten"]})]})}):i.jsxs("div",{className:"min-h-screen bg-background flex",style:{"--org-primary":g||void 0,"--org-secondary":b||void 0},children:[i.jsx("div",{className:"w-full lg:w-1/2 flex items-center justify-center p-4",children:i.jsxs("div",{className:"w-full max-w-md",children:[i.jsxs(la,{to:"/",className:"mb-6 inline-flex items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",children:[i.jsx(Yw,{className:"h-4 w-4"})," Terug naar homepage"]}),i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("div",{className:"inline-flex items-center justify-center mb-4",children:i.jsx("img",{src:C,alt:"nexus os",width:48,height:48,className:"h-14 w-14 object-contain"})}),i.jsxs("h1",{className:"text-3xl font-bold text-foreground",children:["Welkom bij ",i.jsx("span",{className:"font-brand",children:"nexus os"})]}),i.jsx("p",{className:"text-muted-foreground mt-2",children:"Login of maak een account aan"})]}),S?i.jsxs(dt,{children:[i.jsxs(ln,{children:[i.jsx(cn,{children:"Wachtwoord vergeten"}),i.jsx(Os,{children:"Voer je e-mailadres in en we sturen je een reset link"})]}),i.jsx(bt,{children:i.jsxs("form",{onSubmit:oe,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Tt,{htmlFor:"reset-email",children:"E-mail"}),i.jsx(ot,{id:"reset-email",name:"reset-email",type:"email",placeholder:"jouw@email.nl",required:!0})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ne,{type:"button",variant:"outline",className:"flex-1",onClick:()=>E(!1),disabled:j,children:"Terug"}),i.jsx(ne,{type:"submit",className:"flex-1",disabled:j,style:g?{backgroundColor:g}:void 0,children:j?"Bezig...":"Verstuur reset link"})]})]})})]}):i.jsxs(AZ,{defaultValue:"signin",className:"w-full",children:[i.jsxs(qO,{className:"grid w-full grid-cols-2",children:[i.jsx(Rx,{value:"signin",children:"Inloggen"}),i.jsx(Rx,{value:"signup",children:"Registreren"})]}),i.jsx(Ox,{value:"signin",children:i.jsxs(dt,{children:[i.jsxs(ln,{children:[i.jsx(cn,{children:"Inloggen"}),i.jsx(Os,{children:"Log in met je account gegevens"})]}),i.jsx(bt,{children:i.jsxs("form",{onSubmit:ie,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Tt,{htmlFor:"signin-email",children:"E-mail"}),i.jsx(ot,{id:"signin-email",name:"signin-email",type:"email",placeholder:"jouw@email.nl",required:!0})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Tt,{htmlFor:"signin-password",children:"Wachtwoord"}),i.jsx(ot,{id:"signin-password",name:"signin-password",type:"password",placeholder:"••••••••",required:!0})]}),i.jsx(ne,{type:"submit",className:"w-full",disabled:j,style:g?{backgroundColor:g}:void 0,children:j?"Bezig...":"Inloggen"}),i.jsx(ne,{type:"button",variant:"link",className:"w-full text-sm",onClick:()=>E(!0),children:"Wachtwoord vergeten?"})]})})]})}),i.jsx(Ox,{value:"signup",children:i.jsxs(dt,{children:[i.jsxs(ln,{children:[i.jsx(cn,{children:"Registreren"}),i.jsx(Os,{children:"Maak een nieuw account aan"})]}),i.jsx(bt,{children:i.jsxs("form",{onSubmit:W,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Tt,{htmlFor:"signup-name",children:"Volledige naam *"}),i.jsx(ot,{id:"signup-name",name:"signup-name",type:"text",placeholder:"Jan Jansen",required:!0})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Tt,{htmlFor:"signup-email",children:"E-mail *"}),i.jsx(ot,{id:"signup-email",name:"signup-email",type:"email",placeholder:"jouw@email.nl",required:!0})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Tt,{htmlFor:"signup-phone",children:"Telefoonnummer"}),i.jsx(ot,{id:"signup-phone",name:"signup-phone",type:"tel",placeholder:"+31 6 12345678"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Tt,{htmlFor:"signup-password",children:"Wachtwoord *"}),i.jsx(ot,{id:"signup-password",name:"signup-password",type:"password",placeholder:"••••••••",required:!0,minLength:8}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"Minimaal 8 tekens, 1 hoofdletter en 1 cijfer"})]}),i.jsx(ne,{type:"submit",className:"w-full",disabled:j,style:g?{backgroundColor:g}:void 0,children:j?"Bezig...":"Account aanmaken"})]})})]})})]})]})}),i.jsx("div",{className:"hidden lg:block lg:w-1/2 relative",children:i.jsxs("div",{className:"absolute inset-0 bg-cover bg-center bg-no-repeat",style:{backgroundImage:`url('${(v==null?void 0:v.hero_image_url)||"https://images.unsplash.com/photo-1508514177221-188b1cf16e9d?ixlib=rb-4.0.3&auto=format&fit=crop&w=1920&q=80"}')`},children:[i.jsx("div",{className:"absolute inset-0",style:{backgroundColor:g?`${g}33`:"hsl(var(--primary) / 0.2)"}}),i.jsxs("div",{className:"absolute bottom-8 left-8 right-8 text-white",children:[i.jsx("p",{className:"text-lg opacity-90 mb-2",children:_?"Welkom":"Professioneel planningssysteem voor teams"}),i.jsx("h2",{className:"text-3xl font-bold",children:_||"nexus os"})]})]})}),i.jsx(OZ,{title:"Installeer Nexus.OS",description:"Zet de app op je beginscherm en open hem voortaan met één tik"})]})}const DZ=({organizationId:e,branche:t="algemeen",onNext:n})=>{const r=lc(t,"service"),s=lc(t,"services"),[a,o]=p.useState([]),[l,c]=p.useState(""),[u,d]=p.useState("knippen_blonderen"),[f,h]=p.useState(!0),[m,v]=p.useState(null),[w,y]=p.useState(null),[x,g]=p.useState(""),b=p.useCallback(async()=>{try{if(h(!0),v(null),!e){o([]);return}const{data:E,error:N}=await B.rpc("get_public_services_by_org",{org_id:e});if(N)throw N;o(E||[])}catch(E){console.error("Error fetching services:",E),v(`Kon ${s} niet laden. Probeer opnieuw.`)}finally{h(!1)}},[e,s]);p.useEffect(()=>{b();const E=setTimeout(()=>{h(N=>N&&(v("Laden duurde te lang. Probeer opnieuw."),!1))},15e3);return()=>clearTimeout(E)},[b]);const _=p.useMemo(()=>[...new Set(a.map(N=>N.category).filter(Boolean))],[a]);p.useEffect(()=>{_.length>0&&w===null&&y(_[0])},[_,w]);const j=p.useMemo(()=>x.trim()?a.filter(E=>{var N;return E.name.toLowerCase().includes(x.toLowerCase())||((N=E.description)==null?void 0:N.toLowerCase().includes(x.toLowerCase()))}):w?a.filter(E=>E.category===w):a,[a,w,x]),k=()=>{if(l){const E=a.find(N=>N.id===l);n({serviceId:l,serviceDuration:(E==null?void 0:E.duration_minutes)||30,serviceBuffer:(E==null?void 0:E.buffer_minutes)||0,appointmentType:u})}},S=a.find(E=>E.id===l);return f?i.jsx("div",{className:"flex items-center justify-center py-16",children:i.jsx(yn,{className:"h-6 w-6 animate-spin text-cta"})}):m?i.jsxs("div",{className:"flex flex-col items-center justify-center py-16 space-y-4",children:[i.jsx("p",{className:"text-destructive text-sm text-center",children:m}),i.jsxs(ne,{onClick:b,variant:"outline",className:"rounded-full text-sm",children:[i.jsx(qs,{className:"h-3.5 w-3.5 mr-2"}),"Opnieuw proberen"]})]}):!f&&a.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center py-16 space-y-4",children:[i.jsx("p",{className:"text-muted-foreground text-sm text-center",children:e?`Deze organisatie heeft nog geen ${s} geconfigureerd.`:`Er zijn momenteel geen ${s} beschikbaar.`}),i.jsxs(ne,{onClick:b,variant:"outline",className:"rounded-full text-sm",children:[i.jsx(qs,{className:"h-3.5 w-3.5 mr-2"}),"Opnieuw proberen"]})]}):i.jsxs("div",{className:"space-y-3",children:[_.length>1&&i.jsx("div",{className:"flex gap-1.5 flex-wrap",children:_.map(E=>i.jsx("button",{onClick:()=>{y(E),g("")},className:Y("px-3.5 py-1.5 rounded-full text-xs font-medium transition-all",!x&&w===E?"bg-cta text-cta-foreground":"bg-surface-cream text-ink-muted hover:text-foreground"),children:E},E))}),i.jsxs("div",{className:"flex items-center gap-2.5 bg-surface-cream rounded-xl px-3.5 py-2.5",children:[i.jsx(Q5,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),i.jsx("input",{value:x,onChange:E=>g(E.target.value),placeholder:`Zoek een ${r}`,className:"flex-1 bg-transparent border-none outline-none text-sm text-foreground placeholder:text-muted-foreground"})]}),i.jsxs("div",{className:"flex flex-col gap-1.5",children:[j.length===0&&i.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:["Geen ",s," gevonden"]}),j.map(E=>{const N=l===E.id;return i.jsxs("div",{onClick:()=>c(E.id),className:Y("flex items-start gap-3 p-3.5 rounded-xl cursor-pointer transition-all",N?"bg-cta/8 border-[1.5px] border-cta":"border-[1.5px] border-transparent hover:bg-surface-cream"),children:[i.jsx("div",{className:Y("w-5 h-5 rounded-full border-[1.5px] flex-shrink-0 mt-0.5 flex items-center justify-center transition-all",N?"border-cta bg-cta":"border-border bg-white"),children:N&&i.jsx(kc,{className:"h-3 w-3 text-white",strokeWidth:3})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex justify-between items-baseline gap-3",children:[i.jsx("span",{className:"text-[15px] font-semibold text-foreground",children:E.name}),E.price>0&&i.jsxs("span",{className:"text-[15px] font-medium text-foreground font-display tracking-tight whitespace-nowrap",children:["€",E.price.toFixed(0)]})]}),E.popular&&i.jsx("span",{className:"inline-flex items-center gap-1 bg-[#fff4e0] text-[#b45a0f] px-2 py-0.5 rounded-full text-[10px] font-semibold mt-1.5 tracking-wide",children:"★ Meest geboekt"}),(E.duration_minutes>0||E.description)&&i.jsx("p",{className:"text-[13px] text-muted-foreground mt-1.5 leading-relaxed",children:[E.duration_minutes>0?`${E.duration_minutes} min`:null,E.description||null].filter(Boolean).join(" · ")})]})]},E.id)})]}),i.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-border/60",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Totaal"}),i.jsx("div",{className:"text-xl font-bold text-foreground font-display tracking-tight leading-tight",children:S?`€${S.price.toFixed(0)}`:"—"})]}),i.jsx(ne,{onClick:k,disabled:!l,className:"rounded-full px-5 py-2.5 text-sm font-semibold bg-cta text-cta-foreground hover:bg-cta/90 disabled:bg-border disabled:text-muted-foreground",children:"Volgende →"})]})]})},IZ={electricien:{label:"Electricien",icon:i.jsx(Ju,{className:"h-3 w-3"}),color:"bg-yellow-500/20 text-yellow-700 border-yellow-500/30"},monteur_allround:{label:"Monteur Allround",icon:i.jsx(fo,{className:"h-3 w-3"}),color:"bg-blue-500/20 text-blue-700 border-blue-500/30"},dakmonteur:{label:"Dakmonteur",icon:i.jsx(Nd,{className:"h-3 w-3"}),color:"bg-orange-500/20 text-orange-700 border-orange-500/30"},bbl:{label:"Leerling (BBL)",icon:i.jsx(R5,{className:"h-3 w-3"}),color:"bg-green-500/20 text-green-700 border-green-500/30"},barber:{label:"Barbier",icon:i.jsx(bf,{className:"h-3 w-3"}),color:"bg-purple-500/20 text-purple-700 border-purple-500/30"},colorist:{label:"Colorist",icon:i.jsx(bf,{className:"h-3 w-3"}),color:"bg-pink-500/20 text-pink-700 border-pink-500/30"},kapper:{label:"Kapper",icon:i.jsx(bf,{className:"h-3 w-3"}),color:"bg-indigo-500/20 text-indigo-700 border-indigo-500/30"},stylist:{label:"Stylist",icon:i.jsx(bf,{className:"h-3 w-3"}),color:"bg-teal-500/20 text-teal-700 border-teal-500/30"}},LZ=({serviceId:e,organizationId:t,onNext:n,onBack:r})=>{const[s,a]=p.useState([]),[o,l]=p.useState(new Set),[c,u]=p.useState(""),[d,f]=p.useState(!0),[h,m]=p.useState(null),v=async()=>{try{if(m(null),f(!0),!t){const{data:b,error:_}=await B.rpc("get_public_staff");if(_)throw _;a(b||[]),l(new Set((b||[]).map(j=>j.id)));return}const{data:x,error:g}=await B.rpc("get_public_staff_by_org",{org_id:t});if(g)throw g;if(a(x||[]),e){const{data:b,error:_}=await B.rpc("get_public_staff_for_service_by_org",{p_service_id:e,org_id:t});if(_)throw _;const j=new Set((b||[]).map(k=>k.id));l(j),b&&b.length===1&&u(b[0].id)}else l(new Set((x||[]).map(b=>b.id)))}catch(x){console.error("Error fetching staff:",x),m("Kon medewerkers niet laden. Probeer opnieuw.")}finally{f(!1)}};p.useEffect(()=>{v();const x=setTimeout(()=>{f(g=>g&&(m("Laden duurde te lang. Probeer de pagina te vernieuwen."),!1))},1e4);return()=>clearTimeout(x)},[e,t]);const w=x=>{o.has(x)&&u(x)};if(d)return i.jsx("div",{className:"flex items-center justify-center py-16",children:i.jsx(yn,{className:"h-6 w-6 animate-spin text-cta"})});if(h)return i.jsxs("div",{className:"text-center py-16 space-y-4",children:[i.jsx("p",{className:"text-destructive text-sm",children:h}),i.jsxs(ne,{onClick:v,variant:"outline",className:"rounded-full text-sm",children:[i.jsx(qs,{className:"h-3.5 w-3.5 mr-2"}),"Opnieuw proberen"]})]});if(!d&&s.length===0)return i.jsxs("div",{className:"text-center py-16 space-y-4",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:"Er zijn momenteel geen medewerkers beschikbaar."}),i.jsxs(ne,{onClick:v,variant:"outline",className:"rounded-full text-sm",children:[i.jsx(qs,{className:"h-3.5 w-3.5 mr-2"}),"Opnieuw proberen"]})]});const y=s.find(x=>x.id===c);return i.jsx(s2,{children:i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:"flex flex-col gap-2",children:s.map(x=>{const g=x.specialization?IZ[x.specialization]:null,b=o.has(x.id),_=c===x.id,j=i.jsxs("div",{onClick:()=>w(x.id),className:Y("flex items-center gap-3.5 p-3.5 rounded-xl transition-all",b?Y("cursor-pointer",_?"bg-cta/8 border-[1.5px] border-cta":"bg-surface-cream border-[1.5px] border-transparent hover:border-border"):"opacity-40 cursor-not-allowed border-[1.5px] border-transparent"),children:[i.jsx(Md,{className:"h-12 w-12 flex-shrink-0",children:i.jsx(Dd,{className:Y("text-sm font-medium",b?"bg-surface-cream text-ink-muted":"bg-muted text-muted-foreground"),children:x.name.split(" ").map(k=>k[0]).join("")})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:Y("text-[15px] font-semibold truncate",b?"text-foreground":"text-muted-foreground"),children:x.name}),x.is_primary&&b&&i.jsx(s$,{className:"h-3.5 w-3.5 fill-yellow-400 text-yellow-400 flex-shrink-0"})]}),g&&i.jsxs(Qe,{variant:"outline",className:Y("mt-1 text-[10px]",b?g.color:"bg-muted/50 text-muted-foreground border-muted"),children:[g.icon,i.jsx("span",{className:"ml-1",children:g.label})]}),!b&&i.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"Biedt deze dienst niet aan"})]}),i.jsx("div",{className:Y("w-5 h-5 rounded-full border-[1.5px] flex-shrink-0 flex items-center justify-center transition-all",_?"border-cta bg-cta":b?"border-border bg-white":"border-muted bg-muted/30"),children:_&&i.jsx(kc,{className:"h-3 w-3 text-white",strokeWidth:3})})]},x.id);return b?i.jsx("div",{children:j},x.id):i.jsxs(Fz,{children:[i.jsx(zz,{asChild:!0,children:j}),i.jsx(a2,{children:i.jsxs("p",{children:[x.name," biedt de geselecteerde dienst niet aan"]})})]},x.id)})}),i.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-border/60",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Medewerker"}),i.jsx("div",{className:"text-base font-semibold text-foreground leading-tight",children:y?y.name:"Nog niet gekozen"})]}),i.jsx(ne,{onClick:()=>n(c),disabled:!c,className:"rounded-full px-5 py-2.5 text-sm font-semibold bg-cta text-cta-foreground hover:bg-cta/90 disabled:bg-border disabled:text-muted-foreground",children:"Volgende →"})]})]})})};var Ie=function(){return Ie=Object.assign||function(t){for(var n,r=1,s=arguments.length;r1&&(c||!u),f=t>1&&(u||!c),h=function(){r&&a(r)},m=function(){s&&a(s)};return i.jsx(gJ,{displayMonth:e.displayMonth,hideNext:d,hidePrevious:f,nextMonth:s,previousMonth:r,onPreviousClick:h,onNextClick:m})}function yJ(e){var t,n=St(),r=n.classNames,s=n.disableNavigation,a=n.styles,o=n.captionLayout,l=n.components,c=(t=l==null?void 0:l.CaptionLabel)!==null&&t!==void 0?t:XO,u;return s?u=i.jsx(c,{id:e.id,displayMonth:e.displayMonth}):o==="dropdown"?u=i.jsx(mS,{displayMonth:e.displayMonth,id:e.id}):o==="dropdown-buttons"?u=i.jsxs(i.Fragment,{children:[i.jsx(mS,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),i.jsx(pS,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}):u=i.jsxs(i.Fragment,{children:[i.jsx(c,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),i.jsx(pS,{displayMonth:e.displayMonth,id:e.id})]}),i.jsx("div",{className:r.caption,style:a.caption,children:u})}function vJ(e){var t=St(),n=t.footer,r=t.styles,s=t.classNames.tfoot;return n?i.jsx("tfoot",{className:s,style:r.tfoot,children:i.jsx("tr",{children:i.jsx("td",{colSpan:8,children:n})})}):i.jsx(i.Fragment,{})}function xJ(e,t,n){for(var r=n?_a(new Date):Pn(new Date,{locale:e,weekStartsOn:t}),s=[],a=0;a<7;a++){var o=mt(r,a);s.push(o)}return s}function wJ(){var e=St(),t=e.classNames,n=e.styles,r=e.showWeekNumber,s=e.locale,a=e.weekStartsOn,o=e.ISOWeek,l=e.formatters.formatWeekdayName,c=e.labels.labelWeekday,u=xJ(s,a,o);return i.jsxs("tr",{style:n.head_row,className:t.head_row,children:[r&&i.jsx("td",{style:n.head_cell,className:t.head_cell}),u.map(function(d,f){return i.jsx("th",{scope:"col",className:t.head_cell,style:n.head_cell,"aria-label":c(d,{locale:s}),children:l(d,{locale:s})},f)})]})}function bJ(){var e,t=St(),n=t.classNames,r=t.styles,s=t.components,a=(e=s==null?void 0:s.HeadRow)!==null&&e!==void 0?e:wJ;return i.jsx("thead",{style:r.head,className:n.head,children:i.jsx(a,{})})}function _J(e){var t=St(),n=t.locale,r=t.formatters.formatDay;return i.jsx(i.Fragment,{children:r(e.date,{locale:n})})}var zb=p.createContext(void 0);function kJ(e){if(!Kd(e.initialProps)){var t={selected:void 0,modifiers:{disabled:[]}};return i.jsx(zb.Provider,{value:t,children:e.children})}return i.jsx(jJ,{initialProps:e.initialProps,children:e.children})}function jJ(e){var t=e.initialProps,n=e.children,r=t.selected,s=t.min,a=t.max,o=function(u,d,f){var h,m;(h=t.onDayClick)===null||h===void 0||h.call(t,u,d,f);var v=!!(d.selected&&s&&(r==null?void 0:r.length)===s);if(!v){var w=!!(!d.selected&&a&&(r==null?void 0:r.length)===a);if(!w){var y=r?YO([],r):[];if(d.selected){var x=y.findIndex(function(g){return mr(u,g)});y.splice(x,1)}else y.push(u);(m=t.onSelect)===null||m===void 0||m.call(t,y,u,d,f)}}},l={disabled:[]};r&&l.disabled.push(function(u){var d=a&&r.length>a-1,f=r.some(function(h){return mr(h,u)});return!!(d&&!f)});var c={selected:r,onDayClick:o,modifiers:l};return i.jsx(zb.Provider,{value:c,children:n})}function Bb(){var e=p.useContext(zb);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}function SJ(e,t){var n=t||{},r=n.from,s=n.to;return r&&s?mr(s,e)&&mr(r,e)?void 0:mr(s,e)?{from:s,to:void 0}:mr(r,e)?void 0:Sx(r,e)?{from:e,to:s}:{from:r,to:e}:s?Sx(e,s)?{from:s,to:e}:{from:e,to:s}:r?J0(e,r)?{from:e,to:r}:{from:r,to:e}:{from:e,to:void 0}}var Ub=p.createContext(void 0);function EJ(e){if(!Gd(e.initialProps)){var t={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return i.jsx(Ub.Provider,{value:t,children:e.children})}return i.jsx(NJ,{initialProps:e.initialProps,children:e.children})}function NJ(e){var t=e.initialProps,n=e.children,r=t.selected,s=r||{},a=s.from,o=s.to,l=t.min,c=t.max,u=function(m,v,w){var y,x;(y=t.onDayClick)===null||y===void 0||y.call(t,m,v,w);var g=SJ(m,r);(x=t.onSelect)===null||x===void 0||x.call(t,g,m,v,w)},d={range_start:[],range_end:[],range_middle:[],disabled:[]};if(a?(d.range_start=[a],o?(d.range_end=[o],mr(a,o)||(d.range_middle=[{after:a,before:o}])):d.range_end=[a]):o&&(d.range_start=[o],d.range_end=[o]),l&&(a&&!o&&d.disabled.push({after:Jg(a,l-1),before:mt(a,l-1)}),a&&o&&d.disabled.push({after:a,before:mt(a,l-1)}),!a&&o&&d.disabled.push({after:Jg(o,l-1),before:mt(o,l-1)})),c){if(a&&!o&&(d.disabled.push({before:mt(a,-c+1)}),d.disabled.push({after:mt(a,c-1)})),a&&o){var f=Fs(o,a)+1,h=c-f;d.disabled.push({before:Jg(a,h)}),d.disabled.push({after:mt(o,h)})}!a&&o&&(d.disabled.push({before:mt(o,-c+1)}),d.disabled.push({after:mt(o,c-1)}))}return i.jsx(Ub.Provider,{value:{selected:r,onDayClick:u,modifiers:d},children:n})}function Vb(){var e=p.useContext(Ub);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function xh(e){return Array.isArray(e)?YO([],e):e!==void 0?[e]:[]}function CJ(e){var t={};return Object.entries(e).forEach(function(n){var r=n[0],s=n[1];t[r]=xh(s)}),t}var bs;(function(e){e.Outside="outside",e.Disabled="disabled",e.Selected="selected",e.Hidden="hidden",e.Today="today",e.RangeStart="range_start",e.RangeEnd="range_end",e.RangeMiddle="range_middle"})(bs||(bs={}));var TJ=bs.Selected,na=bs.Disabled,PJ=bs.Hidden,AJ=bs.Today,jy=bs.RangeEnd,Sy=bs.RangeMiddle,Ey=bs.RangeStart,RJ=bs.Outside;function OJ(e,t,n){var r,s=(r={},r[TJ]=xh(e.selected),r[na]=xh(e.disabled),r[PJ]=xh(e.hidden),r[AJ]=[e.today],r[jy]=[],r[Sy]=[],r[Ey]=[],r[RJ]=[],r);return e.fromDate&&s[na].push({before:e.fromDate}),e.toDate&&s[na].push({after:e.toDate}),Kd(e)?s[na]=s[na].concat(t.modifiers[na]):Gd(e)&&(s[na]=s[na].concat(n.modifiers[na]),s[Ey]=n.modifiers[Ey],s[Sy]=n.modifiers[Sy],s[jy]=n.modifiers[jy]),s}var eM=p.createContext(void 0);function MJ(e){var t=St(),n=Bb(),r=Vb(),s=OJ(t,n,r),a=CJ(t.modifiers),o=Ie(Ie({},s),a);return i.jsx(eM.Provider,{value:o,children:e.children})}function tM(){var e=p.useContext(eM);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function DJ(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function IJ(e){return!!(e&&typeof e=="object"&&"from"in e)}function LJ(e){return!!(e&&typeof e=="object"&&"after"in e)}function $J(e){return!!(e&&typeof e=="object"&&"before"in e)}function FJ(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function zJ(e,t){var n,r=t.from,s=t.to;if(r&&s){var a=Fs(s,r)<0;a&&(n=[s,r],r=n[0],s=n[1]);var o=Fs(e,r)>=0&&Fs(s,e)>=0;return o}return s?mr(s,e):r?mr(r,e):!1}function BJ(e){return Q0(e)}function UJ(e){return Array.isArray(e)&&e.every(Q0)}function VJ(e,t){return t.some(function(n){if(typeof n=="boolean")return n;if(BJ(n))return mr(e,n);if(UJ(n))return n.includes(e);if(IJ(n))return zJ(e,n);if(FJ(n))return n.dayOfWeek.includes(e.getDay());if(DJ(n)){var r=Fs(n.before,e),s=Fs(n.after,e),a=r>0,o=s<0,l=Sx(n.before,n.after);return l?o&&a:a||o}return LJ(n)?Fs(e,n.after)>0:$J(n)?Fs(n.before,e)>0:typeof n=="function"?n(e):!1})}function Wb(e,t,n){var r=Object.keys(t).reduce(function(a,o){var l=t[o];return VJ(e,l)&&a.push(o),a},[]),s={};return r.forEach(function(a){return s[a]=!0}),n&&!vp(e,n)&&(s.outside=!0),s}function WJ(e,t){for(var n=Yn(e[0]),r=gp(e[e.length-1]),s,a,o=n;o<=r;){var l=Wb(o,t),c=!l.disabled&&!l.hidden;if(!c){o=mt(o,1);continue}if(l.selected)return o;l.today&&!a&&(a=o),s||(s=o),o=mt(o,1)}return a||s}var HJ=365;function nM(e,t){var n=t.moveBy,r=t.direction,s=t.context,a=t.modifiers,o=t.retry,l=o===void 0?{count:0,lastFocused:e}:o,c=s.weekStartsOn,u=s.fromDate,d=s.toDate,f=s.locale,h={day:mt,week:_x,month:Pr,year:kW,startOfWeek:function(y){return s.ISOWeek?_a(y):Pn(y,{locale:f,weekStartsOn:c})},endOfWeek:function(y){return s.ISOWeek?tA(y):ko(y,{locale:f,weekStartsOn:c})}},m=h[n](e,r==="after"?1:-1);r==="before"&&u?m=jW([u,m]):r==="after"&&d&&(m=SW([d,m]));var v=!0;if(a){var w=Wb(m,a);v=!w.disabled&&!w.hidden}return v?m:l.count>HJ?l.lastFocused:nM(m,{moveBy:n,direction:r,context:s,modifiers:a,retry:Ie(Ie({},l),{count:l.count+1})})}var rM=p.createContext(void 0);function qJ(e){var t=Yd(),n=tM(),r=p.useState(),s=r[0],a=r[1],o=p.useState(),l=o[0],c=o[1],u=WJ(t.displayMonths,n),d=s??(l&&t.isDateDisplayed(l))?l:u,f=function(){c(s),a(void 0)},h=function(y){a(y)},m=St(),v=function(y,x){if(s){var g=nM(s,{moveBy:y,direction:x,context:m,modifiers:n});mr(s,g)||(t.goToDate(g,s),h(g))}},w={focusedDay:s,focusTarget:d,blur:f,focus:h,focusDayAfter:function(){return v("day","after")},focusDayBefore:function(){return v("day","before")},focusWeekAfter:function(){return v("week","after")},focusWeekBefore:function(){return v("week","before")},focusMonthBefore:function(){return v("month","before")},focusMonthAfter:function(){return v("month","after")},focusYearBefore:function(){return v("year","before")},focusYearAfter:function(){return v("year","after")},focusStartOfWeek:function(){return v("startOfWeek","before")},focusEndOfWeek:function(){return v("endOfWeek","after")}};return i.jsx(rM.Provider,{value:w,children:e.children})}function Hb(){var e=p.useContext(rM);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}function KJ(e,t){var n=tM(),r=Wb(e,n,t);return r}var qb=p.createContext(void 0);function GJ(e){if(!Dp(e.initialProps)){var t={selected:void 0};return i.jsx(qb.Provider,{value:t,children:e.children})}return i.jsx(YJ,{initialProps:e.initialProps,children:e.children})}function YJ(e){var t=e.initialProps,n=e.children,r=function(a,o,l){var c,u,d;if((c=t.onDayClick)===null||c===void 0||c.call(t,a,o,l),o.selected&&!t.required){(u=t.onSelect)===null||u===void 0||u.call(t,void 0,a,o,l);return}(d=t.onSelect)===null||d===void 0||d.call(t,a,a,o,l)},s={selected:t.selected,onDayClick:r};return i.jsx(qb.Provider,{value:s,children:n})}function sM(){var e=p.useContext(qb);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function QJ(e,t){var n=St(),r=sM(),s=Bb(),a=Vb(),o=Hb(),l=o.focusDayAfter,c=o.focusDayBefore,u=o.focusWeekAfter,d=o.focusWeekBefore,f=o.blur,h=o.focus,m=o.focusMonthBefore,v=o.focusMonthAfter,w=o.focusYearBefore,y=o.focusYearAfter,x=o.focusStartOfWeek,g=o.focusEndOfWeek,b=function(M){var C,F,W,ie;Dp(n)?(C=r.onDayClick)===null||C===void 0||C.call(r,e,t,M):Kd(n)?(F=s.onDayClick)===null||F===void 0||F.call(s,e,t,M):Gd(n)?(W=a.onDayClick)===null||W===void 0||W.call(a,e,t,M):(ie=n.onDayClick)===null||ie===void 0||ie.call(n,e,t,M)},_=function(M){var C;h(e),(C=n.onDayFocus)===null||C===void 0||C.call(n,e,t,M)},j=function(M){var C;f(),(C=n.onDayBlur)===null||C===void 0||C.call(n,e,t,M)},k=function(M){var C;(C=n.onDayMouseEnter)===null||C===void 0||C.call(n,e,t,M)},S=function(M){var C;(C=n.onDayMouseLeave)===null||C===void 0||C.call(n,e,t,M)},E=function(M){var C;(C=n.onDayPointerEnter)===null||C===void 0||C.call(n,e,t,M)},N=function(M){var C;(C=n.onDayPointerLeave)===null||C===void 0||C.call(n,e,t,M)},O=function(M){var C;(C=n.onDayTouchCancel)===null||C===void 0||C.call(n,e,t,M)},z=function(M){var C;(C=n.onDayTouchEnd)===null||C===void 0||C.call(n,e,t,M)},T=function(M){var C;(C=n.onDayTouchMove)===null||C===void 0||C.call(n,e,t,M)},I=function(M){var C;(C=n.onDayTouchStart)===null||C===void 0||C.call(n,e,t,M)},P=function(M){var C;(C=n.onDayKeyUp)===null||C===void 0||C.call(n,e,t,M)},H=function(M){var C;switch(M.key){case"ArrowLeft":M.preventDefault(),M.stopPropagation(),n.dir==="rtl"?l():c();break;case"ArrowRight":M.preventDefault(),M.stopPropagation(),n.dir==="rtl"?c():l();break;case"ArrowDown":M.preventDefault(),M.stopPropagation(),u();break;case"ArrowUp":M.preventDefault(),M.stopPropagation(),d();break;case"PageUp":M.preventDefault(),M.stopPropagation(),M.shiftKey?w():m();break;case"PageDown":M.preventDefault(),M.stopPropagation(),M.shiftKey?y():v();break;case"Home":M.preventDefault(),M.stopPropagation(),x();break;case"End":M.preventDefault(),M.stopPropagation(),g();break}(C=n.onDayKeyDown)===null||C===void 0||C.call(n,e,t,M)},V={onClick:b,onFocus:_,onBlur:j,onKeyDown:H,onKeyUp:P,onMouseEnter:k,onMouseLeave:S,onPointerEnter:E,onPointerLeave:N,onTouchCancel:O,onTouchEnd:z,onTouchMove:T,onTouchStart:I};return V}function XJ(){var e=St(),t=sM(),n=Bb(),r=Vb(),s=Dp(e)?t.selected:Kd(e)?n.selected:Gd(e)?r.selected:void 0;return s}function ZJ(e){return Object.values(bs).includes(e)}function JJ(e,t){var n=[e.classNames.day];return Object.keys(t).forEach(function(r){var s=e.modifiersClassNames[r];if(s)n.push(s);else if(ZJ(r)){var a=e.classNames["day_".concat(r)];a&&n.push(a)}}),n}function eee(e,t){var n=Ie({},e.styles.day);return Object.keys(t).forEach(function(r){var s;n=Ie(Ie({},n),(s=e.modifiersStyles)===null||s===void 0?void 0:s[r])}),n}function tee(e,t,n){var r,s,a,o=St(),l=Hb(),c=KJ(e,t),u=QJ(e,c),d=XJ(),f=!!(o.onDayClick||o.mode!=="default");p.useEffect(function(){var k;c.outside||l.focusedDay&&f&&mr(l.focusedDay,e)&&((k=n.current)===null||k===void 0||k.focus())},[l.focusedDay,e,n,f,c.outside]);var h=JJ(o,c).join(" "),m=eee(o,c),v=!!(c.outside&&!o.showOutsideDays||c.hidden),w=(a=(s=o.components)===null||s===void 0?void 0:s.DayContent)!==null&&a!==void 0?a:_J,y=i.jsx(w,{date:e,displayMonth:t,activeModifiers:c}),x={style:m,className:h,children:y,role:"gridcell"},g=l.focusTarget&&mr(l.focusTarget,e)&&!c.outside,b=l.focusedDay&&mr(l.focusedDay,e),_=Ie(Ie(Ie({},x),(r={disabled:c.disabled,role:"gridcell"},r["aria-selected"]=c.selected,r.tabIndex=b||g?0:-1,r)),u),j={isButton:f,isHidden:v,activeModifiers:c,selectedDays:d,buttonProps:_,divProps:x};return j}function nee(e){var t=p.useRef(null),n=tee(e.date,e.displayMonth,t);return n.isHidden?i.jsx("div",{role:"gridcell"}):n.isButton?i.jsx(pm,Ie({name:"day",ref:t},n.buttonProps)):i.jsx("div",Ie({},n.divProps))}function ree(e){var t=e.number,n=e.dates,r=St(),s=r.onWeekNumberClick,a=r.styles,o=r.classNames,l=r.locale,c=r.labels.labelWeekNumber,u=r.formatters.formatWeekNumber,d=u(Number(t),{locale:l});if(!s)return i.jsx("span",{className:o.weeknumber,style:a.weeknumber,children:d});var f=c(Number(t),{locale:l}),h=function(m){s(t,n,m)};return i.jsx(pm,{name:"week-number","aria-label":f,className:o.weeknumber,style:a.weeknumber,onClick:h,children:d})}function see(e){var t,n,r=St(),s=r.styles,a=r.classNames,o=r.showWeekNumber,l=r.components,c=(t=l==null?void 0:l.Day)!==null&&t!==void 0?t:nee,u=(n=l==null?void 0:l.WeekNumber)!==null&&n!==void 0?n:ree,d;return o&&(d=i.jsx("td",{className:a.cell,style:s.cell,children:i.jsx(u,{number:e.weekNumber,dates:e.dates})})),i.jsxs("tr",{className:a.row,style:s.row,children:[d,e.dates.map(function(f){return i.jsx("td",{className:a.cell,style:s.cell,role:"presentation",children:i.jsx(c,{displayMonth:e.displayMonth,date:f})},b7(f))})]})}function gS(e,t,n){for(var r=n!=null&&n.ISOWeek?tA(t):ko(t,n),s=n!=null&&n.ISOWeek?_a(e):Pn(e,n),a=Fs(r,s),o=[],l=0;l<=a;l++)o.push(mt(s,l));var c=o.reduce(function(u,d){var f=n!=null&&n.ISOWeek?Od(d):yp(d,n),h=u.find(function(m){return m.weekNumber===f});return h?(h.dates.push(d),u):(u.push({weekNumber:f,dates:[d]}),u)},[]);return c}function aee(e,t){var n=gS(Yn(e),gp(e),t);if(t!=null&&t.useFixedWeeks){var r=k7(e,t);if(r<6){var s=n[n.length-1],a=s.dates[s.dates.length-1],o=_x(a,6-r),l=gS(_x(a,1),o,t);n.push.apply(n,l)}}return n}function oee(e){var t,n,r,s=St(),a=s.locale,o=s.classNames,l=s.styles,c=s.hideHead,u=s.fixedWeeks,d=s.components,f=s.weekStartsOn,h=s.firstWeekContainsDate,m=s.ISOWeek,v=aee(e.displayMonth,{useFixedWeeks:!!u,ISOWeek:m,locale:a,weekStartsOn:f,firstWeekContainsDate:h}),w=(t=d==null?void 0:d.Head)!==null&&t!==void 0?t:bJ,y=(n=d==null?void 0:d.Row)!==null&&n!==void 0?n:see,x=(r=d==null?void 0:d.Footer)!==null&&r!==void 0?r:vJ;return i.jsxs("table",{id:e.id,className:o.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!c&&i.jsx(w,{}),i.jsx("tbody",{className:o.tbody,style:l.tbody,children:v.map(function(g){return i.jsx(y,{displayMonth:e.displayMonth,dates:g.dates,weekNumber:g.weekNumber},g.weekNumber)})}),i.jsx(x,{displayMonth:e.displayMonth})]})}function iee(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var lee=iee()?p.useLayoutEffect:p.useEffect,Ny=!1,cee=0;function yS(){return"react-day-picker-".concat(++cee)}function uee(e){var t,n=e??(Ny?yS():null),r=p.useState(n),s=r[0],a=r[1];return lee(function(){s===null&&a(yS())},[]),p.useEffect(function(){Ny===!1&&(Ny=!0)},[]),(t=e??s)!==null&&t!==void 0?t:void 0}function dee(e){var t,n,r=St(),s=r.dir,a=r.classNames,o=r.styles,l=r.components,c=Yd().displayMonths,u=uee(r.id?"".concat(r.id,"-").concat(e.displayIndex):void 0),d=r.id?"".concat(r.id,"-grid-").concat(e.displayIndex):void 0,f=[a.month],h=o.month,m=e.displayIndex===0,v=e.displayIndex===c.length-1,w=!m&&!v;s==="rtl"&&(t=[m,v],v=t[0],m=t[1]),m&&(f.push(a.caption_start),h=Ie(Ie({},h),o.caption_start)),v&&(f.push(a.caption_end),h=Ie(Ie({},h),o.caption_end)),w&&(f.push(a.caption_between),h=Ie(Ie({},h),o.caption_between));var y=(n=l==null?void 0:l.Caption)!==null&&n!==void 0?n:yJ;return i.jsxs("div",{className:f.join(" "),style:h,children:[i.jsx(y,{id:u,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),i.jsx(oee,{id:d,"aria-labelledby":u,displayMonth:e.displayMonth})]},e.displayIndex)}function fee(e){var t=St(),n=t.classNames,r=t.styles;return i.jsx("div",{className:n.months,style:r.months,children:e.children})}function hee(e){var t,n,r=e.initialProps,s=St(),a=Hb(),o=Yd(),l=p.useState(!1),c=l[0],u=l[1];p.useEffect(function(){s.initialFocus&&a.focusTarget&&(c||(a.focus(a.focusTarget),u(!0)))},[s.initialFocus,c,a.focus,a.focusTarget,a]);var d=[s.classNames.root,s.className];s.numberOfMonths>1&&d.push(s.classNames.multiple_months),s.showWeekNumber&&d.push(s.classNames.with_weeknumber);var f=Ie(Ie({},s.styles.root),s.style),h=Object.keys(r).filter(function(v){return v.startsWith("data-")}).reduce(function(v,w){var y;return Ie(Ie({},v),(y={},y[w]=r[w],y))},{}),m=(n=(t=r.components)===null||t===void 0?void 0:t.Months)!==null&&n!==void 0?n:fee;return i.jsx("div",Ie({className:d.join(" "),style:f,dir:s.dir,id:s.id,nonce:r.nonce,title:r.title,lang:r.lang},h,{children:i.jsx(m,{children:o.displayMonths.map(function(v,w){return i.jsx(dee,{displayIndex:w,displayMonth:v},w)})})}))}function mee(e){var t=e.children,n=$Z(e,["children"]);return i.jsx(rJ,{initialProps:n,children:i.jsx(hJ,{children:i.jsx(GJ,{initialProps:n,children:i.jsx(kJ,{initialProps:n,children:i.jsx(EJ,{initialProps:n,children:i.jsx(MJ,{children:i.jsx(qJ,{children:t})})})})})})})}function pee(e){return i.jsx(mee,Ie({},e,{children:i.jsx(hee,{initialProps:e})}))}function $c({className:e,classNames:t,showOutsideDays:n=!0,...r}){return i.jsx(pee,{showOutsideDays:n,className:Y("p-3",e),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:Y(dd({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:Y(dd({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:"ring-1 ring-inset ring-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",...t},components:{IconLeft:({...s})=>i.jsx(fT,{className:"h-4 w-4"}),IconRight:({...s})=>i.jsx(Gm,{className:"h-4 w-4"})},...r})}$c.displayName="Calendar";const gee={0:"zo",1:"ma",2:"di",3:"wo",4:"do",5:"vr",6:"za"};var fE;const yee=((fE=Cp.find(e=>e.key==="work_start_time"))==null?void 0:fE.defaultValue)||"08:00";var hE;const vee=((hE=Cp.find(e=>e.key==="work_end_time"))==null?void 0:hE.defaultValue)||"17:00";var mE;const xee=((mE=Cp.find(e=>e.key==="work_days"))==null?void 0:mE.defaultValue)||["ma","di","wo","do","vr"];function aM(e,t,n=30){const[r,s]=e.split(":").map(Number),[a,o]=t.split(":").map(Number),l=r*60+s,c=a*60+o,u=[];for(let d=l;d{const o=r("work_start_time")||yee,l=r("work_end_time")||vee,c=r("work_days")||xee,u=parseInt(o.split(":")[0],10),d=parseInt(l.split(":")[0],10),f=aM(o,l);return{workStartTime:o,workEndTime:l,workDays:c,timeSlots:f,startHour:u,endHour:d,isLoading:s}},[r,s])}const wee={0:1,1:2,2:3,3:4,4:5,5:6,6:0},vS={1:0,2:1,3:2,4:3,5:4,6:5,0:6};function lM(e,t){const[n,r]=p.useState([]),[s,a]=p.useState(!0),o=iM(t);p.useEffect(()=>{if(!e){a(!1);return}(async()=>{a(!0);try{const{data:h,error:m}=await B.rpc("get_public_staff_working_hours",{p_staff_id:e});m?(console.error("Error fetching staff working hours:",m),r([])):r((h||[]).map(v=>({dayOfWeek:v.day_of_week,startTime:v.start_time.slice(0,5),endTime:v.end_time.slice(0,5)})))}catch{r([])}finally{a(!1)}})()},[e]);const l=n.length>0,c=p.useMemo(()=>{if(!l)return h=>oM(h,o.workDays);const f=new Set(n.map(h=>wee[h.dayOfWeek]));return h=>f.has(h.getDay())},[l,n,o.workDays]),u=p.useMemo(()=>l?f=>{const h=vS[f.getDay()],m=n.find(v=>v.dayOfWeek===h);return m?aM(m.startTime,m.endTime):[]}:f=>o.timeSlots,[l,n,o.timeSlots]),d=p.useMemo(()=>l?f=>{const h=vS[f.getDay()],m=n.find(v=>v.dayOfWeek===h);return m?parseInt(m.endTime.split(":")[0],10):o.endHour}:f=>o.endHour,[l,n,o.endHour]);return{hasIndividualHours:l,isStaffWorkingDay:c,getTimeSlotsForDate:u,getEndHourForDate:d,schedules:n,isLoading:s||o.isLoading}}const bee=({staffId:e,serviceId:t,organizationId:n,onNext:r,onBack:s})=>{const[a,o]=p.useState(void 0),[l,c]=p.useState(null),[u,d]=p.useState([]),[f,h]=p.useState([]),[m,v]=p.useState(null),[w,y]=p.useState(!0),{workStartTime:x,workEndTime:g,workDays:b,isLoading:_}=iM(n),{isStaffWorkingDay:j,isLoading:k}=lM(e,n),S=p.useMemo(()=>{const T=parseInt(x.split(":")[0],10),I=parseInt(g.split(":")[0],10),H=`${Math.floor((T+I)/2).toString().padStart(2,"0")}:00`;return{ochtend:{label:"Ochtend",time:`${x} - ${H}`,icon:i.jsx(o$,{className:"h-5 w-5"})},middag:{label:"Middag",time:`${H} - ${g}`,icon:i.jsx(E5,{className:"h-5 w-5"})},hele_dag:{label:"Hele dag",time:`${x} - ${g}`,icon:i.jsx(Wt,{className:"h-5 w-5"})}}},[x,g]);p.useEffect(()=>{(async()=>{y(!0);try{const{data:I}=await B.from("services").select("estimated_days, default_day_part").eq("id",t).single();I&&(v({estimated_days:I.estimated_days||1,default_day_part:I.default_day_part||"hele_dag"}),c(I.default_day_part||"hele_dag"));const{data:P}=await B.from("staff_availability").select("date").eq("staff_id",e);P&&d(P.map(F=>F.date));const{data:H}=await B.from("appointments").select("appointment_date, day_part").eq("staff_id",e).neq("status","cancelled"),V=(H||[]).map(F=>({date:F.appointment_date,day_part:F.day_part||"hele_dag"})),{data:M}=await B.from("project_staff").select("project_id").eq("staff_id",e);let C=[];if(M&&M.length>0){const F=M.map(ie=>ie.project_id),{data:W}=await B.from("projects").select("selected_dates, day_part, status").in("id",F).not("status","in",'("done","cancelled","archived")');if(W)for(const ie of W){const oe=ie.selected_dates||[],ce=ie.day_part||"hele_dag";for(const re of oe)C.push({date:re,day_part:ce})}}h([...V,...C])}catch(I){console.error("Error fetching data:",I)}finally{y(!1)}})()},[e,t]);const E=(T,I)=>{const P=he(T,"yyyy-MM-dd"),H=f.filter(V=>V.date===P);return H.length===0?!0:H.some(V=>V.day_part==="hele_dag")||I==="hele_dag"&&H.length>0?!1:!H.some(V=>V.day_part===I)},N=p.useMemo(()=>{if(!a||!m||m.estimated_days<=1)return null;let T=a,I=1;for(;I{const I=_i(new Date);if(J0(T,I)||!j(T))return!0;const P=he(T,"yyyy-MM-dd");return!!u.includes(P)},z=()=>{!a||!l||r({startDate:he(a,"yyyy-MM-dd"),endDate:N?he(N,"yyyy-MM-dd"):null,dayPart:l})};return w||_||k?i.jsx("div",{className:"flex items-center justify-center py-12",children:i.jsx(yn,{className:"h-8 w-8 animate-spin text-primary"})}):i.jsxs("div",{className:"space-y-6",children:[i.jsx("h2",{className:"text-xl sm:text-2xl font-semibold",children:"Kies datum en dagdeel"}),m&&m.estimated_days>1&&i.jsx(dt,{className:"p-4 bg-blue-50 border-blue-200",children:i.jsxs("p",{className:"text-sm text-blue-800",children:[i.jsx("strong",{children:"Let op:"})," Deze klus duurt ",m.estimated_days," werkdagen. Kies een startdatum en de einddatum wordt automatisch berekend."]})}),i.jsx("div",{className:"flex justify-center",children:i.jsx($c,{mode:"single",selected:a,onSelect:o,disabled:O,locale:tt,className:"rounded-md border pointer-events-auto"})}),a&&i.jsxs("div",{className:"text-center",children:[i.jsxs(Qe,{variant:"secondary",className:"text-base px-4 py-2",children:[he(a,"EEEE d MMMM yyyy",{locale:tt}),N&&i.jsxs("span",{children:[" t/m ",he(N,"EEEE d MMMM",{locale:tt})]})]}),m&&m.estimated_days>1&&i.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["(",m.estimated_days," werkdagen)"]})]}),a&&i.jsxs("div",{className:"space-y-3",children:[i.jsx("h3",{className:"font-medium text-center",children:"Kies dagdeel"}),i.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:Object.entries(S).map(([T,I])=>{const P=E(a,T);return i.jsx(dt,{className:`p-4 cursor-pointer transition-all text-center ${P?l===T?"ring-2 ring-primary":"hover:shadow-md":"opacity-50 cursor-not-allowed bg-muted"}`,onClick:()=>P&&c(T),children:i.jsxs("div",{className:"flex flex-col items-center gap-2",children:[i.jsx("div",{className:l===T?"text-primary":"text-muted-foreground",children:I.icon}),i.jsx("span",{className:"font-medium",children:I.label}),i.jsx("span",{className:"text-sm text-muted-foreground",children:I.time}),!P&&i.jsx(Qe,{variant:"outline",className:"text-xs",children:"Bezet"})]})},T)})})]}),i.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4 pt-2",children:[i.jsx(ne,{onClick:s,variant:"outline",className:"flex-1 h-11",children:"Vorige"}),i.jsx(ne,{onClick:z,disabled:!a||!l,className:"flex-1 h-11",children:"Volgende"})]})]})};var Qd=e=>e.type==="checkbox",Zo=e=>e instanceof Date,Kn=e=>e==null;const cM=e=>typeof e=="object";var Xt=e=>!Kn(e)&&!Array.isArray(e)&&cM(e)&&!Zo(e),uM=e=>Xt(e)&&e.target?Qd(e.target)?e.target.checked:e.target.value:e,_ee=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,dM=(e,t)=>e.has(_ee(t)),kee=e=>{const t=e.constructor&&e.constructor.prototype;return Xt(t)&&t.hasOwnProperty("isPrototypeOf")},Kb=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function fn(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(!(Kb&&(e instanceof Blob||r))&&(n||Xt(e)))if(t=n?[]:{},!n&&!kee(e))t=e;else for(const s in e)e.hasOwnProperty(s)&&(t[s]=fn(e[s]));else return e;return t}var Ip=e=>/^\w*$/.test(e),Kt=e=>e===void 0,Gb=e=>Array.isArray(e)?e.filter(Boolean):[],Yb=e=>Gb(e.replace(/["|']|\]/g,"").split(/\.|\[/)),me=(e,t,n)=>{if(!t||!Xt(e))return n;const r=(Ip(t)?[t]:Yb(t)).reduce((s,a)=>Kn(s)?s:s[a],e);return Kt(r)||r===e?Kt(e[t])?n:e[t]:r},br=e=>typeof e=="boolean",gt=(e,t,n)=>{let r=-1;const s=Ip(t)?[t]:Yb(t),a=s.length,o=a-1;for(;++rX.useContext(Qb),jee=e=>{const{children:t,...n}=e;return X.createElement(Qb.Provider,{value:n},t)};var fM=(e,t,n,r=!0)=>{const s={defaultValues:t._defaultValues};for(const a in e)Object.defineProperty(s,a,{get:()=>{const o=a;return t._proxyFormState[o]!==hs.all&&(t._proxyFormState[o]=!r||hs.all),n&&(n[o]=!0),e[o]}});return s};const Xb=typeof window<"u"?X.useLayoutEffect:X.useEffect;function See(e){const t=Lp(),{control:n=t.control,disabled:r,name:s,exact:a}=e||{},[o,l]=X.useState(n._formState),c=X.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Xb(()=>n._subscribe({name:s,formState:c.current,exact:a,callback:u=>{!r&&l({...n._formState,...u})}}),[s,r,a]),X.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),X.useMemo(()=>fM(o,n,c.current,!1),[o,n])}var zs=e=>typeof e=="string",hM=(e,t,n,r,s)=>zs(e)?(r&&t.watch.add(e),me(n,e,s)):Array.isArray(e)?e.map(a=>(r&&t.watch.add(a),me(n,a))):(r&&(t.watchAll=!0),n),Mx=e=>Kn(e)||!cM(e);function da(e,t,n=new WeakSet){if(Mx(e)||Mx(t))return e===t;if(Zo(e)&&Zo(t))return e.getTime()===t.getTime();const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(const a of r){const o=e[a];if(!s.includes(a))return!1;if(a!=="ref"){const l=t[a];if(Zo(o)&&Zo(l)||Xt(o)&&Xt(l)||Array.isArray(o)&&Array.isArray(l)?!da(o,l,n):o!==l)return!1}}return!0}function Eee(e){const t=Lp(),{control:n=t.control,name:r,defaultValue:s,disabled:a,exact:o,compute:l}=e||{},c=X.useRef(s),u=X.useRef(l),d=X.useRef(void 0);u.current=l;const f=X.useMemo(()=>n._getWatch(r,c.current),[n,r]),[h,m]=X.useState(u.current?u.current(f):f);return Xb(()=>n._subscribe({name:r,formState:{values:!0},exact:o,callback:v=>{if(!a){const w=hM(r,n._names,v.values||n._formValues,!1,c.current);if(u.current){const y=u.current(w);da(y,d.current)||(m(y),d.current=y)}else m(w)}}}),[n,a,r,o]),X.useEffect(()=>n._removeUnmounted()),h}function Nee(e){const t=Lp(),{name:n,disabled:r,control:s=t.control,shouldUnregister:a,defaultValue:o}=e,l=dM(s._names.array,n),c=X.useMemo(()=>me(s._formValues,n,me(s._defaultValues,n,o)),[s,n,o]),u=Eee({control:s,name:n,defaultValue:c,exact:!0}),d=See({control:s,name:n,exact:!0}),f=X.useRef(e),h=X.useRef(s.register(n,{...e.rules,value:u,...br(e.disabled)?{disabled:e.disabled}:{}}));f.current=e;const m=X.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!me(d.errors,n)},isDirty:{enumerable:!0,get:()=>!!me(d.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!me(d.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!me(d.validatingFields,n)},error:{enumerable:!0,get:()=>me(d.errors,n)}}),[d,n]),v=X.useCallback(g=>h.current.onChange({target:{value:uM(g),name:n},type:gm.CHANGE}),[n]),w=X.useCallback(()=>h.current.onBlur({target:{value:me(s._formValues,n),name:n},type:gm.BLUR}),[n,s._formValues]),y=X.useCallback(g=>{const b=me(s._fields,n);b&&g&&(b._f.ref={focus:()=>g.focus&&g.focus(),select:()=>g.select&&g.select(),setCustomValidity:_=>g.setCustomValidity(_),reportValidity:()=>g.reportValidity()})},[s._fields,n]),x=X.useMemo(()=>({name:n,value:u,...br(r)||d.disabled?{disabled:d.disabled||r}:{},onChange:v,onBlur:w,ref:y}),[n,r,d.disabled,v,w,y,u]);return X.useEffect(()=>{const g=s._options.shouldUnregister||a;s.register(n,{...f.current.rules,...br(f.current.disabled)?{disabled:f.current.disabled}:{}});const b=(_,j)=>{const k=me(s._fields,_);k&&k._f&&(k._f.mount=j)};if(b(n,!0),g){const _=fn(me(s._options.defaultValues,n));gt(s._defaultValues,n,_),Kt(me(s._formValues,n))&>(s._formValues,n,_)}return!l&&s.register(n),()=>{(l?g&&!s._state.action:g)?s.unregister(n):b(n,!1)}},[n,s,l,a]),X.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),X.useMemo(()=>({field:x,formState:d,fieldState:m}),[x,d,m])}const Cee=e=>e.render(Nee(e));var mM=(e,t,n,r,s)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:s||!0}}:{},Ru=e=>Array.isArray(e)?e:[e],xS=()=>{let e=[];return{get observers(){return e},next:s=>{for(const a of e)a.next&&a.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(a=>a!==s)}}),unsubscribe:()=>{e=[]}}},ir=e=>Xt(e)&&!Object.keys(e).length,Zb=e=>e.type==="file",ms=e=>typeof e=="function",ym=e=>{if(!Kb)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},pM=e=>e.type==="select-multiple",Jb=e=>e.type==="radio",Tee=e=>Jb(e)||Qd(e),Cy=e=>ym(e)&&e.isConnected;function Pee(e,t){const n=t.slice(0,-1).length;let r=0;for(;r{for(const t in e)if(ms(e[t]))return!0;return!1};function vm(e,t={}){const n=Array.isArray(e);if(Xt(e)||n)for(const r in e)Array.isArray(e[r])||Xt(e[r])&&!gM(e[r])?(t[r]=Array.isArray(e[r])?[]:{},vm(e[r],t[r])):Kn(e[r])||(t[r]=!0);return t}function yM(e,t,n){const r=Array.isArray(e);if(Xt(e)||r)for(const s in e)Array.isArray(e[s])||Xt(e[s])&&!gM(e[s])?Kt(t)||Mx(n[s])?n[s]=Array.isArray(e[s])?vm(e[s],[]):{...vm(e[s])}:yM(e[s],Kn(t)?{}:t[s],n[s]):n[s]=!da(e[s],t[s]);return n}var ru=(e,t)=>yM(e,t,vm(t));const wS={value:!1,isValid:!1},bS={value:!0,isValid:!0};var vM=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Kt(e[0].attributes.value)?Kt(e[0].value)||e[0].value===""?bS:{value:e[0].value,isValid:!0}:bS:wS}return wS},xM=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Kt(e)?e:t?e===""?NaN:e&&+e:n&&zs(e)?new Date(e):r?r(e):e;const _S={isValid:!1,value:null};var wM=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,_S):_S;function kS(e){const t=e.ref;return Zb(t)?t.files:Jb(t)?wM(e.refs).value:pM(t)?[...t.selectedOptions].map(({value:n})=>n):Qd(t)?vM(e.refs).value:xM(Kt(t.value)?e.ref.value:t.value,e)}var Ree=(e,t,n,r)=>{const s={};for(const a of e){const o=me(t,a);o&>(s,a,o._f)}return{criteriaMode:n,names:[...e],fields:s,shouldUseNativeValidation:r}},xm=e=>e instanceof RegExp,su=e=>Kt(e)?e:xm(e)?e.source:Xt(e)?xm(e.value)?e.value.source:e.value:e,jS=e=>({isOnSubmit:!e||e===hs.onSubmit,isOnBlur:e===hs.onBlur,isOnChange:e===hs.onChange,isOnAll:e===hs.all,isOnTouch:e===hs.onTouched});const SS="AsyncFunction";var Oee=e=>!!e&&!!e.validate&&!!(ms(e.validate)&&e.validate.constructor.name===SS||Xt(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===SS)),Mee=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),ES=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const Ou=(e,t,n,r)=>{for(const s of n||Object.keys(e)){const a=me(e,s);if(a){const{_f:o,...l}=a;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],s)&&!r)return!0;if(o.ref&&t(o.ref,o.name)&&!r)return!0;if(Ou(l,t))break}else if(Xt(l)&&Ou(l,t))break}}};function NS(e,t,n){const r=me(e,n);if(r||Ip(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const a=s.join("."),o=me(t,a),l=me(e,a);if(o&&!Array.isArray(o)&&n!==a)return{name:n};if(l&&l.type)return{name:a,error:l};if(l&&l.root&&l.root.type)return{name:`${a}.root`,error:l.root};s.pop()}return{name:n}}var Dee=(e,t,n,r)=>{n(e);const{name:s,...a}=e;return ir(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(o=>t[o]===(!r||hs.all))},Iee=(e,t,n)=>!e||!t||e===t||Ru(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r))),Lee=(e,t,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(t||e):(n?r.isOnBlur:s.isOnBlur)?!e:(n?r.isOnChange:s.isOnChange)?e:!0,$ee=(e,t)=>!Gb(me(e,t)).length&&tn(e,t),Fee=(e,t,n)=>{const r=Ru(me(e,n));return gt(r,"root",t[n]),gt(e,n,r),e},wh=e=>zs(e);function CS(e,t,n="validate"){if(wh(e)||Array.isArray(e)&&e.every(wh)||br(e)&&!e)return{type:n,message:wh(e)?e:"",ref:t}}var el=e=>Xt(e)&&!xm(e)?e:{value:e,message:""},TS=async(e,t,n,r,s,a)=>{const{ref:o,refs:l,required:c,maxLength:u,minLength:d,min:f,max:h,pattern:m,validate:v,name:w,valueAsNumber:y,mount:x}=e._f,g=me(n,w);if(!x||t.has(w))return{};const b=l?l[0]:o,_=T=>{s&&b.reportValidity&&(b.setCustomValidity(br(T)?"":T||""),b.reportValidity())},j={},k=Jb(o),S=Qd(o),E=k||S,N=(y||Zb(o))&&Kt(o.value)&&Kt(g)||ym(o)&&o.value===""||g===""||Array.isArray(g)&&!g.length,O=mM.bind(null,w,r,j),z=(T,I,P,H=ra.maxLength,V=ra.minLength)=>{const M=T?I:P;j[w]={type:T?H:V,message:M,ref:o,...O(T?H:V,M)}};if(a?!Array.isArray(g)||!g.length:c&&(!E&&(N||Kn(g))||br(g)&&!g||S&&!vM(l).isValid||k&&!wM(l).isValid)){const{value:T,message:I}=wh(c)?{value:!!c,message:c}:el(c);if(T&&(j[w]={type:ra.required,message:I,ref:b,...O(ra.required,I)},!r))return _(I),j}if(!N&&(!Kn(f)||!Kn(h))){let T,I;const P=el(h),H=el(f);if(!Kn(g)&&!isNaN(g)){const V=o.valueAsNumber||g&&+g;Kn(P.value)||(T=V>P.value),Kn(H.value)||(I=Vnew Date(new Date().toDateString()+" "+W),C=o.type=="time",F=o.type=="week";zs(P.value)&&g&&(T=C?M(g)>M(P.value):F?g>P.value:V>new Date(P.value)),zs(H.value)&&g&&(I=C?M(g)+T.value,H=!Kn(I.value)&&g.length<+I.value;if((P||H)&&(z(P,T.message,I.message),!r))return _(j[w].message),j}if(m&&!N&&zs(g)){const{value:T,message:I}=el(m);if(xm(T)&&!g.match(T)&&(j[w]={type:ra.pattern,message:I,ref:o,...O(ra.pattern,I)},!r))return _(I),j}if(v){if(ms(v)){const T=await v(g,n),I=CS(T,b);if(I&&(j[w]={...I,...O(ra.validate,I.message)},!r))return _(I.message),j}else if(Xt(v)){let T={};for(const I in v){if(!ir(T)&&!r)break;const P=CS(await v[I](g,n),b,I);P&&(T={...P,...O(I,P.message)},_(P.message),r&&(j[w]=T))}if(!ir(T)&&(j[w]={ref:b,...T},!r))return j}}return _(!0),j};const zee={mode:hs.onSubmit,reValidateMode:hs.onChange,shouldFocusError:!0};function Bee(e={}){let t={...zee,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:ms(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},s=Xt(t.defaultValues)||Xt(t.values)?fn(t.defaultValues||t.values)||{}:{},a=t.shouldUnregister?{}:fn(s),o={action:!1,mount:!1,watch:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,u=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let f={...d};const h={array:xS(),state:xS()},m=t.criteriaMode===hs.all,v=A=>$=>{clearTimeout(u),u=setTimeout(A,$)},w=async A=>{if(!t.disabled&&(d.isValid||f.isValid||A)){const $=t.resolver?ir((await S()).errors):await N(r,!0);$!==n.isValid&&h.state.next({isValid:$})}},y=(A,$)=>{!t.disabled&&(d.isValidating||d.validatingFields||f.isValidating||f.validatingFields)&&((A||Array.from(l.mount)).forEach(q=>{q&&($?gt(n.validatingFields,q,$):tn(n.validatingFields,q))}),h.state.next({validatingFields:n.validatingFields,isValidating:!ir(n.validatingFields)}))},x=(A,$=[],q,de,G=!0,U=!0)=>{if(de&&q&&!t.disabled){if(o.action=!0,U&&Array.isArray(me(r,A))){const Z=q(me(r,A),de.argA,de.argB);G&>(r,A,Z)}if(U&&Array.isArray(me(n.errors,A))){const Z=q(me(n.errors,A),de.argA,de.argB);G&>(n.errors,A,Z),$ee(n.errors,A)}if((d.touchedFields||f.touchedFields)&&U&&Array.isArray(me(n.touchedFields,A))){const Z=q(me(n.touchedFields,A),de.argA,de.argB);G&>(n.touchedFields,A,Z)}(d.dirtyFields||f.dirtyFields)&&(n.dirtyFields=ru(s,a)),h.state.next({name:A,isDirty:z(A,$),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else gt(a,A,$)},g=(A,$)=>{gt(n.errors,A,$),h.state.next({errors:n.errors})},b=A=>{n.errors=A,h.state.next({errors:n.errors,isValid:!1})},_=(A,$,q,de)=>{const G=me(r,A);if(G){const U=me(a,A,Kt(q)?me(s,A):q);Kt(U)||de&&de.defaultChecked||$?gt(a,A,$?U:kS(G._f)):P(A,U),o.mount&&w()}},j=(A,$,q,de,G)=>{let U=!1,Z=!1;const pe={name:A};if(!t.disabled){if(!q||de){(d.isDirty||f.isDirty)&&(Z=n.isDirty,n.isDirty=pe.isDirty=z(),U=Z!==pe.isDirty);const Be=da(me(s,A),$);Z=!!me(n.dirtyFields,A),Be?tn(n.dirtyFields,A):gt(n.dirtyFields,A,!0),pe.dirtyFields=n.dirtyFields,U=U||(d.dirtyFields||f.dirtyFields)&&Z!==!Be}if(q){const Be=me(n.touchedFields,A);Be||(gt(n.touchedFields,A,q),pe.touchedFields=n.touchedFields,U=U||(d.touchedFields||f.touchedFields)&&Be!==q)}U&&G&&h.state.next(pe)}return U?pe:{}},k=(A,$,q,de)=>{const G=me(n.errors,A),U=(d.isValid||f.isValid)&&br($)&&n.isValid!==$;if(t.delayError&&q?(c=v(()=>g(A,q)),c(t.delayError)):(clearTimeout(u),c=null,q?gt(n.errors,A,q):tn(n.errors,A)),(q?!da(G,q):G)||!ir(de)||U){const Z={...de,...U&&br($)?{isValid:$}:{},errors:n.errors,name:A};n={...n,...Z},h.state.next(Z)}},S=async A=>{y(A,!0);const $=await t.resolver(a,t.context,Ree(A||l.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return y(A),$},E=async A=>{const{errors:$}=await S(A);if(A)for(const q of A){const de=me($,q);de?gt(n.errors,q,de):tn(n.errors,q)}else n.errors=$;return $},N=async(A,$,q={valid:!0})=>{for(const de in A){const G=A[de];if(G){const{_f:U,...Z}=G;if(U){const pe=l.array.has(U.name),Be=G._f&&Oee(G._f);Be&&d.validatingFields&&y([de],!0);const at=await TS(G,l.disabled,a,m,t.shouldUseNativeValidation&&!$,pe);if(Be&&d.validatingFields&&y([de]),at[U.name]&&(q.valid=!1,$))break;!$&&(me(at,U.name)?pe?Fee(n.errors,at,U.name):gt(n.errors,U.name,at[U.name]):tn(n.errors,U.name))}!ir(Z)&&await N(Z,$,q)}}return q.valid},O=()=>{for(const A of l.unMount){const $=me(r,A);$&&($._f.refs?$._f.refs.every(q=>!Cy(q)):!Cy($._f.ref))&&L(A)}l.unMount=new Set},z=(A,$)=>!t.disabled&&(A&&$&>(a,A,$),!da(W(),s)),T=(A,$,q)=>hM(A,l,{...o.mount?a:Kt($)?s:zs(A)?{[A]:$}:$},q,$),I=A=>Gb(me(o.mount?a:s,A,t.shouldUnregister?me(s,A,[]):[])),P=(A,$,q={})=>{const de=me(r,A);let G=$;if(de){const U=de._f;U&&(!U.disabled&>(a,A,xM($,U)),G=ym(U.ref)&&Kn($)?"":$,pM(U.ref)?[...U.ref.options].forEach(Z=>Z.selected=G.includes(Z.value)):U.refs?Qd(U.ref)?U.refs.forEach(Z=>{(!Z.defaultChecked||!Z.disabled)&&(Array.isArray(G)?Z.checked=!!G.find(pe=>pe===Z.value):Z.checked=G===Z.value||!!G)}):U.refs.forEach(Z=>Z.checked=Z.value===G):Zb(U.ref)?U.ref.value="":(U.ref.value=G,U.ref.type||h.state.next({name:A,values:fn(a)})))}(q.shouldDirty||q.shouldTouch)&&j(A,G,q.shouldTouch,q.shouldDirty,!0),q.shouldValidate&&F(A)},H=(A,$,q)=>{for(const de in $){if(!$.hasOwnProperty(de))return;const G=$[de],U=A+"."+de,Z=me(r,U);(l.array.has(A)||Xt(G)||Z&&!Z._f)&&!Zo(G)?H(U,G,q):P(U,G,q)}},V=(A,$,q={})=>{const de=me(r,A),G=l.array.has(A),U=fn($);gt(a,A,U),G?(h.array.next({name:A,values:fn(a)}),(d.isDirty||d.dirtyFields||f.isDirty||f.dirtyFields)&&q.shouldDirty&&h.state.next({name:A,dirtyFields:ru(s,a),isDirty:z(A,U)})):de&&!de._f&&!Kn(U)?H(A,U,q):P(A,U,q),ES(A,l)&&h.state.next({...n,name:A}),h.state.next({name:o.mount?A:void 0,values:fn(a)})},M=async A=>{o.mount=!0;const $=A.target;let q=$.name,de=!0;const G=me(r,q),U=Be=>{de=Number.isNaN(Be)||Zo(Be)&&isNaN(Be.getTime())||da(Be,me(a,q,Be))},Z=jS(t.mode),pe=jS(t.reValidateMode);if(G){let Be,at;const vn=$.type?kS(G._f):uM(A),Jt=A.type===gm.BLUR||A.type===gm.FOCUS_OUT,$n=!Mee(G._f)&&!t.resolver&&!me(n.errors,q)&&!G._f.deps||Lee(Jt,me(n.touchedFields,q),n.isSubmitted,pe,Z),er=ES(q,l,Jt);gt(a,q,vn),Jt?(G._f.onBlur&&G._f.onBlur(A),c&&c(0)):G._f.onChange&&G._f.onChange(A);const jn=j(q,vn,Jt),Js=!ir(jn)||er;if(!Jt&&h.state.next({name:q,type:A.type,values:fn(a)}),$n)return(d.isValid||f.isValid)&&(t.mode==="onBlur"?Jt&&w():Jt||w()),Js&&h.state.next({name:q,...er?{}:jn});if(!Jt&&er&&h.state.next({...n}),t.resolver){const{errors:tr}=await S([q]);if(U(vn),de){const nr=NS(n.errors,r,q),Qr=NS(tr,r,nr.name||q);Be=Qr.error,q=Qr.name,at=ir(tr)}}else y([q],!0),Be=(await TS(G,l.disabled,a,m,t.shouldUseNativeValidation))[q],y([q]),U(vn),de&&(Be?at=!1:(d.isValid||f.isValid)&&(at=await N(r,!0)));de&&(G._f.deps&&F(G._f.deps),k(q,at,Be,jn))}},C=(A,$)=>{if(me(n.errors,$)&&A.focus)return A.focus(),1},F=async(A,$={})=>{let q,de;const G=Ru(A);if(t.resolver){const U=await E(Kt(A)?A:G);q=ir(U),de=A?!G.some(Z=>me(U,Z)):q}else A?(de=(await Promise.all(G.map(async U=>{const Z=me(r,U);return await N(Z&&Z._f?{[U]:Z}:Z)}))).every(Boolean),!(!de&&!n.isValid)&&w()):de=q=await N(r);return h.state.next({...!zs(A)||(d.isValid||f.isValid)&&q!==n.isValid?{}:{name:A},...t.resolver||!A?{isValid:q}:{},errors:n.errors}),$.shouldFocus&&!de&&Ou(r,C,A?G:l.mount),de},W=A=>{const $={...o.mount?a:s};return Kt(A)?$:zs(A)?me($,A):A.map(q=>me($,q))},ie=(A,$)=>({invalid:!!me(($||n).errors,A),isDirty:!!me(($||n).dirtyFields,A),error:me(($||n).errors,A),isValidating:!!me(n.validatingFields,A),isTouched:!!me(($||n).touchedFields,A)}),oe=A=>{A&&Ru(A).forEach($=>tn(n.errors,$)),h.state.next({errors:A?n.errors:{}})},ce=(A,$,q)=>{const de=(me(r,A,{_f:{}})._f||{}).ref,G=me(n.errors,A)||{},{ref:U,message:Z,type:pe,...Be}=G;gt(n.errors,A,{...Be,...$,ref:de}),h.state.next({name:A,errors:n.errors,isValid:!1}),q&&q.shouldFocus&&de&&de.focus&&de.focus()},re=(A,$)=>ms(A)?h.state.subscribe({next:q=>"values"in q&&A(T(void 0,$),q)}):T(A,$,!0),ue=A=>h.state.subscribe({next:$=>{Iee(A.name,$.name,A.exact)&&Dee($,A.formState||d,ct,A.reRenderRoot)&&A.callback({values:{...a},...n,...$,defaultValues:s})}}).unsubscribe,ke=A=>(o.mount=!0,f={...f,...A.formState},ue({...A,formState:f})),L=(A,$={})=>{for(const q of A?Ru(A):l.mount)l.mount.delete(q),l.array.delete(q),$.keepValue||(tn(r,q),tn(a,q)),!$.keepError&&tn(n.errors,q),!$.keepDirty&&tn(n.dirtyFields,q),!$.keepTouched&&tn(n.touchedFields,q),!$.keepIsValidating&&tn(n.validatingFields,q),!t.shouldUnregister&&!$.keepDefaultValue&&tn(s,q);h.state.next({values:fn(a)}),h.state.next({...n,...$.keepDirty?{isDirty:z()}:{}}),!$.keepIsValid&&w()},Q=({disabled:A,name:$})=>{(br(A)&&o.mount||A||l.disabled.has($))&&(A?l.disabled.add($):l.disabled.delete($))},fe=(A,$={})=>{let q=me(r,A);const de=br($.disabled)||br(t.disabled);return gt(r,A,{...q||{},_f:{...q&&q._f?q._f:{ref:{name:A}},name:A,mount:!0,...$}}),l.mount.add(A),q?Q({disabled:br($.disabled)?$.disabled:t.disabled,name:A}):_(A,!0,$.value),{...de?{disabled:$.disabled||t.disabled}:{},...t.progressive?{required:!!$.required,min:su($.min),max:su($.max),minLength:su($.minLength),maxLength:su($.maxLength),pattern:su($.pattern)}:{},name:A,onChange:M,onBlur:M,ref:G=>{if(G){fe(A,$),q=me(r,A);const U=Kt(G.value)&&G.querySelectorAll&&G.querySelectorAll("input,select,textarea")[0]||G,Z=Tee(U),pe=q._f.refs||[];if(Z?pe.find(Be=>Be===U):U===q._f.ref)return;gt(r,A,{_f:{...q._f,...Z?{refs:[...pe.filter(Cy),U,...Array.isArray(me(s,A))?[{}]:[]],ref:{type:U.type,name:A}}:{ref:U}}}),_(A,!1,void 0,U)}else q=me(r,A,{}),q._f&&(q._f.mount=!1),(t.shouldUnregister||$.shouldUnregister)&&!(dM(l.array,A)&&o.action)&&l.unMount.add(A)}}},ee=()=>t.shouldFocusError&&Ou(r,C,l.mount),je=A=>{br(A)&&(h.state.next({disabled:A}),Ou(r,($,q)=>{const de=me(r,q);de&&($.disabled=de._f.disabled||A,Array.isArray(de._f.refs)&&de._f.refs.forEach(G=>{G.disabled=de._f.disabled||A}))},0,!1))},Ee=(A,$)=>async q=>{let de;q&&(q.preventDefault&&q.preventDefault(),q.persist&&q.persist());let G=fn(a);if(h.state.next({isSubmitting:!0}),t.resolver){const{errors:U,values:Z}=await S();n.errors=U,G=fn(Z)}else await N(r);if(l.disabled.size)for(const U of l.disabled)tn(G,U);if(tn(n.errors,"root"),ir(n.errors)){h.state.next({errors:{}});try{await A(G,q)}catch(U){de=U}}else $&&await $({...n.errors},q),ee(),setTimeout(ee);if(h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ir(n.errors)&&!de,submitCount:n.submitCount+1,errors:n.errors}),de)throw de},te=(A,$={})=>{me(r,A)&&(Kt($.defaultValue)?V(A,fn(me(s,A))):(V(A,$.defaultValue),gt(s,A,fn($.defaultValue))),$.keepTouched||tn(n.touchedFields,A),$.keepDirty||(tn(n.dirtyFields,A),n.isDirty=$.defaultValue?z(A,fn(me(s,A))):z()),$.keepError||(tn(n.errors,A),d.isValid&&w()),h.state.next({...n}))},_e=(A,$={})=>{const q=A?fn(A):s,de=fn(q),G=ir(A),U=G?s:de;if($.keepDefaultValues||(s=q),!$.keepValues){if($.keepDirtyValues){const Z=new Set([...l.mount,...Object.keys(ru(s,a))]);for(const pe of Array.from(Z))me(n.dirtyFields,pe)?gt(U,pe,me(a,pe)):V(pe,me(U,pe))}else{if(Kb&&Kt(A))for(const Z of l.mount){const pe=me(r,Z);if(pe&&pe._f){const Be=Array.isArray(pe._f.refs)?pe._f.refs[0]:pe._f.ref;if(ym(Be)){const at=Be.closest("form");if(at){at.reset();break}}}}if($.keepFieldsRef)for(const Z of l.mount)V(Z,me(U,Z));else r={}}a=t.shouldUnregister?$.keepDefaultValues?fn(s):{}:fn(U),h.array.next({values:{...U}}),h.state.next({values:{...U}})}l={mount:$.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!d.isValid||!!$.keepIsValid||!!$.keepDirtyValues,o.watch=!!t.shouldUnregister,h.state.next({submitCount:$.keepSubmitCount?n.submitCount:0,isDirty:G?!1:$.keepDirty?n.isDirty:!!($.keepDefaultValues&&!da(A,s)),isSubmitted:$.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:G?{}:$.keepDirtyValues?$.keepDefaultValues&&a?ru(s,a):n.dirtyFields:$.keepDefaultValues&&A?ru(s,A):$.keepDirty?n.dirtyFields:{},touchedFields:$.keepTouched?n.touchedFields:{},errors:$.keepErrors?n.errors:{},isSubmitSuccessful:$.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},Me=(A,$)=>_e(ms(A)?A(a):A,$),Ue=(A,$={})=>{const q=me(r,A),de=q&&q._f;if(de){const G=de.refs?de.refs[0]:de.ref;G.focus&&(G.focus(),$.shouldSelect&&ms(G.select)&&G.select())}},ct=A=>{n={...n,...A}},Et={control:{register:fe,unregister:L,getFieldState:ie,handleSubmit:Ee,setError:ce,_subscribe:ue,_runSchema:S,_focusError:ee,_getWatch:T,_getDirty:z,_setValid:w,_setFieldArray:x,_setDisabledField:Q,_setErrors:b,_getFieldArray:I,_reset:_e,_resetDefaultValues:()=>ms(t.defaultValues)&&t.defaultValues().then(A=>{Me(A,t.resetOptions),h.state.next({isLoading:!1})}),_removeUnmounted:O,_disableForm:je,_subjects:h,_proxyFormState:d,get _fields(){return r},get _formValues(){return a},get _state(){return o},set _state(A){o=A},get _defaultValues(){return s},get _names(){return l},set _names(A){l=A},get _formState(){return n},get _options(){return t},set _options(A){t={...t,...A}}},subscribe:ke,trigger:F,register:fe,handleSubmit:Ee,watch:re,setValue:V,getValues:W,reset:Me,resetField:te,clearErrors:oe,unregister:L,setError:ce,setFocus:Ue,getFieldState:ie};return{...Et,formControl:Et}}function bM(e={}){const t=X.useRef(void 0),n=X.useRef(void 0),[r,s]=X.useState({isDirty:!1,isValidating:!1,isLoading:ms(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:ms(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!ms(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:o,...l}=Bee(e);t.current={...l,formState:r}}const a=t.current.control;return a._options=e,Xb(()=>{const o=a._subscribe({formState:a._proxyFormState,callback:()=>s({...a._formState}),reRenderRoot:!0});return s(l=>({...l,isReady:!0})),a._formState.isReady=!0,o},[a]),X.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),X.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),X.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),X.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),X.useEffect(()=>{if(a._proxyFormState.isDirty){const o=a._getDirty();o!==r.isDirty&&a._subjects.state.next({isDirty:o})}},[a,r.isDirty]),X.useEffect(()=>{e.values&&!da(e.values,n.current)?(a._reset(e.values,{keepFieldsRef:!0,...a._options.resetOptions}),n.current=e.values,s(o=>({...o}))):a._resetDefaultValues()},[a,e.values]),X.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=fM(r,a),t.current}const PS=(e,t,n)=>{if(e&&"reportValidity"in e){const r=me(n,t);e.setCustomValidity(r&&r.message||""),e.reportValidity()}},_M=(e,t)=>{for(const n in t.fields){const r=t.fields[n];r&&r.ref&&"reportValidity"in r.ref?PS(r.ref,n,e):r.refs&&r.refs.forEach(s=>PS(s,n,e))}},Uee=(e,t)=>{t.shouldUseNativeValidation&&_M(e,t);const n={};for(const r in e){const s=me(t.fields,r),a=Object.assign(e[r]||{},{ref:s&&s.ref});if(Vee(t.names||Object.keys(e),r)){const o=Object.assign({},me(n,r));gt(o,"root",a),gt(n,r,o)}else gt(n,r,a)}return n},Vee=(e,t)=>e.some(n=>n.startsWith(t+"."));var Wee=function(e,t){for(var n={};e.length;){var r=e[0],s=r.code,a=r.message,o=r.path.join(".");if(!n[o])if("unionErrors"in r){var l=r.unionErrors[0].errors[0];n[o]={message:l.message,type:l.code}}else n[o]={message:a,type:s};if("unionErrors"in r&&r.unionErrors.forEach(function(d){return d.errors.forEach(function(f){return e.push(f)})}),t){var c=n[o].types,u=c&&c[r.code];n[o]=mM(o,t,n,s,u?[].concat(u,r.message):r.message)}e.shift()}return n},kM=function(e,t,n){return n===void 0&&(n={}),function(r,s,a){try{return Promise.resolve(function(o,l){try{var c=Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(u){return a.shouldUseNativeValidation&&_M({},a),{errors:{},values:n.raw?r:u}})}catch(u){return l(u)}return c&&c.then?c.then(void 0,l):c}(0,function(o){if(function(l){return Array.isArray(l==null?void 0:l.errors)}(o))return{values:{},errors:Uee(Wee(o.errors,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw o}))}catch(o){return Promise.reject(o)}}},it;(function(e){e.assertEqual=s=>{};function t(s){}e.assertIs=t;function n(s){throw new Error}e.assertNever=n,e.arrayToEnum=s=>{const a={};for(const o of s)a[o]=o;return a},e.getValidEnumValues=s=>{const a=e.objectKeys(s).filter(l=>typeof s[s[l]]!="number"),o={};for(const l of a)o[l]=s[l];return e.objectValues(o)},e.objectValues=s=>e.objectKeys(s).map(function(a){return s[a]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},e.find=(s,a)=>{for(const o of s)if(a(o))return o},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}e.joinValues=r,e.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(it||(it={}));var AS;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(AS||(AS={}));const Se=it.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$a=e=>{switch(typeof e){case"undefined":return Se.undefined;case"string":return Se.string;case"number":return Number.isNaN(e)?Se.nan:Se.number;case"boolean":return Se.boolean;case"function":return Se.function;case"bigint":return Se.bigint;case"symbol":return Se.symbol;case"object":return Array.isArray(e)?Se.array:e===null?Se.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Se.promise:typeof Map<"u"&&e instanceof Map?Se.map:typeof Set<"u"&&e instanceof Set?Se.set:typeof Date<"u"&&e instanceof Date?Se.date:Se.object;default:return Se.unknown}},le=it.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 ka extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(a){return a.message},r={_errors:[]},s=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let l=r,c=0;for(;cn.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const a=s.path[0];n[a]=n[a]||[],n[a].push(t(s))}else r.push(t(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}ka.create=e=>new ka(e);const Dx=(e,t)=>{let n;switch(e.code){case le.invalid_type:e.received===Se.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case le.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,it.jsonStringifyReplacer)}`;break;case le.unrecognized_keys:n=`Unrecognized key(s) in object: ${it.joinValues(e.keys,", ")}`;break;case le.invalid_union:n="Invalid input";break;case le.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${it.joinValues(e.options)}`;break;case le.invalid_enum_value:n=`Invalid enum value. Expected ${it.joinValues(e.options)}, received '${e.received}'`;break;case le.invalid_arguments:n="Invalid function arguments";break;case le.invalid_return_type:n="Invalid function return type";break;case le.invalid_date:n="Invalid date";break;case le.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:it.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case le.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case le.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case le.custom:n="Invalid input";break;case le.invalid_intersection_types:n="Intersection results could not be merged";break;case le.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case le.not_finite:n="Number must be finite";break;default:n=t.defaultError,it.assertNever(e)}return{message:n}};let Hee=Dx;function qee(){return Hee}const Kee=e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,a=[...n,...s.path||[]],o={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let l="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)l=u(o,{data:t,defaultError:l}).message;return{...s,path:a,message:l}};function ve(e,t){const n=qee(),r=Kee({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Dx?void 0:Dx].filter(s=>!!s)});e.common.issues.push(r)}class Ar{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const s of n){if(s.status==="aborted")return Le;s.status==="dirty"&&t.dirty(),r.push(s.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const s of n){const a=await s.key,o=await s.value;r.push({key:a,value:o})}return Ar.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const s of n){const{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return Le;a.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[a.value]=o.value)}return{status:t.value,value:r}}}const Le=Object.freeze({status:"aborted"}),hu=e=>({status:"dirty",value:e}),Yr=e=>({status:"valid",value:e}),RS=e=>e.status==="aborted",OS=e=>e.status==="dirty",fc=e=>e.status==="valid",wm=e=>typeof Promise<"u"&&e instanceof Promise;var Ne;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Ne||(Ne={}));class jo{constructor(t,n,r,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=s}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 MS=(e,t)=>{if(fc(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new ka(e.common.issues);return this._error=n,this._error}}};function Ye(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(o,l)=>{const{message:c}=e;return o.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??r??l.defaultError}:o.code!=="invalid_type"?{message:l.defaultError}:{message:c??n??l.defaultError}},description:s}}class st{get description(){return this._def.description}_getType(t){return $a(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:$a(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Ar,ctx:{common:t.parent.common,data:t.data,parsedType:$a(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(wm(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:$a(t)},s=this._parseSync({data:t,path:r.path,parent:r});return MS(r,s)}"~validate"(t){var r,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:$a(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:n});return fc(a)?{value:a.value}:{issues:n.common.issues}}catch(a){(s=(r=a==null?void 0:a.message)==null?void 0:r.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(a=>fc(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:$a(t)},s=this._parse({data:t,path:r.path,parent:r}),a=await(wm(s)?s:Promise.resolve(s));return MS(r,a)}refine(t,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,a)=>{const o=t(s),l=()=>a.addIssue({code:le.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(t,n){return this._refinement((r,s)=>t(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(t){return new mc({schema:this,typeName:$e.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,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:n=>this["~validate"](n)}}optional(){return go.create(this,this._def)}nullable(){return pc.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Hs.create(this)}promise(){return jm.create(this,this._def)}or(t){return _m.create([this,t],this._def)}and(t){return km.create(this,t,this._def)}transform(t){return new mc({...Ye(this._def),schema:this,typeName:$e.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Fx({...Ye(this._def),innerType:this,defaultValue:n,typeName:$e.ZodDefault})}brand(){return new gte({typeName:$e.ZodBranded,type:this,...Ye(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new zx({...Ye(this._def),innerType:this,catchValue:n,typeName:$e.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return e_.create(this,t)}readonly(){return Bx.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Gee=/^c[^\s-]{8,}$/i,Yee=/^[0-9a-z]+$/,Qee=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Xee=/^[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,Zee=/^[a-z0-9_-]{21}$/i,Jee=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ete=/^[-+]?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)?)??$/,tte=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,nte="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ty;const rte=/^(?:(?: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])$/,ste=/^(?:(?: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])$/,ate=/^(([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]))$/,ote=/^(([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])$/,ite=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,lte=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,jM="((\\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])))",cte=new RegExp(`^${jM}$`);function SM(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function ute(e){return new RegExp(`^${SM(e)}$`)}function dte(e){let t=`${jM}T${SM(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function fte(e,t){return!!((t==="v4"||!t)&&rte.test(e)||(t==="v6"||!t)&&ate.test(e))}function hte(e,t){if(!Jee.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||t&&s.alg!==t)}catch{return!1}}function mte(e,t){return!!((t==="v4"||!t)&&ste.test(e)||(t==="v6"||!t)&&ote.test(e))}class to extends st{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Se.string){const a=this._getOrReturnCtx(t);return ve(a,{code:le.invalid_type,expected:Se.string,received:a.parsedType}),Le}const r=new Ar;let s;for(const a of this._def.checks)if(a.kind==="min")t.data.lengtha.value&&(s=this._getOrReturnCtx(t,s),ve(s,{code:le.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const o=t.data.length>a.value,l=t.data.lengtht.test(s),{validation:n,code:le.invalid_string,...Ne.errToObj(r)})}_addCheck(t){return new to({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Ne.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Ne.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Ne.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Ne.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Ne.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Ne.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Ne.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Ne.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Ne.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Ne.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Ne.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Ne.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Ne.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Ne.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Ne.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Ne.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...Ne.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...Ne.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...Ne.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...Ne.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...Ne.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...Ne.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...Ne.errToObj(n)})}nonempty(t){return this.min(1,Ne.errToObj(t))}trim(){return new to({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new to({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new to({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.valuenew to({checks:[],typeName:$e.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Ye(e)});function pte(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,a=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return a%o/10**s}class hd extends st{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Se.number){const a=this._getOrReturnCtx(t);return ve(a,{code:le.invalid_type,expected:Se.number,received:a.parsedType}),Le}let r;const s=new Ar;for(const a of this._def.checks)a.kind==="int"?it.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),ve(r,{code:le.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?t.dataa.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),ve(r,{code:le.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?pte(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),ve(r,{code:le.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),ve(r,{code:le.not_finite,message:a.message}),s.dirty()):it.assertNever(a);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,Ne.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ne.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ne.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ne.toString(n))}setLimit(t,n,r,s){return new hd({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Ne.toString(s)}]})}_addCheck(t){return new hd({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Ne.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ne.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ne.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ne.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ne.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ne.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:Ne.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ne.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ne.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.valuet.kind==="int"||t.kind==="multipleOf"&&it.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.valuenew hd({checks:[],typeName:$e.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Ye(e)});class md extends st{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Se.bigint)return this._getInvalidInput(t);let r;const s=new Ar;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.dataa.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),ve(r,{code:le.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),ve(r,{code:le.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):it.assertNever(a);return{status:s.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return ve(n,{code:le.invalid_type,expected:Se.bigint,received:n.parsedType}),Le}gte(t,n){return this.setLimit("min",t,!0,Ne.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ne.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ne.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ne.toString(n))}setLimit(t,n,r,s){return new md({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Ne.toString(s)}]})}_addCheck(t){return new md({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ne.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ne.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ne.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ne.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ne.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.valuenew md({checks:[],typeName:$e.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Ye(e)});class Ix extends st{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Se.boolean){const r=this._getOrReturnCtx(t);return ve(r,{code:le.invalid_type,expected:Se.boolean,received:r.parsedType}),Le}return Yr(t.data)}}Ix.create=e=>new Ix({typeName:$e.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Ye(e)});class bm extends st{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Se.date){const a=this._getOrReturnCtx(t);return ve(a,{code:le.invalid_type,expected:Se.date,received:a.parsedType}),Le}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return ve(a,{code:le.invalid_date}),Le}const r=new Ar;let s;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()a.value&&(s=this._getOrReturnCtx(t,s),ve(s,{code:le.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):it.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new bm({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:Ne.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:Ne.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.valuenew bm({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:$e.ZodDate,...Ye(e)});class DS extends st{_parse(t){if(this._getType(t)!==Se.symbol){const r=this._getOrReturnCtx(t);return ve(r,{code:le.invalid_type,expected:Se.symbol,received:r.parsedType}),Le}return Yr(t.data)}}DS.create=e=>new DS({typeName:$e.ZodSymbol,...Ye(e)});class IS extends st{_parse(t){if(this._getType(t)!==Se.undefined){const r=this._getOrReturnCtx(t);return ve(r,{code:le.invalid_type,expected:Se.undefined,received:r.parsedType}),Le}return Yr(t.data)}}IS.create=e=>new IS({typeName:$e.ZodUndefined,...Ye(e)});class LS extends st{_parse(t){if(this._getType(t)!==Se.null){const r=this._getOrReturnCtx(t);return ve(r,{code:le.invalid_type,expected:Se.null,received:r.parsedType}),Le}return Yr(t.data)}}LS.create=e=>new LS({typeName:$e.ZodNull,...Ye(e)});class $S extends st{constructor(){super(...arguments),this._any=!0}_parse(t){return Yr(t.data)}}$S.create=e=>new $S({typeName:$e.ZodAny,...Ye(e)});class FS extends st{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Yr(t.data)}}FS.create=e=>new FS({typeName:$e.ZodUnknown,...Ye(e)});class So extends st{_parse(t){const n=this._getOrReturnCtx(t);return ve(n,{code:le.invalid_type,expected:Se.never,received:n.parsedType}),Le}}So.create=e=>new So({typeName:$e.ZodNever,...Ye(e)});class zS extends st{_parse(t){if(this._getType(t)!==Se.undefined){const r=this._getOrReturnCtx(t);return ve(r,{code:le.invalid_type,expected:Se.void,received:r.parsedType}),Le}return Yr(t.data)}}zS.create=e=>new zS({typeName:$e.ZodVoid,...Ye(e)});class Hs extends st{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),s=this._def;if(n.parsedType!==Se.array)return ve(n,{code:le.invalid_type,expected:Se.array,received:n.parsedType}),Le;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,l=n.data.lengths.maxLength.value&&(ve(n,{code:le.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,l)=>s.type._parseAsync(new jo(n,o,n.path,l)))).then(o=>Ar.mergeArray(r,o));const a=[...n.data].map((o,l)=>s.type._parseSync(new jo(n,o,n.path,l)));return Ar.mergeArray(r,a)}get element(){return this._def.type}min(t,n){return new Hs({...this._def,minLength:{value:t,message:Ne.toString(n)}})}max(t,n){return new Hs({...this._def,maxLength:{value:t,message:Ne.toString(n)}})}length(t,n){return new Hs({...this._def,exactLength:{value:t,message:Ne.toString(n)}})}nonempty(t){return this.min(1,t)}}Hs.create=(e,t)=>new Hs({type:e,minLength:null,maxLength:null,exactLength:null,typeName:$e.ZodArray,...Ye(t)});function ol(e){if(e instanceof rn){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=go.create(ol(r))}return new rn({...e._def,shape:()=>t})}else return e instanceof Hs?new Hs({...e._def,type:ol(e.element)}):e instanceof go?go.create(ol(e.unwrap())):e instanceof pc?pc.create(ol(e.unwrap())):e instanceof Si?Si.create(e.items.map(t=>ol(t))):e}class rn extends st{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=it.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==Se.object){const u=this._getOrReturnCtx(t);return ve(u,{code:le.invalid_type,expected:Se.object,received:u.parsedType}),Le}const{status:r,ctx:s}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof So&&this._def.unknownKeys==="strip"))for(const u in s.data)o.includes(u)||l.push(u);const c=[];for(const u of o){const d=a[u],f=s.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new jo(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof So){const u=this._def.unknownKeys;if(u==="passthrough")for(const d of l)c.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(u==="strict")l.length>0&&(ve(s,{code:le.unrecognized_keys,keys:l}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const d of l){const f=s.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new jo(s,f,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const d of c){const f=await d.key,h=await d.value;u.push({key:f,value:h,alwaysSet:d.alwaysSet})}return u}).then(u=>Ar.mergeObjectSync(r,u)):Ar.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return Ne.errToObj,new rn({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var a,o;const s=((o=(a=this._def).errorMap)==null?void 0:o.call(a,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:Ne.errToObj(t).message??s}:{message:s}}}:{}})}strip(){return new rn({...this._def,unknownKeys:"strip"})}passthrough(){return new rn({...this._def,unknownKeys:"passthrough"})}extend(t){return new rn({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new rn({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:$e.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new rn({...this._def,catchall:t})}pick(t){const n={};for(const r of it.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new rn({...this._def,shape:()=>n})}omit(t){const n={};for(const r of it.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new rn({...this._def,shape:()=>n})}deepPartial(){return ol(this)}partial(t){const n={};for(const r of it.objectKeys(this.shape)){const s=this.shape[r];t&&!t[r]?n[r]=s:n[r]=s.optional()}return new rn({...this._def,shape:()=>n})}required(t){const n={};for(const r of it.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof go;)a=a._def.innerType;n[r]=a}return new rn({...this._def,shape:()=>n})}keyof(){return EM(it.objectKeys(this.shape))}}rn.create=(e,t)=>new rn({shape:()=>e,unknownKeys:"strip",catchall:So.create(),typeName:$e.ZodObject,...Ye(t)});rn.strictCreate=(e,t)=>new rn({shape:()=>e,unknownKeys:"strict",catchall:So.create(),typeName:$e.ZodObject,...Ye(t)});rn.lazycreate=(e,t)=>new rn({shape:e,unknownKeys:"strip",catchall:So.create(),typeName:$e.ZodObject,...Ye(t)});class _m extends st{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function s(a){for(const l of a)if(l.result.status==="valid")return l.result;for(const l of a)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;const o=a.map(l=>new ka(l.ctx.common.issues));return ve(n,{code:le.invalid_union,unionErrors:o}),Le}if(n.common.async)return Promise.all(r.map(async a=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let a;const o=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},d=c._parseSync({data:n.data,path:n.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!a&&(a={result:d,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const l=o.map(c=>new ka(c));return ve(n,{code:le.invalid_union,unionErrors:l}),Le}}get options(){return this._def.options}}_m.create=(e,t)=>new _m({options:e,typeName:$e.ZodUnion,...Ye(t)});function Lx(e,t){const n=$a(e),r=$a(t);if(e===t)return{valid:!0,data:e};if(n===Se.object&&r===Se.object){const s=it.objectKeys(t),a=it.objectKeys(e).filter(l=>s.indexOf(l)!==-1),o={...e,...t};for(const l of a){const c=Lx(e[l],t[l]);if(!c.valid)return{valid:!1};o[l]=c.data}return{valid:!0,data:o}}else if(n===Se.array&&r===Se.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let a=0;a{if(RS(a)||RS(o))return Le;const l=Lx(a.value,o.value);return l.valid?((OS(a)||OS(o))&&n.dirty(),{status:n.value,value:l.data}):(ve(r,{code:le.invalid_intersection_types}),Le)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,o])=>s(a,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}km.create=(e,t,n)=>new km({left:e,right:t,typeName:$e.ZodIntersection,...Ye(n)});class Si extends st{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Se.array)return ve(r,{code:le.invalid_type,expected:Se.array,received:r.parsedType}),Le;if(r.data.lengththis._def.items.length&&(ve(r,{code:le.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...r.data].map((o,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new jo(r,o,r.path,l)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>Ar.mergeArray(n,o)):Ar.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new Si({...this._def,rest:t})}}Si.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Si({items:e,typeName:$e.ZodTuple,rest:null,...Ye(t)})};class BS extends st{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Se.map)return ve(r,{code:le.invalid_type,expected:Se.map,received:r.parsedType}),Le;const s=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([l,c],u)=>({key:s._parse(new jo(r,l,r.path,[u,"key"])),value:a._parse(new jo(r,c,r.path,[u,"value"]))}));if(r.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of o){const u=await c.key,d=await c.value;if(u.status==="aborted"||d.status==="aborted")return Le;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}})}else{const l=new Map;for(const c of o){const u=c.key,d=c.value;if(u.status==="aborted"||d.status==="aborted")return Le;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}}}}BS.create=(e,t,n)=>new BS({valueType:t,keyType:e,typeName:$e.ZodMap,...Ye(n)});class pd extends st{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Se.set)return ve(r,{code:le.invalid_type,expected:Se.set,received:r.parsedType}),Le;const s=this._def;s.minSize!==null&&r.data.sizes.maxSize.value&&(ve(r,{code:le.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const a=this._def.valueType;function o(c){const u=new Set;for(const d of c){if(d.status==="aborted")return Le;d.status==="dirty"&&n.dirty(),u.add(d.value)}return{status:n.value,value:u}}const l=[...r.data.values()].map((c,u)=>a._parse(new jo(r,c,r.path,u)));return r.common.async?Promise.all(l).then(c=>o(c)):o(l)}min(t,n){return new pd({...this._def,minSize:{value:t,message:Ne.toString(n)}})}max(t,n){return new pd({...this._def,maxSize:{value:t,message:Ne.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}pd.create=(e,t)=>new pd({valueType:e,minSize:null,maxSize:null,typeName:$e.ZodSet,...Ye(t)});class US extends st{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}US.create=(e,t)=>new US({getter:e,typeName:$e.ZodLazy,...Ye(t)});class $x extends st{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return ve(n,{received:n.data,code:le.invalid_literal,expected:this._def.value}),Le}return{status:"valid",value:t.data}}get value(){return this._def.value}}$x.create=(e,t)=>new $x({value:e,typeName:$e.ZodLiteral,...Ye(t)});function EM(e,t){return new hc({values:e,typeName:$e.ZodEnum,...Ye(t)})}class hc extends st{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return ve(n,{expected:it.joinValues(r),received:n.parsedType,code:le.invalid_type}),Le}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return ve(n,{received:n.data,code:le.invalid_enum_value,options:r}),Le}return Yr(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return hc.create(t,{...this._def,...n})}exclude(t,n=this._def){return hc.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}hc.create=EM;class VS extends st{_parse(t){const n=it.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Se.string&&r.parsedType!==Se.number){const s=it.objectValues(n);return ve(r,{expected:it.joinValues(s),received:r.parsedType,code:le.invalid_type}),Le}if(this._cache||(this._cache=new Set(it.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const s=it.objectValues(n);return ve(r,{received:r.data,code:le.invalid_enum_value,options:s}),Le}return Yr(t.data)}get enum(){return this._def.values}}VS.create=(e,t)=>new VS({values:e,typeName:$e.ZodNativeEnum,...Ye(t)});class jm extends st{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Se.promise&&n.common.async===!1)return ve(n,{code:le.invalid_type,expected:Se.promise,received:n.parsedType}),Le;const r=n.parsedType===Se.promise?n.data:Promise.resolve(n.data);return Yr(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}jm.create=(e,t)=>new jm({type:e,typeName:$e.ZodPromise,...Ye(t)});class mc extends st{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$e.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=this._def.effect||null,a={addIssue:o=>{ve(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const o=s.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async l=>{if(n.value==="aborted")return Le;const c=await this._def.schema._parseAsync({data:l,path:r.path,parent:r});return c.status==="aborted"?Le:c.status==="dirty"||n.value==="dirty"?hu(c.value):c});{if(n.value==="aborted")return Le;const l=this._def.schema._parseSync({data:o,path:r.path,parent:r});return l.status==="aborted"?Le:l.status==="dirty"||n.value==="dirty"?hu(l.value):l}}if(s.type==="refinement"){const o=l=>{const c=s.refinement(l,a);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(r.common.async===!1){const l=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return l.status==="aborted"?Le:(l.status==="dirty"&&n.dirty(),o(l.value),{status:n.value,value:l.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(l=>l.status==="aborted"?Le:(l.status==="dirty"&&n.dirty(),o(l.value).then(()=>({status:n.value,value:l.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!fc(o))return Le;const l=s.transform(o.value,a);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:l}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>fc(o)?Promise.resolve(s.transform(o.value,a)).then(l=>({status:n.value,value:l})):Le);it.assertNever(s)}}mc.create=(e,t,n)=>new mc({schema:e,typeName:$e.ZodEffects,effect:t,...Ye(n)});mc.createWithPreprocess=(e,t,n)=>new mc({schema:t,effect:{type:"preprocess",transform:e},typeName:$e.ZodEffects,...Ye(n)});class go extends st{_parse(t){return this._getType(t)===Se.undefined?Yr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}go.create=(e,t)=>new go({innerType:e,typeName:$e.ZodOptional,...Ye(t)});class pc extends st{_parse(t){return this._getType(t)===Se.null?Yr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}pc.create=(e,t)=>new pc({innerType:e,typeName:$e.ZodNullable,...Ye(t)});class Fx extends st{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===Se.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Fx.create=(e,t)=>new Fx({innerType:e,typeName:$e.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ye(t)});class zx extends st{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return wm(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ka(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ka(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}zx.create=(e,t)=>new zx({innerType:e,typeName:$e.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ye(t)});class WS extends st{_parse(t){if(this._getType(t)!==Se.nan){const r=this._getOrReturnCtx(t);return ve(r,{code:le.invalid_type,expected:Se.nan,received:r.parsedType}),Le}return{status:"valid",value:t.data}}}WS.create=e=>new WS({typeName:$e.ZodNaN,...Ye(e)});class gte extends st{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class e_ extends st{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Le:a.status==="dirty"?(n.dirty(),hu(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Le:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(t,n){return new e_({in:t,out:n,typeName:$e.ZodPipeline})}}class Bx extends st{_parse(t){const n=this._def.innerType._parse(t),r=s=>(fc(s)&&(s.value=Object.freeze(s.value)),s);return wm(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}Bx.create=(e,t)=>new Bx({innerType:e,typeName:$e.ZodReadonly,...Ye(t)});var $e;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})($e||($e={}));const Cs=to.create,Sm=Ix.create;So.create;Hs.create;const NM=rn.create;_m.create;km.create;Si.create;const Qf=$x.create;hc.create;jm.create;go.create;pc.create;const CM=jee,TM=p.createContext({}),cr=({...e})=>i.jsx(TM.Provider,{value:{name:e.name},children:i.jsx(Cee,{...e})}),$p=()=>{const e=p.useContext(TM),t=p.useContext(PM),{getFieldState:n,formState:r}=Lp(),s=n(e.name,r);if(!e)throw new Error("useFormField should be used within ");const{id:a}=t;return{id:a,name:e.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...s}},PM=p.createContext({}),Wn=p.forwardRef(({className:e,...t},n)=>{const r=p.useId();return i.jsx(PM.Provider,{value:{id:r},children:i.jsx("div",{ref:n,className:Y("space-y-2",e),...t})})});Wn.displayName="FormItem";const Hn=p.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:s}=$p();return i.jsx(Tt,{ref:n,className:Y(r&&"text-destructive",e),htmlFor:s,...t})});Hn.displayName="FormLabel";const qn=p.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:s,formMessageId:a}=$p();return i.jsx(OC,{ref:t,id:r,"aria-describedby":n?`${s} ${a}`:`${s}`,"aria-invalid":!!n,...e})});qn.displayName="FormControl";const mu=p.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=$p();return i.jsx("p",{ref:n,id:r,className:Y("text-sm text-muted-foreground",e),...t})});mu.displayName="FormDescription";const ds=p.forwardRef(({className:e,children:t,...n},r)=>{const{error:s,formMessageId:a}=$p(),o=s?String(s==null?void 0:s.message):t;return o?i.jsx("p",{ref:r,id:a,className:Y("text-sm font-medium text-destructive",e),...n,children:o}):null});ds.displayName="FormMessage";const yte=NM({preferredDate:Cs().min(1,"Datum is verplicht"),preferredTime:Cs().optional(),flexibleDates:Sm().default(!0),notificationsEnabled:Sm().default(!0),notes:Cs().optional()}),vte=({open:e,onOpenChange:t,staffId:n,serviceId:r,preferredDate:s,customerName:a,customerEmail:o,customerPhone:l,organizationId:c})=>{const[u,d]=p.useState(!1),f=bM({resolver:kM(yte),defaultValues:{preferredDate:s.toISOString().split("T")[0],preferredTime:"",flexibleDates:!0,notificationsEnabled:!0,notes:""}});p.useEffect(()=>{(async()=>{const{data:{user:v}}=await B.auth.getUser();if(v){const{data:w}=await B.from("profiles").select("waitlist_notifications_enabled").eq("id",v.id).single();w&&f.setValue("notificationsEnabled",w.waitlist_notifications_enabled??!0)}})()},[f]);const h=async m=>{d(!0);try{const{data:{user:v}}=await B.auth.getUser();if(!a||!o){K.error("Klantgegevens ontbreken. Vul eerst uw gegevens in.");return}c&&await Je({organizationId:c,scope:"waitlist-signup",key:`${o}-${m.preferredDate}-${r}`});const{error:w}=await B.from("waitlist").insert({customer_id:(v==null?void 0:v.id)||null,staff_id:n,service_id:r,preferred_date:m.preferredDate,preferred_time:m.preferredTime||null,flexible_dates:m.flexibleDates,customer_name:a,customer_email:o,customer_phone:l||null,notes:m.notes||null,status:"active",organization_id:c||null});if(w)throw w;v&&await B.from("profiles").update({waitlist_notifications_enabled:m.notificationsEnabled}).eq("id",v.id),K.success("U bent toegevoegd aan de wachtlijst! We nemen contact op zodra er een plek vrijkomt."),t(!1),f.reset()}catch(v){console.error("Error adding to waitlist:",v),K.error("Er is een fout opgetreden. Probeer het opnieuw.")}finally{d(!1)}};return i.jsx(Mc,{open:e,onOpenChange:t,children:i.jsxs(Oi,{className:"sm:max-w-[500px]",children:[i.jsxs(Bd,{children:[i.jsx(Mi,{children:"Schrijf u in op de wachtlijst"}),i.jsx(Ud,{children:"Er zijn momenteel geen beschikbare tijden op deze datum. Laat uw gegevens achter en we nemen contact op zodra er een plek vrijkomt."}),i.jsxs("div",{className:"mt-2 flex items-center gap-2 text-xs text-muted-foreground bg-muted/50 rounded-md px-3 py-2",children:[i.jsx("span",{className:"text-primary",children:"ℹ️"}),i.jsx("span",{children:"Uw inschrijving is 7 dagen geldig. Daarna wordt deze automatisch gearchiveerd."})]})]}),i.jsx(CM,{...f,children:i.jsxs("form",{onSubmit:f.handleSubmit(h),className:"space-y-4",children:[i.jsx(cr,{control:f.control,name:"preferredDate",render:({field:m})=>i.jsxs(Wn,{children:[i.jsx(Hn,{children:"Gewenste Datum"}),i.jsx(qn,{children:i.jsx(ot,{type:"date",...m})}),i.jsx(ds,{})]})}),i.jsx(cr,{control:f.control,name:"preferredTime",render:({field:m})=>i.jsxs(Wn,{children:[i.jsx(Hn,{children:"Gewenste Tijd (optioneel)"}),i.jsx(qn,{children:i.jsx(ot,{type:"time",...m,placeholder:"bijv. 10:00"})}),i.jsx(ds,{})]})}),i.jsx(cr,{control:f.control,name:"flexibleDates",render:({field:m})=>i.jsxs(Wn,{className:"flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4",children:[i.jsx(qn,{children:i.jsx(ji,{checked:m.value,onCheckedChange:m.onChange})}),i.jsxs("div",{className:"space-y-1 leading-none",children:[i.jsx(Hn,{children:"Ik ben flexibel met andere data"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"We contacteren u ook voor andere beschikbare momenten"})]})]})}),i.jsx(cr,{control:f.control,name:"notificationsEnabled",render:({field:m})=>i.jsxs(Wn,{className:"flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4",children:[i.jsx(qn,{children:i.jsx(ji,{checked:m.value,onCheckedChange:m.onChange})}),i.jsxs("div",{className:"space-y-1 leading-none",children:[i.jsx(Hn,{children:"Stuur mij een bericht wanneer er een plek vrijkomt"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"We nemen alleen contact op voor deze specifieke wachtlijst"})]})]})}),i.jsx(cr,{control:f.control,name:"notes",render:({field:m})=>i.jsxs(Wn,{children:[i.jsx(Hn,{children:"Opmerkingen (optioneel)"}),i.jsx(qn,{children:i.jsx(Di,{placeholder:"Bijv. specifieke voorkeuren of tijden die niet werken...",...m})}),i.jsx(ds,{})]})}),i.jsxs("div",{className:"flex gap-3 pt-4",children:[i.jsx(ne,{type:"button",variant:"outline",onClick:()=>t(!1),className:"flex-1",disabled:u,children:"Annuleren"}),i.jsx(ne,{type:"submit",className:"flex-1",disabled:u,children:u?i.jsxs(i.Fragment,{children:[i.jsx(yn,{className:"mr-2 h-4 w-4 animate-spin"}),"Toevoegen..."]}):"Toevoegen aan wachtlijst"})]})]})})]})})},xte=({open:e,onOpenChange:t,onConfirm:n,initialDates:r=[]})=>{const[s,a]=p.useState(r),o=u=>{const d=he(u,"yyyy-MM-dd"),f=s.some(h=>he(h,"yyyy-MM-dd")===d);a(f?s.filter(h=>he(h,"yyyy-MM-dd")!==d):[...s,u].sort((h,m)=>h.getTime()-m.getTime()))},l=u=>{a(s.filter(d=>d!==u))},c=()=>{s.length>0&&(n(s),t(!1))};return i.jsx(Mc,{open:e,onOpenChange:t,children:i.jsxs(Oi,{className:"max-w-md",children:[i.jsxs(Bd,{children:[i.jsx(Mi,{children:"Selecteer specifieke datums"}),i.jsx(Ud,{children:"Klik op meerdere datums waarop u beschikbaar bent voor een afspraak"})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"flex justify-center",children:i.jsx($c,{onDayClick:o,disabled:u=>u0&&i.jsxs("div",{className:"space-y-2",children:[i.jsxs("p",{className:"text-sm font-medium",children:["Geselecteerde datums (",s.length,"):"]}),i.jsx("div",{className:"flex flex-wrap gap-2",children:s.map(u=>i.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[he(u,"d MMM",{locale:tt}),i.jsx(Sa,{className:"h-3 w-3 cursor-pointer hover:text-destructive",onClick:()=>l(u)})]},u.toISOString()))})]})]}),i.jsxs(Sp,{children:[i.jsx(ne,{variant:"outline",onClick:()=>t(!1),children:"Annuleren"}),i.jsxs(ne,{onClick:c,disabled:s.length===0,children:["Bevestigen (",s.length,")"]})]})]})})},wte=({staffId:e,serviceId:t,serviceDuration:n=30,serviceBuffer:r=0,onNext:s,onBack:a,customerName:o,customerEmail:l,customerPhone:c,organizationId:u})=>{const[d,f]=p.useState(),[h,m]=p.useState(""),[v,w]=p.useState([]),[y,x]=p.useState(!1),[g,b]=p.useState(!1),[_,j]=p.useState("none"),[k,S]=p.useState([]),[E,N]=p.useState(!1),[O,z]=p.useState([]),{isStaffWorkingDay:T,getTimeSlotsForDate:I,getEndHourForDate:P,isLoading:H}=lM(e,u),V=n+r,M=Math.ceil(V/30);p.useEffect(()=>{if(!e)return;(async()=>{const{data:fe,error:ee}=await B.from("staff_availability").select("date").eq("staff_id",e);if(ee){console.error("Error fetching staff availability:",ee);return}z((fe||[]).map(je=>je.date))})()},[e]),p.useEffect(()=>{if(!d||!e)return;const Q=async()=>{x(!0);try{const ee=he(d,"yyyy-MM-dd"),{data:je,error:Ee}=await B.rpc("get_booked_time_slots",{p_staff_id:e,p_appointment_date:ee});if(Ee)throw Ee;const te=(je||[]).map(_e=>_e.appointment_time);w(te)}catch(ee){console.error("Error fetching booked slots:",ee),K.error("Kon beschikbare tijden niet laden")}finally{x(!1)}};Q();const fe=B.channel("appointments-changes").on("postgres_changes",{event:"*",schema:"public",table:"appointments",filter:`staff_id=eq.${e}`},()=>{Q()}).subscribe();return()=>{B.removeChannel(fe)}},[d,e]);const C=()=>{d&&h&&s(d,h,_,_==="specific"?k:void 0)},F=()=>{j(_==="flexible"?"none":"flexible"),_==="specific"&&S([])},W=()=>{N(!0)},ie=Q=>{S(Q),j("specific")},oe=Q=>{const fe=k.filter(ee=>ee!==Q);S(fe),fe.length===0&&j("none")},ce=Q=>{if(!d)return!1;const[fe,ee]=Q.split(":").map(Number),je=P(d);for(let Ee=0;Ee=je)return!1}return!0},re=d?I(d):[],ue=re.filter(Q=>ce(Q)),ke=d&&!y&&!H&&ue.length===0,L=d?he(d,"EEEE d MMMM",{locale:tt}):"";return i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"flex justify-center",children:i.jsx($c,{mode:"single",selected:d,onSelect:f,disabled:Q=>{if(Qb(!0),variant:"outline",className:"rounded-full text-sm",children:[i.jsx($k,{className:"h-3.5 w-3.5 mr-2"}),"Wachtlijst"]})]}):i.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:re.map(Q=>{const fe=ce(Q),ee=h===Q;return i.jsx("button",{onClick:()=>fe&&m(Q),disabled:!fe,title:!fe&&M>1?`Niet genoeg ruimte voor ${n} min`:void 0,className:Y("py-2.5 text-center text-[13px] font-medium rounded-xl transition-all",ee?"bg-cta text-cta-foreground":fe?"bg-surface-cream text-foreground hover:border-foreground":"bg-surface-cream text-muted-foreground/40 cursor-not-allowed"),children:Q},Q)})})]}),d&&h&&!ke&&i.jsxs("div",{className:"border-t border-border/60 pt-4 space-y-3",children:[i.jsx("div",{children:i.jsx("p",{className:"text-xs text-muted-foreground",children:"Wil je ook op de hoogte gehouden worden als er eerder plekken vrijkomen?"})}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsxs("button",{onClick:F,className:Y("flex items-center gap-2.5 px-3.5 py-2.5 rounded-xl text-sm text-left transition-all",_==="flexible"?"bg-cta/8 border-[1.5px] border-cta text-foreground":"bg-surface-cream border-[1.5px] border-transparent text-muted-foreground hover:text-foreground"),children:[i.jsx($k,{className:"h-3.5 w-3.5 flex-shrink-0"}),"Schrijf me in voor de wachtlijst"]}),i.jsxs("button",{onClick:W,className:Y("flex items-center gap-2.5 px-3.5 py-2.5 rounded-xl text-sm text-left transition-all",_==="specific"?"bg-cta/8 border-[1.5px] border-cta text-foreground":"bg-surface-cream border-[1.5px] border-transparent text-muted-foreground hover:text-foreground"),children:[i.jsx(Km,{className:"h-3.5 w-3.5 flex-shrink-0"}),"Schrijf in voor specifieke data"]})]}),_==="specific"&&k.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-xs font-medium text-foreground",children:"Geselecteerde datums:"}),i.jsx("div",{className:"flex flex-wrap gap-1.5",children:k.map(Q=>i.jsxs(Qe,{variant:"secondary",className:"gap-1 rounded-full text-xs",children:[he(Q,"d MMM",{locale:tt}),i.jsx(Sa,{className:"h-3 w-3 cursor-pointer hover:text-destructive",onClick:()=>oe(Q)})]},Q.toISOString()))})]}),_==="flexible"&&i.jsx("div",{className:"bg-surface-cream rounded-xl px-3.5 py-2.5",children:i.jsx("p",{className:"text-xs text-muted-foreground",children:"✓ Je ontvangt een bericht als er eerder plekken vrijkomen"})})]}),i.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-border/60",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-[11px] text-muted-foreground",children:L||"Selecteer een datum"}),i.jsx("div",{className:"text-base font-semibold text-foreground leading-tight",children:h||"—"})]}),i.jsx(ne,{onClick:C,disabled:!d||!h,className:"rounded-full px-5 py-2.5 text-sm font-semibold bg-cta text-cta-foreground hover:bg-cta/90 disabled:bg-border disabled:text-muted-foreground",children:"Volgende →"})]}),i.jsx(vte,{open:g,onOpenChange:b,staffId:e,serviceId:t,preferredDate:d||new Date,customerName:o,customerEmail:l,customerPhone:c,organizationId:u}),i.jsx(xte,{open:E,onOpenChange:N,onConfirm:ie,initialDates:k})]})},bte=({userId:e,initial:t,branche:n="algemeen",onNext:r,onBack:s})=>{const a=lc(n,"services"),o=lc(n,"appointment").toLowerCase(),l=n==="kappers_beauty",[c,u]=p.useState((t==null?void 0:t.name)??""),[d,f]=p.useState((t==null?void 0:t.email)??""),[h,m]=p.useState((t==null?void 0:t.phone)??""),[v,w]=p.useState(""),[y,x]=p.useState(!1),[g,b]=p.useState(!!e);p.useEffect(()=>{t!=null&&t.name&&u(k=>k||t.name),t!=null&&t.email&&f(k=>k||t.email),t!=null&&t.phone&&m(k=>k||t.phone)},[t==null?void 0:t.name,t==null?void 0:t.email,t==null?void 0:t.phone]),p.useEffect(()=>{if(!e){b(!1);return}(async()=>{const{data:S,error:E}=await B.from("profiles").select("full_name, email, phone").eq("id",e).maybeSingle();E?(K.error("Fout bij laden profiel"),console.error(E)):S&&(S.full_name&&u(S.full_name),S.email&&f(S.email),S.phone&&m(S.phone)),b(!1)})()},[e]);const _=()=>{c&&d&&h&&r({customerName:c,customerEmail:d,customerPhone:h})},j=c.trim().length>=2&&d.includes("@")&&h.trim().length>=8;return g?i.jsx("div",{className:"flex justify-center py-16",children:i.jsx("div",{className:"animate-spin h-5 w-5 border-2 border-cta border-t-transparent rounded-full"})}):i.jsxs("div",{className:"space-y-3.5",children:[i.jsxs("div",{className:"space-y-3",children:[i.jsx(Xf,{label:"Naam",required:!0,children:i.jsx("input",{value:c,onChange:k=>u(k.target.value),placeholder:"Voor- en achternaam",className:"w-full bg-surface-cream border-[1.5px] border-transparent rounded-xl px-3.5 py-3 text-sm text-foreground outline-none transition-colors focus:border-foreground placeholder:text-muted-foreground"})}),i.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[i.jsx(Xf,{label:"Telefoon",required:!0,children:i.jsx("input",{value:h,onChange:k=>m(k.target.value),placeholder:"06 12 34 56 78",type:"tel",className:"w-full bg-surface-cream border-[1.5px] border-transparent rounded-xl px-3.5 py-3 text-sm text-foreground outline-none transition-colors focus:border-foreground placeholder:text-muted-foreground"})}),i.jsx(Xf,{label:"E-mail",required:!0,children:i.jsx("input",{value:d,onChange:k=>f(k.target.value),placeholder:"jij@voorbeeld.nl",type:"email",className:"w-full bg-surface-cream border-[1.5px] border-transparent rounded-xl px-3.5 py-3 text-sm text-foreground outline-none transition-colors focus:border-foreground placeholder:text-muted-foreground"})})]}),i.jsx(Xf,{label:"Opmerking (optioneel)",sub:l?"Voorkeuren, allergieën, of andere info":"Bijzonderheden of andere info",children:i.jsx("textarea",{value:v,onChange:k=>w(k.target.value),rows:3,placeholder:l?"Bijvoorbeeld: korter aan de zijkanten dan vorige keer.":"Bijvoorbeeld: de oprit is smal, graag even bellen voor aankomst.",className:"w-full bg-surface-cream border-[1.5px] border-transparent rounded-xl px-3.5 py-3 text-sm text-foreground outline-none transition-colors focus:border-foreground placeholder:text-muted-foreground resize-vertical min-h-[72px]"})})]}),i.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer",children:[i.jsx("button",{type:"button",onClick:()=>x(!y),className:Y("w-[18px] h-[18px] rounded flex-shrink-0 mt-0.5 flex items-center justify-center border-[1.5px] transition-all",y?"border-cta bg-cta":"border-border bg-white"),children:y&&i.jsx(kc,{className:"h-3 w-3 text-white",strokeWidth:3})}),i.jsxs("span",{className:"text-[13px] text-muted-foreground leading-relaxed",children:["Houd me op de hoogte van nieuwe ",a," & aanbiedingen"]})]}),i.jsx("div",{className:"bg-surface-cream rounded-xl px-3.5 py-2.5",children:i.jsxs("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:["Je ontvangt automatisch een bevestiging per e-mail, en een herinnering 24 uur voor je ",o,"."]})}),i.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-border/60",children:[i.jsx("div",{className:"flex-1"}),i.jsx(ne,{onClick:_,disabled:!j,className:"rounded-full px-5 py-2.5 text-sm font-semibold bg-cta text-cta-foreground hover:bg-cta/90 disabled:bg-border disabled:text-muted-foreground",children:"Naar overzicht →"})]})]})};function Xf({label:e,sub:t,required:n,children:r}){return i.jsxs("label",{className:"block",children:[i.jsxs("div",{className:"text-xs font-semibold text-foreground mb-1.5",children:[e,n&&i.jsx("span",{className:"text-cta ml-1",children:"*"})]}),r,t&&i.jsx("div",{className:"text-[11px] text-muted-foreground mt-1.5",children:t})]})}const Py={ochtend:{label:"Ochtend",time:"08:00 - 12:00"},middag:{label:"Middag",time:"13:00 - 17:00"},hele_dag:{label:"Hele dag",time:"08:00 - 17:00"}},Ay={ochtend:"08:00",middag:"13:00",hele_dag:"08:00"},_te=({userId:e,bookingData:t,organizationId:n,onBack:r,onConfirm:s})=>{const[a,o]=p.useState(!1),[l,c]=p.useState(!1),[u,d]=p.useState(null),[f,h]=p.useState(""),[m,v]=p.useState(!1),w=async()=>{var k,S,E;if(!t.staffId||!t.serviceId||!t.startDate){K.error("Ontbrekende afspraakgegevens. Ga terug en controleer je selectie.");return}if(!((k=t.customerName)!=null&&k.trim())||!((S=t.customerEmail)!=null&&S.trim())){K.error("Naam en e-mailadres zijn verplicht.");return}if(!$b(t.customerEmail.trim())){K.error("Ongeldig e-mailadres.");return}if(t.customerPhone&&!Fb(t.customerPhone)){K.error("Ongeldig telefoonnummer.");return}o(!0);try{let N=n;if(!N){const{data:T}=await B.from("staff").select("organization_id").eq("id",t.staffId).single();N=(T==null?void 0:T.organization_id)||null}if(!N)throw new Error("Geen organisatiecontext gevonden voor boeking.");const O=[t.staffId,t.serviceId,t.startDate,t.appointmentTime||Ay[t.dayPart||"hele_dag"],(E=t.customerEmail)==null?void 0:E.trim().toLowerCase()].join(":");let z;if(e){await Je({organizationId:N,scope:"booking-confirmation-authenticated",key:`auth:${e}:${O}`,ttlSeconds:1800}),z=crypto.randomUUID();const T={customer_id:e,customer_name:t.customerName,customer_email:t.customerEmail,customer_phone:t.customerPhone,staff_id:t.staffId,service_id:t.serviceId,appointment_date:t.startDate,appointment_time:t.appointmentTime||Ay[t.dayPart||"hele_dag"],appointment_type:t.appointmentType||null,status:"pending",booking_token:z,organization_id:N,day_part:t.dayPart||"hele_dag",end_date:t.endDate||null},{error:I}=await B.from("appointments").insert(T);if(I)throw I}else{await Je({organizationId:N,scope:"booking-confirmation-guest",key:`guest:${O}`,ttlSeconds:1800});const{data:T,error:I}=await B.rpc("create_guest_appointment",{p_staff_id:t.staffId,p_service_id:t.serviceId,p_appointment_date:t.startDate,p_appointment_time:t.appointmentTime||Ay[t.dayPart||"hele_dag"],p_customer_name:t.customerName,p_customer_email:t.customerEmail,p_appointment_type:t.appointmentType||null,p_customer_phone:t.customerPhone||null,p_notes:null,p_organization_id:N});if(I)throw I;const{data:P}=await B.from("appointments").select("booking_token").eq("id",T).single();z=(P==null?void 0:P.booking_token)||crypto.randomUUID(),await B.from("appointments").update({day_part:t.dayPart||"hele_dag",end_date:t.endDate||null}).eq("id",T)}try{const{error:T}=await B.functions.invoke("send-booking-confirmation",{body:{bookingToken:z}});T&&console.error("Email sending failed:",T)}catch(T){console.error("Email sending error:",T)}d(z),e?(K.success("Afspraak succesvol gemaakt!"),s()):c(!0)}catch(N){console.error("Error creating appointment:",N);const O=N instanceof Error?N.message:"Er is een fout opgetreden bij het maken van de afspraak";K.error(O)}finally{o(!1)}},y=async()=>{if(!f||f.length<6){K.error("Wachtwoord moet minimaal 6 tekens zijn");return}o(!0);try{const{data:k,error:S}=await B.auth.signUp({email:t.customerEmail,password:f,options:{emailRedirectTo:`${window.location.origin}/`,data:{full_name:t.customerName}}});if(S)throw S;if(!k.user)throw new Error("Geen gebruiker aangemaakt");await B.from("profiles").insert({id:k.user.id,full_name:t.customerName,email:t.customerEmail,phone:t.customerPhone,organization_id:n||null}),await B.from("user_roles").insert({user_id:k.user.id,role:"customer"}),await B.from("appointments").update({customer_id:k.user.id}).eq("booking_token",u),K.success("Account aangemaakt! Check je email voor verificatie."),s()}catch(k){console.error("Account creation error:",k);const S=k instanceof Error?k.message:"Fout bij aanmaken account";K.error(S)}finally{o(!1)}},x=()=>{K.success("Afspraak succesvol gemaakt! Check je email voor details."),s()},g=()=>{if(!t.startDate||!t.endDate)return 1;let k=0,S=mn(t.startDate);const E=mn(t.endDate);for(;S<=E;)vW(S)||k++,S=mt(S,1);return k};if(l){const k=t.startDate?he(mn(t.startDate),"EEEE d MMMM",{locale:tt}):"";return i.jsxs("div",{className:"space-y-5",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"w-[72px] h-[72px] rounded-full bg-[#e7f8ee] mx-auto mb-4 flex items-center justify-center",children:i.jsx("span",{className:"text-[#2f9d5c] text-3xl font-semibold",children:"✓"})}),i.jsxs("div",{className:"text-2xl font-bold text-foreground font-display tracking-tight mb-1.5",children:["Tot ",k?he(mn(t.startDate),"EEEE",{locale:tt}):"snel","!"]}),i.jsxs("p",{className:"text-[13px] text-muted-foreground",children:["Je afspraak staat in onze agenda. We sturen een bevestiging naar"," ",i.jsx("strong",{className:"text-foreground",children:t.customerEmail}),"."]})]}),i.jsxs("div",{className:"bg-surface-cream rounded-2xl p-5 space-y-3",children:[i.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Samenvatting"}),i.jsxs("div",{className:"border-t border-border/60 pt-3 grid grid-cols-2 gap-2.5 text-[13px]",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-[11px] text-muted-foreground mb-0.5",children:"Datum"}),i.jsx("div",{className:"font-semibold",children:k})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-[11px] text-muted-foreground mb-0.5",children:"Tijd"}),i.jsx("div",{className:"font-semibold",children:t.appointmentTime||Py[t.dayPart||"hele_dag"].time})]})]})]}),i.jsxs("div",{className:"border-[1.5px] border-cta/20 rounded-2xl p-5 space-y-3",children:[i.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Maak een account aan"}),i.jsx("p",{className:"text-[13px] text-muted-foreground",children:"Beheer je afspraken makkelijk en krijg toegang tot extra functies."}),i.jsxs("div",{children:[i.jsx(Tt,{htmlFor:"password",className:"text-xs font-semibold",children:"Kies een wachtwoord"}),i.jsx(ot,{id:"password",type:"password",value:f,onChange:S=>h(S.target.value),placeholder:"Minimaal 6 tekens",className:"mt-1.5 bg-surface-cream border-transparent rounded-xl focus:border-foreground"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsx(ne,{onClick:x,variant:"outline",className:"rounded-full text-sm",disabled:a,children:"Overslaan"}),i.jsx(ne,{onClick:y,className:"rounded-full text-sm bg-cta text-cta-foreground hover:bg-cta/90",disabled:a,children:a?i.jsxs(i.Fragment,{children:[i.jsx(yn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Aanmaken..."]}):"Account aanmaken"})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("button",{className:"flex items-center justify-center gap-2 py-3 bg-white border-[1.5px] border-border/60 rounded-xl text-[13px] font-semibold text-foreground cursor-pointer hover:bg-surface-cream transition-colors",children:["📅 ",i.jsx("span",{children:"Agenda"})]}),i.jsxs("button",{className:"flex items-center justify-center gap-2 py-3 bg-[#25D366] border-none rounded-xl text-[13px] font-semibold text-white cursor-pointer hover:bg-[#22c55e] transition-colors",children:["💬 ",i.jsx("span",{children:"WhatsApp"})]})]})]})}const b=t.dayPart?Py[t.dayPart]:Py.hele_dag,_=g(),j=[{label:t.appointmentTime?"Datum & tijd":"Datum",value:t.startDate?he(mn(t.startDate),"EEEE d MMMM yyyy",{locale:tt}):"",sub:t.appointmentTime?`om ${t.appointmentTime}`:`${b.label} (${b.time})`},{label:"Naam",value:t.customerName||""},{label:"E-mail",value:t.customerEmail||""},{label:"Telefoon",value:t.customerPhone||""}];return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"bg-surface-cream rounded-2xl p-1",children:[j.map((k,S)=>i.jsxs("div",{className:Y("grid grid-cols-[100px_1fr] gap-4 items-baseline px-4 py-3",S1&&i.jsxs("div",{className:"px-4 py-2 text-xs text-muted-foreground",children:[_," werkdagen"]})]}),i.jsxs("div",{className:"bg-surface-cream rounded-xl px-3.5 py-2.5 text-xs text-muted-foreground leading-relaxed",children:[i.jsx("strong",{className:"text-foreground",children:"Gratis annuleren"})," tot 24 uur van tevoren."]}),i.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer",children:[i.jsx("button",{type:"button",onClick:()=>v(!m),className:Y("w-[18px] h-[18px] rounded flex-shrink-0 mt-0.5 flex items-center justify-center border-[1.5px] transition-all",m?"border-cta bg-cta":"border-border bg-white"),children:m&&i.jsx(kc,{className:"h-3 w-3 text-white",strokeWidth:3})}),i.jsxs("span",{className:"text-[13px] text-muted-foreground leading-relaxed",children:["Ik ga akkoord met de ",i.jsx("u",{children:"algemene voorwaarden"})," en het annuleringsbeleid."]})]}),i.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t border-border/60",children:[i.jsx("div",{className:"flex-1"}),i.jsx(ne,{onClick:w,disabled:a||!m,className:"rounded-full px-5 py-2.5 text-sm font-semibold bg-cta text-cta-foreground hover:bg-cta/90 disabled:bg-border disabled:text-muted-foreground",children:a?i.jsxs(i.Fragment,{children:[i.jsx(yn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Bevestigen..."]}):"Boek afspraak →"})]})]})};var Fp="Popover",[AM]=Ln(Fp,[Cc]),Xd=Cc(),[kte,Ro]=AM(Fp),RM=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:s,onOpenChange:a,modal:o=!1}=e,l=Xd(t),c=p.useRef(null),[u,d]=p.useState(!1),[f,h]=vs({prop:r,defaultProp:s??!1,onChange:a,caller:Fp});return i.jsx(h0,{...l,children:i.jsx(kte,{scope:t,contentId:Vs(),triggerRef:c,open:f,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),hasCustomAnchor:u,onCustomAnchorAdd:p.useCallback(()=>d(!0),[]),onCustomAnchorRemove:p.useCallback(()=>d(!1),[]),modal:o,children:n})})};RM.displayName=Fp;var OM="PopoverAnchor",jte=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Ro(OM,n),a=Xd(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=s;return p.useEffect(()=>(o(),()=>l()),[o,l]),i.jsx(ep,{...a,...r,ref:t})});jte.displayName=OM;var MM="PopoverTrigger",DM=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Ro(MM,n),a=Xd(n),o=ze(t,s.triggerRef),l=i.jsx(Te.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":zM(s.open),...r,ref:o,onClick:xe(e.onClick,s.onOpenToggle)});return s.hasCustomAnchor?l:i.jsx(ep,{asChild:!0,...a,children:l})});DM.displayName=MM;var t_="PopoverPortal",[Ste,Ete]=AM(t_,{forceMount:void 0}),IM=e=>{const{__scopePopover:t,forceMount:n,children:r,container:s}=e,a=Ro(t_,t);return i.jsx(Ste,{scope:t,forceMount:n,children:i.jsx(Jn,{present:n||a.open,children:i.jsx(Sd,{asChild:!0,container:s,children:r})})})};IM.displayName=t_;var gc="PopoverContent",LM=p.forwardRef((e,t)=>{const n=Ete(gc,e.__scopePopover),{forceMount:r=n.forceMount,...s}=e,a=Ro(gc,e.__scopePopover);return i.jsx(Jn,{present:r||a.open,children:a.modal?i.jsx(Cte,{...s,ref:t}):i.jsx(Tte,{...s,ref:t})})});LM.displayName=gc;var Nte=gi("PopoverContent.RemoveScroll"),Cte=p.forwardRef((e,t)=>{const n=Ro(gc,e.__scopePopover),r=p.useRef(null),s=ze(t,r),a=p.useRef(!1);return p.useEffect(()=>{const o=r.current;if(o)return ab(o)},[]),i.jsx(_p,{as:Nte,allowPinchZoom:!0,children:i.jsx($M,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xe(e.onCloseAutoFocus,o=>{var l;o.preventDefault(),a.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:xe(e.onPointerDownOutside,o=>{const l=o.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;a.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:xe(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),Tte=p.forwardRef((e,t)=>{const n=Ro(gc,e.__scopePopover),r=p.useRef(!1),s=p.useRef(!1);return i.jsx($M,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:a=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=a.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),$M=p.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:d,...f}=e,h=Ro(gc,n),m=Xd(n);return sb(),i.jsx(wp,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:a,children:i.jsx(wc,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:d,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>h.onOpenChange(!1),children:i.jsx(m0,{"data-state":zM(h.open),role:"dialog",id:h.contentId,...m,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),FM="PopoverClose",Pte=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Ro(FM,n);return i.jsx(Te.button,{type:"button",...r,ref:t,onClick:xe(e.onClick,()=>s.onOpenChange(!1))})});Pte.displayName=FM;var Ate="PopoverArrow",Rte=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Xd(n);return i.jsx(p0,{...s,...r,ref:t})});Rte.displayName=Ate;function zM(e){return e?"open":"closed"}var Ote=RM,Mte=DM,Dte=IM,BM=LM;const UM=Ote,VM=Mte,n_=p.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},s)=>i.jsx(Dte,{children:i.jsx(BM,{ref:s,align:t,sideOffset:n,className:Y("z-[130] 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",e),...r})}));n_.displayName=BM.displayName;const Ite=[{key:"ochtend",label:"Ochtend",time:"08:00 - 12:00"},{key:"middag",label:"Middag",time:"13:00 - 17:00"},{key:"hele_dag",label:"Hele dag",time:"08:00 - 17:00"}];function Lte({value:e,onChange:t,onNext:n,onBack:r}){const[s,a]=p.useState(!1);return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Tt,{children:"Voorkeursdatum"}),i.jsxs(UM,{open:s,onOpenChange:a,children:[i.jsx(VM,{asChild:!0,children:i.jsxs(ne,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[i.jsx(Wt,{className:"mr-2 h-4 w-4"}),e.preferredDate?he(new Date(e.preferredDate),"d MMMM yyyy",{locale:tt}):"Kies een voorkeursdatum…"]})}),i.jsx(n_,{className:"w-auto p-0",align:"start",children:i.jsx($c,{mode:"single",selected:e.preferredDate?new Date(e.preferredDate):void 0,onSelect:o=>{t({...e,preferredDate:o?he(o,"yyyy-MM-dd"):null}),a(!1)},disabled:o=>oi.jsxs("button",{type:"button",onClick:()=>t({...e,dayPart:o.key}),className:`rounded-lg border p-3 text-center text-sm transition ${e.dayPart===o.key?"border-primary bg-primary/10 font-medium":"border-border hover:bg-muted/40"}`,children:[i.jsx("span",{className:"block",children:o.label}),i.jsx("span",{className:"block text-xs text-muted-foreground",children:o.time})]},o.key))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Tt,{htmlFor:"pref-note",children:"Opmerking (optioneel)"}),i.jsx(Di,{id:"pref-note",rows:3,value:e.note,onChange:o=>t({...e,note:o.target.value}),placeholder:"Bijv. liefst in de ochtend, of een specifieke wens."})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx(ne,{variant:"outline",onClick:r,children:"Terug"}),i.jsx(ne,{onClick:n,disabled:!e.preferredDate,children:"Verder"})]})]})}function $te({organizationId:e,requestData:t,onBack:n,onComplete:r}){const[s,a]=p.useState(!1),[o,l]=p.useState(!1),c=async()=>{var u,d;if(!((u=t.customerName)!=null&&u.trim())||!((d=t.customerEmail)!=null&&d.trim())){K.error("Naam en e-mailadres zijn verplicht.");return}if(!$b(t.customerEmail.trim())){K.error("Ongeldig e-mailadres.");return}if(t.customerPhone&&!Fb(t.customerPhone)){K.error("Ongeldig telefoonnummer.");return}a(!0);try{await Je({organizationId:e,scope:"booking-request-submit",key:[t.customerEmail.trim().toLowerCase(),t.serviceId??"geen-dienst",t.preferredDate??"geen-datum"].join(":"),ttlSeconds:1800});const f={ochtend:"Ochtend",middag:"Middag",hele_dag:"Hele dag"},h={__service_id:t.serviceId??null,__service_name:t.serviceName??null,__preferred_date:t.preferredDate??null,__day_part:t.dayPart??null,__staff_pref_id:t.staffId??null,...t.serviceName?{dienst:{label:"Dienst",type:"text",value:t.serviceName}}:{},...t.preferredDate?{voorkeursdatum:{label:"Voorkeursdatum",type:"date",value:t.preferredDate}}:{},...t.dayPart?{dagdeel:{label:"Voorkeursdagdeel",type:"text",value:f[t.dayPart]??t.dayPart}}:{},...t.note?{opmerking:{label:"Opmerking",type:"textarea",value:t.note}}:{},...Object.fromEntries((t.intakeAnswers??[]).map(w=>[`intake_${w.fieldId}`,{label:w.label,type:w.type,value:w.value}]))},m=crypto.randomUUID(),{error:v}=await B.from("intake_submissions").insert({id:m,organization_id:e,customer_name:t.customerName,customer_email:t.customerEmail,customer_phone:t.customerPhone??null,fields:h,status:"new",customer_user_id:null});if(v)throw v;try{await B.functions.invoke("send-intake-confirmation",{body:{submissionId:m}})}catch(w){console.warn("ontvangstbevestiging niet verstuurd",w)}l(!0)}catch(f){console.error("request submit error",f),K.error("Kon je aanvraag niet versturen. Probeer het opnieuw.")}finally{a(!1)}};return o?i.jsxs("div",{className:"flex flex-col items-center gap-4 py-10 text-center",children:[i.jsx(yi,{className:"h-12 w-12 text-green-600"}),i.jsx("h3",{className:"text-lg font-semibold",children:"Bedankt voor uw aanvraag"}),i.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"U hoort binnen 24 uur van ons en we proberen rekening te houden met uw voorkeurstijd."}),i.jsx(ne,{onClick:r,children:"Sluiten"})]}):i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"rounded-lg border border-border p-4 text-sm",children:[i.jsx("p",{className:"font-medium",children:"Controleer uw aanvraag"}),i.jsxs("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:[t.serviceName&&i.jsxs("li",{children:["Klus: ",t.serviceName]}),t.preferredDate&&i.jsxs("li",{children:["Voorkeursdatum: ",t.preferredDate]}),t.dayPart&&i.jsxs("li",{children:["Dagdeel: ",t.dayPart]}),(t.intakeAnswers??[]).map(u=>i.jsxs("li",{children:[u.label,": ",u.value]},u.fieldId)),i.jsxs("li",{children:["Naam: ",t.customerName]}),i.jsxs("li",{children:["E-mail: ",t.customerEmail]})]})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx(ne,{variant:"outline",onClick:n,disabled:s,children:"Terug"}),i.jsxs(ne,{onClick:c,disabled:s,children:[s&&i.jsx(yn,{className:"mr-2 h-4 w-4 animate-spin"}),"Aanvraag versturen"]})]})]})}function Fte({orgSlug:e}){var s,a;const{data:t}=xt({queryKey:["booking-contact-strip",e],enabled:!!e,staleTime:3e5,queryFn:async()=>{const{data:o,error:l}=await B.from("public_organizations").select("contact_email, contact_phone").eq("slug",e).maybeSingle();return l?null:o}}),n=(s=t==null?void 0:t.contact_phone)==null?void 0:s.trim(),r=(a=t==null?void 0:t.contact_email)==null?void 0:a.trim();return!n&&!r?null:i.jsxs("div",{className:"mt-5 flex flex-wrap items-center justify-center gap-x-5 gap-y-2 text-[13px] text-muted-foreground",children:[i.jsx("span",{className:"w-full text-center text-[12px]",children:"Liever even overleggen?"}),n&&i.jsxs("a",{href:`tel:${n.replace(/\s/g,"")}`,className:"inline-flex items-center gap-1.5 transition-colors hover:text-foreground",children:[i.jsx(Ai,{className:"h-3.5 w-3.5"}),n]}),r&&i.jsxs("a",{href:`mailto:${r}`,className:"inline-flex items-center gap-1.5 transition-colors hover:text-foreground",children:[i.jsx(uo,{className:"h-3.5 w-3.5"}),r]})]})}var zte=[" ","Enter","ArrowUp","ArrowDown"],Bte=[" ","Enter"],Ei="Select",[zp,Bp,Ute]=Hw(Ei),[Fc]=Ln(Ei,[Ute,Cc]),Up=Cc(),[Vte,Oo]=Fc(Ei),[Wte,Hte]=Fc(Ei),WM=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:s,onOpenChange:a,value:o,defaultValue:l,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:h,required:m,form:v}=e,w=Up(t),[y,x]=p.useState(null),[g,b]=p.useState(null),[_,j]=p.useState(!1),k=Vd(u),[S,E]=vs({prop:r,defaultProp:s??!1,onChange:a,caller:Ei}),[N,O]=vs({prop:o,defaultProp:l,onChange:c,caller:Ei}),z=p.useRef(null),T=y?v||!!y.closest("form"):!0,[I,P]=p.useState(new Set),H=Array.from(I).map(V=>V.props.value).join(";");return i.jsx(h0,{...w,children:i.jsxs(Vte,{required:m,scope:t,trigger:y,onTriggerChange:x,valueNode:g,onValueNodeChange:b,valueNodeHasChildren:_,onValueNodeHasChildrenChange:j,contentId:Vs(),value:N,onValueChange:O,open:S,onOpenChange:E,dir:k,triggerPointerDownPosRef:z,disabled:h,children:[i.jsx(zp.Provider,{scope:t,children:i.jsx(Wte,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(V=>{P(M=>new Set(M).add(V))},[]),onNativeOptionRemove:p.useCallback(V=>{P(M=>{const C=new Set(M);return C.delete(V),C})},[]),children:n})}),T?i.jsxs(pD,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:N,onChange:V=>O(V.target.value),disabled:h,form:v,children:[N===void 0?i.jsx("option",{value:""}):null,Array.from(I)]},H):null]})})};WM.displayName=Ei;var HM="SelectTrigger",qM=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...s}=e,a=Up(n),o=Oo(HM,n),l=o.disabled||r,c=ze(t,o.onTriggerChange),u=Bp(n),d=p.useRef("touch"),[f,h,m]=yD(w=>{const y=u().filter(b=>!b.disabled),x=y.find(b=>b.value===o.value),g=vD(y,w,x);g!==void 0&&o.onValueChange(g.value)}),v=w=>{l||(o.onOpenChange(!0),m()),w&&(o.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return i.jsx(ep,{asChild:!0,...a,children:i.jsx(Te.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":gD(o.value)?"":void 0,...s,ref:c,onClick:xe(s.onClick,w=>{w.currentTarget.focus(),d.current!=="mouse"&&v(w)}),onPointerDown:xe(s.onPointerDown,w=>{d.current=w.pointerType;const y=w.target;y.hasPointerCapture(w.pointerId)&&y.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(v(w),w.preventDefault())}),onKeyDown:xe(s.onKeyDown,w=>{const y=f.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&h(w.key),!(y&&w.key===" ")&&zte.includes(w.key)&&(v(),w.preventDefault())})})})});qM.displayName=HM;var KM="SelectValue",GM=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:s,children:a,placeholder:o="",...l}=e,c=Oo(KM,n),{onValueNodeHasChildrenChange:u}=c,d=a!==void 0,f=ze(t,c.onValueNodeChange);return Zt(()=>{u(d)},[u,d]),i.jsx(Te.span,{...l,ref:f,style:{pointerEvents:"none"},children:gD(c.value)?i.jsx(i.Fragment,{children:o}):a})});GM.displayName=KM;var qte="SelectIcon",YM=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...s}=e;return i.jsx(Te.span,{"aria-hidden":!0,...s,ref:t,children:r||"▼"})});YM.displayName=qte;var Kte="SelectPortal",QM=e=>i.jsx(Sd,{asChild:!0,...e});QM.displayName=Kte;var Ni="SelectContent",XM=p.forwardRef((e,t)=>{const n=Oo(Ni,e.__scopeSelect),[r,s]=p.useState();if(Zt(()=>{s(new DocumentFragment)},[]),!n.open){const a=r;return a?Pi.createPortal(i.jsx(ZM,{scope:e.__scopeSelect,children:i.jsx(zp.Slot,{scope:e.__scopeSelect,children:i.jsx("div",{children:e.children})})}),a):null}return i.jsx(JM,{...e,ref:t})});XM.displayName=Ni;var ss=10,[ZM,Mo]=Fc(Ni),Gte="SelectContentImpl",Yte=gi("SelectContent.RemoveScroll"),JM=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:a,onPointerDownOutside:o,side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:v,hideWhenDetached:w,avoidCollisions:y,...x}=e,g=Oo(Ni,n),[b,_]=p.useState(null),[j,k]=p.useState(null),S=ze(t,L=>_(L)),[E,N]=p.useState(null),[O,z]=p.useState(null),T=Bp(n),[I,P]=p.useState(!1),H=p.useRef(!1);p.useEffect(()=>{if(b)return ab(b)},[b]),sb();const V=p.useCallback(L=>{const[Q,...fe]=T().map(Ee=>Ee.ref.current),[ee]=fe.slice(-1),je=document.activeElement;for(const Ee of L)if(Ee===je||(Ee==null||Ee.scrollIntoView({block:"nearest"}),Ee===Q&&j&&(j.scrollTop=0),Ee===ee&&j&&(j.scrollTop=j.scrollHeight),Ee==null||Ee.focus(),document.activeElement!==je))return},[T,j]),M=p.useCallback(()=>V([E,b]),[V,E,b]);p.useEffect(()=>{I&&M()},[I,M]);const{onOpenChange:C,triggerPointerDownPosRef:F}=g;p.useEffect(()=>{if(b){let L={x:0,y:0};const Q=ee=>{var je,Ee;L={x:Math.abs(Math.round(ee.pageX)-(((je=F.current)==null?void 0:je.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((Ee=F.current)==null?void 0:Ee.y)??0))}},fe=ee=>{L.x<=10&&L.y<=10?ee.preventDefault():b.contains(ee.target)||C(!1),document.removeEventListener("pointermove",Q),F.current=null};return F.current!==null&&(document.addEventListener("pointermove",Q),document.addEventListener("pointerup",fe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Q),document.removeEventListener("pointerup",fe,{capture:!0})}}},[b,C,F]),p.useEffect(()=>{const L=()=>C(!1);return window.addEventListener("blur",L),window.addEventListener("resize",L),()=>{window.removeEventListener("blur",L),window.removeEventListener("resize",L)}},[C]);const[W,ie]=yD(L=>{const Q=T().filter(je=>!je.disabled),fe=Q.find(je=>je.ref.current===document.activeElement),ee=vD(Q,L,fe);ee&&setTimeout(()=>ee.ref.current.focus())}),oe=p.useCallback((L,Q,fe)=>{const ee=!H.current&&!fe;(g.value!==void 0&&g.value===Q||ee)&&(N(L),ee&&(H.current=!0))},[g.value]),ce=p.useCallback(()=>b==null?void 0:b.focus(),[b]),re=p.useCallback((L,Q,fe)=>{const ee=!H.current&&!fe;(g.value!==void 0&&g.value===Q||ee)&&z(L)},[g.value]),ue=r==="popper"?Ux:eD,ke=ue===Ux?{side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:v,hideWhenDetached:w,avoidCollisions:y}:{};return i.jsx(ZM,{scope:n,content:b,viewport:j,onViewportChange:k,itemRefCallback:oe,selectedItem:E,onItemLeave:ce,itemTextRefCallback:re,focusSelectedItem:M,selectedItemText:O,position:r,isPositioned:I,searchRef:W,children:i.jsx(_p,{as:Yte,allowPinchZoom:!0,children:i.jsx(wp,{asChild:!0,trapped:g.open,onMountAutoFocus:L=>{L.preventDefault()},onUnmountAutoFocus:xe(s,L=>{var Q;(Q=g.trigger)==null||Q.focus({preventScroll:!0}),L.preventDefault()}),children:i.jsx(wc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:L=>L.preventDefault(),onDismiss:()=>g.onOpenChange(!1),children:i.jsx(ue,{role:"listbox",id:g.contentId,"data-state":g.open?"open":"closed",dir:g.dir,onContextMenu:L=>L.preventDefault(),...x,...ke,onPlaced:()=>P(!0),ref:S,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:xe(x.onKeyDown,L=>{const Q=L.ctrlKey||L.altKey||L.metaKey;if(L.key==="Tab"&&L.preventDefault(),!Q&&L.key.length===1&&ie(L.key),["ArrowUp","ArrowDown","Home","End"].includes(L.key)){let ee=T().filter(je=>!je.disabled).map(je=>je.ref.current);if(["ArrowUp","End"].includes(L.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(L.key)){const je=L.target,Ee=ee.indexOf(je);ee=ee.slice(Ee+1)}setTimeout(()=>V(ee)),L.preventDefault()}})})})})})})});JM.displayName=Gte;var Qte="SelectItemAlignedPosition",eD=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...s}=e,a=Oo(Ni,n),o=Mo(Ni,n),[l,c]=p.useState(null),[u,d]=p.useState(null),f=ze(t,S=>d(S)),h=Bp(n),m=p.useRef(!1),v=p.useRef(!0),{viewport:w,selectedItem:y,selectedItemText:x,focusSelectedItem:g}=o,b=p.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&u&&w&&y&&x){const S=a.trigger.getBoundingClientRect(),E=u.getBoundingClientRect(),N=a.valueNode.getBoundingClientRect(),O=x.getBoundingClientRect();if(a.dir!=="rtl"){const je=O.left-E.left,Ee=N.left-je,te=S.left-Ee,_e=S.width+te,Me=Math.max(_e,E.width),Ue=window.innerWidth-ss,ct=Nx(Ee,[ss,Math.max(ss,Ue-Me)]);l.style.minWidth=_e+"px",l.style.left=ct+"px"}else{const je=E.right-O.right,Ee=window.innerWidth-N.right-je,te=window.innerWidth-S.right-Ee,_e=S.width+te,Me=Math.max(_e,E.width),Ue=window.innerWidth-ss,ct=Nx(Ee,[ss,Math.max(ss,Ue-Me)]);l.style.minWidth=_e+"px",l.style.right=ct+"px"}const z=h(),T=window.innerHeight-ss*2,I=w.scrollHeight,P=window.getComputedStyle(u),H=parseInt(P.borderTopWidth,10),V=parseInt(P.paddingTop,10),M=parseInt(P.borderBottomWidth,10),C=parseInt(P.paddingBottom,10),F=H+V+I+C+M,W=Math.min(y.offsetHeight*5,F),ie=window.getComputedStyle(w),oe=parseInt(ie.paddingTop,10),ce=parseInt(ie.paddingBottom,10),re=S.top+S.height/2-ss,ue=T-re,ke=y.offsetHeight/2,L=y.offsetTop+ke,Q=H+V+L,fe=F-Q;if(Q<=re){const je=z.length>0&&y===z[z.length-1].ref.current;l.style.bottom="0px";const Ee=u.clientHeight-w.offsetTop-w.offsetHeight,te=Math.max(ue,ke+(je?ce:0)+Ee+M),_e=Q+te;l.style.height=_e+"px"}else{const je=z.length>0&&y===z[0].ref.current;l.style.top="0px";const te=Math.max(re,H+w.offsetTop+(je?oe:0)+ke)+fe;l.style.height=te+"px",w.scrollTop=Q-re+w.offsetTop}l.style.margin=`${ss}px 0`,l.style.minHeight=W+"px",l.style.maxHeight=T+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[h,a.trigger,a.valueNode,l,u,w,y,x,a.dir,r]);Zt(()=>b(),[b]);const[_,j]=p.useState();Zt(()=>{u&&j(window.getComputedStyle(u).zIndex)},[u]);const k=p.useCallback(S=>{S&&v.current===!0&&(b(),g==null||g(),v.current=!1)},[b,g]);return i.jsx(Zte,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:m,onScrollButtonChange:k,children:i.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:_},children:i.jsx(Te.div,{...s,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});eD.displayName=Qte;var Xte="SelectPopperPosition",Ux=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:s=ss,...a}=e,o=Up(n);return i.jsx(m0,{...o,...a,ref:t,align:r,collisionPadding:s,style:{boxSizing:"border-box",...a.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)"}})});Ux.displayName=Xte;var[Zte,r_]=Fc(Ni,{}),Vx="SelectViewport",tD=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...s}=e,a=Mo(Vx,n),o=r_(Vx,n),l=ze(t,a.onViewportChange),c=p.useRef(0);return i.jsxs(i.Fragment,{children:[i.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:r}),i.jsx(zp.Slot,{scope:n,children:i.jsx(Te.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:xe(s.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=o;if(h!=null&&h.current&&f){const m=Math.abs(c.current-d.scrollTop);if(m>0){const v=window.innerHeight-ss*2,w=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),x=Math.max(w,y);if(x0?_:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});tD.displayName=Vx;var nD="SelectGroup",[Jte,ene]=Fc(nD),rD=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=Vs();return i.jsx(Jte,{scope:n,id:s,children:i.jsx(Te.div,{role:"group","aria-labelledby":s,...r,ref:t})})});rD.displayName=nD;var sD="SelectLabel",aD=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=ene(sD,n);return i.jsx(Te.div,{id:s.id,...r,ref:t})});aD.displayName=sD;var Em="SelectItem",[tne,oD]=Fc(Em),iD=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:s=!1,textValue:a,...o}=e,l=Oo(Em,n),c=Mo(Em,n),u=l.value===r,[d,f]=p.useState(a??""),[h,m]=p.useState(!1),v=ze(t,g=>{var b;return(b=c.itemRefCallback)==null?void 0:b.call(c,g,r,s)}),w=Vs(),y=p.useRef("touch"),x=()=>{s||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")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 i.jsx(tne,{scope:n,value:r,disabled:s,textId:w,isSelected:u,onItemTextChange:p.useCallback(g=>{f(b=>b||((g==null?void 0:g.textContent)??"").trim())},[]),children:i.jsx(zp.ItemSlot,{scope:n,value:r,disabled:s,textValue:d,children:i.jsx(Te.div,{role:"option","aria-labelledby":w,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...o,ref:v,onFocus:xe(o.onFocus,()=>m(!0)),onBlur:xe(o.onBlur,()=>m(!1)),onClick:xe(o.onClick,()=>{y.current!=="mouse"&&x()}),onPointerUp:xe(o.onPointerUp,()=>{y.current==="mouse"&&x()}),onPointerDown:xe(o.onPointerDown,g=>{y.current=g.pointerType}),onPointerMove:xe(o.onPointerMove,g=>{var b;y.current=g.pointerType,s?(b=c.onItemLeave)==null||b.call(c):y.current==="mouse"&&g.currentTarget.focus({preventScroll:!0})}),onPointerLeave:xe(o.onPointerLeave,g=>{var b;g.currentTarget===document.activeElement&&((b=c.onItemLeave)==null||b.call(c))}),onKeyDown:xe(o.onKeyDown,g=>{var _;((_=c.searchRef)==null?void 0:_.current)!==""&&g.key===" "||(Bte.includes(g.key)&&x(),g.key===" "&&g.preventDefault())})})})})});iD.displayName=Em;var pu="SelectItemText",lD=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:s,...a}=e,o=Oo(pu,n),l=Mo(pu,n),c=oD(pu,n),u=Hte(pu,n),[d,f]=p.useState(null),h=ze(t,x=>f(x),c.onItemTextChange,x=>{var g;return(g=l.itemTextRefCallback)==null?void 0:g.call(l,x,c.value,c.disabled)}),m=d==null?void 0:d.textContent,v=p.useMemo(()=>i.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:w,onNativeOptionRemove:y}=u;return Zt(()=>(w(v),()=>y(v)),[w,y,v]),i.jsxs(i.Fragment,{children:[i.jsx(Te.span,{id:c.textId,...a,ref:h}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Pi.createPortal(a.children,o.valueNode):null]})});lD.displayName=pu;var cD="SelectItemIndicator",uD=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return oD(cD,n).isSelected?i.jsx(Te.span,{"aria-hidden":!0,...r,ref:t}):null});uD.displayName=cD;var Wx="SelectScrollUpButton",dD=p.forwardRef((e,t)=>{const n=Mo(Wx,e.__scopeSelect),r=r_(Wx,e.__scopeSelect),[s,a]=p.useState(!1),o=ze(t,r.onScrollButtonChange);return Zt(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollTop>0;a(u)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?i.jsx(hD,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});dD.displayName=Wx;var Hx="SelectScrollDownButton",fD=p.forwardRef((e,t)=>{const n=Mo(Hx,e.__scopeSelect),r=r_(Hx,e.__scopeSelect),[s,a]=p.useState(!1),o=ze(t,r.onScrollButtonChange);return Zt(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?i.jsx(hD,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});fD.displayName=Hx;var hD=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...s}=e,a=Mo("SelectScrollButton",n),o=p.useRef(null),l=Bp(n),c=p.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return p.useEffect(()=>()=>c(),[c]),Zt(()=>{var d;const u=l().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[l]),i.jsx(Te.div,{"aria-hidden":!0,...s,ref:t,style:{flexShrink:0,...s.style},onPointerDown:xe(s.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:xe(s.onPointerMove,()=>{var u;(u=a.onItemLeave)==null||u.call(a),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:xe(s.onPointerLeave,()=>{c()})})}),nne="SelectSeparator",mD=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return i.jsx(Te.div,{"aria-hidden":!0,...r,ref:t})});mD.displayName=nne;var qx="SelectArrow",rne=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=Up(n),a=Oo(qx,n),o=Mo(qx,n);return a.open&&o.position==="popper"?i.jsx(p0,{...s,...r,ref:t}):null});rne.displayName=qx;var sne="SelectBubbleInput",pD=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const s=p.useRef(null),a=ze(r,s),o=Pp(t);return p.useEffect(()=>{const l=s.current;if(!l)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(o!==t&&d){const f=new Event("change",{bubbles:!0});d.call(l,t),l.dispatchEvent(f)}},[o,t]),i.jsx(Te.select,{...n,style:{...zC,...n.style},ref:a,defaultValue:t})});pD.displayName=sne;function gD(e){return e===""||e===void 0}function yD(e){const t=on(e),n=p.useRef(""),r=p.useRef(0),s=p.useCallback(o=>{const l=n.current+o;t(l),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(l)},[t]),a=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,s,a]}function vD(e,t,n){const s=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let o=ane(e,Math.max(a,0));s.length===1&&(o=o.filter(u=>u!==n));const c=o.find(u=>u.textValue.toLowerCase().startsWith(s.toLowerCase()));return c!==n?c:void 0}function ane(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var one=WM,xD=qM,ine=GM,lne=YM,cne=QM,wD=XM,une=tD,dne=rD,bD=aD,_D=iD,fne=lD,hne=uD,kD=dD,jD=fD,SD=mD;const mne=one,gae=dne,pne=ine,ED=p.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(xD,{ref:r,className:Y("flex h-10 w-full items-center justify-between rounded-md border border-field-border bg-field px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground transition-[color,background-color,border-color,box-shadow] focus:outline-none focus:ring-2 focus:ring-ring focus:bg-[hsl(var(--field-focus))] focus:shadow-[0_0_0_3px_hsl(var(--field-glow))] ring-inset disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,i.jsx(lne,{asChild:!0,children:i.jsx(Qw,{className:"h-4 w-4 opacity-50"})})]}));ED.displayName=xD.displayName;const ND=p.forwardRef(({className:e,...t},n)=>i.jsx(kD,{ref:n,className:Y("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(hT,{className:"h-4 w-4"})}));ND.displayName=kD.displayName;const CD=p.forwardRef(({className:e,...t},n)=>i.jsx(jD,{ref:n,className:Y("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(Qw,{className:"h-4 w-4"})}));CD.displayName=jD.displayName;const TD=p.forwardRef(({className:e,children:t,position:n="popper",...r},s)=>i.jsx(cne,{children:i.jsxs(wD,{ref:s,className:Y("relative z-[130] 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",n==="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",e),position:n,...r,children:[i.jsx(ND,{}),i.jsx(une,{className:Y("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),i.jsx(CD,{})]})}));TD.displayName=wD.displayName;const gne=p.forwardRef(({className:e,...t},n)=>i.jsx(bD,{ref:n,className:Y("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));gne.displayName=bD.displayName;const PD=p.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(_D,{ref:r,className:Y("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",e),...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(hne,{children:i.jsx(kc,{className:"h-4 w-4"})})}),i.jsx(fne,{children:t})]}));PD.displayName=_D.displayName;const yne=p.forwardRef(({className:e,...t},n)=>i.jsx(SD,{ref:n,className:Y("-mx-1 my-1 h-px bg-muted",e),...t}));yne.displayName=SD.displayName;var s_="Radio",[vne,AD]=Ln(s_),[xne,wne]=vne(s_),RD=p.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:s=!1,required:a,disabled:o,value:l="on",onCheck:c,form:u,...d}=e,[f,h]=p.useState(null),m=ze(t,y=>h(y)),v=p.useRef(!1),w=f?u||!!f.closest("form"):!0;return i.jsxs(xne,{scope:n,checked:s,disabled:o,children:[i.jsx(Te.button,{type:"button",role:"radio","aria-checked":s,"data-state":ID(s),"data-disabled":o?"":void 0,disabled:o,value:l,...d,ref:m,onClick:xe(e.onClick,y=>{s||c==null||c(),w&&(v.current=y.isPropagationStopped(),v.current||y.stopPropagation())})}),w&&i.jsx(DD,{control:f,bubbles:!v.current,name:r,value:l,checked:s,required:a,disabled:o,form:u,style:{transform:"translateX(-100%)"}})]})});RD.displayName=s_;var OD="RadioIndicator",MD=p.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...s}=e,a=wne(OD,n);return i.jsx(Jn,{present:r||a.checked,children:i.jsx(Te.span,{"data-state":ID(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:t})})});MD.displayName=OD;var bne="RadioBubbleInput",DD=p.forwardRef(({__scopeRadio:e,control:t,checked:n,bubbles:r=!0,...s},a)=>{const o=p.useRef(null),l=ze(o,a),c=Pp(n),u=Jm(t);return p.useEffect(()=>{const d=o.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const v=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(v)}},[c,n,r]),i.jsx(Te.input,{type:"radio","aria-hidden":!0,defaultChecked:n,...s,tabIndex:-1,ref:l,style:{...s.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});DD.displayName=bne;function ID(e){return e?"checked":"unchecked"}var _ne=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Vp="RadioGroup",[kne]=Ln(Vp,[Op,AD]),LD=Op(),$D=AD(),[jne,Sne]=kne(Vp),FD=p.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:s,value:a,required:o=!1,disabled:l=!1,orientation:c,dir:u,loop:d=!0,onValueChange:f,...h}=e,m=LD(n),v=Vd(u),[w,y]=vs({prop:a,defaultProp:s??null,onChange:f,caller:Vp});return i.jsx(jne,{scope:n,name:r,required:o,disabled:l,value:w,onValueChange:y,children:i.jsx(AO,{asChild:!0,...m,orientation:c,dir:v,loop:d,children:i.jsx(Te.div,{role:"radiogroup","aria-required":o,"aria-orientation":c,"data-disabled":l?"":void 0,dir:v,...h,ref:t})})})});FD.displayName=Vp;var zD="RadioGroupItem",BD=p.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...s}=e,a=Sne(zD,n),o=a.disabled||r,l=LD(n),c=$D(n),u=p.useRef(null),d=ze(t,u),f=a.value===s.value,h=p.useRef(!1);return p.useEffect(()=>{const m=w=>{_ne.includes(w.key)&&(h.current=!0)},v=()=>h.current=!1;return document.addEventListener("keydown",m),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",m),document.removeEventListener("keyup",v)}},[]),i.jsx(RO,{asChild:!0,...l,focusable:!o,active:f,children:i.jsx(RD,{disabled:o,required:a.required,checked:f,...c,...s,name:a.name,ref:d,onCheck:()=>a.onValueChange(s.value),onKeyDown:xe(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:xe(s.onFocus,()=>{var m;h.current&&((m=u.current)==null||m.click())})})})});BD.displayName=zD;var Ene="RadioGroupIndicator",UD=p.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,s=$D(n);return i.jsx(MD,{...s,...r,ref:t})});UD.displayName=Ene;var VD=FD,WD=BD,Nne=UD;const HD=p.forwardRef(({className:e,...t},n)=>i.jsx(VD,{className:Y("grid gap-2",e),...t,ref:n}));HD.displayName=VD.displayName;const qD=p.forwardRef(({className:e,...t},n)=>i.jsx(WD,{ref:n,className:Y("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-0 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:i.jsx(Nne,{className:"flex items-center justify-center",children:i.jsx(Zw,{className:"h-2.5 w-2.5 fill-current text-current"})})}));qD.displayName=WD.displayName;const Cne=new Set(["text","textarea","email","phone","number","date","select","radio","checkbox","boolean","section","file_image","file_document"]),KD=new Set(["checkbox","file_image","file_document"]),Tne=new Set(["select","radio","checkbox"]),a_=new Set(["section"]),yae=new Set(["file_image","file_document"]);function bh(e){if(!Array.isArray(e))return null;const t=[];for(const n of e)if(n&&typeof n=="object"&&"value"in n){const r=n;t.push({value:String(r.value),label:String(r.label??r.value)})}return t.length>0?t:null}function HS(e,t){return e.filter(n=>Cne.has(n.field_type)).filter(n=>n.service_id===null||n.service_id===t).sort((n,r)=>n.sort_order-r.sort_order)}function Pne(e){if(e&&typeof e=="object"&&"extensions"in e){const t=e.extensions;if(Array.isArray(t))return t.map(n=>String(n).toLowerCase())}return[]}function Ane(e){var n;switch((n=e.split(".").pop())==null?void 0:n.toLowerCase()){case"eps":case"ai":return"application/postscript";case"tiff":case"tif":return"image/tiff";case"pdf":return"application/pdf";default:return}}function Nm(e){return Array.isArray(e)?e.map(String):typeof e=="string"&&e?[e]:[]}function Rne(e,t){const n=t[e.id];return KD.has(e.field_type)?Nm(n).length>0:(typeof n=="string"?n:"").trim()!==""}function One(e,t){return e.find(n=>n.is_required&&!a_.has(n.field_type)&&!Rne(n,t))??null}function Mne(e,t){return e.filter(n=>!a_.has(n.field_type)).map(n=>{const r=bh(n.options),s=o=>{var l;return Tne.has(n.field_type)?((l=r==null?void 0:r.find(c=>c.value===o))==null?void 0:l.label)??o:o};if(KD.has(n.field_type)){const o=Nm(t[n.id]).map(s);return{fieldId:n.id,label:n.label,type:n.field_type,value:o}}const a=(typeof t[n.id]=="string"?t[n.id]:"").trim();return{fieldId:n.id,label:n.label,type:n.field_type,value:s(a)}}).filter(n=>Array.isArray(n.value)?n.value.length>0:n.value!=="")}function Dne({fields:e,value:t,onChange:n,onNext:r,onBack:s,organizationId:a}){const[o,l]=p.useState(null),[c]=p.useState(()=>crypto.randomUUID()),[u,d]=p.useState(null),f=async(y,x)=>{var k;if(!x||!a)return;const g=Pne(y.options),_=[...Array.isArray(t[y.id])?t[y.id]:[]],j=y.max_files??5;d(y.id);try{for(const S of Array.from(x).slice(0,j)){const E=((k=S.name.split(".").pop())==null?void 0:k.toLowerCase())??"";if(g.length>0&&!g.includes(E)){K.error(`"${S.name}": extensie niet toegestaan.`);continue}const N=Ad(S,"intakeUpload");if(N.valid===!1){K.error(`"${S.name}": ${N.error}`);continue}try{await pb(`intake-upload:${y.id}:${S.name}`,async()=>{const O=`${a}/intake/${c}/${Date.now()}-${S.name}`,{error:z}=await B.storage.from("intake-uploads").upload(O,S,{contentType:Ane(S.name),upsert:!1});if(z)throw z;const{data:T}=B.storage.from("intake-uploads").getPublicUrl(O);_.push(T.publicUrl)})}catch{K.error(`"${S.name}": uploaden mislukt.`)}}n({...t,[y.id]:_})}finally{d(null)}},h=(y,x)=>n({...t,[y]:x}),m=(y,x)=>{const g=Nm(t[y]),b=g.includes(x)?g.filter(_=>_!==x):[...g,x];n({...t,[y]:b})},v=y=>{var g;const x=t[y.id]??"";switch(y.field_type){case"textarea":return i.jsx(Di,{rows:3,value:x,placeholder:y.placeholder??"",onChange:b=>h(y.id,b.target.value)});case"number":return i.jsx(ot,{type:"number",value:x,placeholder:y.placeholder??"",onChange:b=>h(y.id,b.target.value)});case"email":return i.jsx(ot,{type:"email",value:x,placeholder:y.placeholder??"",onChange:b=>h(y.id,b.target.value)});case"phone":return i.jsx(ot,{type:"tel",value:x,placeholder:y.placeholder??"",onChange:b=>h(y.id,b.target.value)});case"select":return i.jsxs(mne,{value:x,onValueChange:b=>h(y.id,b),children:[i.jsx(ED,{children:i.jsx(pne,{placeholder:"Selecteer…"})}),i.jsx(TD,{children:(bh(y.options)??[]).map(b=>i.jsx(PD,{value:b.value,children:b.label},b.value))})]});case"date":return i.jsxs(UM,{open:o===y.id,onOpenChange:b=>l(b?y.id:null),children:[i.jsx(VM,{asChild:!0,children:i.jsx(ne,{variant:"outline",className:"w-full justify-start text-left font-normal",children:x?he(new Date(x),"d MMMM yyyy",{locale:tt}):"Kies een datum…"})}),i.jsx(n_,{className:"w-auto p-0",align:"start",children:i.jsx($c,{mode:"single",locale:tt,selected:x?new Date(x):void 0,onSelect:b=>{h(y.id,b?he(b,"yyyy-MM-dd"):""),l(null)}})})]});case"radio":return i.jsx(HD,{value:x,onValueChange:b=>h(y.id,b),className:"space-y-2",children:(bh(y.options)??[]).map(b=>i.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5",children:[i.jsx(qD,{value:b.value,id:`${y.id}-${b.value}`}),i.jsx("span",{className:"text-sm",children:b.label})]},b.value))});case"checkbox":{const b=Nm(t[y.id]);return i.jsx("div",{className:"space-y-2",children:(bh(y.options)??[]).map(_=>i.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5",children:[i.jsx(ji,{checked:b.includes(_.value),onCheckedChange:()=>m(y.id,_.value)}),i.jsx("span",{className:"text-sm",children:_.label})]},_.value))})}case"boolean":return i.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5",children:[i.jsx(ji,{checked:x==="ja",onCheckedChange:b=>h(y.id,b===!0?"ja":"")}),i.jsx("span",{className:"text-sm",children:((g=y.placeholder)==null?void 0:g.trim())||"Ja"})]});case"section":return null;case"file_image":case"file_document":{const b=Array.isArray(t[y.id])?t[y.id]:[];return i.jsxs("div",{className:"space-y-2",children:[i.jsx("input",{type:"file",multiple:!0,onChange:_=>f(y,_.target.files),disabled:u===y.id,className:"text-sm"}),u===y.id&&i.jsx("p",{className:"text-xs text-muted-foreground",children:"Uploaden…"}),b.length>0&&i.jsx("ul",{className:"text-xs text-muted-foreground space-y-0.5",children:b.map(_=>i.jsxs("li",{className:"truncate",children:["✓ ",_.split("/").pop()]},_))})]})}default:return i.jsx(ot,{value:x,placeholder:y.placeholder??"",onChange:b=>h(y.id,b.target.value)})}},w=()=>{const y=One(e,t);if(y){K.error(`"${y.label}" is verplicht.`);return}r(Mne(e,t))};return i.jsxs("div",{className:"space-y-5",children:[e.map(y=>a_.has(y.field_type)?i.jsxs("div",{className:"space-y-1 border-t pt-5 first:border-t-0 first:pt-0",children:[i.jsx("h3",{className:"text-sm font-semibold",children:y.label}),y.help_text&&i.jsx("p",{className:"text-sm text-muted-foreground",children:y.help_text})]},y.id):i.jsxs("div",{className:"space-y-2",children:[i.jsxs(Tt,{children:[y.label,y.is_required&&i.jsx("span",{className:"text-destructive",children:" *"})]}),v(y),y.help_text&&i.jsx("p",{className:"text-xs text-muted-foreground",children:y.help_text})]},y.id)),i.jsxs("div",{className:"flex justify-between",children:[i.jsx(ne,{variant:"outline",onClick:s,children:"Terug"}),i.jsx(ne,{onClick:w,children:"Verder"})]})]})}function Ine(e){return xt({queryKey:["intake-fields",e],enabled:!!e,queryFn:async()=>{if(!e)return[];const{data:t,error:n}=await B.from("public_intake_form_fields").select("id, service_id, label, field_type, placeholder, help_text, is_required, sort_order, options, max_files").eq("organization_id",e).order("sort_order",{ascending:!0}).limit(200);if(n)throw n;return(t??[]).map(r=>({id:String(r.id),service_id:r.service_id?String(r.service_id):null,label:String(r.label),field_type:String(r.field_type),placeholder:r.placeholder?String(r.placeholder):null,help_text:r.help_text?String(r.help_text):null,is_required:r.is_required===!0,sort_order:typeof r.sort_order=="number"?r.sort_order:0,options:r.options??null,max_files:typeof r.max_files=="number"?r.max_files:null}))}})}const Lne=new Set(["ochtend","middag","hele_dag"]),$ne=new Set(["file_image","file_document"]),qS="intake_",Fne=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function GD(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function KS(e,t){const n=e[t];return typeof n=="string"&&Fne.test(n)?n:null}function GS(e){const t=GD(e).value;if(typeof t=="string")return t.trim()||null;if(typeof t=="number")return String(t);if(Array.isArray(t)){const n=t.filter(r=>typeof r=="string");return n.length>0?n.join(", "):null}return null}function zne(e,t){const n=GD(e),r=new Map(t.map(u=>[u.id,u])),s={};let a=0,o=0;for(const[u,d]of Object.entries(n)){if(!u.startsWith(qS))continue;const f=u.slice(qS.length),h=r.get(f);if(!h){o++;continue}if($ne.has(h.field_type)){a++;continue}const m=GS(d);m!==null&&(s[f]=m)}const l=n.__day_part,c=GS(n.opmerking);return{serviceId:KS(n,"__service_id"),staffId:KS(n,"__staff_pref_id"),dayPart:typeof l=="string"&&Lne.has(l)?l:null,note:c??"",intakeValues:s,skipped:{files:a,unknownFields:o}}}function Bne(e){const t=[];return e.files>0&&t.push(e.files===1?"het eerder geüploade bestand":`de ${e.files} eerder geüploade bestanden`),e.unknownFields>0&&t.push(e.unknownFields===1?"één vraag die inmiddels vervallen is":`${e.unknownFields} vragen die inmiddels vervallen zijn`),t.length===0?"":`Niet overgenomen: ${t.join(" en ")}. Controleer je gegevens en kies een nieuwe datum.`}function Une(e,t,n){return e?[t.service?"service":null,n?"intake":null,t.staff?"staff":null,t.preferred_time?"datetime":null,"details","confirmation"].filter(Boolean):["service","staff","datetime","details","confirmation"]}const o_=e=>`nexus.portal.${e}`;function Vne(e){try{const t=sessionStorage.getItem(o_(e));if(!t)return null;const n=JSON.parse(t);return n.token?n:null}catch{return null}}function vae(e,t){sessionStorage.setItem(o_(e),JSON.stringify(t))}function Ry(e){sessionStorage.removeItem(o_(e))}function Wne(e){const t=e?Vne(e):null,n=xt({queryKey:["portal-session",e,t==null?void 0:t.token],enabled:!!e&&!!(t!=null&&t.token),retry:(r,s)=>(s==null?void 0:s.code)==="P0001"?!1:r<2,queryFn:async()=>{const{data:r,error:s}=await B.rpc("portal_session_info",{_session_token:t.token});if(s){if(s.code==="P0001")return e&&Ry(e),null;throw s}const a=Array.isArray(r)?r[0]??null:r;if(!a)return e&&Ry(e),null;if(e&&String(a.org_slug)!==e)return Ry(e),null;const o=a.customer_phone?String(a.customer_phone):t.phone;return{token:t.token,name:String(a.customer_name??t.name),email:String(a.customer_email??t.email),phone:o||void 0,orgSlug:String(a.org_slug??e)}}});return{session:n.data??null,isValid:!!n.data,isLoading:n.isLoading&&!!(t!=null&&t.token),hasStored:!!(t!=null&&t.token)}}const Hne="0 0% 100%",qne="28 14% 13%",Kne="#26211D",Gne=62,Yne=new Set(["000000","ffffff"]);function i_(e){if(!e)return null;const t=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return null;const n=t[1].toLowerCase();return n.length===3?n.split("").map(r=>r+r).join(""):n}function YD(e){return{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16)}}function Qne({r:e,g:t,b:n}){const r=e/255,s=t/255,a=n/255,o=Math.max(r,s,a),l=Math.min(r,s,a),c=(o+l)/2,u=o-l;let d=0,f=0;return u!==0&&(f=c>.5?u/(2-o-l):u/(o+l),o===r?d=(s-a)/u%6:o===s?d=(a-r)/u+2:d=(r-s)/u+4,d*=60,d<0&&(d+=360)),{h:d,s:f,l:c}}function Xne({h:e,s:t,l:n}){const r=(1-Math.abs(2*n-1))*t,s=r*(1-Math.abs(e/60%2-1)),a=n-r/2;let o=0,l=0,c=0;return e<60?(o=r,l=s):e<120?(o=s,l=r):e<180?(l=r,c=s):e<240?(l=s,c=r):e<300?(o=s,c=r):(o=r,c=s),{r:Math.round((o+a)*255),g:Math.round((l+a)*255),b:Math.round((c+a)*255)}}function QD({r:e,g:t,b:n}){const r=s=>{const a=s/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function YS(e,t){const n=Math.max(e,t),r=Math.min(e,t);return(n+.05)/(r+.05)}const Zne=QD(YD(i_(Kne))),Jne=1;function ere(e){const t=QD(e),n=YS(t,Jne),r=YS(t,Zne);return n>=r?Hne:qne}function QS(e){const t=i_(e);return!t||Yne.has(t)?null:e.trim()}function tre(e){const t=Qne(YD(e));return{...t,l:Math.min(t.l,Gne/100)}}function nre(e){const t={},n=QS(e==null?void 0:e.primary_color),r=QS(e==null?void 0:e.secondary_color);n&&(t["--org-primary"]=n),r&&(t["--org-secondary"]=r);const s=i_(r??n);if(s){const a=tre(s),o=`${Math.round(a.h)} ${Math.round(a.s*100)}% ${Math.round(a.l*100)}%`,l=ere(Xne(a));t["--cta"]=o,t["--cta-foreground"]=l,t["--primary"]=o,t["--primary-foreground"]=l,t["--ring"]=o}return t}function rre(e){return e?e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(t=>t[0].toUpperCase()).join(""):""}function sre(e){const t=(e==null?void 0:e.primary_color)??null,n=(e==null?void 0:e.secondary_color)??null,r=p.useMemo(()=>nre({primary_color:t,secondary_color:n}),[t,n]);return p.useEffect(()=>{const s=Object.entries(r);if(s.length===0)return;const a=document.documentElement,o=s.map(([l])=>[l,a.style.getPropertyValue(l)]);for(const[l,c]of s)a.style.setProperty(l,c);return()=>{for(const[l,c]of o)c?a.style.setProperty(l,c):a.style.removeProperty(l)}},[r]),r}const are=(e,t)=>{const n=lc(e,"service"),r=lc(e,"staffMember").toLowerCase(),s=t?"aanvraag":"afspraak";return{service:`Kies een ${n}`,intake:"Aanvraaggegevens",staff:`Kies een ${r}`,datetime:"Datum & tijd",details:"Jouw gegevens",confirmation:`Bevestig je ${s}`}};function ore({steps:e,currentStep:t}){const n=e.indexOf(t);return i.jsx("div",{className:"flex items-center justify-center gap-1.5 py-3",children:e.map((r,s)=>i.jsx("div",{className:Y("h-1.5 rounded-full transition-all duration-300",s===n?"w-5 bg-cta":s{var de,G;const e=Xs(),{isAdmin:t}=Rd(),{branding:n,loading:r,error:s,orgSlug:a}=GO(),o=Wne(a),[l]=HP(),c=l.get("embed")==="true",u=l.get("chrome")==="1",d=u?"*":window.location.origin,f=l.get("service"),h=l.get("staff"),m=l.get("copy"),v=l.toString(),w=sre(n),[y,x]=p.useState(null),[g,b]=p.useState(null),[_,j]=p.useState("service"),[k,S]=p.useState({}),[E,N]=p.useState(!1),[O,z]=p.useState(null),T=(n==null?void 0:n.booking_mode)==="quote",{data:I=[],isFetched:P}=Ine(T?n==null?void 0:n.id:void 0),H=T?HS(I,k.serviceId):[],[V,M]=p.useState({}),[C,F]=p.useState([]),[W,ie]=p.useState({preferredDate:null,dayPart:"hele_dag",note:""}),[oe,ce]=p.useState(null),[re,ue]=p.useState(!m),ke=f??(oe==null?void 0:oe.serviceId)??null;p.useEffect(()=>{var Be;if(re||r||T&&!P||o.isLoading)return;const U=(Be=o.session)==null?void 0:Be.token;if(!U){ue(!0);return}let Z=!1;return(async()=>{const{data:at,error:vn}=await B.rpc("portal_request_for_copy",{_session_token:U,_submission_id:m});if(Z)return;const Jt=Array.isArray(at)?at[0]??null:at;if(vn||!Jt){K.error("Deze aanvraag kon niet worden overgenomen. Vul hem opnieuw in."),ue(!0);return}const $n=zne(Jt.fields,I);M($n.intakeValues),ie(jn=>({preferredDate:null,dayPart:$n.dayPart??jn.dayPart,note:$n.note})),$n.staffId&&S(jn=>({...jn,staffId:$n.staffId})),ce($n),ue(!0);const er=Bne($n.skipped);er&&K.info(er)})(),()=>{Z=!0}},[re,m,r,T,P,I,o.isLoading,(de=o.session)==null?void 0:de.token]),p.useEffect(()=>{if(!ke||E||!re||r||T&&!P)return;let U=!1;return(async()=>{const{data:pe,error:Be}=await B.from("services").select("id, duration_minutes, buffer_minutes, category").eq("id",ke).maybeSingle();if(U)return;if(Be||!pe){K.error("De geselecteerde dienst is niet (meer) beschikbaar. Kies opnieuw."),N(!0);return}S(Jt=>({...Jt,serviceId:pe.id,serviceDuration:pe.duration_minutes,serviceBuffer:pe.buffer_minutes,...h?{staffId:h}:{}}));const at=ee(pe.id),vn=new Set(["service"]);h&&vn.add("staff"),j(at.find(Jt=>!vn.has(Jt))??at[0]),N(!0)})(),()=>{U=!0}},[ke,h,E,r,T,P,re]),p.useEffect(()=>{(async()=>{if(n!=null&&n.id){const{data:Z}=await B.from("organizations").select("branche").eq("id",n.id).single();Z!=null&&Z.branche&&z(Z.branche)}})()},[n==null?void 0:n.id]),p.useEffect(()=>{const{data:{subscription:U}}=B.auth.onAuthStateChange((Z,pe)=>{b(pe),x((pe==null?void 0:pe.user)??null)});return B.auth.getSession().then(({data:{session:Z}})=>{b(Z),x((Z==null?void 0:Z.user)??null)}),()=>U.unsubscribe()},[]),p.useEffect(()=>{a&&n!=null&&n.portal_login_required&&!o.isLoading&&!o.isValid&&e(`/${a}/portal/login${v?`?${v}`:""}`,{replace:!0})},[n==null?void 0:n.portal_login_required,o.isLoading,o.isValid,a,v,e]),p.useEffect(()=>{o.session&&L({customerName:o.session.name,customerEmail:o.session.email,...o.session.phone?{customerPhone:o.session.phone}:{}})},[(G=o.session)==null?void 0:G.token]),p.useEffect(()=>{const U=ee();U.includes(_)||j(U[0])},[n==null?void 0:n.booking_mode,_]);const L=U=>{S(Z=>({...Z,...U}))},Q=O==="kappers_beauty"||O==="monteurs"?O:"algemeen",fe=Q==="kappers_beauty",ee=U=>{const Z=U??k.serviceId,pe=T?HS(I,Z):[];return Une(T,KO(n==null?void 0:n.booking_widget_steps),pe.length>0)},je=(U,Z)=>{if(U!=="staff")return!1;const pe=Z??k.serviceId;return!!(h&&k.staffId===h&&pe===ke)},Ee=(U,Z)=>{let pe=Z-1;for(;pe>=0&&je(U[pe]);)pe--;return pe},te=U=>{const Z=ee(U);let pe=Z.indexOf(_)+1;for(;pe{const U=ee(),Z=Ee(U,U.indexOf(_));Z>=0&&j(U[Z])},Me=async()=>{await lp(),K.success("Uitgelogd"),e("/")},Ue=typeof window<"u"&&window.parent!==window,ct=()=>{try{window.parent.postMessage({type:"BOOKING_CANCEL",orgSlug:a},d)}catch(U){console.warn("postMessage failed",U)}};if(r&&a)return i.jsx("div",{className:"min-h-screen bg-surface-cream",children:i.jsx("div",{className:"container mx-auto px-4 py-6 sm:py-10",children:i.jsxs("div",{className:"max-w-[500px] mx-auto",children:[i.jsx(Dt,{className:"h-10 w-24 mx-auto mb-5 rounded-lg"}),i.jsxs("div",{className:"bg-white rounded-2xl border border-[hsl(40,15%,88%)] p-6 space-y-4",children:[i.jsx(Dt,{className:"h-5 w-40 mx-auto"}),i.jsx(Dt,{className:"h-1.5 w-20 mx-auto rounded-full"}),i.jsx(Dt,{className:"h-64 w-full rounded-xl"})]})]})})});if(s&&a)return i.jsx("div",{className:"min-h-screen bg-surface-cream",children:i.jsx("div",{className:"container mx-auto px-4 py-6 sm:py-10",children:i.jsx("div",{className:"max-w-[500px] mx-auto",children:i.jsxs("div",{className:"bg-white rounded-2xl border border-[hsl(40,15%,88%)] p-8 text-center space-y-4",children:[i.jsx(Xw,{className:"h-12 w-12 text-destructive mx-auto"}),i.jsx("h1",{className:"text-xl font-semibold text-foreground",children:"Organisatie niet gevonden"}),i.jsxs("p",{className:"text-sm text-muted-foreground",children:['De organisatie "',a,'" bestaat niet of is niet actief.']}),i.jsx(ne,{onClick:()=>e("/"),variant:"outline",className:"rounded-full",children:"Naar homepage"})]})})})});const Rt=ee(),Et=are(Q,T)[_],A=Ee(Rt,Rt.indexOf(_))>=0,$=rre(n==null?void 0:n.name),q=!c&&!a;return i.jsxs("div",{className:Y("min-h-screen bg-surface-cream",q&&"pb-20 md:pb-0"),style:w,children:[i.jsx("div",{className:Y(c?"px-3 py-4":"container mx-auto px-4 py-6 sm:py-10"),children:i.jsxs("div",{className:Y(c?"mx-auto":"max-w-[500px] mx-auto"),children:[!c&&(n==null?void 0:n.logo_url)&&i.jsx("div",{className:"flex justify-center mb-5",children:i.jsx("img",{src:n.logo_url,alt:n.name,className:"h-10 w-auto object-contain"})}),c&&u&&i.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n!=null&&n.logo_url?i.jsx("img",{src:n.logo_url,alt:n.name,className:"h-7 w-auto max-w-[120px] object-contain"}):$&&i.jsx("span",{"aria-hidden":"true",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-cta text-[11px] font-semibold text-cta-foreground",children:$}),(n==null?void 0:n.name)&&i.jsx("span",{className:"truncate text-sm font-semibold text-foreground",children:n.name})]}),Ue&&i.jsx("button",{type:"button",onClick:ct,"aria-label":"Sluiten",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-white hover:text-foreground",children:i.jsx(Sa,{className:"h-4 w-4"})})]}),i.jsxs("div",{className:"bg-white rounded-2xl border border-[hsl(40,15%,88%)] shadow-[0_18px_40px_-20px_rgba(7,7,7,0.12),0_4px_14px_-8px_rgba(7,7,7,0.05)] overflow-hidden",children:[i.jsxs("div",{className:"px-5 pt-5 pb-0",children:[i.jsxs("div",{className:"flex items-center justify-between min-h-[28px]",children:[i.jsxs("button",{onClick:A?_e:void 0,disabled:!A,className:Y("flex items-center gap-1 text-sm font-medium transition-colors",A?"text-cta cursor-pointer hover:text-cta/80":"text-transparent pointer-events-none"),children:[i.jsx(fT,{className:"h-4 w-4"}),"Terug"]}),i.jsx("span",{className:"text-sm font-semibold text-foreground",children:Et}),i.jsx("div",{className:"w-16"})]}),i.jsx(ore,{steps:Rt,currentStep:_})]}),i.jsxs("div",{className:"px-5 pb-5",children:[_==="service"&&i.jsx(DZ,{organizationId:n==null?void 0:n.id,branche:Q,onNext:U=>{L(U),te(U.serviceId)}}),_==="intake"&&T&&i.jsx(Dne,{fields:H,organizationId:n==null?void 0:n.id,value:V,onChange:M,onNext:U=>{F(U),te()},onBack:_e}),_==="staff"&&i.jsx(LZ,{serviceId:k.serviceId,organizationId:n==null?void 0:n.id,onNext:U=>{L({staffId:U}),te()},onBack:_e}),_==="datetime"&&!T&&fe&&i.jsx(wte,{staffId:k.staffId,serviceId:k.serviceId,serviceDuration:k.serviceDuration,serviceBuffer:k.serviceBuffer,customerName:k.customerName||"",customerEmail:k.customerEmail||"",customerPhone:k.customerPhone,organizationId:n==null?void 0:n.id,onNext:(U,Z)=>{L({startDate:U.toISOString().split("T")[0],appointmentTime:Z}),te()},onBack:_e}),_==="datetime"&&!T&&!fe&&i.jsx(bee,{staffId:k.staffId,serviceId:k.serviceId,onNext:U=>{L(U),te()},onBack:_e}),_==="datetime"&&T&&i.jsx(Lte,{value:W,onChange:ie,onNext:te,onBack:_e}),_==="details"&&i.jsx(bte,{userId:y==null?void 0:y.id,branche:Q,initial:{name:k.customerName,email:k.customerEmail,phone:k.customerPhone},onNext:U=>{L(U),te()},onBack:_e}),_==="confirmation"&&!T&&i.jsx(_te,{userId:y==null?void 0:y.id,bookingData:k,organizationId:n==null?void 0:n.id,onBack:_e,onConfirm:()=>{if(c)try{window.parent.postMessage({type:"BOOKING_COMPLETE",orgSlug:a},d)}catch(U){console.warn("postMessage failed",U)}S({}),j("service"),window.scrollTo(0,0)}}),_==="confirmation"&&T&&i.jsx($te,{organizationId:n.id,requestData:{serviceId:k.serviceId,staffId:k.staffId,preferredDate:W.preferredDate,dayPart:W.dayPart,note:W.note,customerName:k.customerName,customerEmail:k.customerEmail,customerPhone:k.customerPhone,intakeAnswers:C},onBack:_e,onComplete:()=>{if(c)try{window.parent.postMessage({type:"BOOKING_COMPLETE",orgSlug:a},d)}catch(U){console.warn("postMessage failed",U)}S({}),ie({preferredDate:null,dayPart:"hele_dag",note:""}),M({}),F([]),j("service"),window.scrollTo(0,0)}})]})]}),!c&&i.jsx(Fte,{orgSlug:a})]})}),q&&i.jsx(pp,{user:y,isAdmin:t,onLogout:Me})]})};var Wp="Switch",[ire]=Ln(Wp),[lre,cre]=ire(Wp),XD=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:s,defaultChecked:a,required:o,disabled:l,value:c="on",onCheckedChange:u,form:d,...f}=e,[h,m]=p.useState(null),v=ze(t,b=>m(b)),w=p.useRef(!1),y=h?d||!!h.closest("form"):!0,[x,g]=vs({prop:s,defaultProp:a??!1,onChange:u,caller:Wp});return i.jsxs(lre,{scope:n,checked:x,disabled:l,children:[i.jsx(Te.button,{type:"button",role:"switch","aria-checked":x,"aria-required":o,"data-state":tI(x),"data-disabled":l?"":void 0,disabled:l,value:c,...f,ref:v,onClick:xe(e.onClick,b=>{g(_=>!_),y&&(w.current=b.isPropagationStopped(),w.current||b.stopPropagation())})}),y&&i.jsx(eI,{control:h,bubbles:!w.current,name:r,value:c,checked:x,required:o,disabled:l,form:d,style:{transform:"translateX(-100%)"}})]})});XD.displayName=Wp;var ZD="SwitchThumb",JD=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,s=cre(ZD,n);return i.jsx(Te.span,{"data-state":tI(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:t})});JD.displayName=ZD;var ure="SwitchBubbleInput",eI=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...s},a)=>{const o=p.useRef(null),l=ze(o,a),c=Pp(n),u=Jm(t);return p.useEffect(()=>{const d=o.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const v=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(v)}},[c,n,r]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...s,tabIndex:-1,ref:l,style:{...s.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});eI.displayName=ure;function tI(e){return e?"checked":"unchecked"}var nI=XD,dre=JD;const Kx=p.forwardRef(({className:e,...t},n)=>i.jsx(nI,{className:Y("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-0 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",e),...t,ref:n,children:i.jsx(dre,{className:Y("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")})}));Kx.displayName=nI.displayName;const fre=bc("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",warning:"border-warning/50 bg-warning/10 text-warning-foreground [&>svg]:text-warning",info:"border-accent/50 bg-accent/10 text-accent-foreground [&>svg]:text-accent"}},defaultVariants:{variant:"default"}}),rI=p.forwardRef(({className:e,variant:t,...n},r)=>i.jsx("div",{ref:r,role:"alert",className:Y(fre({variant:t}),e),...n}));rI.displayName="Alert";const hre=p.forwardRef(({className:e,...t},n)=>i.jsx("h5",{ref:n,className:Y("mb-1 font-medium leading-none tracking-tight",e),...t}));hre.displayName="AlertTitle";const sI=p.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:Y("text-sm [&_p]:leading-relaxed",e),...t}));sI.displayName="AlertDescription";const mre=NM({full_name:Cs().min(2,"Naam moet minimaal 2 karakters zijn").max(100,"Naam mag maximaal 100 karakters zijn"),email:Cs().email("Ongeldig e-mailadres").max(255,"E-mail mag maximaal 255 karakters zijn"),phone:Cs().regex(/^(\+31|0)[0-9]{9}$/,"Ongeldig Nederlands telefoonnummer (gebruik +31 of 0)").optional().or(Qf("")),birth_date:Cs().optional(),street_address:Cs().max(200,"Adres mag maximaal 200 karakters zijn").optional().or(Qf("")),postal_code:Cs().regex(/^[1-9][0-9]{3}\s?[A-Z]{2}$/i,"Ongeldige postcode (bijv. 1234AB)").optional().or(Qf("")),city:Cs().max(100,"Plaatsnaam mag maximaal 100 karakters zijn").optional().or(Qf("")),newsletter_enabled:Sm(),waitlist_notifications_enabled:Sm()});function pre(){const e=Xs(),{isAdmin:t}=Rd(),{isImpersonating:n,impersonatedUser:r,getEffectiveUserId:s}=mp(),[a,o]=p.useState(!0),[l,c]=p.useState(!1),[u,d]=p.useState(null),[f,h]=p.useState(null),m=bM({resolver:kM(mre),defaultValues:{full_name:"",email:"",phone:"",birth_date:"",street_address:"",postal_code:"",city:"",newsletter_enabled:!1,waitlist_notifications_enabled:!0}});p.useEffect(()=>{v()},[n,r]);const v=async()=>{try{const{data:{user:x}}=await B.auth.getUser();if(!x){e("/auth");return}h(x);const g=s();if(!g){e("/auth");return}d(g);const{data:b,error:_}=await B.from("profiles").select("*").eq("id",g).single();if(_)throw _;b&&m.reset({full_name:b.full_name||"",email:b.email||"",phone:b.phone||"",birth_date:b.birth_date||"",street_address:b.street_address||"",postal_code:b.postal_code||"",city:b.city||"",newsletter_enabled:b.newsletter_enabled||!1,waitlist_notifications_enabled:b.waitlist_notifications_enabled??!0})}catch(x){console.error("Error fetching profile:",x),K.error("Kon profiel niet laden")}finally{o(!1)}},w=async x=>{if(u){if(n){K.error("Je kunt het profiel niet wijzigen tijdens impersonatie");return}try{c(!0);const{error:g}=await B.from("profiles").update({full_name:x.full_name,phone:x.phone||null,birth_date:x.birth_date||null,street_address:x.street_address||null,postal_code:x.postal_code||null,city:x.city||null,newsletter_enabled:x.newsletter_enabled,waitlist_notifications_enabled:x.waitlist_notifications_enabled,updated_at:new Date().toISOString()}).eq("id",u);if(g)throw g;K.success("Profiel succesvol bijgewerkt!")}catch(g){console.error("Error updating profile:",g),K.error("Kon profiel niet bijwerken")}finally{c(!1)}}},y=async()=>{const x=await lp();if(!x.ok){K.error("Uitloggen ging niet vlekkeloos",{description:`Je bent op dit apparaat uitgelogd. Reden: ${x.reason}`}),B0();return}K.success("Uitgelogd"),e("/auth",{replace:!0})};return a?i.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:i.jsxs("div",{className:"text-center",children:[i.jsx(yn,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-primary"}),i.jsx("p",{className:"text-muted-foreground",children:"Profiel laden..."})]})}):i.jsxs("div",{className:"min-h-screen bg-background pb-20 md:pb-0",children:[i.jsxs("div",{className:"container mx-auto p-4 sm:p-6 max-w-3xl",children:[i.jsxs("div",{className:"mb-4 sm:mb-6",children:[i.jsxs(ne,{variant:"ghost",onClick:()=>e("/"),className:"mb-3 sm:mb-4 -ml-2",children:[i.jsx(Yw,{className:"mr-2 h-4 w-4"}),"Terug naar Home"]}),i.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:n?`Profiel van ${r==null?void 0:r.full_name}`:"Mijn Profiel"}),i.jsx("p",{className:"text-sm sm:text-base text-muted-foreground mt-1 sm:mt-2",children:n?"Je bekijkt het profiel van een andere gebruiker":"Beheer uw persoonlijke gegevens"})]}),n&&i.jsxs(rI,{className:"mb-4 bg-amber-50 border-amber-200",children:[i.jsx(Ym,{className:"h-4 w-4 text-amber-600"}),i.jsx(sI,{className:"text-amber-800",children:"Je bekijkt dit profiel in impersonatie modus. Wijzigingen zijn niet toegestaan."})]}),i.jsx(CM,{...m,children:i.jsxs("form",{onSubmit:m.handleSubmit(w),className:"space-y-4 sm:space-y-6",children:[i.jsxs(dt,{className:"border-0 shadow-none",children:[i.jsxs(ln,{children:[i.jsxs(cn,{className:"flex items-center gap-2",children:[i.jsx(vr,{className:"h-5 w-5"}),"Persoonlijke Informatie"]}),i.jsx(Os,{children:"Uw basisgegevens voor contactopname en identificatie"})]}),i.jsxs(bt,{className:"space-y-4",children:[i.jsx(cr,{control:m.control,name:"full_name",render:({field:x})=>i.jsxs(Wn,{children:[i.jsx(Hn,{children:"Volledige Naam *"}),i.jsx(qn,{children:i.jsx(ot,{placeholder:"Jan Jansen",...x})}),i.jsx(ds,{})]})}),i.jsx(cr,{control:m.control,name:"email",render:({field:x})=>i.jsxs(Wn,{children:[i.jsx(Hn,{children:"E-mail *"}),i.jsx(qn,{children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(uo,{className:"h-4 w-4 text-muted-foreground"}),i.jsx(ot,{type:"email",placeholder:"jan@example.com",...x,disabled:!0})]})}),i.jsx(mu,{children:"E-mailadres kan niet worden gewijzigd"}),i.jsx(ds,{})]})}),i.jsx(cr,{control:m.control,name:"phone",render:({field:x})=>i.jsxs(Wn,{children:[i.jsx(Hn,{children:"Telefoonnummer"}),i.jsx(qn,{children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Ai,{className:"h-4 w-4 text-muted-foreground"}),i.jsx(ot,{type:"tel",placeholder:"0612345678 of +31612345678",...x})]})}),i.jsx(ds,{})]})}),i.jsx(cr,{control:m.control,name:"birth_date",render:({field:x})=>i.jsxs(Wn,{children:[i.jsx(Hn,{children:"Geboortedatum"}),i.jsx(qn,{children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Wt,{className:"h-4 w-4 text-muted-foreground"}),i.jsx(ot,{type:"date",...x})]})}),i.jsx(mu,{children:"Voor verjaardagswensen en persoonlijke service"}),i.jsx(ds,{})]})})]})]}),i.jsxs(dt,{className:"border-0 shadow-none",children:[i.jsxs(ln,{children:[i.jsxs(cn,{className:"flex items-center gap-2",children:[i.jsx(xo,{className:"h-5 w-5"}),"Adresgegevens"]}),i.jsx(Os,{children:"Optioneel - voor bezorgdiensten en locatie-informatie"})]}),i.jsxs(bt,{className:"space-y-4",children:[i.jsx(cr,{control:m.control,name:"street_address",render:({field:x})=>i.jsxs(Wn,{children:[i.jsx(Hn,{children:"Straat en Huisnummer"}),i.jsx(qn,{children:i.jsx(ot,{placeholder:"Hoofdstraat 123",...x})}),i.jsx(ds,{})]})}),i.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[i.jsx(cr,{control:m.control,name:"postal_code",render:({field:x})=>i.jsxs(Wn,{children:[i.jsx(Hn,{children:"Postcode"}),i.jsx(qn,{children:i.jsx(ot,{placeholder:"1234AB",...x})}),i.jsx(ds,{})]})}),i.jsx(cr,{control:m.control,name:"city",render:({field:x})=>i.jsxs(Wn,{children:[i.jsx(Hn,{children:"Plaats"}),i.jsx(qn,{children:i.jsx(ot,{placeholder:"Amsterdam",...x})}),i.jsx(ds,{})]})})]})]})]}),i.jsxs(dt,{className:"border-0 shadow-none",children:[i.jsxs(ln,{children:[i.jsx(cn,{children:"Voorkeuren"}),i.jsx(Os,{children:"Beheer uw communicatievoorkeuren"})]}),i.jsxs(bt,{className:"space-y-4",children:[i.jsx(cr,{control:m.control,name:"newsletter_enabled",render:({field:x})=>i.jsxs(Wn,{className:"flex flex-row items-center justify-between rounded-lg p-4",children:[i.jsxs("div",{className:"space-y-0.5",children:[i.jsx(Hn,{className:"text-base",children:"Nieuwsbrief"}),i.jsx(mu,{children:"Ontvang updates over aanbiedingen en nieuws"})]}),i.jsx(qn,{children:i.jsx(Kx,{checked:x.value,onCheckedChange:x.onChange})})]})}),i.jsx(cr,{control:m.control,name:"waitlist_notifications_enabled",render:({field:x})=>i.jsxs(Wn,{className:"flex flex-row items-center justify-between rounded-lg p-4",children:[i.jsxs("div",{className:"space-y-0.5",children:[i.jsx(Hn,{className:"text-base",children:"Wachtlijst Notificaties"}),i.jsx(mu,{children:"Ontvang een bericht wanneer er een plek vrijkomt op de wachtlijst"})]}),i.jsx(qn,{children:i.jsx(Kx,{checked:x.value,onCheckedChange:x.onChange})})]})})]})]}),i.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4",children:[i.jsx(ne,{type:"button",variant:"outline",onClick:()=>e("/"),className:"flex-1 h-11",children:n?"Terug":"Annuleren"}),!n&&i.jsx(ne,{type:"submit",disabled:l,className:"flex-1 h-11",children:l?i.jsxs(i.Fragment,{children:[i.jsx(yn,{className:"mr-2 h-4 w-4 animate-spin"}),"Opslaan..."]}):i.jsxs(i.Fragment,{children:[i.jsx(Y5,{className:"mr-2 h-4 w-4"}),"Opslaan"]})})]})]})})]}),i.jsx(pp,{user:f,isAdmin:t,onLogout:y})]})}const gre=()=>{const[e,t]=p.useState(null),[n,r]=p.useState(!0),[s,a]=p.useState(null);return p.useEffect(()=>{const o=async()=>{try{const{data:{user:c}}=await B.auth.getUser();if(!c){t(null),r(!1);return}const{data:u,error:d}=await B.from("organization_members").select(` organization_id, role, organizations!inner ( id, name, slug ) `).eq("user_id",c.id).eq("is_active",!0).single();if(d){d.code==="PGRST116"?t(null):(console.error("Error fetching organization:",d),a(d.message)),r(!1);return}if(u&&u.organizations){const f=u.organizations;t({organizationId:f.id,organizationName:f.name,organizationSlug:f.slug,userOrgRole:u.role})}}catch(c){console.error("Error:",c),a(c instanceof Error?c.message:"Unknown error")}finally{r(!1)}};o();const{data:{subscription:l}}=B.auth.onAuthStateChange(()=>{o()});return()=>l.unsubscribe()},[]),{organization:e,loading:n,error:s}},yre=()=>{var v,w;const e=Xs(),{impersonatedUser:t,isImpersonating:n,getEffectiveUserId:r}=mp(),[s,a]=p.useState([]),[o,l]=p.useState(null),[c,u]=p.useState(!0),{organization:d}=gre(),f=r(),h=(d==null?void 0:d.organizationName)||"Planning";p.useEffect(()=>{if(!n){e("/");return}(async()=>{const x=d==null?void 0:d.organizationId;if(!f||!x)return;u(!0);const{data:g}=await B.from("profiles").select("id, full_name, email, phone, birth_date").eq("id",f).eq("organization_id",x).maybeSingle();g&&l(g);const{data:b}=await B.from("appointments").select(` id, appointment_date, appointment_time, status, service:services(name, duration_minutes, price), staff:staff(name) `).eq("customer_id",f).eq("organization_id",x).gte("appointment_date",he(new Date,"yyyy-MM-dd")).order("appointment_date",{ascending:!0}).order("appointment_time",{ascending:!0}).limit(5);a(b||[]),u(!1)})()},[f,n,d==null?void 0:d.organizationId,e]);const m=y=>{switch(y){case"confirmed":return i.jsx(Qe,{className:"bg-green-500/10 text-green-600 border-green-200",children:"Bevestigd"});case"pending":return i.jsx(Qe,{variant:"secondary",children:"In afwachting"});case"completed":return i.jsx(Qe,{variant:"outline",children:"Voltooid"});case"cancelled":return i.jsx(Qe,{variant:"destructive",children:"Geannuleerd"});default:return i.jsx(Qe,{variant:"secondary",children:y})}};return n?i.jsxs("div",{className:"min-h-screen pb-20 md:pb-0 bg-background",children:[i.jsx("nav",{className:"bg-card border-b sticky top-0 z-50",children:i.jsx(Xo,{children:i.jsxs("div",{className:"py-3 sm:py-4 flex justify-between items-center",children:[i.jsx(la,{to:"/",className:"flex items-center gap-3",children:i.jsx("span",{className:"text-lg sm:text-xl font-bold",children:h})}),i.jsx("div",{className:"flex gap-2 items-center",children:i.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>e("/booking"),children:[i.jsx(Wt,{className:"mr-2 h-4 w-4"}),"Afspraak maken"]})})]})})}),i.jsx("section",{className:"bg-gradient-to-b from-primary to-primary/90 text-primary-foreground py-8 sm:py-12",children:i.jsxs(Xo,{className:"text-center",children:[i.jsx(Md,{className:"w-20 h-20 mx-auto mb-4 border-4 border-primary-foreground/20",children:i.jsx(Dd,{className:"text-2xl bg-primary-foreground/10",children:((v=t==null?void 0:t.full_name)==null?void 0:v.split(" ").map(y=>y[0]).join("").toUpperCase())||"U"})}),i.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:["Welkom, ",((w=t==null?void 0:t.full_name)==null?void 0:w.split(" ")[0])||"Klant","!"]}),i.jsxs("p",{className:"text-lg opacity-90",children:["Dit is wat ",t==null?void 0:t.full_name," ziet als klant"]})]})}),i.jsxs(Xo,{className:"py-6 space-y-6",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(la,{to:"/booking",children:i.jsx(dt,{className:"hover:shadow-md transition-shadow cursor-pointer h-full",children:i.jsxs(bt,{className:"p-4 flex flex-col items-center justify-center text-center",children:[i.jsx(Wt,{className:"h-8 w-8 text-primary mb-2"}),i.jsx("span",{className:"font-medium",children:"Nieuwe afspraak"})]})})}),i.jsx(la,{to:"/profile",children:i.jsx(dt,{className:"hover:shadow-md transition-shadow cursor-pointer h-full",children:i.jsxs(bt,{className:"p-4 flex flex-col items-center justify-center text-center",children:[i.jsx(vr,{className:"h-8 w-8 text-primary mb-2"}),i.jsx("span",{className:"font-medium",children:"Mijn profiel"})]})})})]}),i.jsxs(dt,{children:[i.jsxs(ln,{children:[i.jsxs(cn,{className:"flex items-center gap-2",children:[i.jsx(Wt,{className:"h-5 w-5"}),"Komende afspraken"]}),i.jsx(Os,{children:s.length===0?"Geen geplande afspraken":`${s.length} afspra${s.length===1?"ak":"ken"} gepland`})]}),i.jsx(bt,{className:"space-y-4",children:c?i.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Laden..."}):s.length===0?i.jsxs("div",{className:"text-center py-8",children:[i.jsx("p",{className:"text-muted-foreground mb-4",children:"Je hebt nog geen afspraken gepland"}),i.jsx(la,{to:"/booking",children:i.jsxs(ne,{children:[i.jsx(Wt,{className:"mr-2 h-4 w-4"}),"Maak je eerste afspraak"]})})]}):i.jsxs(i.Fragment,{children:[s.map(y=>{var x,g;return i.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg hover:bg-accent/50 transition-colors",children:[i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("div",{className:"flex flex-col items-center justify-center bg-primary/10 rounded-lg p-3 min-w-[60px]",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:he(new Date(y.appointment_date),"MMM",{locale:tt}).toUpperCase()}),i.jsx("span",{className:"text-2xl font-bold text-primary",children:he(new Date(y.appointment_date),"d")})]}),i.jsxs("div",{children:[i.jsx("h4",{className:"font-medium",children:(x=y.service)==null?void 0:x.name}),i.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i.jsx(To,{className:"h-3 w-3"}),y.appointment_time.slice(0,5),i.jsx("span",{children:"•"}),i.jsx("span",{children:(g=y.staff)==null?void 0:g.name})]}),i.jsx("div",{className:"mt-1",children:m(y.status)})]})]}),i.jsx(Lk,{className:"h-5 w-5 text-muted-foreground"})]},y.id)}),i.jsx("div",{className:"pt-2 border-t",children:i.jsxs(la,{to:"/profile",className:"text-sm text-primary hover:underline flex items-center gap-1",children:["Bekijk alle afspraken",i.jsx(Lk,{className:"h-3 w-3"})]})})]})})]}),o&&i.jsxs(dt,{children:[i.jsx(ln,{children:i.jsxs(cn,{className:"flex items-center gap-2",children:[i.jsx(vr,{className:"h-5 w-5"}),"Mijn gegevens"]})}),i.jsxs(bt,{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(uo,{className:"h-4 w-4 text-muted-foreground"}),i.jsx("span",{children:o.email})]}),o.phone&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ai,{className:"h-4 w-4 text-muted-foreground"}),i.jsx("span",{children:o.phone})]}),o.birth_date&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Wt,{className:"h-4 w-4 text-muted-foreground"}),i.jsxs("span",{children:["Verjaardag: ",he(new Date(o.birth_date),"d MMMM",{locale:tt})]})]}),i.jsx("div",{className:"pt-2",children:i.jsx(la,{to:"/profile",children:i.jsx(ne,{variant:"outline",size:"sm",children:"Profiel bewerken"})})})]})]})]}),i.jsx(pp,{user:null,isAdmin:!1,onLogout:()=>{}})]}):null},vre=()=>{const e=Qs();return p.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",e.pathname)},[e.pathname]),i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-100",children:i.jsxs("div",{className:"text-center",children:[i.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),i.jsx("p",{className:"mb-4 text-xl text-gray-600",children:"Oops! Page not found"}),i.jsx("a",{href:"/",className:"text-blue-500 underline hover:text-blue-700",children:"Return to Home"})]})})},ZS=p.lazy(()=>lt(()=>import("./Admin-DIOrS4A5.js").then(e=>e.z),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),JS=p.lazy(()=>lt(()=>import("./CustomerProfile-Ty27TGIi.js"),__vite__mapDeps([13,1,2,3,4,5,14,15,16]))),eE=p.lazy(()=>lt(()=>import("./CustomerEngagement-CUXvGTKn.js"),__vite__mapDeps([17,18,19,10]))),xre=p.lazy(()=>lt(()=>import("./AcceptInvitation-DpazuymM.js"),__vite__mapDeps([20,10]))),wre=p.lazy(()=>lt(()=>import("./ClaimSlot-B4B7Dgb0.js"),[])),bre=p.lazy(()=>lt(()=>import("./Install-JMZEM7vK.js"),__vite__mapDeps([21,6]))),_re=p.lazy(()=>lt(()=>import("./ReviewRedirect-BntKCZ5g.js"),[])),kre=p.lazy(()=>lt(()=>import("./DayLinkView-Daz5IXPb.js"),__vite__mapDeps([22,23]))),jre=p.lazy(()=>lt(()=>import("./SupportPortal-CLl-ehNG.js"),__vite__mapDeps([24,11,25,26,5,27,4,28,29,30,31]))),Sre=p.lazy(()=>lt(()=>import("./SupportTicketPage-DWGSRiaM.js"),__vite__mapDeps([32,26,29,30,31]))),Ere=p.lazy(()=>lt(()=>import("./Landing-hvOQYUt-.js"),__vite__mapDeps([33,34,35,36,3,37,38,39,40,41,42]))),Nre=p.lazy(()=>lt(()=>import("./Features-DPddZM08.js"),__vite__mapDeps([43,34,35,36,3,37,38,42]))),Cre=p.lazy(()=>lt(()=>import("./FeatureDetail-Dplz5eLu.js"),__vite__mapDeps([44,34,35,36,3,37,38,42]))),Tre=p.lazy(()=>lt(()=>import("./Pricing-DR4W2MbH.js"),__vite__mapDeps([45,34,35,36,3,37,38,39,40,41,42]))),Pre=p.lazy(()=>lt(()=>import("./About-Jd8yCnzW.js"),__vite__mapDeps([46,34,35,36,3,37,38,47,42]))),Are=p.lazy(()=>lt(()=>import("./Contact-l0b5fv3p.js"),__vite__mapDeps([48,34,35,36,3,37,38,47]))),Rre=p.lazy(()=>lt(()=>import("./MarketingBlog-CYdU2QMb.js"),__vite__mapDeps([49,34,35,36,3,37,38,42]))),Ore=p.lazy(()=>lt(()=>import("./MarketingBlogPost-DyoVbrav.js"),__vite__mapDeps([50,34,35,36,3,37,38,42]))),Mre=p.lazy(()=>lt(()=>import("./Privacy-BkT86iL3.js"),__vite__mapDeps([51,34,35,36,3,37,38]))),Dre=p.lazy(()=>lt(()=>import("./NieuwsbriefWeb-Cp717jsZ.js"),__vite__mapDeps([52,34,35,36,3,37,38]))),Ire=p.lazy(()=>lt(()=>import("./Voorwaarden-B8gsFgsJ.js"),__vite__mapDeps([53,34,35,36,3,37,38]))),Lre=p.lazy(()=>lt(()=>import("./Verwerkersovereenkomst-BM5j3Ahp.js"),__vite__mapDeps([54,34,35,36,3,37,38]))),$re=p.lazy(()=>lt(()=>import("./SiteLayout-Yuj2VlH1.js").then(e=>e.S),__vite__mapDeps([55,38,56])).then(e=>({default:e.SiteLayout}))),Fre=p.lazy(()=>lt(()=>import("./SiteHome-DCkv13t5.js"),__vite__mapDeps([57,55,38,56]))),zre=p.lazy(()=>lt(()=>import("./SiteServices-De6XQ9T2.js"),__vite__mapDeps([58,55,38,56]))),Bre=p.lazy(()=>lt(()=>import("./SiteTeam-D6KhFZqg.js"),__vite__mapDeps([59,55,38,56]))),Ure=p.lazy(()=>lt(()=>import("./SiteBlog-Bp5SZq_x.js"),__vite__mapDeps([60,55,38,56]))),Vre=p.lazy(()=>lt(()=>import("./SiteBlogPost-P0UQlzs9.js"),__vite__mapDeps([61,55,38,56]))),Wre=p.lazy(()=>lt(()=>import("./SiteContact-C9npDlkn.js"),__vite__mapDeps([62,55,38,56]))),Hre=p.lazy(()=>lt(()=>import("./PortalLogin-BZu9GdLT.js"),[])),qre=p.lazy(()=>lt(()=>import("./PortalHome-DVnP9f57.js"),__vite__mapDeps([63,5,15]))),aI=new n6({defaultOptions:{queries:{staleTime:5*60*1e3,gcTime:10*60*1e3,retry:1,refetchOnWindowFocus:!1}}});HU(aI);const Kre=()=>i.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:i.jsxs("div",{className:"flex flex-col items-center gap-3",children:[i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"}),i.jsx("span",{className:"text-sm text-muted-foreground",children:"Laden..."})]})}),et=({children:e})=>i.jsx(p.Suspense,{fallback:i.jsx(Kre,{}),children:e}),tl=({children:e})=>i.jsx(Z9,{children:i.jsx(tW,{children:i.jsx(eW,{requiredRole:"admin",children:e})})}),Gre=()=>i.jsx(W9,{children:i.jsx(m6,{client:aI,children:i.jsx(KU,{children:i.jsx(K9,{children:i.jsx(G9,{children:i.jsx(q9,{children:i.jsxs(s2,{children:[i.jsx(H$,{}),i.jsx(J$,{}),i.jsx(GU,{}),i.jsx(LV,{}),i.jsx(X9,{}),i.jsx(L9,{children:i.jsxs(C9,{children:[i.jsx(Fe,{path:"/:orgSlug/auth",element:i.jsx(hS,{})}),i.jsx(Fe,{path:"/:orgSlug/admin",element:i.jsx(tl,{children:i.jsx(et,{children:i.jsx(ZS,{})})})}),i.jsx(Fe,{path:"/:orgSlug/admin/customer/:customerId/engagement",element:i.jsx(tl,{children:i.jsx(et,{children:i.jsx(eE,{})})})}),i.jsx(Fe,{path:"/:orgSlug/admin/customer/:customerId",element:i.jsx(tl,{children:i.jsx(et,{children:i.jsx(JS,{})})})}),i.jsx(Fe,{path:"/:orgSlug/booking",element:i.jsx(XS,{})}),i.jsx(Fe,{path:"/",element:qP(window.location.hostname)||KP()?i.jsx(hp,{to:"/auth",replace:!0}):i.jsx(et,{children:i.jsx(Ere,{})})}),i.jsx(Fe,{path:"/functies",element:i.jsx(et,{children:i.jsx(Nre,{})})}),i.jsx(Fe,{path:"/functies/:slug",element:i.jsx(et,{children:i.jsx(Cre,{})})}),i.jsx(Fe,{path:"/tarieven",element:i.jsx(et,{children:i.jsx(Tre,{})})}),i.jsx(Fe,{path:"/over-ons",element:i.jsx(et,{children:i.jsx(Pre,{})})}),i.jsx(Fe,{path:"/contact",element:i.jsx(et,{children:i.jsx(Are,{})})}),i.jsx(Fe,{path:"/blog",element:i.jsx(et,{children:i.jsx(Rre,{})})}),i.jsx(Fe,{path:"/blog/:slug",element:i.jsx(et,{children:i.jsx(Ore,{})})}),i.jsx(Fe,{path:"/nieuws/:id",element:i.jsx(et,{children:i.jsx(Dre,{})})}),i.jsx(Fe,{path:"/privacy",element:i.jsx(et,{children:i.jsx(Mre,{})})}),i.jsx(Fe,{path:"/algemene-voorwaarden",element:i.jsx(et,{children:i.jsx(Ire,{})})}),i.jsx(Fe,{path:"/verwerkersovereenkomst",element:i.jsx(et,{children:i.jsx(Lre,{})})}),i.jsx(Fe,{path:"/dashboard",element:i.jsx(yZ,{})}),i.jsx(Fe,{path:"/booking",element:i.jsx(XS,{})}),i.jsx(Fe,{path:"/profile",element:i.jsx(pre,{})}),i.jsx(Fe,{path:"/auth",element:i.jsx(hS,{})}),i.jsx(Fe,{path:"/accept-invitation",element:i.jsx(et,{children:i.jsx(xre,{})})}),i.jsx(Fe,{path:"/customer-view",element:i.jsx(yre,{})}),i.jsx(Fe,{path:"/install",element:i.jsx(et,{children:i.jsx(bre,{})})}),i.jsx(Fe,{path:"/claim/:token",element:i.jsx(et,{children:i.jsx(wre,{})})}),i.jsx(Fe,{path:"/dagplanning/:token",element:i.jsx(et,{children:i.jsx(kre,{})})}),i.jsx(Fe,{path:"/support/:orgKey",element:i.jsx(et,{children:i.jsx(jre,{})})}),i.jsx(Fe,{path:"/support/:orgKey/:ticketId",element:i.jsx(et,{children:i.jsx(Sre,{})})}),i.jsx(Fe,{path:"/review/:requestId",element:i.jsx(et,{children:i.jsx(_re,{})})}),i.jsx(Fe,{path:"/admin",element:i.jsx(tl,{children:i.jsx(et,{children:i.jsx(ZS,{})})})}),i.jsx(Fe,{path:"/admin/customer/:customerId/engagement",element:i.jsx(tl,{children:i.jsx(et,{children:i.jsx(eE,{})})})}),i.jsx(Fe,{path:"/admin/customer/:customerId",element:i.jsx(tl,{children:i.jsx(et,{children:i.jsx(JS,{})})})}),i.jsx(Fe,{path:"/:orgSlug/portal/login",element:i.jsx(et,{children:i.jsx(Hre,{})})}),i.jsx(Fe,{path:"/:orgSlug/portal",element:i.jsx(et,{children:i.jsx(qre,{})})}),i.jsxs(Fe,{element:i.jsx(et,{children:i.jsx($re,{})}),children:[i.jsx(Fe,{path:"/:orgSlug",element:i.jsx(et,{children:i.jsx(Fre,{})})}),i.jsx(Fe,{path:"/:orgSlug/diensten",element:i.jsx(et,{children:i.jsx(zre,{})})}),i.jsx(Fe,{path:"/:orgSlug/team",element:i.jsx(et,{children:i.jsx(Bre,{})})}),i.jsx(Fe,{path:"/:orgSlug/blog",element:i.jsx(et,{children:i.jsx(Ure,{})})}),i.jsx(Fe,{path:"/:orgSlug/blog/:postSlug",element:i.jsx(et,{children:i.jsx(Vre,{})})}),i.jsx(Fe,{path:"/:orgSlug/contact",element:i.jsx(et,{children:i.jsx(Wre,{})})})]}),i.jsx(Fe,{path:"*",element:i.jsx(vre,{})})]})})]})})})})})})});function Yre(e={}){const{immediate:t=!1,onNeedRefresh:n,onOfflineReady:r,onRegistered:s,onRegisteredSW:a,onRegisterError:o}=e;let l,c,u;const d=async(h=!0)=>{await c,u==null||u()};async function f(){if("serviceWorker"in navigator){if(l=await lt(async()=>{const{Workbox:h}=await import("./workbox-window.prod.es5-vqzQaGvo.js");return{Workbox:h}},[]).then(({Workbox:h})=>new h("/sw.js",{scope:"/",type:"classic"})).catch(h=>{o==null||o(h)}),!l)return;u=()=>{l==null||l.messageSkipWaiting()};{let h=!1;const m=()=>{h=!0,l==null||l.addEventListener("controlling",v=>{v.isUpdate&&window.location.reload()}),n==null||n()};l.addEventListener("installed",v=>{typeof v.isUpdate>"u"?typeof v.isExternal<"u"&&v.isExternal?m():!h&&(r==null||r()):v.isUpdate||r==null||r()}),l.addEventListener("waiting",m)}l.register({immediate:t}).then(h=>{a?a("/sw.js",h):s==null||s(h)}).catch(h=>{o==null||o(h)})}}return c=f(),d}const Qre=qP(window.location.hostname)||KP();if(Qre){const e=Yre({immediate:!0,onNeedRefresh(){K("Er staat een update klaar",{description:"We hebben de app verbeterd. Klik op Vernieuwen om de nieuwste versie te laden.",action:{label:"Vernieuwen",onClick:()=>{const t=new Promise(n=>{var r;(r=navigator.serviceWorker)==null||r.addEventListener("controllerchange",()=>n(!0),{once:!0}),setTimeout(()=>n(!1),2e3)});e(!0),t.then(async n=>{n||(await F0({mayWipe:!0}),window.location.reload())})}},duration:1/0})},onRegisteredSW(t,n){n&&(n.update(),setInterval(()=>n.update(),36e5))}})}else qU();window.addEventListener("vite:preloadError",e=>{sessionStorage.getItem("nexus-chunk-reload")||(sessionStorage.setItem("nexus-chunk-reload","1"),e.preventDefault(),F0({mayWipe:!1}).then(()=>window.location.reload()))});window.__NEXUS_BOOTED=!0;TC(document.getElementById("root")).render(i.jsxs(i.Fragment,{children:[i.jsx(Gre,{}),i.jsx(b3,{})]}));export{GO as $,Yw as A,ne as B,dt as C,C5 as D,tt as E,Eu as F,Tt as G,Y as H,ot as I,xt as J,Lk as K,la as L,uo as M,hp as N,oW as O,jc as P,To as Q,Tp as R,n$ as S,l$ as T,vr as U,yi as V,xo as W,Sa as X,Ai as Y,pae as Z,$b as _,Xs as a,ji as a$,sre as a0,HP as a1,rre as a2,Dt as a3,vae as a4,Wne as a5,Xu as a6,Qe as a7,Ry as a8,He as a9,Je as aA,hj as aB,s2 as aC,Fz as aD,zz as aE,a2 as aF,Mc as aG,Oi as aH,Bd as aI,Mi as aJ,Ud as aK,Jw as aL,rI as aM,Vr as aN,sI as aO,aW as aP,Ke as aQ,Y5 as aR,Md as aS,nq as aT,Dd as aU,xse as aV,$H as aW,iq as aX,D5 as aY,L5 as aZ,Sp as a_,Fs as aa,vs as ab,Te as ac,Vs as ad,xe as ae,Jn as af,Ln as ag,ze as ah,Zt as ai,Ise as aj,Wr as ak,mne as al,ED as am,pne as an,TD as ao,PD as ap,vR as aq,xR as ar,wse as as,bse as at,FH as au,kse as av,_se as aw,jse as ax,Ym as ay,Gm as az,Rd as b,kW as b$,oO as b0,kb as b1,jb as b2,Eb as b3,Nb as b4,Sb as b5,Tb as b6,Cb as b7,_c as b8,pT as b9,qO as bA,Rx as bB,dT as bC,i$ as bD,Kx as bE,Pr as bF,Wd as bG,Dc as bH,Lc as bI,yb as bJ,Ad as bK,Pn as bL,mT as bM,$k as bN,e$ as bO,Od as bP,mt as bQ,mr as bR,Yn as bS,gp as bT,vp as bU,eA as bV,Pv as bW,$5 as bX,Cd as bY,Fk as bZ,U5 as b_,rW as ba,cae as bb,iae as bc,AZ as bd,Ox as be,lt as bf,fS as bg,bx as bh,V5 as bi,fT as bj,X as bk,Hw as bl,Vd as bm,Qw as bn,Jg as bo,qs as bp,_R as bq,N5 as br,s$ as bs,A5 as bt,bf as bu,Ww as bv,I5 as bw,Tse as bx,Ju as by,t$ as bz,zt as c,T5 as c$,Km as c0,j5 as c1,hT as c2,q5 as c3,qm as c4,M5 as c5,B5 as c6,Fb as c7,fo as c8,F5 as c9,use as cA,cse as cB,lse as cC,Ic as cD,fd as cE,X0 as cF,cc as cG,vse as cH,yse as cI,Ri as cJ,NM as cK,Cs as cL,Z5 as cM,tae as cN,oZ as cO,hy as cP,nae as cQ,uZ as cR,EW as cS,eae as cT,k5 as cU,HX as cV,hae as cW,mae as cX,kA as cY,jA as cZ,R5 as c_,Ht as ca,ko as cb,Zu as cc,r$ as cd,K5 as ce,W5 as cf,wl as cg,Gh as ch,Zw as ci,Kh as cj,uT as ck,gT as cl,c$ as cm,H5 as cn,Nd as co,e0 as cp,G5 as cq,MR as cr,HD as cs,qD as ct,lc as cu,dse as cv,Hd as cw,_5 as cx,mn as cy,fse as cz,K as d,wb as d$,dd as d0,b5 as d1,Mj as d2,vb as d3,Dj as d4,xb as d5,Jse as d6,zk as d7,iM as d8,aM as d9,DZ as dA,Dne as dB,Une as dC,KO as dD,QS as dE,yT as dF,Qs as dG,Pi as dH,WG as dI,bM as dJ,Sx as dK,tX as dL,nX as dM,hre as dN,ZP as dO,fW as dP,nZ as dQ,dW as dR,Qg as dS,hW as dT,mse as dU,pse as dV,gse as dW,hse as dX,Bk as dY,mY as dZ,yY as d_,$c as da,vW as db,J0 as dc,_i as dd,E5 as de,o$ as df,Sse as dg,Bse as dh,UM as di,VM as dj,n_ as dk,HQ as dl,pW as dm,lp as dn,mW as dp,qo as dq,Zre as dr,pb as ds,Tne as dt,yae as du,a_ as dv,gae as dw,gne as dx,nre as dy,HS as dz,bt as e,Fd as e$,Cp as e0,QH as e1,CC as e2,cb as e3,ub as e4,Ld as e5,$d as e6,RC as e7,on as e8,h0 as e9,Ase as eA,NG as eB,bY as eC,Vse as eD,Wse as eE,Hse as eF,qse as eG,Kse as eH,Gse as eI,SY as eJ,sQ as eK,aQ as eL,Mse as eM,Dse as eN,Xse as eO,Zse as eP,$se as eQ,Fse as eR,_b as eS,zR as eT,kY as eU,yq as eV,NA as eW,Cse as eX,xp as eY,Use as eZ,dY as e_,ep as ea,Cc as eb,Op as ec,Sd as ed,ab as ee,RO as ef,IC as eg,sb as eh,_p as ei,wp as ej,wc as ek,AO as el,m0 as em,gi as en,p0 as eo,_Y as ep,Yse as eq,Qse as er,jY as es,bc as et,SR as eu,CG as ev,Rse as ew,Ose as ex,ER as ey,Pse as ez,ln as f,nR as f0,zd as f1,rR as f2,Uk as f3,pE as f4,r6 as f5,i1 as f6,tse as f7,ese as f8,S6 as f9,q9 as fA,B0 as fB,iT as fC,_x as fa,PR as fb,Lse as fc,lae as fd,uae as fe,aae as ff,rae as fg,sae as fh,zX as fi,JX as fj,Id as fk,zse as fl,z5 as fm,Ese as fn,Nse as fo,uA as fp,WX as fq,oae as fr,dae as fs,yp as ft,ur as fu,mp as fv,fae as fw,QQ as fx,nS as fy,dq as fz,cn as g,Wt as h,S5 as i,i as j,Xw as k,se as l,kc as m,Os as n,OZ as o,J5 as p,Q5 as q,p as r,B as s,wt as t,dp as u,Ge as v,yn as w,Di as x,X5 as y,he as z};