vendor: 6,424 bytes, lines 1-9
1var V7=Object.defineProperty;var p_=e=>{throw TypeError(e)};var q7=(e,s,r)=>s in e?V7(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r;var Ze=(e,s,r)=>q7(e,typeof s!="symbol"?s+"":s,r),oy=(e,s,r)=>s.has(e)||p_("Cannot "+r);var ne=(e,s,r)=>(oy(e,s,"read from private field"),r?r.call(e):s.get(e)),ct=(e,s,r)=>s.has(e)?p_("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(e):s.set(e,r),Qe=(e,s,r,n)=>(oy(e,s,"write to private field"),n?n.call(e,r):s.set(e,r),r),Ot=(e,s,r)=>(oy(e,s,"access private method"),r);var np=(e,s,r,n)=>({set _(a){Qe(e,s,a,r)},get _(){return ne(e,s,n)}});function H7(e,s){for(var r=0;r<s.length;r++){const n=s[r];if(typeof n!="string"&&!Array.isArray(n)){for(const a in n)if(a!=="default"&&!(a in e)){const i=Object.getOwnPropertyDescriptor(n,a);i&&Object.defineProperty(e,a,i.get?i:{enumerable:!0,get:()=>n[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function r(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(a){if(a.ep)return;a.ep=!0;const i=r(a);fetch(a.href,i)}})();var la=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rk(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function W7(e){if(e.__esModule)return e;var s=e.default;if(typeof s=="function"){var r=function n(){return this instanceof n?Reflect.construct(s,arguments,this.constructor):s.apply(this,arguments)};r.prototype=s.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}),r}var nk={exports:{}},Ig={},ak={exports:{}},Bt={};/** 2 * @license React 3 * react.production.min.js 4 * 5 * Copyright (c) Facebook, Inc. and its affiliates. 6 * 7 * This source code is licensed under the MIT license found in the 8 * LICENSE file in the root directory of this source tree. 9 */var ff=Symbol.for("react.element"),G7=Symbol.for("react.portal"),Y7=Symbol.for("react.fragment"),K7=Symbol.for("react.strict_mode"),Q7=Symbol.for("react.profiler"),X7=Symbol.for("react.provider"),Z7=Symbol.for("react.context"),J7=Symbol.for("react.forward_ref"),eM=Symbol.for("react.suspense"),tM=Symbol.for("react.memo"),sM=Symbol.for("react.lazy"),x_=Symbol.iterator;function rM(e){return e===null||typeof e!="object"?null:(e=x_&&e[x_]||e["@@iterator"],typeof e=="function"?e:null)}var ik={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ok=Object.assign,lk={};function yu(e,s,r){this.props=e,this.context=s,this.refs=lk,this.updater=r||ik}yu.prototype.isReactComponent={};yu.prototype.setState=function(e,s){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,s,"setState")};yu.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ck(){}ck.prototype=yu.prototype;function b1(e,s,r){this.props=e,this.context=s,this.refs=lk,this.updater=r||ik}var j1=b1.prototype=new ck;j1.constructor=b1;ok(j1,yu.prototype);j1.isPureReactComponent=!0;var g_=Array.isArray,dk=Object.prototype.hasOwnProperty,w1={current:null},uk={key:!0,ref:!0,__self:!0,__source:!0};function mk(e,s,r){var n,a={},i=null,o=null;if(s!=null)for(n in s.ref!==void 0&&(o=s.ref),s.key!==void 0&&(i=""+s.key),s)dk.call(s,n)&&!uk.hasOwnProperty(n)&&(a[n]=s[n]);var l=arguments.length-2;if(l===1)a.children=r;else if(1<l){for(var c=Array(l),d=0;d<l;d++)c[d]=arguments[d+2];a.children=c}if(e&&e.defaultProps)for(n in l=e.defaultProps,l)a[n]===void 0&&(a[n]=l[n]);return{$$typeof:ff,type:e,key:i,ref:o,props:a,_owner:w1.current}}function nM(e,s){return{$$typeof:ff,type:e.type,key:s,ref:e.ref,props:e.props,_owner:e._owner}}function N1(e){return typeof e=="object"&&e!==null&&e.$$typeof===ff}function aM(e){var s={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(r){return s[r]})}var v_=/\/+/g;function ly(e,s){return typeof e=="object"&&e!==null&&e.key!=null?aM(""+e.key):s.toString(36)}function Gp(e,s,r,n,a){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case ff:case G7:o=!0}}if(o)return o=e,a=a(o),e=n===""?"."+ly(o,0):n,g_(a)?(r="",e!=null&&(r=e.replace(v_,"$&/")+"/"),Gp(a,s,r,"",function(d){return d})):a!=null&&(N1(a)&&(a=nM(a,r+(!a.key||o&&o.key===a.key?"":(""+a.key).replace(v_,"$&/")+"/")+e)),s.push(a)),1;if(o=0,n=n===""?".":n+":",g_(e))for(var l=0;l<e.length;l++){i=e[l];var c=n+ly(i,l);o+=Gp(i,s,r,c,a)}else if(c=rM(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=n+ly(i,l++),o+=Gp(i,s,r,c,a);else if(i==="object")throw s=String(e),Error("Objects are not valid as a React child (found: "+(s==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":s)+"). If you meant to render a collection of children, use an array instead.");return o}function ap(e,s,r){if(e==null)return e;var n=[],a=0;return Gp(e,n,"","",function(i){return s.call(r,i,a++)}),n}function iM(e){if(e._status===-1){var s=e._result;s=s(),s.then(function(r){(e._status===0||e._status===-1)&&(e._status=1,e._result=r)},function(r){(e._status===0||e._status===-1)&&(e._status=2,e._result=r)}),e._status===-1&&(e._status=0,e._result=s)}if(e._status===1)return e._result.default;throw e._result}var nn={current:null},Yp={transition:null},oM={ReactCurrentDispatcher:nn,ReactCurrentBatchConfig:Yp,ReactCurrentOwner:w1};function hk(){throw Error("act(...) is not supported in production builds of React.")}
vendor: 4,180 bytes, lines 9-25
9Bt.Children={map:ap,forEach:function(e,s,r){ap(e,function(){s.apply(this,arguments)},r)},count:function(e){var s=0;return ap(e,function(){s++}),s},toArray:function(e){return ap(e,function(s){return s})||[]},only:function(e){if(!N1(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Bt.Component=yu;Bt.Fragment=Y7;Bt.Profiler=Q7;Bt.PureComponent=b1;Bt.StrictMode=K7;Bt.Suspense=eM;Bt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=oM;Bt.act=hk;Bt.cloneElement=function(e,s,r){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var n=ok({},e.props),a=e.key,i=e.ref,o=e._owner;if(s!=null){if(s.ref!==void 0&&(i=s.ref,o=w1.current),s.key!==void 0&&(a=""+s.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in s)dk.call(s,c)&&!uk.hasOwnProperty(c)&&(n[c]=s[c]===void 0&&l!==void 0?l[c]:s[c])}var c=arguments.length-2;if(c===1)n.children=r;else if(1<c){l=Array(c);for(var d=0;d<c;d++)l[d]=arguments[d+2];n.children=l}return{$$typeof:ff,type:e.type,key:a,ref:i,props:n,_owner:o}};Bt.createContext=function(e){return e={$$typeof:Z7,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:X7,_context:e},e.Consumer=e};Bt.createElement=mk;Bt.createFactory=function(e){var s=mk.bind(null,e);return s.type=e,s};Bt.createRef=function(){return{current:null}};Bt.forwardRef=function(e){return{$$typeof:J7,render:e}};Bt.isValidElement=N1;Bt.lazy=function(e){return{$$typeof:sM,_payload:{_status:-1,_result:e},_init:iM}};Bt.memo=function(e,s){return{$$typeof:tM,type:e,compare:s===void 0?null:s}};Bt.startTransition=function(e){var s=Yp.transition;Yp.transition={};try{e()}finally{Yp.transition=s}};Bt.unstable_act=hk;Bt.useCallback=function(e,s){return nn.current.useCallback(e,s)};Bt.useContext=function(e){return nn.current.useContext(e)};Bt.useDebugValue=function(){};Bt.useDeferredValue=function(e){return nn.current.useDeferredValue(e)};Bt.useEffect=function(e,s){return nn.current.useEffect(e,s)};Bt.useId=function(){return nn.current.useId()};Bt.useImperativeHandle=function(e,s,r){return nn.current.useImperativeHandle(e,s,r)};Bt.useInsertionEffect=function(e,s){return nn.current.useInsertionEffect(e,s)};Bt.useLayoutEffect=function(e,s){return nn.current.useLayoutEffect(e,s)};Bt.useMemo=function(e,s){return nn.current.useMemo(e,s)};Bt.useReducer=function(e,s,r){return nn.current.useReducer(e,s,r)};Bt.useRef=function(e){return nn.current.useRef(e)};Bt.useState=function(e){return nn.current.useState(e)};Bt.useSyncExternalStore=function(e,s,r){return nn.current.useSyncExternalStore(e,s,r)};Bt.useTransition=function(){return nn.current.useTransition()};Bt.version="18.3.1";ak.exports=Bt;var u=ak.exports;const ve=rk(u),_1=H7({__proto__:null,default:ve},[u]);/** 10 * @license React 11 * react-jsx-runtime.production.min.js 12 * 13 * Copyright (c) Facebook, Inc. and its affiliates. 14 * 15 * This source code is licensed under the MIT license found in the 16 * LICENSE file in the root directory of this source tree. 17 */var lM=u,cM=Symbol.for("react.element"),dM=Symbol.for("react.fragment"),uM=Object.prototype.hasOwnProperty,mM=lM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,hM={key:!0,ref:!0,__self:!0,__source:!0};function fk(e,s,r){var n,a={},i=null,o=null;r!==void 0&&(i=""+r),s.key!==void 0&&(i=""+s.key),s.ref!==void 0&&(o=s.ref);for(n in s)uM.call(s,n)&&!hM.hasOwnProperty(n)&&(a[n]=s[n]);if(e&&e.defaultProps)for(n in s=e.defaultProps,s)a[n]===void 0&&(a[n]=s[n]);return{$$typeof:cM,type:e,key:i,ref:o,props:a,_owner:mM.current}}Ig.Fragment=dM;Ig.jsx=fk;Ig.jsxs=fk;nk.exports=Ig;var t=nk.exports,pk={exports:{}},Wn={},xk={exports:{}},gk={};/** 18 * @license React 19 * scheduler.production.min.js 20 * 21 * Copyright (c) Facebook, Inc. and its affiliates. 22 * 23 * This source code is licensed under the MIT license found in the 24 * LICENSE file in the root directory of this source tree. 25 */(function(e){function s(D,_){var H=D.length;D.push(_);e:for(;0<H;){var O=H-1>>>1,U=D[O];if(0<a(U,_))D[O]=_,D[H]=U,H=O;else break e}}function r(D){return D.length===0?null:D[0]}
vendor: 9,179 bytes, lines 25-33
25function n(D){if(D.length===0)return null;var _=D[0],H=D.pop();if(H!==_){D[0]=H;e:for(var O=0,U=D.length,G=U>>>1;O<G;){var E=2*(O+1)-1,z=D[E],Z=E+1,M=D[Z];if(0>a(z,H))Z<U&&0>a(M,z)?(D[O]=M,D[Z]=H,O=Z):(D[O]=z,D[E]=H,O=E);else if(Z<U&&0>a(M,H))D[O]=M,D[Z]=H,O=Z;else break e}}return _}function a(D,_){var H=D.sortIndex-_.sortIndex;return H!==0?H:D.id-_.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var c=[],d=[],m=1,h=null,f=3,p=!1,x=!1,g=!1,b=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(D){for(var _=r(d);_!==null;){if(_.callback===null)n(d);else if(_.startTime<=D)n(d),_.sortIndex=_.expirationTime,s(c,_);else break;_=r(d)}}function v(D){if(g=!1,y(D),!x)if(r(c)!==null)x=!0,C(N);else{var _=r(d);_!==null&&L(v,_.startTime-D)}}function N(D,_){x=!1,g&&(g=!1,w($),$=-1),p=!0;var H=f;try{for(y(_),h=r(c);h!==null&&(!(h.expirationTime>_)||D&&!T());){var O=h.callback;if(typeof O=="function"){h.callback=null,f=h.priorityLevel;var U=O(h.expirationTime<=_);_=e.unstable_now(),typeof U=="function"?h.callback=U:h===r(c)&&n(c),y(_)}else n(c);h=r(c)}if(h!==null)var G=!0;else{var E=r(d);E!==null&&L(v,E.startTime-_),G=!1}return G}finally{h=null,f=H,p=!1}}var S=!1,k=null,$=-1,R=5,A=-1;function T(){return!(e.unstable_now()-A<R)}function P(){if(k!==null){var D=e.unstable_now();A=D;var _=!0;try{_=k(!0,D)}finally{_?B():(S=!1,k=null)}}else S=!1}var B;if(typeof j=="function")B=function(){j(P)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,I=Y.port2;Y.port1.onmessage=P,B=function(){I.postMessage(null)}}else B=function(){b(P,0)};function C(D){k=D,S||(S=!0,B())}function L(D,_){$=b(function(){D(e.unstable_now())},_)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(D){D.callback=null},e.unstable_continueExecution=function(){x||p||(x=!0,C(N))},e.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<D?Math.floor(1e3/D):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return r(c)},e.unstable_next=function(D){switch(f){case 1:case 2:case 3:var _=3;break;default:_=f}var H=f;f=_;try{return D()}finally{f=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(D,_){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var H=f;f=D;try{return _()}finally{f=H}},e.unstable_scheduleCallback=function(D,_,H){var O=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?O+H:O):H=O,D){case 1:var U=-1;break;case 2:U=250;break;case 5:U=1073741823;break;case 4:U=1e4;break;default:U=5e3}return U=H+U,D={id:m++,callback:_,priorityLevel:D,startTime:H,expirationTime:U,sortIndex:-1},H>O?(D.sortIndex=H,s(d,D),r(c)===null&&D===r(d)&&(g?(w($),$=-1):g=!0,L(v,H-O))):(D.sortIndex=U,s(c,D),x||p||(x=!0,C(N))),D},e.unstable_shouldYield=T,e.unstable_wrapCallback=function(D){var _=f;return function(){var H=f;f=_;try{return D.apply(this,arguments)}finally{f=H}}}})(gk);xk.exports=gk;var fM=xk.exports;/** 26 * @license React 27 * react-dom.production.min.js 28 * 29 * Copyright (c) Facebook, Inc. and its affiliates. 30 * 31 * This source code is licensed under the MIT license found in the 32 * LICENSE file in the root directory of this source tree. 33 */var pM=u,qn=fM;function Ie(e){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r<arguments.length;r++)s+="&args[]="+encodeURIComponent(arguments[r]);return"Minified React error #"+e+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var vk=new Set,eh={};function Ec(e,s){Yd(e,s),Yd(e+"Capture",s)}function Yd(e,s){for(eh[e]=s,e=0;e<s.length;e++)vk.add(s[e])}var zi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),L0=Object.prototype.hasOwnProperty,xM=/^[: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]*$/,y_={},b_={};function gM(e){return L0.call(b_,e)?!0:L0.call(y_,e)?!1:xM.test(e)?b_[e]=!0:(y_[e]=!0,!1)}function vM(e,s,r,n){if(r!==null&&r.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return n?!1:r!==null?!r.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function yM(e,s,r,n){if(s===null||typeof s>"u"||vM(e,s,r,n))return!0;if(n)return!1;if(r!==null)switch(r.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function an(e,s,r,n,a,i,o){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=n,this.attributeNamespace=a,this.mustUseProperty=r,this.propertyName=e,this.type=s,this.sanitizeURL=i,this.removeEmptyString=o}var $r={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){$r[e]=new an(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var s=e[0];$r[s]=new an(s,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){$r[e]=new an(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){$r[e]=new an(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){$r[e]=new an(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){$r[e]=new an(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){$r[e]=new an(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){$r[e]=new an(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){$r[e]=new an(e,5,!1,e.toLowerCase(),null,!1,!1)});var S1=/[\-:]([a-z])/g;function C1(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 s=e.replace(S1,C1);$r[s]=new an(s,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var s=e.replace(S1,C1);$r[s]=new an(s,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var s=e.replace(S1,C1);$r[s]=new an(s,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){$r[e]=new an(e,1,!1,e.toLowerCase(),null,!1,!1)});$r.xlinkHref=new an("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){$r[e]=new an(e,1,!1,e.toLowerCase(),null,!0,!0)});function k1(e,s,r,n){var a=$r.hasOwnProperty(s)?$r[s]:null;(a!==null?a.type!==0:n||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(yM(s,r,a,n)&&(r=null),n||a===null?gM(s)&&(r===null?e.removeAttribute(s):e.setAttribute(s,""+r)):a.mustUseProperty?e[a.propertyName]=r===null?a.type===3?!1:"":r:(s=a.attributeName,n=a.attributeNamespace,r===null?e.removeAttribute(s):(a=a.type,r=a===3||a===4&&r
vendor: 4,890 bytes, lines 33-37
33===!0?"":""+r,n?e.setAttributeNS(n,s,r):e.setAttribute(s,r))))}var Zi=pM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,ip=Symbol.for("react.element"),nd=Symbol.for("react.portal"),ad=Symbol.for("react.fragment"),$1=Symbol.for("react.strict_mode"),B0=Symbol.for("react.profiler"),yk=Symbol.for("react.provider"),bk=Symbol.for("react.context"),E1=Symbol.for("react.forward_ref"),z0=Symbol.for("react.suspense"),U0=Symbol.for("react.suspense_list"),P1=Symbol.for("react.memo"),go=Symbol.for("react.lazy"),jk=Symbol.for("react.offscreen"),j_=Symbol.iterator;function Ju(e){return e===null||typeof e!="object"?null:(e=j_&&e[j_]||e["@@iterator"],typeof e=="function"?e:null)}var Vs=Object.assign,cy;function bm(e){if(cy===void 0)try{throw Error()}catch(r){var s=r.stack.trim().match(/\n( *(at )?)/);cy=s&&s[1]||""}return` 34`+cy+e}var dy=!1;function uy(e,s){if(!e||dy)return"";dy=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(d){var n=d}Reflect.construct(e,[],s)}else{try{s.call()}catch(d){n=d}e.call(s.prototype)}else{try{throw Error()}catch(d){n=d}e()}}catch(d){if(d&&n&&typeof d.stack=="string"){for(var a=d.stack.split(` 35`),i=n.stack.split(` 36`),o=a.length-1,l=i.length-1;1<=o&&0<=l&&a[o]!==i[l];)l--;for(;1<=o&&0<=l;o--,l--)if(a[o]!==i[l]){if(o!==1||l!==1)do if(o--,l--,0>l||a[o]!==i[l]){var c=` 37`+a[o].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=o&&0<=l);break}}}finally{dy=!1,Error.prepareStackTrace=r}return(e=e?e.displayName||e.name:"")?bm(e):""}function bM(e){switch(e.tag){case 5:return bm(e.type);case 16:return bm("Lazy");case 13:return bm("Suspense");case 19:return bm("SuspenseList");case 0:case 2:case 15:return e=uy(e.type,!1),e;case 11:return e=uy(e.type.render,!1),e;case 1:return e=uy(e.type,!0),e;default:return""}}function V0(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 ad:return"Fragment";case nd:return"Portal";case B0:return"Profiler";case $1:return"StrictMode";case z0:return"Suspense";case U0:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case bk:return(e.displayName||"Context")+".Consumer";case yk:return(e._context.displayName||"Context")+".Provider";case E1:var s=e.render;return e=e.displayName,e||(e=s.displayName||s.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case P1:return s=e.displayName||null,s!==null?s:V0(e.type)||"Memo";case go:s=e._payload,e=e._init;try{return V0(e(s))}catch{}}return null}function jM(e){var s=e.type;switch(e.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=s.render,e=e.displayName||e.name||"",s.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return V0(s);case 8:return s===$1?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function tl(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function wk(e){var s=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function wM(e){var s=wk(e)?"checked":"value",r=Object.getOwnPropertyDescriptor(e.constructor.prototype,s),n=""+e[s];if(!e.hasOwnProperty(s)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var a=r.get,i=r.set;return Object.defineProperty(e,s,{configurable:!0,get:function(){return a.call(this)},set:function(o){n=""+o,i.call(this,o)}}),Object.defineProperty(e,s,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(o){n=""+o},stopTracking:function(){e._valueTracker=null,delete e[s]}}}}function op(e){e._valueTracker||(e._valueTracker=wM(e))}function Nk(e){if(!e)return!1;var s=e._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return e&&(n=wk(e)?e.checked?"true":"false":e.value),e=n,e!==r?(s.setValue(e),!0):!1}function vx(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 q0(e,s){var r=s.checked;return Vs({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??e._wrapperState.initialChecked})}function w_(e,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.
vendor: 4,858 bytes, line 37
37checked!=null?s.checked:s.defaultChecked;r=tl(s.value!=null?s.value:r),e._wrapperState={initialChecked:n,initialValue:r,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function _k(e,s){s=s.checked,s!=null&&k1(e,"checked",s,!1)}function H0(e,s){_k(e,s);var r=tl(s.value),n=s.type;if(r!=null)n==="number"?(r===0&&e.value===""||e.value!=r)&&(e.value=""+r):e.value!==""+r&&(e.value=""+r);else if(n==="submit"||n==="reset"){e.removeAttribute("value");return}s.hasOwnProperty("value")?W0(e,s.type,r):s.hasOwnProperty("defaultValue")&&W0(e,s.type,tl(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(e.defaultChecked=!!s.defaultChecked)}function N_(e,s,r){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var n=s.type;if(!(n!=="submit"&&n!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+e._wrapperState.initialValue,r||s===e.value||(e.value=s),e.defaultValue=s}r=e.name,r!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,r!==""&&(e.name=r)}function W0(e,s,r){(s!=="number"||vx(e.ownerDocument)!==e)&&(r==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+r&&(e.defaultValue=""+r))}var jm=Array.isArray;function yd(e,s,r,n){if(e=e.options,s){s={};for(var a=0;a<r.length;a++)s["$"+r[a]]=!0;for(r=0;r<e.length;r++)a=s.hasOwnProperty("$"+e[r].value),e[r].selected!==a&&(e[r].selected=a),a&&n&&(e[r].defaultSelected=!0)}else{for(r=""+tl(r),s=null,a=0;a<e.length;a++){if(e[a].value===r){e[a].selected=!0,n&&(e[a].defaultSelected=!0);return}s!==null||e[a].disabled||(s=e[a])}s!==null&&(s.selected=!0)}}function G0(e,s){if(s.dangerouslySetInnerHTML!=null)throw Error(Ie(91));return Vs({},s,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function __(e,s){var r=s.value;if(r==null){if(r=s.children,s=s.defaultValue,r!=null){if(s!=null)throw Error(Ie(92));if(jm(r)){if(1<r.length)throw Error(Ie(93));r=r[0]}s=r}s==null&&(s=""),r=s}e._wrapperState={initialValue:tl(r)}}function Sk(e,s){var r=tl(s.value),n=tl(s.defaultValue);r!=null&&(r=""+r,r!==e.value&&(e.value=r),s.defaultValue==null&&e.defaultValue!==r&&(e.defaultValue=r)),n!=null&&(e.defaultValue=""+n)}function S_(e){var s=e.textContent;s===e._wrapperState.initialValue&&s!==""&&s!==null&&(e.value=s)}function Ck(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Y0(e,s){return e==null||e==="http://www.w3.org/1999/xhtml"?Ck(s):e==="http://www.w3.org/2000/svg"&&s==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var lp,kk=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(s,r,n,a){MSApp.execUnsafeLocalFunction(function(){return e(s,r,n,a)})}:e}(function(e,s){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=s;else{for(lp=lp||document.createElement("div"),lp.innerHTML="<svg>"+s.valueOf().toString()+"</svg>",s=lp.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;s.firstChild;)e.appendChild(s.firstChild)}});function th(e,s){if(s){var r=e.firstChild;if(r&&r===e.lastChild&&r.nodeType===3){r.nodeValue=s;return}}e.textContent=s}var Tm={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},NM=["Webkit","ms","Moz","O"];Object.keys(Tm).forEach(function(e){NM.forEach(function(s){s=s+e.charAt(0).toUpperCase()+e.substring(1),Tm[s]=Tm[e]})});function $k(e,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||Tm.hasOwnProperty(e)&&Tm[e]?(""+s).trim():s+"px"}function Ek(e,s){e=e.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=$k(r,s[r],n);r==="float"&&(r="cssFloat"),n?e.setProperty(r,a):e[r]=a}}var _M=Vs({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 K0(e,s){if(s){if(_M[e]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Ie(137,e));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Ie(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Ie(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Ie(62))}}function Q0(e,s){if(e.indexOf("-")===-1)return typeof s.is=="str
37ing";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 X0=null;function A1(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Z0=null,bd=null,jd=null;function C_(e){if(e=gf(e)){if(typeof Z0!="function")throw Error(Ie(280));var s=e.stateNode;s&&(s=Ug(s),Z0(e.stateNode,e.type,s))}}function Pk(e){bd?jd?jd.push(e):jd=[e]:bd=e}function Ak(){if(bd){var e=bd,s=jd;if(jd=bd=null,C_(e),s)for(e=0;e<s.length;e++)C_(s[e])}}function Tk(e,s){return e(s)}function Dk(){}var my=!1;function Rk(e,s,r){if(my)return e(s,r);my=!0;try{return Tk(e,s,r)}finally{my=!1,(bd!==null||jd!==null)&&(Dk(),Ak())}}function sh(e,s){var r=e.stateNode;if(r===null)return null;var n=Ug(r);if(n===null)return null;r=n[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(e=e.type,n=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!n;break e;default:e=!1}if(e)return null;if(r&&typeof r!="function")throw Error(Ie(231,s,typeof r));return r}var J0=!1;if(zi)try{var em={};Object.defineProperty(em,"passive",{get:function(){J0=!0}}),window.addEventListener("test",em,em),window.removeEventListener("test",em,em)}catch{J0=!1}function SM(e,s,r,n,a,i,o,l,c){var d=Array.prototype.slice.call(arguments,3);try{s.apply(r,d)}catch(m){this.onError(m)}}var Dm=!1,yx=null,bx=!1,eb=null,CM={onError:function(e){Dm=!0,yx=e}};function kM(e,s,r,n,a,i,o,l,c){Dm=!1,yx=null,SM.apply(CM,arguments)}function $M(e,s,r,n,a,i,o,l,c){if(kM.apply(this,arguments),Dm){if(Dm){var d=yx;Dm=!1,yx=null}else throw Error(Ie(198));bx||(bx=!0,eb=d)}}function Pc(e){var s=e,r=e;if(e.alternate)for(;s.return;)s=s.return;else{e=s;do s=e,s.flags&4098&&(r=s.return),e=s.return;while(e)}return s.tag===3?r:null}function Mk(e){if(e.tag===13){var s=e.memoizedState;if(s===null&&(e=e.alternate,e!==null&&(s=e.memoizedState)),s!==null)return s.dehydrated}return null}function k_(e){if(Pc(e)!==e)throw Error(Ie(188))}function EM(e){var s=e.alternate;if(!s){if(s=Pc(e),s===null)throw Error(Ie(188));return s!==e?null:e}for(var r=e,n=s;;){var a=r.return;if(a===null)break;var i=a.alternate;if(i===null){if(n=a.return,n!==null){r=n;continue}break}if(a.child===i.child){for(i=a.child;i;){if(i===r)return k_(a),e;if(i===n)return k_(a),s;i=i.sibling}throw Error(Ie(188))}if(r.return!==n.return)r=a,n=i;else{for(var o=!1,l=a.child;l;){if(l===r){o=!0,r=a,n=i;break}if(l===n){o=!0,n=a,r=i;break}l=l.sibling}if(!o){for(l=i.child;l;){if(l===r){o=!0,r=i,n=a;break}if(l===n){o=!0,n=i,r=a;break}l=l.sibling}if(!o)throw Error(Ie(189))}}if(r.alternate!==n)throw Error(Ie(190))}if(r.tag!==3)throw Error(Ie(188));return r.stateNode.current===r?e:s}function Ok(e){return e=EM(e),e!==null?Ik(e):null}function Ik(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var s=Ik(e);if(s!==null)return s;e=e.sibling}return null}var Fk=qn.unstable_scheduleCallback,$_=qn.unstable_cancelCallback,PM=qn.unstable_shouldYield,AM=qn.unstable_requestPaint,Zs=qn.unstable_now,TM=qn.unstable_getCurrentPriorityLevel,T1=qn.unstable_ImmediatePriority,Lk=qn.unstable_UserBlockingPriority,jx=qn.unstable_NormalPriority,DM=qn.unstable_LowPriority,Bk=qn.unstable_IdlePriority,Fg=null,oi=null;function RM(e){if(oi&&typeof oi.onCommitFiberRoot=="function")try{oi.onCommitFiberRoot(Fg,e,void 0,(e.current.flags&128)===128)}catch{}}var Ea=Math.clz32?Math.clz32:IM,MM=Math.log,OM=Math.LN2;function IM(e){return e>>>=0,e===0?32:31-(MM(e)/OM|0)|0}var cp=64,dp=4194304;function wm(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 wx(e,s){var r=e.pendingLanes;if(r===0)return 0;var n=0,a=e.suspendedLanes,i=e.pingedLanes,o=r&268435455;if(o!==0){var l=o&~a;l!==0?n=wm(l):(i&=o,i!==0&&(n=wm(i)))}else o=r&~a,o!==0?n=wm(o):i!==0&&(n=wm(i));if(n===0)return 0;if(s!==0&&s!==n&&!(s&a)&&(a=n&-n,i=s&-s,a>=i||a===16&&(i&4194240)!==0))return s;if(n&4&&(n|=r&16),s=e.entangledLanes,s!==0)for(e=e.entanglements,s&=n;0<s;)r=31-Ea(s),a=1<<r,n|=e[r],s&=~a;return n}function FM(e,s){switch(e){case 1:case 2:case 4:return s+250;case 8:case 16:case 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 s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function LM(e,s){for(var r=e.suspendedLanes,n=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-Ea(i),l=1<<o,c=a[o];
vendor: 4,364 bytes, line 37
37c===-1?(!(l&r)||l&n)&&(a[o]=FM(l,s)):c<=s&&(e.expiredLanes|=l),i&=~l}}function tb(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function zk(){var e=cp;return cp<<=1,!(cp&4194240)&&(cp=64),e}function hy(e){for(var s=[],r=0;31>r;r++)s.push(e);return s}function pf(e,s,r){e.pendingLanes|=s,s!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,s=31-Ea(s),e[s]=r}function BM(e,s){var r=e.pendingLanes&~s;e.pendingLanes=s,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=s,e.mutableReadLanes&=s,e.entangledLanes&=s,s=e.entanglements;var n=e.eventTimes;for(e=e.expirationTimes;0<r;){var a=31-Ea(r),i=1<<a;s[a]=0,n[a]=-1,e[a]=-1,r&=~i}}function D1(e,s){var r=e.entangledLanes|=s;for(e=e.entanglements;r;){var n=31-Ea(r),a=1<<n;a&s|e[n]&s&&(e[n]|=s),r&=~a}}var ls=0;function Uk(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Vk,R1,qk,Hk,Wk,sb=!1,up=[],zo=null,Uo=null,Vo=null,rh=new Map,nh=new Map,jo=[],zM="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function E_(e,s){switch(e){case"focusin":case"focusout":zo=null;break;case"dragenter":case"dragleave":Uo=null;break;case"mouseover":case"mouseout":Vo=null;break;case"pointerover":case"pointerout":rh.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":nh.delete(s.pointerId)}}function tm(e,s,r,n,a,i){return e===null||e.nativeEvent!==i?(e={blockedOn:s,domEventName:r,eventSystemFlags:n,nativeEvent:i,targetContainers:[a]},s!==null&&(s=gf(s),s!==null&&R1(s)),e):(e.eventSystemFlags|=n,s=e.targetContainers,a!==null&&s.indexOf(a)===-1&&s.push(a),e)}function UM(e,s,r,n,a){switch(s){case"focusin":return zo=tm(zo,e,s,r,n,a),!0;case"dragenter":return Uo=tm(Uo,e,s,r,n,a),!0;case"mouseover":return Vo=tm(Vo,e,s,r,n,a),!0;case"pointerover":var i=a.pointerId;return rh.set(i,tm(rh.get(i)||null,e,s,r,n,a)),!0;case"gotpointercapture":return i=a.pointerId,nh.set(i,tm(nh.get(i)||null,e,s,r,n,a)),!0}return!1}function Gk(e){var s=Fl(e.target);if(s!==null){var r=Pc(s);if(r!==null){if(s=r.tag,s===13){if(s=Mk(r),s!==null){e.blockedOn=s,Wk(e.priority,function(){qk(r)});return}}else if(s===3&&r.stateNode.current.memoizedState.isDehydrated){e.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Kp(e){if(e.blockedOn!==null)return!1;for(var s=e.targetContainers;0<s.length;){var r=rb(e.domEventName,e.eventSystemFlags,s[0],e.nativeEvent);if(r===null){r=e.nativeEvent;var n=new r.constructor(r.type,r);X0=n,r.target.dispatchEvent(n),X0=null}else return s=gf(r),s!==null&&R1(s),e.blockedOn=r,!1;s.shift()}return!0}function P_(e,s,r){Kp(e)&&r.delete(s)}function VM(){sb=!1,zo!==null&&Kp(zo)&&(zo=null),Uo!==null&&Kp(Uo)&&(Uo=null),Vo!==null&&Kp(Vo)&&(Vo=null),rh.forEach(P_),nh.forEach(P_)}function sm(e,s){e.blockedOn===s&&(e.blockedOn=null,sb||(sb=!0,qn.unstable_scheduleCallback(qn.unstable_NormalPriority,VM)))}function ah(e){function s(a){return sm(a,e)}if(0<up.length){sm(up[0],e);for(var r=1;r<up.length;r++){var n=up[r];n.blockedOn===e&&(n.blockedOn=null)}}for(zo!==null&&sm(zo,e),Uo!==null&&sm(Uo,e),Vo!==null&&sm(Vo,e),rh.forEach(s),nh.forEach(s),r=0;r<jo.length;r++)n=jo[r],n.blockedOn===e&&(n.blockedOn=null);for(;0<jo.length&&(r=jo[0],r.blockedOn===null);)Gk(r),r.blockedOn===null&&jo.shift()}var wd=Zi.ReactCurrentBatchConfig,Nx=!0;function qM(e,s,r,n){var a=ls,i=wd.transition;wd.transition=null;try{ls=1,M1(e,s,r,n)}finally{ls=a,wd.transition=i}}function HM(e,s,r,n){var a=ls,i=wd.transition;wd.transition=null;try{ls=4,M1(e,s,r,n)}finally{ls=a,wd.transition=i}}function M1(e,s,r,n){if(Nx){var a=rb(e,s,r,n);if(a===null)Ny(e,s,n,_x,r),E_(e,n);else if(UM(a,e,s,r,n))n.stopPropagation();else if(E_(e,n),s&4&&-1<zM.indexOf(e)){for(;a!==null;){var i=gf(a);if(i!==null&&Vk(i),i=rb(e,s,r,n),i===null&&Ny(e,s,n,_x,r),i===a)break;a=i}a!==null&&n.stopPropagation()}else Ny(e,s,n,null,r)}}var _x=null;function rb(e,s,r,n){if(_x=null,e=A1(n),e=Fl(e),e!==null)if(s=Pc(e),s===null)e=null;else if(r=s.tag,r===13){if(e=Mk(s),e!==null)return e;e=null}else if(r===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;e=null}else s!==e&&(e=null);return _x=e,null}
vendor: 10,401 bytes, line 37
37function Yk(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(TM()){case T1:return 1;case Lk:return 4;case jx:case DM:return 16;case Bk:return 536870912;default:return 16}default:return 16}}var Oo=null,O1=null,Qp=null;function Kk(){if(Qp)return Qp;var e,s=O1,r=s.length,n,a="value"in Oo?Oo.value:Oo.textContent,i=a.length;for(e=0;e<r&&s[e]===a[e];e++);var o=r-e;for(n=1;n<=o&&s[r-n]===a[i-n];n++);return Qp=a.slice(e,1<n?1-n:void 0)}function Xp(e){var s=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&s===13&&(e=13)):e=s,e===10&&(e=13),32<=e||e===13?e:0}function mp(){return!0}function A_(){return!1}function Gn(e){function s(r,n,a,i,o){this._reactName=r,this._targetInst=a,this.type=n,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(r=e[l],this[l]=r?r(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?mp:A_,this.isPropagationStopped=A_,this}return Vs(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=mp)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=mp)},persist:function(){},isPersistent:mp}),s}var bu={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},I1=Gn(bu),xf=Vs({},bu,{view:0,detail:0}),WM=Gn(xf),fy,py,rm,Lg=Vs({},xf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:F1,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==rm&&(rm&&e.type==="mousemove"?(fy=e.screenX-rm.screenX,py=e.screenY-rm.screenY):py=fy=0,rm=e),fy)},movementY:function(e){return"movementY"in e?e.movementY:py}}),T_=Gn(Lg),GM=Vs({},Lg,{dataTransfer:0}),YM=Gn(GM),KM=Vs({},xf,{relatedTarget:0}),xy=Gn(KM),QM=Vs({},bu,{animationName:0,elapsedTime:0,pseudoElement:0}),XM=Gn(QM),ZM=Vs({},bu,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),JM=Gn(ZM),eO=Vs({},bu,{data:0}),D_=Gn(eO),tO={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},sO={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},rO={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function nO(e){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(e):(e=rO[e])?!!s[e]:!1}function F1(){return nO}var aO=Vs({},xf,{key:function(e){if(e.key){var s=tO[e.key]||e.key;if(s!=="Unidentified")return s}return e.type==="keypress"?(e=Xp(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?sO[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:F1,charCode:function(e){return e.type==="keypress"?Xp(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Xp(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),iO=Gn(aO),oO=Vs({},Lg,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),R_=Gn(oO),lO=Vs({},xf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:F1}),cO=Gn(lO),dO=Vs({},bu,{propertyName:0,elapsedTime:0,pseudoElement:0}),uO=Gn(dO),mO=Vs({},Lg,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),hO=Gn(mO),fO=[9,13,27,32],L1=zi&&"CompositionEvent"in window,Rm=null;zi&&"documentMode"in document&&(Rm=document.documentMode);var pO=zi&&"TextEvent"in window&&!Rm,Qk=zi&&(!L1||Rm&&8<Rm&&11>=Rm),M_=" ",O_=!1;function Xk(e,s){switch(e){case"keyup":return fO.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Zk(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var id=!1;function xO(e,s){switch(e){case"compositionend":return Zk(s);case"keypress":return s.which!==32?null:(O_=!0,M_);case"textInput":return e=s.data,e===M_&&O_?null:e;default:return null}}function gO(e,s){if(id)return e==="compositionend"||!L1&&Xk(e,s)?(e=Kk(),Qp=O1=Oo=null,id=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return Qk&&s.locale!=="ko"?null:s.data;default:return null}}var vO={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function I_(e){var s=e&&e.nodeName&&e.nodeName.toLowerCase();return s==="input"?!!vO[e.type]:s==="textarea"}function Jk(e,s,r,n){Pk(n),s=Sx(s,"onChange"),0<s.length&&(r=new I1("onChange","change",null,r,n),e.push({event:r,listeners:s}))}var Mm=null,ih=null;function yO(e){d5(e,0)}function Bg(e){var s=cd(e);if(Nk(s))return e}function bO(e,s){if(e==="change")return s}var e5=!1;if(zi){var gy;if(zi){var vy="oninput"in document;if(!vy){var F_=document.createElement("div");F_.setAttribute("oninput","return;"),vy=typeof F_.oninput=="function"}gy=vy}else gy=!1;e5=gy&&(!document.documentMode||9<document.documentMode)}function L_(){Mm&&(Mm.detachEvent("onpropertychange",t5),ih=Mm=null)}function t5(e){if(e.propertyName==="value"&&Bg(ih)){var s=[];Jk(s,ih,e,A1(e)),Rk(yO,s)}}function jO(e,s,r){e==="focusin"?(L_(),Mm=s,ih=r,Mm.attachEvent("onpropertychange",t5)):e==="focusout"&&L_()}function wO(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Bg(ih)}function NO(e,s){if(e==="click")return Bg(s)}function _O(e,s){if(e==="input"||e==="change")return Bg(s)}function SO(e,s){return e===s&&(e!==0||1/e===1/s)||e!==e&&s!==s}var Ra=typeof Object.is=="function"?Object.is:SO;function oh(e,s){if(Ra(e,s))return!0;if(typeof e!="object"||e===null||typeof s!="object"||s===null)return!1;var r=Object.keys(e),n=Object.keys(s);if(r.length!==n.length)return!1;for(n=0;n<r.length;n++){var a=r[n];if(!L0.call(s,a)||!Ra(e[a],s[a]))return!1}return!0}function B_(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function z_(e,s){var r=B_(e);e=0;for(var n;r;){if(r.nodeType===3){if(n=e+r.textContent.length,e<=s&&n>=s)return{node:r,offset:s-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=B_(r)}}function s5(e,s){return e&&s?e===s?!0:e&&e.nodeType===3?!1:s&&s.nodeType===3?s5(e,s.parentNode):"contains"in e?e.contains(s):e.compareDocumentPosition?!!(e.compareDocumentPosition(s)&16):!1:!1}function r5(){for(var e=window,s=vx();s instanceof e.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)e=s.contentWindow;else break;s=vx(e.document)}return s}function B1(e){var s=e&&e.nodeName&&e.nodeName.toLowerCase();return s&&(s==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||s==="textarea"||e.contentEditable==="true")}function CO(e){var s=r5(),r=e.focusedElem,n=e.selectionRange;if(s!==r&&r&&r.ownerDocument&&s5(r.ownerDocument.documentElement,r)){if(n!==null&&B1(r)){if(s=n.start,e=n.end,e===void 0&&(e=s),"selectionStart"in r)r.selectionStart=s,r.selectionEnd=Math.min(e,r.value.length);else if(e=(s=r.ownerDocument||document)&&s.defaultView||window,e.getSelection){e=e.getSelection();var a=r.textContent.length,i=Math.min(n.start,a);n=n.end===void 0?i:Math.min(n.end,a),!e.extend&&i>n&&(a=n,n=i,i=a),a=z_(r,i);var o=z_(r,n);a&&o&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(s=s.createRange(),s.setStart(a.node,a.offset),e.removeAllRanges(),i>n?(e.addRange(s),e.extend(o.node,o.offset)):(s.setEnd(o.node,o.offset),e.addRange(s)))}}for(s=[],e=r;e=e.parentNode;)e.nodeType===1&&s.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r<s.length;r++)e=s[r],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var kO=zi&&"documentMode"in document&&11>=document.documentMode,od=null,nb=null,Om=null,ab=!1;function U_(e,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;ab||od==null||od!==vx(n)||(n=od,"selectionStart"in n&&B1(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focu
vendor: 4,383 bytes, line 37
37sNode:n.focusNode,focusOffset:n.focusOffset}),Om&&oh(Om,n)||(Om=n,n=Sx(nb,"onSelect"),0<n.length&&(s=new I1("onSelect","select",null,s,r),e.push({event:s,listeners:n}),s.target=od)))}function hp(e,s){var r={};return r[e.toLowerCase()]=s.toLowerCase(),r["Webkit"+e]="webkit"+s,r["Moz"+e]="moz"+s,r}var ld={animationend:hp("Animation","AnimationEnd"),animationiteration:hp("Animation","AnimationIteration"),animationstart:hp("Animation","AnimationStart"),transitionend:hp("Transition","TransitionEnd")},yy={},n5={};zi&&(n5=document.createElement("div").style,"AnimationEvent"in window||(delete ld.animationend.animation,delete ld.animationiteration.animation,delete ld.animationstart.animation),"TransitionEvent"in window||delete ld.transitionend.transition);function zg(e){if(yy[e])return yy[e];if(!ld[e])return e;var s=ld[e],r;for(r in s)if(s.hasOwnProperty(r)&&r in n5)return yy[e]=s[r];return e}var a5=zg("animationend"),i5=zg("animationiteration"),o5=zg("animationstart"),l5=zg("transitionend"),c5=new Map,V_="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function ml(e,s){c5.set(e,s),Ec(s,[e])}for(var by=0;by<V_.length;by++){var jy=V_[by],$O=jy.toLowerCase(),EO=jy[0].toUpperCase()+jy.slice(1);ml($O,"on"+EO)}ml(a5,"onAnimationEnd");ml(i5,"onAnimationIteration");ml(o5,"onAnimationStart");ml("dblclick","onDoubleClick");ml("focusin","onFocus");ml("focusout","onBlur");ml(l5,"onTransitionEnd");Yd("onMouseEnter",["mouseout","mouseover"]);Yd("onMouseLeave",["mouseout","mouseover"]);Yd("onPointerEnter",["pointerout","pointerover"]);Yd("onPointerLeave",["pointerout","pointerover"]);Ec("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Ec("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Ec("onBeforeInput",["compositionend","keypress","textInput","paste"]);Ec("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Ec("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Ec("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Nm="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),PO=new Set("cancel close invalid load scroll toggle".split(" ").concat(Nm));function q_(e,s,r){var n=e.type||"unknown-event";e.currentTarget=r,$M(n,s,void 0,e),e.currentTarget=null}function d5(e,s){s=(s&4)!==0;for(var r=0;r<e.length;r++){var n=e[r],a=n.event;n=n.listeners;e:{var i=void 0;if(s)for(var o=n.length-1;0<=o;o--){var l=n[o],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==i&&a.isPropagationStopped())break e;q_(a,l,d),i=c}else for(o=0;o<n.length;o++){if(l=n[o],c=l.instance,d=l.currentTarget,l=l.listener,c!==i&&a.isPropagationStopped())break e;q_(a,l,d),i=c}}}if(bx)throw e=eb,bx=!1,eb=null,e}function Cs(e,s){var r=s[db];r===void 0&&(r=s[db]=new Set);var n=e+"__bubble";r.has(n)||(u5(s,e,2,!1),r.add(n))}function wy(e,s,r){var n=0;s&&(n|=4),u5(r,e,n,s)}var fp="_reactListening"+Math.random().toString(36).slice(2);function lh(e){if(!e[fp]){e[fp]=!0,vk.forEach(function(r){r!=="selectionchange"&&(PO.has(r)||wy(r,!1,e),wy(r,!0,e))});var s=e.nodeType===9?e:e.ownerDocument;s===null||s[fp]||(s[fp]=!0,wy("selectionchange",!1,s))}}function u5(e,s,r,n){switch(Yk(s)){case 1:var a=qM;break;case 4:a=HM;break;default:a=M1}r=a.bind(null,s,r,e),a=void 0,!J0||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(a=!0),n?a!==void 0?e.addEventListener(s,r,{capture:!0,passive:a}):e.addEventListener(s,r,!0):a!==void 0?e.addEventListener(s,r,{passive:a}):e.addEventListener(s,r,!1)}function Ny(e,s,r,n,a){var i=n;
vendor: 2,645 bytes, line 37
37if(!(s&1)&&!(s&2)&&n!==null)e:for(;;){if(n===null)return;var o=n.tag;if(o===3||o===4){var l=n.stateNode.containerInfo;if(l===a||l.nodeType===8&&l.parentNode===a)break;if(o===4)for(o=n.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===a||c.nodeType===8&&c.parentNode===a))return;o=o.return}for(;l!==null;){if(o=Fl(l),o===null)return;if(c=o.tag,c===5||c===6){n=i=o;continue e}l=l.parentNode}}n=n.return}Rk(function(){var d=i,m=A1(r),h=[];e:{var f=c5.get(e);if(f!==void 0){var p=I1,x=e;switch(e){case"keypress":if(Xp(r)===0)break e;case"keydown":case"keyup":p=iO;break;case"focusin":x="focus",p=xy;break;case"focusout":x="blur",p=xy;break;case"beforeblur":case"afterblur":p=xy;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=T_;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=YM;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=cO;break;case a5:case i5:case o5:p=XM;break;case l5:p=uO;break;case"scroll":p=WM;break;case"wheel":p=hO;break;case"copy":case"cut":case"paste":p=JM;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=R_}var g=(s&4)!==0,b=!g&&e==="scroll",w=g?f!==null?f+"Capture":null:f;g=[];for(var j=d,y;j!==null;){y=j;var v=y.stateNode;if(y.tag===5&&v!==null&&(y=v,w!==null&&(v=sh(j,w),v!=null&&g.push(ch(j,v,y)))),b)break;j=j.return}0<g.length&&(f=new p(f,x,null,r,m),h.push({event:f,listeners:g}))}}if(!(s&7)){e:{if(f=e==="mouseover"||e==="pointerover",p=e==="mouseout"||e==="pointerout",f&&r!==X0&&(x=r.relatedTarget||r.fromElement)&&(Fl(x)||x[Ui]))break e;if((p||f)&&(f=m.window===m?m:(f=m.ownerDocument)?f.defaultView||f.parentWindow:window,p?(x=r.relatedTarget||r.toElement,p=d,x=x?Fl(x):null,x!==null&&(b=Pc(x),x!==b||x.tag!==5&&x.tag!==6)&&(x=null)):(p=null,x=d),p!==x)){if(g=T_,v="onMouseLeave",w="onMouseEnter",j="mouse",(e==="pointerout"||e==="pointerover")&&(g=R_,v="onPointerLeave",w="onPointerEnter",j="pointer"),b=p==null?f:cd(p),y=x==null?f:cd(x),f=new g(v,j+"leave",p,r,m),f.target=b,f.relatedTarget=y,v=null,Fl(m)===d&&(g=new g(w,j+"enter",x,r,m),g.target=y,g.relatedTarget=b,v=g),b=v,p&&x)t:{for(g=p,w=x,j=0,y=g;y;y=Lc(y))j++;for(y=0,v=w;v;v=Lc(v))y++;for(;0<j-y;)g=Lc(g),j--;for(;0<y-j;)w=Lc(w),y--;for(;j--;){if(g===w||w!==null&&g===w.alternate)break t;g=Lc(g),w=Lc(w)}g=null}else g=null;p!==null&&H_(h,f,p,g,!1),x!==null&&b!==null&&H_(h,b,x,g,!0)}}
vendor: 4,242 bytes, lines 37-38
37e:{if(f=d?cd(d):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var N=bO;else if(I_(f))if(e5)N=_O;else{N=wO;var S=jO}else(p=f.nodeName)&&p.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(N=NO);if(N&&(N=N(e,d))){Jk(h,N,r,m);break e}S&&S(e,f,d),e==="focusout"&&(S=f._wrapperState)&&S.controlled&&f.type==="number"&&W0(f,"number",f.value)}switch(S=d?cd(d):window,e){case"focusin":(I_(S)||S.contentEditable==="true")&&(od=S,nb=d,Om=null);break;case"focusout":Om=nb=od=null;break;case"mousedown":ab=!0;break;case"contextmenu":case"mouseup":case"dragend":ab=!1,U_(h,r,m);break;case"selectionchange":if(kO)break;case"keydown":case"keyup":U_(h,r,m)}var k;if(L1)e:{switch(e){case"compositionstart":var $="onCompositionStart";break e;case"compositionend":$="onCompositionEnd";break e;case"compositionupdate":$="onCompositionUpdate";break e}$=void 0}else id?Xk(e,r)&&($="onCompositionEnd"):e==="keydown"&&r.keyCode===229&&($="onCompositionStart");$&&(Qk&&r.locale!=="ko"&&(id||$!=="onCompositionStart"?$==="onCompositionEnd"&&id&&(k=Kk()):(Oo=m,O1="value"in Oo?Oo.value:Oo.textContent,id=!0)),S=Sx(d,$),0<S.length&&($=new D_($,e,null,r,m),h.push({event:$,listeners:S}),k?$.data=k:(k=Zk(r),k!==null&&($.data=k)))),(k=pO?xO(e,r):gO(e,r))&&(d=Sx(d,"onBeforeInput"),0<d.length&&(m=new D_("onBeforeInput","beforeinput",null,r,m),h.push({event:m,listeners:d}),m.data=k))}d5(h,s)})}function ch(e,s,r){return{instance:e,listener:s,currentTarget:r}}function Sx(e,s){for(var r=s+"Capture",n=[];e!==null;){var a=e,i=a.stateNode;a.tag===5&&i!==null&&(a=i,i=sh(e,r),i!=null&&n.unshift(ch(e,i,a)),i=sh(e,s),i!=null&&n.push(ch(e,i,a))),e=e.return}return n}function Lc(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function H_(e,s,r,n,a){for(var i=s._reactName,o=[];r!==null&&r!==n;){var l=r,c=l.alternate,d=l.stateNode;if(c!==null&&c===n)break;l.tag===5&&d!==null&&(l=d,a?(c=sh(r,i),c!=null&&o.unshift(ch(r,c,l))):a||(c=sh(r,i),c!=null&&o.push(ch(r,c,l)))),r=r.return}o.length!==0&&e.push({event:s,listeners:o})}var AO=/\r\n?/g,TO=/\u0000|\uFFFD/g;function W_(e){return(typeof e=="string"?e:""+e).replace(AO,` 38`).replace(TO,"")}function pp(e,s,r){if(s=W_(s),W_(e)!==s&&r)throw Error(Ie(425))}function Cx(){}var ib=null,ob=null;function lb(e,s){return e==="textarea"||e==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var cb=typeof setTimeout=="function"?setTimeout:void 0,DO=typeof clearTimeout=="function"?clearTimeout:void 0,G_=typeof Promise=="function"?Promise:void 0,RO=typeof queueMicrotask=="function"?queueMicrotask:typeof G_<"u"?function(e){return G_.resolve(null).then(e).catch(MO)}:cb;function MO(e){setTimeout(function(){throw e})}function _y(e,s){var r=s,n=0;do{var a=r.nextSibling;if(e.removeChild(r),a&&a.nodeType===8)if(r=a.data,r==="/$"){if(n===0){e.removeChild(a),ah(s);return}n--}else r!=="$"&&r!=="$?"&&r!=="$!"||n++;r=a}while(r);ah(s)}function qo(e){for(;e!=null;e=e.nextSibling){var s=e.nodeType;if(s===1||s===3)break;if(s===8){if(s=e.data,s==="$"||s==="$!"||s==="$?")break;if(s==="/$")return null}}return e}function Y_(e){e=e.previousSibling;for(var s=0;e;){if(e.nodeType===8){var r=e.data;if(r==="$"||r==="$!"||r==="$?"){if(s===0)return e;s--}else r==="/$"&&s++}e=e.previousSibling}return null}var ju=Math.random().toString(36).slice(2),Xa="__reactFiber$"+ju,dh="__reactProps$"+ju,Ui="__reactContainer$"+ju,db="__reactEvents$"+ju,OO="__reactListeners$"+ju,IO="__reactHandles$"+ju;function Fl(e){var s=e[Xa];if(s)return s;for(var r=e.parentNode;r;){if(s=r[Ui]||r[Xa]){if(r=s.alternate,s.child!==null||r!==null&&r.child!==null)for(e=Y_(e);e!==null;){if(r=e[Xa])return r;e=Y_(e)}return s}e=r,r=e.parentNode}return null}function gf(e){return e=e[Xa]||e[Ui],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function cd(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Ie(33))}function Ug(e){return e[dh]||null}var ub=[],dd=-1;function hl(e){return{current:e}}function $s(e){0>dd||(e.current=ub[dd],ub[dd]=null,dd--)}function js(e,s){dd++,ub[dd]=e.current,e.current=s}var sl={},Br=hl(sl),wn=hl(!1),ac=sl;
vendor: 13,942 bytes, line 38
38function Kd(e,s){var r=e.type.contextTypes;if(!r)return sl;var n=e.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===s)return n.__reactInternalMemoizedMaskedChildContext;var a={},i;for(i in r)a[i]=s[i];return n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=a),a}function Nn(e){return e=e.childContextTypes,e!=null}function kx(){$s(wn),$s(Br)}function K_(e,s,r){if(Br.current!==sl)throw Error(Ie(168));js(Br,s),js(wn,r)}function m5(e,s,r){var n=e.stateNode;if(s=s.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var a in n)if(!(a in s))throw Error(Ie(108,jM(e)||"Unknown",a));return Vs({},r,n)}function $x(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||sl,ac=Br.current,js(Br,e),js(wn,wn.current),!0}function Q_(e,s,r){var n=e.stateNode;if(!n)throw Error(Ie(169));r?(e=m5(e,s,ac),n.__reactInternalMemoizedMergedChildContext=e,$s(wn),$s(Br),js(Br,e)):$s(wn),js(wn,r)}var Ai=null,Vg=!1,Sy=!1;function h5(e){Ai===null?Ai=[e]:Ai.push(e)}function FO(e){Vg=!0,h5(e)}function fl(){if(!Sy&&Ai!==null){Sy=!0;var e=0,s=ls;try{var r=Ai;for(ls=1;e<r.length;e++){var n=r[e];do n=n(!0);while(n!==null)}Ai=null,Vg=!1}catch(a){throw Ai!==null&&(Ai=Ai.slice(e+1)),Fk(T1,fl),a}finally{ls=s,Sy=!1}}return null}var ud=[],md=0,Ex=null,Px=0,ea=[],ta=0,ic=null,Mi=1,Oi="";function kl(e,s){ud[md++]=Px,ud[md++]=Ex,Ex=e,Px=s}function f5(e,s,r){ea[ta++]=Mi,ea[ta++]=Oi,ea[ta++]=ic,ic=e;var n=Mi;e=Oi;var a=32-Ea(n)-1;n&=~(1<<a),r+=1;var i=32-Ea(s)+a;if(30<i){var o=a-a%5;i=(n&(1<<o)-1).toString(32),n>>=o,a-=o,Mi=1<<32-Ea(s)+a|r<<a|n,Oi=i+e}else Mi=1<<i|r<<a|n,Oi=e}function z1(e){e.return!==null&&(kl(e,1),f5(e,1,0))}function U1(e){for(;e===Ex;)Ex=ud[--md],ud[md]=null,Px=ud[--md],ud[md]=null;for(;e===ic;)ic=ea[--ta],ea[ta]=null,Oi=ea[--ta],ea[ta]=null,Mi=ea[--ta],ea[ta]=null}var Mn=null,Rn=null,Ps=!1,Ca=null;function p5(e,s){var r=sa(5,null,null,0);r.elementType="DELETED",r.stateNode=s,r.return=e,s=e.deletions,s===null?(e.deletions=[r],e.flags|=16):s.push(r)}function X_(e,s){switch(e.tag){case 5:var r=e.type;return s=s.nodeType!==1||r.toLowerCase()!==s.nodeName.toLowerCase()?null:s,s!==null?(e.stateNode=s,Mn=e,Rn=qo(s.firstChild),!0):!1;case 6:return s=e.pendingProps===""||s.nodeType!==3?null:s,s!==null?(e.stateNode=s,Mn=e,Rn=null,!0):!1;case 13:return s=s.nodeType!==8?null:s,s!==null?(r=ic!==null?{id:Mi,overflow:Oi}:null,e.memoizedState={dehydrated:s,treeContext:r,retryLane:1073741824},r=sa(18,null,null,0),r.stateNode=s,r.return=e,e.child=r,Mn=e,Rn=null,!0):!1;default:return!1}}function mb(e){return(e.mode&1)!==0&&(e.flags&128)===0}function hb(e){if(Ps){var s=Rn;if(s){var r=s;if(!X_(e,s)){if(mb(e))throw Error(Ie(418));s=qo(r.nextSibling);var n=Mn;s&&X_(e,s)?p5(n,r):(e.flags=e.flags&-4097|2,Ps=!1,Mn=e)}}else{if(mb(e))throw Error(Ie(418));e.flags=e.flags&-4097|2,Ps=!1,Mn=e}}}function Z_(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Mn=e}function xp(e){if(e!==Mn)return!1;if(!Ps)return Z_(e),Ps=!0,!1;var s;if((s=e.tag!==3)&&!(s=e.tag!==5)&&(s=e.type,s=s!=="head"&&s!=="body"&&!lb(e.type,e.memoizedProps)),s&&(s=Rn)){if(mb(e))throw x5(),Error(Ie(418));for(;s;)p5(e,s),s=qo(s.nextSibling)}if(Z_(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Ie(317));e:{for(e=e.nextSibling,s=0;e;){if(e.nodeType===8){var r=e.data;if(r==="/$"){if(s===0){Rn=qo(e.nextSibling);break e}s--}else r!=="$"&&r!=="$!"&&r!=="$?"||s++}e=e.nextSibling}Rn=null}}else Rn=Mn?qo(e.stateNode.nextSibling):null;return!0}function x5(){for(var e=Rn;e;)e=qo(e.nextSibling)}function Qd(){Rn=Mn=null,Ps=!1}function V1(e){Ca===null?Ca=[e]:Ca.push(e)}var LO=Zi.ReactCurrentBatchConfig;function nm(e,s,r){if(e=r.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(r._owner){if(r=r._owner,r){if(r.tag!==1)throw Error(Ie(309));var n=r.stateNode}if(!n)throw Error(Ie(147,e));var a=n,i=""+e;return s!==null&&s.ref!==null&&typeof s.ref=="function"&&s.ref._stringRef===i?s.ref:(s=function(o){var l=a.refs;o===null?delete l[i]:l[i]=o},s._stringRef=i,s)}if(typeof e!="string")throw Error(Ie(284));if(!r._owner)throw Error(Ie(290,e))}return e}function gp(e,s){throw e=Object.prototype.toString.call(s),Error(Ie(31,e==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":e))}function J_(e){var s=e._init;return s(e._payload)}function g5(e){function s(w,j){if(e){var y=w.deletions;y===null?(w.deletions=[j],w.flags|=16):y.push(j)}}function r(w,j){if(!e)return null;for(;j!==null;)s(w,j),j=j.sibling;return null}function n(w,j){for(w=new Map;j!==null;)j.key!==null?w.set(j.key,j):w.set(j.index,j),j=j.sibling;return w}function a(w,j){return w=Yo(w,j),w.index=0,w.sibling=null,w}function i(w,j,y){return w.index=y,e?(y=w.alternate,y!==null?(y=y.index,y<j?(w.flags|=2,j):y):(w.flags|=2,j)):(w.flags|=1048576,j)}function o(w){return e&&w.alternate===null&&(w.flags|=2),w}function l(w,j,y,v){return j===null||j.tag!==6?(j=Ty(y,w.mode,v),j.return=w,j):(j=a(j,y),j.return=w,j)}function c(w,j,y,v){var N=y.type;return N===ad?m(w,j,y.props.children,v,y.key):j!==null&&(j.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===go&&J_(N)===j.type)?(v=a(j,y.props),v.ref=nm(w,j,y),v.return=w,v):(v=nx(y.type,y.key,y.props,null,w.mode,v),v.ref=nm(w,j,y),v.return=w,v)}function d(w,j,y,v){return j===null||j.tag!==4||j.stateNode.containerInfo!==y.containerInfo||j.stateNode.implementation!==y.implementation?(j=Dy(y,w.mode,v),j.return=w,j):(j=a(j,y.children||[]),j.return=w,j)}function m(w,j,y,v,N){return j===null||j.tag!==7?(j=tc(y,w.mode,v,N),j.return=w,j):(j=a(j,y),j.return=w,j)}function h(w,j,y){if(typeof j=="string"&&j!==""||typeof j=="number")return j=Ty(""+j,w.mode,y),j.return=w,j;if(typeof j=="object"&&j!==null){switch(j.$$typeof){case ip:return y=nx(j.type,j.key,j.props,null,w.mode,y),y.ref=nm(w,null,j),y.return=w,y;case nd:return j=Dy(j,w.mode,y),j.return=w,j;case go:var v=j._init;return h(w,v(j._payload),y)}if(jm(j)||Ju(j))return j=tc(j,w.mode,y,null),j.return=w,j;gp(w,j)}return null}function f(w,j,y,v){var N=j!==null?j.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return N!==null?null:l(w,j,""+y,v);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case ip:return y.key===N?c(w,j,y,v):null;case nd:return y.key===N?d(w,j,y,v):null;case go:return N=y._init,f(w,j,N(y._payload),v)}if(jm(y)||Ju(y))return N!==null?null:m(w,j,y,v,null);gp(w,y)}return null}function p(w,j,y,v,N){if(typeof v=="string"&&v!==""||typeof v=="number")return w=w.get(y)||null,l(j,w,""+v,N);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case ip:return w=w.get(v.key===null?y:v.key)||null,c(j,w,v,N);case nd:return w=w.get(v.key===null?y:v.key)||null,d(j,w,v,N);case go:var S=v._init;return p(w,j,y,S(v._payload),N)}if(jm(v)||Ju(v))return w=w.get(y)||null,m(j,w,v,N,null);gp(j,v)}return null}function x(w,j,y,v){for(var N=null,S=null,k=j,$=j=0,R=null;k!==null&&$<y.length;$++){k.index>$?(R=k,k=null):R=k.sibling;var A=f(w,k,y[$],v);if(A===null){k===null&&(k=R);break}e&&k&&A.alternate===null&&s(w,k),j=i(A,j,$),S===null?N=A:S.sibling=A,S=A,k=R}if($===y.length)return r(w,k),Ps&&kl(w,$),N;if(k===null){for(;$<y.length;$++)k=h(w,y[$],v),k!==null&&(j=i(k,j,$),S===null?N=k:S.sibling=k,S=k);return Ps&&kl(w,$),N}for(k=n(w,k);$<y.length;$++)R=p(k,w,$,y[$],v),R!==null&&(e&&R.alternate!==null&&k.delete(R.key===null?$:R.key),j=i(R,j,$),S===null?N=R:S.sibling=R,S=R);return e&&k.forEach(function(T){return s(w,T)}),Ps&&kl(w,$),N}function g(w,j,y,v){var N=Ju(y);if(typeof N!="function")throw Error(Ie(150));if(y=N.call(y),y==null)throw Error(Ie(151));for(var S=N=null,k=j,$=j=0,R=null,A=y.next();k!==null&&!A.done;$++,A=y.next()){k.index>$?(R=k,k=null):R=k.sibling;var T=f(w,k,A.value,v);if(T===null){k===null&&(k=R);break}e&&k&&T.alternate===null&&s(w,k),j=i(T,j,$),S===null?N=T:S.sibling=T,S=T,k=R}if(A.done)return r(w,k),Ps&&kl(w,$),N;if(k===null){for(;!A.done;$++,A=y.next())A=h(w,A.value,v),A!==null&&(j=i(A,j,$),S===null?N=A:S.sibling=A,S=A);return Ps&&kl(w,$),N}for(k=n(w,k);!A.done;$++,A=y.next())A=p(k,w,$,A.value,v),A!==null&&(e&&A.alternate!==null&&k.delete(A.key===null?$:A.key),j=i(A,j,$),S===null?N=A:S.sibling=A,S=A);return e&&k.forEach(function(P){return s(w,P)}),Ps&&kl(w,$),N}function b(w,j,y,v){if(typeof y=="object"&&y!==null&&y.type===ad&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case ip:e:{for(var N=y.key,S=j;S!==null;){if(S.key===N){if(N=y.type,N===ad){if(S.tag===7){r(w,S.sibling),j=a(S,y.props.children),j.return=w,w=j;break e}}else if(S.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===go&&J_(N)===S.type){r(w,S.sibling),j=a(S,y.props),j.ref=nm(w,S,y),j.return=w,w=j;break e}r(w,S);break}else s(w,S);S=S.sibling}y.type===ad?(j=tc(y.props.children,w.mode,v,y.key),j.return=w,w=j):(v=nx(y.type,y.key,y.props,null,w.mode,v),v.ref=nm(w,j,y),v.return=w,w=v)}return o(w);case nd:e:{for(S=y.key;j!==null;){if(j.key===S)if(j.tag===4&&j.stateNode.containerInfo===y.containerInfo&&j.stateNode.implementation===y.implementation){r(w,j.sibling),j=a(j,y.children||[]),j.return=w,w=j;break e}else{r(w,j);break}else s(w,j);j=j.sibling}j=Dy(y,w.mode,v),j.return=w,w=j}return o(w);case go:return S=y._init,b(w,j,S(y._payload),v)}if(jm(y))return x(w,j,y,v);if(Ju(y))return g(w,j,y,v);gp(w,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,j!==null&&j.tag===6?(r(w,j.sibling),j=a(j,y),j.return=w,w=j):(r(w,j),j=Ty(y,w.mode,v),j.return=w,w=j),o(w)):r(w,j)}return b}var Xd=g5(!0),v5=g5(!1),Ax=hl(null),Tx=null,hd=null,q1=null;function H1(){q1=hd=Tx=null}function W1(e){var s=Ax.current;$s(Ax),e._currentValue=s}function fb(e,s,r){for(;e!==null;){var n=e.alternate;if((e.childLanes&s)!==s?(e.childLanes|=s,n!==null&&(n.childLanes|=s)):n!==null&&(n.childLanes&s)!==s&&(n.childLanes|=s),e===r)break;e=e.return}}function Nd(e,s){Tx=e,q1=hd=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&s&&(vn=!0),e.firstContext=null)}function ca(e){var s=e._currentValue;if(q1!==e)if(e={context:e,memoizedValue:s,next:null},hd===null){if(Tx===null)throw Error(Ie(308));hd=e,Tx.dependencies={lanes:0,firstContext:e}}else hd=hd.next=e;return s}var Ll=null;function G1(e){Ll===null?Ll=[e]:Ll.push(e)}function y5(e,s,r,n){var a=s.interleaved;return a===null?(r.next=r,G1(s)):(r.next=a.next,a.next=r),s.interleaved=r,Vi(e,n)}function Vi(e,s){e.lanes|=s;var r=e.alternate;for(r!==null&&(r.lanes|=s),r=e,e=e.return;e!==null;)e.childLanes|=s,r=e.alternate,r!==null&&(r.childLanes|=s),r=e,e=e.return;return r.tag===3?r.stateNode:null}var vo=!1;function Y1(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function b5(e,s){e=e.updateQueue,s.updateQueue===e&&(s.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Fi(e,s){return{eventTime:e,lane:s,tag:0,payload:null,callback:null,next:null}}function Ho(e,s,r){var n=e.updateQueue;if(n===null)return null;if(n=n.shared,Yt&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,Vi(e,r)}return a=n.interleaved,a===null?(s.next=s,G1(n)):(s.next=a.next,a.next=s),n.interleaved=s,Vi(e,r)}function Zp(e,s,r){if(s=s.updateQueue,s!==null&&(s=s.shared,(r&4194240)!==0)){var n=s.lanes;n&=e.pendingLanes,r|=n,s.lanes=r,D1(e,r)}}function e4(e,s){var r=e.updateQueue,n=e.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var a=null,i=null;if(r=r.firstBaseUpdate,r!==null){do{var o={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};i===null?a=i=o:i=i.next=o,r=r.next}while(r!==null);i===null?a=i=s:i=i.next=s}else a=i=s;r={baseState:n.baseState,firstBaseUpdate:a,lastBaseUpdate:i,shared:n.shared,effects:n.effects},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=s:e.next=s,r.lastBaseUpdate=s}function Dx(e,s,r,n){var a=e.updateQueue;vo=!1;var i=a.firstBaseUpdate,o=a.lastBaseUpdate,l=a.shared.pending;if(l!==null){a.shared.pending=null;var c=l,d=c.next;c.next=null,o===null?i=d:o.next=d,o=c;var m=e.alternate;m!==null&&(m=m.updateQueue,l=m.lastBaseUpdate,l!==o&&(l===null?m.firstBaseUpdate=d:l.next=d,m.lastBaseUpdate=c))}if(i!==null){var h=a.baseState;o=0,m=d=c=null,l=i;do{var f=l.lane,p=l.eventTime;if((n&f)===f){m!==null&&(m=m.next={eventTime:p,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var x=e,g=l;switch(f=s,p=r,g.tag){case 1:if(x=g.payload,typeof x=="function"){h=x.call(p,h,f);break e}h=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=g.payload,f=typeof x=="function"?x.call(p,h,f):x,f==null)break e;h=Vs({},h,f);break e;case 2:vo=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,f=a.effects,f===null?a.effects=[l]:f.push(l))}else p={eventTime:p,lane:f,tag:l.tag,payload:l.payload,callback:l.callback,next:null},m===null?(d=m=p,c=h):m=m.next=p,o|=f;if(l=l.next,l===null){if(l=a.shared.pending,l===null)break;f=l,l=f.next,f.next=null,a.lastBaseUpdate=f,a.shared.pending=null}}while(!0);if(m===null&&(c=h),a.baseState=c,a.firstBaseUpdate=d,a.lastBaseUpdate=m,s=a.shared.interleaved,s!==null){a=s;do o|=a.lane,a=a.next;while(a!==s)}else i===null&&(a.shared.lanes=0);lc|=o,e.lanes=o,e.memoizedState=h}}function t4(e,s,r){if(e=s.effects,s.effects=null,e!==null)for(s=0;s<e.length;s++){var n=e[s],a=n.callback;if(a!==null){if(n.callback=null,n=r,typeof a!="function")throw Error(Ie(191,a));a.call(n)}}}var vf={},li=hl(vf),uh=hl(vf),mh=hl(vf);function Bl(e){if(e===vf)throw Error(Ie(174));return e}function K1(e,s){switch(js(mh,s),js(uh,e),js(li,vf),e=s.nodeType,e){case 9:case 11:s=(s=s.documentElement)?s.namespaceURI:Y0(null,"");break;default:e=e===8?s.parentNode:s,s=e.namespaceURI||null,e=e.tagName,s=Y0(s,e)}$s(li),js(li,s)}function Zd(){$s(li),$s(uh),$s(mh)}function j5(e){Bl(mh.current);var s=Bl(li.current),r=Y0(s,e.type);s!==r&&(js(uh,e),js(li,r))}
vendor: 8,642 bytes, line 38
38function Q1(e){uh.current===e&&($s(li),$s(uh))}var Os=hl(0);function Rx(e){for(var s=e;s!==null;){if(s.tag===13){var r=s.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||r.data==="$?"||r.data==="$!"))return s}else if(s.tag===19&&s.memoizedProps.revealOrder!==void 0){if(s.flags&128)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===e)break;for(;s.sibling===null;){if(s.return===null||s.return===e)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Cy=[];function X1(){for(var e=0;e<Cy.length;e++)Cy[e]._workInProgressVersionPrimary=null;Cy.length=0}var Jp=Zi.ReactCurrentDispatcher,ky=Zi.ReactCurrentBatchConfig,oc=0,zs=null,lr=null,gr=null,Mx=!1,Im=!1,hh=0,BO=0;function Dr(){throw Error(Ie(321))}function Z1(e,s){if(s===null)return!1;for(var r=0;r<s.length&&r<e.length;r++)if(!Ra(e[r],s[r]))return!1;return!0}function J1(e,s,r,n,a,i){if(oc=i,zs=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,Jp.current=e===null||e.memoizedState===null?qO:HO,e=r(n,a),Im){i=0;do{if(Im=!1,hh=0,25<=i)throw Error(Ie(301));i+=1,gr=lr=null,s.updateQueue=null,Jp.current=WO,e=r(n,a)}while(Im)}if(Jp.current=Ox,s=lr!==null&&lr.next!==null,oc=0,gr=lr=zs=null,Mx=!1,s)throw Error(Ie(300));return e}function ew(){var e=hh!==0;return hh=0,e}function Ga(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return gr===null?zs.memoizedState=gr=e:gr=gr.next=e,gr}function da(){if(lr===null){var e=zs.alternate;e=e!==null?e.memoizedState:null}else e=lr.next;var s=gr===null?zs.memoizedState:gr.next;if(s!==null)gr=s,lr=e;else{if(e===null)throw Error(Ie(310));lr=e,e={memoizedState:lr.memoizedState,baseState:lr.baseState,baseQueue:lr.baseQueue,queue:lr.queue,next:null},gr===null?zs.memoizedState=gr=e:gr=gr.next=e}return gr}function fh(e,s){return typeof s=="function"?s(e):s}function $y(e){var s=da(),r=s.queue;if(r===null)throw Error(Ie(311));r.lastRenderedReducer=e;var n=lr,a=n.baseQueue,i=r.pending;if(i!==null){if(a!==null){var o=a.next;a.next=i.next,i.next=o}n.baseQueue=a=i,r.pending=null}if(a!==null){i=a.next,n=n.baseState;var l=o=null,c=null,d=i;do{var m=d.lane;if((oc&m)===m)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),n=d.hasEagerState?d.eagerState:e(n,d.action);else{var h={lane:m,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=h,o=n):c=c.next=h,zs.lanes|=m,lc|=m}d=d.next}while(d!==null&&d!==i);c===null?o=n:c.next=l,Ra(n,s.memoizedState)||(vn=!0),s.memoizedState=n,s.baseState=o,s.baseQueue=c,r.lastRenderedState=n}if(e=r.interleaved,e!==null){a=e;do i=a.lane,zs.lanes|=i,lc|=i,a=a.next;while(a!==e)}else a===null&&(r.lanes=0);return[s.memoizedState,r.dispatch]}function Ey(e){var s=da(),r=s.queue;if(r===null)throw Error(Ie(311));r.lastRenderedReducer=e;var n=r.dispatch,a=r.pending,i=s.memoizedState;if(a!==null){r.pending=null;var o=a=a.next;do i=e(i,o.action),o=o.next;while(o!==a);Ra(i,s.memoizedState)||(vn=!0),s.memoizedState=i,s.baseQueue===null&&(s.baseState=i),r.lastRenderedState=i}return[i,n]}function w5(){}function N5(e,s){var r=zs,n=da(),a=s(),i=!Ra(n.memoizedState,a);if(i&&(n.memoizedState=a,vn=!0),n=n.queue,tw(C5.bind(null,r,n,e),[e]),n.getSnapshot!==s||i||gr!==null&&gr.memoizedState.tag&1){if(r.flags|=2048,ph(9,S5.bind(null,r,n,a,s),void 0,null),br===null)throw Error(Ie(349));oc&30||_5(r,s,a)}return a}function _5(e,s,r){e.flags|=16384,e={getSnapshot:s,value:r},s=zs.updateQueue,s===null?(s={lastEffect:null,stores:null},zs.updateQueue=s,s.stores=[e]):(r=s.stores,r===null?s.stores=[e]:r.push(e))}function S5(e,s,r,n){s.value=r,s.getSnapshot=n,k5(s)&&$5(e)}function C5(e,s,r){return r(function(){k5(s)&&$5(e)})}function k5(e){var s=e.getSnapshot;e=e.value;try{var r=s();return!Ra(e,r)}catch{return!0}}function $5(e){var s=Vi(e,1);s!==null&&Pa(s,e,1,-1)}function s4(e){var s=Ga();return typeof e=="function"&&(e=e()),s.memoizedState=s.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:fh,lastRenderedState:e},s.queue=e,e=e.dispatch=VO.bind(null,zs,e),[s.memoizedState,e]}function ph(e,s,r,n){return e={tag:e,create:s,destroy:r,deps:n,next:null},s=zs.updateQueue,s===null?(s={lastEffect:null,stores:null},zs.updateQueue=s,s.lastEffect=e.next=e):(r=s.lastEffect,r===null?s.lastEffect=e.next=e:(n=r.next,r.next=e,e.next=n,s.lastEffect=e)),e}function E5(){return da().memoizedState}function ex(e,s,r,n){var a=Ga();zs.flags|=e,a.memoizedState=ph(1|s,r,void 0,n===void 0?null:n)}function qg(e,s,r,n){var a=da();n=n===void 0?null:n;var i=void 0;if(lr!==null){var o=lr.memoizedState;if(i=o.destroy,n!==null&&Z1(n,o.deps)){a.memoizedState=ph(s,r,i,n);return}}zs.flags|=e,a.memoizedState=ph(1|s,r,i,n)}function r4(e,s){return ex(8390656,8,e,s)}function tw(e,s){return qg(2048,8,e,s)}function P5(e,s){return qg(4,2,e,s)}function A5(e,s){return qg(4,4,e,s)}function T5(e,s){if(typeof s=="function")return e=e(),s(e),function(){s(null)};if(s!=null)return e=e(),s.current=e,function(){s.current=null}}function D5(e,s,r){return r=r!=null?r.concat([e]):null,qg(4,4,T5.bind(null,s,e),r)}function sw(){}function R5(e,s){var r=da();s=s===void 0?null:s;var n=r.memoizedState;return n!==null&&s!==null&&Z1(s,n[1])?n[0]:(r.memoizedState=[e,s],e)}function M5(e,s){var r=da();s=s===void 0?null:s;var n=r.memoizedState;return n!==null&&s!==null&&Z1(s,n[1])?n[0]:(e=e(),r.memoizedState=[e,s],e)}function O5(e,s,r){return oc&21?(Ra(r,s)||(r=zk(),zs.lanes|=r,lc|=r,e.baseState=!0),s):(e.baseState&&(e.baseState=!1,vn=!0),e.memoizedState=r)}function zO(e,s){var r=ls;ls=r!==0&&4>r?r:4,e(!0);var n=ky.transition;ky.transition={};try{e(!1),s()}finally{ls=r,ky.transition=n}}function I5(){return da().memoizedState}function UO(e,s,r){var n=Go(e);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},F5(e))L5(s,r);else if(r=y5(e,s,r,n),r!==null){var a=Zr();Pa(r,e,n,a),B5(r,s,n)}}function VO(e,s,r){var n=Go(e),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(F5(e))L5(s,a);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=s.lastRenderedReducer,i!==null))try{var o=s.lastRenderedState,l=i(o,r);if(a.hasEagerState=!0,a.eagerState=l,Ra(l,o)){var c=s.interleaved;c===null?(a.next=a,G1(s)):(a.next=c.next,c.next=a),s.interleaved=a;return}}catch{}finally{}r=y5(e,s,a,n),r!==null&&(a=Zr(),Pa(r,e,n,a),B5(r,s,n))}}function F5(e){var s=e.alternate;return e===zs||s!==null&&s===zs}function L5(e,s){Im=Mx=!0;var r=e.pending;r===null?s.next=s:(s.next=r.next,r.next=s),e.pending=s}function B5(e,s,r){if(r&4194240){var n=s.lanes;n&=e.pendingLanes,r|=n,s.lanes=r,D1(e,r)}}var Ox={readContext:ca,useCallback:Dr,useContext:Dr,useEffect:Dr,useImperativeHandle:Dr,useInsertionEffect:Dr,useLayoutEffect:Dr,useMemo:Dr,useReducer:Dr,useRef:Dr,useState:Dr,useDebugValue:Dr,useDeferredValue:Dr,useTransition:Dr,useMutableSource:Dr,useSyncExternalStore:Dr,useId:Dr,unstable_isNewReconciler:!1},qO={readContext:ca,useCallback:function(e,s){return Ga().memoizedState=[e,s===void 0?null:s],e},useContext:ca,useEffect:r4,useImperativeHandle:function(e,s,r){return r=r!=null?r.concat([e]):null,ex(4194308,4,T5.bind(null,s,e),r)},useLayoutEffect:function(e,s){return ex(4194308,4,e,s)},useInsertionEffect:function(e,s){return ex(4,2,e,s)},useMemo:function(e,s){var r=Ga();return s=s===void 0?null:s,e=e(),r.memoizedState=[e,s],e},useReducer:function(e,s,r){var n=Ga();return s=r!==void 0?r(s):s,n.memoizedState=n.baseState=s,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:s},n.queue=e,e=e.dispatch=UO.bind(null,zs,e),[n.memoizedState,e]},useRef:function(e){var s=Ga();return e={current:e},s.memoizedState=e},useState:s4,useDebugValue:sw,useDeferredValue:function(e){return Ga().memoizedState=e},useTransition:function(){var e=s4(!1),s=e[0];return e=zO.bind(null,e[1]),Ga().memoizedState=e,[s,e]},useMutableSource:function(){},useSyncExternalStore:function(e,s,r){var n=zs,a=Ga();if(Ps){if(r===void 0)throw Error(Ie(407));r=r()}else{if(r=s(),br===null)throw Error(Ie(349));oc&30||_5(n,s,r)}a.memoizedState=r;var i={value:r,getSnapshot:s};return a.queue=i,r4(C5.bind(null,n,i,e),[e]),n.flags|=2048,ph(9,S5.bind(null,n,i,r,s),void 0,null),r},useId:function(){var e=Ga(),s=br.identifierPrefix;if(Ps){var r=Oi,n=Mi;r=(n&~(1<<32-Ea(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=hh++,0<r&&(s+="H"+r.toString(32)),s+=":"}else r=BO++,s=":"+s+"r"+r.toString(32)+":";return e.memoizedState=s},unstable_isNewReconciler:!1},HO={readContext:ca,useCallback:R5,useContext:ca,useEffect:tw,useImperativeHandle:D5,useInsertionEffect:P5,useLayoutEffect:A5,useMemo:M5,useReducer:$y,useRef
vendor: 6,411 bytes, lines 38-40
38:E5,useState:function(){return $y(fh)},useDebugValue:sw,useDeferredValue:function(e){var s=da();return O5(s,lr.memoizedState,e)},useTransition:function(){var e=$y(fh)[0],s=da().memoizedState;return[e,s]},useMutableSource:w5,useSyncExternalStore:N5,useId:I5,unstable_isNewReconciler:!1},WO={readContext:ca,useCallback:R5,useContext:ca,useEffect:tw,useImperativeHandle:D5,useInsertionEffect:P5,useLayoutEffect:A5,useMemo:M5,useReducer:Ey,useRef:E5,useState:function(){return Ey(fh)},useDebugValue:sw,useDeferredValue:function(e){var s=da();return lr===null?s.memoizedState=e:O5(s,lr.memoizedState,e)},useTransition:function(){var e=Ey(fh)[0],s=da().memoizedState;return[e,s]},useMutableSource:w5,useSyncExternalStore:N5,useId:I5,unstable_isNewReconciler:!1};function ba(e,s){if(e&&e.defaultProps){s=Vs({},s),e=e.defaultProps;for(var r in e)s[r]===void 0&&(s[r]=e[r]);return s}return s}function pb(e,s,r,n){s=e.memoizedState,r=r(n,s),r=r==null?s:Vs({},s,r),e.memoizedState=r,e.lanes===0&&(e.updateQueue.baseState=r)}var Hg={isMounted:function(e){return(e=e._reactInternals)?Pc(e)===e:!1},enqueueSetState:function(e,s,r){e=e._reactInternals;var n=Zr(),a=Go(e),i=Fi(n,a);i.payload=s,r!=null&&(i.callback=r),s=Ho(e,i,a),s!==null&&(Pa(s,e,a,n),Zp(s,e,a))},enqueueReplaceState:function(e,s,r){e=e._reactInternals;var n=Zr(),a=Go(e),i=Fi(n,a);i.tag=1,i.payload=s,r!=null&&(i.callback=r),s=Ho(e,i,a),s!==null&&(Pa(s,e,a,n),Zp(s,e,a))},enqueueForceUpdate:function(e,s){e=e._reactInternals;var r=Zr(),n=Go(e),a=Fi(r,n);a.tag=2,s!=null&&(a.callback=s),s=Ho(e,a,n),s!==null&&(Pa(s,e,n,r),Zp(s,e,n))}};function n4(e,s,r,n,a,i,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(n,i,o):s.prototype&&s.prototype.isPureReactComponent?!oh(r,n)||!oh(a,i):!0}function z5(e,s,r){var n=!1,a=sl,i=s.contextType;return typeof i=="object"&&i!==null?i=ca(i):(a=Nn(s)?ac:Br.current,n=s.contextTypes,i=(n=n!=null)?Kd(e,a):sl),s=new s(r,i),e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,s.updater=Hg,e.stateNode=s,s._reactInternals=e,n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=i),s}function a4(e,s,r,n){e=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(r,n),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(r,n),s.state!==e&&Hg.enqueueReplaceState(s,s.state,null)}function xb(e,s,r,n){var a=e.stateNode;a.props=r,a.state=e.memoizedState,a.refs={},Y1(e);var i=s.contextType;typeof i=="object"&&i!==null?a.context=ca(i):(i=Nn(s)?ac:Br.current,a.context=Kd(e,i)),a.state=e.memoizedState,i=s.getDerivedStateFromProps,typeof i=="function"&&(pb(e,s,i,r),a.state=e.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof a.getSnapshotBeforeUpdate=="function"||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(s=a.state,typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount(),s!==a.state&&Hg.enqueueReplaceState(a,a.state,null),Dx(e,r,a,n),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function Jd(e,s){try{var r="",n=s;do r+=bM(n),n=n.return;while(n);var a=r}catch(i){a=` 39Error generating stack: `+i.message+` 40`+i.stack}return{value:e,source:s,stack:a,digest:null}}function Py(e,s,r){return{value:e,source:null,stack:r??null,digest:s??null}}function gb(e,s){try{console.error(s.value)}catch(r){setTimeout(function(){throw r})}}var GO=typeof WeakMap=="function"?WeakMap:Map;function U5(e,s,r){r=Fi(-1,r),r.tag=3,r.payload={element:null};var n=s.value;return r.callback=function(){Fx||(Fx=!0,kb=n),gb(e,s)},r}function V5(e,s,r){r=Fi(-1,r),r.tag=3;var n=e.type.getDerivedStateFromError;if(typeof n=="function"){var a=s.value;r.payload=function(){return n(a)},r.callback=function(){gb(e,s)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(r.callback=function(){gb(e,s),typeof n!="function"&&(Wo===null?Wo=new Set([this]):Wo.add(this));var o=s.stack;this.componentDidCatch(s.value,{componentStack:o!==null?o:""})}),r}function i4(e,s,r){var n=e.pingCache;if(n===null){n=e.pingCache=new GO;var a=new Set;n.set(s,a)}else a=n.get(s),a===void 0&&(a=new Set,n.set(s,a));a.has(r)||(a.add(r),e=oI.bind(null,e,s,r),s.then(e,e))}function o4(e){do{var s;if((s=e.tag===13)&&(s=e.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return e;e=e.return}while(e!==null);return null}function l4(e,s,r,n,a){return e.mode&1?(e.flags|=65536,e.lanes=a,e):(e===s?e.flags|=65536:(e.flags|=128,r.flags|=131072,r.flags&=-52805,r.tag===1&&(r.alternate===null?r.tag=17:(s=Fi(-1,1),s.tag=2,Ho(r,s,1))),r.lanes|=1),e)}var YO=Zi.ReactCurrentOwner,vn=!1;function Yr(e,s,r,n){s.child=e===null?v5(s,null,r,n):Xd(s,e.child,r,n)}function c4(e,s,r,n,a){r=r.render;var i=s.ref;return Nd(s,a),n=J1(e,s,r,n,i,a),r=ew(),e!==null&&!vn?(s.updateQueue=e.updateQueue,s.flags&=-2053,e.lanes&=~a,qi(e,s,a)):(Ps&&r&&z1(s),s.flags|=1,Yr(e,s,n,a),s.child)}function d4(e,s,r,n,a){if(e===null){var i=r.type;return typeof i=="function"&&!dw(i)&&i.defaultProps===void 0&&r.compare===null&&r.defaultProps===void 0?(s.tag=15,s.type=i,q5(e,s,i,n,a)):(e=nx(r.type,null,n,s,s.mode,a),e.ref=s.ref,e.return=s,s.child=e)}if(i=e.child,!(e.lanes&a)){var o=i.memoizedProps;if(r=r.compare,r=r!==null?r:oh,r(o,n)&&e.ref===s.ref)return qi(e,s,a)}return s.flags|=1,e=Yo(i,n),e.ref=s.ref,e.return=s,s.child=e}function q5(e,s,r,n,a){if(e!==null){var i=e.memoizedProps;if(oh(i,n)&&e.ref===s.ref)if(vn=!1,s.pendingProps=n=i,(e.lanes&a)!==0)e.flags&131072&&(vn=!0);else return s.lanes=e.lanes,qi(e,s,a)}return vb(e,s,r,n,a)}function H5(e,s,r){var n=s.pendingProps,a=n.children,i=e!==null?e.memoizedState:null;if(n.mode==="hidden")if(!(s.mode&1))s.memoizedState={baseLanes:0,cachePool:null,transitions:null},js(pd,Tn),Tn|=r;else{if(!(r&1073741824))return e=i!==null?i.baseLanes|r:r,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:e,cachePool:null,transitions:null},s.updateQueue=null,js(pd,Tn),Tn|=e,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},n=i!==null?i.baseLanes:r,js(pd,Tn),Tn|=n}else i!==null?(n=i.baseLanes|r,s.memoizedState=null):n=r,js(pd,Tn),Tn|=n;return Yr(e,s,a,r),s.child}function W5(e,s){var r=s.ref;(e===null&&r!==null||e!==null&&e.ref!==r)&&(s.flags|=512,s.flags|=2097152)}
vendor: 8,776 bytes, line 40
40function vb(e,s,r,n,a){var i=Nn(r)?ac:Br.current;return i=Kd(s,i),Nd(s,a),r=J1(e,s,r,n,i,a),n=ew(),e!==null&&!vn?(s.updateQueue=e.updateQueue,s.flags&=-2053,e.lanes&=~a,qi(e,s,a)):(Ps&&n&&z1(s),s.flags|=1,Yr(e,s,r,a),s.child)}function u4(e,s,r,n,a){if(Nn(r)){var i=!0;$x(s)}else i=!1;if(Nd(s,a),s.stateNode===null)tx(e,s),z5(s,r,n),xb(s,r,n,a),n=!0;else if(e===null){var o=s.stateNode,l=s.memoizedProps;o.props=l;var c=o.context,d=r.contextType;typeof d=="object"&&d!==null?d=ca(d):(d=Nn(r)?ac:Br.current,d=Kd(s,d));var m=r.getDerivedStateFromProps,h=typeof m=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==n||c!==d)&&a4(s,o,n,d),vo=!1;var f=s.memoizedState;o.state=f,Dx(s,n,o,a),c=s.memoizedState,l!==n||f!==c||wn.current||vo?(typeof m=="function"&&(pb(s,r,m,n),c=s.memoizedState),(l=vo||n4(s,r,l,n,f,c,d))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(s.flags|=4194308)):(typeof o.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=n,s.memoizedState=c),o.props=n,o.state=c,o.context=d,n=l):(typeof o.componentDidMount=="function"&&(s.flags|=4194308),n=!1)}else{o=s.stateNode,b5(e,s),l=s.memoizedProps,d=s.type===s.elementType?l:ba(s.type,l),o.props=d,h=s.pendingProps,f=o.context,c=r.contextType,typeof c=="object"&&c!==null?c=ca(c):(c=Nn(r)?ac:Br.current,c=Kd(s,c));var p=r.getDerivedStateFromProps;(m=typeof p=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==h||f!==c)&&a4(s,o,n,c),vo=!1,f=s.memoizedState,o.state=f,Dx(s,n,o,a);var x=s.memoizedState;l!==h||f!==x||wn.current||vo?(typeof p=="function"&&(pb(s,r,p,n),x=s.memoizedState),(d=vo||n4(s,r,d,n,f,x,c)||!1)?(m||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(n,x,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(n,x,c)),typeof o.componentDidUpdate=="function"&&(s.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(s.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(s.flags|=1024),s.memoizedProps=n,s.memoizedState=x),o.props=n,o.state=x,o.context=c,n=d):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(s.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(s.flags|=1024),n=!1)}return yb(e,s,r,n,i,a)}function yb(e,s,r,n,a,i){W5(e,s);var o=(s.flags&128)!==0;if(!n&&!o)return a&&Q_(s,r,!1),qi(e,s,i);n=s.stateNode,YO.current=s;var l=o&&typeof r.getDerivedStateFromError!="function"?null:n.render();return s.flags|=1,e!==null&&o?(s.child=Xd(s,e.child,null,i),s.child=Xd(s,null,l,i)):Yr(e,s,l,i),s.memoizedState=n.state,a&&Q_(s,r,!0),s.child}function G5(e){var s=e.stateNode;s.pendingContext?K_(e,s.pendingContext,s.pendingContext!==s.context):s.context&&K_(e,s.context,!1),K1(e,s.containerInfo)}function m4(e,s,r,n,a){return Qd(),V1(a),s.flags|=256,Yr(e,s,r,n),s.child}var bb={dehydrated:null,treeContext:null,retryLane:0};function jb(e){return{baseLanes:e,cachePool:null,transitions:null}}function Y5(e,s,r){var n=s.pendingProps,a=Os.current,i=!1,o=(s.flags&128)!==0,l;if((l=o)||(l=e!==null&&e.memoizedState===null?!1:(a&2)!==0),l?(i=!0,s.flags&=-129):(e===null||e.memoizedState!==null)&&(a|=1),js(Os,a&1),e===null)return hb(s),e=s.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(s.mode&1?e.data==="$!"?s.lanes=8:s.lanes=1073741824:s.lanes=1,null):(o=n.children,e=n.fallback,i?(n=s.mode,i=s.child,o={mode:"hidden",children:o},!(n&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=Yg(o,n,0,null),e=tc(e,n,r,null),i.return=s,e.return=s,i.sibling=e,s.child=i,s.child.memoizedState=jb(r),s.memoizedState=bb,e):rw(s,o));if(a=e.memoizedState,a!==null&&(l=a.dehydrated,l!==null))return KO(e,s,o,n,l,a,r);if(i){i=n.fallback,o=s.mode,a=e.child,l=a.sibling;var c={mode:"hidden",children:n.children};return!(o&1)&&s.child!==a?(n=s.child,n.childLanes=0,n.pendingProps=c,s.deletions=null):(n=Yo(a,c),n.subtreeFlags=a.subtreeFlags&14680064),l!==null?i=Yo(l,i):(i=tc(i,o,r,null),i.flags|=2),i.return=s,n.return=s,n.sibling=i,s.child=n,n=i,i=s.child,o=e.child.memoizedState,o=o===null?jb(r):{baseLanes:o.baseLanes|r,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~r,s.memoizedState=bb,n}return i=e.child,e=i.sibling,n=Yo(i,{mode:"visible",children:n.children}),!(s.mode&1)&&(n.lanes=r),n.return=s,n.sibling=null,e!==null&&(r=s.deletions,r===null?(s.deletions=[e],s.flags|=16):r.push(e)),s.child=n,s.memoizedState=null,n}function rw(e,s){return s=Yg({mode:"visible",children:s},e.mode,0,null),s.return=e,e.child=s}function vp(e,s,r,n){return n!==null&&V1(n),Xd(s,e.child,null,r),e=rw(s,s.pendingProps.children),e.flags|=2,s.memoizedState=null,e}function KO(e,s,r,n,a,i,o){if(r)return s.flags&256?(s.flags&=-257,n=Py(Error(Ie(422))),vp(e,s,o,n)):s.memoizedState!==null?(s.child=e.child,s.flags|=128,null):(i=n.fallback,a=s.mode,n=Yg({mode:"visible",children:n.children},a,0,null),i=tc(i,a,o,null),i.flags|=2,n.return=s,i.return=s,n.sibling=i,s.child=n,s.mode&1&&Xd(s,e.child,null,o),s.child.memoizedState=jb(o),s.memoizedState=bb,i);if(!(s.mode&1))return vp(e,s,o,null);if(a.data==="$!"){if(n=a.nextSibling&&a.nextSibling.dataset,n)var l=n.dgst;return n=l,i=Error(Ie(419)),n=Py(i,n,void 0),vp(e,s,o,n)}if(l=(o&e.childLanes)!==0,vn||l){if(n=br,n!==null){switch(o&-o){case 4:a=2;break;case 16:a=8;break;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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=a&(n.suspendedLanes|o)?0:a,a!==0&&a!==i.retryLane&&(i.retryLane=a,Vi(e,a),Pa(n,e,a,-1))}return cw(),n=Py(Error(Ie(421))),vp(e,s,o,n)}return a.data==="$?"?(s.flags|=128,s.child=e.child,s=lI.bind(null,e),a._reactRetry=s,null):(e=i.treeContext,Rn=qo(a.nextSibling),Mn=s,Ps=!0,Ca=null,e!==null&&(ea[ta++]=Mi,ea[ta++]=Oi,ea[ta++]=ic,Mi=e.id,Oi=e.overflow,ic=s),s=rw(s,n.children),s.flags|=4096,s)}function h4(e,s,r){e.lanes|=s;var n=e.alternate;n!==null&&(n.lanes|=s),fb(e.return,s,r)}function Ay(e,s,r,n,a){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:n,tail:r,tailMode:a}:(i.isBackwards=s,i.rendering=null,i.renderingStartTime=0,i.last=n,i.tail=r,i.tailMode=a)}function K5(e,s,r){var n=s.pendingProps,a=n.revealOrder,i=n.tail;if(Yr(e,s,n.children,r),n=Os.current,n&2)n=n&1|2,s.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=s.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&h4(e,r,s);else if(e.tag===19)h4(e,r,s);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===s)break e;for(;e.sibling===null;){if(e.return===null||e.return===s)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}n&=1}if(js(Os,n),!(s.mode&1))s.memoizedState=null;else switch(a){case"forwards":for(r=s.child,a=null;r!==null;)e=r.alternate,e!==null&&Rx(e)===null&&(a=r),r=r.sibling;r=a,r===null?(a=s.child,s.child=null):(a=r.sibling,r.sibling=null),Ay(s,!1,a,r,i);break;case"backwards":for(r=null,a=s.child,s.child=null;a!==null;){if(e=a.alternate,e!==null&&Rx(e)===null){s.child=a;break}e=a.sibling,a.sibling=r,r=a,a=e}Ay(s,!0,r,null,i);break;case"together":Ay(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function tx(e,s){!(s.mode&1)&&e!==null&&(e.alternate=null,s.alternate=null,s.flags|=2)}function qi(e,s,r){if(e!==null&&(s.dependencies=e.dependencies),lc|=s.lanes,!(r&s.childLanes))return null;if(e!==null&&s.child!==e.child)throw Error(Ie(153));if(s.child!==null){for(e=s.child,r=Yo(e,e.pendingProps),s.child=r,r.return=s;e.sibling!==null;)e=e.sibling,r=r.sibling=Yo(e,e.pendingProps),r.return=s;r.sibling=null}return s.child}function QO(e,s,r){switch(s.tag){case 3:G5(s),Qd();break;case 5:j5(s);break;case 1:Nn(s.type)&&$x(s);break;case 4:K1(s,s.stateNode.containerInfo);break;case 10:var n=s.type._context,a=s.memoizedProps.value;js(Ax,n._currentValue),n._currentValue=a;break;case 13:if(n=s.memoizedState,n!==null)return n.dehydrated!==null?(js(Os,Os.current&1),s.flags|=128,null):r&s.child.childLanes?Y5(e,s,r):(js(Os,Os.current&1),e=q
vendor: 4,858 bytes, line 40
40i(e,s,r),e!==null?e.sibling:null);js(Os,Os.current&1);break;case 19:if(n=(r&s.childLanes)!==0,e.flags&128){if(n)return K5(e,s,r);s.flags|=128}if(a=s.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),js(Os,Os.current),n)break;return null;case 22:case 23:return s.lanes=0,H5(e,s,r)}return qi(e,s,r)}var Q5,wb,X5,Z5;Q5=function(e,s){for(var r=s.child;r!==null;){if(r.tag===5||r.tag===6)e.appendChild(r.stateNode);else if(r.tag!==4&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break;for(;r.sibling===null;){if(r.return===null||r.return===s)return;r=r.return}r.sibling.return=r.return,r=r.sibling}};wb=function(){};X5=function(e,s,r,n){var a=e.memoizedProps;if(a!==n){e=s.stateNode,Bl(li.current);var i=null;switch(r){case"input":a=q0(e,a),n=q0(e,n),i=[];break;case"select":a=Vs({},a,{value:void 0}),n=Vs({},n,{value:void 0}),i=[];break;case"textarea":a=G0(e,a),n=G0(e,n),i=[];break;default:typeof a.onClick!="function"&&typeof n.onClick=="function"&&(e.onclick=Cx)}K0(r,n);var o;r=null;for(d in a)if(!n.hasOwnProperty(d)&&a.hasOwnProperty(d)&&a[d]!=null)if(d==="style"){var l=a[d];for(o in l)l.hasOwnProperty(o)&&(r||(r={}),r[o]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(eh.hasOwnProperty(d)?i||(i=[]):(i=i||[]).push(d,null));for(d in n){var c=n[d];if(l=a!=null?a[d]:void 0,n.hasOwnProperty(d)&&c!==l&&(c!=null||l!=null))if(d==="style")if(l){for(o in l)!l.hasOwnProperty(o)||c&&c.hasOwnProperty(o)||(r||(r={}),r[o]="");for(o in c)c.hasOwnProperty(o)&&l[o]!==c[o]&&(r||(r={}),r[o]=c[o])}else r||(i||(i=[]),i.push(d,r)),r=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(eh.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&Cs("scroll",e),i||l===c||(i=[])):(i=i||[]).push(d,c))}r&&(i=i||[]).push("style",r);var d=i;(s.updateQueue=d)&&(s.flags|=4)}};Z5=function(e,s,r,n){r!==n&&(s.flags|=4)};function am(e,s){if(!Ps)switch(e.tailMode){case"hidden":s=e.tail;for(var r=null;s!==null;)s.alternate!==null&&(r=s),s=s.sibling;r===null?e.tail=null:r.sibling=null;break;case"collapsed":r=e.tail;for(var n=null;r!==null;)r.alternate!==null&&(n=r),r=r.sibling;n===null?s||e.tail===null?e.tail=null:e.tail.sibling=null:n.sibling=null}}function Rr(e){var s=e.alternate!==null&&e.alternate.child===e.child,r=0,n=0;if(s)for(var a=e.child;a!==null;)r|=a.lanes|a.childLanes,n|=a.subtreeFlags&14680064,n|=a.flags&14680064,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)r|=a.lanes|a.childLanes,n|=a.subtreeFlags,n|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=n,e.childLanes=r,s}function XO(e,s,r){var n=s.pendingProps;switch(U1(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Rr(s),null;case 1:return Nn(s.type)&&kx(),Rr(s),null;case 3:return n=s.stateNode,Zd(),$s(wn),$s(Br),X1(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(xp(s)?s.flags|=4:e===null||e.memoizedState.isDehydrated&&!(s.flags&256)||(s.flags|=1024,Ca!==null&&(Pb(Ca),Ca=null))),wb(e,s),Rr(s),null;case 5:Q1(s);var a=Bl(mh.current);if(r=s.type,e!==null&&s.stateNode!=null)X5(e,s,r,n,a),e.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!n){if(s.stateNode===null)throw Error(Ie(166));return Rr(s),null}if(e=Bl(li.current),xp(s)){n=s.stateNode,r=s.type;var i=s.memoizedProps;switch(n[Xa]=s,n[dh]=i,e=(s.mode&1)!==0,r){case"dialog":Cs("cancel",n),Cs("close",n);break;case"iframe":case"object":case"embed":Cs("load",n);break;case"video":case"audio":for(a=0;a<Nm.length;a++)Cs(Nm[a],n);break;case"source":Cs("error",n);break;case"img":case"image":case"link":Cs("error",n),Cs("load",n);break;case"details":Cs("toggle",n);break;case"input":w_(n,i),Cs("invalid",n);break;case"select":n._wrapperState={wasMultiple:!!i.multiple},Cs("invalid",n);break;case"textarea":__(n,i),Cs("invalid",n)}K0(r,i),a=null;for(var o in i)if(i.hasOwnProperty(o)){var l=i[o];o==="children"?typeof l=="string"?n.textContent!==l&&(i.suppressHydrationWarning!==!0&&pp(n.textContent,l,e),a=["children",l]):typeof l=="number"&&n.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&pp(n.textContent,l,e),a=["children",""+l]):eh.hasOwnProperty(o)&&l!=null&&o==="onScroll"&&Cs("scroll",n)}switch(r){case"input":op(n),N_(n,i,!0);break;case"textarea":op(n),S_(n);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(n.onclick=Cx)}n=a,s.updateQueue=n,n!==null&&(s.flags|=4)}else{o=a.nodeType===9?a:a.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Ck(r)),e==="http://www.w3.org/1999/xhtml"?r==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>
40",e=e.removeChild(e.firstChild)):typeof n.is=="string"?e=o.createElement(r,{is:n.is}):(e=o.createElement(r),r==="select"&&(o=e,n.multiple?o.multiple=!0:n.size&&(o.size=n.size))):e=o.createElementNS(e,r),e[Xa]=s,e[dh]=n,Q5(e,s,!1,!1),s.stateNode=e;e:{switch(o=Q0(r,n),r){case"dialog":Cs("cancel",e),Cs("close",e),a=n;break;case"iframe":case"object":case"embed":Cs("load",e),a=n;break;case"video":case"audio":for(a=0;a<Nm.length;a++)Cs(Nm[a],e);a=n;break;case"source":Cs("error",e),a=n;break;case"img":case"image":case"link":Cs("error",e),Cs("load",e),a=n;break;case"details":Cs("toggle",e),a=n;break;case"input":w_(e,n),a=q0(e,n),Cs("invalid",e);break;case"option":a=n;break;case"select":e._wrapperState={wasMultiple:!!n.multiple},a=Vs({},n,{value:void 0}),Cs("invalid",e);break;case"textarea":__(e,n),a=G0(e,n),Cs("invalid",e);break;default:a=n}K0(r,a),l=a;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?Ek(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&kk(e,c)):i==="children"?typeof c=="string"?(r!=="textarea"||c!=="")&&th(e,c):typeof c=="number"&&th(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(eh.hasOwnProperty(i)?c!=null&&i==="onScroll"&&Cs("scroll",e):c!=null&&k1(e,i,c,o))}switch(r){case"input":op(e),N_(e,n,!1);break;case"textarea":op(e),S_(e);break;case"option":n.value!=null&&e.setAttribute("value",""+tl(n.value));break;case"select":e.multiple=!!n.multiple,i=n.value,i!=null?yd(e,!!n.multiple,i,!1):n.defaultValue!=null&&yd(e,!!n.multiple,n.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=Cx)}switch(r){case"button":case"input":case"select":case"textarea":n=!!n.autoFocus;break e;case"img":n=!0;break e;default:n=!1}}n&&(s.flags|=4)}s.ref!==null&&(s.flags|=512,s.flags|=2097152)}return Rr(s),null;case 6:if(e&&s.stateNode!=null)Z5(e,s,e.memoizedProps,n);else{if(typeof n!="string"&&s.stateNode===null)throw Error(Ie(166));if(r=Bl(mh.current),Bl(li.current),xp(s)){if(n=s.stateNode,r=s.memoizedProps,n[Xa]=s,(i=n.nodeValue!==r)&&(e=Mn,e!==null))switch(e.tag){case 3:pp(n.nodeValue,r,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&pp(n.nodeValue,r,(e.mode&1)!==0)}i&&(s.flags|=4)}else n=(r.nodeType===9?r:r.ownerDocument).createTextNode(n),n[Xa]=s,s.stateNode=n}return Rr(s),null;case 13:if($s(Os),n=s.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ps&&Rn!==null&&s.mode&1&&!(s.flags&128))x5(),Qd(),s.flags|=98560,i=!1;else if(i=xp(s),n!==null&&n.dehydrated!==null){if(e===null){if(!i)throw Error(Ie(318));if(i=s.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(Ie(317));i[Xa]=s}else Qd(),!(s.flags&128)&&(s.memoizedState=null),s.flags|=4;Rr(s),i=!1}else Ca!==null&&(Pb(Ca),Ca=null),i=!0;if(!i)return s.flags&65536?s:null}return s.flags&128?(s.lanes=r,s):(n=n!==null,n!==(e!==null&&e.memoizedState!==null)&&n&&(s.child.flags|=8192,s.mode&1&&(e===null||Os.current&1?ur===0&&(ur=3):cw())),s.updateQueue!==null&&(s.flags|=4),Rr(s),null);case 4:return Zd(),wb(e,s),e===null&&lh(s.stateNode.containerInfo),Rr(s),null;case 10:return W1(s.type._context),Rr(s),null;case 17:return Nn(s.type)&&kx(),Rr(s),null;case 19:if($s(Os),i=s.memoizedState,i===null)return Rr(s),null;if(n=(s.flags&128)!==0,o=i.rendering,o===null)if(n)am(i,!1);else{if(ur!==0||e!==null&&e.flags&128)for(e=s.child;e!==null;){if(o=Rx(e),o!==null){for(s.flags|=128,am(i,!1),n=o.updateQueue,n!==null&&(s.updateQueue=n,s.flags|=4),s.subtreeFlags=0,n=r,r=s.child;r!==null;)i=r,e=n,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,e=o.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),r=r.sibling;return js(Os,Os.current&1|2),s.child}e=e.sibling}i.tail!==null&&Zs()>eu&&(s.flags|=128,n=!0,am(i,!1),s.lanes=4194304)}else{if(!n)if(e=Rx(o),e!==null){if(s.flags|=128,n=!0,r=e.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),am(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!Ps)return Rr(s),null}else 2*Zs()-i.renderingStartTime>eu&&r!==1073741824&&(s.flags|=128,n=!0,am(i,!1),s.lanes=4194304);i.isBackwards?(o.sibling=s.child,s.child=o):(r=i.last,r!==null?r.sibling=o:s.child=o,i.last=o)}return i.tail!==null?(s=i.tail,i.rendering=s,i.tail=s.sibling,i.renderingStartTime=Zs(),s.sibling=null,r=Os.current,js(Os,n?r&1|2:r&1),s):(Rr(s),null);case 22:case 23:return lw(),n=s.memoizedState!==null,e!==null&&e.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?Tn&1073741824&&(Rr(s),s.subtreeFlags&6&&(s.flags|=8192)):Rr(s),null;case 24:return null;case 25:return null}throw Error(Ie(156,s.tag))}function ZO(e,s){switch(U1(s),s.tag){case 1:return Nn(s.type)&&kx(),e=s.flags,e&65536?(s.flags=e&-65537|128,s):null;
vendor: 25,175 bytes, line 40
40case 3:return Zd(),$s(wn),$s(Br),X1(),e=s.flags,e&65536&&!(e&128)?(s.flags=e&-65537|128,s):null;case 5:return Q1(s),null;case 13:if($s(Os),e=s.memoizedState,e!==null&&e.dehydrated!==null){if(s.alternate===null)throw Error(Ie(340));Qd()}return e=s.flags,e&65536?(s.flags=e&-65537|128,s):null;case 19:return $s(Os),null;case 4:return Zd(),null;case 10:return W1(s.type._context),null;case 22:case 23:return lw(),null;case 24:return null;default:return null}}var yp=!1,Or=!1,JO=typeof WeakSet=="function"?WeakSet:Set,et=null;function fd(e,s){var r=e.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){Gs(e,s,n)}else r.current=null}function Nb(e,s,r){try{r()}catch(n){Gs(e,s,n)}}var f4=!1;function eI(e,s){if(ib=Nx,e=r5(),B1(e)){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{r=(r=e.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var a=n.anchorOffset,i=n.focusNode;n=n.focusOffset;try{r.nodeType,i.nodeType}catch{r=null;break e}var o=0,l=-1,c=-1,d=0,m=0,h=e,f=null;t:for(;;){for(var p;h!==r||a!==0&&h.nodeType!==3||(l=o+a),h!==i||n!==0&&h.nodeType!==3||(c=o+n),h.nodeType===3&&(o+=h.nodeValue.length),(p=h.firstChild)!==null;)f=h,h=p;for(;;){if(h===e)break t;if(f===r&&++d===a&&(l=o),f===i&&++m===n&&(c=o),(p=h.nextSibling)!==null)break;h=f,f=h.parentNode}h=p}r=l===-1||c===-1?null:{start:l,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(ob={focusedElem:e,selectionRange:r},Nx=!1,et=s;et!==null;)if(s=et,e=s.child,(s.subtreeFlags&1028)!==0&&e!==null)e.return=s,et=e;else for(;et!==null;){s=et;try{var x=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var g=x.memoizedProps,b=x.memoizedState,w=s.stateNode,j=w.getSnapshotBeforeUpdate(s.elementType===s.type?g:ba(s.type,g),b);w.__reactInternalSnapshotBeforeUpdate=j}break;case 3:var y=s.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ie(163))}}catch(v){Gs(s,s.return,v)}if(e=s.sibling,e!==null){e.return=s.return,et=e;break}et=s.return}return x=f4,f4=!1,x}function Fm(e,s,r){var n=s.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var a=n=n.next;do{if((a.tag&e)===e){var i=a.destroy;a.destroy=void 0,i!==void 0&&Nb(s,r,i)}a=a.next}while(a!==n)}}function Wg(e,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var r=s=s.next;do{if((r.tag&e)===e){var n=r.create;r.destroy=n()}r=r.next}while(r!==s)}}function _b(e){var s=e.ref;if(s!==null){var r=e.stateNode;switch(e.tag){case 5:e=r;break;default:e=r}typeof s=="function"?s(e):s.current=e}}function J5(e){var s=e.alternate;s!==null&&(e.alternate=null,J5(s)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(s=e.stateNode,s!==null&&(delete s[Xa],delete s[dh],delete s[db],delete s[OO],delete s[IO])),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 e$(e){return e.tag===5||e.tag===3||e.tag===4}function p4(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||e$(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 Sb(e,s,r){var n=e.tag;if(n===5||n===6)e=e.stateNode,s?r.nodeType===8?r.parentNode.insertBefore(e,s):r.insertBefore(e,s):(r.nodeType===8?(s=r.parentNode,s.insertBefore(e,r)):(s=r,s.appendChild(e)),r=r._reactRootContainer,r!=null||s.onclick!==null||(s.onclick=Cx));else if(n!==4&&(e=e.child,e!==null))for(Sb(e,s,r),e=e.sibling;e!==null;)Sb(e,s,r),e=e.sibling}function Cb(e,s,r){var n=e.tag;if(n===5||n===6)e=e.stateNode,s?r.insertBefore(e,s):r.appendChild(e);else if(n!==4&&(e=e.child,e!==null))for(Cb(e,s,r),e=e.sibling;e!==null;)Cb(e,s,r),e=e.sibling}var _r=null,Na=!1;function io(e,s,r){for(r=r.child;r!==null;)t$(e,s,r),r=r.sibling}function t$(e,s,r){if(oi&&typeof oi.onCommitFiberUnmount=="function")try{oi.onCommitFiberUnmount(Fg,r)}catch{}switch(r.tag){case 5:Or||fd(r,s);case 6:var n=_r,a=Na;_r=null,io(e,s,r),_r=n,Na=a,_r!==null&&(Na?(e=_r,r=r.stateNode,e.nodeType===8?e.parentNode.removeChild(r):e.removeChild(r)):_r.removeChild(r.stateNode));break;case 18:_r!==null&&(Na?(e=_r,r=r.stateNode,e.nodeType===8?_y(e.parentNode,r):e.nodeType===1&&_y(e,r),ah(e)):_y(_r,r.stateNode));break;case 4:n=_r,a=Na,_r=r.stateNode.containerInfo,Na=!0,io(e,s,r),_r=n,Na=a;break;case 0:case 11:case 14:case 15:if(!Or&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){a=n=n.next;do{var i=a,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&Nb(r,s,o),a=a.next}while(a!==n)}io(e,s,r);break;case 1:if(!Or&&(fd(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(l){Gs(r,s,l)}io(e,s,r);break;case 21:io(e,s,r);break;case 22:r.mode&1?(Or=(n=Or)||r.memoizedState!==null,io(e,s,r),Or=n):io(e,s,r);break;default:io(e,s,r)}}function x4(e){var s=e.updateQueue;if(s!==null){e.updateQueue=null;var r=e.stateNode;r===null&&(r=e.stateNode=new JO),s.forEach(function(n){var a=cI.bind(null,e,n);r.has(n)||(r.add(n),n.then(a,a))})}}function va(e,s){var r=s.deletions;if(r!==null)for(var n=0;n<r.length;n++){var a=r[n];try{var i=e,o=s,l=o;e:for(;l!==null;){switch(l.tag){case 5:_r=l.stateNode,Na=!1;break e;case 3:_r=l.stateNode.containerInfo,Na=!0;break e;case 4:_r=l.stateNode.containerInfo,Na=!0;break e}l=l.return}if(_r===null)throw Error(Ie(160));t$(i,o,a),_r=null,Na=!1;var c=a.alternate;c!==null&&(c.return=null),a.return=null}catch(d){Gs(a,s,d)}}if(s.subtreeFlags&12854)for(s=s.child;s!==null;)s$(s,e),s=s.sibling}function s$(e,s){var r=e.alternate,n=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(va(s,e),Ha(e),n&4){try{Fm(3,e,e.return),Wg(3,e)}catch(g){Gs(e,e.return,g)}try{Fm(5,e,e.return)}catch(g){Gs(e,e.return,g)}}break;case 1:va(s,e),Ha(e),n&512&&r!==null&&fd(r,r.return);break;case 5:if(va(s,e),Ha(e),n&512&&r!==null&&fd(r,r.return),e.flags&32){var a=e.stateNode;try{th(a,"")}catch(g){Gs(e,e.return,g)}}if(n&4&&(a=e.stateNode,a!=null)){var i=e.memoizedProps,o=r!==null?r.memoizedProps:i,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&_k(a,i),Q0(l,o);var d=Q0(l,i);for(o=0;o<c.length;o+=2){var m=c[o],h=c[o+1];m==="style"?Ek(a,h):m==="dangerouslySetInnerHTML"?kk(a,h):m==="children"?th(a,h):k1(a,m,h,d)}switch(l){case"input":H0(a,i);break;case"textarea":Sk(a,i);break;case"select":var f=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!i.multiple;var p=i.value;p!=null?yd(a,!!i.multiple,p,!1):f!==!!i.multiple&&(i.defaultValue!=null?yd(a,!!i.multiple,i.defaultValue,!0):yd(a,!!i.multiple,i.multiple?[]:"",!1))}a[dh]=i}catch(g){Gs(e,e.return,g)}}break;case 6:if(va(s,e),Ha(e),n&4){if(e.stateNode===null)throw Error(Ie(162));a=e.stateNode,i=e.memoizedProps;try{a.nodeValue=i}catch(g){Gs(e,e.return,g)}}break;case 3:if(va(s,e),Ha(e),n&4&&r!==null&&r.memoizedState.isDehydrated)try{ah(s.containerInfo)}catch(g){Gs(e,e.return,g)}break;case 4:va(s,e),Ha(e);break;case 13:va(s,e),Ha(e),a=e.child,a.flags&8192&&(i=a.memoizedState!==null,a.stateNode.isHidden=i,!i||a.alternate!==null&&a.alternate.memoizedState!==null||(iw=Zs())),n&4&&x4(e);break;case 22:if(m=r!==null&&r.memoizedState!==null,e.mode&1?(Or=(d=Or)||m,va(s,e),Or=d):va(s,e),Ha(e),n&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!m&&e.mode&1)for(et=e,m=e.child;m!==null;){for(h=et=m;et!==null;){switch(f=et,p=f.child,f.tag){case 0:case 11:case 14:case 15:Fm(4,f,f.return);break;case 1:fd(f,f.return);var x=f.stateNode;if(typeof x.componentWillUnmount=="function"){n=f,r=f.return;try{s=n,x.props=s.memoizedProps,x.state=s.memoizedState,x.componentWillUnmount()}catch(g){Gs(n,r,g)}}break;case 5:fd(f,f.return);break;case 22:if(f.memoizedState!==null){v4(h);continue}}p!==null?(p.return=f,et=p):v4(h)}m=m.sibling}e:for(m=null,h=e;;){if(h.tag===5){if(m===null){m=h;try{a=h.stateNode,d?(i=a.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=h.stateNode,c=h.memoizedProps.style,o=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=$k("display",o))}catch(g){Gs(e,e.return,g)}}}else if(h.tag===6){if(m===null)try{h.stateNode.nodeValue=d?"":h.memoizedProps}catch(g){Gs(e,e.return,g)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===e)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===e)break e;for(;h.sibling===null;){if(h.return===null||h.return===e)break e;m===h&&(m=null),h=h.return}m===h&&(m=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:va(s,e),Ha(e),n&4&&x4(e);break;case 21:break;default:va(s,e),Ha(e)}}function Ha(e){var s=e.flags;if(s&2){try{e:{for(var r=e.return;r!==null;){if(e$(r)){var n=r;break e}r=r.return}throw Error(Ie(160))}switch(n.tag){case 5:var a=n.stateNode;n.flags&32&&(th(a,""),n.flags&=-33);var i=p4(e);Cb(e,i,a);break;case 3:case 4:var o=n.stateNode.containerInfo,l=p4(e);Sb(e,l,o);break;default:throw Error(Ie(161))}}catch(c){Gs(e,e.return,c)}e.flags&=-3}s&4096&&(e.flags&=-4097)}function tI(e,s,r){et=e,r$(e)}function r$(e,s,r){for(var n=(e.mode&1)!==0;et!==null;){var a=et,i=a.child;if(a.tag===22&&n){var o=a.memoizedState!==null||yp;if(!o){var l=a.alternate,c=l!==null&&l.memoizedState!==null||Or;l=yp;var d=Or;if(yp=o,(Or=c)&&!d)for(et=a;et!==null;)o=et,c=o.child,o.tag===22&&o.memoizedState!==null?y4(a):c!==null?(c.return=o,et=c):y4(a);for(;i!==null;)et=i,r$(i),i=i.sibling;et=a,yp=l,Or=d}g4(e)}else a.subtreeFlags&8772&&i!==null?(i.return=a,et=i):g4(e)}}function g4(e){for(;et!==null;){var s=et;if(s.flags&8772){var r=s.alternate;try{if(s.flags&8772)switch(s.tag){case 0:case 11:case 15:Or||Wg(5,s);break;case 1:var n=s.stateNode;if(s.flags&4&&!Or)if(r===null)n.componentDidMount();else{var a=s.elementType===s.type?r.memoizedProps:ba(s.type,r.memoizedProps);n.componentDidUpdate(a,r.memoizedState,n.__reactInternalSnapshotBeforeUpdate)}var i=s.updateQueue;i!==null&&t4(s,i,n);break;case 3:var o=s.updateQueue;if(o!==null){if(r=null,s.child!==null)switch(s.child.tag){case 5:r=s.child.stateNode;break;case 1:r=s.child.stateNode}t4(s,o,r)}break;case 5:var l=s.stateNode;if(r===null&&s.flags&4){r=l;var c=s.memoizedProps;switch(s.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&r.focus();break;case"img":c.src&&(r.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(s.memoizedState===null){var d=s.alternate;if(d!==null){var m=d.memoizedState;if(m!==null){var h=m.dehydrated;h!==null&&ah(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ie(163))}Or||s.flags&512&&_b(s)}catch(f){Gs(s,s.return,f)}}if(s===e){et=null;break}if(r=s.sibling,r!==null){r.return=s.return,et=r;break}et=s.return}}function v4(e){for(;et!==null;){var s=et;if(s===e){et=null;break}var r=s.sibling;if(r!==null){r.return=s.return,et=r;break}et=s.return}}function y4(e){for(;et!==null;){var s=et;try{switch(s.tag){case 0:case 11:case 15:var r=s.return;try{Wg(4,s)}catch(c){Gs(s,r,c)}break;case 1:var n=s.stateNode;if(typeof n.componentDidMount=="function"){var a=s.return;try{n.componentDidMount()}catch(c){Gs(s,a,c)}}var i=s.return;try{_b(s)}catch(c){Gs(s,i,c)}break;case 5:var o=s.return;try{_b(s)}catch(c){Gs(s,o,c)}}}catch(c){Gs(s,s.return,c)}if(s===e){et=null;break}var l=s.sibling;if(l!==null){l.return=s.return,et=l;break}et=s.return}}var sI=Math.ceil,Ix=Zi.ReactCurrentDispatcher,nw=Zi.ReactCurrentOwner,na=Zi.ReactCurrentBatchConfig,Yt=0,br=null,nr=null,kr=0,Tn=0,pd=hl(0),ur=0,xh=null,lc=0,Gg=0,aw=0,Lm=null,xn=null,iw=0,eu=1/0,Ei=null,Fx=!1,kb=null,Wo=null,bp=!1,Io=null,Lx=0,Bm=0,$b=null,sx=-1,rx=0;function Zr(){return Yt&6?Zs():sx!==-1?sx:sx=Zs()}function Go(e){return e.mode&1?Yt&2&&kr!==0?kr&-kr:LO.transition!==null?(rx===0&&(rx=zk()),rx):(e=ls,e!==0||(e=window.event,e=e===void 0?16:Yk(e.type)),e):1}function Pa(e,s,r,n){if(50<Bm)throw Bm=0,$b=null,Error(Ie(185));pf(e,r,n),(!(Yt&2)||e!==br)&&(e===br&&(!(Yt&2)&&(Gg|=r),ur===4&&wo(e,kr)),_n(e,n),r===1&&Yt===0&&!(s.mode&1)&&(eu=Zs()+500,Vg&&fl()))}function _n(e,s){var r=e.callbackNode;LM(e,s);var n=wx(e,e===br?kr:0);if(n===0)r!==null&&$_(r),e.callbackNode=null,e.callbackPriority=0;else if(s=n&-n,e.callbackPriority!==s){if(r!=null&&$_(r),s===1)e.tag===0?FO(b4.bind(null,e)):h5(b4.bind(null,e)),RO(function(){!(Yt&6)&&fl()}),r=null;else{switch(Uk(n)){case 1:r=T1;break;case 4:r=Lk;break;case 16:r=jx;break;case 536870912:r=Bk;break;default:r=jx}r=u$(r,n$.bind(null,e))}e.callbackPriority=s,e.callbackNode=r}}function n$(e,s){if(sx=-1,rx=0,Yt&6)throw Error(Ie(327));var r=e.callbackNode;if(_d()&&e.callbackNode!==r)return null;var n=wx(e,e===br?kr:0);if(n===0)return null;if(n&30||n&e.expiredLanes||s)s=Bx(e,n);else{s=n;var a=Yt;Yt|=2;var i=i$();(br!==e||kr!==s)&&(Ei=null,eu=Zs()+500,ec(e,s));do try{aI();break}catch(l){a$(e,l)}while(!0);H1(),Ix.current=i,Yt=a,nr!==null?s=0:(br=null,kr=0,s=ur)}if(s!==0){if(s===2&&(a=tb(e),a!==0&&(n=a,s=Eb(e,a))),s===1)throw r=xh,ec(e,0),wo(e,n),_n(e,Zs()),r;if(s===6)wo(e,n);else{if(a=e.current.alternate,!(n&30)&&!rI(a)&&(s=Bx(e,n),s===2&&(i=tb(e),i!==0&&(n=i,s=Eb(e,i))),s===1))throw r=xh,ec(e,0),wo(e,n),_n(e,Zs()),r;switch(e.finishedWork=a,e.finishedLanes=n,s){case 0:case 1:throw Error(Ie(345));case 2:$l(e,xn,Ei);break;case 3:if(wo(e,n),(n&130023424)===n&&(s=iw+500-Zs(),10<s)){if(wx(e,0)!==0)break;if(a=e.suspendedLanes,(a&n)!==n){Zr(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=cb($l.bind(null,e,xn,Ei),s);break}$l(e,xn,Ei);break;case 4:if(wo(e,n),(n&4194240)===n)break;for(s=e.eventTimes,a=-1;0<n;){var o=31-Ea(n);i=1<<o,o=s[o],o>a&&(a=o),n&=~i}if(n=a,n=Zs()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*sI(n/1960))-n,10<n){e.timeoutHandle=cb($l.bind(null,e,xn,Ei),n);break}$l(e,xn,Ei);break;case 5:$l(e,xn,Ei);break;default:throw Error(Ie(329))}}}return _n(e,Zs()),e.callbackNode===r?n$.bind(null,e):null}function Eb(e,s){var r=Lm;return e.current.memoizedState.isDehydrated&&(ec(e,s).flags|=256),e=Bx(e,s),e!==2&&(s=xn,xn=r,s!==null&&Pb(s)),e}function Pb(e){xn===null?xn=e:xn.push.apply(xn,e)}function rI(e){for(var s=e;;){if(s.flags&16384){var r=s.updateQueue;if(r!==null&&(r=r.stores,r!==null))for(var n=0;n<r.length;n++){var a=r[n],i=a.getSnapshot;a=a.value;try{if(!Ra(i(),a))return!1}catch{return!1}}}if(r=s.child,s.subtreeFlags&16384&&r!==null)r.return=s,s=r;else{if(s===e)break;for(;s.sibling===null;){if(s.return===null||s.return===e)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function wo(e,s){for(s&=~aw,s&=~Gg,e.suspendedLanes|=s,e.pingedLanes&=~s,e=e.expirationTimes;0<s;){var r=31-Ea(s),n=1<<r;e[r]=-1,s&=~n}}function b4(e){if(Yt&6)throw Error(Ie(327));_d();var s=wx(e,0);if(!(s&1))return _n(e,Zs()),null;var r=Bx(e,s);if(e.tag!==0&&r===2){var n=tb(e);n!==0&&(s=n,r=Eb(e,n))}if(r===1)throw r=xh,ec(e,0),wo(e,s),_n(e,Zs()),r;if(r===6)throw Error(Ie(345));return e.finishedWork=e.current.alternate,e.finishedLanes=s,$l(e,xn,Ei),_n(e,Zs()),null}function ow(e,s){var r=Yt;Yt|=1;try{return e(s)}finally{Yt=r,Yt===0&&(eu=Zs()+500,Vg&&fl())}}function cc(e){Io!==null&&Io.tag===0&&!(Yt&6)&&_d();var s=Yt;Yt|=1;var r=na.transition,n=ls;try{if(na.transition=null,ls=1,e)return e()}finally{ls=n,na.transition=r,Yt=s,!(Yt&6)&&fl()}}function lw(){Tn=pd.current,$s(pd)}function ec(e,s){e.finishedWork=null,e.finishedLanes=0;var r=e.timeoutHandle;if(r!==-1&&(e.timeoutHandle=-1,DO(r)),nr!==null)for(r=nr.return;r!==null;){var n=r;switch(U1(n),n.tag){case 1:n=n.type.childContextTypes,n!=null&&kx();break;case 3:Zd(),$s(wn),$s(Br),X1();break;case 5:Q1(n);break;case 4:Zd();break;case 13:$s(Os);break;case 19:$s(Os);break;case 10:W1(n.type._context);break;case 22:case 23:lw()}r=r.return}if(br=e,nr=e=Yo(e.current,null),kr=Tn=s,ur=0,xh=null,aw=Gg=lc=0,xn=Lm=null,Ll!==null){for(s=0;s<Ll.length;s++)if(r=Ll[s],n=r.interleaved,n!==null){r.interleaved=null;var a=n.next,i=r.pending;if(i!==null){var o=i.next;i.next=a,n.next=o}r.pending=n}Ll=null}return e}function a$(e,s){do{var r=nr;try{if(H1(),Jp.current=Ox,Mx){for(var n=zs.memoizedState;n!==null;){var a=n.queue;a!==null&&(a.pending=null),n=n.next}Mx=!1}if(oc=0,gr=lr=zs=null,Im=!1,hh=0,nw.current=null,r===null||r.return===null){ur=1,xh=s,nr=null;break}e:{var i=e,o=r.return,l=r,c=s;if(s=kr,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,m=l,h=m.tag;if(!(m.mode&1)&&(h===0||h===11||h===15)){var f=m.alternate;f?(m.updateQueue=f.updateQueue,m.memoizedState=f.memoizedState,m.lanes=f.lanes):(m.updateQueue=null,m.memoizedState=null)}var p=o4(o);if(p!==null){p.flags&=-257,l4(p,o,l,i,s),p.mode&1&&i4(i,d,s),s=p,c=d;var x=s.updateQueue;if(x===null){var g=new Set;g.add(c),s.updateQueue=g}else x.add(c);break e}else{if(!(s&1)){i4(i,d,s),cw();break e}c=Error(Ie(426))}}else if(Ps&&l.mode&1){var b=o4(o);if(b!==null){!(b.flags&65536)&&(b.flags|=256),l4(b,o,l,i,s),V1(Jd(c,l));break e}}i=c=Jd(c,l),ur!==4&&(ur=2),Lm===null?Lm=[i]:Lm.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,s&=-s,i.lanes|=s;var w=U5(i,c,s);e4(i,w);break e;case 1:l=c;var j=i.type,y=i.stateNode;if(!(i.flags&128)&&(typeof j.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(Wo===null||!Wo.has(y)))){i.flags|=65536,s&=-s,i.lanes|=s;var v=V5(i,l,s);e4(i,v);break e}}i=i.return}while(i!==null)}l$(r)}catch(N){s=N,nr===r&&r!==null&&(nr=r=r.return);continue}break}while(!0)}function i$(){var e=Ix.current;return Ix.current=Ox,e===null?Ox:e}function cw(){(ur===0||ur===3||ur===2)&&(ur=4),br===null||!(lc&268435455)&&!(Gg&268435455)||wo(br,kr)}function Bx(e,s){var r=Yt;Yt|=2;var n=i$();(br!==e||kr!==s)&&(Ei=null,ec(e,s));do try{nI();break}catch(a){a$(e,a)}while(!0);if(H1(),Yt=r,Ix.current=n,nr!==null)throw Error(Ie(261));return br=null,kr=0,ur}function nI(){for(;nr!==null;)o$(nr)}function aI(){for(;nr!==null&&!PM();)o$(nr)}function o$(e){var s=d$(e.alternate,e,Tn);e.memoizedProps=e.pendingProps,s===null?l$(e):nr=s,nw.current=null}function l$(e){var s=e;do{var r=s.alternate;if(e=s.return,s.flags&32768){if(r=ZO(r,s),r!==null){r.flags&=32767,nr=r;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{ur=6,nr=null;return}}else if(r=XO(r,s,Tn),r!==null){nr=r;return}if(s=s.sibling,s!==null){nr=s;return}nr=s=e}while(s!==null);ur===0&&(ur=5)}function $l(e,s,r){var n=ls,a=na.transition;try{na.transition=null,ls=1,iI(e,s,r,n)}finally{na.transition=a,ls=n}return null}function iI(e,s,r,n){do _d();while(Io!==null);if(Yt&6)throw Error(Ie(327));r=e.finishedWork;var a=e.finishedLanes;if(r===null)return null;if(e.finishedWork=null,e.finishedLanes=0,r===e.current)throw Error(Ie(177));e.callbackNode=null,e.callbackPriority=0;var i=r.lanes|r.childLanes;if(BM(e,i),e===br&&(nr=br=null,kr=0),!(r.subtreeFlags&2064)&&!(r.flags&2064)||bp||(bp=!0,u$(jx,function(){return _d(),null})),i=(r.flags&15990)!==0,r.subtreeFlags&15990||i){i=na.transition,na.transition=null;var o=ls;ls=1;var l=Yt;Yt|=4,nw.current=null,eI(e,r),s$(r,e),CO(ob),Nx=!!ib,ob=ib=null,e.current=r,tI(r),AM(),Yt=l,ls=o,na.transition=i}else e.current=r;if(bp&&(bp=!1,Io=e,Lx=a),i=e.pendingLanes,i===0&&(Wo=null),RM(r.stateNode),_n(e,Zs()),s!==null)for(n=e.onRecoverableError,r=0;r<s.length;r++)a=s[r],n(a.value,{componentStack:a.stack,digest:a.digest});if(Fx)throw Fx=!1,e=kb,kb=null,e;return Lx&1&&e.tag!==0&&_d(),i=e.pendingLanes,i&1?e===$b?Bm++:(Bm=0,$b=e):Bm=0,fl(),null}function _d(){if(Io!==null){var e=Uk(Lx),s=na.transition,r=ls;try{if(na.transition=null,ls=16>e?16:e,Io===null)var n=!1;else{if(e=Io,Io=null,Lx=0,Yt&6)throw Error(Ie(331));var a=Yt;for(Yt|=4,et=e.current;et!==null;){var i=et,o=i.child;if(et.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(et=d;et!==null;){var m=et;switch(m.tag){case 0:case 11:case 15:Fm(8,m,i)}var h=m.child;if(h!==null)h.return=m,et=h;else for(;et!==null;){m=et;var f=m.sibling,p=m.return;if(J5(m),m===d){et=null;break}if(f!==null){f.return=p,et=f;break}et=p}}}var x=i.alternate;if(x!==null){var g=x.child;if(g!==null){x.child=null;do{var b=g.sibling;g.sibling=null,g=b}while(g!==null)}}et=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,et=o;else e:for(;et!==null;){if(i=et,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Fm(9,i,i.return)}var w=i.sibling;if(w!==null){w.return=i.return,et=w;break e}et=i.return}}var j=e.current;for(et=j;et!==null;){o=et;var y=o.child;if(o.subtreeFlags&2064&&y!==null)y.return=o,et=y;else e:for(o=j;et!==null;){if(l=et,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Wg(9,l)}}catch(N){Gs(l,l.return,N)}if(l===o){et=null;break e}var v=l.sibling;if(v!==null){v.return=l.return,et=v;break e}et=l.return}}if(Yt=a,fl(),oi&&typeof oi.onPostCommitFiberRoot=="function")try{oi.onPostCommitFiberRoot(Fg,e)}catch{}n=!0}return n}finally{ls=r,na.transition=s}}return!1}function j4(e,s,r){s=Jd(r,s),s=U5(e,s,1),e=Ho(e,s,1),s=Zr(),e!==null&&(pf(e,1,s),_n(e,s))}function Gs(e,s,r){if(e.tag===3)j4(e,e,r);else for(;s!==null;){if(s.tag===3){j4(s,e,r);break}else if(s.tag===1){var n=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(Wo===null||!Wo.has(n))){e=Jd(r,e),e=V5(s,e,1),s=Ho(s,e,1),e=Zr(),s!==null&&(pf(s,1,e),_n(s,e));break}}s=s.return}}function oI(e,s,r){var n=e.pingCache;n!==null&&n.delete(s),s=Zr(),e.pingedLanes|=e.suspendedLanes&r,br===e&&(kr&r)===r&&(ur===4||ur===3&&(kr&130023424)===kr&&500>Zs()-iw?ec(e,0):aw|=r),_n(e,s)}function c$(e,s){s===0&&(e.mode&1?(s=dp,dp<<=1,!(dp&130023424)&&(dp=4194304)):s=1);var r=Zr();e=Vi(e,s),e!==null&&(pf(e,s,r),_n(e,r))}function lI(e){var s=e.memoizedState,r=0;s!==null&&(r=s.retryLane),c$(e,r)}function cI(e,s){var r=0;switch(e.tag){case 13:var n=e.stateNode,a=e.memoizedState;a!==null&&(r=a.retryLane);break;case 19:n=e.stateNode;break;default:throw Error(Ie(314))}n!==null&&n.delete(s),c$(e,r)}var d$;d$=function(e,s,r){if(e!==null)if(e.memoizedProps!==s.pendingProps||wn.current)vn=!0;else{if(!(e.lanes&r)&&!(s.flags&128))return vn=!1,QO(e,s,r);vn=!!(e.flags&131072)}else vn=!1,Ps&&s.flags&1048576&&f5(s,Px,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;tx(e,s),e=s.pendingProps;var a=Kd(s,Br.current);Nd(s,r),a=J1(null,s,n,e,a,r);var i=ew();return s.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Nn(n)?(i=!0,$x(s)):i=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Y1(s),a.updater=Hg,s.stateNode=a,a._reactInternals=s,xb(s,n,e,r),s=yb(null,s,n,!0,i,r)):(s.tag=0,Ps&&i&&z1(s),Yr(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(tx(e,s),e=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=uI(n),e=ba(n,e),a){case 0:s=vb(null,s,n,e,r);break e;case 1:s=u4(null,s,n,e,r);break e;case 11:s=c4(null,s,n,e,r);break e;case 14:s=d4(null,s,n,ba(n.type,e),r);break e}throw Error(Ie(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:ba(n,a),vb(e,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:ba(n,a),u4(e,s,n,a,r);case 3:e:{if(G5(s),e===null)throw Error(Ie(387));n=s.pendingProps,i=s.memoizedState,a=i.element,b5(e,s),Dx(s,n,null,r);var o=s.memoizedState;if(n=o.element,i.isDehydrated)if(i={element:n,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},s.updateQueue.baseState=i,s.memoizedState=i,s.flags&256){a=Jd(Error(Ie(423)),s),s=m4(e,s,n,r,a);break e}else if(n!==a){a=Jd(Error(Ie(424)),s),s=m4(e,s,n,r,a);break e}else for(Rn=qo(s.stateNode.containerInfo.firstChild),Mn=s,Ps=!0,Ca=null,r=v5(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(Qd(),n===a){s=qi(e,s,r);break e}Yr(e,s,n,r)}s=s.child}return s;case 5:return j5(s),e===null&&hb(s),n=s.type,a=s.pendingProps,i=e!==null?e.memoizedProps:null,o=a.children,lb(n,a)?o=null:i!==null&&lb(n,i)&&(s.flags|=32),W5(e,s),Yr(e,s,o,r),s.child;case 6:return e===null&&hb(s),null;case 13:return Y5(e,s,r);case 4:return K1(s,s.stateNode.containerInfo),n=s.pendingProps,e===null?s.child=Xd(s,null,n,r):Yr(e,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:ba(n,a),c4(e,s,n,a,r);case 7:return Yr(e,s,s.pendingProps,r),s.child;case 8:return Yr(e,s,s.pendingProps.children,r),s.child;case 12:return Yr(e,s,s.pendingProps.children,r),s.child;case 10:e:{if(n=s.type._context,a=s.pendingProps,i=s.memoizedProps,o=a.value,js(Ax,n._currentValue),n._currentValue=o,i!==null)if(Ra(i.value,o)){if(i.children===a.children&&!wn.current){s=qi(e,s,r);break e}}else for(i=s.child,i!==null&&(i.return=s);i!==null;){var l=i.dependencies;if(l!==null){o=i.child;for(var c=l.firstContext;c!==null;){if(c.context===n){if(i.tag===1){c=Fi(-1,r&-r),c.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var m=d.pending;m===null?c.next=c:(c.next=m.next,m.next=c),d.pending=c}}i.lanes|=r,c=i.alternate,c!==null&&(c.lanes|=r),fb(i.return,r,s),l.lanes|=r;break}c=c.next}}else if(i.tag===10)o=i.type===s.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(Ie(341));
vendor: 9,803 bytes, line 40
40o.lanes|=r,l=o.alternate,l!==null&&(l.lanes|=r),fb(o,r,s),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===s){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}Yr(e,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,Nd(s,r),a=ca(a),n=n(a),s.flags|=1,Yr(e,s,n,r),s.child;case 14:return n=s.type,a=ba(n,s.pendingProps),a=ba(n.type,a),d4(e,s,n,a,r);case 15:return q5(e,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:ba(n,a),tx(e,s),s.tag=1,Nn(n)?(e=!0,$x(s)):e=!1,Nd(s,r),z5(s,n,a),xb(s,n,a,r),yb(null,s,n,!0,e,r);case 19:return K5(e,s,r);case 22:return H5(e,s,r)}throw Error(Ie(156,s.tag))};function u$(e,s){return Fk(e,s)}function dI(e,s,r,n){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function sa(e,s,r,n){return new dI(e,s,r,n)}function dw(e){return e=e.prototype,!(!e||!e.isReactComponent)}function uI(e){if(typeof e=="function")return dw(e)?1:0;if(e!=null){if(e=e.$$typeof,e===E1)return 11;if(e===P1)return 14}return 2}function Yo(e,s){var r=e.alternate;return r===null?(r=sa(e.tag,s,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=s,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&14680064,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,s=e.dependencies,r.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r}function nx(e,s,r,n,a,i){var o=2;if(n=e,typeof e=="function")dw(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case ad:return tc(r.children,a,i,s);case $1:o=8,a|=8;break;case B0:return e=sa(12,r,s,a|2),e.elementType=B0,e.lanes=i,e;case z0:return e=sa(13,r,s,a),e.elementType=z0,e.lanes=i,e;case U0:return e=sa(19,r,s,a),e.elementType=U0,e.lanes=i,e;case jk:return Yg(r,a,i,s);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case yk:o=10;break e;case bk:o=9;break e;case E1:o=11;break e;case P1:o=14;break e;case go:o=16,n=null;break e}throw Error(Ie(130,e==null?e:typeof e,""))}return s=sa(o,r,s,a),s.elementType=e,s.type=n,s.lanes=i,s}function tc(e,s,r,n){return e=sa(7,e,n,s),e.lanes=r,e}function Yg(e,s,r,n){return e=sa(22,e,n,s),e.elementType=jk,e.lanes=r,e.stateNode={isHidden:!1},e}function Ty(e,s,r){return e=sa(6,e,null,s),e.lanes=r,e}function Dy(e,s,r){return s=sa(4,e.children!==null?e.children:[],e.key,s),s.lanes=r,s.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},s}function mI(e,s,r,n,a){this.tag=s,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=hy(0),this.expirationTimes=hy(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hy(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function uw(e,s,r,n,a,i,o,l,c){return e=new mI(e,s,r,l,c),s===1?(s=1,i===!0&&(s|=8)):s=0,i=sa(3,null,null,s),e.current=i,i.stateNode=e,i.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},Y1(i),e}function hI(e,s,r){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:nd,key:n==null?null:""+n,children:e,containerInfo:s,implementation:r}}function m$(e){if(!e)return sl;e=e._reactInternals;e:{if(Pc(e)!==e||e.tag!==1)throw Error(Ie(170));var s=e;do{switch(s.tag){case 3:s=s.stateNode.context;break e;case 1:if(Nn(s.type)){s=s.stateNode.__reactInternalMemoizedMergedChildContext;break e}}s=s.return}while(s!==null);throw Error(Ie(171))}if(e.tag===1){var r=e.type;if(Nn(r))return m5(e,r,s)}return s}function h$(e,s,r,n,a,i,o,l,c){return e=uw(r,n,!0,e,a,i,o,l,c),e.context=m$(null),r=e.current,n=Zr(),a=Go(r),i=Fi(n,a),i.callback=s??null,Ho(r,i,a),e.current.lanes=a,pf(e,a,n),_n(e,n),e}function Kg(e,s,r,n){var a=s.current,i=Zr(),o=Go(a);return r=m$(r),s.context===null?s.context=r:s.pendingContext=r,s=Fi(i,o),s.payload={element:e},n=n===void 0?null:n,n!==null&&(s.callback=n),e=Ho(a,s,o),e!==null&&(Pa(e,a,o,i),Zp(e,a,o)),o}function zx(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function w4(e,s){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var r=e.retryLane;e.retryLane=r!==0&&r<s?r:s}}function mw(e,s){w4(e,s),(e=e.alternate)&&w4(e,s)}function fI(){return null}var f$=typeof reportError=="function"?reportError:function(e){console.error(e)};function hw(e){this._internalRoot=e}Qg.prototype.render=hw.prototype.render=function(e){var s=this._internalRoot;if(s===null)throw Error(Ie(409));Kg(e,s,null,null)};Qg.prototype.unmount=hw.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var s=e.containerInfo;cc(function(){Kg(null,e,null,null)}),s[Ui]=null}};function Qg(e){this._internalRoot=e}Qg.prototype.unstable_scheduleHydration=function(e){if(e){var s=Hk();e={blockedOn:null,target:e,priority:s};for(var r=0;r<jo.length&&s!==0&&s<jo[r].priority;r++);jo.splice(r,0,e),r===0&&Gk(e)}};function fw(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Xg(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function N4(){}function pI(e,s,r,n,a){if(a){if(typeof n=="function"){var i=n;n=function(){var d=zx(o);i.call(d)}}var o=h$(s,n,e,0,null,!1,!1,"",N4);return e._reactRootContainer=o,e[Ui]=o.current,lh(e.nodeType===8?e.parentNode:e),cc(),o}for(;a=e.lastChild;)e.removeChild(a);if(typeof n=="function"){var l=n;n=function(){var d=zx(c);l.call(d)}}var c=uw(e,0,!1,null,null,!1,!1,"",N4);return e._reactRootContainer=c,e[Ui]=c.current,lh(e.nodeType===8?e.parentNode:e),cc(function(){Kg(s,c,r,n)}),c}function Zg(e,s,r,n,a){var i=r._reactRootContainer;if(i){var o=i;if(typeof a=="function"){var l=a;a=function(){var c=zx(o);l.call(c)}}Kg(s,o,e,a)}else o=pI(r,s,e,a,n);return zx(o)}Vk=function(e){switch(e.tag){case 3:var s=e.stateNode;if(s.current.memoizedState.isDehydrated){var r=wm(s.pendingLanes);r!==0&&(D1(s,r|1),_n(s,Zs()),!(Yt&6)&&(eu=Zs()+500,fl()))}break;case 13:cc(function(){var n=Vi(e,1);if(n!==null){var a=Zr();Pa(n,e,1,a)}}),mw(e,1)}};R1=function(e){if(e.tag===13){var s=Vi(e,134217728);if(s!==null){var r=Zr();Pa(s,e,134217728,r)}mw(e,134217728)}};qk=function(e){if(e.tag===13){var s=Go(e),r=Vi(e,s);if(r!==null){var n=Zr();Pa(r,e,s,n)}mw(e,s)}};Hk=function(){return ls};Wk=function(e,s){var r=ls;try{return ls=e,s()}finally{ls=r}};Z0=function(e,s,r){switch(s){case"input":if(H0(e,r),s=r.name,r.type==="radio"&&s!=null){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll("input[name="+JSON.stringify(""+s)+'][type="radio"]'),s=0;s<r.length;s++){var n=r[s];if(n!==e&&n.form===e.form){var a=Ug(n);if(!a)throw Error(Ie(90));Nk(n),H0(n,a)}}}break;case"textarea":Sk(e,r);break;case"select":s=r.value,s!=null&&yd(e,!!r.multiple,s,!1)}};Tk=ow;Dk=cc;var xI={usingClientEntryPoint:!1,Events:[gf,cd,Ug,Pk,Ak,ow]},im={findFiberByHostInstance:Fl,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},gI={bundleType:im.bundleType,version:im.version,rendererPackageName:im.rendererPackageName,rendererConfig:im.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Zi.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Ok(e),e===null?null:e.stateNode},findFiberByHostInstance:im.findFiberByHostInstance||fI,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var jp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!jp.isDisabled&&jp.supportsFiber)try{Fg=jp.inject(gI),oi=jp}catch{}}Wn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=xI;Wn.createPortal=function(e,s){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!fw(s))throw Error(Ie(200));return hI(e,s,null,r)};Wn.createRoot=function(e,s){if(!fw(e))throw Error(Ie(299));var r=!1,n="",a=f$;return s!=null&&(s.unstable_strictMode===!0&&(r=!0),s.identifierPrefix!==void 0&&(n=s.identifierPrefix),s.onRecoverableError!==void 0&&(a=s.onRecoverableError)),s=uw(e,1,!1,null,null,r,!1,n,a),e[Ui]=s.current,lh(e.nodeType===8?e.parentNode:e),new hw(s)};Wn.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var s=e._reactInternals;if(s===void 0)throw typeof e.render=="function"?Error(Ie(188)):(e=Object.keys(e).join(","),Error(Ie(268,e)));return e=Ok(s),e=e===null?null:e.stateNode,e};Wn.flushSync=function(e){return cc(e)};Wn.hydrate=function(e,s,r){if(!Xg(s))throw Error(Ie(200));return Zg(null,e,s,!0,r)};Wn.hydrateRoot=function(e,s,r){if(!fw(e))throw Error(Ie(405));var n=r!=null&&r.hydratedSources||null,a=!1,i="",o=f$;if(r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(i=r.identifierPrefix),r.onRecoverableError!==void 0&&(o=r.onRecoverableError)),s=h$(s,null,e,1,r??null,a,
40!1,i,o),e[Ui]=s.current,lh(e),n)for(e=0;e<n.length;e++)r=n[e],a=r._getVersion,a=a(r._source),s.mutableSourceEagerHydrationData==null?s.mutableSourceEagerHydrationData=[r,a]:s.mutableSourceEagerHydrationData.push(r,a);return new Qg(s)};Wn.render=function(e,s,r){if(!Xg(s))throw Error(Ie(200));return Zg(null,e,s,!1,r)};Wn.unmountComponentAtNode=function(e){if(!Xg(e))throw Error(Ie(40));return e._reactRootContainer?(cc(function(){Zg(null,null,e,!1,function(){e._reactRootContainer=null,e[Ui]=null})}),!0):!1};Wn.unstable_batchedUpdates=ow;Wn.unstable_renderSubtreeIntoContainer=function(e,s,r,n){if(!Xg(r))throw Error(Ie(200));if(e==null||e._reactInternals===void 0)throw Error(Ie(38));return Zg(e,s,r,!1,n)};Wn.version="18.3.1-next-f1338f8080-20240426";function p$(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(p$)}catch(e){console.error(e)}}p$(),pk.exports=Wn;var yn=pk.exports;const Jg=rk(yn);var x$,_4=yn;x$=_4.createRoot,_4.hydrateRoot;var wu=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(){}},dc=typeof window>"u"||"Deno"in globalThis;function Kr(){}function vI(e,s){return typeof e=="function"?e(s):e}function Ab(e){return typeof e=="number"&&e>=0&&e!==1/0}function g$(e,s){return Math.max(e+(s||0)-Date.now(),0)}function Ko(e,s){return typeof e=="function"?e(s):e}function Xn(e,s){return typeof e=="function"?e(s):e}function S4(e,s){const{type:r="all",exact:n,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(n){if(s.queryHash!==pw(o,s.options))return!1}else if(!gh(s.queryKey,o))return!1}if(r!=="all"){const c=s.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&s.isStale()!==l||a&&a!==s.state.fetchStatus||i&&!i(s))}function C4(e,s){const{exact:r,status:n,predicate:a,mutationKey:i}=e;if(i){if(!s.options.mutationKey)return!1;if(r){if(uc(s.options.mutationKey)!==uc(i))return!1}else if(!gh(s.options.mutationKey,i))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function pw(e,s){return((s==null?void 0:s.queryKeyHashFn)||uc)(e)}function uc(e){return JSON.stringify(e,(s,r)=>Tb(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function gh(e,s){return e===s?!0:typeof e!=typeof s?!1:e&&s&&typeof e=="object"&&typeof s=="object"?Object.keys(s).every(r=>gh(e[r],s[r])):!1}function v$(e,s){if(e===s)return e;const r=k4(e)&&k4(s);if(r||Tb(e)&&Tb(s)){const n=r?e:Object.keys(e),a=n.length,i=r?s:Object.keys(s),o=i.length,l=r?[]:{},c=new Set(n);let d=0;for(let m=0;m<o;m++){const h=r?m:i[m];(!r&&c.has(h)||r)&&e[h]===void 0&&s[h]===void 0?(l[h]=void 0,d++):(l[h]=v$(e[h],s[h]),l[h]===e[h]&&e[h]!==void 0&&d++)}return a===o&&d===a?e:l}return s}function Ux(e,s){if(!s||Object.keys(e).length!==Object.keys(s).length)return!1;for(const r in e)if(e[r]!==s[r])return!1;return!0}function k4(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Tb(e){if(!$4(e))return!1;const s=e.constructor;if(s===void 0)return!0;const r=s.prototype;return!(!$4(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function $4(e){return Object.prototype.toString.call(e)==="[object Object]"}function yI(e){return new Promise(s=>{setTimeout(s,e)})}function Db(e,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,s):r.structuralSharing!==!1?v$(e,s):s}function bI(e,s,r=0){const n=[...e,s];return r&&n.length>r?n.slice(1):n}function jI(e,s,r=0){const n=[s,...e];return r&&n.length>r?n.slice(0,-1):n}var xw=Symbol();function y$(e,s){return!e.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!e.queryFn||e.queryFn===xw?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function b$(e,s){return typeof e=="function"?e(...s):!!e}var Hl,Co,Od,GC,wI=(GC=class extends wu{constructor(){super();ct(this,Hl);ct(this,Co);ct(this,Od);Qe(this,Od,s=>
vendor: 14,768 bytes, line 40
40{if(!dc&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){ne(this,Co)||this.setEventListener(ne(this,Od))}onUnsubscribe(){var s;this.hasListeners()||((s=ne(this,Co))==null||s.call(this),Qe(this,Co,void 0))}setEventListener(s){var r;Qe(this,Od,s),(r=ne(this,Co))==null||r.call(this),Qe(this,Co,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){ne(this,Hl)!==s&&(Qe(this,Hl,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof ne(this,Hl)=="boolean"?ne(this,Hl):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},Hl=new WeakMap,Co=new WeakMap,Od=new WeakMap,GC),gw=new wI,Id,ko,Fd,YC,NI=(YC=class extends wu{constructor(){super();ct(this,Id,!0);ct(this,ko);ct(this,Fd);Qe(this,Fd,s=>{if(!dc&&window.addEventListener){const r=()=>s(!0),n=()=>s(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){ne(this,ko)||this.setEventListener(ne(this,Fd))}onUnsubscribe(){var s;this.hasListeners()||((s=ne(this,ko))==null||s.call(this),Qe(this,ko,void 0))}setEventListener(s){var r;Qe(this,Fd,s),(r=ne(this,ko))==null||r.call(this),Qe(this,ko,s(this.setOnline.bind(this)))}setOnline(s){ne(this,Id)!==s&&(Qe(this,Id,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return ne(this,Id)}},Id=new WeakMap,ko=new WeakMap,Fd=new WeakMap,YC),Vx=new NI;function Rb(){let e,s;const r=new Promise((a,i)=>{e=a,s=i});r.status="pending",r.catch(()=>{});function n(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{n({status:"fulfilled",value:a}),e(a)},r.reject=a=>{n({status:"rejected",reason:a}),s(a)},r}function _I(e){return Math.min(1e3*2**e,3e4)}function j$(e){return(e??"online")==="online"?Vx.isOnline():!0}var w$=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Ry(e){return e instanceof w$}function N$(e){let s=!1,r=0,n=!1,a;const i=Rb(),o=g=>{var b;n||(f(new w$(g)),(b=e.abort)==null||b.call(e))},l=()=>{s=!0},c=()=>{s=!1},d=()=>gw.isFocused()&&(e.networkMode==="always"||Vx.isOnline())&&e.canRun(),m=()=>j$(e.networkMode)&&e.canRun(),h=g=>{var b;n||(n=!0,(b=e.onSuccess)==null||b.call(e,g),a==null||a(),i.resolve(g))},f=g=>{var b;n||(n=!0,(b=e.onError)==null||b.call(e,g),a==null||a(),i.reject(g))},p=()=>new Promise(g=>{var b;a=w=>{(n||d())&&g(w)},(b=e.onPause)==null||b.call(e)}).then(()=>{var g;a=void 0,n||(g=e.onContinue)==null||g.call(e)}),x=()=>{if(n)return;let g;const b=r===0?e.initialPromise:void 0;try{g=b??e.fn()}catch(w){g=Promise.reject(w)}Promise.resolve(g).then(h).catch(w=>{var S;if(n)return;const j=e.retry??(dc?0:3),y=e.retryDelay??_I,v=typeof y=="function"?y(r,w):y,N=j===!0||typeof j=="number"&&r<j||typeof j=="function"&&j(r,w);if(s||!N){f(w);return}r++,(S=e.onFail)==null||S.call(e,r,w),yI(v).then(()=>d()?void 0:p()).then(()=>{s?f(w):x()})})};return{promise:i,cancel:o,continue:()=>(a==null||a(),i),cancelRetry:l,continueRetry:c,canStart:m,start:()=>(m()?x():p().then(x),i)}}var SI=e=>setTimeout(e,0);function CI(){let e=[],s=0,r=l=>{l()},n=l=>{l()},a=SI;const i=l=>{s?e.push(l):a(()=>{r(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{n(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;s++;try{c=l()}finally{s--,s||o()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{n=l},setScheduler:l=>{a=l}}}var dr=CI(),Wl,KC,_$=(KC=class{constructor(){ct(this,Wl)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ab(this.gcTime)&&Qe(this,Wl,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(dc?1/0:5*60*1e3))}clearGcTimeout(){ne(this,Wl)&&(clearTimeout(ne(this,Wl)),Qe(this,Wl,void 0))}},Wl=new WeakMap,KC),Ld,Gl,Qn,Yl,Mr,df,Kl,ja,ki,QC,kI=(QC=class extends _${constructor(s){super();ct(this,ja);ct(this,Ld);ct(this,Gl);ct(this,Qn);ct(this,Yl);ct(this,Mr);ct(this,df);ct(this,Kl);Qe(this,Kl,!1),Qe(this,df,s.defaultOptions),this.setOptions(s.options),this.observers=[],Qe(this,Yl,s.client),Qe(this,Qn,ne(this,Yl).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,Qe(this,Ld,$I(this.options)),this.state=s.state??ne(this,Ld),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=ne(this,Mr))==null?void 0:s.promise}setOptions(s){this.options={...ne(this,df),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&ne(this,Qn).remove(this)}setData(s,r){const n=Db(this.state.data,s,this.options);return Ot(this,ja,ki).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(s,r){Ot(this,ja,ki).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=ne(this,Mr))==null?void 0:n.promise;return(a=ne(this,Mr))==null||a.cancel(s),r?r.then(Kr).catch(Kr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ne(this,Ld))}isActive(){return this.observers.some(s=>Xn(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===xw||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>Ko(s.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(s=>s.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(s=0){return this.state.data===void 0?!0:s==="static"?!1:this.state.isInvalidated?!0:!g$(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=ne(this,Mr))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=ne(this,Mr))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),ne(this,Qn).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(ne(this,Mr)&&(ne(this,Kl)?ne(this,Mr).cancel({revert:!0}):ne(this,Mr).cancelRetry()),this.scheduleGc()),ne(this,Qn).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ot(this,ja,ki).call(this,{type:"invalidate"})}fetch(s,r){var d,m,h;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(ne(this,Mr))return ne(this,Mr).continueRetry(),ne(this,Mr).promise}if(s&&this.setOptions(s),!this.options.queryFn){const f=this.observers.find(p=>p.options.queryFn);f&&this.setOptions(f.options)}const n=new AbortController,a=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(Qe(this,Kl,!0),n.signal)})},i=()=>{const f=y$(this.options,r),x=(()=>{const g={client:ne(this,Yl),queryKey:this.queryKey,meta:this.meta};return a(g),g})();return Qe(this,Kl,!1),this.options.persister?this.options.persister(f,x,this):f(x)},l=(()=>{const f={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:ne(this,Yl),state:this.state,fetchFn:i};return a(f),f})();(d=this.options.behavior)==null||d.onFetch(l,this),Qe(this,Gl,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((m=l.fetchOptions)==null?void 0:m.meta))&&Ot(this,ja,ki).call(this,{type:"fetch",meta:(h=l.fetchOptions)==null?void 0:h.meta});const c=f=>{var p,x,g,b;Ry(f)&&f.silent||Ot(this,ja,ki).call(this,{type:"error",error:f}),Ry(f)||((x=(p=ne(this,Qn).config).onError)==null||x.call(p,f,this),(b=(g=ne(this,Qn).config).onSettled)==null||b.call(g,this.state.data,f,this)),this.scheduleGc()};return Qe(this,Mr,N$({initialPromise:r==null?void 0:r.initialPromise,fn:l.fetchFn,abort:n.abort.bind(n),onSuccess:f=>{var p,x,g,b;if(f===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(f)}catch(w){c(w);return}(x=(p=ne(this,Qn).config).onSuccess)==null||x.call(p,f,this),(b=(g=ne(this,Qn).config).onSettled)==null||b.call(g,f,this.state.error,this),this.scheduleGc()},onError:c,onFail:(f,p)=>{Ot(this,ja,ki).call(this,{type:"failed",failureCount:f,error:p})},onPause:()=>{Ot(this,ja,ki).call(this,{type:"pause"})},onContinue:()=>{Ot(this,ja,ki).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0})),ne(this,Mr).start()}},Ld=new WeakMap,Gl=new WeakMap,Qn=new WeakMap,Yl=new WeakMap,Mr=new WeakMap,df=new WeakMap,Kl=new WeakMap,ja=new WeakSet,ki=function(s){const r=n=>{switch(s.type){case"failed":return{...n,fetchFailureCount:s.failureCount,fetchFailureReason:s.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...S$(n.data,this.options),fetchMeta:s.meta??null};case"success":return Qe(this,Gl,void 0),{...n,data:s.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:s.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!s.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const a=s.error;return Ry(a)&&a.revert&&ne(this,Gl)?{...ne(this,Gl),fetchStatus:"idle"}:{...n,error:a,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...s.state}}};this.state=r(this.state),dr.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),ne(this,Qn).notify({query:this,type:"updated",action:s})})},QC);function S$(e,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:j$(s.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function $I(e){const s=typeof e.initialData=="function"?e.initialData():e.initialData,r=s!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:s,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Ya,XC,EI=(XC=class extends wu{constructor(s={}){super();ct(this,Ya);this.config=s,Qe(this,Ya,new Map)}build(s,r,n){const a=r.queryKey,i=r.queryHash??pw(a,r);let o=this.get(i);return o||(o=new kI({client:s,queryKey:a,queryHash:i,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(o)),o}add(s){ne(this,Ya).has(s.queryHash)||(ne(this,Ya).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=ne(this,Ya).get(s.queryHash);r&&(s.destroy(),r===s&&ne(this,Ya).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){dr.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return ne(this,Ya).get(s)}getAll(){return[...ne(this,Ya).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>S4(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>S4(s,n)):r}notify(s){dr.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){dr.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){dr.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},Ya=new WeakMap,XC),Ka,Wr,Ql,Qa,mo,ZC,PI=(ZC=class extends _${constructor(s){super();ct(this,Qa);ct(this,Ka);ct(this,Wr);ct(this,Ql);this.mutationId=s.mutationId,Qe(this,Wr,s.mutationCache),Qe(this,Ka,[]),this.state=s.state||C$(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){ne(this,Ka).includes(s)||(ne(this,Ka).push(s),this.clearGcTimeout(),ne(this,Wr).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){Qe(this,Ka,ne(this,Ka).filter(r=>r!==s)),this.scheduleGc(),ne(this,Wr).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){ne(this,Ka).length||(this.state.status==="pending"?this.scheduleGc():ne(this,Wr).remove(this))}continue(){var s;return((s=ne(this,Ql))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var i,o,l,c,d,m,h,f,p,x,g,b,w,j,y,v,N,S,k,$;const r=()=>{Ot(this,Qa,mo).call(this,{type:"continue"})};Qe(this,Ql,N$({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:(R,A)=>{Ot(this,Qa,mo).call(this,{type:"failed",failureCount:R,error:A})},onPause:()=>{Ot(this,Qa,mo).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>ne(this,Wr).canRun(this)}));const n=this.state.status==="pending",a=!ne(this,Ql).canStart();try{if(n)r();else{Ot(this,Qa,mo).call(this,{type:"pending",variables:s,isPaused:a}),await((o=(i=ne(this,Wr).config).onMutate)==null?void 0:o.call(i,s,this));const A=await((c=(l=this.options).onMutate)==null?void 0:c.call(l,s));A!==this.state.context&&Ot(this,Qa,mo).call(this,{type:"pending",context:A,variables:s,isPaused:a})}const R=await ne(this,Ql).start();return await((m=(d=ne(this,Wr).config).onSuccess)==null?void 0:m.call(d,R,s,this.state.context,this)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,R,s,this.state.context)),await((x=(p=ne(this,Wr).config).onSettled)==null?void 0:x.call(p,R,null,this.state.variables,this.state.context,this)),await((b=(g=this.options).onSettled)==null?void 0:b.call(g,R,null,s,this.state.context)),Ot(this,Qa,mo).call(this,{type:"success",data:R}),R}catch(R){try{throw await((j=(w=ne(this,Wr).config).onError)==null?void 0:j.call(w,R,s,this.state.context,this)),await((v=(y=this.options).onError)==null?void 0:v.call(y,R,s,this.state.context)),await((S=(N=ne(this,Wr).config).onSettled)==null?void 0:S.call(N,void 0,R,this.state.variables,this.state.context,this)),await(($=(k=this.options).onSettled)==null?void 0:$.call(k,void 0,R,s,this.state.context)),R}finally{Ot(this,Qa,mo).call(this,{type:"error",error:R})}}finally{ne(this,Wr).runNext(this)}}},Ka=new WeakMap,Wr=new WeakMap,Ql=new WeakMap,Qa=new WeakSet,mo=function(s){const r=n=>{switch(s.type){case"failed":return{...n,failureCount:s.failureCount,failureReason:s.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};
40case"pending":return{...n,context:s.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:s.isPaused,status:"pending",variables:s.variables,submittedAt:Date.now()};case"success":return{...n,data:s.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:s.error,failureCount:n.failureCount+1,failureReason:s.error,isPaused:!1,status:"error"}}};this.state=r(this.state),dr.batch(()=>{ne(this,Ka).forEach(n=>{n.onMutationUpdate(s)}),ne(this,Wr).notify({mutation:this,type:"updated",action:s})})},ZC);function C$(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Di,wa,uf,JC,AI=(JC=class extends wu{constructor(s={}){super();ct(this,Di);ct(this,wa);ct(this,uf);this.config=s,Qe(this,Di,new Set),Qe(this,wa,new Map),Qe(this,uf,0)}build(s,r,n){const a=new PI({mutationCache:this,mutationId:++np(this,uf)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){ne(this,Di).add(s);const r=wp(s);if(typeof r=="string"){const n=ne(this,wa).get(r);n?n.push(s):ne(this,wa).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(ne(this,Di).delete(s)){const r=wp(s);if(typeof r=="string"){const n=ne(this,wa).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&ne(this,wa).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=wp(s);if(typeof r=="string"){const n=ne(this,wa).get(r),a=n==null?void 0:n.find(i=>i.state.status==="pending");return!a||a===s}else return!0}runNext(s){var n;const r=wp(s);if(typeof r=="string"){const a=(n=ne(this,wa).get(r))==null?void 0:n.find(i=>i!==s&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){dr.batch(()=>{ne(this,Di).forEach(s=>{this.notify({type:"removed",mutation:s})}),ne(this,Di).clear(),ne(this,wa).clear()})}getAll(){return Array.from(ne(this,Di))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>C4(r,n))}findAll(s={}){return this.getAll().filter(r=>C4(s,r))}notify(s){dr.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>
vendor: 16,518 bytes, line 40
40r.state.isPaused);return dr.batch(()=>Promise.all(s.map(r=>r.continue().catch(Kr))))}},Di=new WeakMap,wa=new WeakMap,uf=new WeakMap,JC);function wp(e){var s;return(s=e.options.scope)==null?void 0:s.id}function E4(e){return{onFetch:(s,r)=>{var m,h,f,p,x;const n=s.options,a=(f=(h=(m=s.fetchOptions)==null?void 0:m.meta)==null?void 0:h.fetchMore)==null?void 0:f.direction,i=((p=s.state.data)==null?void 0:p.pages)||[],o=((x=s.state.data)==null?void 0:x.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const d=async()=>{let g=!1;const b=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(s.signal.aborted?g=!0:s.signal.addEventListener("abort",()=>{g=!0}),s.signal)})},w=y$(s.options,s.fetchOptions),j=async(y,v,N)=>{if(g)return Promise.reject();if(v==null&&y.pages.length)return Promise.resolve(y);const k=(()=>{const T={client:s.client,queryKey:s.queryKey,pageParam:v,direction:N?"backward":"forward",meta:s.options.meta};return b(T),T})(),$=await w(k),{maxPages:R}=s.options,A=N?jI:bI;return{pages:A(y.pages,$,R),pageParams:A(y.pageParams,v,R)}};if(a&&i.length){const y=a==="backward",v=y?TI:P4,N={pages:i,pageParams:o},S=v(n,N);l=await j(N,S,y)}else{const y=e??i.length;do{const v=c===0?o[0]??n.initialPageParam:P4(n,l);if(c>0&&v==null)break;l=await j(l,v),c++}while(c<y)}return l};s.options.persister?s.fetchFn=()=>{var g,b;return(b=(g=s.options).persister)==null?void 0:b.call(g,d,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=d}}}function P4(e,{pages:s,pageParams:r}){const n=s.length-1;return s.length>0?e.getNextPageParam(s[n],s,r[n],r):void 0}function TI(e,{pages:s,pageParams:r}){var n;return s.length>0?(n=e.getPreviousPageParam)==null?void 0:n.call(e,s[0],s,r[0],r):void 0}var Ws,$o,Eo,Bd,zd,Po,Ud,Vd,ek,DI=(ek=class{constructor(e={}){ct(this,Ws);ct(this,$o);ct(this,Eo);ct(this,Bd);ct(this,zd);ct(this,Po);ct(this,Ud);ct(this,Vd);Qe(this,Ws,e.queryCache||new EI),Qe(this,$o,e.mutationCache||new AI),Qe(this,Eo,e.defaultOptions||{}),Qe(this,Bd,new Map),Qe(this,zd,new Map),Qe(this,Po,0)}mount(){np(this,Po)._++,ne(this,Po)===1&&(Qe(this,Ud,gw.subscribe(async e=>{e&&(await this.resumePausedMutations(),ne(this,Ws).onFocus())})),Qe(this,Vd,Vx.subscribe(async e=>{e&&(await this.resumePausedMutations(),ne(this,Ws).onOnline())})))}unmount(){var e,s;np(this,Po)._--,ne(this,Po)===0&&((e=ne(this,Ud))==null||e.call(this),Qe(this,Ud,void 0),(s=ne(this,Vd))==null||s.call(this),Qe(this,Vd,void 0))}isFetching(e){return ne(this,Ws).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return ne(this,$o).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const s=this.defaultQueryOptions({queryKey:e});return(r=ne(this,Ws).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const s=this.defaultQueryOptions(e),r=ne(this,Ws).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(Ko(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(e){return ne(this,Ws).findAll(e).map(({queryKey:s,state:r})=>{const n=r.data;return[s,n]})}setQueryData(e,s,r){const n=this.defaultQueryOptions({queryKey:e}),a=ne(this,Ws).get(n.queryHash),i=a==null?void 0:a.state.data,o=vI(s,i);if(o!==void 0)return ne(this,Ws).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(e,s,r){return dr.batch(()=>ne(this,Ws).findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(e){var r;const s=this.defaultQueryOptions({queryKey:e});return(r=ne(this,Ws).get(s.queryHash))==null?void 0:r.state}removeQueries(e){const s=ne(this,Ws);dr.batch(()=>{s.findAll(e).forEach(r=>{s.remove(r)})})}resetQueries(e,s){const r=ne(this,Ws);return dr.batch(()=>(r.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},s)))}cancelQueries(e,s={}){const r={revert:!0,...s},n=dr.batch(()=>ne(this,Ws).findAll(e).map(a=>a.cancel(r)));return Promise.all(n).then(Kr).catch(Kr)}invalidateQueries(e,s={}){return dr.batch(()=>(ne(this,Ws).findAll(e).forEach(r=>{r.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"},s)))}refetchQueries(e,s={}){const r={...s,cancelRefetch:s.cancelRefetch??!0},n=dr.batch(()=>ne(this,Ws).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,r);return r.throwOnError||(i=i.catch(Kr)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(Kr)}fetchQuery(e){const s=this.defaultQueryOptions(e);s.retry===void 0&&(s.retry=!1);const r=ne(this,Ws).build(this,s);return r.isStaleByTime(Ko(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Kr).catch(Kr)}fetchInfiniteQuery(e){return e.behavior=E4(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Kr).catch(Kr)}ensureInfiniteQueryData(e){return e.behavior=E4(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Vx.isOnline()?ne(this,$o).resumePausedMutations():Promise.resolve()}getQueryCache(){return ne(this,Ws)}getMutationCache(){return ne(this,$o)}getDefaultOptions(){return ne(this,Eo)}setDefaultOptions(e){Qe(this,Eo,e)}setQueryDefaults(e,s){ne(this,Bd).set(uc(e),{queryKey:e,defaultOptions:s})}getQueryDefaults(e){const s=[...ne(this,Bd).values()],r={};return s.forEach(n=>{gh(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,s){ne(this,zd).set(uc(e),{mutationKey:e,defaultOptions:s})}getMutationDefaults(e){const s=[...ne(this,zd).values()],r={};return s.forEach(n=>{gh(e,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const s={...ne(this,Eo).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return s.queryHash||(s.queryHash=pw(s.queryKey,s)),s.refetchOnReconnect===void 0&&(s.refetchOnReconnect=s.networkMode!=="always"),s.throwOnError===void 0&&(s.throwOnError=!!s.suspense),!s.networkMode&&s.persister&&(s.networkMode="offlineFirst"),s.queryFn===xw&&(s.enabled=!1),s}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...ne(this,Eo).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){ne(this,Ws).clear(),ne(this,$o).clear()}},Ws=new WeakMap,$o=new WeakMap,Eo=new WeakMap,Bd=new WeakMap,zd=new WeakMap,Po=new WeakMap,Ud=new WeakMap,Vd=new WeakMap,ek),hn,Ut,mf,Gr,Xl,qd,Ao,To,hf,Hd,Wd,Zl,Jl,Do,Gd,ns,_m,Mb,Ob,Ib,Fb,Lb,Bb,zb,k$,tk,RI=(tk=class extends wu{constructor(s,r){super();ct(this,ns);ct(this,hn);ct(this,Ut);ct(this,mf);ct(this,Gr);ct(this,Xl);ct(this,qd);ct(this,Ao);ct(this,To);ct(this,hf);ct(this,Hd);ct(this,Wd);ct(this,Zl);ct(this,Jl);ct(this,Do);ct(this,Gd,new Set);this.options=r,Qe(this,hn,s),Qe(this,To,null),Qe(this,Ao,Rb()),this.options.experimental_prefetchInRender||ne(this,Ao).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(ne(this,Ut).addObserver(this),A4(ne(this,Ut),this.options)?Ot(this,ns,_m).call(this):this.updateResult(),Ot(this,ns,Fb).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ub(ne(this,Ut),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ub(ne(this,Ut),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ot(this,ns,Lb).call(this),Ot(this,ns,Bb).call(this),ne(this,Ut).removeObserver(this)}setOptions(s){const r=this.options,n=ne(this,Ut);if(this.options=ne(this,hn).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Xn(this.options.enabled,ne(this,Ut))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ot(this,ns,zb).call(this),ne(this,Ut).setOptions(this.options),r._defaulted&&!Ux(this.options,r)&&ne(this,hn).getQueryCache().notify({type:"observerOptionsUpdated",query:ne(this,Ut),observer:this});const a=this.hasListeners();a&&T4(ne(this,Ut),n,this.options,r)&&Ot(this,ns,_m).call(this),this.updateResult(),a&&(ne(this,Ut)!==n||Xn(this.options.enabled,ne(this,Ut))!==Xn(r.enabled,ne(this,Ut))||Ko(this.options.staleTime,ne(this,Ut))!==Ko(r.staleTime,ne(this,Ut)))&&Ot(this,ns,Mb).call(this);const i=Ot(this,ns,Ob).call(this);a&&(ne(this,Ut)!==n||Xn(this.options.enabled,ne(this,Ut))!==Xn(r.enabled,ne(this,Ut))||i!==ne(this,Do))&&Ot(this,ns,Ib).call(this,i)}getOptimisticResult(s){const r=ne(this,hn).getQueryCache().build(ne(this,hn),s),n=this.createResult(r,s);return OI(this,n)&&(Qe(this,Gr,n),Qe(this,qd,this.options),Qe(this,Xl,ne(this,Ut).state)),n}getCurrentResult(){return ne(this,Gr)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){ne(this,Gd).add(s)}getCurrentQuery(){return ne(this,Ut)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=ne(this,hn).defaultQueryOptions(s),n=ne(this,hn).getQueryCache().build(ne(this,hn),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return Ot(this,ns,_m).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),ne(this,Gr)))}createResult(s,r){var R;const n=ne(this,Ut),a=this.options,i=ne(this,Gr),o=ne(this,Xl),l=ne(this,qd),d=s!==n?s.state:ne(this,mf),{state:m}=s;let h={...m},f=!1,p;if(r._optimisticResults){const A=this.hasListeners(),T=!A&&A4(s,r),P=A&&T4(s,n,r,a);(T||P)&&(h={...h,...S$(m.data,s.options)}),r._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:x,errorUpdatedAt:g,status:b}=h;p=h.data;let w=!1;if(r.placeholderData!==void 0&&p===void 0&&b==="pending"){let A;i!=null&&i.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData)?(A=i.data,w=!0):A=typeof r.placeholderData=="function"?r.placeholderData((R=ne(this,Wd))==null?void 0:R.state.data,ne(this,Wd)):r.placeholderData,A!==void 0&&(b="success",p=Db(i==null?void 0:i.data,A,r),f=!0)}if(r.select&&p!==void 0&&!w)if(i&&p===(o==null?void 0:o.data)&&r.select===ne(this,hf))p=ne(this,Hd);else try{Qe(this,hf,r.select),p=r.select(p),p=Db(i==null?void 0:i.data,p,r),Qe(this,Hd,p),Qe(this,To,null)}catch(A){Qe(this,To,A)}ne(this,To)&&(x=ne(this,To),p=ne(this,Hd),g=Date.now(),b="error");const j=h.fetchStatus==="fetching",y=b==="pending",v=b==="error",N=y&&j,S=p!==void 0,$={status:b,fetchStatus:h.fetchStatus,isPending:y,isSuccess:b==="success",isError:v,isInitialLoading:N,isLoading:N,data:p,dataUpdatedAt:h.dataUpdatedAt,error:x,errorUpdatedAt:g,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>d.dataUpdateCount||h.errorUpdateCount>d.errorUpdateCount,isFetching:j,isRefetching:j&&!y,isLoadingError:v&&!S,isPaused:h.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:v&&S,isStale:vw(s,r),refetch:this.refetch,promise:ne(this,Ao),isEnabled:Xn(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const A=B=>{$.status==="error"?B.reject($.error):$.data!==void 0&&B.resolve($.data)},T=()=>{const B=Qe(this,Ao,$.promise=Rb());A(B)},P=ne(this,Ao);switch(P.status){case"pending":s.queryHash===n.queryHash&&A(P);break;case"fulfilled":($.status==="error"||$.data!==P.value)&&T();break;case"rejected":($.status!=="error"||$.error!==P.reason)&&T();break}}return $}updateResult(){const s=ne(this,Gr),r=this.createResult(ne(this,Ut),this.options);if(Qe(this,Xl,ne(this,Ut).state),Qe(this,qd,this.options),ne(this,Xl).data!==void 0&&Qe(this,Wd,ne(this,Ut)),Ux(r,s))return;Qe(this,Gr,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!ne(this,Gd).size)return!0;const o=new Set(i??ne(this,Gd));return this.options.throwOnError&&o.add("error"),Object.keys(ne(this,Gr)).some(l=>{const c=l;return ne(this,Gr)[c]!==s[c]&&o.has(c)})};Ot(this,ns,k$).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ot(this,ns,Fb).call(this)}},hn=new WeakMap,Ut=new WeakMap,mf=new WeakMap,Gr=new WeakMap,Xl=new WeakMap,qd=new WeakMap,Ao=new WeakMap,To=new WeakMap,hf=new WeakMap,Hd=new WeakMap,Wd=new WeakMap,Zl=new WeakMap,Jl=new WeakMap,Do=new WeakMap,Gd=new WeakMap,ns=new WeakSet,_m=function(s){Ot(this,ns,zb).call(this);let r=ne(this,Ut).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(Kr)),r},Mb=function(){Ot(this,ns,Lb).call(this);const s=Ko(this.options.staleTime,ne(this,Ut));if(dc||ne(this,Gr).isStale||!Ab(s))return;const n=g$(ne(this,Gr).dataUpdatedAt,s)+1;Qe(this,Zl,setTimeout(()=>{ne(this,Gr).isStale||this.updateResult()},n))},Ob=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ne(this,Ut)):this.options.refetchInterval)??!1},Ib=function(s){Ot(this,ns,Bb).call(this),Qe(this,Do,s),!(dc||Xn(this.options.enabled,ne(this,Ut))===!1||!Ab(ne(this,Do))||ne(this,Do)===0)&&Qe(this,Jl,setInterval(()=>{(this.options.refetchIntervalInBackground||gw.isFocused())&&Ot(this,ns,_m).call(this)},ne(this,Do)))},Fb=function(){Ot(this,ns,Mb).call(this),Ot(this,ns,Ib).call(this,Ot(this,ns,Ob).call(this))},Lb=function(){ne(this,Zl)&&(clearTimeout(ne(this,Zl)),Qe(this,Zl,void 0))},Bb=function(){ne(this,Jl)&&(clearInterval(ne(this,Jl)),Qe(this,Jl,void 0))},zb=function(){const s=ne(this,hn).getQueryCache().build(ne(this,hn),this.options);if(s===ne(this,Ut))return;const r=ne(this,Ut);Qe(this,Ut,s),Qe(this,mf,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},k$=function(s){dr.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(ne(this,Gr))}),ne(this,hn).getQueryCache().notify({query:ne(this,Ut),type:"observerResultsUpdated"})})},tk);function MI(e,s){return Xn(s.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&s.retryOnMount===!1)}function A4(e,s){return MI(e,s)||e.state.data!==void 0&&Ub(e,s,s.refetchOnMount)}function Ub(e,s,r){if(Xn(s.enabled,e)!==!1&&Ko(s.staleTime,e)!=="static"){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&vw(e,s)}return!1}function T4(e,s,r,n){return(e!==s||Xn(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&vw(e,r)}function vw(e,s){return Xn(s.enabled,e)!==!1&&e.isStaleByTime(Ko(s.staleTime,e))}function OI(e,s){return!Ux(e.getCurrentResult(),s)}var Ro,Mo,fn,Ri,Bi,ax,Vb,sk,II=(sk=class extends wu{constructor(r,n){super();ct(this,Bi);ct(this,Ro);ct(this,Mo);ct(this,fn);ct(this,Ri);Qe(this,Ro,r),this.setOptions(n),this.bindMethods(),Ot(this,Bi,ax).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var a;const n=this.options;this.options=ne(this,Ro).defaultMutationOptions(r),Ux(this.options,n)||ne(this,Ro).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ne(this,fn),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&uc(n.mutationKey)!==uc(this.options.mutationKey)?this.reset():((a=ne(this,fn))==null?void 0:a.state.status)==="pending"&&ne(this,fn).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=ne(this,fn))==null||r.removeObserver(this)}onMutationUpdate(r){Ot(this,Bi,ax).call(this),Ot(this,Bi,Vb).call(this,r)}getCurrentResult(){return ne(this,Mo)}reset(){var r;(r=ne(this,fn))==null||r.removeObserver(this),Qe(this,fn,void 0),Ot(this,Bi,ax).call(this),Ot(this,Bi,Vb).call(this)}mutate(r,n){var a;return Qe(this,Ri,n),(a=ne(this,fn))==null||a.removeObserver(this),Qe(this,fn,ne(this,Ro).getMutationCache().build(ne(this,Ro),this.options)),ne(this,fn).addObserver(this),ne(this,fn).execute(r)}},Ro=new WeakMap,Mo=new WeakMap,fn=new WeakMap,Ri=new WeakMap,Bi=new WeakSet,ax=function(){var n;const r=((n=ne(this,fn))==null?void 0:n.state)??C$();Qe(this,Mo,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},Vb=function(r){dr.batch(()=>{var n,a,i,o,l,c,d,m;if(ne(this,Ri)&&this.hasListeners()){const h=ne(this,Mo).variables,f=ne(this,Mo).context;(r==null?void 0:r.type)==="success"?((a=(n=ne(this,Ri)).onSuccess)==null||a.call(n,r.data,h,f),(o=(i=ne(this,Ri)).onSettled)==null||o.call(i,r.data,null,h,f)):(r==null?void 0:r.type)==="error"&&((c=(l=ne(this,Ri)).onError)==null||c.call(l,r.error,h,f),(m=(d=ne(this,Ri)).onSettled)==null||m.call(d,void 0,r.error,h,f))}
40this.listeners.forEach(h=>{h(ne(this,Mo))})})},sk),$$=u.createContext(void 0),Xs=e=>{const s=u.useContext($$);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},FI=({client:e,children:s})=>(u.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),t.jsx($$.Provider,{value:e,children:s})),E$=u.createContext(!1),LI=()=>u.useContext(E$);E$.Provider;function BI(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var zI=u.createContext(BI()),UI=()=>u.useContext(zI),VI=(e,s)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(s.isReset()||(e.retryOnMount=!1))},qI=e=>{u.useEffect(()=>{e.clearReset()},[e])},HI=({result:e,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>e.isError&&!s.isReset()&&!e.isFetching&&n&&(a&&e.data===void 0||b$(r,[e.error,n])),WI=e=>{if(e.suspense){const s=n=>n==="static"?n:Math.max(n??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...n)=>s(r(...n)):s(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},GI=(e,s)=>e.isLoading&&e.isFetching&&!s,YI=(e,s)=>(e==null?void 0:e.suspense)&&s.isPending,D4=(e,s,r)=>s.fetchOptimistic(e).catch(()=>{r.clearReset()});function KI(e,s,r){var h,f,p,x,g;const n=LI(),a=UI(),i=Xs(),o=i.defaultQueryOptions(e);(f=(h=i.getDefaultOptions().queries)==null?void 0:h._experimental_beforeQuery)==null||f.call(h,o),o._optimisticResults=n?"isRestoring":"optimistic",WI(o),VI(o,a),qI(a);const l=!i.getQueryCache().get(o.queryHash),[c]=u.useState(()=>new s(i,o)),d=c.getOptimisticResult(o),m=!n&&e.subscribed!==!1;if(u.useSyncExternalStore(u.useCallback(b=>{const w=m?c.subscribe(dr.batchCalls(b)):Kr;return c.updateResult(),w},[c,m]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),u.useEffect(()=>{c.setOptions(o)},[o,c]),YI(o,d))throw D4(o,c,a);if(HI({result:d,errorResetBoundary:a,throwOnError:o.throwOnError,query:i.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw d.error;if((x=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||x.call(p,o,d),o.experimental_prefetchInRender&&!dc&&GI(d,n)){const b=l?D4(o,c,a):(g=i.getQueryCache().get(o.queryHash))==null?void 0:g.promise;b==null||b.catch(Kr).finally(()=>{c.updateResult()})}return o.notifyOnChangeProps?d:c.trackResult(d)}function Lt(e,s){return KI(e,RI)}function os(e,s){const r=Xs(),[n]=u.useState(()=>new II(r,e));u.useEffect(()=>{n.setOptions(e)},[n,e]);const a=u.useSyncExternalStore(u.useCallback(o=>n.subscribe(dr.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=u.useCallback((o,l)=>{n.mutate(o,l).catch(Kr)},[n]);if(a.error&&b$(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}const QI=new DI({defaultOptions:{queries:{staleTime:2*60*1e3,gcTime:10*60*1e3,retry:2,retryDelay:e=>Math.min(500*2**e,5e3),refetchOnWindowFocus:!1,refetchOnReconnect:!0,refetchOnMount:!0,networkMode:"always"}}});function XI({children:e}){return t.jsx(FI,{client:QI,children:e})}const ZI=1,JI=1e6;let My=0;function eF(){return My=(My+1)%Number.MAX_SAFE_INTEGER,My.toString()}const Oy=new Map,R4=e=>{if(Oy.has(e))return;const s=setTimeout(()=>{Oy.delete(e),zm({type:"REMOVE_TOAST",toastId:e})},JI);Oy.set(e,s)},tF=(e,s)=>{switch(s.type){case"ADD_TOAST":return{...e,toasts:[s.toast,...e.toasts].slice(0,ZI)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(r=>r.id===s.toast.id?{...r,...s.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=s;return r?R4(r):e.toasts.forEach(n=>{R4(n.id)}),{...e,toasts:e.toasts.map(n=>
40n.id===r||r===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return s.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(r=>r.id!==s.toastId)}}},ix=[];let ox={toasts:[]};function zm(e){ox=tF(ox,e),ix.forEach(s=>{s(ox)})}function Ks({...e}){const s=eF(),r=a=>zm({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>zm({type:"DISMISS_TOAST",toastId:s});return zm({type:"ADD_TOAST",toast:{...e,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function rt(){const[e,s]=u.useState(ox);return u.useEffect(()=>(ix.push(s),()=>{const r=ix.indexOf(s);r>-1&&ix.splice(r,1)}),[e]),{...e,toast:Ks,dismiss:r=>zm({type:"DISMISS_TOAST",toastId:r})}}function Se(e,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(e==null||e(a),r===!1||!a.defaultPrevented)return s==null?void 0:s(a)}}function sF(e,s){typeof e=="function"?e(s):e!=null&&(e.current=s)}function yf(...e){return s=>e.forEach(r=>sF(r,s))}function at(...e){return u.useCallback(yf(...e),e)}function rF(e,s=[]){let r=[];function n(i,o){const l=u.createContext(o),c=r.length;r=[...r,o];function d(h){const{scope:f,children:p,...x}=h,g=(f==null?void 0:f[e][c])||l,b=u.useMemo(()=>x,Object.values(x));return t.jsx(g.Provider,{value:b,children:p})}function m(h,f){const p=(f==null?void 0:f[e][c])||l,x=u.useContext(p);if(x)return x;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return d.displayName=i+"Provider",[d,m]}const a=()=>{const i=r.map(o=>u.createContext(o));return function(l){const c=(l==null?void 0:l[e])||i;return u.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[n,nF(a,...s)]}function nF(...e){const s=e[0];if(e.length===1)return s;const r=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=n.reduce((l,{useScope:c,scopeName:d})=>{const h=c(i)[`__scope${d}`];return{...l,...h}},{});return u.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return r.scopeName=s.scopeName,r}var tn=u.forwardRef((e,s)=>{const{children:r,...n}=e,a=u.Children.toArray(r),i=a.find(aF);if(i){const o=i.props.children,l=a.map(c=>c===i?u.Children.count(o)>1?u.Children.only(null):u.isValidElement(o)?o.props.children:null:c);return t.jsx(qb,{...n,ref:s,children:u.isValidElement(o)?u.cloneElement(o,void 0,l):null})}return t.jsx(qb,{...n,ref:s,children:r})});tn.displayName="Slot";var qb=u.forwardRef((e,s)=>{const{children:r,...n}=e;if(u.isValidElement(r)){const a=oF(r);return u.cloneElement(r,{...iF(n,r.props),ref:s?yf(s,a):a})}return u.Children.count(r)>1?u.Children.only(null):null});qb.displayName="SlotClone";var yw=({children:e})=>t.jsx(t.Fragment,{children:e});function aF(e){return u.isValidElement(e)&&e.type===yw}function iF(e,s){const r={...s};for(const n in s){const a=e[n],i=s[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{i(...l),a(...l)}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function oF(e){var n,a;let s=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?e.ref:(s=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function pl(e){const s=e+"CollectionProvider",[r,n]=rF(s),[a,i]=r(s,{collectionRef:{current:null},itemMap:new Map}),o=p=>{const{scope:x,children:g}=p,b=ve.useRef(null),w=ve.useRef(new Map).current;return t.jsx(a,{scope:x,itemMap:w,collectionRef:b,children:g})};o.displayName=s;const l=e+"CollectionSlot",c=ve.forwardRef((p,x)=>{const{scope:g,children:b}=p,w=i(l,g),j=at(x,w.collectionRef);return t.jsx(tn,{ref:j,children:b})});c.displayName=l;const d=e+"CollectionItemSlot",m="data-radix-collection-item",h=ve.forwardRef((p,x)=>{const{scope:g,children:b,...w}=p,j=ve.useRef(null),y=at(x,j),v=i(d,g);return ve.useEffect(()=>(v.itemMap.set(j,{ref:j,...w}),()=>void v.itemMap.delete(j))),t.jsx(tn,{[m]:"",ref:y,children:b})});h.displayName=d;function f(p){const x=i(e+"CollectionConsumer",p);return ve.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const w=Array.from(b.querySelectorAll(`[${m}]`));return Array.from(x.itemMap.values()).sort((v,N)=>w.indexOf(v.ref.current)-w.indexOf(N.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:o,Slot:c,ItemSlot:h},f,n]}function lF(e,s){const r=u.createContext(s),n=i=>{const{children:o,...l}=i,c=u.useMemo(()=>l,Object.values(l));return t.jsx(r.Provider,{value:c,children:o})};n.displayName=e+"Provider";function a(i){const o=u.useContext(r);if(o)return o;if(s!==void 0)return s;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[n,a]}function hr(e,s=[]){let r=[];function n(i,o){const l=u.createContext(o),c=r.length;r=[...r,o];const d=h=>{var w;const{scope:f,children:p,...x}=h,g=((w=f==null?void 0:f[e])==null?void 0:w[c])||l,b=u.useMemo(()=>x,Object.values(x));return t.jsx(g.Provider,{value:b,children:p})};d.displayName=i+"Provider";function m(h,f){var g;const p=((g=f==null?void 0:f[e])==null?void 0:g[c])||l,x=u.useContext(p);if(x)return x;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[d,m]}const a=()=>{const i=r.map(o=>u.createContext(o));return function(l){const c=(l==null?void 0:l[e])||i;return u.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[n,cF(a,...s)]}function cF(...e){const s=e[0];if(e.length===1)return s;const r=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));
vendor: 3,272 bytes, line 40
40return function(i){const o=n.reduce((l,{useScope:c,scopeName:d})=>{const h=c(i)[`__scope${d}`];return{...l,...h}},{});return u.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return r.scopeName=s.scopeName,r}var dF=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ze=dF.reduce((e,s)=>{const r=u.forwardRef((n,a)=>{const{asChild:i,...o}=n,l=i?tn:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(l,{...o,ref:a})});return r.displayName=`Primitive.${s}`,{...e,[s]:r}},{});function vh(e,s){e&&yn.flushSync(()=>e.dispatchEvent(s))}function Qt(e){const s=u.useRef(e);return u.useEffect(()=>{s.current=e}),u.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function uF(e,s=globalThis==null?void 0:globalThis.document){const r=Qt(e);u.useEffect(()=>{const n=a=>{a.key==="Escape"&&r(a)};return s.addEventListener("keydown",n,{capture:!0}),()=>s.removeEventListener("keydown",n,{capture:!0})},[r,s])}var mF="DismissableLayer",Hb="dismissableLayer.update",hF="dismissableLayer.pointerDownOutside",fF="dismissableLayer.focusOutside",M4,P$=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),xl=u.forwardRef((e,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:l,...c}=e,d=u.useContext(P$),[m,h]=u.useState(null),f=(m==null?void 0:m.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=u.useState({}),x=at(s,k=>h(k)),g=Array.from(d.layers),[b]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),w=g.indexOf(b),j=m?g.indexOf(m):-1,y=d.layersWithOutsidePointerEventsDisabled.size>0,v=j>=w,N=xF(k=>{const $=k.target,R=[...d.branches].some(A=>A.contains($));!v||R||(a==null||a(k),o==null||o(k),k.defaultPrevented||l==null||l())},f),S=gF(k=>{const $=k.target;[...d.branches].some(A=>A.contains($))||(i==null||i(k),o==null||o(k),k.defaultPrevented||l==null||l())},f);return uF(k=>{j===d.layers.size-1&&(n==null||n(k),!k.defaultPrevented&&l&&(k.preventDefault(),l()))},f),u.useEffect(()=>{if(m)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(M4=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(m)),d.layers.add(m),O4(),()=>{r&&d.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=M4)}},[m,f,r,d]),u.useEffect(()=>()=>{m&&(d.layers.delete(m),d.layersWithOutsidePointerEventsDisabled.delete(m),O4())},[m,d]),u.useEffect(()=>{const k=()=>p({});return document.addEventListener(Hb,k),()=>document.removeEventListener(Hb,k)},[]),t.jsx(ze.div,{...c,ref:x,style:{pointerEvents:y?v?"auto":"none":void 0,...e.style},onFocusCapture:Se(e.onFocusCapture,S.onFocusCapture),onBlurCapture:Se(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:Se(e.onPointerDownCapture,N.onPointerDownCapture)})});xl.displayName=mF;var pF="DismissableLayerBranch",A$=u.forwardRef((e,s)=>{const r=u.useContext(P$),n=u.useRef(null),a=at(s,n);return u.useEffect(()=>{const i=n.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),t.jsx(ze.div,{...e,ref:a})});A$.displayName=pF;function xF(e,s=globalThis==null?void 0:globalThis.document){const r=Qt
40(e),n=u.useRef(!1),a=u.useRef(()=>{});return u.useEffect(()=>{const i=l=>{if(l.target&&!n.current){let c=function(){T$(hF,r,d,{discrete:!0})};const d={originalEvent:l};l.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=c,s.addEventListener("click",a.current,{once:!0})):c()}else s.removeEventListener("click",a.current);n.current=!1},o=window.setTimeout(()=>{s.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),s.removeEventListener("pointerdown",i),s.removeEventListener("click",a.current)}},[s,r]),{onPointerDownCapture:()=>n.current=!0}}function gF(e,s=globalThis==null?void 0:globalThis.document){const r=Qt(e),n=u.useRef(!1);return u.useEffect(()=>{const a=i=>{i.target&&!n.current&&T$(fF,r,{originalEvent:i},{discrete:!1})};return s.addEventListener("focusin",a),()=>s.removeEventListener("focusin",a)},[s,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function O4(){const e=new CustomEvent(Hb);document.dispatchEvent(e)}function T$(e,s,r,{discrete:n}){const a=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});s&&a.addEventListener(e,s,{once:!0}),n?vh(a,i):a.dispatchEvent(i)}var vF=xl,yF=A$,qs=globalThis!=null&&globalThis.document?u.useLayoutEffect:()=>{},bF="Portal",Nu=u.forwardRef((e,s)=>{var l;const{container:r,...n}=e,[a,i]=u.useState(!1);qs(()=>i(!0),[]);const o=r||a&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return o?Jg.createPortal(t.jsx(ze.div,{...n,ref:s}),o):null});Nu.displayName=bF;function jF(e,s){return u.useReducer((r,n)=>s[r][n]??r,e)}var Ts=e=>{const{present:s,children:r}=e,n=wF(s),a=typeof r=="function"?r({present:n.isPresent}):u.Children.only(r),i=at(n.ref,NF(a));return typeof r=="function"||n.isPresent?u.cloneElement(a,{ref:i}):null};Ts.displayName="Presence";function wF(e){const[s,r]=u.useState(),n=u.useRef({}),a=u.useRef(e),i=u.useRef("none"),o=e?"mounted":"unmounted",[l,c]=jF(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=Np(n.current);i.current=l==="mounted"?d:"none"},[l]),qs(()=>{const d=n.current,m=a.current;if(m!==e){const f=i.current,p=Np(d);e?c("MOUNT"):p==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(m&&f!==p?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),qs(()=>{if(s){let d;const m=s.ownerDocument.defaultView??window,h=p=>{const g=Np(n.current).includes(p.animationName);if(p.target===s&&g&&(c("ANIMATION_END"),!a.current)){const b=s.style.animationFillMode;s.style.animationFillMode="forwards",d=m.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=b)})}},f=p=>{p.target===s&&(i.current=Np(n.current))};return s.addEventListener("animationstart",f),s.addEventListener("animationcancel",h),s.addEventListener("animationend",h),()=>{m.clearTimeout(d),s.removeEventListener("animationstart",f),s.removeEventListener("animationcancel",h),s.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[s,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{d&&(n.current=getComputedStyle(d)),r(d)},[])}}function Np(e){return(e==null?void 0:e.animationName)||"none"}function NF(e){var n,a;let s=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?e.ref:(s=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function wr({prop:e,defaultProp:s,onChange:r=()=>{}}){const[n,a]=_F({defaultProp:s,onChange:r}),i=e!==void 0,o=i?e:n,l=Qt(r),c=u.useCallback(d=>{if(i){const h=typeof d=="function"?d(e):d;h!==e&&l(h)}else a(d)},[i,e,a,l]);return[o,c]}function _F({defaultProp:e,onChange:s}){const r=u.useState(e),[n]=r,a=u.useRef(n),i=Qt(s);return u.useEffect(()=>{a.current!==n&&(i(n),a.current=n)},[n,a,i]),r}var SF="VisuallyHidden",bf=u.forwardRef((e,s)=>t.jsx(ze.span,{...e,ref:s,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));bf.displayName=SF;var D$=bf,bw="ToastProvider",[jw,CF,kF]=pl("Toast"),[R$,rfe]=hr("Toast",[kF]),[$F,ev]=R$(bw),M$=e=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:i=50,children:o}=e,[l,c]=u.useState(null),[d,m]=u.useState(0),h=u.useRef(!1),f=u.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${bw}\`. Expected non-empty \`string\`.`),t.jsx(jw.Provider,{scope:s,children:t.jsx($F,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:i,toastCount:d,viewport:l,onViewportChange:c,onToastAdd:u.useCallback(()=>m(p=>p+1),[]),onToastRemove:u.useCallback(()=>m(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:f,children:o})})};M$.displayName=bw;var O$="ToastViewport",EF=["F8"],Wb="toast.viewportPause",Gb="toast.viewportResume",I$=u.forwardRef((e,s)=>{const{__scopeToast:r,hotkey:n=EF,label:a="Notifications ({hotkey})",...i}=e,o=ev(O$,r),l=CF(r),c=u.useRef(null),d=u.useRef(null),m=u.useRef(null),h=u.useRef(null),f=at(s,h,o.onViewportChange),p=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),x=o.toastCount>0;u.useEffect(()=>{const b=w=>{var y;n.length!==0&&n.every(v=>w[v]||w.code===v)&&((y=h.current)==null||y.focus())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[n]),u.useEffect(()=>{const b=c.current,w=h.current;if(x&&b&&w){const j=()=>
40{if(!o.isClosePausedRef.current){const S=new CustomEvent(Wb);w.dispatchEvent(S),o.isClosePausedRef.current=!0}},y=()=>{if(o.isClosePausedRef.current){const S=new CustomEvent(Gb);w.dispatchEvent(S),o.isClosePausedRef.current=!1}},v=S=>{!b.contains(S.relatedTarget)&&y()},N=()=>{b.contains(document.activeElement)||y()};return b.addEventListener("focusin",j),b.addEventListener("focusout",v),b.addEventListener("pointermove",j),b.addEventListener("pointerleave",N),window.addEventListener("blur",j),window.addEventListener("focus",y),()=>{b.removeEventListener("focusin",j),b.removeEventListener("focusout",v),b.removeEventListener("pointermove",j),b.removeEventListener("pointerleave",N),window.removeEventListener("blur",j),window.removeEventListener("focus",y)}}},[x,o.isClosePausedRef]);const g=u.useCallback(({tabbingDirection:b})=>{const j=l().map(y=>{const v=y.ref.current,N=[v,...UF(v)];return b==="forwards"?N:N.reverse()});return(b==="forwards"?j.reverse():j).flat()},[l]);return u.useEffect(()=>{const b=h.current;if(b){const w=j=>{var N,S,k;const y=j.altKey||j.ctrlKey||j.metaKey;if(j.key==="Tab"&&!y){const $=document.activeElement,R=j.shiftKey;if(j.target===b&&R){(N=d.current)==null||N.focus();return}const P=g({tabbingDirection:R?"backwards":"forwards"}),B=P.findIndex(Y=>Y===$);Iy(P.slice(B+1))?j.preventDefault():R?(S=d.current)==null||S.focus():(k=m.current)==null||k.focus()}};return b.addEventListener("keydown",w),()=>b.removeEventListener("keydown",w)}},[l,g]),t.jsxs(yF,{ref:c,role:"region","aria-label":a.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:x?void 0:"none"},children:[x&&t.jsx(Yb,{ref:d,onFocusFromOutsideViewport:()=>{const b=g({tabbingDirection:"forwards"});Iy(b)}}),t.jsx(jw.Slot,{scope:r,children:t.jsx(ze.ol,{tabIndex:-1,...i,ref:f})}),x&&t.jsx(Yb,{ref:m,onFocusFromOutsideViewport:()=>{const b=g({tabbingDirection:"backwards"});Iy(b)}})]})});I$.displayName=O$;var F$="ToastFocusProxy",Yb=u.forwardRef((e,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=e,i=ev(F$,r);return t.jsx(bf,{"aria-hidden":!0,tabIndex:0,...a,ref:s,style:{position:"fixed"},onFocus:o=>{var d;const l=o.relatedTarget;!((d=i.viewport)!=null&&d.contains(l))&&n()}})});Yb.displayName=F$;var tv="Toast",PF="toast.swipeStart",AF="toast.swipeMove",TF="toast.swipeCancel",DF="toast.swipeEnd",L$=u.forwardRef((e,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:i,...o}=e,[l=!0,c]=wr({prop:n,defaultProp:a,onChange:i});return t.jsx(Ts,{present:r||l,children:t.jsx(OF,{open:l,...o,ref:s,onClose:()=>c(!1),onPause:Qt(e.onPause),onResume:Qt(e.onResume),onSwipeStart:Se(e.onSwipeStart,d=>{d.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Se(e.onSwipeMove,d=>{const{x:m,y:h}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","move"),d.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${m}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:Se(e.onSwipeCancel,d=>{d.currentTarget.setAttribute("data-swipe","cancel"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Se(e.onSwipeEnd,d=>{const{x:m,y:h}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","end"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${m}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),c(!1)})})})});L$.displayName=tv;var[RF,MF]=R$(tv,{onClose(){}}),OF=u.forwardRef((e,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:i,onClose:o,onEscapeKeyDown:l,onPause:c,onResume:d,onSwipeStart:m,onSwipeMove:h,onSwipeCancel:f,onSwipeEnd:p,...x}=e,g=ev(tv,r),[b,w]=u.useState(null),j=at(s,Y=>w(Y)),y=u.useRef(null),v=u.useRef(null),N=a||g.duration,S=u.useRef(0),k=u.useRef(N),$=u.useRef(0),{onToastAdd:R,onToastRemove:A}=g,T=Qt(()=>{var I;(b==null?void 0:b.contains(document.activeElement))&&((I=g.viewport)==null||I.focus()),o()}),P=u.useCallback(Y=>
vendor: 4,521 bytes, line 40
40{!Y||Y===1/0||(window.clearTimeout($.current),S.current=new Date().getTime(),$.current=window.setTimeout(T,Y))},[T]);u.useEffect(()=>{const Y=g.viewport;if(Y){const I=()=>{P(k.current),d==null||d()},C=()=>{const L=new Date().getTime()-S.current;k.current=k.current-L,window.clearTimeout($.current),c==null||c()};return Y.addEventListener(Wb,C),Y.addEventListener(Gb,I),()=>{Y.removeEventListener(Wb,C),Y.removeEventListener(Gb,I)}}},[g.viewport,N,c,d,P]),u.useEffect(()=>{i&&!g.isClosePausedRef.current&&P(N)},[i,N,g.isClosePausedRef,P]),u.useEffect(()=>(R(),()=>A()),[R,A]);const B=u.useMemo(()=>b?W$(b):null,[b]);return g.viewport?t.jsxs(t.Fragment,{children:[B&&t.jsx(IF,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:B}),t.jsx(RF,{scope:r,onClose:T,children:yn.createPortal(t.jsx(jw.ItemSlot,{scope:r,children:t.jsx(vF,{asChild:!0,onEscapeKeyDown:Se(l,()=>{g.isFocusedToastEscapeKeyDownRef.current||T(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:t.jsx(ze.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":i?"open":"closed","data-swipe-direction":g.swipeDirection,...x,ref:j,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:Se(e.onKeyDown,Y=>{Y.key==="Escape"&&(l==null||l(Y.nativeEvent),Y.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,T()))}),onPointerDown:Se(e.onPointerDown,Y=>{Y.button===0&&(y.current={x:Y.clientX,y:Y.clientY})}),onPointerMove:Se(e.onPointerMove,Y=>{if(!y.current)return;const I=Y.clientX-y.current.x,C=Y.clientY-y.current.y,L=!!v.current,D=["left","right"].includes(g.swipeDirection),_=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,H=D?_(0,I):0,O=D?0:_(0,C),U=Y.pointerType==="touch"?10:2,G={x:H,y:O},E={originalEvent:Y,delta:G};L?(v.current=G,_p(AF,h,E,{discrete:!1})):I4(G,g.swipeDirection,U)?(v.current=G,_p(PF,m,E,{discrete:!1}),Y.target.setPointerCapture(Y.pointerId)):(Math.abs(I)>U||Math.abs(C)>U)&&(y.current=null)}),onPointerUp:Se(e.onPointerUp,Y=>{const I=v.current,C=Y.target;if(C.hasPointerCapture(Y.pointerId)&&C.releasePointerCapture(Y.pointerId),v.current=null,y.current=null,I){const L=Y.currentTarget,D={originalEvent:Y,delta:I};I4(I,g.swipeDirection,g.swipeThreshold)?_p(DF,p,D,{discrete:!0}):_p(TF,f,D,{discrete:!0}),L.addEventListener("click",_=>_.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),IF=e=>{const{__scopeToast:s,children:r,...n}=e,a=ev(tv,s),[i,o]=u.useState(!1),[l,c]=u.useState(!1);return BF(()=>o(!0)),u.useEffect(()=>{const d=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(d)},[]),l?null:t.jsx(Nu,{asChild:!0,children:t.jsx(bf,{...n,children:i&&t.jsxs(t.Fragment,{children:[a.label," ",r]})})})},FF="ToastTitle",B$=u.forwardRef((e,s)=>{const{__scopeToast:r,...n}=e;return t.jsx(ze.div,{...n,ref:s})});B$.displayName=FF;var LF="ToastDescription",z$=u.forwardRef((e,s)=>{const{__scopeToast:r,...n}=e;return t.jsx(ze.div,{...n,ref:s})});z$.displayName=LF;var U$="ToastAction",V$=u.forwardRef((e,s)=>{const{altText:r,...n}=e;return r.trim()?t.jsx(H$,{altText:r,asChild:!0,children:t.jsx(ww,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${U$}\`. Expected non-empty \`string\`.`),null)});V$.displayName=U$;var q$="ToastClose",ww=u.forwardRef((e,s)=>{const{__scopeToast:r,...n}=e,a=MF(q$,r);return t.jsx(H$,{asChild:!0,children:t.jsx(ze.button,{type:"button",...n,ref:s,onClick:Se(e.onClick,a.onClose)})})});ww.displayName=q$;var H$=u.forwardRef((e,s)=>{const{__scopeToast:r,altText:n,...a}=e;return t.jsx(ze.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function W$(e){const s=[];return Array.from(e.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),zF(n)){const a=n.ariaHidden||n.hidden||n.style.display==="none",i=n.dataset.radixToastAnnounceExclude==="";if(!a)if(i){const o=n.dataset.radixToastAnnounceAlt;o&&s.push(o)}else s.push(...W$(n))}}),s}function _p(e,s,r,{discrete:n}){const a=r.originalEvent.currentTarget,i=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:r});s&&a.addEventListener(e,s,{once:!0}),n?vh(a,i):a.dispatchEvent(i)}var I4=(e,s,r=0)=>{const n=Math.abs(e.x),a=Math.abs(e.y),i=n>a;return s==="left"||s==="right"?i&&n>r:!i&&a>r};function BF(e=()=>{}){const s=Qt(e);qs(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}
vendor: 6,466 bytes, lines 40-105
40function zF(e){return e.nodeType===e.ELEMENT_NODE}function UF(e){const s=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}function Iy(e){const s=document.activeElement;return e.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var VF=M$,G$=I$,Y$=L$,K$=B$,Q$=z$,X$=V$,Z$=ww;function J$(e){var s,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(s=0;s<a;s++)e[s]&&(r=J$(e[s]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function eE(){for(var e,s,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(s=J$(e))&&(n&&(n+=" "),n+=s);return n}const F4=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,L4=eE,fa=(e,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return L4(e,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:a,defaultVariants:i}=s,o=Object.keys(a).map(d=>{const m=r==null?void 0:r[d],h=i==null?void 0:i[d];if(m===null)return null;const f=F4(m)||F4(h);return a[d][f]}),l=r&&Object.entries(r).reduce((d,m)=>{let[h,f]=m;return f===void 0||(d[h]=f),d},{}),c=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((d,m)=>{let{class:h,className:f,...p}=m;return Object.entries(p).every(x=>{let[g,b]=x;return Array.isArray(b)?b.includes({...i,...l}[g]):{...i,...l}[g]===b})?[...d,h,f]:d},[]);return L4(e,o,c,r==null?void 0:r.class,r==null?void 0:r.className)};/** 41 * @license lucide-react v0.462.0 - ISC 42 * 43 * This source code is licensed under the ISC license. 44 * See the LICENSE file in the root directory of this source tree. 45 */const qF=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),tE=(...e)=>e.filter((s,r,n)=>!!s&&s.trim()!==""&&n.indexOf(s)===r).join(" ").trim();/** 46 * @license lucide-react v0.462.0 - ISC 47 * 48 * This source code is licensed under the ISC license. 49 * See the LICENSE file in the root directory of this source tree. 50 */var HF={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"};/** 51 * @license lucide-react v0.462.0 - ISC 52 * 53 * This source code is licensed under the ISC license. 54 * See the LICENSE file in the root directory of this source tree. 55 */const WF=u.forwardRef(({color:e="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:i,iconNode:o,...l},c)=>u.createElement("svg",{ref:c,...HF,width:s,height:s,stroke:e,strokeWidth:n?Number(r)*24/Number(s):r,className:tE("lucide",a),...l},[...o.map(([d,m])=>u.createElement(d,m)),...Array.isArray(i)?i:[i]]));/** 56 * @license lucide-react v0.462.0 - ISC 57 * 58 * This source code is licensed under the ISC license. 59 * See the LICENSE file in the root directory of this source tree. 60 */const _e=(e,s)=>{const r=u.forwardRef(({className:n,...a},i)=>u.createElement(WF,{ref:i,iconNode:s,className:tE(`lucide-${qF(e)}`,n),...a}));return r.displayName=`${e}`,r};/** 61 * @license lucide-react v0.462.0 - ISC 62 * 63 * This source code is licensed under the ISC license. 64 * See the LICENSE file in the root directory of this source tree. 65 */const GF=_e("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** 66 * @license lucide-react v0.462.0 - ISC 67 * 68 * This source code is licensed under the ISC license. 69 * See the LICENSE file in the root directory of this source tree. 70 */const Hi=_e("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** 71 * @license lucide-react v0.462.0 - ISC 72 * 73 * This source code is licensed under the ISC license. 74 * See the LICENSE file in the root directory of this source tree. 75 */const jf=_e("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** 76 * @license lucide-react v0.462.0 - ISC 77 * 78 * This source code is licensed under the ISC license. 79 * See the LICENSE file in the root directory of this source tree. 80 */const YF=_e("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** 81 * @license lucide-react v0.462.0 - ISC 82 * 83 * This source code is licensed under the ISC license. 84 * See the LICENSE file in the root directory of this source tree. 85 */const sE=_e("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** 86 * @license lucide-react v0.462.0 - ISC 87 * 88 * This source code is licensed under the ISC license. 89 * See the LICENSE file in the root directory of this source tree. 90 */const sv=_e("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"}]]);/** 91 * @license lucide-react v0.462.0 - ISC 92 * 93 * This source code is licensed under the ISC license. 94 * See the LICENSE file in the root directory of this source tree. 95 */const tu=_e("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** 96 * @license lucide-react v0.462.0 - ISC 97 * 98 * This source code is licensed under the ISC license. 99 * See the LICENSE file in the root directory of this source tree. 100 */const B4=_e("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"}]]);/** 101 * @license lucide-react v0.462.0 - ISC 102 * 103 * This source code is licensed under the ISC license. 104 * See the LICENSE file in the root directory of this source tree. 105 */const Xr=_e("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"}
105],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** 106 * @license lucide-react v0.462.0 - ISC 107 * 108 * This source code is licensed under the ISC license. 109 * See the LICENSE file in the root directory of this source tree. 110 */const qx=_e("Building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]]);/** 111 * @license lucide-react v0.462.0 - ISC 112 * 113 * This source code is licensed under the ISC license. 114 * See the LICENSE file in the root directory of this source tree. 115 */const sc=_e("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** 116 * @license lucide-react v0.462.0 - ISC 117 * 118 * This source code is licensed under the ISC license. 119 * See the LICENSE file in the root directory of this source tree. 120 */const Qo=_e("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"}]]);/** 121 * @license lucide-react v0.462.0 - ISC 122 * 123 * This source code is licensed under the ISC license. 124 * See the LICENSE file in the root directory of this source tree. 125 */const It=_e("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"}]]);/** 126 * @license lucide-react v0.462.0 - ISC 127 * 128 * This source code is licensed under the ISC license. 129 * See the LICENSE file in the root directory of this source tree. 130 */const wf=_e("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"}]]);/** 131 * @license lucide-react v0.462.0 - ISC 132 * 133 * This source code is licensed under the ISC license. 134 * See the LICENSE file in the root directory of this source tree. 135 */const Bs=_e("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** 136 * @license lucide-react v0.462.0 - ISC 137 * 138 * This source code is licensed under the ISC license. 139 * See the LICENSE file in the root directory of this source tree. 140 */const Ma=_e("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** 141 * @license lucide-react v0.462.0 - ISC 142 * 143 * This source code is licensed under the ISC license. 144 * See the LICENSE file in the root directory of this source tree. 145 */const su=_e("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** 146 * @license lucide-react v0.462.0 - ISC 147 * 148 * This source code is licensed under the ISC license. 149 * See the LICENSE file in the root directory of this source tree. 150 */const Ac=_e("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** 151 * @license lucide-react v0.462.0 - ISC 152 * 153 * This source code is licensed under the ISC license. 154 * See the LICENSE file in the root directory of this source tree. 155 */const rE=_e("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** 156 * @license lucide-react v0.462.0 - ISC 157 * 158 * This source code is licensed under the ISC license. 159 * See the LICENSE file in the root directory of this source tree. 160 */const yh=_e("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/** 161 * @license lucide-react v0.462.0 - ISC 162 * 163 * This source code is licensed under the ISC license. 164 * See the LICENSE file in the root directory of this source tree. 165 */const Hs=_e("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"}]]);/** 166 * @license lucide-react v0.462.0 - ISC 167 * 168 * This source code is licensed under the ISC license. 169 * See the LICENSE file in the root directory of this source tree. 170 */const xs=_e("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** 171 * @license lucide-react v0.462.0 - ISC 172 * 173 * This source code is licensed under the ISC license. 174 * See the LICENSE file in the root directory of this source tree. 175 */const As=_e("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** 176 * @license lucide-react v0.462.0 - ISC 177 * 178 * This source code is licensed under the ISC license. 179 * See the LICENSE file in the root directory of this source tree. 180 */const Hx=_e("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** 181 * @license lucide-react v0.462.0 - ISC 182 * 183 * This source code is licensed under the ISC license. 184 * See the LICENSE file in the root directory of this source tree. 185 */const Nf=_e("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"}]]);/** 186 * @license lucide-react v0.462.0 - ISC 187 * 188 * This source code is licensed under the ISC license. 189 * See the LICENSE file in the root directory of this source tree. 190 */const nE=_e("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** 191 * @license lucide-react v0.462.0 - ISC 192 * 193 * This source code is licensed under the ISC license. 194 * See the LICENSE file in the root directory of this source tree.
195 */const KF=_e("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/** 196 * @license lucide-react v0.462.0 - ISC 197 * 198 * This source code is licensed under the ISC license. 199 * See the LICENSE file in the root directory of this source tree. 200 */const ws=_e("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** 201 * @license lucide-react v0.462.0 - ISC 202 * 203 * This source code is licensed under the ISC license. 204 * See the LICENSE file in the root directory of this source tree. 205 */const QF=_e("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/** 206 * @license lucide-react v0.462.0 - ISC 207 * 208 * This source code is licensed under the ISC license. 209 * See the LICENSE file in the root directory of this source tree. 210 */const Wx=_e("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** 211 * @license lucide-react v0.462.0 - ISC 212 * 213 * This source code is licensed under the ISC license. 214 * See the LICENSE file in the root directory of this source tree. 215 */const ci=_e("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"}]]);/** 216 * @license lucide-react v0.462.0 - ISC 217 * 218 * This source code is licensed under the ISC license. 219 * See the LICENSE file in the root directory of this source tree. 220 */const Sd=_e("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/** 221 * @license lucide-react v0.462.0 - ISC 222 * 223 * This source code is licensed under the ISC license. 224 * See the LICENSE file in the root directory of this source tree. 225 */const ei=_e("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"}]]);/** 226 * @license lucide-react v0.462.0 - ISC 227 * 228 * This source code is licensed under the ISC license. 229 * See the LICENSE file in the root directory of this source tree. 230 */const _u=_e("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"}]]);/** 231 * @license lucide-react v0.462.0 - ISC 232 * 233 * This source code is licensed under the ISC license. 234 * See the LICENSE file in the root directory of this source tree. 235 */const di=_e("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** 236 * @license lucide-react v0.462.0 - ISC 237 * 238 * This source code is licensed under the ISC license. 239 * See the LICENSE file in the root directory of this source tree. 240 */const tr=_e("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"}]]);/** 241 * @license lucide-react v0.462.0 - ISC 242 * 243 * This source code is licensed under the ISC license. 244 * See the LICENSE file in the root directory of this source tree. 245 */const aE=_e("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);/** 246 * @license lucide-react v0.462.0 - ISC 247 * 248 * This source code is licensed under the ISC license. 249 * See the LICENSE file in the root directory of this source tree. 250 */const XF=_e("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);/** 251 * @license lucide-react v0.462.0 - ISC 252 * 253 * This source code is licensed under the ISC license. 254 * See the LICENSE file in the root directory of this source tree. 255 */const Gx=_e("FileSpreadsheet",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);/** 256 * @license lucide-react v0.462.0 - ISC 257 * 258 * This source code is licensed under the ISC license. 259 * See the LICENSE file in the root directory of this source tree. 260 */const ir=_e("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"}]]);/** 261 * @license lucide-react v0.462.0 - ISC 262 * 263 * This source code is licensed under the ISC license. 264 * See the LICENSE file in the root directory of this source tree. 265 */const ZF=_e("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/** 266 * @license lucide-react v0.462.0 - ISC 267 * 268 * This source code is licensed under the ISC license. 269 * See the LICENSE file in the root directory of this source tree. 270 */const mc=_e("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** 271 * @license lucide-react v0.462.0 - ISC 272 * 273 * This source code is licensed under the ISC license. 274 * See the LICENSE file in the root directory of this source tree. 275 */const JF=_e("FolderDown",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}
275],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m15 13-3 3-3-3",key:"6j2sf0"}]]);/** 276 * @license lucide-react v0.462.0 - ISC 277 * 278 * This source code is licensed under the ISC license. 279 * See the LICENSE file in the root directory of this source tree. 280 */const iE=_e("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/** 281 * @license lucide-react v0.462.0 - ISC 282 * 283 * This source code is licensed under the ISC license. 284 * See the LICENSE file in the root directory of this source tree. 285 */const yr=_e("Gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]);/** 286 * @license lucide-react v0.462.0 - ISC 287 * 288 * This source code is licensed under the ISC license. 289 * See the LICENSE file in the root directory of this source tree. 290 */const Tc=_e("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** 291 * @license lucide-react v0.462.0 - ISC 292 * 293 * This source code is licensed under the ISC license. 294 * See the LICENSE file in the root directory of this source tree. 295 */const oE=_e("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** 296 * @license lucide-react v0.462.0 - ISC 297 * 298 * This source code is licensed under the ISC license. 299 * See the LICENSE file in the root directory of this source tree. 300 */const Su=_e("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** 301 * @license lucide-react v0.462.0 - ISC 302 * 303 * This source code is licensed under the ISC license. 304 * See the LICENSE file in the root directory of this source tree. 305 */const Nw=_e("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"}]]);/** 306 * @license lucide-react v0.462.0 - ISC 307 * 308 * This source code is licensed under the ISC license. 309 * See the LICENSE file in the root directory of this source tree. 310 */const eL=_e("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"}]]);/** 311 * @license lucide-react v0.462.0 - ISC 312 * 313 * This source code is licensed under the ISC license. 314 * See the LICENSE file in the root directory of this source tree. 315 */const gl=_e("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"}]]);/** 316 * @license lucide-react v0.462.0 - ISC 317 * 318 * This source code is licensed under the ISC license. 319 * See the LICENSE file in the root directory of this source tree. 320 */const pi=_e("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"}]]);/** 321 * @license lucide-react v0.462.0 - ISC 322 * 323 * This source code is licensed under the ISC license. 324 * See the LICENSE file in the root directory of this source tree. 325 */const z4=_e("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/** 326 * @license lucide-react v0.462.0 - ISC 327 * 328 * This source code is licensed under the ISC license. 329 * See the LICENSE file in the root directory of this source tree. 330 */const hc=_e("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** 331 * @license lucide-react v0.462.0 - ISC 332 * 333 * This source code is licensed under the ISC license. 334 * See the LICENSE file in the root directory of this source tree. 335 */const lE=_e("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);/** 336 * @license lucide-react v0.462.0 - ISC 337 * 338 * This source code is licensed under the ISC license. 339 * See the LICENSE file in the root directory of this source tree.
340 */const tL=_e("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"}]]);/** 341 * @license lucide-react v0.462.0 - ISC 342 * 343 * This source code is licensed under the ISC license. 344 * See the LICENSE file in the root directory of this source tree. 345 */const _w=_e("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** 346 * @license lucide-react v0.462.0 - ISC 347 * 348 * This source code is licensed under the ISC license. 349 * See the LICENSE file in the root directory of this source tree. 350 */const U4=_e("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** 351 * @license lucide-react v0.462.0 - ISC 352 * 353 * This source code is licensed under the ISC license. 354 * See the LICENSE file in the root directory of this source tree. 355 */const Sw=_e("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** 356 * @license lucide-react v0.462.0 - ISC 357 * 358 * This source code is licensed under the ISC license. 359 * See the LICENSE file in the root directory of this source tree. 360 */const cE=_e("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);/** 361 * @license lucide-react v0.462.0 - ISC 362 * 363 * This source code is licensed under the ISC license. 364 * See the LICENSE file in the root directory of this source tree. 365 */const Kb=_e("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/** 366 * @license lucide-react v0.462.0 - ISC 367 * 368 * This source code is licensed under the ISC license. 369 * See the LICENSE file in the root directory of this source tree. 370 */const it=_e("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** 371 * @license lucide-react v0.462.0 - ISC 372 * 373 * This source code is licensed under the ISC license. 374 * See the LICENSE file in the root directory of this source tree. 375 */const Cu=_e("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"}]]);/** 376 * @license lucide-react v0.462.0 - ISC 377 * 378 * This source code is licensed under the ISC license. 379 * See the LICENSE file in the root directory of this source tree. 380 */const Qb=_e("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"}]]);/** 381 * @license lucide-react v0.462.0 - ISC 382 * 383 * This source code is licensed under the ISC license. 384 * See the LICENSE file in the root directory of this source tree. 385 */const ar=_e("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"}]]);/** 386 * @license lucide-react v0.462.0 - ISC 387 * 388 * This source code is licensed under the ISC license. 389 * See the LICENSE file in the root directory of this source tree. 390 */const _t=_e("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"}]]);/** 391 * @license lucide-react v0.462.0 - ISC 392 * 393 * This source code is licensed under the ISC license. 394 * See the LICENSE file in the root directory of this source tree. 395 */const sL=_e("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/** 396 * @license lucide-react v0.462.0 - ISC 397 * 398 * This source code is licensed under the ISC license. 399 * See the LICENSE file in the root directory of this source tree. 400 */const dE=_e("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** 401 * @license lucide-react v0.462.0 - ISC 402 * 403 * This source code is licensed under the ISC license. 404 * See the LICENSE file in the root directory of this source tree. 405 */const Xo=_e("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"}]]);/** 406 * @license lucide-react v0.462.0 - ISC 407 * 408 * This source code is licensed under the ISC license. 409 * See the LICENSE file in the root directory of this source tree. 410 */const rL=_e("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/** 411 * @license lucide-react v0.462.0 - ISC 412 * 413 * This source code is licensed under the ISC license. 414 * See the LICENSE file in the root directory of this source tree. 415 */const nL=_e("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"}]]);/** 416 * @license lucide-react v0.462.0 - ISC 417 * 418 * This source code is licensed under the ISC license. 419 * See the LICENSE file in the root directory of this source tree. 420 */const aL=_e("Music2",[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]]);/** 421 * @license lucide-react v0.462.0 - ISC 422 * 423 * This source code is licensed under the ISC license. 424 * See the LICENSE file in the root directory of this source tree. 425 */const Dc=_e("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);/** 426 * @license lucide-react v0.462.0 - ISC 427 * 428 * This source code is licensed under the ISC license. 429 * See the LICENSE file in the root directory of this source tree. 430 */const _f=_e("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"}]]);/** 431 * @license lucide-react v0.462.0 - ISC 432 * 433 * This source code is licensed under the ISC license. 434 * See the LICENSE file in the root directory of this source tree. 435 */const Wi=_e("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/** 436 * @license lucide-react v0.462.0 - ISC 437 * 438 * This source code is licensed under the ISC license. 439 * See the LICENSE file in the root directory of this source tree. 440 */const iL=_e("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/** 441 * @license lucide-react v0.462.0 - ISC 442 * 443 * This source code is licensed under the ISC license. 444 * See the LICENSE file in the root directory of this source tree. 445 */const V4=_e("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);/** 446 * @license lucide-react v0.462.0 - ISC 447 * 448 * This source code is licensed under the ISC license. 449 * See the LICENSE file in the root directory of this source tree. 450 */const Cw=_e("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"}]]);/** 451 * @license lucide-react v0.462.0 - ISC 452 * 453 * This source code is licensed under the ISC license. 454 * See the LICENSE file in the root directory of this source tree. 455 */const oL=_e("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/** 456 * @license lucide-react v0.462.0 - ISC 457 * 458 * This source code is licensed under the ISC license. 459 * See the LICENSE file in the root directory of this source tree. 460 */const ra=_e("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"}]]);/** 461 * @license lucide-react v0.462.0 - ISC 462 * 463 * This source code is licensed under the ISC license. 464 * See the LICENSE file in the root directory of this source tree. 465 */const lL=_e("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);/** 466 * @license lucide-react v0.462.0 - ISC 467 * 468 * This source code is licensed under the ISC license. 469 * See the LICENSE file in the root directory of this source tree. 470 */const zr=_e("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"}]]);/** 471 * @license lucide-react v0.462.0 - ISC 472 * 473 * This source code is licensed under the ISC license. 474 * See the LICENSE file in the root directory of this source tree. 475 */const Xt=_e("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** 476 * @license lucide-react v0.462.0 - ISC 477 * 478 * This source code is licensed under the ISC license. 479 * See the LICENSE file in the root directory of this source tree. 480 */const Yx=_e("PoundSterling",[["path",{d:"M18 7c0-5.333-8-5.333-8 0",key:"1prm2n"}],["path",{d:"M10 7v14",key:"18tmcs"}],["path",{d:"M6 21h12",key:"4dkmi1"}],["path",{d:"M6 13h10",key:"ybwr4a"}]]);/** 481 * @license lucide-react v0.462.0 - ISC 482 * 483 * This source code is licensed under the ISC license. 484 * See the LICENSE file in the root directory of this source tree. 485 */const cL=_e("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/** 486 * @license lucide-react v0.462.0 - ISC 487 * 488 * This source code is licensed under the ISC license. 489 * See the LICENSE file in the root directory of this source tree. 490 */const kw=_e("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"}]]);/** 491 * @license lucide-react v0.462.0 - ISC 492 * 493 * This source code is licensed under the ISC license. 494 * See the LICENSE file in the root directory of this source tree.
495 */const dL=_e("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** 496 * @license lucide-react v0.462.0 - ISC 497 * 498 * This source code is licensed under the ISC license. 499 * See the LICENSE file in the root directory of this source tree. 500 */const q4=_e("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"}]]);/** 501 * @license lucide-react v0.462.0 - ISC 502 * 503 * This source code is licensed under the ISC license. 504 * See the LICENSE file in the root directory of this source tree. 505 */const uL=_e("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"}]]);/** 506 * @license lucide-react v0.462.0 - ISC 507 * 508 * This source code is licensed under the ISC license. 509 * See the LICENSE file in the root directory of this source tree. 510 */const Ur=_e("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** 511 * @license lucide-react v0.462.0 - ISC 512 * 513 * This source code is licensed under the ISC license. 514 * See the LICENSE file in the root directory of this source tree. 515 */const $w=_e("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"}]]);/** 516 * @license lucide-react v0.462.0 - ISC 517 * 518 * This source code is licensed under the ISC license. 519 * See the LICENSE file in the root directory of this source tree. 520 */const Ew=_e("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"}]]);/** 521 * @license lucide-react v0.462.0 - ISC 522 * 523 * This source code is licensed under the ISC license. 524 * See the LICENSE file in the root directory of this source tree. 525 */const lx=_e("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** 526 * @license lucide-react v0.462.0 - ISC 527 * 528 * This source code is licensed under the ISC license. 529 * See the LICENSE file in the root directory of this source tree. 530 */const bh=_e("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** 531 * @license lucide-react v0.462.0 - ISC 532 * 533 * This source code is licensed under the ISC license. 534 * See the LICENSE file in the root directory of this source tree. 535 */const Oa=_e("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"}]]);/** 536 * @license lucide-react v0.462.0 - ISC 537 * 538 * This source code is licensed under the ISC license. 539 * See the LICENSE file in the root directory of this source tree. 540 */const uE=_e("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}
540],["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"}]]);/** 541 * @license lucide-react v0.462.0 - ISC 542 * 543 * This source code is licensed under the ISC license. 544 * See the LICENSE file in the root directory of this source tree. 545 */const mL=_e("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/** 546 * @license lucide-react v0.462.0 - ISC 547 * 548 * This source code is licensed under the ISC license. 549 * See the LICENSE file in the root directory of this source tree. 550 */const ui=_e("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** 551 * @license lucide-react v0.462.0 - ISC 552 * 553 * This source code is licensed under the ISC license. 554 * See the LICENSE file in the root directory of this source tree. 555 */const Jr=_e("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/** 556 * @license lucide-react v0.462.0 - ISC 557 * 558 * This source code is licensed under the ISC license. 559 * See the LICENSE file in the root directory of this source tree. 560 */const mE=_e("StarOff",[["path",{d:"M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43",ke
560y:"16m0ql"}],["path",{d:"M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91",key:"1vt8nq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** 561 * @license lucide-react v0.462.0 - ISC 562 * 563 * This source code is licensed under the ISC license. 564 * See the LICENSE file in the root directory of this source tree. 565 */const mr=_e("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"}]]);/** 566 * @license lucide-react v0.462.0 - ISC 567 * 568 * This source code is licensed under the ISC license. 569 * See the LICENSE file in the root directory of this source tree. 570 */const hL=_e("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"}]]);/** 571 * @license lucide-react v0.462.0 - ISC 572 * 573 * This source code is licensed under the ISC license. 574 * See the LICENSE file in the root directory of this source tree. 575 */const fc=_e("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"}]]);/** 576 * @license lucide-react v0.462.0 - ISC 577 * 578 * This source code is licensed under the ISC license. 579 * See the LICENSE file in the root directory of this source tree. 580 */const fL=_e("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);/** 581 * @license lucide-react v0.462.0 - ISC 582 * 583 * This source code is licensed under the ISC license. 584 * See the LICENSE file in the root directory of this source tree. 585 */const rv=_e("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** 586 * @license lucide-react v0.462.0 - ISC 587 * 588 * This source code is licensed under the ISC license. 589 * See the LICENSE file in the root directory of this source tree. 590 */const Pw=_e("Ticket",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]);/** 591 * @license lucide-react v0.462.0 - ISC 592 * 593 * This source code is licensed under the ISC license. 594 * See the LICENSE file in the root directory of this source tree. 595 */const cs=_e("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"}]]);/** 596 * @license lucide-react v0.462.0 - ISC 597 * 598 * This source code is licensed under the ISC license. 599 * See the LICENSE file in the root directory of this source tree. 600 */const jh=_e("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"}]]);/** 601 * @license lucide-react v0.462.0 - ISC 602 * 603 * This source code is licensed under the ISC license. 604 * See the LICENSE file in the root directory of this source tree. 605 */const mi=_e("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"}]]);/** 606 * @license lucide-react v0.462.0 - ISC 607 * 608 * This source code is licensed under the ISC license. 609 * See the LICENSE file in the root directory of this source tree. 610 */const hi=_e("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}
vendor: 4,145 bytes, lines 610-655
610],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/** 611 * @license lucide-react v0.462.0 - ISC 612 * 613 * This source code is licensed under the ISC license. 614 * See the LICENSE file in the root directory of this source tree. 615 */const Sf=_e("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** 616 * @license lucide-react v0.462.0 - ISC 617 * 618 * This source code is licensed under the ISC license. 619 * See the LICENSE file in the root directory of this source tree. 620 */const pL=_e("Twitter",[["path",{d:"M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z",key:"pff0z6"}]]);/** 621 * @license lucide-react v0.462.0 - ISC 622 * 623 * This source code is licensed under the ISC license. 624 * See the LICENSE file in the root directory of this source tree. 625 */const sn=_e("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** 626 * @license lucide-react v0.462.0 - ISC 627 * 628 * This source code is licensed under the ISC license. 629 * See the LICENSE file in the root directory of this source tree. 630 */const Aw=_e("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"}]]);/** 631 * @license lucide-react v0.462.0 - ISC 632 * 633 * This source code is licensed under the ISC license. 634 * See the LICENSE file in the root directory of this source tree. 635 */const bn=_e("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"}]]);/** 636 * @license lucide-react v0.462.0 - ISC 637 * 638 * This source code is licensed under the ISC license. 639 * See the LICENSE file in the root directory of this source tree. 640 */const ua=_e("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"}]]);/** 641 * @license lucide-react v0.462.0 - ISC 642 * 643 * This source code is licensed under the ISC license. 644 * See the LICENSE file in the root directory of this source tree. 645 */const Es=_e("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** 646 * @license lucide-react v0.462.0 - ISC 647 * 648 * This source code is licensed under the ISC license. 649 * See the LICENSE file in the root directory of this source tree. 650 */const hE=_e("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);/** 651 * @license lucide-react v0.462.0 - ISC 652 * 653 * This source code is licensed under the ISC license. 654 * See the LICENSE file in the root directory of this source tree. 655 */const xL=_e("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"}]]),Tw="-",gL=e=>{const s=yL(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{const l=o.split(Tw);return l[0]===""&&l.length!==1&&l.shift(),fE(l,s)||vL(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&n[o]?[...c,...n[o]]:c}}},fE=(e,s)=>{var o;if(e.length===0)return s.classGroupId;const r=e[0],n=s.nextPart.get(r),a=n?fE(e.slice(1),n):void 0;if(a)return a;
vendor: 5,457 bytes, line 655
655if(s.validators.length===0)return;const i=e.join(Tw);return(o=s.validators.find(({validator:l})=>l(i)))==null?void 0:o.classGroupId},H4=/^\[(.+)\]$/,vL=e=>{if(H4.test(e)){const s=H4.exec(e)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},yL=e=>{const{theme:s,prefix:r}=e,n={nextPart:new Map,validators:[]};return jL(Object.entries(e.classGroups),r).forEach(([i,o])=>{Xb(o,n,i,s)}),n},Xb=(e,s,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?s:W4(s,a);i.classGroupId=r;return}if(typeof a=="function"){if(bL(a)){Xb(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([i,o])=>{Xb(o,W4(s,i),r,n)})})},W4=(e,s)=>{let r=e;return s.split(Tw).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},bL=e=>e.isThemeGetter,jL=(e,s)=>s?e.map(([r,n])=>{const a=n.map(i=>typeof i=="string"?s+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([o,l])=>[s+o,l])):i);return[r,a]}):e,wL=e=>{if(e<1)return{get:()=>{},set:()=>{}};let s=0,r=new Map,n=new Map;const a=(i,o)=>{r.set(i,o),s++,s>e&&(s=0,n=r,r=new Map)};return{get(i){let o=r.get(i);if(o!==void 0)return o;if((o=n.get(i))!==void 0)return a(i,o),o},set(i,o){r.has(i)?r.set(i,o):a(i,o)}}},pE="!",NL=e=>{const{separator:s,experimentalParseClassName:r}=e,n=s.length===1,a=s[0],i=s.length,o=l=>{const c=[];let d=0,m=0,h;for(let b=0;b<l.length;b++){let w=l[b];if(d===0){if(w===a&&(n||l.slice(b,b+i)===s)){c.push(l.slice(m,b)),m=b+i;continue}if(w==="/"){h=b;continue}}w==="["?d++:w==="]"&&d--}const f=c.length===0?l:l.substring(m),p=f.startsWith(pE),x=p?f.substring(1):f,g=h&&h>m?h-m:void 0;return{modifiers:c,hasImportantModifier:p,baseClassName:x,maybePostfixModifierPosition:g}};return r?l=>r({className:l,parseClassName:o}):o},_L=e=>{if(e.length<=1)return e;const s=[];let r=[];return e.forEach(n=>{n[0]==="["?(s.push(...r.sort(),n),r=[]):r.push(n)}),s.push(...r.sort()),s},SL=e=>({cache:wL(e.cacheSize),parseClassName:NL(e),...gL(e)}),CL=/\s+/,kL=(e,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,i=[],o=e.trim().split(CL);let l="";for(let c=o.length-1;c>=0;c-=1){const d=o[c],{modifiers:m,hasImportantModifier:h,baseClassName:f,maybePostfixModifierPosition:p}=r(d);let x=!!p,g=n(x?f.substring(0,p):f);if(!g){if(!x){l=d+(l.length>0?" "+l:l);continue}if(g=n(f),!g){l=d+(l.length>0?" "+l:l);continue}x=!1}const b=_L(m).join(":"),w=h?b+pE:b,j=w+g;if(i.includes(j))continue;i.push(j);const y=a(g,x);for(let v=0;v<y.length;++v){const N=y[v];i.push(w+N)}l=d+(l.length>0?" "+l:l)}return l};function $L(){let e=0,s,r,n="";for(;e<arguments.length;)(s=arguments[e++])&&(r=xE(s))&&(n&&(n+=" "),n+=r);return n}const xE=e=>{if(typeof e=="string")return e;let s,r="";for(let n=0;n<e.length;n++)e[n]&&(s=xE(e[n]))&&(r&&(r+=" "),r+=s);return r};function EL(e,...s){let r,n,a,i=o;function o(c){const d=s.reduce((m,h)=>h(m),e());return r=SL(d),n=r.cache.get,a=r.cache.set,i=l,l(c)}function l(c){const d=n(c);if(d)return d;const m=kL(c,r);return a(c,m),m}return function(){return i($L.apply(null,arguments))}}const Ss=e=>{const s=r=>r[e]||[];return s.isThemeGetter=!0,s},gE=/^\[(?:([a-z-]+):)?(.+)\]$/i,PL=/^\d+\/\d+$/,AL=new Set(["px","full","screen"]),TL=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,DL=/\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$/,RL=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,ML=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,OL=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_i=e=>Cd(e)||AL.has(e)||PL.test(e),oo=e=>ku(e,"length",qL),Cd=e=>!!e&&!Number.isNaN(Number(e)),Fy=e=>ku(e,"number",Cd),om=e=>!!e&&Number.isInteger(Number(e)),IL=e=>e.endsWith("%")&&Cd(e.slice(0,-1)),At=e=>gE.test(e),lo=e=>TL.test(e),FL=new Set(["length","size","percentage"]),LL=e=>ku(e,FL,vE),BL=e=>ku(e,"position",vE),zL=new Set(["image","url"]),UL=e=>ku(e,zL,WL),VL=e=>ku(e,"",HL),lm=()=>!0,ku=(e,s,r)=>{const n=gE.exec(e);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},qL=e=>DL.test(e)&&!RL.test(e),vE=()=>!1,HL=e=>ML.test(e),WL=e=>OL.test(e),GL=()=>{const e=Ss("colors"),s=Ss("spacing"),r=Ss("blur"),n=Ss("brightness"),a=Ss("borderColor"),i=Ss("borderRadius"),o=Ss("borderSpacing"),l=Ss("borderWidth"),c=Ss("contrast"),d=Ss("grayscale"),m=Ss("hueRotate"),h=Ss("invert"),f=Ss("gap"),p=Ss("gradientColorStops"),x=Ss("gradientColorStopPositions"),g=Ss("inset"),b=Ss("margin"),w=Ss("opacity"),j=Ss("padding"),y=Ss("saturate"),v=Ss("scale"),N=Ss("sepia"),S=Ss("skew"),k=Ss("space"),$=Ss("translate"),R=()=>["auto","contain","none"],A=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto",At,s],P=()=>[At,s],B=()=>["",_i,oo],Y=()=>["auto",Cd,At],I=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],C=()=>["solid","dashed","dotted","double","none"],L=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],D=()=>["start","end","center","between","around","evenly","stretch"],_=()=>["","0",At],H=()=>["auto","avoid","all","avoid-page","page","left","right","column"],O=()=>[Cd,At];return{cacheSize:500,separator:":",theme:{colors:[lm],spacing:[_i,oo],blur:["none","",lo,At],brightness:O(),borderColor:[e],borderRadius:["n
655one","","full",lo,At],borderSpacing:P(),borderWidth:B(),contrast:O(),grayscale:_(),hueRotate:O(),invert:_(),gap:P(),gradientColorStops:[e],gradientColorStopPositions:[IL,oo],inset:T(),margin:T(),opacity:O(),padding:P(),saturate:O(),scale:O(),sepia:_(),skew:O(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",At]}],container:["container"],columns:[{columns:[lo]}],"break-after":[{"break-after":H()}],"break-before":[{"break-before":H()}],"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:[...I(),At]}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",om,At]}],basis:[{basis:T()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",At]}],grow:[{grow:_()}],shrink:[{shrink:_()}],order:[{order:["first","last","none",om,At]}],"grid-cols":[{"grid-cols":[lm]}],"col-start-end":[{col:["auto",{span:["full",om,At]},At]}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":[lm]}],"row-start-end":[{row:["auto",{span:[om,At]},At]}],"row-start":[{"row-start":Y()}],"row-end":[{"row-end":Y()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",At]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",At]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...D()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...D(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...D(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[j]}],px:[{px:[j]}],py:[{py:[j]}],ps:[{ps:[j]}],pe:[{pe:[j]}],pt:[{pt:[j]}],pr:[{pr:[j]}],pb:[{pb:[j]}],pl:[{pl:[j]}],m:[{m:[b]}],mx:[{mx:[b]}],my:[{my:[b]}],ms:[{ms:[b]}],me:[{me:[b]}],mt:[{mt:[b]}],mr:[{mr:[b]}],mb:[{mb:[b]}],ml:[{ml:[b]}],"space-x":[{"space-x":[k]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[k]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",At,s]}],"min-w":[{"min-w":[At,s,"min","max","fit"]}],"max-w":[{"max-w":[At,s,"none","full","min","max","fit","prose",{screen:[lo]},lo]}],h:[{h:[At,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[At,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[At,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[At,s,"auto","min","max","fit"]}],"font-size":[{text:["base",lo,oo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Fy]}],"font-family":[{font:[lm]}],"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-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",At]}],"line-clamp":[{"line-clamp":["none",Cd,Fy]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",_i,At]}],"list-image":[{"list-image":["none",At]}],"list-style-type":[{list:["none","disc","decimal",At]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[w]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[w]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...C(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",_i,oo]}],"underline-offset":[{"underline-offset":["auto",_i,At]}],"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:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",At]}],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",At]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[w]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...I(),BL]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",LL]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},UL]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[x]}
vendor: 5,180 bytes, line 655
655],"gradient-via-pos":[{via:[x]}],"gradient-to-pos":[{to:[x]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"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":[w]}],"border-style":[{border:[...C(),"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":[w]}],"divide-style":[{divide:C()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...C()]}],"outline-offset":[{"outline-offset":[_i,At]}],"outline-w":[{outline:[_i,oo]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:B()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[w]}],"ring-offset-w":[{"ring-offset":[_i,oo]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",lo,VL]}],"shadow-color":[{shadow:[lm]}],opacity:[{opacity:[w]}],"mix-blend":[{"mix-blend":[...L(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":L()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",lo,At]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[m]}],invert:[{invert:[h]}],saturate:[{saturate:[y]}],sepia:[{sepia:[N]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[m]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[w]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"backdrop-sepia":[{"backdrop-sepia":[N]}],"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",At]}],duration:[{duration:O()}],ease:[{ease:["linear","in","out","in-out",At]}],delay:[{delay:O()}],animate:[{animate:["none","spin","ping","pulse","bounce",At]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[v]}],"scale-x":[{"scale-x":[v]}],"scale-y":[{"scale-y":[v]}],rotate:[{rotate:[om,At]}],"translate-x":[{"translate-x":[$]}],"translate-y":[{"translate-y":[$]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",At]}],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",At]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"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"]}
vendor: 4,647 bytes, line 655
655],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",At]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[_i,oo,Fy]}],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"]}}},YL=EL(GL);function oe(...e){return YL(eE(e))}const KL=VF,yE=u.forwardRef(({className:e,...s},r)=>t.jsx(G$,{ref:r,className:oe("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...s}));yE.displayName=G$.displayName;const QL=fa("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"}}),bE=u.forwardRef(({className:e,variant:s,...r},n)=>t.jsx(Y$,{ref:n,className:oe(QL({variant:s}),e),...r}));bE.displayName=Y$.displayName;const XL=u.forwardRef(({className:e,...s},r)=>t.jsx(X$,{ref:r,className:oe("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 hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...s}));XL.displayName=X$.displayName;const jE=u.forwardRef(({className:e,...s},r)=>t.jsx(Z$,{ref:r,className:oe("absolute right-2 top-2 rounded-md p-1 text-foreground
655/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...s,children:t.jsx(Es,{className:"h-4 w-4"})}));jE.displayName=Z$.displayName;const wE=u.forwardRef(({className:e,...s},r)=>t.jsx(K$,{ref:r,className:oe("text-sm font-semibold",e),...s}));wE.displayName=K$.displayName;const NE=u.forwardRef(({className:e,...s},r)=>t.jsx(Q$,{ref:r,className:oe("text-sm opacity-90",e),...s}));NE.displayName=Q$.displayName;function ZL(){const{toasts:e}=rt();return t.jsxs(KL,{children:[e.map(function({id:s,title:r,description:n,action:a,...i}){return t.jsxs(bE,{...i,children:[t.jsxs("div",{className:"grid gap-1",children:[r&&t.jsx(wE,{children:r}),n&&t.jsx(NE,{children:n})]}),a,t.jsx(jE,{})]},s)}),t.jsx(yE,{})]})}var G4=["light","dark"],JL="(prefers-color-scheme: dark)",eB=u.createContext(void 0),tB={setTheme:e=>{},themes:[]},sB=()=>{var e;return(e=u.useContext(eB))!=null?e:tB};u.memo(({forcedTheme:e,storageKey:s,attribute:r,enableSystem:n,enableColorScheme:a,defaultTheme:i,value:o,attrs:l,nonce:c})=>{let d=i==="system",m=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${l.map(x=>`'${x}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,h=a?G4.includes(i)&&i?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${i}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",f=(x,g=!1,b=!0)=>{let w=o?o[x]:x,j=g?x+"|| ''":`'${w}'`,y="";return a&&b&&!g&&G4.includes(x)&&(y+=`d.style.colorScheme = '${x}';`),r==="class"?g||w?y+=`c.add(${j})`:y+="null":w&&(y+=`d[s](n,${j})`),y},p=e?`!function(){${m}${f(e)}}()`:n?`!function(){try{${m}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${d})){var t='${JL}',m=window.matchMedia(t);if(m.media!==t||m.matches){${f("dark")}}else{${f("light")}}}else if(e){${o?`var x=${JSON.stringify(o)};`:""}${f(o?"x[e]":"e",!0)}}${d?"":"else{"+f(i,!1,!1)+"}"}${h}}catch(e){}}()`:`!function(){try{${m}var e=localStorage.getItem('${s}');if(e){${o?`var x=${JSON.stringify(o)};`:""}${f(o?"x[e]":"e",!0)}}else{${f(i,!1,!1)};}${h}}catch(t){}}();`;return u.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:p}})});var rB=e=>{switch(e){case"success":return iB;case"info":return lB;case"warning":return oB;case"error":return cB;default:return null}},nB=Array(12).fill(0),aB=({visible:e})=>ve.createElement("div",{className:"sonner-loading-wrapper","data-visible":e},ve.createElement("div",{className:"sonner-spinner"},nB.map((s,r)=>ve.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),iB=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.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"})),oB=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ve.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"})),lB=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.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"})),cB=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.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"})),dB=()=>{let[e,s]=ve.useState(document.hidden);return ve.useEffect(()=>{let r=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),e},Zb=1,uB=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let s=this.subscribers.indexOf(e);this.subscribers.splice(s,1)}),this.publish=e=>
655{this.subscribers.forEach(s=>s(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var s;let{message:r,...n}=e,a=typeof(e==null?void 0:e.id)=="number"||((s=e.id)==null?void 0:s.length)>0?e.id:Zb++,i=this.toasts.find(l=>l.id===a),o=e.dismissible===void 0?!0:e.dismissible;return i?this.toasts=this.toasts.map(l=>l.id===a?(this.publish({...l,...e,id:a,title:r}),{...l,...e,id:a,dismissible:o,title:r}):l):this.addToast({title:r,...n,dismissible:o,id:a}),a},this.dismiss=e=>(e||this.toasts.forEach(s=>{this.subscribers.forEach(r=>r({id:s.id,dismiss:!0}))}),this.subscribers.forEach(s=>s({id:e,dismiss:!0})),e),this.message=(e,s)=>this.create({...s,message:e}),this.error=(e,s)=>this.create({...s,message:e,type:"error"}),this.success=(e,s)=>this.create({...s,type:"success",message:e}),this.info=(e,s)=>this.create({...s,type:"info",message:e}),this.warning=(e,s)=>this.create({...s,type:"warning",message:e}),this.loading=(e,s)=>this.create({...s,type:"loading",message:e}),this.promise=(e,s)=>{if(!s)return;let r;s.loading!==void 0&&(r=this.create({...s,promise:e,type:"loading",message:s.loading,description:typeof s.description!="function"?s.description:void 0}));let n=e instanceof Promise?e:e(),a=r!==void 0;return n.then(async i=>{if(hB(i)&&!i.ok){a=!1;let o=typeof s.error=="function"?await s.error(`HTTP error! status: ${i.status}`):s.error,l=typeof s.description=="function"?await s.description(`HTTP error! status: ${i.status}`):s.description;this.create({id:r,type:"error",message:o,description:l})}else if(s.success!==void 0){a=!1;let o=typeof s.success=="function"?await s.success(i):s.success,l=typeof s.description=="function"?await s.description(i):s.description;this.create({id:r,type:"success",message:o,description:l})}}).catch(async i=>{if(s.error!==void 0){a=!1;let o=typeof s.error=="function"?await s.error(i):s.error,l=typeof s.description=="function"?await s.description(i):s.description;this.create({id:r,type:"error",message:o,description:l})}}).finally(()=>{var i;a&&(this.dismiss(r),r=void 0),(i=s.finally)==null||i.call(s)}),r},this.custom=(e,s)=>{let r=(s==null?void 0:s.id)||Zb++;return this.create({jsx:e(r),id:r,...s}),r},this.subscribers=[],this.toasts=[]}},An=new uB,mB=(e,s)=>{let r=(s==null?void 0:s.id)||Zb++;return An.addToast({title:e,...s,id:r}),r},hB=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",fB=mB,pB=()=>An.toasts,ks=Object.assign(fB,{success:An.success,info:An.info,warning:An.warning,error:An.error,custom:An.custom,message:An.message,promise:An.promise,dismiss:An.dismiss,loading:An.loading},{getHistory:pB});function xB(e,{insertAt:s}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",s==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}xB(`: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}:where([data-sonner-toaster][data-x-position="right"]){right:max(var(--offset),env(safe-area-inset-right))}:where([data-sonner-toaster][data-x-position="left"]){left:max(var(--offset),env(safe-area-inset-left))}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:max(var(--offset),env(safe-area-inset-top))}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:max(var(--offset),env(safe-area-inset-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;
655left: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;background:var(--gray1);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}: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:0;right:0;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}
655: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, 0px));transition:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation:swipe-out .2s ease-out forwards}@keyframes swipe-out{0%{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount)));opacity:1}to{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount) + var(--lift) * -100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;--mobile-offset: 16px;right:var(--mobile-offset);left:var(--mobile-offset);width:100%}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset)}[data-sonner-toaster][data-y-position=bottom]{bottom:20px}[data-sonner-toaster][data-y-position=top]{top:20px}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset);right:var(--mobile-offset);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-border: hsl(0, 0%, 20%);--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-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%)} 656`);function Sp(e){return e.label!==void 0}var gB=3,vB="32px",yB=4e3,bB=356,jB=14,wB=20,NB=200;function _B(...e){return e.filter(Boolean).join(" ")}var SB=e=>{var s,r,n,a,i,o,l,c,d,m;let{invert:h,toast:f,unstyled:p,interacting:x,setHeights:g,visibleToasts:b,heights:w,index:j,toasts:y,exp
656anded:v,removeToast:N,defaultRichColors:S,closeButton:k,style:$,cancelButtonStyle:R,actionButtonStyle:A,className:T="",descriptionClassName:P="",duration:B,position:Y,gap:I,loadingIcon:C,expandByDefault:L,classNames:D,icons:_,closeButtonAriaLabel:H="Close toast",pauseWhenPageIsHidden:O,cn:U}=e,[G,E]=ve.useState(!1),[z,Z]=ve.useState(!1),[M,F]=ve.useState(!1),[ee,se]=ve.useState(!1),[le,X]=ve.useState(0),[ye,Ce]=ve.useState(0),ke=ve.useRef(null),fe=ve.useRef(null),Ee=j===0,K=j+1<=b,te=f.type,Q=f.dismissible!==!1,ae=f.className||"",me=f.descriptionClassName||"",pe=ve.useMemo(()=>w.findIndex(De=>De.toastId===f.id)||0,[w,f.id]),be=ve.useMemo(()=>{var De;return(De=f.closeButton)!=null?De:k},[f.closeButton,k]),ce=ve.useMemo(()=>f.duration||B||yB,[f.duration,B]),ie=ve.useRef(0),je=ve.useRef(0),Re=ve.useRef(0),Ae=ve.useRef(null),[Ue,Ve]=Y.split("-"),lt=ve.useMemo(()=>w.reduce((De,Le,We)=>We>=pe?De:De+Le.height,0),[w,pe]),J=dB(),Ne=f.invert||h,gt=te==="loading";je.current=ve.useMemo(()=>pe*I+lt,[pe,lt]),ve.useEffect(()=>{E(!0)},[]),ve.useLayoutEffect(()=>{if(!G)return;let De=fe.current,Le=De.style.height;De.style.height="auto";let We=De.getBoundingClientRect().height;De.style.height=Le,Ce(We),g(Ke=>Ke.find(st=>st.toastId===f.id)?Ke.map(st=>st.toastId===f.id?{...st,height:We}:st):[{toastId:f.id,height:We,position:f.position},...Ke])},[G,f.title,f.description,g,f.id]);let He=ve.useCallback(()=>{Z(!0),X(je.current),g(De=>De.filter(Le=>Le.toastId!==f.id)),setTimeout(()=>{N(f)},NB)},[f,N,g,je]);ve.useEffect(()=>{if(f.promise&&te==="loading"||f.duration===1/0||f.type==="loading")return;let De,Le=ce;return v||x||O&&J?(()=>{if(Re.current<ie.current){let We=new Date().getTime()-ie.current;Le=Le-We}Re.current=new Date().getTime()})():Le!==1/0&&(ie.current=new Date().getTime(),De=setTimeout(()=>{var We;(We=f.onAutoClose)==null||We.call(f,f),He()},Le)),()=>clearTimeout(De)},[v,x,L,f,ce,He,f.promise,te,O,J]),ve.useEffect(()=>{let De=fe.current;if(De){let Le=De.getBoundingClientRect().height;return Ce(Le),g(We=>[{toastId:f.id,height:Le,position:f.position},...We]),()=>g(We=>We.filter(Ke=>Ke.toastId!==f.id))}},[g,f.id]),ve.useEffect(()=>{f.delete&&He()},[He,f.delete]);function Te(){return _!=null&&_.loading?ve.createElement("div",{className:"sonner-loader","data-visible":te==="loading"},_.loading):C?ve.createElement("div",{className:"sonner-loader","data-visible":te==="loading"},C):ve.createElement(aB,{visible:te==="loading"})}return ve.createElement("li",{"aria-live":f.important?"assertive":"polite","aria-atomic":"true",role:"status",tabIndex:0,ref:fe,className:U(T,ae,D==null?void 0:D.toast,(s=f==null?void 0:f.classNames)==null?void 0:s.toast,D==null?void 0:D.default,D==null?void 0:D[te],(r=f==null?void 0:f.classNames)==null?void 0:r[te]),"data-sonner-toast":"","data-rich-colors":(n=f.richColors)!=null?n:S,"data-styled":!(f.jsx||f.unstyled||p),"data-mounted":G,"data-promise":!!f.promise,"data-removed":z,"data-visible":K,"data-y-position":Ue,"data-x-position":Ve,"data-index":j,"data-front":Ee,"data-swiping":M,"data-dismissible":Q,"data-type":te,"data-invert":Ne,"data-swipe-out":ee,"data-expanded":!!(v||L&&G),style:{"--index":j,"--toasts-before":j,"--z-index":y.length-j,"--offset":`${z?le:je.current}px`,"--initial-height":L?"auto":`${ye}px`,...$,...f.style},onPointerDown:De=>{gt||!Q||(ke.current=new Date,X(je.current),De.target.setPointerCapture(De.pointerId),De.target.tagName!=="BUTTON"&&(F(!0),Ae.current={x:De.clientX,y:De.clientY}))},onPointerUp:()=>{var De,Le,We,Ke;if(ee||!Q)return;Ae.current=null;let st=Number(((De=fe.current)==null?void 0:De.style.getPropertyValue("--swipe-amount").replace("px",""))||0),dt=new Date().getTime()-((Le=ke.current)==null?void 0:Le.getTime()),tt=Math.abs(st)/dt;if(Math.abs(st)>=wB||tt>.11){X(je.current),(We=f.onDismiss)==null||We.call(f,f),He(),se(!0);return}(Ke=fe.current)==null||Ke.style.setProperty("--swipe-amount","0px"),F(!1)},onPointerMove:De=>{var Le;if(!Ae.current||!Q)return;let We=De.clientY-Ae.current.y,Ke=De.clientX-Ae.current.x,st=(Ue==="top"?Math.min:Math.max)(0,We),dt=De.pointerType==="touch"?10:2;Math.abs(st)>dt?(Le=fe.current)==null||Le.style.setProperty("--swipe-amount",`${We}px`):Math.abs(Ke)>dt&&(Ae.current=null)}},be&&!f.jsx?ve.createElement("button",{"aria-label":H,"data-disabled":gt,"data-close-button":!0,onClick:gt||!Q?()=>{}:()=>{var De;He(),(De=f.onDismiss)==null||De.call(f,f)},className:U(D==null?void 0:D.closeButton,(a=f==null?void 0:f.classNames)==null?void 0:a.closeButton)},ve.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"},ve.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ve.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}
656))):null,f.jsx||ve.isValidElement(f.title)?f.jsx||f.title:ve.createElement(ve.Fragment,null,te||f.icon||f.promise?ve.createElement("div",{"data-icon":"",className:U(D==null?void 0:D.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||Te():null,f.type!=="loading"?f.icon||(_==null?void 0:_[te])||rB(te):null):null,ve.createElement("div",{"data-content":"",className:U(D==null?void 0:D.content,(o=f==null?void 0:f.classNames)==null?void 0:o.content)},ve.createElement("div",{"data-title":"",className:U(D==null?void 0:D.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},f.title),f.description?ve.createElement("div",{"data-description":"",className:U(P,me,D==null?void 0:D.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},f.description):null),ve.isValidElement(f.cancel)?f.cancel:f.cancel&&Sp(f.cancel)?ve.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||R,onClick:De=>{var Le,We;Sp(f.cancel)&&Q&&((We=(Le=f.cancel).onClick)==null||We.call(Le,De),He())},className:U(D==null?void 0:D.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,ve.isValidElement(f.action)?f.action:f.action&&Sp(f.action)?ve.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||A,onClick:De=>{var Le,We;Sp(f.action)&&(De.defaultPrevented||((We=(Le=f.action).onClick)==null||We.call(Le,De),He()))},className:U(D==null?void 0:D.actionButton,(m=f==null?void 0:f.classNames)==null?void 0:m.actionButton)},f.action.label):null))};function Y4(){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}var CB=e=>{let{invert:s,position:r="bottom-right",hotkey:n=["altKey","KeyT"],expand:a,closeButton:i,className:o,offset:l,theme:c="light",richColors:d,duration:m,style:h,visibleToasts:f=gB,toastOptions:p,dir:x=Y4(),gap:g=jB,loadingIcon:b,icons:w,containerAriaLabel:j="Notifications",pauseWhenPageIsHidden:y,cn:v=_B}=e,[N,S]=ve.useState([]),k=ve.useMemo(()=>Array.from(new Set([r].concat(N.filter(O=>O.position).map(O=>O.position)))),[N,r]),[$,R]=ve.useState([]),[A,T]=ve.useState(!1),[P,B]=ve.useState(!1),[Y,I]=ve.useState(c!=="system"?c:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),C=ve.useRef(null),L=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),D=ve.useRef(null),_=ve.useRef(!1),H=ve.useCallback(O=>{var U;(U=N.find(G=>G.id===O.id))!=null&&U.delete||An.dismiss(O.id),S(G=>G.filter(({id:E})=>E!==O.id))},[N]);return ve.useEffect(()=>An.subscribe(O=>{if(O.dismiss){S(U=>U.map(G=>G.id===O.id?{...G,delete:!0}:G));return}setTimeout(()=>{Jg.flushSync(()=>{S(U=>{let G=U.findIndex(E=>E.id===O.id);return G!==-1?[...U.slice(0,G),{...U[G],...O},...U.slice(G+1)]:[O,...U]})})})}),[]),ve.useEffect(()=>{if(c!=="system"){I(c);return}c==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?I("dark"):I("light")),typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",({matches:O})=>{I(O?"dark":"light")})},[c]),ve.useEffect(()=>{N.length<=1&&T(!1)},[N]),ve.useEffect(()=>{let O=U=>{var G,E;n.every(z=>U[z]||U.code===z)&&(T(!0),(G=C.current)==null||G.focus()),U.code==="Escape"&&(document.activeElement===C.current||(E=C.current)!=null&&E.contains(document.activeElement))&&T(!1)};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[n]),ve.useEffect(()=>{if(C.current)return()=>{D.current&&(D.current.focus({preventScroll:!0}),D.current=null,_.current=!1)}},[C.current]),N.length?ve.createElement("section",{"aria-label":`${j} ${L}`,tabIndex:-1},k.map((O,U)=>{var G;let[E,z]=O.split("-");return ve.createElement("ol",{key:O,dir:x==="auto"?Y4():x,tabIndex:-1,ref:C,className:o,"data-sonner-toaster":!0,"data-theme":Y,"data-y-position":E,"data-x-position":z,style:{"--front-toast-height":`${((G=$[0])==null?void 0:G.height)||0}px`,"--offset":typeof l=="number"?`${l}px`:l||vB,"--width":`${bB}px`,"--gap":`${g}px`,...h},onBlur:Z=>{_.current&&!Z.currentTarget.contains(Z.relatedTarget)&&(_.current=!1,D.current&&(D.current.focus({preventScroll:!0}),D.current=null))},onFocus:Z=>{Z.target instanceof HTMLElement&&Z.target.dataset.dismissible==="false"||_.current||(_.current=!0,D.current=Z.relatedTarget)},onMouseEnter:()=>T(!0),onMouseMove:()=>T(!0),onMouseLeave:()=>{P||T(!1)},onPointerDown:Z=>{Z.target instanceof HTMLElement&&Z.target.dataset.dismissible==="false"||B(!0)},onPointerUp:()=>B(!1)},N.filter(Z=>!Z.position&&U===0||Z.position===O).map((Z,M)=>{var F,ee;return ve.createElement(SB,{key:Z.id,icons:w,index:M,toast:Z,defaultRichColors:d,duration:(F=p==null?void 0:p.duration)!=null?F:m,className:p==null?void 0:p.className,descriptionClassName:p==null?void 0:p.descriptionClassName,invert:s,visibleToasts:f,closeButton:(ee=p==null?void 0:p.closeButton)!=null?ee:i,interacting:P,position:O,style:p==null?void 0:p.style,unstyled:p==null?void 0:p.unstyled,classNames:p==null?void 0:p.classNames,cancelButtonStyle:p==null?void 0:p.cancelButtonStyle,actionButtonStyle:p==null?void 0:p.actionButtonStyle,removeToast:H,toasts:N.filter(se=>se.position==Z.position),heights:$.filter(se=>se.position==Z.position),setHeights:R,expandByDefault:a,gap:g,loadingIcon:b,expanded:A,pauseWhenPageIsHidden:y,cn:v})}))})):null};const kB=({...e})=>{const{theme:s="system"}=sB();return t.jsx(CB,{theme:s,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 $B=_1.useId||(()=>{}
vendor: 11,592 bytes, line 656
656),EB=0;function Lr(e){const[s,r]=u.useState($B());return qs(()=>{r(n=>n??String(EB++))},[e]),s?`radix-${s}`:""}const PB=["top","right","bottom","left"],rl=Math.min,Dn=Math.max,Kx=Math.round,Cp=Math.floor,nl=e=>({x:e,y:e}),AB={left:"right",right:"left",bottom:"top",top:"bottom"},TB={start:"end",end:"start"};function Jb(e,s,r){return Dn(e,rl(s,r))}function Gi(e,s){return typeof e=="function"?e(s):e}function Yi(e){return e.split("-")[0]}function $u(e){return e.split("-")[1]}function Dw(e){return e==="x"?"y":"x"}function Rw(e){return e==="y"?"height":"width"}function al(e){return["top","bottom"].includes(Yi(e))?"y":"x"}function Mw(e){return Dw(al(e))}function DB(e,s,r){r===void 0&&(r=!1);const n=$u(e),a=Mw(e),i=Rw(a);let o=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[i]>s.floating[i]&&(o=Qx(o)),[o,Qx(o)]}function RB(e){const s=Qx(e);return[ej(e),s,ej(s)]}function ej(e){return e.replace(/start|end/g,s=>TB[s])}function MB(e,s,r){const n=["left","right"],a=["right","left"],i=["top","bottom"],o=["bottom","top"];switch(e){case"top":case"bottom":return r?s?a:n:s?n:a;case"left":case"right":return s?i:o;default:return[]}}function OB(e,s,r,n){const a=$u(e);let i=MB(Yi(e),r==="start",n);return a&&(i=i.map(o=>o+"-"+a),s&&(i=i.concat(i.map(ej)))),i}function Qx(e){return e.replace(/left|right|bottom|top/g,s=>AB[s])}function IB(e){return{top:0,right:0,bottom:0,left:0,...e}}function _E(e){return typeof e!="number"?IB(e):{top:e,right:e,bottom:e,left:e}}function Xx(e){const{x:s,y:r,width:n,height:a}=e;return{width:n,height:a,top:r,left:s,right:s+n,bottom:r+a,x:s,y:r}}function K4(e,s,r){let{reference:n,floating:a}=e;const i=al(s),o=Mw(s),l=Rw(o),c=Yi(s),d=i==="y",m=n.x+n.width/2-a.width/2,h=n.y+n.height/2-a.height/2,f=n[l]/2-a[l]/2;let p;switch(c){case"top":p={x:m,y:n.y-a.height};break;case"bottom":p={x:m,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:h};break;case"left":p={x:n.x-a.width,y:h};break;default:p={x:n.x,y:n.y}}switch($u(s)){case"start":p[o]-=f*(r&&d?-1:1);break;case"end":p[o]+=f*(r&&d?-1:1);break}return p}const FB=async(e,s,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:i=[],platform:o}=r,l=i.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(s));let d=await o.getElementRects({reference:e,floating:s,strategy:a}),{x:m,y:h}=K4(d,n,c),f=n,p={},x=0;for(let g=0;g<l.length;g++){const{name:b,fn:w}=l[g],{x:j,y,data:v,reset:N}=await w({x:m,y:h,initialPlacement:n,placement:f,strategy:a,middlewareData:p,rects:d,platform:o,elements:{reference:e,floating:s}});m=j??m,h=y??h,p={...p,[b]:{...p[b],...v}},N&&x<=50&&(x++,typeof N=="object"&&(N.placement&&(f=N.placement),N.rects&&(d=N.rects===!0?await o.getElementRects({reference:e,floating:s,strategy:a}):N.rects),{x:m,y:h}=K4(d,f,c)),g=-1)}return{x:m,y:h,placement:f,strategy:a,middlewareData:p}};async function wh(e,s){var r;s===void 0&&(s={});const{x:n,y:a,platform:i,rects:o,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:m="viewport",elementContext:h="floating",altBoundary:f=!1,padding:p=0}=Gi(s,e),x=_E(p),b=l[f?h==="floating"?"reference":"floating":h],w=Xx(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(b)))==null||r?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:m,strategy:c})),j=h==="floating"?{x:n,y:a,width:o.floating.width,height:o.floating.height}:o.reference,y=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),v=await(i.isElement==null?void 0:i.isElement(y))?await(i.getScale==null?void 0:i.getScale(y))||{x:1,y:1}:{x:1,y:1},N=Xx(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:j,offsetParent:y,strategy:c}):j);return{top:(w.top-N.top+x.top)/v.y,bottom:(N.bottom-w.bottom+x.bottom)/v.y,left:(w.left-N.left+x.left)/v.x,right:(N.right-w.right+x.right)/v.x}}const LB=e=>({name:"arrow",options:e,async fn(s){const{x:r,y:n,placement:a,rects:i,platform:o,elements:l,middlewareData:c}=s,{element:d,padding:m=0}=Gi(e,s)||{};if(d==null)return{};const h=_E(m),f={x:r,y:n},p=Mw(a),x=Rw(p),g=await o.getDimensions(d),b=p==="y",w=b?"top":"left",j=b?"bottom":"right",y=b?"clientHeight":"clientWidth",v=i.reference[x]+i.reference[p]-f[p]-i.floating[x],N=f[p]-i.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let k=S?S[y]:0;(!k||!await(o.isElement==null?void 0:o.isElement(S)))&&(k=l.floating[y]||i.floating[x]);const $=v/2-N/2,R=k/2-g[x]/2-1,A=rl(h[w],R),T=rl(h[j],R),P=A,B=k-g[x]-T,Y=k/2-g[x]/2+$,I=Jb(P,Y,B),C=!c.arrow&&$u(a)!=null&&Y!==I&&i.reference[x]/2-(Y<P?A:T)-g[x]/2<0,L=C?Y<P?Y-P:Y-B:0;return{[p]:f[p]+L,data:{[p]:I,centerOffset:Y-I-L,...C&&{alignmentOffset:L}},reset:C}}}),BB=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(s){var r,n;const{placement:a,middlewareData:i,rects:o,initialPlacement:l,platform:c,elements:d}=s,{mainAxis:m=!0,crossAxis:h=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:g=!0,...b}=Gi(e,s);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const w=Yi(a),j=al(l),y=Yi(l)===l,v=await(c.isRTL==null?void 0:c.isRTL(d.floating)),N=f||(y||!g?[Qx(l)]:RB(l)),S=x!=="none";!f&&S&&N.push(...OB(l,g,x,v));const k=[l,...N],$=await wh(s,b),R=[];let A=((n=i.flip)==null?void 0:n.overflows)||[];if(m&&R.push($[w]),h){const Y=DB(a,o,v);R.push($[Y[0]],$[Y[1]])}if(A=[...A,{placement:a,overflows:R}],!R.every(Y=>Y<=0)){var T,P;const Y=(((T=i.flip)==null?void 0:T.index)||0)+1,I=k[Y];if(I)return{data:{index:Y,overflows:A},reset:{placement:I}};let C=(P=A.filter(L=>L.overflows[0]<=0).sort((L,D)=>L.overflows[1]-D.overflows[1])[0])==null?void 0:P.placement;if(!C)switch(p){case"bestFit":{var B;const L=(B=A.filter(D=>{if(S){const _=al(D.placement);return _===j||_==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(_=>_>0).reduce((_,H)=>_+H,0)]).sort((D,_)=>D[1]-_[1])[0])==null?void 0:B[0];L&&(C=L);break}case"initialPlacement":C=l;break}if(a!==C)return{reset:{placement:C}}}return{}}}};function Q4(e,s){return{top:e.top-s.height,right:e.right-s.width,bottom:e.bottom-s.height,left:e.left-s.width}}function X4(e){return PB.some(s=>e[s]>=0)}const zB=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=Gi(e,s);switch(n){case"referenceHidden":{const i=await wh(s,{...a,elementContext:"reference"}),o=Q4(i,r.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:X4(o)}}}case"escaped":{const i=await wh(s,{...a,altBoundary:!0}),o=Q4(i,r.floating);return{data:{escapedOffsets:o,escaped:X4(o)}}}default:return{}}}}};async function UB(e,s){const{placement:r,platform:n,elements:a}=e,i=await(n.isRTL==null?void 0:n.isRTL(a.floating)),o=Yi(r),l=$u(r),c=al(r)==="y",d=["left","top"].includes(o)?-1:1,m=i&&c?-1:1,h=Gi(s,e);let{mainAxis:f,crossAxis:p,alignmentAxis:x}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof x=="number"&&(p=l==="end"?x*-1:x),c?{x:p*m,y:f*d}:{x:f*d,y:p*m}}const VB=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(s){var r,n;const{x:a,y:i,placement:o,middlewareData:l}=s,c=await UB(s,e);return o===((r=l.offset)==null?void 0:r.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:a+c.x,y:i+c.y,data:{...c,placement:o}}}}},qB=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(s){const{x:r,y:n,placement:a}=s,{mainAxis:i=!0,crossAxis:o=!1,limiter:l={fn:b=>{let{x:w,y:j}=b;return{x:w,y:j}}},...c}=Gi(e,s),d={x:r,y:n},m=await wh(s,c),h=al(Yi(a)),f=Dw(h);let p=d[f],x=d[h];if(i){const b=f==="y"?"top":"left",w=f==="y"?"bottom":"right",j=p+m[b],y=p-m[w];p=Jb(j,p,y)}if(o){const b=h==="y"?"top":"left",w=h==="y"?"bottom":"right",j=x+m[b],y=x-m[w];x=Jb(j,x,y)}const g=l.fn({...s,[f]:p,[h]:x});return{...g,data:{x:g.x-r,y:g.y-n,enabled:{[f]:i,[h]:o}}}}}},HB=function(e){return e===void 0&&(e={}),{options:e,fn(s){const{x:r,y:n,placement:a,rects:i,middlewareData:o}=s,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=Gi(e,s),m={x:r,y:n},h=al(a),f=Dw(h);let p=m[f],x=m[h];const g=Gi(l,s),b=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const y=f==="y"?"height":"width",v=i.reference[f]-i.floating[y]+b.mainAxis,N=i.reference[f]+i.reference[y]-b.mainAxis;p<v?p=v:p>N&&(p=N)}if(d){var w,j;const y=f==="y"?"width":"height",v=["top","left"].includes(Yi(a)),N=i.reference[h]-i.floating[y]+(v&&((w=o.offset)==null?void 0:w[h])||0)+(v?0:b.crossAxis),S=i.reference[h]+i.reference[y]+(v?0:((j=o.offset)==null?void 0:j[h])||0)-(v?b.crossAxis:0);x<N?x=N:x>S&&(x=S)}return{[f]:p,[h]:x}}}},WB=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(s){var r,n;const{placement:a,rects:i,platform:o,elements:l}=s,{apply:c=()=>{},...d}=Gi(e,s),m=await wh(s,d),h=Yi(a),f=$u(a),p=al(a)==="y",{width:x,height:g}=i.floating;let b,w;h==="top"||h==="bottom"?(b=h,w=f===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(w=h,b=f==="end"?"top":"bottom");const j=g-m.top-m.bottom,y=x-m.left-m.right,v=rl(g-m[b],j),N=rl(x-m[w],y),S=!s.middlewareData.shift;let k=v,$=N;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&($=y),(n=s.middlewareData.shift)!=null&&n.enabled.y&&(k=j),S&&!f){const A=Dn(m.left,0),T=Dn(m.right,0),P=Dn(m.top,0),B=Dn(m.bottom,0);p?$=x-2*(A!==0||T!==0?A+T:Dn(m.left,m.right)):k=g-2*(P!==0||B!==0?P+B:Dn(m.top,m.bottom))}await c({...s,availableWidth:$,availableHeight:k});const R=await o.getDimensions(l.floating);return x!==R.width||g!==R.height?{reset:{rects:!0}}:{}}}};function nv(){return typeof window<"u"}function Eu(e){return SE(e)?(e.nodeName||"").toLowerCase():"#document"}function On(e){var s;return(e==null||(s=e.ownerDocument)==null?void 0:s.defaultView)||window}function bi(e){var s;return(s=(SE(e)?e.ownerDocument:e.document)||window.document)==null?void 0:s.documentElement}function SE(e){return nv()?e instanceof Node||e instanceof On(e).Node:!1}function Ia(e){return nv()?e instanceof Element||e instanceof On(e).Element:!1}function xi(e){return nv()?e instanceof HTMLElement||e instanceof On(e).HTMLElement:!1}function Z4(e){return!nv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof On(e).ShadowRoot}function Cf(e){const{overflow:s,overflowX:r,overflowY:n,display:a}=Fa(e);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!["inline","contents"].includes(a)}function GB(e){return["table","td","th"].includes(Eu(e))}function av(e){return[":popover-open",":modal"].some(s=>{try{return e.matches(s)}catch{return!1}})}function Ow(e){const s=Iw(),r=Ia(e)?Fa(e):e;return r.transform!=="none"||r.perspective!=="none"||(r.containerType?r.containerType!=="normal":!1)||!s&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!s&&(r.filter?r.filter!=="none":!1)||["transform","perspective","filter"].some(n=>(r.willChange||"").includes(n))||["paint","layout","strict","content"].some(n=>(r.contain||"").includes(n))}function YB(e){let s=il(e);for(;xi(s)&&!ru(s);){if(Ow(s))return s;if(av(s))return null;s=il(s)}return null}function Iw(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function ru(e){return["html","body","#document"].includes(Eu(e))}function Fa(e){return On(e).getComputedStyle(e)}function iv(e){return Ia(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function il(e){if(Eu(e)==="html")return e;const s=e.assignedSlot||e.parentNode||Z4(e)&&e.host||bi(e);
vendor: 6,641 bytes, line 656
656return Z4(s)?s.host:s}function CE(e){const s=il(e);return ru(s)?e.ownerDocument?e.ownerDocument.body:e.body:xi(s)&&Cf(s)?s:CE(s)}function Nh(e,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=CE(e),i=a===((n=e.ownerDocument)==null?void 0:n.body),o=On(a);if(i){const l=tj(o);return s.concat(o,o.visualViewport||[],Cf(a)?a:[],l&&r?Nh(l):[])}return s.concat(a,Nh(a,[],r))}function tj(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function kE(e){const s=Fa(e);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=xi(e),i=a?e.offsetWidth:r,o=a?e.offsetHeight:n,l=Kx(r)!==i||Kx(n)!==o;return l&&(r=i,n=o),{width:r,height:n,$:l}}function Fw(e){return Ia(e)?e:e.contextElement}function kd(e){const s=Fw(e);if(!xi(s))return nl(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:i}=kE(s);let o=(i?Kx(r.width):r.width)/n,l=(i?Kx(r.height):r.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const KB=nl(0);function $E(e){const s=On(e);return!Iw()||!s.visualViewport?KB:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function QB(e,s,r){return s===void 0&&(s=!1),!r||s&&r!==On(e)?!1:s}function pc(e,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=e.getBoundingClientRect(),i=Fw(e);let o=nl(1);s&&(n?Ia(n)&&(o=kd(n)):o=kd(e));const l=QB(i,r,n)?$E(i):nl(0);let c=(a.left+l.x)/o.x,d=(a.top+l.y)/o.y,m=a.width/o.x,h=a.height/o.y;if(i){const f=On(i),p=n&&Ia(n)?On(n):n;let x=f,g=tj(x);for(;g&&n&&p!==x;){const b=kd(g),w=g.getBoundingClientRect(),j=Fa(g),y=w.left+(g.clientLeft+parseFloat(j.paddingLeft))*b.x,v=w.top+(g.clientTop+parseFloat(j.paddingTop))*b.y;c*=b.x,d*=b.y,m*=b.x,h*=b.y,c+=y,d+=v,x=On(g),g=tj(x)}}return Xx({width:m,height:h,x:c,y:d})}function XB(e){let{elements:s,rect:r,offsetParent:n,strategy:a}=e;const i=a==="fixed",o=bi(n),l=s?av(s.floating):!1;if(n===o||l&&i)return r;let c={scrollLeft:0,scrollTop:0},d=nl(1);const m=nl(0),h=xi(n);if((h||!h&&!i)&&((Eu(n)!=="body"||Cf(o))&&(c=iv(n)),xi(n))){const f=pc(n);d=kd(n),m.x=f.x+n.clientLeft,m.y=f.y+n.clientTop}return{width:r.width*d.x,height:r.height*d.y,x:r.x*d.x-c.scrollLeft*d.x+m.x,y:r.y*d.y-c.scrollTop*d.y+m.y}}function ZB(e){return Array.from(e.getClientRects())}function sj(e,s){const r=iv(e).scrollLeft;return s?s.left+r:pc(bi(e)).left+r}function JB(e){const s=bi(e),r=iv(e),n=e.ownerDocument.body,a=Dn(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),i=Dn(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let o=-r.scrollLeft+sj(e);const l=-r.scrollTop;return Fa(n).direction==="rtl"&&(o+=Dn(s.clientWidth,n.clientWidth)-a),{width:a,height:i,x:o,y:l}}function ez(e,s){const r=On(e),n=bi(e),a=r.visualViewport;let i=n.clientWidth,o=n.clientHeight,l=0,c=0;if(a){i=a.width,o=a.height;const d=Iw();(!d||d&&s==="fixed")&&(l=a.offsetLeft,c=a.offsetTop)}return{width:i,height:o,x:l,y:c}}function tz(e,s){const r=pc(e,!0,s==="fixed"),n=r.top+e.clientTop,a=r.left+e.clientLeft,i=xi(e)?kd(e):nl(1),o=e.clientWidth*i.x,l=e.clientHeight*i.y,c=a*i.x,d=n*i.y;return{width:o,height:l,x:c,y:d}}function J4(e,s,r){let n;if(s==="viewport")n=ez(e,r);else if(s==="document")n=JB(bi(e));else if(Ia(s))n=tz(s,r);else{const a=$E(e);n={...s,x:s.x-a.x,y:s.y-a.y}}return Xx(n)}function EE(e,s){const r=il(e);return r===s||!Ia(r)||ru(r)?!1:Fa(r).position==="fixed"||EE(r,s)}function sz(e,s){const r=s.get(e);if(r)return r;let n=Nh(e,[],!1).filter(l=>Ia(l)&&Eu(l)!=="body"),a=null;const i=Fa(e).position==="fixed";let o=i?il(e):e;for(;Ia(o)&&!ru(o);){const l=Fa(o),c=Ow(o);!c&&l.position==="fixed"&&(a=null),(i?!c&&!a:!c&&l.position==="static"&&!!a&&["absolute","fixed"].includes(a.position)||Cf(o)&&!c&&EE(e,o))?n=n.filter(m=>m!==o):a=l,o=il(o)}return s.set(e,n),n}function rz(e){let{element:s,boundary:r,rootBoundary:n,strategy:a}=e;const o=[...r==="clippingAncestors"?av(s)?[]:sz(s,this._c):[].concat(r),n],l=o[0],c=o.reduce((d,m)=>{const h=J4(s,m,a);return d.top=Dn(h.top,d.top),d.right=rl(h.right,d.right),d.bottom=rl(h.bottom,d.bottom),d.left=Dn(h.left,d.left),d},J4(s,l,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function nz(e){const{width:s,height:r}=kE(e);return{width:s,height:r}}function az(e,s,r){const n=xi(s),a=bi(s),i=r==="fixed",o=pc(e,!0,i,s);let l={scrollLeft:0,scrollTop:0};const c=nl(0);if(n||!n&&!i)if((Eu(s)!=="body"||Cf(a))&&(l=iv(s)),n){const p=pc(s,!0,i,s);c.x=p.x+s.clientLeft,c.y=p.y+s.clientTop}else a&&(c.x=sj(a));let d=0,m=0;if(a&&!n&&!i){const p=a.getBoundingClientRect();m=p.top+l.scrollTop,d=p.left+l.scrollLeft-sj(a,p)}const h=o.left+l.scrollLeft-c.x-d,f=o.top+l.scrollTop-c.y-m;return{x:h,y:f,width:o.width,height:o.height}}function Ly(e){return Fa(e).position==="static"}function eS(e,s){if(!xi(e)||Fa(e).position==="fixed")return null;if(s)return s(e);let r=e.offsetParent;return bi(e)===r&&(r=r.ownerDocument.body),r}function PE(e,s){const r=On(e);if(av(e))return r;if(!xi(e)){let a=il(e);for(;a&&!ru(a);){if(Ia(a)&&!Ly(a))return a;a=il(a)}return r}let n=eS(e,s);for(;n&&GB(n)&&Ly(n);)n=eS(n,s);return n&&ru(n)&&Ly(n)&&!Ow(n)?r:n||YB(e)||r}const iz=async function(e){const s=this.getOffsetParent||PE,r=this.getDimensions,n=await r(e.floating);return{reference:az(e.reference,await s(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function oz(e){return Fa(e).direction==="rtl"}const lz={convertOffsetParentRelativeRectToViewportRelativeRect:XB,getDocumentElement:bi,getClippingRect:rz,getOffsetParent:PE,getElementRects:iz,getClientRects:ZB,getDimensions:nz,getScale:kd,isElement:Ia,isRTL:oz};function cz(e,s){let r=null,n;const a=bi(e);function i(){var l;clearTimeout(n),(l=r)==null||l.disconnect(),r=null}function o(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),i();const{left:d,top:m,width:h,height:f}=e.getBoundingClientRect();if(l||s(),!h||!f)return;const p=Cp(m),x=Cp(a.clientWidth-(d+h)),g=Cp(a.clientHeight-(m+f)),b=Cp(d),j={rootMargin:-p+"px "+-x+"px "+-g+"px "+-b+"px",threshold:Dn(0,rl(1,c))||1};let y=!0;function v(N){const S=N[0].intersectionRatio;if(S!==c){if(!y)return o();S?o(!1,S):n=setTimeout(()=>{o(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(v,{...j,root:a.ownerDocument})}catch{r=new IntersectionObserver(v,j)}r.observe(e)}return o(!0),i}function dz(e,s,r,n){n===void 0&&(n={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,d=Fw(e),m=a||i?[...d?Nh(d):[],...Nh(s)]:[];m.forEach(w=>{a&&w.addEventListener("scroll",r,{passive:!0}),i&&w.addEventListener("resize",r)});const h=d&&l?cz(d,r):null;let f=-1,p=null;o&&(p=new ResizeObserver(w=>
vendor: 4,724 bytes, line 656
656{let[j]=w;j&&j.target===d&&p&&(p.unobserve(s),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(s)})),r()}),d&&!c&&p.observe(d),p.observe(s));let x,g=c?pc(e):null;c&&b();function b(){const w=pc(e);g&&(w.x!==g.x||w.y!==g.y||w.width!==g.width||w.height!==g.height)&&r(),g=w,x=requestAnimationFrame(b)}return r(),()=>{var w;m.forEach(j=>{a&&j.removeEventListener("scroll",r),i&&j.removeEventListener("resize",r)}),h==null||h(),(w=p)==null||w.disconnect(),p=null,c&&cancelAnimationFrame(x)}}const uz=VB,mz=qB,hz=BB,fz=WB,pz=zB,tS=LB,xz=HB,gz=(e,s,r)=>{const n=new Map,a={platform:lz,...r},i={...a.platform,_c:n};return FB(e,s,{...a,platform:i})};var cx=typeof document<"u"?u.useLayoutEffect:u.useEffect;function Zx(e,s){if(e===s)return!0;if(typeof e!=typeof s)return!1;if(typeof e=="function"&&e.toString()===s.toString())return!0;let r,n,a;if(e&&s&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==s.length)return!1;for(n=r;n--!==0;)if(!Zx(e[n],s[n]))return!1;return!0}if(a=Object.keys(e),r=a.length,r!==Object.keys(s).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(s,a[n]))return!1;for(n=r;n--!==0;){const i=a[n];if(!(i==="_owner"&&e.$$typeof)&&!Zx(e[i],s[i]))return!1}return!0}return e!==e&&s!==s}function AE(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function sS(e,s){const r=AE(e);return Math.round(s*r)/r}function By(e){const s=u.useRef(e);return cx(()=>{s.current=e}),s}function vz(e){e===void 0&&(e={});const{placement:s="bottom",strategy:r="absolute",middleware:n=[],platform:a,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[m,h]=u.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[f,p]=u.useState(n);Zx(f,n)||p(n);const[x,g]=u.useState(null),[b,w]=u.useState(null),j=u.useCallback(D=>{D!==S.current&&(S.current=D,g(D))},[]),y=u.useCallback(D=>{D!==k.current&&(k.current=D,w(D))},[]),v=i||x,N=o||b,S=u.useRef(null),k=u.useRef(null),$=u.useRef(m),R=c!=null,A=By(c),T=By(a),P=By(d),B=u.useCallback(()=>{if(!S.current||!k.current)return;const D={placement:s,strategy:r,middleware:f};T.current&&(D.platform=T.current),gz(S.current,k.current,D).then(_=>{const H={..._,isPositioned:P.current!==!1};Y.current&&!Zx($.current,H)&&($.current=H,yn.flushSync(()=>{h(H)}))})},[f,s,r,T,P]);cx(()=>{d===!1&&$.current.isPositioned&&($.current.isPositioned=!1,h(D=>({...D,isPositioned:!1})))},[d]);const Y=u.useRef(!1);cx(()=>(Y.current=!0,()=>{Y.current=!1}),[]),cx(()=>{if(v&&(S.current=v),N&&(k.current=N),v&&N){if(A.current)return A.current(v,N,B);B()}},[v,N,B,A,R]);const I=u.useMemo(()=>({reference:S,floating:k,setReference:j,setFloating:y}),[j,y]),C=u.useMemo(()=>({reference:v,floating:N}),[v,N]),L=u.useMemo(()=>{const D={position:r,left:0,top:0};if(!C.floating)return D;const _=sS(C.floating,m.x),H=sS(C.floating,m.y);return l?{...D,transform:"translate("+_+"px, "+H+"px)",...AE(C.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:_,top:H}},[r,l,C.floating,m.x,m.y]);return u.useMemo(()=>({...m,update:B,refs:I,elements:C,floatingStyles:L}),[m,B,I,C,L])}const yz=e=>{function s(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:n,padding:a}=typeof e=="function"?e(r):e;return n&&s(n)?n.current!=null?tS({element:n.current,padding:a}).fn(r):{}:n?tS({element:n,padding:a}).fn(r):{}}}},bz=(e,s)=>({...uz(e),options:[e,s]}),jz=(e,s)=>({...mz(e),options:[e,s]}),wz=(e,s)=>({...xz(e),options:[e,s]}),Nz=(e,s)=>({...hz(e),options:[e,s]}),_z=(e,s)=>({...fz(e),options:[e,s]}),Sz=(e,s)=>({...pz(e),options:[e,s]}),Cz=(e,s)=>({...yz(e),options:[e,s]});var kz="Arrow",TE=u.forwardRef((e,s)=>{const{children:r,width:n=10,height:a=5,...i}=e;return t.jsx(ze.svg,{...i,ref:s,width:n,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});TE.displayName=kz;var $z=TE;function Ez(e,s=[]){let r=[];function n(i,o){const l=u.createContext(o),c=r.length;r=[...r,o];function d(h){const{scope:f,children:p,...x}=h,g=(f==null?void 0:f[e][c])||l,b=u.useMemo(()=>x,Object.values(x));return t.jsx(g.Provider,{value:b,children:p})}function m(h,f){const p=(f==null?void 0:f[e][c])||l,x=u.useContext(p);if(x)return x;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return d.displayName=i+"Provider",[d,m]}const a=()=>{const i=r.map(o=>u.createContext(o));return function(l){const c=(l==null?void 0:l[e])||i;return u.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[n,Pz(a,...s)]}function Pz(...e){const s=e[0];if(e.length===1)return s;const r=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));
vendor: 8,237 bytes, line 656
656return function(i){const o=n.reduce((l,{useScope:c,scopeName:d})=>{const h=c(i)[`__scope${d}`];return{...l,...h}},{});return u.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return r.scopeName=s.scopeName,r}function kf(e){const[s,r]=u.useState(void 0);return qs(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let o,l;if("borderBoxSize"in i){const c=i.borderBoxSize,d=Array.isArray(c)?c[0]:c;o=d.inlineSize,l=d.blockSize}else o=e.offsetWidth,l=e.offsetHeight;r({width:o,height:l})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),s}var Lw="Popper",[DE,vl]=Ez(Lw),[Az,RE]=DE(Lw),ME=e=>{const{__scopePopper:s,children:r}=e,[n,a]=u.useState(null);return t.jsx(Az,{scope:s,anchor:n,onAnchorChange:a,children:r})};ME.displayName=Lw;var OE="PopperAnchor",IE=u.forwardRef((e,s)=>{const{__scopePopper:r,virtualRef:n,...a}=e,i=RE(OE,r),o=u.useRef(null),l=at(s,o);return u.useEffect(()=>{i.onAnchorChange((n==null?void 0:n.current)||o.current)}),n?null:t.jsx(ze.div,{...a,ref:l})});IE.displayName=OE;var Bw="PopperContent",[Tz,Dz]=DE(Bw),FE=u.forwardRef((e,s)=>{var M,F,ee,se,le,X;const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:i="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:m=0,sticky:h="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:x,...g}=e,b=RE(Bw,r),[w,j]=u.useState(null),y=at(s,ye=>j(ye)),[v,N]=u.useState(null),S=kf(v),k=(S==null?void 0:S.width)??0,$=(S==null?void 0:S.height)??0,R=n+(i!=="center"?"-"+i:""),A=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},T=Array.isArray(d)?d:[d],P=T.length>0,B={padding:A,boundary:T.filter(Mz),altBoundary:P},{refs:Y,floatingStyles:I,placement:C,isPositioned:L,middlewareData:D}=vz({strategy:"fixed",placement:R,whileElementsMounted:(...ye)=>dz(...ye,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[bz({mainAxis:a+$,alignmentAxis:o}),c&&jz({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?wz():void 0,...B}),c&&Nz({...B}),_z({...B,apply:({elements:ye,rects:Ce,availableWidth:ke,availableHeight:fe})=>{const{width:Ee,height:K}=Ce.reference,te=ye.floating.style;te.setProperty("--radix-popper-available-width",`${ke}px`),te.setProperty("--radix-popper-available-height",`${fe}px`),te.setProperty("--radix-popper-anchor-width",`${Ee}px`),te.setProperty("--radix-popper-anchor-height",`${K}px`)}}),v&&Cz({element:v,padding:l}),Oz({arrowWidth:k,arrowHeight:$}),f&&Sz({strategy:"referenceHidden",...B})]}),[_,H]=zE(C),O=Qt(x);qs(()=>{L&&(O==null||O())},[L,O]);const U=(M=D.arrow)==null?void 0:M.x,G=(F=D.arrow)==null?void 0:F.y,E=((ee=D.arrow)==null?void 0:ee.centerOffset)!==0,[z,Z]=u.useState();return qs(()=>{w&&Z(window.getComputedStyle(w).zIndex)},[w]),t.jsx("div",{ref:Y.setFloating,"data-radix-popper-content-wrapper":"",style:{...I,transform:L?I.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:z,"--radix-popper-transform-origin":[(se=D.transformOrigin)==null?void 0:se.x,(le=D.transformOrigin)==null?void 0:le.y].join(" "),...((X=D.hide)==null?void 0:X.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(Tz,{scope:r,placedSide:_,onArrowChange:N,arrowX:U,arrowY:G,shouldHideArrow:E,children:t.jsx(ze.div,{"data-side":_,"data-align":H,...g,ref:y,style:{...g.style,animation:L?void 0:"none"}})})})});FE.displayName=Bw;var LE="PopperArrow",Rz={top:"bottom",right:"left",bottom:"top",left:"right"},BE=u.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,i=Dz(LE,n),o=Rz[i.placedSide];return t.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:t.jsx($z,{...a,ref:r,style:{...a.style,display:"block"}})})});BE.displayName=LE;function Mz(e){return e!==null}var Oz=e=>({name:"transformOrigin",options:e,fn(s){var b,w,j;const{placement:r,rects:n,middlewareData:a}=s,o=((b=a.arrow)==null?void 0:b.centerOffset)!==0,l=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[d,m]=zE(r),h={start:"0%",center:"50%",end:"100%"}[m],f=(((w=a.arrow)==null?void 0:w.x)??0)+l/2,p=(((j=a.arrow)==null?void 0:j.y)??0)+c/2;let x="",g="";return d==="bottom"?(x=o?h:`${f}px`,g=`${-c}px`):d==="top"?(x=o?h:`${f}px`,g=`${n.floating.height+c}px`):d==="right"?(x=`${-c}px`,g=o?h:`${p}px`):d==="left"&&(x=`${n.floating.width+c}px`,g=o?h:`${p}px`),{data:{x,y:g}}}});function zE(e){const[s,r="center"]=e.split("-");return[s,r]}var ov=ME,$f=IE,lv=FE,cv=BE,[dv,nfe]=hr("Tooltip",[vl]),uv=vl(),UE="TooltipProvider",Iz=700,rj="tooltip.open",[Fz,zw]=dv(UE),VE=e=>{const{__scopeTooltip:s,delayDuration:r=Iz,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:i}=e,[o,l]=u.useState(!0),c=u.useRef(!1),d=u.useRef(0);return u.useEffect(()=>{const m=d.current;return()=>window.clearTimeout(m)},[]),t.jsx(Fz,{scope:s,isOpenDelayed:o,delayDuration:r,onOpen:u.useCallback(()=>{window.clearTimeout(d.current),l(!1)},[]),onClose:u.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l(!0),n)},[n]),isPointerInTransitRef:c,onPointerInTransitChange:u.useCallback(m=>{c.current=m},[]),disableHoverableContent:a,children:i})};VE.displayName=UE;var mv="Tooltip",[Lz,hv]=dv(mv),qE=e=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a=!1,onOpenChange:i,disableHoverableContent:o,delayDuration:l}=e,c=zw(mv,e.__scopeTooltip),d=uv(s),[m,h]=u.useState(null),f=Lr(),p=u.useRef(0),x=o??c.disableHoverableContent,g=l??c.delayDuration,b=u.useRef(!1),[w=!1,j]=wr({prop:n,defaultProp:a,onChange:k=>{k?(c.onOpen(),document.dispatchEvent(new CustomEvent(rj))):c.onClose(),i==null||i(k)}}),y=u.useMemo(()=>w?b.current?"delayed-open":"instant-open":"closed",[w]),v=u.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,j(!0)},[j]),N=u.useCallback(()=>{window.clearTimeout(p.current),p.current=0,j(!1)},[j]),S=u.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,j(!0),p.current=0},g)},[g,j]);return u.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),t.jsx(ov,{...d,children:t.jsx(Lz,{scope:s,contentId:f,open:w,stateAttribute:y,trigger:m,onTriggerChange:h,onTriggerEnter:u.useCallback(()=>{c.isOpenDelayed?S():v()},[c.isOpenDelayed,S,v]),onTriggerLeave:u.useCallback(()=>{x?N():(window.clearTimeout(p.current),p.current=0)},[N,x]),onOpen:v,onClose:N,disableHoverableContent:x,children:r})})};qE.displayName=mv;var nj="TooltipTrigger",HE=u.forwardRef((e,s)=>{const{__scopeTooltip:r,...n}=e,a=hv(nj,r),i=zw(nj,r),o=uv(r),l=u.useRef(null),c=at(s,l,a.onTriggerChange),d=u.useRef(!1),m=u.useRef(!1),h=u.useCallback(()=>d.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),t.jsx($f,{asChild:!0,...o,children:t.jsx(ze.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:c,onPointerMove:Se(e.onPointerMove,f=>{f.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(a.onTriggerEnter(),m.current=!0)}),onPointerLeave:Se(e.onPointerLeave,()=>{a.onTriggerLeave(),m.current=!1}),onPointerDown:Se(e.onPointerDown,()=>{d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Se(e.onFocus,()=>{d.current||a.onOpen()}),onBlur:Se(e.onBlur,a.onClose),onClick:Se(e.onClick,a.onClose)})})});HE.displayName=nj;var Bz="TooltipPortal",[afe,zz]=dv(Bz,{forceMount:void 0}),nu="TooltipContent",WE=u.forwardRef((e,s)=>{const r=zz(nu,e.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...i}=e,o=hv(nu,e.__scopeTooltip);return t.jsx(Ts,{present:n||o.open,children:o.disableHoverableContent?t.jsx(GE,{side:a,...i,ref:s}):t.jsx(Uz,{side:a,...i,ref:s})})}),Uz=u.forwardRef((e,s)=>{const r=hv(nu,e.__scopeTooltip),n=zw(nu,e.__scopeTooltip),a=u.useRef(null),i=at(s,a),[o,l]=u.useState(null),{trigger:c,onClose:d}=r,m=a.current,{onPointerInTransitChange:h}=n,f=u.useCallback(()=>
vendor: 4,170 bytes, line 656
656{l(null),h(!1)},[h]),p=u.useCallback((x,g)=>{const b=x.currentTarget,w={x:x.clientX,y:x.clientY},j=Wz(w,b.getBoundingClientRect()),y=Gz(w,j),v=Yz(g.getBoundingClientRect()),N=Qz([...y,...v]);l(N),h(!0)},[h]);return u.useEffect(()=>()=>f(),[f]),u.useEffect(()=>{if(c&&m){const x=b=>p(b,m),g=b=>p(b,c);return c.addEventListener("pointerleave",x),m.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",x),m.removeEventListener("pointerleave",g)}}},[c,m,p,f]),u.useEffect(()=>{if(o){const x=g=>{const b=g.target,w={x:g.clientX,y:g.clientY},j=(c==null?void 0:c.contains(b))||(m==null?void 0:m.contains(b)),y=!Kz(w,o);j?f():y&&(f(),d())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[c,m,o,d,f]),t.jsx(GE,{...e,ref:i})}),[Vz,qz]=dv(mv,{isInside:!1}),GE=u.forwardRef((e,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:i,onPointerDownOutside:o,...l}=e,c=hv(nu,r),d=uv(r),{onClose:m}=c;return u.useEffect(()=>(document.addEventListener(rj,m),()=>document.removeEventListener(rj,m)),[m]),u.useEffect(()=>{if(c.trigger){const h=f=>{const p=f.target;p!=null&&p.contains(c.trigger)&&m()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,m]),t.jsx(xl,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:t.jsxs(lv,{"data-state":c.stateAttribute,...d,...l,ref:s,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:[t.jsx(yw,{children:n}),t.jsx(Vz,{scope:r,isInside:!0,children:t.jsx(D$,{id:c.contentId,role:"tooltip",children:a||n})})]})})});WE.displayName=nu;var YE="TooltipArrow",Hz=u.forwardRef((e,s)=>{const{__scopeTooltip:r,...n}=e,a=uv(r);return qz(YE,r).isInside?null:t.jsx(cv,{...a,...n,ref:s})});Hz.displayName=YE;function Wz(e,s){const r=Math.abs(s.top-e.y),n=Math.abs(s.bottom-e.y),a=Math.abs(s.right-e.x),i=Math.abs(s.left-e.x);switch(Math.min(r,n,a,i)){case i:return"left";case a:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function Gz(e,s,r=5){const n=[];switch(s){case"top":n.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":n.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":n.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":n.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return n}function Yz(e){const{top:s,right:r,bottom:n,left:a}=e;return[{x:a,y:s},{x:r,y:s},{x:r,y:n},{x:a,y:n}]}function Kz(e,s){const{x:r,y:n}=e;let a=!1;for(let i=0,o=s.length-1;i<s.length;o=i++){const l=s[i].x,c=s[i].y,d=s[o].x,m=s[o].y;c>n!=m>n&&r<(d-l)*(n-c)/(m-c)+l&&(a=!a)}return a}function Qz(e){const s=e.slice();return s.sort((r,n)=>r.x<n.x?-1:r.x>n.x?1:r.y<n.y?-1:r.y>n.y?1:0),Xz(s)}function Xz(e){if(e.length<=1)return e.slice();const s=[];for(let n=0;n<e.length;n++){const a=e[n];for(;s.length>=2;){const i=s[s.length-1],o=s[s.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))s.pop();else break}s.push(a)}s.pop();const r=[];for(let n=e.length-1;n>=0;n--){const a=e[n];for(;r.length>=2;){const i=r[r.length-1],o=r[r.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))r.pop();else break}r.push(a)}return r.pop(),s.length===1&&r.length===1&&s[0].x===r[0].x&&s[0].y===r[0].y?s:s.concat(r)}var Zz=VE,Jz=qE,eU=HE,KE=WE;const QE=Zz,XE=Jz,ZE=eU,Uw=u.forwardRef(({className:e,sideOffset:s=4,...r},n)=>t.jsx(KE,{ref:n,sideOffset:s,className:oe("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:sli
656de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r}));Uw.displayName=KE.displayName;/** 657 * @remix-run/router v1.20.0 658 * 659 * Copyright (c) Remix Software Inc. 660 * 661 * This source code is licensed under the MIT license found in the 662 * LICENSE.md file in the root directory of this source tree. 663 * 664 * @license MIT 665 */function _h(){return _h=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_h.apply(this,arguments)}var Fo;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(Fo||(Fo={}));const rS="popstate";function tU(e){e===void 0&&(e={});function s(n,a){let{pathname:i,search:o,hash:l}=n.location;return aj("",{pathname:i,search:o,hash:l},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function r(n,a){return typeof a=="string"?a:Jx(a)}return rU(s,r,null,e)}function Us(e,s){if(e===!1||e===null||typeof e>"u")throw new Error(s)}function JE(e,s){if(!e){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function sU(){return Math.random().toString(36).substr(2,8)}function nS(e,s){return{usr:e.state,key:e.key,idx:s}}function aj(e,s,r,n){return r===void 0&&(r=null),_h({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof s=="string"?Pu(s):s,{state:r,key:s&&s.key||n||sU()})}function Jx(e){let{pathname:s="/",search:r="",hash:n=""}=e;return r&&r!=="?"&&(s+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(s+=n.charAt(0)==="#"?n:"#"+n),s}function Pu(e){let s={};if(e){let r=e.indexOf("#");r>=0&&(s.hash=e.substr(r),e=e.substr(0,r));let n=e.indexOf("?");n>=0&&(s.search=e.substr(n),e=e.substr(0,n)),e&&(s.pathname=e)}return s}function rU(e,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:i=!1}=n,o=a.history,l=Fo.Pop,c=null,d=m();d==null&&(d=0,o.replaceState(_h({},o.state,{idx:d}),""));function m(){return(o.state||{idx:null}).idx}function h(){l=Fo.Pop;let b=m(),w=b==null?null:b-d;d=b,c&&c({action:l,location:g.location,delta:w})}function f(b,w){l=Fo.Push;let j=aj(g.location,b,w);d=m()+1;let y=nS(j,d),v=g.createHref(j);try{o.pushState(y,"",v)}catch(N){if(N instanceof DOMException&&N.name==="DataCloneError")throw N;a.location.assign(v)}i&&c&&c({action:l,location:g.location,delta:1})}function p(b,w){l=Fo.Replace;let j=aj(g.location,b,w);d=m();let y=nS(j,d),v=g.createHref(j);o.replaceState(y,"",v),i&&c&&c({action:l,location:g.location,delta:0})}function x(b){let w=a.location.origin!=="null"?a.location.origin:a.location.href,j=typeof b=="string"?b:Jx(b);return j=j.replace(/ $/,"%20"),Us(w,"No window.location.(origin|href) available to create URL for href: "+j),new URL(j,w)}let g={get action(){return l},get location(){return e(a,o)},listen(b){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(rS,h),c=b,()=>{a.removeEventListener(rS,h),c=null}},createHref(b){return s(a,b)},createURL:x,encodeLocation(b){let w=x(b);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:f,replace:p,go(b){return o.go(b)}};return g}var aS;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(aS||(aS={}));function nU(e,s,r){return r===void 0&&(r="/"),aU(e,s,r,!1)}function aU(e,s,r,n){let a=typeof s=="string"?Pu(s):s,i=au(a.pathname||"/",r);if(i==null)return null;let o=e6(e);iU(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let d=gU(i);l=pU(o[c],d,n)}return l}function e6(e,s,r,n){s===void 0&&(s=[]),r===void 0&&(r=[]),n===void 0&&(n="");let a=(i,o,l)=>{let c={relativePath:l===void 0?i.path||"":l,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};c.relativePath.startsWith("/")&&(Us(c.relativePath.startsWith(n),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(n.length));let d=Zo([n,c.relativePath]),m=r.concat(c);i.children&&i.children.length>0&&(Us(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),e6(i.children,s,m,d)),!(i.path==null&&!i.index)&&s.push({path:d,score:hU(d,i.index),routesMeta:m})};return e.forEach((i,o)=>{var l;if(i.path===""||!((l=i.path)!=null&&l.includes("?")))a(i,o);else for(let c of t6(i.path))a(i,o,c)}),s}function t6(e){let s=e.split("/");if(s.length===0)return[];let[r,...n]=s,a=r.endsWith("?"),i=r.replace(/\?$/,"");if(n.length===0)return a?[i,""]:[i];let o=t6(n.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),a&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function iU(e){e.sort((s,r)=>s.score!==r.score?r.score-s.score:fU(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const oU=/^:[\w-]+$/,lU=3,cU=2,dU=1,uU=10,mU=-2,iS=e=>e==="*";function hU(e,s){let r=e.split("/"),n=r.length;return r.some(iS)&&(n+=mU),s&&(n+=cU),r.filter(a=>!iS(a)).reduce((a,i)=>a+(oU.test(i)?lU:i===""?dU:uU),n)}function fU(e,s){return e.length===s.length&&e.slice(0,-1).every((n,a)=>n===s[a])?e[e.length-1]-s[s.length-1]:0}function pU(e,s,r){let{routesMeta:n}=e,a={},i="/",o=[];for(let l=0;l<n.length;++l){let c=n[l],d=l===n.length-1,m=i==="/"?s:s.slice(i.length)||"/",h=eg({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},m),f=c.route;if(!h&&d&&r&&!n[n.length-1].route.index&&(h=eg({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},m)),!h)return null;
vendor: 9,263 bytes, lines 665-674
665Object.assign(a,h.params),o.push({params:a,pathname:Zo([i,h.pathname]),pathnameBase:jU(Zo([i,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(i=Zo([i,h.pathnameBase]))}return o}function eg(e,s){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,n]=xU(e.path,e.caseSensitive,e.end),a=s.match(r);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:n.reduce((d,m,h)=>{let{paramName:f,isOptional:p}=m;if(f==="*"){let g=l[h]||"";o=i.slice(0,i.length-g.length).replace(/(.)\/+$/,"$1")}const x=l[h];return p&&!x?d[f]=void 0:d[f]=(x||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:o,pattern:e}}function xU(e,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),JE(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 n=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(n.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(n.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,s?void 0:"i"),n]}function gU(e){try{return e.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return JE(!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 ("+s+").")),e}}function au(e,s){if(s==="/")return e;if(!e.toLowerCase().startsWith(s.toLowerCase()))return null;let r=s.endsWith("/")?s.length-1:s.length,n=e.charAt(r);return n&&n!=="/"?null:e.slice(r)||"/"}function vU(e,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof e=="string"?Pu(e):e;return{pathname:r?r.startsWith("/")?r:yU(r,s):s,search:wU(n),hash:NU(a)}}function yU(e,s){let r=s.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function zy(e,s,r,n){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+s+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function bU(e){return e.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function Vw(e,s){let r=bU(e);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function qw(e,s,r,n){n===void 0&&(n=!1);let a;typeof e=="string"?a=Pu(e):(a=_h({},e),Us(!a.pathname||!a.pathname.includes("?"),zy("?","pathname","search",a)),Us(!a.pathname||!a.pathname.includes("#"),zy("#","pathname","hash",a)),Us(!a.search||!a.search.includes("#"),zy("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=r;else{let h=s.length-1;if(!n&&o.startsWith("..")){let f=o.split("/");for(;f[0]==="..";)f.shift(),h-=1;a.pathname=f.join("/")}l=h>=0?s[h]:"/"}let c=vU(a,l),d=o&&o!=="/"&&o.endsWith("/"),m=(i||o===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(d||m)&&(c.pathname+="/"),c}const Zo=e=>e.join("/").replace(/\/\/+/g,"/"),jU=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),wU=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,NU=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function _U(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const s6=["post","put","patch","delete"];new Set(s6);const SU=["get",...s6];new Set(SU);/** 666 * React Router v6.27.0 667 * 668 * Copyright (c) Remix Software Inc. 669 * 670 * This source code is licensed under the MIT license found in the 671 * LICENSE.md file in the root directory of this source tree. 672 * 673 * @license MIT 674 */function Sh(){return Sh=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Sh.apply(this,arguments)}const fv=u.createContext(null),r6=u.createContext(null),Ji=u.createContext(null),pv=u.createContext(null),eo=u.createContext({outlet:null,matches:[],isDataRoute:!1}),n6=u.createContext(null);function CU(e,s){let{relative:r}=s===void 0?{}:s;Au()||Us(!1);let{basename:n,navigator:a}=u.useContext(Ji),{hash:i,pathname:o,search:l}=gv(e,{relative:r}),c=o;return n!=="/"&&(c=o==="/"?n:Zo([n,o])),a.createHref({pathname:c,search:l,hash:i})}function Au(){return u.useContext(pv)!=null}function Va(){return Au()||Us(!1),u.useContext(pv).location}function a6(e){u.useContext(Ji).static||u.useLayoutEffect(e)}function ds(){let{isDataRoute:e}=u.useContext(eo);return e?LU():kU()}function kU(){Au()||Us(!1);let e=u.useContext(fv),{basename:s,future:r,navigator:n}=u.useContext(Ji),{matches:a}=u.useContext(eo),{pathname:i}=Va(),o=JSON.stringify(Vw(a,r.v7_relativeSplatPath)),l=u.useRef(!1);return a6(()=>{l.current=!0}),u.useCallback(function(d,m){if(m===void 0&&(m={}),!l.current)return;if(typeof d=="number"){n.go(d);return}let h=qw(d,JSON.parse(o),i,m.relative==="path");e==null&&s!=="/"&&(h.pathname=h.pathname==="/"?s:Zo([s,h.pathname])),(m.replace?n.replace:n.push)(h,m.state,m)},[s,n,o,i,e])}function xv(){let{matches:e}=u.useContext(eo),s=e[e.length-1];return s?s.params:{}}function gv(e,s){let{relative:r}=s===void 0?{}:s,{future:n}=u.useContext(Ji),{matches:a}=u.useContext(eo),{pathname:i}=Va(),o=JSON.stringify(Vw(a,n.v7_relativeSplatPath));return u.useMemo(()=>qw(e,JSON.parse(o),i,r==="path"),[e,o,i,r])}function $U(e,s){return EU(e,s)}function EU(e,s,r,n){Au()||Us(!1);let{navigator:a}=u.useContext(Ji),{matches:i}=u.useContext(eo),o=i[i.length-1],l=o?o.params:{};o&&o.pathname;let c=o?o.pathnameBase:"/";o&&o.route;let d=Va(),m;if(s){var h;let b=typeof s=="string"?Pu(s):s;c==="/"||(h=b.pathname)!=null&&h.startsWith(c)||Us(!1),m=b}else m=d;let f=m.pathname||"/",p=f;if(c!=="/"){let b=c.replace(/^\//,"").split("/");p="/"+f.replace(/^\//,"").split("/").slice(b.length).join("/")}let x=nU(e,{pathname:p}),g=RU(x&&x.map(b=>Object.assign({},b,{params:Object.assign({},l,b.params),pathname:Zo([c,a.encodeLocation?a.encodeLocation(b.pathname).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:Zo([c,a.encodeLocation?a.encodeLocation(b.pathnameBase).pathname:b.pathnameBase])})),i,r,n);return s&&g?u.createElement(pv.Provider,{value:{location:Sh({pathname:"/",search:"",hash:"",state:null,key:"default"},m),navigationType:Fo.Pop}},g):g}function PU(){let e=FU(),s=_U(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return u.createElement(u.Fragment,null,u.createElement("h2",null,"Unexpected Application Error!"),u.createElement("h3",{style:{fontStyle:"italic"}},s),r?u.createElement("pre",{style:a},r):null,null)}const AU=u.createElement(PU,null);class TU extends u.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,r){return r.location!==s.location||r.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:r.error,location:r.location,revalidation:s.revalidation||r.revalidation}}componentDidCatch(s,r){console.error("React Router caught the following error during render",s,r)}render(){return this.state.error!==void 0?u.createElement(eo.Provider,{value:this.props.routeContext},u.createElement(n6.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function DU(e){let{routeContext:s,match:r,children:n}=e,a=u.useContext(fv);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),u.createElement(eo.Provider,{value:s},n)}function RU(e,s,r,n){var a;if(s===void 0&&(s=[]),r===void 0&&(r=null),n===void 0&&(n=null),e==null){var i;if(!r)return null;if(r.errors)e=r.matches;else if((i=n)!=null&&i.v7_partialHydration&&s.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let o=e,l=(a=r)==null?void 0:a.errors;if(l!=null){let m=o.findIndex(h=>h.route.id&&(l==null?void 0:l[h.route.id])!==void 0);m>=0||Us(!1),o=o.slice(0,Math.min(o.length,m+1))}let c=!1,d=-1;if(r&&n&&n.v7_partialHydration)for(let m=0;m<o.length;m++){let h=o[m];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(d=m),h.route.id){let{loaderData:f,errors:p}=r,x=h.route.loader&&f[h.route.id]===void 0&&(!p||p[h.route.id]===void 0);if(h.route.lazy||x){c=!0,d>=0?o=o.slice(0,d+1):o=[o[0]];break}}}return o.reduceRight((m,h,f)=>{let p,x=!1,g=null,b=null;r&&(p=l&&h.route.id?l[h.route.id]:void 0,g=h.route.errorElement||AU,c&&(d<0&&f===0?(x=!0,b=null):d===f&&(x=!0,b=h.route.hydrateFallbackElement||null)));let w=s.concat(o.slice(0,f+1)),j=()=>{let y;return p?y=g:x?y=b:h.route.Component?y=u.createElement(h.route.Component,null):h.route.element?y=h.route.element:y=m,u.createElement(DU,{match:h,routeC
674ontext:{outlet:m,matches:w,isDataRoute:r!=null},children:y})};return r&&(h.route.ErrorBoundary||h.route.errorElement||f===0)?u.createElement(TU,{location:r.location,revalidation:r.revalidation,component:g,error:p,children:j(),routeContext:{outlet:null,matches:w,isDataRoute:!0}}):j()},null)}var i6=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(i6||{}),tg=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}(tg||{});function MU(e){let s=u.useContext(fv);return s||Us(!1),s}function OU(e){let s=u.useContext(r6);return s||Us(!1),s}function IU(e){let s=u.useContext(eo);return s||Us(!1),s}function o6(e){let s=IU(),r=s.matches[s.matches.length-1];return r.route.id||Us(!1),r.route.id}function FU(){var e;let s=u.useContext(n6),r=OU(tg.UseRouteError),n=o6(tg.UseRouteError);return s!==void 0?s:(e=r.errors)==null?void 0:e[n]}function LU(){let{router:e}=MU(i6.UseNavigateStable),s=o6(tg.UseNavigateStable),r=u.useRef(!1);return a6(()=>{r.current=!0}),u.useCallback(function(a,i){i===void 0&&(i={}),r.current&&(typeof a=="number"?e.navigate(a):e.navigate(a,Sh({fromRouteId:s},i)))},[e,s])}function BU(e){let{to:s,replace:r,state:n,relative:a}=e;Au()||Us(!1);let{future:i,static:o}=u.useContext(Ji),{matches:l}=u.useContext(eo),{pathname:c}=Va(),d=ds(),m=qw(s,Vw(l,i.v7_relativeSplatPath),c,a==="path"),h=JSON.stringify(m);return u.useEffect(()=>d(JSON.parse(h),{replace:r,state:n,relative:a}),[d,h,a,r,n]),null}function Rs(e){Us(!1)}function zU(e){let{basename:s="/",children:r=null,location:n,navigationType:a=Fo.Pop,navigator:i,static:o=!1,future:l}=e;Au()&&Us(!1);let c=s.replace(/^\/*/,"/"),d=u.useMemo(()=>({basename:c,navigator:i,static:o,future:Sh({v7_relativeSplatPath:!1},l)}),[c,l,i,o]);typeof n=="string"&&(n=Pu(n));let{pathname:m="/",search:h="",hash:f="",state:p=null,key:x="default"}=n,g=u.useMemo(()=>{let b=au(m,c);return b==null?null:{location:{pathname:b,search:h,hash:f,state:p,key:x},navigationType:a}},[c,m,h,f,p,x,a]);return g==null?null:u.createElement(Ji.Provider,{value:d},u.createElement(pv.Provider,{children:r,value:g}))}function UU(e){let{children:s,location:r}=e;return $U(ij(s),r)}new Promise(()=>{});function ij(e,s){s===void 0&&(s=[]);let r=[];return u.Children.forEach(e,(n,a)=>{if(!u.isValidElement(n))return;let i=[...s,a];if(n.type===u.Fragment){r.push.apply(r,ij(n.props.children,i));return}n.type!==Rs&&Us(!1),!n.props.index||!n.props.children||Us(!1);let o={id:n.props.id||i.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(o.children=ij(n.props.children,i)),r.push(o)}),r}/** 675 * React Router DOM v6.27.0 676 * 677 * Copyright (c) Remix Software Inc. 678 * 679 * This source code is licensed under the MIT license found in the 680 * LICENSE.md file in the root directory of this source tree. 681 * 682 * @license MIT 683 */function sg(){return sg=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},sg.apply(this,arguments)}function l6(e,s){if(e==null)return{};var r={},n=Object.keys(e),a,i;for(i=0;i<n.length;i++)a=n[i],!(s.indexOf(a)>=0)&&(r[a]=e[a]);return r}function VU(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function qU(e,s){return e.button===0&&(!s||s==="_self")&&!VU(e)}function oj(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((s,r)=>{let n=e[r];return s.concat(Array.isArray(n)?n.map(a=>[r,a]):[[r,n]])},[]))}function HU(e,s){let r=oj(e);
683return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(i=>{r.append(a,i)})}),r}const WU=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],GU=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],YU="6";try{window.__reactRouterVersion=YU}catch{}const KU=u.createContext({isTransitioning:!1}),QU="startTransition",oS=_1[QU];function XU(e){let{basename:s,children:r,future:n,window:a}=e,i=u.useRef();i.current==null&&(i.current=tU({window:a,v5Compat:!0}));let o=i.current,[l,c]=u.useState({action:o.action,location:o.location}),{v7_startTransition:d}=n||{},m=u.useCallback(h=>{d&&oS?oS(()=>c(h)):c(h)},[c,d]);return u.useLayoutEffect(()=>o.listen(m),[o,m]),u.createElement(zU,{basename:s,children:r,location:l.location,navigationType:l.action,navigator:o,future:n})}const ZU=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",JU=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,hs=u.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:i,replace:o,state:l,target:c,to:d,preventScrollReset:m,viewTransition:h}=s,f=l6(s,WU),{basename:p}=u.useContext(Ji),x,g=!1;if(typeof d=="string"&&JU.test(d)&&(x=d,ZU))try{let y=new URL(window.location.href),v=d.startsWith("//")?new URL(y.protocol+d):new URL(d),N=au(v.pathname,p);v.origin===y.origin&&N!=null?d=N+v.search+v.hash:g=!0}catch{}let b=CU(d,{relative:a}),w=sV(d,{replace:o,state:l,target:c,preventScrollReset:m,relative:a,viewTransition:h});function j(y){n&&n(y),y.defaultPrevented||w(y)}return u.createElement("a",sg({},f,{href:x||b,onClick:g||i?n:j,ref:r,target:c}))}),eV=u.forwardRef(function(s,r){let{"aria-current":n="page",caseSensitive:a=!1,className:i="",end:o=!1,style:l,to:c,viewTransition:d,children:m}=s,h=l6(s,GU),f=gv(c,{relative:h.relative}),p=Va(),x=u.useContext(r6),{navigator:g,basename:b}=u.useContext(Ji),w=x!=null&&rV(f)&&d===!0,j=g.encodeLocation?g.encodeLocation(f).pathname:f.pathname,y=p.pathname,v=x&&x.navigation&&x.navigation.location?x.navigation.location.pathname:null;a||(y=y.toLowerCase(),v=v?v.toLowerCase():null,j=j.toLowerCase()),v&&b&&(v=au(v,b)||v);const N=j!=="/"&&j.endsWith("/")?j.length-1:j.length;let S=y===j||!o&&y.startsWith(j)&&y.charAt(N)==="/",k=v!=null&&(v===j||!o&&v.startsWith(j)&&v.charAt(j.length)==="/"),$={isActive:S,isPending:k,isTransitioning:w},R=S?n:void 0,A;typeof i=="function"?A=i($):A=[i,S?"active":null,k?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let T=typeof l=="function"?l($):l;return u.createElement(hs,sg({},h,{"aria-current":R,className:A,ref:r,style:T,to:c,viewTransition:d}),typeof m=="function"?m($):m)});var lj;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(lj||(lj={}));var lS;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(lS||(lS={}));function tV(e){let s=u.useContext(fv);return s||Us(!1),s}function sV(e,s){let{target:r,replace:n,state:a,preventScrollReset:i,relative:o,viewTransition:l}=s===void 0?{}:s,c=ds(),d=Va(),m=gv(e,{relative:o});return u.useCallback(h=>{if(qU(h,r)){h.preventDefault();let f=n!==void 0?n:Jx(d)===Jx(m);c(e,{replace:f,state:a,preventScrollReset:i,relative:o,viewTransition:l})}},[d,c,m,n,a,r,e,i,o,l])}function Hw(e){let s=u.useRef(oj(e)),r=u.useRef(!1),n=Va(),a=u.useMemo(()=>HU(n.search,r.current?null:s.current),[n.search]),i=ds(),o=u.useCallback((l,c)=>{const d=oj(typeof l=="function"?l(a):l);r.current=!0,i("?"+d,c)},[i,a]);return[a,o]}function rV(e,s){s===void 0&&(s={});let r=u.useContext(KU);r==null&&Us(!1);let{basename:n}=tV(lj.useViewTransitionState),a=gv(e,{relative:s.relative});if(!r.isTransitioning)return!1;let i=au(r.currentLocation.pathname,n)||r.currentLocation.pathname,o=au(r.nextLocation.pathname,n)||r.nextLocation.pathname;return eg(a.pathname,o)!=null||eg(a.pathname,i)!=null}const nV="modulepreload",aV=function(e){return"/"+e},cS={}
683,xc=function(s,r,n){let a=Promise.resolve();if(r&&r.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"));a=Promise.allSettled(r.map(c=>{if(c=aV(c),c in cS)return;cS[c]=!0;const d=c.endsWith(".css"),m=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${m}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":nV,d||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),d)return new Promise((f,p)=>{h.addEventListener("load",f),h.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return a.then(o=>{for(const l of o||[])l.status==="rejected"&&i(l.reason);return s().catch(i)})},iV=e=>{let s;return e?s=e:typeof fetch>"u"?s=(...r)=>xc(async()=>{const{default:n}=await Promise.resolve().then(()=>Tu);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class Ww extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class oV extends Ww{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class lV extends Ww{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class cV extends Ww{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var cj;(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"})(cj||(cj={}));var dV=function(e,s,r,n){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(m){try{d(n.next(m))}catch(h){o(h)}}function c(m){try{d(n.throw(m))}catch(h){o(h)}}function d(m){m.done?i(m.value):a(m.value).then(l,c)}d((n=n.apply(e,s||[])).next())})};class uV{constructor(s,{headers:r={},customFetch:n,region:a=cj.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=iV(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s,r={}){var n;return dV(this,void 0,void 0,function*(){try{const{headers:a,method:i,body:o}=r;let l={},{region:c}=r;c||(c=this.region),c&&c!=="any"&&(l["x-region"]=c);let d;o&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)&&(typeof Blob<"u"&&o instanceof Blob||o instanceof ArrayBuffer?(l["Content-Type"]="application/octet-stream",d=o):typeof o=="string"?(l["Content-Type"]="text/plain",d=o):typeof FormData<"u"&&o instanceof FormData?d=o:(l["Content-Type"]="application/json",d=JSON.stringify(o)));const m=yield this.fetch(`${this.url}/${s}`,{method:i||"POST",headers:Object.assign(Object.assign(Object.assign({},l),this.headers),a),body:d}).catch(x=>{throw new oV(x)}),h=m.headers.get("x-relay-error");if(h&&h==="true")throw new lV(m);if(!m.ok)throw new cV(m);let f=((n=m.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),p;return f==="application/json"?p=yield m.json():f==="application/octet-stream"?p=yield m.blob():f==="text/event-stream"?p=m:f==="multipart/form-data"?p=yield m.formData():p=yield m.text(),{data:p,error:null}}catch(a){return{data:null,error:a}}})}}var gn={},Gw={},vv={},Ef={},yv={},bv={},mV=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},iu=mV();const hV=iu.fetch,c6=iu.fetch.bind(iu),d6=iu.Headers,fV=iu.Request,pV=iu.Response,Tu=Object.freeze(Object.defineProperty({__proto__:null,Headers:d6,Request:fV,Response:pV,default:c6,fetch:hV},Symbol.toStringTag,{value:"Module"})),xV=W7(Tu);var jv={};
683Object.defineProperty(jv,"__esModule",{value:!0});let gV=class extends Error{constructor(s){super(s.message),this.name="PostgrestError",this.details=s.details,this.hint=s.hint,this.code=s.code}};jv.default=gV;var u6=la&&la.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(bv,"__esModule",{value:!0});const vV=u6(xV),yV=u6(jv);let bV=class{constructor(s){this.shouldThrowOnError=!1,this.method=s.method,this.url=s.url,this.headers=s.headers,this.schema=s.schema,this.body=s.body,this.shouldThrowOnError=s.shouldThrowOnError,this.signal=s.signal,this.isMaybeSingle=s.isMaybeSingle,s.fetch?this.fetch=s.fetch:typeof fetch>"u"?this.fetch=vV.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(s,r){return this.headers=Object.assign({},this.headers),this.headers[s]=r,this}then(s,r){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");const n=this.fetch;let a=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,l,c;let d=null,m=null,h=null,f=i.status,p=i.statusText;if(i.ok){if(this.method!=="HEAD"){const w=await i.text();w===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?m=w:m=JSON.parse(w))}const g=(o=this.headers.Prefer)===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),b=(l=i.headers.get("content-range"))===null||l===void 0?void 0:l.split("/");g&&b&&b.length>1&&(h=parseInt(b[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(m)&&(m.length>1?(d={code:"PGRST116",details:`Results contain ${m.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},m=null,h=null,f=406,p="Not Acceptable"):m.length===1?m=m[0]:m=null)}else{const g=await i.text();try{d=JSON.parse(g),Array.isArray(d)&&i.status===404&&(m=[],d=null,f=200,p="OK")}catch{i.status===404&&g===""?(f=204,p="No Content"):d={message:g}}if(d&&this.isMaybeSingle&&(!((c=d==null?void 0:d.details)===null||c===void 0)&&c.includes("0 rows"))&&(d=null,f=200,p="OK"),d&&this.shouldThrowOnError)throw new yV.default(d)}return{error:d,data:m,count:h,status:f,statusText:p}});return this.shouldThrowOnError||(a=a.catch(i=>{var o,l,c;return{error:{message:`${(o=i==null?void 0:i.name)!==null&&o!==void 0?o:"FetchError"}: ${i==null?void 0:i.message}`,details:`${(l=i==null?void 0:i.stack)!==null&&l!==void 0?l:""}`,hint:"",code:`${(c=i==null?void 0:i.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),a.then(s,r)}returns(){return this}overrideTypes(){return this}};bv.default=bV;var jV=la&&la.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(yv,"__esModule",{value:!0});const wV=jV(bv);let NV=class extends wV.default{select(s){let r=!1;const n=(s??"*").split("").map(a=>/\s/.test(a)&&!r?"":(a==='"'&&(r=!r),a)).join("");return this.url.searchParams.set("select",n),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(s,{ascending:r=!0,nullsFirst:n,foreignTable:a,referencedTable:i=a}={}){const o=i?`${i}.order`:"order",l=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${l?`${l},`:""}${s}.${r?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(s,{foreignTable:r,referencedTable:n=r}={}){const a=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(a,`${s}`),this}range(s,r,{foreignTable:n,referencedTable:a=n}={}){const i=typeof a>"u"?"offset":`${a}.offset`,o=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(i,`${s}`),this.url.searchParams.set(o,`${r-s+1}`),this}abortSignal(s){return this.signal=s,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}
683explain({analyze:s=!1,verbose:r=!1,settings:n=!1,buffers:a=!1,wal:i=!1,format:o="text"}={}){var l;const c=[s?"analyze":null,r?"verbose":null,n?"settings":null,a?"buffers":null,i?"wal":null].filter(Boolean).join("|"),d=(l=this.headers.Accept)!==null&&l!==void 0?l:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${o}; for="${d}"; options=${c};`,o==="json"?this:this}rollback(){var s;return((s=this.headers.Prefer)!==null&&s!==void 0?s:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}};yv.default=NV;var _V=la&&la.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ef,"__esModule",{value:!0});const SV=_V(yv);let CV=class extends SV.default{eq(s,r){return this.url.searchParams.append(s,`eq.${r}`),this}neq(s,r){return this.url.searchParams.append(s,`neq.${r}`),this}gt(s,r){return this.url.searchParams.append(s,`gt.${r}`),this}gte(s,r){return this.url.searchParams.append(s,`gte.${r}`),this}lt(s,r){return this.url.searchParams.append(s,`lt.${r}`),this}lte(s,r){return this.url.searchParams.append(s,`lte.${r}`),this}like(s,r){return this.url.searchParams.append(s,`like.${r}`),this}likeAllOf(s,r){return this.url.searchParams.append(s,`like(all).{${r.join(",")}}`),this}likeAnyOf(s,r){return this.url.searchParams.append(s,`like(any).{${r.join(",")}}`),this}ilike(s,r){return this.url.searchParams.append(s,`ilike.${r}`),this}ilikeAllOf(s,r){return this.url.searchParams.append(s,`ilike(all).{${r.join(",")}}`),this}ilikeAnyOf(s,r){return this.url.searchParams.append(s,`ilike(any).{${r.join(",")}}`),this}is(s,r){return this.url.searchParams.append(s,`is.${r}`),this}in(s,r){const n=Array.from(new Set(r)).map(a=>typeof a=="string"&&new RegExp("[,()]").test(a)?`"${a}"`:`${a}`).join(",");return this.url.searchParams.append(s,`in.(${n})`),this}contains(s,r){return typeof r=="string"?this.url.searchParams.append(s,`cs.${r}`):Array.isArray(r)?this.url.searchParams.append(s,`cs.{${r.join(",")}}`):this.url.searchParams.append(s,`cs.${JSON.stringify(r)}`),this}containedBy(s,r){return typeof r=="string"?this.url.searchParams.append(s,`cd.${r}`):Array.isArray(r)?this.url.searchParams.append(s,`cd.{${r.join(",")}}`):this.url.searchParams.append(s,`cd.${JSON.stringify(r)}`),this}rangeGt(s,r){return this.url.searchParams.append(s,`sr.${r}`),this}rangeGte(s,r){return this.url.searchParams.append(s,`nxl.${r}`),this}rangeLt(s,r){return this.url.searchParams.append(s,`sl.${r}`),this}rangeLte(s,r){return this.url.searchParams.append(s,`nxr.${r}`),this}rangeAdjacent(s,r){return this.url.searchParams.append(s,`adj.${r}`),this}overlaps(s,r){return typeof r=="string"?this.url.searchParams.append(s,`ov.${r}`):this.url.searchParams.append(s,`ov.{${r.join(",")}}`),this}textSearch(s,r,{config:n,type:a}={}){let i="";a==="plain"?i="pl":a==="phrase"?i="ph":a==="websearch"&&(i="w");const o=n===void 0?"":`(${n})`;return this.url.searchParams.append(s,`${i}fts${o}.${r}`),this}match(s){return Object.entries(s).forEach(([r,n])=>{this.url.searchParams.append(r,`eq.${n}`)}),this}not(s,r,n){return this.url.searchParams.append(s,`not.${r}.${n}`),this}or(s,{foreignTable:r,referencedTable:n=r}={}){const a=n?`${n}.or`:"or";return this.url.searchParams.append(a,`(${s})`),this}filter(s,r,n){return this.url.searchParams.append(s,`${r}.${n}`),this}};Ef.default=CV;var kV=la&&la.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};
683Object.defineProperty(vv,"__esModule",{value:!0});const cm=kV(Ef);let $V=class{constructor(s,{headers:r={},schema:n,fetch:a}){this.url=s,this.headers=r,this.schema=n,this.fetch=a}select(s,{head:r=!1,count:n}={}){const a=r?"HEAD":"GET";let i=!1;const o=(s??"*").split("").map(l=>/\s/.test(l)&&!i?"":(l==='"'&&(i=!i),l)).join("");return this.url.searchParams.set("select",o),n&&(this.headers.Prefer=`count=${n}`),new cm.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(s,{count:r,defaultToNull:n=!0}={}){const a="POST",i=[];if(this.headers.Prefer&&i.push(this.headers.Prefer),r&&i.push(`count=${r}`),n||i.push("missing=default"),this.headers.Prefer=i.join(","),Array.isArray(s)){const o=s.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(o.length>0){const l=[...new Set(o)].map(c=>`"${c}"`);this.url.searchParams.set("columns",l.join(","))}}return new cm.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:this.fetch,allowEmpty:!1})}upsert(s,{onConflict:r,ignoreDuplicates:n=!1,count:a,defaultToNull:i=!0}={}){const o="POST",l=[`resolution=${n?"ignore":"merge"}-duplicates`];if(r!==void 0&&this.url.searchParams.set("on_conflict",r),this.headers.Prefer&&l.push(this.headers.Prefer),a&&l.push(`count=${a}`),i||l.push("missing=default"),this.headers.Prefer=l.join(","),Array.isArray(s)){const c=s.reduce((d,m)=>d.concat(Object.keys(m)),[]);if(c.length>0){const d=[...new Set(c)].map(m=>`"${m}"`);this.url.searchParams.set("columns",d.join(","))}}return new cm.default({method:o,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:this.fetch,allowEmpty:!1})}update(s,{count:r}={}){const n="PATCH",a=[];return this.headers.Prefer&&a.push(this.headers.Prefer),r&&a.push(`count=${r}`),this.headers.Prefer=a.join(","),new cm.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:this.fetch,allowEmpty:!1})}delete({count:s}={}){const r="DELETE",n=[];return s&&n.push(`count=${s}`),this.headers.Prefer&&n.unshift(this.headers.Prefer),this.headers.Prefer=n.join(","),new cm.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};vv.default=$V;var wv={},Nv={};Object.defineProperty(Nv,"__esModule",{value:!0});Nv.version=void 0;Nv.version="0.0.0-automated";Object.defineProperty(wv,"__esModule",{value:!0});wv.DEFAULT_HEADERS=void 0;const EV=Nv;wv.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${EV.version}`};var m6=la&&la.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Gw,"__esModule",{value:!0});const PV=m6(vv),AV=m6(Ef),TV=wv;let DV=class h6{constructor(s,{headers:r={},schema:n,fetch:a}={}){this.url=s,this.headers=Object.assign(Object.assign({},TV.DEFAULT_HEADERS),r),this.schemaName=n,this.fetch=a}from(s){const r=new URL(`${this.url}/${s}`);return new PV.default(r,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(s){return new h6(this.url,{headers:this.headers,schema:s,fetch:this.fetch})}rpc(s,r={},{head:n=!1,get:a=!1,count:i}={}){let o;const l=new URL(`${this.url}/rpc/${s}`);let c;n||a?(o=n?"HEAD":"GET",Object.entries(r).filter(([m,h])=>h!==void 0).map(([m,h])=>[m,Array.isArray(h)?`{${h.join(",")}}`:`${h}`]).forEach(([m,h])=>{l.searchParams.append(m,h)})):(o="POST",c=r);const d=Object.assign({},this.headers);return i&&(d.Prefer=`count=${i}`),new AV.default({method:o,url:l,headers:d,schema:this.schemaName,body:c,fetch:this.fetch,allowEmpty:!1})}};Gw.default=DV;var Du=la&&la.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(gn,"__esModule",{value:!0});gn.PostgrestError=gn.PostgrestBuilder=gn.PostgrestTransformBuilder=gn.PostgrestFilterBuilder=gn.PostgrestQueryBuilder=gn.PostgrestClient=void 0;const f6=Du(Gw);gn.PostgrestClient=f6.default;const p6=Du(vv);gn.PostgrestQueryBuilder=p6.default;const x6=Du(Ef);gn.PostgrestFilterBuilder=x6.default;const g6=Du(yv);gn.PostgrestTransformBuilder=g6.default;const v6=Du(bv);gn.PostgrestBuilder=v6.default;const y6=Du(jv);gn.PostgrestError=y6.default;var RV=gn.default={PostgrestClient:f6.default,PostgrestQueryBuilder:p6.default,PostgrestFilterBuilder:x6.default,PostgrestTransformBuilder:g6.default,PostgrestBuilder:v6.default,PostgrestError:y6.default};const{PostgrestClient:MV,PostgrestQueryBuilder:ufe,PostgrestFilterBuilder:mfe,PostgrestTransformBuilder:hfe,PostgrestBuilder:ffe,PostgrestError:pfe}=RV;let dj;typeof window>"u"?dj=require("ws"):dj=window.WebSocket;const OV=dj,IV="2.11.10",FV={"X-Client-Info":`realtime-js/${IV}`},LV="1.0.0",b6=1e4,BV=1e3;var $d;(function(e){e[e.connecting=0]="connecting",e[e.open=1]="open",e[e.closing=2]="closing",e[e.closed=3]="closed"})($d||($d={}));var Hr;(function(e){e.closed="closed",e.errored="errored",e.joined="joined",e.joining="joining",e.leaving="leaving"})(Hr||(Hr={}));var _a;(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"})(_a||(_a={}));var uj;(function(e){e.websocket="websocket"})(uj||(uj={}));var Ml;(function(e){e.Connecting="connecting",e.Open="open",e.Closing="closing",e.Closed="closed"})(Ml||(Ml={}));class zV{constructor(){this.HEADER_LENGTH=1}decode(s,r){return s.constructor===ArrayBuffer?r(this._binaryDecode(s)):r(typeof s=="string"?JSON.parse(s):{})}_binaryDecode(s){const r=new DataView(s),n=new TextDecoder;return this._decodeBroadcast(s,r,n)}_decodeBroadcast(s,r,n){const a=r.getUint8(1),i=r.getUint8(2);let o=this.HEADER_LENGTH+2;const l=n.decode(s.slice(o,o+a));o=o+a;const c=n.decode(s.slice(o,o+i));o=o+i;const d=JSON.parse(n.decode(s.slice(o,s.byteLength)));return{ref:null,topic:l,event:c,payload:d}}}class j6{constructor(s,r){this.callback=s,this.timerCalc=r,this.timer=void 0,this.tries=0,this.callback=s,this.timerCalc=r}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var bs;(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"})(bs||(bs={}));const dS=(e,s,r={})=>{var n;const a=(n=r.skipTypes)!==null&&n!==void 0?n:[];return Object.keys(s).reduce((i,o)=>(i[o]=UV(o,e,s,a),i),{})},UV=(e,s,r,n)=>{const a=s.find(l=>
vendor: 6,983 bytes, line 683
683l.name===e),i=a==null?void 0:a.type,o=r[e];return i&&!n.includes(i)?w6(i,o):mj(o)},w6=(e,s)=>{if(e.charAt(0)==="_"){const r=e.slice(1,e.length);return WV(s,r)}switch(e){case bs.bool:return VV(s);case bs.float4:case bs.float8:case bs.int2:case bs.int4:case bs.int8:case bs.numeric:case bs.oid:return qV(s);case bs.json:case bs.jsonb:return HV(s);case bs.timestamp:return GV(s);case bs.abstime:case bs.date:case bs.daterange:case bs.int4range:case bs.int8range:case bs.money:case bs.reltime:case bs.text:case bs.time:case bs.timestamptz:case bs.timetz:case bs.tsrange:case bs.tstzrange:return mj(s);default:return mj(s)}},mj=e=>e,VV=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},qV=e=>{if(typeof e=="string"){const s=parseFloat(e);if(!Number.isNaN(s))return s}return e},HV=e=>{if(typeof e=="string")try{return JSON.parse(e)}catch(s){return console.log(`JSON parse error: ${s}`),e}return e},WV=(e,s)=>{if(typeof e!="string")return e;const r=e.length-1,n=e[r];if(e[0]==="{"&&n==="}"){let i;const o=e.slice(1,r);try{i=JSON.parse("["+o+"]")}catch{i=o?o.split(","):[]}return i.map(l=>w6(s,l))}return e},GV=e=>typeof e=="string"?e.replace(" ","T"):e,N6=e=>{let s=e;return s=s.replace(/^ws/i,"http"),s=s.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),s.replace(/\/+$/,"")};class Uy{constructor(s,r,n={},a=b6){this.channel=s,this.event=r,this.payload=n,this.timeout=a,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(s){this.timeout=s,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(s){this.payload=Object.assign(Object.assign({},this.payload),s)}receive(s,r){var n;return this._hasReceived(s)&&r((n=this.receivedResp)===null||n===void 0?void 0:n.response),this.recHooks.push({status:s,callback:r}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const s=r=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=r,this._matchReceive(r)};this.channel._on(this.refEvent,{},s),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(s,r){this.refEvent&&this.channel._trigger(this.refEvent,{status:s,response:r})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:s,response:r}){this.recHooks.filter(n=>n.status===s).forEach(n=>n.callback(r))}_hasReceived(s){return this.receivedResp&&this.receivedResp.status===s}}var uS;(function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"})(uS||(uS={}));class Um{constructor(s,r){this.channel=s,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const n=(r==null?void 0:r.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},a=>{const{onJoin:i,onLeave:o,onSync:l}=this.caller;this.joinRef=this.channel._joinRef(),this.state=Um.syncState(this.state,a,i,o),this.pendingDiffs.forEach(c=>{this.state=Um.syncDiff(this.state,c,i,o)}),this.pendingDiffs=[],l()}),this.channel._on(n.diff,{},a=>{const{onJoin:i,onLeave:o,onSync:l}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(a):(this.state=Um.syncDiff(this.state,a,i,o),l())}),this.onJoin((a,i,o)=>{this.channel._trigger("presence",{event:"join",key:a,currentPresences:i,newPresences:o})}),this.onLeave((a,i,o)=>{this.channel._trigger("presence",{event:"leave",key:a,currentPresences:i,leftPresences:o})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(s,r,n,a){const i=this.cloneDeep(s),o=this.transformState(r),l={},c={};return this.map(i,(d,m)=>{o[d]||(c[d]=m)}),this.map(o,(d,m)=>{const h=i[d];if(h){const f=m.map(b=>b.presence_ref),p=h.map(b=>b.presence_ref),x=m.filter(b=>p.indexOf(b.presence_ref)<0),g=h.filter(b=>f.indexOf(b.presence_ref)<0);x.length>0&&(l[d]=x),g.length>0&&(c[d]=g)}else l[d]=m}),this.syncDiff(i,{joins:l,leaves:c},n,a)}static syncDiff(s,r,n,a){const{joins:i,leaves:o}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return n||(n=()=>{}),a||(a=()=>{}),this.map(i,(l,c)=>{var d;const m=(d=s[l])!==null&&d!==void 0?d:[];if(s[l]=this.cloneDeep(c),m.length>0){const h=s[l].map(p=>p.presence_ref),f=m.filter(p=>h.indexOf(p.presence_ref)<0);s[l].unshift(...f)}n(l,m,c)}),this.map(o,(l,c)=>{let d=s[l];if(!d)return;const m=c.map(h=>h.presence_ref);d=d.filter(h=>m.indexOf(h.presence_ref)<0),s[l]=d,a(l,d,c),d.length===0&&delete s[l]}),s}static map(s,r){return Object.getOwnPropertyNames(s).map(n=>r(n,s[n]))}static transformState(s){return s=this.cloneDeep(s),Object.getOwnPropertyNames(s).reduce((r,n)=>{const a=s[n];return"metas"in a?r[n]=a.metas.map(i=>(i.presence_ref=i.phx_ref,delete i.phx_ref,delete i.phx_ref_prev,i)):r[n]=a,r},{})}static cloneDeep(s){return JSON.parse(JSON.stringify(s))}onJoin(s){this.caller.onJoin=s}onLeave(s){this.caller.onLeave=s}onSync(s){this.caller.onSync=s}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var mS;(function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"})(mS||(mS={}));var hS;(function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"})(hS||(hS={}));var Pi;(function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"})(Pi||(Pi={}));class Yw{constructor(s,r={config:{}},n){this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=Hr.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=s.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""},private:!1},r.config),this.timeout=this.socket.timeout,this.joinPush=new Uy(this,_a.join,this.params,this.timeout),this.rejoinTimer=new j6(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Hr.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(a=>a.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Hr.closed,this.socket._remove(this)}),this._onError(a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=Hr.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Hr.errored,this.rejoinTimer.scheduleTimeout())}),this._on(_a.reply,{},(a,i)=>{this._trigger(this._replyEventName(i),a)}
683),this.presence=new Um(this),this.broadcastEndpointURL=N6(this.socket.endPoint)+"/api/broadcast",this.private=this.params.config.private||!1}subscribe(s,r=this.timeout){var n,a;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{config:{broadcast:i,presence:o,private:l}}=this.params;this._onError(m=>s==null?void 0:s(Pi.CHANNEL_ERROR,m)),this._onClose(()=>s==null?void 0:s(Pi.CLOSED));const c={},d={broadcast:i,presence:o,postgres_changes:(a=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(m=>m.filter))!==null&&a!==void 0?a:[],private:l};this.socket.accessTokenValue&&(c.access_token=this.socket.accessTokenValue),this.updateJoinPayload(Object.assign({config:d},c)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:m})=>{var h;if(this.socket.setAuth(),m===void 0){s==null||s(Pi.SUBSCRIBED);return}else{const f=this.bindings.postgres_changes,p=(h=f==null?void 0:f.length)!==null&&h!==void 0?h:0,x=[];for(let g=0;g<p;g++){const b=f[g],{filter:{event:w,schema:j,table:y,filter:v}}=b,N=m&&m[g];if(N&&N.event===w&&N.schema===j&&N.table===y&&N.filter===v)x.push(Object.assign(Object.assign({},b),{id:N.id}));else{this.unsubscribe(),this.state=Hr.errored,s==null||s(Pi.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=x,s&&s(Pi.SUBSCRIBED);return}}).receive("error",m=>{this.state=Hr.errored,s==null||s(Pi.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(m).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(Pi.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(s,r={}){return await this.send({type:"presence",event:"track",payload:s},r.timeout||this.timeout)}async untrack(s={}){return await this.send({type:"presence",event:"untrack"},s)}on(s,r,n){return this._on(s,r,n)}async send(s,r={}){var n,a;if(!this._canPush()&&s.type==="broadcast"){const{event:i,payload:o}=s,c={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:o,private:this.private}]})};try{const d=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);return await((a=d.body)===null||a===void 0?void 0:a.cancel()),d.ok?"ok":"error"}catch(d){return d.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var o,l,c;const d=this._push(s.type,s,r.timeout||this.timeout);s.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)&&i("ok"),d.receive("ok",()=>i("ok")),d.receive("error",()=>i("error")),d.receive("timeout",()=>i("timed out"))})}updateJoinPayload(s){this.joinPush.updatePayload(s)}unsubscribe(s=this.timeout){this.state=Hr.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(_a.close,"leave",this._joinRef())};return this.joinPush.destroy(),new Promise(n=>{const a=new Uy(this,_a.leave,{},s);a.receive("ok",()=>{r(),n("ok")}).receive("timeout",()=>{r(),n("timed out")}).receive("error",()=>{n("error")}),a.send(),this._canPush()||a.trigger("ok",{})})}teardown(){this.pushBuffer.forEach(s=>s.destroy()),this.rejoinTimer&&clearTimeout(this.rejoinTimer.timer),this.joinPush.destroy()}async _fetchWithTimeout(s,r,n){const a=new AbortController,i=setTimeout(()=>a.abort(),n),o=await this.socket.fetch(s,Object.assign(Object.assign({},r),{signal:a.signal}));return clearTimeout(i),o}_push(s,r,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${s}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;
683let a=new Uy(this,s,r,n);return this._canPush()?a.send():(a.startTimeout(),this.pushBuffer.push(a)),a}_onMessage(s,r,n){return r}_isMember(s){return this.topic===s}_joinRef(){return this.joinPush.ref}_trigger(s,r,n){var a,i;const o=s.toLocaleLowerCase(),{close:l,error:c,leave:d,join:m}=_a;if(n&&[l,c,d,m].indexOf(o)>=0&&n!==this._joinRef())return;let f=this._onMessage(o,r,n);if(r&&!f)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?(a=this.bindings.postgres_changes)===null||a===void 0||a.filter(p=>{var x,g,b;return((x=p.filter)===null||x===void 0?void 0:x.event)==="*"||((b=(g=p.filter)===null||g===void 0?void 0:g.event)===null||b===void 0?void 0:b.toLocaleLowerCase())===o}).map(p=>p.callback(f,n)):(i=this.bindings[o])===null||i===void 0||i.filter(p=>{var x,g,b,w,j,y;if(["broadcast","presence","postgres_changes"].includes(o))if("id"in p){const v=p.id,N=(x=p.filter)===null||x===void 0?void 0:x.event;return v&&((g=r.ids)===null||g===void 0?void 0:g.includes(v))&&(N==="*"||(N==null?void 0:N.toLocaleLowerCase())===((b=r.data)===null||b===void 0?void 0:b.type.toLocaleLowerCase()))}else{const v=(j=(w=p==null?void 0:p.filter)===null||w===void 0?void 0:w.event)===null||j===void 0?void 0:j.toLocaleLowerCase();return v==="*"||v===((y=r==null?void 0:r.event)===null||y===void 0?void 0:y.toLocaleLowerCase())}else return p.type.toLocaleLowerCase()===o}).map(p=>{if(typeof f=="object"&&"ids"in f){const x=f.data,{schema:g,table:b,commit_timestamp:w,type:j,errors:y}=x;f=Object.assign(Object.assign({},{schema:g,table:b,commit_timestamp:w,eventType:j,new:{},old:{},errors:y}),this._getPayloadRecords(x))}p.callback(f,n)})}_isClosed(){return this.state===Hr.closed}_isJoined(){return this.state===Hr.joined}_isJoining(){return this.state===Hr.joining}_isLeaving(){return this.state===Hr.leaving}_replyEventName(s){return`chan_reply_${s}`}_on(s,r,n){const a=s.toLocaleLowerCase(),i={type:a,filter:r,callback:n};return this.bindings[a]?this.bindings[a].push(i):this.bindings[a]=[i],this}_off(s,r){const n=s.toLocaleLowerCase();return this.bindings[n]=this.bindings[n].filter(a=>{var i;return!(((i=a.type)===null||i===void 0?void 0:i.toLocaleLowerCase())===n&&Yw.isEqual(a.filter,r))}),this}static isEqual(s,r){if(Object.keys(s).length!==Object.keys(r).length)return!1;for(const n in s)if(s[n]!==r[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(s){this._on(_a.close,{},s)}_onError(s){this._on(_a.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Hr.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=dS(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=dS(s.columns,s.old_record)),r}}const fS=()=>{},YV=` 684 addEventListener("message", (e) => { 685 if (e.data.event === "start") { 686 setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); 687 } 688 });`;class KV{constructor(s,r){var n;this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers=FV,this.params={},this.timeout=b6,this.heartbeatIntervalMs=25e3,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=fS,this.ref=0,this.logger=fS,this.conn=null,this.sendBuffer=[],this.serializer=new zV,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._resolveFetch=i=>{let o;return i?o=i:typeof fetch>"u"?o=(...l)=>xc(async()=>{const{default:c}=await Promise.resolve().then(()=>Tu);return{default:c}},void 0).then(({default:c})=>c(...l)):o=fetch,(...l)=>o(...l)},this.endPoint=`${s}/${uj.websocket}`,this.httpEndpoint=N6(s),r!=null&&r.transport?this.transport=r.transport:this.transport=null,r!=null&&r.params&&(this.params=r.params),r!=null&&r.headers&&(this.headers=Object.assign(Object.assign({},this.headers),r.headers)),r!=null&&r.timeout&&(this.timeout=r.timeout),r!=null&&r.logger&&(this.logger=r.logger),(r!=null&&r.logLevel||r!=null&&r.log_level)&&(this.logLevel=r.logLevel||r.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),r!=null&&r.heartbeatIntervalMs&&(this.heartbeatIntervalMs=r.heartbeatIntervalMs);const a=(n=r==null?void 0:r.params)===null||n===void 0?void 0:n.apikey;if(a&&(this.accessTokenValue=a,this.apiKey=a),this.reconnectAfterMs=r!=null&&r.reconnectAfterMs?r.reconnectAfterMs:i=>[1e3,2e3,5e3,1e4][i-1]||1e4,this.encode=r!=null&&r.encode?r.encode:(i,o)=>o(JSON.stringify(i)),this.decode=r!=null&&r.decode?r.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new j6(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(r==null?void 0:r.fetch),r!=null&&r.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.worker=(r==null?void 0:r.worker)||!1,this.workerUrl=r==null?void 0:r.workerUrl}this.accessToken=(r==null?void 0:r.accessToken)||null}
688connect(){if(!this.conn){if(this.transport||(this.transport=OV),this.transport){typeof window<"u"&&this.transport===window.WebSocket?this.conn=new this.transport(this.endpointURL()):this.conn=new this.transport(this.endpointURL(),void 0,{headers:this.headers}),this.setupConnection();return}this.conn=new QV(this.endpointURL(),void 0,{close:()=>{this.conn=null}})}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:LV}))}disconnect(s,r){this.conn&&(this.conn.onclose=function(){},s?this.conn.close(s,r??""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset(),this.channels.forEach(n=>n.teardown()))}getChannels(){return this.channels}async removeChannel(s){const r=await s.unsubscribe();return this.channels=this.channels.filter(n=>n._joinRef!==s._joinRef),this.channels.length===0&&this.disconnect(),r}async removeAllChannels(){const s=await Promise.all(this.channels.map(r=>r.unsubscribe()));return this.channels=[],this.disconnect(),s}log(s,r,n){this.logger(s,r,n)}connectionState(){switch(this.conn&&this.conn.readyState){case $d.connecting:return Ml.Connecting;case $d.open:return Ml.Open;case $d.closing:return Ml.Closing;default:return Ml.Closed}}isConnected(){return this.connectionState()===Ml.Open}channel(s,r={config:{}}){const n=`realtime:${s}`,a=this.getChannels().find(i=>i.topic===n);if(a)return a;{const i=new Yw(`realtime:${s}`,r,this);return this.channels.push(i),i}}push(s){const{topic:r,event:n,payload:a,ref:i}=s,o=()=>{this.encode(s,l=>{var c;(c=this.conn)===null||c===void 0||c.send(l)})};this.log("push",`${r} ${n} (${i})`,a),this.isConnected()?o():this.sendBuffer.push(o)}async setAuth(s=null){let r=s||this.accessToken&&await this.accessToken()||this.accessTokenValue;this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(n=>{r&&n.updateJoinPayload({access_token:r,version:this.headers&&this.headers["X-Client-Info"]}),n.joinedOnce&&n._isJoined()&&n._push(_a.access_token,{access_token:r})}))}async sendHeartbeat(){var s;if(!this.isConnected()){this.heartbeatCallback("disconnected");return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.heartbeatCallback("timeout"),(s=this.conn)===null||s===void 0||s.close(BV,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatCallback("sent"),await this.setAuth()}onHeartbeat(s){this.heartbeatCallback=s}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(s=>s()),this.sendBuffer=[])}_makeRef(){let s=this.ref+1;return s===this.ref?this.ref=0:this.ref=s,this.ref.toString()}_leaveOpenTopic(s){let r=this.channels.find(n=>n.topic===s&&(n._isJoined()||n._isJoining()));r&&(this.log("transport",`leaving duplicate topic "${s}"`),r.unsubscribe())}_remove(s){this.channels=this.channels.filter(r=>r.topic!==s.topic)}setupConnection(){this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=s=>this._onConnError(s),this.conn.onmessage=s=>this._onConnMessage(s),this.conn.onclose=s=>this._onConnClose(s))}_onConnMessage(s){this.decode(s.data,r=>{let{topic:n,event:a,payload:i,ref:o}=r;n==="phoenix"&&a==="phx_reply"&&this.heartbeatCallback(r.payload.status=="ok"?"ok":"error"),o&&o===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null),this.log("receive",`${i.status||""} ${n} ${a} ${o&&"("+o+")"||""}`,i),Array.from(this.channels).filter(l=>l._isMember(n)).forEach(l=>l._trigger(a,i,o)),this.stateChangeCallbacks.message.forEach(l=>l(r))})}_onConnOpen(){if(this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this.reconnectTimer.reset(),!this.worker)this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs);else{this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const s=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(s),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this.workerRef.terminate()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}
688this.stateChangeCallbacks.open.forEach(s=>s())}_onConnClose(s){this.log("transport","close",s),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(r=>r(s))}_onConnError(s){this.log("transport",s.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(r=>r(s))}_triggerChanError(){this.channels.forEach(s=>s._trigger(_a.error))}_appendParams(s,r){if(Object.keys(r).length===0)return s;const n=s.match(/\?/)?"&":"?",a=new URLSearchParams(r);return`${s}${n}${a}`}_workerObjectUrl(s){let r;if(s)r=s;else{const n=new Blob([YV],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}}class QV{constructor(s,r,n){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=$d.connecting,this.send=()=>{},this.url=null,this.url=s,this.close=n.close}}class Kw extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function xr(e){return typeof e=="object"&&e!==null&&"__isStorageError"in e}class XV extends Kw{constructor(s,r){super(s),this.name="StorageApiError",this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class hj extends Kw{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}var ZV=function(e,s,r,n){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(m){try{d(n.next(m))}catch(h){o(h)}}function c(m){try{d(n.throw(m))}catch(h){o(h)}}function d(m){m.done?i(m.value):a(m.value).then(l,c)}d((n=n.apply(e,s||[])).next())})};const _6=e=>{let s;return e?s=e:typeof fetch>"u"?s=(...r)=>xc(async()=>{const{default:n}=await Promise.resolve().then(()=>Tu);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},JV=()=>ZV(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield xc(()=>Promise.resolve().then(()=>Tu),void 0)).Response:Response}),fj=e=>{if(Array.isArray(e))return e.map(r=>fj(r));if(typeof e=="function"||e!==Object(e))return e;const s={};return Object.entries(e).forEach(([r,n])=>{const a=r.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));s[a]=fj(n)}),s};var Rc=function(e,s,r,n){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(m){try{d(n.next(m))}catch(h){o(h)}}function c(m){try{d(n.throw(m))}catch(h){o(h)}}function d(m){m.done?i(m.value):a(m.value).then(l,c)}d((n=n.apply(e,s||[])).next())})};const Vy=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),eq=(e,s,r)=>Rc(void 0,void 0,void 0,function*(){const n=yield JV();e instanceof n&&!(r!=null&&r.noResolveJson)?e.json().then(a=>{s(new XV(Vy(a),e.status||500))}).catch(a=>{s(new hj(Vy(a),a))}):s(new hj(Vy(e),e))}),tq=(e,s,r,n)=>{const a={method:e,headers:(s==null?void 0:s.headers)||{}};return e==="GET"?a:(a.headers=Object.assign({"Content-Type":"application/json"},s==null?void 0:s.headers),n&&(a.body=JSON.stringify(n)),Object.assign(Object.assign({},a),r))};function Pf(e,s,r,n,a,i){return Rc(this,void 0,void 0,function*(){return new Promise((o,l)=>{e(r,tq(s,n,a,i)).then(c=>{if(!c.ok)throw c;return n!=null&&n.noResolveJson?c:c.json()}).then(c=>o(c)).catch(c=>eq(c,l,n))})})}function rg(e,s,r,n){return Rc(this,void 0,void 0,function*(){return Pf(e,"GET",s,r,n)})}function yo(e,s,r,n,a){return Rc(this,void 0,void 0,function*(){return Pf(e,"POST",s,n,a,r)})}function sq(e,s,r,n,a){return Rc(this,void 0,void 0,function*(){return Pf(e,"PUT",s,n,a,r)})}function rq(e,s,r,n){return Rc(this,void 0,void 0,function*(){return Pf(e,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function S6(e,s,r,n,a){return Rc(this,void 0,void 0,function*(){return Pf(e,"DELETE",s,n,a,r)})}var un=function(e,s,r,n){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(m){try{d(n.next(m))}catch(h){o(h)}}function c(m){try{d(n.throw(m))}catch(h){o(h)}}function d(m){m.done?i(m.value):a(m.value).then(l,c)}d((n=n.apply(e,s||[])).next())})};const nq={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},pS={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class aq{constructor(s,r={},n,a){this.url=s,this.headers=r,this.bucketId=n,this.fetch=_6(a)}uploadOrUpdate(s,r,n,a){return un(this,void 0,void 0,function*(){try{let i;const o=Object.assign(Object.assign({},pS),a);let l=Object.assign(Object.assign({},this.headers),s==="POST"&&{"x-upsert":String(o.upsert)});const c=o.metadata;typeof Blob<"u"&&n instanceof Blob?(i=new FormData,i.append("cacheControl",o.cacheControl),c&&i.append("metadata",this.encodeMetadata(c)),i.append("",n)):typeof FormData<"u"&&n instanceof FormData?(i=n,i.append("cacheControl",o.cacheControl),c&&i.append("metadata",this.encodeMetadata(c))):(i=n,l["cache-control"]=`max-age=${o.cacheControl}`,l["content-type"]=o.contentType,c&&(l["x-metadata"]=this.toBase64(this.encodeMetadata(c)))),a!=null&&a.headers&&(l=Object.assign(Object.assign({},l),a.headers));const d=this._removeEmptyFolders(r),m=this._getFinalPath(d),h=yield this.fetch(`${this.url}/object/${m}`,Object.assign({method:s,body:i,headers:l},o!=null&&o.duplex?{duplex:o.duplex}:{})),f=yield h.json();return h.ok?{data:{path:d,id:f.Id,fullPath:f.Key},error:null}:{data:null,error:f}}catch(i){if(xr(i))return{data:null,error:i};throw i}})}upload(s,r,n){return un(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return un(this,void 0,void 0,function*(){const i=this._removeEmptyFolders(s),o=this._getFinalPath(i),l=new URL(this.url+`/object/upload/sign/${o}`);l.searchParams.set("token",r);try{let c;const d=Object.assign({upsert:pS.upsert},a),m=Object.assign(Object.assign({},this.headers),{"x-upsert":String(d.upsert)});typeof Blob<"u"&&n instanceof Blob?(c=new FormData,c.append("cacheControl",d.cacheControl),c.append("",n)):typeof FormData<"u"&&n instanceof FormData?(c=n,c.append("cacheControl",d.cacheControl)):(c=n,m["cache-control"]=`max-age=${d.cacheControl}`,m["content-type"]=d.contentType);const h=yield this.fetch(l.toString(),{method:"PUT",body:c,headers:m}),f=yield h.json();return h.ok?{data:{path:i,fullPath:f.Key},error:null}:{data:null,error:f}}catch(c){if(xr(c))return{data:null,error:c};throw c}})}createSignedUploadUrl(s,r){return un(this,void 0,void 0,function*(){try{let n=this._getFinalPath(s);const a=Object.assign({},this.headers);r!=null&&r.upsert&&(a["x-upsert"]="true");const i=yield yo(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:a}),o=new URL(this.url+i.url),l=o.searchParams.get("token");if(!l)throw new Kw("No token returned by API");return{data:{signedUrl:o.toString(),path:s,token:l},error:null}}catch(n){if(xr(n))return{data:null,error:n};throw n}})}update(s,r,n){return un(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return un(this,void 0,void 0,function*(){try{return{data:yield yo(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:s,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers}),error:null}}catch(a){if(xr(a))return{data:null,error:a};throw a}})}copy(s,r,n){return un(this,void 0,void 0,function*(){try{return{data:{path:(yield yo(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:s,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers})).Key},error:null}}catch(a){if(xr(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return un(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),i=yield yo(this.fetch,`${this.url}/object/sign/${a}
688`,Object.assign({expiresIn:r},n!=null&&n.transform?{transform:n.transform}:{}),{headers:this.headers});const o=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return i={signedUrl:encodeURI(`${this.url}${i.signedURL}${o}`)},{data:i,error:null}}catch(a){if(xr(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return un(this,void 0,void 0,function*(){try{const a=yield yo(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:r,paths:s},{headers:this.headers}),i=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return{data:a.map(o=>Object.assign(Object.assign({},o),{signedUrl:o.signedURL?encodeURI(`${this.url}${o.signedURL}${i}`):null})),error:null}}catch(a){if(xr(a))return{data:null,error:a};throw a}})}download(s,r){return un(this,void 0,void 0,function*(){const a=typeof(r==null?void 0:r.transform)<"u"?"render/image/authenticated":"object",i=this.transformOptsToQueryString((r==null?void 0:r.transform)||{}),o=i?`?${i}`:"";try{const l=this._getFinalPath(s);return{data:yield(yield rg(this.fetch,`${this.url}/${a}/${l}${o}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(l){if(xr(l))return{data:null,error:l};throw l}})}info(s){return un(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield rg(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:fj(n),error:null}}catch(n){if(xr(n))return{data:null,error:n};throw n}})}exists(s){return un(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield rq(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(xr(n)&&n instanceof hj){const a=n.originalError;if([400,404].includes(a==null?void 0:a.status))return{data:!1,error:n}}throw n}})}getPublicUrl(s,r){const n=this._getFinalPath(s),a=[],i=r!=null&&r.download?`download=${r.download===!0?"":r.download}`:"";i!==""&&a.push(i);const l=typeof(r==null?void 0:r.transform)<"u"?"render/image":"object",c=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});c!==""&&a.push(c);let d=a.join("&");return d!==""&&(d=`?${d}`),{data:{publicUrl:encodeURI(`${this.url}/${l}/public/${n}${d}`)}}}remove(s){return un(this,void 0,void 0,function*(){try{return{data:yield S6(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(xr(r))return{data:null,error:r};throw r}})}list(s,r,n){return un(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},nq),r),{prefix:s||""});return{data:yield yo(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(xr(a))return{data:null,error:a};throw a}})}encodeMetadata(s){return JSON.stringify(s)}toBase64(s){return typeof Buffer<"u"?Buffer.from(s).toString("base64"):btoa(s)}_getFinalPath(s){return`${this.bucketId}/${s}`}_removeEmptyFolders(s){return s.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(s){const r=[];return s.width&&r.push(`width=${s.width}`),s.height&&r.push(`height=${s.height}`),s.resize&&r.push(`resize=${s.resize}`),s.format&&r.push(`format=${s.format}`),s.quality&&r.push(`quality=${s.quality}`),r.join("&")}}const iq="2.7.1",oq={"X-Client-Info":`storage-js/${iq}`};var Bc=function(e,s,r,n){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(m){try{d(n.next(m))}catch(h){o(h)}}function c(m){try{d(n.throw(m))}catch(h){o(h)}}function d(m){m.done?i(m.value):a(m.value).then(l,c)}d((n=n.apply(e,s||[])).next())})};class lq{constructor(s,r={},n){this.url=s,this.headers=Object.assign(Object.assign({},oq),r),this.fetch=_6(n)}listBuckets(){return Bc(this,void 0,void 0,function*(){try{return{data:yield rg(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(s){if(xr(s))return{data:null,error:s};throw s}})}getBucket(s){return Bc(this,void 0,void 0,function*(){try{return{data:yield rg(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(xr(r))return{data:null,error:r};throw r}})}createBucket(s,r={public:!1}){return Bc(this,void 0,void 0,function*(){try{return{data:yield yo(this.fetch,`${this.url}/bucket`,{id:s,name:s,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(xr(n))return{data:null,error:n};throw n}})}updateBucket(s,r){return Bc(this,void 0,void 0,function*(){try{return{data:yield sq(this.fetch,`${this.url}/bucket/${s}`,{id:s,name:s,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(xr(n))return{data:null,error:n};throw n}})}emptyBucket(s){return Bc(this,void 0,void 0,function*(){try{return{data:yield yo(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(xr(r))return{data:null,error:r};throw r}})}deleteBucket(s){return Bc(this,void 0,void 0,function*(){try{return{data:yield S6(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(xr(r))return{data:null,error:r};throw r}})}}class cq extends lq{constructor(s,r={},n){super(s,r,n)}from(s){return new aq(this.url,this.headers,s,this.fetch)}}const dq="2.49.10";let Sm="";typeof Deno<"u"?Sm="deno":typeof document<"u"?Sm="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Sm="react-native":Sm="node";const uq={"X-Client-Info":`supabase-js-${Sm}/${dq}`},mq={headers:uq},hq={schema:"public"},fq={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},pq={};var xq=function(e,s,r,n){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(m){try{d(n.next(m))}catch(h){o(h)}}function c(m){try{d(n.throw(m))}catch(h){o(h)}}function d(m){m.done?i(m.value):a(m.value).then(l,c)}d((n=n.apply(e,s||[])).next())})};const gq=e=>{let s;return e?s=e:typeof fetch>"u"?s=c6:s=fetch,(...r)=>s(...r)},vq=()=>typeof Headers>"u"?d6:Headers,yq=(e,s,r)=>{const n=gq(r),a=vq();return(i,o)=>xq(void 0,void 0,void 0,function*(){var l;const c=(l=yield s())!==null&&l!==void 0?l:e;let d=new a(o==null?void 0:o.headers);return d.has("apikey")||d.set("apikey",e),d.has("Authorization")||d.set("Authorization",`Bearer ${c}`),n(i,Object.assign(Object.assign({},o),{headers:d}))})};var bq=function(e,s,r,n){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(m){try{d(n.next(m))}catch(h){o(h)}}function c(m){try{d(n.throw(m))}catch(h){o(h)}}function d(m){m.done?i(m.value):a(m.value).then(l,c)}d((n=n.apply(e,s||[])).next())})};function jq(e){return e.endsWith("/")?e:e+"/"}function wq(e,s){var r,n;const{db:a,auth:i,realtime:o,global:l}=e,{db:c,auth:d,realtime:m,global:h}=s,f={db:Object.assign(Object.assign({},c),a),auth:Object.assign(Object.assign({},d),i),realtime:Object.assign(Object.assign({},m),o),global:Object.assign(Object.assign(Object.assign({},h),l),{headers:Object.assign(Object.assign({},(r=h==null?void 0:h.headers)!==null&&r!==void 0?r:{}),(n=l==null?void 0:l.headers)!==null&&n!==void 0?n:{})}),accessToken:()=>bq(this,void 0,void 0,function*(){return""})};return e.accessToken?f.accessToken=e.accessToken:delete f.accessToken,f}const C6="2.69.1",td=30*1e3,pj=3,qy=pj*td,Nq="http://localhost:9999",_q="supabase.auth.token",Sq={"X-Client-Info":`gotrue-js/${C6}`},xj="X-Supabase-Api-Version",k6={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},Cq=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,kq=6e5;
688class Qw extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Tt(e){return typeof e=="object"&&e!==null&&"__isAuthError"in e}class $q extends Qw{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function Eq(e){return Tt(e)&&e.name==="AuthApiError"}class $6 extends Qw{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class yl extends Qw{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class ho extends yl{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Pq(e){return Tt(e)&&e.name==="AuthSessionMissingError"}class Hy extends yl{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class kp extends yl{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class $p extends yl{constructor(s,r=null){super(s,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function Aq(e){return Tt(e)&&e.name==="AuthImplicitGrantRedirectError"}class xS extends yl{constructor(s,r=null){super(s,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class gj extends yl{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function Wy(e){return Tt(e)&&e.name==="AuthRetryableFetchError"}class gS extends yl{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class Vm extends yl{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const vS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),yS=` 689\r=`.split(""),Tq=(()=>{const e=new Array(128);for(let s=0;s<e.length;s+=1)e[s]=-1;for(let s=0;s<yS.length;s+=1)e[yS[s].charCodeAt(0)]=-2;for(let s=0;s<vS.length;s+=1)e[vS[s].charCodeAt(0)]=s;return e})();function E6(e,s,r){const n=Tq[e];if(n>-1)for(s.queue=s.queue<<6|n,s.queuedBits+=6;s.queuedBits>=8;)r(s.queue>>s.queuedBits-8&255),s.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}}function bS(e){const s=[],r=o=>{s.push(String.fromCodePoint(o))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},i=o=>{Mq(o,n,r)};for(let o=0;o<e.length;o+=1)E6(e.charCodeAt(o),a,i);return s.join("")}function Dq(e,s){if(e<=127){s(e);return}else if(e<=2047){s(192|e>>6),s(128|e&63);return}else if(e<=65535){s(224|e>>12),s(128|e>>6&63),s(128|e&63);return}else if(e<=1114111){s(240|e>>18),s(128|e>>12&63),s(128|e>>6&63),s(128|e&63);return}throw new Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}function Rq(e,s){for(let r=0;r<e.length;r+=1){let n=e.charCodeAt(r);if(n>55295&&n<=56319){const a=(n-55296)*1024&65535;n=(e.charCodeAt(r+1)-56320&65535|a)+65536,r+=1}Dq(n,s)}}function Mq(e,s,r){if(s.utf8seq===0){if(e<=127){r(e);return}for(let n=1;n<6;n+=1)if(!(e>>7-n&1)){s.utf8seq=n;break}if(s.utf8seq===2)s.codepoint=e&31;else if(s.utf8seq===3)s.codepoint=e&15;else if(s.utf8seq===4)s.codepoint=e&7;else throw new Error("Invalid UTF-8 sequence");s.utf8seq-=1}else if(s.utf8seq>0){if(e<=127)throw new Error("Invalid UTF-8 sequence");s.codepoint=s.codepoint<<6|e&63,s.utf8seq-=1,s.utf8seq===0&&r(s.codepoint)}}function Oq(e){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;a<e.length;a+=1)E6(e.charCodeAt(a),r,n);return new Uint8Array(s)}function Iq(e){const s=[];return Rq(e,r=>s.push(r)),new Uint8Array(s)}function Fq(e){return Math.round(Date.now()/1e3)+e}function Lq(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const s=Math.random()*16|0;return(e=="x"?s:s&3|8).toString(16)})}const Wa=()=>typeof window<"u"&&typeof document<"u",_l={tested:!1,writable:!1},qm=()=>{if(!Wa())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(_l.tested)return _l.writable;const e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),_l.tested=!0,_l.writable=!0}catch{_l.tested=!0,_l.writable=!1}return _l.writable};function Bq(e){const s={},r=new URL(e);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEac
689h((a,i)=>{s[i]=a})}catch{}return r.searchParams.forEach((n,a)=>{s[a]=n}),s}const P6=e=>{let s;return e?s=e:typeof fetch>"u"?s=(...r)=>xc(async()=>{const{default:n}=await Promise.resolve().then(()=>Tu);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},zq=e=>typeof e=="object"&&e!==null&&"status"in e&&"ok"in e&&"json"in e&&typeof e.json=="function",A6=async(e,s,r)=>{await e.setItem(s,JSON.stringify(r))},Ep=async(e,s)=>{const r=await e.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},Pp=async(e,s)=>{await e.removeItem(s)};class _v{constructor(){this.promise=new _v.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}_v.promiseConstructor=Promise;function Gy(e){const s=e.split(".");if(s.length!==3)throw new Vm("Invalid JWT structure");for(let n=0;n<s.length;n++)if(!Cq.test(s[n]))throw new Vm("JWT not in base64url format");return{header:JSON.parse(bS(s[0])),payload:JSON.parse(bS(s[1])),signature:Oq(s[2]),raw:{header:s[0],payload:s[1]}}}async function Uq(e){return await new Promise(s=>{setTimeout(()=>s(null),e)})}function Vq(e,s){return new Promise((n,a)=>{(async()=>{for(let i=0;i<1/0;i++)try{const o=await e(i);if(!s(i,null,o)){n(o);return}}catch(o){if(!s(i,o)){a(o);return}}})()})}function qq(e){return("0"+e.toString(16)).substr(-2)}function Hq(){const s=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length;let a="";for(let i=0;i<56;i++)a+=r.charAt(Math.floor(Math.random()*n));return a}return crypto.getRandomValues(s),Array.from(s,qq).join("")}async function Wq(e){const r=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",r),a=new Uint8Array(n);return Array.from(a).map(i=>String.fromCharCode(i)).join("")}async function Gq(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 r=await Wq(e);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function zc(e,s,r=!1){const n=Hq();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await A6(e,`${s}-code-verifier`,a);const i=await Gq(n);return[i,n===i?"plain":"s256"]}const Yq=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function Kq(e){const s=e.headers.get(xj);if(!s||!s.match(Yq))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function Qq(e){if(!e)throw new Error("Missing exp claim");const s=Math.floor(Date.now()/1e3);if(e<=s)throw new Error("JWT has expired")}function Xq(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")}}var Zq=function(e,s){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&s.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)s.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r};const El=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),Jq=[502,503,504];async function jS(e){var s;if(!zq(e))throw new gj(El(e),0);if(Jq.includes(e.status))throw new gj(El(e),e.status);let r;try{r=await e.json()}catch(i){throw new $6(El(i),i)}let n;const a=Kq(e);if(a&&a.getTime()>=k6["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new gS(El(r),e.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new ho}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((i,o)=>i&&typeof o=="string",!0))throw new gS(El(r),e.status,r.weak_password.reasons);throw new $q(El(r),e.status||500,n)}const eH=(e,s,r,n)=>{const a={method:e,headers:(s==null?void 0:s.headers)||{}};return e==="GET"?a:(a.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},s==null?void 0:s.headers),a.body=JSON.stringify(n),Object.assign(Object.assign({},a),r))};async function zt(e,s,r,n){var a;const i=Object.assign({},n==null?void 0:n.headers);i[xj]||(i[xj]=k6["2024-01-01"].name),n!=null&&n.jwt&&(i.Authorization=`Bearer ${n.jwt}`);const o=(a=n==null?void 0:n.query)!==null&&a!==void 0?a:{};n!=null&&n.redirectTo&&(o.redirect_to=n.redirectTo);const l=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",c=await tH(e,s,r+l,{headers:i,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(c):{data:Object.assign({},c),error:null}}async function tH(e,s,r,n,a,i){const o=eH(s,n,a,i);let l;try{l=await e(r,Object.assign({},o))}catch(c){throw console.error(c),new gj(El(c),0)}if(l.ok||await jS(l),n!=null&&n.noResolveJson)return l;try{return await l.json()}catch(c){await jS(c)}}function fo(e){var s;let r=null;aH(e)&&(r=Object.assign({},e),e.expires_at||(r.expires_at=Fq(e.expires_in)));const n=(s=e.user)!==null&&s!==void 0?s:e;return{data:{session:r,user:n},error:null}}function wS(e){const s=fo(e);return!s.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((r,n)=>r&&typeof n=="string",!0)&&(s.data.weak_password=e.weak_password),s}function No(e){var s;return{data:{user:(s=e.user)!==null&&s!==void 0?s:e},error:null}}function sH(e){return{data:e,error:null}}function rH(e){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:i}=e,o=Zq(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),l={action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:i},c=Object.assign({},o);return{data:{properties:l,user:c},error:null}}function nH(e){return e}function aH(e){return e.access_token&&e.refresh_token&&e.expires_in}var iH=function(e,s){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&s.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)s.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r};class oH{constructor({url:s="",headers:r={},fetch:n}){this.url=s,this.headers=r,this.fetch=P6(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(s,r="global"){try{return await zt(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:s,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Tt(n))return{data:null,error:n};throw n}}async inviteUserByEmail(s,r={}){try{return await zt(this.fetch,"POST",`${this.url}/invite`,{body:{email:s,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:No})}catch(n){if(Tt(n))return{data:{user:null},error:n};throw n}}async generateLink(s){try{const{options:r}=s,n=iH(s,["options"]),a=Object.assign(Object.assign({},n),r);return"newEmail"in n&&(a.new_email=n==null?void 0:n.newEmail,delete a.newEmail),await zt(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:rH,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(Tt(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(s){try{return await zt(this.fetch,"POST",`${this.url}/admin/users`,{body:s,headers:this.headers,xform:No})}catch(r){if(Tt(r))return{data:{user:null},error:r};throw r}}async listUsers(s){var r,n,a,i,o,l,c;try{const d={nextPage:null,lastPage:0,total:0},m=await zt(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=s==null?void 0:s.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(i=(a=s==null?void 0:s.perPage)===null||a===void 0?void 0:a.toString())!==null&&i!==void 0?i:""},xform:nH});if(m.error)throw m.error;const h=await m.json(),f=(o=m.headers.get("x-total-count"))!==null&&o!==void 0?o:0,p=(c=(l=m.headers.get("link"))===null||l===void 0?void 0:l.split(","))!==null&&c!==void 0?c:[];return p.length>
6890&&(p.forEach(x=>{const g=parseInt(x.split(";")[0].split("=")[1].substring(0,1)),b=JSON.parse(x.split(";")[1].split("=")[1]);d[`${b}Page`]=g}),d.total=parseInt(f)),{data:Object.assign(Object.assign({},h),d),error:null}}catch(d){if(Tt(d))return{data:{users:[]},error:d};throw d}}async getUserById(s){try{return await zt(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:No})}catch(r){if(Tt(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){try{return await zt(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:No})}catch(n){if(Tt(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){try{return await zt(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:No})}catch(n){if(Tt(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){try{const{data:r,error:n}=await zt(this.fetch,"GET",`${this.url}/admin/users/${s.userId}/factors`,{headers:this.headers,xform:a=>({data:{factors:a},error:null})});return{data:r,error:n}}catch(r){if(Tt(r))return{data:null,error:r};throw r}}async _deleteFactor(s){try{return{data:await zt(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(Tt(r))return{data:null,error:r};throw r}}}const lH={getItem:e=>qm()?globalThis.localStorage.getItem(e):null,setItem:(e,s)=>{qm()&&globalThis.localStorage.setItem(e,s)},removeItem:e=>{qm()&&globalThis.localStorage.removeItem(e)}};function NS(e={}){return{getItem:s=>e[s]||null,setItem:(s,r)=>{e[s]=r},removeItem:s=>{delete e[s]}}}function cH(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}const Uc={debug:!!(globalThis&&qm()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class T6 extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class dH extends T6{}async function uH(e,s,r){Uc.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),Uc.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},s),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,s===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async a=>{if(a){Uc.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,a.name);try{return await r()}finally{Uc.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,a.name)}}else{if(s===0)throw Uc.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new dH(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(Uc.debug)try{const i=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(i,null," "))}catch(i){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",i)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}}))}cH();const mH={url:Nq,storageKey:_q,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Sq,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function _S(e,s,r){return await r()}class Ch{constructor(s){var r,n;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=Ch.nextInstanceID,Ch.nextInstanceID+=1,this.instanceID>0&&Wa()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const a=Object.assign(Object.assign({},mH),s);if(this.logDebugMessages=!!a.debug,typeof a.debug=="function"&&(this.logger=a.debug),this.persistSession=a.persistSession,this.storageKey=a.storageKey,this.autoRefreshToken=a.autoRefreshToken,this.admin=new oH({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=P6(a.fetch),this.lock=a.lock||_S,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:Wa()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=uH:this.lock=_S,this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?a.storage?this.storage=a.storage:qm()?this.storage=lH:(this.memoryStorage={},this.storage=NS(this.memoryStorage)):(this.memoryStorage={},this.storage=NS(this.memoryStorage)),Wa()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(i){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",i)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async i=>{this._debug("received broadcast notification from other tab or client",i),await this._notifyAllSubscribers(i.data.event,i.data.session,!1)})}this.initialize()}_debug(...s){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${C6}) ${new Date().toISOString()}`,...s),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var s;try{const r=Bq(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),Wa()&&this.detectSessionInUrl&&n!=="none"){const{data:a,error:i}=await this._getSessionFromURL(r,n);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),Aq(i)){const c=(s=i.details)===null||s===void 0?void 0:s.code;if(c==="identity_already_exists"||c==="identity_not_found"||c==="single_identity_not_deletable")return{error:i}}return await this._removeSession(),{error:i}}const{session:o,redirectType:l}=a;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(r){return Tt(r)?{error:r}:{error:new $6("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const i=await zt(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=s==null?void 0:s.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(a=s==null?void 0:s.options)===null||a===void 0?void 0:a.captchaToken}},xform:fo}),{data:o,error:l}=i;if(l||!o)return{data:{user:null,session:null},error:l};const c=o.session,d=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",c)),{data:{user:d,session:c},error:null}}catch(i){if(Tt(i))return{data:{user:null,session:null},error:i};throw i}}async signUp(s){var r,n,a;try{let i;if("email"in s){const{email:m,password:h,options:f}=s;let p=null,x=null;this.flowType==="pkce"&&([p,x]=await zc(this.storage,this.storageKey)),i=await zt(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:f==null?void 0:f.emailRedirectTo,body:{email:m,password:h,data:(r=f==null?void 0:f.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:p,code_challenge_method:x},xform:fo})}else if("phone"in s){const{phone:m,password:h,options:f}=s;i=await zt(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:m,password:h,data:(n=f==null?void 0:f.data)!==null&&n!==void 0?n:{},channel:(a=f==null?void 0:f.channel)!==null&&a!==void 0?a:"sms",gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken}},xform:fo})}else throw new kp("You must provide either an email or phone number and a password");const{data:o,error:l}=i;if(l||!o)return{data:{user:null,session:null},error:l};const c=o.session,d=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",c)),{data:{user:d,session:c},error:null}}catch(i){if(Tt(i))return{data:{user:null,session:null},error:i};throw i}}async signInWithPassword(s){try{let r;if("email"in s){const{email:i,password:o,options:l}=s;r=await zt(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:o,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:wS})}else if("phone"in s){const{phone:i,password:o,options:l}=s;r=await zt(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:o,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:wS})}else throw new kp("You must provide either an email or phone number and a password");const{data:n,error:a}=r;return a?{data:{user:null,session:null},error:a}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new Hy}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:a})}catch(r){if(Tt(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOAuth(s){var r,n,a,i;return await this._handleProviderSignIn(s.provider,{redirectTo:(r=s.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=s.options)===null||n===void 0?void 0:n.scopes,queryParams:(a=s.options)===null||a===void 0?void 0:a.queryParams,skipBrowserRedirect:(i=s.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(s){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(s))}async _exchangeCodeForSession(s){const r=await Ep(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:i,error:o}=await zt(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:fo});if(await Pp(this.storage,`${this.storageKey}-code-verifier`),o)throw o;return!i||!i.session||!i.user?{data:{user:null,session:null,redirectType:null},error:new Hy}:(i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),{data:Object.assign(Object.assign({},i),{redirectType:a??null}),error:o})}catch(i){if(Tt(i))return{data:{user:null,session:null,redirectType:null},error:i};throw i}}async signInWithIdToken(s){try{const{options:r,provider:n,token:a,access_token:i,nonce:o}=s,l=await zt(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:a,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:fo}),{data:c,error:d}=l;return d?{data:{user:null,session:null},error:d}:!c||!c.session||!c.user?{data:{user:null,session:null},error:new Hy}:(c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",c.session)),{data:c,error:d})}catch(r){if(Tt(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(s){var r,n,a,i,o;try{if("email"in s){const{email:l,options:c}=s;let d=null,m=null;this.flowType==="pkce"&&([d,m]=await zc(this.storage,this.storageKey));const{error:h}=await zt(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:l,data:(r=c==null?void 0:c.data)!==null&&r!==void 0?r:{},create_user:(n=c==null?void 0:c.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},code_challenge:d,code_challenge_method:m},redirectTo:c==null?void 0:c.emailRedirectTo});return{data:{user:null,session:null},error:h}}if("phone"in s){const{phone:l,options:c}=s,{data:d,error:m}=await zt(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:l,data:(a=c==null?void 0:c.data)!==null&&a!==void 0?a:{},create_user:(i=c==null?void 0:c.shouldCreateUser)!==null&&i!==void 0?i:!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{data:{user:null,session:null,messageId:d==null?void 0:d.message_id},error:m}}throw new kp("You must provide either an email or phone number.")}catch(l){if(Tt(l))return{data:{user:null,session:null},error:l};throw l}}async verifyOtp(s){var r,n;try{let a,i;
689"options"in s&&(a=(r=s.options)===null||r===void 0?void 0:r.redirectTo,i=(n=s.options)===null||n===void 0?void 0:n.captchaToken);const{data:o,error:l}=await zt(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:i}}),redirectTo:a,xform:fo});if(l)throw l;if(!o)throw new Error("An error occurred on token verification.");const c=o.session,d=o.user;return c!=null&&c.access_token&&(await this._saveSession(c),await this._notifyAllSubscribers(s.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",c)),{data:{user:d,session:c},error:null}}catch(a){if(Tt(a))return{data:{user:null,session:null},error:a};throw a}}async signInWithSSO(s){var r,n,a;try{let i=null,o=null;return this.flowType==="pkce"&&([i,o]=await zc(this.storage,this.storageKey)),await zt(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in s?{provider_id:s.providerId}:null),"domain"in s?{domain:s.domain}:null),{redirect_to:(n=(r=s.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((a=s==null?void 0:s.options)===null||a===void 0)&&a.captchaToken?{gotrue_meta_security:{captcha_token:s.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:i,code_challenge_method:o}),headers:this.headers,xform:sH})}catch(i){if(Tt(i))return{data:null,error:i};throw i}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;if(n)throw n;if(!r)throw new ho;const{error:a}=await zt(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(Tt(s))return{data:{user:null,session:null},error:s};throw s}}async resend(s){try{const r=`${this.url}/resend`;if("email"in s){const{email:n,type:a,options:i}=s,{error:o}=await zt(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:a,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return{data:{user:null,session:null},error:o}}else if("phone"in s){const{phone:n,type:a,options:i}=s,{data:o,error:l}=await zt(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:a,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return{data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:l}}throw new kp("You must provide either an email or phone number and a type")}catch(r){if(Tt(r))return{data:{user:null,session:null},error:r};throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async r=>r))}async _acquireLock(s,r){this._debug("#_acquireLock","begin",s);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),a=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await a}catch{}})()),a}return await this.lock(`lock:${this.storageKey}`,s,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const a=[...this.pendingInLock];await Promise.all(a),this.pendingInLock.splice(0,a.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(s){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await s(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let s=null;const r=await Ep(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?s=r:(this._debug("#getSession()","session from storage is not val
689id"),await this._removeSession())),!s)return{data:{session:null},error:null};const n=s.expires_at?s.expires_at*1e3-Date.now()<qy:!1;if(this._debug("#__loadSession()",`session has${n?"":" not"} expired`,"expires_at",s.expires_at),!n){if(this.storage.isServer){let o=this.suppressGetSessionWarning;s=new Proxy(s,{get:(c,d,m)=>(!o&&d==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),o=!0,this.suppressGetSessionWarning=!0),Reflect.get(c,d,m))})}return{data:{session:s},error:null}}const{session:a,error:i}=await this._callRefreshToken(s.refresh_token);return i?{data:{session:null},error:i}:{data:{session:a},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(s){return s?await this._getUser(s):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(s){try{return s?await zt(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:No}):await this._useSession(async r=>{var n,a,i;const{data:o,error:l}=r;if(l)throw l;return!(!((n=o.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new ho}:await zt(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(a=o.session)===null||a===void 0?void 0:a.access_token)!==null&&i!==void 0?i:void 0,xform:No})})}catch(r){if(Tt(r))return Pq(r)&&(await this._removeSession(),await Pp(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:r};throw r}}async updateUser(s,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(s,r))}async _updateUser(s,r={}){try{return await this._useSession(async n=>{const{data:a,error:i}=n;if(i)throw i;if(!a.session)throw new ho;const o=a.session;let l=null,c=null;this.flowType==="pkce"&&s.email!=null&&([l,c]=await zc(this.storage,this.storageKey));const{data:d,error:m}=await zt(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},s),{code_challenge:l,code_challenge_method:c}),jwt:o.access_token,xform:No});if(m)throw m;return o.user=d.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),{data:{user:o.user},error:null}})}catch(n){if(Tt(n))return{data:{user:null},error:n};throw n}}async setSession(s){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(s))}async _setSession(s){try{if(!s.access_token||!s.refresh_token)throw new ho;const r=Date.now()/1e3;let n=r,a=!0,i=null;const{payload:o}=Gy(s.access_token);if(o.exp&&(n=o.exp,a=n<=r),a){const{session:l,error:c}=await this._callRefreshToken(s.refresh_token);if(c)return{data:{user:null,session:null},error:c};if(!l)return{data:{user:null,session:null},error:null};i=l}else{const{data:l,error:c}=await this._getUser(s.access_token);if(c)throw c;i={access_token:s.access_token,refresh_token:s.refresh_token,user:l.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return{data:{user:i.user,session:i},error:null}}catch(r){if(Tt(r))return{data:{session:null,user:null},error:r};throw r}}async refreshSession(s){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(s))}async _refreshSession(s){try{return await this._useSession(async r=>{var n;if(!s){const{data:o,error:l}=r;if(l)throw l;s=(n=o.session)!==null&&n!==void 0?n:void 0}if(!(s!=null&&s.refresh_token))throw new ho;const{session:a,error:i}=await this._callRefreshToken(s.refresh_token);return i?{data:{user:null,session:null},error:i}:a?{data:{user:a.user,session:a},error:null}:{data:{user:null,session:null},error:null}})}catch(r){if(Tt(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!Wa())throw new $p("No browser detected.");
689if(s.error||s.error_description||s.error_code)throw new $p(s.error_description||"Error in URL with unspecified error_description",{error:s.error||"unspecified_error",code:s.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new xS("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new $p("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!s.code)throw new xS("No code detected.");const{data:j,error:y}=await this._exchangeCodeForSession(s.code);if(y)throw y;const v=new URL(window.location.href);return v.searchParams.delete("code"),window.history.replaceState(window.history.state,"",v.toString()),{data:{session:j.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:i,refresh_token:o,expires_in:l,expires_at:c,token_type:d}=s;if(!i||!l||!o||!d)throw new $p("No session defined in URL");const m=Math.round(Date.now()/1e3),h=parseInt(l);let f=m+h;c&&(f=parseInt(c));const p=f-m;p*1e3<=td&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${p}s, should have been closer to ${h}s`);const x=f-h;m-x>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",x,f,m):m-x<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",x,f,m);const{data:g,error:b}=await this._getUser(i);if(b)throw b;const w={provider_token:n,provider_refresh_token:a,access_token:i,expires_in:h,expires_at:f,refresh_token:o,token_type:d,user:g.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:w,redirectType:s.type},error:null}}catch(n){if(Tt(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantCallback(s){return!!(s.access_token||s.error_description)}async _isPKCECallback(s){const r=await Ep(this.storage,`${this.storageKey}-code-verifier`);return!!(s.code&&r)}async signOut(s={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(s))}async _signOut({scope:s}={scope:"global"}){return await this._useSession(async r=>{var n;const{data:a,error:i}=r;if(i)return{error:i};const o=(n=a.session)===null||n===void 0?void 0:n.access_token;if(o){const{error:l}=await this.admin.signOut(o,s);if(l&&!(Eq(l)&&(l.status===404||l.status===401||l.status===403)))return{error:l}}return s!=="others"&&(await this._removeSession(),await Pp(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=Lq(),n={id:r,callback:s,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(s){return await this._useSession(async r=>{var n,a;try{const{data:{session:i},error:o}=r;if(o)throw o;await((n=this.stateChangeEmitters.get(s))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",s,"session",i)}catch(i){await((a=this.stateChangeEmitters.get(s))===null||a===void 0?void 0:a.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",s,"error",i),console.error(i)}})}async resetPasswordForEmail(s,r={}){let n=null,a=null;this.flowType==="pkce"&&([n,a]=await zc(this.storage,this.storageKey,!0));try{return await zt(this.fetch,"POST",`${this.url}/recover`,{body:{email:s,code_challenge:n,code_challenge_method:a,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(i){if(Tt(i))return{data:null,error:i};throw i}}async getUserIdentities(){var s;try{const{data:r,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(s=r.user.identities)!==null&&s!==void 0?s:[]},error:null}}catch(r){if(Tt(r))return{data:null,error:r};throw r}}async linkIdentity(s){var r;try{const{data:n,error:a}=await this._useSession(async i=>{var o,l,c,d,m;const{data:h,error:f}=i;if(f)throw f;const p=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,s.provider,{redirectTo:(o=s.options)===null||o===void 0?void 0:o.redirectTo,scopes:(l=s.options)===null||l===void 0?void 0:l.scopes,queryParams:(c=s.options)===null||c===void 0?void 0:c.queryParams,skipBrowserRedirect:!0});return await zt(this.fetch,"GET",p,{headers:this.headers,jwt:(m=(d=h.session)===null||d===void 0?void 0:d.access_token)!==null&&m!==void 0?m:void 0})});if(a)throw a;return Wa()&&!(!((r=s.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),{data:{provider:s.provider,url:n==null?void 0:n.url},error:null}}catch(n){if(Tt(n))return{data:{provider:s.provider,url:null},error:n};throw n}}async unlinkIdentity(s){try{return await this._useSession(async r=>{var n,a;const{data:i,error:o}=r;if(o)throw o;
689return await zt(this.fetch,"DELETE",`${this.url}/user/identities/${s.identity_id}`,{headers:this.headers,jwt:(a=(n=i.session)===null||n===void 0?void 0:n.access_token)!==null&&a!==void 0?a:void 0})})}catch(r){if(Tt(r))return{data:null,error:r};throw r}}async _refreshAccessToken(s){const r=`#_refreshAccessToken(${s.substring(0,5)}...)`;this._debug(r,"begin");try{const n=Date.now();return await Vq(async a=>(a>0&&await Uq(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await zt(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:fo})),(a,i)=>{const o=200*Math.pow(2,a);return i&&Wy(i)&&Date.now()+o-n<td})}catch(n){if(this._debug(r,"error",n),Tt(n))return{data:{session:null,user:null},error:n};throw n}finally{this._debug(r,"end")}}_isValidSession(s){return typeof s=="object"&&s!==null&&"access_token"in s&&"refresh_token"in s&&"expires_at"in s}async _handleProviderSignIn(s,r){const n=await this._getUrlForProvider(`${this.url}/authorize`,s,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",s,"options",r,"url",n),Wa()&&!r.skipBrowserRedirect&&window.location.assign(n),{data:{provider:s,url:n},error:null}}async _recoverAndRefresh(){var s;const r="#_recoverAndRefresh()";this._debug(r,"begin");try{const n=await Ep(this.storage,this.storageKey);if(this._debug(r,"session from storage",n),!this._isValidSession(n)){this._debug(r,"session is not valid"),n!==null&&await this._removeSession();return}const a=((s=n.expires_at)!==null&&s!==void 0?s:1/0)*1e3-Date.now()<qy;if(this._debug(r,`session has${a?"":" not"} expired with margin of ${qy}s`),a){if(this.autoRefreshToken&&n.refresh_token){const{error:i}=await this._callRefreshToken(n.refresh_token);i&&(console.error(i),Wy(i)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",i),await this._removeSession()))}}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(r,"error",n),console.error(n);return}finally{this._debug(r,"end")}}async _callRefreshToken(s){var r,n;if(!s)throw new ho;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const a=`#_callRefreshToken(${s.substring(0,5)}...)`;this._debug(a,"begin");try{this.refreshingDeferred=new _v;const{data:i,error:o}=await this._refreshAccessToken(s);if(o)throw o;if(!i.session)throw new ho;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const l={session:i.session,error:null};return this.refreshingDeferred.resolve(l),l}catch(i){if(this._debug(a,"error",i),Tt(i)){const o={session:null,error:i};return Wy(i)||await this._removeSession(),(r=this.refreshingDeferred)===null||r===void 0||r.resolve(o),o}throw(n=this.refreshingDeferred)===null||n===void 0||n.reject(i),i}finally{this.refreshingDeferred=null,this._debug(a,"end")}}async _notifyAllSubscribers(s,r,n=!0){const a=`#_notifyAllSubscribers(${s})`;this._debug(a,"begin",r,`broadcast = ${n}`);try{this.broadcastChannel&&n&&this.broadcastChannel.postMessage({event:s,session:r});const i=[],o=Array.from(this.stateChangeEmitters.values()).map(async l=>{try{await l.callback(s,r)}catch(c){i.push(c)}});if(await Promise.all(o),i.length>0){for(let l=0;l<i.length;l+=1)console.error(i[l]);throw i[0]}}finally{this._debug(a,"end")}}async _saveSession(s){this._debug("#_saveSession()",s),this.suppressGetSessionWarning=!0,await A6(this.storage,this.storageKey,s)}async _removeSession(){this._debug("#_removeSession()"),await Pp(this.storage,this.storageKey),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const s=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{s&&Wa()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",s)}catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const s=setInterval(()=>this._autoRefreshTokenTick(),td);this.autoRefreshTicker=s,s&&typeof s=="object"&&typeof s.unref=="function"?s.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(s),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const s=this.autoRefreshTicker;this.autoRefreshTicker=null,s&&clearInterval(s)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const s=Date.now();try{return await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const a=Math.floor((n.expires_at*1e3-s)/td);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${td}ms, refresh threshold is ${pj} ticks`),a<=pj&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(s){if(s.isAcquireTimeout||s instanceof T6)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Wa()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(s){console.error("_handleVisibilityChange",s)}}async _onVisibilityChanged(s){const r=`#_onVisibilityChanged(${s})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),s||(await this.initializePromise,await this._acquireLock(-1,async()=>
689{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(s,r,n){const a=[`provider=${encodeURIComponent(r)}`];if(n!=null&&n.redirectTo&&a.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&a.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[i,o]=await zc(this.storage,this.storageKey),l=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});a.push(l.toString())}if(n!=null&&n.queryParams){const i=new URLSearchParams(n.queryParams);a.push(i.toString())}return n!=null&&n.skipBrowserRedirect&&a.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${s}?${a.join("&")}`}async _unenroll(s){try{return await this._useSession(async r=>{var n;const{data:a,error:i}=r;return i?{data:null,error:i}:await zt(this.fetch,"DELETE",`${this.url}/factors/${s.factorId}`,{headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(Tt(r))return{data:null,error:r};throw r}}async _enroll(s){try{return await this._useSession(async r=>{var n,a;const{data:i,error:o}=r;if(o)return{data:null,error:o};const l=Object.assign({friendly_name:s.friendlyName,factor_type:s.factorType},s.factorType==="phone"?{phone:s.phone}:{issuer:s.issuer}),{data:c,error:d}=await zt(this.fetch,"POST",`${this.url}/factors`,{body:l,headers:this.headers,jwt:(n=i==null?void 0:i.session)===null||n===void 0?void 0:n.access_token});return d?{data:null,error:d}:(s.factorType==="totp"&&(!((a=c==null?void 0:c.totp)===null||a===void 0)&&a.qr_code)&&(c.totp.qr_code=`data:image/svg+xml;utf-8,${c.totp.qr_code}`),{data:c,error:null})})}catch(r){if(Tt(r))return{data:null,error:r};throw r}}async _verify(s){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:a,error:i}=r;if(i)return{data:null,error:i};const{data:o,error:l}=await zt(this.fetch,"POST",`${this.url}/factors/${s.factorId}/verify`,{body:{code:s.code,challenge_id:s.challengeId},headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});return l?{data:null,error:l}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),{data:o,error:l})})}catch(r){if(Tt(r))return{data:null,error:r};throw r}})}async _challenge(s){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:a,error:i}=r;return i?{data:null,error:i}:await zt(this.fetch,"POST",`${this.url}/factors/${s.factorId}/challenge`,{body:{channel:s.channel},headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(Tt(r))return{data:null,error:r};throw r}})}async _challengeAndVerify(s){const{data:r,error:n}=await this._challenge({factorId:s.factorId});return n?{data:null,error:n}:await this._verify({factorId:s.factorId,challengeId:r.id,code:s.code})}async _listFactors(){const{data:{user:s},error:r}=await this.getUser();if(r)return{data:null,error:r};const n=(s==null?void 0:s.factors)||[],a=n.filter(o=>o.factor_type==="totp"&&o.status==="verified"),i=n.filter(o=>o.factor_type==="phone"&&o.status==="verified");return{data:{all:n,totp:a,phone:i},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async s=>{var r,n;const{data:{session:a},error:i}=s;if(i)return{data:null,error:i};if(!a)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:o}=Gy(a.access_token);let l=null;o.aal&&(l=o.aal);let c=l;((n=(r=a.user.factors)===null||r===void 0?void 0:r.filter(h=>h.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(c="aal2");const m=o.amr||[];return{data:{currentLevel:l,nextLevel:c,currentAuthenticationMethods:m},error:null}}))}async fetchJwk(s,r={keys:[]}){let n=r.keys.find(o=>o.kid===s);if(n||(n=this.jwks.keys.find(o=>o.kid===s),n&&this.jwks_cached_at+kq>Date.now()))return n;const{data:a,error:i}=await zt(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(i)throw i;if(!a.keys||a.keys.length===0)throw new Vm("JWKS is empty");if(this.jwks=a,this.jwks_cached_at=Date.now(),n=a.keys.find(o=>o.kid===s),!n)throw new Vm("No matching signing key found in JWKS");return n}async getClaims(s,r={keys:[]}){try{let n=s;if(!n){const{data:p,error:x}
689=await this.getSession();if(x||!p.session)return{data:null,error:x};n=p.session.access_token}const{header:a,payload:i,signature:o,raw:{header:l,payload:c}}=Gy(n);if(Qq(i.exp),!a.kid||a.alg==="HS256"||!("crypto"in globalThis&&"subtle"in globalThis.crypto)){const{error:p}=await this.getUser(n);if(p)throw p;return{data:{claims:i,header:a,signature:o},error:null}}const d=Xq(a.alg),m=await this.fetchJwk(a.kid,r),h=await crypto.subtle.importKey("jwk",m,d,!0,["verify"]);if(!await crypto.subtle.verify(d,h,o,Iq(`${l}.${c}`)))throw new Vm("Invalid JWT signature");return{data:{claims:i,header:a,signature:o},error:null}}catch(n){if(Tt(n))return{data:null,error:n};throw n}}}Ch.nextInstanceID=0;const hH=Ch;class fH extends hH{constructor(s){super(s)}}var pH=function(e,s,r,n){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(m){try{d(n.next(m))}catch(h){o(h)}}function c(m){try{d(n.throw(m))}catch(h){o(h)}}function d(m){m.done?i(m.value):a(m.value).then(l,c)}d((n=n.apply(e,s||[])).next())})};class xH{constructor(s,r,n){var a,i,o;if(this.supabaseUrl=s,this.supabaseKey=r,!s)throw new Error("supabaseUrl is required.");if(!r)throw new Error("supabaseKey is required.");const l=jq(s),c=new URL(l);this.realtimeUrl=new URL("realtime/v1",c),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",c),this.storageUrl=new URL("storage/v1",c),this.functionsUrl=new URL("functions/v1",c);const d=`sb-${c.hostname.split(".")[0]}-auth-token`,m={db:hq,realtime:pq,auth:Object.assign(Object.assign({},fq),{storageKey:d}),global:mq},h=wq(n??{},m);this.storageKey=(a=h.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(i=h.global.headers)!==null&&i!==void 0?i:{},h.accessToken?(this.accessToken=h.accessToken,this.auth=new Proxy({},{get:(f,p)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(p)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((o=h.auth)!==null&&o!==void 0?o:{},this.headers,h.global.fetch),this.fetch=yq(r,this._getAccessToken.bind(this),h.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},h.realtime)),this.rest=new MV(new URL("rest/v1",c).href,{headers:this.headers,schema:h.db.schema,fetch:this.fetch}),h.accessToken||this._listenForAuthEvents()}get functions(){return new uV(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}get storage(){return new cq(this.storageUrl.href,this.headers,this.fetch)}from(s){return this.rest.from(s)}schema(s){return this.rest.schema(s)}rpc(s,r={},n={}){return this.rest.rpc(s,r,n)}channel(s,r={config:{}}){return this.realtime.channel(s,r)}getChannels(){return this.realtime.getChannels()}removeChannel(s){return this.realtime.removeChannel(s)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var s,r;return pH(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();const{data:n}=yield this.auth.getSession();return(r=(s=n.session)===null||s===void 0?void 0:s.access_token)!==null&&r!==void 0?r:null})}_initSupabaseAuthClient({autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,storageKey:i,flowType:o,lock:l,debug:c},d,m){const h={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new fH({url:this.authUrl.href,headers:Object.assign(Object.assign({},h),d),storageKey:i,autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,flowType:o,lock:l,debug:c,fetch:m,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(s){return new KV(this.realtimeUrl.href,Object.assign(Object.assign({},s),{params:Object.assign({apikey:this.supabaseKey},s==null?void 0:s.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,n)=>{this._handleTokenChanged(r,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(s,r,n){(s==="TOKEN_REFRESHED"||s==="SIGNED_IN")&&this.changedAccessToken!==n?this.changedAccessToken=n:s==="SIGNED_OUT"&&(this.realtime.setAuth(),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const gH=(e,s,r)=>new xH(e,s,r),vH="https://qajegkbvbpekdggtrupv.supabase.co",yH="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InFhamVna2J2YnBla2RnZ3RydXB2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDkxMjM1NjEsImV4cCI6MjA2NDY5OTU2MX0.pYwQldpBjowrqBL_rwyBipOU5SkEAytfJLBzmLPGuBQ",W=gH(vH,yH),D6=u.createContext(void 0),Ar=()=>{const e=u.useContext(D6);return e===void 0?(console.warn("useAuth called outside AuthProvider - using defaults"),{user:null,session:null,loading:!0,isAdmin:!1,signIn:async()=>({error:new Error("Auth not initialized")}),signUp:async()=>({error:new Error("Auth not initialized")}),signOut:async()=>{}}):e},bH=({children:e})=>{const[s,r]=u.useState(null),[n,a]=u.useState(null),[i,o]=u.useState(!0),[l,c]=u.useState(!1),d=ds(),m=u.useCallback(g=>{setTimeout(async()=>{try{const{data:b}=await W.from("user_roles").select("role").eq("user_id",g).eq("role","admin").maybeSingle();c(!!b)}catch(b){console.error("Error checking admin role:",b),c(!1)}},0)},[]);u.useEffect(()=>{const{data:{subscription:g}}=W.auth.onAuthStateChange((b,w)=>{console.log("AuthContext: Auth state changed:",b),a(w),r((w==null?void 0:w.user)??null),o(!1),w!=null&&w.user?m(w.user.id):c(!1),b==="SIGNED_OUT"&&(c(!1),setTimeout(()=>{window.location.pathname!=="/"&&(window.location.href="/")},100))});return W.auth.getSession().then(({data:{session:b}})=>{a(b),r((b==null?void 0:b.user)??null),o(!1),b!=null&&b.user&&m(b.user.id)}),()=>g.unsubscribe()},[m,d]);const h=u.useCallback(async(g,b)=>{try{const{data:w,error:j}=await W.auth.signInWithPassword({email:g,password:b});if(j)return{error:new Error(j.message)};if(w.user){Ks({title:"Welcome back!",description:"You have been successfully signed in."});const{data:y}=await W.from("user_roles").select("role").eq("user_id",w.user.id).eq("role","admin").maybeSingle(),v=!!y;c(v),d(v?"/admin":"/dashboard")}return{}}catch(w){return{error:new Error(w.message||"An unexpected error occurred")}}},[d]),f=u.useCallback(async(g,b,w)=>{try{const j=w!=null&&w.redirectPath?`${window.location.origin}${w.redirectPath}`:`${window.location.origin}/`,{data:y,error:v}=await W.auth.signUp({email:g,password:b,options:{emailRedirectTo:j,data:{display_name:(w==null?void 0:w.displayName)||g.split("@")[0]}}});if(v)return{error:new Error(v.message)};if(y.user&&!y.session)return Ks({title:"Check Your Email",description:"We've sent you a confirmation link. Please check your email to verify your account."}),{needsConfirmation:!0};Ks({title:"Account Created!",description:"Welcome! Your account has been created successfully."});try{await W.functions.invoke("send-welcome-email",{body:{email:g,displayName:w==null?void 0:w.displayName}})}catch(N){console.error("Error sending welcome email:",N)}return d("/dashboard"),{}}catch(j){return{error:new Error(j.message||"An unexpected error occurred")}}},[d]),p=u.useCallback(async()=>{try{await W.auth.signOut(),d("/"),Ks({title:"Signed out",description:"You have been successfully signed out."})}catch(g){console.error("Error signing out:",g),Ks({title:"Error",description:"Failed to sign out. Please try again.",variant:"destructive"})}},[d]),x={user:s,session:n,loading:i,isAdmin:l,signIn:h,signUp:f,signOut:p};return t.jsx(D6.Provider,{value:x,children:e})};var Yy="focusScope.autoFocusOnMount",Ky="focusScope.autoFocusOnUnmount",SS={bubbles:!1,cancelable:!0},jH="FocusScope",Af=u.forwardRef((e,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=e,[l,c]=u.useState(null),d=Qt(a),m=Qt(i),h=u.useRef(null),f=at(s,g=>c(g)),p=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(n){let g=function(y){if(p.paused||!l)return;const v=y.target;l.contains(v)?h.current=v:po(h.current,{select:!0})},b=function(y){if(p.paused||!l)return;const v=y.relatedTarget;v!==null&&(l.contains(v)||po(h.current,{select:!0}))},w=function(y){if(document.activeElement===document.body)for(const N of y)N.removedNodes.length>0&&po(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",b);const j=new MutationObserver(w);return l&&j.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",b),j.disconnect()}}},[n,l,p.paused]),u.useEffect(()=>{if(l){kS.add(p);const g=document.activeElement;if(!l.contains(g)){const w=new CustomEvent(Yy,SS);l.addEventListener(Yy,d),l.dispatchEvent(w),w.defaultPrevented||(wH(kH(R6(l)),{select:!0}),document.activeElement===g&&po(l))}return()=>{l.removeEventListener(Yy,d),setTimeout(()=>{const w=new CustomEvent(Ky,SS);l.addEventListener(Ky,m),l.dispatchEvent(w),w.defaultPrevented||po(g??document.body,{select:!0}),l.removeEventListener(Ky,m),kS.remove(p)}
vendor: 4,873 bytes, line 689
689,0)}}},[l,d,m,p]);const x=u.useCallback(g=>{if(!r&&!n||p.paused)return;const b=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,w=document.activeElement;if(b&&w){const j=g.currentTarget,[y,v]=NH(j);y&&v?!g.shiftKey&&w===v?(g.preventDefault(),r&&po(y,{select:!0})):g.shiftKey&&w===y&&(g.preventDefault(),r&&po(v,{select:!0})):w===j&&g.preventDefault()}},[r,n,p.paused]);return t.jsx(ze.div,{tabIndex:-1,...o,ref:f,onKeyDown:x})});Af.displayName=jH;function wH(e,{select:s=!1}={}){const r=document.activeElement;for(const n of e)if(po(n,{select:s}),document.activeElement!==r)return}function NH(e){const s=R6(e),r=CS(s,e),n=CS(s.reverse(),e);return[r,n]}function R6(e){const s=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}function CS(e,s){for(const r of e)if(!_H(r,{upTo:s}))return r}function _H(e,{upTo:s}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(s!==void 0&&e===s)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function SH(e){return e instanceof HTMLInputElement&&"select"in e}function po(e,{select:s=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&SH(e)&&s&&e.select()}}var kS=CH();function CH(){let e=[];return{add(s){const r=e[0];s!==r&&(r==null||r.pause()),e=$S(e,s),e.unshift(s)},remove(s){var r;e=$S(e,s),(r=e[0])==null||r.resume()}}}function $S(e,s){const r=[...e],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function kH(e){return e.filter(s=>s.tagName!=="A")}var Qy=0;function Sv(){u.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ES()),document.body.insertAdjacentElement("beforeend",e[1]??ES()),Qy++,()=>{Qy===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),Qy--}},[])}function ES(){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 Fr=function(){return Fr=Object.assign||function(s){for(var r,n=1,a=arguments.length;n<a;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(s[i]=r[i])}return s},Fr.apply(this,arguments)};function Xw(e,s){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&s.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)s.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r}function M6(e,s,r){if(r||arguments.length===2)for(var n=0,a=s.length,i;n<a;n++)(i||!(n in s))&&(i||(i=Array.prototype.slice.call(s,0,n)),i[n]=s[n]);return e.concat(i||Array.prototype.slice.call(s))}var Hm="right-scroll-bar-position",Wm="width-before-scroll-bar",$H="with-scroll-bars-hidden",EH="--removed-body-scroll-bar-size";function Xy(e,s){return typeof e=="function"?e(s):e&&(e.current=s),e}function PH(e,s){var r=u.useState(function(){return{value:e,callback:s,facade:{get current(){return r.value},set current(n){var a=r.value;a!==n&&(r.value=n,r.callback(n,a))}}}})[0];return r.callback=s,r.facade}var AH=typeof window<"u"?u.useLayoutEffect:u.useEffect,PS=new WeakMap;function O6(e,s){var r=PH(null,function(n){return e.forEach(function(a){return Xy(a,n)})});return AH(function(){var n=PS.get(r);if(n){var a=new Set(n),i=new Set(e),o=r.current;a.forEach(function(l){i.has(l)||Xy(l,null)}),i.forEach(function(l){a.has(l)||Xy(l,o)})}PS.set(r,e)},[e]),r}function TH(e){return e}function DH(e,s){s===void 0&&(s=TH);var r=[],n=!1,a={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(i){var o=s(i,n);return r.push(o),function(){r=r.filter(function(l){return l!==o})}},assignSyncMedium:function(i){for(n=!0;r.length;){var o=r;r=[],o.forEach(i)}r={push:function(l){return i(l)},filter:function(){return r}}},assignMedium:function(i){n=!0;var o=[];if(r.length){var l=r;r=[],l.forEach(i),o=r}var c=function(){var m=o;o=[],m.forEach(i)},d=function(){return Promise.resolve().then(c)};d(),r={push:function(m){o.push(m),d()},filter:function(m){return o=o.filter(m),r}}}};return a}function I6(e){e===void 0&&(e={});var s=DH(null);return s.options=Fr({async:!0,ssr:!1},e),s}var F6=function(e){var s=e.sideCar,r=Xw(e,["sideCar"]);if(!s)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=s.read();if(!n)throw new Error("Sidecar medium not found");return u.createElement(n,Fr({},r))};
vendor: 4,593 bytes, lines 689-726
689F6.isSideCarExport=!0;function L6(e,s){return e.useMedium(s),F6}var B6=I6(),Zy=function(){},Cv=u.forwardRef(function(e,s){var r=u.useRef(null),n=u.useState({onScrollCapture:Zy,onWheelCapture:Zy,onTouchMoveCapture:Zy}),a=n[0],i=n[1],o=e.forwardProps,l=e.children,c=e.className,d=e.removeScrollBar,m=e.enabled,h=e.shards,f=e.sideCar,p=e.noIsolation,x=e.inert,g=e.allowPinchZoom,b=e.as,w=b===void 0?"div":b,j=e.gapMode,y=Xw(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),v=f,N=O6([r,s]),S=Fr(Fr({},y),a);return u.createElement(u.Fragment,null,m&&u.createElement(v,{sideCar:B6,removeScrollBar:d,shards:h,noIsolation:p,inert:x,setCallbacks:i,allowPinchZoom:!!g,lockRef:r,gapMode:j}),o?u.cloneElement(u.Children.only(l),Fr(Fr({},S),{ref:N})):u.createElement(w,Fr({},S,{className:c,ref:N}),l))});Cv.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Cv.classNames={fullWidth:Wm,zeroRight:Hm};var RH=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function MH(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var s=RH();return s&&e.setAttribute("nonce",s),e}function OH(e,s){e.styleSheet?e.styleSheet.cssText=s:e.appendChild(document.createTextNode(s))}function IH(e){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(e)}var FH=function(){var e=0,s=null;return{add:function(r){e==0&&(s=MH())&&(OH(s,r),IH(s)),e++},remove:function(){e--,!e&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},LH=function(){var e=FH();return function(s,r){u.useEffect(function(){return e.add(s),function(){e.remove()}},[s&&r])}},Zw=function(){var e=LH(),s=function(r){var n=r.styles,a=r.dynamic;return e(n,a),null};return s},BH={left:0,top:0,right:0,gap:0},Jy=function(e){return parseInt(e||"",10)||0},zH=function(e){var s=window.getComputedStyle(document.body),r=s[e==="padding"?"paddingLeft":"marginLeft"],n=s[e==="padding"?"paddingTop":"marginTop"],a=s[e==="padding"?"paddingRight":"marginRight"];return[Jy(r),Jy(n),Jy(a)]},UH=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return BH;var s=zH(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:s[0],top:s[1],right:s[2],gap:Math.max(0,n-r+s[2]-s[0])}},VH=Zw(),Ed="data-scroll-locked",qH=function(e,s,r,n){var a=e.left,i=e.top,o=e.right,l=e.gap;return r===void 0&&(r="margin"),` 690 .`.concat($H,` { 691 overflow: hidden `).concat(n,`; 692 padding-right: `).concat(l,"px ").concat(n,`; 693 } 694 body[`).concat(Ed,`] { 695 overflow: hidden `).concat(n,`; 696 overscroll-behavior: contain; 697 `).concat([s&&"position: relative ".concat(n,";"),r==="margin"&&` 698 padding-left: `.concat(a,`px; 699 padding-top: `).concat(i,`px; 700 padding-right: `).concat(o,`px; 701 margin-left:0; 702 margin-top:0; 703 margin-right: `).concat(l,"px ").concat(n,`; 704 `),r==="padding"&&"padding-right: ".concat(l,"px ").concat(n,";")].filter(Boolean).join(""),` 705 } 706 707 .`).concat(Hm,` { 708 right: `).concat(l,"px ").concat(n,`; 709 } 710 711 .`).concat(Wm,` { 712 margin-right: `).concat(l,"px ").concat(n,`; 713 } 714 715 .`).concat(Hm," .").concat(Hm,` { 716 right: 0 `).concat(n,`; 717 } 718 719 .`).concat(Wm," .").concat(Wm,` { 720 margin-right: 0 `).concat(n,`; 721 } 722 723 body[`).concat(Ed,`] { 724 `).concat(EH,": ").concat(l,`px; 725 } 726`)},AS=function(){var e=parseInt(document.body.getAttribute(Ed)||"0",10);return isFinite(e)?e:0},HH=function(){u.useEffect(function(){return document.body.setAttribute(Ed,(AS()+1).toString()),function(){var e=AS()-1;e<=0?document.body.removeAttribute(Ed):document.body.setAttribute(Ed,e.toString())}},[])},z6=function(e){var s=e.noRelative,r=e.noImportant,n=e.gapMode,a=n===void 0?"margin":n;HH();var i=u.useMemo(function(){return UH(a)},[a]);return u.createElement(VH,{styles:qH(i,!s,a,r?"":"!important")})},vj=!1;if(typeof window<"u")try{var Ap=Object.defineProperty({},"passive",{get:function(){return vj=!0,!0}});window.addEventListener("test",Ap,Ap),window.removeEventListener("test",Ap,Ap)}catch{vj=!1}var Vc=vj?{passive:!1}:!1,WH=function(e){return e.tagName==="TEXTAREA"},U6=function(e,s){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!WH(e)&&r[s]==="visible")},GH=function(e){return U6(e,"overflowY")},YH=function(e){return U6(e,"overflowX")},TS=function(e,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=V6(e,n);if(a){var i=q6(e,n),o=i[1],l=i[2];if(o>l)return!0}n=n.parentNode}while(n&&n!==r.body);return!1}
vendor: 9,056 bytes, lines 726-729
726,KH=function(e){var s=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[s,r,n]},QH=function(e){var s=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[s,r,n]},V6=function(e,s){return e==="v"?GH(s):YH(s)},q6=function(e,s){return e==="v"?KH(s):QH(s)},XH=function(e,s){return e==="h"&&s==="rtl"?-1:1},ZH=function(e,s,r,n,a){var i=XH(e,window.getComputedStyle(s).direction),o=i*n,l=r.target,c=s.contains(l),d=!1,m=o>0,h=0,f=0;do{var p=q6(e,l),x=p[0],g=p[1],b=p[2],w=g-b-i*x;(x||w)&&V6(e,l)&&(h+=w,f+=x),l instanceof ShadowRoot?l=l.host:l=l.parentNode}while(!c&&l!==document.body||c&&(s.contains(l)||s===l));return(m&&(Math.abs(h)<1||!a)||!m&&(Math.abs(f)<1||!a))&&(d=!0),d},Tp=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},DS=function(e){return[e.deltaX,e.deltaY]},RS=function(e){return e&&"current"in e?e.current:e},JH=function(e,s){return e[0]===s[0]&&e[1]===s[1]},eW=function(e){return` 727 .block-interactivity-`.concat(e,` {pointer-events: none;} 728 .allow-interactivity-`).concat(e,` {pointer-events: all;} 729`)},tW=0,qc=[];function sW(e){var s=u.useRef([]),r=u.useRef([0,0]),n=u.useRef(),a=u.useState(tW++)[0],i=u.useState(Zw)[0],o=u.useRef(e);u.useEffect(function(){o.current=e},[e]),u.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var g=M6([e.lockRef.current],(e.shards||[]).map(RS),!0).filter(Boolean);return g.forEach(function(b){return b.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),g.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=u.useCallback(function(g,b){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!o.current.allowPinchZoom;var w=Tp(g),j=r.current,y="deltaX"in g?g.deltaX:j[0]-w[0],v="deltaY"in g?g.deltaY:j[1]-w[1],N,S=g.target,k=Math.abs(y)>Math.abs(v)?"h":"v";if("touches"in g&&k==="h"&&S.type==="range")return!1;var $=TS(k,S);if(!$)return!0;if($?N=k:(N=k==="v"?"h":"v",$=TS(k,S)),!$)return!1;if(!n.current&&"changedTouches"in g&&(y||v)&&(n.current=N),!N)return!0;var R=n.current||N;return ZH(R,b,g,R==="h"?y:v,!0)},[]),c=u.useCallback(function(g){var b=g;if(!(!qc.length||qc[qc.length-1]!==i)){var w="deltaY"in b?DS(b):Tp(b),j=s.current.filter(function(N){return N.name===b.type&&(N.target===b.target||b.target===N.shadowParent)&&JH(N.delta,w)})[0];if(j&&j.should){b.cancelable&&b.preventDefault();return}if(!j){var y=(o.current.shards||[]).map(RS).filter(Boolean).filter(function(N){return N.contains(b.target)}),v=y.length>0?l(b,y[0]):!o.current.noIsolation;v&&b.cancelable&&b.preventDefault()}}},[]),d=u.useCallback(function(g,b,w,j){var y={name:g,delta:b,target:w,should:j,shadowParent:rW(w)};s.current.push(y),setTimeout(function(){s.current=s.current.filter(function(v){return v!==y})},1)},[]),m=u.useCallback(function(g){r.current=Tp(g),n.current=void 0},[]),h=u.useCallback(function(g){d(g.type,DS(g),g.target,l(g,e.lockRef.current))},[]),f=u.useCallback(function(g){d(g.type,Tp(g),g.target,l(g,e.lockRef.current))},[]);u.useEffect(function(){return qc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",c,Vc),document.addEventListener("touchmove",c,Vc),document.addEventListener("touchstart",m,Vc),function(){qc=qc.filter(function(g){return g!==i}),document.removeEventListener("wheel",c,Vc),document.removeEventListener("touchmove",c,Vc),document.removeEventListener("touchstart",m,Vc)}},[]);var p=e.removeScrollBar,x=e.inert;return u.createElement(u.Fragment,null,x?u.createElement(i,{styles:eW(a)}):null,p?u.createElement(z6,{gapMode:e.gapMode}):null)}function rW(e){for(var s=null;e!==null;)e instanceof ShadowRoot&&(s=e.host,e=e.host),e=e.parentNode;return s}const nW=L6(B6,sW);var Tf=u.forwardRef(function(e,s){return u.createElement(Cv,Fr({},e,{ref:s,sideCar:nW}))});Tf.classNames=Cv.classNames;var aW=function(e){if(typeof document>"u")return null;var s=Array.isArray(e)?e[0]:e;return s.ownerDocument.body},Hc=new WeakMap,Dp=new WeakMap,Rp={},e0=0,H6=function(e){return e&&(e.host||H6(e.parentNode))},iW=function(e,s){return s.map(function(r){if(e.contains(r))return r;var n=H6(r);return n&&e.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},oW=function(e,s,r,n){var a=iW(s,Array.isArray(e)?e:[e]);Rp[r]||(Rp[r]=new WeakMap);var i=Rp[r],o=[],l=new Set,c=new Set(a),d=function(h){!h||l.has(h)||(l.add(h),d(h.parentNode))};a.forEach(d);var m=function(h){!h||c.has(h)||Array.prototype.forEach.call(h.children,function(f){if(l.has(f))m(f);else try{var p=f.getAttribute(n),x=p!==null&&p!=="false",g=(Hc.get(f)||0)+1,b=(i.get(f)||0)+1;Hc.set(f,g),i.set(f,b),o.push(f),g===1&&x&&Dp.set(f,!0),b===1&&f.setAttribute(r,"true"),x||f.setAttribute(n,"true")}catch(w){console.error("aria-hidden: cannot operate on ",f,w)}})};return m(s),l.clear(),e0++,function(){o.forEach(function(h){var f=Hc.get(h)-1,p=i.get(h)-1;Hc.set(h,f),i.set(h,p),f||(Dp.has(h)||h.removeAttribute(n),Dp.delete(h)),p||h.removeAttribute(r)}),e0--,e0||(Hc=new WeakMap,Hc=new WeakMap,Dp=new WeakMap,Rp={})}},Df=function(e,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),a=aW(e);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),oW(n,a,r,"aria-hidden")):function(){return null}},Jw="Dialog",[W6,G6]=hr(Jw),[lW,qa]=W6(Jw),Y6=e=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:i,modal:o=!0}=e,l=u.useRef(null),c=u.useRef(null),[d=!1,m]=wr({prop:n,defaultProp:a,onChange:i});return t.jsx(lW,{scope:s,triggerRef:l,contentRef:c,contentId:Lr(),titleId:Lr(),descriptionId:Lr(),open:d,onOpenChange:m,onOpenToggle:u.useCallback(()=>m(h=>!h),[m]),modal:o,children:r})};Y6.displayName=Jw;var K6="DialogTrigger",Q6=u.forwardRef((e,s)=>{const{__scopeDialog:r,...n}=e,a=qa(K6,r),i=at(s,a.triggerRef);return t.jsx(ze.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":s2(a.open),...n,ref:i,onClick:Se(e.onClick,a.onOpenToggle)})});Q6.displayName=K6;var e2="DialogPortal",[cW,X6]=W6(e2,{forceMount:void 0}),Z6=e=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=e,i=qa(e2,s);return t.jsx(cW,{scope:s,forceMount:r,children:u.Children.map(n,o=>t.jsx(Ts,{present:r||i.open,children:t.jsx(Nu,{asChild:!0,container:a,children:o})}))})};Z6.displayName=e2;var ng="DialogOverlay",J6=u.forwardRef((e,s)=>{const r=X6(ng,e.__scopeDialog),{forceMount:n=r.forceMount,...a}=e,i=qa(ng,e.__scopeDialog);return i.modal?t.jsx(Ts,{present:n||i.open,children:t.jsx(dW,{...a,ref:s})}):null});J6.displayName=ng;var dW=u.forwardRef((e,s)=>{const{__scopeDialog:r,...n}=e,a=qa(ng,r);return t.jsx(Tf,{as:tn,allowPinchZoom:!0,shards:[a.contentRef],children:t.jsx(ze.div,{"data-state":s2(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),gc="DialogContent",eP=u.forwardRef((e,s)=>{const r=X6(gc,e.__scopeDialog),{forceMount:n=r.forceMount,...a}=e,i=qa(gc,e.__scopeDialog);return t.jsx(Ts,{present:n||i.open,children:i.modal?t.jsx(uW,{...a,ref:s}):t.jsx(mW,{...a,ref:s})})});eP.displayName=gc;var uW=u.forwardRef((e,s)=>{const r=qa(gc,e.__scopeDialog),n=u.useRef(null),a=at(s,r.contentRef,n);return u.useEffect(()=>{const i=n.current;if(i)return Df(i)},[]),t.jsx(tP,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Se(e.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=r.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Se(e.onPointerDownOutside,i=>{const o=i.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&i.preventDefault()}),onFocusOutside:Se(e.onFocusOutside,i=>i.preventDefault())})}),mW=u.forwardRef((e,s)=>{const r=qa(gc,e.__scopeDialog),n=u.useRef(!1),a=u.useRef(!1);return t.jsx(tP,{...e,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,i),i.defaultPrevented||(n.current||(l=r.triggerRef.current)==null||l.focus(),i.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:i=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((d=r.triggerRef.current)==null?void 0:d.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),tP=u.forwardRef((e,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=e,l=qa(gc,r),c=u.useRef(null),d=at(s,c);return Sv(),t.jsxs(t.Fragment,{children:[t.jsx(Af,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:i,children:t.jsx(xl,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":s2(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),t.jsxs(t.Fragment,{children:[t.jsx(fW,{titleId:l.titleId}),t.jsx(xW,{contentRef:c,descriptionId:l.descriptionId})]})]})}
729),t2="DialogTitle",sP=u.forwardRef((e,s)=>{const{__scopeDialog:r,...n}=e,a=qa(t2,r);return t.jsx(ze.h2,{id:a.titleId,...n,ref:s})});sP.displayName=t2;var rP="DialogDescription",nP=u.forwardRef((e,s)=>{const{__scopeDialog:r,...n}=e,a=qa(rP,r);return t.jsx(ze.p,{id:a.descriptionId,...n,ref:s})});nP.displayName=rP;var aP="DialogClose",iP=u.forwardRef((e,s)=>{const{__scopeDialog:r,...n}=e,a=qa(aP,r);return t.jsx(ze.button,{type:"button",...n,ref:s,onClick:Se(e.onClick,()=>a.onOpenChange(!1))})});iP.displayName=aP;function s2(e){return e?"open":"closed"}var oP="DialogTitleWarning",[hW,lP]=lF(oP,{contentName:gc,titleName:t2,docsSlug:"dialog"}),fW=({titleId:e})=>{const s=lP(oP),r=`\`${s.contentName}\` requires a \`${s.titleName}\` for the component to be accessible for screen reader users. 730 731If you want to hide the \`${s.titleName}\`, you can wrap it with our VisuallyHidden component. 732 733For more information, see https://radix-ui.com/primitives/docs/components/${s.docsSlug}`;return u.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},pW="DialogDescriptionWarning",xW=({contentRef:e,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${lP(pW).contentName}}.`;return u.useEffect(()=>{var i;const a=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");s&&a&&(document.getElementById(s)||console.warn(n))},[n,e,s]),null},r2=Y6,n2=Q6,a2=Z6,Rf=J6,Mf=eP,Of=sP,If=nP,kv=iP;const i2=r2,gW=n2,vW=a2,cP=u.forwardRef(({className:e,...s},r)=>t.jsx(Rf,{className:oe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...s,ref:r}));cP.displayName=Rf.displayName;const yW=fa("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),$v=u.forwardRef(({side:e="right",className:s,children:r,...n},a)=>t.jsxs(vW,{children:[t.jsx(cP,{}),t.jsxs(Mf,{ref:a,className:oe(yW({side:e}),s),...n,children:[r,t.jsxs(kv,{className:"absolute right-4 top-4 roun
733ded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[t.jsx(Es,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));$v.displayName=Mf.displayName;const o2=({className:e,...s})=>t.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...s});o2.displayName="SheetHeader";const l2=u.forwardRef(({className:e,...s},r)=>t.jsx(Of,{ref:r,className:oe("text-lg font-semibold text-foreground",e),...s}));l2.displayName=Of.displayName;const dP=u.forwardRef(({className:e,...s},r)=>t.jsx(If,{ref:r,className:oe("text-sm text-muted-foreground",e),...s}));dP.displayName=If.displayName;var c2="Collapsible",[bW,uP]=hr(c2),[jW,d2]=bW(c2),mP=u.forwardRef((e,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[c=!1,d]=wr({prop:n,defaultProp:a,onChange:o});return t.jsx(jW,{scope:r,disabled:i,contentId:Lr(),open:c,onOpenToggle:u.useCallback(()=>d(m=>!m),[d]),children:t.jsx(ze.div,{"data-state":f2(c),"data-disabled":i?"":void 0,...l,ref:s})})});mP.displayName=c2;var hP="CollapsibleTrigger",u2=u.forwardRef((e,s)=>{const{__scopeCollapsible:r,...n}=e,a=d2(hP,r);return t.jsx(ze.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":f2(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Se(e.onClick,a.onOpenToggle)})});u2.displayName=hP;var m2="CollapsibleContent",h2=u.forwardRef((e,s)=>{const{forceMount:r,...n}=e,a=d2(m2,e.__scopeCollapsible);return t.jsx(Ts,{present:r||a.open,children:({present:i})=>t.jsx(wW,{...n,ref:s,present:i})})});h2.displayName=m2;var wW=u.forwardRef((e,s)=>{const{__scopeCollapsible:r,present:n,children:a,...i}=e,o=d2(m2,r),[l,c]=u.useState(n),d=u.useRef(null),m=at(s,d),h=u.useRef(0),f=h.current,p=u.useRef(0),x=p.current,g=o.open||l,b=u.useRef(g),w=u.useRef();return u.useEffect(()=>{const j=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(j)},[]),qs(()=>{const j=d.current;if(j){w.current=w.current||{transitionDuration:j.style.transitionDuration,animationName:j.style.animationName},j.style.transitionDuration="0s",j.style.animationName="none";const y=j.getBoundingClientRect();h.current=y.height,p.current=y.width,b.current||(j.style.transitionDuration=w.current.transitionDuration,j.style.animationName=w.current.animationName),c(n)}},[o.open,n]),t.jsx(ze.div,{"data-state":f2(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!g,...i,ref:m,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":x?`${x}px`:void 0,...e.style},children:g&&a})});function f2(e){return e?"open":"closed"}var fP=mP,NW=u2,_W=h2,SW=u.createContext(void 0);function to(e){const s=u.useContext(SW);return e||s||"ltr"}var so="Accordion",CW=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[p2,kW,$W]=pl(so),[Ev,xfe]=hr(so,[$W,uP]),x2=uP(),pP=ve.forwardRef((e,s)=>{const{type:r,...n}=e,a=n,i=n;return t.jsx(p2.Provider,{scope:e.__scopeAccordion,children:r==="multiple"?t.jsx(TW,{...i,ref:s}):t.jsx(AW,{...a,ref:s})})});pP.displayName=so;var[xP,EW]=Ev(so),[gP,PW]=Ev(so,{collapsible:!1}),AW=ve.forwardRef((e,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},collapsible:i=!1,...o}=e,[l,c]=wr({prop:r,defaultProp:n,onChange:a});return t.jsx(xP,{scope:e.__scopeAccordion,value:l?[l]:[],onItemOpen:c,onItemClose:ve.useCallback(()=>i&&c(""),[i,c]),children:t.jsx(gP,{scope:e.__scopeAccordion,collapsible:i,children:t.jsx(vP,{...o,ref:s})})})}),TW=ve.forwardRef((e,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...i}=e,[o=[],l]=wr({prop:r,defaultProp:n,onChange:a}),c=ve.useCallback(m=>l((h=[])=>[...h,m]),[l]),d=ve.useCallback(m=>l((h=[])=>h.filter(f=>f!==m)),[l]);return t.jsx(xP,{scope:e.__scopeAccordion,value:o,onItemOpen:c,onItemClose:d,children:t.jsx(gP,{scope:e.__scopeAccordion,collapsible:!0,children:t.jsx(vP,{...i,ref:s})})})}),[DW,Pv]=Ev(so),vP=ve.forwardRef((e,s)=>{const{__scopeAccordion:r,disabled:n,dir:a,orientation:i="vertical",...o}=e,l=ve.useRef(null),c=at(l,s),d=kW(r),h=to(a)==="ltr",f=Se(e.onKeyDown,p=>{var $;if(!CW.includes(p.key))return;const x=p.target,g=d().filter(R=>{var A;return!((A=R.ref.current)!=null&&A.disabled)}),b=g.findIndex(R=>R.ref.current===x),w=g.length;if(b===-1)return;p.preventDefault();let j=b;const y=0,v=w-1,N=()=>{j=b+1,j>v&&(j=y)},S=()=>{j=b-1,j<y&&(j=v)};switch(p.key){case"Home":j=y;break;case"End":j=v;break;case"ArrowRight":i==="horizontal"&&(h?N():S());break;case"ArrowDown":i==="vertical"&&N();break;case"ArrowLeft":i==="horizontal"&&(h?S():N());break;case"ArrowUp":i==="vertical"&&S();break}const k=j%w;($=g[k].ref.current)==null||$.focus()});return t.jsx(DW,{scope:r,disabled:n,direction:a,orientation:i,children:t.jsx(p2.Slot,{scope:r,children:t.jsx(ze.div,{...o,"data-orientation":i,ref:c,onKeyDown:n?void 0:f})})})}),ag="AccordionItem",[RW,g2]=Ev(ag),yP=ve.forwardRef((e,s)=>{const{__scopeAccordion:r,value:n,...a}=e,i=Pv(ag,r),o=EW(ag,r),l=x2(r),c=Lr(),d=n&&o.value.includes(n)||!1,m=i.disabled||e.disabled;return t.jsx(RW,{scope:r,open:d,disabled:m,triggerId:c,children:t.jsx(fP,{"data-orientation":i.orientation,"data-state":SP(d),...l,...a,ref:s,disabled:m,open:d,onOpenChange:h=>{h?o.onItemOpen(n):o.onItemClose(n)}})})});yP.displayName=ag;var bP="AccordionHeader",jP=ve.forwardRef((e,s)=>{const{__scopeAccordion:r,...n}=e,a=Pv(so,r),i=g2(bP,r);return t.jsx(ze.h3,{"data-orientation":a.orientation,"data-state":SP(i.open),"data-disabled":i.disabled?"":void 0,...n,ref:s})});jP.displayName=bP;var yj="AccordionTrigger",wP=ve.forwardRef((e,s)=>{const{__scopeAccordion:r,...n}=e,a=Pv(so,r),i=g2(yj,r),o=PW(yj,r),l=x2(r);return t.jsx(p2.ItemSlot,{scope:r,children:t.jsx(NW,{"aria-disabled":i.open&&!o.collapsible||void 0,"data-orientation":a.orientation,id:i.triggerId,...l,...n,ref:s})})});wP.displayName=yj;var NP="AccordionContent",_P=ve.forwardRef((e,s)=>{const{__scopeAccordion:r,...n}=e,a=Pv(so,r),i=g2(NP,r),o=x2(r);return t.jsx(_W,{role:"region","aria-labelledby":i.triggerId,"data-orientation":a.orientation,...o,...n,ref:s,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});_P.displayName=NP;function SP(e){return e?"open":"closed"}var MW=pP,OW=yP,IW=jP,CP=wP,kP=_P;const Ru=MW,ti=u.forwardRef(({className:e,...s},r)=>t.jsx(OW,{ref:r,className:oe("border-b",e),...s}));ti.displayName="AccordionItem";const si=u.forwardRef(({className:e,children:s,...r},n)=>t.jsx(IW,{className:"flex",children:t.jsxs(CP,{ref:n,className:oe("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...r,children:[s,t.jsx(Ma,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));si.displayName=CP.displayName;const ri=u.forwardRef(({className:e,children:s,...r},n)=>t.jsx(kP,{ref:n,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:t.jsx("div",{className:oe("pb-4 pt-0",e),children:s})}));ri.displayName=kP.displayName;
733const kh=fa("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-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),q=u.forwardRef(({className:e,variant:s,size:r,asChild:n=!1,...a},i)=>{const o=n?tn:"button";return t.jsx(o,{className:oe(kh({variant:s,size:r,className:e})),ref:i,...a})});q.displayName="Button";const FW=fa("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function we({className:e,variant:s,...r}){return t.jsx("div",{className:oe(FW({variant:s}),e),...r})}const ig=fP,og=u2,lg=h2;function Is({className:e,...s}){return t.jsx("div",{className:oe("animate-pulse rounded-md bg-muted",e),...s})}const LW=()=>{const e=Xs(),s=Lt({queryKey:["alerts","active"],queryFn:async()=>{console.log("useActiveAlerts: Fetching alerts via RPC...");const{data:r,error:n}=await W.rpc("get_active_alerts");if(n)throw console.error("useActiveAlerts: Error fetching alerts:",n),n;return console.log("useActiveAlerts: Successfully fetched alerts:",r),(r||[]).map(a=>({...a,alert_type:a.alert_type}))},staleTime:5*60*1e3,gcTime:10*60*1e3,refetchOnWindowFocus:!0,refetchOnReconnect:!0});return u.useEffect(()=>{console.log("useActiveAlerts: Setting up real-time subscription...");const r=`alerts-changes-${Math.random().toString(36).substring(7)}`,n=W.channel(r).on("postgres_changes",{event:"*",schema:"public",table:"alerts"},a=>{console.log("useActiveAlerts: Real-time update received:",a),e.invalidateQueries({queryKey:["alerts","active"]})}).subscribe();return()=>{console.log("useActiveAlerts: Cleaning up real-time subscription..."),n.unsubscribe(),W.removeChannel(n)}},[e]),s},MS=e=>({red:"bg-red-600 text-white",orange:"bg-orange-600 text-white",yellow:"bg-yellow-600 text-white",green:"bg-green-600 text-white",blue:"bg-blue-600 text-white",purple:"bg-purple-600 text-white"})[e]||"bg-red-600 text-white",BW=()=>{const[e,s]=u.useState(!0),{data:r=[],isLoading:n,error:a}=LW(),i=r.filter(l=>l.alert_type==="deadline"),o=r.filter(l=>l.alert_type==="premium_slot");return n?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Important Information"}),t.jsx(Is,{className:"h-16 w-full"}),t.jsx(Is,{className:"h-12 w-full"})]}):a?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Important Information"}),t.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-3 flex items-center gap-2",children:[t.jsx(mi,{className:"h-4 w-4 text-destructive"}),t.jsx("span",{className:"text-sm text-destructive",children:"Failed to load alerts"})]})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Important Information"}),i.length>0&&i.map(l=>t.jsxs("div",{className:"bg-gradient-to-r from-red-50 to-orange-50 border-2 border-red-200 rounded-lg p-4 shadow-md",children:[t.jsxs("h4",{className:"text-base font-bold text-red-700 mb-2 flex items-center justify-between",children:[t.jsxs("span",{children:["â ï¸ ",l.title]}),l.badge_text&&t.jsx(we,{className:MS(l.badge_color),children:l.badge_text})]}),t.jsx("div",{className:"text-sm text-red-600",children:l.message.split(` 734`).map((c,d)=>t.jsx("p",{className:d===0?"font-semibold mb-1":"text-xs font-medium",children:c},d))})]},l.id)),o.length>0&&t.jsxs(ig,{open:e,onOpenChange:s,children:[t.jsxs(og,{className:"flex items-center justify-between w-full text-left",children:[t.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Premium Slot Alerts"}),t.jsx(Ma,{className:`h-4 w-4 transform transition-transform ${e?"rotate-180":""}`})]}
vendor: 4,294 bytes, lines 734-735
734),t.jsx(lg,{className:"mt-2 space-y-2",children:o.map(l=>t.jsxs("div",{className:"bg-gradient-to-r from-orange-50 to-yellow-50 border border-orange-200 rounded-lg p-3 shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("h5",{className:"text-sm font-semibold text-orange-700",children:l.title}),l.badge_text&&t.jsx(we,{className:MS(l.badge_color),children:l.badge_text})]}),t.jsx("div",{className:"text-xs text-orange-600 space-y-1",children:l.message.split(` 735`).map((c,d)=>t.jsx("p",{className:d===0?"font-medium":"",children:c},d))})]},l.id))})]})]})};function Mu(e){const s=u.useRef({value:e,previous:e});return u.useMemo(()=>(s.current.value!==e&&(s.current.previous=s.current.value,s.current.value=e),s.current.previous),[e])}var Ou="NavigationMenu",[v2,$P,zW]=pl(Ou),[bj,UW,VW]=pl(Ou),[y2,gfe]=hr(Ou,[zW,VW]),[qW,pa]=y2(Ou),[HW,WW]=y2(Ou),EP=u.forwardRef((e,s)=>{const{__scopeNavigationMenu:r,value:n,onValueChange:a,defaultValue:i,delayDuration:o=200,skipDelayDuration:l=300,orientation:c="horizontal",dir:d,...m}=e,[h,f]=u.useState(null),p=at(s,R=>f(R)),x=to(d),g=u.useRef(0),b=u.useRef(0),w=u.useRef(0),[j,y]=u.useState(!0),[v="",N]=wr({prop:n,onChange:R=>{const A=R!=="",T=l>0;A?(window.clearTimeout(w.current),T&&y(!1)):(window.clearTimeout(w.current),w.current=window.setTimeout(()=>y(!0),l)),a==null||a(R)},defaultProp:i}),S=u.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>N(""),150)},[N]),k=u.useCallback(R=>{window.clearTimeout(b.current),N(R)},[N]),$=u.useCallback(R=>{v===R?window.clearTimeout(b.current):g.current=window.setTimeout(()=>{window.clearTimeout(b.current),N(R)},o)},[v,N,o]);return u.useEffect(()=>()=>{window.clearTimeout(g.current),window.clearTimeout(b.current),window.clearTimeout(w.current)},[]),t.jsx(AP,{scope:r,isRootMenu:!0,value:v,dir:x,orientation:c,rootNavigationMenu:h,onTriggerEnter:R=>{window.clearTimeout(g.current),j?$(R):k(R)},onTriggerLeave:()=>{window.clearTimeout(g.current),S()},onContentEnter:()=>window.clearTimeout(b.current),onContentLeave:S,onItemSelect:R=>{N(A=>A===R?"":R)},onItemDismiss:()=>N(""),children:t.jsx(ze.nav,{"aria-label":"Main","data-orientation":c,dir:x,...m,ref:p})})});EP.displayName=Ou;var PP="NavigationMenuSub",GW=u.forwardRef((e,s)=>{const{__scopeNavigationMenu:r,value:n,onValueChange:a,defaultValue:i,orientation:o="horizontal",...l}=e,c=pa(PP,r),[d="",m]=wr({prop:n,onChange:a,defaultProp:i});return t.jsx(AP,{scope:r,isRootMenu:!1,value:d,dir:c.dir,orientation:o,rootNavigationMenu:c.rootNavigationMenu,onTriggerEnter:h=>m(h),onItemSelect:h=>m(h),onItemDismiss:()=>m(""),children:t.jsx(ze.div,{"data-orientation":o,...l,ref:s})})});GW.displayName=PP;var AP=e=>{const{scope:s,isRootMenu:r,rootNavigationMenu:n,dir:a,orientation:i,children:o,value:l,onItemSelect:c,onItemDismiss:d,onTriggerEnter:m,onTriggerLeave:h,onContentEnter:f,onContentLeave:p}=e,[x,g]=u.useState(null),[b,w]=u.useState(new Map),[j,y]=u.useState(null);return t.jsx(qW,{scope:s,isRootMenu:r,rootNavigationMenu:n,value:l,previousValue:Mu(l),baseId:Lr(),dir:a,orientation:i,viewport:x,onViewportChange:g,indicatorTrack:j,onIndicatorTrackChange:y,onTriggerEnter:Qt(m),onTriggerLeave:Qt(h),onContentEnter:Qt(f),onContentLeave:Qt(p),onItemSelect:Qt(c),onItemDismiss:Qt(d),onViewportContentChange:u.useCallback((v,N)=>{w(S=>(S.set(v,N),new Map(S)))},[]),onViewportContentRemove:u.useCallback(v=>{w(N=>N.has(v)?(N.delete(v),new Map(N)):N)},[]),children:t.jsx(v2.Provider,{scope:s,children:t.jsx(HW,{scope:s,items:b,children:o})})})},TP="NavigationMenuList",DP=u.forwardRef((e,s)=>{const{__scopeNavigationMenu:r,...n}=e,a=pa(TP,r),i=t.jsx(ze.ul,{"data-orientation":a.orientation,...n,ref:s});return t.jsx(ze.div,{style:{position:"relative"},ref:a.onIndicatorTrackChange,children:t.jsx(v2.Slot,{scope:r,children:a.isRootMenu?t.jsx(VP,{asChild:!0,children:i}):i})})});DP.displayName=TP;var RP="NavigationMenuItem",[YW,MP]=y2(RP),OP=u.forwardRef((e,s)=>{const{__scopeNavigationMenu:r,value:n,...a}=e,i=Lr(),o=n||i||"LEGACY_REACT_AUTO_VALUE",l=u.useRef(null),c=u.useRef(null),d=u.useRef(null),m=u.useRef(()=>{}),h=u.useRef(!1),f=u.useCallback((x="start")=>{if(l.current){m.current();const g=wj(l.current);g.length&&w2(x==="start"?g:g.reverse())}},[]),p=u.useCallback(()=>
vendor: 4,199 bytes, line 735
735{if(l.current){const x=wj(l.current);x.length&&(m.current=tG(x))}},[]);return t.jsx(YW,{scope:r,value:o,triggerRef:c,contentRef:l,focusProxyRef:d,wasEscapeCloseRef:h,onEntryKeyDown:f,onFocusProxyEnter:f,onRootContentClose:p,onContentFocusOutside:p,children:t.jsx(ze.li,{...a,ref:s})})});OP.displayName=RP;var jj="NavigationMenuTrigger",IP=u.forwardRef((e,s)=>{const{__scopeNavigationMenu:r,disabled:n,...a}=e,i=pa(jj,e.__scopeNavigationMenu),o=MP(jj,e.__scopeNavigationMenu),l=u.useRef(null),c=at(l,o.triggerRef,s),d=HP(i.baseId,o.value),m=WP(i.baseId,o.value),h=u.useRef(!1),f=u.useRef(!1),p=o.value===i.value;return t.jsxs(t.Fragment,{children:[t.jsx(v2.ItemSlot,{scope:r,value:o.value,children:t.jsx(qP,{asChild:!0,children:t.jsx(ze.button,{id:d,disabled:n,"data-disabled":n?"":void 0,"data-state":N2(p),"aria-expanded":p,"aria-controls":m,...a,ref:c,onPointerEnter:Se(e.onPointerEnter,()=>{f.current=!1,o.wasEscapeCloseRef.current=!1}),onPointerMove:Se(e.onPointerMove,cg(()=>{n||f.current||o.wasEscapeCloseRef.current||h.current||(i.onTriggerEnter(o.value),h.current=!0)})),onPointerLeave:Se(e.onPointerLeave,cg(()=>{n||(i.onTriggerLeave(),h.current=!1)})),onClick:Se(e.onClick,()=>{i.onItemSelect(o.value),f.current=p}),onKeyDown:Se(e.onKeyDown,x=>{const b={horizontal:"ArrowDown",vertical:i.dir==="rtl"?"ArrowLeft":"ArrowRight"}[i.orientation];p&&x.key===b&&(o.onEntryKeyDown(),x.preventDefault())})})})}),p&&t.jsxs(t.Fragment,{children:[t.jsx(D$,{"aria-hidden":!0,tabIndex:0,ref:o.focusProxyRef,onFocus:x=>{const g=o.contentRef.current,b=x.relatedTarget,w=b===l.current,j=g==null?void 0:g.contains(b);(w||!j)&&o.onFocusProxyEnter(w?"start":"end")}}),i.viewport&&t.jsx("span",{"aria-owns":m})]})]})});IP.displayName=jj;var KW="NavigationMenuLink",OS="navigationMenu.linkSelect",FP=u.forwardRef((e,s)=>{const{__scopeNavigationMenu:r,active:n,onSelect:a,...i}=e;return t.jsx(qP,{asChild:!0,children:t.jsx(ze.a,{"data-active":n?"":void 0,"aria-current":n?"page":void 0,...i,ref:s,onClick:Se(e.onClick,o=>{const l=o.target,c=new CustomEvent(OS,{bubbles:!0,cancelable:!0});if(l.addEventListener(OS,d=>a==null?void 0:a(d),{once:!0}),vh(l,c),!c.defaultPrevented&&!o.metaKey){const d=new CustomEvent(dx,{bubbles:!0,cancelable:!0});vh(l,d)}},{checkForDefaultPrevented:!1})})})});FP.displayName=KW;var b2="NavigationMenuIndicator",LP=u.forwardRef((e,s)=>{const{forceMount:r,...n}=e,a=pa(b2,e.__scopeNavigationMenu),i=!!a.value;return a.indicatorTrack?Jg.createPortal(t.jsx(Ts,{present:r||i,children:t.jsx(QW,{...n,ref:s})}),a.indicatorTrack):null});LP.displayName=b2;var QW=u.forwardRef((e,s)=>{const{__scopeNavigationMenu:r,...n}=e,a=pa(b2,r),i=$P(r),[o,l]=u.useState(null),[c,d]=u.useState(null),m=a.orientation==="horizontal",h=!!a.value;u.useEffect(()=>{var g;const x=(g=i().find(b=>b.value===a.value))==null?void 0:g.ref.current;x&&l(x)},[i,a.value]);const f=()=>{o&&d({size:m?o.offsetWidth:o.offsetHeight,offset:m?o.offsetLeft:o.offsetTop})};return Nj(o,f),Nj(a.indicatorTrack,f),c?t.jsx(ze.div,{"aria-hidden":!0,"data-state":h?"visible":"hidden","data-orientation":a.orientation,...n,ref:s,style:{position:"absolute",...m?{left:0,width:c.size+"px",transform:`translateX(${c.offset}px)`}:{top:0,height:c.size+"px",transform:`translateY(${c.offset}px)`},...n.style}}):null}),ou="NavigationMenuContent",BP=u.forwardRef((e,s)=>{const{forceMount:r,...n}=e,a=pa(ou,e.__scopeNavigationMenu),i=MP(ou,e.__scopeNavigationMenu),o=at(i.contentRef,s),l=i.value===a.value,c={value:i.value,triggerRef:i.triggerRef,focusProxyRef:i.focusProxyRef,wasEscapeCloseRef:i.wasEscapeCloseRef,onContentFocusOutside:i.onContentFocusOutside,onRootContentClose:i.onRootContentClose,...n};return a.viewport?t.jsx(XW,{forceMount:r,...c,ref:o}):t.jsx(Ts,{present:r||l,children:t.jsx(zP,{"data-state":N2(l),...c,ref:o,onPointerEnter:Se(e.onPointerEnter,a.onContentEnter),onPointerLeave:Se(e.onPointerLeave,cg(a.onContentLeave)),style:{pointerEvents:!l&&a.isRootMenu?"none":void 0,...c.style}})})});BP.displayName=ou;var XW=u.forwardRef((e,s)=>{const r=pa(ou,e.__scopeNavigationMenu),{onViewportContentChange:n,onViewportContentRemove:a}=r;return qs(()=>{n(e.value,{ref:s,...e})},[e,s,n]),qs(()=>()=>a(e.value),[e.value,a]),null}
735),dx="navigationMenu.rootContentDismiss",zP=u.forwardRef((e,s)=>{const{__scopeNavigationMenu:r,value:n,triggerRef:a,focusProxyRef:i,wasEscapeCloseRef:o,onRootContentClose:l,onContentFocusOutside:c,...d}=e,m=pa(ou,r),h=u.useRef(null),f=at(h,s),p=HP(m.baseId,n),x=WP(m.baseId,n),g=$P(r),b=u.useRef(null),{onItemDismiss:w}=m;u.useEffect(()=>{const y=h.current;if(m.isRootMenu&&y){const v=()=>{var N;w(),l(),y.contains(document.activeElement)&&((N=a.current)==null||N.focus())};return y.addEventListener(dx,v),()=>y.removeEventListener(dx,v)}},[m.isRootMenu,e.value,a,w,l]);const j=u.useMemo(()=>{const v=g().map(A=>A.value);m.dir==="rtl"&&v.reverse();const N=v.indexOf(m.value),S=v.indexOf(m.previousValue),k=n===m.value,$=S===v.indexOf(n);if(!k&&!$)return b.current;const R=(()=>{if(N!==S){if(k&&S!==-1)return N>S?"from-end":"from-start";if($&&N!==-1)return N>S?"to-start":"to-end"}return null})();return b.current=R,R},[m.previousValue,m.value,m.dir,g,n]);return t.jsx(VP,{asChild:!0,children:t.jsx(xl,{id:x,"aria-labelledby":p,"data-motion":j,"data-orientation":m.orientation,...d,ref:f,disableOutsidePointerEvents:!1,onDismiss:()=>{var v;const y=new Event(dx,{bubbles:!0,cancelable:!0});(v=h.current)==null||v.dispatchEvent(y)},onFocusOutside:Se(e.onFocusOutside,y=>{var N;c();const v=y.target;(N=m.rootNavigationMenu)!=null&&N.contains(v)&&y.preventDefault()}),onPointerDownOutside:Se(e.onPointerDownOutside,y=>{var k;const v=y.target,N=g().some($=>{var R;return(R=$.ref.current)==null?void 0:R.contains(v)}),S=m.isRootMenu&&((k=m.viewport)==null?void 0:k.contains(v));(N||S||!m.isRootMenu)&&y.preventDefault()}),onKeyDown:Se(e.onKeyDown,y=>{var S;const v=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!v){const k=wj(y.currentTarget),$=document.activeElement,R=k.findIndex(P=>P===$),T=y.shiftKey?k.slice(0,R).reverse():k.slice(R+1,k.length);w2(T)?y.preventDefault():(S=i.current)==null||S.focus()}}),onEscapeKeyDown:Se(e.onEscapeKeyDown,y=>{o.current=!0})})})}),j2="NavigationMenuViewport",UP=u.forwardRef((e,s)=>{const{forceMount:r,...n}=e,i=!!pa(j2,e.__scopeNavigationMenu).value;return t.jsx(Ts,{present:r||i,children:t.jsx(ZW,{...n,ref:s})})});UP.displayName=j2;var ZW=u.forwardRef((e,s)=>{const{__scopeNavigationMenu:r,children:n,...a}=e,i=pa(j2,r),o=at(s,i.onViewportChange),l=WW(ou,e.__scopeNavigationMenu),[c,d]=u.useState(null),[m,h]=u.useState(null),f=c?(c==null?void 0:c.width)+"px":void 0,p=c?(c==null?void 0:c.height)+"px":void 0,x=!!i.value,g=x?i.value:i.previousValue;return Nj(m,()=>{m&&d({width:m.offsetWidth,height:m.offsetHeight})}),t.jsx(ze.div,{"data-state":N2(x),"data-orientation":i.orientation,...a,ref:o,style:{pointerEvents:!x&&i.isRootMenu?"none":void 0,"--radix-navigation-menu-viewport-width":f,"--radix-navigation-menu-viewport-height":p,...a.style},onPointerEnter:Se(e.onPointerEnter,i.onContentEnter),onPointerLeave:Se(e.onPointerLeave,cg(i.onContentLeave)),children:Array.from(l.items).map(([w,{ref:j,forceMount:y,...v}])=>{const N=g===w;return t.jsx(Ts,{present:y||N,children:t.jsx(zP,{...v,ref:yf(j,S=>{N&&S&&h(S)})})},w)})})}),JW="FocusGroup",VP=u.forwardRef((e,s)=>{const{__scopeNavigationMenu:r,...n}=e,a=pa(JW,r);return t.jsx(bj.Provider,{scope:r,children:t.jsx(bj.Slot,{scope:r,children:t.jsx(ze.div,{dir:a.dir,...n,ref:s})})})}),IS=["ArrowRight","ArrowLeft","ArrowUp","ArrowDown"],eG="FocusGroupItem",qP=u.forwardRef((e,s)=>{const{__scopeNavigationMenu:r,...n}=e,a=UW(r),i=pa(eG,r);return t.jsx(bj.ItemSlot,{scope:r,children:t.jsx(ze.button,{...n,ref:s,onKeyDown:Se(e.onKeyDown,o=>{if(["Home","End",...IS].includes(o.key)){let c=a().map(h=>h.ref.current);if([i.dir==="rtl"?"ArrowRight":"ArrowLeft","ArrowUp","End"].includes(o.key)&&c.reverse(),IS.includes(o.key)){const h=c.indexOf(o.currentTarget);c=c.slice(h+1)}setTimeout(()=>w2(c)),o.preventDefault()}})})})});function wj(e){const s=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}function w2(e){const s=document.activeElement;return e.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}function tG(e){return e.forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")}),()=>{e.forEach(s=>{const r=s.dataset.tabindex;s.setAttribute("tabindex",r)})}}
735function Nj(e,s){const r=Qt(s);qs(()=>{let n=0;if(e){const a=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return a.observe(e),()=>{window.cancelAnimationFrame(n),a.unobserve(e)}}},[e,r])}function N2(e){return e?"open":"closed"}function HP(e,s){return`${e}-trigger-${s}`}function WP(e,s){return`${e}-content-${s}`}function cg(e){return s=>s.pointerType==="mouse"?e(s):void 0}var GP=EP,YP=DP,sG=OP,KP=IP,rG=FP,QP=LP,XP=BP,ZP=UP;const JP=u.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(GP,{ref:n,className:oe("relative z-10 flex w-full items-center justify-center",e),...r,children:[s,t.jsx(r8,{})]}));JP.displayName=GP.displayName;const e8=u.forwardRef(({className:e,...s},r)=>t.jsx(YP,{ref:r,className:oe("group flex flex-1 list-none items-center justify-center space-x-1",e),...s}));e8.displayName=YP.displayName;const FS=sG,nG=fa("group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50"),t8=u.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(KP,{ref:n,className:oe(nG(),"group",e),...r,children:[s," ",t.jsx(Ma,{className:"relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180","aria-hidden":"true"})]}));t8.displayName=KP.displayName;const s8=u.forwardRef(({className:e,...s},r)=>t.jsx(XP,{ref:r,className:oe("left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ",e),...s}));s8.displayName=XP.displayName;const aG=rG,r8=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{className:oe("absolute left-1/2 -translate-x-1/2 top-full flex justify-center"),children:t.jsx(ZP,{className:oe("origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-[var(--radix-navigation-menu-viewport-width)] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90",e),ref:r,...s})}));r8.displayName=ZP.displayName;const iG=u.forwardRef(({className:e,...s},r)=>t.jsx(QP,{ref:r,className:oe("top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",e),...s,children:t.jsx("div",{className:"relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md"})}));iG.displayName=QP.displayName;function oG(e,s=[]){let r=[];function n(i,o){const l=u.createContext(o),c=r.length;r=[...r,o];function d(h){const{scope:f,children:p,...x}=h,g=(f==null?void 0:f[e][c])||l,b=u.useMemo(()=>x,Object.values(x));return t.jsx(g.Provider,{value:b,children:p})}function m(h,f){const p=(f==null?void 0:f[e][c])||l,x=u.useContext(p);if(x)return x;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return d.displayName=i+"Provider",[d,m]}const a=()=>{const i=r.map(o=>u.createContext(o));return function(l){const c=(l==null?void 0:l[e])||i;return u.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[n,lG(a,...s)]}function lG(...e){const s=e[0];if(e.length===1)return s;const r=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=n.reduce((l,{useScope:c,scopeName:d})=>{const h=c(i)[`__scope${d}`];return{...l,...h}},{});return u.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return r.scopeName=s.scopeName,r}var t0="rovingFocusGroup.onEntryFocus",cG={bubbles:!1,cancelable:!0},Av="RovingFocusGroup",[_j,n8,dG]=pl(Av),[uG,Iu]=oG(Av,[dG]),[mG,hG]=uG(Av),a8=u.forwardRef((e,s)=>t.jsx(_j.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(_j.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(fG,{...e,ref:s})})}));a8.displayName=Av;var fG=u.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:m=!1,...h}=e,f=u.useRef(null),p=at(s,f),x=to(i),[g=null,b]=wr({prop:o,defaultProp:l,onChange:c}),[w,j]=u.useState(!1),y=Qt(d),v=n8(r),N=u.useRef(!1),[S,k]=u.useState(0);return u.useEffect(()=>{const $=f.current;if($)return $.addEventListener(t0,y),()=>$.removeEventListener(t0,y)},[y]),t.jsx(mG,{scope:r,orientation:n,dir:x,loop:a,currentTabStopId:g,onItemFocus:u.useCallback($=>b($),[b]),onItemShiftTab:u.useCallback(()=>j(!0),[]),onFocusableItemAdd:u.useCallback(()=>k($=>$+1),[]),onFocusableItemRemove:u.useCallback(()=>k($=>$-1),[]),children:t.jsx(ze.div,{tabIndex:w||S===0?-1:0,"data-orientation":n,...h,ref:p,style:{outline:"none",...e.style},onMouseDown:Se(e.onMouseDown,()=>{N.current=!0}),onFocus:Se(e.onFocus,$=>{const R=!N.current;if($.target===$.currentTarget&&R&&!w){const A=new CustomEvent(t0,cG);if($.currentTarget.dispatchEvent(A),!A.defaultPrevented){const T=v().filter(C=>C.focusable),P=T.find(C=>C.active),B=T.find(C=>
vendor: 17,404 bytes, line 735
735C.id===g),I=[P,B,...T].filter(Boolean).map(C=>C.ref.current);l8(I,m)}}N.current=!1}),onBlur:Se(e.onBlur,()=>j(!1))})})}),i8="RovingFocusGroupItem",o8=u.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:i,...o}=e,l=Lr(),c=i||l,d=hG(i8,r),m=d.currentTabStopId===c,h=n8(r),{onFocusableItemAdd:f,onFocusableItemRemove:p}=d;return u.useEffect(()=>{if(n)return f(),()=>p()},[n,f,p]),t.jsx(_j.ItemSlot,{scope:r,id:c,focusable:n,active:a,children:t.jsx(ze.span,{tabIndex:m?0:-1,"data-orientation":d.orientation,...o,ref:s,onMouseDown:Se(e.onMouseDown,x=>{n?d.onItemFocus(c):x.preventDefault()}),onFocus:Se(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:Se(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const g=gG(x,d.orientation,d.dir);if(g!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let w=h().filter(j=>j.focusable).map(j=>j.ref.current);if(g==="last")w.reverse();else if(g==="prev"||g==="next"){g==="prev"&&w.reverse();const j=w.indexOf(x.currentTarget);w=d.loop?vG(w,j+1):w.slice(j+1)}setTimeout(()=>l8(w))}})})})});o8.displayName=i8;var pG={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function xG(e,s){return s!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function gG(e,s,r){const n=xG(e.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return pG[n]}function l8(e,s=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function vG(e,s){return e.map((r,n)=>e[(s+n)%e.length])}var _2=a8,S2=o8,Sj=["Enter"," "],yG=["ArrowDown","PageUp","Home"],c8=["ArrowUp","PageDown","End"],bG=[...yG,...c8],jG={ltr:[...Sj,"ArrowRight"],rtl:[...Sj,"ArrowLeft"]},wG={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ff="Menu",[$h,NG,_G]=pl(Ff),[Mc,d8]=hr(Ff,[_G,vl,Iu]),Tv=vl(),u8=Iu(),[SG,Oc]=Mc(Ff),[CG,Lf]=Mc(Ff),m8=e=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:i,modal:o=!0}=e,l=Tv(s),[c,d]=u.useState(null),m=u.useRef(!1),h=Qt(i),f=to(a);return u.useEffect(()=>{const p=()=>{m.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>m.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),t.jsx(ov,{...l,children:t.jsx(SG,{scope:s,open:r,onOpenChange:h,content:c,onContentChange:d,children:t.jsx(CG,{scope:s,onClose:u.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:f,modal:o,children:n})})})};m8.displayName=Ff;var kG="MenuAnchor",C2=u.forwardRef((e,s)=>{const{__scopeMenu:r,...n}=e,a=Tv(r);return t.jsx($f,{...a,...n,ref:s})});C2.displayName=kG;var k2="MenuPortal",[$G,h8]=Mc(k2,{forceMount:void 0}),f8=e=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=e,i=Oc(k2,s);return t.jsx($G,{scope:s,forceMount:r,children:t.jsx(Ts,{present:r||i.open,children:t.jsx(Nu,{asChild:!0,container:a,children:n})})})};f8.displayName=k2;var aa="MenuContent",[EG,$2]=Mc(aa),p8=u.forwardRef((e,s)=>{const r=h8(aa,e.__scopeMenu),{forceMount:n=r.forceMount,...a}=e,i=Oc(aa,e.__scopeMenu),o=Lf(aa,e.__scopeMenu);return t.jsx($h.Provider,{scope:e.__scopeMenu,children:t.jsx(Ts,{present:n||i.open,children:t.jsx($h.Slot,{scope:e.__scopeMenu,children:o.modal?t.jsx(PG,{...a,ref:s}):t.jsx(AG,{...a,ref:s})})})})}),PG=u.forwardRef((e,s)=>{const r=Oc(aa,e.__scopeMenu),n=u.useRef(null),a=at(s,n);return u.useEffect(()=>{const i=n.current;if(i)return Df(i)},[]),t.jsx(E2,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Se(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),AG=u.forwardRef((e,s)=>{const r=Oc(aa,e.__scopeMenu);return t.jsx(E2,{...e,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),E2=u.forwardRef((e,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:f,onDismiss:p,disableOutsideScroll:x,...g}=e,b=Oc(aa,r),w=Lf(aa,r),j=Tv(r),y=u8(r),v=NG(r),[N,S]=u.useState(null),k=u.useRef(null),$=at(s,k,b.onContentChange),R=u.useRef(0),A=u.useRef(""),T=u.useRef(0),P=u.useRef(null),B=u.useRef("right"),Y=u.useRef(0),I=x?Tf:u.Fragment,C=x?{as:tn,allowPinchZoom:!0}:void 0,L=_=>{var M,F;const H=A.current+_,O=v().filter(ee=>!ee.disabled),U=document.activeElement,G=(M=O.find(ee=>ee.ref.current===U))==null?void 0:M.textValue,E=O.map(ee=>ee.textValue),z=VG(E,H,G),Z=(F=O.find(ee=>ee.textValue===z))==null?void 0:F.ref.current;(function ee(se){A.current=se,window.clearTimeout(R.current),se!==""&&(R.current=window.setTimeout(()=>ee(""),1e3))})(H),Z&&setTimeout(()=>Z.focus())};u.useEffect(()=>()=>window.clearTimeout(R.current),[]),Sv();const D=u.useCallback(_=>{var O,U;return B.current===((O=P.current)==null?void 0:O.side)&&HG(_,(U=P.current)==null?void 0:U.area)},[]);return t.jsx(EG,{scope:r,searchRef:A,onItemEnter:u.useCallback(_=>{D(_)&&_.preventDefault()},[D]),onItemLeave:u.useCallback(_=>{var H;D(_)||((H=k.current)==null||H.focus(),S(null))},[D]),onTriggerLeave:u.useCallback(_=>{D(_)&&_.preventDefault()},[D]),pointerGraceTimerRef:T,onPointerGraceIntentChange:u.useCallback(_=>{P.current=_},[]),children:t.jsx(I,{...C,children:t.jsx(Af,{asChild:!0,trapped:a,onMountAutoFocus:Se(i,_=>{var H;_.preventDefault(),(H=k.current)==null||H.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:t.jsx(xl,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:f,onDismiss:p,children:t.jsx(_2,{asChild:!0,...y,dir:w.dir,orientation:"vertical",loop:n,currentTabStopId:N,onCurrentTabStopIdChange:S,onEntryFocus:Se(c,_=>{w.isUsingKeyboardRef.current||_.preventDefault()}),preventScrollOnEntryFocus:!0,children:t.jsx(lv,{role:"menu","aria-orientation":"vertical","data-state":A8(b.open),"data-radix-menu-content":"",dir:w.dir,...j,...g,ref:$,style:{outline:"none",...g.style},onKeyDown:Se(g.onKeyDown,_=>{const O=_.target.closest("[data-radix-menu-content]")===_.currentTarget,U=_.ctrlKey||_.altKey||_.metaKey,G=_.key.length===1;O&&(_.key==="Tab"&&_.preventDefault(),!U&&G&&L(_.key));const E=k.current;if(_.target!==E||!bG.includes(_.key))return;_.preventDefault();const Z=v().filter(M=>!M.disabled).map(M=>M.ref.current);c8.includes(_.key)&&Z.reverse(),zG(Z)}),onBlur:Se(e.onBlur,_=>{_.currentTarget.contains(_.target)||(window.clearTimeout(R.current),A.current="")}),onPointerMove:Se(e.onPointerMove,Eh(_=>{const H=_.target,O=Y.current!==_.clientX;if(_.currentTarget.contains(H)&&O){const U=_.clientX>Y.current?"right":"left";B.current=U,Y.current=_.clientX}}))})})})})})})});p8.displayName=aa;var TG="MenuGroup",P2=u.forwardRef((e,s)=>{const{__scopeMenu:r,...n}=e;return t.jsx(ze.div,{role:"group",...n,ref:s})});P2.displayName=TG;var DG="MenuLabel",x8=u.forwardRef((e,s)=>{const{__scopeMenu:r,...n}=e;return t.jsx(ze.div,{...n,ref:s})});x8.displayName=DG;var dg="MenuItem",LS="menu.itemSelect",Dv=u.forwardRef((e,s)=>{const{disabled:r=!1,onSelect:n,...a}=e,i=u.useRef(null),o=Lf(dg,e.__scopeMenu),l=$2(dg,e.__scopeMenu),c=at(s,i),d=u.useRef(!1),m=()=>{const h=i.current;if(!r&&h){const f=new CustomEvent(LS,{bubbles:!0,cancelable:!0});h.addEventListener(LS,p=>n==null?void 0:n(p),{once:!0}),vh(h,f),f.defaultPrevented?d.current=!1:o.onClose()}};return t.jsx(g8,{...a,ref:c,disabled:r,onClick:Se(e.onClick,m),onPointerDown:h=>{var f;(f=e.onPointerDown)==null||f.call(e,h),d.current=!0},onPointerUp:Se(e.onPointerUp,h=>{var f;d.current||(f=h.currentTarget)==null||f.click()}),onKeyDown:Se(e.onKeyDown,h=>{const f=l.searchRef.current!=="";r||f&&h.key===" "||Sj.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Dv.displayName=dg;var g8=u.forwardRef((e,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...i}=e,o=$2(dg,r),l=u8(r),c=u.useRef(null),d=at(s,c),[m,h]=u.useState(!1),[f,p]=u.useState("");return u.useEffect(()=>{const x=c.current;x&&p((x.textContent??"").trim())},[i.children]),t.jsx($h.ItemSlot,{scope:r,disabled:n,textValue:a??f,children:t.jsx(S2,{asChild:!0,...l,focusable:!n,children:t.jsx(ze.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...i,ref:d,onPointerMove:Se(e.onPointerMove,Eh(x=>{n?o.onItemLeave(x):(o.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Se(e.onPointerLeave,Eh(x=>o.onItemLeave(x))),onFocus:Se(e.onFocus,()=>h(!0)),onBlur:Se(e.onBlur,()=>h(!1))})})})}),RG="MenuCheckboxItem",v8=u.forwardRef((e,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=e;return t.jsx(N8,{scope:e.__scopeMenu,checked:r,children:t.jsx(Dv,{role:"menuitemcheckbox","aria-checked":ug(r)?"mixed":r,...a,ref:s,"data-state":T2(r),onSelect:Se(a.onSelect,()=>n==null?void 0:n(ug(r)?!0:!r),{checkForDefaultPrevented:!1})})})});v8.displayName=RG;var y8="MenuRadioGroup",[MG,OG]=Mc(y8,{value:void 0,onValueChange:()=>{}}),b8=u.forwardRef((e,s)=>{const{value:r,onValueChange:n,...a}=e,i=Qt(n);return t.jsx(MG,{scope:e.__scopeMenu,value:r,onValueChange:i,children:t.jsx(P2,{...a,ref:s})})});b8.displayName=y8;var j8="MenuRadioItem",w8=u.forwardRef((e,s)=>{const{value:r,...n}=e,a=OG(j8,e.__scopeMenu),i=r===a.value;return t.jsx(N8,{scope:e.__scopeMenu,checked:i,children:t.jsx(Dv,{role:"menuitemradio","aria-checked":i,...n,ref:s,"data-state":T2(i),onSelect:Se(n.onSelect,()=>{var o;return(o=a.onValueChange)==null?void 0:o.call(a,r)},{checkForDefaultPrevented:!1})})})});w8.displayName=j8;var A2="MenuItemIndicator",[N8,IG]=Mc(A2,{checked:!1}),_8=u.forwardRef((e,s)=>{const{__scopeMenu:r,forceMount:n,...a}=e,i=IG(A2,r);return t.jsx(Ts,{present:n||ug(i.checked)||i.checked===!0,children:t.jsx(ze.span,{...a,ref:s,"data-state":T2(i.checked)})})});_8.displayName=A2;var FG="MenuSeparator",S8=u.forwardRef((e,s)=>{const{__scopeMenu:r,...n}=e;return t.jsx(ze.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});S8.displayName=FG;var LG="MenuArrow",C8=u.forwardRef((e,s)=>{const{__scopeMenu:r,...n}=e,a=Tv(r);return t.jsx(cv,{...a,...n,ref:s})});C8.displayName=LG;var BG="MenuSub",[vfe,k8]=Mc(BG),Cm="MenuSubTrigger",$8=u.forwardRef((e,s)=>{const r=Oc(Cm,e.__scopeMenu),n=Lf(Cm,e.__scopeMenu),a=k8(Cm,e.__scopeMenu),i=$2(Cm,e.__scopeMenu),o=u.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=i,d={__scopeMenu:e.__scopeMenu},m=u.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return u.useEffect(()=>m,[m]),u.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),c(null)}},[l,c]),t.jsx(C2,{asChild:!0,...d,children:t.jsx(g8,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":A8(r.open),...e,ref:yf(s,a.onTriggerChange),onClick:h=>{var f;(f=e.onClick)==null||f.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Se(e.onPointerMove,Eh(h=>{i.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!r.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{r.onOpenChange(!0),m()},100))})),onPointerLeave:Se(e.onPointerLeave,Eh(h=>{var p,x;m();const f=(p=r.content)==null?void 0:p.getBoundingClientRect();if(f){const g=(x=r.content)==null?void 0:x.dataset.side,b=g==="right",w=b?-5:5,j=f[b?"left":"right"],y=f[b?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+w,y:h.clientY},{x:j,y:f.top},{x:y,y:f.top},{x:y,y:f.bottom},{x:j,y:f.bottom}],side:g}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Se(e.onKeyDown,h=>{var p;const f=i.searchRef.current!=="";e.disabled||f&&h.key===" "||jG[n.dir].includes(h.key)&&(r.onOpenChange(!0),(p=r.content)==null||p.focus(),h.preventDefault())})})})});$8.displayName=Cm;var E8="MenuSubContent",P8=u.forwardRef((e,s)=>{const r=h8(aa,e.__scopeMenu),{forceMount:n=r.forceMount,...a}=e,i=Oc(aa,e.__scopeMenu),o=Lf(aa,e.__scopeMenu),l=k8(E8,e.__scopeMenu),c=u.useRef(null),d=at(s,c);return t.jsx($h.Provider,{scope:e.__scopeMenu,children:t.jsx(Ts,{present:n||i.open,children:t.jsx($h.Slot,{scope:e.__scopeMenu,children:t.jsx(E2,{id:l.contentId,"aria-labelledby":l.triggerId,...a,ref:d,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{var h;o.isUsingKeyboardRef.current&&((h=c.current)==null||h.focus()),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Se(e.onFocusOutside,m=>{m.target!==l.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Se(e.onEscapeKeyDown,m=>{o.onClose(),m.preventDefault()}),onKeyDown:Se(e.onKeyDown,m=>{var p;const h=m.currentTarget.contains(m.target),f=wG[o.dir].includes(m.key);h&&f&&(i.onOpenChange(!1),(p=l.trigger)==null||p.focus(),m.preventDefault())})})})})})});P8.displayName=E8;function A8(e){return e?"open":"closed"}function ug(e){return e==="indeterminate"}function T2(e){return ug(e)?"indeterminate":e?"checked":"unchecked"}function zG(e){const s=document.activeElement;for(const r of e)if(r===s||(r.focus(),document.activeElement!==s))return}function UG(e,s){return e.map((r,n)=>e[(s+n)%e.length])}function VG(e,s,r){const a=s.length>1&&Array.from(s).every(d=>d===s[0])?s[0]:s,i=r?e.indexOf(r):-1;let o=UG(e,Math.max(i,0));a.length===1&&(o=o.filter(d=>d!==r));const c=o.find(d=>d.toLowerCase().startsWith(a.toLowerCase()));return c!==r?c:void 0}function qG(e,s){const{x:r,y:n}=e;let a=!1;for(let i=0,o=s.length-1;i<s.length;o=i++){const l=s[i].x,c=s[i].y,d=s[o].x,m=s[o].y;c>n!=m>n&&r<(d-l)*(n-c)/(m-c)+l&&(a=!a)}return a}function HG(e,s){if(!s)return!1;const r={x:e.clientX,y:e.clientY};return qG(r,s)}function Eh(e){return s=>s.pointerType==="mouse"?e(s):void 0}var WG=m8,GG=C2,YG=f8,KG=p8,QG=P2,XG=x8,ZG=Dv,JG=v8,eY=b8,tY=w8,sY=_8,rY=S8,nY=C8,aY=$8,iY=P8,D2="DropdownMenu",[oY,yfe]=hr(D2,[d8]),on=d8(),[lY,T8]=oY(D2),D8=e=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:i,onOpenChange:o,modal:l=!0}=e,c=on(s),d=u.useRef(null),[m=!1,h]=wr({prop:a,defaultProp:i,onChange:o});return t.jsx(lY,{scope:s,triggerId:Lr(),triggerRef:d,contentId:Lr(),open:m,onOpenChange:h,onOpenToggle:u.useCallback(()=>h(f=>!f),[h]),modal:l,children:t.jsx(WG,{...c,open:m,onOpenChange:h,dir:n,modal:l,children:r})})};D8.displayName=D2;var R8="DropdownMenuTrigger",M8=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=e,i=T8(R8,r),o=on(r);return t.jsx(GG,{asChild:!0,...o,children:t.jsx(ze.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...a,ref:yf(s,i.triggerRef),onPointerDown:Se(e.onPointerDown,l=>{!n&&l.button===0&&l.ctrlKey===!1&&(i.onOpenToggle(),i.open||l.preventDefault())}),onKeyDown:Se(e.onKeyDown,l=>{n||(["Enter"," "].includes(l.key)&&i.onOpenToggle(),l.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});M8.displayName=R8;var cY="DropdownMenuPortal",O8=e=>{const{__scopeDropdownMenu:s,...r}=e,n=on(s);return t.jsx(YG,{...n,...r})};O8.displayName=cY;var I8="DropdownMenuContent",F8=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=T8(I8,r),i=on(r),o=u.useRef(!1);return t.jsx(KG,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...n,ref:s,onCloseAutoFocus:Se(e.onCloseAutoFocus,l=>{var c;o.current||(c=a.triggerRef.current)==null||c.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:Se(e.onInteractOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,m=c.button===2||d;(!a.modal||m)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});F8.displayName=I8;var dY="DropdownMenuGroup",uY=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=on(r);return t.jsx(QG,{...a,...n,ref:s})});uY.displayName=dY;var mY="DropdownMenuLabel",L8=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=on(r);return t.jsx(XG,{...a,...n,ref:s})});L8.displayName=mY;var hY="DropdownMenuItem",B8=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=on(r);return t.jsx(ZG,{...a,...n,ref:s})});B8.displayName=hY;var fY="DropdownMenuCheckboxItem",z8=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=on(r);return t.jsx(JG,{...a,...n,ref:s})});z8.displayName=fY;var pY="DropdownMenuRadioGroup",xY=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=on(r);return t.jsx(eY,{...a,...n,ref:s})});
735xY.displayName=pY;var gY="DropdownMenuRadioItem",U8=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=on(r);return t.jsx(tY,{...a,...n,ref:s})});U8.displayName=gY;var vY="DropdownMenuItemIndicator",V8=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=on(r);return t.jsx(sY,{...a,...n,ref:s})});V8.displayName=vY;var yY="DropdownMenuSeparator",q8=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=on(r);return t.jsx(rY,{...a,...n,ref:s})});q8.displayName=yY;var bY="DropdownMenuArrow",jY=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=on(r);return t.jsx(nY,{...a,...n,ref:s})});jY.displayName=bY;var wY="DropdownMenuSubTrigger",H8=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=on(r);return t.jsx(aY,{...a,...n,ref:s})});H8.displayName=wY;var NY="DropdownMenuSubContent",W8=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=on(r);return t.jsx(iY,{...a,...n,ref:s,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});W8.displayName=NY;var _Y=D8,SY=M8,CY=O8,G8=F8,Y8=L8,K8=B8,Q8=z8,X8=U8,Z8=V8,J8=q8,eA=H8,tA=W8;const sA=_Y,rA=SY,kY=u.forwardRef(({className:e,inset:s,children:r,...n},a)=>t.jsxs(eA,{ref:a,className:oe("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",s&&"pl-8",e),...n,children:[r,t.jsx(Ac,{className:"ml-auto h-4 w-4"})]}));kY.displayName=eA.displayName;const $Y=u.forwardRef(({className:e,...s},r)=>t.jsx(tA,{ref:r,className:oe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s}));$Y.displayName=tA.displayName;const R2=u.forwardRef(({className:e,sideOffset:s=4,...r},n)=>t.jsx(CY,{children:t.jsx(G8,{ref:n,sideOffset:s,className:oe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));R2.displayName=G8.displayName;const zl=u.forwardRef(({className:e,inset:s,...r},n)=>t.jsx(K8,{ref:n,className:oe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s&&"pl-8",e),...r}));zl.displayName=K8.displayName;const EY=u.forwardRef(({className:e,children:s,checked:r,...n},a)=>t.jsxs(Q8,{ref:a,className:oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:r,...n,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Z8,{children:t.jsx(Bs,{className:"h-4 w-4"})})}),s]}));EY.displayName=Q8.displayName;const PY=u.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(X8,{ref:n,className:oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Z8,{children:t.jsx(nE,{className:"h-2 w-2 fill-current"})})}),s]}));PY.displayName=X8.displayName;const nA=u.forwardRef(({className:e,inset:s,...r},n)=>t.jsx(Y8,{ref:n,className:oe("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",e),...r}));nA.displayName=Y8.displayName;const Cj=u.forwardRef(({className:e,...s},r)=>t.jsx(J8,{ref:r,className:oe("-mx-1 my-1 h-px bg-muted",e),...s}));Cj.displayName=J8.displayName;const M2=()=>{const{isAdmin:e}=Ar();return e},gs=()=>{var b,w;const[e,s]=u.useState(!1),r=ds(),{user:n,isAdmin:a,signOut:i}=Ar(),o=M2(),l=async()=>{s(!1),await i()},c=(j,y)=>{y&&s(!1),j.includes("#")||j.includes("?")?window.location.href=j:r(j)},d=[{name:"Latest Community News",href:"/#news",description:"Stay updated with the latest local stories and updates",icon:Dc}
735,{name:"Featured Advertisers",href:"/#advertisers",description:"Discover local businesses and services in your area",icon:mr},{name:"Newsletter Signup",href:"/#newsletter",description:"Subscribe to receive regular community updates",icon:ar}],m=[{name:"Current Competitions",href:"/competitions",description:"Enter exciting competitions with amazing prizes",icon:hi},{name:"Competition Rules",href:"/competitions#rules",description:"Read terms and conditions for all competitions",icon:tr}],h=[{name:"Application Form",href:"/apply-to-distribute",description:"Apply to become a distribution partner in your area",icon:B4},{name:"Distribution Areas",href:"/apply-to-distribute#areas",description:"View available distribution territories",icon:_t},{name:"Requirements",href:"/apply-to-distribute#requirements",description:"Learn about distributor requirements and benefits",icon:tr}],f=[{name:"Browse Businesses",href:"/business-directory",description:"Find local businesses and services by category",icon:qx},{name:"Add Your Business",href:"/business-directory#add",description:"List your business in our community directory",icon:B4},{name:"Featured Listings",href:"/business-directory#featured",description:"Premium business listings with enhanced visibility",icon:mr}],p=[{name:"Find Events",href:"/whats-on",description:"Browse upcoming events in your area",icon:It},{name:"Add Events",href:"/whats-on?tab=add",description:"Submit your event to be featured",icon:It}],x=[{name:"Advertising Overview",href:"/advertising#top",description:"Learn about our reach, story, and magazine editions",icon:Xo},{name:"Rate Card Calculator",href:"/advertising#rate-card-calculator",description:"Get a quick pricing estimate in seconds",icon:sc},{name:"Online Quote & Booking Tool",href:"/advertising#calculator",description:"Full quote builder with all package options",icon:yr},{name:"Advertising Enquiry Form",href:"/advertising#enquiry-form",description:"Get in touch for a personalised quote",icon:zr}],g=[{title:"Home",items:d,path:"/"},...o?[{title:"Events",items:p,path:"/whats-on"}]:[],{title:"Competitions",items:m,path:"/competitions"},{title:"Directory",items:f,path:"/business-directory"},{title:"Advertising",items:x,path:"/advertising"},{title:"Distribute",items:h,path:"/apply-to-distribute"}];return t.jsx("nav",{className:"sticky top-0 z-50 bg-white shadow-md",children:t.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex justify-between items-center h-16",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx(hs,{to:"/",children:t.jsx("img",{src:"/lovable-uploads/discover-logo-2.png",alt:"Discover Magazines Logo",className:"h-16 w-auto py-2"})})}),t.jsxs("div",{className:"hidden md:flex items-center space-x-4",children:[t.jsx(JP,{children:t.jsxs(e8,{className:"space-x-2",children:[g.map(j=>t.jsxs(FS,{children:[t.jsx(t8,{className:"text-gray-700 hover:text-community-green px-3 py-2 rounded-md text-sm font-medium transition-colors duration-200 bg-transparent hover:bg-transparent data-[state=open]:bg-transparent",onClick:()=>r(j.path),children:j.title}),t.jsx(s8,{children:t.jsx("div",{className:"w-[860px] xl:w-[960px] bg-white border border-border shadow-lg rounded-lg p-6",children:t.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[t.jsxs("div",{className:"col-span-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-foreground mb-4",children:j.title}),t.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2",children:j.items.map(y=>{const v=y.icon;return t.jsx(aG,{asChild:!0,children:t.jsxs("div",{onClick:()=>c(y.href),className:"group flex items-start space-x-3 p-3 rounded-lg hover:bg-accent transition-colors cursor-pointer",children:[t.jsx("div",{className:"flex-shrink-0 w-6 h-6 text-muted-foreground group-hover:text-community-green transition-colors",children:t.jsx(v,{size:20})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-foreground group-hover:text-community-green transition-colors",children:y.name}),t.jsx("p",{className:"text-sm text-muted-foreground leading-tight mt-1",children:y.description})]})]})},y.name)})})]}),t.jsx("div",{className:"col-span-1 bg-muted/30 p-5 rounded-lg",children:t.jsx("div",{className:"space-y-4",children:j.title==="Advertising"?t.jsx(BW,{}):j.title==="Events"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Upcoming Events"}),t.jsxs("div",{className:"bg-white rounded-lg p-4 shadow-sm border",children:[t.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"What's happening?"}),t.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Discover local events and activities happening in your community."}),t.jsx(hs,{to:"/whats-on",className:"inline-flex items-center text-sm font-medium text-community-green hover:text-green-600 transition-colors",children:"Browse events â"})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Latest News"}),t.jsxs("div",{className:"bg-white rounded-lg p-4 shadow-sm border",children:[t.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Community Update!"}),t.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Stay updated with the latest community stories and local events in South Hampshire."}),t.jsx(hs,{to:"/stories",className:"inline-flex items-center text-sm font-medium text-community-green hover:text-green-600 transition-colors",children:"Read more â"})]})]})})})]})})})]},j.title)),t.jsx(FS,{children:t.jsx(hs,{to:"/contact",className:"text-gray-700 hover:text-community-green px-3 py-2 rounded-md text-sm font-medium transition-colors duration-200",children:"Contact"})})]})}),n&&t.jsxs(sA,{children:[t.jsx(rA,{asChild:!0,children:t.jsxs(q,{variant:"ghost",size:"sm",className:"text-gray-700 hover:text-community-green ml-4",children:[t.jsx(bn,{size:16,className:"mr-1"}),(b=n.email)==null?void 0:b.split("@")[0],t.jsx(Ma,{size:14,className:"ml-1"})]})}),t.jsxs(R2,{className:"w-48",align:"end",children:[t.jsx(zl,{asChild:!0,children:t.jsxs(hs,{to:"/dashboard",className:"flex items-center w-full",children:[t.jsx(bn,{size:16,className:"mr-2"}),"Dashboard"]})}),t.jsxs(zl,{onClick:l,className:"flex items-center w-full",children:[t.jsx(Qb,{size:16,className:"mr-2"}),"Sign Out"]})]})]}),n&&a&&t.jsx(hs,{to:"/admin",className:"ml-4",children:t.jsxs(q,{variant:"ghost",size:"sm",className:"text-purple-700 hover:text-purple-800",children:[t.jsx(Oa,{size:16,className:"mr-1"}),"Admin"]})}),!n&&t.jsx(hs,{to:"/auth",className:"ml-4",children:t.jsx(q,{size:"sm",className:"bg-community-green hover:bg-green-600 text-white",children:"Customer Login"})})]}),t.jsx("div",{className:"md:hidden",children:t.jsxs(i2,{open:e,onOpenChange:s,children:[t.jsx(gW,{asChild:!0,children:t.jsx(q,{variant:"ghost",size:"icon",className:"text-gray-700 hover:text-community-green",children:t.jsx(rL,{size:24})})}),t.jsxs($v,{side:"right",className:"w-full sm:w-80 bg-background",children:[t.jsx(o2,{children:t.jsx(l2,{className:"text-left text-lg font-semibold text-foreground",children:"Menu"})}),t.jsxs("div",{className:"mt-6 space-y-6",children:[t.jsx(Ru,{type:"single",collapsible:!0,className:"w-full",children:g.map(j=>t.jsxs(ti,{value:j.title,className:"border-b border-border",children:[t.jsx(si,{className:"text-left hover:text-community-green hover:no-underline py-4",children:t.jsx("div",{className:"flex items-center justify-between w-full",children:t.jsx("span",{className:"text-base font-medium text-foreground",children:j.title})})}),t.jsx(ri,{className:"pb-4",children:t.jsx("div",{className:"space-y-2",children:j.items.map(y=>{const v=y.icon;return t.jsxs("div",{onClick:()=>c(y.href,!0),className:"flex items-center space-x-3 p-3 rounded-lg hover:bg-accent transition-colors group cursor-pointer",children:[t.jsx("div",{className:"flex-shrink-0 w-5 h-5 text-muted-foreground group-hover:text-community-green transition-colors",children:t.jsx(v,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-foreground group-hover:text-community-green transition-colors",children:y.name}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1 leading-tight",children:y.description})]})]},y.name)})})})]},j.title))}),t.jsxs(hs,{to:"/contact",onClick:()=>s(!1),className:"flex items-center space-x-3 px-3 py-4 border-b border-border hover:bg-accent transition-colors group",children:[t.jsx(zr,{size:18,className:"text-muted-foreground group-hover:text-community-green"}),t.jsx("span",{className:"text-base font-medium text-foreground group-hover:text-community-green",children:"Contact"})]}),t.jsx("div",{className:"border-t border-border pt-6 space-y-3",children:n?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center space-x-2 px-3 py-2 text-sm text-muted-foreground",children:[t.jsx(bn,{size:16}),t.jsxs("span",{children:["Signed in as ",(w=n.email)==null?void 0:w.split("@")[0]]})]}),t.jsxs(hs,{to:"/dashboard",className:"flex items-center space-x-3 px-3 py-3 rounded-lg hover:bg-accent transition-colors text-foreground hover:text-community-green",onClick:()=>s(!1),children:[t.jsx(bn,{size:18}),t.jsx("span",{className:"font-medium",children:"Dashboard"})]}),a&&t.jsxs(hs,{to:"/admin",className:"flex items-center space-x-3 px-3 py-3 rounded-lg hover:bg-accent transition-colors text-purple-700 hover:text-purple-800",onClick:()=>s(!1),children:[t.jsx(Oa,{size:18}),t.jsx("span",{className:"font-medium",children:"Admin Dashboard"})]}),t.jsxs("button",{onClick:l,className:"flex items-center space-x-3 px-3 py-3 rounded-lg hover:bg-accent transition-colors text-foreground hover:text-community-green w-full text-left",children:[t.jsx(Qb,{size:18}),t.jsx("span",{className:"font-medium",children:"Sign Out"})]})]}):t.jsx(hs,{to:"/auth",className:"block w-full",onClick:()=>s(!1),children:t.jsx(q,{className:"w-full bg-community-green hover:bg-green-600 text-white py-3",children:"Customer Login"})})})]})]})]})})]})})})},xe=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...s}));
735xe.displayName="Card";const Me=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:oe("flex flex-col space-y-1.5 p-6",e),...s}));Me.displayName="CardHeader";const Oe=u.forwardRef(({className:e,...s},r)=>t.jsx("h3",{ref:r,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...s}));Oe.displayName="CardTitle";const Er=u.forwardRef(({className:e,...s},r)=>t.jsx("p",{ref:r,className:oe("text-sm text-muted-foreground",e),...s}));Er.displayName="CardDescription";const ge=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:oe("p-6 pt-0",e),...s}));ge.displayName="CardContent";const AY=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:oe("flex items-center p-6 pt-0",e),...s}));AY.displayName="CardFooter";function ot(e){const s=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&s==="[object Date]"?new e.constructor(+e):typeof e=="number"||s==="[object Number]"||typeof e=="string"||s==="[object String]"?new Date(e):new Date(NaN)}function ps(e,s){return e instanceof Date?new e.constructor(s):new Date(s)}function Sr(e,s){const r=ot(e);return isNaN(s)?ps(e,NaN):(s&&r.setDate(r.getDate()+s),r)}function Cr(e,s){const r=ot(e);if(isNaN(s))return ps(e,NaN);if(!s)return r;const n=r.getDate(),a=ps(e,r.getTime());a.setMonth(r.getMonth()+s+1,0);const i=a.getDate();return n>=i?a:(r.setFullYear(a.getFullYear(),a.getMonth(),n),r)}const O2=6048e5,TY=864e5,DY=6e4,RY=36e5,MY=1e3,Mp=43200,BS=1440;let OY={};function bl(){return OY}function $n(e,s){var l,c,d,m;const r=bl(),n=(s==null?void 0:s.weekStartsOn)??((c=(l=s==null?void 0:s.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((m=(d=r.locale)==null?void 0:d.options)==null?void 0:m.weekStartsOn)??0,a=ot(e),i=a.getDay(),o=(i<n?7:0)+i-n;return a.setDate(a.getDate()-o),a.setHours(0,0,0,0),a}function Ki(e){return $n(e,{weekStartsOn:1})}function aA(e){const s=ot(e),r=s.getFullYear(),n=ps(e,0);n.setFullYear(r+1,0,4),n.setHours(0,0,0,0);const a=Ki(n),i=ps(e,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const o=Ki(i);return s.getTime()>=a.getTime()?r+1:s.getTime()>=o.getTime()?r:r-1}function lu(e){const s=ot(e);return s.setHours(0,0,0,0),s}function ol(e){const s=ot(e),r=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()));return r.setUTCFullYear(s.getFullYear()),+e-+r}function ni(e,s){const r=lu(e),n=lu(s),a=+r-ol(r),i=+n-ol(n);return Math.round((a-i)/TY)}function IY(e){const s=aA(e),r=ps(e,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),Ki(r)}function kj(e,s){const r=s*7;return Sr(e,r)}function FY(e,s){return Cr(e,s*12)}function LY(e){let s;return e.forEach(function(r){const n=ot(r);(s===void 0||s<n||isNaN(Number(n)))&&(s=n)}),s||new Date(NaN)}function BY(e){let s;return e.forEach(r=>{const n=ot(r);(!s||s>n||isNaN(+n))&&(s=n)}),s||new Date(NaN)}function ux(e,s){const r=ot(e),n=ot(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function zY(e){return ps(e,Date.now())}function jn(e,s){const r=lu(e),n=lu(s);return+r==+n}function I2(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function UY(e){if(!I2(e)&&typeof e!="number")return!1;const s=ot(e);return!isNaN(Number(s))}function cu(e,s){const r=ot(e),n=ot(s),a=r.getFullYear()-n.getFullYear(),i=r.getMonth()-n.getMonth();return a*12+i}function VY(e,s,r){const n=$n(e,r),a=$n(s,r),i=+n-ol(n),o=+a-ol(a);return Math.round((i-o)/O2)}function qY(e){return s=>{const n=(e?Math[e]:Math.trunc)(s);return n===0?0:n}}function HY(e,s){return+ot(e)-+ot(s)}function WY(e){const s=ot(e);return s.setHours(23,59,59,999),s}function du(e){const s=ot(e),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function GY(e){const s=ot(e);return+WY(s)==+du(s)}function YY(e,s){const r=ot(e),n=ot(s),a=ux(r,n),i=Math.abs(cu(r,n));let o;if(i<1)o=0;else{r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-a*i);let l=ux(r,n)===-a;GY(ot(e))&&i===1&&ux(e,n)===1&&(l=!1),o=a*(i-Number(l))}return o===0?0:o}function KY(e,s,r){const n=HY(e,s)/1e3;return qY(r==null?void 0:r.roundingMethod)(n)}function jr(e){const s=ot(e);return s.setDate(1),s.setHours(0,0,0,0),s}function iA(e){const s=ot(e),r=ps(e,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Rv(e,s){var l,c,d,m;const r=bl(),n=(s==null?void 0:s.weekStartsOn)??((c=(l=s==null?void 0:s.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((m=(d=r.locale)==null?void 0:d.options)==null?void 0:m.weekStartsOn)??0,a=ot(e),i=a.getDay(),o=(i<n?-7:0)+6-(i-n);return a.setDate(a.getDate()+o),a.setHours(23,59,59,999),a}function oA(e){return Rv(e,{weekStartsOn:1}
vendor: 8,274 bytes, line 735
735)}const QY={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},XY=(e,s,r)=>{let n;const a=QY[e];return typeof a=="string"?n=a:s===1?n=a.one:n=a.other.replace("{{count}}",s.toString()),r!=null&&r.addSuffix?r.comparison&&r.comparison>0?"in "+n:n+" ago":n};function s0(e){return(s={})=>{const r=s.width?String(s.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}const ZY={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},JY={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},eK={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},tK={date:s0({formats:ZY,defaultWidth:"full"}),time:s0({formats:JY,defaultWidth:"full"}),dateTime:s0({formats:eK,defaultWidth:"full"})},sK={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},rK=(e,s,r,n)=>sK[e];function dm(e){return(s,r)=>{const n=r!=null&&r.context?String(r.context):"standalone";let a;if(n==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,l=r!=null&&r.width?String(r.width):o;a=e.formattingValues[l]||e.formattingValues[o]}else{const o=e.defaultWidth,l=r!=null&&r.width?String(r.width):e.defaultWidth;a=e.values[l]||e.values[o]}const i=e.argumentCallback?e.argumentCallback(s):s;return a[i]}}const nK={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},aK={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},iK={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"]},oK={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"]},lK={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"}},cK={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"}},dK=(e,s)=>{const r=Number(e),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},uK={ordinalNumber:dK,era:dm({values:nK,defaultWidth:"wide"}),quarter:dm({values:aK,defaultWidth:"wide",argumentCallback:e=>e-1}),month:dm({values:iK,defaultWidth:"wide"}),day:dm({values:oK,defaultWidth:"wide"}),dayPeriod:dm({values:lK,defaultWidth:"wide",formattingValues:cK,defaultFormattingWidth:"wide"})};function um(e){return(s,r={})=>{const n=r.width,a=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],i=s.match(a);if(!i)return null;const o=i[0],l=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(l)?hK(l,h=>h.test(o)):mK(l,h=>h.test(o));let d;d=e.valueCallback?e.valueCallback(c):c,d=r.valueCallback?r.valueCallback(d):d;const m=s.slice(o.length);return{value:d,rest:m}}}function mK(e,s){for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&s(e[r]))return r}function hK(e,s){for(let r=0;r<e.length;r++)if(s(e[r]))return r}function fK(e){return(s,r={})=>{const n=s.match(e.matchPattern);if(!n)return null;const a=n[0],i=s.match(e.parsePattern);if(!i)return null;let o=e.valueCallback?e.valueCallback(i[0]):i[0];o=r.valueCallback?r.valueCallback(o):o;const l=s.slice(a.length);return{value:o,rest:l}}}const pK=/^(\d+)(th|st|nd|rd)?/i,xK=/\d+/i,gK={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},vK={any:[/^b/i,/^(a|c)/i]},yK={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},bK={any:[/1/i,/2/i,/3/i,/4/i]},jK={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},wK={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]},NK={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},_K={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]},SK={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},CK={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}},kK={ordinalNumber:fK({matchPattern:pK,parsePattern:xK,valueCallback:e=>parseInt(e,10)}),era:um({matchPatterns:gK,defaultMatchWidth:"wide",parsePatterns:vK,defaultParseWidth:"any"}),quarter:um({matchPatterns:yK,defaultMatchWidth:"wide",parsePatterns:bK,defaultParseWidth:"any",valueCallback:e=>e+1}),month:um({matchPatterns:jK,defaultMatchWidth:"wide",parsePatterns:wK,defaultParseWidth:"any"}),day:um({matchPatterns:NK,defaultMatchWidth:"wide",parsePatterns:_K,defaultParseWidth:"any"}),dayPeriod:um({matchPatterns:SK,defaultMatchWidth:"any",parsePatterns:CK,defaultParseWidth:"any"})},Mv={code:"en-US",formatDistance:XY,formatLong:tK,formatRelative:rK,localize:uK,match:kK,options:{weekStartsOn:0,firstWeekContainsDate:1}};function $K(e){const s=ot(e);return ni(s,iA(s))+1}function F2(e){const s=ot(e),r=+Ki(s)-+IY(s);return Math.round(r/O2)+1}function L2(e,s){var m,h,f,p;const r=ot(e),n=r.getFullYear(),a=bl(),i=(s==null?void 0:s.firstWeekContainsDate)??((h=(m=s==null?void 0:s.locale)==null?void 0:m.options)==null?void 0:h.firstWeekContainsDate)??a.firstWeekContainsDate??((p=(f=a.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??1,o=ps(e,0);o.setFullYear(n+1,0,i),o.setHours(0,0,0,0);const l=$n(o,s),c=ps(e,0);c.setFullYear(n,0,i),c.setHours(0,0,0,0);const d=$n(c,s);return r.getTime()>=l.getTime()?n+1:r.getTime()>=d.getTime()?n:n-1}function EK(e,s){var l,c,d,m;const r=bl(),n=(s==null?void 0:s.firstWeekContainsDate)??((c=(l=s==null?void 0:s.locale)==null?void 0:l.options)==null?void 0:c.firstWeekContainsDate)??r.firstWeekContainsDate??((m=(d=r.locale)==null?void 0:d.options)==null?void 0:m.firstWeekContainsDate)??1,a=L2(e,s),i=ps(e,0);return i.setFullYear(a,0,n),i.setHours(0,0,0,0),$n(i,s)}function B2(e,s){const r=ot(e),n=+$n(r,s)-+EK(r,s);return Math.round(n/O2)+1}function is(e,s){const r=e<0?"-":"",n=Math.abs(e).toString().padStart(s,"0");return r+n}
vendor: 5,448 bytes, line 735
735const co={y(e,s){const r=e.getFullYear(),n=r>0?r:1-r;return is(s==="yy"?n%100:n,s.length)},M(e,s){const r=e.getMonth();return s==="M"?String(r+1):is(r+1,2)},d(e,s){return is(e.getDate(),s.length)},a(e,s){const r=e.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(e,s){return is(e.getHours()%12||12,s.length)},H(e,s){return is(e.getHours(),s.length)},m(e,s){return is(e.getMinutes(),s.length)},s(e,s){return is(e.getSeconds(),s.length)},S(e,s){const r=s.length,n=e.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return is(a,s.length)}},Wc={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},zS={G:function(e,s,r){const n=e.getFullYear()>0?1:0;switch(s){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(e,s,r){if(s==="yo"){const n=e.getFullYear(),a=n>0?n:1-n;return r.ordinalNumber(a,{unit:"year"})}return co.y(e,s)},Y:function(e,s,r,n){const a=L2(e,n),i=a>0?a:1-a;if(s==="YY"){const o=i%100;return is(o,2)}return s==="Yo"?r.ordinalNumber(i,{unit:"year"}):is(i,s.length)},R:function(e,s){const r=aA(e);return is(r,s.length)},u:function(e,s){const r=e.getFullYear();return is(r,s.length)},Q:function(e,s,r){const n=Math.ceil((e.getMonth()+1)/3);switch(s){case"Q":return String(n);case"QQ":return is(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,s,r){const n=Math.ceil((e.getMonth()+1)/3);switch(s){case"q":return String(n);case"qq":return is(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,s,r){const n=e.getMonth();switch(s){case"M":case"MM":return co.M(e,s);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(e,s,r){const n=e.getMonth();switch(s){case"L":return String(n+1);case"LL":return is(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(e,s,r,n){const a=B2(e,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):is(a,s.length)},I:function(e,s,r){const n=F2(e);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):is(n,s.length)},d:function(e,s,r){return s==="do"?r.ordinalNumber(e.getDate(),{unit:"date"}):co.d(e,s)},D:function(e,s,r){const n=$K(e);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):is(n,s.length)},E:function(e,s,r){const n=e.getDay();switch(s){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(e,s,r,n){const a=e.getDay(),i=(a-n.weekStartsOn+8)%7||7;switch(s){case"e":return String(i);case"ee":return is(i,2);case"eo":return r.ordinalNumber(i,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});case"eeee":default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(e,s,r,n){const a=e.getDay(),i=(a-n.weekStartsOn+8)%7||7;switch(s){case"c":return String(i);case"cc":return is(i,s.length);case"co":return r.ordinalNumber(i,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});case"cccc":default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(e,s,r){const n=e.getDay(),a=n===0?7:n;switch(s){case"i":return String(a);case"ii":return is(a,s.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(e,s,r){const a=e.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,s,r){const n=e.getHours();let a;switch(n===12?a=Wc.noon:n===0?a=Wc.midnight:a=n/12>
vendor: 4,371 bytes, line 735
735=1?"pm":"am",s){case"b":case"bb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,s,r){const n=e.getHours();let a;switch(n>=17?a=Wc.evening:n>=12?a=Wc.afternoon:n>=4?a=Wc.morning:a=Wc.night,s){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,s,r){if(s==="ho"){let n=e.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return co.h(e,s)},H:function(e,s,r){return s==="Ho"?r.ordinalNumber(e.getHours(),{unit:"hour"}):co.H(e,s)},K:function(e,s,r){const n=e.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):is(n,s.length)},k:function(e,s,r){let n=e.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):is(n,s.length)},m:function(e,s,r){return s==="mo"?r.ordinalNumber(e.getMinutes(),{unit:"minute"}):co.m(e,s)},s:function(e,s,r){return s==="so"?r.ordinalNumber(e.getSeconds(),{unit:"second"}):co.s(e,s)},S:function(e,s){return co.S(e,s)},X:function(e,s,r){const n=e.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return VS(n);case"XXXX":case"XX":return Pl(n);case"XXXXX":case"XXX":default:return Pl(n,":")}},x:function(e,s,r){const n=e.getTimezoneOffset();switch(s){case"x":return VS(n);case"xxxx":case"xx":return Pl(n);case"xxxxx":case"xxx":default:return Pl(n,":")}},O:function(e,s,r){const n=e.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+US(n,":");case"OOOO":default:return"GMT"+Pl(n,":")}},z:function(e,s,r){const n=e.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+US(n,":");case"zzzz":default:return"GMT"+Pl(n,":")}},t:function(e,s,r){const n=Math.trunc(e.getTime()/1e3);return is(n,s.length)},T:function(e,s,r){const n=e.getTime();return is(n,s.length)}};function US(e,s=""){const r=e>0?"-":"+",n=Math.abs(e),a=Math.trunc(n/60),i=n%60;return i===0?r+String(a):r+String(a)+s+is(i,2)}function VS(e,s){return e%60===0?(e>0?"-":"+")+is(Math.abs(e)/60,2):Pl(e,s)}function Pl(e,s=""){const r=e>0?"-":"+",n=Math.abs(e),a=is(Math.trunc(n/60),2),i=is(n%60,2);return r+a+s+i}const qS=(e,s)=>{switch(e){case"P":return s.date({width:"short"});case"PP":return s.date({width:"medium"});case"PPP":return s.date({width:"long"});case"PPPP":default:return s.date({width:"full"})}},lA=(e,s)=>{switch(e){case"p":return s.time({width:"short"});case"pp":return s.time({width:"medium"});case"ppp":return s.time({width:"long"});case"pppp":default:return s.time({width:"full"})}},PK=(e,s)=>{const r=e.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return qS(e,s);let i;switch(n){case"P":i=s.dateTime({width:"short"});break;case"PP":i=s.dateTime({width:"medium"});break;case"PPP":i=s.dateTime({width:"long"});break;case"PPPP":default:i=s.dateTime({width:"full"});break}return i.replace("{{date}}",qS(n,s)).replace("{{time}}",lA(a,s))},$j={p:lA,P:PK},AK=/^D+$/,TK=/^Y+$/,DK=["D","DD","YY","YYYY"];function cA(e){return AK.test(e)}function dA(e){return TK.test(e)}function Ej(e,s,r){const n=RK(e,s,r);if(console.warn(n),DK.includes(e))throw new RangeError(n)}function RK(e,s,r){const n=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${s}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const MK=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,OK=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,IK=/^'([^]*?)'?$/,FK=/''/g,LK=/[a-zA-Z]/;function Dt(e,s,r){var m,h,f,p,x,g,b,w;const n=bl(),a=(r==null?void 0:r.locale)??n.locale??Mv,i=(r==null?void 0:r.firstWeekContainsDate)??((h=(m=r==null?void 0:r.locale)==null?void 0:m.options)==null?void 0:h.firstWeekContainsDate)??n.firstWeekContainsDate??((p=(f=n.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??1,o=(r==null?void 0:r.weekStartsOn)??((g=(x=r==null?void 0:r.locale)==null?void 0:x.options)==null?void 0:g.weekStartsOn)??n.weekStartsOn??((w=(b=n.locale)==null?void 0:b.options)==null?void 0:w.weekStartsOn)??0,l=ot(e);
735if(!UY(l))throw new RangeError("Invalid time value");let c=s.match(OK).map(j=>{const y=j[0];if(y==="p"||y==="P"){const v=$j[y];return v(j,a.formatLong)}return j}).join("").match(MK).map(j=>{if(j==="''")return{isToken:!1,value:"'"};const y=j[0];if(y==="'")return{isToken:!1,value:BK(j)};if(zS[y])return{isToken:!0,value:j};if(y.match(LK))throw new RangeError("Format string contains an unescaped latin alphabet character `"+y+"`");return{isToken:!1,value:j}});a.localize.preprocessor&&(c=a.localize.preprocessor(l,c));const d={firstWeekContainsDate:i,weekStartsOn:o,locale:a};return c.map(j=>{if(!j.isToken)return j.value;const y=j.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&dA(y)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&cA(y))&&Ej(y,s,String(e));const v=zS[y[0]];return v(l,y,a.localize,d)}).join("")}function BK(e){const s=e.match(IK);return s?s[1].replace(FK,"'"):e}function zK(e,s,r){const n=bl(),a=(r==null?void 0:r.locale)??n.locale??Mv,i=2520,o=ux(e,s);if(isNaN(o))throw new RangeError("Invalid time value");const l=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:o});let c,d;o>0?(c=ot(s),d=ot(e)):(c=ot(e),d=ot(s));const m=KY(d,c),h=(ol(d)-ol(c))/1e3,f=Math.round((m-h)/60);let p;if(f<2)return r!=null&&r.includeSeconds?m<5?a.formatDistance("lessThanXSeconds",5,l):m<10?a.formatDistance("lessThanXSeconds",10,l):m<20?a.formatDistance("lessThanXSeconds",20,l):m<40?a.formatDistance("halfAMinute",0,l):m<60?a.formatDistance("lessThanXMinutes",1,l):a.formatDistance("xMinutes",1,l):f===0?a.formatDistance("lessThanXMinutes",1,l):a.formatDistance("xMinutes",f,l);if(f<45)return a.formatDistance("xMinutes",f,l);if(f<90)return a.formatDistance("aboutXHours",1,l);if(f<BS){const x=Math.round(f/60);return a.formatDistance("aboutXHours",x,l)}else{if(f<i)return a.formatDistance("xDays",1,l);if(f<Mp){const x=Math.round(f/BS);return a.formatDistance("xDays",x,l)}else if(f<Mp*2)return p=Math.round(f/Mp),a.formatDistance("aboutXMonths",p,l)}if(p=YY(d,c),p<12){const x=Math.round(f/Mp);return a.formatDistance("xMonths",x,l)}else{const x=p%12,g=Math.trunc(p/12);return x<3?a.formatDistance("aboutXYears",g,l):x<9?a.formatDistance("overXYears",g,l):a.formatDistance("almostXYears",g+1,l)}}function UK(e,s){return zK(e,zY(e),s)}function VK(e){const s=ot(e),r=s.getFullYear(),n=s.getMonth(),a=ps(e,0);return a.setFullYear(r,n+1,0),a.setHours(0,0,0,0),a.getDate()}function qK(){return Object.assign({},bl())}function HK(e){let r=ot(e).getDay();return r===0&&(r=7),r}function WK(e){return Math.trunc(+ot(e)/1e3)}function GK(e){const s=ot(e),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(0,0,0,0),s}function YK(e,s){return VY(GK(e),jr(e),s)+1}function Pj(e,s){const r=ot(e),n=ot(s);return r.getTime()>n.getTime()}function uA(e,s){const r=ot(e),n=ot(s);return+r<+n}function KK(e,s){const r=s instanceof Date?ps(s,0):new s(0);return r.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),r.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),r}const QK=10;class mA{constructor(){Ze(this,"subPriority",0)}validate(s,r){return!0}}class XK extends mA{constructor(s,r,n,a,i){super(),this.value=s,this.validateValue=r,this.setValue=n,this.priority=a,i&&(this.subPriority=i)}validate(s,r){return this.validateValue(s,this.value,r)}set(s,r,n){return this.setValue(s,r,this.value,n)}}class ZK extends mA{constructor(){super(...arguments);Ze(this,"priority",QK);Ze(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:ps(r,KK(r,Date))}}class Zt{run(s,r,n,a){const i=this.parse(s,r,n,a);return i?{setter:new XK(i.value,this.validate,this.set,this.priority,this.subPriority),rest:i.rest}:null}validate(s,r,n){return!0}}class JK extends Zt{constructor(){super(...arguments);Ze(this,"priority",140);Ze(this,"incompatibleTokens",["R","u","t","T"])}parse(r,n,a){switch(n){case"G":case"GG":case"GGG":return a.era(r,{width:"abbreviated"})||a.era(r,{width:"narrow"});case"GGGGG":return a.era(r,{width:"narrow"});case"GGGG":default:return a.era(r,{width:"wide"})||a.era(r,{width:"abbreviated"})||a.era(r,{width:"narrow"})}}set(r,n,a){return n.era=a,r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}const Js={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}/}
vendor: 19,125 bytes, line 735
735,Za={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 er(e,s){return e&&{value:s(e.value),rest:e.rest}}function Fs(e,s){const r=s.match(e);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function Ja(e,s){const r=s.match(e);if(!r)return null;if(r[0]==="Z")return{value:0,rest:s.slice(1)};const n=r[1]==="+"?1:-1,a=r[2]?parseInt(r[2],10):0,i=r[3]?parseInt(r[3],10):0,o=r[5]?parseInt(r[5],10):0;return{value:n*(a*RY+i*DY+o*MY),rest:s.slice(r[0].length)}}function hA(e){return Fs(Js.anyDigitsSigned,e)}function Qs(e,s){switch(e){case 1:return Fs(Js.singleDigit,s);case 2:return Fs(Js.twoDigits,s);case 3:return Fs(Js.threeDigits,s);case 4:return Fs(Js.fourDigits,s);default:return Fs(new RegExp("^\\d{1,"+e+"}"),s)}}function mg(e,s){switch(e){case 1:return Fs(Js.singleDigitSigned,s);case 2:return Fs(Js.twoDigitsSigned,s);case 3:return Fs(Js.threeDigitsSigned,s);case 4:return Fs(Js.fourDigitsSigned,s);default:return Fs(new RegExp("^-?\\d{1,"+e+"}"),s)}}function z2(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 fA(e,s){const r=s>0,n=r?s:1-s;let a;if(n<=50)a=e||100;else{const i=n+50,o=Math.trunc(i/100)*100,l=e>=i%100;a=e+o-(l?100:0)}return r?a:1-a}function pA(e){return e%400===0||e%4===0&&e%100!==0}class eQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",130);Ze(this,"incompatibleTokens",["Y","R","u","w","I","i","e","c","t","T"])}parse(r,n,a){const i=o=>({year:o,isTwoDigitYear:n==="yy"});switch(n){case"y":return er(Qs(4,r),i);case"yo":return er(a.ordinalNumber(r,{unit:"year"}),i);default:return er(Qs(n.length,r),i)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a){const i=r.getFullYear();if(a.isTwoDigitYear){const l=fA(a.year,i);return r.setFullYear(l,0,1),r.setHours(0,0,0,0),r}const o=!("era"in n)||n.era===1?a.year:1-a.year;return r.setFullYear(o,0,1),r.setHours(0,0,0,0),r}}class tQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",130);Ze(this,"incompatibleTokens",["y","R","u","Q","q","M","L","I","d","D","i","t","T"])}parse(r,n,a){const i=o=>({year:o,isTwoDigitYear:n==="YY"});switch(n){case"Y":return er(Qs(4,r),i);case"Yo":return er(a.ordinalNumber(r,{unit:"year"}),i);default:return er(Qs(n.length,r),i)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,i){const o=L2(r,i);if(a.isTwoDigitYear){const c=fA(a.year,o);return r.setFullYear(c,0,i.firstWeekContainsDate),r.setHours(0,0,0,0),$n(r,i)}const l=!("era"in n)||n.era===1?a.year:1-a.year;return r.setFullYear(l,0,i.firstWeekContainsDate),r.setHours(0,0,0,0),$n(r,i)}}class sQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",130);Ze(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return mg(n==="R"?4:n.length,r)}set(r,n,a){const i=ps(r,0);return i.setFullYear(a,0,4),i.setHours(0,0,0,0),Ki(i)}}class rQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",130);Ze(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return mg(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class nQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",120);Ze(this,"incompatibleTokens",["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"Q":case"QQ":return Qs(n.length,r);case"Qo":return a.ordinalNumber(r,{unit:"quarter"});case"QQQ":return a.quarter(r,{width:"abbreviated",context:"formatting"})||a.quarter(r,{width:"narrow",context:"formatting"});case"QQQQQ":return a.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return a.quarter(r,{width:"wide",context:"formatting"})||a.quarter(r,{width:"abbreviated",context:"formatting"})||a.quarter(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=1&&n<=4}set(r,n,a){return r.setMonth((a-1)*3,1),r.setHours(0,0,0,0),r}}class aQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",120);Ze(this,"incompatibleTokens",["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"q":case"qq":return Qs(n.length,r);case"qo":return a.ordinalNumber(r,{unit:"quarter"});case"qqq":return a.quarter(r,{width:"abbreviated",context:"standalone"})||a.quarter(r,{width:"narrow",context:"standalone"});case"qqqqq":return a.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return a.quarter(r,{width:"wide",context:"standalone"})||a.quarter(r,{width:"abbreviated",context:"standalone"})||a.quarter(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=1&&n<=4}set(r,n,a){return r.setMonth((a-1)*3,1),r.setHours(0,0,0,0),r}}class iQ extends Zt{constructor(){super(...arguments);Ze(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);Ze(this,"priority",110)}parse(r,n,a){const i=o=>o-1;switch(n){case"M":return er(Fs(Js.month,r),i);case"MM":return er(Qs(2,r),i);case"Mo":return er(a.ordinalNumber(r,{unit:"month"}),i);case"MMM":return a.month(r,{width:"abbreviated",context:"formatting"})||a.month(r,{width:"narrow",context:"formatting"});case"MMMMM":return a.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return a.month(r,{width:"wide",context:"formatting"})||a.month(r,{width:"abbreviated",context:"formatting"})||a.month(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.setMonth(a,1),r.setHours(0,0,0,0),r}}class oQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",110);Ze(this,"incompatibleTokens",["Y","R","q","Q","M","w","I","D","i","e","c","t","T"])}parse(r,n,a){const i=o=>o-1;switch(n){case"L":return er(Fs(Js.month,r),i);case"LL":return er(Qs(2,r),i);case"Lo":return er(a.ordinalNumber(r,{unit:"month"}),i);case"LLL":return a.month(r,{width:"abbreviated",context:"standalone"})||a.month(r,{width:"narrow",context:"standalone"});case"LLLLL":return a.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return a.month(r,{width:"wide",context:"standalone"})||a.month(r,{width:"abbreviated",context:"standalone"})||a.month(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.setMonth(a,1),r.setHours(0,0,0,0),r}}function lQ(e,s,r){const n=ot(e),a=B2(n,r)-s;return n.setDate(n.getDate()-a*7),n}class cQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",100);Ze(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,a){switch(n){case"w":return Fs(Js.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return Qs(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,i){return $n(lQ(r,a,i),i)}}function dQ(e,s){const r=ot(e),n=F2(r)-s;return r.setDate(r.getDate()-n*7),r}class uQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",100);Ze(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"])}parse(r,n,a){switch(n){case"I":return Fs(Js.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return Qs(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return Ki(dQ(r,a))}}const mQ=[31,28,31,30,31,30,31,31,30,31,30,31],hQ=[31,29,31,30,31,30,31,31,30,31,30,31];class fQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",90);Ze(this,"subPriority",1);Ze(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"d":return Fs(Js.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return Qs(n.length,r)}}validate(r,n){const a=r.getFullYear(),i=pA(a),o=r.getMonth();return i?n>=1&&n<=hQ[o]:n>=1&&n<=mQ[o]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class pQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",90);Ze(this,"subpriority",1);Ze(this,"incompatibleTokens",["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"])}parse(r,n,a){switch(n){case"D":case"DD":return Fs(Js.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return Qs(n.length,r)}}validate(r,n){const a=r.getFullYear();return pA(a)?n>=1&&n<=366:n>=1&&n<=365}set(r,n,a){return r.setMonth(0,a),r.setHours(0,0,0,0),r}}function U2(e,s,r){var h,f,p,x;const n=bl(),a=(r==null?void 0:r.weekStartsOn)??((f=(h=r==null?void 0:r.locale)==null?void 0:h.options)==null?void 0:f.weekStartsOn)??n.weekStartsOn??((x=(p=n.locale)==null?void 0:p.options)==null?void 0:x.weekStartsOn)??0,i=ot(e),o=i.getDay(),c=(s%7+7)%7,d=7-a,m=s<0||s>6?s-(o+d)%7:(c+d)%7-(o+d)%7;return Sr(i,m)}class xQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",90);Ze(this,"incompatibleTokens",["D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"E":case"EE":case"EEE":return a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"EEEEE":return a.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"EEEE":default:return a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,i){return r=U2(r,a,i),r.setHours(0,0,0,0),r}}class gQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",90);Ze(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"])}parse(r,n,a,i){const o=l=>{const c=Math.floor((l-1)/7)*7;return(l+i.weekStartsOn+6)%7+c};switch(n){case"e":case"ee":return er(Qs(n.length,r),o);case"eo":return er(a.ordinalNumber(r,{unit:"day"}),o);case"eee":return a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"eeeee":return a.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"eeee":default:return a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,i){return r=U2(r,a,i),r.setHours(0,0,0,0),r}}class vQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",90);Ze(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"])}parse(r,n,a,i){const o=l=>{const c=Math.floor((l-1)/7)*7;return(l+i.weekStartsOn+6)%7+c};switch(n){case"c":case"cc":return er(Qs(n.length,r),o);case"co":return er(a.ordinalNumber(r,{unit:"day"}),o);case"ccc":return a.day(r,{width:"abbreviated",context:"standalone"})||a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"});case"ccccc":return a.day(r,{width:"narrow",context:"standalone"});case"cccccc":return a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"});case"cccc":default:return a.day(r,{width:"wide",context:"standalone"})||a.day(r,{width:"abbreviated",context:"standalone"})||a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,i){return r=U2(r,a,i),r.setHours(0,0,0,0),r}}function yQ(e,s){const r=ot(e),n=HK(r),a=s-n;return Sr(r,a)}class bQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",90);Ze(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"])}parse(r,n,a){const i=o=>o===0?7:o;switch(n){case"i":case"ii":return Qs(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return er(a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),i);case"iiiii":return er(a.day(r,{width:"narrow",context:"formatting"}),i);case"iiiiii":return er(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),i);case"iiii":default:return er(a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),i)}}validate(r,n){return n>=1&&n<=7}set(r,n,a){return r=yQ(r,a),r.setHours(0,0,0,0),r}}class jQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",80);Ze(this,"incompatibleTokens",["b","B","H","k","t","T"])}parse(r,n,a){switch(n){case"a":case"aa":case"aaa":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaaa":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaa":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(z2(a),0,0,0),r}}class wQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",80);Ze(this,"incompatibleTokens",["a","B","H","k","t","T"])}parse(r,n,a){switch(n){case"b":case"bb":case"bbb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbbb":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbb":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(z2(a),0,0,0),r}}class NQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",80);Ze(this,"incompatibleTokens",["a","b","t","T"])}parse(r,n,a){switch(n){case"B":case"BB":case"BBB":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBBB":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBB":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(z2(a),0,0,0),r}}class _Q extends Zt{constructor(){super(...arguments);Ze(this,"priority",70);Ze(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return Fs(Js.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return Qs(n.length,r)}}validate(r,n){return n>=1&&n<=12}set(r,n,a){const i=r.getHours()>=12;return i&&a<12?r.setHours(a+12,0,0,0):!i&&a===12?r.setHours(0,0,0,0):r.setHours(a,0,0,0),r}}class SQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",70);Ze(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,a){switch(n){case"H":return Fs(Js.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return Qs(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class CQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",70);Ze(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return Fs(Js.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return Qs(n.length,r)}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.getHours()>=12&&a<12?r.setHours(a+12,0,0,0):r.setHours(a,0,0,0),r}}class kQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",70);Ze(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,a){switch(n){case"k":return Fs(Js.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return Qs(n.length,r)}}validate(r,n){return n>=1&&n<=24}set(r,n,a){const i=a<=24?a%24:a;return r.setHours(i,0,0,0),r}}class $Q extends Zt{constructor(){super(...arguments);Ze(this,"priority",60);Ze(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return Fs(Js.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return Qs(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class EQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",50);Ze(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return Fs(Js.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return Qs(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class PQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",30);Ze(this,"incompatibleTokens",["t","T"])}parse(r,n){const a=i=>Math.trunc(i*Math.pow(10,-n.length+3));return er(Qs(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class AQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",10);Ze(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return Ja(Za.basicOptionalMinutes,r);case"XX":return Ja(Za.basic,r);case"XXXX":return Ja(Za.basicOptionalSeconds,r);case"XXXXX":return Ja(Za.extendedOptionalSeconds,r);case"XXX":default:return Ja(Za.extended,r)}}set(r,n,a){return n.timestampIsSet?r:ps(r,r.getTime()-ol(r)-a)}}class TQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",10);Ze(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return Ja(Za.basicOptionalMinutes,r);case"xx":return Ja(Za.basic,r);case"xxxx":return Ja(Za.basicOptionalSeconds,r);case"xxxxx":return Ja(Za.extendedOptionalSeconds,r);case"xxx":default:return Ja(Za.extended,r)}}set(r,n,a){return n.timestampIsSet?r:ps(r,r.getTime()-ol(r)-a)}}class DQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",40);Ze(this,"incompatibleTokens","*")}parse(r){return hA(r)}set(r,n,a){return[ps(r,a*1e3),{timestampIsSet:!0}]}}class RQ extends Zt{constructor(){super(...arguments);Ze(this,"priority",20);Ze(this,"incompatibleTokens","*")}parse(r){return hA(r)}set(r,n,a){return[ps(r,a),{timestampIsSet:!0}]}}const MQ={G:new JK,y:new eQ,Y:new tQ,R:new sQ,u:new rQ,Q:new nQ,q:new aQ,M:new iQ,L:new oQ,w:new cQ,I:new uQ,d:new fQ,D:new pQ,E:new xQ,e:new gQ,c:new vQ,i:new bQ,a:new jQ,b:new wQ,B:new NQ,h:new _Q,H:new SQ,K:new CQ,k:new kQ,m:new $Q,s:new EQ,S:new PQ,X:new AQ,x:new TQ,t:new DQ,T:new RQ},OQ=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,IQ=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,FQ=/^'([^]*?)'?$/,LQ=/''/g,BQ=/\S/,zQ=/[a-zA-Z]/;function V2(e,s,r,n){var g,b,w,j;const a=qK(),i=a.locale??Mv,o=a.firstWeekContainsDate??((b=(g=a.locale)==null?void 0:g.options)==null?void 0:b.firstWeekContainsDate)??1,l=a.weekStartsOn??((j=(w=a.locale)==null?void 0:w.options)==null?void 0:j.weekStartsOn)??0,c={firstWeekContainsDate:o,weekStartsOn:l,locale:i},d=[new ZK],m=s.match(IQ).map(y=>{const v=y[0];if(v in $j){const N=$j[v];return N(y,i.formatLong)}return y}).join("").match(OQ),h=[];for(let y of m){dA(y)&&Ej(y,s,e),cA(y)&&Ej(y,s,e);const v=y[0],N=MQ[v];if(N){const{incompatibleTokens:S}=N;if(Array.isArray(S)){const $=h.find(R=>S.includes(R.token)||R.token===v);
735if($)throw new RangeError(`The format string mustn't contain \`${$.fullToken}\` and \`${y}\` at the same time`)}else if(N.incompatibleTokens==="*"&&h.length>0)throw new RangeError(`The format string mustn't contain \`${y}\` and any other token at the same time`);h.push({token:v,fullToken:y});const k=N.run(e,y,i.match,c);if(!k)return ps(r,NaN);d.push(k.setter),e=k.rest}else{if(v.match(zQ))throw new RangeError("Format string contains an unescaped latin alphabet character `"+v+"`");if(y==="''"?y="'":v==="'"&&(y=UQ(y)),e.indexOf(y)===0)e=e.slice(y.length);else return ps(r,NaN)}}if(e.length>0&&BQ.test(e))return ps(r,NaN);const f=d.map(y=>y.priority).sort((y,v)=>v-y).filter((y,v,N)=>N.indexOf(y)===v).map(y=>d.filter(v=>v.priority===y).sort((v,N)=>N.subPriority-v.subPriority)).map(y=>y[0]);let p=ot(r);if(isNaN(p.getTime()))return ps(r,NaN);const x={};for(const y of f){if(!y.validate(p,c))return ps(r,NaN);const v=y.set(p,x,c);Array.isArray(v)?(p=v[0],Object.assign(x,v[1])):p=v}return ps(r,p)}function UQ(e){return e.match(FQ)[1].replace(LQ,"'")}function Aj(e){return+ot(e)<Date.now()}function Ph(e,s){const r=ot(e),n=ot(s);return r.getFullYear()===n.getFullYear()&&r.getMonth()===n.getMonth()}function VQ(e,s){const r=ot(e),n=ot(s);return r.getFullYear()===n.getFullYear()}function r0(e,s){const r=+ot(e),[n,a]=[+ot(s.start),+ot(s.end)].sort((i,o)=>i-o);return r>=n&&r<=a}function n0(e,s){return Sr(e,-s)}function a0(e,s){const r=ot(e),n=r.getFullYear(),a=r.getDate(),i=ps(e,0);i.setFullYear(n,s,15),i.setHours(0,0,0,0);const o=VK(i);return r.setMonth(s,Math.min(a,o)),r}function HS(e,s){const r=ot(e);return isNaN(+r)?ps(e,NaN):(r.setFullYear(s),r)}const xA=["January","February","March","April","May","June","July","August","September","October","November","December"];function Fu(){const e=new Intl.DateTimeFormat("en-GB",{timeZone:"Europe/London",year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date),s=r=>{var n;return parseInt(((n=e.find(a=>a.type===r))==null?void 0:n.value)||"0",10)};return new Date(s("year"),s("month")-1,s("day"))}function Jo(e,s){if(!e||typeof e!="string")return null;const r=e.trim();if(!r||r.toLowerCase()==="tbc")return null;const n=r.split(".");if(n.length===3){const i=parseInt(n[0],10),o=parseInt(n[1],10),l=parseInt(n[2],10);if(!isNaN(i)&&!isNaN(o)&&!isNaN(l))return new Date(l,o-1,i)}if(n.length===2&&s!==void 0){const i=parseInt(n[0],10),o=parseInt(n[1],10),l=typeof s=="string"?parseInt(s,10):s;if(!isNaN(i)&&!isNaN(o)&&!isNaN(l))return new Date(l,o-1,i)}const a=r.match(/^(\d{4})-(\d{2})-(\d{2})$/);return a?new Date(parseInt(a[1],10),parseInt(a[2],10)-1,parseInt(a[3],10)):null}function q2(e){const s=/^(\d{4})-(\d{2})$/.exec(e||"");if(!s)return e;const r=parseInt(s[2],10)-1;return`${xA[r]||e} ${s[1]}`}function qQ(e,s){const r=Jo(e,s);return r?r.toLocaleDateString("en-GB",{day:"numeric",month:"short"}):(e||"").trim()}function WS(e,s){const r=Jo(e,s);return r?r.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"}):(e||"").trim()}function mx(e){if(!e)return null;const s=e.month;if(typeof s!="string"||!s.trim())return null;const r=s.trim().match(/^(\d{4})-(\d{1,2})$/);if(r)return`${r[1]}-${String(parseInt(r[2],10)).padStart(2,"0")}`;const n=xA.findIndex(i=>i.toLowerCase()===s.trim().toLowerCase());if(n===-1)return null;const a=typeof e.year=="string"?parseInt(e.year,10):e.year;return!a||isNaN(a)?null:`${a}-${String(n+1).padStart(2,"0")}`}function gA(e){const s=mx(e);if(!s)return null;const[r,n]=s.split("-"),a=parseInt(r,10),i=parseInt(n,10)-1,o=(e.copyDeadline||"").trim(),l=(e.printDeadline||"").trim(),c=(e.deliveryDate||"").trim();return{key:s,year:a,monthIndex:i,label:q2(s),copyDeadline:Jo(o,a),printDeadline:Jo(l,a),deliveryDate:Jo(c,a),copyDeadlineText:o,printDeadlineText:l,deliveryDateText:c,raw:e}}function HQ(e){const s=Array.isArray(e==null?void 0:e.schedule)?e.schedule:[],r=new Map;return s.forEach(n=>{const a=gA(n);a&&!r.has(a.key)&&r.set(a.key,a)}),Array.from(r.values()).sort((n,a)=>n.key.localeCompare(a.key))}function vA(e,s=Fu()){return HQ(e).filter(r=>yA(r,s))}function yA(e,s=Fu()){const r=e.copyDeadline||e.printDeadline;if(r)return r.getTime()>s.getTime();const n=new Date(e.year,e.monthIndex,1),a=new Date(s.getFullYear(),s.getMonth(),1);return n.getTime()>=a.getTime()}function i0(e,s=Fu()){const r=gA(e);return r?yA(r,s):!1}const WQ="Laterâplease call 023 8026 6388";function GQ(e,s=6,r=Fu()){if(!e||e.length===0)return[];const n=e.length,a=new Map;e.forEach(l=>{vA(l,r).forEach(c=>{a.has(c.key)||a.set(c.key,new Set),a.get(c.key).add(l.id)})});const o=Array.from(a.keys()).sort().slice(0,s).map(l=>{const c=a.get(l);return{value:l,label:q2(l),month:l,eligibleAreaIds:Array.from(c),ineligibleAreaIds:e.map(d=>d.id).filter(d=>!c.has(d)),totalAreas:n}});return o.push({value:"later",label:WQ,month:"later",eligibleAreaIds:[],ineligibleAreaIds:[],totalAreas:n}),o}function GS(e,s,r,n=Fu()){const a=vA(e,n),o=(s&&/^\d{4}-\d{2}$/.test(s)?a.filter(l=>l.key>=s):a).slice(0,Math.max(0,r));return{issues:o,shortfall:Math.max(0,r-o.length)}}function YQ(){return Lt({queryKey:["next_deadline"],queryFn:async()=>{const{data:e,error:s}=await W.from("pricing_areas").select("name, schedule").eq("is_active",!0);if(s)throw console.error("[useNextDeadline] Error fetching areas:",s),s;if(!e||e.length===0)return console.log("[useNextDeadline] No pricing areas foun
735d"),null;const r=Fu();let n=null;for(const a of e){const i=a.schedule;if(!(!i||!Array.isArray(i)))for(const o of i){const l=o.copyDeadline||o.printDeadline;if(!l||typeof l!="string")continue;const c=Jo(l,o.year);c&&c>=r&&(!n||c<n.date)&&(n={date:c,areaName:a.name})}}return n?(console.log("[useNextDeadline] Found:",n.areaName,n.date.toISOString()),{date:n.date,formatted:Dt(n.date,"do MMMM yyyy"),areaName:n.areaName}):(console.log("[useNextDeadline] No future deadline found"),null)},staleTime:5*60*1e3})}const KQ=()=>{const e=ds(),{data:s,isLoading:r}=YQ(),n=M2(),a=s!=null&&s.formatted?`Copy deadline: ${s.formatted}`:r?"Loading...":"Check schedule for deadlines",i=[{icon:ws,title:"Next Issue Deadline",description:a,color:"text-red-600 bg-red-50",priority:!0,link:"/advertising"},{icon:It,title:"Events",description:"Local happenings and community gatherings",color:"text-blue-600 bg-blue-50",priority:!1,link:"/whats-on"},{icon:hi,title:"Competitions",description:"Enter contests and win amazing prizes",color:"text-yellow-600 bg-yellow-50",priority:!1,link:"/competitions"},{icon:Xr,title:"Trusted Businesses",description:"Find reliable local services and shops",color:"text-community-green bg-green-50",priority:!1,link:"/business-directory"},{icon:ir,title:"Local Stories",description:"Inspiring tales from your community",color:"text-purple-600 bg-purple-50",priority:!1,link:"/stories"}],l=(n?i:i.filter(c=>c.link!=="/whats-on")).filter(c=>c.link!=="/competitions");return t.jsx("section",{className:"py-8 md:py-16 bg-background",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"md:hidden",children:[t.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4 snap-x snap-mandatory scrollbar-hide -mx-4 px-4",children:l.map((c,d)=>{const m=c.icon;return t.jsx(xe,{onClick:()=>e(c.link),className:`flex-shrink-0 w-[280px] snap-center group hover:shadow-lg transition-shadow duration-300 cursor-pointer ${c.priority?"ring-2 ring-red-500 ring-offset-2":""}`,children:t.jsxs(ge,{className:"p-5 flex items-center gap-4",children:[t.jsx("div",{className:`w-14 h-14 flex-shrink-0 rounded-full flex items-center justify-center ${c.color}`,children:t.jsx(m,{size:28})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-base font-heading font-semibold text-community-navy mb-1",children:c.title}),t.jsx("p",{className:"text-sm text-muted-foreground font-body line-clamp-2",children:c.description})]})]})},d)})}),t.jsx("div",{className:"flex justify-center gap-1.5 mt-2",children:l.map((c,d)=>t.jsx("div",{className:"w-2 h-2 rounded-full bg-muted-foreground/30"},d))})]}),t.jsx("div",{className:"hidden md:flex flex-wrap justify-center gap-6",children:l.map((c,d)=>{const m=c.icon;return t.jsx(xe,{onClick:()=>e(c.link),className:`group hover:shadow-lg transition-shadow duration-300 cursor-pointer w-[280px] ${c.priority?"ring-2 ring-red-500 ring-offset-2":""}`,children:t.jsxs(ge,{className:"p-6 text-center",children:[t.jsx("div",{className:`w-16 h-16 mx-auto mb-4 rounded-full flex items-center justify-center ${c.color}`,children:t.jsx(m,{size:32})}),t.jsx("h3",{className:"text-xl font-heading font-semibold text-community-navy mb-2",children:c.title}),t.jsx("p",{className:"text-muted-foreground font-body",children:c.description})]})},d)})})]})})};function QQ(e){return Object.prototype.toString.call(e)==="[object Object]"}function YS(e){return QQ(e)||Array.isArray(e)}function XQ(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function H2(e,s){const r=Object.keys(e),n=Object.keys(s);if(r.length!==n.length)return!1;const a=JSON.stringify(Object.keys(e.breakpoints||{})),i=JSON.stringify(Object.keys(s.breakpoints||{}));return a!==i?!1:r.every(o=>{const l=e[o],c=s[o];return typeof l=="function"?`${l}`==`${c}`:!YS(l)||!YS(c)?l===c:H2(l,c)})}function KS(e){return e.concat().sort((s,r)=>s.name>r.name?1:-1).map(s=>s.options)}function ZQ(e,s){if(e.length!==s.length)return!1;const r=KS(e),n=KS(s);return r.every((a,i)=>{const o=n[i];return H2(a,o)})}function W2(e){return typeof e=="number"}function Tj(e){return typeof e=="string"}function Ov(e){return typeof e=="boolean"}function QS(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ls(e){return Math.abs(e)}function G2(e){return Math.sign(e)}function Gm(e,s){return Ls(e-s)}function JQ(e,s){if(e===0||s===0||Ls(e)<=Ls(s))return 0;const r=Gm(Ls(e),Ls(s));return Ls(r/e)}function Ah(e){return Th(e).map(Number)}function Aa(e){return e[Bf(e)]}function Bf(e){return Math.max(0,e.length-1)}function Y2(e,s){return s===Bf(e)}function XS(e,s=0){return Array.from(Array(e),(r,n)=>s+n)}function Th(e){return Object.keys(e)}function bA(e,s){return[e,s].reduce((r,n)=>
vendor: 6,206 bytes, line 735
735(Th(n).forEach(a=>{const i=r[a],o=n[a],l=QS(i)&&QS(o);r[a]=l?bA(i,o):o}),r),{})}function Dj(e,s){return typeof s.MouseEvent<"u"&&e instanceof s.MouseEvent}function eX(e,s){const r={start:n,center:a,end:i};function n(){return 0}function a(c){return i(c)/2}function i(c){return s-c}function o(c,d){return Tj(e)?r[e](c):e(s,c,d)}return{measure:o}}function Dh(){let e=[];function s(a,i,o,l={passive:!0}){let c;if("addEventListener"in a)a.addEventListener(i,o,l),c=()=>a.removeEventListener(i,o,l);else{const d=a;d.addListener(o),c=()=>d.removeListener(o)}return e.push(c),n}function r(){e=e.filter(a=>a())}const n={add:s,clear:r};return n}function tX(e,s,r,n){const a=Dh(),i=1e3/60;let o=null,l=0,c=0;function d(){a.add(e,"visibilitychange",()=>{e.hidden&&x()})}function m(){p(),a.clear()}function h(b){if(!c)return;o||(o=b);const w=b-o;for(o=b,l+=w;l>=i;)r(i),l-=i;const j=l/i;n(j),c&&s.requestAnimationFrame(h)}function f(){c||(c=s.requestAnimationFrame(h))}function p(){s.cancelAnimationFrame(c),o=null,l=0,c=0}function x(){o=null,l=0}return{init:d,destroy:m,start:f,stop:p,update:()=>r(i),render:n}}function sX(e,s){const r=s==="rtl",n=e==="y",a=n?"y":"x",i=n?"x":"y",o=!n&&r?-1:1,l=m(),c=h();function d(x){const{height:g,width:b}=x;return n?g:b}function m(){return n?"top":r?"right":"left"}function h(){return n?"bottom":r?"left":"right"}function f(x){return x*o}return{scroll:a,cross:i,startEdge:l,endEdge:c,measureSize:d,direction:f}}function vc(e=0,s=0){const r=Ls(e-s);function n(d){return d<e}function a(d){return d>s}function i(d){return n(d)||a(d)}function o(d){return i(d)?n(d)?e:s:d}function l(d){return r?d-r*Math.ceil((d-s)/r):d}return{length:r,max:s,min:e,constrain:o,reachedAny:i,reachedMax:a,reachedMin:n,removeOffset:l}}function jA(e,s,r){const{constrain:n}=vc(0,e),a=e+1;let i=o(s);function o(f){return r?Ls((a+f)%a):n(f)}function l(){return i}function c(f){return i=o(f),h}function d(f){return m().set(l()+f)}function m(){return jA(e,l(),r)}const h={get:l,set:c,add:d,clone:m};return h}function rX(e,s,r,n,a,i,o,l,c,d,m,h,f,p,x,g,b,w,j){const{cross:y,direction:v}=e,N=["INPUT","SELECT","TEXTAREA"],S={passive:!1},k=Dh(),$=Dh(),R=vc(50,225).constrain(p.measure(20)),A={mouse:300,touch:400},T={mouse:500,touch:600},P=x?43:25;let B=!1,Y=0,I=0,C=!1,L=!1,D=!1,_=!1;function H(X){if(!j)return;function ye(ke){(Ov(j)||j(X,ke))&&Z(ke)}const Ce=s;k.add(Ce,"dragstart",ke=>ke.preventDefault(),S).add(Ce,"touchmove",()=>{},S).add(Ce,"touchend",()=>{}).add(Ce,"touchstart",ye).add(Ce,"mousedown",ye).add(Ce,"touchcancel",F).add(Ce,"contextmenu",F).add(Ce,"click",ee,!0)}function O(){k.clear(),$.clear()}function U(){const X=_?r:s;$.add(X,"touchmove",M,S).add(X,"touchend",F).add(X,"mousemove",M,S).add(X,"mouseup",F)}function G(X){const ye=X.nodeName||"";return N.includes(ye)}function E(){return(x?T:A)[_?"mouse":"touch"]}function z(X,ye){const Ce=h.add(G2(X)*-1),ke=m.byDistance(X,!x).distance;return x||Ls(X)<R?ke:b&&ye?ke*.5:m.byIndex(Ce.get(),0).distance}function Z(X){const ye=Dj(X,n);_=ye,D=x&&ye&&!X.buttons&&B,B=Gm(a.get(),o.get())>=2,!(ye&&X.button!==0)&&(G(X.target)||(C=!0,i.pointerDown(X),d.useFriction(0).useDuration(0),a.set(o),U(),Y=i.readPoint(X),I=i.readPoint(X,y),f.emit("pointerDown")))}function M(X){if(!Dj(X,n)&&X.touches.length>=2)return F(X);const Ce=i.readPoint(X),ke=i.readPoint(X,y),fe=Gm(Ce,Y),Ee=Gm(ke,I);if(!L&&!_&&(!X.cancelable||(L=fe>Ee,!L)))return F(X);const K=i.pointerMove(X);fe>g&&(D=!0),d.useFriction(.3).useDuration(.75),l.start(),a.add(v(K)),X.preventDefault()}function F(X){const Ce=m.byDistance(0,!1).index!==h.get(),ke=i.pointerUp(X)*E(),fe=z(v(ke),Ce),Ee=JQ(ke,fe),K=P-10*Ee,te=w+Ee/50;L=!1,C=!1,$.clear(),d.useDuration(K).useFriction(te),c.distance(fe,!x),_=!1,f.emit("pointerUp")}function ee(X){D&&(X.stopPropagation(),X.preventDefault(),D=!1)}function se(){return C}return{init:H,destroy:O,pointerDown:se}}function nX(e,s){let n,a;function i(h){return h.timeStamp}function o(h,f){const x=`client${(f||e.scroll)==="x"?"X":"Y"}`;return(Dj(h,s)?h:h.touches[0])[x]}function l(h){return n=h,a=h,o(h)}function c(h){const f=o(h)-o(a),p=i(h)-i(n)>170;return a=h,p&&(n=h),f}function d(h){if(!n||!a)return 0;const f=o(a)-o(n),p=i(h)-i(n),x=i(h)-i(a)>170,g=f/p;return p&&!x&&Ls(g)>.1?g:0}return{pointerDown:l,pointerMove:c,pointerUp:d,readPoint:o}}function aX(){function e(r){const{offsetTop:n,offsetLeft:a,offsetWidth:i,offsetHeight:o}=r;return{top:n,right:a+i,bottom:n+o,left:a,width:i,height:o}}return{measure:e}}function iX(e){function s(n){return e*(n/100)}return{measure:s}}function oX(e,s,r,n,a,i,o){const l=[e].concat(n);let c,d,m=[],h=!1;function f(b){return a.measureSize(o.measure(b))}function p(b){if(!i)return;d=f(e),m=n.map(f);function w(j){for(const y of j){if(h)return;const v=y.target===e,N=n.indexOf(y.target),S=v?d:m[N],k=f(v?e:n[N]);if(Ls(k-S)>=.5){b.reInit(),s.emit("resize");break}}}c=new ResizeObserver(j=>{(Ov(i)||i(b,j))&&w(j)}),r.requestAnimationFrame(()=>{l.forEach(j=>c.observe(j))})}function x(){h=!0,c&&c.disconnect()}return{init:p,destroy:x}}function lX(e,s,r,n,a,i){let o=0,l=0,c=a,d=i,m=e.get(),h=0;function f(S){const k=S/1e3,$=c*k,R=n.get()-e.get(),A=!c;let T=0;return A?(o=0,r.set(n),e.set(n),T=R):(r.set(e),o+=R/$,o*=d,m+=o,e.add(o*k),T=m-h),l=G2(T),h=m,N}function p(){const S=n.get()-s.get();return Ls(S)<.001}function x(){return c}function g(){return l}function b(){return o}function w(){return y(a)}function j(){return v(i)}function y(S){return c=S,N}function v(S){return d=S,N}const N={direction:g,duration:x,velocity:b,seek:f,settled:p,useBaseFriction:j,useBaseDuration:w,useFriction:v,useDuration:y};return N}function cX(e,s,r,n,a){const i=a.measure(10),o=a.measure(50),l=vc(.1,.99);let c=!1;function d(){return!(c||!e.reachedAny(r.get())||!e.reachedAny(s.get()))}function m(p){if(!d())return;const x=e.reachedMin(s.get())?"min":"max",g=Ls(e[x]-s.get()),b=r.get()-s.get(),w=l.constrain(g/o);r.subtract(b*w),!p&&Ls(b)<i&&(r.set(e.constrain(r.get())),n.useDuration(25).useBaseFriction())}function h(p){c=!p}return{shouldConstrain:d,constrain:m,toggleActive:h}}function dX(e,s,r,n,a){const i=vc(-s+e,0),o=h(),l=m(),c=f();function d(x,g){return Gm(x,g)<1}function m(){const x=o[0],g=Aa(o),b=o.lastIndexOf(x),w=o.indexOf(g)+1;
vendor: 9,112 bytes, line 735
735return vc(b,w)}function h(){return r.map((x,g)=>{const{min:b,max:w}=i,j=i.constrain(x),y=!g,v=Y2(r,g);return y?w:v||d(b,j)?b:d(w,j)?w:j}).map(x=>parseFloat(x.toFixed(3)))}function f(){if(s<=e+a)return[i.max];if(n==="keepSnaps")return o;const{min:x,max:g}=l;return o.slice(x,g)}return{snapsContained:c,scrollContainLimit:l}}function uX(e,s,r){const n=s[0],a=r?n-e:Aa(s);return{limit:vc(a,n)}}function mX(e,s,r,n){const i=s.min+.1,o=s.max+.1,{reachedMin:l,reachedMax:c}=vc(i,o);function d(f){return f===1?c(r.get()):f===-1?l(r.get()):!1}function m(f){if(!d(f))return;const p=e*(f*-1);n.forEach(x=>x.add(p))}return{loop:m}}function hX(e){const{max:s,length:r}=e;function n(i){const o=i-s;return r?o/-r:0}return{get:n}}function fX(e,s,r,n,a){const{startEdge:i,endEdge:o}=e,{groupSlides:l}=a,c=h().map(s.measure),d=f(),m=p();function h(){return l(n).map(g=>Aa(g)[o]-g[0][i]).map(Ls)}function f(){return n.map(g=>r[i]-g[i]).map(g=>-Ls(g))}function p(){return l(d).map(g=>g[0]).map((g,b)=>g+c[b])}return{snaps:d,snapsAligned:m}}function pX(e,s,r,n,a,i){const{groupSlides:o}=a,{min:l,max:c}=n,d=m();function m(){const f=o(i),p=!e||s==="keepSnaps";return r.length===1?[i]:p?f:f.slice(l,c).map((x,g,b)=>{const w=!g,j=Y2(b,g);if(w){const y=Aa(b[0])+1;return XS(y)}if(j){const y=Bf(i)-Aa(b)[0]+1;return XS(y,Aa(b)[0])}return x})}return{slideRegistry:d}}function xX(e,s,r,n,a){const{reachedAny:i,removeOffset:o,constrain:l}=n;function c(x){return x.concat().sort((g,b)=>Ls(g)-Ls(b))[0]}function d(x){const g=e?o(x):l(x),b=s.map((j,y)=>({diff:m(j-g,0),index:y})).sort((j,y)=>Ls(j.diff)-Ls(y.diff)),{index:w}=b[0];return{index:w,distance:g}}function m(x,g){const b=[x,x+r,x-r];if(!e)return x;if(!g)return c(b);const w=b.filter(j=>G2(j)===g);return w.length?c(w):Aa(b)-r}function h(x,g){const b=s[x]-a.get(),w=m(b,g);return{index:x,distance:w}}function f(x,g){const b=a.get()+x,{index:w,distance:j}=d(b),y=!e&&i(b);if(!g||y)return{index:w,distance:x};const v=s[w]-j,N=x+m(v,0);return{index:w,distance:N}}return{byDistance:f,byIndex:h,shortcut:m}}function gX(e,s,r,n,a,i,o){function l(h){const f=h.distance,p=h.index!==s.get();i.add(f),f&&(n.duration()?e.start():(e.update(),e.render(1),e.update())),p&&(r.set(s.get()),s.set(h.index),o.emit("select"))}function c(h,f){const p=a.byDistance(h,f);l(p)}function d(h,f){const p=s.clone().set(h),x=a.byIndex(p.get(),f);l(x)}return{distance:c,index:d}}function vX(e,s,r,n,a,i,o,l){const c={passive:!0,capture:!0};let d=0;function m(p){if(!l)return;function x(g){if(new Date().getTime()-d>10)return;o.emit("slideFocusStart"),e.scrollLeft=0;const j=r.findIndex(y=>y.includes(g));W2(j)&&(a.useDuration(0),n.index(j,0),o.emit("slideFocus"))}i.add(document,"keydown",h,!1),s.forEach((g,b)=>{i.add(g,"focus",w=>{(Ov(l)||l(p,w))&&x(b)},c)})}function h(p){p.code==="Tab"&&(d=new Date().getTime())}return{init:m}}function km(e){let s=e;function r(){return s}function n(c){s=o(c)}function a(c){s+=o(c)}function i(c){s-=o(c)}function o(c){return W2(c)?c:c.get()}return{get:r,set:n,add:a,subtract:i}}function wA(e,s){const r=e.scroll==="x"?i:o,n=s.style;let a=!1;function i(h){return`translate3d(${h}px,0px,0px)`}function o(h){return`translate3d(0px,${h}px,0px)`}function l(h){a||(n.transform=r(e.direction(h)))}function c(h){a=!h}function d(){a||(n.transform="",s.getAttribute("style")||s.removeAttribute("style"))}return{clear:d,to:l,toggleActive:c}}function yX(e,s,r,n,a,i,o,l,c){const m=Ah(a),h=Ah(a).reverse(),f=w().concat(j());function p(k,$){return k.reduce((R,A)=>R-a[A],$)}function x(k,$){return k.reduce((R,A)=>p(R,$)>0?R.concat([A]):R,[])}function g(k){return i.map(($,R)=>({start:$-n[R]+.5+k,end:$+s-.5+k}))}function b(k,$,R){const A=g($);return k.map(T=>{const P=R?0:-r,B=R?r:0,Y=R?"end":"start",I=A[T][Y];return{index:T,loopPoint:I,slideLocation:km(-1),translate:wA(e,c[T]),target:()=>l.get()>I?P:B}})}function w(){const k=o[0],$=x(h,k);return b($,r,!1)}function j(){const k=s-o[0]-1,$=x(m,k);return b($,-r,!0)}function y(){return f.every(({index:k})=>{const $=m.filter(R=>R!==k);return p($,s)<=.1})}function v(){f.forEach(k=>{const{target:$,translate:R,slideLocation:A}=k,T=$();T!==A.get()&&(R.to(T),A.set(T))})}function N(){f.forEach(k=>k.translate.clear())}return{canLoop:y,clear:N,loop:v,loopPoints:f}}function bX(e,s,r){let n,a=!1;function i(c){if(!r)return;function d(m){for(const h of m)if(h.type==="childList"){c.reInit(),s.emit("slidesChanged");break}}n=new MutationObserver(m=>{a||(Ov(r)||r(c,m))&&d(m)}),n.observe(e,{childList:!0})}function o(){n&&n.disconnect(),a=!0}return{init:i,destroy:o}}function jX(e,s,r,n){const a={};let i=null,o=null,l,c=!1;function d(){l=new IntersectionObserver(x=>{c||(x.forEach(g=>{const b=s.indexOf(g.target);a[b]=g}),i=null,o=null,r.emit("slidesInView"))},{root:e.parentElement,threshold:n}),s.forEach(x=>l.observe(x))}function m(){l&&l.disconnect(),c=!0}function h(x){return Th(a).reduce((g,b)=>{const w=parseInt(b),{isIntersecting:j}=a[w];return(x&&j||!x&&!j)&&g.push(w),g},[])}function f(x=!0){if(x&&i)return i;if(!x&&o)return o;const g=h(x);return x&&(i=g),x||(o=g),g}return{init:d,destroy:m,get:f}}function wX(e,s,r,n,a,i){const{measureSize:o,startEdge:l,endEdge:c}=e,d=r[0]&&a,m=x(),h=g(),f=r.map(o),p=b();function x(){if(!d)return 0;const j=r[0];return Ls(s[l]-j[l])}function g(){if(!d)return 0;const j=i.getComputedStyle(Aa(n));return parseFloat(j.getPropertyValue(`margin-${c}`))}function b(){return r.map((j,y,v)=>{const N=!y,S=Y2(v,y);return N?f[y]+m:S?f[y]+h:v[y+1][l]-j[l]}).map(Ls)}return{slideSizes:f,slideSizesWithGaps:p,startGap:m,endGap:h}}function NX(e,s,r,n,a,i,o,l,c){const{startEdge:d,endEdge:m,direction:h}=e,f=W2(r);function p(w,j){return Ah(w).filter(y=>y%j===0).map(y=>w.slice(y,y+j))}function x(w){return w.length?Ah(w).reduce((j,y,v)=>{const N=Aa(j)||0,S=N===0,k=y===Bf(w),$=a[d]-i[N][d],R=a[d]-i[y][m],A=!n&&S?h(o):0,T=!n&&k?h(l):0,P=Ls(R-T-($+A));return v&&P>s+c&&j.push(y),k&&j.push(w.length),j},[]).map((j,y,v)=>{const N=Math.max(v[y-1]||0);return w.slice(N,j)}):[]}function g(w){return f?p(w,r):x(w)}return{groupSlides:g}}function _X(e,s,r,n,a,i,o){const{align:l,axis:c,direction:d,startIndex:m,loop:h,duration:f,dragFree:p,dragThreshold:x,inViewThreshold:g,slidesToScroll:b,skipSnaps:w,containScroll:j,watchResize:y,watchSlides:v,watchDrag:N,watchFocus:S}=i,k=2,$=aX(),R=$.measure(s),A=r.map($.measure),T=sX(c,d),P=T.measureSize(R),B=iX(P),Y=eX(l,P),I=!h&&!!j,C=h||!!j,{slideSizes:L,slideSizesWithGaps:D,startGap:_,endGap:H}=wX(T,R,A,r,C,a),O=NX(T,P,b,h,R,A,_,H,k),{snaps:U,snapsAligned:G}=fX(T,Y,R,A,O),E=-Aa(U)+Aa(D),{snapsContained:z,scrollContainLimit:Z}=dX(P,E,G,j,k),M=I?z:G,{limit:F}=uX(E,M,h),ee=jA(Bf(M),m,h),se=ee.clone(),le=Ah(r),X=({dragHandler:Ue,scrollBody:Ve,scrollBounds:lt,options:{loop:J}},Ne)=>{J||lt.constrain(Ue.pointerDown()),Ve.seek(Ne)},ye=({scrollBody:Ue,translate:Ve,location:lt,offsetLocation:J,scrollLooper:Ne,slideLooper:gt,dragHandler:He,animation:Te,eventHandler:De,scrollBounds:Le,options:{loop:We}},Ke)=>{const st=Ue.settled(),dt=!Le.shouldConstrain(),tt=We?st:st&&dt;tt&&!He.pointerDown()&&(Te.stop(),De.emit("settle")),tt||De.emit("scroll");const Jt=lt.get()*Ke+K.get()*(1-Ke);J.set(Jt),We&&(Ne.loop(Ue.direction()),gt.loop()),Ve.to(J.get())},Ce=tX(n,a,Ue=>X(Ae,Ue),Ue=>ye(Ae,Ue)),ke=.68,fe=M[ee.get()],Ee=km(fe),K=km(fe),te=km(fe),Q=km(fe),ae=lX(Ee,te,K,Q,f,ke),me=xX(h,M,E,F,Q),pe=gX(Ce,ee,se,ae,me,Q,o),be=hX(F),ce=Dh(),ie=jX(s,r,o,g),{slideRegistry:je}=pX(I,j,M,Z,O,le),Re=vX(e,r,je,pe,ae,ce,o,S),Ae={ownerDocument:n,ownerWindow:a,eventHandler:o,containerRect:R,slideRects:A,animation:Ce,axis:T,dragHandler:rX(T,e,n,a,Q,nX(T,a),Ee,Ce,pe,ae,me,ee,o,B,p,x,w,ke,N),eventStore:ce,percentOfView:B,index:ee,indexPrevious:se,limit:F,location:Ee,offsetLocation:te,previousLocation:K,options:i,resizeHandler:oX(s,o,a,r,T,y,$),scrollBody:ae,scrollBounds:cX(F,te,Q,ae,B),scrollLooper:mX(E,F,te,[Ee,te,K,Q]),scrollProgress:be,scrollSnapList:M.map(be.get),scrollSnaps:M,scrollTarget:me,scrollTo:pe,slideLooper:yX(T,P,E,L,D,U,M,te,r),slideFocus:Re,slidesHandler:bX(s,o,v),slidesInView:ie,slideIndexes:le,slideRegistry:je,slidesToScroll:O,target:Q,translate:wA(T,s)};return Ae}function SX(){let e={},s;function r(d){s=d}function n(d){return e[d]||[]}function a(d){return n(d).forEach(m=>m(s,d)),c}function i(d,m){return e[d]=n(d).concat([m]),c}function o(d,m){return e[d]=n(d).filter(h=>h!==m),c}function l(){e={}}const c={init:r,emit:a,off:o,on:i,clear:l};return c}const CX={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function kX(e){function s(i,o){return bA(i,o||{})}function r(i){const o=i.breakpoints||{},l=Th(o).filter(c=>e.matchMedia(c).matches).map(c=>o[c]).reduce((c,d)=>s(c,d),{});return s(i,l)}function n(i){return i.map(o=>Th(o.breakpoints||{})).reduce((o,l)=>o.concat(l),[]).map(e.matchMedia)}return{mergeOptions:s,optionsAtMedia:r,optionsMediaQueries:n}}function $X(e){let s=[];function r(i,o){return s=o.filter(({options:l})=>
735e.optionsAtMedia(l).active!==!1),s.forEach(l=>l.init(i,e)),o.reduce((l,c)=>Object.assign(l,{[c.name]:c}),{})}function n(){s=s.filter(i=>i.destroy())}return{init:r,destroy:n}}function hg(e,s,r){const n=e.ownerDocument,a=n.defaultView,i=kX(a),o=$X(i),l=Dh(),c=SX(),{mergeOptions:d,optionsAtMedia:m,optionsMediaQueries:h}=i,{on:f,off:p,emit:x}=c,g=T;let b=!1,w,j=d(CX,hg.globalOptions),y=d(j),v=[],N,S,k;function $(){const{container:le,slides:X}=y;S=(Tj(le)?e.querySelector(le):le)||e.children[0];const Ce=Tj(X)?S.querySelectorAll(X):X;k=[].slice.call(Ce||S.children)}function R(le){const X=_X(e,S,k,n,a,le,c);if(le.loop&&!X.slideLooper.canLoop()){const ye=Object.assign({},le,{loop:!1});return R(ye)}return X}function A(le,X){b||(j=d(j,le),y=m(j),v=X||v,$(),w=R(y),h([j,...v.map(({options:ye})=>ye)]).forEach(ye=>l.add(ye,"change",T)),y.active&&(w.translate.to(w.location.get()),w.animation.init(),w.slidesInView.init(),w.slideFocus.init(se),w.eventHandler.init(se),w.resizeHandler.init(se),w.slidesHandler.init(se),w.options.loop&&w.slideLooper.loop(),S.offsetParent&&k.length&&w.dragHandler.init(se),N=o.init(se,v)))}function T(le,X){const ye=O();P(),A(d({startIndex:ye},le),X),c.emit("reInit")}function P(){w.dragHandler.destroy(),w.eventStore.clear(),w.translate.clear(),w.slideLooper.clear(),w.resizeHandler.destroy(),w.slidesHandler.destroy(),w.slidesInView.destroy(),w.animation.destroy(),o.destroy(),l.clear()}function B(){b||(b=!0,l.clear(),P(),c.emit("destroy"),c.clear())}function Y(le,X,ye){!y.active||b||(w.scrollBody.useBaseFriction().useDuration(X===!0?0:y.duration),w.scrollTo.index(le,ye||0))}function I(le){const X=w.index.add(1).get();Y(X,le,-1)}function C(le){const X=w.index.add(-1).get();Y(X,le,1)}function L(){return w.index.add(1).get()!==O()}function D(){return w.index.add(-1).get()!==O()}function _(){return w.scrollSnapList}function H(){return w.scrollProgress.get(w.location.get())}function O(){return w.index.get()}function U(){return w.indexPrevious.get()}function G(){return w.slidesInView.get()}function E(){return w.slidesInView.get(!1)}function z(){return N}function Z(){return w}function M(){return e}function F(){return S}function ee(){return k}const se={canScrollNext:L,canScrollPrev:D,containerNode:F,internalEngine:Z,destroy:B,off:p,on:f,emit:x,plugins:z,previousScrollSnap:U,reInit:g,rootNode:M,scrollNext:I,scrollPrev:C,scrollProgress:H,scrollSnapList:_,scrollTo:Y,selectedScrollSnap:O,slideNodes:ee,slidesInView:G,slidesNotInView:E};return A(s,r),setTimeout(()=>c.emit("init"),0),se}hg.globalOptions=void 0;function K2(e={},s=[]){const r=u.useRef(e),n=u.useRef(s),[a,i]=u.useState(),[o,l]=u.useState(),c=u.useCallback(()=>{a&&a.reInit(r.current,n.current)},[a]);return u.useEffect(()=>{H2(r.current,e)||(r.current=e,c())},[e,c]),u.useEffect(()=>{ZQ(n.current,s)||(n.current=s,c())},[s,c]),u.useEffect(()=>{if(XQ()&&o){hg.globalOptions=K2.globalOptions;const d=hg(o,r.current,n.current);return i(d),()=>d.destroy()}else i(void 0)},[o,i]),[l,a]}K2.globalOptions=void 0;const NA=u.createContext(null);function Iv(){const e=u.useContext(NA);if(!e)throw new Error("useCarousel must be used within a <Carousel />");return e}const Lu=u.forwardRef(({orientation:e="horizontal",opts:s,setApi:r,plugins:n,className:a,children:i,...o},l)=>{const[c,d]=K2({...s,axis:e==="horizontal"?"x":"y"},n),[m,h]=u.useState(!1),[f,p]=u.useState(!1),x=u.useCallback(j=>{j&&(h(j.canScrollPrev()),p(j.canScrollNext()))},[]),g=u.useCallback(()=>{d==null||d.scrollPrev()},[d]),b=u.useCallback(()=>{d==null||d.scrollNext()},[d]),w=u.useCallback(j=>{j.key==="ArrowLeft"?(j.preventDefault(),g()):j.key==="ArrowRight"&&(j.preventDefault(),b())},[g,b]);return u.useEffect(()=>{!d||!r||r(d)},[d,r]),u.useEffect(()=>{if(d)return x(d),d.on("reInit",x),d.on("select",x),()=>{d==null||d.off("select",x)}},[d,x]),t.jsx(NA.Provider,{value:{carouselRef:c,api:d,opts:s,orientation:e||((s==null?void 0:s.axis)==="y"?"vertical":"horizontal"),scrollPrev:g,scrollNext:b,canScrollPrev:m,canScrollNext:f},children:t.jsx("div",{ref:l,onKeyDownCapture:w,className:oe("relative",a),role:"region","aria-roledescription":"carousel",...o,children:i})})});
735Lu.displayName="Carousel";const Bu=u.forwardRef(({className:e,...s},r)=>{const{carouselRef:n,orientation:a}=Iv();return t.jsx("div",{ref:n,className:"overflow-hidden",children:t.jsx("div",{ref:r,className:oe("flex",a==="horizontal"?"-ml-4":"-mt-4 flex-col",e),...s})})});Bu.displayName="CarouselContent";const zu=u.forwardRef(({className:e,...s},r)=>{const{orientation:n}=Iv();return t.jsx("div",{ref:r,role:"group","aria-roledescription":"slide",className:oe("min-w-0 shrink-0 grow-0 basis-full",n==="horizontal"?"pl-4":"pt-4",e),...s})});zu.displayName="CarouselItem";const Uu=u.forwardRef(({className:e,variant:s="outline",size:r="icon",...n},a)=>{const{orientation:i,scrollPrev:o,canScrollPrev:l}=Iv();return t.jsxs(q,{ref:a,variant:s,size:r,className:oe("absolute h-8 w-8 rounded-full",i==="horizontal"?"-left-12 top-1/2 -translate-y-1/2":"-top-12 left-1/2 -translate-x-1/2 rotate-90",e),disabled:!l,onClick:o,...n,children:[t.jsx(Hi,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Previous slide"})]})});Uu.displayName="CarouselPrevious";const Vu=u.forwardRef(({className:e,variant:s="outline",size:r="icon",...n},a)=>{const{orientation:i,scrollNext:o,canScrollNext:l}=Iv();return t.jsxs(q,{ref:a,variant:s,size:r,className:oe("absolute h-8 w-8 rounded-full",i==="horizontal"?"-right-12 top-1/2 -translate-y-1/2":"-bottom-12 left-1/2 -translate-x-1/2 rotate-90",e),disabled:!l,onClick:o,...n,children:[t.jsx(jf,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Next slide"})]})});Vu.displayName="CarouselNext";const EX=()=>{const e=[{name:"Sarah Mitchell",location:"Fareham",quote:"Discover magazine keeps me connected with everything happening in our community. I love reading the local stories!",rating:5},{name:"David Thompson",location:"Gosport",quote:"The events section is fantastic. I never miss out on local activities thanks to Discover.",rating:5},{name:"Emma Wilson",location:"Havant",quote:"As a local business owner, advertising in Discover has really helped boost our customer base.",rating:5},{name:"Robert Clarke",location:"Waterlooville",quote:"Been reading Discover for years. It truly captures the spirit of our local community.",rating:5}];return t.jsx("section",{className:"py-12 md:py-16 bg-muted/50",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsx("h2",{className:"text-2xl md:text-3xl lg:text-4xl font-heading font-bold text-center text-community-navy mb-8 md:mb-12",children:"What Our Readers Say"}),t.jsxs("div",{className:"relative",children:[t.jsxs(Lu,{className:"w-full max-w-5xl mx-auto",children:[t.jsx(Bu,{children:e.map((s,r)=>t.jsx(zu,{className:"basis-full md:basis-1/2",children:t.jsx(xe,{className:"h-full mx-2",children:t.jsxs(ge,{className:"p-5 md:p-6",children:[t.jsx("div",{className:"flex mb-3 md:mb-4",children:[...Array(s.rating)].map((n,a)=>t.jsx("span",{className:"text-yellow-400 text-lg md:text-xl",children:"â
"},a))}),t.jsxs("blockquote",{className:"text-muted-foreground mb-4 font-body italic text-sm md:text-base",children:['"',s.quote,'"']}),t.jsxs("div",{className:"border-t pt-3 md:pt-4",children:[t.jsx("p",{className:"font-semibold text-community-navy",children:s.name}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s.location})]})]})})},r))}),t.jsx(Uu,{className:"left-0 md:-left-4 lg:-left-12 h-10 w-10 md:h-12 md:w-12"}),t.jsx(Vu,{className:"right-0 md:-right-4 lg:-right-12 h-10 w-10 md:h-12 md:w-12"})]}),t.jsx("p",{className:"text-center text-xs text-muted-foreground mt-4 md:hidden",children:"Swipe to see more reviews"})]})]})})},PX=()=>{const e=ds(),[s,r]=u.useState([]),[n,a]=u.useState(!0);u.useEffect(()=>{(async()=>{try{const{data:l,error:c}=await W.from("stories").select("id, title, excerpt, featured_image_url, created_at, category").eq("is_published",!0).order("created_at",{ascending:!1}).limit(6);if(c)throw c;r(l||[])}catch(l){console.error("Error fetching stories:",l)}finally{a(!1)}})()},[]);const i=o=>new Date(o).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"});return n?t.jsx("section",{className:"py-10 md:py-16 bg-background",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsx("div",{className:"text-center mb-6 md:mb-12",children:t.jsx("h2",{className:"text-2xl md:text-3xl lg:text-4xl font-heading font-bold text-community-navy mb-2 md:mb-4",children:"Latest Stories"})}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[1,2,3].map(o=>t.jsxs("div",{className:"animate-pulse",children:[t.jsx("div",{className:"aspect-video bg-muted rounded-lg"}),t.jsxs("div",{className:"p-4 space-y-2",children:[t.jsx("div",{className:"h-4 bg-muted rounded w-1/4"}),t.jsx("div",{className:"h-6 bg-muted rounded w-3/4"}),t.jsx("div",{className:"h-4 bg-muted rounded w-full"})]})]},o))})]})}):s.length===0?null:t.jsx("section",{className:"py-10 md:py-16 bg-background",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"text-center mb-6 md:mb-12",children:[t.jsx("h2",{className:"text-2xl md:text-3xl lg:text-4xl font-heading font-bold text-community-navy mb-2 md:mb-4",children:"Latest Stories"}),t.jsx("p",{className:"text-sm md:text-xl text-muted-foreground font-body",children:"Stay updated with the latest news from your community"})]}),t.jsxs("div",{className:"md:hidden relative",children:[t.jsxs(Lu,{opts:{align:"start",loop:!0},className:"w-full",children:[t.jsx(Bu,{className:"-ml-3",children:s.map(o=>t.jsx(zu,{className:"pl-3 basis-[85%]",children:t.jsx(xe,{className:"group hover:shadow-lg transition-shadow duration-300 overflow-hidden",children:t.jsxs("div",{className:"flex gap-3 p-3",children:[t.jsx("div",{className:"w-24 h-24 flex-shrink-0 bg-muted rounded-lg overflow-hidden",children:t.jsx("img",{src:o.featured_image_url||"/placeholder.svg",alt:o.title,loading:"lazy",className:"w-full h-full object-cover"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"flex items-center gap-2 mb-1",children:t.jsx("span",{className:"px-2 py-0.5 bg-community-green text-white text-[10px] font-medium rounded-full",children:o.category})}),t.jsx("h3",{className:"text-sm font-heading font-semibold text-community-navy line-clamp-2 mb-1",children:o.title}),t.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:o.excerpt})]})]})})},o.id))}),t.jsx(Uu,{className:"left-0 h-8 w-8"}),t.jsx(Vu,{className:"right-0 h-8 w-8"})]}),t.jsx("p",{className:"text-center text-xs text-muted-foreground mt-3",children:"Swipe to see more stories"})]}),t.jsx("div",{className:"hidden md:grid grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8",children:s.map(o=>t.jsxs(xe,{className:"group hover:shadow-lg transition-shadow duration-300",children:[t.jsx("div",{className:"aspect-video bg-muted rounded-t-lg overflow-hidden",children:t.jsx("img",{src:o.featured_image_url||"/placeholder.svg",alt:o.title,loading:"lazy",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"})}),t.jsxs(ge,{className:"p-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("span",{className:"px-3 py-1 bg-community-green text-white text-xs font-medium rounded-full",children:o.category}),t.jsx("span",{className:"text-muted-foreground text-sm",children:i(o.created_at)})]}),t.jsx("h3",{className:"text-lg font-heading font-semibold text-community-navy group-hover:text-community-green transition-colors line-clamp-2 mb-2",children:o.title}),t.jsx("p",{className:"text-muted-foreground font-body text-sm line-clamp-2 mb-3",children:o.excerpt}),t.jsx(q,{variant:"outline",size:"sm",className:"text-community-green border-community-green hover:bg-community-green hover:text-white",onClick:()=>e(`/story/${o.id}`),children:"Read More"})]})]},o.id))}),t.jsx("div",{className:"text-center mt-6 md:mt-12",children:t.jsx(q,{size:"lg",className:"bg-community-navy hover:bg-slate-700 text-white min-h-[44px]",onClick:()=>e("/stories"),children:"View All Stories"})})]})})},bt=r2,Sn=n2,AX=a2,_A=u.forwardRef(({className:e,...s},r)=>t.jsx(Rf,{ref:r,className:oe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...s}));_A.displayName=Rf.displayName;const xt=u.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(AX,{children:[t.jsx(_A,{}),t.jsxs(Mf,{ref:n,className:oe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rou
735nded-lg",e),...r,children:[s,t.jsxs(kv,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(Es,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));xt.displayName=Mf.displayName;const jt=({className:e,...s})=>t.jsx("div",{className:oe("flex flex-col space-y-1.5 text-center sm:text-left",e),...s});jt.displayName="DialogHeader";const ma=({className:e,...s})=>t.jsx("div",{className:oe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...s});ma.displayName="DialogFooter";const wt=u.forwardRef(({className:e,...s},r)=>t.jsx(Of,{ref:r,className:oe("text-lg font-semibold leading-none tracking-tight",e),...s}));wt.displayName=Of.displayName;const ys=u.forwardRef(({className:e,...s},r)=>t.jsx(If,{ref:r,className:oe("text-sm text-muted-foreground",e),...s}));ys.displayName=If.displayName;const SA=(e=!1)=>Lt({queryKey:["featured-advertisers",e],queryFn:async()=>{let s=W.from("featured_advertisers").select(` 736 *, 737 businesses:business_id ( 738 id, 739 name 740 ) 741 `).order("sort_order",{ascending:!0});e||(s=s.eq("is_active",!0));const{data:r,error:n}=await s;if(n)throw console.error("Error fetching featured advertisers:",n),n;return r}}),TX=()=>{const e=Xs(),s=os({mutationFn:async o=>{const{data:l,error:c}=await W.from("featured_advertisers").insert(o).select().single();if(c)throw c;return l},onSuccess:()=>{e.invalidateQueries({queryKey:["featured-advertisers"]}),ks.success("Featured advertiser created successfully")},onError:o=>{console.error("Error creating featured advertiser:",o),ks.error("Failed to create featured advertiser")}}),r=os({mutationFn:async({id:o,...l})=>{const{data:c,error:d}=await W.from("featured_advertisers").update(l).eq("id",o).select().single();if(d)throw d;return c},onSuccess:()=>{e.invalidateQueries({queryKey:["featured-advertisers"]}),ks.success("Featured advertiser updated successfully")},onError:o=>{console.error("Error updating featured advertiser:",o),ks.error("Failed to update featured advertiser")}}),n=os({mutationFn:async o=>{const{error:l}=await W.from("featured_advertisers").delete().eq("id",o);if(l)throw l},onSuccess:()=>{e.invalidateQueries({queryKey:["featured-advertisers"]}),ks.success("Featured advertiser deleted successfully")},onError:o=>{console.error("Error deleting featured advertiser:",o),ks.error("Failed to delete featured advertiser")}}),a=os({mutationFn:async({id:o,is_active:l})=>{const{error:c}=await W.from("featured_advertisers").update({is_active:l}).eq("id",o);if(c)throw c},onSuccess:()=>{e.invalidateQueries({queryKey:["featured-advertisers"]}),ks.success("Featured advertiser visibility updated")},onError:o=>{console.error("Error toggling featured advertiser:",o),ks.error("Failed to update visibility")}}),i=os({mutationFn:async o=>{var m;const l=o.map(({id:h,sort_order:f})=>W.from("featured_advertisers").update({sort_order:f}).eq("id",h)),d=(m=(await Promise.all(l)).find(h=>h.error))==null?void 0:m.error;if(d)throw d},onSuccess:()=>{e.invalidateQueries({queryKey:["featured-advertisers"]}),ks.success("Order updated successfully")},onError:o=>{console.error("Error updating sort order:",o),ks.error("Failed to update order")}});return{createAdvertiser:s.mutate,updateAdvertiser:r.mutate,deleteAdvertiser:n.mutate,toggleActive:a.mutate,updateSortOrder:i.mutate,isCreating:s.isPending,isUpdating:r.isPending,isDeleting:n.isPending}},DX=()=>{const{data:e,isLoading:s}=SA(!1);return s?t.jsx("section",{className:"py-12 md:py-16 bg-muted/50",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"text-center mb-8 md:mb-12",children:[t.jsx(Is,{className:"h-10 w-64 mx-auto mb-4"}),t.jsx(Is,{className:"h-6 w-96 mx-auto"})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6",children:[...Array(4)].map((r,n)=>t.jsx(Is,{className:"h-[220px] w-full rounded-lg"},n))})]})}):!e||e.length===0?null:t.jsx("section",{className:"py-12 md:py-16 bg-muted/50",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"text-center mb-8 md:mb-12",children:[t.jsx("h2",{className:"text-2xl md:text-3xl lg:text-4xl font-heading font-bold text-community-navy mb-3 md:mb-4",children:"Featured Advert
741isers"}),t.jsx("p",{className:"text-base md:text-xl text-muted-foreground font-body",children:"Supporting local businesses that make our community thrive"})]}),t.jsxs("div",{className:"relative",children:[t.jsxs(Lu,{opts:{align:"start",loop:!0},className:"w-full",children:[t.jsx(Bu,{className:"-ml-3 md:-ml-6",children:e.map(r=>t.jsx(zu,{className:"pl-3 md:pl-6 basis-full sm:basis-1/2 md:basis-1/3 lg:basis-1/4",children:r.business_id?t.jsx(hs,{to:`/business/${r.business_id}`,children:t.jsx("div",{className:"flex items-center justify-center p-4 bg-background rounded-lg shadow-sm hover:shadow-md transition-shadow duration-300 cursor-pointer min-h-[200px] md:min-h-[220px]",children:t.jsx("img",{src:r.image_url,alt:r.name,loading:"lazy",className:"max-w-full max-h-44 md:max-h-48 object-contain hover:scale-105 transition-all duration-300"})})}):t.jsxs(bt,{children:[t.jsx(Sn,{asChild:!0,children:t.jsx("div",{className:"flex items-center justify-center p-4 bg-background rounded-lg shadow-sm hover:shadow-md transition-shadow duration-300 cursor-pointer min-h-[200px] md:min-h-[220px]",children:t.jsx("img",{src:r.image_url,alt:r.name,loading:"lazy",className:"max-w-full max-h-44 md:max-h-48 object-contain hover:scale-105 transition-all duration-300"})})}),t.jsx(xt,{className:"max-w-4xl max-h-[90vh] p-4",children:t.jsx("div",{className:"flex items-center justify-center",children:t.jsx("img",{src:r.image_url,alt:r.name,className:"max-w-full max-h-full object-contain"})})})]})},r.id))}),t.jsx(Uu,{className:"left-0 md:-left-4 lg:-left-12 h-10 w-10 md:h-12 md:w-12"}),t.jsx(Vu,{className:"right-0 md:-right-4 lg:-right-12 h-10 w-10 md:h-12 md:w-12"})]}),t.jsx("p",{className:"text-center text-xs text-muted-foreground mt-4 md:hidden",children:"Swipe to see more advertisers"})]}),t.jsxs("div",{className:"text-center mt-8 md:mt-12",children:[t.jsx("p",{className:"text-muted-foreground font-body mb-4",children:"Want to feature your business here?"}),t.jsx("a",{href:"/advertising",className:"inline-block text-community-green font-semibold hover:text-green-600 transition-colors min-h-[44px] py-2",children:"Learn about our advertising options â"})]})]})})},re=u.forwardRef(({className:e,type:s,...r},n)=>t.jsx("input",{type:s,className:oe("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...r}));re.displayName="Input";var RX="Label",CA=u.forwardRef((e,s)=>t.jsx(ze.label,{...e,ref:s,onMouseDown:r=>{var a;r.target.closest("button, input, select, textarea")||((a=e.onMouseDown)==null||a.call(e,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));CA.displayName=RX;var kA=CA;const MX=fa("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),V=u.forwardRef(({className:e,...s},r)=>t.jsx(kA,{ref:r,className:oe(MX(),e),...s}));V.displayName=kA.displayName;const OX=()=>{const[e,s]=u.useState(""),[r,n]=u.useState(""),[a,i]=u.useState(""),[o,l]=u.useState(""),c=d=>{d.preventDefault(),s(""),n(""),i(""),l("")};return t.jsx("section",{id:"newsletter",className:"py-10 md:py-16 bg-community-navy",children:t.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsx(xe,{className:"bg-background shadow-xl",children:t.jsx(ge,{className:"p-5 md:p-8 lg:p-12",children:t.jsxs("div",{className:"lg:flex lg:items-center lg:justify-between gap-8",children:[t.jsxs("div",{className:"lg:flex-1 mb-6 lg:mb-0",children:[t.jsx("h2",{className:"text-2xl md:text-3xl lg:text-4xl font-heading font-bold text-community-navy mb-3 md:mb-4",children:"Subscribe to our Monthly E-Newsletter"}),t.jsx("p",{className:"text-base md:text-xl text-muted-foreground font-body mb-4 md:mb-6",children:"Exclusive news, stories, early event notifications and special offers"}),t.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-2 -mx-1 px-1 md:flex-wrap md:overflow-visible md:pb-0",children:[t.jsx("span",{className:"flex-shrink-0 px-3 py-1.5 bg-community-green/10 text-community-green text-sm rounded-full whitespace-nowrap",children:"â Community Updates"}),t.jsx("span",{className:"flex-shrink-0 px-3 py-1.5 bg-community-green/10 text-community-green text-sm rounded-full whitespace-nowrap",children:"â Competitions"}),t.jsx("span",{className:"flex-shrink-0 px-3 py-1.5 bg-community-green/10 text-community-green text-sm rounded-full whitespace-nowrap",children:"â Local Promos"})]})]}),t.jsx("div",{className:"lg:w-96",children:t.jsxs("form",{onSubmit:c,className:"space-y-3 md:space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"newsletter-firstname",className:"text-sm font-medium text-foreground",children:"First Name"}),t.jsx(re,{id:"newsletter-firstname",type:"text",placeholder:"First name",value:e,onCh
741ange:d=>s(d.target.value),required:!0,maxLength:50,className:"w-full h-11 md:h-12 text-base"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"newsletter-surname",className:"text-sm font-medium text-foreground",children:"Surname"}),t.jsx(re,{id:"newsletter-surname",type:"text",placeholder:"Surname",value:r,onChange:d=>n(d.target.value),required:!0,maxLength:50,className:"w-full h-11 md:h-12 text-base"})]})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"newsletter-email",className:"text-sm font-medium text-foreground",children:"Email Address"}),t.jsx(re,{id:"newsletter-email",type:"email",placeholder:"Enter your email",value:a,onChange:d=>i(d.target.value),required:!0,maxLength:255,className:"w-full h-11 md:h-12 text-base"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"newsletter-postcode",className:"text-sm font-medium text-foreground",children:"Postcode"}),t.jsx(re,{id:"newsletter-postcode",type:"text",placeholder:"e.g. SO16 1AB",value:o,onChange:d=>l(d.target.value),required:!0,className:"w-full h-11 md:h-12 text-base"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Helps us tailor content to your area"})]}),t.jsx(q,{type:"submit",size:"lg",className:"w-full bg-community-green hover:bg-green-600 text-white h-12 md:h-14 text-base md:text-lg",children:"Subscribe"}),t.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"We respect your privacy. Unsubscribe at any time."})]})})]})})})})})},vs=()=>{const[e,s]=u.useState({}),r=M2(),n=a=>{s(i=>({...i,[a]:!i[a]}))};return t.jsx("footer",{id:"contact",className:"bg-community-navy text-white py-10 md:py-16",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"hidden md:grid lg:grid-cols-[2fr_1fr_1.5fr] md:grid-cols-2 gap-8",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-3xl font-heading font-bold mb-2",children:"Discover Magazines Ltd"}),t.jsx("p",{className:"text-xl font-semibold text-community-green mb-4",children:"South Hampshire's Biggest, Little (and Best!) Magazine"}),t.jsx("p",{className:"text-gray-300 font-body mb-6 max-w-md leading-relaxed",children:"Connecting communities, celebrating local stories and helping businesses thrive"}),t.jsxs("div",{className:"grid sm:grid-cols-3 gap-4 text-sm",children:[t.jsxs("div",{className:"bg-white/5 rounded-lg p-4",children:[t.jsx("p",{className:"text-community-green font-semibold",children:"Circulation"}),t.jsx("p",{className:"text-white font-bold text-lg",children:"142,000 homes"})]}),t.jsxs("div",{className:"bg-white/5 rounded-lg p-4",children:[t.jsx("p",{className:"text-community-green font-semibold",children:"Frequency"}),t.jsx("p",{className:"text-white font-bold text-lg",children:"Bi-monthly"})]}),t.jsxs("div",{className:"bg-white/5 rounded-lg p-4",children:[t.jsx("p",{className:"text-community-green font-semibold",children:"Established"}),t.jsx("p",{className:"text-white font-bold text-lg",children:"2005"})]})]})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-lg font-heading font-semibold mb-6 text-community-green",children:"Quick Links"}),t.jsxs("ul",{className:"space-y-3 font-body",children:[r&&t.jsx("li",{children:t.jsx("a",{href:"/whats-on",className:"text-gray-300 hover:text-community-green transition-colors hover:translate-x-1 transform duration-200 block",children:"Events & What's On"})}),t.jsx("li",{children:t.jsx("a",{href:"/competitions",className:"text-gray-300 hover:text-community-green transition-colors hover:translate-x-1 transform duration-200 block",children:"Competitions"})}),t.jsx("li",{children:t.jsx("a",{href:"/business-directory",className:"text-gray-300 hover:text-community-green transition-colors hover:translate-x-1 transform duration-200 block",children:"Directory"})}),t.jsx("li",{children:t.jsx("a",{href:"/advertising",className:"text-gray-300 hover:text-community-green transition-colors hover:translate-x-1 transform duration-200 block",children:"Advertising"})}),t.jsx("li",{children:t.jsx("a",{href:"/apply-to-distribute",className:"text-gray-300 hover:text-community-green transition-colors hover:translate-x-1 transform duration-200 block",children:"Distribution"})}),t.jsx("li",{children:t.jsx("a",{href:"/contact",className:"text-gray-300 hover:text-community-green transition-colors hover:translate-x-1 transform duration-200 block",children:"Contact"})})]})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-lg font-heading font-semibold mb-6 text-community-green",children:"Get in Touch"}),t.jsxs("div",{className:"space-y-4 font-body",children:[t.jsxs("a",{href:"tel:02380266388",className:"flex items-start gap-3 group",children:[t.jsx("div",{className:"bg-community-green/20 rounded-full p-2 mt-1",children:t.jsx(zr,{className:"h-4 w-4 text-community-green"})}),t.jsx("p",{className:"text-white font-semibold group-hover:text-community-green transition-colors",children:"023 8026 6388"})]}),t.jsxs("a",{href:"mailto:[email protected]",className:"flex items-start gap-3 group",children:[t.jsx("div",{className:"bg-community-green/20 rounded-full p-2 mt-1",children:t.jsx(ar,{className:"h-4 w-4 text-community-green"})}),t.jsx("p",{className:"text-white font-semibold group-hover:text-community-green transition-colors break-all",children:"[email protected]"})]}),t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"bg-community-green/20 rounded-full p-2 mt-1",children:t.jsx(_t,{className:"h-4 w-4 text-community-green"})}),t.jsx("p",{className:"text-white font-semibold",children:"30 Leigh Road, Eastleigh, SO50 9DT Hampshire"})]}),t.jsxs("div",{className:"bg-white/5 rounded-lg p-4 mt-6",children:[t.jsx("p",{className:"text-community-green font-semibold mb-2",children:"Business Hours"}),t.jsx("p",{className:"text-gray-300 text-sm",children:"Mon-Thurs: 9am-5pm"}),t.jsx("p",{className:"text-gray-300 text-sm",children:"Fri: 9am-4pm"})]})]})]})]}),t.jsxs("div",{className:"md:hidden space-y-4",children:[t.jsxs("div",{className:"text-center pb-4 border-b border-white/10",children:[t.jsx("h3",{className:"text-2xl font-heading font-bold mb-1",children:"Discover Magazines Ltd"}),t.jsx("p",{className:"text-sm text-community-green font-semibold",children:"South Hampshire's Biggest, Little (and Be
741st!) Magazine"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3 py-2",children:[t.jsxs("div",{className:"bg-white/5 rounded-lg p-3 text-center",children:[t.jsx("p",{className:"text-community-green text-xs font-semibold",children:"Circulation"}),t.jsx("p",{className:"text-white font-bold",children:"142k homes"})]}),t.jsxs("div",{className:"bg-white/5 rounded-lg p-3 text-center",children:[t.jsx("p",{className:"text-community-green text-xs font-semibold",children:"Since"}),t.jsx("p",{className:"text-white font-bold",children:"2005"})]})]}),t.jsxs(ig,{open:e.links,onOpenChange:()=>n("links"),children:[t.jsxs(og,{className:"flex items-center justify-between w-full py-3 border-b border-white/10",children:[t.jsx("span",{className:"text-lg font-heading font-semibold text-community-green",children:"Quick Links"}),t.jsx(Ma,{className:`h-5 w-5 text-community-green transition-transform ${e.links?"rotate-180":""}`})]}),t.jsxs(lg,{className:"py-3 space-y-3",children:[r&&t.jsx("a",{href:"/whats-on",className:"block py-2 text-gray-300 hover:text-community-green min-h-[44px] flex items-center",children:"Events & What's On"}),t.jsx("a",{href:"/competitions",className:"block py-2 text-gray-300 hover:text-community-green min-h-[44px] flex items-center",children:"Competitions"}),t.jsx("a",{href:"/business-directory",className:"block py-2 text-gray-300 hover:text-community-green min-h-[44px] flex items-center",children:"Directory"}),t.jsx("a",{href:"/advertising",className:"block py-2 text-gray-300 hover:text-community-green min-h-[44px] flex items-center",children:"Advertising"}),t.jsx("a",{href:"/apply-to-distribute",className:"block py-2 text-gray-300 hover:text-community-green min-h-[44px] flex items-center",children:"Distribution"}),t.jsx("a",{href:"/contact",className:"block py-2 text-gray-300 hover:text-community-green min-h-[44px] flex items-center",children:"Contact"})]})]}),t.jsxs(ig,{open:e.contact,onOpenChange:()=>n("contact"),children:[t.jsxs(og,{className:"flex items-center justify-between w-full py-3 border-b border-white/10",children:[t.jsx("span",{className:"text-lg font-heading font-semibold text-community-green",children:"Contact Us"}),t.jsx(Ma,{className:`h-5 w-5 text-community-green transition-transform ${e.contact?"rotate-180":""}`})]}),t.jsxs(lg,{className:"py-4 space-y-4",children:[t.jsxs("a",{href:"tel:02380266388",className:"flex items-center gap-3 py-2 min-h-[44px]",children:[t.jsx("div",{className:"bg-community-green/20 rounded-full p-2",children:t.jsx(zr,{className:"h-5 w-5 text-community-green"})}),t.jsx("span",{className:"text-white font-semibold",children:"023 8026 6388"})]}),t.jsxs("a",{href:"mailto:[email protected]",className:"flex items-center gap-3 py-2 min-h-[44px]",children:[t.jsx("div",{className:"bg-community-green/20 rounded-full p-2",children:t.jsx(ar,{className:"h-5 w-5 text-community-green"})}),t.jsx("span",{className:"text-white font-semibold text-sm break-all",children:"[email protected]"})]}),t.jsxs("div",{className:"flex items-center gap-3 py-2",children:[t.jsx("div",{className:"bg-community-green/20 rounded-full p-2",children:t.jsx(_t,{className:"h-5 w-5 text-community-green"})}),t.jsx("span",{className:"text-white font-semibold",children:"30 Leigh Road, Eastleigh, SO50 9DT Hampshire"})]}),t.jsxs("div",{className:"bg-white/5 rounded-lg p-4 mt-2",children:[t.jsx("p",{className:"text-community-green font-semibold mb-1",children:"Business Hours"}),t.jsx("p",{className:"text-gray-300 text-sm",children:"Mon-Thurs: 9am-5pm | Fri: 9am-4pm"})]})]})]})]}),t.jsxs("div",{className:"border-t border-gray-600 mt-8 md:mt-12 pt-6 md:pt-8 text-center",children:[t.jsx("p",{className:"text-gray-400 font-body text-sm md:text-base",children:"© 2024 Discover Magazines Ltd. All rights reserved."}),t.jsx("p",{className:"text-community-green text-sm mt-1",children:"Proudly serving South Hampshire since 2005"})]})]})})},Fv=(e=!1,s)=>Lt({queryKey:["magazine-editions",e,s],queryFn:async()=>{let r=W.from("magazine_editions").select("*").order("sort_order",{ascending:!0});e||(r=r.eq("is_active",!0)),s&&(r=r.eq("content_type",s));const{data:n,error:a}=await r;if(a)throw a;return n},staleTime:5*60*1e3}),IX=()=>{const e=Xs(),{toast:s}=rt(),r=os({mutationFn:async l=>{const{data:c,error:d}=await W.from("magazine_editions").insert(l).select().single();if(d)throw d;return c},onSuccess:()=>
741{e.invalidateQueries({queryKey:["magazine-editions"]}),s({title:"Success",description:"Edition created successfully"})},onError:l=>{s({title:"Error",description:l.message,variant:"destructive"})}}),n=os({mutationFn:async({id:l,...c})=>{const{data:d,error:m}=await W.from("magazine_editions").update(c).eq("id",l).select().single();if(m)throw m;return d},onSuccess:()=>{e.invalidateQueries({queryKey:["magazine-editions"]}),s({title:"Success",description:"Edition updated successfully"})},onError:l=>{s({title:"Error",description:l.message,variant:"destructive"})}}),a=os({mutationFn:async l=>{const{error:c}=await W.from("magazine_editions").delete().eq("id",l);if(c)throw c},onSuccess:()=>{e.invalidateQueries({queryKey:["magazine-editions"]}),s({title:"Success",description:"Edition deleted successfully"})},onError:l=>{s({title:"Error",description:l.message,variant:"destructive"})}}),i=os({mutationFn:async({id:l,is_active:c})=>{const{error:d}=await W.from("magazine_editions").update({is_active:c}).eq("id",l);if(d)throw d},onSuccess:()=>{e.invalidateQueries({queryKey:["magazine-editions"]}),s({title:"Success",description:"Edition status updated"})},onError:l=>{s({title:"Error",description:l.message,variant:"destructive"})}}),o=os({mutationFn:async l=>{var h;const c=l.map(({id:f,sort_order:p})=>W.from("magazine_editions").update({sort_order:p}).eq("id",f)),m=(h=(await Promise.all(c)).find(f=>f.error))==null?void 0:h.error;if(m)throw m},onSuccess:()=>{e.invalidateQueries({queryKey:["magazine-editions"]}),s({title:"Success",description:"Order updated successfully"})},onError:l=>{s({title:"Error",description:l.message,variant:"destructive"})}});return{createEdition:r,updateEdition:n,deleteEdition:a,toggleActive:i,updateSortOrder:o}},FX=()=>{const[e,s]=u.useState(!1),{toast:r}=rt();return{uploadCoverImage:async a=>{s(!0);try{const i=a.name.split(".").pop(),l=`covers/${`${Date.now()}-${Math.random().toString(36).substring(2)}.${i}`}`,{error:c}=await W.storage.from("magazine-covers").upload(l,a);if(c)throw c;const{data:{publicUrl:d}}=W.storage.from("magazine-covers").getPublicUrl(l);return d}catch(i){return r({title:"Upload failed",description:i.message,variant:"destructive"}),null}finally{s(!1)}},isUploading:e}},LX=[{src:"/lovable-uploads/0ee7cdb0-f6e6-4dd5-9492-8136e247b6ab.png",alt:"Discover Magazine - Winchester & Surrounds Edition",issueMonth:"January 2025",link:null},{src:"/lovable-uploads/3734fd45-4163-4f5c-b495-06604192d54c.png",alt:"Discover Magazine - Itchen Valley Edition",issueMonth:"January 2025",link:null},{src:"/lovable-uploads/c4490b9b-94ad-42c9-a7d4-80ba8a52d3eb.png",alt:"Discover Magazine - Meon Valley & Whiteley Edition",issueMonth:"January 2025",link:null},{src:"/lovable-uploads/d554421b-d268-40db-8d87-a66cd858a71a.png",alt:"Discover Magazine - New Forest & Waterside Edition",issueMonth:"January 2025",link:null},{src:"/lovable-uploads/92f70bb1-98a7-464d-a511-5eb7eef51998.png",alt:"Discover Magazine - Southampton West & Totton Edition",issueMonth:"January 2025",link:null},{src:"/lovable-uploads/25b8b054-62d4-42b8-858b-d8c91da6dc93.png",alt:"Discover Magazine - Test Valley & Romsey Edition",issueMonth:"January 2025",link:null},{src:"/lovable-uploads/f98d0aa9-985f-4d69-85b9-193bf1934a18.png",alt:"Discover Magazine - Winchester & Alresford Edition",issueMonth:"January 2025",link:null},{src:"/lovable-uploads/d4b20a63-65ea-4dec-b4b7-f1e1a6748979.png",alt:"Discover Magazine - Chandler's Ford & Eastleigh Edition",issueMonth:"January 2025",link:null}],BX=()=>{const e=ds(),{data:s,isLoading:r}=Fv(!1,"front_cover"),n=s!=null&&s.length?s.map(a=>({src:a.image_url,alt:a.alt_text||`Discover Magazine - ${a.title} Edition`,issueMonth:a.issue_month||"Current Edition",link:a.link_url})):LX;return t.jsxs("div",{className:"min-h-screen",children:[t.jsx(gs,{}),t.jsxs("main",{children:[t.jsxs("section",{className:"py-12 md:py-20 bg-gradient-to-b from-gray-900 via-slate-800 to-gray-900 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[linear-gradient(45deg,transparent_25%,rgba(0,255,255,0.03)_50%,transparent_75%,transparent_100%)] bg-[length:30px_30px] animate-pulse"}),t.jsx("div",{className:"absolute top-0 left-0 w-48 md:w-96 h-48 md:h-96 bg-community-green/10 rounded-full blur-3xl"}),t.jsx("div",{className:"absolute bottom-0 right-0 w-48 md:w-96 h-48 md:h-96 bg-community-navy/2
7410 rounded-full blur-3xl"}),t.jsxs("div",{className:"relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"text-center mb-8 md:mb-12",children:[t.jsx("h2",{className:"text-2xl md:text-4xl lg:text-5xl font-heading font-bold text-white mb-3 md:mb-4",children:"South Hampshire's Biggest, Little & Best Local Magazine"}),t.jsx("p",{className:"text-base md:text-xl text-gray-300 max-w-2xl mx-auto",children:"A collection of localised editions delivered to 142,000 letterboxes in SO & PO postcodes. Loved by residents since 2005 and continuing to serve businesses with a cost effective advertising platform."})]}),t.jsxs("div",{className:"relative",children:[t.jsxs(Lu,{opts:{align:"start",loop:!0},className:"w-full max-w-5xl mx-auto",children:[t.jsx(Bu,{className:"-ml-3 md:-ml-6",children:n.map((a,i)=>{const o=a.link?"a":"div",l=a.link?{href:a.link,target:"_blank",rel:"noopener noreferrer"}:{};return t.jsx(zu,{className:"pl-3 md:pl-6 basis-[85%] md:basis-1/2 lg:basis-1/3",children:t.jsx(o,{...l,className:a.link?"cursor-pointer block":"",children:t.jsx(xe,{className:"group relative overflow-hidden bg-white/5 backdrop-blur border border-white/10 hover:border-community-green/50 transition-all duration-500 hover:scale-105 hover:shadow-2xl hover:shadow-community-green/20",children:t.jsxs(ge,{className:"p-4 md:p-6",children:[t.jsxs("div",{className:"relative overflow-hidden rounded-lg",children:[t.jsx("img",{src:a.src,alt:a.alt,className:"w-full h-64 md:h-80 lg:h-96 object-contain transition-transform duration-700 group-hover:scale-110"}),t.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/60 via-trans
741parent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500"})]}),t.jsx("div",{className:"absolute inset-0 rounded-lg border border-community-green/20 opacity-0 group-hover:opacity-100 transition-opacity duration-500"})]})})})},i)})}),t.jsx(Uu,{className:"left-2 md:-left-4 lg:-left-16 h-10 w-10 md:h-12 md:w-12 bg-white/10 backdrop-blur border-white/20 text-white hover:bg-community-green hover:border-community-green transition-all duration-300"}),t.jsx(Vu,{className:"right-2 md:-right-4 lg:-right-16 h-10 w-10 md:h-12 md:w-12 bg-white/10 backdrop-blur border-white/20 text-white hover:bg-community-green hover:border-community-green transition-all duration-300"})]}),t.jsx("p",{className:"text-center text-xs text-gray-400 mt-4 md:hidden",children:"Swipe to explore editions"})]}),t.jsx("div",{className:"text-center mt-8 md:mt-12",children:t.jsxs("div",{className:"inline-flex flex-col sm:flex-row gap-3 md:gap-4",children:[t.jsx(q,{className:"bg-community-green hover:bg-community-green/90 text-white px-6 md:px-8 py-3 font-bold rounded-full border border-community-green/20 hover:shadow-lg hover:shadow-community-green/30 transition-all duration-300 min-h-[44px]",onClick:()=>e("/advertising"),children:"ADVERTISING INFO"}),t.jsx(q,{asChild:!0,variant:"outline",className:"border-white/30 hover:bg-white px-6 md:px-8 py-3 font-bold rounded-full backdrop-blur transition-all duration-300 text-slate-950 min-h-[44px]",children:t.jsx("a",{href:"/contact",children:"CONTACT US"})})]})})]})]}),t.jsx(KQ,{}),t.jsx("div",{id:"news",children:t.jsx(PX,{})}),t.jsx(DX,{}),t.jsx("div",{className:"hidden md:block",children:t.jsx(EX,{})}),t.jsx(OX,{})]}),t.jsx(vs,{})]})};var Q2="Tabs",[zX,bfe]=hr(Q2,[Iu]),$A=Iu(),[UX,X2]=zX(Q2),EA=u.forwardRef((e,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:l,activationMode:c="automatic",...d}=e,m=to(l),[h,f]=wr({prop:n,onChange:a,defaultProp:i});return t.jsx(UX,{scope:r,baseId:Lr(),value:h,onValueChange:f,orientation:o,dir:m,activationMode:c,children:t.jsx(ze.div,{dir:m,"data-orientation":o,...d,ref:s})})});EA.displayName=Q2;var PA="TabsList",AA=u.forwardRef((e,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=e,i=X2(PA,r),o=$A(r);return t.jsx(_2,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:n,children:t.jsx(ze.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:s})})});AA.displayName=PA;var TA="TabsTrigger",DA=u.forwardRef((e,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...i}=e,o=X2(TA,r),l=$A(r),c=OA(o.baseId,n),d=IA(o.baseId,n),m=n===o.value;return t.jsx(S2,{asChild:!0,...l,focusable:!a,active:m,children:t.jsx(ze.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":d,"data-state":m?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:c,...i,ref:s,onMouseDown:Se(e.onMouseDown,h=>{!a&&h.button===0&&h.ctrlKey===!1?o.onValueChange(n):h.preventDefault()}),onKeyDown:Se(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&o.onValueChange(n)}),onFocus:Se(e.onFocus,()=>{const h=o.activationMode!=="manual";!m&&!a&&h&&o.onValueChange(n)})})})});DA.displayName=TA;var RA="TabsContent",MA=u.forwardRef((e,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:i,...o}=e,l=X2(RA,r),c=OA(l.baseId,n),d=IA(l.baseId,n),m=n===l.value,h=u.useRef(m);return u.useEffect(()=>{const f=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(f)},[]),t.jsx(Ts,{present:a||m,children:({present:f})=>t.jsx(ze.div,{"data-state":m?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!f,id:d,tabIndex:0,...o,ref:s,style:{...e.style,animationDuration:h.current?"0s":void 0},children:f&&i})})});MA.displayName=RA;function OA(e,s){return`${e}-trigger-${s}`}function IA(e,s){return`${e}-content-${s}`}var VX=EA,FA=AA,LA=DA,BA=MA;const ha=VX,Hn=u.forwardRef(({className:e,...s},r)=>t.jsx(FA,{ref:r,className:oe("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...s}));Hn.displayName=FA.displayName;const Rt=u.forwardRef(({className:e,...s},r)=>t.jsx(LA,{ref:r,className:oe("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...s}));Rt.displayName=LA.displayName;const Mt=u.forwardRef(({className:e,...s},r)=>t.jsx(BA,{ref:r,className:oe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...s}));Mt.displayName=BA.displayName;const qX=({open:e,onOpenChange:s,onSuccess:r})=>{const[n,a]=u.useState(""),[i,o]=u.useState(""),[l,c]=u.useState(""),[d,m]=u.useState(""),[h,f]=u.useState(!1),[p,x]=u.useState("register"),{signIn:g,signUp:b}=Ar(),w=()=>{a(""),o(""),c(""),m("")},j=async v=>{if(v.preventDefault(),!n||!i){Ks({title:"Missing Fields",description:"Please enter your email and password.",variant:"destructive"});return}f(!0);try{const{error:N}=await g(n,i);if(N)throw N;w(),s(!1),r&&r()}catch(N){console.error("Sign in error:",N),Ks({title:"Sign In Failed",description:N.message||"Invalid email or password. Please try again.",variant:"destructive"})}finally{f(!1)}},y=async v=>{if(v.preventDefault(),!n||!i){Ks({title:"Missing Fields",description:"Please enter your email and password.",variant:"destructive"});return}if(i.length<6){Ks({title:"Password Too Short",description:"Password must be at least 6 characters.",variant:"destructive"});return}if(i!==l){Ks({title:"Passwords Don't Match",description:"Please ensure both passwords are the same.",variant:"destructive"});return}f(!0);try{const{error:N,needsConfirmation:S}=await b(n,i,{displayName:d||n.split("@")[0],redirectPath:"/dashboard"});if(N)throw N;w(),s(!1),!S&&r&&r()}catch(N){console.error("Registration error:",N),Ks({title:"Registration Failed",description:N.message||"Unable to create account. Please try again.",variant:"destructive"})}finally{f(!1)}};return t.jsx(bt,{open:e,onOpenChange:s,children:t.jsxs(xt,{className:"sm:max-w-md max-h-[90vh] overflow-y-auto",children:[t.jsxs(jt,{className:"text-center pb-4",children:[t.jsx("div",{className:"flex justify-center mb-4",children:t.jsx("div",{className:"p-3 bg-primary/10 rounded-lg",children:t.jsx(qx,{className:"h-8 w-8 text-primary"})})}),t.jsx(wt,{className:"text-2xl font-heading",children:"Add Your Business"}),t.jsx(ys,{className:"text-base",children:"Create a free account to list your business in our local community directory."})]}),t.jsxs(ha,{value:p,onValueChange:v=>x(v),className:"w-full",children:[t.jsxs(Hn,{className:"grid w-full grid-cols-2",children:[t.jsx(Rt,{value:"signin",children:"Sign In"}),t.jsx(Rt,{value:"register",children:"Register"})]}
741),t.jsx(Mt,{value:"signin",className:"space-y-4 mt-4",children:t.jsxs("form",{onSubmit:j,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"business-signin-email",children:"Email"}),t.jsx(re,{id:"business-signin-email",type:"email",placeholder:"[email protected]",value:n,onChange:v=>a(v.target.value),disabled:h})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"business-signin-password",children:"Password"}),t.jsx(re,{id:"business-signin-password",type:"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",value:i,onChange:v=>o(v.target.value),disabled:h})]}),t.jsx(q,{type:"submit",className:"w-full",disabled:h,children:h?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing in..."]}):"Sign In"})]})}),t.jsx(Mt,{value:"register",className:"space-y-4 mt-4",children:t.jsxs("form",{onSubmit:y,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"business-register-name",children:"Your Name (optional)"}),t.jsx(re,{id:"business-register-name",type:"text",placeholder:"Your name",value:d,onChange:v=>m(v.target.value),disabled:h})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"business-register-email",children:"Email"}),t.jsx(re,{id:"business-register-email",type:"email",placeholder:"[email protected]",value:n,onChange:v=>a(v.target.value),disabled:h})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"business-register-password",children:"Password"}),t.jsx(re,{id:"business-register-password",type:"password",placeholder:"Min. 6 characters",value:i,onChange:v=>o(v.target.value),disabled:h})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"business-register-confirm",children:"Confirm Password"}),t.jsx(re,{id:"business-register-confirm",type:"password",placeholder:"Confirm your password",value:l,onChange:v=>c(v.target.value),disabled:h})]}),t.jsx(q,{type:"submit",className:"w-full",disabled:h,children:h?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating account..."]}):"Create Free Account"})]})})]}),t.jsxs("div",{className:"mt-6 pt-4 border-t",children:[t.jsx("p",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Why list your business?"}),t.jsxs("ul",{className:"space-y-2",children:[t.jsxs("li",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(xs,{className:"h-4 w-4 text-primary"}),"Free listing in our local directory"]}),t.jsxs("li",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(xs,{className:"h-4 w-4 text-primary"}),"Reach customers across SO & PO postcodes"]}),t.jsxs("li",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(xs,{className:"h-4 w-4 text-primary"}),"Update your listing anytime"]})]})]})]})})};function Rj(e){return(e||"").toUpperCase().replace(/[^A-Z0-9]/g,"")}function HX(e){const s=Rj(e);if(!s)return"";const r=s.match(/^([A-Z]{1,2}\d[A-Z\d]?)\d[A-Z]{2}$/);if(r)return r[1];const n=s.match(/^([A-Z]{1,2}\d{0,2}[A-Z]?)/);return n?n[1]:s}function WX(e,s){const r=Rj(e),n=Rj(s);if(!n)return!0;const a=HX(n);return a&&(r===a||r.startsWith(a)||a.startsWith(r))?!0:r.startsWith(n)}function GX({value:e,onChange:s,className:r}){const[n,a]=u.useState([]),[i,o]=u.useState(!1),[l,c]=u.useState(""),d=u.useRef(null);u.useEffect(()=>{let f=!1;return(async()=>{const{data:p,error:x}=await W.rpc("get_directory_postcodes");f||x||!p||a(p.map(g=>
741g.postcode).filter(Boolean))})(),()=>{f=!0}},[]),u.useEffect(()=>{const f=p=>{d.current&&!d.current.contains(p.target)&&o(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const m=u.useMemo(()=>n.filter(f=>WX(f,l)),[n,l]),h=f=>{s(f),c(""),o(!1)};return t.jsxs("div",{ref:d,className:oe("relative",r),children:[t.jsxs("div",{className:"flex items-center gap-2 h-14 rounded-md bg-background border border-input px-3 cursor-text",onClick:()=>o(!0),children:[t.jsx(_t,{className:"h-5 w-5 text-muted-foreground flex-shrink-0"}),t.jsx(re,{value:i?l:e,onChange:f=>{c(f.target.value),o(!0)},onFocus:()=>o(!0),placeholder:e||"Your postcode","aria-label":"Your postcode",className:"border-0 shadow-none focus-visible:ring-0 px-0 h-auto text-base text-foreground"}),t.jsx(Ma,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"})]}),i&&t.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-72 overflow-y-auto rounded-md border border-border bg-popover shadow-lg",children:m.length===0?t.jsx("p",{className:"px-3 py-3 text-sm text-muted-foreground",children:"No matching postcodes in our distribution areas"}):m.map(f=>t.jsxs("button",{type:"button",onClick:()=>h(f),className:"w-full flex items-center justify-between px-3 py-2 text-left text-sm text-popover-foreground hover:bg-accent",children:[t.jsx("span",{children:f}),e===f&&t.jsx(Bs,{className:"h-4 w-4 text-community-green"})]},f))})]})}function YX({value:e,onChange:s,postcode:r,className:n}){const[a,i]=u.useState([]),[o,l]=u.useState(!1),[c,d]=u.useState(!1),m=u.useRef(null),h=u.useRef(!1);u.useEffect(()=>{const x=g=>{m.current&&!m.current.contains(g.target)&&l(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]),u.useEffect(()=>{if(h.current){h.current=!1;return}const x=e.trim();if(x.length<2){i([]),d(!1);return}let g=!1;const b=setTimeout(async()=>{const{data:w,error:j}=await W.rpc("suggest_directory_keywords",{search_term:x,postcode:r||null,limit_count:8});if(g)return;const y=j||!w?[]:w.slice(0,8);i(y.filter(v=>v.kind==="keyword")),d(!0)},250);return()=>{g=!0,clearTimeout(b)}},[e,r]);const f=x=>{h.current=!0,s(x),l(!1)},p=o&&e.trim().length>=2&&c;return t.jsxs("div",{ref:m,className:oe("relative",n),children:[t.jsx(Ur,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground h-5 w-5 pointer-events-none"}),t.jsx(re,{type:"text",value:e,onChange:x=>{s(x.target.value),l(!0)},onFocus:()=>l(!0),placeholder:"Search by keyword","aria-label":"Search keyword",className:"pl-10 h-14 text-base bg-background text-foreground"}),p&&t.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-80 overflow-y-auto rounded-md border border-border bg-popover shadow-lg",children:a.length===0?t.jsx("p",{className:"px-3 py-3 text-sm text-muted-foreground",children:"No matching keywords"}):a.map(x=>t.jsxs("button",{type:"button",onClick:()=>f(x.suggestion),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-accent",children:[t.jsx(fc,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"flex-1 truncate text-sm text-popover-foreground",children:x.suggestion})]},`keyword-${x.suggestion}`))})]})}function KX({value:e,onChange:s,className:r}){const[n,a]=u.useState([]),[i,o]=u.useState(!1),[l,c]=u.useState(!1),d=u.useRef(null),m=u.useRef(!1);u.useEffect(()=>{const p=x=>{d.current&&!d.current.contains(x.target)&&o(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[]),u.useEffect(()=>{if(m.current){m.current=!1;return}const p=e.trim();if(p.length<2){a([]),c(!1);return}let x=!1;const g=setTimeout(async()=>{const{data:b,error:w}=await W.rpc("suggest_directory_business_names",{search_term:p,limit_count:8});x||(a(w||!b?[]:b.slice(0,8)),c(!0))},250);return()=>{x=!0,clearTimeout(g)}},[e]);const h=p=>{m.current=!0,s(p),o(!1)},f=i&&e.trim().length>=2&&l;return t.jsxs("div",{ref:d,className:oe("relative",r),children:[t.jsx(Ur,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground h-5 w-5 pointer-events-none"}
741),t.jsx(re,{type:"text",value:e,onChange:p=>{s(p.target.value),o(!0)},onFocus:()=>o(!0),placeholder:"Business name","aria-label":"Search business name",className:"pl-10 h-14 text-base bg-background text-foreground"}),f&&t.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-80 overflow-y-auto rounded-md border border-border bg-popover shadow-lg",children:n.length===0?t.jsx("p",{className:"px-3 py-3 text-sm text-muted-foreground",children:"No matching businesses"}):n.map(p=>t.jsxs("button",{type:"button",onClick:()=>h(p.suggestion),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-accent",children:[t.jsx(Xr,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"flex-1 truncate text-sm font-medium text-popover-foreground",children:p.suggestion})]},`business-${p.suggestion}`))})]})}function QX({mode:e,onModeChange:s,keyword:r,onKeywordChange:n,postcode:a,onPostcodeChange:i,businessName:o,onBusinessNameChange:l,onSearch:c,onNewSearch:d,hasResults:m=!1,isDirty:h=!1}){const f=e==="keyword",p=r.trim().length>0,x=o.trim().length>0,g=f?p&&!!a:x,b=f?!p&&!a?"Enter a keyword and choose your postcode to search.":p?a?"":"Choose your postcode to search.":"Add a keyword to search.":x?"":"Enter a business name to search.";return t.jsxs("section",{className:"relative bg-community-navy text-white overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 opacity-30 pointer-events-none",style:{backgroundImage:"radial-gradient(ellipse 80% 50% at 30% 20%, hsl(15 80% 50% / 0.4), transparent 60%)"}}),t.jsxs("div",{className:"relative max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-12 md:py-20",children:[t.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full border border-orange-400/40 text-orange-300 text-xs font-semibold uppercase tracking-wider mb-6",children:[t.jsx(_t,{className:"h-3 w-3"}),"Discover Directory"]}),t.jsxs("h1",{className:"font-heading text-4xl md:text-5xl lg:text-6xl leading-tight mb-4",children:["Find a local business in ",t.jsx("span",{className:"italic text-orange-300",children:"your area."})]}),t.jsx("p",{className:"text-white/70 text-base md:text-lg max-w-2xl mb-8",children:"Search by keyword and postcode, or find a business directly by name."}),t.jsxs("div",{className:"flex gap-2 mb-3",children:[t.jsx("button",{type:"button",onClick:()=>s("keyword"),className:oe("px-4 py-2 rounded-full text-sm font-medium transition-colors",f?"bg-orange-500 text-white":"bg-white/10 text-white/80 hover:bg-white/20"),children:"Find by keyword"}),t.jsx("button",{type:"button",onClick:()=>s("business"),className:oe("px-4 py-2 rounded-full text-sm font-medium transition-colors",f?"bg-white/10 text-white/80 hover:bg-white/20":"bg-orange-500 text-white"),children:"Find by business name"})]}),t.jsxs("form",{onSubmit:w=>{w.preventDefault(),g&&c()},className:"flex flex-col md:flex-row gap-3 max-w-4xl",children:[f?t.jsxs(t.Fragment,{children:[t.jsx(YX,{className:"flex-1",value:r,onChange:n,postcode:a}),t.jsx(GX,{className:"w-full md:w-64",value:a,onChange:i})]}):t.jsx(KX,{className:"flex-1",value:o,onChange:l}),t.jsx(q,{type:"submit",size:"lg",disabled:!g,className:"h-14 px-8 bg-orange-500 hover:bg-orange-600 text-white disabled:opacity-60",children:h?t.jsxs(t.Fragment,{children:[t.jsx(kw,{className:"h-5 w-5 mr-2"})," Update search"]}):t.jsxs(t.Fragment,{children:[t.jsx(Ur,{className:"h-5 w-5 mr-2"})," Search"]})})]}),t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 mt-3",children:[t.jsx("p",{className:"text-white/60 text-xs",children:b||(h?"You've changed your search â click Update search to see new results.":m?"Showing results for your current search.":"Press Search to see matching businesses.")}),m&&d&&t.jsx("button",{type:"button",onClick:d,className:"text-left sm:text-right text-xs text-orange-300 hover:text-orange-200 underline underline-offset-2",children:"New search"})]})]})]})}const Z2={Target:rv,Star:mr,MapPin:_t,Heart:Nw,Calendar:It,Clock:ws,FileText:ir,Package:_f,ShoppingCart:uE,Zap:xL,TrendingUp:jh,Award:sE,Gift:yr,Sparkles:ui,Rocket:dL},XX=Object.keys(Z2),Mj=e=>Z2[e]||rv;function ZX(e,s=128){if(!e)return null;try{const r=e.startsWith("http")?e:`https://${e}`,n=new URL(r).hostname.replace(/^www\./,"");if(!n)return null;const a=Math.min(256,Math.max(s,256));return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(n)}&sz=${a}`}catch{return null}}function JX(e,s=128){return e?e.logo_url?e.logo_url:ZX(e.website,s):null}const eZ=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Op(e){if(!e)return null;const r=e.trim().toLowerCase().replace(/\s+/g,"").match(/^(\d{1,2})(?::(\d{2}))?(am|pm)?$/);if(!r)return null;let n=parseInt(r[1],10);const a=r[2]?parseInt(r[2],10):0,i=r[3];return i==="pm"&&n<12&&(n+=12),i==="am"&&n===12&&(n=0),n*60+a}function tZ(e,s=new Date){var i;if(!e||typeof e!="object")return!1;const r=eZ[s.getDay()],n=e[r]??e[(i=r==null?void 0:r.toUpperCase)==null?void 0:i.call(r)];if(!n)return!1;const a=s.getHours()*60+s.getMinutes();if(typeof n=="string"){const o=n.trim().toLowerCase();if(!o||o.includes("closed"))return!1;const l=o.split(/[-ââto]+/).map(m=>
741m.trim()).filter(Boolean);if(l.length!==2)return!1;const c=Op(l[0]),d=Op(l[1]);return c==null||d==null?!1:a>=c&&a<d}if(typeof n=="object"){if(n.closed)return!1;const o=Op(n.open||n.from||""),l=Op(n.close||n.to||"");return o==null||l==null?!1:a>=o&&a<l}return!1}function sZ(e){return[e.address_line1,e.address_line2,e.city,e.postcode].filter(s=>s&&String(s).trim().length>0).join(", ")}function J2({business:e,size:s=64,className:r}){var l;const[n,a]=u.useState(!1),i=n?null:JX(e,Math.max(s*2,256)),o=Z2[((l=e==null?void 0:e.business_categories)==null?void 0:l.icon)||""]||Xr;return t.jsx("div",{className:oe("flex-shrink-0 rounded-xl bg-muted flex items-center justify-center overflow-hidden border border-border/50",r),style:{width:s,height:s},children:i?t.jsx("img",{src:i,alt:e!=null&&e.name?`${e.name} logo`:"Business logo",onError:()=>a(!0),loading:"eager",className:"w-full h-full object-contain p-1"}):t.jsx(o,{className:"w-1/2 h-1/2 text-muted-foreground",strokeWidth:1.5})})}const rZ=1,nZ="17b71783-3a89-4154-a6c7-d094c7d83d27",aZ="ef3dec02-9a74-46ea-a941-0b415710729a",iZ="/__l5e/assets-v1/17b71783-3a89-4154-a6c7-d094c7d83d27/checkatrade.png",oZ="a/v1/ef3dec02-9a74-46ea-a941-0b415710729a/17b71783-3a89-4154-a6c7-d094c7d83d27/checkatrade.png",lZ="checkatrade.png",cZ=6087,dZ="image/png",uZ="2026-08-10T10:00:03Z",mZ={version:rZ,asset_id:nZ,project_id:aZ,url:iZ,r2_key:oZ,original_filename:lZ,size:cZ,content_type:dZ,created_at:uZ},hZ=({className:e})=>t.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:e,children:t.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),fZ=({className:e})=>t.jsx("img",{src:mZ.url,alt:"","aria-hidden":"true",className:e}),pZ=e=>e.startsWith("http")?e:`https://${e}`,zA=e=>[{key:"facebook",label:"Facebook",url:e.facebook_url,Icon:aE,brand:!1},{key:"instagram",label:"Instagram",url:e.instagram_url,Icon:lE,brand:!1},{key:"twitter",label:"X",url:e.twitter_url,Icon:hZ,brand:!1},{key:"linkedin",label:"LinkedIn",url:e.linkedin_url,Icon:cE,brand:!1},{key:"tiktok",label:"TikTok",url:e.tiktok_url,Icon:aL,brand:!1},{key:"youtube",label:"YouTube",url:e.youtube_url,Icon:hE,brand:!1},{key:"checkatrade",label:"Checkatrade",url:e.checkatrade_url,Icon:fZ,brand:!0}].filter(s=>!!s.url&&String(s.url).trim().length>0);function UA({business:e,size:s="md",className:r=""}){const n=zA(e);if(n.length===0)return null;const a=s==="sm"?"h-8 w-8":"h-9 w-9",i=s==="sm"?"h-3.5 w-3.5":"h-4 w-4",o=s==="sm"?"h-4 w-4":"h-5 w-5";return t.jsx("div",{className:`flex flex-wrap items-center gap-2 ${r}`,children:n.map(({key:l,label:c,url:d,Icon:m,brand:h})=>t.jsx("a",{href:pZ(d),target:"_blank",rel:"noreferrer","aria-label":c,title:c,onClick:f=>f.stopPropagation(),className:h?`inline-flex ${a} items-center justify-center rounded-full border border-community-teal/25 bg-background hover:border-community-teal transition-colors`:`inline-flex ${a} items-center justify-center rounded-full border border-community-teal/25 text-community-teal hover:bg-community-teal hover:text-background transition-colors`,children:t.jsx(m,{className:h?`${o} object-contain`:i})},l))})}const eN=[{value:"mobile",label:"Mobile"},{value:"limited",label:"Limited"},{value:"family_run",label:"Family Run"},{value:"owner_run",label:"Owner Run"},{value:"national",label:"National"},{value:"regional",label:"Regional"},{value:"local",label:"Local"},{value:"commercial",label:"Commercial only"}];Object.fromEntries(eN.map(e=>[e.value,e.label]));const xZ=e=>eN.filter(s=>(e||[]).includes(s.value)).map(s=>s.label);function tN({tags:e,className:s=""}){const r=xZ(e);return r.length===0?null:t.jsx("div",{className:`flex flex-wrap gap-1.5 ${s}`,children:r.map(n=>t.jsx("span",{className:"inline-flex items-center rounded-full bg-muted px-2.5 py-0.5 text-xs font-medium text-muted-foreground border border-border",children:n},n))})}const sN=e=>[e.city,e.postcode_out].filter(s=>s&&String(s).trim()).join(", "),rN=e=>(e||"").replace(/^https?:\/\//,"").replace(/\/$/,""),gZ=(e,s=160)=>e.length<=s?e:`${e.slice(0,s).trimEnd()}â¦`;function vZ({business:e}){var l;const s=ds(),r=`/business/${e.slug||e.id}`,n=sN(e),a=(l=e.description)==null?void 0:l.trim(),i=(e.images||[]).filter(
741Boolean)[0]||e.featured_image_url||null,o=(e.name||"?").trim().charAt(0).toUpperCase();return t.jsxs("article",{onClick:()=>s(r),className:"cursor-pointer group rounded-2xl border-2 border-orange-200 bg-card shadow-sm hover:shadow-xl hover:-translate-y-0.5 transition-all duration-300 flex flex-col overflow-hidden",children:[t.jsxs("div",{className:`relative overflow-hidden bg-[hsl(40,40%,95%)] ${i?"aspect-[16/9]":"aspect-[24/7]"}`,children:[i?t.jsx("img",{src:i,alt:`${e.name} photo`,loading:"lazy",onError:c=>{c.currentTarget.style.visibility="hidden"},className:"absolute inset-0 h-full w-full object-cover transition-transform duration-500 group-hover:scale-[1.03]"}):e.logo_url?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gradient-to-br from-[hsl(40,45%,96%)] to-[hsl(24,60%,92%)]",children:t.jsx("img",{src:e.logo_url,alt:`${e.name} logo`,loading:"lazy",className:"max-h-[60%] max-w-[70%] object-contain"})}):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gradient-to-br from-[hsl(40,45%,96%)] to-[hsl(24,60%,92%)]",children:t.jsx("span",{className:"font-heading text-6xl text-orange-300 select-none",children:o})}),i&&t.jsx("div",{className:"absolute inset-x-0 bottom-0 h-24 bg-gradient-to-t from-black/55 to-transparent"}),t.jsxs("span",{className:`absolute top-3 left-3 inline-flex items-center gap-1 text-[10px] uppercase tracking-wider font-bold rounded-full px-2.5 py-1 ${i?"text-white bg-black/55 backdrop-blur-sm":"text-orange-700 bg-orange-100 border border-orange-200"}`,children:[t.jsx(mr,{className:"h-3 w-3 fill-current"})," Featured"]})]}),t.jsxs("div",{className:"relative px-6 pb-5 flex-1",children:[i&&t.jsx("div",{className:"absolute -top-8 left-6 rounded-xl bg-card shadow-md ring-1 ring-border p-1.5",children:t.jsx(J2,{business:e,size:56})}),t.jsxs("div",{className:i?"pt-11":"pt-5",children:[t.jsx("h3",{className:"font-heading text-2xl leading-tight line-clamp-2",children:e.name}),n&&t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:n}),a&&t.jsx("p",{className:"text-sm text-muted-foreground mt-3 line-clamp-2",children:gZ(a,180)}),e.website&&t.jsxs("div",{className:"flex items-center gap-2 text-sm mt-3",children:[t.jsx(Tc,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"truncate text-orange-600",children:rN(e.website)})]}),t.jsx(tN,{tags:e.operating_tags,className:"mt-3"}),t.jsx(UA,{business:e,size:"sm",className:"mt-4"})]})]}),t.jsxs("div",{className:"px-6 py-4 border-t flex items-center justify-between gap-3",children:[e.advertises_in_discover?t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-orange-700/80 truncate",children:[t.jsx("img",{src:"/favicon.svg",alt:"Discover Magazine",className:"h-4 w-4 object-contain flex-shrink-0"}),"Advertises in Discover"]}):t.jsx("span",{}),t.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-orange-600 font-semibold group-hover:gap-2 transition-all flex-shrink-0",children:["View listing ",t.jsx(jf,{className:"h-4 w-4"})]})]})]})}function yZ({business:e}){const s=ds(),r=`/business/${e.slug||e.id}`,n=sN(e);return t.jsxs("article",{onClick:()=>s(r),className:"cursor-pointer group rounded-2xl border border-border bg-card hover:shadow-md transition-shadow flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"p-5 flex gap-4 items-start",children:[t.jsx(J2,{business:e,size:56}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"font-heading text-xl leading-tight line-clamp-2",children:e.name}),n&&t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:n})]})]}),t.jsxs("div",{className:"px-5 pb-5 flex-1",children:[e.website&&t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx(Tc,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"truncate text-orange-600",children:rN(e.website)})]}),t.jsx(tN,{tags:e.operating_tags,className:"mt-3"})]}),t.jsxs("div",{className:"px-5 py-3 border-t flex items-center justify-between",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-community-green/10 text-community-green border border-community-green/30",children:[t.jsx(sv,{className:"h-3.5 w-3.5"})," Verified listing"]}),t.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-orange-600 font-medium group-hover:gap-2 transition-all",children:["View ",t.jsx(jf,{className:"h-4 w-4"})]})]})]})}function bZ({business:e}){const s=ds(),r=`/business/${e.slug||e.id}`,n=sN(e);return t.jsxs("article",{onClick:()=>s(r),className:"cursor-pointer group rounded-2xl border border-border bg-card p-5 hover:shadow-md transition-shadow flex flex-col gap-2",children:[t.jsx("h3",{className:"font-heading text-xl leading-tight line-clamp-2",children:e.name}),n&&t.jsx("p",{className:"text-sm text-muted-foreground",children:n}),e.website&&t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx(Tc,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"truncate text-orange-600",children:rN(e.website)})]}),t.jsxs("span",{className:"mt-auto pt-3 inline-flex items-center gap-1 text-sm text-orange-600 font-medium group-hover:gap-2 transition-all",children:["View ",t.jsx(jf,{className:"h-4 w-4"})]})]})}const jZ=["featured","verified","recent"],wZ={featured:{label:"Featured",note:"Businesses advertising with Discover Magazines",cols:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3"},verified:{label:"Verified",note:"Owners have claimed and confirmed these listings",cols:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3"},recent:{label:"More local listings",note:"Not yet claimed by their owners",cols:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3"}},NZ=e=>{const s=(e.tier||"").toLowerCase();return s==="featured"||s==="verified"||s==="recent"?s:e.featured?"featured":e.is_verified?"verified":"recent"};function _Z({businesses:e}){return t.jsx("div",{className:"space-y-10",children:jZ.map(s=>{const r=e.filter(a=>NZ(a)===s);if(r.length===0)return null;const n=wZ[s];return t.jsx(u.Fragment,{children:t.jsxs("div",{children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 pb-3 mb-5 border-b border-border",children:[t.jsx("h3",{className:"font-heading text-xl",children:n.label}),n.note&&t.jsx("p",{className:"text-sm text-muted-foreground",children:n.note}),t.jsx("span",{className:"ml-auto text-sm text-muted-foreground",children:r.length})]}),t.jsx("div",{className:`grid gap-4 md:gap-6 ${n.cols}`,children:r.map(a=>s==="featured"?t.jsx(vZ,{business:a},a.id):s==="verified"?t.jsx(yZ,{business:a},a.id):t.jsx(bZ,{business:a},a.id))})]})},s)})})}
741const Oj="directory:lastSearch",VA=e=>{try{e?sessionStorage.setItem(Oj,e.replace(/^\?/,"")):sessionStorage.removeItem(Oj)}catch{}},SZ=()=>VA(""),CZ=()=>{try{const e=sessionStorage.getItem(Oj);return e?`/business-directory?${e}`:"/business-directory"}catch{return"/business-directory"}},Sl=60,kZ=()=>{var z,Z,M;const e=ds(),s=Va(),{user:r}=Ar(),[n,a]=Hw(),i=n.get("mode")==="business"?"business":"keyword",o=((z=n.get("q"))==null?void 0:z.trim())||"",l=((Z=n.get("pc"))==null?void 0:Z.trim())||"",c=((M=n.get("name"))==null?void 0:M.trim())||"",d=parseInt(n.get("page")||"1",10),m=Number.isFinite(d)&&d>=1?d:1,h=u.useMemo(()=>i==="keyword"?o&&l?{mode:"keyword",keyword:o,postcode:l}:null:c?{mode:"business",name:c}:null,[i,o,l,c]),[f,p]=u.useState(i),[x,g]=u.useState(o),[b,w]=u.useState(l),[j,y]=u.useState(c),[v,N]=u.useState([]),[S,k]=u.useState(0),[$,R]=u.useState(!1),[A,T]=u.useState(!1),[P,B]=u.useState(!1),Y=u.useRef(0),I=Math.ceil(S/Sl),C=!!h&&(h.mode!==f||h.mode==="keyword"&&(x.trim()!==h.keyword||b!==h.postcode)||h.mode==="business"&&j.trim()!==h.name);u.useEffect(()=>{p(i),g(o),w(l),y(c)},[i,o,l,c]),u.useEffect(()=>{h?VA(n.toString()):SZ()},[h,n]);const L=()=>{a({mode:f},{replace:!0}),N([]),k(0),T(!1)},D=u.useCallback(async(F,ee)=>{const se=++Y.current;R(!0),T(!1);try{let le,X;if(F.mode==="keyword"?[le,X]=await Promise.all([W.rpc("get_public_businesses_count_v2",{keyword:F.keyword,postcode:F.postcode}),W.rpc("get_public_businesses_v2",{keyword:F.keyword,postcode:F.postcode,limit_count:Sl,offset_count:(ee-1)*Sl})]):[le,X]=await Promise.all([W.rpc("get_public_businesses_by_name_count_v2",{name:F.name}),W.rpc("get_public_businesses_by_name_v2",{name:F.name,limit_count:Sl,offset_count:(ee-1)*Sl})]),se!==Y.current)return;if(le.error||X.error){console.error("Directory search failed",le.error||X.error),T(!0),N([]),k(0);return}k(le.data||0),N(X.data||[])}catch(le){console.error("Directory search failed",le),se===Y.current&&(T(!0),N([]),k(0))}finally{se===Y.current&&R(!1)}},[]);u.useEffect(()=>{h&&D(h,m)},[h,m,D]);const _=()=>{if(f==="keyword"){if(!x.trim()||!b)return;a({mode:"keyword",q:x.trim(),pc:b,page:"1"})}else{if(!j.trim())return;a({mode:"business",name:j.trim(),page:"1"})}},H=()=>{g(""),w(""),y(""),L(),window.scrollTo({top:0,behavior:"smooth"})},O=F=>{p(F),a({mode:F},{replace:!0}),N([]),k(0),T(!1)};u.useEffect(()=>{s.hash==="#add"&&(U(),window.history.replaceState(null,"",s.pathname))},[s.hash]);const U=()=>{r?e("/dashboard"):B(!0)},G=F=>{const ee=new URLSearchParams(n);ee.set("page",String(F)),a(ee),window.scrollTo({top:0,behavior:"smooth"})},E=()=>{const F=[];if(I<=5)for(let se=1;se<=I;se++)F.push(se);else if(m<=3){for(let se=1;se<=4;se++)F.push(se);F.push("...",I)}else if(m>=I-2){F.push(1,"...");for(let se=I-3;se<=I;se++)F.push(se)}else{F.push(1,"...");for(let se=m-1;se<=m+1;se++)F.push(se);F.push("...",I)}return F};return t.jsxs("div",{className:"min-h-screen no-select",children:[t.jsx(gs,{}),t.jsxs("main",{children:[t.jsx(QX,{mode:f,onModeChange:O,keyword:x,onKeywordChange:g,postcode:b,onPostcodeChange:w,businessName:j,onBusinessNameChange:y,onSearch:_,onNewSearch:H,hasResults:!!h,isDirty:C}),t.jsx("section",{id:"all-results",className:"py-8 md:py-16",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[h&&t.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-4 mb-6 md:mb-8",children:[t.jsx("h2",{className:"text-2xl md:text-3xl font-heading font-bold",children:h.mode==="keyword"?t.jsxs(t.Fragment,{children:["Results for â",h.keyword,"â near ",h.postcode]}):t.jsxs(t.Fragment,{children:["Results for â",h.name,"â"]})}),t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm md:text-base",children:[t.jsx(mc,{size:16}),t.jsxs("span",{children:[S," businesses found"]})]})]}),h?$?t.jsxs("div",{className:"text-center py-12",children:[t.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-community-green"}),t.jsx("p",{className:"mt-4 text-muted-foreground",children:"Searching local businesses..."})]}):A?t.jsxs("div",{className:"text-center py-12",children:[t.jsx("p",{className:"text-muted-foreground text-lg mb-4",children:"Something went wrong loading results. Please try again."}),t.jsx(q,{onClick:()=>D(h,m),className:"bg-community-green hover:bg-green-600",children:"Retry"})]}):v.length===0?t.jsxs("div",{className:"text-center py-12",children:[t.jsx("p",{className:"text-muted-foreground text-lg",children:h.mode==="
741keyword"?t.jsxs(t.Fragment,{children:["No listings match â",h.keyword,"â near ",h.postcode,"."]}):t.jsxs(t.Fragment,{children:["No listings match â",h.name,"â."]})}),t.jsx("p",{className:"text-muted-foreground text-sm mt-2",children:h.mode==="keyword"?"Try a broader keyword or a neighbouring postcode.":"Try a different spelling or search by keyword."})]}):t.jsxs(t.Fragment,{children:[t.jsx(_Z,{businesses:v}),I>1&&t.jsxs("div",{className:"mt-10 flex flex-col sm:flex-row items-center justify-between gap-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",(m-1)*Sl+1," - ",Math.min(m*Sl,S)," of ",S," businesses"]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs(q,{variant:"outline",size:"sm",onClick:()=>G(m-1),disabled:m===1,className:"gap-1",children:[t.jsx(su,{className:"h-4 w-4"})," Previous"]}),t.jsx("div",{className:"hidden sm:flex items-center gap-1 mx-2",children:E().map((F,ee)=>typeof F=="number"?t.jsx(q,{variant:m===F?"default":"outline",size:"sm",onClick:()=>G(F),className:"min-w-[36px]",children:F},ee):t.jsx("span",{className:"px-2 text-muted-foreground",children:F},ee))}),t.jsxs("span",{className:"sm:hidden text-sm text-muted-foreground mx-2",children:["Page ",m," of ",I]}),t.jsxs(q,{variant:"outline",size:"sm",onClick:()=>G(m+1),disabled:m===I,className:"gap-1",children:["Next ",t.jsx(Ac,{className:"h-4 w-4"})]})]})]})]}):t.jsxs("div",{className:"text-center py-16 bg-muted/40 rounded-lg border-2 border-dashed border-border",children:[t.jsx(Ur,{className:"mx-auto h-12 w-12 text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Start your search"}),t.jsx("p",{className:"text-muted-foreground max-w-md mx-auto",children:f==="keyword"?t.jsxs(t.Fragment,{children:["Enter what you're looking for and choose your postcode above.",t.jsx("br",{}),"Both are needed so we can show businesses that serve your area."]}):"Enter a business name above to find a listing."})]})]})}),t.jsx("section",{className:"py-12 md:py-16 bg-community-green text-white",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center",children:[t.jsx("h2",{className:"text-2xl md:text-3xl font-heading font-bold mb-4 md:mb-6",children:"List Your Business"}),t.jsx("p",{className:"text-lg md:text-xl mb-6 md:mb-8 max-w-2xl mx-auto px-4",children:"Join our directory and connect with local customers in your area. Boost your visibility and grow your business."}),t.jsx(q,{size:"lg",className:"bg-white text-community-green hover:bg-gray-100 px-6 md:px-8 py-3 text-base md:text-lg font-medium",onClick:U,children:"Add Your Business"})]})})]}),t.jsx(vs,{}),t.jsx(qX,{open:P,onOpenChange:B,onSuccess:()=>e("/dashboard")})]})};function Rh(e,[s,r]){return Math.min(r,Math.max(s,e))}var $Z=[" ","Enter","ArrowUp","ArrowDown"],EZ=[" ","Enter"],zf="Select",[Lv,Bv,PZ]=pl(zf),[qu,jfe]=hr(zf,[PZ,vl]),zv=vl(),[AZ,jl]=qu(zf),[TZ,DZ]=qu(zf),qA=e=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:i,value:o,defaultValue:l,onValueChange:c,dir:d,name:m,autoComplete:h,disabled:f,required:p,form:x}=e,g=zv(s),[b,w]=u.useState(null),[j,y]=u.useState(null),[v,N]=u.useState(!1),S=to(d),[k=!1,$]=wr({prop:n,defaultProp:a,onChange:i}),[R,A]=wr({prop:o,defaultProp:l,onChange:c}),T=u.useRef(null),P=b?x||!!b.closest("form"):!0,[B,Y]=u.useState(new Set),I=Array.from(B).map(C=>C.props.value).join(";");return t.jsx(ov,{...g,children:t.jsxs(AZ,{required:p,scope:s,trigger:b,onTriggerChange:w,valueNode:j,onValueNodeChange:y,valueNodeHasChildren:v,onValueNodeHasChildrenChange:N,contentId:Lr(),value:R,onValueChange:A,open:k,onOpenChange:$,dir:S,triggerPointerDownPosRef:T,disabled:f,children:[t.jsx(Lv.Provider,{scope:s,children:t.jsx(TZ,{scope:e.__scopeSelect,onNativeOptionAdd:u.useCallback(C=>{Y(L=>new Set(L).add(C))},[]),onNativeOptionRemove:u.useCallback(C=>{Y(L=>{const D=new Set(L);return D.delete(C),D})},[]),children:r})}),P?t.jsxs(pT,{"aria-hidden":!0,required:p,tabIndex:-1,name:m,autoComplete:h,value:R,onChange:C=>A(C.target.value),disabled:f,form:x,children:[R===void 0?t.jsx("option",{value:""}):null,Array.from(B)]},I):null]})})};qA.displayName=zf;var HA="SelectTrigger",WA=u.forwardRef((e,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=e,i=zv(r),o=jl(HA,r),l=o.disabled||n,c=at(s,o.onTriggerChange),d=Bv(r),m=u.useRef("touch"),[h,f,p]=xT(g=>{const b=d().filter(y=>!y.disabled),w=b.find(y=>y.value===o.value),j=gT(b,g,w);j!==void 0&&o.onValueChange(j.value)}),x=g=>{l||(o.onOpenChange(!0),p()),g&&(o.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return t.jsx($f,{asChild:!0,...i,children:t.jsx(ze.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":fT(o.value)?"":void 0,...a,ref:c,onClick:Se(a.onClick,g=>
vendor: 15,940 bytes, line 741
741{g.currentTarget.focus(),m.current!=="mouse"&&x(g)}),onPointerDown:Se(a.onPointerDown,g=>{m.current=g.pointerType;const b=g.target;b.hasPointerCapture(g.pointerId)&&b.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(x(g),g.preventDefault())}),onKeyDown:Se(a.onKeyDown,g=>{const b=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&f(g.key),!(b&&g.key===" ")&&$Z.includes(g.key)&&(x(),g.preventDefault())})})})});WA.displayName=HA;var GA="SelectValue",YA=u.forwardRef((e,s)=>{const{__scopeSelect:r,className:n,style:a,children:i,placeholder:o="",...l}=e,c=jl(GA,r),{onValueNodeHasChildrenChange:d}=c,m=i!==void 0,h=at(s,c.onValueNodeChange);return qs(()=>{d(m)},[d,m]),t.jsx(ze.span,{...l,ref:h,style:{pointerEvents:"none"},children:fT(c.value)?t.jsx(t.Fragment,{children:o}):i})});YA.displayName=GA;var RZ="SelectIcon",KA=u.forwardRef((e,s)=>{const{__scopeSelect:r,children:n,...a}=e;return t.jsx(ze.span,{"aria-hidden":!0,...a,ref:s,children:n||"â¼"})});KA.displayName=RZ;var MZ="SelectPortal",QA=e=>t.jsx(Nu,{asChild:!0,...e});QA.displayName=MZ;var yc="SelectContent",XA=u.forwardRef((e,s)=>{const r=jl(yc,e.__scopeSelect),[n,a]=u.useState();if(qs(()=>{a(new DocumentFragment)},[]),!r.open){const i=n;return i?yn.createPortal(t.jsx(ZA,{scope:e.__scopeSelect,children:t.jsx(Lv.Slot,{scope:e.__scopeSelect,children:t.jsx("div",{children:e.children})})}),i):null}return t.jsx(JA,{...e,ref:s})});XA.displayName=yc;var ya=10,[ZA,wl]=qu(yc),OZ="SelectContentImpl",JA=u.forwardRef((e,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:l,sideOffset:c,align:d,alignOffset:m,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:x,hideWhenDetached:g,avoidCollisions:b,...w}=e,j=jl(yc,r),[y,v]=u.useState(null),[N,S]=u.useState(null),k=at(s,M=>v(M)),[$,R]=u.useState(null),[A,T]=u.useState(null),P=Bv(r),[B,Y]=u.useState(!1),I=u.useRef(!1);u.useEffect(()=>{if(y)return Df(y)},[y]),Sv();const C=u.useCallback(M=>{const[F,...ee]=P().map(X=>X.ref.current),[se]=ee.slice(-1),le=document.activeElement;for(const X of M)if(X===le||(X==null||X.scrollIntoView({block:"nearest"}),X===F&&N&&(N.scrollTop=0),X===se&&N&&(N.scrollTop=N.scrollHeight),X==null||X.focus(),document.activeElement!==le))return},[P,N]),L=u.useCallback(()=>C([$,y]),[C,$,y]);u.useEffect(()=>{B&&L()},[B,L]);const{onOpenChange:D,triggerPointerDownPosRef:_}=j;u.useEffect(()=>{if(y){let M={x:0,y:0};const F=se=>{var le,X;M={x:Math.abs(Math.round(se.pageX)-(((le=_.current)==null?void 0:le.x)??0)),y:Math.abs(Math.round(se.pageY)-(((X=_.current)==null?void 0:X.y)??0))}},ee=se=>{M.x<=10&&M.y<=10?se.preventDefault():y.contains(se.target)||D(!1),document.removeEventListener("pointermove",F),_.current=null};return _.current!==null&&(document.addEventListener("pointermove",F),document.addEventListener("pointerup",ee,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",F),document.removeEventListener("pointerup",ee,{capture:!0})}}},[y,D,_]),u.useEffect(()=>{const M=()=>D(!1);return window.addEventListener("blur",M),window.addEventListener("resize",M),()=>{window.removeEventListener("blur",M),window.removeEventListener("resize",M)}},[D]);const[H,O]=xT(M=>{const F=P().filter(le=>!le.disabled),ee=F.find(le=>le.ref.current===document.activeElement),se=gT(F,M,ee);se&&setTimeout(()=>se.ref.current.focus())}),U=u.useCallback((M,F,ee)=>{const se=!I.current&&!ee;(j.value!==void 0&&j.value===F||se)&&(R(M),se&&(I.current=!0))},[j.value]),G=u.useCallback(()=>y==null?void 0:y.focus(),[y]),E=u.useCallback((M,F,ee)=>{const se=!I.current&&!ee;(j.value!==void 0&&j.value===F||se)&&T(M)},[j.value]),z=n==="popper"?Ij:eT,Z=z===Ij?{side:l,sideOffset:c,align:d,alignOffset:m,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:x,hideWhenDetached:g,avoidCollisions:b}:{};return t.jsx(ZA,{scope:r,content:y,viewport:N,onViewportChange:S,itemRefCallback:U,selectedItem:$,onItemLeave:G,itemTextRefCallback:E,focusSelectedItem:L,selectedItemText:A,position:n,isPositioned:B,searchRef:H,children:t.jsx(Tf,{as:tn,allowPinchZoom:!0,children:t.jsx(Af,{asChild:!0,trapped:j.open,onMountAutoFocus:M=>{M.preventDefault()},onUnmountAutoFocus:Se(a,M=>{var F;(F=j.trigger)==null||F.focus({preventScroll:!0}),M.preventDefault()}),children:t.jsx(xl,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:M=>M.preventDefault(),onDismiss:()=>j.onOpenChange(!1),children:t.jsx(z,{role:"listbox",id:j.contentId,"data-state":j.open?"open":"closed",dir:j.dir,onContextMenu:M=>M.preventDefault(),...w,...Z,onPlaced:()=>Y(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:Se(w.onKeyDown,M=>{const F=M.ctrlKey||M.altKey||M.metaKey;if(M.key==="Tab"&&M.preventDefault(),!F&&M.key.length===1&&O(M.key),["ArrowUp","ArrowDown","Home","End"].includes(M.key)){let se=P().filter(le=>!le.disabled).map(le=>le.ref.current);if(["ArrowUp","End"].includes(M.key)&&(se=se.slice().reverse()),["ArrowUp","ArrowDown"].includes(M.key)){const le=M.target,X=se.indexOf(le);se=se.slice(X+1)}setTimeout(()=>C(se)),M.preventDefault()}})})})})})})});JA.displayName=OZ;var IZ="SelectItemAlignedPosition",eT=u.forwardRef((e,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=e,i=jl(yc,r),o=wl(yc,r),[l,c]=u.useState(null),[d,m]=u.useState(null),h=at(s,k=>m(k)),f=Bv(r),p=u.useRef(!1),x=u.useRef(!0),{viewport:g,selectedItem:b,selectedItemText:w,focusSelectedItem:j}=o,y=u.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&d&&g&&b&&w){const k=i.trigger.getBoundingClientRect(),$=d.getBoundingClientRect(),R=i.valueNode.getBoundingClientRect(),A=w.getBoundingClientRect();if(i.dir!=="rtl"){const le=A.left-$.left,X=R.left-le,ye=k.left-X,Ce=k.width+ye,ke=Math.max(Ce,$.width),fe=window.innerWidth-ya,Ee=Rh(X,[ya,Math.max(ya,fe-ke)]);l.style.minWidth=Ce+"px",l.style.left=Ee+"px"}else{const le=$.right-A.right,X=window.innerWidth-R.right-le,ye=window.innerWidth-k.right-X,Ce=k.width+ye,ke=Math.max(Ce,$.width),fe=window.innerWidth-ya,Ee=Rh(X,[ya,Math.max(ya,fe-ke)]);l.style.minWidth=Ce+"px",l.style.right=Ee+"px"}const T=f(),P=window.innerHeight-ya*2,B=g.scrollHeight,Y=window.getComputedStyle(d),I=parseInt(Y.borderTopWidth,10),C=parseInt(Y.paddingTop,10),L=parseInt(Y.borderBottomWidth,10),D=parseInt(Y.paddingBottom,10),_=I+C+B+D+L,H=Math.min(b.offsetHeight*5,_),O=window.getComputedStyle(g),U=parseInt(O.paddingTop,10),G=parseInt(O.paddingBottom,10),E=k.top+k.height/2-ya,z=P-E,Z=b.offsetHeight/2,M=b.offsetTop+Z,F=I+C+M,ee=_-F;if(F<=E){const le=T.length>0&&b===T[T.length-1].ref.current;l.style.bottom="0px";const X=d.clientHeight-g.offsetTop-g.offsetHeight,ye=Math.max(z,Z+(le?G:0)+X+L),Ce=F+ye;l.style.height=Ce+"px"}else{const le=T.length>0&&b===T[0].ref.current;l.style.top="0px";const ye=Math.max(E,I+g.offsetTop+(le?U:0)+Z)+ee;l.style.height=ye+"px",g.scrollTop=F-E+g.offsetTop}l.style.margin=`${ya}px 0`,l.style.minHeight=H+"px",l.style.maxHeight=P+"px",n==null||n(),requestAnimationFrame(()=>p.current=!0)}},[f,i.trigger,i.valueNode,l,d,g,b,w,i.dir,n]);qs(()=>y(),[y]);const[v,N]=u.useState();qs(()=>{d&&N(window.getComputedStyle(d).zIndex)},[d]);const S=u.useCallback(k=>{k&&x.current===!0&&(y(),j==null||j(),x.current=!1)},[y,j]);return t.jsx(LZ,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:t.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:v},children:t.jsx(ze.div,{...a,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});eT.displayName=IZ;var FZ="SelectPopperPosition",Ij=u.forwardRef((e,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=ya,...i}=e,o=zv(r);return t.jsx(lv,{...o,...i,ref:s,align:n,collisionPadding:a,style:{boxSizing:"border-box",...i.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)"}})});Ij.displayName=FZ;var[LZ,nN]=qu(yc,{}),Fj="SelectViewport",tT=u.forwardRef((e,s)=>{const{__scopeSelect:r,nonce:n,...a}=e,i=wl(Fj,r),o=nN(Fj,r),l=at(s,i.onViewportChange),c=u.useRef(0);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),t.jsx(Lv.Slot,{scope:r,children:t.jsx(ze.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Se(a.onScroll,d=>{const m=d.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:f}=o;if(f!=null&&f.current&&h){const p=Math.abs(c.current-m.scrollTop);if(p>0){const x=window.innerHeight-ya*2,g=parseFloat(h.style.minHeight),b=parseFloat(h.style.height),w=Math.max(g,b);if(w<x){const j=w+p,y=Math.min(x,j),v=j-y;h.style.height=y+"px",h.style.bottom==="0px"&&(m.scrollTop=v>0?v:0,h.style.justifyContent="flex-end")}}}c.current=m.scrollTop})})})]})});tT.displayName=Fj;var sT="SelectGroup",[BZ,zZ]=qu(sT),UZ=u.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e,a=Lr();return t.jsx(BZ,{scope:r,id:a,children:t.jsx(ze.div,{role:"group","aria-labelledby":a,...n,ref:s})})});UZ.displayName=sT;var rT="SelectLabel",nT=u.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e,a=zZ(rT,r);return t.jsx(ze.div,{id:a.id,...n,ref:s})});nT.displayName=rT;var fg="SelectItem",[VZ,aT]=qu(fg),iT=u.forwardRef((e,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:i,...o}=e,l=jl(fg,r),c=wl(fg,r),d=l.value===n,[m,h]=u.useState(i??""),[f,p]=u.useState(!1),x=at(s,j=>{var y;return(y=c.itemRefCallback)==null?void 0:y.call(c,j,n,a)}),g=Lr(),b=u.useRef("touch"),w=()=>{a||(l.onValueChange(n),l.onOpenChange(!1))};if(n==="")throw new Error("A <Select.Item /> 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 t.jsx(VZ,{scope:r,value:n,disabled:a,textId:g,isSelected:d,onItemTextChange:u.useCallback(j=>{h(y=>y||((j==null?void 0:j.textContent)??"").trim())},[]),children:t.jsx(Lv.ItemSlot,{scope:r,value:n,disabled:a,textValue:m,children:t.jsx(ze.div,{role:"option","aria-labelledby":g,"data-highlighted":f?"":void 0,"aria-selected":d&&f,"data-state":d?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:x,onFocus:Se(o.onFocus,()=>p(!0)),onBlur:Se(o.onBlur,()=>p(!1)),onClick:Se(o.onClick,()=>{b.current!=="mouse"&&w()}),onPointerUp:Se(o.onPointerUp,()=>{b.current==="mouse"&&w()}),onPointerDown:Se(o.onPointerDown,j=>{b.current=j.pointerType}),onPointerMove:Se(o.onPointerMove,j=>{var y;b.current=j.pointerType,a?(y=c.onItemLeave)==null||y.call(c):b.current==="mouse"&&j.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Se(o.onPointerLeave,j=>{var y;j.currentTarget===document.activeElement&&((y=c.onItemLeave)==null||y.call(c))}),onKeyDown:Se(o.onKeyDown,j=>{var v;((v=c.searchRef)==null?void 0:v.current)!==""&&j.key===" "||(EZ.includes(j.key)&&w(),j.key===" "&&j.preventDefault())})})})})});iT.displayName=fg;var $m="SelectItemText",oT=u.forwardRef((e,s)=>{const{__scopeSelect:r,className:n,style:a,...i}=e,o=jl($m,r),l=wl($m,r),c=aT($m,r),d=DZ($m,r),[m,h]=u.useState(null),f=at(s,w=>h(w),c.onItemTextChange,w=>{var j;return(j=l.itemTextRefCallback)==null?void 0:j.call(l,w,c.value,c.disabled)}),p=m==null?void 0:m.textContent,x=u.useMemo(()=>t.jsx("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:b}=d;return qs(()=>(g(x),()=>b(x)),[g,b,x]),t.jsxs(t.Fragment,{children:[t.jsx(ze.span,{id:c.textId,...i,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?yn.createPortal(i.children,o.valueNode):null]})});oT.displayName=$m;var lT="SelectItemIndicator",cT=u.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e;return aT(lT,r).isSelected?t.jsx(ze.span,{"aria-hidden":!0,...n,ref:s}):null});cT.displayName=lT;var Lj="SelectScrollUpButton",dT=u.forwardRef((e,s)=>{const r=wl(Lj,e.__scopeSelect),n=nN(Lj,e.__scopeSelect),[a,i]=u.useState(!1),o=at(s,n.onScrollButtonChange);return qs(()=>{if(r.viewport&&r.isPositioned){let l=function(){const d=c.scrollTop>0;i(d)};const c=r.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?t.jsx(mT,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});dT.displayName=Lj;var Bj="SelectScrollDownButton",uT=u.forwardRef((e,s)=>{const r=wl(Bj,e.__scopeSelect),n=nN(Bj,e.__scopeSelect),[a,i]=u.useState(!1),o=at(s,n.onScrollButtonChange);return qs(()=>{if(r.viewport&&r.isPositioned){let l=function(){const d=c.scrollHeight-c.clientHeight,m=Math.ceil(c.scrollTop)<d;i(m)};const c=r.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?t.jsx(mT,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});uT.displayName=Bj;var mT=u.forwardRef((e,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=e,i=wl("SelectScrollButton",r),o=u.useRef(null),l=Bv(r),c=u.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return u.useEffect(()=>()=>c(),[c]),qs(()=>{var m;const d=l().find(h=>h.ref.current===document.activeElement);(m=d==null?void 0:d.ref.current)==null||m.scrollIntoView({block:"nearest"})},[l]),t.jsx(ze.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Se(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(n,50))}),onPointerMove:Se(a.onPointerMove,()=>{var d;(d=i.onItemLeave)==null||d.call(i),o.current===null&&(o.current=window.setInterval(n,50))}),onPointerLeave:Se(a.onPointerLeave,()=>{c()})})}),qZ="SelectSeparator",hT=u.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e;return t.jsx(ze.div,{"aria-hidden":!0,...n,ref:s})});hT.displayName=qZ;var zj="SelectArrow",HZ=u.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e,a=zv(r),i=jl(zj,r),o=wl(zj,r);return i.open&&o.position==="popper"?t.jsx(cv,{...a,...n,ref:s}):null});HZ.displayName=zj;function fT(e){return e===""||e===void 0}var pT=u.forwardRef((e,s)=>{const{value:r,...n}=e,a=u.useRef(null),i=at(s,a),o=Mu(r);return u.useEffect(()=>{const l=a.current,c=window.HTMLSelectElement.prototype,m=Object.getOwnPropertyDescriptor(c,"value").set;if(o!==r&&m){const h=new Event("change",{bubbles:!0});m.call(l,r),l.dispatchEvent(h)}},[o,r]),t.jsx(bf,{asChild:!0,children:t.jsx("select",{...n,ref:i,defaultValue:r})})});pT.displayName="BubbleSelect";function xT(e){const s=Qt(e),r=u.useRef(""),n=u.useRef(0),a=u.useCallback(o=>{const l=r.current+o;s(l),function c(d){r.current=d,window.clearTimeout(n.current),d!==""&&(n.current=window.setTimeout(()=>c(""),1e3))}(l)},[s]),i=u.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return u.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,i]}function gT(e,s,r){const a=s.length>1&&Array.from(s).every(d=>d===s[0])?s[0]:s,i=r?e.indexOf(r):-1;let o=WZ(e,Math.max(i,0));a.length===1&&(o=o.filter(d=>d!==r));const c=o.find(d=>d.textValue.toLowerCase().startsWith(a.toLowerCase()));return c!==r?c:void 0}function WZ(e,s){return e.map((r,n)=>e[(s+n)%e.length])}var GZ=qA,vT=WA,YZ=YA,KZ=KA,QZ=QA,yT=XA,XZ=tT,bT=nT,jT=iT,ZZ=oT,JZ=cT,wT=dT,NT=uT,_T=hT;const ht=GZ,ft=YZ,ut=u.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(vT,{ref:n,className:oe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm r
741ing-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...r,children:[s,t.jsx(KZ,{asChild:!0,children:t.jsx(Ma,{className:"h-4 w-4 opacity-50"})})]}));ut.displayName=vT.displayName;const ST=u.forwardRef(({className:e,...s},r)=>t.jsx(wT,{ref:r,className:oe("flex cursor-default items-center justify-center py-1",e),...s,children:t.jsx(rE,{className:"h-4 w-4"})}));ST.displayName=wT.displayName;const CT=u.forwardRef(({className:e,...s},r)=>t.jsx(NT,{ref:r,className:oe("flex cursor-default items-center justify-center py-1",e),...s,children:t.jsx(Ma,{className:"h-4 w-4"})}));CT.displayName=NT.displayName;const mt=u.forwardRef(({className:e,children:s,position:r="popper",...n},a)=>t.jsx(QZ,{children:t.jsxs(yT,{ref:a,className:oe("relative z-[9999] max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-border bg-background text-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...n,children:[t.jsx(ST,{}),t.jsx(XZ,{className:oe("p-1 pointer-events-auto",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),t.jsx(CT,{})]})}));mt.displayName=yT.displayName;const eJ=u.forwardRef(({className:e,...s},r)=>t.jsx(bT,{ref:r,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...s}));eJ.displayName=bT.displayName;const Pe=u.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(jT,{ref:n,className:oe("relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-accent hover:text-accent-foreground pointer-events-auto",e),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(JZ,{children:t.jsx(Bs,{className:"h-4 w-4"})})}),t.jsx(ZZ,{children:s})]}));Pe.displayName=jT.displayName;const tJ=u.forwardRef(({className:e,...s},r)=>t.jsx(_T,{ref:r,className:oe("-mx-1 my-1 h-px bg-muted",e),...s}));tJ.displayName=_T.displayName;function Uj({event:e}){const s=l=>{const c=new Date(l);return{day:c.getDate(),month:c.toLocaleDateString("en-GB",{month:"short"}).toUpperCase(),weekday:c.toLocaleDateString("en-GB",{weekday:"short"})}},r=l=>{const c=new Date(l);return{day:c.getDate(),month:c.toLocaleDateString("en-GB",{month:"short"}).toUpperCase()}},n=l=>{const[c,d]=l.split(":"),m=parseInt(c),h=m>=12?"PM":"AM";return`${m%12||12}:${d} ${h}`},a=e.date_end&&e.date_end!==e.date,i=s(e.date),o=a?r(e.date_end):null;return t.jsx(hs,{to:`/events/${e.slug||e.id}`,className:"group block",children:t.jsxs(xe,{className:"overflow-hidden h-full transition-all duration-300 hover:shadow-lg hover:-translate-y-1 border-border/50",children:[t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"h-48 bg-gradient-to-br from-primary/20 to-primary/5 overflow-hidden",children:e.image?t.jsx("img",{src:e.image,alt:e.title,className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"}):t.jsx("div",{className:"w-full h-full flex items-center justify-center",children:t.jsx(It,{className:"h-16 w-16 text-primary/30"})})}),t.jsx("div",{className:"absolute top-3 left-3 bg-background rounded-lg shadow-md p-2 text-center min-w-[60px]",children:a?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"text-xs font-medium text-primary",children:[r(e.date).month," ",r(e.date).day]}),t.jsx("p",{className:"text-sm font-bold leading-none my-0.5",children:"-"}),t.jsxs("p",{className:"text-xs font-medium text-primary",children:[o==null?void 0:o.month," ",o==null?void 0:o.day]})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-xs font-medium text-primary",children:i.month}),t.jsx("p",{className:"text-2xl font-bold leading-none",children:i.day}),t.jsx("p",{className:"text-xs text-muted-foreground",children:i.weekday})]})}),e.featured&&t.jsx("div",{className:"absolute top-3 right-3",children:t.jsxs(we,{className:"bg-yellow-500 hover:bg-yellow-500 text-yellow-950",children:[t.jsx(mr,{className:"h-3 w-3 mr-1 fill-current"}),"Featured"]})})]}),t.jsxs(ge,{className:"p-4",children:[t.jsxs("div",{className:"flex gap-2 mb-2",children:[t.jsx(we,{variant:"secondary",className:"text-xs",children:e.category}),t.jsx(we,{variant:"outline",className:"text-xs",children:e.type})]}),t.jsx("h3",{className:"font-semibold text-lg mb-2 line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),(e.excerpt||e.description)&&t.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:e.excerpt||e.description}),t.jsxs("div",{className:"space-y-1.5 text-sm text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ws,{className:"h-4 w-4 shrink-0"}),t.jsxs("span",{children:[n(e.time),e.end_time&&` - ${n(e.end_time)}`]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_t,{className:"h-4 w-4 shrink-0"}),t.jsxs("span",{className:"truncate",children:[e.location,", ",e.area]})]})]})]})]})})}const sJ=({open:e,onOpenChange:s,onSuccess:r,redirectPath:n})=>{const[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[m,h]=u.useState(""),[f,p]=u.useState(!1),[x,g]=u.useState("signin"),{signIn:b,signUp:w}=Ar(),j=()=>{i(""),l(""),d(""),h("")},y=async N=>{if(N.preventDefault(),!a||!o){Ks({title:"Missing Fields",description:"Please enter your email and password.",variant:"destructive"});return}p(!0);try{const{error:S}=await b(a,o);if(S)throw S;j(),s(!1),r&&r()}catch(S){console.error("Sign in error:",S),Ks({title:"Sign In Failed",description:S.message||"Invalid email or password. Please try again.",variant:"destructive"})}finally{p(!1)}},v=async N=>{if(N.preventDefault(),!a||!o){Ks({title:"Missing Fields",description:"Please enter your email and password.",variant:"destructive"});return}if(o.length<6){Ks({title:"Password Too Short",description:"Password must be at least 6 characters.",variant:"destructive"});return}if(o!==c){Ks({title:"Passwords Don't Match",description:"Please ensure both passwords are the same.",variant:"destructive"});return}p(!0);try{const{error:S,needsConfirmation:k}=await w(a,o,{displayName:m||a.split("@")[0],redirectPath:n});if(S)throw S;j(),s(!1),!k&&r&&r()}catch(S){console.error("Registration error:",S),Ks({title:"Registration Failed",description:S.message||"Unable to create account. Please try again.",variant:"destructive"})}finally{p(!1)}};return t.jsx(bt,{open:e,onOpenChange:s,children:t.jsxs(xt,{className:"sm:max-w-md",children:[t.jsxs(jt,{className:"text-center pb-4",children:[t.jsxs("div",{className:"flex justify-center gap-3 mb-4",children:[t.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:t.jsx(It,{className:"h-6 w-6 text-primary"})}),t.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:t.jsx(ir,{className:"h-6 w-6 text-primary"})})]}),t.jsx(wt,{className:"text-2xl font-heading",children:"Share with Your Community"}),t.jsx(ys,{className:"text-base",children:"Create an account to submit events and stories that will be shared across our local community magazine."})]}),t.jsxs(ha,{value:x,onValueChange:N=>g(N),className:"w-full",children:[t.jsxs(Hn,{className:"grid w-full grid-cols-2",children:[t.jsx(Rt,{value:"signin",children:"Sign In"}),t.jsx(Rt,{value:"register",children:"Register"})]}
741),t.jsx(Mt,{value:"signin",className:"space-y-4 mt-4",children:t.jsxs("form",{onSubmit:y,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"signin-email",children:"Email"}),t.jsx(re,{id:"signin-email",type:"email",placeholder:"[email protected]",value:a,onChange:N=>i(N.target.value),disabled:f})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"signin-password",children:"Password"}),t.jsx(re,{id:"signin-password",type:"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",value:o,onChange:N=>l(N.target.value),disabled:f})]}),t.jsx(q,{type:"submit",className:"w-full",disabled:f,children:f?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing in..."]}):"Sign In"})]})}),t.jsx(Mt,{value:"register",className:"space-y-4 mt-4",children:t.jsxs("form",{onSubmit:v,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"register-name",children:"Display Name (optional)"}),t.jsx(re,{id:"register-name",type:"text",placeholder:"Your name",value:m,onChange:N=>h(N.target.value),disabled:f})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"register-email",children:"Email"}),t.jsx(re,{id:"register-email",type:"email",placeholder:"[email protected]",value:a,onChange:N=>i(N.target.value),disabled:f})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"register-password",children:"Password"}),t.jsx(re,{id:"register-password",type:"password",placeholder:"Min. 6 characters",value:o,onChange:N=>l(N.target.value),disabled:f})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"register-confirm",children:"Confirm Password"}),t.jsx(re,{id:"register-confirm",type:"password",placeholder:"Confirm your password",value:c,onChange:N=>d(N.target.value),disabled:f})]}),t.jsx(q,{type:"submit",className:"w-full",disabled:f,children:f?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating account..."]}):"Create Account"})]})})]}),t.jsxs("div",{className:"mt-6 pt-4 border-t",children:[t.jsx("p",{className:"text-sm font-medium text-muted-foreground mb-3",children:"Why create an account?"}),t.jsxs("ul",{className:"space-y-2",children:[t.jsxs("li",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(xs,{className:"h-4 w-4 text-primary"}),"Track your submitted events & stories"]}),t.jsxs("li",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(xs,{className:"h-4 w-4 text-primary"}),"Get notified when published"]}),t.jsxs("li",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(xs,{className:"h-4 w-4 text-primary"}),"Edit your submissions anytime"]})]})]})]})})},rJ=()=>{const e=u.useRef(!0),s=ds(),[r,n]=Hw(),{user:a}=Ar(),[i,o]=u.useState([]),[l,c]=u.useState(!0),[d,m]=u.useState(null),[h,f]=u.useState(!1),[p,x]=u.useState(""),[g,b]=u.useState("all"),[w,j]=u.useState("all"),[y,v]=u.useState("all"),[N,S]=u.useState("all"),[k,$]=u.useState("grid"),[R,A]=u.useState(void 0),[T,P]=u.useState({from:void 0,to:void 0}),[B,Y]=u.useState([]),[I,C]=u.useState([]),[L,D]=u.useState([]),_=u.useCallback(()=>{a?s("/add-event"):f(!0)},[a,s]),H=()=>{s("/add-event")};u.useEffect(()=>{r.get("tab")==="add"&&(n({},{replace:!0}),_())},[r,n,_]),u.useEffect(()=>()=>{e.current=!1},[]);const O=u.useCallback(async()=>{try{e.current&&(c(!0),m(null));const M=new Date().toISOString().split("T")[0];let F=W.from("events").select("*").eq("is_published",!0).gte("date",M).order("date",{ascending:!0});if(p&&(F=F.or(`title.ilike.%${p}%,description.ilike.%${p}%,location.ilike.%${p}%`)),g!=="all"&&(F=F.eq("category",g)),w!=="all"&&(F=F.eq("area",w)),y!=="all"&&(F=F.eq("type",y)),R){const X=R.toISOString().split("T")[0];F=F.eq("date",X)}if(T.from){const X=T.from.toISOString().split("T")[0];F=F.gte("date",X)}if(T.to){const X=T.to.toISOString().split("T")[0];F=F.lte("date",X)}const{data:ee,error:se}=await F;if(se)throw se;const le=(ee||[]).map(X=>({...X,links:Array.isArray(X.links)?X.links:[]}));e.current&&o(le)}catch(M){console.error("Error fetching events:",M),e.current&&(m("Failed to load events. Please try again."),Ks({title:"Error",description:"Failed to load events. Please try again.",variant:"destructive"}))}finally{e.current&&c(!1)}},[p,g,w,y,R,T.from,T.to]),U=async()=>{try{const M=new Date().toISOString().split("T")[0],{data:F,error:ee}=await W.from("events").select("category, area, type").eq("is_published",!0).gte("date",M);if(ee)throw ee;if(F){const se=[...new Set(F.map(ye=>ye.category))],le=[...new Set(F.map(ye=>ye.area))],X=[...new Set(F.map(ye=>ye.type))];Y(se),C(le),D(X)}}catch(M){console.error("Error fetching filter metadata:",M)}};u.useEffect(()=>{O();const M=setTimeout(()=>{e.current&&l&&c(!1)},1e4);return()=>
741clearTimeout(M)},[O]),u.useEffect(()=>{U()},[]);const G=i.filter(M=>M.featured),z=(()=>{const M=new Date;if(N==="week"){const F=$n(M,{weekStartsOn:1}),ee=Rv(M,{weekStartsOn:1});return i.filter(se=>{const le=new Date(se.date);return r0(le,{start:F,end:ee})})}if(N==="month"){const F=jr(M),ee=du(M);return i.filter(se=>{const le=new Date(se.date);return r0(le,{start:F,end:ee})})}if(N==="next_month"){const F=Cr(M,1),ee=jr(F),se=du(F);return i.filter(le=>{const X=new Date(le.date);return r0(X,{start:ee,end:se})})}return i})(),Z=M=>new Date(M).toLocaleDateString("en-GB",{weekday:"long",year:"numeric",month:"long",day:"numeric"});return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx(gs,{}),t.jsx("section",{className:"bg-gradient-to-r from-primary to-primary/80 text-primary-foreground py-16",children:t.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h1",{className:"text-4xl lg:text-6xl font-heading font-bold mb-6",children:"What's On"}),t.jsx("p",{className:"text-xl lg:text-2xl font-body mb-8 max-w-3xl mx-auto opacity-90",children:"Discover the best events, activities, and entertainment in your local area"}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[t.jsxs(q,{size:"lg",variant:"secondary",className:"font-semibold px-8 py-3",onClick:_,children:[t.jsx(Xt,{className:"mr-2 h-5 w-5"}),"Add Your Event"]}),t.jsx(hs,{to:"/whats-on/archive",children:t.jsxs(q,{size:"lg",variant:"outline",className:"font-semibold px-8 py-3 bg-transparent border-primary-foreground/30 text-primary-foreground hover:bg-primary-foreground/10",children:[t.jsx(GF,{className:"mr-2 h-5 w-5"}),"View Past Events"]})})]})]})})}),G.length>0&&t.jsx("section",{className:"py-12 bg-muted/30",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[t.jsx(mr,{className:"h-6 w-6 text-yellow-500 fill-yellow-500"}),t.jsx("h2",{className:"text-2xl lg:text-3xl font-heading font-bold text-foreground",children:"Featured Events"})]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:G.slice(0,3).map(M=>t.jsx(Uj,{event:M},M.id))})]})}),t.jsx("section",{className:"py-12",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-8",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl lg:text-3xl font-heading font-bold text-foreground mb-2",children:"Upcoming Events"}),t.jsx("p",{className:"text-muted-foreground font-body",children:l?"Loading events...":`${z.length} events found`})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(q,{variant:N==="all"?"default":"outline",size:"sm",onClick:()=>S("all"),children:"All Events"}),t.jsx(q,{variant:N==="week"?"default":"outline",size:"sm",onClick:()=>S("week"),children:"This Week"}),t.jsx(q,{variant:N==="month"?"default":"outline",size:"sm",onClick:()=>S("month"),children:"This Month"}),t.jsx(q,{variant:N==="next_month"?"default":"outline",size:"sm",onClick:()=>S("next_month"),children:"Next Month"})]})]}),t.jsxs("div",{className:"bg-card rounded-lg shadow-sm border mb-8",children:[t.jsx("div",{className:"p-4 border-b md:hidden",children:t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),t.jsx(re,{placeholder:"Search events...",value:p,onChange:M=>x(M.target.value),className:"pl-10 h-12 text-base"})]})}),t.jsx("div",{className:"md:hidden",children:t.jsx(Ru,{type:"single",collapsible:!0,children:t.jsxs(ti,{value:"filters",className:"border-none",children:[t.jsx(si,{className:"px-4 py-3 hover:no-underline",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(mc,{className:"h-5 w-5 text-primary"}),t.jsx("span",{className:"text-base font-heading font-semibold",children:"More Filters"}),(g!=="all"||w!=="all"||y!=="all")&&t.jsx(we,{variant:"secondary",className:"ml-2 text-xs",children:"Active"})]})}),t.jsx(ri,{className:"px-4 pb-4",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Category"}),t.jsxs(ht,{value:g,onValueChange:b,children:[t.jsxs(ut,{className:"h-12",children:[t.jsx(fc,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"All Categories"})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Categories"}),B.map(M=>t.jsx(Pe,{value:M,children:M},M))]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Area"}),t.jsxs(ht,{value:w,onValueChange:j,children:[t.jsxs(ut,{className:"h-12",children:[t.jsx(_t,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"All Areas"})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Areas"}),I.map(M=>t.jsx(Pe,{value:M,children:M},M))]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Type"}),t.jsxs(ht,{value:y,onValueChange:v,children:[t.jsxs(ut,{className:"h-12",children:[t.jsx(It,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"All Types"})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Types"}),L.map(M=>t.jsx(Pe,{value:M,children:M},M))]})]})]}),(p||g!=="all"||w!=="all"||y!=="all")&&t.jsx(q,{variant:"outline",size:"sm",onClick:()=>{x(""),b("all"),j("all"),v("all"),S("all")},className:"w-full",children:"Clear All Filters"})]})})]})})}),t.jsxs("div",{className:"hidden md:block p-6",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx(mc,{className:"h-5 w-5 text-primary"}),t.jsx("h3",{className:"text-lg font-heading font-semibold",children:"Filter Events"})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),t.jsx(re,{placeholder:"Search events...",value:p,onChange:M=>x(M.target.value),className:"pl-10"})]}),t.jsxs(ht,{value:g,onValueChange:b,children:[t.jsxs(ut,{children:[t.jsx(fc,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"All Categories"})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Categories"}),B.map(M=>t.jsx(Pe,{value:M,children:M},M))]})]}),t.jsxs(ht,{value:w,onValueChange:j,children:[t.jsxs(ut,{children:[t.jsx(_t,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"All Areas"})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Areas"}),I.map(M=>t.jsx(Pe,{value:M,children:M},M))]})]}),t.jsxs(ht,{value:y,onValueChange:v,children:[t.jsxs(ut,{children:[t.jsx(It,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"All Types"})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Types"}),L.map(M=>t.jsx(Pe,{value:M,children:M},M))]})]})]}),(p||g!=="all"||w!=="all"||y!=="all")&&t.jsx("div",{className:"mt-4 flex justify-end",children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{x(""),b("all"),j("all"),v("all"),S("all")},children:"Clear All Filters"})})]})]}),t.jsx("div",{className:"flex justify-end items-center mb-6",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(q,{variant:k==="grid"?"default":"outline",size:"sm",onClick:()=>$("grid"),children:[t.jsx(oE,{className:"mr-2 h-4 w-4"}),"Grid"]}),t.jsxs(q,{variant:k==="calendar"?"default":"outline",size:"sm",onClick:()=>$("calendar"),children:[t.jsx(Qo,{className:"mr-2 h-4 w-4"}),"List"]})]})}),l?t.jsx("div",{className:"text-center py-12",children:t.jsxs("div",{className:"max-w-md mx-auto",children:[t.jsx("div",{className:"animate-spin rounded-full h-16 w-16 border-b-2 border-primary mx-auto mb-4"}),t.jsx("h3",{className:"text-xl font-heading font-semibold text-muted-foreground mb-2",children:"Loading Events..."})]})}):d?t.jsx("div",{className:"text-center py-12",children:t.jsxs("div",{className:"max-w-md mx-auto",children:[t.jsx(It,{className:"h-16 w-16 text-destructive/30 mx-auto mb-4"}),t.jsx("h3",{className:"text-xl font-heading font-semibold text-destructive mb-2",children:"Error Loading Events"}),t.jsx("p",{className:"text-muted-foreground mb-6",children:d}),t.jsx(q,{variant:"outline",onClick:()=>O(),children:"Try Again"})]})}):z.length>0?k==="grid"?t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:z.map(M=>t.jsx(Uj,{event:M},M.id))}):t.jsx("div",{className:"space-y-4",children:z.map(M=>t.jsx(hs,{to:`/events/${M.slug||M.id}`,className:"block",children:t.jsx(xe,{className:"p-4 hover:shadow-md transition-shadow duration-200",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"flex-shrink-0 w-20 h-20 rounded-lg overflow-hidden bg-muted",children:M.image?t.jsx("img",{src:M.image,alt:M.title,className:"w-full h-full object-cover"}):t.jsx("div",{className:"w-full h-full flex items-center justify-center",children:t.jsx(It,{className:"h-8 w-8 text-muted-foreground"})})}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-lg font-heading font-semibold mb-1 hover:text-primary transition-colors",children:M.title}),t.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm text-muted-foreground mb-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Qo,{className:"h-4 w-4"}),Z(M.date)]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ws,{className:"h-4 w-4"}),M.time]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(_t,{className:"h-4 w-4"}),M.area]})]}),t.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:M.excerpt||M.description})]}),t.jsxs("div",{className:"flex flex-col gap-2 flex-shrink-0",children:[t.jsx(we,{variant:"secondary",className:"text-xs",children:M.category}),M.featured&&t.jsxs(we,{className:"bg-yellow-500 hover:bg-yellow-500 text-yellow-950 text-xs",children:[t.jsx(mr,{className:"h-3 w-3 mr-1 fill-current"}),"Featured"]})]})]})})]})})},M.id))}):t.jsx("div",{className:"text-center py-12",children:t.jsxs("div",{className:"max-w-md mx-auto",children:[t.jsx(It,{className:"h-16 w-16 text-muted-foreground
741/30 mx-auto mb-4"}),t.jsx("h3",{className:"text-xl font-heading font-semibold text-muted-foreground mb-2",children:"No Events Found"}),t.jsx("p",{className:"text-muted-foreground mb-6",children:"Try adjusting your filters or search terms to find more events."}),t.jsx(q,{variant:"outline",onClick:()=>{x(""),b("all"),j("all"),v("all"),S("all")},children:"Clear All Filters"})]})}),t.jsx("div",{className:"text-center mt-12",children:t.jsx(xe,{className:"max-w-md mx-auto",children:t.jsxs(ge,{className:"p-8",children:[t.jsx("h3",{className:"text-xl font-heading font-bold mb-4",children:"Have an Event to Share?"}),t.jsx("p",{className:"text-muted-foreground font-body mb-6",children:"Submit your local event and reach hundreds of community members"}),t.jsxs(q,{className:"w-full",onClick:_,children:[t.jsx(Xt,{className:"mr-2 h-4 w-4"}),"Add Your Event"]})]})})})]})}),t.jsx(vs,{}),t.jsx(sJ,{open:h,onOpenChange:f,onSuccess:H,redirectPath:"/add-event"})]})},nJ=()=>{const e=u.useRef(!0),[s,r]=u.useState([]),[n,a]=u.useState(!0),[i,o]=u.useState(null),[l,c]=u.useState(""),[d,m]=u.useState("all"),[h,f]=u.useState("all"),[p,x]=u.useState("all"),[g,b]=u.useState("newest"),[w,j]=u.useState([]),[y,v]=u.useState([]),[N,S]=u.useState([]);u.useEffect(()=>()=>{e.current=!1},[]);const k=u.useCallback(async()=>{try{e.current&&(a(!0),o(null));const R=new Date().toISOString().split("T")[0];let A=W.from("events").select("*").eq("is_published",!0).lt("date",R).order("date",{ascending:g==="oldest"});l&&(A=A.or(`title.ilike.%${l}%,description.ilike.%${l}%,location.ilike.%${l}%`)),d!=="all"&&(A=A.eq("category",d)),h!=="all"&&(A=A.eq("area",h)),p!=="all"&&(A=A.eq("type",p));const{data:T,error:P}=await A;if(P)throw P;const B=(T||[]).map(Y=>({...Y,links:Array.isArray(Y.links)?Y.links:[]}));e.current&&r(B)}catch(R){console.error("Error fetching past events:",R),e.current&&(o("Failed to load past events. Please try again."),Ks({title:"Error",description:"Failed to load past events. Please try again.",variant:"destructive"}))}finally{e.current&&a(!1)}},[l,d,h,p,g]),$=async()=>{try{const R=new Date().toISOString().split("T")[0],{data:A,error:T}=await W.from("events").select("category, area, type").eq("is_published",!0).lt("date",R);if(T)throw T;if(A){const P=[...new Set(A.map(I=>I.category))],B=[...new Set(A.map(I=>I.area))],Y=[...new Set(A.map(I=>I.type))];j(P),v(B),S(Y)}}catch(R){console.error("Error fetching filter metadata:",R)}};return u.useEffect(()=>{k();const R=setTimeout(()=>{e.current&&n&&a(!1)},1e4);return()=>clearTimeout(R)},[k]),u.useEffect(()=>{$()},[]),t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx(gs,{}),t.jsx("section",{className:"bg-gradient-to-r from-muted to-muted/80 text-foreground py-16",children:t.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"text-center",children:[t.jsxs(hs,{to:"/whats-on",className:"inline-flex items-center gap-2 text-primary hover:text-primary/80 mb-4 transition-colors",children:[t.jsx(Hi,{className:"h-4 w-4"}),t.jsx("span",{className:"font-medium",children:"Back to Upcoming Events"})]}),t.jsx("h1",{className:"text-4xl lg:text-6xl font-heading font-bold mb-6",children:"Events Archive"}),t.jsx("p",{className:"text-xl lg:text-2xl font-body mb-4 max-w-3xl mx-auto text-muted-foreground",children:"Browse past events from our community"})]})})}),t.jsx("section",{className:"py-12",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-8",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl lg:text-3xl font-heading font-bold text-foreground mb-2",children:"Past Events"}),t.jsx("p",{className:"text-muted-foreground font-body",children:n?"Loading events...":`${s.length} past events found`})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(q,{variant:g==="newest"?"default":"outline",size:"sm",onClick:()=>b("newest"),children:"Most Recent"}),t.jsx(q,{variant:g==="oldest"?"default":"outline",size:"sm",onClick:()=>b("oldest"),children:"Oldest First"})]})]}),t.jsxs("div",{className:"bg-card rounded-lg shadow-sm border mb-8",children:[t.jsx("div",{className:"p-4 border-b md:hidden",children:t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}
741),t.jsx(re,{placeholder:"Search past events...",value:l,onChange:R=>c(R.target.value),className:"pl-10 h-12 text-base"})]})}),t.jsx("div",{className:"md:hidden",children:t.jsx(Ru,{type:"single",collapsible:!0,children:t.jsxs(ti,{value:"filters",className:"border-none",children:[t.jsx(si,{className:"px-4 py-3 hover:no-underline",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(mc,{className:"h-5 w-5 text-primary"}),t.jsx("span",{className:"text-base font-heading font-semibold",children:"More Filters"}),(d!=="all"||h!=="all"||p!=="all")&&t.jsx(we,{variant:"secondary",className:"ml-2 text-xs",children:"Active"})]})}),t.jsx(ri,{className:"px-4 pb-4",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Category"}),t.jsxs(ht,{value:d,onValueChange:m,children:[t.jsxs(ut,{className:"h-12",children:[t.jsx(fc,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"All Categories"})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Categories"}),w.map(R=>t.jsx(Pe,{value:R,children:R},R))]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Area"}),t.jsxs(ht,{value:h,onValueChange:f,children:[t.jsxs(ut,{className:"h-12",children:[t.jsx(_t,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"All Areas"})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Areas"}),y.map(R=>t.jsx(Pe,{value:R,children:R},R))]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Type"}),t.jsxs(ht,{value:p,onValueChange:x,children:[t.jsxs(ut,{className:"h-12",children:[t.jsx(It,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"All Types"})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Types"}),N.map(R=>t.jsx(Pe,{value:R,children:R},R))]})]})]}),(l||d!=="all"||h!=="all"||p!=="all")&&t.jsx(q,{variant:"outline",size:"sm",onClick:()=>{c(""),m("all"),f("all"),x("all")},className:"w-full",children:"Clear All Filters"})]})})]})})}),t.jsxs("div",{className:"hidden md:block p-6",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx(mc,{className:"h-5 w-5 text-primary"}),t.jsx("h3",{className:"text-lg font-heading font-semibold",children:"Filter Past Events"})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),t.jsx(re,{placeholder:"Search past events...",value:l,onChange:R=>c(R.target.value),className:"pl-10"})]}),t.jsxs(ht,{value:d,onValueChange:m,children:[t.jsxs(ut,{children:[t.jsx(fc,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"All Categories"})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Categories"}),w.map(R=>t.jsx(Pe,{value:R,children:R},R))]})]}),t.jsxs(ht,{value:h,onValueChange:f,children:[t.jsxs(ut,{children:[t.jsx(_t,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"All Areas"})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Areas"}),y.map(R=>t.jsx(Pe,{value:R,children:R},R))]})]}),t.jsxs(ht,{value:p,onValueChange:x,children:[t.jsxs(ut,{children:[t.jsx(It,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"All Types"})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Types"}),N.map(R=>t.jsx(Pe,{value:R,children:R},R))]})]})]}),(l||d!=="all"||h!=="all"||p!=="all")&&t.jsx("div",{className:"mt-4 flex justify-end",children:t.jsx(q,{variant:"outline",size:"sm",onClick:()=>{c(""),m("all"),f("all"),x("all")},children:"Clear All Filters"})})]})]}),n&&t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[1,2,3,4,5,6].map(R=>t.jsxs("div",{className:"bg-card rounded-lg shadow-sm border animate-pulse",children:[t.jsx("div",{className:"h-48 bg-muted rounded-t-lg"}),t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsx("div",{className:"h-4 bg-muted rounded w-1/4"}),t.jsx("div",{className:"h-6 bg-muted rounded w-3/4"}),t.jsx("div",{className:"h-4 bg-muted rounded w-1/2"})]})]},R))}),i&&!n&&t.jsxs("div",{className:"text-center py-12",children:[t.jsx("div",{className:"bg-destructive/10 text-destructive px-4 py-3 rounded-lg inline-block mb-4",children:i}),t.jsx("div",{children:t.jsx(q,{onClick:()=>k(),children:"Try Again"})})]}),!n&&!i&&s.length>0&&t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:s.map(R=>t.jsx(Uj,{event:R},R.id))}),!n&&!i&&s.length===0&&t.jsxs("div",{className:"text-center py-16 bg-muted/30 rounded-lg",children:[t.jsx(It,{className:"h-16 w-16 text-muted-foreground mx-auto mb-4"}),t.jsx("h3",{className:"text-xl font-heading font-semibold text-foreground mb-2",children:"No Past Events Found"}),t.jsx("p",{className:"text-muted-foreground font-body mb-6 max-w-md mx-auto",children:l||d!=="all"||h!=="all"||p!=="all"?"Try adjusting your filters to find what you're looking for."
vendor: 34,584 bytes, line 741
741:"There are no past events in the archive yet."}),(l||d!=="all"||h!=="all"||p!=="all")&&t.jsx(q,{variant:"outline",onClick:()=>{c(""),m("all"),f("all"),x("all")},children:"Clear Filters"})]})]})}),t.jsx(vs,{})]})};var Uf=e=>e.type==="checkbox",Ul=e=>e instanceof Date,Qr=e=>e==null;const kT=e=>typeof e=="object";var sr=e=>!Qr(e)&&!Array.isArray(e)&&kT(e)&&!Ul(e),$T=e=>sr(e)&&e.target?Uf(e.target)?e.target.checked:e.target.value:e,aJ=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,ET=(e,s)=>e.has(aJ(s)),iJ=e=>{const s=e.constructor&&e.constructor.prototype;return sr(s)&&s.hasOwnProperty("isPrototypeOf")},aN=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function mn(e){let s;const r=Array.isArray(e);if(e instanceof Date)s=new Date(e);else if(e instanceof Set)s=new Set(e);else if(!(aN&&(e instanceof Blob||e instanceof FileList))&&(r||sr(e)))if(s=r?[]:{},!r&&!iJ(e))s=e;else for(const n in e)e.hasOwnProperty(n)&&(s[n]=mn(e[n]));else return e;return s}var Uv=e=>Array.isArray(e)?e.filter(Boolean):[],Ys=e=>e===void 0,qe=(e,s,r)=>{if(!s||!sr(e))return r;const n=Uv(s.split(/[,[\].]+?/)).reduce((a,i)=>Qr(a)?a:a[i],e);return Ys(n)||n===e?Ys(e[s])?r:e[s]:n},Zn=e=>typeof e=="boolean",iN=e=>/^\w*$/.test(e),PT=e=>Uv(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ts=(e,s,r)=>{let n=-1;const a=iN(s)?[s]:PT(s),i=a.length,o=i-1;for(;++n<i;){const l=a[n];let c=r;if(n!==o){const d=e[l];c=sr(d)||Array.isArray(d)?d:isNaN(+a[n+1])?{}:[]}if(l==="__proto__")return;e[l]=c,e=e[l]}return e};const pg={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},ka={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Si={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},AT=ve.createContext(null),Vv=()=>ve.useContext(AT),oJ=e=>{const{children:s,...r}=e;return ve.createElement(AT.Provider,{value:r},s)};var TT=(e,s,r,n=!0)=>{const a={defaultValues:s._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return s._proxyFormState[o]!==ka.all&&(s._proxyFormState[o]=!n||ka.all),r&&(r[o]=!0),e[o]}});return a},pn=e=>sr(e)&&!Object.keys(e).length,DT=(e,s,r,n)=>{r(e);const{name:a,...i}=e;return pn(i)||Object.keys(i).length>=Object.keys(s).length||Object.keys(i).find(o=>s[o]===(!n||ka.all))},Ym=e=>Array.isArray(e)?e:[e],RT=(e,s,r)=>!e||!s||e===s||Ym(e).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n)));function oN(e){const s=ve.useRef(e);s.current=e,ve.useEffect(()=>{const r=!e.disabled&&s.current.subject&&s.current.subject.subscribe({next:s.current.next});return()=>{r&&r.unsubscribe()}},[e.disabled])}function lJ(e){const s=Vv(),{control:r=s.control,disabled:n,name:a,exact:i}=e||{},[o,l]=ve.useState(r._formState),c=ve.useRef(!0),d=ve.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),m=ve.useRef(a);return m.current=a,oN({disabled:n,next:h=>c.current&&RT(m.current,h.name,i)&&DT(h,d.current,r._updateFormState)&&l({...r._formState,...h}),subject:r._subjects.state}),ve.useEffect(()=>(c.current=!0,d.current.isValid&&r._updateValid(!0),()=>{c.current=!1}),[r]),TT(o,r,d.current,!1)}var ai=e=>typeof e=="string",MT=(e,s,r,n,a)=>ai(e)?(n&&s.watch.add(e),qe(r,e,a)):Array.isArray(e)?e.map(i=>(n&&s.watch.add(i),qe(r,i))):(n&&(s.watchAll=!0),r);function cJ(e){const s=Vv(),{control:r=s.control,name:n,defaultValue:a,disabled:i,exact:o}=e||{},l=ve.useRef(n);l.current=n,oN({disabled:i,subject:r._subjects.values,next:m=>{RT(l.current,m.name,o)&&d(mn(MT(l.current,r._names,m.values||r._formValues,!1,a)))}});const[c,d]=ve.useState(r._getWatch(n,a));return ve.useEffect(()=>r._removeUnmounted()),c}function dJ(e){const s=Vv(),{name:r,disabled:n,control:a=s.control,shouldUnregister:i}=e,o=ET(a._names.array,r),l=cJ({control:a,name:r,defaultValue:qe(a._formValues,r,qe(a._defaultValues,r,e.defaultValue)),exact:!0}),c=lJ({control:a,name:r,exact:!0}),d=ve.useRef(a.register(r,{...e.rules,value:l,...Zn(e.disabled)?{disabled:e.disabled}:{}}));return ve.useEffect(()=>{const m=a._options.shouldUnregister||i,h=(f,p)=>{const x=qe(a._fields,f);x&&x._f&&(x._f.mount=p)};if(h(r,!0),m){const f=mn(qe(a._options.defaultValues,r));ts(a._defaultValues,r,f),Ys(qe(a._formValues,r))&&ts(a._formValues,r,f)}return()=>{(o?m&&!a._state.action:m)?a.unregister(r):h(r,!1)}},[r,a,o,i]),ve.useEffect(()=>{qe(a._fields,r)&&a._updateDisabledField({disabled:n,fields:a._fields,name:r,value:qe(a._fields,r)._f.value})},[n,r,a]),{field:{name:r,value:l,...Zn(n)||c.disabled?{disabled:c.disabled||n}:{},onChange:ve.useCallback(m=>d.current.onChange({target:{value:$T(m),name:r},type:pg.CHANGE}),[r]),onBlur:ve.useCallback(()=>d.current.onBlur({target:{value:qe(a._formValues,r),name:r},type:pg.BLUR}),[r,a]),ref:ve.useCallback(m=>{const h=qe(a._fields,r);h&&m&&(h._f.ref={focus:()=>m.focus(),select:()=>m.select(),setCustomValidity:f=>m.setCustomValidity(f),reportValidity:()=>m.reportValidity()})},[a._fields,r])},formState:c,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!qe(c.errors,r)},isDirty:{enumerable:!0,get:()=>!!qe(c.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!qe(c.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!qe(c.validatingFields,r)},error:{enumerable:!0,get:()=>qe(c.errors,r)}})}}const uJ=e=>e.render(dJ(e));var OT=(e,s,r,n,a)=>s?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:a||!0}}:{},ZS=e=>({isOnSubmit:!e||e===ka.onSubmit,isOnBlur:e===ka.onBlur,isOnChange:e===ka.onChange,isOnAll:e===ka.all,isOnTouch:e===ka.onTouched}),JS=(e,s,r)=>!r&&(s.watchAll||s.watch.has(e)||[...s.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const Km=(e,s,r,n)=>{for(const a of r||Object.keys(e)){const i=qe(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&s(o.refs[0],a)&&!n)return!0;if(o.ref&&s(o.ref,o.name)&&!n)return!0;if(Km(l,s))break}else if(sr(l)&&Km(l,s))break}}};var mJ=(e,s,r)=>{const n=Ym(qe(e,r));return ts(n,"root",s[r]),ts(e,r,n),e},lN=e=>e.type==="file",Ii=e=>typeof e=="function",xg=e=>{if(!aN)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},hx=e=>ai(e),cN=e=>e.type==="radio",gg=e=>e instanceof RegExp;const e3={value:!1,isValid:!1},t3={value:!0,isValid:!0};var IT=e=>{if(Array.isArray(e)){if(e.length>1){const s=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:s,isValid:!!s.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Ys(e[0].attributes.value)?Ys(e[0].value)||e[0].value===""?t3:{value:e[0].value,isValid:!0}:t3:e3}return e3};const s3={isValid:!1,value:null};var FT=e=>Array.isArray(e)?e.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,s3):s3;function r3(e,s,r="validate"){if(hx(e)||Array.isArray(e)&&e.every(hx)||Zn(e)&&!e)return{type:r,message:hx(e)?e:"",ref:s}}var Gc=e=>sr(e)&&!gg(e)?e:{value:e,message:""},n3=async(e,s,r,n,a)=>{const{ref:i,refs:o,required:l,maxLength:c,minLength:d,min:m,max:h,pattern:f,validate:p,name:x,valueAsNumber:g,mount:b,disabled:w}=e._f,j=qe(s,x);if(!b||w)return{};const y=o?o[0]:i,v=P=>{n&&y.reportValidity&&(y.setCustomValidity(Zn(P)?"":P||""),y.reportValidity())},N={},S=cN(i),k=Uf(i),$=S||k,R=(g||lN(i))&&Ys(i.value)&&Ys(j)||xg(i)&&i.value===""||j===""||Array.isArray(j)&&!j.length,A=OT.bind(null,x,r,N),T=(P,B,Y,I=Si.maxLength,C=Si.minLength)=>{const L=P?B:Y;N[x]={type:P?I:C,message:L,ref:i,...A(P?I:C,L)}};if(a?!Array.isArray(j)||!j.length:l&&(!$&&(R||Qr(j))||Zn(j)&&!j||k&&!IT(o).isValid||S&&!FT(o).isValid)){const{value:P,message:B}=hx(l)?{value:!!l,message:l}:Gc(l);if(P&&(N[x]={type:Si.required,message:B,ref:y,...A(Si.required,B)},!r))return v(B),N}if(!R&&(!Qr(m)||!Qr(h))){let P,B;const Y=Gc(h),I=Gc(m);if(!Qr(j)&&!isNaN(j)){const C=i.valueAsNumber||j&&+j;Qr(Y.value)||(P=C>Y.value),Qr(I.value)||(B=C<I.value)}else{const C=i.valueAsDate||new Date(j),L=H=>new Date(new Date().toDateString()+" "+H),D=i.type=="time",_=i.type=="week";ai(Y.value)&&j&&(P=D?L(j)>L(Y.value):_?j>Y.value:C>new Date(Y.value)),ai(I.value)&&j&&(B=D?L(j)<L(I.value):_?j<I.value:C<new Date(I.value))}if((P||B)&&(T(!!P,Y.message,I.message,Si.max,Si.min),!r))return v(N[x].message),N}if((c||d)&&!R&&(ai(j)||a&&Array.isArray(j))){const P=Gc(c),B=Gc(d),Y=!Qr(P.value)&&j.length>+P.value,I=!Qr(B.value)&&j.length<+B.value;if((Y||I)&&(T(Y,P.message,B.message),!r))return v(N[x].message),N}if(f&&!R&&ai(j)){const{value:P,message:B}=Gc(f);if(gg(P)&&!j.match(P)&&(N[x]={type:Si.pattern,message:B,ref:i,...A(Si.pattern,B)},!r))return v(B),N}if(p){if(Ii(p)){const P=await p(j,s),B=r3(P,y);if(B&&(N[x]={...B,...A(Si.validate,B.message)},!r))return v(B.message),N}else if(sr(p)){let P={};for(const B in p){if(!pn(P)&&!r)break;const Y=r3(await p[B](j,s),y,B);Y&&(P={...Y,...A(B,Y.message)},v(Y.message),r&&(N[x]=P))}if(!pn(P)&&(N[x]={ref:y,...P},!r))return N}}return v(!0),N};function hJ(e,s){const r=s.slice(0,-1).length;let n=0;for(;n<r;)e=Ys(e)?n++:e[s[n++]];return e}function fJ(e){for(const s in e)if(e.hasOwnProperty(s)&&!Ys(e[s]))return!1;return!0}function or(e,s){const r=Array.isArray(s)?s:iN(s)?[s]:PT(s),n=r.length===1?e:hJ(e,r),a=r.length-1,i=r[a];return n&&delete n[i],a!==0&&(sr(n)&&pn(n)||Array.isArray(n)&&fJ(n))&&or(e,r.slice(0,-1)),e}var o0=()=>{let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}},Vj=e=>Qr(e)||!kT(e);function _o(e,s){if(Vj(e)||Vj(s))return e===s;if(Ul(e)&&Ul(s))return e.getTime()===s.getTime();const r=Object.keys(e),n=Object.keys(s);if(r.length!==n.length)return!1;for(const a of r){const i=e[a];if(!n.includes(a))return!1;if(a!=="ref"){const o=s[a];if(Ul(i)&&Ul(o)||sr(i)&&sr(o)||Array.isArray(i)&&Array.isArray(o)?!_o(i,o):i!==o)return!1}}return!0}var LT=e=>e.type==="select-multiple",pJ=e=>cN(e)||Uf(e),l0=e=>xg(e)&&e.isConnected,BT=e=>{for(const s in e)if(Ii(e[s]))return!0;return!1};function vg(e,s={}){const r=Array.isArray(e);if(sr(e)||r)for(const n in e)Array.isArray(e[n])||sr(e[n])&&!BT(e[n])?(s[n]=Array.isArray(e[n])?[]:{},vg(e[n],s[n])):Qr(e[n])||(s[n]=!0);return s}function zT(e,s,r){const n=Array.isArray(e);if(sr(e)||n)for(const a in e)Array.isArray(e[a])||sr(e[a])&&!BT(e[a])?Ys(s)||Vj(r[a])?r[a]=Array.isArray(e[a])?vg(e[a],[]):{...vg(e[a])}:zT(e[a],Qr(s)?{}:s[a],r[a]):r[a]=!_o(e[a],s[a]);return r}var mm=(e,s)=>zT(e,s,vg(s)),UT=(e,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>Ys(e)?e:s?e===""?NaN:e&&+e:r&&ai(e)?new Date(e):n?n(e):e;function c0(e){const s=e.ref;if(!(e.refs?e.refs.every(r=>r.disabled):s.disabled))return lN(s)?s.files:cN(s)?FT(e.refs).value:LT(s)?[...s.selectedOptions].map(({value:r})=>r):Uf(s)?IT(e.refs).value:UT(Ys(s.value)?e.ref.value:s.value,e)}var xJ=(e,s,r,n)=>{const a={};for(const i of e){const o=qe(s,i);o&&ts(a,i,o._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:n}},hm=e=>Ys(e)?e:gg(e)?e.source:sr(e)?gg(e.value)?e.value.source:e.value:e;const a3="AsyncFunction";var gJ=e=>(!e||!e.validate)&&!!(Ii(e.validate)&&e.validate.constructor.name===a3||sr(e.validate)&&Object.values(e.validate).find(s=>s.constructor.name===a3)),vJ=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function i3(e,s,r){const n=qe(e,r);if(n||iN(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const i=a.join("."),o=qe(s,i),l=qe(e,i);if(o&&!Array.isArray(o)&&r!==i)return{name:r};if(l&&l.type)return{name:i,error:l};a.pop()}return{name:r}}var yJ=(e,s,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(s||e):(r?n.isOnBlur:a.isOnBlur)?!e:(r?n.isOnChange:a.isOnChange)?e:!0,bJ=(e,s)=>!Uv(qe(e,s)).length&&or(e,s);const jJ={mode:ka.onSubmit,reValidateMode:ka.onChange,shouldFocusError:!0};function wJ(e={}){let s={...jJ,...e},r={submitCount:0,isDirty:!1,isLoading:Ii(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=sr(s.defaultValues)||sr(s.values)?mn(s.defaultValues||s.values)||{}:{},i=s.shouldUnregister?{}:mn(a),o={action:!1,mount:!1,watch:!1},l={mount:new Set,unMount:new Set,array:new Set,watch:new Set},c,d=0;const m={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={values:o0(),array:o0(),state:o0()},f=ZS(s.mode),p=ZS(s.reValidateMode),x=s.criteriaMode===ka.all,g=K=>te=>{clearTimeout(d),d=setTimeout(K,te)},b=async K=>{if(!e.disabled&&(m.isValid||K)){const te=s.resolver?pn((await $()).errors):await A(n,!0);te!==r.isValid&&h.state.next({isValid:te})}},w=(K,te)=>{!e.disabled&&(m.isValidating||m.validatingFields)&&((K||Array.from(l.mount)).forEach(Q=>{Q&&(te?ts(r.validatingFields,Q,te):or(r.validatingFields,Q))}),h.state.next({validatingFields:r.validatingFields,isValidating:!pn(r.validatingFields)}))},j=(K,te=[],Q,ae,me=!0,pe=!0)=>{if(ae&&Q&&!e.disabled){if(o.action=!0,pe&&Array.isArray(qe(n,K))){const be=Q(qe(n,K),ae.argA,ae.argB);me&&ts(n,K,be)}if(pe&&Array.isArray(qe(r.errors,K))){const be=Q(qe(r.errors,K),ae.argA,ae.argB);me&&ts(r.errors,K,be),bJ(r.errors,K)}if(m.touchedFields&&pe&&Array.isArray(qe(r.touchedFields,K))){const be=Q(qe(r.touchedFields,K),ae.argA,ae.argB);me&&ts(r.touchedFields,K,be)}m.dirtyFields&&(r.dirtyFields=mm(a,i)),h.state.next({name:K,isDirty:P(K,te),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ts(i,K,te)},y=(K,te)=>{ts(r.errors,K,te),h.state.next({errors:r.errors})},v=K=>{r.errors=K,h.state.next({errors:r.errors,isValid:!1})},N=(K,te,Q,ae)=>{const me=qe(n,K);if(me){const pe=qe(i,K,Ys(Q)?qe(a,K):Q);Ys(pe)||ae&&ae.defaultChecked||te?ts(i,K,te?pe:c0(me._f)):I(K,pe),o.mount&&b()}},S=(K,te,Q,ae,me)=>{let pe=!1,be=!1;const ce={name:K};if(!e.disabled){const ie=!!(qe(n,K)&&qe(n,K)._f&&qe(n,K)._f.disabled);if(!Q||ae){m.isDirty&&(be=r.isDirty,r.isDirty=ce.isDirty=P(),pe=be!==ce.isDirty);const je=ie||_o(qe(a,K),te);be=!!(!ie&&qe(r.dirtyFields,K)),je||ie?or(r.dirtyFields,K):ts(r.dirtyFields,K,!0),ce.dirtyFields=r.dirtyFields,pe=pe||m.dirtyFields&&be!==!je}if(Q){const je=qe(r.touchedFields,K);je||(ts(r.touchedFields,K,Q),ce.touchedFields=r.touchedFields,pe=pe||m.touchedFields&&je!==Q)}pe&&me&&h.state.next(ce)}return pe?ce:{}},k=(K,te,Q,ae)=>{const me=qe(r.errors,K),pe=m.isValid&&Zn(te)&&r.isValid!==te;if(e.delayError&&Q?(c=g(()=>y(K,Q)),c(e.delayError)):(clearTimeout(d),c=null,Q?ts(r.errors,K,Q):or(r.errors,K)),(Q?!_o(me,Q):me)||!pn(ae)||pe){const be={...ae,...pe&&Zn(te)?{isValid:te}:{},errors:r.errors,name:K};r={...r,...be},h.state.next(be)}},$=async K=>{w(K,!0);const te=await s.resolver(i,s.context,xJ(K||l.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return w(K),te},R=async K=>{const{errors:te}=await $(K);if(K)for(const Q of K){const ae=qe(te,Q);ae?ts(r.errors,Q,ae):or(r.errors,Q)}else r.errors=te;return te},A=async(K,te,Q={valid:!0})=>{for(const ae in K){const me=K[ae];if(me){const{_f:pe,...be}=me;if(pe){const ce=l.array.has(pe.name),ie=me._f&&gJ(me._f);ie&&m.validatingFields&&w([ae],!0);const je=await n3(me,i,x,s.shouldUseNativeValidation&&!te,ce);if(ie&&m.validatingFields&&w([ae]),je[pe.name]&&(Q.valid=!1,te))break;!te&&(qe(je,pe.name)?ce?mJ(r.errors,je,pe.name):ts(r.errors,pe.name,je[pe.name]):or(r.errors,pe.name))}!pn(be)&&await A(be,te,Q)}}return Q.valid},T=()=>{for(const K of l.unMount){const te=qe(n,K);te&&(te._f.refs?te._f.refs.every(Q=>!l0(Q)):!l0(te._f.ref))&&Z(K)}l.unMount=new Set},P=(K,te)=>!e.disabled&&(K&&te&&ts(i,K,te),!_o(O(),a)),B=(K,te,Q)=>MT(K,l,{...o.mount?i:Ys(te)?a:ai(K)?{[K]:te}:te},Q,te),Y=K=>Uv(qe(o.mount?i:a,K,e.shouldUnregister?qe(a,K,[]):[])),I=(K,te,Q={})=>{const ae=qe(n,K);let me=te;if(ae){const pe=ae._f;pe&&(!pe.disabled&&ts(i,K,UT(te,pe)),me=xg(pe.ref)&&Qr(te)?"":te,LT(pe.ref)?[...pe.ref.options].forEach(be=>be.selected=me.includes(be.value)):pe.refs?Uf(pe.ref)?pe.refs.length>1?pe.refs.forEach(be=>(!be.defaultChecked||!be.disabled)&&(be.checked=Array.isArray(me)?!!me.find(ce=>ce===be.value):me===be.value)):pe.refs[0]&&(pe.refs[0].checked=!!me):pe.refs.forEach(be=>be.checked=be.value===me):lN(pe.ref)?pe.ref.value="":(pe.ref.value=me,pe.ref.type||h.values.next({name:K,values:{...i}})))}(Q.shouldDirty||Q.shouldTouch)&&S(K,me,Q.shouldTouch,Q.shouldDirty,!0),Q.shouldValidate&&H(K)},C=(K,te,Q)=>{for(const ae in te){const me=te[ae],pe=`${K}.${ae}`,be=qe(n,pe);(l.array.has(K)||sr(me)||be&&!be._f)&&!Ul(me)?C(pe,me,Q):I(pe,me,Q)}},L=(K,te,Q={})=>{const ae=qe(n,K),me=l.array.has(K),pe=mn(te);ts(i,K,pe),me?(h.array.next({name:K,values:{...i}}),(m.isDirty||m.dirtyFields)&&Q.shouldDirty&&h.state.next({name:K,dirtyFields:mm(a,i),isDirty:P(K,pe)})):ae&&!ae._f&&!Qr(pe)?C(K,pe,Q):I(K,pe,Q),JS(K,l)&&h.state.next({...r}),h.values.next({name:o.mount?K:void 0,values:{...i}})},D=async K=>{o.mount=!0;const te=K.target;let Q=te.name,ae=!0;const me=qe(n,Q),pe=()=>te.type?c0(me._f):$T(K),be=ce=>{ae=Number.isNaN(ce)||Ul(ce)&&isNaN(ce.getTime())||_o(ce,qe(i,Q,ce))};if(me){let ce,ie;const je=pe(),Re=K.type===pg.BLUR||K.type===pg.FOCUS_OUT,Ae=!vJ(me._f)&&!s.resolver&&!qe(r.errors,Q)&&!me._f.deps||yJ(Re,qe(r.touchedFields,Q),r.isSubmitted,p,f),Ue=JS(Q,l,Re);ts(i,Q,je),Re?(me._f.onBlur&&me._f.onBlur(K),c&&c(0)):me._f.onChange&&me._f.onChange(K);const Ve=S(Q,je,Re,!1),lt=!pn(Ve)||Ue;if(!Re&&h.values.next({name:Q,type:K.type,values:{...i}}),Ae)return m.isValid&&(e.mode==="onBlur"?Re&&b():b()),lt&&h.state.next({name:Q,...Ue?{}:Ve});if(!Re&&Ue&&h.state.next({...r}),s.resolver){const{errors:J}=await $([Q]);if(be(je),ae){const Ne=i3(r.errors,n,Q),gt=i3(J,n,Ne.name||Q);ce=gt.error,Q=gt.name,ie=pn(J)}}else w([Q],!0),ce=(await n3(me,i,x,s.shouldUseNativeValidation))[Q],w([Q]),be(je),ae&&(ce?ie=!1:m.isValid&&(ie=await A(n,!0)));ae&&(me._f.deps&&H(me._f.deps),k(Q,ie,ce,Ve))}},_=(K,te)=>{if(qe(r.errors,te)&&K.focus)return K.focus(),1},H=async(K,te={})=>{let Q,ae;const me=Ym(K);if(s.resolver){const pe=await R(Ys(K)?K:me);Q=pn(pe),ae=K?!me.some(be=>qe(pe,be)):Q}else K?(ae=(await Promise.all(me.map(async pe=>{const be=qe(n,pe);return await A(be&&be._f?{[pe]:be}:be)}))).every(Boolean),!(!ae&&!r.isValid)&&b()):ae=Q=await A(n);return h.state.next({...!ai(K)||m.isValid&&Q!==r.isValid?{}:{name:K},...s.resolver||!K?{isValid:Q}:{},errors:r.errors}),te.shouldFocus&&!ae&&Km(n,_,K?me:l.mount),ae},O=K=>{const te={...o.mount?i:a};return Ys(K)?te:ai(K)?qe(te,K):K.map(Q=>qe(te,Q))},U=(K,te)=>({invalid:!!qe((te||r).errors,K),isDirty:!!qe((te||r).dirtyFields,K),error:qe((te||r).errors,K),isValidating:!!qe(r.validatingFields,K),isTouched:!!qe((te||r).touchedFields,K)}),G=K=>{K&&Ym(K).forEach(te=>or(r.errors,te)),h.state.next({errors:K?r.errors:{}})},E=(K,te,Q)=>{const ae=(qe(n,K,{_f:{}})._f||{}).ref,me=qe(r.errors,K)||{},{ref:pe,message:be,type:ce,...ie}=me;ts(r.errors,K,{...ie,...te,ref:ae}),h.state.next({name:K,errors:r.errors,isValid:!1}),Q&&Q.shouldFocus&&ae&&ae.focus&&ae.focus()},z=(K,te)=>Ii(K)?h.values.subscribe({next:Q=>K(B(void 0,te),Q)}):B(K,te,!0),Z=(K,te={})=>{for(const Q of K?Ym(K):l.mount)l.mount.delete(Q),l.array.delete(Q),te.keepValue||(or(n,Q),or(i,Q)),!te.keepError&&or(r.errors,Q),!te.keepDirty&&or(r.dirtyFields,Q),!te.keepTouched&&or(r.touchedFields,Q),!te.keepIsValidating&&or(r.validatingFields,Q),!s.shouldUnregister&&!te.keepDefaultValue&&or(a,Q);h.values.next({values:{...i}}),h.state.next({...r,...te.keepDirty?{isDirty:P()}:{}}),!te.keepIsValid&&b()},M=({disabled:K,name:te,field:Q,fields:ae,value:me})=>{if(Zn(K)&&o.mount||K){const pe=K?void 0:Ys(me)?c0(Q?Q._f:qe(ae,te)._f):me;ts(i,te,pe),S(te,pe,!1,!1,!0)}},F=(K,te={})=>{let Q=qe(n,K);const ae=Zn(te.disabled)||Zn(e.disabled);return ts(n,K,{...Q||{},_f:{...Q&&Q._f?Q._f:{ref:{name:K}},name:K,mount:!0,...te}}),l.mount.add(K),Q?M({field:Q,disabled:Zn(te.disabled)?te.disabled:e.disabled,name:K,value:te.value}):N(K,!0,te.value),{...ae?{disabled:te.disabled||e.disabled}:{},...s.progressive?{required:!!te.required,min:hm(te.min),max:hm(te.max),minLength:hm(te.minLength),maxLength:hm(te.maxLength),pattern:hm(te.pattern)}:{},name:K,onChange:D,onBlur:D,ref:me=>{if(me){F(K,te),Q=qe(n,K);const pe=Ys(me.value)&&me.querySelectorAll&&me.querySelectorAll("input,select,textarea")[0]||me,be=pJ(pe),ce=Q._f.refs||[];if(be?ce.find(ie=>ie===pe):pe===Q._f.ref)return;ts(n,K,{_f:{...Q._f,...be?{refs:[...ce.filter(l0),pe,...Array.isArray(qe(a,K))?[{}]:[]],ref:{type:pe.type,name:K}}:{ref:pe}}}),N(K,!1,void 0,pe)}else Q=qe(n,K,{}),Q._f&&(Q._f.mount=!1),(s.shouldUnregister||te.shouldUnregister)&&!(ET(l.array,K)&&o.action)&&l.unMount.add(K)}}},ee=()=>s.shouldFocusError&&Km(n,_,l.mount),se=K=>{Zn(K)&&(h.state.next({disabled:K}),Km(n,(te,Q)=>{const ae=qe(n,Q);ae&&(te.disabled=ae._f.disabled||K,Array.isArray(ae._f.refs)&&ae._f.refs.forEach(me=>{me.disabled=ae._f.disabled||K}))},0,!1))},le=(K,te)=>async Q=>{let ae;Q&&(Q.preventDefault&&Q.preventDefault(),Q.persist&&Q.persist());let me=mn(i);if(h.state.next({isSubmitting:!0}),s.resolver){const{errors:pe,values:be}=await $();r.errors=pe,me=be}else await A(n);if(or(r.errors,"root"),pn(r.errors)){h.state.next({errors:{}});try{await K(me,Q)}catch(pe){ae=pe}}else te&&await te({...r.errors},Q),ee(),setTimeout(ee);if(h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:pn(r.errors)&&!ae,submitCount:r.submitCount+1,errors:r.errors}),ae)throw ae},X=(K,te={})=>{qe(n,K)&&(Ys(te.defaultValue)?L(K,mn(qe(a,K))):(L(K,te.defaultValue),ts(a,K,mn(te.defaultValue))),te.keepTouched||or(r.touchedFields,K),te.keepDirty||(or(r.dirtyFields,K),r.isDirty=te.defaultValue?P(K,mn(qe(a,K))):P()),te.keepError||(or(r.errors,K),m.isValid&&b()),h.state.next({...r}))},ye=(K,te={})=>{const Q=K?mn(K):a,ae=mn(Q),me=pn(K),pe=me?a:ae;if(te.keepDefaultValues||(a=Q),!te.keepValues){if(te.keepDirtyValues){const be=new Set([...l.mount,...Object.keys(mm(a,i))]);for(const ce of Array.from(be))qe(r.dirtyFields,ce)?ts(pe,ce,qe(i,ce)):L(ce,qe(pe,ce))}else{if(aN&&Ys(K))for(const be of l.mount){const ce=qe(n,be);if(ce&&ce._f){const ie=Array.isArray(ce._f.refs)?ce._f.refs[0]:ce._f.ref;if(xg(ie)){const je=ie.closest("form");if(je){je.reset();break}}}}n={}}i=e.shouldUnregister?te.keepDefaultValues?mn(a):{}:mn(pe),h.array.next({values:{...pe}}),h.values.next({values:{...pe}})}l={mount:te.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!m.isValid||!!te.keepIsValid||!!te.keepDirtyValues,o.watch=!!e.shouldUnregister,h.state.next({submitCount:te.keepSubmitCount?r.submitCount:0,isDirty:me?!1:te.keepDirty?r.isDirty:!!(te.keepDefaultValues&&!_o(K,a)),isSubmitted:te.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:me?{}:te.keepDirtyValues?te.keepDefaultValues&&i?mm(a,i):r.dirtyFields:te.keepDefaultValues&&K?mm(a,K):te.keepDirty?r.dirtyFields:{},touchedFields:te.keepTouched?r.touchedFields:{},errors:te.keepErrors?r.errors:{},isSubmitSuccessful:te.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Ce=(K,te)=>ye(Ii(K)?K(i):K,te);return{control:{register:F,unregister:Z,getFieldState:U,handleSubmit:le,setError:E,_executeSchema:$,_getWatch:B,_getDirty:P,_updateValid:b,_removeUnmounted:T,_updateFieldArray:j,_updateDisabledField:M,_getFieldArray:Y,_reset:ye,_resetDefaultValues:()=>Ii(s.defaultValues)&&s.defaultValues().then(K=>{Ce(K,s.resetOptions),h.state.next({isLoading:!1})}),_updateFormState:K=>{r={...r,...K}},_disableForm:se,_subjects:h,_proxyFormState:m,_setErrors:v,get _fields(){return n},get _formValues(){return i},get _state(){return o},set _state(K){o=K},get _defaultValues(){return a},get _names(){return l},set _names(K){l=K},get _formState(){return r},set _formState(K){r=K},get _options(){return s},set _options(K){s={...s,...K}}},trigger:H,register:F,handleSubmit:le,watch:z,setValue:L,getValues:O,reset:Ce,resetField:X,clearErrors:G,unregister:Z,setError:E,setFocus:(K,te={})=>{const Q=qe(n,K),ae=Q&&Q._f;if(ae){const me=ae.refs?ae.refs[0]:ae.ref;me.focus&&(me.focus(),te.shouldSelect&&me.select())}},getFieldState:U}}function NJ(e={}){const s=ve.useRef(),r=ve.useRef(),[n,a]=ve.useState({isDirty:!1,isValidating:!1,isLoading:Ii(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Ii(e.defaultValues)?void 0:e.defaultValues});s.current||(s.current={...wJ(e),formState:n});const i=s.current.control;return i._options=e,oN({subject:i._subjects.state,next:o=>{DT(o,i._proxyFormState,i._updateFormState,!0)&&a({...i._formState})}}),ve.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),ve.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==n.isDirty&&i._subjects.state.next({isDirty:o})}},[i,n.isDirty]),ve.useEffect(()=>{e.values&&!_o(e.values,r.current)?(i._reset(e.values,i._options.resetOptions),r.current=e.values,a(o=>({...o}))):i._resetDefaultValues()},[e.values,i]),ve.useEffect(()=>{e.errors&&i._setErrors(e.errors)},[e.errors,i]),ve.useEffect(()=>{i._state.mount||(i._updateValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),ve.useEffect(()=>{e.shouldUnregister&&i._subjects.values.next({values:i._getWatch()})},[e.shouldUnregister,i]),ve.useEffect(()=>{s.current&&(s.current.watch=s.current.watch.bind({}))},[n]),s.current.formState=TT(n,i),s.current}const o3=(e,s,r)=>{if(e&&"reportValidity"in e){const n=qe(r,s);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},VT=(e,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?o3(n.ref,r,e):n.refs&&n.refs.forEach(a=>o3(a,r,e))}},_J=(e,s)=>{s.shouldUseNativeValidation&&VT(e,s);const r={};for(const n in e){const a=qe(s.fields,n),i=Object.assign(e[n]||{},{ref:a&&a.ref});if(SJ(s.names||Object.keys(e),n)){const o=Object.assign({},qe(r,n));ts(o,"root",i),ts(r,n,o)}else ts(r,n,i)}return r},SJ=(e,s)=>e.some(r=>r.startsWith(s+"."));var CJ=function(e,s){for(var r={};e.length;){var n=e[0],a=n.code,i=n.message,o=n.path.join(".");if(!r[o])if("unionErrors"in n){var l=n.unionErrors[0].errors[0];r[o]={message:l.message,type:l.code}}else r[o]={message:i,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(m){return m.errors.forEach(function(h){return e.push(h)})}),s){var c=r[o].types,d=c&&c[n.code];r[o]=OT(o,s,r,a,d?[].concat(d,n.message):n.message)}e.shift()}return r},kJ=function(e,s,r){return r===void 0&&(r={}),function(n,a,i){try{return Promise.resolve(function(o,l){try{var c=Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](n,s)).then(function(d){return i.shouldUseNativeValidation&&VT({},i),{errors:{},values:r.raw?n:d}})}catch(d){return l(d)}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:_J(CJ(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}}},Gt;(function(e){e.assertEqual=a=>a;function s(a){}e.assertIs=s;function r(a){throw new Error}e.assertNever=r,e.arrayToEnum=a=>{const i={};for(const o of a)i[o]=o;return i},e.getValidEnumValues=a=>{const i=e.objectKeys(a).filter(l=>typeof a[a[l]]!="number"),o={};for(const l of i)o[l]=a[l];return e.objectValues(o)},e.objectValues=a=>e.objectKeys(a).map(function(i){return a[i]}),e.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const i=[];for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&i.push(o);return i},e.find=(a,i)=>{for(const o of a)if(i(o))return o},e.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&isFinite(a)&&Math.floor(a)===a;function n(a,i=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}e.joinValues=n,e.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(Gt||(Gt={}));var qj;(function(e){e.mergeShapes=(s,r)=>({...s,...r})})(qj||(qj={}));const Je=Gt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),So=e=>{switch(typeof e){case"undefined":return Je.undefined;case"string":return Je.string;case"number":return isNaN(e)?Je.nan:Je.number;case"boolean":return Je.boolean;case"function":return Je.function;case"bigint":return Je.bigint;case"symbol":return Je.symbol;case"object":return Array.isArray(e)?Je.array:e===null?Je.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Je.promise:typeof Map<"u"&&e instanceof Map?Je.map:typeof Set<"u"&&e instanceof Set?Je.set:typeof Date<"u"&&e instanceof Date?Je.date:Je.object;default:return Je.unknown}},Fe=Gt.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"]),$J=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class In extends Error{constructor(s){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=s}get errors(){return this.issues}format(s){const r=s||function(i){return i.message},n={_errors:[]},a=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let l=n,c=0;for(;c<o.path.length;){const d=o.path[c];c===o.path.length-1?(l[d]=l[d]||{_errors:[]},l[d]._errors.push(r(o))):l[d]=l[d]||{_errors:[]},l=l[d],c++}}};return a(this),n}static assert(s){if(!(s instanceof In))throw new Error(`Not a ZodError: ${s}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Gt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(s=r=>r.message){const r={},n=[];for(const a of this.issues)a.path.length>0?(r[a.path[0]]=r[a.path[0]]||[],r[a.path[0]].push(s(a))):n.push(s(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}In.create=e=>new In(e);const uu=(e,s)=>{let r;switch(e.code){case Fe.invalid_type:e.received===Je.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case Fe.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Gt.jsonStringifyReplacer)}`;break;case Fe.unrecognized_keys:r=`Unrecognized key(s) in object: ${Gt.joinValues(e.keys,", ")}`;break;case Fe.invalid_union:r="Invalid input";break;case Fe.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Gt.joinValues(e.options)}`;break;case Fe.invalid_enum_value:r=`Invalid enum value. Expected ${Gt.joinValues(e.options)}, received '${e.received}'`;break;case Fe.invalid_arguments:r="Invalid function arguments";break;case Fe.invalid_return_type:r="Invalid function return type";break;case Fe.invalid_date:r="Invalid date";break;case Fe.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Gt.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case Fe.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case Fe.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case Fe.custom:r="Invalid input";break;case Fe.invalid_intersection_types:r="Intersection results could not be merged";break;case Fe.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case Fe.not_finite:r="Number must be finite";break;default:r=s.defaultError,Gt.assertNever(e)}return{message:r}};let qT=uu;function EJ(e){qT=e}function yg(){return qT}const bg=e=>{const{data:s,path:r,errorMaps:n,issueData:a}=e,i=[...r,...a.path||[]],o={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let l="";const c=n.filter(d=>!!d).slice().reverse();for(const d of c)l=d(o,{data:s,defaultError:l}).message;return{...a,path:i,message:l}},PJ=[];function Ye(e,s){const r=yg(),n=bg({issueData:s,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===uu?void 0:uu].filter(a=>!!a)});e.common.issues.push(n)}class Vr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(s,r){const n=[];for(const a of r){if(a.status==="aborted")return yt;a.status==="dirty"&&s.dirty(),n.push(a.value)}return{status:s.value,value:n}}static async mergeObjectAsync(s,r){const n=[];for(const a of r){const i=await a.key,o=await a.value;n.push({key:i,value:o})}return Vr.mergeObjectSync(s,n)}static mergeObjectSync(s,r){const n={};for(const a of r){const{key:i,value:o}=a;if(i.status==="aborted"||o.status==="aborted")return yt;i.status==="dirty"&&s.dirty(),o.status==="dirty"&&s.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(n[i.value]=o.value)}return{status:s.value,value:n}}}const yt=Object.freeze({status:"aborted"}),xd=e=>({status:"dirty",value:e}),rn=e=>
vendor: 4,211 bytes, line 741
741({status:"valid",value:e}),Hj=e=>e.status==="aborted",Wj=e=>e.status==="dirty",Mh=e=>e.status==="valid",Oh=e=>typeof Promise<"u"&&e instanceof Promise;function jg(e,s,r,n){if(typeof s=="function"?e!==s||!n:!s.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return s.get(e)}function HT(e,s,r,n,a){if(typeof s=="function"?e!==s||!a:!s.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s.set(e,r),r}var nt;(function(e){e.errToObj=s=>typeof s=="string"?{message:s}:s||{},e.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(nt||(nt={}));var Em,Pm;class gi{constructor(s,r,n,a){this._cachedPath=[],this.parent=s,this.data=r,this._path=n,this._key=a}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const l3=(e,s)=>{if(Mh(s))return{success:!0,data:s.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 r=new In(e.common.issues);return this._error=r,this._error}}};function $t(e){if(!e)return{};const{errorMap:s,invalid_type_error:r,required_error:n,description:a}=e;if(s&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return s?{errorMap:s,description:a}:{errorMap:(o,l)=>{var c,d;const{message:m}=e;return o.code==="invalid_enum_value"?{message:m??l.defaultError}:typeof l.data>"u"?{message:(c=m??n)!==null&&c!==void 0?c:l.defaultError}:o.code!=="invalid_type"?{message:l.defaultError}:{message:(d=m??r)!==null&&d!==void 0?d:l.defaultError}},description:a}}class Ft{constructor(s){this.spa=this.safeParseAsync,this._def=s,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(s){return So(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:So(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new Vr,ctx:{common:s.parent.common,data:s.data,parsedType:So(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(Oh(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(s){const r=this._parse(s);return Promise.resolve(r)}parse(s,r){const n=this.safeParse(s,r);if(n.success)return n.data;throw n.error}safeParse(s,r){var n;const a={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:So(s)},i=this._parseSync({data:s,path:a.path,parent:a});return l3(a,i)}async parseAsync(s,r){const n=await this.safeParseAsync(s,r);if(n.success)return n.data;throw n.error}async safeParseAsync(s,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:So(s)},a=this._parse({data:s,path:n.path,parent:n}),i=await(Oh(a)?a:Promise.resolve(a));return l3(n,i)}refine(s,r){const n=a=>typeof r=="string"||typeof r>"u"?{message:r}
vendor: 47,684 bytes, line 741
741:typeof r=="function"?r(a):r;return this._refinement((a,i)=>{const o=s(a),l=()=>i.addIssue({code:Fe.custom,...n(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(s,r){return this._refinement((n,a)=>s(n)?!0:(a.addIssue(typeof r=="function"?r(n,a):r),!1))}_refinement(s){return new La({schema:this,typeName:pt.ZodEffects,effect:{type:"refinement",refinement:s}})}superRefine(s){return this._refinement(s)}optional(){return fi.create(this,this._def)}nullable(){return ul.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ta.create(this,this._def)}promise(){return hu.create(this,this._def)}or(s){return Bh.create([this,s],this._def)}and(s){return zh.create(this,s,this._def)}transform(s){return new La({...$t(this._def),schema:this,typeName:pt.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new Wh({...$t(this._def),innerType:this,defaultValue:r,typeName:pt.ZodDefault})}brand(){return new dN({typeName:pt.ZodBranded,type:this,...$t(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new Gh({...$t(this._def),innerType:this,catchValue:r,typeName:pt.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return Vf.create(this,s)}readonly(){return Yh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const AJ=/^c[^\s-]{8,}$/i,TJ=/^[0-9a-z]+$/,DJ=/^[0-9A-HJKMNP-TV-Z]{26}$/,RJ=/^[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,MJ=/^[a-z0-9_-]{21}$/i,OJ=/^[-+]?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)?)??$/,IJ=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,FJ="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let d0;const LJ=/^(?:(?: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])$/,BJ=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,zJ=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,WT="((\\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])))",UJ=new RegExp(`^${WT}$`);function GT(e){let s="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?s=`${s}\\.\\d{${e.precision}}`:e.precision==null&&(s=`${s}(\\.\\d+)?`),s}function VJ(e){return new RegExp(`^${GT(e)}$`)}function YT(e){let s=`${WT}T${GT(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),s=`${s}(${r.join("|")})`,new RegExp(`^${s}$`)}function qJ(e,s){return!!((s==="v4"||!s)&&LJ.test(e)||(s==="v6"||!s)&&BJ.test(e))}class $a extends Ft{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==Je.string){const i=this._getOrReturnCtx(s);return Ye(i,{code:Fe.invalid_type,expected:Je.string,received:i.parsedType}),yt}const n=new Vr;let a;for(const i of this._def.checks)if(i.kind==="min")s.data.length<i.value&&(a=this._getOrReturnCtx(s,a),Ye(a,{code:Fe.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")s.data.length>i.value&&(a=this._getOrReturnCtx(s,a),Ye(a,{code:Fe.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const o=s.data.length>i.value,l=s.data.length<i.value;(o||l)&&(a=this._getOrReturnCtx(s,a),o?Ye(a,{code:Fe.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&Ye(a,{code:Fe.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")IJ.test(s.data)||(a=this._getOrReturnCtx(s,a),Ye(a,{validation:"email",code:Fe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")d0||(d0=new RegExp(FJ,"u")),d0.test(s.data)||(a=this._getOrReturnCtx(s,a),Ye(a,{validation:"emoji",code:Fe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")RJ.test(s.data)||(a=this._getOrReturnCtx(s,a),Ye(a,{validation:"uuid",code:Fe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")MJ.test(s.data)||(a=this._getOrReturnCtx(s,a),Ye(a,{validation:"nanoid",code:Fe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")AJ.test(s.data)||(a=this._getOrReturnCtx(s,a),Ye(a,{validation:"cuid",code:Fe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")TJ.test(s.data)||(a=this._getOrReturnCtx(s,a),Ye(a,{validation:"cuid2",code:Fe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")DJ.test(s.data)||(a=this._getOrReturnCtx(s,a),Ye(a,{validation:"ulid",code:Fe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(s.data)}catch{a=this._getOrReturnCtx(s,a),Ye(a,{validation:"url",code:Fe.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(s.data)||(a=this._getOrReturnCtx(s,a),Ye(a,{validation:"regex",code:Fe.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?s.data=s.data.trim():i.kind==="includes"?s.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(s,a),Ye(a,{code:Fe.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?s.data=s.data.toLowerCase():i.kind==="toUpperCase"?s.data=s.data.toUpperCase():i.kind==="startsWith"?s.data.startsWith(i.value)||(a=this._getOrReturnCtx(s,a),Ye(a,{code:Fe.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?s.data.endsWith(i.value)||(a=this._getOrReturnCtx(s,a),Ye(a,{code:Fe.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?YT(i).test(s.data)||(a=this._getOrReturnCtx(s,a),Ye(a,{code:Fe.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?UJ.test(s.data)||(a=this._getOrReturnCtx(s,a),Ye(a,{code:Fe.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?VJ(i).test(s.data)||(a=this._getOrReturnCtx(s,a),Ye(a,{code:Fe.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?OJ.test(s.data)||(a=this._getOrReturnCtx(s,a),Ye(a,{validation:"duration",code:Fe.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?qJ(s.data,i.version)||(a=this._getOrReturnCtx(s,a),Ye(a,{validation:"ip",code:Fe.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?zJ.test(s.data)||(a=this._getOrReturnCtx(s,a),Ye(a,{validation:"base64",code:Fe.invalid_string,message:i.message}),n.dirty()):Gt.assertNever(i);return{status:n.value,value:s.data}}_regex(s,r,n){return this.refinement(a=>s.test(a),{validation:r,code:Fe.invalid_string,...nt.errToObj(n)})}_addCheck(s){return new $a({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...nt.errToObj(s)})}url(s){return this._addCheck({kind:"url",...nt.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...nt.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...nt.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...nt.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...nt.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...nt.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...nt.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...nt.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...nt.errToObj(s)})}datetime(s){var r,n;return typeof s=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:s}):this._addCheck({kind:"datetime",precision:typeof(s==null?void 0:s.precision)>"u"?null:s==null?void 0:s.precision,offset:(r=s==null?void 0:s.offset)!==null&&r!==void 0?r:!1,local:(n=s==null?void 0:s.local)!==null&&n!==void 0?n:!1,...nt.errToObj(s==null?void 0:s.message)})}date(s){return this._addCheck({kind:"date",message:s})}time(s){return typeof s=="string"?this._addCheck({kind:"time",precision:null,message:s}):this._addCheck({kind:"time",precision:typeof(s==null?void 0:s.precision)>"u"?null:s==null?void 0:s.precision,...nt.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",...nt.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...nt.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,...nt.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...nt.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...nt.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...nt.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...nt.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...nt.errToObj(r)})}nonempty(s){return this.min(1,nt.errToObj(s))}trim(){return new $a({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $a({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $a({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(s=>s.kind==="datetime")}get isDate(){return!!this._def.checks.find(s=>s.kind==="date")}get isTime(){return!!this._def.checks.find(s=>s.kind==="time")}get isDuration(){return!!this._def.checks.find(s=>s.kind==="duration")}get isEmail(){return!!this._def.checks.find(s=>s.kind==="email")}get isURL(){return!!this._def.checks.find(s=>s.kind==="url")}get isEmoji(){return!!this._def.checks.find(s=>s.kind==="emoji")}get isUUID(){return!!this._def.checks.find(s=>s.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(s=>s.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(s=>s.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(s=>s.kind==="cuid2")}get isULID(){return!!this._def.checks.find(s=>s.kind==="ulid")}get isIP(){return!!this._def.checks.find(s=>s.kind==="ip")}get isBase64(){return!!this._def.checks.find(s=>s.kind==="base64")}get minLength(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxLength(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.value<s)&&(s=r.value);return s}}$a.create=e=>{var s;return new $a({checks:[],typeName:pt.ZodString,coerce:(s=e==null?void 0:e.coerce)!==null&&s!==void 0?s:!1,...$t(e)})};function HJ(e,s){const r=(e.toString().split(".")[1]||"").length,n=(s.toString().split(".")[1]||"").length,a=r>n?r:n,i=parseInt(e.toFixed(a).replace(".","")),o=parseInt(s.toFixed(a).replace(".",""));return i%o/Math.pow(10,a)}class ll extends Ft{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(s){if(this._def.coerce&&(s.data=Number(s.data)),this._getType(s)!==Je.number){const i=this._getOrReturnCtx(s);return Ye(i,{code:Fe.invalid_type,expected:Je.number,received:i.parsedType}),yt}let n;const a=new Vr;for(const i of this._def.checks)i.kind==="int"?Gt.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),Ye(n,{code:Fe.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?s.data<i.value:s.data<=i.value)&&(n=this._getOrReturnCtx(s,n),Ye(n,{code:Fe.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?s.data>i.value:s.data>=i.value)&&(n=this._getOrReturnCtx(s,n),Ye(n,{code:Fe.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?HJ(s.data,i.value)!==0&&(n=this._getOrReturnCtx(s,n),Ye(n,{code:Fe.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),Ye(n,{code:Fe.not_finite,message:i.message}),a.dirty()):Gt.assertNever(i);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,nt.toString(r))}gt(s,r){return this.setLimit("min",s,!1,nt.toString(r))}lte(s,r){return this.setLimit("max",s,!0,nt.toString(r))}lt(s,r){return this.setLimit("max",s,!1,nt.toString(r))}setLimit(s,r,n,a){return new ll({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:nt.toString(a)}]})}_addCheck(s){return new ll({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:nt.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:nt.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:nt.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:nt.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:nt.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:nt.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:nt.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:nt.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:nt.toString(s)})}get minValue(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxValue(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.value<s)&&(s=r.value);return s}get isInt(){return!!this._def.checks.find(s=>s.kind==="int"||s.kind==="multipleOf"&&Gt.isInteger(s.value))}get isFinite(){let s=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(s===null||n.value<s)&&(s=n.value)}return Number.isFinite(r)&&Number.isFinite(s)}}ll.create=e=>new ll({checks:[],typeName:pt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...$t(e)});class cl extends Ft{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(s){if(this._def.coerce&&(s.data=BigInt(s.data)),this._getType(s)!==Je.bigint){const i=this._getOrReturnCtx(s);return Ye(i,{code:Fe.invalid_type,expected:Je.bigint,received:i.parsedType}),yt}let n;const a=new Vr;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?s.data<i.value:s.data<=i.value)&&(n=this._getOrReturnCtx(s,n),Ye(n,{code:Fe.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?s.data>i.value:s.data>=i.value)&&(n=this._getOrReturnCtx(s,n),Ye(n,{code:Fe.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?s.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(s,n),Ye(n,{code:Fe.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):Gt.assertNever(i);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,nt.toString(r))}gt(s,r){return this.setLimit("min",s,!1,nt.toString(r))}lte(s,r){return this.setLimit("max",s,!0,nt.toString(r))}lt(s,r){return this.setLimit("max",s,!1,nt.toString(r))}setLimit(s,r,n,a){return new cl({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:nt.toString(a)}]})}_addCheck(s){return new cl({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:nt.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:nt.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:nt.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:nt.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:nt.toString(r)})}get minValue(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxValue(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.value<s)&&(s=r.value);return s}}cl.create=e=>{var s;return new cl({checks:[],typeName:pt.ZodBigInt,coerce:(s=e==null?void 0:e.coerce)!==null&&s!==void 0?s:!1,...$t(e)})};class Ih extends Ft{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==Je.boolean){const n=this._getOrReturnCtx(s);return Ye(n,{code:Fe.invalid_type,expected:Je.boolean,received:n.parsedType}),yt}return rn(s.data)}}Ih.create=e=>new Ih({typeName:pt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...$t(e)});class bc extends Ft{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==Je.date){const i=this._getOrReturnCtx(s);return Ye(i,{code:Fe.invalid_type,expected:Je.date,received:i.parsedType}),yt}if(isNaN(s.data.getTime())){const i=this._getOrReturnCtx(s);return Ye(i,{code:Fe.invalid_date}),yt}const n=new Vr;let a;for(const i of this._def.checks)i.kind==="min"?s.data.getTime()<i.value&&(a=this._getOrReturnCtx(s,a),Ye(a,{code:Fe.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?s.data.getTime()>i.value&&(a=this._getOrReturnCtx(s,a),Ye(a,{code:Fe.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Gt.assertNever(i);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new bc({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:nt.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:nt.toString(r)})}get minDate(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s!=null?new Date(s):null}get maxDate(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.value<s)&&(s=r.value);return s!=null?new Date(s):null}}bc.create=e=>new bc({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:pt.ZodDate,...$t(e)});class wg extends Ft{_parse(s){if(this._getType(s)!==Je.symbol){const n=this._getOrReturnCtx(s);return Ye(n,{code:Fe.invalid_type,expected:Je.symbol,received:n.parsedType}),yt}return rn(s.data)}}wg.create=e=>new wg({typeName:pt.ZodSymbol,...$t(e)});class Fh extends Ft{_parse(s){if(this._getType(s)!==Je.undefined){const n=this._getOrReturnCtx(s);return Ye(n,{code:Fe.invalid_type,expected:Je.undefined,received:n.parsedType}),yt}return rn(s.data)}}Fh.create=e=>new Fh({typeName:pt.ZodUndefined,...$t(e)});class Lh extends Ft{_parse(s){if(this._getType(s)!==Je.null){const n=this._getOrReturnCtx(s);return Ye(n,{code:Fe.invalid_type,expected:Je.null,received:n.parsedType}),yt}return rn(s.data)}}Lh.create=e=>new Lh({typeName:pt.ZodNull,...$t(e)});class mu extends Ft{constructor(){super(...arguments),this._any=!0}_parse(s){return rn(s.data)}}mu.create=e=>new mu({typeName:pt.ZodAny,...$t(e)});class rc extends Ft{constructor(){super(...arguments),this._unknown=!0}_parse(s){return rn(s.data)}}rc.create=e=>new rc({typeName:pt.ZodUnknown,...$t(e)});class Qi extends Ft{_parse(s){const r=this._getOrReturnCtx(s);return Ye(r,{code:Fe.invalid_type,expected:Je.never,received:r.parsedType}),yt}}Qi.create=e=>new Qi({typeName:pt.ZodNever,...$t(e)});class Ng extends Ft{_parse(s){if(this._getType(s)!==Je.undefined){const n=this._getOrReturnCtx(s);return Ye(n,{code:Fe.invalid_type,expected:Je.void,received:n.parsedType}),yt}return rn(s.data)}}Ng.create=e=>new Ng({typeName:pt.ZodVoid,...$t(e)});class Ta extends Ft{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==Je.array)return Ye(r,{code:Fe.invalid_type,expected:Je.array,received:r.parsedType}),yt;if(a.exactLength!==null){const o=r.data.length>a.exactLength.value,l=r.data.length<a.exactLength.value;(o||l)&&(Ye(r,{code:o?Fe.too_big:Fe.too_small,minimum:l?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&r.data.length<a.minLength.value&&(Ye(r,{code:Fe.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&r.data.length>a.maxLength.value&&(Ye(r,{code:Fe.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>a.type._parseAsync(new gi(r,o,r.path,l)))).then(o=>Vr.mergeArray(n,o));const i=[...r.data].map((o,l)=>a.type._parseSync(new gi(r,o,r.path,l)));return Vr.mergeArray(n,i)}get element(){return this._def.type}min(s,r){return new Ta({...this._def,minLength:{value:s,message:nt.toString(r)}})}max(s,r){return new Ta({...this._def,maxLength:{value:s,message:nt.toString(r)}})}length(s,r){return new Ta({...this._def,exactLength:{value:s,message:nt.toString(r)}})}nonempty(s){return this.min(1,s)}}Ta.create=(e,s)=>new Ta({type:e,minLength:null,maxLength:null,exactLength:null,typeName:pt.ZodArray,...$t(s)});function sd(e){if(e instanceof Ms){const s={};for(const r in e.shape){const n=e.shape[r];s[r]=fi.create(sd(n))}return new Ms({...e._def,shape:()=>s})}else return e instanceof Ta?new Ta({...e._def,type:sd(e.element)}):e instanceof fi?fi.create(sd(e.unwrap())):e instanceof ul?ul.create(sd(e.unwrap())):e instanceof vi?vi.create(e.items.map(s=>sd(s))):e}class Ms extends Ft{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const s=this._def.shape(),r=Gt.objectKeys(s);return this._cached={shape:s,keys:r}}_parse(s){if(this._getType(s)!==Je.object){const d=this._getOrReturnCtx(s);return Ye(d,{code:Fe.invalid_type,expected:Je.object,received:d.parsedType}),yt}const{status:n,ctx:a}=this._processInputParams(s),{shape:i,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof Qi&&this._def.unknownKeys==="strip"))for(const d in a.data)o.includes(d)||l.push(d);const c=[];for(const d of o){const m=i[d],h=a.data[d];c.push({key:{status:"valid",value:d},value:m._parse(new gi(a,h,a.path,d)),alwaysSet:d in a.data})}if(this._def.catchall instanceof Qi){const d=this._def.unknownKeys;if(d==="passthrough")for(const m of l)c.push({key:{status:"valid",value:m},value:{status:"valid",value:a.data[m]}});else if(d==="strict")l.length>0&&(Ye(a,{code:Fe.unrecognized_keys,keys:l}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const m of l){const h=a.data[m];c.push({key:{status:"valid",value:m},value:d._parse(new gi(a,h,a.path,m)),alwaysSet:m in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const d=[];for(const m of c){const h=await m.key,f=await m.value;d.push({key:h,value:f,alwaysSet:m.alwaysSet})}return d}).then(d=>Vr.mergeObjectSync(n,d)):Vr.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(s){return nt.errToObj,new Ms({...this._def,unknownKeys:"strict",...s!==void 0?{errorMap:(r,n)=>{var a,i,o,l;const c=(o=(i=(a=this._def).errorMap)===null||i===void 0?void 0:i.call(a,r,n).message)!==null&&o!==void 0?o:n.defaultError;return r.code==="unrecognized_keys"?{message:(l=nt.errToObj(s).message)!==null&&l!==void 0?l:c}:{message:c}}}:{}})}strip(){return new Ms({...this._def,unknownKeys:"strip"})}passthrough(){return new Ms({...this._def,unknownKeys:"passthrough"})}extend(s){return new Ms({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new Ms({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:pt.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new Ms({...this._def,catchall:s})}pick(s){const r={};return Gt.objectKeys(s).forEach(n=>{s[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new Ms({...this._def,shape:()=>r})}omit(s){const r={};return Gt.objectKeys(this.shape).forEach(n=>{s[n]||(r[n]=this.shape[n])}),new Ms({...this._def,shape:()=>r})}deepPartial(){return sd(this)}partial(s){const r={};return Gt.objectKeys(this.shape).forEach(n=>{const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}),new Ms({...this._def,shape:()=>r})}required(s){const r={};return Gt.objectKeys(this.shape).forEach(n=>{if(s&&!s[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof fi;)i=i._def.innerType;r[n]=i}}),new Ms({...this._def,shape:()=>r})}keyof(){return KT(Gt.objectKeys(this.shape))}}Ms.create=(e,s)=>new Ms({shape:()=>e,unknownKeys:"strip",catchall:Qi.create(),typeName:pt.ZodObject,...$t(s)});Ms.strictCreate=(e,s)=>new Ms({shape:()=>e,unknownKeys:"strict",catchall:Qi.create(),typeName:pt.ZodObject,...$t(s)});Ms.lazycreate=(e,s)=>new Ms({shape:e,unknownKeys:"strip",catchall:Qi.create(),typeName:pt.ZodObject,...$t(s)});class Bh extends Ft{_parse(s){const{ctx:r}=this._processInputParams(s),n=this._def.options;function a(i){for(const l of i)if(l.result.status==="valid")return l.result;for(const l of i)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;const o=i.map(l=>new In(l.ctx.common.issues));return Ye(r,{code:Fe.invalid_union,unionErrors:o}),yt}if(r.common.async)return Promise.all(n.map(async i=>{const o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(a);{let i;const o=[];for(const c of n){const d={...r,common:{...r.common,issues:[]},parent:null},m=c._parseSync({data:r.data,path:r.path,parent:d});if(m.status==="valid")return m;m.status==="dirty"&&!i&&(i={result:m,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(c=>new In(c));return Ye(r,{code:Fe.invalid_union,unionErrors:l}),yt}}get options(){return this._def.options}}Bh.create=(e,s)=>new Bh({options:e,typeName:pt.ZodUnion,...$t(s)});const $i=e=>e instanceof Vh?$i(e.schema):e instanceof La?$i(e.innerType()):e instanceof qh?[e.value]:e instanceof dl?e.options:e instanceof Hh?Gt.objectValues(e.enum):e instanceof Wh?$i(e._def.innerType):e instanceof Fh?[void 0]:e instanceof Lh?[null]:e instanceof fi?[void 0,...$i(e.unwrap())]:e instanceof ul?[null,...$i(e.unwrap())]:e instanceof dN||e instanceof Yh?$i(e.unwrap()):e instanceof Gh?$i(e._def.innerType):[];class qv extends Ft{_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==Je.object)return Ye(r,{code:Fe.invalid_type,expected:Je.object,received:r.parsedType}),yt;const n=this.discriminator,a=r.data[n],i=this.optionsMap.get(a);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(Ye(r,{code:Fe.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),yt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(s,r,n){const a=new Map;for(const i of r){const o=$i(i.shape[s]);if(!o.length)throw new Error(`A discriminator value for key \`${s}\` could not be extracted from all schema options`);for(const l of o){if(a.has(l))throw new Error(`Discriminator property ${String(s)} has duplicate value ${String(l)}`);a.set(l,i)}}return new qv({typeName:pt.ZodDiscriminatedUnion,discriminator:s,options:r,optionsMap:a,...$t(n)})}}function Gj(e,s){const r=So(e),n=So(s);if(e===s)return{valid:!0,data:e};if(r===Je.object&&n===Je.object){const a=Gt.objectKeys(s),i=Gt.objectKeys(e).filter(l=>a.indexOf(l)!==-1),o={...e,...s};for(const l of i){const c=Gj(e[l],s[l]);if(!c.valid)return{valid:!1};o[l]=c.data}return{valid:!0,data:o}}else if(r===Je.array&&n===Je.array){if(e.length!==s.length)return{valid:!1};const a=[];for(let i=0;i<e.length;i++){const o=e[i],l=s[i],c=Gj(o,l);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return r===Je.date&&n===Je.date&&+e==+s?{valid:!0,data:e}:{valid:!1}}class zh extends Ft{_parse(s){const{status:r,ctx:n}=this._processInputParams(s),a=(i,o)=>{if(Hj(i)||Hj(o))return yt;const l=Gj(i.value,o.value);return l.valid?((Wj(i)||Wj(o))&&r.dirty(),{status:r.value,value:l.data}):(Ye(n,{code:Fe.invalid_intersection_types}),yt)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>a(i,o)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}zh.create=(e,s,r)=>new zh({left:e,right:s,typeName:pt.ZodIntersection,...$t(r)});class vi extends Ft{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==Je.array)return Ye(n,{code:Fe.invalid_type,expected:Je.array,received:n.parsedType}),yt;if(n.data.length<this._def.items.length)return Ye(n,{code:Fe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),yt;!this._def.rest&&n.data.length>this._def.items.length&&(Ye(n,{code:Fe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...n.data].map((o,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new gi(n,o,n.path,l)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>Vr.mergeArray(r,o)):Vr.mergeArray(r,i)}get items(){return this._def.items}rest(s){return new vi({...this._def,rest:s})}}vi.create=(e,s)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new vi({items:e,typeName:pt.ZodTuple,rest:null,...$t(s)})};class Uh extends Ft{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==Je.object)return Ye(n,{code:Fe.invalid_type,expected:Je.object,received:n.parsedType}),yt;const a=[],i=this._def.keyType,o=this._def.valueType;for(const l in n.data)a.push({key:i._parse(new gi(n,l,n.path,l)),value:o._parse(new gi(n,n.data[l],n.path,l)),alwaysSet:l in n.data});return n.common.async?Vr.mergeObjectAsync(r,a):Vr.mergeObjectSync(r,a)}get element(){return this._def.valueType}static create(s,r,n){return r instanceof Ft?new Uh({keyType:s,valueType:r,typeName:pt.ZodRecord,...$t(n)}):new Uh({keyType:$a.create(),valueType:s,typeName:pt.ZodRecord,...$t(r)})}}class _g extends Ft{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==Je.map)return Ye(n,{code:Fe.invalid_type,expected:Je.map,received:n.parsedType}),yt;const a=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([l,c],d)=>({key:a._parse(new gi(n,l,n.path,[d,"key"])),value:i._parse(new gi(n,c,n.path,[d,"value"]))}));if(n.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of o){const d=await c.key,m=await c.value;if(d.status==="aborted"||m.status==="aborted")return yt;(d.status==="dirty"||m.status==="dirty")&&r.dirty(),l.set(d.value,m.value)}return{status:r.value,value:l}})}else{const l=new Map;for(const c of o){const d=c.key,m=c.value;if(d.status==="aborted"||m.status==="aborted")return yt;(d.status==="dirty"||m.status==="dirty")&&r.dirty(),l.set(d.value,m.value)}return{status:r.value,value:l}}}}_g.create=(e,s,r)=>new _g({valueType:s,keyType:e,typeName:pt.ZodMap,...$t(r)});class jc extends Ft{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==Je.set)return Ye(n,{code:Fe.invalid_type,expected:Je.set,received:n.parsedType}),yt;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(Ye(n,{code:Fe.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),r.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(Ye(n,{code:Fe.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const i=this._def.valueType;function o(c){const d=new Set;for(const m of c){if(m.status==="aborted")return yt;m.status==="dirty"&&r.dirty(),d.add(m.value)}return{status:r.value,value:d}}const l=[...n.data.values()].map((c,d)=>i._parse(new gi(n,c,n.path,d)));return n.common.async?Promise.all(l).then(c=>o(c)):o(l)}min(s,r){return new jc({...this._def,minSize:{value:s,message:nt.toString(r)}})}max(s,r){return new jc({...this._def,maxSize:{value:s,message:nt.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}jc.create=(e,s)=>new jc({valueType:e,minSize:null,maxSize:null,typeName:pt.ZodSet,...$t(s)});class Pd extends Ft{constructor(){super(...arguments),this.validate=this.implement}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==Je.function)return Ye(r,{code:Fe.invalid_type,expected:Je.function,received:r.parsedType}),yt;function n(l,c){return bg({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,yg(),uu].filter(d=>!!d),issueData:{code:Fe.invalid_arguments,argumentsError:c}})}function a(l,c){return bg({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,yg(),uu].filter(d=>!!d),issueData:{code:Fe.invalid_return_type,returnTypeError:c}})}const i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof hu){const l=this;return rn(async function(...c){const d=new In([]),m=await l._def.args.parseAsync(c,i).catch(p=>{throw d.addIssue(n(c,p)),d}),h=await Reflect.apply(o,this,m);return await l._def.returns._def.type.parseAsync(h,i).catch(p=>{throw d.addIssue(a(h,p)),d})})}else{const l=this;return rn(function(...c){const d=l._def.args.safeParse(c,i);if(!d.success)throw new In([n(c,d.error)]);const m=Reflect.apply(o,this,d.data),h=l._def.returns.safeParse(m,i);if(!h.success)throw new In([a(m,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...s){return new Pd({...this._def,args:vi.create(s).rest(rc.create())})}returns(s){return new Pd({...this._def,returns:s})}implement(s){return this.parse(s)}strictImplement(s){return this.parse(s)}static create(s,r,n){return new Pd({args:s||vi.create([]).rest(rc.create()),returns:r||rc.create(),typeName:pt.ZodFunction,...$t(n)})}}class Vh extends Ft{get schema(){return this._def.getter()}_parse(s){const{ctx:r}=this._processInputParams(s);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Vh.create=(e,s)=>new Vh({getter:e,typeName:pt.ZodLazy,...$t(s)});class qh extends Ft{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return Ye(r,{received:r.data,code:Fe.invalid_literal,expected:this._def.value}),yt}return{status:"valid",value:s.data}}get value(){return this._def.value}}qh.create=(e,s)=>new qh({value:e,typeName:pt.ZodLiteral,...$t(s)});function KT(e,s){return new dl({values:e,typeName:pt.ZodEnum,...$t(s)})}class dl extends Ft{constructor(){super(...arguments),Em.set(this,void 0)}_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return Ye(r,{expected:Gt.joinValues(n),received:r.parsedType,code:Fe.invalid_type}),yt}if(jg(this,Em)||HT(this,Em,new Set(this._def.values)),!jg(this,Em).has(s.data)){const r=this._getOrReturnCtx(s),n=this._def.values;return Ye(r,{received:r.data,code:Fe.invalid_enum_value,options:n}),yt}return rn(s.data)}get options(){return this._def.values}get enum(){const s={};for(const r of this._def.values)s[r]=r;return s}get Values(){const s={};for(const r of this._def.values)s[r]=r;return s}get Enum(){const s={};for(const r of this._def.values)s[r]=r;return s}extract(s,r=this._def){return dl.create(s,{...this._def,...r})}exclude(s,r=this._def){return dl.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}Em=new WeakMap;dl.create=KT;class Hh extends Ft{constructor(){super(...arguments),Pm.set(this,void 0)}_parse(s){const r=Gt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==Je.string&&n.parsedType!==Je.number){const a=Gt.objectValues(r);return Ye(n,{expected:Gt.joinValues(a),received:n.parsedType,code:Fe.invalid_type}),yt}if(jg(this,Pm)||HT(this,Pm,new Set(Gt.getValidEnumValues(this._def.values))),!jg(this,Pm).has(s.data)){const a=Gt.objectValues(r);return Ye(n,{received:n.data,code:Fe.invalid_enum_value,options:a}),yt}return rn(s.data)}get enum(){return this._def.values}}Pm=new WeakMap;Hh.create=(e,s)=>new Hh({values:e,typeName:pt.ZodNativeEnum,...$t(s)});class hu extends Ft{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==Je.promise&&r.common.async===!1)return Ye(r,{code:Fe.invalid_type,expected:Je.promise,received:r.parsedType}),yt;const n=r.parsedType===Je.promise?r.data:Promise.resolve(r.data);return rn(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}hu.create=(e,s)=>new hu({type:e,typeName:pt.ZodPromise,...$t(s)});class La extends Ft{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===pt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(s){const{status:r,ctx:n}=this._processInputParams(s),a=this._def.effect||null,i={addIssue:o=>{Ye(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){const o=a.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return yt;const c=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return c.status==="aborted"?yt:c.status==="dirty"||r.value==="dirty"?xd(c.value):c});{if(r.value==="aborted")return yt;const l=this._def.schema._parseSync({data:o,path:n.path,parent:n});return l.status==="aborted"?yt:l.status==="dirty"||r.value==="dirty"?xd(l.value):l}}if(a.type==="refinement"){const o=l=>{const c=a.refinement(l,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(n.common.async===!1){const l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return l.status==="aborted"?yt:(l.status==="dirty"&&r.dirty(),o(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>l.status==="aborted"?yt:(l.status==="dirty"&&r.dirty(),o(l.value).then(()=>({status:r.value,value:l.value}))))}if(a.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Mh(o))return o;const l=a.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>Mh(o)?Promise.resolve(a.transform(o.value,i)).then(l=>({status:r.value,value:l})):o);Gt.assertNever(a)}}La.create=(e,s,r)=>new La({schema:e,typeName:pt.ZodEffects,effect:s,...$t(r)});La.createWithPreprocess=(e,s,r)=>new La({schema:s,effect:{type:"preprocess",transform:e},typeName:pt.ZodEffects,...$t(r)});class fi extends Ft{_parse(s){return this._getType(s)===Je.undefined?rn(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}fi.create=(e,s)=>new fi({innerType:e,typeName:pt.ZodOptional,...$t(s)});class ul extends Ft{_parse(s){return this._getType(s)===Je.null?rn(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}ul.create=(e,s)=>new ul({innerType:e,typeName:pt.ZodNullable,...$t(s)});class Wh extends Ft{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===Je.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Wh.create=(e,s)=>new Wh({innerType:e,typeName:pt.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...$t(s)});class Gh extends Ft{_parse(s){const{ctx:r}=this._processInputParams(s),n={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Oh(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new In(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new In(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Gh.create=(e,s)=>new Gh({innerType:e,typeName:pt.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...$t(s)});class Sg extends Ft{_parse(s){if(this._getType(s)!==Je.nan){const n=this._getOrReturnCtx(s);return Ye(n,{code:Fe.invalid_type,expected:Je.nan,received:n.parsedType}),yt}return{status:"valid",value:s.data}}}Sg.create=e=>new Sg({typeName:pt.ZodNaN,...$t(e)});const WJ=Symbol("zod_brand");class dN extends Ft{_parse(s){const{ctx:r}=this._processInputParams(s),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class Vf extends Ft{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?yt:i.status==="dirty"?(r.dirty(),xd(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?yt:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(s,r){return new Vf({in:s,out:r,typeName:pt.ZodPipeline})}}class Yh extends Ft{_parse(s){const r=this._def.innerType._parse(s),n=a=>(Mh(a)&&(a.value=Object.freeze(a.value)),a);return Oh(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Yh.create=(e,s)=>new Yh({innerType:e,typeName:pt.ZodReadonly,...$t(s)});function QT(e,s={},r){return e?mu.create().superRefine((n,a)=>{var i,o;if(!e(n)){const l=typeof s=="function"?s(n):typeof s=="string"?{message:s}:s,c=(o=(i=l.fatal)!==null&&i!==void 0?i:r)!==null&&o!==void 0?o:!0,d=typeof l=="string"?{message:l}:l;a.addIssue({code:"custom",...d,fatal:c})}}):mu.create()}const GJ={object:Ms.lazycreate};var pt;(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"})(pt||(pt={}));const YJ=(e,s={message:`Input not instance of ${e.name}`})=>QT(r=>r instanceof e,s),Ol=$a.create,XT=ll.create,KJ=Sg.create,QJ=cl.create,uN=Ih.create,XJ=bc.create,ZJ=wg.create,JJ=Fh.create,eee=Lh.create,tee=mu.create,see=rc.create,ree=Qi.create,nee=Ng.create,aee=Ta.create,ZT=Ms.create,iee=Ms.strictCreate,oee=Bh.create,lee=qv.create,cee=zh.create,dee=vi.create,uee=Uh.create,mee=_g.create,hee=jc.create,fee=Pd.create,pee=Vh.create,xee=qh.create,gee=dl.create,vee=Hh.create,yee=hu.create,c3=La.create,bee=fi.create,jee=ul.create,wee=La.createWithPreprocess,Nee=Vf.create,_ee=()=>Ol().optional(),See=()=>XT().optional(),Cee=()=>uN().optional(),kee={string:e=>$a.create({...e,coerce:!0}),number:e=>ll.create({...e,coerce:!0}),boolean:e=>Ih.create({...e,coerce:!0}),bigint:e=>cl.create({...e,coerce:!0}),date:e=>bc.create({...e,coerce:!0})},$ee=yt;var Eee=Object.freeze({__proto__:null,defaultErrorMap:uu,setErrorMap:EJ,getErrorMap:yg,makeIssue:bg,EMPTY_PATH:PJ,addIssueToContext:Ye,ParseStatus:Vr,INVALID:yt,DIRTY:xd,OK:rn,isAborted:Hj,isDirty:Wj,isValid:Mh,isAsync:Oh,get util(){return Gt},get objectUtil(){return qj},ZodParsedType:Je,getParsedType:So,ZodType:Ft,datetimeRegex:YT,ZodString:$a,ZodNumber:ll,ZodBigInt:cl,ZodBoolean:Ih,ZodDate:bc,ZodSymbol:wg,ZodUndefined:Fh,ZodNull:Lh,ZodAny:mu,ZodUnknown:rc,ZodNever:Qi,ZodVoid:Ng,ZodArray:Ta,ZodObject:Ms,ZodUnion:Bh,ZodDiscriminatedUnion:qv,ZodIntersection:zh,ZodTuple:vi,ZodRecord:Uh,ZodMap:_g,ZodSet:jc,ZodFunction:Pd,ZodLazy:Vh,ZodLiteral:qh,ZodEnum:dl,ZodNativeEnum:Hh,ZodPromise:hu,ZodEffects:La,ZodTransformer:La,ZodOptional:fi,ZodNullable:ul,ZodDefault:Wh,ZodCatch:Gh,ZodNaN:Sg,BRAND:WJ,ZodBranded:dN,ZodPipeline:Vf,ZodReadonly:Yh,custom:QT,Schema:Ft,ZodSchema:Ft,late:GJ,get ZodFirstPartyTypeKind(){return pt},coerce:kee,any:tee,array:aee,bigint:QJ,boolean:uN,date:XJ,discriminatedUnion:lee,effect:c3,enum:gee,function:fee,instanceof:YJ,intersection:cee,lazy:pee,literal:xee,map:mee,nan:KJ,nativeEnum:vee,never:ree,null:eee,nullable:jee,number:XT,object:ZT,oboolean:Cee,onumber:See,optional:bee,ostring:_ee,pipeline:Nee,preprocess:wee,promise:yee,record:uee,set:hee,strictObject:iee,string:Ol,symbol:ZJ,transformer:c3,tuple:dee,undefined:JJ,union:oee,unknown:see,void:nee,NEVER:$ee,ZodIssueCode:Fe,quotelessJson:$J,ZodError:In});const Pee=oJ,JT=u.createContext({}),Yc=({...e})=>t.jsx(JT.Provider,{value:{name:e.name},children:t.jsx(uJ,{...e})}),Hv=()=>{const e=u.useContext(JT),s=u.useContext(eD),{getFieldState:r,formState:n}=Vv(),a=r(e.name,n);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:i}=s;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...a}},eD=u.createContext({}),Al=u.forwardRef(({className:e,...s},r)=>{const n=u.useId();return t.jsx(eD.Provider,{value:{id:n},children:t.jsx("div",{ref:r,className:oe("space-y-2",e),...s})})});Al.displayName="FormItem";const Tl=u.forwardRef(({className:e,...s},r)=>{const{error:n,formItemId:a}=Hv();return t.jsx(V,{ref:r,className:oe(n&&"text-destructive",e),htmlFor:a,...s})});Tl.displayName="FormLabel";const Dl=u.forwardRef(({...e},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:i}=Hv();return t.jsx(tn,{ref:s,id:n,"aria-describedby":r?`${a} ${i}`:`${a}`,"aria-invalid":!!r,...e})});Dl.displayName="FormControl";const Aee=u.forwardRef(({className:e,...s},r)=>{const{formDescriptionId:n}=Hv();return t.jsx("p",{ref:r,id:n,className:oe("text-sm text-muted-foreground",e),...s})});Aee.displayName="FormDescription";const Rl=u.forwardRef(({className:e,children:s,...r},n)=>{const{error:a,formMessageId:i}=Hv(),o=a?String(a==null?void 0:a.message):s;return o?t.jsx("p",{ref:n,id:i,className:oe("text-sm font-medium text-destructive",e),...r,children:o}):null});Rl.displayName="FormMessage";const ms=u.forwardRef(({className:e,...s},r)=>t.jsx("textarea",{className:oe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
741ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...s}));ms.displayName="Textarea";var mN="Checkbox",[Tee,wfe]=hr(mN),[Dee,Ree]=Tee(mN),tD=u.forwardRef((e,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:i,required:o,disabled:l,value:c="on",onCheckedChange:d,form:m,...h}=e,[f,p]=u.useState(null),x=at(s,v=>p(v)),g=u.useRef(!1),b=f?m||!!f.closest("form"):!0,[w=!1,j]=wr({prop:a,defaultProp:i,onChange:d}),y=u.useRef(w);return u.useEffect(()=>{const v=f==null?void 0:f.form;if(v){const N=()=>j(y.current);return v.addEventListener("reset",N),()=>v.removeEventListener("reset",N)}},[f,j]),t.jsxs(Dee,{scope:r,state:w,disabled:l,children:[t.jsx(ze.button,{type:"button",role:"checkbox","aria-checked":el(w)?"mixed":w,"aria-required":o,"data-state":nD(w),"data-disabled":l?"":void 0,disabled:l,value:c,...h,ref:x,onKeyDown:Se(e.onKeyDown,v=>{v.key==="Enter"&&v.preventDefault()}),onClick:Se(e.onClick,v=>{j(N=>el(N)?!0:!N),b&&(g.current=v.isPropagationStopped(),g.current||v.stopPropagation())})}),b&&t.jsx(Mee,{control:f,bubbles:!g.current,name:n,value:c,checked:w,required:o,disabled:l,form:m,style:{transform:"translateX(-100%)"},defaultChecked:el(i)?!1:i})]})});tD.displayName=mN;var sD="CheckboxIndicator",rD=u.forwardRef((e,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=e,i=Ree(sD,r);return t.jsx(Ts,{present:n||el(i.state)||i.state===!0,children:t.jsx(ze.span,{"data-state":nD(i.state),"data-disabled":i.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...e.style}})})});rD.displayName=sD;var Mee=e=>{const{control:s,checked:r,bubbles:n=!0,defaultChecked:a,...i}=e,o=u.useRef(null),l=Mu(r),c=kf(s);u.useEffect(()=>{const m=o.current,h=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(h,"checked").set;if(l!==r&&p){const x=new Event("click",{bubbles:n});m.indeterminate=el(r),p.call(m,el(r)?!1:r),m.dispatchEvent(x)}},[l,r,n]);const d=u.useRef(el(r)?!1:r);return t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:a??d.current,...i,tabIndex:-1,ref:o,style:{...e.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function el(e){return e==="indeterminate"}function nD(e){return el(e)?"indeterminate":e?"checked":"unchecked"}var aD=tD,Oee=rD;const Kt=u.forwardRef(({className:e,...s},r)=>t.jsx(aD,{ref:r,className:oe("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...s,children:t.jsx(Oee,{className:oe("flex items-center justify-center text-current"),children:t.jsx(Bs,{className:"h-4 w-4"})})}));Kt.displayName=aD.displayName;function iD(e=!1){return Lt({queryKey:["competitions",e],queryFn:async()=>{let s=W.from("competitions").select("*").order("end_date",{ascending:!0});e||(s=s.eq("is_active",!0));const{data:r,error:n}=await s;if(n)throw n;return r}})}function Iee(e){return Lt({queryKey:["competition-entries",e],queryFn:async()=>{const{data:s,error:r}=await W.from("competition_entries").select("*").eq("competition_id",e).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!e})}function Fee(){const e=Xs(),s=os({mutationFn:async i=>{const{data:o,error:l}=await W.from("competitions").insert(i).select().single();if(l)throw l;return o},onSuccess:()=>{e.invalidateQueries({queryKey:["competitions"]}),ks.success("Competition created successfully")},onError:i=>{ks.error("Failed to create competition: "+i.message)}}),r=os({mutationFn:async({id:i,...o})=>{const{data:l,error:c}=await W.from("competitions").update(o).eq("id",i).select().single();if(c)throw c;return l},onSuccess:()=>{e.invalidateQueries({queryKey:["competitions"]}),ks.success("Competition updated successfully")},onError:i=>{ks.error("Failed to update competition: "+i.message)}}),n=os({mutationFn:async i=>{const{error:o}=await W.from("competitions").delete().eq("id",i);if(o)throw o},onSuccess:()=>
741{e.invalidateQueries({queryKey:["competitions"]}),ks.success("Competition deleted successfully")},onError:i=>{ks.error("Failed to delete competition: "+i.message)}}),a=os({mutationFn:async({id:i,is_active:o})=>{const{data:l,error:c}=await W.from("competitions").update({is_active:o}).eq("id",i).select().single();if(c)throw c;return l},onSuccess:i=>{e.invalidateQueries({queryKey:["competitions"]}),ks.success(`Competition ${i.is_active?"activated":"deactivated"}`)},onError:i=>{ks.error("Failed to update competition: "+i.message)}});return{createCompetition:s,updateCompetition:r,deleteCompetition:n,toggleActive:a}}function Lee(){const e=Xs();return os({mutationFn:async s=>{const{error:r}=await W.from("competition_entries").insert(s);if(r)throw r;try{const{error:n}=await W.functions.invoke("send-competition-entry-webhook",{body:s});n&&console.error("Webhook invoke error:",n)}catch(n){console.error("Webhook invoke threw:",n)}return s},onSuccess:()=>{e.invalidateQueries({queryKey:["competitions"]}),ks.success("Entry submitted successfully!")},onError:s=>{ks.error("Failed to submit entry: "+s.message)}})}function Bee(){return Lt({queryKey:["competition-categories"],queryFn:async()=>{const{data:e,error:s}=await W.from("competition_categories").select("*").order("name");if(s)throw s;return e}})}function zee(){const e=Xs();return os({mutationFn:async s=>{const{data:r,error:n}=await W.from("competition_categories").insert({name:s.name,label:s.label,color_class:s.color_class||"bg-gray-100 text-gray-800"}).select().single();if(n)throw n;return r},onSuccess:()=>{e.invalidateQueries({queryKey:["competition-categories"]}),ks.success("Category created successfully")},onError:s=>{ks.error("Failed to create category: "+s.message)}})}const Uee=ZT({name:Ol().min(2,"Name must be at least 2 characters").max(100,"Name must be less than 100 characters"),email:Ol().email("Please enter a valid email address").max(255,"Email must be less than 255 characters"),postcode:Ol().min(5,"Please enter a valid postcode").max(10,"Postcode must be less than 10 characters").regex(/^[A-Za-z0-9\s]+$/,"Postcode can only contain letters, numbers and spaces"),phone:Ol().trim().min(7,"Please enter a valid phone number").max(20,"Phone number must be less than 20 characters").regex(/^[0-9+\s()-]+$/,"Phone number can only contain digits, space
741s, +, -, ()"),message:Ol().max(1e3,"Message must be less than 1000 characters").optional(),agreeToTerms:uN().refine(e=>e===!0,{message:"You must agree to the terms and conditions"})}),Vee=({competition:e,isOpen:s,onClose:r})=>{const n=Lee(),a=NJ({resolver:kJ(Uee),defaultValues:{name:"",email:"",postcode:"",phone:"",message:"",agreeToTerms:!1}}),i=async l=>{e&&(await n.mutateAsync({competition_id:e.id,name:l.name,email:l.email,postcode:l.postcode,phone:l.phone,message:l.message||null,agreed_to_terms:l.agreeToTerms}),a.reset(),r())},o=()=>{a.reset(),r()};return e?t.jsx(bt,{open:s,onOpenChange:o,children:t.jsxs(xt,{className:"sm:max-w-md",children:[t.jsxs(jt,{children:[t.jsxs(wt,{className:"flex items-center gap-2 text-community-navy",children:[t.jsx(hi,{className:"w-5 h-5 text-community-green"}),"Enter Competition"]}),t.jsxs(ys,{children:["Enter to win: ",t.jsx("span",{className:"font-semibold text-community-green",children:e.prize})]})]}),t.jsx(Pee,{...a,children:t.jsxs("form",{onSubmit:a.handleSubmit(i),className:"space-y-4",children:[t.jsx(Yc,{control:a.control,name:"name",render:({field:l})=>t.jsxs(Al,{children:[t.jsx(Tl,{children:"Full Name *"}),t.jsx(Dl,{children:t.jsx(re,{placeholder:"Enter your full name",...l})}),t.jsx(Rl,{})]})}),t.jsx(Yc,{control:a.control,name:"email",render:({field:l})=>t.jsxs(Al,{children:[t.jsx(Tl,{children:"Email Address *"}),t.jsx(Dl,{children:t.jsx(re,{placeholder:"Enter your email address",type:"email",...l})}),t.jsx(Rl,{})]})}),t.jsx(Yc,{control:a.control,name:"postcode",render:({field:l})=>t.jsxs(Al,{children:[t.jsx(Tl,{children:"Postcode *"}),t.jsx(Dl,{children:t.jsx(re,{placeholder:"Enter your postcode",...l})}),t.jsx(Rl,{})]})}),t.jsx(Yc,{control:a.control,name:"phone",render:({field:l})=>t.jsxs(Al,{children:[t.jsx(Tl,{children:"Phone Number *"}),t.jsx(Dl,{children:t.jsx(re,{placeholder:"Enter your phone number",...l})}),t.jsx(Rl,{})]})}),t.jsx(Yc,{control:a.control,name:"message",render:({field:l})=>t.jsxs(Al,{children:[t.jsx(Tl,{children:"Message (Optional)"}),t.jsx(Dl,{children:t.jsx(ms,{placeholder:"Tell us why you'd love to win this prize...",className:"resize-none",rows:3,...l})}),t.jsx(Rl,{})]})}),t.jsx(Yc,{control:a.control,name:"agreeToTerms",render:({field:l})=>t.jsxs(Al,{className:"flex flex-row items-start space-x-3 space-y-0",children:[t.jsx(Dl,{children:t.jsx(Kt,{checked:l.value,onCheckedChange:l.onChange})}),t.jsxs("div",{className:"space-y-1 leading-none",children:[t.jsx(Tl,{className:"text-sm",children:"I agree to the competition terms and conditions *"}),t.jsx(Rl,{})]})]})}),t.jsxs("div",{className:"flex gap-3 pt-4",children:[t.jsx(q,{type:"button",variant:"outline",onClick:o,className:"flex-1",disabled:n.isPending,children:"Cancel"}),t.jsx(q,{type:"submit",className:"flex-1 bg-community-green hover:bg-community-green/90",disabled:n.isPending,children:n.isPending?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"w-4 h-4 mr-2 animate-spin"}),"Submitting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(hi,{className:"w-4 h-4 mr-2"}),"Enter Competition"]})})]})]})})]})}):null},qee=({endDate:e})=>{const[s,r]=u.useState({days:0,hours:0,minutes:0,seconds:0});return u.useEffect(()=>{const n=()=>{const i=+new Date(e)-+new Date;i>0&&r({days:Math.floor(i/864e5),hours:Math.floor(i/36e5%24),minutes:Math.floor(i/1e3/60%60),seconds:Math.floor(i/1e3%60)})};n();const a=setInterval(n,1e3);return()=>clearInterval(a)},[e]),t.jsxs("div",{className:"flex items-center gap-2 text-sm font-mono bg-red-50 text-red-700 px-3 py-1 rounded-full",children:[t.jsx(ws,{className:"w-4 h-4"}),t.jsxs("span",{children:[s.days,"d ",s.hours,"h ",s.minutes,"m ",s.seconds,"s"]})]})},Hee=()=>t.jsxs(xe,{className:"mt-8",children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(yr,{className:"w-5 h-5 text-community-green"}),"Competition Rules & Terms"]})}),t.jsx(ge,{className:"prose prose-sm max-w-none",children:t.jsxs("div",{className:"space-y-4 text-gray-700",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"font-semibold text-community-navy mb-2",children:"How to Enter:"}),t.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[t.jsx("li",{children:"You must be 18 years or older to participate"}
741),t.jsx("li",{children:"One entry per person per competition"}),t.jsx("li",{children:"Entries must be submitted before the deadline"}),t.jsx("li",{children:"Winners will be selected at random from all valid entries"})]})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"font-semibold text-community-navy mb-2",children:"Prize Information:"}),t.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[t.jsx("li",{children:"Prizes are non-transferable and cannot be exchanged for cash"}),t.jsx("li",{children:"Winners will be notified within 48 hours of the draw"}),t.jsx("li",{children:"Prizes must be claimed within 30 days of notification"}),t.jsx("li",{children:"Some restrictions may apply to specific prizes"})]})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"font-semibold text-community-navy mb-2",children:"General Terms:"}),t.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[t.jsx("li",{children:"Employees of participating businesses are not eligible"}),t.jsx("li",{children:"We reserve the right to disqualify entries that violate these terms"}),t.jsx("li",{children:"Personal data will be used only for competition administration"}),t.jsx("li",{children:"By entering, you agree to our privacy policy"})]})]}),t.jsx("div",{className:"bg-amber-50 p-4 rounded-lg border border-amber-200",children:t.jsx("p",{className:"text-sm text-amber-900",children:"Entering the competition consents to Discover Magazines Ltd storing the data supplied and sharing only with the relevant competition prize supplier. Entrants consent to receiving Discover's monthly e-newsletter Discover Extra."})})]})})]}),Wee=()=>{const{data:e,isLoading:s}=iD(),[r,n]=u.useState(null),[a,i]=u.useState(!1),o=(e==null?void 0:e.filter(d=>!Aj(new Date(d.end_date))))||[],l=d=>{n(d),i(!0)},c=()=>{i(!1),n(null)};return t.jsxs("div",{className:"min-h-screen",children:[t.jsx(gs,{}),t.jsxs("main",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[t.jsxs("div",{className:"text-center mb-12",children:[t.jsx("h1",{className:"text-4xl lg:text-5xl font-heading font-bold text-community-navy mb-4",children:"Enter Competitions"}),t.jsx("p",{className:"text-xl text-gray-600 font-body max-w-3xl mx-auto",children:"Win amazing prizes from local businesses and discover the best our community has to offer. New competitions added monthly!"})]}),s?t.jsxs("div",{className:"flex items-center justify-center py-16",children:[t.jsx(it,{className:"w-8 h-8 animate-spin text-community-green"}),t.jsx("span",{className:"ml-2 text-gray-600",children:"Loading competitions..."})]}):o.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(hi,{className:"w-16 h-16 mx-auto mb-4 text-gray-300"}),t.jsx("h3",{className:"text-xl font-semibold text-gray-600 mb-2",children:"No Active Competitions"}),t.jsx("p",{className:"text-gray-500",children:"Check back soon for new competitions!"})]}):t.jsx("div",{className:"grid md:grid-cols-2 gap-8 mb-12",children:o.map(d=>t.jsxs(xe,{className:"overflow-hidden hover:shadow-lg transition-shadow",children:[t.jsxs("div",{className:"aspect-video bg-gradient-to-br from-community-green/10 to-community-navy/10 relative",children:[d.image_url?t.jsx("img",{src:d.image_url,alt:d.title,className:"w-full h-full object-cover"}):t.jsx("div",{className:"w-full h-full flex items-center justify-center",children:t.jsx(hi,{className:"w-16 h-16 text-community-navy/30"})}),t.jsx(we,{className:"absolute top-4 left-4",variant:"secondary",children:d.category})]}),t.jsxs(Me,{children:[t.jsxs("div",{className:"flex justify-between items-start mb-2",children:[t.jsx(Oe,{className:"text-xl text-community-navy",children:d.title}),t.jsx(qee,{endDate:d.end_date})]}),t.jsx("p",{className:"text-gray-600 text-sm leading-relaxed",children:d.description})]}),t.jsx(ge,{children:t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(yr,{className:"w-4 h-4 text-community-green"}),t.jsx("span",{className:"font-semibold text-community-green",children:d.prize})]})}),t.jsxs(q,{className:"w-full bg-community-green hover:bg-community-green/90",onClick:()=>l(d),children:[t.jsx(hi,{className:"w-4 h-4 mr-2"}),"Enter Competition"]})]})})]},d.id))}),t.jsx(Hee,{})]}),t.jsx(vs,{}),t.jsx(Vee,{competition:r,isOpen:a,onClose:c})]})};function oD(){return Lt({queryKey:["pricing_areas"],queryFn:async()=>{try{const{data:e,error:s}=await W.from("pricing_areas").select("*").eq("is_active",!0).order("sort_order");if(s)throw new Error(`Failed to fetch pricing areas: ${s.message}`);return(e==null?void 0:e.map(n=>({...n,schedule:n.schedule})))||[]}catch(e){throw e}},staleTime:5*60*1e3,retry:(e,s)=>e<3})}function hN(){return Lt({queryKey:["ad_sizes"],queryFn:async()=>{try{const{data:e,error:s}=await W.from("ad_sizes").select("*").eq("is_active",!0).order("name");if(s)throw new Error(`Failed to fetch ad sizes: ${s.message}`);return(e==null?void 0:e.map(n=>({...n,available_for:n.available_for})))||[]}catch(e){throw e}},staleTime:5*60*1e3,retry:(e,s)=>e<3})}function Gee(){return Lt({queryKey:["pricing_durations"],queryFn:async()=>{try{const{data:e,error:s}=await W.from("pricing_durations").select("*").eq("is_active",!0).order("duration_value");if(s)throw new Error(`Failed to fetch durations: ${s.message}`);return e||[]}catch(e){throw e}},staleTime:5*60*1e3,retry:(e,s)=>e<3})}function Yee(){return Lt({queryKey:["volume_discounts"],queryFn:async()=>{try{const{data:e,error:s}=await W.from("volume_discounts").select("*").eq("is_active",!0).order("min_areas");if(s)throw new Error(`Failed to fetch volume discounts: ${s.message}`);return e||[]}catch(e){throw e}},staleTime:5*60*1e3,retry:(e,s)=>e<3})}function ji(){const{data:e,isLoading:s,isError:r,refetch:n}=oD(),{data:a,isLoading:i,isError:o,refetch:l}=hN(),{data:c,isLoading:d,isError:m,refetch:h}=Gee(),{data:f,isLoading:p,isError:x,refetch:g}=Yee(),b=(c==null?void 0:c.filter(N=>N.duration_type==="fixed"))||[],w=(c==null?void 0:c.filter(N=>N.duration_type==="subscription"))||[];return{areas:e,adSizes:a,durations:b,subscriptionDurations:w,volumeDiscounts:f,isLoading:s||i||d||p,isError:r||o||m||x,refetch:()=>{n(),l(),h(),g()}}}function Kh(e,s,r,n=!1,a=[],i=[],o=[],l=[],c=[],d=[],m=0){if(!e.length||!s||!r||!a.length||!i.length)return null;const h=a.filter(C=>e.includes(C.id)),f=i.find(C=>C.id===s),x=(n?l:o).find(C=>C.id===r);if(!f||!x||!h.length)return null;const g=h.length;let b,w;const j=Kee(g,c),y=1-j/100;if(n){const C=f.subscription_pricing_per_issue;let L=f.base_price_per_month;if(C&&typeof C=="object"&&Object.keys(C).length>0){const _=g.toString();C[_]?L=C[_]:console.warn(`Missing subscription pricing for ${f.name} with ${g} areas. Falling back to base_price_per_month: £${L}. Please configure pricing in Admin > Issue-Based Pricing.`)}else console.warn(`No subscription issue-based pricing configured for ${f.name}. Using fallback base_price_per_month: £${L}. Please configure pricing in Admin > Issue-Based Pricing.`);b=L;const D=L/g;w=h.map(_=>({area:_,adSize:f,basePrice:D,multipliedPrice:D}))}else{const C=f.fixed_pricing_per_issue;let L=f.base_price_per_area;if(C&&typeof C=="object"&&Object.keys(C).length>0){const _=g.toString();C[_]?L=C[_]:console.warn(`Missing fixed pricing for ${f.name} with ${g} areas. Falling back to base_price_per_area: £${L}. Please configure pricing in Admin > Issue-Based Pricing.`)}else console.warn(`No fixed issue-based pricing configured for ${f.name}. Using fallback base_price_per_area: £${L}. Please configure pricing in Admin > Issue-Based Pricing.`);b=L;const D=L/g;w=h.map(_=>({area:_,adSize:f,basePrice:D,multipliedPrice:D}))}const v=b*y,N=b-v,S=x.duration_value,k=1-x.discount_percentage/100;let $=v*S*k;const R=1-m/100,A=$*(m/100),T=$*R,P=a.filter(C=>e.includes(C.id)),B=a.filter(C=>d.includes(C.id)),I=[...P,...B].reduce((C,L)=>C+L.circulation,0);return{subtotal:b,volumeDiscount:N,volumeDiscountPercent:j,durationMultiplier:S,finalTotal:T,totalCirculation:I,agencyDiscount:A,agencyDiscountPercent:m,areaBreakdown:w}}function Kee(e,s){const r=s.find(n=>e>=n.min_areas&&(n.max_areas===null||e<=n.max_areas));return(r==null?void 0:r.discount_percentage)||0}function Nt(e){return e==null||isNaN(e)?"£0.00":`£${e.toLocaleStr
741ing("en-GB",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function Ip(e){return e==null||isNaN(e)?"£0":`£${Math.round(e).toLocaleString("en-GB")}`}function fN(e,s=[],r=1,n=1){if(e.length===0||s.length===0)return null;const a=s.filter(x=>e.includes(x.id));if(a.length===0)return null;const i=a.reduce((x,g)=>x+g.price_with_vat/1.2,0),o=0,l=0,d=e.length+n>=4?10:0,m=i*d/100,h=a.reduce((x,g)=>x+g.bimonthly_circulation,0),f=(i-l-m)*r,p=a.map(x=>({areaId:x.id,areaName:x.name,basePrice:Math.round(x.price_with_vat/1.2*100)/100,circulation:x.bimonthly_circulation}));return{subtotal:i,volumeDiscount:l,volumeDiscountPercent:o,comboDiscount:m,comboDiscountPercent:d,finalTotal:f,totalCirculation:h,areaBreakdown:p,durationMultiplier:r}}function qf(){return Lt({queryKey:["leaflet-areas"],queryFn:async()=>{try{const{data:e,error:s}=await W.from("leaflet_areas").select("*").eq("is_active",!0).order("area_number");if(s)throw s;return(e||[]).map(n=>({...n,schedule:Array.isArray(n.schedule)?n.schedule:[]}))}catch(e){throw e}},staleTime:5*60*1e3,retry:(e,s)=>e<1})}function Hf(){return Lt({queryKey:["leaflet-durations"],queryFn:async()=>{try{const{data:e,error:s}=await W.from("leaflet_campaign_durations").select("*").eq("is_active",!0).order("sort_order");if(s)throw s;return e||[]}catch(e){throw e}},staleTime:5*60*1e3,retry:(e,s)=>e<3})}function Qee(){return Lt({queryKey:["leaflet-sizes"],queryFn:async()=>{try{const{data:e,error:s}=await W.from("leaflet_sizes").select("*").eq("is_active",!0).order("sort_order");if(s)throw s;return e||[]}catch(e){throw e}},staleTime:5*60*1e3,retry:(e,s)=>e<3})}function Hu(){const{data:e,isLoading:s,isError:r,refetch:n}=qf(),{data:a,isLoading:i,isError:o,refetch:l}=Hf(),{data:c,isLoading:d,isError:m,refetch:h}=Qee();return{leafletAreas:e,leafletDurations:a,leafletSizes:c,isLoading:s||i||d,isError:r||o||m,refetch:()=>{n(),l(),h()}}}const lD=ve.createContext(void 0),Wv=()=>{const e=ve.useContext(lD);if(!e)throw new Error("useStepForm must be used within a StepForm");return e},d3=({children:e,onComplete:s,stepLabels:r,onStepChange:n})=>{var p;const[a,i]=u.useState(0),o=ve.Children.count(e),l=u.useRef(null),c=u.useRef(a);u.useEffect(()=>{c.current!==a&&l.current&&l.current.scrollIntoView({behavior:"smooth",block:"start"}),c.current=a,n==null||n(a+1),window.salesAssistantNextStep=()=>{a<o-1&&i(x=>x+1)},window.salesAssistantPrevStep=()=>{a>0&&i(x=>x-1)},window.salesAssistantGoToStep=x=>{x>=1&&x<=o&&i(x-1)},window.salesAssistantGetCurrentStep=()=>a+1},[a,o,n]);const d=async()=>{const x=()=>{a<o-1?i(g=>g+1):a===o-1&&(r!=null&&r.onLastStepNext)?window.handleContactFormSave?window.handleContactFormSave().then(()=>{i(g=>g+1)}).catch(()=>{}):r.onLastStepNext().then(()=>{i(g=>g+1)}).catch(()=>{}):s&&s()};r!=null&&r.onStepTransition?r.onStepTransition(a,x):x()},m=()=>{a>0&&i(x=>x-1)},h=x=>{if(x>=0&&x<o){if(x<=a){i(x);return}r!=null&&r.onStepTransition?r.onStepTransition(a,()=>i(x)):i(x)}},f={currentStep:a,totalSteps:o,nextStep:d,prevStep:m,goToStep:h,stepLabels:r};return t.jsx(lD.Provider,{value:f,children:t.jsxs("div",{ref:l,className:"w-full max-w-none mx-auto px-4",children:[t.jsx("div",{className:"mb-8",children:t.jsx("div",{className:"flex items-center justify-center space-x-2 sm:space-x-4 px-4 xs:px-6 sm:px-0",children:Array.from({length:o},(x,g)=>t.jsxs("div",{className:"flex items-center",children:[t.jsx("button",{onClick:()=>h(g),className:oe("w-10 h-10 sm:w-12 sm:h-12 rounded-full flex items-center justify-center text-sm font-bold transition-all duration-300 cursor-pointer relative",g<a?"bg-community-green text-white shadow-lg hover:bg-community-green/90":g===a?"bg-community-navy text-white shadow-xl ring-4 ring-community-navy/20 animate-pulse":"bg-white text-muted-foreground border-2 border-stone-300 hover:border-community-navy/50 hover:bg-stone-50"),children:g<a?t.jsx(Bs,{className:"w-5 h-5"}):t.jsx("span",{className:"text-base",children:g+1})}),g<o-1&&t.jsx("div",{className:oe("w-8 sm:w-16 h-1 rounded-full transition-all duration-300",g<a?"bg-gradient-to-r from-community-green to-community-navy":"bg-stone-200")})]},g))})}),a>0&&t.jsx("div",{className:"mb-6 pb-6 border-b border-border",children:t.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-4",children:[t.jsxs(q,{variant:"outline",onClick:m,className:"flex items-center justify-center gap-2 w-full sm:w-auto min-h-[44px] text-sm",children:[t.jsx(su,{className:"w-4 h-4"}),t.jsx("span",{className:"hidden xs:inline",children:(r==null?void 0:r.prevButtonLabel)||"Previous Step"}),t.jsx("span",{className:"xs:hidden",children:"Previous"})]}),t.jsxs("div",{className:"text-sm text-muted-foreground text-center font-medium",children:["Step ",a+1," of ",o]})]})}),t.jsx("div",{className:"relative",children:ve.Children.map(e,(x,g)=>t.jsx("div",{className:oe("transition-all duration-300 ease-in-out",g===a?"opacity-100 translate-x-0 relative":"opacity-0 absolute inset-0 translate-x-4 pointer-events-none"),children:x},g))}),a>0&&t.jsx("div",{className:"mt-8 pt-6 border-t border-border",children:t.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-4",children:[t.jsxs(q,{variant:"outline",onClick:m,className:"flex items-center justify-center gap-2 w-full sm:w-auto min-h-[44px] text-sm",children:[t.jsx(su,{className:"w-4 h-4"}),t.jsx("span",{className:"hidden xs:inline",children:(r==null?void 0:r.prevButtonLabel)||"Previous Step"}),t.jsx("span",{className:"xs:hidden",children:"Previous"})]}),t.jsxs("div",{className:"text-sm text-muted-foreground text-center font-medium",children:["Step ",a+1," of ",o]}),a===o-1?t.jsxs("div",{className:"flex flex-col xs:flex-row gap-2 w-full sm:w-auto",children:[t.jsxs(q,{variant:"outline",onClick:()=>{window.handleContactFormSave&&window.handleContactFormSave()},className:"flex items-center justify-center gap-2 w-full xs:w-auto min-h-[44px] text-sm",children:[t.jsx("span",{className:"hidden xs:inline",children:"Save My Quote"}),t.jsx("span",{className:"xs:hidden",children:"Save Quote"})]}),t.jsx(q,{onClick:()=>{window.handleContactFormBook&&window.handleContactFormBook()},className:"flex items-center justify-center gap-2 w-full xs:w-auto min-h-[44px] text-sm",children:"Book Now"})]}):t.jsxs(q,{onClick:d,className:"flex items-center justify-center gap-2 w-full sm:w-auto min-h-[44px] text-sm",children:[t.jsx("span",{className:"hidden xs:inline",children:((p=r==null?void 0:r.nextButtonLabels)==null?void 0:p[a])||"Next Step"}),t.jsx("span",{className:"xs:hidden",children:"Next"}),t.jsx(Ac,{className:"w-4 h-4"})]})]})})]})})},cD=(e=!1)=>Lt({queryKey:["product-packages",e],queryFn:async()=>{console.log("Fetching product packages from Supabase...");let s=W.from("product_packages").select("*").order("sort_order",{ascending:!0});e||(s=s.eq("is_active",!0));const{data:r,error:n}=await s;
741if(n)throw console.error("Error fetching product packages:",n),n;return console.log("Product packages fetched successfully:",(r==null?void 0:r.length)||0,"packages"),(r||[]).map(a=>({...a,features:a.features}))},staleTime:5*60*1e3,gcTime:10*60*1e3,retry:2,retryDelay:1e3,refetchOnMount:"always",refetchOnWindowFocus:!1}),Xee=()=>{const{toast:e}=rt(),s=Xs();return os({mutationFn:async r=>{const n={...r,features:r.features};delete n.created_at,delete n.updated_at;const{error:a}=await W.from("product_packages").update(n).eq("id",r.id);if(a)throw a},onSuccess:()=>{s.invalidateQueries({queryKey:["product-packages"]}),e({title:"Success",description:"Product package updated successfully"})},onError:r=>{console.error("Error updating product package:",r),e({title:"Error",description:"Failed to update product package",variant:"destructive"})}})},Zee=()=>{const{toast:e}=rt(),s=Xs();return os({mutationFn:async r=>{const n={...r,features:r.features},{error:a}=await W.from("product_packages").insert(n);if(a)throw a},onSuccess:()=>{s.invalidateQueries({queryKey:["product-packages"]}),e({title:"Success",description:"Product package created successfully"})},onError:r=>{console.error("Error creating product package:",r),e({title:"Error",description:"Failed to create product package",variant:"destructive"})}})},Jee=()=>{const{toast:e}=rt(),s=Xs();return os({mutationFn:async r=>{const{error:n}=await W.from("product_packages").update({is_active:!1}).eq("id",r);if(n)throw n},onSuccess:()=>{s.invalidateQueries({queryKey:["product-packages"]}),e({title:"Success",description:"Product package deleted successfully"})},onError:r=>{console.error("Error deleting product package:",r),e({title:"Error",description:"Failed to delete product package",variant:"destructive"})}})};async function ete(e){const r=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")}function dD(){const e=[navigator.userAgent,navigator.language,new Date().getTimezoneOffset(),screen.width,screen.height,screen.colorDepth];return btoa(e.join("|"))}async function uD(){try{const s=await(await fetch("https://api.ipify.org?format=json")).json();if(s.ip)return await ete(s.ip)}catch(e){console.warn("Could not get IP address for fraud detection:",e)}return null}const pN=(e,s)=>Lt({queryKey:["bogof-eligibility",e,s],queryFn:async()=>{try{const r=await uD(),n=dD();console.log("Checking BOGOF eligibility...",{email:e,phone:s,hasIpHash:!!r});const{data:a,error:i}=await W.functions.invoke("validate-bogof-eligibility",{body:{email:e,phone:s,ipAddressHash:r,deviceFingerprint:n}});return i?(console.error("Error checking BOGOF eligibility:",i),{isEligible:!0,warnings:["Could not verify eligibility. Please contact support if you have questions."]}):(console.log("BOGOF eligibility result:",a),a)}catch(r){return console.error("Error in BOGOF eligibility check:",r),{isEligible:!0,warnings:["Could not verify eligibility. Please contact support if you have questions."]}}},enabled:!!e||!!s,staleTime:5*60*1e3,retry:!1});async function u3(){const e=await uD(),s=dD();return{ipHash:e,deviceFingerprint:s}}const mD=u.createContext(void 0),hD=()=>{const e=u.useContext(mD);return e===void 0?{isEditing:!1,setIsEditing:()=>{},toggleEditMode:()=>{}}:e},tte=({children:e})=>{const[s,r]=u.useState(!1),n=()=>r(a=>!a);return t.jsx(mD.Provider,{value:{isEditing:s,setIsEditing:r,toggleEditMode:n},children:e})},ste=()=>{const{isAdmin:e}=Ar(),{isEditing:s,toggleEditMode:r}=hD();return e?t.jsx("div",{className:"fixed top-20 right-4 z-50",children:t.jsx(q,{onClick:r,variant:s?"default":"outline",className:` 742 gap-2 shadow-lg transition-all duration-300 743 ${s?"bg-community-green hover:bg-community-green/90 text-white":"bg-white hover:bg-gray-50 border-2 border-community-navy text-community-navy"} 744 `,children:s?t.jsxs(t.Fragment,{children:[t.jsx(Bs,{className:"h-4 w-4"}),"Exit Edit Mode"]}):t.jsxs(t.Fragment,{children:[t.jsx(ra,{className:"h-4 w-4"}),"Edit Page"]})})}):null},Be=({value:e,onSave:s,as:r="span",multiline:n=!1,className:a="",placeholder:i="Click to edit...",children:o})=>{const{isEditing:l}=hD(),[c,d]=u.useState(!1),[m,h]=u.useState(e),f=u.useRef(null),p=u.useRef(null);u.useEffect(()=>{h(e)},[e]),u.useEffect(()=>{c&&f.current&&(f.current.focus(),f.current.select())},[c]);const x=u.useCallback(()=>{m.trim()!==e.trim()&&s(m.trim()),d(!1)},[m,e,s]),g=u.useCallback(()=>{h(e),d(!1)},[e]),b=u.useCallback(j=>{j.key==="Enter"&&!n?(j.preventDefault(),x()):j.key==="Escape"&&g()},[n,x,g]),w=u.useCallback(()=>{l&&!c&&d(!0)},[l,c]);return l?c?t.jsxs("div",{className:"relative",children:[n?t.jsx("textarea",{ref:f,value:m,onChange:j=>h(j.target.value),onKeyDown:b,onBlur:x,className:oe("w-full min-h-[80px] p-2 border-2 border-community-green rounded-lg","focus:outline-none focus:ring-2 focus:ring-community-green/50","bg-white text-community-navy",a),placeholder:i}):t.jsx("input",{ref:f,type:"text",value:m,onChange:j=>h(j.target.value),onKeyDown:b,onBlur:x,className:oe("w-full p-2 border-2 border-community-green rounded-lg","focus:outline-none focus:ring-2 focus:ring-community-green/50","bg-white text-community-navy font-inherit",a),placeholder:i}),t.jsxs("div",{className:"absolute -top-2 -right-2 flex gap-1",children:[t.jsx("button",{onClick:x,className:"bg-community-green text-white p-1 rounded-full shadow-lg hover:bg-community-green/90 transition-colors",children:t.jsx(Bs,{className:"h-3 w-3"})}),t.jsx("button",{onClick:g,className:"bg-red-500 text-white p-1 rounded-full shadow-lg hover:bg-red-600 transition-colors",children:t.jsx(Es,{className:"h-3 w-3"})})]})]}):t.jsxs("div",{ref:p,onClick:w,className:oe("group relative cursor-pointer transition-all duration-200","hover:outline-dashed hover:outline-2 hover:outline-community-green/50 hover:outline-offset-2","rounded"),children:[t.jsx(r,{className:a,children:o||e||i}),t.jsx("div",{className:"absolute -top-2 -right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:t.jsx("div",{className:"bg-community-green text-white p-1 rounded-full shadow-lg",children:t.jsx(ra,{className:"h-3 w-3"})})})]}):t.jsx(r,{className:a,children:o||e})},rte=({feature:e})=>{const s=typeof e.value=="boolean";return t.jsxs("div",{className:oe("flex items-start gap-3 py-2",e.highlight&&"bg-primary/5 -mx-2 px-2 rounded-sm"),children:[t.jsx("div",{className:"flex-shrink-0 mt-0.5",children:s?e.value?t.jsx(Bs,{className:"w-4 h-4 text-green-500"}):t.jsx(Es,{className:"w-4 h-4 text-muted-foreground"}):t.jsx("div",{className:"w-1 h-1 bg-primary rounded-full mt-2"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-foreground mb-0.5",children:e.label}),!s&&t.jsx("div",{className:oe("text-sm text-muted-foreground leading-relaxed",e.highlight&&"text-foreground font-medium"),children:e.value}),e.subtext&&t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:e.subtext})]})]})},m3=({onSelectOption:e,advertisingContent:s,onContentSave:r})=>{var j,y;const{nextStep:n,currentStep:a}=Wv(),i=u.useRef(!0),o=u.useRef(!1),{data:l,isLoading:c,isError:d,refetch:m}=cD(),[h,f]=u.useState(),[p,x]=u.useState(),[g,b]=u.useState(!1);pN(h,p),u.useEffect(()=>()=>{i.current=!1},[]),u.useEffect(()=>{if(c&&!g){const v=setTimeout(()=>{i.current&&c&&(console.warn("Product packages loading timeout - showing retry option"),b(!0))},15e3);return()=>clearTimeout(v)}},[c,g]),u.useEffect(()=>{a===1&&!o.current&&(console.log("PricingOptionsStep visible - forcing fresh data fetch"),o.current=!0,b(!1),m())},[a,m]),u.useEffect(()=>{a!==1&&(o.current=!1)},[a]),u.useEffect(()=>{l&&l.length>0&&g&&(console.log("Packages loaded successfully - clearing error state"),b(!1))},[l,g]),u.useEffect(()=>{(async()=>{const{data:{user:N}}=await W.auth.getUser();if(N){f(N.email);const{data:S}=await W.from("profiles").select("phone").eq("user_id",N.id).maybeSingle();S!=null&&S.phone&&x(S.phone)}})()},[]);const w=(v,N)=>{e(v),n()};return c||!l?g?t.jsxs("div",{className:"text-center py-12 space-y-4",children:[t.jsx(Hs,{className:"w-8 h-8 mx-auto text-destructive"}),t.jsx("p",{className:"text-destructive",children:"Unable to load pricing options."}),t.jsx(q,{variant:"outline",onClick:()=>{b(!1),m()},children:"Try Again"})]}):t.jsxs("div",{className:"text-center py-12",children:[t.jsx(it,{className:"w-8 h-8 animate-spin mx-auto mb-4 text-primary"}),t.jsx("p",{className:"text-muted-foreground",children:"Loading packages..."})]}):d||l.length===0?t.jsxs("div",{className:"text-center py-12 space-y-4",children:[t.jsx(Hs,{className:"w-8 h-8 mx-auto text-destructive"}),t.jsx("p",{className:"text-destructive",children:"Unable to load pricing options."}),t.jsx(q,{variant:"outline",onClick:()=>{b(!1),m()},children:"Try Again"})]}):t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{className:"text-center space-y-4",children:[t.jsx("h2",{className:"text-3xl font-bold bg-gradient-primary bg-clip-text text-transparent",children:t.jsx(Be,{value:((j=s==null?void 0:s.pricingOptions)==null?void 0:j.pageHeading)||"Choose Your Advertising Package",onSave:v=>r==null?void 0:r("pricingOptions.pageHeading",v)})}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:t.jsx(Be,{value:((y=s==null?void 0:s.pricingOptions)==null?void 0:y.pageDescription)||"Select the package that best fits your business needs. Each option is designed for different advertising goals and budgets.",onSave:v=>r==null?void 0:r("pricingOptions.pageDescription",v)})})]}),t.jsx("div",{className:"flex flex-col lg:grid lg:grid-cols-3 gap-8",children:l.map((v,N)=>{const S=Mj(v.icon),k=["from-slate-600 to-slate-800","from-community-green to-emerald-600","from-amber-500 to-orange-600"],$=["border-t-slate-600","border-t-community-green","border-t-amber-500"],R=["bg-gradient-to-br from-slate-100 to-slate-200","bg-gradient-to-br from-green-100 to-emerald-200","bg-gradient-to-br from-amber-100 to-orange-200"],A=v.package_id==="bogof"?1:v.package_id==="leafleting"?2:3;return t.jsxs(xe,{style:{order:A},className:oe("relative overflow-hidden transition-all duration-300 bg-gradient-to-br from-white to-slate-50/80 group lg:!order-none","border-t-4 shadow-lg hover:shadow-2xl hover:-translate-y-1",v.is_popular?"border-t-community-green ring-2 ring-community-green/20 lg:scale-105 z-10":$[N%3]),children:[v.is_popular&&t.jsx("div",{className:oe("absolute top-0 left-0 right-0 bg-gradient-to-r text-white text-center py-3 text-sm font-semibold tracking-wide",k[1]),children:t.jsxs("span",{className:"flex items-center justify-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 bg-white rounded-full animate-pulse"}),"Most Popular Choice",t.jsx("span",{className:"w-2 h-2 bg-white rounded-full animate-pulse"})]})}),t.jsxs(Me,{className:oe("space-y-4",v.is_popular&&"pt-14"),children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:oe("w-12 h-12 rounded-xl flex items-center justify-center shadow-md transition-transform group-hover:scale-110",v.is_popular?R[1]:R[N%3]),children:t.jsx(S,{className:oe("w-6 h-6",v.is_popular?"text-community-green":"text-community-navy")})}),v.badge_text&&t.jsx(we,{variant:v.badge_variant,className:"text-xs font-semibold px-3 py-1 shadow-sm",children:v.badge_text})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Oe,{className:"text-xl font-bold text-community-navy",children:v.title}),t.jsx("p",{className:"text-sm font-semibold text-community-green",children:v.subt
744itle}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:v.description})]})]}),t.jsxs(ge,{className:"space-y-6",children:[t.jsx(q,{onClick:()=>w(v.package_id),className:oe("w-full font-semibold transition-all duration-300",v.is_popular?"bg-community-green hover:bg-community-green/90 text-white shadow-lg hover:shadow-xl":"bg-community-navy hover:bg-community-navy/90 text-white"),size:"lg",children:v.cta_text}),t.jsx("div",{className:"space-y-1 bg-slate-50/50 rounded-lg p-3 -mx-1",children:v.features.map((T,P)=>t.jsx(rte,{feature:T},P))})]})]},v.id)})})]})},nte=fa("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),ss=u.forwardRef(({className:e,variant:s,...r},n)=>t.jsx("div",{ref:n,role:"alert",className:oe(nte({variant:s}),e),...r}));ss.displayName="Alert";const Sa=u.forwardRef(({className:e,...s},r)=>t.jsx("h5",{ref:r,className:oe("mb-1 font-medium leading-none tracking-tight",e),...s}));Sa.displayName="AlertTitle";const rs=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:oe("text-sm [&_p]:leading-relaxed",e),...s}));rs.displayName="AlertDescription";const xN=({campaignData:e,currentStep:s})=>{var c,d,m,h,f,p,x,g,b;const{areas:r,adSizes:n}=ji(),{leafletAreas:a,leafletSizes:i}=Hu(),o=w=>{const j=(e==null?void 0:e.selectedModel)==="leafleting"?a:r,y=j==null?void 0:j.find(v=>v.id===w);return y?y.name:`Area ${w}`},l=w=>{if((e==null?void 0:e.selectedModel)==="leafleting"){const j=i==null?void 0:i.find(y=>y.id===w);return j?j.label:w}else{const j=n==null?void 0:n.find(y=>y.id===w);return j?j.name:w}};return!e||s<2||!e.pricingBreakdown?null:t.jsx("div",{className:"md:hidden mt-6",children:t.jsx(xe,{className:"bg-gradient-to-br from-primary/5 to-accent/10 border-primary/20",children:t.jsxs(ge,{className:"p-4 space-y-3",children:[t.jsxs("h4",{className:"text-sm font-semibold text-primary flex items-center gap-2",children:[t.jsx(ci,{className:"h-4 w-4"}),s>=3?"FINAL PRICING BREAKDOWN":"SUMMARY & COST TO BOOK"]}),((c=e.pricingBreakdown)==null?void 0:c.totalCirculation)&&t.jsx("div",{className:"bg-accent/20 rounded-lg p-3 border border-accent/30",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:"TOTAL HOMES YOU'LL REACH"}),t.jsx("div",{className:"text-xl font-bold text-primary",children:e.pricingBreakdown.totalCirculation.toLocaleString()}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"homes per insertion"})]})}),e.selectedModel&&t.jsx("div",{className:"space-y-1",children:t.jsxs("div",{className:"text-xs font-medium text-foreground",children:[t.jsx("span",{className:"text-muted-foreground",children:"Booking Type:"})," ",e.selectedModel==="fixed"?"Pay As You Go":e.selectedModel==="bogof"?"3+ Subscription Package":"Leafleting Campaign"]})}),e.selectedSize&&t.jsxs("div",{className:"text-xs",children:[t.jsx("span",{className:"text-muted-foreground",children:e.selectedModel==="leafleting"?"Leaflet Size:":"Advert Size:"})," ",t.jsx("span",{className:"font-medium",children:l(e.selectedSize)})]}),(e.selectedModel==="bogof"&&((d=e.bogofPaidAreas)==null?void 0:d.length)>0||e.selectedModel!=="bogof"&&((m=e.selectedAreas)==null?void 0:m.length)>0)&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"text-xs font-medium text-foreground",children:"Paid Area Locations:"}),t.jsx("div",{className:"space-y-0.5 ml-2",children:(h=e.selectedModel==="bogof"?e.bogofPaidAreas:e.selectedAreas)==null?void 0:h.map(w=>t.jsxs("div",{className:"text-xs text-muted-foreground",children:["⢠Paid - ",o(w)]},w))})]}),e.selectedModel==="bogof"&&((f=e.bogofFreeAreas)==null?void 0:f.length)>0&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"text-xs font-medium text-green-600",children:"FREE Area Locations:"}),t.jsx("div",{className:"text-xs text-green-600/80 italic mb-1",children:"These are the free areas that you'll get for the next 3 Issues/6 Months"}),t.jsx("div",{className:"space-y-0.5 ml-2",children:(p=e.bogofFreeAreas)==null?void 0:p.map(w=>t.jsxs("div",{className:"text-xs text-green-600",children:["⢠Free - ",o(w)]},w))}),t.jsx("div",{className:"text-xs text-green-600/70 italic mb-2",children:"To keep these areas after 6 months, you'll need to purchase them separately. Use these areas to experiment with new customer generation."})]}),((x=e.pricingBreakdown)==null?void 0:x.finalTotal)&&t.jsxs("div",{className:"bg-primary/10 rounded p-3 space-y-2",children:[t.jsx("div",{className:"text-xs",children:t.jsx("span",{className:"text-muted-foreground",children:"Pre-payment Required:"})}),t.jsxs("div",{className:"text-sm font-bold text-primary",children:["£",(e.pricingBreakdown.finalTotal||0).toFixed(2)," + VAT (£",((e.pricingBreakdown.finalTotal||0)*1.2).toFixed(2),")"]}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:["per insertion reaching ",((g=e.pricingBreakdown.totalCirculation)==null?void 0:g.toLocaleStr
744ing())||"selected"," homes"]}),((b=e.pricingBreakdown)==null?void 0:b.designFee)&&e.pricingBreakdown.designFee>0&&t.jsxs("div",{className:"mt-2 pt-2 border-t border-primary/20 text-xs space-y-1",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-muted-foreground",children:"Artwork Design Fee:"}),t.jsxs("span",{className:"font-medium",children:["£",e.pricingBreakdown.designFee.toFixed(2)," + VAT"]})]}),t.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"Invoiced separately â not charged via the website."})]})]})]})})})},u0=e=>e?q2(e):"Invalid Date",h3=({pricingModel:e,selectedAreas:s,bogofPaidAreas:r,bogofFreeAreas:n,selectedDuration:a,selectedMonths:i,onAreasChange:o,onBogofAreasChange:l,onDurationChange:c,onMonthsChange:d,onPricingChange:m,onNext:h,campaignData:f,currentStep:p=2,advertisingContent:x,onContentSave:g})=>{var G,E,z,Z,M,F,ee,se,le,X,ye,Ce,ke;const{areas:b,durations:w,subscriptionDurations:j,isLoading:y,isError:v}=ji(),{data:N,isLoading:S,error:k}=qf(),{data:$,isLoading:R,error:A}=Hf(),T=()=>e==="leafleting"?{areas:(N||[]).map(fe=>({...fe,schedule:fe.schedule||[]})),isLoading:S,isError:!!k}:{areas:b||[],isLoading:y,isError:v},{areas:P,isLoading:B,isError:Y}=T(),I=e==="bogof"?[...r,...n]:s,L=e==="leafleting"?$||[]:e==="bogof"?j||[]:w||[],D=e==="leafleting"?R:y,_=(fe,Ee)=>{if(e==="leafleting"||e==="fixed"){const K=Ee?[...s,fe]:s.filter(te=>te!==fe);if(o(K),m&&P){const te=P.filter(Q=>K.includes(Q.id)).reduce((Q,ae)=>{const me=e==="leafleting"?ae.bimonthly_circulation||0:ae.circulation||0;return Q+me},0);m({selectedModel:e,selectedAreas:K,bogofPaidAreas:[],bogofFreeAreas:[],pricingBreakdown:{totalCirculation:te}})}}},H=(fe,Ee)=>{let K,te;if(Ee){if(r.length>=7)return;te=n.filter(Q=>Q!==fe),K=[...r,fe],K.length===7&&(te=P.filter(ae=>!K.includes(ae.id)).map(ae=>ae.id))}else K=r.filter(Q=>Q!==fe),te=n.slice(0,K.length);if(l(K,te),m&&P){const Q=[...K,...te],ae=P.filter(me=>Q.includes(me.id)).reduce((me,pe)=>me+(pe.circulation||0),0);m({selectedModel:e,selectedAreas:[],bogofPaidAreas:K,bogofFreeAreas:te,pricingBreakdown:{totalCirculation:ae}})}},O=(fe,Ee)=>{let K,te;if(Ee?(K=r.filter(Q=>Q!==fe),te=[...n,fe]):(K=r,te=n.filter(Q=>Q!==fe)),l(K,te),m&&P){const Q=[...K,...te],ae=P.filter(me=>Q.includes(me.id)).reduce((me,pe)=>me+(pe.circulation||0),0);m({selectedModel:e,selectedAreas:[],bogofPaidAreas:K,bogofFreeAreas:te,pricingBreakdown:{totalCirculation:ae}})}},U=()=>{var Ee;if(!a||I.length===0)return null;const fe=L==null?void 0:L.find(K=>K.id===a);if(e==="bogof"){const K=[...r.map(me=>P==null?void 0:P.find(pe=>pe.id===me)).filter(Boolean),...n.map(me=>P==null?void 0:P.find(pe=>pe.id===me)).filter(Boolean)],{availableStartDates:te,monthAvailability:Q}=(()=>{var ie;if(K.length===0)return{availableStartDates:[],monthAvailability:{}};(ie=K.find(je=>je==null?void 0:je.schedule))!=null&&ie.schedule;const me=new Map;K.forEach(je=>{((je==null?void 0:je.schedule)||[]).forEach(Ae=>{const Ue=mx(Ae);if(!Ue)return;me.has(Ue)||me.set(Ue,{eligible:[],ineligible:[]});const Ve=me.get(Ue);i0(Ae)?Ve.eligible.push(je):Ve.ineligible.push(je)})});const be=Array.from(me.entries()).filter(([,je])=>je.eligible.length>0).map(([je])=>je).sort().slice(0,3),ce={};return be.forEach(je=>{ce[je]=me.get(je)}),{availableStartDates:be,monthAvailability:ce}})(),ae=Object.keys(i).length>0&&((Ee=i[Object.keys(i)[0]])==null?void 0:Ee[0])||null;return t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"bg-primary/10 border border-primary/20 rounded-lg p-4",children:t.jsxs("p",{className:"text-sm font-medium text-primary",children:["ð Select your campaign start month - this will apply to ALL ",K.length," selected areas"]})}),t.jsxs("div",{className:"border rounded-lg p-6",children:[t.jsxs("h4",{className:"font-medium text-lg mb-4 flex items-center gap-2",children:[t.jsx(It,{className:"h-5 w-5"}),"Campaign start month:"]}),t.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["This start date will be used for all ",K.length," areas in your campaign."]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:te.map((me,pe)=>{const be=ae===me,ce=Q[me],ie=(ce==null?void 0:ce.eligible.length)??K.length,je=(ce==null?void 0:ce.ineligible)??[],Re=je.length>0;return t.jsx("div",{className:` 745 border rounded-lg p-4 cursor-pointer transition-all 746 ${be?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-muted hover:border-primary/50"} 747 `,children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx("input",{type:"radio",id:`global-start-${pe}`,name:"global-start-date",checked:be,onChange:()=>{const Ae={};
747[...r,...n].forEach(Ue=>{Ae[Ue]=[me]}),d(Ae)},className:"mt-1"}),t.jsxs("div",{className:"flex-1 space-y-2",onClick:()=>{const Ae={};[...r,...n].forEach(Ue=>{Ae[Ue]=[me]}),d(Ae)},children:[t.jsx("div",{className:"font-medium text-sm",children:u0(me)}),Re?t.jsxs("div",{className:"text-xs text-muted-foreground",children:["Starts this month for ",ie," of ",K.length," areas. The remaining ",je.length," ",je.length===1?"area starts":"areas start"," on their next available issue (see Campaign Schedule below)."]}):t.jsxs("div",{className:"text-xs text-muted-foreground",children:["Applies to all ",K.length," selected areas"]})]})]})},pe)})})]})]})}if(e==="leafleting"){const K=(fe==null?void 0:fe.issues)||(fe==null?void 0:fe.months)||1;return t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"bg-primary/10 border border-primary/20 rounded-lg p-4",children:t.jsx("p",{className:"text-sm font-medium text-primary",children:"ð
Select the months you want your leaflet campaign to run for each selected area"})}),I.map(te=>{const Q=P==null?void 0:P.find(be=>be.id===te);if(!Q)return null;const me=(Q.schedule||[]).filter(be=>
747i0(be)),pe=i[te]||[];return t.jsxs("div",{className:"border rounded-lg p-6",children:[t.jsxs("h4",{className:"font-medium text-lg mb-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(It,{className:"h-5 w-5"}),Q.name]}),t.jsxs(we,{variant:"outline",className:"text-xs",children:[pe.length,"/",K," selected"]})]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:me.map((be,ce)=>{const ie=pe.includes(be.month),je=!ie&&pe.length>=K;return t.jsx("div",{className:` 748 border rounded-lg p-4 cursor-pointer transition-all 749 ${ie?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-muted hover:border-primary/50"} 750 ${je?"opacity-50 cursor-not-allowed":""} 751 `,children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx("input",{type:"checkbox",id:`leaflet-month-${te}-${ce}`,checked:ie,disabled:je,onChange:Re=>{const Ae=Re.target.checked?[...pe,be.month]:pe.filter(Ue=>Ue!==be.month);d({...i,[te]:Ae})},className:"mt-1"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"font-medium text-sm",children:u0(mx(be)||"")}),be.copyDeadline&&t.jsxs("div",{className:"text-xs text-muted-foreground",children:["Distribution: ",WS(be.copyDeadline,be.year)]})]})]})},ce)})})]},te)})]})}return t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"bg-primary/10 border border-primary/20 rounded-lg p-4",children:t.jsx("p",{className:"text-sm font-medium text-primary",children:"ð Select the months you want your advertising to run for each selected area"})}),I.map(K=>{const te=P==null?void 0:P.find(be=>be.id===K);if(!te)return null;const ae=(te.schedule||[]).filter(be=>i0(be)),me=i[K]||[],pe=(fe==null?void 0:fe.duration_value)||(fe==null?void 0:fe.months)||1;return t.jsxs("div",{className:"border rounded-lg p-6",children:[t.jsxs("h4",{className:"font-medium text-lg mb-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(It,{className:"h-5 w-5"}),"Area: ",te.name]}),t.jsxs(we,{variant:"outline",className:"text-xs",children:[me.length,"/",pe," selected"]})]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:ae.map((be,ce)=>{const ie=mx(be)||be.month,je=me.includes(ie)||me.includes(be.month),Re=!je&&me.length>=pe;return t.jsx("div",{className:` 752 border rounded-lg p-4 cursor-pointer transition-all 753 ${je?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-muted hover:border-primary/50"} 754 ${Re?"opacity-50 cursor-not-allowed":""} 755 `,children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx("input",{type:"checkbox",id:`month-${K}-${ce}`,checked:je,disabled:Re,onChange:Ae=>{const Ue=Ae.target.checked?[...me,ie]:me.filter(Ve=>Ve!==ie&&Ve!==be.month);d({...i,[K]:Ue})},className:"mt-1"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"font-medium text-sm",children:u0(ie)}),be.copyDeadline&&t.jsxs("div",{className:"text-xs text-muted-foreground",children:["Copy deadline: ",WS(be.copyDeadline,be.year)]})]})]})},ce)})})]},K)})]})};return B||D?t.jsxs("div",{className:"flex items-center justify-center p-12",children:[t.jsx(it,{className:"h-8 w-8 animate-spin mr-3"}),t.jsx("span",{className:"text-lg",children:"Loading areas and durations..."})]}):Y||v||!P||P.length===0?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:t.jsx(Be,{value:((G=x==null?void 0:x.areaSelection)==null?void 0:G.pageHeading)||"Select Areas & Publication Schedule",onSave:fe=>g==null?void 0:g("areaSelection.pageHeading",fe)})}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((E=x==null?void 0:x.areaSelection)==null?void 0:E.pageDescription)||"Choose your areas and schedule your campaign",onSave:fe=>g==null?void 0:g("areaSelection.pageDescription",fe)})})]}),t.jsxs(ss,{variant:"destructive",children:[t.jsx(Hs,{className:"h-4 w-4"}),t.jsx(rs,{children:"Unable to load available areas. Please try refreshing the page or contact support."})]})]}):t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{className:"text-center",children:[t.jsxs("h2",{className:"text-2xl font-bold mb-2 flex items-center justify-center gap-2",children:[t.jsx(_t,{className:"h-6 w-6"}),t.jsx(Be,{value:((z=x==null?void 0:x.areaSelection)==null?void 0:z.pageHeading)||"Select Areas & Publication Schedule",onSave:fe=>g==null?void 0:g("areaSelection.pageHeading",fe)})]}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((Z=x==null?void 0:x.areaSelection)==null?void 0:Z.pageDescription)||"Choose your areas and set up your campaign timeline",onSave:fe=>g==null?void 0:g("areaSelection.pageDescription",fe)})})]}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[t.jsx(_t,{className:"h-5 w-5"}),e==="bogof"?t.jsx(Be,{value:((M=x==null?void 0:x.areaSelection)==null?void 0:M.bogofHeading)||"Select Areas for 3+ Subscription Package",onSave:fe=>g==null?void 0:g("areaSelection.bogofHeading",fe),as:"span"}):e==="leafleting"?"Select Leafleting Areas":"Select Areas for Pay As You Go"]}),e==="bogof"&&t.jsxs(ss,{children:[t.jsx(ua,{className:"h-4 w-4"}),t.jsxs(rs,{children:[t.jsx(Be,{value:((F=x==null?void 0:x.areaSelection)==null?void 0:F.bogofAlertTitle)||"3+ Subscription Package:",onSave:fe=>g==null?void 0:g("areaSelection.bogofAlertTitle",fe),as:"span",className:"font-bold"})," ",t.jsx(Be,{value:((ee=x==null?void 0:x.areaSelection)==null?void 0:ee.bogofAlertDescription)||'For every "paid for" area, choose a "free for 3 issues" area. Select your paid areas first, then choose your free areas.',onSave:fe=>g==null?void 0:g("areaSelection.bogofAlertDescription",fe),as:"span"})]})]}),e==="bogof"?t.jsxs("div",{className:"grid grid-cols-2 gap-3 md:gap-6 min-h-[400px] w-full",children:[t.jsxs("div",{className:"space-y-3 md:space-y-4 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[t.jsx(Be,{value:((se=x==null?void 0:x.areaSelection)==null?void 0:se.paidAreasHeading)||"Paid Areas",onSave:fe=>g==null?void 0:g("areaSelection.paidAreasHeading",fe),as:"h4",className:"font-medium text-sm md:text-base"}),t.jsx(we,{variant:"default",className:"text-xs",children:"Required"})]}),t.jsx(Be,{value:((le=x==null?void 0:x.areaSelection)==null?void 0:le.paidAreasDescription)||"These are the areas you will pay for throughout your campaign. Maximum 7 areas",onSave:fe=>g==null?void 0:g("areaSelection.paidAreasDescription",fe),as:"p",className:"text-xs md:text-sm text-muted-foreground"}),t.jsx("div",{className:"grid grid-cols-1 gap-2 md:gap-4",children:P.filter(fe=>!n.includes(fe.id)).map(fe=>{var Ee;
755return t.jsx(xe,{className:`cursor-pointer transition-all duration-200 hover:shadow-md ${r.includes(fe.id)?"ring-2 ring-primary border-primary":""} ${!r.includes(fe.id)&&r.length>=7?"opacity-50 cursor-not-allowed":""}`,onClick:()=>{!r.includes(fe.id)&&r.length>=7||H(fe.id,!r.includes(fe.id))},children:t.jsx(ge,{className:"p-2 md:p-4",children:t.jsxs("div",{className:"flex items-start space-x-2 md:space-x-3",children:[t.jsx(Kt,{id:`paid-${fe.id}`,checked:r.includes(fe.id),disabled:!r.includes(fe.id)&&r.length>=7,onCheckedChange:K=>{!r.includes(fe.id)&&r.length>=7||H(fe.id,K)},className:"mt-0.5 md:mt-1 scale-75 md:scale-100"}),t.jsx("div",{className:"flex-1 space-y-1 md:space-y-2 min-w-0",children:t.jsxs("div",{className:"space-y-1",children:[t.jsx(V,{htmlFor:`paid-${fe.id}`,className:"text-xs md:text-sm font-medium cursor-pointer leading-tight block",children:fe.name}),t.jsxs(we,{variant:"outline",className:"text-[10px] md:text-xs whitespace-nowrap",children:[((Ee=fe.circulation)==null?void 0:Ee.toLocaleString())||0," homes"]})]})})]})})},`paid-${fe.id}`)})})]}),t.jsxs("div",{id:"bogof-free-areas-section",className:"space-y-3 md:space-y-4 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[t.jsx(Be,{value:((X=x==null?void 0:x.areaSelection)==null?void 0:X.freeAreasHeading)||"FREE Bonus Areas",onSave:fe=>g==null?void 0:g("areaSelection.freeAreasHeading",fe),as:"h4",className:"font-medium text-sm md:text-base"}),t.jsx(we,{variant:"secondary",className:"text-xs",children:t.jsx(Be,{value:((ye=x==null?void 0:x.areaSelection)==null?void 0:ye.freeAreasBadge)||"6 Months Free",onSave:fe=>g==null?void 0:g("areaSelection.freeAreasBadge",fe),as:"span"})})]}),t.jsx("p",{className:"text-xs md:text-sm text-muted-foreground",children:r.length===7?"All remaining areas automatically selected as FREE bonus areas!":t.jsx(Be,{value:((Ce=x==null?void 0:x.areaSelection)==null?void 0:Ce.freeAreasDescription)||"Select additional areas to receive for FREE for 6 months.",onSave:fe=>g==null?void 0:g("areaSelection.freeAreasDescription",fe),as:"span"})}),r.length>0?t.jsx("div",{className:"grid grid-cols-1 gap-2 md:gap-4",children:P.filter(fe=>!r.includes(fe.id)).map(fe=>{var te;const Ee=n.includes(fe.id),K=r.length===7||!Ee&&n.length>=r.length;return t.jsx(xe,{className:`cursor-pointer transition-all duration-200 hover:shadow-md ${Ee?"ring-2 ring-green-500 border-green-500":""} ${K?"opacity-50 cursor-not-allowed":""}`,onClick:()=>!K&&O(fe.id,!Ee),children:t.jsx(ge,{className:"p-2 md:p-4",children:t.jsxs("div",{className:"flex items-start space-x-2 md:space-x-3",children:[t.jsx(Kt,{id:`free-${fe.id}`,checked:Ee,disabled:K,onCheckedChange:Q=>O(fe.id,Q),className:"mt-0.5 md:mt-1 scale-75 md:scale-100"}),t.jsx("div",{className:"flex-1 space-y-1 md:space-y-2 min-w-0",children:t.jsxs("div",{className:"space-y-1",children:[t.jsx(V,{htmlFor:`free-${fe.id}`,className:"text-xs md:text-sm font-medium cursor-pointer leading-tight block",children:fe.name}),t.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[t.jsxs(we,{variant:"outline",className:"text-[10px] md:text-xs whitespace-nowrap",children:[((te=fe.circulation)==null?void 0:te.toLocaleString())||0," homes"]}),Ee&&t.jsx(we,{variant:"secondary",className:"text-[10px] md:text-xs bg-green-100 text-green-800",children:"FREE"})]})]})})]})})},`free-${fe.id}`)})}):t.jsx("p",{className:"text-sm text-muted-foreground italic",children:t.jsx(Be,{value:((ke=x==null?void 0:x.areaSelection)==null?void 0:ke.freeAreasUnlockText)||"Select at least one paid area to unlock your free bonus areas.",onSave:fe=>g==null?void 0:g("areaSelection.freeAreasUnlockText",fe),as:"span"})})]})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:P.map(fe=>{var Ee,K;return t.jsx(xe,{className:`cursor-pointer transition-all duration-200 hover:shadow-md ${s.includes(fe.id)?"ring-2 ring-primary border-primary":""}`,onClick:()=>_(fe.id,!s.includes(fe.id)),children:t.jsx(ge,{className:"p-4",children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx(Kt,{id:fe.
755id,checked:s.includes(fe.id),onCheckedChange:te=>_(fe.id,te),className:"mt-1"}),t.jsx("div",{className:"flex-1 space-y-2",children:t.jsxs("div",{className:"space-y-1",children:[t.jsx(V,{htmlFor:fe.id,className:"text-sm font-medium cursor-pointer block",children:fe.name}),t.jsxs(we,{variant:"outline",className:"text-xs",children:[e==="leafleting"?((Ee=fe.bimonthly_circulation)==null?void 0:Ee.toLocaleString())||0:((K=fe.circulation)==null?void 0:K.toLocaleString())||0," homes"]})]})})]})})},fe.id)})}),e==="bogof"&&r.length>0&&n.length<r.length&&t.jsxs(ss,{variant:"destructive",className:"border-2 border-destructive",children:[t.jsx(Hs,{className:"h-4 w-4"}),t.jsxs(rs,{className:"flex flex-col gap-2",children:[t.jsxs("span",{className:"font-semibold",children:["You need to select ",r.length-n.length," more free bonus area",r.length-n.length!==1?"s":""," before you can continue."]}),t.jsx("span",{className:"text-sm",children:"For every paid area, you must choose a matching free area. Please scroll up and click your free areas now."}),t.jsx(q,{variant:"outline",size:"sm",className:"w-fit border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground",onClick:()=>{var fe;return(fe=document.getElementById("bogof-free-areas-section"))==null?void 0:fe.scrollIntoView({behavior:"smooth",block:"center"})},children:"â Select Your Free Areas"})]})]}),(e==="bogof"&&(r.length>0||n.length>0)||e!=="bogof"&&s.length>0)&&t.jsxs("div",{className:"bg-primary/5 border border-primary/20 rounded-lg p-4",children:[t.jsx("h4",{className:"font-medium mb-2",children:"Selection Summary"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:e==="bogof"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:["Paid areas: ",r.length]}),t.jsxs("div",{children:["Free bonus areas: ",n.length,n.length<r.length?` (${r.length-n.length} remaining)`:" â"]}),t.jsxs("div",{children:["Total areas: ",r.length+n.length]})]}):t.jsxs("div",{children:["Selected areas: ",s.length]})})]})]}),I.length>0&&e!=="bogof"&&t.jsxs("div",{id:"campaign-duration-section",className:oe("space-y-4 p-4 rounded-lg border-2 transition-colors",a?"border-transparent":"border-destructive/50 bg-destructive/5"),children:[t.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[t.jsx(ws,{className:"h-5 w-5"}),"Campaign Duration",t.jsx("span",{className:"text-destructive",children:"*"})]}),!a&&t.jsx("p",{className:"text-sm text-destructive",children:"Please select a campaign duration to continue"}),t.jsxs(ht,{value:a,onValueChange:c,children:[t.jsx(ut,{className:oe("w-full",!a&&"border-destructive"),children:t.jsx(ft,{placeholder:"Select campaign duration"})}),t.jsx(mt,{children:L.map(fe=>{if(e==="leafleting"){const Ee=fe.issues||1;return t.jsxs(Pe,{value:fe.id,children:[Ee," ",Ee===1?"Issue":"Issues"," â ",Ee," delivery ",Ee===1?"slot":"slots"," per area selected"]},fe.id)}return t.jsxs(Pe,{value:fe.id,children:[fe.name," of advertising"]},fe.id)})})]})]}),U(),f&&t.jsx(xN,{campaignData:f,currentStep:p})]})};function fD(){return Lt({queryKey:["agency-discount"],queryFn:async()=>{try{console.log("useAgencyDiscount: Starting to check session...");const{data:{session:e},error:s}=await W.auth.getSession();if(s)return console.warn("useAgencyDiscount session error:",s),{agencyDiscountPercent:0,isAgencyMember:!1};if(!(e!=null&&e.user))return console.log("useAgencyDiscount: No session/user found, returning default"),{agencyDiscountPercent:0,isAgencyMember:!1};console.log("useAgencyDiscount: Found user, querying profile for:",e.user.email);const{data:r,error:n}=await W.from("profiles").select("agency_discount_percent, is_agency_member, discount_type").eq("user_id",e.user.id).maybeSingle();if(n)return console.warn("useAgencyDiscount profile error:",n),{agencyDiscountPercent:0,isAgencyMember:!1};console.log("useAgencyDiscount: Profile data:",r);const a=(r==null?void 0:r.agency_discount_percent)||0,i=!!(r&&(r.is_agency_member||r.discount_type==="agency")),o={agencyDiscountPercent:i&&a>0?a:0,isAgencyMember:i};return console.log("useAgencyDiscount: Final result:",o),o}catch(e){return console.error("useAgencyDiscount: Unexpected error:",e),{agencyDiscountPercent:0,isAgencyMember:!1}}},staleTime:6e4,retry:!1})}const f3=({selectedAdSize:e,onAdSizeChange:s,pricingModel:r,selectedAreas:n,bogofPaidAreas:a,bogofFreeAreas:i,selectedDuration:o,onPricingChange:l,showSummary:c=!1,onNext:d,campaignData:m,currentStep:h=3,selectedMonths:f})=>{const{areas:p,adSizes:x,durations:g,subscriptionDurations:b,volumeDiscounts:w,isLoading:j,isError:y}=ji(),{data:v}=fD(),N=(v==null?void 0:v.agencyDiscountPercent)||0;u.useEffect(()=>{var T,P;const A=o||(r==="bogof"?(T=b==null?void 0:b[0])==null?void 0:T.id:(P=g==null?void 0:g[0])==null?void 0:P.id);if(l&&e&&A&&(r==="bogof"?a.length>0:n.length>0)&&p&&x&&g&&b&&w){console.log("AdvertisementSizeStep - Calculating pricing with:",{selectedAdSize:e,effectiveDuration:A,selectedDuration:o,pricingModel:r,selectedAreas:r==="bogof"?a:n,areas:p==null?void 0:p.length,adSizes:x==null?void 0:x.length});const B=Kh(r==="bogof"?a:n,e,A,r==="bogof",p,x,r==="bogof"?b:g,b,w,r==="bogof"?i:[],N);console.log("AdvertisementSizeStep - Pricing calculation result:",B),B?l(B):console.log("AdvertisementSizeStep - Pricing calculation returned null")}else console.log("AdvertisementSizeStep - Pricing calculation skipped, missing:",{hasOnPr
755icingChange:!!l,hasSelectedAdSize:!!e,hasEffectiveDuration:!!A,hasSelectedDuration:!!o,hasAreas:r==="bogof"?a.length>0:n.length>0,hasData:!!(p&&x&&g&&b&&w)})},[e,o,n,a,i,r,p,x,g,b,w,l]);const S=A=>{s(A)},k=(A,T)=>{var D;const P=((D=A.dimensions)==null?void 0:D.split("x"))||["100","100"],B=parseInt(P[0])||100,Y=parseInt(P[1])||100,I=Math.min(120/B,80/Y),C=B*I,L=Y*I;return t.jsx("div",{className:"flex flex-col items-center space-y-3",children:t.jsx("div",{className:oe("border-2 border-dashed rounded-lg flex items-center justify-center transition-all",T?"border-primary bg-primary/10 shadow-lg":"border-muted-foreground/30 bg-muted/20"),style:{width:`${C}px`,height:`${L}px`,minWidth:"60px",minHeight:"40px"},children:t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:A.name})})})};if(r==="leafleting")return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Advertisement Size"}),t.jsx("p",{className:"text-muted-foreground",children:"Advertisement size selection is not applicable for leafleting services."})]}),t.jsxs(ss,{children:[t.jsx(Hs,{className:"h-4 w-4"}),t.jsx(rs,{children:"Leafleting services use your own printed materials. Please proceed to the next step."})]}),t.jsx("div",{className:"flex justify-center",children:t.jsx(q,{onClick:d,size:"lg",children:"Continue to Campaign Details"})})]});if(j)return t.jsxs("div",{className:"flex items-center justify-center p-12",children:[t.jsx(it,{className:"h-8 w-8 animate-spin mr-3"}),t.jsx("span",{className:"text-lg",children:"Loading advertisement sizes..."})]});if(y||!x||x.length===0)return console.log("AdvertisementSizeStep - adSizes:",x),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Advertisement Size"}),t.jsx("p",{className:"text-muted-foreground",children:"Choose the perfect size for your advertisement"})]}),t.jsxs(ss,{variant:"destructive",children:[t.jsx(Hs,{className:"h-4 w-4"}),t.jsx(rs,{children:"Unable to load advertisement sizes. Please try refreshing the page or contact support."})]})]});const $=Array.isArray(x)?x:Object.values(x||{});console.log("AdvertisementSizeStep - adSizesArray:",$);const R=()=>{var T;if(!e||!r||(r==="bogof"?a.length===0:n.length===0))return null;const A=Kh(r==="bogof"?a:n,e,o||"",r==="bogof",p||[],Array.isArray(x)?x:Object.values(x||{}),r==="bogof"?b||[]:g||[],b||[],w||[],r==="bogof"?i:[],N);return A?t.jsxs("div",{className:"bg-primary/5 border border-primary/20 rounded-lg p-6",children:[t.jsx("h3",{className:"text-lg font-semibold mb-4",children:"SUMMARY & COST TO BOOK"}),t.jsx("div",{className:"space-y-3",children:t.jsxs("div",{className:"text-sm",children:[t.jsxs("div",{className:"mb-2",children:[t.jsx("span",{className:"font-medium",children:"Booking Type:"})," ",r==="bogof"?"3+ Subscription Package":"Pay As You Go"]}),t.jsxs("div",{className:"mb-2",children:[t.jsx("span",{className:"font-medium",children:"Advert Size:"})," ",((T=(Array.isArray(x)?x:Object.values(x||{})).find(P=>P.id===e))==null?void 0:T.name)||"Selected size"]}),r==="bogof"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mb-2",children:t.jsx("span",{className:"font-medium",children:"Paid Area Locations:"})}),a.map((P,B)=>{const Y=p==null?void 0:p.find(I=>I.id===P);return Y?t.jsxs("div",{className:"ml-2",children:["Paid - Area ",B+1," - ",Y.name]},P):null}),i.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mb-1 mt-3 font-medium",children:"FREE Area Locations:"}),t.jsxs("div",{className:"ml-2 text-sm text-muted-foreground mb-2",children:["- These are the free areas that you'll get for the next 3 Issues/6 Months",t.jsx("br",{}),"- To keep these areas after 6 months, you'll need to purchase them separately",t.jsx("br",{}),"- Use these areas to experiment with new customer generation."]}),i.map((P,B)=>{const Y=p==null?void 0:p.find(I=>I.id===P);return Y?t.jsxs("div",{className:"ml-2 text-green-600",children:["Free - Area ",B+1," - ",Y.name]},P):null})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mb-2",children:t.jsx("span",{className:"font-medium",children:"Where:"})}),n.map(P=>{const B=p==null?void 0:p.find(D=>D.id===P);if(!B)return null;const Y=f&&f[P]?f[P]:[],I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],C=["January","February","March","April","May","June","July","August","September","October","November","December"],L=Y.map(D=>
755{if(!D)return D;if(D.includes("-")){const[H,O]=D.split("-");return`${I[parseInt(O)-1]} '${H.slice(2)}`}const _=C.findIndex(H=>H.toLowerCase()===D.toLowerCase());return _!==-1?C[_]:D}).join(", ");return t.jsxs("div",{className:"ml-2 space-y-1",children:[t.jsx("div",{children:B.name}),L&&t.jsxs("div",{className:"text-xs text-muted-foreground ml-4",children:["Selected issues: ",L]})]},P)})]}),t.jsxs("div",{className:"mt-3",children:[t.jsx("span",{className:"font-medium",children:"Total Circulation per selection of area/s = "}),A.totalCirculation.toLocaleString()," homes"]}),(()=>{var I,C;const P=((I=(Array.isArray(x)?x:Object.values(x||{})).find(L=>L.id===e))==null?void 0:I.base_price_per_area)||0,B=(r==="bogof"?[...a,...i]:n).length*(((C=g==null?void 0:g.find(L=>L.id===o))==null?void 0:C.duration_value)||0),Y=B*P;return r==="fixed"?t.jsxs("div",{className:"mt-4 pt-4 border-t space-y-2",children:[t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"Rate card of insert = "}),Nt(P)," each + vat"]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"Number of inserts in this campaign = "}),B]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"Rate card cost = "}),B," x ",Nt(P)," = ",Nt(Y)]}),t.jsxs("div",{className:"pt-2 border-t",children:[t.jsx("span",{className:"font-medium",children:"Online Discount Cost "}),Nt(A.finalTotal)," + vat (",Nt(A.finalTotal*1.2),")"]})]}):null})()]})})]}):null};return t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{className:"text-center",children:[t.jsxs("h2",{className:"text-2xl font-bold mb-2 flex items-center justify-center gap-2",children:[t.jsx(Wi,{className:"h-6 w-6"}),"Choose Your Advertisement Size"]}),t.jsx("p",{className:"text-muted-foreground",children:"Select the size that best fits your advertising needs"})]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:(Array.isArray(x)?x:Object.values(x||{})).filter(A=>{var T,P;return r==="bogof"?(T=A.available_for)==null?void 0:T.includes("subscription"):((P=A.available_for)==null?void 0:P.includes("fixed"))||A.base_price_per_area>0}).sort((A,T)=>{const P=B=>{var L;const Y=((L=B.dimensions)==null?void 0:L.split("x"))||["0","0"],I=parseFloat(Y[0].replace("mm","").trim())||0,C=parseFloat(Y[1].replace("mm","").trim())||0;return I*C};return P(T)-P(A)}).map(A=>{const T=e===A.id;return t.jsxs(xe,{className:oe("cursor-pointer transition-all duration-200 hover:shadow-lg",T?"ring-2 ring-primary ring-offset-2 shadow-lg border-primary":"hover:border-primary/50"),onClick:()=>S(A.id),children:[t.jsxs(Me,{className:"pb-4",children:[t.jsx(Oe,{className:"text-lg text-center",children:A.name}),t.jsx(Er,{className:"text-center",children:A.dimensions})]}),t.jsxs(ge,{className:"text-center space-y-4",children:[k(A,T),t.jsx("div",{className:oe("w-full py-2 px-4 rounded-md text-sm font-medium transition-colors",T?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-primary/10"),children:T?"Selected":"Select This Size"})]})]},A.id)})}),c&&R(),m&&t.jsx(xN,{campaignData:m,currentStep:h})]})};var gN="Radio",[ate,pD]=hr(gN),[ite,ote]=ate(gN),xD=u.forwardRef((e,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:i,disabled:o,value:l="on",onCheck:c,form:d,...m}=e,[h,f]=u.useState(null),p=at(s,b=>f(b)),x=u.useRef(!1),g=h?d||!!h.closest("form"):!0;return t.jsxs(ite,{scope:r,checked:a,disabled:o,children:[t.jsx(ze.button,{type:"button",role:"radio","aria-checked":a,"data-state":yD(a),"data-disabled":o?"":void 0,disabled:o,value:l,...m,ref:p,onClick:Se(e.onClick,b=>{a||c==null||c(),g&&(x.current=b.isPropagationStopped(),x.current||b.stopPropagation())})}),g&&t.jsx(lte,{control:h,bubbles:!x.current,name:n,value:l,checked:a,required:i,disabled:o,form:d,style:{transform:"translateX(-100%)"}})]})});xD.displayName=gN;var gD="RadioIndicator",vD=u.forwardRef((e,s)=>{const{__scopeRadio:r,forceMount:n,...a}=e,i=ote(gD,r);return t.jsx(Ts,{present:n||i.checked,children:t.jsx(ze.span,{"data-state":yD(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:s})})});vD.displayName=gD;var lte=e=>{const{control:s,checked:r,bubbles:n=!0,...a}=e,i=u.useRef(null),o=Mu(r),l=kf(s);return u.useEffect(()=>{const c=i.current,d=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(d,"checked").set;if(o!==r&&h){const f=new Event("click",{bubbles:n});h.call(c,r),c.dispatchEvent(f)}},[o,r,n]),t.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function yD(e){return e?"checked":"unchecked"}var cte=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],vN="RadioGroup",[dte,Nfe]=hr(vN,[Iu,pD]),bD=Iu(),jD=pD(),[ute,mte]=dte(vN),wD=u.forwardRef((e,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:a,value:i,required:o=!1,disabled:l=!1,orientation:c,dir:d,loop:m=!0,onValueChange:h,...f}=e,p=bD(r),x=to(d),[g,b]=wr({prop:i,defaultProp:a,onChange:h});return t.jsx(ute,{scope:r,name:n,required:o,disabled:l,value:g,onValueChange:b,children:t.jsx(_2,{asChild:!0,...p,orientation:c,dir:x,loop:m,children:t.jsx(ze.div,{role:"radiogroup","aria-required":o,"aria-orientation":c,"data-disabled":l?"":void 0,dir:x,...f,ref:s})})})});wD.displayName=vN;var ND="RadioGroupItem",_D=u.forwardRef((e,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=e,i=mte(ND,r),o=i.disabled||n,l=bD(r),c=jD(r),d=u.useRef(null),m=at(s,d),h=i.value===a.value,f=u.useRef(!1);return u.useEffect(()=>{const p=g=>{cte.includes(g.key)&&(f.current=!0)},x=()=>f.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",x),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",x)}},[]),t.jsx(S2,{asChild:!0,...l,focusable:!o,active:h,children:t.jsx(xD,{disabled:o,required:i.required,
755checked:h,...c,...a,name:i.name,ref:m,onCheck:()=>i.onValueChange(a.value),onKeyDown:Se(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:Se(a.onFocus,()=>{var p;f.current&&((p=d.current)==null||p.click())})})})});_D.displayName=ND;var hte="RadioGroupIndicator",SD=u.forwardRef((e,s)=>{const{__scopeRadioGroup:r,...n}=e,a=jD(r);return t.jsx(vD,{...a,...n,ref:s})});SD.displayName=hte;var CD=wD,kD=_D,fte=SD;const Da=u.forwardRef(({className:e,...s},r)=>t.jsx(CD,{className:oe("grid gap-2",e),...s,ref:r}));Da.displayName=CD.displayName;const Ir=u.forwardRef(({className:e,...s},r)=>t.jsx(kD,{ref:r,className:oe("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...s,children:t.jsx(fte,{className:"flex items-center justify-center",children:t.jsx(nE,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Ir.displayName=kD.displayName;const p3=({needsDesign:e,onDesignChoiceChange:s,designFee:r,pricingModel:n,advertisingContent:a,onContentSave:i})=>{const o=c=>`£${c.toFixed(2)}`,l=a==null?void 0:a.designFee;return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"text-center",children:[t.jsxs("h2",{className:"text-2xl font-bold mb-2 flex items-center justify-center gap-2",children:[t.jsx(Wi,{className:"h-6 w-6"}),t.jsx(Be,{value:(l==null?void 0:l.pageHeading)||"Artwork Design Service",onSave:c=>i==null?void 0:i("designFee.pageHeading",c),as:"span"})]}),t.jsx(Be,{value:(l==null?void 0:l.pageDescription)||"Do you need help designing your advertisement?",onSave:c=>i==null?void 0:i("designFee.pageDescription",c),as:"p",className:"text-muted-foreground"})]}),t.jsxs(ss,{className:"bg-primary/5 border-primary/20",children:[t.jsx(Hs,{className:"h-5 w-5 text-primary"}),t.jsxs(rs,{className:"text-sm",children:[t.jsx("strong",{children:"Important:"})," ",t.jsx(Be,{value:(l==null?void 0:l.alertText)||"Professional artwork is essential for effective advertising. Our design team can create eye-catching materials that drive results.",onSave:c=>i==null?void 0:i("designFee.alertText",c),as:"span"})]})]}),t.jsxs(xe,{className:"border-2",children:[t.jsxs(Me,{children:[t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(Wi,{className:"h-5 w-5"}),t.jsx(Be,{value:(l==null?void 0:l.cardTitle)||"Artwork Design Fee",onSave:c=>i==null?void 0:i("designFee.cardTitle",c),as:"span"}),r>0&&t.jsxs(we,{variant:"secondary",className:"ml-auto text-base",children:[o(r)," + VAT"]})]}),t.jsx(Er,{children:t.jsx(Be,{value:(l==null?void 0:l.cardDescription)||"Select whether you need our professional design services",onSave:c=>i==null?void 0:i("designFee.cardDescription",c),as:"span"})})]}),t.jsxs(ge,{className:"space-y-6",children:[t.jsxs(Da,{value:e?"yes":"no",onValueChange:c=>s(c==="yes"),className:"space-y-4",children:[t.jsx(xe,{className:`cursor-pointer transition-all border-2 ${e?"border-primary bg-primary/5 shadow-md":"border-muted hover:border-primary/50"}`,onClick:()=>s(!0),children:t.jsx(ge,{className:"p-6",children:t.jsxs("div",{className:"flex items-start space-x-4",children:[t.jsx(Ir,{value:"yes",id:"design-yes",className:"mt-1"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsxs(V,{htmlFor:"design-yes",className:"text-lg font-semibold cursor-pointer flex items-center gap-2",children:[t.jsx(Be,{value:(l==null?void 0:l.yesLabel)||"Yes, please contact me to start the design process",onSave:c=>i==null?void 0:i("designFee.yesLabel",c),as:"span"}),e&&t.jsx(As,{className:"h-5 w-5 text-primary"})]}),t.jsxs("p",{className:"text-sm text-muted-foreground leading-relaxed",children:[t.jsx(Be,{value:(l==null?void 0:l.yesDescription)||"Our professional design team will work with you to create compelling artwork that captures attention and drives customer engagement.",onSave:c=>i==null?void 0:i("designFee.yesDescription",c),as:"span"})," ","Our design team will contact you after booking and invoice the ",o(r)," + VAT artwork fee separately â it is not added to your online total."]}),r>0&&e&&t.jsxs("div",{className:"pt-3 mt-3 border-t",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-sm font-medium",children:"Design Fee:"}),t.jsxs(we,{variant:"default",className:"text-base",children:[o(r)," + VAT"]})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Invoiced separately by our team â not charged via the website."})]}),t.jsxs("div",{className:"pt-2",children:[t.jsxs("p",{className:"text-xs text-primary font-medium",children:["â ",t.jsx(Be,{value:(l==null?void 0:l.bullet1)||"Professional design consultation",onSave:c=>i==null?void 0:i("designFee.bullet1",c),as:"span"})]}),t.jsxs("p",{className:"text-xs text-primary font-medium",children:["â ",t.jsx(Be,{value:(l==null?void 0:l.bullet2)||"Unlimited revisions until you're satisfied",onSave:c=>i==null?void 0:i("designFee.bullet2",c),as:"span"})]}),t.jsxs("p",{className:"text-xs text-primary font-medium",children:["â ",t.jsx(Be,{value:(l==null?void 0:l.bullet3)||"Print-ready artwork delivered",onSave:c=>i==null?void 0:i("designFee.bullet3",c),as:"span"})]})]})]})]})})}
755),t.jsx(xe,{className:`cursor-pointer transition-all border-2 ${e?"border-muted hover:border-primary/50":"border-primary bg-primary/5 shadow-md"}`,onClick:()=>s(!1),children:t.jsx(ge,{className:"p-6",children:t.jsxs("div",{className:"flex items-start space-x-4",children:[t.jsx(Ir,{value:"no",id:"design-no",className:"mt-1"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsxs(V,{htmlFor:"design-no",className:"text-lg font-semibold cursor-pointer flex items-center gap-2",children:[t.jsx(Be,{value:(l==null?void 0:l.noLabel)||"No, finished artwork will be supplied",onSave:c=>i==null?void 0:i("designFee.noLabel",c),as:"span"}),!e&&t.jsx(As,{className:"h-5 w-5 text-primary"})]}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t.jsx(Be,{value:(l==null?void 0:l.noDescription)||"You'll provide your own print-ready artwork that meets our specifications. No design fee will be added to your booking.",onSave:c=>i==null?void 0:i("designFee.noDescription",c),as:"span"})}),t.jsx("div",{className:"pt-2",children:t.jsxs("p",{className:"text-xs text-muted-foreground",children:["â¹ï¸ ",t.jsx(Be,{value:(l==null?void 0:l.noNote)||"Artwork must be supplied in high-resolution (300dpi) print-ready format (PDF, JPG)",onSave:c=>i==null?void 0:i("designFee.noNote",c),as:"span"})]})})]})]})})})]}),t.jsx(ss,{children:t.jsxs(rs,{className:"text-xs",children:[t.jsx("strong",{children:"Note:"})," ",t.jsx(Be,{value:(l==null?void 0:l.footerNote)||"The design fee covers the creation of your artwork. If you choose to supply your own artwork, please ensure it meets our technical specifications.",onSave:c=>i==null?void 0:i("designFee.footerNote",c),as:"span"})]})})]})]})]})},Wu=()=>Lt({queryKey:["payment-options"],queryFn:async()=>{const{data:e,error:s}=await W.from("payment_options").select("*").eq("is_active",!0).order("sort_order");if(s)throw s;return e||[]},staleTime:5*60*1e3}),fu=(e,s,r,n,a=0)=>{var c,d,m,h,f,p,x;a=0;const i=e;let o=i;const l=()=>{const g=n.find(w=>w.option_type==="monthly");if(!g)return;let b=i;return r==="bogof"&&(b=i/2),g.discount_percentage>0&&(b=b*(1-g.discount_percentage/100)),g.additional_fee_percentage!==0&&(b=b*(1+g.additional_fee_percentage/100)),g.minimum_payments&&(b=b/g.minimum_payments),a>0&&g.minimum_payments&&(b+=a/g.minimum_payments),b};if(s.option_type==="monthly"){const g=l();return g!==void 0?g:o}if(r==="bogof"){const g=l();if(g!==void 0){if((c=s.display_name)!=null&&c.includes("6 Months")){const b=((d=n.find(j=>j.option_type==="monthly"))==null?void 0:d.minimum_payments)||12;return(g-a/b)*6+a}if((m=s.display_name)!=null&&m.includes("12 Months")||(h=s.option_type)!=null&&h.includes("12")){const b=((f=n.find(j=>j.option_type==="monthly"))==null?void 0:f.minimum_payments)||12;return(g-a/b)*12*.9+a}}}return r!=="bogof"&&((p=s.display_name)!=null&&p.includes("12 Months")||(x=s.option_type)!=null&&x.includes("12"))&&(o=i*2),s.discount_percentage>0&&(o=o*(1-s.discount_percentage/100)),s.additional_fee_percentage!==0&&(o=o*(1+s.additional_fee_percentage/100)),s.minimum_payments&&s.option_type==="monthly"?o/s.minimum_payments+a/s.minimum_payments:o+a},m0=e=>new Intl.NumberFormat("en-GB",{style:"currency",currency:"GBP",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),$D=6,ED=new Set(["bogof"]);function yN(e){return!!e&&ED.has(String(e))}function Ad(e){const{pricingModel:s,monthlyPrice:r,fallbackFinalTotal:n}=e,a=e.minimumPayments??$D,i=Number(r)||0;return yN(s)&&i>0?Math.round(i*a*100)/100:Number(n)||0}const x3=Object.freeze(Object.defineProperty({__proto__:null,SUBSCRIPTION_MODELS:ED,SUBSCRIPTION_PAYMENTS:$D,isSubscriptionModel:yN,normaliseFinalTotal:Ad},Symbol.toStringTag,{value:"Module"}));function fx(e,s){const r=e??[];return yN(s)?r:r.filter(n=>(n==null?void 0:n.option_type)!=="monthly")}const pte=Eee.string().trim().min(1,"Enter a code").max(32,"Code too long");function bN({productType:e,email:s,currentDiscount:r,onApplied:n,onCleared:a}){const[i,o]=u.useState(""),[l,c]=u.useState(!1),[d,m]=u.useState(null),h=async()=>{var g;m(null);const p=pte.safeParse(i);if(!p.success){m({kind:"error",text:((g=p.error.issues[0])==null?void 0:g.message)||"Invalid code"});return}const x=p.data.toUpperCase();c(!0);try{const{data:b,error:w}=await W.rpc("validate_discount_code",{p_code:x,p_product_type:e,p_email:s||void 0});if(w){m({kind:"error",text:w.message});return}const j=b;
755if(!(j!=null&&j.valid)){m({kind:"error",text:(j==null?void 0:j.message)||"This code is not valid."});return}n({code:x,code_id:j.code_id,discount_type:j.discount_type,discount_value:Number(j.discount_value)||0,free_item_text:j.free_item_text??null}),o(""),m({kind:"success",text:`Code "${x}" applied.`})}catch(b){m({kind:"error",text:(b==null?void 0:b.message)||"Failed to validate code."})}finally{c(!1)}},f=()=>{a(),m(null)};return r?t.jsxs("div",{className:"rounded-md border bg-muted/40 p-3 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx(Bs,{className:"h-4 w-4 text-green-600"}),t.jsxs("span",{children:["Voucher code ",t.jsx("span",{className:"font-mono font-semibold",children:r.code})," applied"]})]}),t.jsxs(q,{type:"button",variant:"ghost",size:"sm",onClick:f,children:[t.jsx(Es,{className:"h-4 w-4 mr-1"})," Remove"]})]}):t.jsxs("div",{className:"space-y-2",children:[t.jsxs(V,{htmlFor:"discount-code",className:"flex items-center gap-2 text-sm",children:[t.jsx(fc,{className:"h-4 w-4"})," Voucher code"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(re,{id:"discount-code",value:i,onChange:p=>o(p.target.value.toUpperCase()),placeholder:"Enter code",maxLength:32,className:"font-mono",onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),h())}}),t.jsx(q,{type:"button",onClick:h,disabled:l||!i.trim(),children:l?"Checkingâ¦":"Apply"})]}),d&&t.jsx("p",{className:d.kind==="error"?"text-sm text-destructive":"text-sm text-green-700",children:d.text})]})}const Kn=e=>Math.round(e*100)/100;function Qh(e){const s=Math.max(0,Number(e.baseFinalTotal)||0),r=Math.max(0,Number(e.baseMonthly)||0);if(!e.discount)return{adjustedFinalTotal:s,adjustedMonthly:r,discountAmount:0,lineLabel:"",isFreeItem:!1};const{discount_type:n,discount_value:a,free_item_text:i}=e.discount,o=Math.max(0,Number(a)||0);if(n==="free_item")return{adjustedFinalTotal:s,adjustedMonthly:r,discountAmount:0,lineLabel:i||"Free item",isFreeItem:!0};if(n==="percentage"){const l=Math.min(100,o),c=1-l/100;if(e.productType==="subscription"){const m=Kn(r*c),h=e.contractMonths&&e.contractMonths>0?e.contractMonths:r>0?Math.round(s/r):0,f=h>0?Kn(m*h):Kn(s*c);return{adjustedFinalTotal:f,adjustedMonthly:m,discountAmount:Kn(s-f),lineLabel:`${l}% off`,isFreeItem:!1}}const d=Kn(s*c);return{adjustedFinalTotal:d,adjustedMonthly:0,discountAmount:Kn(s-d),lineLabel:`${l}% off`,isFreeItem:!1}}if(n==="fixed_amount"){if(e.productType==="subscription"){const c=e.contractMonths&&e.contractMonths>0?e.contractMonths:r>0?Math.round(s/r):1,d=c>0?o/c:o,m=Math.max(0,Kn(r-d)),h=c>
7550?Kn(m*c):Math.max(0,Kn(s-o));return{adjustedFinalTotal:h,adjustedMonthly:m,discountAmount:Kn(s-h),lineLabel:`£${o.toFixed(2)} off`,isFreeItem:!1}}const l=Math.max(0,Kn(s-o));return{adjustedFinalTotal:l,adjustedMonthly:0,discountAmount:Kn(s-l),lineLabel:`£${o.toFixed(2)} off`,isFreeItem:!1}}return{adjustedFinalTotal:s,adjustedMonthly:r,discountAmount:0,lineLabel:"",isFreeItem:!1}}function xte(e){return e==="bogof"?"subscription":e==="leafleting"?"leaflets":"fixed_term"}const g3=({pricingModel:e,selectedAreas:s,bogofPaidAreas:r,bogofFreeAreas:n,selectedAdSize:a,selectedDuration:i,pricingBreakdown:o,selectedPaymentOption:l,onPaymentOptionChange:c,selectedStartingIssue:d,onStartingIssueChange:m,onNext:h,needsDesign:f=!1,designFee:p=0,advertisingContent:x,onContentSave:g,discount:b=null,onDiscountChange:w})=>{var ee,se,le,X,ye,Ce,ke,fe,Ee,K,te,Q,ae,me,pe,be;const{areas:j,adSizes:y,durations:v}=ji(),{leafletAreas:N,leafletSizes:S}=Hu(),{data:k=[]}=Wu(),{nextStep:$}=Wv(),[R,A]=u.useState(),[T,P]=u.useState(),{data:B,isLoading:Y}=pN(R,T);u.useEffect(()=>{(async()=>{const{data:{user:ie}}=await W.auth.getUser();if(ie){A(ie.email);const{data:je}=await W.from("profiles").select("phone").eq("user_id",ie.id).maybeSingle();je!=null&&je.phone&&P(je.phone)}})()},[]);const I=ce=>qQ(ce),C=e==="leafleting"?N:j,L=e==="bogof"?[...r,...n]:s,D=(C==null?void 0:C.filter(ce=>L.includes(ce.id)))||[],_=GQ(D);ve.useEffect(()=>{!d&&_.length>0&&(m==null||m(_[0].value))},[d,_,m]);const H=()=>{if(e==="leafleting"){const ce=S==null?void 0:S.find(ie=>ie.id===a);return(ce==null?void 0:ce.label)||"Unknown Size"}else{const ce=y==null?void 0:y.find(ie=>ie.id===a);return(ce==null?void 0:ce.name)||"Unknown Size"}},O=()=>{if(e==="bogof")return"6 months";const ce=v==null?void 0:v.find(ie=>ie.id===i);return(ce==null?void 0:ce.name)||"Unknown Duration"},U=(o==null?void 0:o.finalTotal)||0,G=(o==null?void 0:o.cpm)||0,E=((o==null?void 0:o.designFee)??0)||f&&p||0,z=(ce,ie)=>{var Ve,lt;if(!b)return{amount:ce,saving:0};const je=ie.option_type==="monthly",Re=je?ie.minimum_payments||12:(Ve=ie.display_name)!=null&&Ve.includes("12")?12:(lt=ie.display_name)!=null&<.includes("6")?6:1,Ae=Qh({productType:"subscription",baseFinalTotal:ce*Re,baseMonthly:je?ce:ce/Math.max(1,Re),contractMonths:Re,discount:b}),Ue=je?Ae.adjustedMonthly:Ae.adjustedFinalTotal;return{amount:Ue,saving:Math.max(0,ce-Ue)}},Z=()=>{l&&$()},F=e==="bogof"&&B&&!B.isEligible;return t.jsxs("div",{className:"space-y-8 max-w-4xl mx-auto",children:[F&&t.jsxs(ss,{className:"bg-pink-50 border-pink-200 dark:bg-pink-950/20 dark:border-pink-800",children:[t.jsx(Hs,{className:"h-4 w-4 text-pink-600 dark:text-pink-400"}),t.jsxs(rs,{className:"text-pink-800 dark:text-pink-300",children:[t.jsx("strong",{children:"Returning Customer"})," â You've previously used this offer. Complete your booking and our team will c
755ontact you with exclusive returning customer rates!"]})]}),t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("h2",{className:"text-3xl font-bold",children:"YOUR BASKET"}),t.jsx("p",{className:"text-muted-foreground",children:"Review your selection and choose your payment option"})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[t.jsxs("div",{className:"space-y-6",children:[t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-xl",children:"Booking Summary"})}),t.jsxs(ge,{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Advert Size"}),t.jsx("p",{className:"font-medium",children:H()}),(()=>{if(e==="leafleting")return null;const ce=y==null?void 0:y.find(ie=>ie.id===a);return ce!=null&&ce.dimensions?t.jsxs("div",{className:"mt-1",children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Dimensions"}),t.jsx("p",{className:"text-sm",children:ce.dimensions})]}):null})()]}),e==="bogof"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Booking Type"}),t.jsx(Be,{value:((se=(ee=x==null?void 0:x.bookingSummary)==null?void 0:ee.bogof)==null?void 0:se.bookingTypeText)||"3+ Subscription Package for New Advertisers including Buy One Area Get One Area Free",onSave:ce=>g==null?void 0:g("bookingSummary.bogof.bookingTypeText",ce),as:"p",className:"font-medium"})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Minimum Duration"}),t.jsx(Be,{value:((X=(le=x==null?void 0:x.bookingSummary)==null?void 0:le.bogof)==null?void 0:X.minimumDurationText)||"3 issues per area = 6 months",onSave:ce=>g==null?void 0:g("bookingSummary.bogof.minimumDurationText",ce),as:"p",className:"font-medium"})]})]}),!e&&t.jsxs("div",{children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Duration"}),t.jsx("p",{className:"font-medium",children:O()})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"When Would You like Your Advertising to Start?"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose one:"}),_.length>0?t.jsxs("div",{className:"border rounded-lg p-4",children:[t.jsx(Da,{value:d||((ye=_[0])==null?void 0:ye.value),onValueChange:ce=>m==null?void 0:m(ce),className:"space-y-2",children:_.map(ce=>t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(Ir,{value:ce.value,id:ce.value}),t.jsx(V,{htmlFor:ce.value,className:"text-sm font-medium cursor-pointer",children:ce.label})]},ce.value))}),(()=>{var Ae;const ce=d||((Ae=_[0])==null?void 0:Ae.value),ie=_.find(Ue=>Ue.value===ce);if(!ie||ie.value==="later")return null;const je=ie.eligibleAreaIds.length,Re=ie.ineligibleAreaIds.length;return je===0||Re===0?null:t.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["Starts this month for ",je," of ",ie.totalAreas," areas. The remaining ",Re," ",Re===1?"area starts":"areas start"," on their next available issue (see Campaign Schedule below)."]})})()]}):t.jsx("p",{className:"font-medium",children:"Next available issue"})]}),t.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-lg mb-2",children:e==="bogof"?"Campaign ScheduleâMonths 1-6":"Campaign Schedule"}),t.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"A full schedule with copy deadlines, print and delivery dates will be available to download in your account"})]}),(e==="bogof"?[...D].sort((ce,ie)=>{const je=r.includes(ce.id),Re=r.includes(ie.id);return je&&!Re?-1:!je&&Re?1:0}):D).map(ce=>{var J;const ie=d||((J=_[0])==null?void 0:J.value)||"",je=e==="bogof"?3:parseInt(i)||3,{issues:Re,shortfall:Ae}=GS(ce,ie==="later"?void 0:ie,je),Ue=Re[0],Ve=e==="bogof"?r.includes(ce.id):!0,lt=e==="bogof"?n.includes(ce.id):!1;return t.jsxs("div",{className:"space-y-2 pb-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[e==="bogof"&&Ve&&t.jsx(we,{variant:"default",className:"bg-primary",children:"Paid"}),e==="bogof"&<&&t.jsx(we,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Free"}),t.jsxs("p",{className:"font-medium",children:[e==="leafleting"&&"area_number"in ce?`Area ${ce.area_number}â`:"",ce.name]})]}),Re.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming issues are currently sc
755heduled for this areaâplease call 023 8026 6388."}):t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Issues: "}),Re.map(Ne=>Ne.label).join(", ")]}),Ae>0&&t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Only ",Re.length," of ",je," issues are currently scheduled for this areaâour team will confirm the remaining ",Ae," ",Ae===1?"issue":"issues"," with you."]}),(Ue==null?void 0:Ue.copyDeadlineText)&&t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Copy deadline: "}),I(Ue.copyDeadlineText)]}),(Ue==null?void 0:Ue.printDeadlineText)&&t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Print deadline: "}),I(Ue.printDeadlineText)]}),(Ue==null?void 0:Ue.deliveryDateText)&&t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Week Commencing: "}),I(Ue.deliveryDateText)]})]})]},ce.id)}),e==="bogof"&&r.length>0&&t.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-lg mb-2",children:"Campaign ScheduleâMonths 7 onwards until cancellation"}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"You are free to opt out after Months 1-6"})]}),r.map((ce,ie)=>{var lt;const je=D.find(J=>J.id===ce);if(!je)return null;const Re=d||((lt=_[0])==null?void 0:lt.value)||"",{issues:Ae}=GS(je,Re==="later"?void 0:Re,4),Ue=Ae[3];let Ve;if(Ue)Ve=Ue.label;else{const J=Ae[0];if(!J)return null;Ve=new Date(J.year,J.monthIndex+6,1).toLocaleDateString("en-GB",{month:"long",year:"numeric"})}return t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(we,{variant:"default",className:"bg-primary",children:"Paid"}),t.jsx("p",{className:"font-medium",children:je.name})]}),t.jsxs("p",{className:"text-sm",children:[Ve," and bi-monthly thereafter"]})]},ce)})]})]})]})]}),t.jsx(xe,{children:t.jsx(ge,{className:"pt-6",children:t.jsxs("div",{className:"text-center",children:[t.jsxs(V,{className:"text-sm font-medium text-muted-foreground",children:["Total Number of Homes Reached",e==="bogof"&&" (Months 1-6)"]}),t.jsxs("p",{className:"text-2xl font-bold text-primary",children:[((Ce=o==null?void 0:o.totalCirculation)==null?void 0:Ce.toLocaleString())||0," homes"]}),e==="bogof"&&(()=>{const ce=v==null?void 0:v.find(Ae=>Ae.id===i),ie=(ce==null?void 0:ce.duration_value)||0,je=ie,Re=((o==null?void 0:o.totalCirculation)||0)*je;return je>1?t.jsxs("div",{className:"mt-3 pt-3 border-t",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Your advert will be published ",t.jsxs("span",{className:"font-semibold text-foreground",children:[je," times"]})," over ",ie," months"]}),t.jsxs("p",{className:"text-lg font-semibold text-primary mt-2",children:[Re.toLocaleString()," total impressions"]})]}):null})()]})})}),e==="bogof"&&t.jsxs(xe,{className:"border-amber-200 bg-amber-50",children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-lg text-amber-800",children:"Commitment Terms"})}),t.jsxs(ge,{className:"text-sm text-amber-700 space-y-3",children:[t.jsx("p",{className:"font-medium",children:"After six months you have three choices:"}),t.jsxs("ol",{className:"list-decimal list-inside space-y-1 ml-2",children:[t.jsx("li",{children:"Continue with the paid for areas at the same cost"}),t.jsx("li",{children:"Change your campaign at a revised cost"}),t.jsx("li",{children:"Cancel and nothing more to pay!"})]}),t.jsx("p",{className:"text-xs",children:"Hopefully, you will want to continue and we'll do all we can to ensure you get the best from your investment in Discover."}),t.jsx("p",{className:"font-medium",children:"Minimum commitment: 3 issues in each area = 6 months of advertising"})]})]})]}),t.jsx("div",{className:"space-y-6",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"text-xl",children:[fx(k,e).length," Payment Option",fx(k,e).length!==1?"s":""]})}),t.jsxs(ge,{children:[e==="bogof"&&w&&t.jsx("div",{className:"mb-4",children:t.jsx(bN,{productType:"subscription",email:R,currentDiscount:b,onApplied:w,onCleared:()=>w(null)})}),t.jsx(Da,{value:l,onValueChange:c,className:"space-y-4",children:fx(k,e).sort((ce,ie)=>{const je=Re=>{var Ae,Ue;
755return Re.option_type==="monthly"?1:(Ae=Re.display_name)!=null&&Ae.includes("6 Months")?2:(Ue=Re.display_name)!=null&&Ue.includes("12 Months")?3:4};return je(ce)-je(ie)}).map(ce=>{const ie=fu(U,ce,e,k,E),{amount:je,saving:Re}=z(ie,ce),Ae=(ce.discount_percentage>0?U-ie:0)+Re;return t.jsxs("div",{className:"flex items-start space-x-3 p-4 border rounded-lg hover:bg-muted/50",children:[t.jsx(Ir,{value:ce.option_type,id:ce.option_type,className:"mt-1"}),t.jsxs("div",{className:"flex-1",children:[t.jsx(V,{htmlFor:ce.option_type,className:"font-medium cursor-pointer",children:ce.option_type==="monthly"?"Monthly Payment Plan":ce.display_name}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:ce.option_type==="monthly"?"GoCardless":ce.description}),t.jsxs("p",{className:"text-lg font-bold text-primary",children:[Nt(je)," + VAT"]}),b&&Re>0&&t.jsxs("p",{className:"text-xs text-green-700",children:["Discount ",b.code," â ",b.discount_type==="percentage"?`${b.discount_value}% off`:`£${Number(b.discount_value).toFixed(2)} off`]}),b&&b.discount_type==="free_item"&&t.jsxs("p",{className:"text-xs text-green-700",children:["Free item (",b.code,"): ",b.free_item_text]}),Ae>0&&t.jsxs(we,{variant:"secondary",className:"bg-green-100 text-green-800 text-xs",children:["Save ",Nt(Ae)]}),ce.minimum_payments&&t.jsx("div",{className:"text-sm text-muted-foreground mt-1 space-y-1",children:t.jsxs("p",{children:["⢠Minimum number of payments = ",ce.minimum_payments]})})]})]},ce.id)})}),t.jsx("div",{className:"mt-6 p-4 bg-gradient-to-r from-primary/10 to-secondary/10 rounded-lg border",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h4",{className:"font-bold text-lg mb-2",children:"ð¯ Amazing Value!"}),t.jsx("p",{className:"text-xl font-bold text-primary",children:(()=>{if(o!=null&&o.totalCirculation){const ce=k.find(ie=>ie.option_type==="monthly");if(ce){const je=fu(U,ce,e,k,E)*2/o.totalCirculation*1e3;return`Only ${Nt(je)} + VAT per 1,000 homes reached`}}return`Only ${Nt(G)} + VAT per 1,000 homes reached`})()})]})}),E>0&&t.jsxs("div",{className:"mt-6 rounded-md border border-dashed border-muted-foreground/30 bg-muted/30 p-4 space-y-1",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm font-medium",children:"Artwork Design Fee"}),t.jsxs("span",{className:"font-semibold",children:[Nt(E)," + VAT"]})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Invoiced separately by our team after booking â not added to the online total above."})]}),t.jsxs("div",{className:"mt-6 space-y-4",children:[t.jsx("h4",{className:"font-semibold text-lg text-center",children:"What to Do Next"}),t.jsx("button",{onClick:()=>{window.open("tel:02380266388","_self")},className:"w-full bg-accent text-accent-foreground hover:bg-accent/80 font-medium py-3 px-6 rounded-md transition-colors",children:"Call Discover Team for Advice 023 8026 6388"}),t.jsx("button",{onClick:Z,disabled:!l,className:"w-full bg-secondary text-secondary-foreground hover:bg-secondary/80 font-medium py-3 px-6 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Save Quote"}),t.jsx("button",{onClick:Z,disabled:!l,className:"w-full bg-primary text-primary-foreground hover:bg-primary/90 font-medium py-3 px-6 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Book Now"})]}),t.jsxs("div",{className:"mt-4 p-3 bg-muted/50 rounded-md text-sm",children:[t.jsx("p",{className:"font-medium mb-1",children:"DESIGN SERVICE:"}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((fe=(ke=x==null?void 0:x.bookingSummary)==null?void 0:ke.bogof)==null?void 0:fe.designServiceText)||"By booking online you get discounted advert design. Our professional design team creates response focused ads at very low cost - just provide your content, images, logo and branding kit if you have one.",onSave:ce=>g==null?void 0:g("bookingSummary.bogof.designServiceText",ce),as:"span"})})]}),t.jsxs("div",{className:"mt-6 space-y-4 text-sm",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-primary font-medium",children:"ð¦"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"WHAT YOU'RE BOOKING:"}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((K=(Ee=x==null?void 0:x.bookingSummary)==null?void 0:Ee.bogof)==null?void 0:K.whatYoureBookingText)||"A c
755omplete advertising package including professional ad design, guaranteed distribution to your selected areas, and placement in our trusted local publication",onSave:ce=>g==null?void 0:g("bookingSummary.bogof.whatYoureBookingText",ce),as:"span"})})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-primary font-medium",children:"ð°"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"INVESTMENT SHOWN:"}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((Q=(te=x==null?void 0:x.bookingSummary)==null?void 0:te.bogof)==null?void 0:Q.investmentShownText)||"Your total includes all costs - ad creation, distribution, and VAT. No hidden fees or surprise charges",onSave:ce=>g==null?void 0:g("bookingSummary.bogof.investmentShownText",ce),as:"span"})})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-primary font-medium",children:"â¡"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"IMMEDIATE CONFIRMATION:"}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((me=(ae=x==null?void 0:x.bookingSummary)==null?void 0:ae.bogof)==null?void 0:me.immediateConfirmationText)||"Book now for instant campaign confirmation and priority page position or call us for help and advice.",onSave:ce=>g==null?void 0:g("bookingSummary.bogof.immediateConfirmationText",ce),as:"span"})})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-primary font-medium",children:"ð¯"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"GUARANTEED REACH:"}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((be=(pe=x==null?void 0:x.bookingSummary)==null?void 0:pe.bogof)==null?void 0:be.guaranteedReachText)||"Your ad will reach every household in your selected areas during the scheduled distribution period, on time, every time.",onSave:ce=>g==null?void 0:g("bookingSummary.bogof.guaranteedReachText",ce),as:"span"})})]})]})]})]})]})})]})]})},gte=e=>{if(!e)return"Invalid Date";const s=["January","February","March","April","May","June","July","August","September","October","November","December"];let r,n;if(e.includes("-")){[r,n]=e.split("-");const a=parseInt(n,10);if(a>=1&&a<=12&&r)return`${s[a-1]} ${r}`}else if(e.includes(" ")){const a=e.split(" ");if(a.length===2){const i=s.findIndex(o=>o.toLowerCase()===a[0].toLowerCase());if(i!==-1)return`${s[i]} ${a[1]}`}}return e},h0=e=>{if(!e)return"";try{if(e.includes(".")){const s=V2(e,"dd.MM.yyyy",new Date);if(!isNaN(s.getTime()))return s.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}if(e.includes("-")&&e.length>7){const s=new Date(e);if(!isNaN(s.getTime()))return s.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}return e}catch{return e}},v3=({selectedAreas:e,selectedLeafletSize:s,selectedDuration:r,selectedMonths:n,pricingBreakdown:a,onNext:i,onMonthsChange:o,advertisingContent:l,onContentSave:c,discount:d=null,onDiscountChange:m,customerEmail:h})=>{var A,T,P,B,Y,I,C,L,D;const{leafletAreas:f,leafletSizes:p,leafletDurations:x}=Hu(),{nextStep:g}=Wv(),b=()=>{const _=p==null?void 0:p.find(H=>H.id===s);return(_==null?void 0:_.label)||"Unknown Size"},w=_=>{const H=f==null?void 0:f.find(O=>O.id===_);return(H==null?void 0:H.name)||"Unknown Area"},j=_=>{const H=f==null?void 0:f.find(O=>O.id===_);return(H==null?void 0:H.area_number)||""},y=()=>{const _=x==null?void 0:x.find(H=>H.id===r);return(_==null?void 0:_.issues)||0},v=new Set((f||[]).map(_=>_.id)),N=Array.from(new Set(e)).filter(_=>v.has(_));f!=null&&f.filter(_=>N.includes(_.id)).reduce((_,H)=>_+(H.bimonthly_circulation||0),0);const S=(a==null?void 0:a.finalTotal)||0,k=Qh({productType:"leaflets",baseFinalTotal:S,discount:d}),$=k.adjustedFinalTotal,R=()=>{g()};return t.jsxs("div",{className:"space-y-8 max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("h2",{className:"text-3xl font-bold",children:"YOUR BASKET"}),t.jsx("p",{className:"text-muted-foreground",children:"Review your selection and choose your payment option"})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[t.jsx("div",{className:"space-y-6",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-xl",children:"Booking Summary"})}),t.jsxs(ge,{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Leaflet Size"}),t.jsx("p",{className:"font-medium",children:b()})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Booking Type"}),t.jsx(Be,{value:((T=(A=l==null?void 0:l.bookingSummary)==null?void 0:A.leafleting)==null?void 0:T.bookingTypeText)||"Leaflet Distribution Campaign",onSave:_=>c==null?void 0:c("bookingSummary.leafleting.bookingTypeText",_),as:"p",className:"font-medium"})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Number of Deliveries per Area"}),t.jsx("p",{className:"font-medium",children:y()})]}),t.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-lg mb-2",children:"Campaign Schedule"}),t.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"A full schedule with copy deadlines, print and delivery dates will be available to download in your account"})]}),N.map(_=>{const H=f==null?void 0:f.find(se=>se.id===_);if(!H)return null;const O=j(_),U=w(_),G=(n==null?void 0:n[_])||[];if(G.length===0)return null;const E=H.schedule||[],z=G.map(se=>gte(se)).join(", "),Z=G[0];let M="",F="",ee="";if(E&&E.length>0){const se=E.find(le=>{if(le.month&&Z){if(le.month.includes("-")&&Z.includes("-"))return le.month===Z;const X=Z.split("-");if(X.length===2){const ye=["January","February","March","April","May","June","July","August","September","October","November","December"],Ce=parseInt(X[1],10),ke=ye[Ce-1];return le.month===ke&&le.year===X[0]}}return!1});se&&(M=se.copyDeadline||"",F=se.printDeadline||"",ee=se.deliveryDate||"")}return t.jsxs("div",{className:"space-y-2 pb-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(we,{variant:"default",className:"bg-primary",children:"Paid"}),t.jsxs("p",{className:"font-medium",children:[O?`Area ${O}â`:"",U.toUpperCase()]})]}),t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Issues: "}),z]}),M&&t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Copy deadline: "}),h0(M)]}),F&&t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Print deadline: "}),h0(F)]}),ee&&t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Week Commencing: "}),h0(ee)]})]},_)})]}),t.jsx("div",{className:"pt-4 border-t",children:t.jsxs("div",{className:"text-center",children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Total Number of Homes Reached"}),t.jsxs("p",{className:"text-2xl font-bold text-primary",children:[((P=a==null?void 0:a.totalCirculation)==null?void 0:P.toLocaleStr
755ing())||0," homes"]})]})})]})]})}),t.jsx("div",{className:"space-y-6",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-xl",children:"Payment Terms"})}),t.jsxs(ge,{className:"space-y-4",children:[t.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg border border-border",children:[t.jsxs("p",{className:"text-sm leading-relaxed",children:["Payment is required ",t.jsx("strong",{children:"25% at time of booking"})," and ",t.jsx("strong",{children:"75% 10 days prior to the delivery date"}),"."]}),t.jsx("p",{className:"text-sm leading-relaxed mt-3",children:"No monthly payment plan or extra discount for payment in full in advance."}),t.jsx("p",{className:"text-sm leading-relaxed mt-3",children:"If the booking is made within the 10 days, then payment will be required in full."})]}),t.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[m&&t.jsx("div",{className:"pb-3",children:t.jsx(bN,{productType:"leaflets",email:h,currentDiscount:d,onApplied:m,onCleared:()=>m(null)})}),(a==null?void 0:a.comboDiscountPercent)>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex justify-between items-center text-sm",children:[t.jsx("span",{children:"Subtotal:"}),t.jsx("span",{className:"font-medium",children:Nt(a.subtotal)})]}),t.jsxs("div",{className:"flex justify-between items-center text-sm text-green-600",children:[t.jsxs("span",{children:["Combo Discount (",a.comboDiscountPercent,"%):"]}),t.jsxs("span",{className:"font-medium",children:["-",Nt(a.comboDiscount)]})]}),t.jsx("div",{className:"h-px bg-border my-2"})]}),(a==null?void 0:a.designFee)&&a.designFee>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex justify-between items-center text-sm",children:[t.jsx("span",{children:"Artwork Design Service:"}),t.jsx("span",{className:"font-medium",children:Nt(a.designFee)})]}),t.jsx("div",{className:"h-px bg-border my-2"})]}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"Campaign Cost excluding VAT"}),t.jsx("span",{className:"font-medium",children:Nt(S)})]}),d&&k.discountAmount>0&&t.jsxs("div",{className:"flex justify-between items-center text-sm text-green-700",children:[t.jsxs("span",{children:["Voucher code applied: ",d.code]}),t.jsxs("span",{className:"font-medium",children:["-",Nt(k.discountAmount)]})]}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-lg font-semibold",children:"Total Cost excluding VAT"}),t.jsx("span",{className:"text-2xl font-bold text-primary",children:Nt($)})]}),d&&k.isFreeItem&&t.jsxs("div",{className:"flex justify-between items-center text-sm text-green-700",children:[t.jsxs("span",{children:["Free item (",d.code,"): ",k.lineLabel]}),t.jsx("span",{className:"font-medium",children:Nt(0)})]}),t.jsxs("div",{className:"flex justify-between items-center text-sm text-muted-foreground",children:[t.jsx("span",{children:"25% Deposit:"}),t.jsx("span",{className:"font-medium",children:Nt($*.25)})]}),t.jsxs("div",{className:"flex justify-between items-center text-sm text-muted-foreground",children:[t.jsx("span",{children:"Balance (75%):"}),t.jsx("span",{className:"font-medium",children:Nt($*.75)})]})]}),t.jsx("div",{className:"mt-6 p-4 bg-gradient-to-r from-primary/10 to-secondary/10 rounded-lg border",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h4",{className:"font-bold text-lg mb-2",children:"ð¯ Amazing Value!"}),t.jsx("p",{className:"text-xl font-bold text-primary",children:(()=>{if(a!=null&&a.totalCirculation&&(a!=null&&a.durationMultiplier)){const H=S/a.durationMultiplier/a.totalCirculation*1e3;return`Only ${Nt(H)} + VAT per 1,000 homes reached`}return"Calculating..."})()})]})}),t.jsxs("div",{className:"mt-6 space-y-4",children:[t.jsx("h4",{className:"font-semibold text-lg text-center",children:"What to Do Next"}),t.jsx("button",{onClick:()=>{window.open("tel:02380266388","_self")},className:"w-full bg-accent text-accent-foreground hover:bg-accent/80 font-medium py-3 px-6 rounded-md transition-colors",children:"Call Discover Team for Advice 023 8026 6388"}),t.jsx("button",{onClick:R,className:"w-full bg-secondary text-secondary-foreground hover:bg-secondary/80 font-medium py-3 px-6 rounded-md transition-colors",children:"Save Quote"}),t.jsx("button",{onClick:R,className:"w-full bg-primary text-primary-foreground hover:bg-primary/90 font-medium py-3 px-6 rounded-md transition-colors",children:"Book Now"})]}),t.jsxs("div",{className:"mt-6 space-y-4 text-sm",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-primary font-medium",children:"ð¦"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"WHAT YOU'RE BOOKING:"}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((Y=(B=l==null?void 0:l.bookingSummary)==null?void 0:B.leafleting)==null?void 0:Y.whatYoureBookingText)||"Professional leaflet distribution service to your selected areas with guaranteed delivery to homes",onSave:_=>c==null?void 0:c("bookingSummary.leafleting.whatYoureBookingText",_),as:"span"})})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-primary font-medium",children:"ð°"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"INVESTMENT SHOWN:"}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((C=(I=l==null?void 0:l.bookingSummary)==null?void 0:I.leafleting)==null?void 0:C.investmentShownText)||"Your total includes all distribution costs and VAT. No hidden fees or surprise charges",onSave:_=>c==null?void 0:c("bookingSummary.leafleting.investmentShownText",_),as:"span"})})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-primary font-medium",children:"â¡"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"IMMEDIATE CONFIRMATION:"}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((D=(L=l==null?void 0:l.bookingSummary)==null?void 0:L.leafleting)==null?void 0:D.immediateConfirmationText)||"Receive instant confirmation and campaign details after booking",onSave:_=>c==null?void 0:c("bookingSummary.leafleting.immediateConfirmationText",_),as:"span"})})]})]})]})]})]})})]})]})};var vte="Separator",y3="horizontal",yte=["horizontal","vertical"],PD=u.forwardRef((e,s)=>{const{decorative:r,orientation:n=y3,...a}=e,i=bte(n)?n:y3,l=r?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return t.jsx(ze.div,{"data-orientation":i,...l,...a,ref:s})});PD.displayName=vte;function bte(e){return yte.includes(e)}var AD=PD;const fs=u.forwardRef(({className:e,orientation:s="horizontal",decorative:r=!0,...n},a)=>t.jsx(AD,{ref:a,decorative:r,orientation:s,className:oe("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));fs.displayName=AD.displayName;const jte=({selectedAreas:e,selectedAdSize:s,selectedDuration:r,selectedMonths:n,pricingBreakdown:a,onNext:i,advertisingContent:o,onContentSave:l,discount:c=null,onDiscountChange:d,customerEmail:m})=>
755{var D,_,H,O,U,G,E,z,Z,M,F;const{areas:h,adSizes:f,durations:p}=ji(),{nextStep:x}=Wv(),g=()=>{const ee=f==null?void 0:f.find(se=>se.id===s);return(ee==null?void 0:ee.name)||"Unknown Size"},b=ee=>{const se=h==null?void 0:h.find(le=>le.id===ee);return(se==null?void 0:se.name)||"Unknown Area"},w=ee=>{const se=h==null?void 0:h.find(le=>le.id===ee);return(se==null?void 0:se.area_number)||""},j=ee=>{if(!n||!n[ee])return"";const se=n[ee]||[],le=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],X=["January","February","March","April","May","June","July","August","September","October","November","December"];return se.map(ye=>{if(ye.includes("-")){const[ke,fe]=ye.split("-"),Ee=le[parseInt(fe)-1],K=ke.slice(2);return`${Ee} '${K}`}const Ce=X.findIndex(ke=>ke.toLowerCase()===ye.toLowerCase());return Ce!==-1?X[Ce]:ye}).join(", ")},y=()=>{const ee=f==null?void 0:f.find(se=>se.id===s);return(ee==null?void 0:ee.base_price_per_area)||0},v=()=>{const ee=p==null?void 0:p.find(se=>se.id===r);return(ee==null?void 0:ee.duration_value)||0},N=()=>{const ee=p==null?void 0:p.find(se=>se.id===r);return(ee==null?void 0:ee.name)||"Unknown Duration"},S=y(),k=e.length,$=v(),R=k*$,A=(a==null?void 0:a.baseTotal)||0,T=(a==null?void 0:a.finalTotal)||0,P=Qh({productType:"fixed_term",baseFinalTotal:T,discount:c}),B=P.adjustedFinalTotal,Y=B*1.2;a!=null&&a.finalTotalBeforeDesign;const I=R>0?B/Math.max(1,R):0,C=A-B,L=()=>{x()};return t.jsxs("div",{className:"space-y-8 max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("h2",{className:"text-3xl font-bold",children:"YOUR BASKET"}),t.jsx("p",{className:"text-muted-foreground",children:"Review your Pay As You Go booking details"})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[t.jsxs("div",{className:"space-y-6",children:[t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-xl",children:"Booking Summary"})}),t.jsxs(ge,{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Advert Size"}),t.jsx("p",{className:"font-medium",children:g()})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Duration"}),t.jsx("p",{className:"font-medium",children:N()})]})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Booking Type"}),t.jsx(Be,{value:((_=(D=o==null?void 0:o.bookingSummary)==null?void 0:D.fixed)==null?void 0:_.bookingTypeText)||"Pay As You Go",onSave:ee=>l==null?void 0:l("bookingSummary.fixed.bookingTypeText",ee),as:"p",className:"font-medium"})]}),t.jsx(fs,{}),t.jsxs("div",{children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Rate Card Price Per Insert"}),t.jsx("p",{className:"font-medium",children:Nt(S)})]}),t.jsx(fs,{}),t.jsxs("div",{children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Number of Issues in Each Area"}),t.jsx("p",{className:"font-medium",children:$})]}),t.jsx(fs,{}),t.jsxs("div",{children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Total Number of Insertions in Booking"}),t.jsx("p",{className:"text-xl font-bold text-primary",children:R}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["(",k," areas à ",$," issues)"]})]})]})]}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-lg",children:'Selected "Paid For" Areas'})}),t.jsx(ge,{children:t.jsx("div",{className:"space-y-3",children:e.map(ee=>{const se=w(ee),le=b(ee),X=j(ee);return t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(we,{variant:"default",className:"bg-primary",children:"Paid"}),t.jsxs("span",{className:"text-sm font-medium",children:[se?`${se} - `:"",le]})]}),X&&t.jsxs("div",{className:"text-xs text-muted-foreground ml-16",children:["Selected issues: ",X]})]},ee)})})})]}),t.jsx(xe,{children:t.jsx(ge,{className:"pt-6",children:t.jsxs("div",{className:"text-center",children:[t.jsx(V,{className:"text-sm font-medium text-muted-foreground",children:"Total Number of Homes Reached"}),t.jsxs("p",{className:"text-2xl font-bold text-primary",children:[((H=a==null?void 0:a.totalCirculation)==null?void 0:H.toLocaleStr
755ing())||0," homes"]})]})})})]}),t.jsx("div",{className:"space-y-6",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-xl",children:"Pricing Summary"})}),t.jsxs(ge,{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-3",children:[d&&t.jsx(bN,{productType:"fixed_term",email:m,currentDiscount:c,onApplied:d,onCleared:()=>d(null)}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"Campaign Cost excluding VAT"}),t.jsx("span",{className:"font-medium",children:Nt(T)})]}),C>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"Saving"}),t.jsxs("span",{className:"font-medium text-green-600",children:["-",Nt(C)]})]}),t.jsx(fs,{})]}),c&&P.discountAmount>0&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("span",{className:"text-sm text-green-700",children:["Voucher code applied: ",c.code]}),t.jsxs("span",{className:"font-medium text-green-700",children:["-",Nt(P.discountAmount)]})]}),c&&P.isFreeItem&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("span",{className:"text-sm text-green-700",children:["Free item (",c.code,"): ",P.lineLabel]}),t.jsx("span",{className:"font-medium text-green-700",children:Nt(0)})]}),t.jsxs("div",{className:"flex justify-between items-center text-lg",children:[t.jsx("span",{className:"font-semibold",children:"Total Cost excluding VAT"}),t.jsx("span",{className:"font-bold",children:Nt(B)})]}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"VAT (20%)"}),t.jsx("span",{className:"font-medium",children:Nt(B*.2)})]}),t.jsx(fs,{className:"my-3"}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-xl font-bold",children:"Total (Incl. VAT)"}),t.jsx("span",{className:"text-2xl font-bold text-primary",children:Nt(Y)})]}),(a==null?void 0:a.designFee)&&a.designFee>0&&t.jsxs(t.Fragment,{children:[t.jsx(fs,{className:"my-3"}),t.jsxs("div",{className:"rounded-md border border-dashed border-muted-foreground/30 bg-muted/30 p-3 space-y-1",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm font-medium",children:"Artwork Design Fee"}),t.jsxs("span",{className:"font-medium",children:[Nt(a.designFee)," + VAT"]})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Invoiced separately by our team â not charged via the website."})]})]}),t.jsx(fs,{className:"my-3"}),t.jsx("div",{className:"p-4 bg-muted/50 rounded-lg border",children:t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm font-medium",children:"Cost Per Insert in This Booking"}),t.jsx("span",{className:"text-lg font-bold text-primary",children:Nt(I)})]})})]}),t.jsx("div",{className:"mt-6 p-4 bg-gradient-to-r from-primary/10 to-secondary/10 rounded-lg border",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h4",{className:"font-bold text-lg mb-2",children:"ð¯ Amazing Value!"}),t.jsx("p",{className:"text-xl font-bold text-primary",children:(()=>{if(a!=null&&a.totalCirculation){const ee=B/a.totalCirculation*1e3;return`Only ${Nt(ee)} + VAT per 1,000 homes reached`}return"Calculating..."})()})]})}),t.jsxs("div",{className:"mt-6 space-y-4",children:[t.jsx("h4",{className:"font-semibold text-lg text-center",children:"What to Do Next"}),t.jsx("button",{onClick:()=>{window.open("tel:01234567890","_self")},className:"w-full bg-accent text-accent-foreground hover:bg-accent/80 font-medium py-3 px-6 rounded-md transition-colors",children:"Call Discover Team"}),t.jsx("button",{onClick:L,className:"w-full bg-secondary text-secondary-foreground hover:bg-secondary/80 font-medium py-3 px-6 rounded-md transition-colors",children:"Save Quote"}),t.jsx("button",{onClick:L,className:"w-full bg-primary text-primary-foreground hover:bg-primary/90 font-medium py-3 px-6 rounded-md transition-colors",children:"Book Now"})]}),t.jsxs("div",{className:"mt-6 space-y-4 text-sm",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-primary font-medium",children:"ð¨"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"DESIGN SERVICE:"}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((U=(O=o==null?void 0:o.bookingSummary)==null?void 0:O.fixed)==null?void 0:U.designServiceText)||"By booking online you get discounted advert design. Our professional design team creates response focused ads at very low cost - just provide your content, images, logo and branding kit if you have one.",onSave:ee=>l==null?void 0:l("bookingSummary.fixed.designServiceText",ee),as:"span"})})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-primary font-medium",children:"ð¦"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"WHAT YOU'RE BOOKING:"}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((E=(G=o==null?void 0:o.bookingSummary)==null?void 0:G.fixed)==null?void 0:E.whatYoureBookingText)||"A Pay As You Go advertising package with guaranteed distribution to your selected areas",onSave:ee=>l==null?void 0:l("bookingSummary.fixed.whatYoureBookingText",ee),as:"span"})})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-primary font-medium",children:"ð°"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"INVESTMENT SHOWN:"}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((Z=(z=o==null?void 0:o.bookingSummary)==null?void 0:z.fixed)==null?void 0:Z.investmentShownText)||"Your total includes all costs - ad creation, distribution, and VAT. No hidden fees or surprise charges",onSave:ee=>l==null?void 0:l("bookingSummary.fixed.investmentShownText",ee),as:"span"})})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-primary font-medium",children:"â¡"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"IMMEDIATE CONFIRMATION:"}),t.jsx("p",{className:"text-muted-foreground",children:t.jsx(Be,{value:((F=(M=o==null?void 0:o.bookingSummary)==null?void 0:M.fixed)==null?void 0:F.immediateConfirmationText)||"Receive instant confirmation and campaign details after booking",onSave:ee=>l==null?void 0:l("bookingSummary.fixed.immediateConfirmationText",ee),as:"span"})})]})]})]})]})]})})]})]})};var jN="Switch",[wte,_fe]=hr(jN),[Nte,_te]=wte(jN),TD=u.forwardRef((e,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:i,required:o,disabled:l,value:c="on",onCheckedChange:d,form:m,...h}=e,[f,p]=u.useState(null),x=at(s,y=>p(y)),g=u.useRef(!1),b=f?m||!!f.closest("form"):!0,[w=!1,j]=wr({prop:a,defaultProp:i,onChange:d});return t.jsxs(Nte,{scope:r,checked:w,disabled:l,children:[t.jsx(ze.button,{type:"button",role:"switch","aria-checked":w,"aria-required":o,"data-state":MD(w),"data-disabled":l?"":void 0,disabled:l,value:c,...h,ref:x,onClick:Se(e.onClick,y=>{j(v=>!v),b&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})}),b&&t.jsx(Ste,{control:f,bubbles:!g.current,name:n,value:c,checked:w,required:o,disabled:l,form:m,style:{transform:"translateX(-100%)"}})]})});TD.displayName=jN;var DD="SwitchThumb",RD=u.forwardRef((e,s)=>{const{__scopeSwitch:r,...n}=e,a=_te(DD,r);return t.jsx(ze.span,{"data-state":MD(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});RD.displayName=DD;var Ste=e=>{const{control:s,checked:r,bubbles:n=!0,...a}=e,i=u.useRef(null),o=Mu(r),l=kf(s);return u.useEffect(()=>{const c=i.current,d=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(d,"checked").set;if(o!==r&&h){const f=new Event("click",{bubbles:n});h.call(c,r),c.dispatchEvent(f)}},[o,r,n]),t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function MD(e){return e?"checked":"unchecked"}var OD=TD,Cte=RD;const kt=u.forwardRef(({className:e,...s},r)=>t.jsx(OD,{className:oe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...s,ref:r,children:t.jsx(Cte,{className:oe("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")})}
755));kt.displayName=OD.displayName;const Fp=({icon:e,text:s})=>t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-white/80 backdrop-blur-sm rounded-lg border border-slate-200/60 shadow-sm",children:[t.jsx("div",{className:"text-community-green",children:e}),t.jsx("span",{className:"text-sm text-slate-600 font-medium",children:s})]}),fm=({icon:e,title:s,children:r,className:n=""})=>t.jsxs("div",{className:`space-y-4 p-5 bg-slate-50/50 rounded-xl border border-slate-100 ${n}`,children:[t.jsxs("div",{className:"flex items-center gap-2 pb-2 border-b border-slate-100",children:[t.jsx("div",{className:"text-community-navy",children:e}),t.jsx("h4",{className:"font-semibold text-community-navy",children:s})]}),r]}),b3=({pricingModel:e,selectedAreas:s,bogofPaidAreas:r,bogofFreeAreas:n,selectedAdSize:a,selectedDuration:i,pricingBreakdown:o,campaignData:l,onSaveQuote:c,onBookNow:d,currentStep:m=4})=>{var U;const{toast:h}=rt();ds();const{isAdmin:f}=Ar(),[p,x]=u.useState(!1),[g,b]=u.useState(!1),[w,j]=u.useState({businessType:"limited_company",firstName:"",lastName:"",jobTitle:"",companyName:"",companySector:"",charityNumber:"",email:"",phone:"",postcode:"",addressLine1:"",addressLine2:"",city:"",password:"",voucherCode:""});u.useState([]);const[y,v]=u.useState(!1),[N,S]=u.useState(null),[k,$]=u.useState(!1);u.useState(!1);const[R,A]=u.useState(),[T,P]=u.useState(),{data:B,isLoading:Y}=pN(R,T);u.useEffect(()=>{(async()=>{const{data:{user:E}}=await W.auth.getUser();if(E){A(E.email);const{data:z}=await W.from("profiles").select("phone").eq("user_id",E.id).maybeSingle();z!=null&&z.phone&&P(z.phone)}})()},[]);const I=async()=>{var G;if(!((G=w.voucherCode)!=null&&G.trim())){h({title:"Invalid Voucher",description:"Please enter a voucher code.",variant:"destructive"});return}$(!0);try{const{data:E,error:z}=await W.from("vouchers").select("*").eq("voucher_code",w.voucherCode.toUpperCase()).eq("service_type","leafleting").eq("is_active",!0).eq("is_used",!1).single();if(z||!E){h({title:"Invalid Voucher",description:"Voucher code not found or expired.",variant:"destructive"});return}if(E.expires_at&&new Date(E.expires_at)<new Date){h({title:"Expired Voucher",description:"This voucher code has expired.",variant:"destructive"});return}S(E),h({title:"Voucher Applied!",description:`${E.voucher_type==="percentage"?E.discount_value+"% off":"£"+E.discount_value+" off"} applied to your order.`})}catch(E){console.error("Error applying voucher:",E),h({title:"Error",description:"Failed to apply voucher. Please try again.",variant:"destructive"})}finally{$(!1)}},C=()=>{S(null),j(G=>({...G,voucherCode:""})),h({title:"Voucher Removed",description:"Voucher discount has been removed."})},L=async()=>{if(!w.postcode){h({title:"No Postcode Entered",description:"Please enter a postcode to lookup addresses.",variant:"destructive"});return}v(!0);try{const G=await fetch(`https://api.postcodes.io/postcodes/${w.postcode}`);if(G.ok){const E=await G.json();if(E.result){const z=E.result.admin_district||"",Z=E.result.admin_ward||"";let M="";Z&&Z!==z&&(M=Z),j(F=>({...F,addressLine2:M,city:z||E.result.parish||""})),h({title:"Postcode Found",description:`Found: ${z}${Z&&Z!==z?`, ${Z}`:""}. Please enter your house number and street name in Address Line 1.`})}}else{const E=w.postcode.replace(/\s/g,""),z=await fetch(`https://api.postcodes.io/postcodes/${E}`);if(z.ok){const Z=await z.json();if(Z.result){const M=Z.result.admin_district||"",F=Z.result.admin_ward||"";let ee="";F&&F!==M&&(ee=F),j(se=>({...se,addressLine2:ee,city:M||Z.result.parish||""})),h({title:"Postcode Found",description:`Found: ${M}${F&&F!==M?`, ${F}`:""}. Please enter your house number and street name in Address Line 1.`})}}
755else h({title:"Invalid Postcode",description:"Please check your postcode format (e.g. SW1A 1AA) and try again.",variant:"destructive"})}}catch(G){console.error("Postcode lookup error:",G),h({title:"Lookup Failed",description:"Unable to lookup postcode. Please enter your address manually.",variant:"destructive"})}finally{v(!1)}},D=u.useCallback(async()=>{if(!w.firstName||!w.lastName||!w.email||!w.postcode||!w.addressLine1){h({title:"Missing Information",description:"Please fill in all required fields.",variant:"destructive"});return}if(!g&&!w.password){h({title:"Missing Information",description:"Please enter a password to create your account.",variant:"destructive"});return}if(w.businessType!=="sole_trader"&&!w.companyName){h({title:"Missing Information",description:"Company/Organisation name is required.",variant:"destructive"});return}if(!g&&w.password.length<6){h({title:"Password Too Short",description:"Password must be at least 6 characters long.",variant:"destructive"});return}x(!0);try{const G={...w};if(g){const E=crypto.randomUUID().slice(0,12);G.isAdminCreating=!0,G.generatedPassword=E,G.password=E}await c(G)}catch(G){console.error("Error saving quote:",G)}finally{x(!1)}},[w,g,c,h]),_=u.useCallback(async()=>{if(!w.firstName||!w.lastName||!w.email||!w.postcode||!w.addressLine1){h({title:"Missing Information",description:"Please fill in all required fields.",variant:"destructive"});return}if(!g&&!w.password){h({title:"Missing Information",description:"Please enter a password to create your account.",variant:"destructive"});return}if(w.businessType!=="sole_trader"&&!w.companyName){h({title:"Missing Information",description:"Company/Organisation name is required.",variant:"destructive"});return}if(!g&&w.password.length<6){h({title:"Password Too Short",description:"Password must be at least 6 characters long.",variant:"destructive"});return}x(!0);try{const G={...w};if(g){const E=crypto.randomUUID().slice(0,12);G.isAdminCreating=!0,G.generatedPassword=E,G.password=E}d?await d(G):await c(G)}catch(G){console.error("Error booking:",G)}finally{x(!1)}},[w,g,d,c,h]);ve.useEffect(()=>(window.handleContactFormSave=D,window.handleContactFormBook=_,()=>{delete window.handleContactFormSave,delete window.handleContactFormBook}),[D,_]);const O=e==="bogof"&&B&&!B.isEligible;return t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{className:"relative bg-gradient-to-b from-amber-50/60 via-slate-50/40 to-white rounded-2xl p-8 lg:p-10 border border-amber-100/50",children:[t.jsx("div",{className:"absolute top-4 right-4 text-amber-400/60",children:t.jsx(ui,{className:"h-6 w-6"})}),t.jsxs("div",{className:"text-center space-y-4 max-w-2xl mx-auto",children:[t.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-1.5 bg-community-green/10 rounded-full",children:[t.jsx(As,{className:"h-4 w-4 text-community-green"}),t.jsx("span",{className:"text-sm font-medium text-community-green",children:"Final Step"})]}),t.jsx("h2",{className:"text-2xl lg:text-3xl font-bold text-community-navy",children:"You're Almost There!"}),t.jsx("p",{className:"text-slate-600 text-lg",children:"Just a few details to secure your campaign. We'll take care of everything from here."})]}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-3 mt-8",children:[t.jsx(Fp,{icon:t.jsx(zr,{className:"h-4 w-4"}),text:"023 8026 6388"}),t.jsx(Fp,{icon:t.jsx(It,{className:"h-4 w-4"}),text:"Since 2005"}),t.jsx(Fp,{icon:t.jsx(Oa,{className:"h-4 w-4"}),text:"No Hidden Fees"}),t.jsx(Fp,{icon:t.jsx(ws,{className:"h-4 w-4"}),text:"Quick Setup"})]})]}),O&&t.jsxs(ss,{className:"bg-pink-50 border-pink-200 dark:bg-pink-950/20 dark:border-pink-800",children:[t.jsx(Hs,{className:"h-4 w-4 text-pink-600 dark:text-pink-400"}),t.jsxs(rs,{className:"text-pink-800 dark:text-pink-300",children:[t.jsx("strong",{children:"Returning Customer"})," â You've previously used this offer. Complete your booking and our team will c
755ontact you with exclusive returning customer rates!"]})]}),t.jsx(xe,{className:"border-slate-200/80 shadow-lg",children:t.jsx(ge,{className:"p-6 lg:p-8",children:t.jsxs("form",{className:"space-y-6",children:[f&&t.jsxs("div",{className:"p-4 bg-amber-50 border-2 border-amber-300 rounded-xl",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-9 h-9 rounded-full bg-amber-100 flex items-center justify-center",children:t.jsx(Aw,{className:"h-5 w-5 text-amber-700"})}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"admin-on-behalf",className:"text-amber-900 font-semibold text-base cursor-pointer",children:"Create on behalf of a customer"}),t.jsx("p",{className:"text-xs text-amber-700 mt-0.5",children:"Admin mode â account & credentials created automatically"})]})]}),t.jsx(kt,{id:"admin-on-behalf",checked:g,onCheckedChange:b})]}),g&&t.jsxs(ss,{className:"mt-3 bg-amber-100/50 border-amber-200",children:[t.jsx(hc,{className:"h-4 w-4 text-amber-700"}),t.jsx(rs,{className:"text-amber-800 text-sm",children:"A login will be created automatically and credentials emailed to the customer with their quote."})]})]}),t.jsx(fm,{icon:t.jsx(Xr,{className:"h-5 w-5"}),title:"Business Type",children:t.jsx(Da,{value:w.businessType,onValueChange:G=>j(E=>({...E,businessType:G})),className:"grid grid-cols-2 lg:grid-cols-4 gap-3",disabled:p,children:[{value:"limited_company",label:"Limited Company"},{value:"sole_trader",label:"Sole Trader"},{value:"non_profit",label:"Non Profit"},{value:"partnership",label:"Partnership"}].map(G=>t.jsxs("div",{className:"relative",children:[t.jsx(Ir,{value:G.value,id:G.value,className:"peer sr-only"}),t.jsx(V,{htmlFor:G.value,className:"flex items-center justify-center p-3 bg-white border-2 border-slate-200 rounded-lg cursor-pointer transition-all hover:border-community-green/50 peer-data-[state=checked]:border-community-green peer-data-[state=checked]:bg-community-green/5 text-sm font-medium text-center",children:G.label})]},G.value))})}),t.jsx(fm,{icon:t.jsx(bn,{className:"h-5 w-5"}),title:w.businessType==="sole_trader"?"Your Details":"Organisation Details",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"firstName",children:"First Name *"}),t.jsx(re,{id:"firstName",name:"firstName",value:w.firstName,onChange:G=>j(E=>({...E,firstName:G.target.value})),placeholder:"Enter your first name",disabled:p,className:"mt-1.5"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"lastName",children:"Last Name *"}),t.jsx(re,{id:"lastName",name:"lastName",value:w.lastName,onChange:G=>j(E=>({...E,lastName:G.target.value})),placeholder:"Enter your last name",disabled:p,className:"mt-1.5"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"jobTitle",children:"Job Title/Position"}),t.jsx(re,{id:"jobTitle",name:"jobTitle",value:w.jobTitle,onChange:G=>j(E=>({...E,jobTitle:G.target.value})),placeholder:"Enter your job title",disabled:p,className:"mt-1.5"})]}),w.businessType!=="sole_trader"?t.jsxs("div",{children:[t.jsx(V,{htmlFor:"companyName",children:w.businessType==="limited_company"?"Company Name (as per Companies House) *":"Organisation Name *"}),t.jsx(re,{id:"companyName",name:"companyName",value:w.companyName,onChange:G=>j(E=>({...E,companyName:G.target.value})),placeholder:"Enter your company/organisation name",disabled:p,className:"mt-1.5"})]}):t.jsxs("div",{children:[t.jsx(V,{htmlFor:"companyName",children:"Business/Trading Name"}),t.jsx(re,{id:"companyName",name:"companyName",value:w.companyName,onChange:G=>j(E=>({...E,companyName:G.target.value})),placeholder:"Enter your business name (optional)",disabled:p,className:"mt-1.5"})]}),w.businessType==="non_profit"&&t.jsxs("div",{children:[t.jsx(V,{htmlFor:"charityNumber",children:"Charity Registration Number"}),t.jsx(re,{id:"charityNumber",name:"charityNumber",value:w.charityNumber,onChange:G=>j(E=>({...E,charityNumber:G.target.value})),placeholder:"Enter your charity registration number",disabled:p,className:"mt-1.5"})]})]})}),t.jsx(fm,{icon:t.jsx(ar,{className:"h-5 w-5"}),title:"Contact Details",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"email",children:"Email Address *"}),t.jsx(re,{id:"email",name:"email",type:"email",value:w.email,onChange:G=>j(E=>({...E,email:G.target.value})),placeholder:"Enter your email",disabled:p,className:"mt-1.5"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"phone",children:"Phone Number *"}),t.jsx(re,{id:"phone",name:"phone",value:w.phone,onChange:G=>j(E=>({...E,phone:G.target.value})),placeholder:"Enter your phone number",disabled:p,className:"mt-1.5"})]})]})}),e==="leafleting"&&t.jsxs("div",{className:"p-5 bg-green-50/80 border border-green-200 rounded-xl",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-green-100 flex items-center justify-center",children:t.jsx("span",{className:"text-green-600 text-lg",children:"ðï¸"})}),t.jsx(V,{className:"text-green-800 font-semibold",children:"Have a Voucher Code?"})]}),t.jsx("p",{className:"text-sm text-green-600 mb-4",children:"Enter your voucher co
755de below to save on your leafleting campaign."}),N?t.jsxs("div",{className:"flex items-center justify-between p-3 bg-green-100 border border-green-300 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(we,{variant:"secondary",className:"bg-green-200 text-green-800",children:N.voucher_code}),t.jsx("span",{className:"text-sm text-green-800 font-medium",children:N.voucher_type==="percentage"?`${N.discount_value}% off`:`£${N.discount_value} off`})]}),t.jsx(q,{variant:"ghost",size:"sm",onClick:C,className:"text-green-700 hover:text-green-900 hover:bg-green-200",disabled:p,children:"Remove"})]}):t.jsxs("div",{className:"flex gap-2",children:[t.jsx(re,{id:"voucher",placeholder:"Enter voucher code",value:w.voucherCode||"",onChange:G=>j(E=>({...E,voucherCode:G.target.value.toUpperCase()})),onKeyPress:G=>G.key==="Enter"&&I(),disabled:p,className:"border-green-300 focus:border-green-500 focus:ring-green-200"}),t.jsx(q,{variant:"default",onClick:I,disabled:k||!((U=w.voucherCode)!=null&&U.trim())||p,className:"whitespace-nowrap bg-green-600 hover:bg-green-700 text-white",children:k?t.jsx(it,{className:"h-4 w-4 animate-spin"}):"Apply"})]})]}),t.jsx(fm,{icon:t.jsx(_t,{className:"h-5 w-5"}),title:"Invoice Address",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"postcode",children:"Postcode *"}),t.jsxs("div",{className:"flex gap-2 mt-1.5",children:[t.jsx(re,{id:"postcode",name:"postcode",value:w.postcode,onChange:G=>j(E=>({...E,postcode:G.target.value.toUpperCase()})),placeholder:"e.g. SW1A 1AA",disabled:p,className:"flex-1"}),t.jsx(q,{type:"button",variant:"outline",onClick:L,disabled:y||p,size:"sm",className:"shrink-0",children:y?t.jsx(it,{className:"h-4 w-4 animate-spin"}):t.jsx(Ur,{className:"h-4 w-4"})})]})]}),t.jsxs("div",{className:"md:col-span-2",children:[t.jsx(V,{htmlFor:"addressLine1",children:"Address Line 1 *"}),t.jsx(re,{id:"addressLine1",name:"addressLine1",value:w.addressLine1,onChange:G=>j(E=>({...E,addressLine1:G.target.value})),placeholder:"House number and street name",disabled:p,className:"mt-1.5"})]}),t.jsxs("div",{className:"md:col-span-2",children:[t.jsx(V,{htmlFor:"addressLine2",children:"Address Line 2"}),t.jsx(re,{id:"addressLine2",name:"addressLine2",value:w.addressLine2,onChange:G=>j(E=>({...E,addressLine2:G.target.value})),placeholder:"Area, district (optional)",disabled:p,className:"mt-1.5"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"city",children:"Town/City *"}),t.jsx(re,{id:"city",name:"city",value:w.city,onChange:G=>j(E=>({...E,city:G.target.value})),placeholder:"Town or city",disabled:p,className:"mt-1.5"})]})]})}),!g&&t.jsx(fm,{icon:t.jsx(Cu,{className:"h-5 w-5"}),title:"Create Your Dashboard",children:t.jsxs("div",{children:[t.jsx(V,{htmlFor:"password",children:"Password *"}),t.jsx(re,{id:"password",name:"password",type:"password",value:w.password,onChange:G=>j(E=>({...E,password:G.target.value})),placeholder:"At least 6 characters",disabled:p,className:"mt-1.5"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"We'll create your account automatically and sign you in. Access your saved quotes anytime."})]})})]})})}),p&&t.jsx("div",{className:"text-center py-4",children:t.jsxs("div",{className:"inline-flex items-center gap-3 px-6 py-3 bg-community-green/10 rounded-full",children:[t.jsx(it,{className:"h-5 w-5 animate-spin text-community-green"}),t.jsx("p",{className:"text-community-navy font-medium",children:"Creating your account and saving your quote..."})]})}),l&&t.jsx(xN,{campaignData:{selectedModel:e,selectedAreas:s,bogofPaidAreas:r,bogofFreeAreas:n,selectedSize:a,selectedDuration:i,totalCost:o==null?void 0:o.finalTotal,pricingBreakdown:o},currentStep:m})]})};class ID extends u.Component{constructor(){super(...arguments);Ze(this,"state",{hasError:!1})}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,n){console.error("Error caught by boundary:",r,n)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:t.jsxs(xe,{className:"w-full max-w-md mx-auto mt-8",children:[t.jsxs(Me,{children:[t.jsx(Oe,{className:"text-destructive",children:"Something went wrong"}),t.jsx(Er,{children:"An error occurred while loading this component"})]}),t.jsxs(ge,{className:"space-y-4",children:[this.state.error&&t.jsx("div",{className:"text-sm text-muted-foreground font-mono bg-muted p-2 rounded",children:this.state.error.message}),t.jsx(q,{onClick:()=>this.setState({hasError:!1,error:void 0}),variant:"outline",children:"Try Again"})]})]}):this.props.children}}const j3=({selectedLeafletSize:e,onLeafletSizeChange:s,onNext:r})=>{const{leafletSizes:n,isLoading:a}=Hu();return a?t.jsx("div",{className:"min-h-[400px] flex items-center justify-center",children:t.jsx("div",{className:"text-muted-foreground",children:"Loading leaflet sizes..."})}):t.jsx(ID,{children:t.jsx("div",{className:"space-y-6",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(ir,{className:"h-5 w-5"}),"Leaflet Size & Specification"]})}),t.jsxs(ge,{children:[t.jsx("p",{className:"text-muted-foreground mb-6",children:"Select the size and format for your leaflet distribution."}),n&&n.length>0?t.jsx(Da,{value:e,onValueChange:s,className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:n.map(i=>t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(Ir,{value:i.id,id:`leaflet-size-${i.id}`}),t.jsxs(V,{htmlFor:`leaflet-size-${i.id}`,className:"flex-1 cursor-pointer p-4 border rounded-lg hover:bg-muted/50 transition-colors",children:[t.jsx("div",{className:"font-medium",children:i.label}),i.description&&t.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:i.description})]})]},i.id))}):t.jsxs("div",{className:"text-center p-8 text-muted-foreground",children:[t.jsx(ir,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),t.jsx("p",{children:"No leaflet sizes available"}),t.jsx("p",{className:"text-sm",children:"Please contact support to set up leaflet size options."})]})]})]})})})};function Yj(e,s){var r,n,a,i;return((n=(r=s.areas)==null?void 0:r.find(o=>o.id===e))==null?void 0:n.name)??((i=(a=s.leafletAreas)==null?void 0:a.find(o=>o.id===e))==null?void 0:i.name)??e}function kte(e,s){var r,n,a,i;if(e)return((n=(r=s.adSizes)==null?void 0:r.find(o=>o.id===e))==null?void 0:n.name)??((i=(a=s.leafletSizes)==null?void 0:a.find(o=>o.id===e))==null?void 0:i.label)??e}function $te(e,s){var r,n,a,i,o,l;if(e)return((n=(r=s.durations)==null?void 0:r.find(c=>c.id===e))==null?void 0:n.name)??((i=(a=s.subscriptionDurations)==null?void 0:a.find(c=>c.id===e))==null?void 0:i.name)??((l=(o=s.leafletDurations)==null?void 0:o.find(c=>c.id===e))==null?void 0:l.name)??e}function Ete(e,s){var r,n;if(e)return((n=(r=s.paymentOptions)==null?void 0:r.find(a=>a.id===e))==null?void 0:n.display_name)??e}function Pte(e){switch(e){case"fixed":return"Pay As You Go";
755case"bogof":return"3+ Subscription Package";case"leafleting":return"Leafleting Service";default:return"General Inquiry"}}function w3(e){if(!e)return"";try{return Dt(new Date(e),"dd MMM yyyy")}catch{return e}}function Ate(e,s){if(!e)return"";const r=e.match(/^(\d{4})-(\d{2})$/);if(r)try{return Dt(new Date(Number(r[1]),Number(r[2])-1,1),"MMMM yyyy")}catch{return e}return s?`${e} ${s}`:e}function Tte(e,s,r){return!(e!=null&&e.areaBreakdown)||!Array.isArray(e.areaBreakdown)?[]:e.areaBreakdown.map(n=>{var o,l,c;const a=((o=n.area)==null?void 0:o.name)??(n.areaId?Yj(n.areaId,r):void 0)??n.area_name??"Unknown Area",i=((l=n.area)==null?void 0:l.circulation)??((c=n.area)==null?void 0:c.bimonthly_circulation)??n.circulation??0;return{name:a,ad_size:s??n.ad_size??void 0,base_price:n.basePrice??n.base_price??n.multipliedPrice??0,circulation:i}})}function Dte(e,s){var r;if(!(e!=null&&e.areaBreakdown)||!Array.isArray(e.areaBreakdown))return[];for(const n of e.areaBreakdown){const a=((r=n.area)==null?void 0:r.schedule)||n.schedule;if(a&&typeof a=="object"){const i=Array.isArray(a)?a:Object.values(a);if(i.length>0)return i.filter(o=>o&&typeof o=="object").map(o=>({month:Ate(o.month,o.year)||o.label||"",copy_deadline:w3(o.copyDeadline),delivery_date:w3(o.deliveryDate)}))}}return[]}function Rte(e,s){var b,w,j,y,v,N,S,k,$,R,A,T,P,B;const r=(e.contact_name||"").trim().split(/\s+/),n=r[0]||"",a=r.slice(1).join(" ")||"",i=e.ad_size||kte(((b=e.selections)==null?void 0:b.selectedAdSize)||((w=e.selections)==null?void 0:w.adSize),s),o=e.duration||$te(((j=e.selections)==null?void 0:j.selectedDuration)||((y=e.selections)==null?void 0:y.duration),s),l=Tte(e.pricing_breakdown,i,s),c=Dte(e.pricing_breakdown),d=Ete(((v=e.selections)==null?void 0:v.payment_option_id)||((N=e.selections)==null?void 0:N.selectedPaymentOption),s),m={record_type:e.record_type,journey_tag:Pte(e.pricing_model),email:e.email,first_name:n,last_name:a,phone:e.phone||"",company:e.company||"",title:e.title||"",status:e.status||"draft",pricing_model:e.pricing_model,ad_size:i,duration:o,subtotal:Number(e.subtotal)||0,final_total:Number(e.final_total)||0,monthly_price:Number(e.monthly_price)||0,total_circulation:Number(e.total_circulation)||0,areas:l,schedule:c,discounts:{agency_discount_percent:Number(e.agency_discount_percent||((S=e.pricing_breakdown)==null?void 0:S.agencyDiscountPercent))||0,volume_discount_percent:Number(e.volume_discount_percent||((k=e.pricing_breakdown)==null?void 0:k.volumeDiscountPercent))||0,duration_discount_percent:Number(e.duration_discount_percent||(($=e.pricing_breakdown)==null?void 0:$.durationDiscountPercent))||0},source:"advertising_calculator",submitted_at:new Date().toISOString()};if(d&&(m.payment_option=d),e.pricing_model==="bogof"){const Y=(e.bogof_paid_areas||[]).map(C=>Yj(C,s)),I=(e.bogof_free_areas||[]).map(C=>Yj(C,s));Y.length>0&&(m.bogof_paid_areas=Y),I.length>0&&(m.bogof_free_areas=I)}e.record_type==="quote"&&(m.pipeline_tag="saved_quote"),(R=e.pricing_breakdown)!=null&&R.designFee&&(m.design_fee=e.pricing_breakdown.designFee);const h=e.selections||{},f=((A=e.invoice_address)==null?void 0:A.postcode)??h.postcode??"",p=((T=e.invoice_address)==null?void 0:T.address_line_1)??h.addressLine1??h.address??"",x=((P=e.invoice_address)==null?void 0:P.address_line_2)??h.addressLine2??"",g=((B=e.invoice_address)==null?void 0:B.city)??h.city??"";return m.invoice_postcode=f,m.invoice_address_line_1=p,m.invoice_address_line_2=x,m.invoice_city=g,m.invoice_address=[p,x,g,f].filter(Y=>Y&&String(Y).trim().length>0).join(", "),m}function px(e,s){return Rte(e,s)}const wN={hero:{trustBadge:"South Hampshire's Leading Local Magazine Publisher",headline:"Reach 142,000 Affluent Homes",subheadline:"Generate brand awareness, create leads, and boost website traffic with South Hampshire's most trusted local magazine network.",videoUrl:"https://qajegkbvbpekdggtrupv.supabase.co/storage/v1/object/public/websitevideo/New%20Hero%20Video.mp4"},stats:[{number:"142k",label:"Bi-monthly Circulation"},{number:"14",label:"Local Editions"},{number:"72%",label:"Repeat Rate"},{number:"1,000s",label:"Customers since 2005"},{number:"580k",label:"Leaflets/Year"}],loveSection:{heading:"Love Your Business...",subheading:"Invest in Local Advertising to Grow, Expand & Thrive",paragraph1:"Discover Magazine is the region's most established and widespread portfolio of local publications available to businesses to generate brand awareness, create leads and boost website traffic from affluent homeowners in South Hampshire.",paragraph2:"We started publishing in 2005, and have since grown to become a trusted advertising partner for hun
755dreds of local businesses. Our magazines reach 142,000 homes across 14 editions, covering Winchester, Southampton, Eastleigh, Fareham, and the New Forest.",quote:"We've perfected the formula for connecting local businesses with local customers."},mediaPack:{heading:"Our Media Pack",description:"Browse our complete media pack to learn about advertising opportunities",embedUrl:"https://indd.adobe.com/embed/0cffeb07-c98f-42bf-9c6b-7661f5c82240?startpage=1&allowFullscreen=false"},editionsMap:{heading:"Interactive Distribution & Circulation Maps",description:"Click on a numbered button or area name to view detailed distribution information",embedUrl:"https://indd.adobe.com/embed/3a8ebb1d-2f10-4a2a-b847-dd653c134e5a?startpage=1&allowFullscreen=false"},calculatorSection:{badge:"Ready to Get Started?",heading:"Get Your Instant Quote & Booking",subheading:"Start by selecting your preferred advertising package",tagline:"Join hundreds of local businesses who've grown with Discover Magazine"},enquirySection:{phone:"023 8064 5852",description:"Our sales team are ready to chat about your advertising goals and find the perfect solution for your business."},roiSection:{mainHeading:"The all important question:",subHeading1:"How Much Does it Cost to Advert
755ise?",subHeading2:"And What Could your Return (ROI) be?",description:"It's difficult to project as there are so many factors that affect ROI. The better these factors are handled the better the end result. The % scales are industry standard. Nothing is guaranteed but we hope this shows we are invested in value for money and results."},productSection:{title:"The Product",subtitle:"What makes a magazine effective",features:[{title:"Circulation",description:"How many copies are printedâthe more printed, the more potential readers and customers"},{title:"Distribution Method",description:"Targeted letterbox delivery vs untargeted pick-up (prone to waste)"},{title:"Audience Targeting",description:"Who is the magazine aimed at? Where exactly is it delivered?"},{title:"Delivery Reliability",description:"Is delivery tracked? Is it reliable?"},{title:"Editorial Balance",description:"Good ratio of editorial to adverts = engaged readers"},{title:"Editorial Quality",description:"Varied, interesting, local, and topical content"}]},advertiserSection:{title:"The Advertiser",subtitle:"What you bring to the table",features:[{title:"Right Ad Size",description:"Is the advert the right size for your type of business?"},{title:"Design Quality",description:"Is the advert selling or just telling? Professional design matters"},{title:"Response Management",description:"Unanswered calls going to voicemail is not well-managed response"},{title:"Measuring Correctly",description:"Are you measuring response or only the result?"}],footerText:"Remember: Advertising generates response, you create the result"},bogofPromo:{badge:"New Advertisers Only",headline:"SEEING DOUBLE",offerDescription:"For Every Area Booked We Give You One Area FREE for 6 months",packageHeading:"3+ Subscription Package for New Advertisers",benefits:["Minimum commitment is 3 consecutive issues = 6 months advertising","Great opportunity to test and trial areas","Mix the advert sizes, advert designs to experiment","Paid on monthly payment plan","After six months: continue, change areas/size, or cancel"],footerTagline:"Double Your Reach. Double Your Impact."},pricingOptions:{pageHeading:"Choose Your Advertising Package",pageDescription:"Select the package that best fits your business needs. Each option is designed for different advertising goals and budgets."},areaSelection:{bogofHeading:"Select Areas for 3+ Subscription Package",bogofAlertTitle:"3+ Subscription Package:",bogofAlertDescription:'For every "paid for" area, choose a "free for 3 issues" area. Select your paid areas first, then choose your free areas.',pageHeading:"Select Areas & Publication Schedule",pageDescription:"Choose your areas and set up your campaign timeline",paidAreasHeading:"Paid Areas",paidAreasDescription:"These are the areas you will pay for throughout your campaign. Maximum 7 areas",freeAreasHeading:"FREE Bonus Areas",freeAreasBadge:"6 Months Free",freeAreasDescription:"Select additional areas to receive for FREE for 6 months.",freeAreasUnlockText:"Select at least one paid area to unlock your free bonus areas."},bookingSummary:{bogof:{bookingTypeText:"3+ Subscription Package for New Advertisers including Buy One Area Get One Area Free",minimumDurationText:"3 issues per area = 6 months",designServiceText:"By booking online you get discounted advert design. Our professional design team creates response focused ads at very low cost - just provide your content, images, logo and branding kit if you have one.",whatYoureBookingText:"A complete advertising package including professional ad design, guaranteed distribution to your selected areas, and placement in our trusted local publication",investmentShownText:"Your total includes all costs - ad creation, distribution, and VAT. No hidden fees or surprise charges",immediateConfirmationText:"Book now for instant campaign confirmation and priority page position or call us for help and advice.",guaranteedReachText:"Your ad will reach every household in your selected areas during the scheduled distribution period, on time, every time."},fixed:{bookingTypeText:"Pay As You Go",designServiceText:"By booking online you get discounted advert design. Our professional design team creates response focused ads at very low cost - just provide your content, images, logo and branding kit if you have one.",whatYoureBookingText:"A Pay As You Go advertising package with guaranteed distribution to your selected areas",investmentShownText:"Your total includes all costs - ad creation, distribution, and VAT. No hidden fees or surprise charges",immediateConfirmationText:"Receive instant confirmation and campaign details after booking"},leafleting:{bookingTypeText:"Leaflet Distribution Campaign",whatYoureBookingText:"Professional leaflet distribution service to your selected areas with guaranteed delivery to homes",investmentShownText:"Your total includes all distribution costs and VAT. No hidden fees or surprise charges",immediateConfirmationText:"Receive instant confirmation and campaign details after booking"}},designFee:{pageHeading:"Artwork Design Service",pageDescription:"Do you need help designing your advertisement?",alertText:"Professional artwork is essential for effective advertising. Our design team can create eye-catching materials that drive results.",cardTitle:"Artwork Design Fee",cardDescription:"Select whether you need our professional design services",yesLabel:"Yes, please contact me to start the design process",yesDescription:"Our professional design team will work with you to create compelling artwork that captures attention and drives customer engagement.",bullet1:"Professional design consultation",bullet2:"Unlimited revisions until you're satisfied",bullet3:"Print-ready artwork delivered",noLabel:"No, finished artwork will be supplied",noDescription:"You'll provide your own print-ready artwork that meets our specifications. No design fee will be added to your booking.",noNote:"Artwork must be supplied in high-resolution print-ready format (PDF, AI, or EPS)",footerNote:"The design fee covers the creation of your artwork. If you choose to supply your own artwork, please ensure it meets our technical specifications."}},Kj=(e,s)=>{if(!s)return e;const r={...e};for(const n of Object.keys(s))typeof e[n]=="object"&&e[n]!==null&&!Array.isArray(e[n])&&typeof s[n]=="object"&&s[n]!==null&&!Array.isArray(s[n])?r[n]=Kj(e[n],s[n]):s[n]!==void 0&&(r[n]=s[n]);return r},NN=()=>{const e=Xs(),{data:s,isLoading:r,error:n}=Lt({queryKey:["advertising-content"],queryFn:async()=>{const{data:m,error:h}=await W.from("content_blocks").select("*").eq("position","advertising").eq("is_active",!0).maybeSingle();if(h)throw console.error("Error fetching advertising content:",h),h;return m},staleTime:1e3*60*5}
755),a=Kj(wN,(s==null?void 0:s.content)||{}),i=os({mutationFn:async m=>{const h=Kj(a,m);if(s!=null&&s.id){const{error:f}=await W.from("content_blocks").update({content:h,updated_at:new Date().toISOString()}).eq("id",s.id);if(f)throw f}else{const{error:f}=await W.from("content_blocks").insert({name:"advertising_page",block_type:"page_content",position:"advertising",content:h,is_active:!0});if(f)throw f}return h},onSuccess:()=>{e.invalidateQueries({queryKey:["advertising-content"]}),Ks({title:"Content saved",description:"Your changes have been saved successfully."})},onError:m=>{console.error("Error saving content:",m),Ks({title:"Error saving content",description:"Failed to save your changes. Please try again.",variant:"destructive"})}});return{content:a,isLoading:r,error:n,updateField:(m,h)=>{const f=m.split("."),p={};let x=p;for(let g=0;g<f.length-1;g++)x[f[g]]={},x=x[f[g]];x[f[f.length-1]]=h,i.mutate(p)},updateStat:(m,h,f)=>{const p=[...a.stats];p[m]={...p[m],[h]:f},i.mutate({stats:p})},updateFeature:(m,h,f,p)=>{const x=[...a[m].features];x[h]={...x[h],[f]:p},i.mutate({[m]:{...a[m],features:x}})},updateBogofBenefit:(m,h)=>{const f=[...a.bogofPromo.benefits];f[m]=h,i.mutate({bogofPromo:{...a.bogofPromo,benefits:f}})},isSaving:i.isPending}},f0=(e,s,r,n)=>{if(!e||e<=0)return 0;const a=n==null?void 0:n.find(o=>o.option_type==="monthly"),i=(a==null?void 0:a.minimum_payments)||6;return s==="bogof"?e/2/i:e/(r||1)},Mte=({children:e,asDialog:s=!1})=>{var H,O,U,G;const{toast:r}=rt(),n=ds(),a=Xs(),{durations:i,subscriptionDurations:o,areas:l,adSizes:c,volumeDiscounts:d}=ji(),{data:m}=Hf(),{leafletAreas:h,leafletSizes:f}=Hu(),{data:p}=Wu(),{content:x,updateField:g}=NN(),[b,w]=u.useState("fixed"),[j,y]=u.useState(1);u.useState(null);const[v,N]=u.useState({selectedAreas:[],bogofPaidAreas:[],bogofFreeAreas:[],selectedAdSize:"",selectedDuration:"",selectedMonths:{},pricingBreakdown:null,selectedPaymentOption:"",selectedStartingIssue:"",needsDesign:!1,designFee:0,discount:null}),[S,k]=u.useState(!1);ve.useEffect(()=>{console.log("AdvertisingStepForm mounted - invalidating product packages cache"),a.invalidateQueries({queryKey:["product-packages"]})},[a]),ve.useEffect(()=>{if(b==="leafleting"&&v.selectedAreas.length>0&&(h!=null&&h.length)){console.log("Calculating leafleting pricing...",{selectedAreas:v.selectedAreas,selectedDuration:v.selectedDuration,leafletAreas:h.length});const E=m==null?void 0:m.find(F=>F.id===v.selectedDuration),z=(E==null?void 0:E.issues)||1,Z=(E==null?void 0:E.issues)||1;console.log("Duration multiplier:",z,"from duration:",E);const M=fN(v.selectedAreas,h,z,Z);console.log("Leafleting pricing calculated:",M),M&&N(F=>({...F,pricingBreakdown:M}))}},[b,v.selectedAreas,v.selectedDuration,h,m]),ve.useEffect(()=>{console.log("AdvertisingStepForm - Campaign data updated:",v),v.pricingBreakdown?console.log("AdvertisingStepForm - Has pricing breakdown:",v.pricingBreakdown):console.log("AdvertisingStepForm - No pricing breakdown yet")},[v]),ve.useEffect(()=>{if(v.selectedAdSize){const E=c==null?void 0:c.find(Z=>Z.id===v.selectedAdSize),z=b==="bogof"?(E==null?void 0:E.design_fee_subscription)||45:(E==null?void 0:E.design_fee)||95;N(Z=>({...Z,designFee:z}))}},[v.selectedAdSize,b,c]),ve.useEffect(()=>{if(!v.pricingBreakdown)return;const z=v.needsDesign&&v.designFee>0?v.designFee:0;N(Z=>{const M=Z.pricingBreakdown;if(!M)return Z;const F=typeof M.finalTotalBeforeDesign=="number"?M.finalTotalBeforeDesign:M.finalTotal;return M.designFee===z&&M.finalTotal===F&&M.finalTotalBeforeDesign===F?Z:{...Z,pricingBreakdown:{...M,designFee:z,finalTotal:F,finalTotalBeforeDesign:F}}})},[v.needsDesign,v.designFee,v.pricingBreakdown]);const[$,R]=u.useState(!1),[A,T]=u.useState(null),P=E=>{w(E)},B=()=>{var E;w("bogof"),N(z=>({selectedAreas:[],bogofPaidAreas:z.selectedAreas,bogofFreeAreas:[],selectedAdSize:"",selectedDuration:"",selectedMonths:{},pricingBreakdown:null,selectedPaymentOption:"",selectedStartingIssue:"",needsDesign:z.needsDesign,designFee:z.designFee,discount:null})),R(!1),T(null),(E=window.salesAssistantGoToStep)==null||E.call(window,2),r({title:"Switched to 3+ Subscription Package!",description:"Your selected areas have been saved. Now select your FREE bonus areas to continue."})},Y=()=>{R(!1),A&&A(),T(null),r({title:"Continuing with Fixed Term",description:"Review your booking details below."})},I=(E,z)=>{const Z=v.discount;if(!Z)return{monthly:E,finalTotal:z,discountBlock:null};const M=xte(b);if(M==="subscription"){const se=E*12,le=Qh({productType:M,baseFinalTotal:se,baseMonthly:E,contractMonths:12,discount:Z});return{monthly:le.adjustedMonthly,finalTotal:le.adjustedMonthly*12,discountBlock:{code:Z.c
755ode,code_id:Z.code_id??null,discount_type:Z.discount_type,discount_value:Z.discount_value,free_item_text:Z.free_item_text??null,discount_amount:le.discountAmount,line_label:le.lineLabel,is_free_item:le.isFreeItem,base_final_total:se,base_monthly:E}}}const F=Qh({productType:M,baseFinalTotal:z,discount:Z});return{monthly:z>0?E*(F.adjustedFinalTotal/z):E,finalTotal:F.adjustedFinalTotal,discountBlock:{code:Z.code,code_id:Z.code_id??null,discount_type:Z.discount_type,discount_value:Z.discount_value,free_item_text:Z.free_item_text??null,discount_amount:F.discountAmount,line_label:F.lineLabel,is_free_item:F.isFreeItem,base_final_total:z}}},C=async E=>{var z,Z,M,F,ee,se,le,X,ye,Ce,ke,fe,Ee,K,te,Q,ae,me;k(!0);try{const pe=b==="bogof"?v.bogofPaidAreas:v.selectedAreas,be=`${E.firstName} ${E.lastName}`,ce=!!E.isAdminCreating;let ie,je=!0;if(ce){const We=E.generatedPassword||crypto.randomUUID().slice(0,12),{data:Ke,error:st}=await W.functions.invoke("admin-manage-user",{body:{action:"create_user",email:E.email,password:We,display_name:be,company:E.companyName||void 0,phone:E.phone||void 0,send_email:!1,allow_existing_user:!0}});if(st||Ke!=null&&Ke.error){const dt=(Ke==null?void 0:Ke.error)||(st==null?void 0:st.message)||"Failed to create customer account";r({title:"Error Creating Account",description:dt,variant:"destructive"});return}if(ie=(Ke==null?void 0:Ke.user_id)||((z=Ke==null?void 0:Ke.user)==null?void 0:z.id),je=!(Ke!=null&&Ke.is_existing_user),E._actualGeneratedPassword=We,!ie){r({title:"Error",description:"Failed to create customer account.",variant:"destructive"});return}await W.from("profiles").upsert({user_id:ie,display_name:be,company:E.companyName||null,phone:E.phone||null},{onConflict:"user_id"})}else{const{data:Le,error:We}=await W.auth.signUp({email:E.email,password:E.password,options:{emailRedirectTo:`${window.location.origin}/dashboard`,data:{display_name:be,phone:E.phone||"",company:E.companyName||""}}});if(ie=(Z=Le==null?void 0:Le.user)==null?void 0:Z.id,(We==null?void 0:We.message)==="User already registered"){je=!1;const{data:Ke,error:st}=await W.auth.signInWithPassword({email:E.email,password:E.password});if(st){r({title:"Incorrect Password",description:"This email is already registered. Please enter your correct password to sign in.",variant:"destructive"});return}ie=(M=Ke==null?void 0:Ke.user)==null?void 0:M.id,r({title:"Welcome Back!",description:"Successfully signed in to your existing account."})}else if(We){r({title:"Sign Up Failed",description:We.message||"Failed to create account.",variant:"destructive"});return}}if(!ie){r({title:"Authentication Failed",description:"Failed to create or authenticate user.",variant:"destructive"});return}const Re=await u3(),Ae=f0(Number((F=v.pricingBreakdown)==null?void 0:F.finalTotal)||0,b,Number((ee=v.pricingBreakdown)==null?void 0:ee.durationMultiplier)||1,p||[]),Ue=Ad({pricingModel:b,monthlyPrice:Ae,fallbackFinalTotal:Number((se=v.pricingBreakdown)==null?void 0:se.finalTotal)||0}),{monthly:Ve,finalTotal:lt,discountBlock:J}=I(Ae,Ue),Ne={user_id:ie,contact_name:be,email:E.email,phone:E.phone||"",company:E.companyName||"",title:`${b==="fixed"?"Fixed Term":b==="bogof"?"3+ Subscription Package":"Leafleting"} Quote`,pricing_model:b,ad_size_id:v.selectedAdSize||null,duration_id:v.selectedDuration||null,selected_area_ids:Array.isArray(pe)?pe:[],bogof_paid_area_ids:b==="bogof"&&Array.isArray(v.bogofPaidAreas)?v.bogofPaidAreas:[],bogof_free_area_ids:b==="bogof"&&Array.isArray(v.bogofFreeAreas)?v.bogofFreeAreas:[],monthly_price:Ve,subtotal:Number((le=v.pricingBreakdown)==null?void 0:le.subtotal)||0,final_total:lt,duration_multiplier:Number((X=v.pricingBreakdown)==null?void 0:X.durationMultiplier)||1,total_circulation:Number((ye=v.pricingBreakdown)==null?void 0:ye.totalCirculation)||0,volume_discount_percent:Number((Ce=v.pricingBreakdown)==null?void 0:Ce.volumeDiscountPercent)||0,duration_discount_percent:Number((ke=v.pricingBreakdown)==null?void 0:ke.durationDiscountPercent)||0,agency_discount_percent:Number((fe=v.pricingBreakdown)==null?void 0:fe.agencyDiscountPercent)||0,distribution_start_date:v.selectedStartingIssue?`${v.selectedStartingIssue}-01`:(()=>{var We;const Le=(We=Object.values(v.selectedMonths||{})[0])==null?void 0:We[0];return Le&&/^\d{4}-\d{2}$/.test(Le)?`${Le}-01`:null})(),pricing_breakdown:{...JSON.parse(JSON.stringify(v.pricingBreakdown||{})),discount:J},selections:{pricingModel:b,selectedAdSize:v.selectedAdSize||null,selectedDuration:v.selectedDuration||null,selectedAreas:Array.isArray(v.selectedAreas)?v.selectedAreas:[],bogofPaidAreas:Array.isArray(v.bogofPaidAreas)?v.bogofPaidAreas:[],bogofFreeAreas:Array.isArray(v.bogofFreeAreas)?v.bogofFreeAreas:[],addressLine1:E.addressLine1||"",addressLine2:E.addressLine2||"",city:E.
755city||"",postcode:E.postcode||"",...v,discount:J}},{data:gt,error:He}=await W.from("quotes").insert(Ne).select().single();if(He){console.error("Quote save error:",He),r({title:"Error Saving Quote",description:"Failed to save quote to database.",variant:"destructive"});return}try{const Le=b==="leafleting"?f==null?void 0:f.find(dt=>dt.id===v.selectedAdSize):c==null?void 0:c.find(dt=>dt.id===v.selectedAdSize),We=b==="leafleting"?m==null?void 0:m.find(dt=>dt.id===v.selectedDuration):(i==null?void 0:i.find(dt=>dt.id===v.selectedDuration))||(o==null?void 0:o.find(dt=>dt.id===v.selectedDuration)),Ke=b==="leafleting"?Le==null?void 0:Le.label:Le==null?void 0:Le.name,st={areas:l,adSizes:c,durations:i,subscriptionDurations:o,paymentOptions:p,leafletAreas:h,leafletSizes:f,leafletDurations:m};await W.functions.invoke("send-quote-booking-webhook",{body:px({record_type:"quote",record_id:gt.id,pricing_model:b,contact_name:be,email:E.email,phone:E.phone||"",company:E.companyName||"",title:Ne.title,ad_size:Ke,duration:We==null?void 0:We.name,selected_areas:pe,bogof_paid_areas:v.bogofPaidAreas||[],bogof_free_areas:v.bogofFreeAreas||[],total_circulation:(Ee=v.pricingBreakdown)==null?void 0:Ee.totalCirculation,subtotal:(K=v.pricingBreakdown)==null?void 0:K.subtotal,final_total:Ne.final_total,monthly_price:Ne.monthly_price,volume_discount_percent:(te=v.pricingBreakdown)==null?void 0:te.volumeDiscountPercent,status:"draft",pricing_breakdown:v.pricingBreakdown,selections:Ne.selections,invoice_address:{postcode:E.postcode||"",address_line_1:E.addressLine1||"",address_line_2:E.addressLine2||"",city:E.
755city||""}},st)}),console.log("Quote webhook sent successfully")}catch(Le){console.error("Quote webhook error:",Le)}try{const Le=b==="leafleting"?f==null?void 0:f.find(tt=>tt.id===v.selectedAdSize):c==null?void 0:c.find(tt=>tt.id===v.selectedAdSize),We=b==="leafleting"?m==null?void 0:m.find(tt=>tt.id===v.selectedDuration):(i==null?void 0:i.find(tt=>tt.id===v.selectedDuration))||(o==null?void 0:o.find(tt=>tt.id===v.selectedDuration)),{data:Ke,error:st}=await W.functions.invoke("send-booking-confirmation-email",{body:{record_type:"quote",record_id:gt.id,pricing_model:b,contact_name:be,email:E.email,phone:E.phone||"",company:E.companyName||"",title:Ne.title,ad_size:b==="leafleting"?Le==null?void 0:Le.label:Le==null?void 0:Le.name,duration:We==null?void 0:We.name,selected_areas:pe.map(tt=>{var Jt;return((Jt=[...l||[],...h||[]].find(us=>us.id===tt))==null?void 0:Jt.name)||tt}),bogof_paid_areas:(v.bogofPaidAreas||[]).map(tt=>{var Jt;return((Jt=l==null?void 0:l.find(us=>us.id===tt))==null?void 0:Jt.name)||tt}),bogof_free_areas:(v.bogofFreeAreas||[]).map(tt=>{var Jt;return((Jt=l==null?void 0:l.find(us=>us.id===tt))==null?void 0:Jt.name)||tt}),total_circulation:(Q=v.pricingBreakdown)==null?void 0:Q.totalCirculation,subtotal:(ae=v.pricingBreakdown)==null?void 0:ae.subtotal,final_total:Ne.final_total,monthly_price:Ne.monthly_price,volume_discount_percent:(me=v.pricingBreakdown)==null?void 0:me.volumeDiscountPercent,pricing_breakdown:{...v.pricingBreakdown||{},discount:J},selections:Ne.selections,distribution_start_date:Ne.distribution_start_date,...ce?{is_admin_created:!0,...je?{generated_password:E._actualGeneratedPassword||E.generatedPassword||E.password}:{is_existing_user:!0}}:{}}}),dt=!st&&(Ke==null?void 0:Ke.customer_email_sent)===!0;console.log("Quote confirmation email result:",{quoteEmailResp:Ke,quoteEmailInvokeErr:st}),dt||r({title:"Quote saved â confirmation email delayed",description:"Your quote is saved, but we couldn't send the confirmation email. Our team will follow up shortly."})}catch(Le){console.error("Quote confirmation email error:",Le),r({title:"Quote saved â confirmation email delayed",description:"Your quote is saved, but we couldn't send the confirmation email. Our team will follow up shortly."})}const Te={...Ne,user_id:ie},{error:De}=await W.from("quote_requests").insert(Te);De&&console.error("Quote request save error:",De),ce?(r({title:je?"Quote Created for Customer!":"Quote Created for Existing Customer!",description:je?`Quote saved and credentials emailed to ${E.email}.`:`Quote saved. A login link has been sent to ${E.email}. They can use "Forgot Password" if needed.`}),setTimeout(()=>{n("/admin")},1500)):(je&&localStorage.setItem("newUserFromCalculator","true"),localStorage.setItem("justSavedQuote","true"),r({title:je?"Account Created & Quote Saved!":"Quote Saved Successfully!",description:je?"Welcome! Your account has been created and your quote is saved. Redirecting to your dashboard...":"Your quote has been saved to your dashboard. Redirecting..."}),setTimeout(()=>{n("/dashboard")},1500))}catch(pe){console.error("Error in handleContactInfoSave:",pe),r({title:"Error",description:pe.message||"Failed to save quote. Please try again.",variant:"destructive"})}finally{k(!1)}},L=async E=>{var z,Z,M,F,ee,se,le,X,ye,Ce,ke,fe,Ee,K,te,Q,ae,me,pe,be,ce,ie,je,Re,Ae,Ue,Ve,lt,J,Ne,gt,He,Te,De;k(!0);try{let Le=!1;if(b==="bogof"){const{data:{user:Et}}=await W.auth.getUser();let as=E.email,Ct=E.phone;if(Et!=null&&Et.email){as=Et.email;const{data:Ge}=await W.from("profiles").select("phone").eq("user_id",Et.id).maybeSingle();Ge!=null&&Ge.phone&&(Ct=Ge.phone)}const{data:he,error:$e}=await W.functions.invoke("validate-bogof-eligibility",{body:{email:as,phone:Ct}});$e?console.error("Error checking BOGOF eligibility:",$e):he&&!he.isEligible&&(Le=!0)}const We=b==="bogof"?v.bogofPaidAreas:v.selectedAreas,Ke=`${E.firstName} ${E.lastName}`;console.log("Starting booking process...",{contactData:E,campaignData:v,selectedPricingModel:b,isReturningBogofCustomer:Le});const st=!!E.isAdminCreating;let dt,tt=!0;
755if(st){const as=E.generatedPassword||crypto.randomUUID().slice(0,12),{data:Ct,error:he}=await W.functions.invoke("admin-manage-user",{body:{action:"create_user",email:E.email,password:as,display_name:Ke,send_email:!1,allow_existing_user:!0}});if(he||Ct!=null&&Ct.error){const $e=(Ct==null?void 0:Ct.error)||(he==null?void 0:he.message)||"Failed to create customer account";r({title:"Error Creating Account",description:$e,variant:"destructive"});return}dt=(Ct==null?void 0:Ct.user_id)||((z=Ct==null?void 0:Ct.user)==null?void 0:z.id),tt=!(Ct!=null&&Ct.is_existing_user),E._actualGeneratedPassword=as}else{const{data:Et,error:as}=await W.auth.signUp({email:E.email,password:E.password,options:{emailRedirectTo:`${window.location.origin}/dashboard`,data:{display_name:Ke,phone:E.phone||"",company:E.companyName||""}}});if(dt=(Z=Et==null?void 0:Et.user)==null?void 0:Z.id,(as==null?void 0:as.message)==="User already registered"){tt=!1;const{data:Ct,error:he}=await W.auth.signInWithPassword({email:E.email,password:E.password});if(he){r({title:"Incorrect Password",description:"This email is already registered. Please enter your correct password to sign in.",variant:"destructive"});return}dt=(M=Ct==null?void 0:Ct.user)==null?void 0:M.id}else if(as){r({title:"Sign Up Failed",description:as.message||"Failed to create account.",variant:"destructive"});return}}const Jt=await u3();if(console.log("Fraud detection data:",Jt),Le){const Et=f0(Number((F=v.pricingBreakdown)==null?void 0:F.finalTotal)||0,b,Number((ee=v.pricingBreakdown)==null?void 0:ee.durationMultiplier)||1,p||[]),as=Ad({pricingModel:b,monthlyPrice:Et,fallbackFinalTotal:Number((se=v.pricingBreakdown)==null?void 0:se.finalTotal)||0}),{monthly:Ct,finalTotal:he,discountBlock:$e}=I(Et,as),Ge={user_id:dt,contact_name:Ke,email:E.email,phone:E.phone||"",company:E.companyName||"",title:"3+ Subscription Package - Returning Customer Interest",pricing_model:b,ad_size_id:v.selectedAdSize||null,duration_id:v.selectedDuration||null,selected_area_ids:Array.isArray(We)?We:[],bogof_paid_area_ids:b==="bogof"&&Array.isArray(v.bogofPaidAreas)?v.bogofPaidAreas:[],bogof_free_area_ids:b==="bogof"&&Array.isArray(v.bogofFreeAreas)?v.bogofFreeAreas:[],monthly_price:Ct,subtotal:Number((le=v.pricingBreakdown)==null?void 0:le.subtotal)||0,final_total:he,duration_multiplier:Number((X=v.pricingBreakdown)==null?void 0:X.durationMultiplier)||1,total_circulation:Number((ye=v.pricingBreakdown)==null?void 0:ye.totalCirculation)||0,volume_discount_percent:Number((Ce=v.pricingBreakdown)==null?void 0:Ce.volumeDiscountPercent)||0,duration_discount_percent:Number((ke=v.pricingBreakdown)==null?void 0:ke.durationDiscountPercent)||0,agency_discount_percent:Number((fe=v.pricingBreakdown)==null?void 0:fe.agencyDiscountPercent)||0,distribution_start_date:v.selectedStartingIssue?`${v.selectedStartingIssue}-01`:(Ee=Object.values(v.selectedMonths||{})[0])!=null&&Ee[0]?`${(K=Object.values(v.selectedMonths||{})[0])==null?void 0:K[0]}-01`:null,pricing_breakdown:{...JSON.parse(JSON.stringify(v.pricingBreakdown||{})),discount:$e},selections:{pricingModel:b,selectedAdSize:v.selectedAdSize||null,selectedDuration:v.selectedDuration||null,selectedAreas:Array.isArray(v.selectedAreas)?v.selectedAreas:[],bogofPaidAreas:Array.isArray(v.bogofPaidAreas)?v.bogofPaidAreas:[],bogofFreeAreas:Array.isArray(v.bogofFreeAreas)?v.bogofFreeAreas:[],addressLine1:E.addressLine1||"",addressLine2:E.addressLine2||"",city:E.
755city||"",postcode:E.postcode||"",...v,discount:$e},notes:"Returning customer - previously used 3+ Subscription Package. Interested in booking again - please contact with new terms.",status:"bogof_return_interest"},{data:Pt,error:_s}=await W.from("quotes").insert(Ge).select("id").single();_s&&console.error("Quote save error:",_s);const{error:ln}=await W.from("quote_requests").insert(Ge);ln&&console.error("Quote request save error:",ln);try{const cn=c==null?void 0:c.find(dn=>dn.id===v.selectedAdSize),Ni=(i==null?void 0:i.find(dn=>dn.id===v.selectedDuration))||(o==null?void 0:o.find(dn=>dn.id===v.selectedDuration)),{data:Fc,error:no}=await W.functions.invoke("send-booking-confirmation-email",{body:{record_type:"quote",record_id:Pt==null?void 0:Pt.id,pricing_model:"bogof",contact_name:Ke,email:E.email,phone:E.phone||"",company:E.companyName||"",title:Ge.title,ad_size:cn==null?void 0:cn.name,duration:Ni==null?void 0:Ni.name,selected_areas:(We||[]).map(dn=>{var ao;return((ao=l==null?void 0:l.find(Zu=>Zu.id===dn))==null?void 0:ao.name)||dn}),bogof_paid_areas:(v.bogofPaidAreas||[]).map(dn=>{var ao;return((ao=l==null?void 0:l.find(Zu=>Zu.id===dn))==null?void 0:ao.name)||dn}),bogof_free_areas:(v.bogofFreeAreas||[]).map(dn=>{var ao;return((ao=l==null?void 0:l.find(Zu=>Zu.id===dn))==null?void 0:ao.name)||dn}),total_circulation:(te=v.pricingBreakdown)==null?void 0:te.totalCirculation,subtotal:(Q=v.pricingBreakdown)==null?void 0:Q.subtotal,final_total:Ge.final_total,monthly_price:Ge.monthly_price,volume_discount_percent:(ae=v.pricingBreakdown)==null?void 0:ae.volumeDiscountPercent,pricing_breakdown:{...v.pricingBreakdown||{},discount:$e},distribution_start_date:Ge.distribution_start_date,is_returning_bogof_customer:!0}}),U7=!no&&(Fc==null?void 0:Fc.customer_email_sent)===!0;console.log("Returning BOGOF confirmation email result:",{emailResp:Fc,emailInvokeErr:no}),U7||r({title:"Interest saved â confirmation email delayed",description:"We've recorded your interest, but couldn't send the confirmation email. Our team will follow up shortly."})}catch(cn){console.error("Returning BOGOF confirmation email error:",cn),r({title:"Interest saved â confirmation email delayed",description:"We've recorded your interest, but couldn't send the confirmation email. Our team will follow up shortly."})}try{const cn=c==null?void 0:c.find(no=>no.id===v.selectedAdSize),Ni=(i==null?void 0:i.find(no=>no.id===v.selectedDuration))||(o==null?void 0:o.find(no=>no.id===v.selectedDuration)),Fc={areas:l,adSizes:c,durations:i,subscriptionDurations:o,paymentOptions:p,leafletAreas:h,leafletSizes:f,leafletDurations:m};await W.functions.invoke("send-quote-booking-webhook",{body:px({record_type:"quote",record_id:Pt==null?void 0:Pt.id,pricing_model:"bogof",contact_name:Ke,email:E.email,phone:E.phone||"",company:E.companyName||"",title:Ge.title,ad_size:cn==null?void 0:cn.name,duration:Ni==null?void 0:Ni.name,selected_areas:We,bogof_paid_areas:v.bogofPaidAreas||[],bogof_free_areas:v.bogofFreeAreas||[],total_circulation:(me=v.pricingBreakdown)==null?void 0:me.totalCirculation,subtotal:(pe=v.pricingBreakdown)==null?void 0:pe.subtotal,final_total:Ge.final_total,monthly_price:Ge.monthly_price,volume_discount_percent:(be=v.pricingBreakdown)==null?void 0:be.volumeDiscountPercent,status:"bogof_return_interest",is_returning_bogof_customer:!0,pricing_breakdown:v.pricingBreakdown,selections:Ge.selections,invoice_address:{postcode:E.postcode||"",address_line_1:E.addressLine1||"",address_line_2:E.addressLine2||"",city:E.
755city||""}},Fc)}),console.log("Returning BOGOF CRM webhook sent successfully")}catch(cn){console.error("Returning BOGOF CRM webhook error:",cn)}tt&&localStorage.setItem("newUserFromCalculator","true"),localStorage.setItem("justSavedQuote","true"),localStorage.setItem("returningBogofCustomer","true"),r({title:"Thanks for Your Interest!",description:"Our team will contact you with exclusive returning customer rates. Redirecting to your dashboard..."}),setTimeout(()=>{n("/dashboard")},2e3);return}const us=f0(Number((ce=v.pricingBreakdown)==null?void 0:ce.finalTotal)||0,b,Number((ie=v.pricingBreakdown)==null?void 0:ie.durationMultiplier)||1,p||[]),St=Ad({pricingModel:b,monthlyPrice:us,fallbackFinalTotal:Number((je=v.pricingBreakdown)==null?void 0:je.finalTotal)||0}),{monthly:fr,finalTotal:Yn,discountBlock:Ds}=I(us,St),rr={user_id:dt,contact_name:Ke,email:E.email,phone:E.phone||"",company:E.companyName||"",title:`${b==="fixed"?"Fixed Term":b==="bogof"?"3+ Subscription Package":"Leafleting"} Booking`,pricing_model:b,ad_size_id:v.selectedAdSize||null,duration_id:v.selectedDuration||null,selected_area_ids:Array.isArray(We)?We:[],bogof_paid_area_ids:b==="bogof"&&Array.isArray(v.bogofPaidAreas)?v.bogofPaidAreas:[],bogof_free_area_ids:b==="bogof"&&Array.isArray(v.bogofFreeAreas)?v.bogofFreeAreas:[],monthly_price:fr,subtotal:Number((Re=v.pricingBreakdown)==null?void 0:Re.subtotal)||0,final_total:Yn,duration_multiplier:Number((Ae=v.pricingBreakdown)==null?void 0:Ae.durationMultiplier)||1,total_circulation:Number((Ue=v.pricingBreakdown)==null?void 0:Ue.totalCirculation)||0,volume_discount_percent:Number((Ve=v.pricingBreakdown)==null?void 0:Ve.volumeDiscountPercent)||0,duration_discount_percent:Number((lt=v.pricingBreakdown)==null?void 0:lt.durationDiscountPercent)||0,pricing_breakdown:{...v.pricingBreakdown?JSON.parse(JSON.stringify(v.pricingBreakdown)):{},discount:Ds},selections:{pricingModel:b,selectedAdSize:v.selectedAdSize,selectedDuration:v.selectedDuration,selectedAreas:v.selectedAreas||[],bogofPaidAreas:v.bogofPaidAreas||[],bogofFreeAreas:v.bogofFreeAreas||[],selectedMonths:v.selectedMonths||{},selectedStartingIssue:v.selectedStartingIssue||null,payment_option_id:v.selectedPaymentOption||null,addressLine1:E.addressLine1||"",addressLine2:E.addressLine2||"",city:E.
755city||"",postcode:E.postcode||"",discount:Ds},ip_address_hash:Jt.ipHash,device_fingerprint:Jt.deviceFingerprint,status:"pending"};console.log("Booking payload:",JSON.stringify(rr,null,2));const{data:Nr,error:Tr}=await W.from("bookings").insert(rr).select().single();if(console.log("Booking insert result:",{bookingData:Nr,bookingError:Tr}),Tr){console.error("Booking save error:",Tr),r({title:"Error Creating Booking",description:`Failed to create booking: ${Tr.message}. Please try again.`,variant:"destructive"});return}try{const{error:Et}=await W.functions.invoke("send-booking-webhook",{body:{bookingData:Nr,step1Data:{pricingModel:b},step2Data:v,step3Data:E,userId:dt}});Et&&(console.error("Webhook error:",Et),r({title:"Booking Created",description:"Your booking has been created but there was an issue sending it to our system. Our team will process it manually.",variant:"default"}))}catch(Et){console.error("Webhook send error:",Et)}try{const Et=b==="leafleting"?f==null?void 0:f.find($e=>$e.id===v.selectedAdSize):c==null?void 0:c.find($e=>$e.id===v.selectedAdSize),as=b==="leafleting"?m==null?void 0:m.find($e=>$e.id===v.selectedDuration):(i==null?void 0:i.find($e=>$e.id===v.selectedDuration))||(o==null?void 0:o.find($e=>$e.id===v.selectedDuration)),Ct=b==="leafleting"?Et==null?void 0:Et.label:Et==null?void 0:Et.name,he={areas:l,adSizes:c,durations:i,subscriptionDurations:o,paymentOptions:p,leafletAreas:h,leafletSizes:f,leafletDurations:m};await W.functions.invoke("send-quote-booking-webhook",{body:px({record_type:"booking",record_id:Nr.id,pricing_model:b,contact_name:Ke,email:E.email,phone:E.phone||"",company:E.companyName||"",title:rr.title,ad_size:Ct,duration:as==null?void 0:as.name,selected_areas:We,bogof_paid_areas:v.bogofPaidAreas||[],bogof_free_areas:v.bogofFreeAreas||[],total_circulation:(J=v.pricingBreakdown)==null?void 0:J.totalCirculation,subtotal:(Ne=v.pricingBreakdown)==null?void 0:Ne.subtotal,final_total:rr.final_total,monthly_price:rr.monthly_price,volume_discount_percent:(gt=v.pricingBreakdown)==null?void 0:gt.volumeDiscountPercent,status:"pending",pricing_breakdown:v.pricingBreakdown,selections:rr.selections,invoice_address:{postcode:E.postcode||"",address_line_1:E.addressLine1||"",address_line_2:E.addressLine2||"",city:E.
755city||""}},he)}),console.log("Booking CRM webhook sent successfully")}catch(Et){console.error("Booking CRM webhook error:",Et)}try{const Et=c==null?void 0:c.find(Ge=>Ge.id===v.selectedAdSize),as=(i==null?void 0:i.find(Ge=>Ge.id===v.selectedDuration))||(o==null?void 0:o.find(Ge=>Ge.id===v.selectedDuration)),{data:Ct,error:he}=await W.functions.invoke("send-booking-confirmation-email",{body:{record_type:"booking",record_id:Nr.id,pricing_model:b,contact_name:Ke,email:E.email,phone:E.phone||"",company:E.companyName||"",title:rr.title,ad_size:Et==null?void 0:Et.name,duration:as==null?void 0:as.name,selected_areas:We.map(Ge=>{var Pt;return((Pt=[...l||[],...h||[]].find(_s=>_s.id===Ge))==null?void 0:Pt.name)||Ge}),bogof_paid_areas:(v.bogofPaidAreas||[]).map(Ge=>{var Pt;return((Pt=l==null?void 0:l.find(_s=>_s.id===Ge))==null?void 0:Pt.name)||Ge}),bogof_free_areas:(v.bogofFreeAreas||[]).map(Ge=>{var Pt;return((Pt=l==null?void 0:l.find(_s=>_s.id===Ge))==null?void 0:Pt.name)||Ge}),total_circulation:(He=v.pricingBreakdown)==null?void 0:He.totalCirculation,subtotal:(Te=v.pricingBreakdown)==null?void 0:Te.subtotal,final_total:rr.final_total,monthly_price:rr.monthly_price,volume_discount_percent:(De=v.pricingBreakdown)==null?void 0:De.volumeDiscountPercent,pricing_breakdown:{...v.pricingBreakdown||{},discount:Ds},distribution_start_date:v.selectedStartingIssue?`${v.selectedStartingIssue}-01`:(()=>{var Pt;const Ge=(Pt=Object.values(v.selectedMonths||{})[0])==null?void 0:Pt[0];return Ge&&/^\d{4}-\d{2}$/.test(Ge)?`${Ge}-01`:null})(),...st?{is_admin_created:!0,...tt?{generated_password:E._actualGeneratedPassword||E.generatedPassword||E.password}:{is_existing_user:!0}}:{}}}),$e=!he&&(Ct==null?void 0:Ct.customer_email_sent)===!0;console.log("Booking confirmation email result:",{bookingEmailResp:Ct,bookingEmailInvokeErr:he}),$e||r({title:"Booking saved â confirmation email delayed",description:"Your booking is saved, but we couldn't send the confirmation email. Our team will follow up shortly."})}catch(Et){console.error("Booking confirmation email error:",Et),r({title:"Booking saved â confirmation email delayed",description:"Your booking is saved, but we couldn't send the confirmation email. Our team will follow up shortly."})}st?(r({title:tt?"Booking Created for Customer!":"Booking Created for Existing Customer!",description:tt?`Booking saved and credentials emailed to ${E.email}.`:`Booking saved. A login link has been sent to ${E.email}. They can use "Forgot Password" if needed.`}),setTimeout(()=>{n("/admin")},1500)):(tt&&localStorage.setItem("newUserFromCalculator","true"),localStorage.setItem("justCreatedBooking","true"),r({title:tt?"Account Created!":"Booking Created!",description:"Redirecting you to your dashboard where you can set up payment..."}),setTimeout(()=>{n("/dashboard")},1500))}catch(Le){console.error("Error in handleContactInfoBook:",Le),r({title:"Error",description:Le.message||"Failed to create booking. Please try again.",variant:"destructive"})}finally{k(!1)}},D={nextButtonLabels:["Select Areas & Publication Schedule","Choose Advertisement Size","Quote & Payment Options","Next: Contact Details","Save My Quote"],prevButtonLabel:"Previous Step",onLastStepNext:()=>Promise.resolve(),onStepTransition:(E,z)=>{var Z,M,F,ee;if(E===1){if(b==="leafleting"){if(!v.selectedDuration){r({title:"Campaign Duration Required",description:"Please select a campaign duration before continuing.",variant:"destructive"}),(Z=document.getElementById("campaign-duration-section"))==null||Z.scrollIntoView({behavior:"smooth",block:"center"});return}if(!v.selectedAreas.every(le=>{var X;return((X=v.selectedMonths[le])==null?void 0:X.length)>0})&&v.selectedAreas.length>0){r({title:"Schedule Selection Required",description:"Please select delivery months for all selected areas.",variant:"destructive"});return}}if(b==="fixed"){if(!v.selectedDuration){r({title:"Campaign Duration Required",description:"Please select a campaign duration before continuing.",variant:"destructive"}),(M=document.getElementById("campaign-duration-section"))==null||M.scrollIntoView({behavior:"smooth",block:"center"});return}if(!v.selectedAreas.every(le=>{var X;return((X=v.selectedMonths[le])==null?void 0:X.length)>0})&&v.selectedAreas.length>0){r({title:"Schedule Selection Required",description:"Please select publication months for all selected areas.",variant:"destructive"});return}}if(b==="bogof"){if(v.bogofPaidAreas.length===0){r({title:"Area Selection Required",description:"Please select at least one paid area before continuing.",variant:"destructive"});return}if(v.bogofFreeAreas.length!==v.bogofPaidAreas.length){const se=v.bogofPaidAreas.length-v.bogofFreeAreas.length;r({title:"Free Areas Required",description:`You still need to select ${se} free bonus area${se!==1?"s":""} before continuing. Scroll up and click your free areas now.`,variant:"destructive"}),(F=document.getElementById("bogof-free-areas-section"))==null||F.scrollIntoView({behavior:"smooth",block:"center"});return}}}if(E===3&&b==="bogof"&&!v.selectedPaymentOption){r({title:"Payment Option Required",description:"Please select a payment option to continue.",variant:"destructive"});return}if(E===3&&b==="fixed"&&(((ee=v.selectedAreas)==null?void 0:ee.length)||0)>=3&&v.selectedAdSize){T(()=>z),R(!0);return}z()}},_=E=>{y(E)};return t.jsxs(ID,{children:[s&&e?t.jsxs(bt,{onOpenChange:E=>{E&&a.invalidateQueries({queryKey:["product-packages"]})},children:[t.jsx(Sn,{asChild:!0,children:e}),t.jsxs(xt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[t.jsx(jt,{children:t.jsx(wt,{className:"text-2xl font-bold",children:"Advertising Cost Calculator"})}),t.jsxs(d3,{stepLabels:D,onStepChange:_,children:[t.jsx(m3,{onSelectOption:P,advertisingContent:x,onContentSave:g}),t.jsx(h3,{pricingModel:b,selectedAreas:v.selectedAreas,bogofPaidAreas:v.bogofPaidAreas,bogofFreeAreas:v.bogofFreeAreas,selectedDuration:v.selectedDuration,selectedMonths:v.selectedMonths,onAreasChange:E=>N(z=>({...z,selectedAreas:E})),onBogofAreasChange:(E,z)=>N(Z=>({...Z,bogofPaidAreas:E,bogofFreeAreas:z})),onDurationChange:E=>N(z=>({...z,selectedDuration:E})),onMonthsChange:E=>N(z=>({...z,selectedMonths:E})),onNext:()=>{},campaignData:{selectedModel:b,selectedAreas:v.selectedAreas,bogofPaidAreas:v.bogofPaidAreas,bogofFreeAreas:v.bogofFreeAreas,selectedSize:v.selectedAdSize,selectedDuration:v.selectedDuration,totalCost:(H=v.pricingBreakdown)==null?void 0:H.finalTotal,pricingBreakdown:v.pricingBreakdown},currentStep:j,advertisingContent:x,onContentSave:g}),b==="leafleting"?t.jsx(j3,{selectedLeafletSize:v.selectedAdSize,onLeafletSizeChange:E=>N(z=>({...z,selectedAdSize:E})),onNext:()=>{}}):t.jsx(f3,{selectedAdSize:v.selectedAdSize,onAdSizeChange:E=>N(z=>({...z,selectedAdSize:E})),pricingModel:b,selectedAreas:v.selectedAreas,bogofPaidAreas:v.bogofPaidAreas,bogofFreeAreas:v.bogofFreeAreas,selectedDuration:v.selectedDuration,onPricingChange:E=>{console.log("AdvertisingStepForm - Pricing breakdown received:",E),N(z=>({...z,pricingBreakdown:E}))},showSummary:!0,onNext:()=>{},campaignData:{selectedModel:b,selectedAreas:v.selectedAreas,bogofPaidAreas:v.bogofPaidAreas,bogofFreeAreas:v.bogofFreeAreas,selectedSize:v.selectedAdSize,selectedDuration:v.selectedDuration,totalCost:(O=v.pricingBreakdown)==null?void 0:O.finalTotal,pricingBreakdown:v.pricingBreakdown},currentStep:j,selectedMonths:v.selectedMonths}),t.jsx(p3,{needsDesign:v.needsDesign,onDesignChoiceChange:E=>N(z=>({...z,needsDesign:E})),designFee:v.designFee,pricingModel:b,advertisingContent:x,onContentSave:g}),b==="leafleting"?t.jsx(v3,{selectedAreas:v.selectedAreas,selectedLeafletSize:v.selectedAdSize,selectedDuration:v.selectedDuration,selectedMonths:v.selectedMonths,pricingBreakdown:v.pricingBreakdown,advertisingContent:x,onContentSave:g,discount:v.discount,onDiscountChange:E=>N(z=>({...z,discount:E}))}):t.jsx(g3,{pricingModel:b,selectedAreas:v.selectedAreas,bogofPaidAreas:v.bogofPaidAreas,bogofFreeAreas:v.bogofFreeAreas,selectedAdSize:v.selectedAdSize,selectedDuration:v.selectedDuration,pricingBreakdown:v.pricingBreakdown,selectedPaymentOption:v.selectedPaymentOption,onPaymentOptionChange:E=>N(z=>({...z,selectedPaymentOption:E})),selectedStartingIssue:v.selectedStartingIssue,onStartingIssueChange:E=>N(z=>({...z,selectedStartingIssue:E})),needsDesign:v.needsDesign,designFee:v.designFee,advertisingContent:x,onContentSave:g,discount:v.discount,onDiscountChange:E=>N(z=>({...z,discount:E}))}),t.jsx(b3,{pricingModel:b,selectedAreas:v.selectedAreas,bogofPaidAreas:v.bogofPaidAreas,bogofFreeAreas:v.bogofFreeAreas,selectedAdSize:v.selectedAdSize,selectedDuration:v.selectedDuration,pricingBreakdown:v.pricingBreakdown,campaignData:v,onSaveQuote:C,onBookNow:L,currentStep:5})]})]})]}):t.jsx("div",{className:"relative",children:t.jsxs(d3,{stepLabels:D,onStepChange:_,children:[t.jsx(m3,{onSelectOption:P,advertisingContent:x,onContentSave:g}),t.jsx(h3,{pricingModel:b,selectedAreas:v.selectedAreas,bogofPaidAreas:v.bogofPaidAreas,bogofFreeAreas:v.bogofFreeAreas,selectedDuration:v.selectedDuration,selectedMonths:v.selectedMonths,onAreasChange:E=>N(z=>({...z,selectedAreas:E})),onBogofAreasChange:(E,z)=>N(Z=>({...Z,bogofPaidAreas:E,bogofFreeAreas:z})),onDurationChange:E=>N(z=>({...z,selectedDuration:E})),onMonthsChange:E=>N(z=>({...z,selectedMonths:E})),onPricingChange:E=>N(z=>({...z,...E})),onNext:()=>{},campaignData:{selectedModel:b,selectedAreas:v.selectedAreas,bogofPaidAreas:v.bogofPaidAreas,bogofFreeAreas:v.bogofFreeAreas,selectedSize:v.selectedAdSize,selectedDuration:v.selectedDuration,totalCost:(U=v.pricingBreakdown)==null?void 0:U.finalTotal,pricingBreakdown:v.pricingBreakdown},currentStep:j,advertisingContent:x,onContentSave:g}),b==="leafleting"?t.jsx(j3,{selectedLeafletSize:v.selectedAdSize,onLeafletSizeChange:E=>N(z=>({...z,selectedAdSize:E})),onNext:()=>{}}):t.jsxs(t.Fragment,{children:[t.jsx(f3,{selectedAdSize:v.selectedAdSize,onAdSizeChange:E=>N(z=>({...z,selectedAdSize:E})),pricingModel:b,selectedAreas:v.selectedAreas,bogofPaidAreas:v.bogofPaidAreas,bogofFreeAreas:v.bogofFreeAreas,selectedDuration:v.selectedDuration,onPricingChange:E=>{console.log("AdvertisingStepForm - Pricing breakdown received:",E),N(z=>({...z,pricingBreakdown:E}))},showSummary:!0,onNext:()=>{},campaignData:{selectedModel:b,selectedAreas:v.selectedAreas,bogofPaidAreas:v.bogofPaidAreas,bogofFreeAreas:v.bogofFreeAreas,selectedSize:v.selectedAdSize,selectedDuration:v.selectedDuration,totalCost:(G=v.pricingBreakdown)==null?void 0:G.finalTotal,pricingBreakdown:v.pricingBreakdown},currentStep:j,selectedMonths:v.selectedMonths}),t.jsx(p3,{needsDesign:v.needsDesign,onDesignChoiceChange:E=>N(z=>({...z,needsDesign:E})),designFee:v.designFee,pricingModel:b,advertisingContent:x,onContentSave:g})]}),b==="leafleting"?t.jsx(v3,{selectedAreas:v.selectedAreas,selectedLeafletSize:v.selectedAdSize,selectedDuration:v.selectedDuration,selectedMonths:v.selectedMonths,pricingBreakdown:v.pricingBreakdown,advertisingContent:x,onContentSave:g,discount:v.discount,onDiscountChange:E=>N(z=>({...z,discount:E}))}):b==="fixed"?t.jsx(jte,{selectedAreas:v.selectedAreas,selectedAdSize:v.selectedAdSize,selectedDuration:v.selectedDuration,selectedMonths:v.selectedMonths,pricingBreakdown:v.pricingBreakdown,advertisingContent:x,onContentSave:g,discount:v.discount,onDiscountChange:E=>N(z=>({...z,discount:E}))}):t.jsx(g3,{pricingModel:b,selectedAreas:v.selectedAreas,bogofPaidAreas:v.bogofPaidAreas,bogofFreeAreas:v.bogofFreeAreas,selectedAdSize:v.selectedAdSize,selectedDuration:v.selectedDuration,pricingBreakdown:v.pricingBreakdown,selectedPaymentOption:v.selectedPaymentOption,onPaymentOptionChange:E=>N(z=>({...z,selectedPaymentOption:E})),selectedStartingIssue:v.selectedStartingIssue,onStartingIssueChange:E=>N(z=>({...z,selectedStartingIssue:E})),needsDesign:v.needsDesign,designFee:v.designFee,advertisingContent:x,onContentSave:g,discount:v.discount,onDiscountChange:E=>N(z=>({...z,discount:E}))}),t.jsx(b3,{pricingModel:b,selectedAreas:v.selectedAreas,bogofPaidAreas:v.bogofPaidAreas,bogofFreeAreas:v.bogofFreeAreas,selectedAdSize:v.selectedAdSize,selectedDuration:v.selectedDuration,pricingBreakdown:v.pricingBreakdown,campaignData:v,onSaveQuote:C,onBookNow:L,currentStep:5})]})}),t.jsx(bt,{open:$,onOpenChange:R,children:t.jsxs(xt,{className:"max-w-[95vw] sm:max-w-2xl max-h-[95vh] overflow-y-auto p-4 sm:p-6",children:[t.jsxs(jt,{className:"space-y-4 sm:sp
755ace-y-5",children:[t.jsx(wt,{className:"text-lg sm:text-2xl font-bold text-center leading-tight",children:"Are you sure you want to book Fixed Term?"}),t.jsxs(ys,{className:"text-center space-y-4 sm:space-y-5",children:[t.jsx("p",{className:"text-sm sm:text-lg font-semibold leading-relaxed text-foreground",children:"3+ Subscription Package is available to New Advertisers â Save £££, Buy One Get One Free"}),t.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 rounded-lg p-4 space-y-2",children:[t.jsx("p",{className:"text-sm sm:text-base text-foreground/80",children:"If you booked this campaign on our 3+ Subscription Package you would pay"}),t.jsx("p",{className:"text-xl sm:text-2xl font-bold text-green-600 dark:text-green-500",children:(()=>{const E=o==null?void 0:o.find(F=>F.duration_value===6);if(!E||!v.selectedAdSize||!v.selectedAreas.length||!l||!c||!d)return"£207";const z=Kh(v.selectedAreas,v.selectedAdSize,E.id,!0,l,c,i||[],o||[],d,v.selectedAreas,0);if(!z)return"£207";const Z=Math.round(z.finalTotal/6),M=Math.round(Z*1.2);return`£${Z} + VAT (£${M})`})()}),t.jsx("p",{className:"text-xs sm:text-sm text-foreground/70 font-medium",children:"per month for six months INCLUDING"})]})]})]}),t.jsx("div",{className:"space-y-3 my-5 sm:my-6",children:t.jsxs("ul",{className:"space-y-3 sm:space-y-3.5",children:[t.jsxs("li",{className:"flex items-start gap-3",children:[t.jsx(As,{className:"h-5 w-5 sm:h-5 sm:w-5 text-green-600 dark:text-green-500 mt-0.5 flex-shrink-0"}),t.jsxs("span",{className:"text-sm sm:text-base leading-relaxed",children:[t.jsx("strong",{children:"BUY ONE AREA GET ONE FREE - FOR 3 ISSUES"})," â double the number of homes you reach!"]})]}),t.jsxs("li",{className:"flex items-start gap-3",children:[t.jsx(As,{className:"h-5 w-5 sm:h-5 sm:w-5 text-green-600 dark:text-green-500 mt-0.5 flex-shrink-0"}),t.jsx("span",{className:"text-sm sm:text-base font-semibold",children:"FREE EDITORIAL"})]}),t.jsxs("li",{className:"flex items-start gap-3",children:[t.jsx(As,{className:"h-5 w-5 sm:h-5 sm:w-5 text-green-600 dark:text-green-500 mt-0.5 flex-shrink-0"}),t.jsx("span",{className:"text-sm sm:text-base font-semibold leading-relaxed",children:"FREE PREMIUM POSITION UPGRADE (only available on full page)"})]}),t.jsxs("li",{className:"flex items-start gap-3",children:[t.jsx(As,{className:"h-5 w-5 sm:h-5 sm:w-5 text-green-600 dark:text-green-500 mt-0.5 flex-shrink-0"}),t.jsx("span",{className:"text-sm sm:text-base font-semibold",children:"FREE ADVERT DESIGN"})]})]})}),t.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[t.jsx(q,{variant:"default",onClick:B,className:"bg-green-600 hover:bg-green-700 text-white w-full h-12 text-base font-semibold",children:"YES, CONTINUE"}),t.jsx(q,{variant:"outline",onClick:Y,className:"border-2 border-blue-500 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-950 w-full h-12 text-base font-medium",children:"No, continue with fixed term"})]})]})})]})};var FD=["PageUp","PageDown"],LD=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],BD={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Gu="Slider",[Qj,Ote,Ite]=pl(Gu),[zD,Sfe]=hr(Gu,[Ite]),[Fte,Gv]=zD(Gu),UD=u.forwardRef((e,s)=>{const{name:r,min:n=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:c=0,defaultValue:d=[n],value:m,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:p=!1,form:x,...g}=e,b=u.useRef(new Set),w=u.useRef(0),y=o==="horizontal"?Lte:Bte,[v=[],N]=wr({prop:m,defaultProp:d,onChange:T=>{var B;(B=[...b.current][w.current])==null||B.focus(),h(T)}}),S=u.useRef(v);function k(T){const P=Hte(v,T);A(T,P)}function $(T){A(T,w.current)}function R(){const T=S.current[w.current];v[w.current]!==T&&f(v)}function A(T,P,{commit:B}={commit:!1}){const Y=Kte(i),I=Qte(Math.round((T-n)/i)*i+n,Y),C=Rh(I,[n,a]);N((L=[])=>{const D=Vte(L,C,P);if(Yte(D,c*i)){w.current=D.indexOf(C);const _=String(D)!==String(L);return _&&B&&f(D),_?D:L}else return L})}return t.jsx(Fte,{scope:e.__scopeSlider,name:r,disabled:l,min:n,max:a,valueIndexToChangeRef:w,thumbs:b.current,values:v,orientation:o,form:x,children:t.jsx(Qj.Provider,{scope:e.__scopeSlider,children:t.jsx(Qj.Slot,{scope:e.__scopeSlider,children:t.jsx(y,{"aria-disabled":l,"data-disabled":l?"":void 0,...g,ref:s,onPointerDown:Se(g.onPointerDown,()=>{l||(S.current=v)}),min:n,max:a,inverted:p,onSlideStart:l?void 0:k,onSlideMove:l?void 0:$,onSlideEnd:l?void 0:R,onHomeKeyDown:()=>!l&&A(n,0,{commit:!0}),onEndKeyDown:()=>!l&&A(a,v.length-1,{commit:!0}),onStepKeyDown:({event:T,direction:P})=>{if(!l){const I=FD.includes(T.key)||T.shiftKey&&LD.includes(T.key)?10:1,C=w.current,L=v[C],D=i*I*P;A(L+D,C,{commit:!0})}}})})})})});UD.displayName=Gu;var[VD,qD]=zD(Gu,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Lte=u.forwardRef((e,s)=>{const{min:r,max:n,dir:a,inverted:i,onSlideStart:o,onSlideMove:l,onSlideEnd:c,onStepKeyDown:d,...m}=e,[h,f]=u.useState(null),p=at(s,y=>f(y)),x=u.useRef(),g=to(a),b=g==="ltr",w=b&&!i||!b&&i;
755function j(y){const v=x.current||h.getBoundingClientRect(),N=[0,v.width],k=_N(N,w?[r,n]:[n,r]);return x.current=v,k(y-v.left)}return t.jsx(VD,{scope:e.__scopeSlider,startEdge:w?"left":"right",endEdge:w?"right":"left",direction:w?1:-1,size:"width",children:t.jsx(HD,{dir:g,"data-orientation":"horizontal",...m,ref:p,style:{...m.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:y=>{const v=j(y.clientX);o==null||o(v)},onSlideMove:y=>{const v=j(y.clientX);l==null||l(v)},onSlideEnd:()=>{x.current=void 0,c==null||c()},onStepKeyDown:y=>{const N=BD[w?"from-left":"from-right"].includes(y.key);d==null||d({event:y,direction:N?-1:1})}})})}),Bte=u.forwardRef((e,s)=>{const{min:r,max:n,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:l,onStepKeyDown:c,...d}=e,m=u.useRef(null),h=at(s,m),f=u.useRef(),p=!a;function x(g){const b=f.current||m.current.getBoundingClientRect(),w=[0,b.height],y=_N(w,p?[n,r]:[r,n]);return f.current=b,y(g-b.top)}return t.jsx(VD,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:t.jsx(HD,{"data-orientation":"vertical",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:g=>{const b=x(g.clientY);i==null||i(b)},onSlideMove:g=>{const b=x(g.clientY);o==null||o(b)},onSlideEnd:()=>{f.current=void 0,l==null||l()},onStepKeyDown:g=>{const w=BD[p?"from-bottom":"from-top"].includes(g.key);c==null||c({event:g,direction:w?-1:1})}})})}),HD=u.forwardRef((e,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:c,...d}=e,m=Gv(Gu,r);return t.jsx(ze.span,{...d,ref:s,onKeyDown:Se(e.onKeyDown,h=>{h.key==="Home"?(o(h),h.preventDefault()):h.key==="End"?(l(h),h.preventDefault()):FD.concat(LD).includes(h.key)&&(c(h),h.preventDefault())}),onPointerDown:Se(e.onPointerDown,h=>{const f=h.target;f.setPointerCapture(h.pointerId),h.preventDefault(),m.thumbs.has(f)?f.focus():n(h)}),onPointerMove:Se(e.onPointerMove,h=>{h.target.hasPointerCapture(h.pointerId)&&a(h)}),onPointerUp:Se(e.onPointerUp,h=>{const f=h.target;f.hasPointerCapture(h.pointerId)&&(f.releasePointerCapture(h.pointerId),i(h))})})}),WD="SliderTrack",GD=u.forwardRef((e,s)=>{const{__scopeSlider:r,...n}=e,a=Gv(WD,r);return t.jsx(ze.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});GD.displayName=WD;var Xj="SliderRange",YD=u.forwardRef((e,s)=>{const{__scopeSlider:r,...n}=e,a=Gv(Xj,r),i=qD(Xj,r),o=u.useRef(null),l=at(s,o),c=a.values.length,d=a.values.map(f=>QD(f,a.min,a.max)),m=c>1?Math.min(...d):0,h=100-Math.max(...d);return t.jsx(ze.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:l,style:{...e.style,[i.startEdge]:m+"%",[i.endEdge]:h+"%"}})});YD.displayName=Xj;var Zj="SliderThumb",KD=u.forwardRef((e,s)=>{const r=Ote(e.__scopeSlider),[n,a]=u.useState(null),i=at(s,l=>a(l)),o=u.useMemo(()=>n?r().findIndex(l=>l.ref.current===n):-1,[r,n]);return t.jsx(zte,{...e,ref:i,index:o})}),zte=u.forwardRef((e,s)=>{const{__scopeSlider:r,index:n,name:a,...i}=e,o=Gv(Zj,r),l=qD(Zj,r),[c,d]=u.useState(null),m=at(s,j=>d(j)),h=c?o.form||!!c.closest("form"):!0,f=kf(c),p=o.values[n],x=p===void 0?0:QD(p,o.min,o.max),g=qte(n,o.values.length),b=f==null?void 0:f[l.size],w=b?Wte(b,x,l.direction):0;return u.useEffect(()=>{if(c)return o.thumbs.add(c),()=>{o.thumbs.delete(c)}},[c,o.thumbs]),t.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[l.startEdge]:`calc(${x}% + ${w}px)`},children:[t.jsx(Qj.ItemSlot,{scope:e.__scopeSlider,children:t.jsx(ze.span,{role:"slider","aria-label":e["aria-label"]||g,"aria-valuemin":o.min,"aria-valuenow":p,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:m,style:p===void 0?{display:"none"}:e.style,onFocus:Se(e.onFocus,()=>{o.valueIndexToChangeRef.current=n})})}),h&&t.jsx(Ute,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:p},n)]})});KD.displayName=Zj;var Ute=e=>{const{value:s,...r}=e,n=u.useRef(null),a=Mu(s);return u.useEffect(()=>{const i=n.current,o=window.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(o,"value").set;if(a!==s&&c){const d=new Event("input",{bubbles:!0});c.call(i,s),i.dispatchEvent(d)}},[a,s]),t.jsx("input",{style:{display:"none"},...r,ref:n,defaultValue:s})};function Vte(e=[],s,r){const n=[...e];return n[r]=s,n.sort((a,i)=>a-i)}function QD(e,s,r){const i=100/(r-s)*(e-s);return Rh(i,[0,100])}function qte(e,s){return s>2?`Value ${e+1} of ${s}`:s===2?["Minimum","Maximum"][e]:void 0}function Hte(e,s){if(e.length===1)return 0;const r=e.map(a=>Math.abs(a-s)),n=Math.min(...r);return r.indexOf(n)}function Wte(e,s,r){const n=e/2,i=_N([0,50],[0,n]);return(n-i(s)*r)*r}function Gte(e){return e.slice(0,-1).map((s,r)=>e[r+1]-s)}function Yte(e,s){if(s>0){const r=Gte(e);return Math.min(...r)>=s}return!0}function _N(e,s){return r=>{if(e[0]===e[1]||s[0]===s[1])return s[0];const n=(s[1]-s[0])/(e[1]-e[0]);return s[0]+n*(r-e[0])}}function Kte(e){return(String(e).split(".")[1]||"").length}function Qte(e,s){const r=Math.pow(10,s);return Math.round(e*r)/r}var XD=UD,Xte=GD,Zte=YD,Jte=KD;const ese=fa("relative flex w-full touch-none select-none items-center",{variants:{variant:{default:"",brand:""}},defaultVariants:{variant:"default"}}),tse=fa("relative h-2 w-full grow overflow-hidden rounded-full",{variants:{variant:{default:"bg-secondary",brand:"bg-emerald-100"}},defaultVariants:{variant:"default"}}),sse=fa("absolute h-full",{variants:{variant:{default:"bg-primary",brand:"bg-community-green"}},defaultVariants:{variant:"default"}}),rse=fa("block h-5 w-5 rounded-full border-2 bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"border-primary",brand:"border-community-green hover:border-community-navy shadow-lg"}},defaultVariants:{variant:"default"}}),Vl=u.forwardRef(({className:e,variant:s,...r},n)=>t.jsxs(XD,{ref:n,className:oe(ese({variant:s}),e),...r,children:[t.jsx(Xte,{className:oe(tse({variant:s})),children:t.jsx(Zte,{className:oe(sse({variant:s}))})}),t.jsx(Jte,{className:oe(rse({variant:s}))})]}));Vl.displayName=XD.displayName;const nse=[wf,_t,bn,xs,tu,ui],ase=[dE,Wi,zr,jh],ise=({content:e,updateField:s,updateFeature:r})=>{const n=e||wN;return t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-community-navy via-slate-800 to-community-navy p-8 md:p-10 text-center",children:[t.jsx("div",{className:"absolute top-0 left-1/4 w-64 h-64 bg-community-green/10 rounded-full blur-3xl"}),t.jsx("div",{className:"absolute bottom-0 right-1/4 w-48 h-48 bg-community-green/10 rounded-full blur-3xl"}),t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"inline-flex items-center justify-center p-3 bg-community-green/20 rounded-full mb-4",children:t.jsx(Hx,{className:"h-8 w-8 text-community-green"})}),t.jsx(Be,{value:n.roiSection.mainHeading,onSave:a=>s("roiSection.mainHeading",a),as:"h2",className:"text-2xl md:text-3xl lg:text-4xl font-bold text-white mb-4"}),t.jsxs("p",{className:"text-2xl md:text-3xl lg:text-4xl font-black text-community-green leading-tight",children:[t.jsx(Be,{value:n.roiSection.subHeading1,onSave:a=>s("roiSection.subHeading1",a),as:"span",className:"block"}),t.jsx(Be,{value:n.roiSection.subHeading2,onSave:a=>s("roiSection.subHeading2",a),as:"span",className:"block"})]}),t.jsx(Be,{value:n.roiSection.description,onSave:a=>s("roiSection.description",a),as:"p",multiline:!0,className:"text-slate-300 text-lg mt-4 max-w-3xl mx-auto"})]})]}),t.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[t.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-slate-50 to-white border-2 border-slate-200 shadow-xl",children:[t.jsx("div",{className:"h-2 bg-gradient-to-r from-community-green to-emerald-400"}),t.jsxs("div",{className:"p-6 md:p-8",children:[t.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[t.jsx("div",{className:"p-3 rounded-xl bg-community-green shadow-lg shadow-community-green/20",children:t.jsx(Dc,{className:"h-7 w-7 text-white"})}),t.jsxs("div",{children:[t.jsx(Be,{value:n.productSection.title,onSave:a=>s("productSection.title",a),as:"h3",className:"text-2xl font-black text-community-navy"}),t.jsx(Be,{value:n.productSection.subtitle,onSave:a=>s("productSection.subtitle",a),as:"p",className:"text-sm text-muted-foreground"})]})]}),t.jsx("ul",{className:"space-y-4",children:n.productSection.features.map((a,i)=>{const o=nse[i]||wf;return t.jsxs("li",{className:"flex gap-4 p-3 rounded-lg bg-white border border-slate-100 hover:border-community-green/30 hover:shadow-md transition-all duration-200",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"p-2 rounded-lg bg-community-green/10",children:t.jsx(o,{className:"h-5 w-5 text-community-green"})})}),t.jsxs("div",{children:[t.jsx(Be,{value:a.title,onSave:l=>r("productSection",i,"title",l),as:"span",className:"font-bold text-community-navy block"}),t.jsx(Be,{value:a.description,onSave:l=>r("productSection",i,"description",l),as:"span",className:"text-muted-foreground text-sm"})]})]},i)})})]})]}),t.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-community-navy via-slate-800 to-community-navy shadow-xl",children:[t.jsx("div",{className:"h-2 bg-gradient-to-r from-community-green to-emerald-400"}),t.jsxs("div",{className:"p-6 md:p-8",children:[t.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[t.jsx("div",{className:"p-3 rounded-xl bg-community-green shadow-lg shadow-community-green/20",children:t.jsx(bn,{className:"h-7 w-7 text-white"})}),t.jsxs("div",{children:[t.jsx(Be,{value:n.advertiserSection.title,onSave:a=>s("advertiserSection.title",a),as:"h3",className:"text-2xl font-black text-white"}),t.jsx(Be,{value:n.advertiserSection.subtitle,onSave:a=>s("advertiserSection.subtitle",a),as:"p",className:"text-sm text-slate-400"})]})]}),t.jsx("ul",{className:"space-y-4",children:n.advertiserSection.features.map((a,i)=>{const o=ase[i]||dE;return t.jsxs("li",{className:"flex gap-4 p-3 rounded-lg bg-white/5 border border-white/10 hover:border-community-green/30 hover:bg-white/10 transition-all duration-200",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("div",{className:"p-2 rounded-lg bg-community-green/20",children:t.jsx(o,{className:"h-5 w-5 text-community-green"})})}),t.jsxs("div",{children:[t.jsx(Be,{value:a.title,onSave:l=>r("advertiserSection",i,"title",l),as:"span",className:"font-bold text-white block"}),t.jsx(Be,{value:a.description,onSave:l=>r("advertiserSection",i,"description",l),as:"span",className:"text-slate-400 text-sm"})]})]},i)})}),t.jsx("div",{className:"mt-6 p-4 rounded-xl bg-community-green/20 border border-community-green/30",children:t.jsx(Be,{value:n.advertiserSection.footerText,onSave:a=>s("advertiserSection.footerText",a),as:"p",className:"text-white text-sm text-center"})})]})]})]})]})},ose=({content:e,updateField:s,updateBogofBenefit:r})=>{const n=e||wN,a=[{paid:1,free:1},{paid:3,free:3},{paid:5,free:5},{paid:7,free:7}];return t.jsxs("div",{className:"relative overflow-hidden rounded-2xl",children:[t.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-community-navy via-slate-900 to-black"}),t.jsx("div",{className:"absolute top-0 left-0 w-96 h-96 bg-community-green/20 rounded-full blur-[100px] -translate-x-1/2 -translate-y-1/2"}),t.jsx("div",{className:"absolute bottom-0 right-0 w-80 h-80 bg-pink-500/20 rounded-full blur-[80px] translate-x-1/3 translate-y-1/3"}),t.jsx("div",{className:"absolute top-1/2 left-1/2 w-64 h-64 bg-community-green/10 rounded-full blur-[60px] -translate-x-1/2 -translate-y-1/2"}),t.jsxs("div",{className:"relative p-8 md:p-12 lg:p-16",children:[t.jsx("div",{className:"flex justify-center mb-6",children:t.jsxs(we,{className:"px-6 py-2 text-base font-bold bg-gradient-to-r from-yellow-400 to-amber-500 text-black border-0 shadow-lg shadow-yellow-500/30 animate-pulse-subtle",children:[t.jsx(mr,{className:"h-4 w-4 mr-2 fill-current"}),t.jsx(Be,{value:n.bogofPromo.badge,onSave:i=>s("bogofPromo.badge",i),as:"span"}),t.jsx(mr,{className:"h-4 w-4 ml-2 fill-current"})]})}),t.jsxs("div",{className:"text-center mb-10",children:[t.jsx("h2",{className:"text-4xl md:text-5xl lg:text-6xl font-black text-white mb-4 tracking-tight",children:t.jsx(Be,{value:n.bogofPromo.headline,onSave:i=>s("bogofPromo.headline",i),as:"span",className:"text-transparent bg-clip-text bg-gradient-to-r from-community-green to-emerald-400"})}),t.jsx(Be,{value:n.bogofPromo.offerDescription,onSave:i=>s("bogofPromo.offerDescription",i),as:"p",className:"text-xl md:text-2xl text-slate-300 max-w-2xl mx-auto"})]}),t.jsx("div",{className:"flex flex-wrap justify-center gap-4 md:gap-6 mb-10",children:a.map((i,o)=>t.jsxs("div",{className:"group relative",children:[t.jsx("div",{className:"absolute -inset-1 bg-gradient-to-r from-community-green to-pink-500 rounded-2xl blur opacity-40 group-hover:opacity-75 transition-opacity duration-300"}),t.jsxs("div",{className:"relative flex items-center gap-2 md:gap-3 bg-gradient-to-br from-slate-800 to-slate-900 rounded-xl p-4 md:p-6 border border-white/10",children:[t.jsx("span",{className:"text-4xl md:text-5xl lg:text-6xl font-black text-white",children:i.paid}),t.jsx("span",{className:"text-3xl md:text-4xl lg:text-5xl font-bold text-community-green",children:"+"}),t.jsx("span",{className:"text-4xl md:text-5xl lg:text-6xl font-black text-transparent bg-clip-text bg-gradient-to-r from-pink-400 to-pink-500",children:i.free}),t.jsx("div",{className:"absolute -top-2 -right-2 px-2 py-0.5 bg-pink-500 text-white text-xs font-bold rounded-full shadow-lg",children:"FREE"})]})]},o))}),t.jsxs("div",{className:"max-w-3xl mx-auto",children:[t.jsxs("div",{className:"flex items-center justify-center gap-3 mb-6",children:[t.jsx(yr,{className:"h-6 w-6 text-community-green"}),t.jsx(Be,{value:n.bogofPromo.packageHeading,onSave:i=>s("bogofPromo.packageHeading",i),as:"h3",className:"text-xl md:text-2xl font-bold text-white"})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:n.bogofPromo.benefits.map((i,o)=>t.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-white/5 border border-white/10 hover:bg-white/10 transition-colors",children:[t.jsx(xs,{className:"h-5 w-5 text-community-green flex-shrink-0 mt-0.5"}),t.jsx(Be,{value:i,onSave:l=>r(o,l),as:"span",className:"text-slate-300 text-sm"})]},o))})]}),t.jsx("div",{className:"flex justify-center mt-8",children:t.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[t.jsx(ui,{className:"h-4 w-4"}),t.jsx(Be,{value:n.bogofPromo.footerTagline,onSave:i=>s("bogofPromo.footerTagline",i),as:"span",className:"text-sm"}),t.jsx(ui,{className:"h-4 w-4"})]})})]})]})}
755,pm=[{label:"1/8",name:"1/8 Page"},{label:"1/6",name:"1/6 Page"},{label:"1/4",name:"1/4 Page"},{label:"1/3",name:"1/3 Page"},{label:"1/2",name:"1/2 Page Landscape"},{label:"2/3",name:"2/3 Page"},{label:"Full",name:"Full Page"}],lse={"1/8 Page":{1:27,2:51,3:73,4:95,5:116,6:136,7:155},"1/6 Page":{1:37,2:69,3:99,4:128,5:156,6:183,7:209},"1/4 Page":{1:48,2:90,3:129,4:167,5:204,6:239,7:273},"1/3 Page":{1:64,2:125,3:185,4:244,5:301,6:356,7:408},"1/2 Page Landscape":{1:77,2:144,3:207,4:268,5:327,6:384,7:438},"2/3 Page":{1:96,2:182,3:266,4:347,5:426,6:502,7:574},"Full Page":{1:127,2:238,3:342,4:442,5:540,6:634,7:724}},cse=[14700,9200,9800,11600,13500,8e3,8600,10400,12200,11e3,9200,9800,7400,6600],dse=()=>{const[e,s]=u.useState(2),[r,n]=u.useState(3),[a,i]=u.useState(1e3),[o,l]=u.useState(.05),{areas:c,adSizes:d,subscriptionDurations:m,isLoading:h,isError:f}=ji(),{content:p,updateField:x,updateFeature:g,updateBogofBenefit:b}=NN(),w=u.useMemo(()=>{if(!(d!=null&&d.length))return null;const k=pm[e].name;return d.find($=>$.name===k)||null},[d,e]),j=u.useMemo(()=>Math.min(r*2,14),[r]),y=u.useMemo(()=>c!=null&&c.length?[...c].slice(0,j).reduce(($,R)=>$+R.circulation,0):cse.slice(0,j).reduce((k,$)=>k+$,0),[c,j]),v=u.useMemo(()=>{var $;const k=pm[e].name;if(w!=null&&w.subscription_pricing_per_issue){const R=w.subscription_pricing_per_issue;if(typeof R=="object"){const A=r.toString();if(R[A])return R[A]/2}}return((($=lse[k])==null?void 0:$[r])||180)/2},[w,e,r]),N=u.useMemo(()=>v*6,[v]),S=u.useMemo(()=>{const k=Math.round(y*o/100),$=k*a,R=N>0?($-N)/N*100:0;return{potentialCustomers:k,audience:y,potentialRevenue:$,roi:Math.round(R)}},[y,o,a,N]);return t.jsxs("div",{className:"space-y-8",children:[t.jsx(ise,{content:p,updateField:x,updateFeature:g}),t.jsx(ose,{content:p,updateField:x,updateBogofBenefit:b}),t.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-community-navy via-slate-800 to-community-navy p-1",children:[t.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-community-green/10 rounded-full blur-3xl -translate-y-1/2 translate-x-1/2"}),t.jsx("div",{className:"absolute bottom-0 left-0 w-48 h-48 bg-community-green/10 rounded-full blur-3xl translate-y-1/2 -translate-x-1/2"}),t.jsxs("div",{className:"relative bg-background rounded-xl overflow-hidden",children:[t.jsxs(xe,{id:"rate-card-calculator",className:"w-full border-0 shadow-none scroll-mt-20",children:[t.jsxs(Me,{className:"bg-gradient-to-r from-community-navy to-slate-800 border-b-4 border-community-green",children:[t.jsxs(Oe,{className:"flex items-center gap-3 text-2xl text-white",children:[t.jsx("div",{className:"p-2 bg-community-green rounded-lg",children:t.jsx(sc,{className:"h-6 w-6 text-white"})}),"Interactive Rate Card Calculator"]}),t.jsx("p",{className:"text-slate-300 mt-2",children:"Explore pricing options using our slider controls below"})]}),t.jsxs(ge,{className:"p-6 md:p-8 space-y-8",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"text-lg font-semibold text-community-navy",children:"Ad Size"}),t.jsxs(we,{className:"text-lg px-4 py-1.5 bg-community-navy text-white border-0 shadow-md",children:[pm[e].label," Page"]})]}),t.jsx(Vl,{value:[e],onValueChange:k=>s(k[0]),min:0,max:pm.length-1,step:1,variant:"brand",className:"w-full"}),t.jsx("div",{className:"flex justify-between text-xs text-muted-foreground px-1",children:pm.map((k,$)=>t.jsx("span",{className:$===e?"font-bold text-community-green":"",children:k.label},k.label))})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"text-lg font-semibold text-community-navy",children:"Number of Areas"}),t.jsxs(we,{className:"text-lg px-4 py-1.5 bg-community-navy text-white border-0 shadow-md",children:[r," ",r===1?"Area":"Areas"]})]}),t.jsx(Vl,{value:[r],onValueChange:k=>n(k[0]),min:1,max:7,step:1,variant:"brand",className:"w-full"}),t.jsx("div",{className:"flex justify-between text-xs text-muted-foreground px-1",children:[1,2,3,4,5,6,7].map(k=>t.jsx("span",{className:k===r?"font-bold text-community-green":"",children:k},k))})]}),t.jsxs("div",{className:"relative overflow-hidden rounded-xl bg-gradient-to-r from-community-green via-emerald-500 to-community-green p-[2px] animate-pulse-subtle",children:[t.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent animate-shimmer"}),t.jsx("div",{className:"relative bg-gradient-to-r from-emerald-50 to-green-50 rounded-[10px] p-4 md:p-5",children:t.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-3 md:gap-4 text-center md:text-left",children:[t.jsxs("div",{className:"relative flex-shrink-0",children:[t.jsx("div",{className:"absolute inset-0 bg-community-green/30 rounded-full animate-ping"}),t.jsx("div",{className:"relative p-3 bg-community-green rounded-full",children:t.jsx(yr,{className:"h-6 w-6 md:h-7 md:w-7 text-white"})})]}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-center md:justify-start gap-1.5 md:gap-2 mb-1",children:[t.jsx(ui,{className:"h-4 w-4 md:h-5 md:w-5 text-yellow-500"}),t.jsx("p",{className:"font-bold text-community-navy text-base md:text-lg",children:"Double Your Reach - FREE!"}),t.jsx(ui,{className:"h-4 w-4 md:h-5 md:w-5 text-yellow-500"})]}),t.jsxs("p",{className:"text-community-navy text-sm md:text-base",children:["You get"," ",t.jsx("span",{className:"inline-flex items-center justify-center min-w-[2rem] md:min-w-[2.5rem] px-1.5 md:px-2 py-0.5 bg-community-green text-white font-bold text-xl md:text-2xl rounded-lg shadow-lg mx-1",children:j})," ","areas for the price of"," ",t.jsx("span",{className:"font-semibold",children:r}),"!"]})]})]})})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{className:"relative overflow-hidden rounded-xl bg-slate-800 p-6 text-center shadow-xl",children:[t.jsx("div",{className:"absolute top-0 right-0 w-24 h-24 bg-community-green/20 rounded-full blur-2xl"}),t.jsxs("div",{className:"relative",children:[t.jsxs("div",{className:"flex items-center justify-center gap-2 mb-3",children:[t.jsx(gl,{className:"h-5 w-5 text-community-green"}),t.jsx("span",{className:"text-sm font-medium text-slate-300 uppercase tracking-wide",children:"Approx Homes Reached"})]}),t.jsx("p",{className:"text-5xl font-bold text-white",children:(Math.round(y/1e3)*1e3).toLocaleStr
755ing()}),t.jsx("p",{className:"text-sm text-slate-400 mt-2",children:"Bi-monthly"})]})]}),t.jsxs("div",{className:"relative overflow-hidden rounded-xl bg-gradient-to-br from-community-green to-emerald-600 p-6 text-center shadow-xl",children:[t.jsx("div",{className:"absolute top-0 right-0 w-24 h-24 bg-white/10 rounded-full blur-2xl"}),t.jsxs("div",{className:"relative",children:[t.jsxs("div",{className:"flex items-center justify-center gap-2 mb-3",children:[t.jsx(Yx,{className:"h-5 w-5 text-white"}),t.jsx("span",{className:"text-sm font-medium text-white/80 uppercase tracking-wide",children:"Cost per month"})]}),t.jsx("p",{className:"text-5xl font-bold text-white",children:Ip(v)}),t.jsx("p",{className:"text-sm text-white/70 mt-2",children:"+ VAT"})]})]}),t.jsxs("div",{className:"relative overflow-hidden rounded-xl bg-community-navy p-6 text-center shadow-xl",children:[t.jsx("div",{className:"absolute top-0 right-0 w-24 h-24 bg-community-green/20 rounded-full blur-2xl"}),t.jsxs("div",{className:"relative",children:[t.jsxs("div",{className:"flex items-center justify-center gap-2 mb-3",children:[t.jsx(Yx,{className:"h-5 w-5 text-community-green"}),t.jsx("span",{className:"text-sm font-medium text-slate-300 uppercase tracking-wide",children:"6 Month Campaign"})]}),t.jsx("p",{className:"text-5xl font-bold text-white",children:Ip(N)}),t.jsx("p",{className:"text-sm text-slate-400 mt-2",children:"+ VAT (Total)"})]})]})]})]})]}),t.jsxs(xe,{className:"w-full border-0 border-t-4 border-community-navy shadow-none rounded-none",children:[t.jsxs(Me,{className:"bg-gradient-to-r from-slate-100 to-slate-50 border-b",children:[t.jsxs(Oe,{className:"flex items-center gap-3 text-2xl text-community-navy",children:[t.jsx("div",{className:"p-2 bg-community-navy rounded-lg",children:t.jsx(jh,{className:"h-6 w-6 text-community-green"})}),"Calculate Your Potential ROI"]}),t.jsx("p",{className:"text-muted-foreground mt-1",children:"Estimate your return based on your business metrics"})]}),t.jsxs(ge,{className:"p-6 md:p-8 space-y-8",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"text-lg font-semibold text-community-navy",children:"Average Customer Value"}),t.jsx(we,{className:"text-lg px-4 py-1.5 bg-community-navy text-white border-0 shadow-md",children:Ip(a)})]}),t.jsx(Vl,{value:[a],onValueChange:k=>i(k[0]),min:100,max:5e3,step:100,variant:"brand",className:"w-full"}),t.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground px-1",children:[t.jsx("span",{children:"£100"}),t.jsx("span",{children:"£1,700"}),t.jsx("span",{children:"£3,400"}),t.jsx("span",{children:"£5,000+"})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"text-lg font-semibold text-community-navy",children:"Conversion Rate"}),t.jsxs(we,{className:"text-lg px-4 py-1.5 bg-community-navy text-white border-0 shadow-md",children:[o.toFixed(2),"%"]})]}),t.jsx(Vl,{value:[o*100],onValueChange:k=>l(k[0]/100),min:1,max:50,step:1,variant:"brand",className:"w-full"}),t.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground px-1",children:[t.jsxs("span",{className:"text-center",children:["0.01%",t.jsx("br",{}),t.jsx("span",{className:"text-[10px]",children:"Conservative"})]}),t.jsxs("span",{className:"text-center",children:["0.1%",t.jsx("br",{}),t.jsx("span",{className:"text-[10px]",children:"Typical"})]}),t.jsxs("span",{className:"text-center",children:["0.25%",t.jsx("br",{}),t.jsx("span",{className:"text-[10px]",children:"Good"})]}),t.jsxs("span",{className:"text-center",children:["0.5%",t.jsx("br",{}),t.jsx("span",{className:"text-[10px]",children:"Excellent"})]})]}),t.jsx("p",{className:"text-xs text-muted-foreground italic mt-2",children:"Print advertising typically sees 0.02-0.1% conversion to action. Even at conservative rates, the ROI can be significant due to high customer values."})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{className:"relative overflow-hidden rounded-xl bg-slate-800 p-5 text-center shadow-lg",children:[t.jsx("div",{className:"absolute top-0 right-0 w-16 h-16 bg-community-green/20 rounded-full blur-xl"}),t.jsxs("div",{className:"relative",children:[t.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[t.jsx(rv,{className:"h-5 w-5 text-community-green"}),t.jsx("span",{className:"text-sm font-medium text-slate-300",children:"Potential Customers"})]}),t.jsx("p",{className:"text-3xl font-bold text-white",children:S.potentialCustomers.toLocaleStr
755ing()})]})]}),t.jsxs("div",{className:"relative overflow-hidden rounded-xl bg-community-navy p-5 text-center shadow-lg",children:[t.jsx("div",{className:"absolute top-0 right-0 w-16 h-16 bg-community-green/20 rounded-full blur-xl"}),t.jsxs("div",{className:"relative",children:[t.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[t.jsx(ua,{className:"h-5 w-5 text-community-green"}),t.jsx("span",{className:"text-sm font-medium text-slate-300",children:"Audience Reach"})]}),t.jsx("p",{className:"text-3xl font-bold text-white",children:S.audience.toLocaleString()})]})]}),t.jsxs("div",{className:"relative overflow-hidden rounded-xl bg-gradient-to-br from-community-green to-emerald-600 p-5 text-center shadow-xl ring-2 ring-yellow-400/50",children:[t.jsx("div",{className:"absolute top-0 right-0 w-16 h-16 bg-white/20 rounded-full blur-xl"}),t.jsx("div",{className:"absolute -top-1 -right-1",children:t.jsx(ui,{className:"h-6 w-6 text-yellow-400"})}),t.jsxs("div",{className:"relative",children:[t.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[t.jsx(jh,{className:"h-5 w-5 text-white"}),t.jsx("span",{className:"text-sm font-medium text-white/90",children:"Potential Revenue"})]}),t.jsx("p",{className:"text-3xl font-bold text-white",children:Ip(S.potentialRevenue)}),t.jsx("p",{className:"text-sm text-white/80 mt-1",children:"potential revenue"})]})]})]}),t.jsx("p",{className:"text-xs text-muted-foreground text-center italic",children:"* ROI calculations are estimates based on your inputs. Actual results may vary based on your business, offer, and market conditions."})]})]})]})]})]})},use=()=>{var fe,Ee,K,te,Q,ae,me,pe,be,ce;const{toast:e}=rt();ds();const s=Xs();u.useState({name:"",email:"",phone:"",company:"",password:""});const[r,n]=u.useState("fixed"),[a,i]=u.useState("fixed"),[o,l]=u.useState([]),[c,d]=u.useState([]),[m,h]=u.useState([]),[f,p]=u.useState(""),[x,g]=u.useState(""),[b,w]=u.useState(!1),[j,y]=u.useState(!1);u.useState(!1),u.useState(!1);const[v,N]=u.useState({}),[S,k]=u.useState(!1),[$,R]=u.useState(!1),{areas:A,adSizes:T,durations:P,subscriptionDurations:B,volumeDiscounts:Y,isLoading:I,isError:C,refetch:L}=ji(),{data:D,isLoading:_,error:H}=qf(),{data:O,isLoading:U,error:G}=Hf(),{data:E}=Fv(!1,"online_content"),z=[{src:"/lovable-uploads/0ee7cdb0-f6e6-4dd5-9492-8136e247b6ab.png",alt:"Winchester & Surrounds",title:"WINCHESTER & SURROUNDS",link:null},{src:"/lovable-uploads/3734fd45-4163-4f5c-b495-06604192d54c.png",alt:"Itchen Valley",title:"ITCHEN VALLEY",link:null},{src:"/lovable-uploads/c4490b9b-94ad-42c9-a7d4-80ba8a52d3eb.png",alt:"Meon Valley & Whiteley",title:"MEON VALLEY & WHITELEY",link:null},{src:"/lovable-uploads/d554421b-d268-40db-8d87-a66cd858a71a.png",alt:"New Forest & Waterside",title:"NEW FOREST & WATERSIDE",link:null},{src:"/lovable-uploads/92f70bb1-98a7-464d-a511-5eb7eef51998.png",alt:"Southampton West & Totton",title:"SOUTHAMPTON WEST & TOTTON",link:null},{src:"/lovable-uploads/25b8b054-62d4-42b8-858b-d8c91da6dc93.png",alt:"Test Valley & Romsey",title:"TEST VALLEY & ROMSEY",link:null},{src:"/lovable-uploads/f98d0aa9-985f-4d69-85b9-193bf1934a18.png",alt:"Winchester & Alresford",title:"WINCHESTER & ALRESFORD",link:null},{src:"/lovable-uploads/d4b20a63-65ea-4dec-b4b7-f1e1a6748979.png",alt:"Chandler's Ford & Eastleigh",title:"CHANDLER'S FORD & EASTLEIGH",link:null}],Z=E!=null&&E.length?E.map(ie=>({src:ie.image_url,alt:ie.alt_text||`Discover Magazine - ${ie.title} Edition`,title:ie.title,link:ie.link_url})):z,{data:M}=fD(),F=(M==null?void 0:M.agencyDiscountPercent)||0;Wu(),u.useEffect(()=>{console.log("Advertising page mounted - invalidating calculator queries"),s.invalidateQueries({queryKey:["product-packages"]}),s.invalidateQueries({queryKey:["pricing"]})},[s]),u.useCallback((ie,je)=>{l(Re=>je?[...Re,ie]:Re.filter(Ae=>Ae!==ie))},[]),u.useCallback(()=>{r==="fixed"&&o.length>2&&!j&&w(!0)},[r,o.length,j]),u.useCallback(()=>{w(!1),y(!0)},[]),u.useCallback(()=>{w(!1),y(!0),n("bogof"),d(Array.from(new Set([...o]))),o.length>=3?e({title:"Switched to BOGOF",description:"Great choice! Now pick y
755our free areas."}):e({title:"Almost there",description:"Choose 1 more paid area to unlock your free areas."})},[o,e]);const ee=u.useMemo(()=>r==="bogof"?c:o,[r,o,c]),se=u.useMemo(()=>{if(r==="leafleting"){if(!f||!x||ee.length===0)return null;const Re=O==null?void 0:O.find(Ve=>Ve.id===x),Ae=(Re==null?void 0:Re.issues)||1,Ue=(Re==null?void 0:Re.issues)||1;return fN(ee,D||[],Ae,Ue)}return!f||!x||ee.length===0?null:Kh(ee,f,x,r==="subscription"||r==="bogof",A,T,r==="subscription"||r==="bogof"?B:P,B,Y,r==="bogof"?m:[],F)},[ee,f,x,r,A,T,P,B,Y,c,o,D,O,m,F]);ve.useEffect(()=>{try{const ie=r==="leafleting"?O:r==="subscription"||r==="bogof"?B:P;if(ie&&ie.length>0)if(x)ie.some(Re=>Re.id===x)||g("");else{const je=ie.find(Re=>Re.is_default)||ie[0];je&&g(je.id)}i(r)}catch(ie){console.error("Error in duration useEffect:",ie)}},[r,P,B,O]),ve.useEffect(()=>{if(r==="leafleting"&&x&&O){const ie=O.find(Re=>Re.id===x),je=(ie==null?void 0:ie.issues)||1;N(Re=>{const Ae={...Re};let Ue=!1;return Object.keys(Ae).forEach(Ve=>{const lt=Ae[Ve]||[];lt.length>je&&(Ae[Ve]=lt.slice(0,je),Ue=!0)}),Ue?Ae:Re})}},[x,r,O]),u.useEffect(()=>{const ie=window.location.hash;if(ie){const je=document.getElementById(ie.substring(1));je&&setTimeout(()=>{je.scrollIntoView({behavior:"smooth"})},100)}},[]),u.useEffect(()=>{const ie=document.querySelector("[data-contact-section]");if(!ie)return;const je=new IntersectionObserver(Re=>{Re.forEach(Ae=>{Ae.isIntersecting&&!$&&(R(!0),r==="fixed"&&!S&&se&&k(!0))})},{threshold:.5});return je.observe(ie),()=>je.disconnect()},[r,$,S,se]);const le=()=>{k(!1),e({title:"Pay As You Go Confirmed",description:"You can continue with your Pay As You Go booking."})},X=()=>{k(!1),n("subscription"),g(""),e({title:"Switched to Subscription",description:"You're now using our subscription pricing model."})};if(C)return t.jsx("div",{className:"min-h-screen bg-background",children:t.jsx("div",{className:"container mx-auto px-4 py-8",children:t.jsxs(xe,{className:"max-w-md mx-auto",children:[t.jsxs(Me,{children:[t.jsxs(Oe,{className:"text-destructive flex items-center gap-2",children:[t.jsx(Hs,{className:"h-5 w-5"}),"Failed to Load Data"]}),t.jsx(Er,{children:"Unable to load pricing data"})]}),t.jsx(ge,{children:t.jsx(q,{onClick:L,variant:"outline",children:"Try Again"})})]})})});const{content:ye,updateField:Ce,updateStat:ke}=NN();return t.jsx(tte,{children:t.jsxs("div",{id:"top",className:"min-h-screen bg-gray-50",children:[t.jsx(gs,{}),t.jsx(ste,{}),t.jsxs("section",{className:"relative bg-community-navy overflow-hidden min-h-[85vh] flex items-center",children:[t.jsx("video",{autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 w-full h-full object-cover object-center",children:t.jsx("source",{src:ye.hero.videoUrl,type:"video/mp4"})}),t.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-community-navy/95 via-community-navy/80 to-community-navy/60"}),t.jsx("div",{className:"absolute top-1/2 left-1/4 w-[600px] h-[600px] bg-community-green/10 rounded-full blur-[120px] -translate-x-1/2 -translate-y-1/2"}),t.jsx("div",{className:"absolute bottom-0 right-0 w-[400px] h-[400px] bg-community-green/5 rounded-full blur-[80px]"}),t.jsx("div",{className:"relative w-full max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-20 lg:py-28",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center",children:[t.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 bg-white/10 backdrop-blur-sm rounded-full border border-white/20 mb-8",children:[t.jsx("div",{className:"w-2 h-2 bg-community-green rounded-full animate-pulse"}),t.jsx(Be,{value:ye.hero.trustBadge,onSave:ie=>Ce("hero.trustBadge",ie),as:"span",className:"text-sm text-white/90 font-medium"})]}),t.jsxs("div",{className:"space-y-4 mb-8",children:[t.jsx(Be,{value:ye.hero.headline,onSave:ie=>Ce("hero.headline",ie),as:"h1",className:"text-4xl md:text-5xl lg:text-6xl font-heading font-bold text-white leading-tight"}),t.jsx(Be,{value:ye.hero.subheadline,onSave:ie=>Ce("hero.subheadline",ie),as:"p",multiline:!0,className:"text-xl md:text-2xl text-white/80 leading-relaxed max-w-2xl mx-auto"})]})]})}),t.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-48 bg-gradient-to-t from-stone-50 to-transparent"})]}),t.jsx("section",{className:"relative -mt-20 z-10 px-4 sm:px-6 lg:px-8 pb-8",children:t.jsx("div",{className:"max-w-6xl mx-auto",children:t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 ga
755p-4",children:[t.jsxs("div",{className:"col-span-2 md:col-span-1 bg-white rounded-2xl shadow-xl p-6 text-center border border-stone-100 hover:shadow-2xl hover:-translate-y-1 transition-all duration-300 group",children:[t.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 bg-gradient-to-br from-community-green to-emerald-400 rounded-xl mb-4 group-hover:scale-110 transition-transform",children:t.jsx(gl,{className:"h-6 w-6 text-white"})}),t.jsx(Be,{value:((fe=ye.stats[0])==null?void 0:fe.number)||"142k",onSave:ie=>ke(0,"number",ie),as:"div",className:"text-3xl lg:text-4xl font-heading font-bold text-community-navy"}),t.jsx(Be,{value:((Ee=ye.stats[0])==null?void 0:Ee.label)||"Bi-monthly Circulation",onSave:ie=>ke(0,"label",ie),as:"div",className:"text-sm text-muted-foreground mt-1"})]}),t.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 text-center border border-stone-100 hover:shadow-2xl hover:-translate-y-1 transition-all duration-300 group",children:[t.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 bg-gradient-to-br from-community-navy to-slate-700 rounded-xl mb-4 group-hover:scale-110 transition-transform",children:t.jsx(_t,{className:"h-6 w-6 text-white"})}),t.jsx(Be,{value:((K=ye.stats[1])==null?void 0:K.number)||"14",onSave:ie=>ke(1,"number",ie),as:"div",className:"text-3xl lg:text-4xl font-heading font-bold text-community-navy"}),t.jsx(Be,{value:((te=ye.stats[1])==null?void 0:te.label)||"Local Editions",onSave:ie=>ke(1,"label",ie),as:"div",className:"text-sm text-muted-foreground mt-1"})]}),t.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 text-center border border-stone-100 hover:shadow-2xl hover:-translate-y-1 transition-all duration-300 group",children:[t.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 bg-gradient-to-br from-amber-500 to-orange-400 rounded-xl mb-4 group-hover:scale-110 transition-transform",children:t.jsx(cL,{className:"h-6 w-6 text-white"})}),t.jsx(Be,{value:((Q=ye.stats[2])==null?void 0:Q.number)||"72%",onSave:ie=>ke(2,"number",ie),as:"div",className:"text-3xl lg:text-4xl font-heading font-bold text-community-navy"}),t.jsx(Be,{value:((ae=ye.stats[2])==null?void 0:ae.label)||"Repeat Rate",onSave:ie=>ke(2,"label",ie),as:"div",className:"text-sm text-muted-foreground mt-1"})]}),t.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 text-center border border-stone-100 hover:shadow-2xl hover:-translate-y-1 transition-all duration-300 group",children:[t.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 bg-gradient-to-br from-purple-500 to-violet-400 rounded-xl mb-4 group-hover:scale-110 transition-transform",children:t.jsx(ua,{className:"h-6 w-6 text-white"})}),t.jsx(Be,{value:((me=ye.stats[3])==null?void 0:me.number)||"1,000s",onSave:ie=>ke(3,"number",ie),as:"div",className:"text-3xl lg:text-4xl font-heading font-bold text-community-navy"}),t.jsx(Be,{value:((pe=ye.stats[3])==null?void 0:pe.label)||"Customers since 2005",onSave:ie=>ke(3,"label",ie),as:"div",className:"text-sm text-muted-foreground mt-1"})]}),t.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 text-center border border-stone-100 hover:shadow-2xl hover:-translate-y-1 transition-all duration-300 group",children:[t.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 bg-gradient-to-br from-rose-500 to-pink-400 rounded-xl mb-4 group-hover:scale-110 transition-transform",children:t.jsx(ir,{className:"h-6 w-6 text-white"})}),t.jsx(Be,{value:((be=ye.stats[4])==null?void 0:be.number)||"580k",onSave:ie=>ke(4,"number",ie),as:"div",className:"text-3xl lg:text-4xl font-heading font-bold text-community-navy"}),t.jsx(Be,{value:((ce=ye.stats[4])==null?void 0:ce.label)||"Leaflets/Year",onSave:ie=>ke(4,"label",ie),as:"div",className:"text-sm text-muted-foreground mt-1"})]})]})})}),t.jsxs("section",{className:"py-20 bg-gradient-to-br from-stone-50 via-amber-50/30 to-stone-100 relative overflow-hidden",children:[t.jsx("div",{className:"absolute top-20 right-10 w-64 h-64 bg-community-green/5 rounded-full blur-3xl"}),t.jsx("div",{className:"absolute bottom-20 left-10 w-48 h-48 bg-community-navy/5 rounded-full blur-3xl"}),t.jsx("div",{className:"relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"grid lg:grid-cols-2 gap-12 items-center",children:[t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{children:[t.jsx("div",{className:"inline-flex items-center justify-center p-3 bg-community-green/10 rounded-2xl mb-6",children:t.jsx(Nw,{className:"h-10 w-10 text-community-green fill-community-green"})}),t.jsx(Be,{value:ye.loveSection.heading,onSave:ie=>Ce("loveSection.heading",ie),as:"h2",className:"text-3xl md:text-4xl lg:text-5xl font-heading font-bold text-community-navy leading-tight"}),t.jsx(Be,{value:ye.loveSection.subheading,onSave:ie=>Ce("loveSection.subheading",ie),as:"p",className:"text-2xl md:text-3xl font-heading font-bold text-community-green mt-2"})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(Be,{value:ye.loveSection.paragraph1,onSave:ie=>Ce("loveSection.paragraph1",ie),as:"p",multiline:!0,className:"text-lg text-muted-foreground leading-relaxed"}),t.jsx(Be,{value:ye.loveSection.paragraph2,onSave:ie=>Ce("loveSection.paragraph2",ie),as:"p",multiline:!0,className:"text-lg text-muted-foreground leading-relaxed"})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4 pt-4",children:[t.jsxs("div",{className:"text-center p-4 bg-white rounded-xl shadow-sm border border-stone-200",children:[t.jsx("div",{className:"text-3xl font-bold text-community-navy",children:"20"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Years Experience"})]}),t.jsxs("div",{className:"text-center p-4 bg-white rounded-xl shadow-sm border border-stone-200",children:[t.jsx("div",{className:"text-3xl font-bold text-community-green",children:"14"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Local Editions"})]}),t.jsxs("div",{className:"text-center p-4 bg-white rounded-xl shadow-sm border border-stone-200",children:[t.jsx("div",{className:"text-3xl font-bold text-community-navy",children:"142k+"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Homes Reached"})]})]}),t.jsx("div",{className:"p-5 bg-community-navy rounded-xl",children:t.jsxs("p",{className:"text-white text-center font-medium",children:[`"We've perfected the formula for local print media â for advertisers `,t.jsx("span",{className:"text-community-green",children:"and"}),' our readers."']})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute -inset-4 bg-gradient-to-br from-community-navy/5 to-community-green/5 rounded-3xl"}),t.jsxs("div",{className:"relative bg-gradient-to-br from-slate-900 via-slate-800 to-community-navy rounded-2xl p-6 shadow-2xl",children:[t.jsx("div",{className:"flex items-center justify-between mb-4",children:t.jsx("span",{className:"text-sm font-medium text-slate-400 uppercase tracking-wider",children:"Online Edition"})}),t.jsxs(Lu,{opts:{align:"center",loop:!0},className:"w-full",children:[t.jsx(Bu,{className:"-ml-4",children:Z.map((ie,je)=>{const Re=ie.link?"a":"div",Ae=ie.link?{href:ie.link,target:"_blank",rel:"noopener noreferrer"}:{};return t.jsx(zu,{className:"pl-4 basis-full",children:t.jsx(Re,{...Ae,className:oe("group relative overflow-hidden rounded-xl bg-white/5 border border-white/10 hover:border-community-green/50 transition-all duration-500 block",ie.link&&"cursor-pointer"),children:t.jsx("div",{className:"relative overflow-hidden",children:t.jsx("img",{src:ie.src,alt:ie.alt,className:"w-full h-[500px] object-contain transition-transform duration-700 group-hover:scale-105"})})})},je)})}),t.jsx(Uu,{className:"absolute -left-3 top-1/2 -translate-y-1/2 bg-white/10 backdrop-blur border-white/20 text-white hover:bg-community-green hover:border-community-green transition-all duration-300 h-10 w-10"}),t.jsx(Vu,{className:"absolute -right-3 top-1/2 -translate-y-1/2 bg-white/10 backdrop-blur border-white/20 text-white hover:bg-community-green hover:border-community-green transition-all duration-300 h-10 w-10"})]}),t.jsx("div",{className:"flex justify-center gap-1.5 mt-4",children:Z.map((ie,je)=>t.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-white/20"},je))})]})]})]})})]}),t.jsx("section",{className:"py-16 bg-white",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx(Be,{value:ye.mediaPack.heading,onSave:ie=>Ce("mediaPack.heading",ie),as:"h2",className:"text-4xl font-heading font-bold text-community-navy mb-4"}),t.jsx(Be,{value:ye.mediaPack.description,onSave:ie=>Ce("mediaPack.description",ie),as:"p",className:"text-lg text-muted-foreground"})]}),t.jsx("div",{className:"w-full rounded-2xl overflow-hidden shadow-lg border-2 border-community-navy/2
7550 bg-white",children:t.jsxs("div",{className:"relative w-full overflow-hidden",style:{paddingBottom:"75%"},children:[t.jsx("iframe",{src:ye.mediaPack.embedUrl,className:"absolute w-full",style:{height:"115%",top:"-5%",left:"0"},frameBorder:"0",title:"Discover Media Pack",allowFullScreen:!1}),t.jsx("div",{className:"absolute top-0 left-0 right-0 h-4 bg-transparent z-10",style:{pointerEvents:"auto"}}),t.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-4 bg-transparent z-10",style:{pointerEvents:"auto"}})]})})]})}),t.jsx("section",{id:"editions-map",className:"py-16 bg-gradient-to-b from-slate-50 to-white",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx(Be,{value:ye.editionsMap.heading,onSave:ie=>Ce("editionsMap.heading",ie),as:"h2",className:"text-4xl font-heading font-bold text-community-navy mb-4"}),t.jsx(Be,{value:ye.editionsMap.description,onSave:ie=>Ce("editionsMap.description",ie),as:"p",className:"text-lg text-muted-foreground"})]}),t.jsx("div",{className:"w-full rounded-2xl overflow-hidden shadow-lg border-2 border-community-navy/20 bg-white",children:t.jsxs("div",{className:"relative w-full overflow-hidden",style:{paddingBottom:"56%"},children:[t.jsx("iframe",{src:ye.editionsMap.embedUrl,className:"absolute w-full",style:{height:"135%",top:"-12%",left:"0"},frameBorder:"0",title:"14 Local Editions Interactive Map",allowFullScreen:!1}),t.jsx("div",{className:"absolute top-0 left-0 right-0 h-4 bg-transparent z-10",style:{pointerEvents:"auto"}}),t.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-4 bg-transparent z-10",style:{pointerEvents:"auto"}})]})})]})}),t.jsx("section",{id:"quick-quote",className:"py-16 bg-white",children:t.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsx(dse,{})})}),t.jsxs("section",{id:"calculator",className:"py-20 bg-gradient-to-br from-slate-50 via-amber-50/30 to-stone-100 relative overflow-hidden",children:[t.jsx("div",{className:"absolute top-20 right-20 w-72 h-72 bg-community-green/5 rounded-full blur-3xl pointer-events-none"}),t.jsx("div",{className:"absolute bottom-20 left-20 w-56 h-56 bg-community-navy/5 rounded-full blur-3xl pointer-events-none"}),t.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-96 h-96 bg-amber-100/20 rounded-full blur-3xl pointer-events-none"}),t.jsxs("div",{className:"relative max-w-6xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"text-center mb-12",children:[t.jsx("div",{className:"flex justify-center mb-6",children:t.jsxs("div",{className:"inline-flex items-center gap-3 px-5 py-2.5 bg-white rounded-full shadow-md border border-stone-200",children:[t.jsx("div",{className:"w-2.5 h-2.5 bg-community-green rounded-full animate-pulse"}),t.jsx(Be,{value:ye.calculatorSection.badge,onSave:ie=>Ce("calculatorSection.badge",ie),as:"span",className:"text-sm font-medium text-community-navy"}),t.jsx("div",{className:"w-2.5 h-2.5 bg-community-green rounded-full animate-pulse"})]})}),t.jsx(Be,{value:ye.calculatorSection.heading,onSave:ie=>Ce("calculatorSection.heading",ie),as:"h2",className:"text-4xl font-heading font-bold text-community-navy mb-4"}),t.jsx(Be,{value:ye.calculatorSection.subheading,onSave:ie=>Ce("calculatorSection.subheading",ie),as:"p",className:"text-xl text-muted-foreground mb-6"}),t.jsx("div",{className:"max-w-xl mx-auto p-4 bg-white/60 backdrop-blur-sm rounded-xl border border-stone-200/50",children:t.jsx(Be,{value:ye.calculatorSection.tagline,onSave:ie=>Ce("calculatorSection.tagline",ie),as:"p",className:"text-center text-muted-foreground italic"})})]}),t.jsx(Mte,{})]})]}),t.jsx(bt,{open:S,onOpenChange:k,children:t.jsxs(xt,{className:"max-w-2xl",children:[t.jsxs(jt,{children:[t.jsx(wt,{className:"text-2xl font-bold text-center",children:"Are you sure you want to book Pay As You Go?"}),t.jsxs(ys,{className:"text-center",children:["If you booked this selection on our 3+ Subscription Package you would pay"," ",t.jsxs("span",{className:"font-bold text-community-green",children:["£",se!=null&&se.finalTotal?Math.round(se.finalTotal*.85):144," + vat (£",se!=null&&se.finalTotal?Math.round(se.finalTotal*.85*1.2):172.8,")"]})," ","per month for minimum of six months INCLUDING"]})]}),t.jsx("div",{className:"space-y-4 my-6",children:t.jsxs("ul",{className:"space-y-2",children:[t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx(As,{className:"h-5 w-5 text-community-green mt-0.5 flex-shrink-0"}),t.jsx("span",{children:"2 x EXTRA AREASâFREE FOR 3 ISSUESâdouble the number of homes you reach!"})]}),t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx(As,{className:"h-5 w-5 text-community-green mt-0.5 flex-shrink-0"}),t.jsx("span",{children:"FREE EDITORIAL"})]}),t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx(As,{className:"h-5 w-5 text-community-green mt-0.5 flex-shrink-0"}),t.jsx("span",{children:"FREE PREMIUM POSITION UPGRADE"})]}),t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx(As,{className:"h-5 w-5 text-community-green mt-0.5 flex-shrink-0"}),t.jsx("span",{children:"FREE ADVERT DESIGN"})]})]})}),t.jsxs("div",{className:"flex gap-4 justify-center",children:[t.jsx(q,{onClick:le,className:"bg-community-green hover:bg-community-green/90 text-white px-8 py-2",children:"YES, CONTINUE"}),t.jsx(q,{onClick:X,variant:"outline",className:"border-2 border-community-green text-community-green hover:bg-community-green hover:text-white px-6 py-2",children:"NO, SWITCH TO SUBSCRIPTION, PLEASE"})]})]})}),t.jsx(vs,{})]})})},mse=()=>
755{const e=[{icon:Yx,title:"Competitive Pay",description:"Earn £9.18 per 100 magazines delivered, plus other bonuses and top ups"},{icon:ws,title:"Flexible Hours",description:"Work around your schedule as long as they are delivered within 7 days"},{icon:_t,title:"Local Routes",description:"Deliver in your neighborhood or preferred areas"},{icon:ua,title:"Great Team",description:"Join a supportive community of distributors"}],s=[{title:"Base Pay",rate:"£9.18 per 100 Magazines",description:"Standard delivery rate"},{title:"Extra for Leaflet Inserts",rate:"£0.75 per 100 Leaflets",description:"Additional payment for leaflet distribution"},{title:"Early Delivery Bonus",rate:"10% of your base pay",description:"If 100% delivered in 5 days"}];return t.jsxs("div",{className:"min-h-screen bg-gray-50",children:[t.jsx(gs,{}),t.jsx("section",{className:"bg-gradient-to-r from-community-navy to-community-green text-white py-16",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center",children:[t.jsx("h1",{className:"text-4xl md:text-5xl font-heading font-bold mb-6",children:"Join Our Distribution Team"}),t.jsx("p",{className:"text-xl mb-8 max-w-3xl mx-auto",children:"Become part of our community network and help local businesses reach their customers while earning competitive pay."})]})}),t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:[t.jsx("div",{className:"mb-12 bg-amber-50 border border-amber-200 rounded-lg p-6",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx(xs,{className:"h-5 w-5 text-amber-600"})}),t.jsxs("div",{className:"ml-3",children:[t.jsx("h3",{className:"text-lg font-medium text-amber-800",children:"Age Requirement"}),t.jsx("p",{className:"text-amber-700 mt-1",children:"You must be 13 years or older to apply for a distribution position. Parental consent required for applicants under 18."})]})]})}),t.jsxs("section",{className:"mb-12",children:[t.jsx("h2",{className:"text-3xl font-heading font-bold text-center mb-8",children:"Why Join Our Team?"}),t.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-4 gap-6",children:e.map((r,n)=>t.jsxs(xe,{className:"text-center",children:[t.jsxs(Me,{children:[t.jsx("div",{className:"mx-auto w-12 h-12 bg-community-green/10 rounded-lg flex items-center justify-center mb-4",children:t.jsx(r.icon,{className:"h-6 w-6 text-community-green"})}),t.jsx(Oe,{className:"text-lg",children:r.title})]}),t.jsx(ge,{children:t.jsx(Er,{children:r.description})})]},n))})]}),t.jsxs("section",{className:"mb-12",children:[t.jsx("h2",{className:"text-3xl font-heading font-bold text-center mb-8",children:"Pay Rates"}),t.jsx("div",{className:"grid md:grid-cols-3 gap-6",children:s.map((r,n)=>t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-xl",children:r.title})}),t.jsx(ge,{children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-2xl font-bold text-community-green",children:r.rate}),t.jsx("p",{className:"text-sm text-gray-600",children:r.description})]})})]},n))})]}),t.jsx("section",{className:"mb-12",children:t.jsxs(xe,{className:"max-w-4xl mx-auto",children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-2xl text-center",children:"What's Involved"})}),t.jsxs(ge,{children:[t.jsxs("div",{className:"prose prose-gray max-w-none",children:[t.jsx("p",{className:"text-gray-600 mb-4",children:"This is a great opportunity to earn money while getting exercise and helping connect your local community with important information and local business promotions. As a magazine distributor, you'll be responsible for delivering Discover to households in your assigned area every other month. Here's what you need to know:"}),t.jsxs("ul",{className:"space-y-2 text-gray-600",children:[t.jsx("li",{children:"⢠Distributors must have a suitable location at their property for several boxes to be left by delivery manager in a safe and dry location. Otherwise, collection from depot at your own expense is available."}),t.jsx("li",{children:"⢠Agree to have a GPS tracking app on your mobile phone and use the app every time you deliver."}),t.jsx("li",{children:"⢠Deliver to every household in your assigned route"}),t.jsx("li",{children:"⢠Complete deliveries within 7 days of collection"}),t.jsx("li",{children:"⢠Handle magazines with care to ensure quality delivery"}),t.jsx("li",{children:"⢠Be respectful of residents' property and comply with their requests on junk mail, gates and driveways etc"}),t.jsx("li",{children:"⢠Report any issues or problems to your area coordinator"}),t.jsx("li",{children:"⢠Inform yourself from the app of all delivery dates and be available for those dates in the year."}),t.jsx("li",{children:"⢠Advise of illness, absence or inability to carry out duties with as much notice as possible"}),t.jsx("li",{children:"⢠Follow health and safety guidelines at all times"})]})]}),t.jsx("div",{className:"mt-6 text-center",children:t.jsx(q,{size:"lg",className:"bg-community-green hover:bg-community-green/90",onClick:()=>{window.open("https://roundcontrol.co.uk/discover-magazines/join-waiting-list","_blank")},children:"Apply Now"})})]})]})}),t.jsxs("section",{id:"areas",className:"mb-12 scroll-mt-20",children:[t.jsx("h2",{className:"text-3xl font-heading font-bold text-center mb-8",children:"Distribution Areas"}),t.jsx(xe,{className:"max-w-4xl mx-auto",children:t.jsx(ge,{className:"p-6",children:t.jsxs("div",{className:"flex flex-col items-center justify-center",children:[t.jsx("div",{className:"w-full aspect-[4/3] bg-muted rounded-lg flex items-center justify-center border-2 border-dashed border-muted-foreground
755/30",children:t.jsxs("div",{className:"text-center p-8",children:[t.jsx(sL,{className:"h-16 w-16 text-muted-foreground/50 mx-auto mb-4"}),t.jsx("p",{className:"text-muted-foreground font-medium",children:"Distribution Areas Map"}),t.jsx("p",{className:"text-sm text-muted-foreground/70 mt-2",children:"Map image coming soon"})]})}),t.jsx("p",{className:"text-sm text-muted-foreground text-center mt-4 max-w-2xl",children:"Our distribution network covers key areas across South Hampshire. View the map above to see if your area is available for delivery opportunities."})]})})})]})]}),t.jsx(vs,{})]})},hse="story-submissions",Jj=5,fse=10*1024*1024,pse=["image/jpeg","image/png","image/webp","image/heic","application/pdf"],ZD=e=>e>=1024*1024?`${(e/(1024*1024)).toFixed(1)}MB`:`${Math.max(1,Math.round(e/1024))}KB`,xse=(e,s)=>s>=Jj?`You can attach up to ${Jj} files.`:pse.includes(e.type)?e.size>fse?`${e.name} is ${ZD(e.size)}. Each file must be 10MB or smaller.`:null:`${e.name} is not a supported file type. Please use a JPG, PNG, WEBP, HEIC or PDF.`,gse=e=>{const s=e.lastIndexOf("."),r=(s>0?e.slice(0,s):e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"file",n=(s>0?e.slice(s+1):"").toLowerCase().replace(/[^a-z0-9]/g,"");return n?`${r}.${n}`:r},vse=async e=>{const s=new Date,r=String(s.getFullYear()),n=String(s.getMonth()+1).padStart(2,"0"),a=`submissions/${r}/${n}/${crypto.randomUUID()}-${gse(e.name)}`,{error:i}=await W.storage.from(hse).upload(a,e,{cacheControl:"3600",upsert:!1,contentType:e.type});if(i)throw new Error(i.message);return{name:e.name,path:a,size:e.size,type:e.type}},yse={first_name:"",last_name:"",email:"",phone:"",postcode:"",company:""},bse={marketing_email:!1,terms_accepted:!1,privacy_accepted:!1,consent_email_contact_required:!1,consent_think_monthly_optional:!1,discover_extra:!1,think_monthly:!1,email_contact:!1},jse=e=>{switch(e){case"editorial":return["first_name","last_name","email","phone"];case"advertising":return["first_name","last_name","email","phone","company"];case"discover_extra":case"think_advertising":return["first_name","email"];case"distributor":return["first_name","last_name","email","phone","postcode"];default:return["first_name","email"]}},N3=e=>{switch(e){case"editorial":return["Journey Selection","Story Details","Contact Information","Review & Submit"];case"advertising":return["Journey Selection","Campaign Details","Contact Information","Review & Submit"];case"discover_extra":case"think_advertising":return["Journey Selection","Contact Information","Interests","Confirm Subscription"];case"distributor":return["Journey Selection","Contact Information","Distribution Details","Review & Submit"];default:return["Journey Selection"]}},wse=e=>{switch(e){case"editorial":return"Submit a Story";case"advertising":return"Request an Advertising Quote";case"discover_extra":return"Subscribe to Discover EXTRA";case"think_advertising":return"Subscribe to THINK Advertising";case"distributor":return"Apply for Magazine Distribution";default:return"Unknown"}},JD=()=>{const e=new URLSearchParams(window.location.search);return{source:"discover_combined_form",utm_source:e.get("utm_source"),utm_medium:e.get("utm_medium"),utm_campaign:e.get("utm_campaign"),utm_content:e.get("utm_content"),utm_term:e.get("utm_term"),page_url:window.location.href}},_3=()=>({journey_type:null,current_step:0,contact:yse,data:{},consents:bse,meta:JD()}),Nse=()=>{const[e,s]=u.useState(_3),[r,n]=u.useState(!1),[a,i]=u.useState(!1),[o,l]=u.useState(null),[c,d]=u.useState(null);u.useEffect(()=>{s(S=>({...S,meta:JD()}))},[]);const m=u.useCallback(S=>{s(k=>({...k,journey_type:S,current_step:1,data:{}}))},[]),h=u.useCallback(S=>{s(k=>({...k,contact:{...k.contact,...S}}))},[]),f=u.useCallback(S=>{s(k=>({...k,data:{...k.data,...S}}))},[]),p=u.useCallback(S=>{s(k=>({...k,consents:{...k.consents,...S}}))},[]),x=u.useCallback(()=>{s(S=>({...S,current_step:S.current_step+1}))},[]),g=u.useCallback(()=>{s(S=>({...S,current_step:Math.max(0,S.current_step-1)}))},[]),b=u.useCallback(S=>{s(k=>({...k,current_step:S}))},[]),w=u.useCallback(()=>{s(_3()),i(!1),n(!1),l(null),d(null)},[]),j=u.useCallback(()=>N3(e.journey_type).length,[e.journey_type]),y=u.useCallback(()=>N3(e.journey_type),[e.journey_type]),v=u.useCallback(async()=>{n(!0),l(null);let S={...e.data};const $=(S.editorial_attachments??[]).filter(A=>A instanceof File);if($.length>0){const A=[];for(let T=0;T<$.length;T++){d({current:T+1,total:$.length});try{A.push(await vse($[T]))}catch(P){throw console.error("Attachment upload failed:",P),d(null),n(!1),l(`We c
755ouldn't upload "${$[T].name}". Your story has not been sent â please check your connection and try again.`),P instanceof Error?P:new Error("Attachment upload failed")}}d(null),S={...S,editorial_attachments:A}}const R={form_category:wse(e.journey_type),journey_type:e.journey_type,contact:e.contact,data:S,consents:e.consents,meta:{...e.meta,source:"discover_combined_form",page_url:window.location.href,submitted_at:new Date().toISOString()}};try{const{data:A,error:T}=await W.functions.invoke("submit-discover-form",{body:R});if(T)throw new Error(T.message||"Submission failed");return console.log("Form submitted successfully:",R),i(!0),l(null),R}catch(A){throw console.error("Form submission error:",A),l(A instanceof Error?"Unable to submit your form. Please check your connection and try again.":"An unexpected error occurred. Please try again."),A}finally{n(!1)}},[e]),N=u.useCallback(()=>v(),[v]);return{formState:e,isSubmitting:r,isSubmitted:a,submissionError:o,uploadProgress:c,setJourneyType:m,updateContact:h,updateData:f,updateConsents:p,nextStep:x,prevStep:g,goToStep:b,resetForm:w,getTotalSteps:j,getStepNames:y,submitForm:v,retrySubmit:N}},_se=[{type:"editorial",label:"Submit a story (Editorial)",description:"Share your news or community story with our readers",icon:Cw,color:"text-blue-600",bgColor:"bg-blue-50 hover:bg-blue-100",borderColor:"border-blue-200 data-[selected=true]:border-blue-500 data-[selected=true]:ring-2 data-[selected=true]:ring-blue-200"},{type:"advertising",label:"Request an advertising quote",description:"Get pricing for your ad campaign in our magazine",icon:Xo,color:"text-community-green",bgColor:"bg-community-green/5 hover:bg-community-green/10",borderColor:"border-community-green/30 data-[selected=true]:border-community-green data-[selected=true]:ring-2 data-[selected=true]:ring-community-green/20"},{type:"discover_extra",label:"Subscribe to Discover EXTRA",description:"Our weekly email newsletter with local news & events",icon:ar,color:"text-purple-600",bgColor:"bg-purple-50 hover:bg-purple-100",borderColor:"border-purple-200 data-[selected=true]:border-purple-500 data-[selected=true]:ring-2 data-[selected=true]:ring-purple-200"},{type:"think_advertising",label:"Subscribe to THINK Advertising",description:"Monthly marketing insights and tips for local businesses",icon:_w,color:"text-rose-600",bgColor:"bg-rose-50 hover:bg-rose-100",borderColor:"border-rose-200 data-[selected=true]:border-rose-500 data-[selected=true]:ring-2 data-[selected=true]:ring-rose-200"},{type:"distributor",label:"Apply for magazine distribution",description:"Become a distribution partner and earn extra income",icon:Sf,color:"text-orange-600",bgColor:"bg-orange-50 hover:bg-orange-100",borderColor:"border-orange-200 data-[selected=true]:border-orange-500 data-[selected=true]:ring-2 data-[selected=true]:ring-orange-200",externalUrl:"https://roundcontrol.co.uk/discover-magazines-ltd/join-waiting-list"}],Sse=({selectedJourney:e,onSelect:s})=>{const r=n=>{n.externalUrl?window.open(n.externalUrl,"_blank","noopener,noreferrer"):s(n.type)};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("h2",{className:"text-2xl md:text-3xl font-heading font-bold text-community-navy mb-2",children:"What would you like to do today?"}),t.jsx("p",{className:"text-gray-600",children:"Select an option below to get started"})]}),t.jsx("div",{className:"grid gap-4",children:_se.map(n=>{const a=n.icon,i=e===n.type&&!n.externalUrl;return t.jsxs("button",{type:"button","data-selected":i,onClick:()=>r(n),className:oe("w-full p-5 rounded-xl border-2 transition-all duration-200 text-left group","flex items-center gap-4",n.bgColor,n.borderColor,i&&"shadow-md"),children:[t.jsx("div",{className:oe("flex-shrink-0 w-12 h-12 rounded-full flex items-center justify-center",i?"bg-white shadow-sm":"bg-white/50"),children:t.jsx(a,{className:oe("h-6 w-6",n.color)})}),t.jsxs("div",{className:"flex-grow min-w-0",children:[t.jsxs("h3",{className:oe("font-semibold text-lg text-community-navy group-hover:text-community-navy/80",i&&"text-community-navy"),children:[n.label,n.externalUrl&&t.jsx(_u,{className:"inline-block h-4 w-4 ml-2 text-gray-400"})]}),t.jsx("p",{className:"text-sm text-gray-600 mt-0.5",children:n.description})]}),i&&t.jsx(As,{className:oe("flex-shrink-0 h-6 w-6",n.color)})]},n.type)})})]})},xm=({contact:e,journeyType:s,onChange:r,errors:n={},consents:a,onConsentsChange:i})=>{const o=jse(s),l=h=>o.includes(h),c=h=>({first_name:"First Name",last_name:"Last Name",email:"Email Address",phone:"Phone Number",postcode:"Postcode",company:"Company/Business N
755ame"})[h],d=(h,f,p="text",x="")=>{const g=l(h),b=!!n[h];return t.jsxs("div",{className:"space-y-2",children:[t.jsxs(V,{htmlFor:h,className:"flex items-center gap-2 text-sm font-medium text-gray-700",children:[f,c(h),g&&t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(re,{id:h,type:p,value:e[h],onChange:w=>r({[h]:w.target.value}),placeholder:x,required:g,className:oe("transition-colors",b&&"border-destructive focus-visible:ring-destructive")}),b&&t.jsx("p",{className:"text-sm text-destructive",children:n[h]})]})},m=()=>s==="discover_extra"?t.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"We usually send one email a month, occasionally two if there is a special event, announcement or offer to share. By adding your postcode we know which edition of Discover you receive (one of 14 local editions) and can tailor the e-newsletter to you. You can unsubscribe at any time."}):t.jsx("p",{className:"text-gray-600 text-sm",children:"We'll use this information to get back to you"});return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"text-center mb-6",children:[t.jsx("h2",{className:"text-2xl font-heading font-bold text-community-navy mb-2",children:"Your Contact Details"}),m()]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[d("first_name",t.jsx(bn,{className:"h-4 w-4 text-gray-400"}),"text","John"),d("last_name",t.jsx(bn,{className:"h-4 w-4 text-gray-400"}),"text","Smith")]}),t.jsxs("div",{className:"space-y-4",children:[d("email",t.jsx(ar,{className:"h-4 w-4 text-gray-400"}),"email","[email protected]"),(s==="editorial"||s==="advertising"||s==="distributor")&&d("phone",t.jsx(zr,{className:"h-4 w-4 text-gray-400"}),"tel","07700 900000"),(s==="distributor"||s==="discover_extra")&&d("postcode",t.jsx(_t,{className:"h-4 w-4 text-gray-400"}),"text","SO50 9DT"),(s==="advertising"||s==="think_advertising")&&d("company",t.jsx(Xr,{className:"h-4 w-4 text-gray-400"}),"text","Your Business Ltd")]}),s==="discover_extra"&&a&&i&&t.jsx("div",{className:"mt-6 p-4 bg-muted/50 rounded-lg border",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Kt,{id:"discover_extra_consent",checked:a.discover_extra,onCheckedChange:h=>i({discover_extra:!!h}),className:"mt-0.5"}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs(V,{htmlFor:"discover_extra_consent",className:"text-sm font-medium cursor-pointer",children:["Yes, I'd like to receive Discover EXTRA emails ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Get exclusive content, competitions, and local news delivered to your inbox."})]})]})})]})},Cse=[{value:"community_news_story",label:"Community News Story",icon:Dc},{value:"personal_story",label:"Personal Story",icon:nL},{value:"local_business",label:"Local Business",icon:hL},{value:"cheer_for_charity",label:"Cheer for Charity",icon:Nw},{value:"a_good_read",label:"A Good Read",icon:tu},{value:"young_superstar",label:"Young Superstar",icon:mr},{value:"community_hero",label:"Community Hero",icon:sE}],kse=({data:e,onChange:s,errors:r,consents:n,onConsentsChange:a})=>{const i=e.editorial_story_summary||"",o=i.trim()?i.trim().split(/\s+/).length:0,l=o>30,[c,d]=u.useState(null),m=f=>{const p=f.target.files;if(p){const x=[...e.editorial_attachments||[]];let g=null;for(const b of Array.from(p)){const w=xse(b,x.length);if(w){g=w;continue}x.push(b)}d(g),s({editorial_attachments:x})}f.target.value=""},h=f=>{const x=(e.editorial_attachments||[]).filter((g,b)=>b!==f);d(null),s({editorial_attachments:x})};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold text-foreground mb-2",children:"Story Details"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:"Tell us about your story for Discover magazine."})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"editorial_organisation",children:"Organisation (optional)"}),t.jsx(re,{id:"editorial_organisation",placeholder:"Your organisation or group name",value:e.editorial_organisation||"",onChange:f=>s({editorial_organisation:f.target.value})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx(V,{htmlFor:"editorial_story_summary",children:"Summary of your story in one sentence *"}),t.jsxs("span",{className:oe("text-xs",l?"text-destructive font-medium":"text-muted-foreground"),children:[o,"/30 words"]})]}),t.jsx(re,{id:"editorial_story_summary",placeholder:"Briefly describe your story in one sentence",value:e.editorial_story_summary||"",onChange:f=>s({editorial_story_summary:f.target.value}),className:oe(r!=null&&r.editorial_story_summary||l?"border-destructive":"")}),l&&t.jsx("p",{className:"text-xs text-destructive",children:"Please keep your summary to 30 words or less."}),(r==null?void 0:r.editorial_story_summary)&&t.jsx("p",{className:"text-xs text-destructive",children:r.editorial_story_summary})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{children:"Editorial Category *"}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Cse.map(f=>{const p=f.icon,x=e.editorial_category===f.value;return t.jsxs("button",{type:"button",onClick:()=>s({editorial_category:f.value}),className:oe("flex items-center gap-3 p-4 rounded-lg border-2 text-left transition-all",x?"border-community-green bg-community-green/10 text-foreground":"border-border hover:border-community-green/50 hover:bg-muted/50"),children:[t.jsx(p,{className:oe("h-5 w-5 flex-shrink-0",x?"text-community-green":"text-muted-foreground")}),t.jsx("span",{className:"font-medium",children:f.label})]},f.value)})}),(r==null?void 0:r.editorial_category)&&t.jsx("p",{className:"text-xs text-destructive",children:r.editorial_category})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"editorial_story_text",children:"The text of your story *"}),t.jsx("p",{className:"text-sm text-muted-foreground italic",children:"Please write in 3rd person (he/she/they), not my/our/I."}),t.jsx(ms,{id:"editorial_story_text",placeholder:"Write your full story here...",value:e.editorial_story_text||"",onChange:f=>s({editorial_story_text:f.target.value}),className:oe("min-h-[200px] resize-y",r!=null&&r.editorial_story_text?"border-destructive":"")}),(r==null?void 0:r.editorial_story_text)&&t.jsx("p",{className:"text-xs text-destructive",children:r.editorial_story_text})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{children:"Attachments (optional)"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Photos or PDFs related to your story â up to ",Jj," files, 10MB each (JPG, PNG, WEBP, HEIC or PDF)."]}),t.jsx("div",{className:"flex items-center gap-4",children:t.jsxs("label",{className:"cursor-pointer",children:[t.jsx("input",{type:"file",multiple:!0,accept:"image/jpeg,image/png,image/webp,image/heic,application/pdf",onChange:m,className:"hidden"}),t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-md border border-dashed border-border hover:border-community-green hover:bg-muted/50 transition-colors",children:[t.jsx(sn,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"Choose files"})]})]})}),c&&t.jsx("p",{className:"text-xs text-destructive",children:c}),e.editorial_attachments&&e.editorial_attachments.length>0&&t.jsx("div",{className:"space-y-2 mt-3",children:e.editorial_attachments.map((f,p)=>t.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/50 rounded-md",children:[t.jsxs("span",{className:"text-sm truncate flex-1 mr-2",children:[f.name,t.jsxs("span",{className:"text-muted-foreground",children:[" (",ZD(f.size),")"]})]}),t.jsx("button",{type:"button",onClick:()=>h(p),className:"p-1 hover:bg-destructive/10 rounded transition-colors",children:t.jsx(Es,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"})})]}
755,`${f.name}-${p}`))})]}),n&&a&&t.jsxs("div",{className:"mt-6 p-4 bg-muted/50 rounded-lg border",children:[t.jsx("h3",{className:"text-sm font-medium text-foreground mb-3",children:"Communication Preferences"}),t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Kt,{id:"editorial_email_consent",checked:n.email_contact,onCheckedChange:f=>a({email_contact:!!f}),className:"mt-0.5"}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(V,{htmlFor:"editorial_email_consent",className:"text-sm font-medium cursor-pointer",children:"I consent to being contacted by email regarding my story submission *"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"We'll use your email to follow up on your story and keep you updated."})]})]})]})]})},$se=[{value:"not_currently_advertising",label:"Not currently advertising",icon:"ð"},{value:"currently_advertising_change_extend_improve",label:"Currently advertising - want to change, extend or improve",icon:"ð"},{value:"advertising_marketing_agency",label:"Advertising/marketing agency",icon:"ð¢"}],Ese=[{value:"yes_distribution_only",label:"Yes - distribution only",icon:"ð¬"},{value:"yes_design_print_distribution",label:"Yes - design, print & distribution",icon:"ð¨"},{value:"no_thanks",label:"No thanks",icon:"â"}],Pse=[{value:"southampton_city_suburbs",label:"Southampton City & Suburbs"},{value:"chandlers_ford",label:"Chandler's Ford"},{value:"eastleigh_surrounds",label:"Eastleigh & Surrounds"},{value:"hedge_end_botley",label:"Hedge End & Botley"},{value:"locks_heath_warsash_whiteley",label:"Locks Heath, Warsash & Whiteley"},{value:"itchfield_lee_on_solent_stubbington_alverstoke",label:"Titchfield, Lee-on-Solent, Stubbington & Alverstoke"},{value:"meon_valley",label:"Meon Valley"},{value:"winchester_villages",label:"Winchester Villages"},{value:"romsey_north_baddesley",label:"Romsey & North Baddesley"},{value:"totton",label:"Totton"},{value:"new_forest_waterside",label:"New Forest Waterside"},{value:"woolston_itchen_peartree_sholing",label:"Woolston, Itchen, Peartree & Sholing"},{value:"hamble_netley_bursledon_west_end",label:"Hamble, Netley, Bursledon & West End"},{value:"test_valley_stockbridge",label:"Test Valley & Stockbridge"}],Ase=[{value:"full_page_a5",label:"Full Page (A5)"},{value:"full_page_premium_back_cover",label:"Full Page Premium (Back Cover)"},{value:"two_thirds_page",label:"Two Thirds Page"},{value:"half_page",label:"Half Page"},{value:"one_third_page",label:"One Third Page"},{value:"quarter_page",label:"Quarter Page"},{value:"one_sixth_page",label:"One Sixth Page"},{value:"one_eighth_page",label:"One Eighth Page"},{value:"none_unsure",label:"Not sure / Need advice"}],Tse=[{value:"received_magazine",label:"Received the magazine through my door"},{value:"picked_up_magazine",label:"Picked up a copy somewhere"},{value:"word_of_mouth",label:"Word of mouth / recommendation"},{value:"google_search",label:"Google search"},{value:"social_media",label:"Social media (Facebook, Instagram, etc.)"},{value:"local_event",label:"Local event or networking"},{value:"email_newsletter",label:"Email newsletter"},{value:"existing_advertiser",label:"Already an advertiser"},{value:"sales_call",label:"Sales call or visit"},{value:"leaflet_flyer",label:"Leaflet or flyer"},{value:"other",label:"Other"}],Dse=({data:e,onChange:s,consents:r,onConsentsChange:n,errors:a})=>{const i=(o,l)=>{const c=e[o]||[],d=c.includes(l)?c.filter(m=>m!==l):[...c,l];s({[o]:d})};return t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Advertising Quote Request"}),t.jsx("p",{className:"text-muted-foreground",children:"Tell us about your business and advertising needs."})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Business Details"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"advertising_business_name",children:"Business Name *"}),t.jsx(re,{id:"advertising_business_name",value:e.advertising_business_name||"",onChange:o=>s({advertising_business_name:o.target.value}),placeholder:"Your business name",className:a!=null&&a.advertising_business_name?"border-destructive":""}),(a==null?void 0:a.advertising_business_name)&&t.jsx("p",{className:"text-sm text-destructive",children:a.advertising_business_name})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"advertising_landline",children:"Landline (optional)"}),t.jsx(re,{id:"advertising_landline",value:e.advertising_landline||"",onChange:o=>s({advertising_landline:o.target.value}),placeholder:"Landline number",type:"tel"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Mobile number is captured in contact details"})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{className:"text-base font-medium",children:"Have you seen/read a hard copy of Discover magazine? *"}),t.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{value:"yes",label:"Yes",icon:"â
"},{value:"no",label:"No",icon:"â"}].map(o=>t.jsxs("button",{type:"button",onClick:()=>s({advertising_seen_hard_copy:o.value}),className:`p-4 rounded-lg border-2 text-left transition-all ${e.advertising_seen_hard_copy===o.value?"border-primary bg-primary/10":"border-border hover:border-primary/50"}`,children:[t.jsx("span",{className:"text-xl mr-2",children:o.icon}),t.jsx("span",{className:"font-medium",children:o.label})]},o.value))}),(a==null?void 0:a.advertising_seen_hard_copy)&&t.jsx("p",{className:"text-sm text-destructive",children:a.advertising_seen_hard_copy})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{className:"text-base font-medium",children:"Current advertising situation *"}),t.jsx("div",{className:"space-y-2",children:$se.map(o=>t.jsxs("button",{type:"button",onClick:()=>s({advertising_current_situation:o.value}),className:`w-full p-4 rounded-lg border-2 text-left transition-all ${e.advertising_current_situation===o.value?"border-primary bg-primary/10":"border-border hover:border-primary/50"}`,children:[t.jsx("span",{className:"text-xl mr-3",children:o.icon}),t.jsx("span",{className:"font-medium",children:o.label})]},o.value))}),(a==null?void 0:a.advertising_current_situation)&&t.jsx("p",{className:"text-sm text-destructive",children:a.advertising_current_situation})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{className:"text-base font-medium",children:"Interested in our leaflet delivery service? *"}),t.jsx("div",{className:"space-y-2",children:Ese.map(o=>t.jsxs("button",{type:"button",onClick:()=>s({advertising_leaflet_interest:o.value}),className:`w-full p-4 rounded-lg border-2 text-left transition-all ${e.advertising_leaflet_interest===o.value?"border-primary bg-primary/10":"border-border hover:border-primary/50"}`,children:[t.jsx("span",{className:"text-xl mr-3",children:o.icon}),t.jsx("span",{className:"font-medium",children:o.label})]},o.value))}),(a==null?void 0:a.advertising_leaflet_interest)&&t.jsx("p",{className:"text-sm text-destructive",children:a.advertising_leaflet_interest})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{className:"text-base font-medium",children:"Which editions are you interested in advertising in? *"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Select all that apply"}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:Pse.map(o=>t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${(e.advertising_editions_interested||[]).includes(o.value)?"border-primary bg-primary/10":"border-border hover:border-primary/50"}`,children:[t.jsx(Kt,{checked:(e.advertising_editions_interested||[]).includes(o.value),onCheckedChange:()=>i("advertising_editions_interested",o.value)}),t.jsx("span",{className:"text-sm font-medium",children:o.label})]},o.value))}),(a==null?void 0:a.advertising_editions_interested)&&t.jsx("p",{className:"text-sm text-destructive",children:a.advertising_editions_interested})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{className:"text-base font-medium",children:"Which ad sizes are you interested in? *"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Select all that apply"}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:Ase.map(o=>t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${(e.advertising_ad_sizes||[]).includes(o.value)?"border-primary bg-primary/10":"border-border hover:border-primary/50"}`,children:[t.jsx(Kt,{checked:(e.advertising_ad_sizes||[]).includes(o.value),onCheckedChange:()=>i("advertising_ad_sizes",o.value)}),t.jsx("span",{className:"text-sm font-medium",children:o.label})]},o.value))}),(a==null?void 0:a.advertising_ad_sizes)&&t.jsx("p",{className:"text-sm text-destructive",children:a.advertising_ad_sizes})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"advertising_extra_info",children:"Anything else you'd like us to know? (optional)"}),t.jsx(ms,{id:"advertising_extra_info",value:e.advertising_extra_info||"",onChange:o=>s({advertising_extra_info:o.target.value}),placeholder:"Tell us about your goals, timeline, or any specific requirements...",rows:4})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"advertising_how_heard",children:"How did you hear about us? *"}),t.jsxs(ht,{value:e.advertising_how_heard||"",onValueChange:o=>s({advertising_how_heard:o}),children:[t.jsx(ut,{className:a!=null&&a.advertising_how_heard?"border-destructive":"",children:t.jsx(ft,{placeholder:"Please select..."})}),t.jsx(mt,{children:Tse.map(o=>t.jsx(Pe,{value:o.value,children:o.label},o.value))})]}),(a==null?void 0:a.advertising_how_heard)&&t.jsx("p",{className:"text-sm text-destructive",children:a.advertising_how_heard})]}),t.jsxs("div",{className:"space-y-4 pt-4 border-t border-border",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Communication Preferences"}),t.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[t.jsx(Kt,{checked:r.consent_email_contact_required,onCheckedChange:o=>n({consent_email_contact_required:!!o}),className:"mt-1"}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"I consent to being contacted by email about my advertising enquiry *"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"We'll use your email to send you a quote and follow up on your enquiry."})]})]}),(a==null?void 0:a.consent_email_contact_required)&&t.jsx("p",{className:"text-sm text-destructive",children:a.consent_email_contact_required}),t.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[t.jsx(Kt,{checked:r.consent_think_monthly_optional,onCheckedChange:o=>n({consent_think_monthly_optional:!!o}),className:"mt-1"}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium",children:"Subscribe to THINK monthly newsletter (optional)"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Get tips and insights for local businesses, delivered monthly."})]})]})]})]})},Rse=[{value:"every_issue",label:"Every issue"},{value:"most_issues",label:"Most issues"},{value:"occasionally",label:"Occasionally"},{value:"rarely",label:"Rarely"},{value:"first_time",label:"First time seeing it"}],Mse=[{value:"competitions",label:"Competitions"},{value:"whats_on",label:"What's On"},{value:"on_the_grapevine_local_stories",label:"On the Grapevine (Local Stories)"},{value:"theatre_listings",label:"Theatre Listings"},{value:"puzzles",label:"Puzzles"},{value:"recipe",label:"Recipe"},{value:"editors_letter",label:"Editor's Letter"},{value:"lifestyle_articles",label:"Lifestyle Articles"}],Ose=[{value:"yes_definitely",label:"Yes, definitely"},{value:"yes_already_have",label:"Yes, I already have"},{value:"maybe",label:"Maybe"},{value:"unlikely",label:"Unlikely"}],Ise=[{value:"much_better",label:"Much better"},{value:"better",label:"Better"},{value:"about_same",label:"About the same"},{value:"not_as_good",label:"Not as good"},{value:"only_one_receive",label:"It's the only one I receive"}],S3=({data:e,onChange:s,journeyType:r,consents:n,onConsentsChange:a})=>{const i=e,o=e,l=c=>{const d=i.newsletter_discover_interests||[],m=d.includes(c)?d.filter(h=>h!==c):[...d,c];s({newsletter_discover_interests:m})};return r==="discover_extra"?t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:t.jsx(Dc,{className:"h-6 w-6 text-primary"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Discover EXTRA Feedback"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Help us improve your Discover experience"})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs(V,{className:"text-base font-medium",children:["How often do you keep and use Discover? ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs(ht,{value:i.newsletter_discover_keep_use_frequency||"",onValueChange:c=>s({newsletter_discover_keep_use_frequency:c}),children:[t.jsx(ut,{children:t.jsx(ft,{placeholder:"Select frequency..."})}),t.jsx(mt,{children:Rse.map(c=>t.jsx(Pe,{value:c.value,children:c.label},c.value))})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(V,{className:"text-base font-medium",children:"Which sections interest you most? (optional)"}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Mse.map(c=>{const d=(i.newsletter_discover_interests||[]).includes(c.value);return t.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-all ${d?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,onClick:()=>
755l(c.value),children:[t.jsx(Kt,{checked:d,onCheckedChange:()=>l(c.value),onClick:m=>m.stopPropagation()}),t.jsx("span",{className:"text-sm",children:c.label})]},c.value)})})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs(V,{className:"text-base font-medium",children:["Would you use Discover to source a local business? ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs(ht,{value:i.newsletter_discover_source_local_business||"",onValueChange:c=>s({newsletter_discover_source_local_business:c}),children:[t.jsx(ut,{children:t.jsx(ft,{placeholder:"Select an option..."})}),t.jsx(mt,{children:Ose.map(c=>t.jsx(Pe,{value:c.value,children:c.label},c.value))})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs(V,{className:"text-base font-medium",children:["How does Discover rate compared to other community magazines you get? ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs(ht,{value:i.newsletter_discover_rating||"",onValueChange:c=>s({newsletter_discover_rating:c}),children:[t.jsx(ut,{children:t.jsx(ft,{placeholder:"Select rating..."})}),t.jsx(mt,{children:Ise.map(c=>t.jsx(Pe,{value:c.value,children:c.label},c.value))})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{className:"text-base font-medium",children:"Any other comments? (optional)"}),t.jsx(ms,{placeholder:"Share your thoughts about Discover...",value:i.newsletter_discover_comments||"",onChange:c=>s({newsletter_discover_comments:c.target.value}),rows:4})]}),t.jsx("div",{className:"p-4 bg-muted/50 rounded-lg border",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Kt,{id:"discover_extra_consent",checked:n.discover_extra,onCheckedChange:c=>a({discover_extra:c})}),t.jsxs(V,{htmlFor:"discover_extra_consent",className:"text-sm leading-relaxed cursor-pointer",children:[t.jsx("span",{className:"font-medium",children:"Yes, I'd like to receive Discover EXTRA emails"})," ",t.jsx("span",{className:"text-destructive",children:"*"}),t.jsx("p",{className:"text-muted-foreground mt-1",children:"Get exclusive content, competitions, and local news delivered to your inbox."})]})]})})]}):r==="think_advertising"?t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:t.jsx(ar,{className:"h-6 w-6 text-primary"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"THINK Monthly Newsletter"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Stay updated with advertising tips and offers"})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{className:"text-base font-medium",children:"Feedback / what you'd like to see (optional)"}),t.jsx(ms,{placeholder:"Tell us what topics or content you'd like us to cover...",value:o.newsletter_think_feedback||"",onChange:c=>s({newsletter_think_feedback:c.target.value}),rows:5}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Your feedback helps us create content that's valuable to you."})]}),t.jsx("div",{className:"p-4 bg-muted/50 rounded-lg border",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Kt,{id:"think_monthly_consent",checked:n.think_monthly,onCheckedChange:c=>a({think_monthly:c})}),t.jsxs(V,{htmlFor:"think_monthly_consent",className:"text-sm leading-relaxed cursor-pointer",children:[t.jsx("span",{className:"font-medium",children:"Yes, I'd like to receive THINK monthly emails"})," ",t.jsx("span",{className:"text-destructive",children:"*"}),t.jsx("p",{className:"text-muted-foreground mt-1",children:"Get advertising tips, special offers, and business insights delivered monthly."})]})]})})]}):null},Fse=[{id:"southampton",label:"Southampton"},{id:"chandlers_ford_north_baddesley",label:"Chandler's Ford & North Baddesley"},{id:"eastleigh_surrounds",label:"Eastleigh & Surrounds"},{id:"hedge_end_west_end_botley",label:"Hedge End, West End & Botley"},{id:"locks_heath_surrounds",label:"Locks Heath & Surrounds"},{id:"fareham_surrounds",label:"Fareham & Surrounds"},{id:"winchester",label:"Winchester"},{id:"romsey",label:"Romsey"},{id:"totton_waterside_blackfield",label:"Totton, Waterside & Blackfield"},{id:"woolston_itchen_peartree_sholing",label:"Woolston, Itchen, Peartree & Sholing"}],Lse=[{value:"yes",label:"Yes, I have safe storage"},{value:"no",label:"No"},{value:"not_sure",label:"Not sure"}],Bse=[{value:"under_16",label:"Under 16"},{value:"16_17",label:"16-17"},{value:"18_plus",label:"18+"}],zse=({data:e,onChange:s,consents:r,onConsentsChange:n})=>{const a=e.distribution_areas_interested||[],i=o=>{const l=a.includes(o)?a.filter(c=>c!==o):[...a,o];s({distribution_areas_interested:l})};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"text-center mb-6",children:[t.jsx("h2",{className:"text-2xl font-heading font-bold text-foreground mb-2",children:"Distribution Details"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:"Tell us about your availability and location"})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs(V,{className:"text-base font-medium flex items-center gap-2",children:[t.jsx(gl,{className:"h-4 w-4 text-muted-foreground"}),"Your Address"]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsxs(V,{htmlFor:"address_1",className:"text-sm",children:["Address Line 1 ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(re,{id:"address_1",value:e.distribution_address_1||"",onChange:o=>s({distribution_address_1:o.target.value}),placeholder:"Street address"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"address_2",className:"text-sm",children:"Address Line 2"}),t.jsx(re,{id:"address_2",value:e.distribution_address_2||"",onChange:o=>s({distribution_address_2:o.target.value}),placeholder:"Apartment, suite, etc. (optional)"})]}),t.jsxs("div",{children:[t.jsxs(V,{htmlFor:"city",className:"text-sm",children:["City ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(re,{id:"city",value:e.distribution_city||"",onChange:o=>s({distribution_city:o.target.value}),placeholder:"City"})]})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs(V,{className:"text-base font-medium flex items-center gap-2",children:[t.jsx(Oa,{className:"h-4 w-4 text-muted-foreground"}),"Do you have safe storage available? ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs(ht,{value:e.distribution_safe_storage||"",onValueChange:o=>s({distribution_safe_storage:o}),children:[t.jsx(ut,{children:t.jsx(ft,{placeholder:"Select an option"})}),t.jsx(mt,{children:Lse.map(o=>t.jsx(Pe,{value:o.value,children:o.label},o.value))})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs(V,{className:"text-base font-medium flex items-center gap-2",children:[t.jsx(_t,{className:"h-4 w-4 text-muted-foreground"}),"Areas interested in delivering ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Select all areas you'd be willing to deliver to"}),t.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:Fse.map(o=>t.jsxs("label",{className:oe("flex items-center gap-2 p-3 rounded-lg border cursor-pointer transition-colors",a.includes(o.id)?"bg-primary/10 border-primary":"bg-background border-border hover:border-primary/50"),children:[t.jsx(Kt,{checked:a.includes(o.id),onCheckedChange:()=>i(o.id)}),t.jsx("span",{className:"text-sm",children:o.label})]},o.id))})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs(V,{className:"text-base font-medium flex items-center gap-2",children:[t.jsx(ua,{className:"h-4 w-4 text-muted-foreground"}),"Age Band ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs(ht,{value:e.distribution_age_band||"",onValueChange:o=>s({distribution_age_band:o}),children:[t.jsx(ut,{children:t.jsx(ft,{placeholder:"Select your age band"})}),t.jsx(mt,{children:Bse.map(o=>t.jsx(Pe,{value:o.value,children:o.label},o.value))})]})]}),t.jsx("div",{className:"pt-4 border-t",children:t.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[t.jsx(Kt,{checked:r.email_contact,onCheckedChange:o=>n({email_contact:o===!0}),className:"mt-0.5"}),t.jsxs("span",{className:"text-sm",children:["I consent to be contacted by email regarding distribution opportunities ",t.jsx("span",{className:"text-destructive",children:"*"})]})]})})]})},Use=e=>{switch(e){case"editorial":return{icon:Cw,color:"text-blue-600",bgColor:"bg-blue-100",title:"Story Submission",successTitle:"Story Submitted!",successMessage:"Thank y
755ou for sharing your story with us. Our editorial team will review your submission and get back to you within 5-7 working days. Keep an eye on your inbox for updates!"};case"advertising":return{icon:Xo,color:"text-community-green",bgColor:"bg-community-green/20",title:"Advertising Quote Request",successTitle:"Quote Request Received!",successMessage:"Thanks for your interest in advertising with Discover. A member of our sales team will contact you within 24 hours to discuss your advertising options and provide a tailored quote."};case"discover_extra":return{icon:ar,color:"text-purple-600",bgColor:"bg-purple-100",title:"Discover EXTRA Subscription",successTitle:"Welcome to Discover EXTRA!",successMessage:"You're now subscribed to our exclusive digital newsletter. Check your inbox for a confirmation email â your first edition will arrive soon with local news, offers, and community updates."};case"think_advertising":return{icon:_w,color:"text-rose-600",bgColor:"bg-rose-100",title:"THINK Advertising Subscription",successTitle:"Welcome to THINK!",successMessage:"You're now subscribed to THINK, our monthly marketing insights newsletter. Expect expert tips, advertising trends, and success stories delivered straight to your inbox."};case"distributor":return{icon:Sf,color:"text-orange-600",bgColor:"bg-orange-100",title:"Distributor Application",successTitle:"Application Received!",successMessage:"Thank you for applying to become a Discover distributor. Our distribution team will review your application and contact you within 3-5 working days to discu
755ss next steps."};default:return{icon:As,color:"text-gray-600",bgColor:"bg-gray-100",title:"Form Submission",successTitle:"Thank You!",successMessage:"Your submission has been received. We'll be in touch soon."}}},Kc=({journeyType:e,consents:s,onConsentChange:r,isSubmitted:n})=>{const a=Use(e),i=a.icon;return n?t.jsxs("div",{className:"text-center py-8",children:[t.jsx("div",{className:oe("inline-flex items-center justify-center w-20 h-20 rounded-full mb-6",a.bgColor),children:t.jsx(As,{className:oe("h-10 w-10",a.color)})}),t.jsx("h2",{className:"text-2xl font-heading font-bold text-community-navy mb-4",children:a.successTitle}),t.jsx("p",{className:"text-muted-foreground max-w-md mx-auto leading-relaxed",children:a.successMessage})]}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"text-center mb-6",children:[t.jsx("div",{className:oe("inline-flex items-center justify-center w-16 h-16 rounded-full mb-4",a.bgColor),children:t.jsx(i,{className:oe("h-8 w-8",a.color)})}),t.jsx("h2",{className:"text-2xl font-heading font-bold text-community-navy mb-2",children:"Almost There!"}),t.jsx("p",{className:"text-gray-600 text-sm",children:"Please review and confirm the following"})]}),t.jsxs("div",{className:"space-y-4 bg-gray-50 rounded-lg p-4",children:[t.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[t.jsx(Kt,{checked:s.terms_accepted,onCheckedChange:o=>r({terms_accepted:o===!0}),className:"mt-0.5"}),t.jsxs("div",{className:"text-sm",children:[t.jsxs("span",{className:"text-gray-700",children:["I agree to the"," ",t.jsx("a",{href:"/terms",className:"text-community-green hover:underline",children:"Terms of Service"})," ","and"," ",t.jsx("a",{href:"/privacy",className:"text-community-green hover:underline",children:"Privacy Policy"})]}),t.jsx("span",{className:"text-destructive ml-1",children:"*"})]})]}),t.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[t.jsx(Kt,{checked:s.privacy_accepted,onCheckedChange:o=>r({privacy_accepted:o===!0}),className:"mt-0.5"}),t.jsxs("div",{className:"text-sm text-gray-700",children:["I understand my data will be processed as described in the Privacy Policy",t.jsx("span",{className:"text-destructive ml-1",children:"*"})]})]}),t.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[t.jsx(Kt,{checked:s.marketing_email,onCheckedChange:o=>r({marketing_email:o===!0}),className:"mt-0.5"}),t.jsxs("div",{className:"text-sm text-gray-700",children:["I'd like to receive occasional updates and news from Discover",t.jsx("span",{className:"text-gray-400 ml-1",children:"(optional)"})]})]})]}),t.jsx("p",{className:"text-xs text-gray-500 text-center",children:"By submitting this form, you confirm that the information provided is accurate."})]})},Vse=e=>{switch(e){case"editorial":return{icon:Cw,color:"text-blue-600",bgColor:"bg-blue-100"};case"advertising":return{icon:Xo,color:"text-community-green",bgColor:"bg-community-green/20"};case"discover_extra":return{icon:ar,color:"text-purple-600",bgColor:"bg-purple-100"};case"think_advertising":return{icon:_w,color:"text-rose-600",bgColor:"bg-rose-100"};case"distributor":return{icon:Sf,color:"text-orange-600",bgColor:"bg-orange-100"};default:return null}},qse=e=>{switch(e){case"editorial":return"Editorial Submission";case"advertising":return"Advertising Quote";case"discover_extra":return"Discover EXTRA";case"think_advertising":return"THINK Advertising";case"distributor":return"Distributor Application";default:return""}},Hse=({journeyType:e,currentStep:s,steps:r})=>{const n=Vse(e);if(!e||r.length<=1)return null;const a=n==null?void 0:n.icon;return t.jsxs("div",{className:"mb-8",children:[n&&a&&t.jsxs("div",{className:"flex items-center justify-center gap-2 mb-6",children:[t.jsx("div",{className:oe("p-2 rounded-full",n.bgColor),children:t.jsx(a,{className:oe("h-5 w-5",n.color)})}),t.jsx("span",{className:oe("font-semibold",n.color),children:qse(e)})]}),t.jsx("div",{className:"flex items-center justify-center",children:r.map((i,o)=>{const l=o<s,c=o===s,d=o>s;return t.jsxs("div",{className:"flex items-center",children:[t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx("div",{className:oe("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",l&&"bg-community-green text-white",c&&"bg-community-navy text-white ring-4 ring-community-navy/2
7550",d&&"bg-gray-100 text-gray-400"),children:l?t.jsx(Bs,{className:"h-4 w-4"}):o+1}),t.jsx("span",{className:oe("hidden sm:block text-xs mt-2 max-w-[80px] text-center",c?"text-community-navy font-medium":"text-gray-500"),children:i})]}),o<r.length-1&&t.jsx("div",{className:oe("w-8 sm:w-12 h-0.5 mx-1",o<s?"bg-community-green":"bg-gray-200")})]},i)})}),t.jsxs("p",{className:"sm:hidden text-center mt-4 text-sm text-gray-600",children:["Step ",s+1,": ",t.jsx("span",{className:"font-medium",children:r[s]})]})]})},Wse=()=>{const{formState:e,isSubmitting:s,isSubmitted:r,submissionError:n,uploadProgress:a,setJourneyType:i,updateContact:o,updateData:l,updateConsents:c,nextStep:d,prevStep:m,resetForm:h,getStepNames:f,submitForm:p,retrySubmit:x}=Nse(),{journey_type:g,current_step:b,contact:w,data:j,consents:y}=e,v=f(),N=()=>{var R,A,T;if(b===0)return!!g;if(g==="editorial"){if(b===1){const P=j,B=(P.editorial_story_summary||"").trim().split(/\s+/).filter(Boolean).length;return!!(P.editorial_story_summary&&B<=30&&P.editorial_category&&P.editorial_story_text&&y.email_contact)}if(b===2)return!!(w.first_name&&w.last_name&&w.email&&w.phone);if(b===3)return y.terms_accepted&&y.privacy_accepted}if(g==="advertising"){if(b===1){const P=j;return!!(P.advertising_business_name&&P.advertising_seen_hard_copy&&P.advertising_current_situation&&P.advertising_leaflet_interest&&(((R=P.advertising_editions_interested)==null?void 0:R.length)??0)>0&&(((A=P.advertising_ad_sizes)==null?void 0:A.length)??0)>0&&P.advertising_how_heard&&y.consent_email_contact_required)}if(b===2)return!!(w.first_name&&w.last_name&&w.email&&w.phone);if(b===3)return y.terms_accepted&&y.privacy_accepted}if(g==="discover_extra"){if(b===1)return!!(w.first_name&&w.email&&y.discover_extra);if(b===2){const P=j;return!!(P.newsletter_discover_keep_use_frequency&&P.newsletter_discover_source_local_business&&P.newsletter_discover_rating&&y.discover_extra)}if(b===3)return y.terms_accepted&&y.privacy_accepted}if(g==="think_advertising"){if(b===1)return!!(w.first_name&&w.email);if(b===2)return y.think_monthly;if(b===3)return y.terms_accepted&&y.privacy_accepted}if(g==="distributor"){if(b===1)return!!(w.first_name&&w.last_name&&w.email&&w.phone&&w.postcode);
755if(b===2){const P=j;return!!(P.distribution_address_1&&P.distribution_city&&P.distribution_safe_storage&&(((T=P.distribution_areas_interested)==null?void 0:T.length)??0)>0&&P.distribution_age_band&&y.email_contact)}if(b===3)return y.terms_accepted&&y.privacy_accepted}return!0},S=b===v.length-1,k=async()=>{if(S)try{await p()}catch{}else d()},$=()=>{if(b===0)return t.jsx(Sse,{selectedJourney:g,onSelect:i});if(r)return t.jsx(Kc,{journeyType:g,consents:y,onConsentChange:c,isSubmitted:!0});switch(g){case"editorial":if(b===1)return t.jsx(kse,{data:j,onChange:l,consents:y,onConsentsChange:c});if(b===2)return t.jsx(xm,{contact:w,journeyType:g,onChange:o});if(b===3)return t.jsx(Kc,{journeyType:g,consents:y,onConsentChange:c,isSubmitted:!1});break;case"advertising":if(b===1)return t.jsx(Dse,{data:j,onChange:l,consents:y,onConsentsChange:c});if(b===2)return t.jsx(xm,{contact:w,journeyType:g,onChange:o});if(b===3)return t.jsx(Kc,{journeyType:g,consents:y,onConsentChange:c,isSubmitted:!1});break;case"discover_extra":if(b===1)return t.jsx(xm,{contact:w,journeyType:g,onChange:o,consents:y,onConsentsChange:c});if(b===2)return t.jsx(S3,{data:j,onChange:l,journeyType:g,consents:y,onConsentsChange:c});if(b===3)return t.jsx(Kc,{journeyType:g,consents:y,onConsentChange:c,isSubmitted:!1});break;case"think_advertising":if(b===1)return t.jsx(xm,{contact:w,journeyType:g,onChange:o});if(b===2)return t.jsx(S3,{data:j,onChange:l,journeyType:g,consents:y,onConsentsChange:c});if(b===3)return t.jsx(Kc,{journeyType:g,consents:y,onConsentChange:c,isSubmitted:!1});break;case"distributor":if(b===1)return t.jsx(xm,{contact:w,journeyType:g,onChange:o});if(b===2)return t.jsx(zse,{data:j,onChange:l,consents:y,onConsentsChange:c});if(b===3)return t.jsx(Kc,{journeyType:g,consents:y,onConsentChange:c,isSubmitted:!1});break}return null};return t.jsx(xe,{className:"border-community-green/20 shadow-lg",children:t.jsxs(ge,{className:"p-6 sm:p-8",children:[t.jsx(Hse,{journeyType:g,currentStep:b,steps:v}),t.jsx("div",{className:"min-h-[400px]",children:$()}),n&&!r&&t.jsxs("div",{className:"mt-4 p-4 bg-destructive/10 border border-destructive/20 rounded-lg flex items-start gap-3",children:[t.jsx(Hs,{className:"h-5 w-5 text-destructive flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm text-destructive font-medium",children:"Submission Failed"}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:n})]}),t.jsx(q,{variant:"outline",size:"sm",onClick:x,disabled:s,className:"flex-shrink-0",children:s?t.jsx(it,{className:"h-4 w-4 animate-spin"}):t.jsxs(t.Fragment,{children:[t.jsx(q4,{className:"h-4 w-4 mr-1"}),"Retry"]})})]}),r?t.jsx("div",{className:"flex justify-center mt-8 pt-6 border-t",children:t.jsxs(q,{onClick:h,variant:"outline",children:[t.jsx(q4,{className:"h-4 w-4 mr-2"}),"Start New Form"]})}):t.jsxs("div",{className:"flex justify-between mt-8 pt-6 border-t",children:[b>0?t.jsxs(q,{variant:"outline",onClick:m,disabled:s,children:[t.jsx(Hi,{className:"h-4 w-4 mr-2"}),"Back"]}):t.jsx("div",{}),t.jsx(q,{onClick:k,disabled:!N()||s,className:"bg-community-green hover:bg-community-green/90",children:s?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"h-4 w-4 mr-2 animate-spin"}),a?`Uploading file ${a.current} of ${a.total}...`:"Submitting..."]}):S?"Submit":t.jsxs(t.Fragment,{children:["Continue",t.jsx(jf,{className:"h-4 w-4 ml-2"})]})})]})]})})},Gse=()=>t.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-community-yellow/20 via-white to-community-green/20",children:[t.jsx(gs,{}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 text-center",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsx("h1",{className:"text-4xl md:text-6xl font-heading font-bold text-community-navy mb-6",children:"Contact Us"}),t.jsx("p",{className:"text-xl text-gray-600 font-body max-w-2xl mx-auto",children:"Get in touch with our friendly team. We're here to help with all your enquiries."})]})}),t.jsx("section",{className:"py-12 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-7xl mx-auto",children:t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[t.jsxs("div",{className:"order-1 lg:order-2",children:[t.jsx("h2",{className:"text-2xl font-heading font-bold text-community-navy mb-6",children:"Discover Forms Hub"}),t.jsx(Wse,{})]}),t.jsx("div",{className:"order-2 lg:order-1",children:t.jsxs(xe,{className:"border-community-green/20 shadow-lg h-fit",children:[t.jsx(Me,{className:"bg-gradient-to-r from-community-green/10 to-community-yellow/10 pb-4",children:t.jsxs(Oe,{className:"flex items-center gap-3 text-2xl text-community-navy",children:[t.jsx(zr,{className:"h-6 w-6 text-community-green"}),"Contact Details"]}
755)}),t.jsxs(ge,{className:"p-6",children:[t.jsxs("div",{className:"grid md:grid-cols-2 gap-6 mb-6",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-community-navy mb-2",children:"Main Number"}),t.jsx("p",{className:"text-2xl font-mono text-community-green font-bold mb-3",children:"023 8026 6388"}),t.jsxs("div",{className:"space-y-1.5 text-sm text-gray-700 bg-community-green/5 p-3 rounded-lg",children:[t.jsx("p",{className:"font-semibold text-community-navy mb-2",children:"Phone Menu:"}),t.jsxs("p",{children:["Press ",t.jsx("span",{className:"font-mono font-bold text-community-navy",children:"1"})," for advertising sales"]}),t.jsxs("p",{children:["Press ",t.jsx("span",{className:"font-mono font-bold text-community-navy",children:"2"})," for accounts"]}),t.jsxs("p",{children:["Press ",t.jsx("span",{className:"font-mono font-bold text-community-navy",children:"3"})," for design & production"]}),t.jsxs("p",{children:["Press ",t.jsx("span",{className:"font-mono font-bold text-community-navy",children:"4"})," for distributor enquiries"]}),t.jsx("p",{className:"pt-1 italic text-gray-500",children:"Hold for Reception"})]})]}),t.jsxs("div",{children:[t.jsxs("h3",{className:"text-lg font-semibold text-community-navy mb-2 flex items-center gap-2",children:[t.jsx(ws,{className:"h-4 w-4"}),"Phone Line Hours"]}),t.jsx("p",{className:"text-gray-700",children:"Mon-Fri: 8am - 8pm"}),t.jsx("p",{className:"text-gray-700 mb-4",children:"Sat & Sun: 9am - 5pm"}),t.jsxs("h3",{className:"text-lg font-semibold text-community-navy mb-2 flex items-center gap-2",children:[t.jsx(_t,{className:"h-4 w-4"}),"Office Address"]}),t.jsx("p",{className:"text-gray-700",children:"30 Leigh Road"}),t.jsx("p",{className:"text-gray-700 mb-1",children:"Eastleigh SO50 9DT"}),t.jsx("p",{className:"text-sm text-gray-600",children:"Mon-Fri: 9am-5pm (Fri 4pm)"}),t.jsx("p",{className:"text-sm text-community-green font-semibold",children:"Visitors welcome!"})]})]}),t.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[t.jsxs("h3",{className:"font-semibold text-community-navy mb-2 flex items-center gap-2",children:[t.jsx(Sf,{className:"h-4 w-4"}),"Depot/Deliveries"]}),t.jsxs("p",{className:"text-gray-700 text-sm",children:["Car park at rear via Toynbee Road â",t.jsx("a",{href:"https://what3words.com/flip.envy.player",target:"_blank",rel:"noopener noreferrer",className:"text-community-green hover:text-community-green/80 underline ml-1",children:"what3words: flip.envy.player"})]})]})]})]})})]})})}),t.jsx(vs,{})]}),Yse=()=>{const[e,s]=u.useState(""),[r,n]=u.useState(""),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(!1),[m,h]=u.useState(!1),[f,p]=u.useState(!1),[x,g]=u.useState(""),[b,w]=u.useState(!1),j=ds(),{toast:y}=rt(),{user:v,isAdmin:N,signIn:S,signUp:k}=Ar();u.useEffect(()=>{v&&j(N?"/admin":"/dashboard")},[v,N,j]);const $=async(P,B)=>{try{await W.functions.invoke("send-welcome-email",{body:{email:P,displayName:B}})}catch(Y){console.error("Error sending welcome email:",Y)}},R=async P=>{P.preventDefault(),h(!0);try{const{error:B,needsConfirmation:Y}=await k(a,o);B?y({title:"Sign Up Error",description:B.message,variant:"destructive"}):(i(""),l(""),Y&&await $(a))}catch{y({title:"Error",description:"An unexpected error occurred. Please try again.",variant:"destructive"})}finally{h(!1)}},A=async P=>{P.preventDefault(),d(!0);try{const{error:B}=await S(e,r);B?y({title:"Sign In Error",description:B.message,variant:"destructive"}):(s(""),n(""))}catch{y({title:"Error",description:"An unexpected error occurred. Please try again.",variant:"destructive"})}finally{d(!1)}},T=async P=>{if(P.preventDefault(),!x){y({title:"Email required",description:"Please enter your email address.",variant:"destructive"});return}w(!0);try{const{data:B,error:Y}=await W.functions.invoke("send-password-reset",{body:{email:x}});if(Y)throw console.error("Password reset error:",Y),new Error(Y.message||"Failed to send reset email");if(B!=null&&B.error)throw new Error(B.error);y({title:"Check your email",description:"We've sent you a password reset link. Please check your inbox."}),p(!1),g("")}catch(B){console.error("Unexpected error during password reset:",B),y({title:"Error",description:B.message||"An unexpected error occurred. Please try again.",variant:"destructive"})}finally{w(!1)}};return t.jsxs("div",{className:"min-h-screen",children:[t.jsx(gs,{}),t.jsx("main",{className:"py-16 bg-gray-50",children:t.jsxs("div",{className:"max-w-md mx-auto px-4",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("h1",{className:"text-3xl font-heading font-bold mb-4",children:"Business Owner Portal"}),t.jsx("p",{className:"text-gray-600",children:"Sign in to manage your business listings and connect with local customers."})]}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-center",children:"Get Started"})}),t.jsx(ge,{children:t.jsxs(ha,{defaultValue:"signin",className:"w-full",children:[t.jsxs(Hn,{className:"grid w-full grid-cols-2",children:[t.jsx(Rt,{value:"signin",children:"Sign In"}),t.jsx(Rt,{value:"signup",children:"Register"})]}),t.jsx(Mt,{value:"signin",children:t.jsxs("form",{onSubmit:A,className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"signin-email",className:"block text-sm font-medium mb-1",children:"Email"}
755),t.jsx(re,{id:"signin-email",type:"email",value:e,onChange:P=>s(P.target.value),required:!0,placeholder:"Enter your email",disabled:c})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"signin-password",className:"block text-sm font-medium mb-1",children:"Password"}),t.jsx(re,{id:"signin-password",type:"password",value:r,onChange:P=>n(P.target.value),required:!0,placeholder:"Enter your password",disabled:c})]}),t.jsx(q,{type:"submit",className:"w-full bg-community-green hover:bg-green-600",disabled:c,children:c?"Signing In...":"Sign In"}),t.jsx("div",{className:"text-center",children:t.jsx("button",{type:"button",onClick:()=>p(!0),className:"text-sm text-community-green hover:underline",children:"Forgot your password?"})})]})}),t.jsx(Mt,{value:"signup",children:t.jsxs("form",{onSubmit:R,className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"signup-email",className:"block text-sm font-medium mb-1",children:"Email"}),t.jsx(re,{id:"signup-email",type:"email",value:a,onChange:P=>i(P.target.value),required:!0,placeholder:"Enter your email",disabled:m})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"signup-password",className:"block text-sm font-medium mb-1",children:"Password"}),t.jsx(re,{id:"signup-password",type:"password",value:o,onChange:P=>l(P.target.value),required:!0,placeholder:"Create a password",minLength:6,disabled:m})]}),t.jsx(q,{type:"submit",className:"w-full bg-community-green hover:bg-green-600",disabled:m,children:m?"Creating Account...":"Create Account"})]})})]})})]})]})}),t.jsx(vs,{}),t.jsx(bt,{open:f,onOpenChange:p,children:t.jsxs(xt,{className:"sm:max-w-md",children:[t.jsxs(jt,{children:[t.jsx(wt,{children:"Reset Password"}),t.jsx(ys,{children:"Enter your email address and we'll send you a link to reset your password."})]}),t.jsxs("form",{onSubmit:T,children:[t.jsx("div",{className:"space-y-4 py-4",children:t.jsxs("div",{children:[t.jsx("label",{htmlFor:"forgot-email",className:"block text-sm font-medium mb-1",children:"Email Address"}),t.jsx(re,{id:"forgot-email",type:"email",value:x,onChange:P=>g(P.target.value),required:!0,placeholder:"Enter your email",disabled:b})]})}),t.jsxs(ma,{children:[t.jsx(q,{type:"button",variant:"outline",onClick:()=>p(!1),disabled:b,children:"Cancel"}),t.jsx(q,{type:"submit",className:"bg-community-green hover:bg-green-600",disabled:b,children:b?"Sending...":"Send Reset Link"})]})]})]})})]})},Kse=[{id:1,name:"Southampton City Suburbs",postcodes:"SO15 SO16 SO17",homes:1e4,color:"#93C572",highlightImage:"870.png",buttonPosition:{top:52,left:38},coverageDetails:"ABC1 homes in the more affluent residential suburban streets of Southampton including Chilworth, Upper Shirley, Rownhams, Nursling Bassett Green, Regents Park, Highfield. Sector 7 of SO16 is delivered to by Royal Mail. Excluding HMO, student areas & flats.",leafletService:{available:!0,homes:7100}},{id:2,name:"Chandler's Ford",postcodes:"SO53",homes:11300,color:"#F5D547",highlightImage:"868.png",buttonPosition:{top:38,left:44},coverageDetails:"Affluent residential suburb between Southampton and Winchester. Includes Valley Park, Knightwood, Hiltingbury, Chalvington, Toynbee, Peverells Wood, Scantabout, Hocombe.",leafletService:{available:!0,homes:11300}},{id:3,name:"Fair Oak, Horton Heath & Eastleigh",postcodes:"SO50",homes:12500,color:"#E6A8D7",highlightImage:"863.png",buttonPosition:{top:42,left:52},coverageDetails:"Majority of this circulation covers Bishopstoke, Fair Oak, Horton Heath, Lakeside plus the more affluent residential streets of Eastleigh. Properties are either detached or semi-detached, townhouses but excluding flats, council owned areas and terraced houses.",leafletService:{available:!0,homes:12500}},{id:4,name:"Hedge End & Botley",postcodes:"SO30",homes:9400,color:"#87CEEB",highlightImage:"861.png",buttonPosition:{top:56,left:56},coverageDetails:"A community east of Southampton, Hedge End and Botley is primarily residential with a retail park and village high streets. A mixture of new build estates, bungalows, older detached and semi-detached homes.",leafletService:{available:!0,homes:9400}},{id:5,name:"Locks Heath & Whiteley",postcodes:"SO31 PO15",homes:12e3,color:"#D2691E",highlightImage:"837.png",buttonPosition:{top:74,left:58},coverageDetails:"This area includes the residential communities of Locks Heath, Park Gate, Sarisbury Green, Warsash and the new build estate of Whiteley. The suburban area straddles the M27 and lies equidistant from Southampton and Fareham.",leafletService:{available:!0,homes:12e3}},{id:6,name:"Fareham & Villages",postcodes:"PO12, PO13, PO14, PO15, PO16",homes:12100,color:"#FF6B6B",highlightImage:"774.png",buttonPosition:{top:80,left:72},coverageDetails:"West of Portsmouth lie the town of Fareham plus a collection of villages; Stubbington, Lee-on-the-Solent, Titchfield. Discover is delivered to selected above average affluent homes in the west side of Fareham.",leafletService:{available:!0,homes:12100}},{id:7,name:"Wickham, B Waltham & Meon Valley Villages",postcodes:"SO32 PO17",homes:12400,color:"#9370D
755B",highlightImage:"770.png",buttonPosition:{top:48,left:68},coverageDetails:"Often referred to as Meon Valley. Delivered is by Royal Mail and every property in the postcode SO32 includes two sectors 1 and 2 which include the market town of Bishop's Waltham, Waltham Chase, Swanmore, Durley, Upham, Boorley Green. Also included is PO17 which includes Wickham, Shedfield, Shirrell Heath.",leafletService:{available:!1}},{id:8,name:"Winchester & Surrounding Villages",postcodes:"SO21 SO22 SO23",homes:12e3,color:"#20B2AA",highlightImage:"763.png",buttonPosition:{top:26,left:52},coverageDetails:"The residential suburbs of this affluent, historic city of Winchester include Fulflood, Tegwood, Badger Farm, Olivers Battery, St Cross, Sleepers Hill, Pitt, Kings Worthy, Abbots Barton, Headbourne Worthy, surrounding villages is city center, Weeke, Harestock.",leafletService:{available:!0,homes:8e3}},{id:9,name:"Romsey & North Baddesley",postcodes:"SO51 SO52",homes:8600,color:"#FFB347",highlightImage:"758.png",buttonPosition:{top:40,left:34},coverageDetails:"The residential areas of market town of Romsey including Abbotswood plus the 3,000 strong suburban community between Romsey and Chandler's Ford of North Baddesley.",leafletService:{available:!0,homes:8600}},{id:10,name:"Totton",postcodes:"SO40",homes:7e3,color:"#98D8C8",highlightImage:"749.png",buttonPosition:{top:58,left:30},coverageDetails:"Just west of Southampton this fairly new suburb is a mix of new build estates and bungalows. Included is West Totton, Testwood, Hangers Farm, Testbourne, Rushington, Hammonds Green. The council estate of Calmore and Eling is excluded.",leafletService:{available:!0,homes:7e3}},{id:11,name:"New Forest & Waterside",postcodes:"SO40, SO41, SO42, SO43, SO45",homes:10640,color:"#228B22",highlightImage:"711.png",buttonPosition:{top:68,left:26},coverageDetails:"The New Forest postcodes are delivered to by Royal Mail so every property, many rural, remote and high value properties in SO42, SO43 and parts of SO41 receive Discover. Towns included are Lyndhurst, Brockenhurst, Beaulieu, Minstead, Ashurst, Boldre, Bramshaw.",leafletService:{available:!0,homes:4e3,note:"Waterside only"}},{id:12,name:"Sholing, Itchen & Woolston",postcodes:"SO19",homes:7e3,color:"#FF69B4",highlightImage:"708.png",buttonPosition:{top:60,left:46},coverageDetails:"This area is a compact residential suburb east of Southampton reached by the Itchen Bridge or south from M27. Selected properties in Sholing, Itchen, Peartree and Woolston.",leafletService:{available:!0,homes:7e3}},{id:13,name:"Hamble, Netley, Bursledon & West End",postcodes:"SO18 SO31",homes:9200,color:"#DDA0DD",highlightImage:"665.png",buttonPosition:{top:68,left:52},coverageDetails:"Neighbouring Area 12 and south of M27 including West End (near Hedge End), Chalk Hill, parts of Bitterne, Bursledon down to the quaint and popular harbour village of Hamble and nearby Netley. Excluded: Townhill.",leafletService:{available:!0,homes:9200}},{id:14,name:"Stockbridge, Wellows & Test Valley Villages",postcodes:"SO51, SO20",homes:8e3,color:"#B8860B",highlightImage:"662.png",buttonPosition:{top:16,left:32},coverageDetails:"This postcode covers an expansive rural district including the Test Valley villages around Romsey, Stockbridge, West Tytherley, Kings Somborne, Broughton, Houghton, Braishfield, Lockerley, Awbridge, Timsbury, Michelmarsh, Wellow, plus the outer Winchester villages.",leafletService:{available:!1}}];function e9(e){const[s,r]=u.useState([]),[n,a]=u.useState(!0),{toast:i}=rt(),o=u.useCallback(async(f=!0)=>{try{a(!0);let p=W.from(e).select("*").order("sort_order",{ascending:!0});f&&(p=p.eq("is_active",!0));const{data:x,error:g}=await p;if(g)throw g;r(x||[])}catch(p){console.error(`Error fetching ${e}:`,p)}finally{a(!1)}},[e]),l=async f=>{try{const p=s.reduce((g,b)=>Math.max(g,b.sort_order),-1),{error:x}=await W.from(e).insert({name:f,sort_order:p+1});if(x)throw x;return i({title:"Created",description:`"${f}" added successfully`}),await o(!1),!0}catch(p){return i({title:"Error",description:p.message,variant:"destructive"}),!1}},c=async(f,p)=>{try{const{error:x}=await W.from(e).update(p).eq("id",f);if(x)throw x;return await o(!1),!0}catch(x){return i({title:"Error",description:x.message,variant:"destructive"}),!1}},d=async f=>{try{const{error:p}=await W.from(e).delete().eq("id",f);if(p)throw p;return i({title:"Deleted",description:"Item removed successfully"}),await o(!1),!0}catch(p){return i({title:"Error",description:p.message,variant:"destructive"}),!1}},m=async f=>{if(f<=0)return;const p=s[f],x=s[f-1];await Promise.all([c(p.id,{sort_order:x.sort_order}),c(x.id,{sort_order:p.sort_order})])},h=async f=>{if(f>=s.length-1)return;const p=s[f],x=s[f+1];await Promise.all([c(p.id,{sort_order:x.sort_order}),c(x.id,{sort_order:p.sort_order})])};return u.useEffect(()=>{o()},[o]),{items:s,loading:n,fetch:o,create:l,update:c,remove:d,moveUp:m,moveDown:h}}function t9(e=!0){const s=e9("event_categories");return u.useEffect(()=>{s.fetch(e)},[e]),s}function s9(e=!0){const s=e9("event_types");return u.useEffect(()=>{s.fetch(e)},[e]),s}function r9({formData:e,onChange:s,imagePreview:r,existingImageUrl:n,onImageChange:a,disabled:i=!1,showInfoBanner:o=!1,isOnBehalf:l=!1}){const{items:c}=t9(),{items:d}=s9(),m=u.useRef(null),h=r||n||null,f=p=>{var g;const x=((g=p.target.files)==null?void 0:g[0])||null;a(x)};return t.jsxs("div",{className:"space-y-8",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[t.jsx(It,{className:"h-5 w-5 text-primary"}),"Basic Information"]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"md:col-span-2",children:[t.jsx(V,{htmlFor:"title",children:"Event Title *"}),t.jsx(re,{id:"title",value:e.title,onChange:p=>s("title",p.target.value),placeholder:"e.g. Summer Music Festival",disabled:i,required:!0})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"organizer",children:"Organiser *"}),t.jsx(re,{id:"organizer",value:e.organizer,onChange:p=>s("organizer",p.target.value),placeholder:"e.g. Local Community Group",disabled:i,required:!0})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"category",children:"Category *"}),t.jsxs(ht,{value:e.category,onValueChange:p=>s("category",p),disabled:i,children:[t.jsx(ut,{id:"category",children:t.jsx(ft,{placeholder:"Select"})}),t.jsx(mt,{children:c.map(p=>t.jsx(Pe,{value:p.name,children:p.name},p.id))})]})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"type",children:"Type *"}),t.jsxs(ht,{value:e.type,onValueChange:p=>s("type",p),disabled:i,children:[t.jsx(ut,{id:"type",children:t.jsx(ft,{placeholder:"Select"})}),t.jsx(mt,{children:d.map(p=>t.jsx(Pe,{value:p.name,children:p.name},p.id))})]})]})]})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[t.jsx(ws,{className:"h-5 w-5 text-primary"}),"Date & Time"]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"date",children:"Start Date *"}),t.jsx(re,{id:"date",type:"date",value:e.date,onChange:p=>s("date",p.target.value),disabled:i,required:!0})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"date_end",children:"End Date (optional)"}),t.jsx(re,{id:"date_end",type:"date",value:e.date_end,onChange:p=>s("date_end",p.target.value),min:e.date,disabled:i}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Leave blank for single-day events"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"time",children:"Start Time *"}),t.jsx(re,{id:"time",type:"time",value:e.time,onChange:p=>s("time",p.target.value),disabled:i,required:!0})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"end_time",children:"End Time"}),t.jsx(re,{id:"end_time",type:"time",value:e.end_time,onChange:p=>s("end_time",p.target.value),disabled:i})]})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[t.jsx(_t,{className:"h-5 w-5 text-primary"}
755),"Location"]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"md:col-span-2",children:[t.jsx(V,{htmlFor:"location",children:"Venue / Address *"}),t.jsx(re,{id:"location",value:e.location,onChange:p=>s("location",p.target.value),placeholder:"e.g. Community Hall, 123 High Street",disabled:i,required:!0})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"area",children:"Area / Town *"}),t.jsxs(ht,{value:e.area,onValueChange:p=>s("area",p),disabled:i,children:[t.jsx(ut,{id:"area",children:t.jsx(ft,{placeholder:"Select your area"})}),t.jsx(mt,{children:Kse.map(p=>t.jsxs(Pe,{value:p.name,children:[p.name," (",p.postcodes,")"]},p.id))})]})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"postcode",children:"Postcode"}),t.jsx(re,{id:"postcode",value:e.postcode,onChange:p=>s("postcode",p.target.value),placeholder:"e.g. RG40 1AA",disabled:i})]})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold",children:"Description"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"excerpt",children:"Short Description (max 200 characters)"}),t.jsx(ms,{id:"excerpt",value:e.excerpt,onChange:p=>s("excerpt",p.target.value.slice(0,200)),placeholder:"A brief summary of your event...",className:"h-20",disabled:i,maxLength:200}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[e.excerpt.length,"/200 characters"]})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"full_description",children:"Full Description"}),t.jsx(ms,{id:"full_description",value:e.full_description,onChange:p=>s("full_description",p.target.value),placeholder:"Tell people more about your event, what to expect, what to bring...",className:"min-h-[150px]",disabled:i})]})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[t.jsx(pi,{className:"h-5 w-5 text-primary"}),"Event Image"]}),t.jsxs("div",{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors 756 ${h?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary"}`,onClick:()=>{var p;return!i&&((p=m.current)==null?void 0:p.click())},children:[t.jsx("input",{ref:m,type:"file",accept:"image/*",onChange:f,className:"hidden",disabled:i}),h?t.jsxs("div",{className:"space-y-4",children:[t.jsx("img",{src:h,alt:"Preview",className:"max-h-48 mx-auto rounded-lg object-cover"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to change image"})]}):t.jsxs("div",{className:"space-y-2",children:[t.jsx(sn,{className:"h-10 w-10 mx-auto text-muted-foreground"}),t.jsx("p",{className:"text-sm font-medium",children:"Click to upload an image"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"PNG, JPG or WEBP (max 5MB)"})]})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[t.jsx(bn,{className:"h-5 w-5 text-primary"}),"Contact & Links"]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsxs(V,{htmlFor:"contact_email",children:["Contact Email ",l&&t.jsx("span",{className:"text-destructive",children:"* (organiser login)"})]}),t.jsxs("div",{className:"relative",children:[t.jsx(ar,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(re,{id:"contact_email",type:"email",value:e.contact_email,onChange:p=>s("contact_email",p.target.value),placeholder:"[email protected]",className:"pl-10",disabled:i,required:l})]})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"contact_phone",children:"Contact Phone"}),t.jsxs("div",{className:"relative",children:[t.jsx(zr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(re,{id:"contact_phone",type:"tel",value:e.contact_phone,onChange:p=>s("contact_phone",p.target.value),placeholder:"01234 567890",className:"pl-10",disabled:i})]})]}),t.jsxs("div",{className:"md:col-span-2",children:[t.jsx(V,{htmlFor:"website_url",children:"Website Address"}),t.jsxs("div",{className:"relative",children:[t.jsx(Tc,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(re,{id:"website_url",type:"url",value:e.website_url,onChange:p=>s("website_url",p.target.value),placeholder:"https://www.example.com",className:"pl-10",disabled:i})]})]}),t.jsxs("div",{className:"md:col-span-2",children:[t.jsx(V,{htmlFor:"ticket_url",children:"Ticket / Booking URL"}),t.jsxs("div",{className:"relative",children:[t.jsx(Sw,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(re,{id:"ticket_url",type:"url",value:e.ticket_url,onChange:p=>s("ticket_url",p.target.value),placeholder:"https://tickets.example.com/event",className:"pl-10",disabled:i})]})]})]})]}),o&&t.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 flex gap-3",children:[t.jsx(Hs,{className:"h-5 w-5 text-primary flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"text-sm",children:[t.jsx("p",{className:"font-medium mb-1",children:"Review Process"}),t.jsx("p",{className:"text-muted-foreground",children:"All events are reviewed before being published. This usually takes 1-2 business days. We'll notify you once your event is live."})]})]})]})}const n9={title:"",organizer:"",date:"",date_end:"",time:"",end_time:"",location:"",area:"",postcode:"",category:"",type:"",excerpt:"",full_description:"",ticket_url:"",contact_email:"",contact_phone:"",website_url:""},p0=768;function Qse(){const[e,s]=u.useState(void 0);return u.useEffect(()=>{const r=window.matchMedia(`(max-width: ${p0-1}px)`),n=()=>{s(window.innerWidth<p0)};return r.addEventListener("change",n),s(window.innerWidth<p0),()=>r.removeEventListener("change",n)},[]),!!e}const Xse="sidebar:state",Zse=60*60*24*7,Jse="16rem",ere="18rem",tre="3rem",sre="b",a9=u.createContext(null);function Yu(){const e=u.useContext(a9);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const SN=u.forwardRef(({defaultOpen:e=!0,open:s,onOpenChange:r,className:n,style:a,children:i,...o},l)=>{const c=Qse(),[d,m]=u.useState(!1),[h,f]=u.useState(e),p=s??h,x=u.useCallback(j=>{const y=typeof j=="function"?j(p):j;r?r(y):f(y),document.cookie=`${Xse}=${y}; path=/; max-age=${Zse}`},[r,p]),g=u.useCallback(()=>c?m(j=>!j):x(j=>!j),[c,x,m]);u.useEffect(()=>{const j=y=>
756{y.key===sre&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),g())};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[g]);const b=p?"expanded":"collapsed",w=u.useMemo(()=>({state:b,open:p,setOpen:x,isMobile:c,openMobile:d,setOpenMobile:m,toggleSidebar:g}),[b,p,x,c,d,m,g]);return t.jsx(a9.Provider,{value:w,children:t.jsx(QE,{delayDuration:0,children:t.jsx("div",{style:{"--sidebar-width":Jse,"--sidebar-width-icon":tre,...a},className:oe("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",n),ref:l,...o,children:i})})})});SN.displayName="SidebarProvider";const CN=u.forwardRef(({side:e="left",variant:s="sidebar",collapsible:r="offcanvas",className:n,children:a,...i},o)=>{const{isMobile:l,state:c,openMobile:d,setOpenMobile:m}=Yu();return r==="none"?t.jsx("div",{className:oe("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",n),ref:o,...i,children:a}):l?t.jsx(i2,{open:d,onOpenChange:m,...i,children:t.jsx($v,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":ere},side:e,children:t.jsx("div",{className:"flex h-full w-full flex-col",children:a})})}):t.jsxs("div",{ref:o,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":c==="collapsed"?r:"","data-variant":s,"data-side":e,children:[t.jsx("div",{className:oe("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",s==="floating"||s==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),t.jsx("div",{className:oe("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",s==="floating"||s==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",n),...i,children:t.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:a})})]})});CN.displayName="Sidebar";const kN=u.forwardRef(({className:e,onClick:s,...r},n)=>{const{toggleSidebar:a}=Yu();return t.jsxs(q,{ref:n,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:oe("h-7 w-7",e),onClick:i=>{s==null||s(i),a()},...r,children:[t.jsx(iL,{}),t.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});kN.displayName="SidebarTrigger";const rre=u.forwardRef(({className:e,...s},r)=>{const{toggleSidebar:n}=Yu();return t.jsx("button",{ref:r,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:n,title:"Toggle Sidebar",className:oe("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...s})});rre.displayName="SidebarRail";const i9=u.forwardRef(({className:e,...s},r)=>t.jsx("main",{ref:r,className:oe("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-
756h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...s}));i9.displayName="SidebarInset";const nre=u.forwardRef(({className:e,...s},r)=>t.jsx(re,{ref:r,"data-sidebar":"input",className:oe("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...s}));nre.displayName="SidebarInput";const are=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,"data-sidebar":"header",className:oe("flex flex-col gap-2 p-2",e),...s}));are.displayName="SidebarHeader";const ire=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,"data-sidebar":"footer",className:oe("flex flex-col gap-2 p-2",e),...s}));ire.displayName="SidebarFooter";const ore=u.forwardRef(({className:e,...s},r)=>t.jsx(fs,{ref:r,"data-sidebar":"separator",className:oe("mx-2 w-auto bg-sidebar-border",e),...s}));ore.displayName="SidebarSeparator";const $N=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,"data-sidebar":"content",className:oe("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...s}));$N.displayName="SidebarContent";const gd=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,"data-sidebar":"group",className:oe("relative flex w-full min-w-0 flex-col p-2",e),...s}));gd.displayName="SidebarGroup";const Am=u.forwardRef(({className:e,asChild:s=!1,...r},n)=>{const a=s?tn:"div";return t.jsx(a,{ref:n,"data-sidebar":"group-label",className:oe("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...r})});Am.displayName="SidebarGroupLabel";const lre=u.forwardRef(({className:e,asChild:s=!1,...r},n)=>{const a=s?tn:"button";return t.jsx(a,{ref:n,"data-sidebar":"group-action",className:oe("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...r})});lre.displayName="SidebarGroupAction";const vd=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,"data-sidebar":"group-content",className:oe("w-full text-sm",e),...s}));vd.displayName="SidebarGroupContent";const ql=u.forwardRef(({className:e,...s},r)=>t.jsx("ul",{ref:r,"data-sidebar":"menu",className:oe("flex w-full min-w-0 flex-col gap-1",e),...s}));ql.displayName="SidebarMenu";const Lo=u.forwardRef(({className:e,...s},r)=>t.jsx("li",{ref:r,"data-sidebar":"menu-item",className:oe("group/menu-item relative",e),...s}));Lo.displayName="SidebarMenuItem";const cre=fa("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Bo=u.forwardRef(({asChild:e=!1,isActive:s=!1,variant:r="default",size:n="default",tooltip:a,className:i,...o},l)=>{const c=e?tn:"button",{isMobile:d,state:m}=Yu(),h=t.jsx(c,{ref:l,"data-sidebar":"menu-button","data-size":n,"data-active":s,className:oe(cre({variant:r,size:n}),i),...o});
756return a?(typeof a=="string"&&(a={children:a}),t.jsxs(XE,{children:[t.jsx(ZE,{asChild:!0,children:h}),t.jsx(Uw,{side:"right",align:"center",hidden:m!=="collapsed"||d,...a})]})):h});Bo.displayName="SidebarMenuButton";const dre=u.forwardRef(({className:e,asChild:s=!1,showOnHover:r=!1,...n},a)=>{const i=s?tn:"button";return t.jsx(i,{ref:a,"data-sidebar":"menu-action",className:oe("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...n})});dre.displayName="SidebarMenuAction";const ure=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,"data-sidebar":"menu-badge",className:oe("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...s}));ure.displayName="SidebarMenuBadge";const mre=u.forwardRef(({className:e,showIcon:s=!1,...r},n)=>{const a=u.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return t.jsxs("div",{ref:n,"data-sidebar":"menu-skeleton",className:oe("rounded-md h-8 flex gap-2 px-2 items-center",e),...r,children:[s&&t.jsx(Is,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),t.jsx(Is,{className:"h-4 flex-1 max-w-[--skeleton-width]","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":a}})]})});mre.displayName="SidebarMenuSkeleton";const hre=u.forwardRef(({className:e,...s},r)=>t.jsx("ul",{ref:r,"data-sidebar":"menu-sub",className:oe("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...s}));hre.displayName="SidebarMenuSub";const fre=u.forwardRef(({...e},s)=>t.jsx("li",{ref:s,...e}));fre.displayName="SidebarMenuSubItem";const pre=u.forwardRef(({asChild:e=!1,size:s="md",isActive:r,className:n,...a},i)=>{const o=e?tn:"a";return t.jsx(o,{ref:i,"data-sidebar":"menu-sub-button","data-size":s,"data-active":r,className:oe("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",s==="sm"&&"text-xs",s==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",n),...a})});pre.displayName="SidebarMenuSubButton";const qt=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{className:"relative w-full overflow-auto",children:t.jsx("table",{ref:r,className:oe("w-full caption-bottom text-sm",e),...s})}));qt.displayName="Table";const Ht=u.forwardRef(({className:e,...s},r)=>t.jsx("thead",{ref:r,className:oe("[&_tr]:border-b",e),...s}));Ht.displayName="TableHeader";const Wt=u.forwardRef(({className:e,...s},r)=>t.jsx("tbody",{ref:r,className:oe("[&_tr:last-child]:border-0",e),...s}));Wt.displayName="TableBody";const xre=u.forwardRef(({className:e,...s},r)=>t.jsx("tfoot",{ref:r,className:oe("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...s}));xre.displayName="TableFooter";const Xe=u.forwardRef(({className:e,...s},r)=>t.jsx("tr",{ref:r,className:oe("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...s}));Xe.displayName="TableRow";const ue=u.forwardRef(({className:e,...s},r)=>t.jsx("th",{ref:r,className:oe("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...s}));ue.displayName="TableHead";const de=u.forwardRef(({className:e,...s},r)=>t.jsx("td",{ref:r,className:oe("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...s}));de.displayName="TableCell";const gre=u.forwardRef(({className:e,...s},r)=>t.jsx("caption",{ref:r,className:oe("mt-4 text-sm text-muted-foreground",e),...s}));gre.displayName="TableCaption";const vre=e=>{switch(e){case"bogof":return"3+ Subscription Package for New Advertisers";case"fixed":case"fixed_term":return"Pay As You Go";
756case"leafleting":return"Leaflet Distribution";default:return e}},yre=e=>{switch(e){case"active":return"Active";case"approved":return"Approved";case"pending":return"Pending";default:return"Saved Quote"}};function bre({quote:e}){const{data:s=[]}=oD(),{data:r=[]}=hN(),{data:n=[]}=qf(),a=e.pricing_model==="bogof",i=e.pricing_model==="leafleting",o=r.find(y=>y.id===e.ad_size_id),l=s.filter(y=>{var v;return(v=e.bogof_paid_area_ids)==null?void 0:v.includes(y.id)}),c=s.filter(y=>{var v;return(v=e.bogof_free_area_ids)==null?void 0:v.includes(y.id)}),d=i?n.filter(y=>{var v;return(v=e.selected_area_ids)==null?void 0:v.includes(y.id)}).map(y=>({...y,circulation:y.bimonthly_circulation,postcodes:y.postcodes})):s.filter(y=>{var v;return(v=e.selected_area_ids)==null?void 0:v.includes(y.id)}),m=e.selections,h=(m==null?void 0:m.months)||{},f=()=>{if(!e.distribution_start_date)return[];const y=e.duration_multiplier||1,v=new Date(e.distribution_start_date),N=[];for(let S=0;S<y;S++){const k=new Date(v.getFullYear(),v.getMonth()+S*2);N.push(`${k.getFullYear()}-${String(k.getMonth()+1).padStart(2,"0")}`)}return N},p=Object.keys(h).length>0,x=p?[]:f(),g=(y,v)=>{const N=v.schedule;if(N){const $=N.find(R=>R.month===y);if($!=null&&$.deliveryDate){const R=Jo($.deliveryDate,$.year)??new Date(NaN);if(!isNaN(R.getTime()))return R.toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}}const[S,k]=y.split("-");return S&&k?new Date(Number(S),Number(k)-1).toLocaleDateString("en-GB",{month:"short",year:"numeric"}):y},b=y=>{if(!i)return[];const v=y.schedule;if(!v||v.length===0)return[];const N=e.duration_multiplier||1;let S;if(e.distribution_start_date){const k=new Date(e.distribution_start_date);S=v.filter($=>{const R=$.month;if(!R)return!1;const[A,T]=R.split("-");return new Date(Number(A),Number(T)-1)>=new Date(k.getFullYear(),k.getMonth())}).sort(($,R)=>($.month||"").localeCompare(R.month||"")).slice(0,N)}else S=[...v].sort((k,$)=>(k.month||"").localeCompare($.month||"")).slice(0,N);return S.map(k=>{const $=k.deliveryDate;if($){const T=Jo($,k.year)??new Date(NaN);if(!isNaN(T.getTime()))return`w/c ${T.toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}`}const[R,A]=(k.month||"").split("-");return R&&A?new Date(Number(R),Number(A)-1).toLocaleDateString("en-GB",{month:"short",year:"numeric"}):k.month||""})},w=({area:y,isFree:v=!1})=>{const N=b(y),S=p?h[y.id]||[]:x,k=a?S.slice(0,3):S,$=i?N:k.map(R=>g(R,y));return t.jsxs("div",{className:`p-3 rounded-lg border ${v?"border-emerald-200 bg-emerald-50/50":"border-border bg-muted/30"}`,children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-2",children:[v?t.jsx(yr,{className:"h-4 w-4 text-emerald-600"}):t.jsx(_t,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"font-medium",children:y.name}),v&&t.jsx(we,{variant:"outline",className:"text-xs border-emerald-300 text-emerald-700 bg-emerald-50",children:"FREE"})]})}),t.jsxs("div",{className:"mt-1 ml-6 text-sm text-muted-foreground",children:[t.jsxs("span",{children:[(y.circulation||0).toLocaleString()," circulation"]}),y.postcodes&&t.jsxs("span",{className:"ml-2",children:["· ",typeof y.postcodes=="string"?y.postcodes:Array.isArray(y.postcodes)?y.postcodes.join(", "):""]})]}),$.length>0&&t.jsxs("div",{className:"mt-1 ml-6 text-sm text-muted-foreground flex items-center gap-1.5",children:[t.jsx(It,{className:"h-3.5 w-3.5"}),t.jsx("span",{children:$.join(", ")})]})]})},j=l.length>0||c.length>0||d.length>0;return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{children:"Campaign Type"}),t.jsx("p",{children:vre(e.pricing_model)})]}),t.jsxs("div",{children:[t.jsx(V,{children:"Status"}),t.jsx("p",{children:yre(e.status)})]})]}),o&&t.jsxs("div",{children:[t.jsx(V,{children:"Ad Size"}),t.jsxs("p",{children:[o.name," ",t.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",o.dimensions,")"]})]})]}),a?t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{children:"Monthly Price"}),t.jsxs("p",{className:"font-semibold text-lg",children:[Nt(e.monthly_price||0)," + VAT"]})]}),t.jsxs("div",{children:[t.jsx(V,{children:"6 payments (minimum)"}),t.jsxs("p",{className:"font-semibold text-lg",children:[Nt(e.final_total||0)," + VAT"]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["(6 à ",Nt(e.monthly_price||0)," per month)"]})]})]}):e.pricing_model==="fixed"||e.pricing_model==="fixed_term"||e.pricing_model==="leafleting"?t.jsxs("div",{children:[t.jsx(V,{children:i?"Cost":"Price"}),t.jsxs("p",{className:"font-semibold text-lg",children:[Nt(e.final_total||0)," + VAT"]})]}):t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{children:"Monthly Price"}),t.jsxs("p",{className:"font-semibold text-lg",children:[Nt(e.monthly_price||0)," + VAT"]})]}),t.jsxs("div",{children:[t.jsx(V,{children:"Final Total"}),t.jsxs("p",{className:"font-semibold text-lg",children:[Nt(e.final_total||0)," + VAT"]})]})]}),e.total_circulation>0&&t.jsxs("div",{children:[t.jsx(V,{children:"Total Circulation"}
756),t.jsx("p",{children:(e.total_circulation||0).toLocaleString()})]}),i&&t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.distribution_start_date&&t.jsxs("div",{children:[t.jsx(V,{children:"Distribution Start"}),t.jsx("p",{children:new Date(e.distribution_start_date).toLocaleDateString("en-GB",{month:"long",year:"numeric"})})]}),e.duration_multiplier&&t.jsxs("div",{children:[t.jsx(V,{children:"Duration"}),t.jsxs("p",{children:[e.duration_multiplier," ",e.duration_multiplier===1?"issue":"issues"]})]}),e.leaflets_required_by&&t.jsxs("div",{children:[t.jsx(V,{children:"Leaflets Required By"}),t.jsx("p",{children:new Date(e.leaflets_required_by).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})]}),(m==null?void 0:m.leafletSize)&&t.jsxs("div",{children:[t.jsx(V,{children:"Leaflet Size"}),t.jsx("p",{children:m.leafletSize})]})]}),j&&t.jsxs("div",{className:"border-t pt-4",children:[t.jsxs("h4",{className:"font-medium mb-3 flex items-center gap-2",children:[t.jsx(_t,{className:"h-4 w-4"}),"Area Selection ",a&&"(Buy 1 Get 1 Free)"]}),a?t.jsxs("div",{className:"space-y-4",children:[l.length>0&&t.jsxs("div",{children:[t.jsx(V,{className:"text-sm mb-2 block",children:"Subscribed Areas (minimum 3 issues)"}),t.jsx("div",{className:"space-y-2",children:l.map(y=>t.jsx(w,{area:y},y.id))})]}),c.length>0&&t.jsxs("div",{children:[t.jsx(V,{className:"text-sm mb-2 block",children:"FREE Bonus Areas for 3 issues only"}),t.jsx("div",{className:"space-y-2",children:c.map(y=>t.jsx(w,{area:y,isFree:!0},y.id))})]})]}):t.jsx("div",{className:"space-y-2",children:d.map(y=>t.jsx(w,{area:y},y.id))})]}),e.contact_name&&t.jsxs("div",{className:"border-t pt-4",children:[t.jsx("h4",{className:"font-medium mb-2",children:"Contact Information"}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{children:"Name"}),t.jsx("p",{children:e.contact_name})]}),e.email&&t.jsxs("div",{children:[t.jsx(V,{children:"Email"}),t.jsx("p",{children:e.email})]}),e.phone&&t.jsxs("div",{children:[t.jsx(V,{children:"Phone"}),t.jsx("p",{children:e.phone})]}),e.company&&t.jsxs("div",{children:[t.jsx(V,{children:"Company"}),t.jsx("p",{children:e.company})]})]})]}),t.jsx("div",{className:"border-t pt-4 text-sm text-muted-foreground",children:t.jsxs("p",{children:["Created: ",new Date(e.created_at).toLocaleDateString("en-GB",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})})]})}function jre({open:e,onClose:s}){const[r,n]=u.useState(""),[a,i]=u.useState(""),[o,l]=u.useState(!1),[c,d]=u.useState(!1),[m,h]=u.useState(!1),{toast:f}=rt(),p=async g=>{if(g.preventDefault(),r.length<6){f({title:"Password too short",description:"Password must be at least 6 characters long.",variant:"destructive"});return}if(r!==a){f({title:"Passwords don't match",description:"Please make sure both passwords are the same.",variant:"destructive"});return}h(!0);try{const{error:b}=await W.auth.updateUser({password:r});if(b)throw b;f({title:"Password set successfully!",description:"Your account is now secure. You can use this password to log in next time."}),s()}catch(b){console.error("Password update error:",b),f({title:"Error setting password",description:b.message||"Failed to set password. Please try again.",variant:"destructive"})}finally{h(!1)}},x=()=>{f({title:"Reminder",description:"Don't forget to set a password later to secure your account!",variant:"default"}),s()};return t.jsx(bt,{open:e,onOpenChange:s,children:t.jsxs(xt,{className:"sm:max-w-md",children:[t.jsxs(jt,{children:[t.jsxs(wt,{className:"flex items-center gap-2",children:[t.jsx(Cu,{className:"h-5 w-5"}),"Secure Your Account"]}),t.jsx(ys,{children:"Your quote has been saved! To prevent losing access to your account, please create a password."})]}),t.jsxs("form",{onSubmit:p,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"password",children:"New Password"}),t.jsxs("div",{className:"relative",children:[t.jsx(re,{id:"password",type:o?"text":"password",value:r,onChange:g=>n(g.target.value),placeholder:"Enter a secure password",className:"pr-10"}),t.jsx(q,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>l(!o),children:o?t.jsx(di,{className:"h-4 w-4"}):t.jsx(tr,{className:"h-4 w-4"})})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"confirmPassword",children:"Confirm Password"}),t.jsxs("div",{className:"relative",children:[t.jsx(re,{id:"confirmPassword",type:c?"text":"password",value:a,onChange:g=>i(g.target.value),placeholder:"Confirm your password",className:"pr-10"}),t.jsx(q,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>d(!c),children:c?t.jsx(di,{className:"h-4 w-4"}):t.jsx(tr,{className:"h-4 w-4"})})]})]}),t.jsxs("div",{className:"flex gap-2 pt-4",children:[t.jsx(q,{type:"submit",disabled:m,className:"flex-1",children:m?"Setting password...":"Set Password"}),t.jsx(q,{type:"button",variant:"outline",onClick:x,disabled:m,className:"flex-1",children:"Skip for now"})]})]})]})})}function wre({open:e,onClose:s}){const[r,n]=u.useState(""),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(!1),[m,h]=u.useState(!1),[f,p]=u.useState(!1),[x,g]=u.useState(!1),{toast:b}=rt(),w=()=>{n(""),i(""),l(""),d(!1),h(!1),p(!1)},j=async v=>{if(v.preventDefault(),a.length<6){b({title:"Password too short",description:"Password must be at least 6 characters long.",variant:"destructive"});return}if(a!==o){b({title:"Passwords don't match",description:"Please make sure both passwords are the same.",variant:"destructive"});return}g(!0);try{const{data:{user:N}}=await W.auth.getUser();if(!(N!=null&&N.email))throw new Error("User email not found");const{error:S}=await W.auth.signInWithPassword({email:N.email,password:r});if(S){b({title:"Incorrect password",description:"The current password you entered is incorrect.",variant:"destructive"}),g(!1);return}const{error:k}=await W.auth.updateUser({password:a});if(k)throw k;b({title:"Password changed successfully!",description:"Your password has been updated."}),w(),s()}catch(N){console.error("Password change error:",N),b({title:"Error changing password",description:N.message||"Failed to change password. Please try again.",variant:"destructive"})}finally{g(!1)}},y=()=>{w(),s()};return t.jsx(bt,{open:e,onOpenChange:y,children:t.jsxs(xt,{className:"sm:max-w-md",children:[t.jsxs(jt,{children:[t.jsxs(wt,{className:"flex items-center gap-2",children:[t.jsx(Cu,{className:"h-5 w-5"}),"Change Password"]}),t.jsx(ys,{children:"Enter your current password and choose a new password for your account."})]}),t.jsxs("form",{onSubmit:j,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"currentPassword",children:"Current Password"}),t.jsxs("div",{className:"relative",children:[t.jsx(re,{id:"currentPassword",type:c?"text":"password",value:r,onChange:v=>n(v.target.value),placeholder:"Enter your current password",className:"pr-10",required:!0}),t.jsx(q,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>d(!c),children:c?t.jsx(di,{className:"h-4 w-4"}):t.jsx(tr,{className:"h-4 w-4"})})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"newPassword",children:"New Password"}),t.jsxs("div",{className:"relative",children:[t.jsx(re,{id:"newPassword",type:m?"text":"password",value:a,onChange:v=>i(v.target.value),placeholder:"Enter a new password",className:"pr-10",required:!0}),t.jsx(q,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>h(!m),children:m?t.jsx(di,{className:"h-4 w-4"}):t.jsx(tr,{className:"h-4 w-4"})})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"confirmPassword",children:"Confirm New Password"}),t.jsxs("div",{className:"relative",children:[t.jsx(re,{id:"confirmPassword",type:f?"text":"password",value:o,onChange:v=>l(v.target.value),placeholder:"Confirm your new password",className:"pr-10",required:!0}),t.jsx(q,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>
756p(!f),children:f?t.jsx(di,{className:"h-4 w-4"}):t.jsx(tr,{className:"h-4 w-4"})})]})]}),t.jsxs("div",{className:"flex gap-2 pt-4",children:[t.jsx(q,{type:"submit",disabled:x,className:"flex-1",children:x?"Changing password...":"Change Password"}),t.jsx(q,{type:"button",variant:"outline",onClick:y,disabled:x,children:"Cancel"})]})]})]})})}function Nre({user:e,quotes:s,bookings:r=[],isFirstLogin:n=!1,onBookNowClick:a}){var f,p;const i=r.some(x=>x.payment_status==="paid"||x.payment_status==="subscription_active"||x.payment_status==="mandate_active");r.some(x=>!x.payment_status||x.payment_status==="pending");const o=r.filter(x=>x.payment_status==="paid"||x.payment_status==="subscription_active"||x.payment_status==="mandate_active").reduce((x,g)=>x+(g.total_circulation||0),0),l=r.filter(x=>!x.payment_status||x.payment_status==="pending").reduce((x,g)=>x+(g.total_circulation||0),0),c=r.filter(x=>!x.payment_status||x.payment_status==="pending").reduce((x,g)=>x+(g.final_total||0),0);r.filter(x=>!x.payment_status||x.payment_status==="pending").length;const d=s.reduce((x,g)=>x+(g.total_circulation||0),0)+l;s.reduce((x,g)=>x+(g.final_total||0),0)+c,s.filter(x=>x.pricing_model).length;const m=((f=e==null?void 0:e.user_metadata)==null?void 0:f.display_name)||((p=e==null?void 0:e.email)==null?void 0:p.split("@")[0])||"Friend",h=n?"Welcome":"Hello";return t.jsx("div",{className:"mb-8",children:t.jsxs("div",{className:"text-center mb-6",children:[t.jsxs("h1",{className:"text-4xl font-heading font-bold mb-2",children:[h,", ",m,"! ð"]}),t.jsx("p",{className:"text-xl text-muted-foreground mb-4",children:i&&o>0?`Your advert is in the process of being seen by ${o.toLocaleString()} number of homes`:l>0||d>0?"You're one step away from reaching up to 142,000 Discover readers' homes!":"Start creating your advertising campaign today!"})]})})}function _re({quote:e,onView:s,onDelete:r,isDeleting:n,onBookNow:a}){if(!e)return null;const i=e.status==="draft"||e.status==="bogof_return_interest"||!e.status,o=m=>{switch(m==null?void 0:m.toLowerCase()){case"active":return"bg-emerald-100 text-emerald-800 border-emerald-200";case"approved":return"bg-green-100 text-green-800 border-green-200";
756case"pending":return"bg-blue-100 text-blue-800 border-blue-200";case"draft":return"bg-yellow-100 text-yellow-800 border-yellow-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},l=m=>{switch(m==null?void 0:m.toLowerCase()){case"active":return"Active";case"approved":return"Approved";case"pending":return"Pending";case"draft":return"Saved Quote";default:return"Saved Quote"}},c=m=>{switch(m){case"fixed":return"Pay As You Go";case"bogof":return"3+ Subscription Package for New Advertisers";case"leafleting":return"Leaflet Distribution";case"subscription":return"Subscription";default:return m}},d=m=>new Date(m).toLocaleDateString("en-GB",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return t.jsxs(xe,{className:`h-full relative overflow-hidden transition-all duration-300 ${i?"border-2 border-amber-400 shadow-md hover:shadow-lg bg-gradient-to-br from-amber-50/50 via-white to-amber-50/30":e.status==="active"||e.status==="approved"?"border-2 border-emerald-400 shadow-md hover:shadow-lg bg-gradient-to-br from-emerald-50/50 via-white to-emerald-50/30":"hover:shadow-md"}`,children:[i&&t.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-amber-400 via-orange-400 to-amber-400 opacity-20 animate-pulse pointer-events-none"}),(e.status==="active"||e.status==="approved")&&t.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-emerald-400 via-green-400 to-emerald-400 opacity-10 pointer-events-none"}),t.jsx(Me,{className:"pb-3 relative",children:t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"space-y-2 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Oe,{className:"text-lg leading-tight",children:e.title||c(e.pricing_model)}),i&&t.jsx("div",{className:"flex items-center gap-1 text-amber-600",children:t.jsx(Hs,{className:"w-4 h-4"})}),(e.status==="active"||e.status==="approved")&&t.jsx("div",{className:"flex items-center gap-1 text-emerald-600",children:t.jsx(Oa,{className:"w-5 h-5 text-emerald-600"})})]}),t.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:t.jsx(we,{variant:"outline",className:`${o(e.status||"draft")} ${i?"font-semibold":""}`,children:l(e.status||"draft")})})]}),r&&t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>r(e),disabled:n,className:"text-destructive hover:text-destructive hover:bg-destructive/10 ml-2",children:n?t.jsx("div",{className:"w-4 h-4 animate-spin rounded-full border-2 border-destructive border-t-transparent"}):t.jsx(cs,{className:"w-4 h-4"})})]})}),t.jsxs(ge,{className:"space-y-4 relative",children:[i&&t.jsxs(ss,{className:"border-amber-400 bg-amber-50/80 backdrop-blur-sm",children:[t.jsx(Hs,{className:"h-4 w-4 text-amber-600"}),t.jsx(rs,{className:"text-amber-900 font-medium",children:"This quote is ready to book when you are"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsx("div",{className:"flex items-center gap-2 text-sm",children:t.jsxs("div",{children:[t.jsx("div",{className:`font-semibold text-xl ${i?"text-amber-900":"text-primary"}`,children:Nt(e.pricing_model==="fixed"||e.pricing_model==="fixed_term"?e.final_total||0:e.monthly_price>0?e.monthly_price:e.final_total)}),t.jsx("div",{className:"text-xs text-muted-foreground",children:e.pricing_model==="bogof"?"per month + VAT":e.pricing_model==="fixed"||e.pricing_model==="fixed_term"||e.pricing_model==="leafleting"?"campaign total + VAT":""})]})}),t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx(_f,{className:"w-4 h-4 text-muted-foreground"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium",children:(e.total_circulation||0).toLocaleString()}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Circulation"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(ws,{className:"w-4 h-4"}),t.jsxs("span",{children:["Created: ",d(e.created_at)]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs(q,{variant:"outline",size:"sm",onClick:()=>s(e),children:[t.jsx(tr,{className:"h-4 w-4 mr-1"}),"Booking Details"]}
756),a&&t.jsxs(q,{size:"sm",onClick:()=>a(e),className:"bg-gradient-to-r from-green-600 to-green-700 hover:from-green-700 hover:to-green-800 text-white",children:[t.jsx(Oa,{className:"h-4 w-4 mr-1"}),"Accept Terms & Book"]})]})]})]})}function Sre({totalCirculation:e,totalInvestment:s}){const[r,n]=u.useState([1]),[a,i]=u.useState(50),[o,l]=u.useState([30]),c=Math.round(e*r[0]/100),d=c*a,m=Math.round(c*o[0]/100)*a*2,h=d+m,f=s>0?(h-s)/s*100:0;return t.jsxs(xe,{children:[t.jsxs(Me,{children:[t.jsxs(Oe,{className:"flex items-center",children:[t.jsx(sc,{className:"h-5 w-5 text-blue-600 mr-2"}),"Your ROI Calculator"]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["See the potential return on your ",Nt(s)," investment"]})]}),t.jsxs(ge,{className:"space-y-6",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{className:"text-sm font-medium",children:"Expected Response Rate"}),t.jsx("div",{className:"px-3",children:t.jsx(Vl,{value:r,onValueChange:n,max:5,min:.5,step:.1,className:"w-full"})}),t.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[t.jsx("span",{children:"0.5%"}),t.jsxs("span",{className:"font-medium",children:[r[0],"% = ",c," customers"]}),t.jsx("span",{children:"5%"})]}),t.jsx("p",{className:"text-xs text-blue-600 bg-blue-50 p-2 rounded",children:"ð¡ Industry average is 1-2% for local advertising"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"aov",className:"text-sm font-medium",children:"Average Customer Value (£)"}),t.jsx(re,{id:"aov",type:"number",value:a,onChange:p=>i(Number(p.target.value)),min:"1",placeholder:"50"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{className:"text-sm font-medium",children:"Become Repeat Customers"}),t.jsx("div",{className:"px-3",children:t.jsx(Vl,{value:o,onValueChange:l,max:50,min:10,step:5,className:"w-full"})}),t.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[t.jsx("span",{children:"10%"}),t.jsxs("span",{className:"font-medium",children:[o[0],"%"]}),t.jsx("span",{children:"50%"})]})]}),t.jsxs("div",{className:"border-t pt-4 space-y-3",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-muted-foreground",children:"Initial Revenue"}),t.jsx("p",{className:"font-bold text-lg",children:Nt(d)})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-muted-foreground",children:"Repeat Revenue"}),t.jsx("p",{className:"font-bold text-lg",children:Nt(m)})]})]}),t.jsxs("div",{className:"p-4 bg-gradient-to-r from-green-50 to-blue-50 rounded-lg border",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"font-medium",children:"Total Revenue Potential"}),t.jsx("span",{className:"text-2xl font-bold text-green-700",children:Nt(h)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"Return on Investment"}),t.jsxs("div",{className:"flex items-center",children:[t.jsx(jh,{className:"h-4 w-4 text-green-600 mr-1"}),t.jsxs("span",{className:"text-lg font-bold text-green-700",children:[f.toFixed(0),"%"]})]})]})]}),f>200&&t.jsxs("div",{className:"p-3 bg-yellow-50 border border-yellow-200 rounded",children:[t.jsxs("div",{className:"flex items-center mb-1",children:[t.jsx(Sd,{className:"h-4 w-4 text-yellow-600 mr-2"}),t.jsx("span",{className:"font-medium text-yellow-800",children:"Excellent ROI Potential!"})]}),t.jsx("p",{className:"text-xs text-yellow-700",children:"This projection shows strong potential returns. Ready to make it happen?"})]})]})]})]})}function Cre({open:e,onClose:s,onConfirm:r,quote:n,isDeleting:a}){return n?t.jsx(bt,{open:e,onOpenChange:s,children:t.jsxs(xt,{className:"max-w-md",onCloseAutoFocus:i=>i.preventDefault(),children:[t.jsxs(jt,{className:"text-center pb-4",children:[t.jsx("div",{className:"mx-auto mb-4 h-12 w-12 rounded-full bg-red-100 flex items-center justify-center",children:t.jsx(mi,{className:"h-6 w-6 text-red-600"})}),t.jsx(wt,{className:"text-xl font-semibold text-gray-900",children:"Delete Quote?"}),t.jsx(ys,{className:"text-gray-500 mt-2",children:"This action cannot be undone. This quote will be permanently removed from your dashboard."})]}),t.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 border border-gray-200",children:[t.jsx("h4",{className:"font-medium text-gray-900 mb-2",children:n.title||"Advertising Campaign"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Campaign Type:"}),t.jsx("span",{className:"font-medium",children:n.pricing_model==="bogof"?"3+ Subscription Package":n.pricing_model==="fixed"||n.pricing_model==="fixed_term"?"Pay As You Go":n.pricing_model==="leafleting"?"Leaflet Distribution":n.pricing_model})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Total Investment:"}),t.jsx("span",{className:"font-medium text-primary",children:Nt(n.final_total)})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Total Reach:"}),t.jsxs("span",{className:"font-medium",children:[(n.total_circulation||0).toLocaleStr
756ing()," homes"]})]})]})]}),t.jsxs("div",{className:"flex gap-3 pt-4",children:[t.jsx(q,{variant:"outline",onClick:s,disabled:a,className:"flex-1",children:"Cancel"}),t.jsx(q,{variant:"destructive",onClick:r,disabled:a,className:"flex-1 bg-red-600 hover:bg-red-700",children:a?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Deleting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(cs,{className:"h-4 w-4 mr-2"}),"Delete Quote"]})})]})]})}):null}var o9="AlertDialog",[kre,Cfe]=hr(o9,[G6]),ro=G6(),l9=e=>{const{__scopeAlertDialog:s,...r}=e,n=ro(s);return t.jsx(r2,{...n,...r,modal:!0})};l9.displayName=o9;var $re="AlertDialogTrigger",c9=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,...n}=e,a=ro(r);return t.jsx(n2,{...a,...n,ref:s})});c9.displayName=$re;var Ere="AlertDialogPortal",d9=e=>{const{__scopeAlertDialog:s,...r}=e,n=ro(s);return t.jsx(a2,{...n,...r})};d9.displayName=Ere;var Pre="AlertDialogOverlay",u9=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,...n}=e,a=ro(r);return t.jsx(Rf,{...a,...n,ref:s})});u9.displayName=Pre;var Td="AlertDialogContent",[Are,Tre]=kre(Td),m9=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,children:n,...a}=e,i=ro(r),o=u.useRef(null),l=at(s,o),c=u.useRef(null);return t.jsx(hW,{contentName:Td,titleName:h9,docsSlug:"alert-dialog",children:t.jsx(Are,{scope:r,cancelRef:c,children:t.jsxs(Mf,{role:"alertdialog",...i,...a,ref:l,onOpenAutoFocus:Se(a.onOpenAutoFocus,d=>{var m;d.preventDefault(),(m=c.current)==null||m.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:[t.jsx(yw,{children:n}),t.jsx(Rre,{contentRef:o})]})})})});m9.displayName=Td;var h9="AlertDialogTitle",f9=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,...n}=e,a=ro(r);return t.jsx(Of,{...a,...n,ref:s})});f9.displayName=h9;var p9="AlertDialogDescription",x9=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,...n}=e,a=ro(r);return t.jsx(If,{...a,...n,ref:s})});x9.displayName=p9;var Dre="AlertDialogAction",g9=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,...n}=e,a=ro(r);return t.jsx(kv,{...a,...n,ref:s})});g9.displayName=Dre;var v9="AlertDialogCancel",y9=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,...n}=e,{cancelRef:a}=Tre(v9,r),i=ro(r),o=at(s,a);return t.jsx(kv,{...i,...n,ref:o})});y9.displayName=v9;var Rre=({contentRef:e})=>{const s=`\`${Td}\` requires a description for the component to be accessible for screen reader users. 757 758You can add a description to the \`${Td}\` by passing a \`${p9}\` component as a child, which also benefits sighted users by adding visible context to the dialog. 759 760Alternatively, 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 \`${Td}\`. 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. 761 762For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return u.useEffect(()=>{var n;document.getElementById((n=e.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,e]),null},Mre=l9,Ore=c9,Ire=d9,b9=u9,j9=m9,w9=g9,N9=y9,_9=f9,S9=x9;const ia=Mre,Li=Ore,Fre=Ire,C9=u.forwardRef(({className:e,...s},r)=>t.jsx(b9,{className:oe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...s,ref:r}));C9.displayName=b9.displayName;const Fn=u.forwardRef(({className:e,...s},r)=>t.jsxs(Fre,{children:[t.jsx(C9,{}),t.jsx(j9,{ref:r,className:oe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rou
762nded-lg",e),...s})]}));Fn.displayName=j9.displayName;const Ln=({className:e,...s})=>t.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...s});Ln.displayName="AlertDialogHeader";const Bn=({className:e,...s})=>t.jsx("div",{className:oe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...s});Bn.displayName="AlertDialogFooter";const zn=u.forwardRef(({className:e,...s},r)=>t.jsx(_9,{ref:r,className:oe("text-lg font-semibold",e),...s}));zn.displayName=_9.displayName;const Un=u.forwardRef(({className:e,...s},r)=>t.jsx(S9,{ref:r,className:oe("text-sm text-muted-foreground",e),...s}));Un.displayName=S9.displayName;const Vn=u.forwardRef(({className:e,...s},r)=>t.jsx(w9,{ref:r,className:oe(kh(),e),...s}));Vn.displayName=w9.displayName;const oa=u.forwardRef(({className:e,...s},r)=>t.jsx(N9,{ref:r,className:oe(kh({variant:"outline"}),"mt-2 sm:mt-0",e),...s}));oa.displayName=N9.displayName;const Lre=({booking:e,onViewDetails:s,onNavigateToVouchers:r})=>{var w,j,y;const n=["payment_pending","subscription_pending","mandate_created"].includes(e.payment_status||""),a=(!e.payment_status||e.payment_status==="pending")&&!n,i=e.payment_status==="paid"||e.payment_status==="subscription_active"||e.payment_status==="mandate_active",[o,l]=u.useState(!1),[c,d]=u.useState(null),{data:m=[]}=Wu(),h=(w=e.selections)==null?void 0:w.payment_option_id,f=(()=>{var N,S;if(h==="monthly"&&e.monthly_price)return e.monthly_price;const v=m.find(k=>k.option_type===h);if(v&&m.length>0){const k=((N=e.pricing_breakdown)==null?void 0:N.baseTotal)||e.final_total||0,$=((S=e.pricing_breakdown)==null?void 0:S.designFee)||0;return fu(k,v,e.pricing_model,m,$)}return e.pricing_model==="bogof"&&e.monthly_price?e.monthly_price:e.final_total})();u.useEffect(()=>{(async()=>{if(e.pricing_model==="bogof"&&i){const{data:N,error:S}=await W.from("vouchers").select("voucher_code, is_used").eq("created_from_booking_id",e.id).eq("is_active",!0).single();!S&&N&&!N.is_used&&(l(!0),d(N.voucher_code))}})()},[e.id,e.pricing_model,i]);const p=v=>{if(!v)return"bg-gray-100 text-gray-800 border-gray-200";switch(v){case"paid":case"subscription_active":case"mandate_active":return"bg-green-100 text-green-800 border-green-200";case"payment_pending":case"subscription_pending":case"mandate_created":return"bg-blue-100 text-blue-800 border-blue-200";case"failed":return"bg-red-100 text-red-800 border-red-200";default:return"bg-yellow-100 text-yellow-800 border-yellow-200"}},x=v=>!v||v==="pending"?e.terms_accepted_at?"Booking Terms Accepted":"Awaiting Terms Acceptance":v==="paid"||v==="subscription_active"||v==="mandate_active"?"Paid":["payment_pending","subscription_pending","mandate_created"].includes(v||"")?"Setup Complete":e.terms_accepted_at?"Booking Terms Accepted":"Awaiting Terms Acceptance",g=v=>{switch(v){case"fixed":return"Pay As You Go";case"bogof":return"3+ Subscription Package";case"leafleting":return"Leafleting Service";default:return v}},b=v=>new Date(v).toLocaleDateString("en-GB",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return t.jsxs(xe,{className:`h-full relative overflow-hidden transition-all duration-300 ${a?"border-2 border-amber-400 shadow-lg hover:shadow-xl bg-gradient-to-br from-amber-50/50 via-white to-amber-50/30":i?"border-2 border-emerald-400 shadow-md hover:shadow-lg bg-gradient-to-br from-emerald-50/50 via-white to-emerald-50/30 cursor-pointer":n?"border-2 border-blue-400 shadow-md hover:shadow-lg bg-gradient-to-br from-blue-50/50 via-white to-blue-50/30 cursor-pointer":"hover:shadow-md cursor-pointer"}`,onClick:()=>s==null?void 0:s(e),children:[a&&t.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-amber-400 via-orange-400 to-amber-400 opacity-20 animate-pulse pointer-events-none"}),i&&t.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-emerald-400 via-green-400 to-emerald-400 opacity-10 pointer-events-none"}),t.jsx(Me,{className:"pb-3 relative",children:t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"space-y-2 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Oe,{className:"text-lg leading-tight",children:[`${g(e.pricing_model)} â Booked ${b(e.created_at).split(",")[0]}`,((j=e.selections)==null?void 0:j.ad_size_name)&&t.jsxs("span",{className:"text-muted-foreground font-normal text-sm ml-2",children:["â ",e.selections.ad_size_name]})]}),a&&t.jsx("div",{className:"flex items-center gap-1 text-amber-600 animate-pulse",children:t.jsx(Hs,{className:"w-4 h-4"})}),i&&t.jsx("div",{className:"flex items-center gap-1 text-emerald-600",children:t.jsx(As,{className:"w-5 h-5 fill-emerald-600 text-white"})})]}),t.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:t.jsx(we,{variant:"outline",className:`${p(e.payment_status)} ${a?"font-semibold":""}`,children:x(e.payment_status)})})]}),i&&t.jsxs(ia,{children:[t.jsx(Li,{asChild:!0,children:t.jsx(q,{variant:"ghost",size:"sm",onClick:v=>v.stopPropagation(),className:"text-muted-foreground hover:text-foreground ml-2",children:t.jsx(Nf,{className:"w-4 h-4"})})}),t.jsxs(Fn,{children:[t.jsxs(Ln,{children:[t.jsx(zn,{children:"Subscription Cancellation"}),t.jsxs(Un,{className:"space-y-2",children:[t.jsxs("p",{children:["To cancel your subscription, please email ",t.jsx("strong",{children:"[email protected]"})," or call ",t.jsx("strong",{children:"023 8026 6388"}),"."]}),t.jsx("p",{children:"Cancellations can only be processed after the completion of your first 3 paid issues."})]})]}),t.jsx(Bn,{children:t.jsx(Vn,{children:"Close"})})]})]})]})}),t.jsxs(ge,{className:"space-y-4 relative",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsx("div",{className:"flex items-center gap-2 text-sm",children:t.jsx("div",{children:h==="monthly"?t.jsx(t.Fragment,{children:t.jsxs("div",{className:`font-semibold text-xl ${a?"text-amber-900":"text-primary"}`,children:[Nt(f)," + vat"]})}):t.jsx(t.Fragment,{children:t.jsxs("div",{className:`font-semibold text-xl ${a?"text-amber-900":"text-primary"}`,children:[Nt(f)," + VAT"]})})})}),t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx(_f,{className:"w-4 h-4 text-muted-foreground"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium",children:((y=e.total_circulation)==null?void 0:y.toLocaleStr
762ing())||0}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Circulation"})]})]})]}),e.webhook_sent_at&&t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(ws,{className:"w-4 h-4"}),t.jsxs("span",{children:["Submitted",a?" - Not paid":"",": ",b(e.webhook_sent_at)]})]}),e.status==="webhook_failed"&&t.jsx("div",{className:"text-xs text-red-600 bg-red-50 p-2 rounded",children:"There was an issue submitting this booking. Our team will process it manually."}),a&&t.jsxs(q,{className:"w-full bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white font-semibold shadow-md hover:shadow-lg transition-all duration-200",size:"lg",onClick:v=>{v.stopPropagation(),s==null||s(e)},children:[t.jsx(ci,{className:"w-4 h-4 mr-2"}),e.pricing_model==="leafleting"?(()=>{var S,k;const v=((S=e.selections)==null?void 0:S.distribution_start_date)||((k=e.selections)==null?void 0:k.leaflets_required_by);return(v?Math.ceil((new Date(v).getTime()-Date.now())/(1e3*60*60*24)):999)<=10?"Pay in Full by Card":"Pay 25% Deposit by Card"})():e.pricing_model==="fixed"?"Pay Full Amount by Card":"Set Up Payment Plan"]}),n&&t.jsx(q,{className:"w-full bg-gradient-to-r from-blue-500 to-indigo-500 hover:from-blue-600 hover:to-indigo-600 text-white font-semibold shadow-md hover:shadow-lg transition-all duration-200",size:"lg",onClick:v=>{v.stopPropagation(),s==null||s(e)},children:"View Booking Details"}),i&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs(ss,{className:"border-emerald-400 bg-emerald-50/80 backdrop-blur-sm",children:[t.jsx(As,{className:"h-4 w-4 text-emerald-600"}),t.jsx(rs,{className:"text-emerald-900 font-medium",children:"Payment confirmed! Your campaign is booked and will be processed."})]}),o&&t.jsxs(q,{className:"w-full bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 text-white font-semibold shadow-md hover:shadow-lg transition-all duration-200",size:"lg",onClick:v=>{v.stopPropagation(),r&&r()},children:[t.jsx(yr,{className:"w-4 h-4 mr-2"}),"Redeem Your 10% Leaflet Voucher"]})]})]})]})},Bre=()=>{const{toast:e}=rt(),s=os({mutationFn:async a=>{const{data:i,error:o}=await W.functions.invoke("create-gocardless-mandate",{body:a});if(o)throw o;return i},onError:a=>{console.error("Error creating mandate:",a),e({title:"Payment Setup Failed",description:a.message||"Failed to set up Direct Debit. Please try again.",variant:"destructive"})}}),r=os({mutationFn:async a=>{const{data:i,error:o}=await W.functions.invoke("create-gocardless-payment",{body:a});if(o)throw o;return i},onError:a=>{console.error("Error creating payment:",a),e({title:"Payment Failed",description:a.message||"Failed to create payment. Please try again.",variant:"destructive"})}});return{createMandate:s,createPayment:r,completeRedirectFlow:async a=>{try{const{data:i,error:o}=await W.functions.invoke("complete-gocardless-redirect",{body:{redirectFlowId:a}});if(o)throw o;return i}catch(i){throw console.error("Error completing redirect flow:",i),e({title:"Payment Setup Failed",description:i.message||"Failed to complete payment setup.",variant:"destructive"}),i}}}},EN=.2,k9=e=>Math.round(e*100)/100,zre=e=>k9(e*(1+EN)),Ure=e=>k9(e*EN),Vre=({booking:e,open:s,onOpenChange:r})=>{var B,Y,I;const{toast:n}=rt(),[a,i]=u.useState(((B=e==null?void 0:e.selections)==null?void 0:B.payment_option_id)||null),[o,l]=u.useState(!!(e!=null&&e.terms_accepted_at));u.useEffect(()=>{e!=null&&e.terms_accepted_at&&l(!0)},[e==null?void 0:e.terms_accepted_at]);const[c,d]=u.useState(!1),[m,h]=u.useState(!1),{data:f=[]}=Wu(),{createMandate:p}=Bre(),{data:x,refetch:g}=Lt({queryKey:["gocardless-mandate",e==null?void 0:e.id],queryFn:async()=>{if(!(e!=null&&e.id))return null;const{data:C,error:L}=await W.from("gocardless_mandates").select("*").eq("booking_id",e.id).maybeSingle();if(L)throw L;return C},enabled:!!(e!=null&&e.id)&&s}),{data:b}=Lt({queryKey:["gocardless-payments",e==null?void 0:e.id],queryFn:async()=>{if(!(e!=null&&e.id))return[];const{data:C,error:L}=await W.from("gocardless_payments").select("*").eq("booking_id",e.id).order("created_at",{ascending:!1});if(L)throw L;return C},enabled:!!(e!=null&&e.id)&&s}),{data:w}=Lt({queryKey:["gocardless-subscriptions",e==null?void 0:e.id],queryFn:async()=>
762{if(!(e!=null&&e.id))return[];const{data:C,error:L}=await W.from("gocardless_subscriptions").select("*").eq("booking_id",e.id).order("created_at",{ascending:!1});if(L)throw L;return C},enabled:!!(e!=null&&e.id)&&s}),{data:j}=Lt({queryKey:["areas-for-booking",e==null?void 0:e.id,e==null?void 0:e.pricing_model],queryFn:async()=>{if(!e)return[];const C=[...e.selected_area_ids||[],...e.bogof_paid_area_ids||[],...e.bogof_free_area_ids||[]].filter(Boolean);if(C.length===0)return[];if((e.pricing_model==="leafleting"?"leaflet_areas":"pricing_areas")==="leaflet_areas"){const{data:D,error:_}=await W.from("leaflet_areas").select("id, name, postcodes, bimonthly_circulation, price_with_vat").in("id",C);if(_)throw _;return(D||[]).map(H=>({id:H.id,name:H.name,postcodes:H.postcodes,circulation:H.bimonthly_circulation,price_with_vat:H.price_with_vat}))}else{const{data:D,error:_}=await W.from("pricing_areas").select("id, name, circulation, postcodes").in("id",C);if(_)throw _;return(D||[]).map(H=>({id:H.id,name:H.name,postcodes:Array.isArray(H.postcodes)?H.postcodes.join(", "):"",circulation:H.circulation}))}},enabled:!!e&&s}),{data:y}=Lt({queryKey:["ad-size",e==null?void 0:e.ad_size_id],queryFn:async()=>{if(!(e!=null&&e.ad_size_id))return null;const{data:C,error:L}=await W.from("ad_sizes").select("*").eq("id",e.ad_size_id).single();if(L)throw L;return C},enabled:!!(e!=null&&e.ad_size_id)&&s}),{data:v}=Lt({queryKey:["duration",e==null?void 0:e.duration_id],queryFn:async()=>{if(!(e!=null&&e.duration_id))return null;const{data:C,error:L}=await W.from("pricing_durations").select("*").eq("id",e.duration_id).single();if(L)throw L;return C},enabled:!!(e!=null&&e.duration_id)&&s});Lt({queryKey:["invoices",e==null?void 0:e.id],queryFn:async()=>{if(!(e!=null&&e.id))return[];const{data:C,error:L}=await W.from("invoices").select("*").eq("booking_id",e.id).order("created_at",{ascending:!1});if(L)throw L;return C},enabled:!!(e!=null&&e.id)&&s});const N=async()=>{var _,H,O,U,G;if(!a||!e){n({title:"Please select a payment option",variant:"destructive"});return}const C=((_=e.selections)==null?void 0:_.addressLine1)||((H=e.selections)==null?void 0:H.address)||"",L=((O=e.selections)==null?void 0:O.city)||"",D=(U=e.selections)!=null&&U.postcode&&e.selections.postcode!=="POSTCODE"?e.selections.postcode:"";try{const E=await p.mutateAsync({bookingId:e.id,customerEmail:e.email,customerName:e.contact_name,customerAddress:{addressLine1:C,addressLine2:((G=e.selections)==null?void 0:G.addressLine2)||"",city:L,postcode:D}});E.redirectUrl&&(await W.from("bookings").update({selections:{...e.selections,payment_option_id:a}}).eq("id",e.id),window.location.href=E.redirectUrl)}catch(E){console.error("Error setting up payment:",E)}},S=async C=>{if(e){h(!0);try{const L=C||e.final_total||e.monthly_price,{data:D,error:_}=await W.functions.invoke("create-stripe-checkout",{body:{bookingId:e.id,amount:L,customerEmail:e.email,pricingModel:e.pricing_model,isDeposit:!!C&&C<(e.final_total||e.monthly_price),successUrl:`${window.location.origin}/payment-setup?booking_id=${e.id}&stripe_success=true`,cancelUrl:`${window.location.origin}/dashboard`}});if(_)throw _;if(D!=null&&D.url)window.location.href=D.url;else throw new Error("No checkout URL returned")}catch(L){console.error("Stripe checkout error:",L),n({title:"Payment Error",description:L.message||"Failed to start checkout. Please try again.",variant:"destructive"})}finally{h(!1)}}},$=(()=>{if(b&&b.length>0){const C=b[0];return{type:"payment",status:C.status,amount:C.amount,chargeDate:C.charge_date}}if(w&&w.length>0){const C=w[0];return{type:"subscription",status:C.status,amount:C.amount}}return x?{type:"mandate",status:x.status}:null})();if(!e)return null;const R=C=>{switch(C.toLowerCase()){case"confirmed":return"bg-green-100 text-green-800";
762case"pending":return"bg-yellow-100 text-yellow-800";case"completed":return"bg-blue-100 text-blue-800";case"cancelled":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}},A=C=>{switch(C){case"fixed":return"Pay As You Go";case"bogof":return"3+ Subscription";case"leafleting":return"Leaflet Distribution";default:return C}},T=C=>new Date(C).toLocaleDateString("en-GB",{day:"2-digit",month:"long",year:"numeric"}),P=C=>new Intl.NumberFormat("en-GB",{style:"currency",currency:"GBP"}).format(C);return t.jsx(bt,{open:s,onOpenChange:r,children:t.jsx(xt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",onCloseAutoFocus:C=>C.preventDefault(),children:t.jsxs("div",{className:"space-y-6",children:[t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center justify-between",children:["Campaign Overview",t.jsx(we,{className:R(e.status),children:e.status})]})}),t.jsxs(ge,{className:"space-y-6",children:[t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(_t,{className:"h-5 w-5 text-primary"}),t.jsx("h4",{className:"font-semibold text-base",children:"Campaign Package"})]}),t.jsxs("div",{className:"bg-muted p-4 rounded-lg space-y-2",children:[t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Type:"})," ",t.jsx("span",{className:"text-muted-foreground",children:A(e.pricing_model)})]}),y&&t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Ad Size:"})," ",t.jsxs("span",{className:"text-muted-foreground",children:[y.name," (",y.dimensions,")"]})]}),(()=>{var U,G;const C=(U=e.selections)==null?void 0:U.selectedStartingIssue,L=((G=e.selections)==null?void 0:G.selectedMonths)||{},D=Object.values(L)[0],_=D==null?void 0:D[0],H=C||_;if(!H)return null;const O=E=>{if(!E)return"";if(E.includes("-")){const[Z,M]=E.split("-"),F=parseInt(M,10);return`${["January","February","March","April","May","June","July","August","September","October","November","December"][F-1]} ${Z}`}const z=new Date(e.created_at).getFullYear();return`${E} ${z}`};return t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Start Date:"})," ",t.jsx("span",{className:"text-muted-foreground",children:O(H)})]})})(),v&&t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Duration:"})," ",t.jsxs("span",{className:"text-muted-foreground",children:[v.name,e.duration_multiplier&&e.duration_multiplier>1&&` Ã ${e.duration_multiplier}`]})]})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(ua,{className:"h-5 w-5 text-primary"}),t.jsx("h4",{className:"font-semibold text-base",children:"Your Reach & Investment"})]}),t.jsxs("div",{className:"bg-muted p-4 rounded-lg space-y-2",children:[t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Total Circulation:"})," ",t.jsxs("span",{className:"text-muted-foreground font-semibold",children:[((Y=e.total_circulation)==null?void 0:Y.toLocaleString())||"N/A"," homes"]})]}),t.jsxs("p",{className:"text-sm",children:[t.jsxs("span",{className:"font-medium",children:[e.pricing_model==="bogof"?"Monthly Cost":"Campaign Cost",":"]})," ",t.jsx("span",{className:"text-muted-foreground font-semibold",children:(()=>{var H,O,U,G,E;if(e.pricing_model==="bogof")return P(e.monthly_price||0)+" + VAT";if(e.pricing_model==="leafleting"&&j&&j.length>0){const z=((H=e.pricing_breakdown)==null?void 0:H.areaBreakdown)||[];let Z=!1;if(z.length>0){const F=(O=z[0])==null?void 0:O.basePrice,ee=j.find(se=>{var le;return se.id===((le=z[0])==null?void 0:le.areaId)});ee!=null&&ee.price_with_vat&&F&&(Z=Math.abs(F-ee.price_with_vat)<1)}const M=Z?Math.round(e.final_total/1.2*100)/100:e.final_total;return P(M||0)+" + VAT"}const C=(U=e.selections)==null?void 0:U.payment_option_id,L=f.find(z=>z.option_type===C),D=e.pricing_model==="bogof"&&e.monthly_price?e.monthly_price*12:((G=e.pricing_breakdown)==null?void 0:G.baseTotal)||e.final_total||e.monthly_price,_=((E=e.pricing_breakdown)==null?void 0:E.designFee)||0;return L&&f.length>0?P(fu(D,L,e.pricing_model,f,_))+" + VAT":P(e.final_total||e.monthly_price)+" + VAT"})()})]}),t.jsxs("p",{className:"text-sm",children:[t.jsx("span",{className:"font-medium",children:"Created:"})," ",t.jsx("span",{className:"text-muted-foreground",children:T(e.created_at)})]})]})]})]})}),t.jsx(fs,{}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(_t,{className:"h-5 w-5 text-primary"}),t.jsx("h4",{className:"font-semibold text-base",children:"Distribution Areas"})]}),(()=>{const C=e.pricing_model==="bogof"?e.bogof_paid_area_ids||[]:e.selected_area_
762ids||[],L=e.selections,D=(L==null?void 0:L.months)||{},_=G=>{const[E,z]=G.split("-");return E&&z?new Date(Number(E),Number(z)-1).toLocaleDateString("en-GB",{month:"long",year:"numeric"}):G},H=()=>{if(!e.distribution_start_date)return[];const G=e.duration_multiplier||1,E=new Date(e.distribution_start_date),z=[];for(let Z=0;Z<G;Z++){const M=new Date(E.getFullYear(),E.getMonth()+Z*2);z.push(`${M.getFullYear()}-${String(M.getMonth()+1).padStart(2,"0")}`)}return z},O=Object.keys(D).length>0,U=O?[]:H();return!j||C.length===0?t.jsx("div",{className:"bg-muted p-4 rounded-lg",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"No areas selected"})}):t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm font-semibold",children:e.pricing_model==="bogof"?"Subscribed Areas":"Your Selected Areas"}),C.map(G=>{var se;const E=j.find(le=>le.id===G);if(!E)return null;const Z=(O?D[G]||[]:U).map(_),F=(((se=e.pricing_breakdown)==null?void 0:se.areaBreakdown)||[]).find(le=>le.areaId===G);let ee=null;return e.pricing_model==="leafleting"&&F&&(ee=E.price_with_vat&&Math.abs(F.basePrice-E.price_with_vat)<1?Math.round(F.basePrice/1.2*100)/100:F.basePrice),t.jsxs("div",{className:"bg-muted p-3 rounded-lg",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_t,{className:"h-4 w-4 text-primary"}),t.jsx("span",{className:"text-sm font-medium",children:E.name})]}),ee!==null&&t.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:[P(ee)," + VAT"]})]}),t.jsxs("div",{className:"ml-6 mt-1 text-xs text-muted-foreground",children:[(E.circulation||0).toLocaleString()," circulation",E.postcodes&&t.jsxs("span",{className:"ml-2",children:["· ",Array.isArray(E.postcodes)?E.postcodes.join(", "):E.postcodes]})]}),Z.length>0?t.jsxs("div",{className:"ml-6 mt-1 text-xs text-muted-foreground flex items-center gap-1",children:[t.jsx(Qo,{className:"h-3.5 w-3.5"}),t.jsxs("span",{children:["Issues: ",Z.join(", ")]})]}):e.distribution_start_date?t.jsxs("div",{className:"ml-6 mt-1 text-xs text-muted-foreground flex items-center gap-1",children:[t.jsx(Qo,{className:"h-3.5 w-3.5"}),t.jsxs("span",{children:["Start: ",new Date(e.distribution_start_date).toLocaleDateString("en-GB",{month:"long",year:"numeric"})]})]}):null]},G)}),t.jsx("p",{className:"text-xs text-muted-foreground",children:e.pricing_model==="bogof"?`${C.length} subscribed area${C.length!==1?"s":""}`:`${C.length} area${C.length!==1?"s":""} selected`})]})})(),e.pricing_model==="bogof"&&(e.bogof_free_area_ids||[]).length>0&&t.jsx("div",{className:"bg-green-50 border border-green-200 p-4 rounded-lg",children:t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx("div",{className:"h-8 w-8 rounded-full bg-green-100 flex items-center justify-center flex-shrink-0",children:t.jsx(_t,{className:"h-4 w-4 text-green-600"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-semibold mb-2 text-green-900",children:"Bonus Free Areas for SIX months ð"}),t.jsx("div",{className:"text-sm text-green-800 space-y-1",children:(()=>{const C=e.bogof_free_area_ids||[];if(!j||C.length===0)return t.jsx("span",{children:"No areas selected"});const L=C.map(D=>j.find(_=>_.id===D)).filter(Boolean);return L.length===0?t.jsx("span",{children:"Loading..."}):L.map(D=>t.jsx("div",{children:D.name},D.id))})()}),t.jsxs("p",{className:"text-xs text-green-700 mt-2",children:[(e.bogof_free_area_ids||[]).length," additional area",(e.bogof_free_area_ids||[]).length!==1?"s":""," at no extra cost"]})]})]})})]}),e.notes&&t.jsxs(t.Fragment,{children:[t.jsx(fs,{}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm font-semibold",children:"Additional Notes"}),t.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-3 rounded-lg",children:e.notes})]})]})]})]}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center space-x-2",children:[t.jsx(ci,{className:"h-5 w-5"}),t.jsx("span",{children:"Payment"})]})}),t.jsx(ge,{className:"space-y-4",children:$?t.jsxs("div",{children:[$.type==="payment"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 bg-muted rounded-lg",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[$.status==="confirmed"||$.status==="paid_out"?t.jsx(xs,{className:"h-6 w-6 text-green-600"}):$.status==="failed"||$.status==="cancelled"?t.jsx(Hs,{className:"h-6 w-6 text-red-600"}):t.jsx(it,{className:"h-6 w-6 text-blue-600 animate-spin"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:$.status==="confirmed"||$.status==="paid_out"?"Payment Confirmed":$.status==="failed"?"Payment Failed":"Payment Pending"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[P($.amount),$.chargeDate&&` ⢠Due: ${T($.chargeDate)}`]})]})]}),t.jsx(we,{className:$.status==="confirmed"||$.status==="paid_out"?"bg-green-100 text-green-800":$.status==="failed"||$.status==="cancelled"?"bg-red-100 text-red-800":"bg-blue-100 text-blue-800",children:$.status.replace(/_/g," ")})]}),($.status==="failed"||$.status==="cancelled")&&t.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:t.jsxs("p",{className:"text-sm text-red-800",children:[t.jsx("strong",{children:"Payment Issue:"})," Your payment was not successful. Please contact our support team to resolve this issue."]})})]}),$.type==="subscription"&&t.jsx("div",{className:"space-y-3",children:t.jsxs("div",{className:"flex items-center justify-between p-4 bg-muted rounded-lg",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[$.status==="active"?t.jsx(xs,{className:"h-6 w-6 text-green-600"}):t.jsx(it,{className:"h-6 w-6 text-blue-600 animate-spin"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:$.status==="active"?"Monthly Subscription Active":"Subscription Pending"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[P($.amount)," per month"]})]})]}),t.jsx(we,{className:$.status==="active"?"bg-green-100 text-green-800":"bg-blue-100 text-blue-800",children:$.status.replace(/_/g," ")})]})}),$.type==="mandate"&&!(b!=null&&b.length)&&!(w!=null&&w.length)&&t.jsx("div",{className:"space-y-3",children:t.jsx("div",{className:"flex items-center justify-between p-4 bg-blue-50 border border-blue-200 rounded-lg",children:t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx(it,{className:"h-6 w-6 text-blue-600 animate-spin"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-blue-900",children:"Direct Debit Setup Complete"}),t.jsx("p",{className:"text-sm text-blue-700",children:"No payment is taken without the issue of an Invoice. You will receive an invoice by email by the end of the next working day. Payment for this invoice will be taken by direct debit on the day of the invoice due date."})]})]})})})]}):e.payment_status==="paid"||e.payment_status==="confirmed"?t.jsxs("div",{className:"flex items-center justify-between p-4 bg-muted rounded-lg",children:[t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx(xs,{className:"h-6 w-6 text-green-600"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"Payment Complete"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[P(e.final_total||e.monthly_price)," + VAT"]})]})]}),t.jsx(we,{className:"bg-green-100 text-green-800",children:"Paid"})]}):e.pricing_model==="fixed"||e.pricing_model==="leafleting"?(()=>{var z,Z;const C=e.pricing_model==="leafleting",L=e.distribution_start_date||e.leaflets_required_by,D=L?Math.ceil((new Date(L).getTime()-Date.now())/(1e3*60*60*24)):999,_=C&&D<=10,H=e.final_total||e.monthly_price;let O=H;if(C&&j&&j.length>0){const M=((z=e.pricing_breakdown)==null?void 0:z.areaBreakdown)||[];if(M.length>0){const F=(Z=M[0])==null?void 0:Z.basePrice,ee=j.find(se=>{var le;return se.id===((le=M[0])==null?void 0:le.areaId)});ee!=null&&ee.price_with_vat&&F&&Math.abs(F-ee.price_with_vat)<1&&(O=Math.round(H/1.2*100)/100)}}const U=Math.ceil(O*.25*100)/100,G=C&&!_?U:O,E=C&&!_;return t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:E?"Pay a 25% deposit now to secure your leaflet distribution slot:":"Pay the full amount securely by card:"}),t.jsxs("div",{className:"p-4 border-2 border-primary bg-primary/5 rounded-lg",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"font-medium",children:E?"Pay 25% Deposit":"Pay Full Amount"}),t.jsxs("span",{className:"font-bold text-lg",children:[P(G)," + VAT"]})]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:E?`One-off deposit payment via Stripe ⢠Remaining ${P(O-U)} + VAT due before distribution`:"One-off card payment via Stripe"})]}),C&&!E&&t.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-3",children:t.jsxs("p",{className:"text-sm text-amber-800",children:[t.jsx("strong",{children:"Full payment required:"})," Your distribution date is within 10 days, so the full amount is due now."]})}),e!=null&&e.terms_accepted_at?t.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-50 border border-green-200 rounded-lg",children:[t.jsx(xs,{className:"h-4 w-4 text-green-600 shrink-0"}),t.jsxs("p",{className:"text-sm text-green-700",children:["Terms accepted on ",new Date(e.terms_accepted_at).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})]})]}):t.jsxs("div",{className:"flex items-start space-x-3 p-4 bg-blue-50/80 border border-blue-200 rounded-lg",children:[t.jsx(Kt,{id:"legalDocumentsBooking",checked:o,onCheckedChange:M=>l(!!M),className:"mt-0.5"}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(V,{htmlFor:"legalDocumentsBooking",className:"text-sm font-medium cursor-pointer",children:"I accept the T&C's *"}),t.jsxs(bt,{open:c,onOpenChange:d,children:[t.jsx(Sn,{asChild:!0,children:t.jsxs(q,{variant:"link",size:"sm",className:"p-0 h-auto text-blue-600 hover:text-blue-800",children:[t.jsx(hc,{className:"h-4 w-4 mr-1"}),"View Documents"]})}),t.jsxs(xt,{className:"max-w-4xl max-h-[80vh] overflow-y-auto",onCloseAutoFocus:M=>M.preventDefault(),children:[t.jsx(jt,{children:t.jsx(wt,{children:"Legal Documents"})}),t.jsxs("div",{className:"space-y-6 text-sm",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Terms & Conditions"}),t.jsxs("div",{className:"space-y-2 text-muted-foreground",children:[t.jsx("p",{children:"By using our advertising services, you agree to the following terms:"}),t.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[t.jsx("li",{children:"Payment terms: Full payment required before print date"}),t.jsx("li",{children:"Campaign specifications are final once approved"}),t.jsx("li",{children:"We reserve the right to refuse advertising content that violates our content policy"}),t.jsx("li",{children:"Delivery dates are estimates and may vary due to external factors"})]})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Service Agreement"}),t.jsxs("div",{className:"space-y-2 text-muted-foreground",children:[t.jsx("p",{children:"This agreement outlines the specific details of your advertising campaign:"}),t.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[t.jsx("li",{children:"Campaign duration and distribution schedule"}),t.jsx("li",{children:"Target areas and circulation numbers"}),t.jsx("li",{children:"Advertisement specifications and design requirements"}),t.jsx("li",{children:"Quality standards and printing specifications"}),t.jsx("li",{children:"Distribution methods and tracking procedures"}),t.jsx("li",{children:"Performance metrics and reporting standards"})]})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Data Protection Notice"}),t.jsxs("div",{className:"space-y-2 text-muted-foreground",children:[t.jsx("p",{children:"We are committed to protecting your personal information:"}),t.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[t.jsx("li",{children:"Personal data is collected only for service delivery purposes"}),t.jsx("li",{children:"Information is stored securely and encrypted"}),t.jsx("li",{children:"Data is not shared with third parties without consent"}),t.jsx("li",{children:"You have the right to access, modify, or delete your data"}),t.jsx("li",{children:"We comply with GDPR and UK data protection regulations"}),t.jsx("li",{children:"Data retention policy: Information kept for 7 years for accounting purposes"})]})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Privacy Policy"}),t.jsxs("div",{className:"space-y-2 text-muted-foreground",children:[t.jsx("p",{children:"Our privacy policy explains how we
762collect and use your information:"}),t.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[t.jsx("li",{children:"Website cookies are used to improve user experience"}),t.jsx("li",{children:"Analytics data helps us improve our services"}),t.jsx("li",{children:"Marketing communications are opt-in only"}),t.jsx("li",{children:"Account information is used for service delivery and support"}),t.jsx("li",{children:"Payment information is processed by secure third-party providers"}),t.jsx("li",{children:"You can update privacy preferences in your account settings"})]})]})]}),t.jsx("div",{className:"border-t pt-4 mt-6",children:t.jsx("p",{className:"text-xs text-muted-foreground",children:"Last updated: September 2024. These documents will be available for download in your account dashboard after booking completion."})})]})]})]})]}),t.jsx("p",{className:"text-xs text-blue-700",children:"By checking this box, you acknowledge that you have read and agree to our terms of service, data protection policies, and service agreement."})]})]}),t.jsx(q,{onClick:()=>S(G),disabled:!o&&!(e!=null&&e.terms_accepted_at)||m,className:"w-full",size:"lg",children:m?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"mr-2 h-4 w-4 animate-spin"}),"Redirecting to payment..."]}):t.jsxs(t.Fragment,{children:[t.jsx(ci,{className:"mr-2 h-4 w-4"}),E?"Pay 25% Deposit by Card":"Pay Full Amount by Card"]})}),t.jsx("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:t.jsxs("p",{className:"text-sm text-blue-800",children:[t.jsx("strong",{children:"Secure Payment:"})," Your payment will be processed securely via Stripe. You'll be redirected to a secure checkout page to complete your card payment."]})})]})})():t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:(I=e.selections)!=null&&I.payment_option_id?"Your selected to pay:":"Select your payment:"}),t.jsx(Da,{value:a||"",onValueChange:i,children:f.filter(C=>{var L;return!((L=e.selections)!=null&&L.payment_option_id)||C.option_type===e.selections.payment_option_id}).sort((C,L)=>{const D=_=>{var H,O;return _.option_type==="monthly"||_.option_type==="direct_debit"?1:(H=_.display_name)!=null&&H.includes("6 Months")?2:(O=_.display_name)!=null&&O.includes("12 Months")?3:4};return D(C)-D(L)}).map(C=>{var U;const L=e.pricing_model==="bogof"&&e.monthly_price?e.monthly_price*12:e.final_total||e.monthly_price,D=e.pricing_model||"fixed",_=((U=e.pricing_breakdown)==null?void 0:U.designFee)||0,H=fu(L,C,D,f,_),O=C.discount_percentage>0?L*C.discount_percentage/100:0;return t.jsxs("div",{className:`flex items-start space-x-3 p-4 border-2 rounded-lg cursor-pointer transition-all ${a===C.option_type?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,onClick:()=>i(C.option_type),children:[t.jsx(Ir,{value:C.option_type,id:C.id,className:"mt-1"}),t.jsx("div",{className:"flex-1",children:t.jsxs(V,{htmlFor:C.id,className:"cursor-pointer",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"font-medium",children:C.display_name.includes("6 Months")?"6 months in advance":C.display_name.includes("12 Months")?"12 months in advance":C.display_name}),t.jsxs("span",{className:"font-bold text-lg",children:[P(H)," + VAT",C.option_type==="direct_debit"&&t.jsx("span",{className:"text-sm text-muted-foreground",children:"/month"})]})]}),t.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:["Direct Debit will collect"," ",t.jsxs("span",{className:"font-semibold text-foreground",children:[P(zre(H))," inc VAT"]})," ","(",P(H)," + ",P(Ure(H))," VAT @ ",EN*100,"%)",(C.option_type==="direct_debit"||C.option_type==="monthly")&&" per month"]}),C.discount_percentage>0&&O>0&&t.jsxs("p",{className:"text-sm text-green-600",children:["Save ",P(O)," (",C.discount_percentage,"% discount)"]}),C.minimum_payments&&C.option_type==="monthly"&&t.jsxs("div",{className:"space-y-1",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["⢠Minimum number of payments = ",C.minimum_payments]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"⢠'Go Cardless REF DISCOVERMAGA' will appear on your statement"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"⢠1ST payment will be taken within the next 5 days. Subsequent payments on the 10th day of each month."})]})]})})]},C.id)})}),t.jsxs("div",{className:"flex items-start space-x-3 p-4 bg-blue-50/80 border border-blue-200 rounded-lg",children:[t.jsx(Kt,{id:"legalDocumentsBooking",checked:o,onCheckedChange:C=>l(!!C),className:"mt-0.5"}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(V,{htmlFor:"legalDocumentsBooking",className:"text-sm font-medium cursor-pointer",children:"I accept the T&C's *"}),t.jsxs(bt,{open:c,onOpenChange:d,children:[t.jsx(Sn,{asChild:!0,children:t.jsxs(q,{variant:"link",size:"sm",className:"p-0 h-auto text-blue-600 hover:text-blue-800",children:[t.jsx(hc,{className:"h-4 w-4 mr-1"}),"View Documents"]})}),t.jsxs(xt,{className:"max-w-4xl max-h-[80vh] overflow-y-auto",onCloseAutoFocus:C=>C.preventDefault(),children:[t.jsx(jt,{children:t.jsx(wt,{children:"Legal Documents"})}),t.jsxs("div",{className:"space-y-6 text-sm",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Terms & Conditions"}),t.jsxs("div",{className:"space-y-2 text-muted-foreground",children:[t.jsx("p",{children:"By using our advertising services, you agree to the following terms:"}),t.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[t.jsx("li",{children:"Payment terms: Full payment required before print date"}),t.jsx("li",{children:"Campaign specifications are final once approved"}),t.jsx("li",{children:"We reserve the right to refuse advertising content that violates our content policy"}),t.jsx("li",{children:"Delivery dates are estimates and may vary due to external factors"})]})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Service Agreement"}),t.jsxs("div",{className:"space-y-2 text-muted-foreground",children:[t.jsx("p",{children:"This agreement outlines the specific details of your advertising campaign:"}),t.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[t.jsx("li",{children:"Campaign duration and distribution schedule"}),t.jsx("li",{children:"Target areas and circulation numbers"}),t.jsx("li",{children:"Advertisement specifications and design requirements"}),t.jsx("li",{children:"Quality standards and printing specifications"}),t.jsx("li",{children:"Distribution methods and tracking procedures"}),t.jsx("li",{children:"Performance metrics and reporting standards"})]})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Data Protection Notice"}),t.jsxs("div",{className:"space-y-2 text-muted-foreground",children:[t.jsx("p",{children:"We are committed to protecting your personal information:"}),t.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[t.jsx("li",{children:"Personal data is collected only for service delivery purposes"}),t.jsx("li",{children:"Information is stored securely and encrypted"}),t.jsx("li",{children:"Data is not shared with third parties without consent"}),t.jsx("li",{children:"You have the right to access, modify, or delete your data"}),t.jsx("li",{children:"We comply with GDPR and UK data protection regulations"}),t.jsx("li",{children:"Data retention policy: Information kept for 7 years for accounting purposes"})]})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Privacy Policy"}),t.jsxs("div",{className:"space-y-2 text-muted-foreground",children:[t.jsx("p",{children:"Our privacy policy explains how we
762collect and use your information:"}),t.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[t.jsx("li",{children:"Website cookies are used to improve user experience"}),t.jsx("li",{children:"Analytics data helps us improve our services"}),t.jsx("li",{children:"Marketing communications are opt-in only"}),t.jsx("li",{children:"Account information is used for service delivery and support"}),t.jsx("li",{children:"Payment information is processed by secure third-party providers"}),t.jsx("li",{children:"You can update privacy preferences in your account settings"})]})]})]}),t.jsx("div",{className:"border-t pt-4 mt-6",children:t.jsx("p",{className:"text-xs text-muted-foreground",children:"Last updated: September 2024. These documents will be available for download in your account dashboard after booking completion."})})]})]})]})]}),t.jsx("p",{className:"text-xs text-blue-700",children:"By checking this box, you acknowledge that you have read and agree to our terms of service, data protection policies, and service agreement."})]})]}),t.jsx(q,{onClick:N,disabled:!a||!o&&!(e!=null&&e.terms_accepted_at)||p.isPending,className:"w-full",size:"lg",children:p.isPending?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"mr-2 h-4 w-4 animate-spin"}),"Setting up payment..."]}):t.jsxs(t.Fragment,{children:[t.jsx(ci,{className:"mr-2 h-4 w-4"}),"Set Up Payment Plan by GoCardless"]})}),t.jsx("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:t.jsxs("p",{className:"text-sm text-blue-800",children:[t.jsx("strong",{children:"Secure Payment:"})," Your payment will be processed securely via GoCardless Direct Debit. You'll be redirected to set up your Direct Debit mandate before payment is collected."]})})]})})]}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{children:"Contact Information"})}),t.jsx(ge,{className:"space-y-3",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Contact Name"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e.contact_name})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Email"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e.email})]}),e.phone&&t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Phone"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e.phone})]}),e.company&&t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Company"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e.company})]})]})})]}),t.jsx(xe,{})]})})})},C3=({voucher:e,onUseVoucher:s})=>{const{toast:r}=rt(),n=()=>{navigator.clipboard.writeText(e.voucher_code),r({title:"Voucher Code Copied!",description:"You can now use this code when booking leafleting services."})},a=c=>c?new Date(c).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}):null,i=()=>e.voucher_type==="percentage"?`${e.discount_value}% OFF`:`£${e.discount_value} OFF`,o=e.expires_at&&new Date(e.expires_at)<new Date,l=e.is_active&&!e.is_used&&!o;return t.jsxs(xe,{className:`relative overflow-hidden ${e.is_used?"opacity-60":l?"border-community-green shadow-lg":"opacity-75"}`,children:[t.jsx(Me,{className:"pb-3",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(yr,{className:"w-5 h-5 text-community-green"}),t.jsx(Oe,{className:"text-lg font-heading",children:"Leafleting Voucher"})]}),t.jsx(we,{variant:l?"default":e.is_used?"secondary":"destructive",children:e.is_used?"Used":o?"Expired":"Active"})]})}),t.jsxs(ge,{className:"space-y-4",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-3xl font-bold text-community-green mb-2",children:i()}),t.jsxs("p",{className:"text-sm text-muted-foreground capitalize",children:[e.service_type," Service Discount"]})]}),t.jsx("div",{className:"bg-muted rounded-lg p-3",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Voucher Code"}),t.jsx("p",{className:"font-mono font-bold text-lg tracking-wider",children:e.voucher_code})]}),t.jsx(q,{variant:"outline",size:"sm",onClick:n,className:"ml-2",children:t.jsx(Wx,{className:"w-4 h-4"})})]})}),e.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),e.expires_at&&t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(It,{className:"w-4 h-4"}),t.jsxs("span",{children:["Expires: ",a(e.expires_at)]})]}),e.is_used&&e.used_at&&t.jsxs("div",{className:"text-sm text-muted-foreground",children:["Used on: ",a(e.used_at)]}),l&&t.jsx(q,{className:"w-full bg-community-green hover:bg-green-600",onClick:()=>s==null?void 0:s(e.id),children:"Use This Voucher"})]})]})},qre=({user:e})=>{const[s,r]=u.useState([]),[n,a]=u.useState(!0),{toast:i}=rt(),o=async()=>
762{if(e){a(!0);try{const{data:m,error:h}=await W.from("vouchers").select("*").eq("user_id",e.id).order("created_at",{ascending:!1});if(h)throw h;r(m||[])}catch(m){console.error("Error loading vouchers:",m),i({title:"Error Loading Vouchers",description:m.message,variant:"destructive"})}finally{a(!1)}}};u.useEffect(()=>{o()},[e]);const l=m=>{i({title:"Ready to Use Voucher!",description:"Navigate to the leafleting service page and enter your voucher code at checkout."})},c=s.filter(m=>m.is_active&&!m.is_used),d=s.filter(m=>m.is_used);return n?t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(yr,{className:"w-5 h-5 text-community-green"}),"Your Vouchers"]})}),t.jsx(ge,{children:t.jsxs("div",{className:"animate-pulse space-y-4",children:[t.jsx("div",{className:"h-32 bg-muted rounded"}),t.jsx("div",{className:"h-32 bg-muted rounded"})]})})]}):s.length===0?t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(yr,{className:"w-5 h-5 text-community-green"}),"Your Vouchers"]})}),t.jsx(ge,{children:t.jsxs("div",{className:"text-center py-8",children:[t.jsx(yr,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),t.jsx("p",{className:"text-muted-foreground",children:"No vouchers yet"}),t.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Book a 3+ Subscription Package to earn a 10% leafleting voucher!"})]})})]}):t.jsxs("div",{className:"space-y-6",children:[c.length>0&&t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(yr,{className:"w-5 h-5 text-community-green"}),"Active Vouchers (",c.length,")"]})}),t.jsxs(ge,{children:[t.jsxs(ss,{className:"mb-4",children:[t.jsx(hc,{className:"h-4 w-4"}),t.jsx(rs,{children:"Use these vouchers when booking leafleting services to get your discount!"})]}),t.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:c.map(m=>t.jsx(C3,{voucher:m,onUseVoucher:l},m.id))})]})]}),d.length>0&&t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(yr,{className:"w-5 h-5 text-muted-foreground"}),"Used Vouchers (",d.length,")"]})}),t.jsx(ge,{children:t.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:d.map(m=>t.jsx(C3,{voucher:m},m.id))})})]})]})};function Hre({activeTab:e,setActiveTab:s,businessCount:r,eventCount:n,quoteCount:a,bookingCount:i,voucherCount:o=0,editingBusiness:l,editingEvent:c,advertiserStatus:d="none"}){const{state:m}=Yu(),h=j=>e===j?"bg-primary/10 text-primary border-r-2 border-primary font-medium":"hover:bg-muted/50 text-muted-foreground hover:text-foreground",f=[...l?[{title:"Edit Listing",value:"create",icon:Xr,disabled:!1}]:[],{title:`Your Listings (${r})`,value:"listings",icon:Kb,disabled:!1}],p=[{title:c?"Edit Event":"Create Event",value:"create-event",icon:c?It:Xt,disabled:!1},{title:`Your Events (${n})`,value:"events",icon:Kb,disabled:!1}],x=[{title:"Create Booking",value:"create-booking",icon:Xt,disabled:!1},{title:`Saved Quotes (${a})`,value:"quotes",icon:ir,disabled:!1},{title:`Bookings (${i})`,value:"bookings",icon:tu,disabled:!1},{title:"Artwork Upload",value:"artwork",icon:Wi,disabled:!1},{title:"My Schedule",value:"schedule",icon:Qo,disabled:!1},{title:`Your Vouchers (${o})`,value:"vouchers",icon:yr,disabled:!1},{title:"Terms & Conditions",value:"terms",icon:Oa,disabled:!1}],g=[{title:`Past Bookings (${i})`,value:"bookings",icon:tu,disabled:!1},{title:`Past Quotes (${a})`,value:"quotes",icon:ir,disabled:!1},{title:`Your Vouchers (${o})`,value:"vouchers",icon:yr,disabled:!1},{title:"Terms & Conditions",value:"terms",icon:Oa,disabled:!1}],b=d==="lapsed"?g:x,w=d==="active"||d==="lapsed";return t.jsx(CN,{className:"border-r",children:t.jsxs($N,{children:[t.jsxs(gd,{children:[t.jsx(Am,{className:"text-sm font-semibold text-muted-foreground",children:"Advertising"}),t.jsx(vd,{children:t.jsx(ql,{children:b.map(j=>t.jsx(Lo,{children:t.jsxs(Bo,{onClick:()=>s(j.value),disabled:j.disabled,className:h(j.value),children:[t.jsx(j.icon,{className:"h-4 w-4"}),m!=="collapsed"&&t.jsx("span",{children:j.title})]})},j.value))})})]}),w&&t.jsxs(gd,{children:[t.jsx(Am,{className:"text-sm font-semibold text-muted-foreground",children:"Magazines Online"}),t.jsx(vd,{children:t.jsx(ql,{children:t.jsx(Lo,{children:t.jsxs(Bo,{onClick:()=>s("magazines"),className:h("magazines"),children:[t.jsx(Dc,{className:"h-4 w-4"}),m!=="collapsed"&&t.jsx("span",{children:d==="lapsed"?"Past Editions":"View Editions"})]})})})})]}),t.jsxs(gd,{children:[t.jsx(Am,{className:"text-sm font-semibold text-muted-foreground",children:"Business Directory"}),t.jsx(vd,{children:t.jsx(ql,{children:f.map(j=>t.jsx(Lo,{children:t.jsxs(Bo,{onClick:()=>
762s(j.value),disabled:j.disabled,className:h(j.value),children:[t.jsx(j.icon,{className:"h-4 w-4"}),m!=="collapsed"&&t.jsx("span",{children:j.title})]})},j.value))})})]}),t.jsxs(gd,{children:[t.jsx(Am,{className:"text-sm font-semibold text-muted-foreground",children:"Events"}),t.jsx(vd,{children:t.jsx(ql,{children:p.map(j=>t.jsx(Lo,{children:t.jsxs(Bo,{onClick:()=>s(j.value),disabled:j.disabled,className:h(j.value),children:[t.jsx(j.icon,{className:"h-4 w-4"}),m!=="collapsed"&&t.jsx("span",{children:j.title})]})},j.value))})})]})]})})}var PN="Avatar",[Wre,kfe]=hr(PN),[Gre,$9]=Wre(PN),E9=u.forwardRef((e,s)=>{const{__scopeAvatar:r,...n}=e,[a,i]=u.useState("idle");return t.jsx(Gre,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:i,children:t.jsx(ze.span,{...n,ref:s})})});E9.displayName=PN;var P9="AvatarImage",A9=u.forwardRef((e,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...i}=e,o=$9(P9,r),l=Yre(n,i.referrerPolicy),c=Qt(d=>{a(d),o.onImageLoadingStatusChange(d)});return qs(()=>{l!=="idle"&&c(l)},[l,c]),l==="loaded"?t.jsx(ze.img,{...i,ref:s,src:n}):null});A9.displayName=P9;var T9="AvatarFallback",D9=u.forwardRef((e,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=e,i=$9(T9,r),[o,l]=u.useState(n===void 0);return u.useEffect(()=>{if(n!==void 0){const c=window.setTimeout(()=>l(!0),n);return()=>window.clearTimeout(c)}},[n]),o&&i.imageLoadingStatus!=="loaded"?t.jsx(ze.span,{...a,ref:s}):null});D9.displayName=T9;function Yre(e,s){const[r,n]=u.useState("idle");return qs(()=>{if(!e){n("error");return}let a=!0;const i=new window.Image,o=l=>()=>{a&&n(l)};return n("loading"),i.onload=o("loaded"),i.onerror=o("error"),i.src=e,s&&(i.referrerPolicy=s),()=>{a=!1}},[e,s]),r}var R9=E9,M9=A9,O9=D9;const I9=u.forwardRef(({className:e,...s},r)=>t.jsx(R9,{ref:r,className:oe("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...s}));I9.displayName=R9.displayName;const Kre=u.forwardRef(({className:e,...s},r)=>t.jsx(M9,{ref:r,className:oe("aspect-square h-full w-full",e),...s}));Kre.displayName=M9.displayName;const F9=u.forwardRef(({className:e,...s},r)=>t.jsx(O9,{ref:r,className:oe("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...s}));F9.displayName=O9.displayName;function Qre({user:e,onProfileClick:s}){const r=ds(),{signOut:n}=Ar(),a=async()=>{await n()},i=()=>{r("/")},o=()=>{r("/support")},l=()=>e!=null&&e.email?e.email.charAt(0).toUpperCase():"U";return t.jsxs("header",{className:"flex h-16 shrink-0 items-center justify-between gap-2 border-b px-6 bg-background",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(kN,{className:"-ml-1"}),t.jsx("div",{className:"h-4 w-px bg-sidebar-border"}),t.jsx("h1",{className:"text-lg font-semibold",children:"Dashboard"})]}),t.jsxs(sA,{children:[t.jsx(rA,{asChild:!0,children:t.jsx(q,{variant:"ghost",className:"relative h-9 w-9 rounded-full",children:t.jsx(I9,{className:"h-9 w-9",children:t.jsx(F9,{className:"bg-primary text-primary-foreground",children:l()})})})}),t.jsxs(R2,{className:"w-56",align:"end",forceMount:!0,children:[t.jsx(nA,{className:"font-normal",children:t.jsxs("div",{className:"flex flex-col space-y-1",children:[t.jsx("p",{className:"text-sm font-medium leading-none",children:"Account"}),t.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:e==null?void 0:e.email})]})}),t.jsx(Cj,{}),t.jsxs(zl,{onClick:i,children:[t.jsx(gl,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:"Back to Website"})]}),t.jsxs(zl,{onClick:s,children:[t.jsx($w,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:"Profile Settings"})]}),t.jsxs(zl,{onClick:o,children:[t.jsx(Hx,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:"Support"})]}),t.jsx(Cj,{}),t.jsxs(zl,{onClick:a,className:"text-destructive focus:text-destructive",children:[t.jsx(Qb,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:"Sign Out"})]})]})]})]})}const k3=(e,s,r,n)=>{if(!e||e<=0)return 0;const a=n==null?void 0:n.find(o=>o.option_type==="monthly"),i=(a==null?void 0:a.minimum_payments)||6;return s==="bogof"?e/2/i:e/(r||1)};function Xre({user:e,onBookingCreated:s,onQuoteSaved:r,onBookNowWithTerms:n,isAdmin:a=!1}){var Ee,K,te;const{toast:i}=rt(),[o,l]=u.useState(!1),[c,d]=u.useState("fixed"),[m,h]=u.useState([]),[f,p]=u.useState([]),[x,g]=u.useState([]),[b,w]=u.useState(""),[j,y]=u.useState({}),[v,N]=u.useState(""),[S,k]=u.useState(""),[$,R]=u.useState(!1),[A,T]=u.useState(""),[P,B]=u.useState(""),{areas:Y,adSizes:I,durations:C,subscriptionDurations:L,volumeDiscounts:D,isLoading:_}=ji(),{leafletAreas:H,leafletDurations:O,leafletSizes:U,isLoading:G}=Hu(),{data:E=[]}
762=Wu(),[z,Z]=u.useState(null),[M,F]=u.useState(!1);u.useEffect(()=>{(async()=>{const{data:ae}=await W.from("profiles").select("*").eq("user_id",e.id).single();ae&&Z(ae)})()},[e.id]),u.useEffect(()=>{(async()=>{const{data:ae}=await W.from("user_roles").select("role").eq("user_id",e.id).eq("role","admin").limit(1);if(ae&&ae.length>0){F(!1);return}const{data:me}=await W.from("bookings").select("id").eq("user_id",e.id).eq("pricing_model","bogof").limit(1);F(!!me&&me.length>0)})()},[e.id]),u.useEffect(()=>{h([]),p([]),g([]),w(""),y({}),k(""),N(""),B("")},[c]),u.useEffect(()=>{const Q=c==="leafleting"?O:c==="bogof"?L:C;if(Q&&Q.length>0&&!b&&(c!=="leafleting"||!v))if((c==="leafleting"?"leaflet":"ad")==="leaflet"){const me=Q.find(pe=>pe.is_default)||Q[0];me&&N(me.id)}else{const me=Q.find(pe=>pe.is_default)||Q[0];me&&w(me.id)}},[c,C,L,O]);const ee=u.useMemo(()=>{if(!$||!S)return 0;const Q=I==null?void 0:I.find(ae=>ae.id===S);return c==="bogof"?(Q==null?void 0:Q.design_fee_subscription)||45:(Q==null?void 0:Q.design_fee)||95},[$,S,I,c]),se=u.useMemo(()=>{if(c==="leafleting"){if(!m.length||!v)return null;const Q=O==null?void 0:O.find(me=>me.id===v);if(!Q)return null;const ae=Q.months/2;return fN(m,H||[],ae,Q.issues)}else{const Q=c==="bogof"?f:m;if(!Q.length||!S||!b)return null;const ae=c==="fixed"?C==null?void 0:C.find(be=>be.id===b):L==null?void 0:L.find(be=>be.id===b),me=I==null?void 0:I.find(be=>be.id===S);return!ae||!me?null:Kh(Q,S,b,c==="bogof",Y||[],I||[],(c==="bogof"?L:C)||[],L||[],D||[],c==="bogof"?x:[],0)}},[c,m,f,x,S,b,v,Y,I,C,L,D,H,O]),le=u.useMemo(()=>{if(!se)return null;if(ee>0&&$){const Q=se.finalTotal;return{...se,designFee:ee,finalTotalBeforeDesign:Q,finalTotal:Q+ee}}return{...se,designFee:0}},[se,ee,$]),X=()=>{const Q=A&&A.length>0;return c==="leafleting"?m.length>0&&v&&P!=="":c==="bogof"?f.length>=3&&x.length>=3&&S&&b&&Q:m.length>0&&S&&b&&Q},ye=async()=>{var Q,ae,me,pe;if(!(!X()||!le)){l(!0);try{const be=k3(le.finalTotal,c,le.durationMultiplier||1,E),ce=Ad({pricingModel:c,monthlyPrice:be,fallbackFinalTotal:le.finalTotal}),ie={user_id:e.id,contact_name:(z==null?void 0:z.display_name)||((Q=e.email)==null?void 0:Q.split("@")[0])||"",email:e.email||"",phone:(z==null?void 0:z.phone)||null,pricing_model:c,ad_size_id:c==="leafleting"?null:S,duration_id:c==="leafleting"?null:b,selected_area_ids:c==="leafleting"?m:c==="bogof"?[...f,...x]:m,bogof_paid_area_ids:c==="bogof"?f:null,bogof_free_area_ids:c==="bogof"?x:null,monthly_price:be,subtotal:le.subtotal,final_total:ce,total_circulation:le.totalCirculation,volume_discount_percent:"volumeDiscount"in le?le.volumeDiscount:0,duration_discount_percent:"durationDiscount"in le&&le.durationDiscount||0,agency_discount_percent:(z==null?void 0:z.agency_discount_percent)||0,distribution_start_date:j&&((ae=Object.values(j)[0])!=null&&ae[0])?`${Object.values(j)[0][0]}-01`:null,pricing_breakdown:le,selections:{areas:c==="leafleting"?m:c==="bogof"?{paid:f,free:x}:m,adSize:S,duration:b,months:j,includeDesign:$,leafletSize:P,leafletDuration:v,payment_option_id:A},status:"draft"},{data:je,error:Re}=await W.from("quotes").insert([ie]).select().single();if(Re)throw Re;try{const Ae=c==="leafleting"?U==null?void 0:U.find(lt=>lt.id===P):I==null?void 0:I.find(lt=>lt.id===S),Ue=c==="leafleting"?O==null?void 0:O.find(lt=>lt.id===v):(C==null?void 0:C.find(lt=>lt.id===b))||(L==null?void 0:L.find(lt=>lt.id===b)),Ve={areas:Y,adSizes:I,durations:C,subscriptionDurations:L,paymentOptions:E,leafletAreas:H||[]};await W.functions.invoke("send-quote-booking-webhook",{body:px({record_type:"quote",record_id:je.id,pricing_model:c,contact_name:(z==null?void 0:z.display_name)||((me=e.email)==null?void 0:me.split("@")[0])||"",email:e.email||"",phone:(z==null?void 0:z.phone)||"",company:"",title:"Dashboard Quote",ad_size:c==="leafleting"?Ae==null?void 0:Ae.label:Ae==null?void 0:Ae.name,duration:Ue==null?void 0:Ue.name,selected_areas:c==="bogof"?[...f,...x]:m,bogof_paid_areas:c==="bogof"?f:[],bogof_free_areas:c==="bogof"?x:[],total_circulation:le.totalCirculation,subtotal:le.subtotal,final_total:ie.final_total,monthly_price:ie.monthly_price,volume_discount_percent:"volumeDiscount"in le?le.volumeDiscount:0,status:"draft",pricing_breakdown:le,selections:ie.selections},Ve)}),console.log("Dashboard quote webhook sent successfully")}catch(Ae){console.error("Dashboard quote webhook error:",Ae)}try{const Ae=c==="leafleting"?U==null?void 0:U.find(Ve=>Ve.id===P):I==null?void 0:I.find(Ve=>Ve.id===S),Ue=c==="leafleting"?O==null?void 0:O.find(Ve=>Ve.id===v):(C==null?void 0:C.find(Ve=>Ve.id===b))||(L==null?void 0:L.find(Ve=>Ve.id===b));await W.functions.invoke("send-booking-confirmation-email",{body:{record_type:"quote",record_id:je.id,pricing_model:c,contact_name:(z==null?void 0:z.display_name)||((pe=e.email)==null?void 0:pe.split("@")[0])||"",email:e.email||"",phone:(z==null?void 0:z.phone)||"",ad_size:c==="leafleting"?Ae==null?void 0:Ae.label:Ae==null?void 0:Ae.name,duration:Ue==null?void 0:Ue.name,selected_areas:(c==="bogof"?[...f,...x]:m).map(Ve=>{var lt;return((lt=[...Y||[],...H||[]].find(J=>J.id===Ve))==null?void 0:lt.name)||Ve}),bogof_paid_areas:(c==="bogof"?f:[]).map(Ve=>{var lt;return((lt=Y==null?void 0:Y.find(J=>J.id===Ve))==null?void 0:lt.name)||Ve}),bogof_free_areas:(c==="bogof"?x:[]).map(Ve=>{var lt;return((lt=Y==null?void 0:Y.find(J=>J.id===Ve))==null?void 0:lt.name)||Ve}),total_circulation:le.totalCirculation,subtotal:le.subtotal,final_total:ie.final_total,monthly_price:ie.monthly_price,pricing_breakdown:le,selections:ie.selections,distribution_start_date:ie.distribution_start_date}}),console.log("Dashboard quote confirmation email sent")}catch(Ae){console.error("Dashboard quote email error:",Ae)}i({title:"Quote Saved",description:"Your quote has been saved successfully."}),r==null||r()}catch(be){i({title:"Error",description:be.message,variant:"destructive"})}finally{l(!1)}}},Ce=async()=>{var Q,ae;if(!(!X()||!le)){l(!0);try{const me=k3(le.finalTotal,c,le.durationMultiplier||1,E),pe=Ad({pricingModel:c,monthlyPrice:me,fallbackFinalTotal:le.finalTotal}),be={user_id:e.id,contact_name:(z==null?void 0:z.display_name)||((Q=e.email)==null?void 0:Q.split("@")[0])||"",email:e.email||"",phone:(z==null?void 0:z.phone)||null,pricing_model:c,ad_size_id:c==="leafleting"?null:S,duration_id:c==="leafleting"?null:b,selected_area_
762ids:c==="leafleting"?m:c==="bogof"?[...f,...x]:m,bogof_paid_area_ids:c==="bogof"?f:null,bogof_free_area_ids:c==="bogof"?x:null,monthly_price:me,subtotal:le.subtotal,final_total:pe,total_circulation:le.totalCirculation,volume_discount_percent:"volumeDiscount"in le?le.volumeDiscount:0,duration_discount_percent:"durationDiscount"in le&&le.durationDiscount||0,agency_discount_percent:(z==null?void 0:z.agency_discount_percent)||0,distribution_start_date:j&&((ae=Object.values(j)[0])!=null&&ae[0])?`${Object.values(j)[0][0]}-01`:null,pricing_breakdown:le,selections:{areas:c==="leafleting"?m:c==="bogof"?{paid:f,free:x}:m,adSize:S,duration:b,months:j,includeDesign:$,leafletSize:P,leafletDuration:v,payment_option_id:A},status:"draft"},{data:ce,error:ie}=await W.from("quotes").insert([be]).select().single();if(ie)throw ie;n?n(ce):(i({title:"Quote Saved",description:"Your quote has been saved. Please accept terms to complete booking."}),r==null||r())}catch(me){i({title:"Error",description:me.message,variant:"destructive"})}finally{l(!1)}}},ke=()=>{h([]),p([]),g([]),w(""),y({}),k(""),R(!1),N(""),B("")},fe=u.useMemo(()=>c==="leafleting"?m.reduce((Q,ae)=>{const me=H==null?void 0:H.find(pe=>pe.id===ae);return Q+((me==null?void 0:me.bimonthly_circulation)||0)},0):(c==="bogof"?[...f,...x]:m).reduce((ae,me)=>{const pe=Y==null?void 0:Y.find(be=>be.id===me);
762return ae+((pe==null?void 0:pe.circulation)||0)},0),[c,m,f,x,Y,H]);return _||G?t.jsx(xe,{children:t.jsx(ge,{className:"py-12",children:t.jsx("div",{className:"text-center text-muted-foreground",children:"Loading form..."})})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(_f,{className:"h-5 w-5"}),"Create New Booking"]})}),t.jsxs(ge,{className:"space-y-6",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{className:"text-base font-semibold",children:"Select Package Type"}),t.jsx(Da,{value:c,onValueChange:Q=>d(Q),children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsx(xe,{className:`cursor-pointer transition-all ${c==="fixed"?"ring-2 ring-primary":""}`,children:t.jsxs(ge,{className:"pt-6",children:[t.jsx(Ir,{value:"fixed",id:"fixed",className:"sr-only"}),t.jsx(V,{htmlFor:"fixed",className:"cursor-pointer",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"font-semibold",children:"Pay As You Go"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"One-time campaign with set duration"})]})})]})}),t.jsx(xe,{className:`cursor-pointer transition-all ${c==="bogof"?"ring-2 ring-primary":""}`,children:t.jsxs(ge,{className:"pt-6",children:[t.jsx(Ir,{value:"bogof",id:"bogof",className:"sr-only"}),t.jsx(V,{htmlFor:"bogof",className:"cursor-pointer",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"font-semibold",children:"3+ Subscription Package"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Best value for ongoing campaigns"})]})})]})}),t.jsx(xe,{className:`cursor-pointer transition-all ${c==="leafleting"?"ring-2 ring-primary":""}`,children:t.jsxs(ge,{className:"pt-6",children:[t.jsx(Ir,{value:"leafleting",id:"leafleting",className:"sr-only"}),t.jsx(V,{htmlFor:"leafleting",className:"cursor-pointer",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"font-semibold",children:"Leafleting"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Direct mail distribution"})]})})]})})]})})]}),c==="bogof"&&M&&!a&&t.jsxs(ss,{className:"border-amber-500/50 bg-amber-500/10",children:[t.jsx(zr,{className:"h-4 w-4 text-amber-600"}),t.jsxs(rs,{className:"text-sm",children:[t.jsx("strong",{children:"Returning Customer Notice:"})," As you've previously booked the 3+ Subscription Package, please call our team to discuss your next booking and explore special retention offers available to you."]})]}),t.jsx(fs,{}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs(V,{className:"text-base font-semibold flex items-center gap-2",children:[t.jsx(_t,{className:"h-4 w-4"}),"Select Areas"]}),c==="bogof"?t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{className:"text-sm font-medium",children:"Paid Areas (min. 3)"}),t.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto border rounded-md p-3",children:Y==null?void 0:Y.map(Q=>{var ae;return t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(Kt,{id:`paid-${Q.id}`,checked:f.includes(Q.id),onCheckedChange:me=>{if(me)p([...f,Q.id]),g(x.filter(pe=>pe!==Q.id));else{const pe=f.filter(be=>be!==Q.id);p(pe),x.length>pe.length&&g(be=>be.slice(0,pe.length))}}}),t.jsxs(V,{htmlFor:`paid-${Q.id}`,className:"text-sm cursor-pointer flex-1",children:[Q.name," (",(ae=Q.circulation)==null?void 0:ae.toLocaleString()," circulation)"]})]},Q.id)})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(we,{variant:f.length>=3?"default":"outline",children:[f.length," selected"]}),f.length<3&&t.jsxs("span",{className:"text-xs text-amber-600",children:["Select at least ",3-f.length," more"]})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{className:"text-sm font-medium",children:"Free Areas (min. 3)"}),t.jsxs("div",{className:"space-y-2 max-h-64 overflow-y-auto border rounded-md p-3",children:[f.length===0&&t.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Select paid areas first - those areas will not appear here"}),Y==null?void 0:Y.filter(Q=>!f.includes(Q.id)).map(Q=>{var ae;return t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(Kt,{id:`free-${Q.id}`,checked:x.includes(Q.id),onCheckedChange:me=>{g(me?[...x,Q.id]:x.filter(pe=>pe!==Q.id))}}),t.jsxs(V,{htmlFor:`free-${Q.id}
762`,className:"text-sm cursor-pointer flex-1",children:[Q.name," (",(ae=Q.circulation)==null?void 0:ae.toLocaleString()," circulation)"]})]},Q.id)})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(we,{variant:x.length>=3?"default":"outline",children:[x.length," selected"]}),x.length<3&&f.length>=3&&t.jsxs("span",{className:"text-xs text-amber-600",children:["Select at least ",3-x.length," more"]})]})]})]}):t.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto border rounded-md p-3",children:(Ee=c==="leafleting"?H:Y)==null?void 0:Ee.map(Q=>{var ae;return t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(Kt,{id:Q.id,checked:m.includes(Q.id),onCheckedChange:me=>{h(me?[...m,Q.id]:m.filter(pe=>pe!==Q.id))}}),t.jsxs(V,{htmlFor:Q.id,className:"text-sm cursor-pointer flex-1",children:[Q.name," (",(ae=c==="leafleting"?Q.bimonthly_circulation:Q.circulation)==null?void 0:ae.toLocaleString()," circulation)"]})]},Q.id)})}),t.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:t.jsxs(we,{variant:"secondary",children:["Total: ",fe.toLocaleString()," circulation"]})})]}),t.jsx(fs,{}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs(V,{className:"text-base font-semibold flex items-center gap-2",children:[t.jsx(It,{className:"h-4 w-4"}),"Select Duration"]}),t.jsxs(ht,{value:c==="leafleting"?v:b,onValueChange:c==="leafleting"?N:w,children:[t.jsx(ut,{children:t.jsx(ft,{placeholder:"Choose duration"})}),t.jsx(mt,{children:(K=c==="leafleting"?O:c==="fixed"?C:L)==null?void 0:K.map(Q=>t.jsxs(Pe,{value:Q.id,children:[Q.name,Q.description&&` - ${Q.description}`]},Q.id))})]})]}),c!=="leafleting"&&t.jsxs(t.Fragment,{children:[t.jsx(fs,{}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs(V,{className:"text-base font-semibold flex items-center gap-2",children:[t.jsx(V4,{className:"h-4 w-4"}),"Select Advertisement Size"]}),t.jsxs(ht,{value:S,onValueChange:k,children:[t.jsx(ut,{children:t.jsx(ft,{placeholder:"Choose ad size"})}),t.jsx(mt,{children:I==null?void 0:I.filter(Q=>{const ae=Q.available_for;return!ae||ae.length===0?!0:ae.includes(c==="bogof"?"subscription":"fixed")}).map(Q=>t.jsxs(Pe,{value:Q.id,children:[Q.name," - ",Q.dimensions]},Q.id))})]})]}),t.jsx(fs,{}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs(V,{className:"text-base font-semibold flex items-center gap-2",children:[t.jsx(ra,{className:"h-4 w-4"}),"Design Service"]}),t.jsx(Da,{value:$?"yes":"no",onValueChange:Q=>R(Q==="yes"),children:t.jsxs("div",{className:"flex gap-4",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(Ir,{value:"no",id:"design-no"}),t.jsx(V,{htmlFor:"design-no",className:"cursor-pointer",children:"No, I have my own design"})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(Ir,{value:"yes",id:"design-yes"}),t.jsxs(V,{htmlFor:"design-yes",className:"cursor-pointer",children:["Yes, include design service",$&&(I==null?void 0:I.find(Q=>Q.id===S))&&t.jsxs("span",{className:"ml-2 text-muted-foreground",children:["(+",Nt(((te=I.find(Q=>Q.id===S))==null?void 0:te.design_fee)||0),")"]})]})]})]})})]})]}),c==="leafleting"&&t.jsxs(t.Fragment,{children:[t.jsx(fs,{}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs(V,{className:"text-base font-semibold flex items-center gap-2",children:[t.jsx(V4,{className:"h-4 w-4"}),"Select Leaflet Size"]}),t.jsxs(ht,{value:P,onValueChange:B,children:[t.jsx(ut,{children:t.jsx(ft,{placeholder:"Choose leaflet size"})}),t.jsx(mt,{children:U==null?void 0:U.map(Q=>t.jsxs(Pe,{value:Q.id,children:[Q.label,Q.description&&` - ${Q.description}`]},Q.id))})]})]})]})]})]}),le&&t.jsxs(xe,{className:"border-primary/50",children:[t.jsxs(Me,{children:[t.jsxs(Oe,{className:"flex items-center gap-2 text-primary",children:[t.jsx(Yx,{className:"h-5 w-5"}),c==="leafleting"?"Payment Method":`${E.length} Payment Option${E.length!==1?"s":""}`,c!=="leafleting"&&t.jsx("span",{className:"text-destructive",children:"*"})]}),c!=="leafleting"&&!A&&t.jsx("p",{className:"text-sm text-amber-600 mt-1",children:"Please select a payment option to continue"})]}),t.jsx(ge,{className:"space-y-4",children:(()=>{const Q=le.finalTotal||0,ae=le.totalCirculation||0,me=le.designFee||0;return Q?t.jsxs(t.Fragment,{children:[c==="leafleting"?t.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/5 p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(As,{className:"h-5 w-5 text-primary"}),t.jsx("span",{className:"font-semibold text-foreground",children:"Stripe Secure Payment"})]}),t.jsxs("ul",{className:"space-y-2 text-sm text-foreground",children:[t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"font-medium text-primary",children:"25%"}),t.jsx("span",{children:"Deposit due at the time of booking"})]}),t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"font-medium text-primary",children:"75%"}),t.jsx("span",{children:"Balance due before distribution"})]})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"If distribution is within 10 days, 100% payment is required at booking."})]}):t.jsx(t.Fragment,{children:(()=>{const be=[...fx(E,c)].sort((ce,ie)=>{const je={monthly:1,"6_months":2,"12_months":3};return(je[ce.option_type]||99)-(je[ie.option_type]||99)});return t.jsx(Da,{value:A,onValueChange:T,className:"space-y-3",children:be.map(ce=>{const ie=fu(Q,ce,c,E,me),je=ce.option_type==="monthly",Re=ce.discount_percentage>0;return t.jsxs("div",{className:`flex items-center space-x-3 p-4 rounded-lg border transition-all cursor-pointer ${A===ce.option_type?"border-primary bg-primary/5 ring-1 ring-primary":"border-border hover:border-primary/50"}`,onClick:()=>T(ce.option_type),children:[t.jsx(Ir,{value:ce.option_type,id:ce.option_type}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(V,{htmlFor:ce.option_type,className:"font-semibold cursor-pointer",children:ce.display_name}),Re&&t.jsxs(we,{variant:"secondary",className:"bg-green-100 text-green-700 text-xs",children:["Save ",ce.discount_percentage,"%"]})]}),ce.description&&t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:ce.description}),je&&ce.minimum_payments&&t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[ce.minimum_payments," monthly payments"]})]}),t.jsxs("div",{className:"text-right",children:[t.jsx("div",{className:"font-bold text-lg",children:m0(ie)}),je&&t.jsx("span",{className:"text-xs text-muted-foreground",children:"/month"}),!je&&t.jsx("span",{className:"text-xs text-muted-foreground",children:"+ VAT"})]})]},ce.id)})})})()}),ae>0&&t.jsxs(t.Fragment,{children:[t.jsx(fs,{}),t.jsxs("div",{className:"bg-gradient-to-r from-amber-50 to-orange-50 dark:from-amber-950/30 dark:to-orange-950/30 rounded-lg p-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(ui,{className:"h-5 w-5 text-amber-600"}),t.jsx("span",{className:"font-semibold text-amber-800 dark:text-amber-400",children:"Amazing Value"})]}),t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx(gl,{className:"h-4 w-4 text-muted-foreground"}),t.jsxs("span",{children:["Only ",t.jsx("strong",{className:"text-primary",children:m0(Q/ae*1e3)})," per 1,000 homes reached"]})]})]})]}),t.jsx(fs,{}),t.jsxs("div",{className:"space-y-2 text-sm",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-muted-foreground",children:"Total Campaign Cost:"}),t.jsxs("span",{className:"font-semibold",children:[m0(Q)," + VAT"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-muted-foreground",children:"Total Circulation:"}),t.jsxs("span",{className:"font-semibold",children:[ae.toLocaleStr
762ing()," homes"]})]})]})]}):null})()})]}),!X()&&t.jsxs(ss,{children:[t.jsx(Hs,{className:"h-4 w-4"}),t.jsx(rs,{children:"Please complete all required selections before saving or booking."})]}),t.jsx(xe,{children:t.jsx(ge,{className:"pt-6",children:t.jsxs("div",{className:"flex flex-wrap gap-3",children:[t.jsx(q,{onClick:ye,disabled:!X()||o,variant:"outline",className:"flex-1",children:"Save as Quote"}),t.jsxs(q,{onClick:Ce,disabled:!X()||o,className:"flex-1",children:[t.jsx(As,{className:"h-4 w-4 mr-2"}),"Book Now"]}),t.jsx(q,{onClick:ke,variant:"ghost",disabled:o,children:"Clear Form"})]})})})]})}const Zre=['"FREE for 3" applies for the first 3 bi-monthly issues only','You must nominate the "paid for" 3+ Subscribed areas','The free areas run concurrently with the "paid for" areas',"Paid for areas will continue to run unless cancellation or change of areas/size requested","3+ Subscriptions are paid monthly by direct debit (GoCardless)","By setting up the direct debit you are accepting the terms of a 3+ Subscription with Discover Magazines Ltd","Payments are taken by GoCardless on 10th day of each month","Inflationary increase applies per anniversary after 24 months from start of booking â no increase for 24 months"],Jre=["Payment is due in full before publication","Fixed term bookings run for the agreed number of issues only","No automatic renewal â a new booking is required to continue","Cancellation is not available once artwork has been submitted for print","Design fees (if applicable) are non-refundable","Prices are exclusive of VAT"],ene=["Once booking is confirmed, 25% of the full amount is required at time of booking. Payment by debit/credit card.","The remaining 75% is due 10 days prior to the delivery date.","If the booking is made within 10 days of delivery, payment is required in full at the time of booking.","No monthly payment plan or extra discount for payment in full in advance is available."];function L9({pricingModel:e}){const s=e==="fixed"||e==="fixed_term",r=e==="leafleting",n=!e;return t.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"rounded-xl bg-primary/10 p-3",children:t.jsx(Oa,{className:"h-7 w-7 text-primary"})}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight text-foreground",children:"Terms of Booking & Payment"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:"Please review the terms that apply to your advertising bookings with Discover Magazines."})]})]}),t.jsxs(Ru,{type:"multiple",value:["terms","fixed-terms","leaflet-terms","payment"],className:"space-y-3",children:[(n||!s&&!r)&&t.jsxs(ti,{value:"terms",className:"border rounded-lg bg-card px-4 shadow-sm",children:[t.jsx(si,{className:"hover:no-underline gap-3",children:t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx(As,{className:"h-5 w-5 text-primary shrink-0"}),t.jsxs("div",{children:[t.jsx("span",{className:"font-semibold text-foreground",children:"3+ Subscription Terms"}),t.jsx(we,{variant:"secondary",className:"ml-2 text-[10px] align-middle",children:"3+ Subscription Package"})]})]})}),t.jsx(ri,{children:t.jsx("ul",{className:"space-y-3 pl-1",children:Zre.map((a,i)=>t.jsxs("li",{className:"flex items-start gap-3 text-sm text-muted-foreground leading-relaxed",children:[t.jsx("span",{className:"mt-1 flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary/10 text-[11px] font-bold text-primary",children:i+1}),t.jsx("span",{children:a})]},i))})})]}),(n||s&&!r)&&t.jsxs(ti,{value:"fixed-terms",className:"border rounded-lg bg-card px-4 shadow-sm",children:[t.jsx(si,{className:"hover:no-underline gap-3",children:t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx(As,{className:"h-5 w-5 text-primary shrink-0"}),t.jsxs("div",{children:[t.jsx("span",{className:"font-semibold text-foreground",children:"Pay As You Go Booking Terms"}),t.jsx(we,{variant:"secondary",className:"ml-2 text-[10px] align-middle",children:"Pay As You Go"})]})]})}),t.jsx(ri,{children:t.jsx("ul",{className:"space-y-3 pl-1",children:Jre.map((a,i)=>t.jsxs("li",{className:"flex items-start gap-3 text-sm text-muted-foreground leading-relaxed",children:[t.jsx("span",{className:"mt-1 flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary/10 text-[11px] font-bold text-primary",children:i+1}),t.jsx("span",{children:a})]},i))})})]}),(n||r)&&t.jsxs(ti,{value:"leaflet-terms",className:"border rounded-lg bg-card px-4 shadow-sm",children:[t.jsx(si,{className:"hover:no-underline gap-3",children:t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx(As,{className:"h-5 w-5 text-primary shrink-0"}),t.jsxs("div",{children:[t.jsx("span",{className:"font-semibold text-foreground",children:"Payment Terms (Leaflet Distribution)"}),t.jsx(we,{variant:"secondary",className:"ml-2 text-[10px] align-middle",children:"Leaflet Distribution"})]})]})}),t.jsx(ri,{children:t.jsx("ul",{className:"space-y-3 pl-1",children:ene.map((a,i)=>t.jsxs("li",{className:"flex items-start gap-3 text-sm text-muted-foreground leading-relaxed",children:[t.jsx("span",{className:"mt-1 flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary/10 text-[11px] font-bold text-primary",children:i+1}),t.jsx("span",{children:a})]},i))})})]}),t.jsxs(ti,{value:"payment",className:"border rounded-lg bg-card px-4 shadow-sm",children:[t.jsx(si,{className:"hover:no-underline gap-3",children:t.jsxs("div",{className:"flex items-center gap-3 text-left",children:[t.jsx(ci,{className:"h-5 w-5 text-primary shrink-0"}),t.jsx("span",{className:"font-semibold text-foreground",children:"Payment & Billing"})]})}),t.jsx(ri,{children:t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"rounded-lg border bg-muted/40 p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(_t,{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0"}),t.jsxs("div",{className:"text-sm",children:[t.jsx("p",{className:"font-medium text-foreground",children:"Invoice Issuer"}),t.jsx("p",{className:"text-muted-foreground",children:"Discover Magazines Ltd, 30 Leigh Road, Eastleigh SO50 9DT"})]})]}),!r&&!s&&t.jsxs(t.Fragment,{children:[t.jsx(fs,{}),t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(ci,{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0"}),t.jsxs("div",{className:"text-sm",children:[t.jsx("p",{className:"font-medium text-foreground",children:"GoCardless Bank Reference"}),t.jsxs("p",{className:"text-muted-foreground",children:[t.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs font-mono",children:"DISCOVERMAG"})," ","â Direct Debit Guarantee"]})]})]}),t.jsx(fs,{}),t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(ws,{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0"}),t.jsxs("div",{className:"text-sm",children:[t.jsx("p",{className:"font-medium text-foreground",children:"Payment Schedule"}),t.jsx("p",{className:"text-muted-foreground",children:"Payments are collected on the 10th of each month via GoCardless Direct Debit"})]})]})]})]})})})]})]}),t.jsx(xe,{className:"border-dashed",children:t.jsxs(ge,{className:"flex items-start gap-3 p-4",children:[t.jsx(mi,{className:"h-4 w-4 mt-0.5 text-amber-500 shrink-0"}),t.jsxs("p",{className:"text-xs text-muted-foreground leading-relaxed",children:[r?"These terms apply specifically to Leaflet Distribution bookings. Magazine advertising bookings may have different c
762onditions.":s?"These terms apply specifically to Fixed Term bookings. Subscription (3+ Subscription) bookings may have different conditions.":n?"These terms apply to your advertising bookings with Discover Magazines. Different booking types may have specific conditions.":"These terms apply specifically to 3+ Subscription (Repeat Package) bookings. Fixed-term bookings may have different conditions."," ","If you have any questions about your booking terms, please contact us using the details above."]})]})})]})}function tne({quote:e,open:s,onOpenChange:r,onConfirm:n,isSubmitting:a=!1}){const[i,o]=u.useState(!1),[l,c]=u.useState(!1);ve.useEffect(()=>{s&&(e!=null&&e.id)&&!l&&(c(!0),W.from("quotes").update({terms_viewed_at:new Date().toISOString()}).eq("id",e.id).then()),s||(o(!1),c(!1))},[s,e==null?void 0:e.id]);const d=async()=>{!i||!e||await n(e)};return e?t.jsx(bt,{open:s,onOpenChange:r,children:t.jsxs(xt,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",onCloseAutoFocus:m=>m.preventDefault(),children:[t.jsx(jt,{children:t.jsxs(wt,{className:"flex items-center gap-2 text-xl",children:[t.jsx(Oa,{className:"h-5 w-5 text-primary"}),"Review & Accept Terms"]})}),t.jsxs("div",{className:"space-y-6",children:[t.jsx(L9,{pricingModel:e==null?void 0:e.pricing_model}),t.jsxs("div",{className:"flex items-start space-x-3 p-4 bg-primary/5 border-2 border-primary/20 rounded-lg",children:[t.jsx(Kt,{id:"termsAcceptance",checked:i,onCheckedChange:m=>o(!!m),className:"mt-0.5"}),t.jsxs(V,{htmlFor:"termsAcceptance",className:"cursor-pointer text-sm leading-relaxed",children:["I have read and accept the ",t.jsx("span",{className:"font-semibold",children:"Terms of Booking & Payment"}),". I understand that by confirming this booking, I agree to the terms outlined above."]})]})]}),t.jsxs(ma,{className:"gap-2 sm:gap-0",children:[t.jsx(q,{variant:"outline",onClick:()=>r(!1),disabled:a,children:"Cancel"}),t.jsx(q,{onClick:d,disabled:!i||a,className:"bg-gradient-to-r from-green-600 to-green-700 hover:from-green-700 hover:to-green-800 text-white",children:a?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"h-4 w-4 mr-1 animate-spin"}),"Confirming..."]}):t.jsxs(t.Fragment,{children:[t.jsx(xs,{className:"h-4 w-4 mr-1"}),"Confirm Booking"]})})]})]})}):null}const sne=({booking:e,adSize:s})=>{const{toast:r}=rt(),n=Xs(),[a,i]=u.useState(!1),[o,l]=u.useState(""),[c,d]=u.useState(null),{data:m,isLoading:h}=Lt({queryKey:["booking-artwork",e.id],queryFn:async()=>{const{data:w,error:j}=await W.from("booking_artwork").select("*").eq("booking_id",e.id).order("uploaded_at",{ascending:!1}).limit(1).maybeSingle();if(j)throw j;return w}});if(!(e.payment_status==="paid"||e.payment_status==="confirmed"))return null;const p=w=>{var v;const j=(v=w.target.files)==null?void 0:v[0];if(!j)return;if(!["application/pdf","image/jpeg","image/jpg"].includes(j.type)){r({title:"Invalid file type",description:"Please upload a PDF or JPG file.",variant:"destructive"});return}if(j.size>20*1024*1024){r({title:"File too large",description:"Maximum file size is 20MB.",variant:"destructive"});return}d(j)},x=async()=>{if(c){i(!0);try{const{data:{user:w}}=await W.auth.getUser();if(!w)throw new Error("Not authenticated");const j=c.name.split(".").pop(),y=`${w.id}/${e.id}/${Date.now()}.${j}`,{error:v}=await W.storage.from("booking-artwork").upload(y,c);if(v)throw v;const{error:N}=await W.from("booking_artwork").insert({booking_id:e.id,user_id:w.id,file_url:y,file_name:c.name,file_size:c.size,notes:o||null,status:"pending"});if(N)throw N;r({title:"Artwork uploaded!",description:"Your artwork has been submitted for review."}),d(null),l(""),n.invalidateQueries({queryKey:["booking-artwork",e.id]})}catch(w){console.error("Upload error:",w),r({title:"Upload failed",description:w.message,variant:"destructive"})}finally{i(!1)}}},g=w=>{switch(w){case"approved":return t.jsx(we,{className:"bg-green-100 text-green-800",children:"Approved"});case"rejected":return t.jsx(we,{className:"bg-red-100 text-red-800",children:"Rejected"});default:return t.jsx(we,{className:"bg-yellow-100 text-yellow-800",children:"Pending Review"})}},b=!m||m.status==="rejected";return t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center space-x-2",children:[t.jsx(Wi,{className:"h-5 w-5"}),t.jsx("span",{children:"Artwork Submission"})]})}),t.jsxs(ge,{className:"space-y-4",children:[s&&t.jsxs("div",{className:"bg-muted p-4 rounded-lg space-y-1",children:[t.jsxs("p",{className:"text-sm font-medium",children:["Ad Size: ",s.name," â ",s.dimensions]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Please supply artwork at ",t.jsx("strong",{children:s.dimensions}),", 300dpi, as PDF or JPG."]})]}),m&&t.jsxs("div",{className:"border rounded-lg p-4 space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ir,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm font-medium",children:m.file_name})]}),g(m.status)]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Uploaded: ",new Date(m.uploaded_at).toLocaleDateString("en-GB",{day:"2-digit",month:"long",year:"numeric"})]}),m.notes&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Notes: ",m.notes]}),m.status==="rejected"&&m.admin_notes&&t.jsx("div",{className:"bg-red-50 border border-red-200 rounded p-3",children:t.jsxs("p",{className:"text-sm text-red-800",children:[t.jsx("strong",{children:"Feedback:"})," ",m.admin_notes]})})]}),b&&t.jsxs("div",{className:"space-y-3",children:[(m==null?void 0:m.status)==="rejected"&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Your artwork was rejected. Please upload a revised version."}),t.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[t.jsx("input",{type:"file",accept:".pdf,.jpg,.jpeg",onChange:p,className:"hidden",id:"artwork-upload",disabled:a}),t.jsxs("label",{htmlFor:"artwork-upload",className:"cursor-pointer space-y-2 block",children:[t.jsx(sn,{className:"h-8 w-8 mx-auto text-muted-foreground"}),c?t.jsx("p",{className:"text-sm font-medium",children:c.name}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select your artwork file"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF or JPG, max 20MB"})]})]})]}),t.jsx(ms,{placeholder:"Optional notes about your artwork...",value:o,onChange:w=>l(w.target.value),rows:2}),t.jsx(q,{onClick:x,disabled:!c||a,className:"w-full",children:a?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"mr-2 h-4 w-4 animate-spin"}),"Uploading..."]}):t.jsxs(t.Fragment,{children:[t.jsx(sn,{className:"mr-2 h-4 w-4"}),"Submit Artwork"]})})]}),(m==null?void 0:m.status)==="approved"&&t.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-50 border border-green-200 rounded-lg",children:[t.jsx(xs,{className:"h-4 w-4 text-green-600"}),t.jsx("p",{className:"text-sm text-green-700",children:"Your artwork has been approved!"})]})]})]})},rne=()=>{const{user:e}=Ar(),{data:s=[],isLoading:r}=Lt({queryKey:["paid-bookings",e==null?void 0:e.id],queryFn:async()=>
762{if(!(e!=null&&e.id))return[];const{data:l,error:c}=await W.from("bookings").select("*").eq("user_id",e.id).not("payment_status","in",'("cancelled","failed","refunded")').order("created_at",{ascending:!1});if(c)throw c;return l||[]},enabled:!!(e!=null&&e.id)}),n=[...new Set(s.map(l=>l.ad_size_id).filter(Boolean))],{data:a=[]}=Lt({queryKey:["ad-sizes-for-artwork",n],queryFn:async()=>{if(n.length===0)return[];const{data:l,error:c}=await W.from("ad_sizes").select("*").in("id",n);if(c)throw c;return l||[]},enabled:n.length>0}),i=l=>l&&a.find(c=>c.id===l)||null,o=l=>new Date(l).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"});return r?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):s.length===0?t.jsx(xe,{children:t.jsxs(ge,{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx(pi,{className:"h-12 w-12 text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Bookings Yet"}),t.jsx("p",{className:"text-muted-foreground max-w-md",children:"Once you've made a booking, you'll be able to upload your print-ready artwork here."})]})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-2xl font-bold flex items-center gap-2",children:[t.jsx(Wi,{className:"h-6 w-6 text-primary"}),"Artwork Upload"]}),t.jsx("p",{className:"text-muted-foreground mt-1",children:"Upload your print-ready artwork for each confirmed booking below."})]}),s.map(l=>{const c=i(l.ad_size_id);return t.jsxs(xe,{className:"overflow-hidden",children:[t.jsxs(Me,{className:"bg-muted/30",children:[t.jsxs(Oe,{className:"text-base flex items-center justify-between",children:[t.jsxs("span",{children:["Booking: ",l.title||l.pricing_model," â ",o(l.created_at)]}),t.jsx(we,{variant:"outline",className:"capitalize",children:l.payment_status})]}),c&&t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Ad Size: ",t.jsx("span",{className:"font-medium",children:c.name})," (",c.dimensions,")"]})]}),t.jsx(ge,{className:"pt-4",children:t.jsx(sne,{booking:l,adSize:c})})]},l.id)})]})},nne=["paid","subscription_active","mandate_active"];function ane(){const{user:e}=Ar(),[s,r]=u.useState([]),[n,a]=u.useState([]),[i,o]=u.useState([]),[l,c]=u.useState([]),[d,m]=u.useState(!0),[h,f]=u.useState(()=>jr(new Date));u.useEffect(()=>{if(!e)return;(async()=>{m(!0);const[v,N,S,k]=await Promise.all([W.from("bookings").select("*, booking_artwork!inner(id)").eq("user_id",e.id).in("payment_status",nne),W.from("ad_sizes").select("id, name").eq("is_active",!0),W.from("pricing_areas").select("id, name").eq("is_active",!0),W.from("leaflet_areas").select("id, name, schedule").eq("is_active",!0)]);r(v.data||[]),a(N.data||[]),o(S.data||[]),c(k.data||[]),m(!1)})()},[e]);const p=u.useMemo(()=>{const y={};return i.forEach(v=>{y[v.id]=v.name}),l.forEach(v=>{y[v.id]=v.name}),y},[i,l]),x=u.useMemo(()=>{const y={};return n.forEach(v=>{y[v.id]=v.name}),y},[n]),g=u.useMemo(()=>{const y=[];return s.forEach(v=>{const N=v.selections,S=N==null?void 0:N.months,$=(v.selected_area_ids||[]).map(T=>p[T]||"Unknown Area"),R=v.ad_size_id?x[v.ad_size_id]||"Ad":"",A=v.title||v.company||"Booking";if(S&&Object.keys(S).length>0){const T=new Set;
762Object.values(S).forEach(P=>{Array.isArray(P)&&P.forEach(B=>T.add(B))}),T.forEach(P=>{const B=P.split("-");if(B.length>=2){const Y=new Date(parseInt(B[0]),parseInt(B[1])-1,1);y.push({month:Y,bookingId:v.id,bookingTitle:A,pricingModel:v.pricing_model,areaNames:$,adSizeName:R,paymentStatus:v.payment_status})}})}else if(v.distribution_start_date){const T=new Date(v.distribution_start_date),P=v.duration_multiplier||1;for(let B=0;B<P;B++){const Y=Cr(jr(T),B*2);y.push({month:Y,bookingId:v.id,bookingTitle:A,pricingModel:v.pricing_model,areaNames:$,adSizeName:R,paymentStatus:v.payment_status})}}}),y},[s,p,x]),b=u.useMemo(()=>{const y=[];for(let v=0;v<12;v++)y.push(Cr(h,v));return y},[h]),w=y=>g.filter(v=>Ph(v.month,y)),j=y=>y==null?void 0:y.toLowerCase().includes("leaflet");return d?t.jsx(xe,{children:t.jsx(ge,{className:"py-12 text-center text-muted-foreground",children:"Loading your schedule..."})}):s.length===0?t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(Qo,{className:"h-5 w-5"}),"My Schedule"]})}),t.jsx(ge,{children:t.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[t.jsx(Qo,{className:"h-12 w-12 mx-auto mb-4 opacity-40"}),t.jsx("p",{className:"font-medium",children:"No scheduled campaigns yet"}),t.jsx("p",{className:"text-sm mt-1",children:"Once you have a paid booking with artwork uploaded, your advertising schedule will appear here."})]})})]}):t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(Qo,{className:"h-5 w-5"}),"My Schedule"]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(q,{variant:"outline",size:"icon",onClick:()=>f(y=>Cr(y,-6)),children:t.jsx(su,{className:"h-4 w-4"})}),t.jsxs("span",{className:"text-sm font-medium min-w-[140px] text-center",children:[Dt(h,"MMM yyyy")," â ",Dt(Cr(h,11),"MMM yyyy")]}),t.jsx(q,{variant:"outline",size:"icon",onClick:()=>f(y=>Cr(y,6)),children:t.jsx(Ac,{className:"h-4 w-4"})})]})]})}),t.jsxs(ge,{children:[t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-3",children:b.map((y,v)=>{const N=w(y),S=Ph(y,new Date);return t.jsxs("div",{className:`rounded-lg border p-3 min-h-[120px] transition-colors ${S?"border-primary bg-primary/5":N.length>0?"border-accent bg-accent/30":"border-border bg-muted/20"}`,children:[t.jsx("p",{className:`text-xs font-semibold mb-2 ${S?"text-primary":"text-muted-foreground"}`,children:Dt(y,"MMM yyyy")}),N.length===0?t.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"No campaigns"}):t.jsx("div",{className:"space-y-1.5",children:N.map((k,$)=>t.jsxs("div",{className:`rounded p-1.5 text-[10px] leading-tight ${j(k.pricingModel)?"bg-secondary/60 text-secondary-foreground":"bg-primary/15 text-primary"}`,children:[t.jsxs("div",{className:"flex items-center gap-1 mb-0.5",children:[j(k.pricingModel)?t.jsx(ir,{className:"h-2.5 w-2.5 shrink-0"}):t.jsx(Xo,{className:"h-2.5 w-2.5 shrink-0"}),t.jsx("span",{className:"font-medium truncate",children:k.bookingTitle})]}),k.adSizeName&&t.jsx("p",{className:"truncate opacity-80",children:k.adSizeName}),t.jsxs("p",{className:"truncate opacity-70",children:[k.areaNames.slice(0,2).join(", "),k.areaNames.length>2&&` +${k.areaNames.length-2}`]})]},`${k.bookingId}-${$}`))})]},v)})}),t.jsxs("div",{className:"flex flex-wrap gap-4 mt-4 pt-4 border-t text-xs text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 rounded bg-primary/15 border border-primary/30"}),t.jsx("span",{children:"Magazine Ad"})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 rounded bg-secondary/60 border border-secondary"}),t.jsx("span",{children:"Leaflet Distribution"})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 rounded border-2 border-primary"}),t.jsx("span",{children:"Current Month"})]})]})]})]})}const ine=({lapsed:e=!1})=>{const{data:s,isLoading:r}=Fv(!1,"front_cover"),n=s?e?s.length<=1?[]:s.slice(1):s:[];return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-2xl font-bold flex items-center gap-2",children:[t.jsx(tu,{className:"h-6 w-6 text-primary"}),"Magazines Online"]}),t.jsx("p",{className:"text-muted-foreground",children:e?"Browse past editions you have access to. Reactivate your account to view the current issue.":"Read current and past editions of the magazine online."})]}),r?t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(a=>t.jsx(Is,{className:"h-80"},a))}):n.length===0?t.jsx(xe,{children:t.jsx(ge,{className:"py-12 text-center text-muted-foreground",children:"No magazines available yet."})}):t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:n.map(a=>t.jsxs(xe,{className:"overflow-hidden hover:shadow-lg transition-shadow",children:[t.jsx("div",{className:"aspect-[3/4] bg-muted overflow-hidden",children:t.jsx("img",{src:a.image_url,alt:a.alt_text||a.title,className:"w-full h-full object-cover",loading:"lazy"})}),t.jsxs(ge,{className:"p-4 space-y-2",children:[t.jsx("h3",{className:"font-semibold leading-tight",children:a.title}),a.issue_month&&t.jsx("p",{className:"text-sm text-muted-foreground",children:a.issue_month}),a.link_url&&t.jsx(q,{asChild:!0,size:"sm",className:"w-full mt-2",variant:"outline",children:t.jsxs("a",{href:a.link_url,target:"_blank",rel:"noopener noreferrer",children:[t.jsx(_u,{className:"h-4 w-4 mr-2"}),"View Online"]})})]})]},a.id))})]})},one=({status:e})=>{const s=ds();return e==="none"?null:e==="active"?t.jsxs(ss,{className:"border-green-200 bg-green-50 dark:border-green-900 dark:bg-green-950",children:[t.jsx(As,{className:"h-4 w-4 text-green-600"}),t.jsx(rs,{className:"text-green-900 dark:text-green-100",children:"You're an active advertiser â full access to upcoming editions, artwork uploads, and tools."})]}):t.jsxs(ss,{className:"border-amber-200 bg-amber-50 dark:border-amber-900 dark:bg-amber-950",children:[t.jsx(mi,{className:"h-4 w-4 text-amber-600"}),t.jsxs(rs,{className:"flex items-center justify-between gap-4 text-amber-900 dark:text-amber-100",children:[t.jsx("span",{children:"Welcome back. Your account is currently inactive â past bookings and vouchers are still available."}),t.jsx(q,{size:"sm",variant:"outline",className:"border-amber-300 hover:bg-amber-100",onClick:()=>s("/advertising"),children:"Book again â"})]})]})};var AN="Popover",[B9,$fe]=hr(AN,[vl]),Wf=vl(),[lne,Nl]=B9(AN),z9=e=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:i,modal:o=!1}=e,l=Wf(s),c=u.useRef(null),[d,m]=u.useState(!1),[h=!1,f]=wr({prop:n,defaultProp:a,onChange:i});return t.jsx(ov,{...l,children:t.jsx(lne,{scope:s,contentId:Lr(),triggerRef:c,open:h,onOpenChange:f,onOpenToggle:u.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:d,onCustomAnchorAdd:u.useCallback(()=>m(!0),[]),onCustomAnchorRemove:u.useCallback(()=>m(!1),[]),modal:o,children:r})})};z9.displayName=AN;var U9="PopoverAnchor",cne=u.forwardRef((e,s)=>{const{__scopePopover:r,...n}=e,a=Nl(U9,r),i=Wf(r),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=a;return u.useEffect(()=>(o(),()=>l()),[o,l]),t.jsx($f,{...i,...n,ref:s})});cne.displayName=U9;var V9="PopoverTrigger",q9=u.forwardRef((e,s)=>{const{__scopePopover:r,...n}
vendor: 4,166 bytes, line 762
762=e,a=Nl(V9,r),i=Wf(r),o=at(s,a.triggerRef),l=t.jsx(ze.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":K9(a.open),...n,ref:o,onClick:Se(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?l:t.jsx($f,{asChild:!0,...i,children:l})});q9.displayName=V9;var TN="PopoverPortal",[dne,une]=B9(TN,{forceMount:void 0}),H9=e=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=e,i=Nl(TN,s);return t.jsx(dne,{scope:s,forceMount:r,children:t.jsx(Ts,{present:r||i.open,children:t.jsx(Nu,{asChild:!0,container:a,children:n})})})};H9.displayName=TN;var pu="PopoverContent",W9=u.forwardRef((e,s)=>{const r=une(pu,e.__scopePopover),{forceMount:n=r.forceMount,...a}=e,i=Nl(pu,e.__scopePopover);return t.jsx(Ts,{present:n||i.open,children:i.modal?t.jsx(mne,{...a,ref:s}):t.jsx(hne,{...a,ref:s})})});W9.displayName=pu;var mne=u.forwardRef((e,s)=>{const r=Nl(pu,e.__scopePopover),n=u.useRef(null),a=at(s,n),i=u.useRef(!1);return u.useEffect(()=>{const o=n.current;if(o)return Df(o)},[]),t.jsx(Tf,{as:tn,allowPinchZoom:!0,children:t.jsx(G9,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Se(e.onCloseAutoFocus,o=>{var l;o.preventDefault(),i.current||(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Se(e.onPointerDownOutside,o=>{const l=o.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;i.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:Se(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),hne=u.forwardRef((e,s)=>{const r=Nl(pu,e.__scopePopover),n=u.useRef(!1),a=u.useRef(!1);return t.jsx(G9,{...e,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,i),i.defaultPrevented||(n.current||(l=r.triggerRef.current)==null||l.focus(),i.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:i=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((d=r.triggerRef.current)==null?void 0:d.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),G9=u.forwardRef((e,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:m,...h}=e,f=Nl(pu,r),p=Wf(r);return Sv(),t.jsx(Af,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:i,children:t.jsx(xl,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:m,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>f.onOpenChange(!1),children:t.jsx(lv,{"data-state":K9(f.open),role:"dialog",id:f.contentId,...p,...h,ref:s,style:{...h.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)"}})})})}),Y9="PopoverClose",fne=u.forwardRef((e,s)=>{const{__scopePopover:r,...n}=e,a=Nl(Y9,r);return t.jsx(ze.button,{type:"button",...n,ref:s,onClick:Se(e.onClick,()=>a.onOpenChange(!1))})});fne.displayName=Y9;var pne="PopoverArrow",xne=u.forwardRef((e,s)=>{const{__scopePopover:r,...n}=e,a=Wf(r);return t.jsx(cv,{...a,...n,ref:s})});xne.displayName=pne;function K9(e){return e?"open":"closed"}var gne=z9,vne=q9,yne=H9,Q9=W9;const Cn=gne,kn=vne,en=u.forwardRef(({className:e,align:s="center",sideOffset:r=4,...n},a)=>t.jsx(yne,{children:t.jsx(Q9,{ref:a,align:s,sideOffset:r,className:oe("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:sli
762de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));en.displayName=Q9.displayName;var $3=1,bne=.9,jne=.8,wne=.17,x0=.1,g0=.999,Nne=.9999,_ne=.99,Sne=/[\\\/_+.#"@\[\(\{&]/,Cne=/[\\\/_+.#"@\[\(\{&]/g,kne=/[\s-]/,X9=/[\s-]/g;function e1(e,s,r,n,a,i,o){if(i===s.length)return a===e.length?$3:_ne;var l=`${a},${i}`;if(o[l]!==void 0)return o[l];for(var c=n.charAt(i),d=r.indexOf(c,a),m=0,h,f,p,x;d>=0;)h=e1(e,s,r,n,d+1,i+1,o),h>m&&(d===a?h*=$3:Sne.test(e.charAt(d-1))?(h*=jne,p=e.slice(a,d-1).match(Cne),p&&a>0&&(h*=Math.pow(g0,p.length))):kne.test(e.charAt(d-1))?(h*=bne,x=e.slice(a,d-1).match(X9),x&&a>0&&(h*=Math.pow(g0,x.length))):(h*=wne,a>0&&(h*=Math.pow(g0,d-a))),e.charAt(d)!==s.charAt(i)&&(h*=Nne)),(h<x0&&r.charAt(d-1)===n.charAt(i+1)||n.charAt(i+1)===n.charAt(i)&&r.charAt(d-1)!==n.charAt(i))&&(f=e1(e,s,r,n,d+1,i+2,o),f*x0>h&&(h=f*x0)),h>m&&(m=h),d=r.indexOf(c,d+1);return o[l]=m,m}function E3(e){return e.toLowerCase().replace(X9," ")}function $ne(e,s,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,e1(e,s,E3(e),E3(s),0,0,{})}function Pr(){return Pr=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Pr.apply(null,arguments)}function Dd(e,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(e==null||e(a),r===!1||!a.defaultPrevented)return s==null?void 0:s(a)}}function Ene(e,s){typeof e=="function"?e(s):e!=null&&(e.current=s)}function Z9(...e){return s=>e.forEach(r=>Ene(r,s))}function Gf(...e){return u.useCallback(Z9(...e),e)}function Pne(e,s=[]){let r=[];function n(i,o){const l=u.createContext(o),c=r.length;r=[...r,o];function d(h){const{scope:f,children:p,...x}=h,g=(f==null?void 0:f[e][c])||l,b=u.useMemo(()=>x,Object.values(x));return u.createElement(g.Provider,{value:b},p)}function m(h,f){const p=(f==null?void 0:f[e][c])||l,x=u.useContext(p);if(x)return x;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return d.displayName=i+"Provider",[d,m]}const a=()=>{const i=r.map(o=>u.createContext(o));return function(l){const c=(l==null?void 0:l[e])||i;return u.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[n,Ane(a,...s)]}function Ane(...e){const s=e[0];if(e.length===1)return s;const r=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=n.reduce((l,{useScope:c,scopeName:d})=>{const h=c(i)[`__scope${d}`];return{...l,...h}},{});return u.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return r.scopeName=s.scopeName,r}const Tne=globalThis!=null&&globalThis.document?u.useLayoutEffect:()=>{},Dne=_1.useId||(()=>{});let Rne=0;function v0(e){const[s,r]=u.useState(Dne());return Tne(()=>{e||r(n=>n??String(Rne++))},[e]),e||(s?`radix-${s}`:"")}function J9(e){const s=u.useRef(e);return u.useEffect(()=>{s.current=e}),u.useMemo(()=>(...r)=>{var n;return(n=s.current)===null||n===void 0?void 0:n.call(s,...r)},[])}function Mne({prop:e,defaultProp:s,onChange:r=()=>{}}){const[n,a]=One({defaultProp:s,onChange:r}),i=e!==void 0,o=i?e:n,l=J9(r),c=u.useCallback(d=>{if(i){const h=typeof d=="function"?d(e):d;h!==e&&l(h)}else a(d)},[i,e,a,l]);return[o,c]}function One({defaultProp:e,onChange:s}){const r=u.useState(e),[n]=r,a=u.useRef(n),i=J9(s);return u.useEffect(()=>{a.current!==n&&(i(n),a.current=n)},[n,a,i]),r}function Ine(e,s){typeof e=="function"?e(s):e!=null&&(e.current=s)}function Fne(...e){return s=>e.forEach(r=>Ine(r,s))}const eR=u.forwardRef((e,s)=>{const{children:r,...n}=e,a=u.Children.toArray(r),i=a.find(Bne);if(i){const o=i.props.children,l=a.map(c=>c===i?u.Children.count(o)>1?u.Children.only(null):u.isValidElement(o)?o.props.children:null:c);return u.createElement(t1,Pr({},n,{ref:s}),u.isValidElement(o)?u.cloneElement(o,void 0,l):null)}return u.createElement(t1,Pr({},n,{ref:s}),r)});eR.displayName="Slot";const t1=u.forwardRef((e,s)=>{const{children:r,...n}=e;return u.isValidElement(r)?u.cloneElement(r,{...zne(n,r.props),ref:s?Fne(s,r.ref):r.ref}):u.Children.count(r)>1?u.Children.only(null):null});t1.displayName="SlotClone";const Lne=({children:e})=>u.createElement(u.Fragment,null,e);function Bne(e){return u.isValidElement(e)&&e.type===Lne}function zne(e,s){const r={...s};for(const n in s){const a=e[n],i=s[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{i(...l),a(...l)}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}
vendor: 5,737 bytes, line 762
762:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}const Une=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],xa=Une.reduce((e,s)=>{const r=u.forwardRef((n,a)=>{const{asChild:i,...o}=n,l=i?eR:s;return u.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),u.createElement(l,Pr({},o,{ref:a}))});return r.displayName=`Primitive.${s}`,{...e,[s]:r}},{});function Vne(e,s){e&&yn.flushSync(()=>e.dispatchEvent(s))}function DN(e){const s=u.useRef(e);return u.useEffect(()=>{s.current=e}),u.useMemo(()=>(...r)=>{var n;return(n=s.current)===null||n===void 0?void 0:n.call(s,...r)},[])}function qne(e,s=globalThis==null?void 0:globalThis.document){const r=DN(e);u.useEffect(()=>{const n=a=>{a.key==="Escape"&&r(a)};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[r,s])}const s1="dismissableLayer.update",Hne="dismissableLayer.pointerDownOutside",Wne="dismissableLayer.focusOutside";let P3;const Gne=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Yne=u.forwardRef((e,s)=>{var r;const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:o,onInteractOutside:l,onDismiss:c,...d}=e,m=u.useContext(Gne),[h,f]=u.useState(null),p=(r=h==null?void 0:h.ownerDocument)!==null&&r!==void 0?r:globalThis==null?void 0:globalThis.document,[,x]=u.useState({}),g=Gf(s,$=>f($)),b=Array.from(m.layers),[w]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),j=b.indexOf(w),y=h?b.indexOf(h):-1,v=m.layersWithOutsidePointerEventsDisabled.size>0,N=y>=j,S=Kne($=>{const R=$.target,A=[...m.branches].some(T=>T.contains(R));!N||A||(i==null||i($),l==null||l($),$.defaultPrevented||c==null||c())},p),k=Qne($=>{const R=$.target;[...m.branches].some(T=>T.contains(R))||(o==null||o($),l==null||l($),$.defaultPrevented||c==null||c())},p);return qne($=>{y===m.layers.size-1&&(a==null||a($),!$.defaultPrevented&&c&&($.preventDefault(),c()))},p),u.useEffect(()=>{if(h)return n&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(P3=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(h)),m.layers.add(h),A3(),()=>{n&&m.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=P3)}},[h,p,n,m]),u.useEffect(()=>()=>{h&&(m.layers.delete(h),m.layersWithOutsidePointerEventsDisabled.delete(h),A3())},[h,m]),u.useEffect(()=>{const $=()=>x({});return document.addEventListener(s1,$),()=>document.removeEventListener(s1,$)},[]),u.createElement(xa.div,Pr({},d,{ref:g,style:{pointerEvents:v?N?"auto":"none":void 0,...e.style},onFocusCapture:Dd(e.onFocusCapture,k.onFocusCapture),onBlurCapture:Dd(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:Dd(e.onPointerDownCapture,S.onPointerDownCapture)}))});function Kne(e,s=globalThis==null?void 0:globalThis.document){const r=DN(e),n=u.useRef(!1),a=u.useRef(()=>{});return u.useEffect(()=>{const i=l=>{if(l.target&&!n.current){let m=function(){tR(Hne,r,d,{discrete:!0})};var c=m;const d={originalEvent:l};l.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=m,s.addEventListener("click",a.current,{once:!0})):m()}else s.removeEventListener("click",a.current);n.current=!1},o=window.setTimeout(()=>{s.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),s.removeEventListener("pointerdown",i),s.removeEventListener("click",a.current)}},[s,r]),{onPointerDownCapture:()=>n.current=!0}}function Qne(e,s=globalThis==null?void 0:globalThis.document){const r=DN(e),n=u.useRef(!1);return u.useEffect(()=>{const a=i=>{i.target&&!n.current&&tR(Wne,r,{originalEvent:i},{discrete:!1})};return s.addEventListener("focusin",a),()=>s.removeEventListener("focusin",a)},[s,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function A3(){const e=new CustomEvent(s1);document.dispatchEvent(e)}function tR(e,s,r,{discrete:n}){const a=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});s&&a.addEventListener(e,s,{once:!0}),n?Vne(a,i):a.dispatchEvent(i)}function T3(e){const s=u.useRef(e);return u.useEffect(()=>{s.current=e}),u.useMemo(()=>(...r)=>{var n;return(n=s.current)===null||n===void 0?void 0:n.call(s,...r)},[])}const y0="focusScope.autoFocusOnMount",b0="focusScope.autoFocusOnUnmount",D3={bubbles:!1,cancelable:!0},Xne=u.forwardRef((e,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=e,[l,c]=u.useState(null),d=T3(a),m=T3(i),h=u.useRef(null),f=Gf(s,g=>c(g)),p=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(n){let j=function(S){if(p.paused||!l)return;const k=S.target;l.contains(k)?h.current=k:xo(h.current,{select:!0})},y=function(S){if(p.paused||!l)return;const k=S.relatedTarget;k!==null&&(l.contains(k)||xo(h.current,{select:!0}))},v=function(S){if(document.activeElement===document.body)for(const $ of S)$.removedNodes.length>0&&xo(l)};var g=j,b=y,w=v;document.addEventListener("focusin",j),document.addEventListener("focusout",y);const N=new MutationObserver(v);return l&&N.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",y),N.disconnect()}}},[n,l,p.paused]),u.useEffect(()=>{if(l){M3.add(p);const g=document.activeElement;if(!l.contains(g)){const w=new CustomEvent(y0,D3);l.addEventListener(y0,d),l.dispatchEvent(w),w.defaultPrevented||(Zne(rae(sR(l)),{select:!0}),document.activeElement===g&&xo(l))}return()=>{l.removeEventListener(y0,d),setTimeout(()=>{const w=new CustomEvent(b0,D3);l.addEventListener(b0,m),l.dispatchEvent(w),w.defaultPrevented||xo(g??document.body,{select:!0}),l.removeEventListener(b0,m),M3.remove(p)}
762,0)}}},[l,d,m,p]);const x=u.useCallback(g=>{if(!r&&!n||p.paused)return;const b=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,w=document.activeElement;if(b&&w){const j=g.currentTarget,[y,v]=Jne(j);y&&v?!g.shiftKey&&w===v?(g.preventDefault(),r&&xo(y,{select:!0})):g.shiftKey&&w===y&&(g.preventDefault(),r&&xo(v,{select:!0})):w===j&&g.preventDefault()}},[r,n,p.paused]);return u.createElement(xa.div,Pr({tabIndex:-1},o,{ref:f,onKeyDown:x}))});function Zne(e,{select:s=!1}={}){const r=document.activeElement;for(const n of e)if(xo(n,{select:s}),document.activeElement!==r)return}function Jne(e){const s=sR(e),r=R3(s,e),n=R3(s.reverse(),e);return[r,n]}function sR(e){const s=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}function R3(e,s){for(const r of e)if(!eae(r,{upTo:s}))return r}function eae(e,{upTo:s}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(s!==void 0&&e===s)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function tae(e){return e instanceof HTMLInputElement&&"select"in e}function xo(e,{select:s=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&tae(e)&&s&&e.select()}}const M3=sae();function sae(){let e=[];return{add(s){const r=e[0];s!==r&&(r==null||r.pause()),e=O3(e,s),e.unshift(s)},remove(s){var r;e=O3(e,s),(r=e[0])===null||r===void 0||r.resume()}}}function O3(e,s){const r=[...e],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function rae(e){return e.filter(s=>s.tagName!=="A")}const nae=u.forwardRef((e,s)=>{var r;const{container:n=globalThis==null||(r=globalThis.document)===null||r===void 0?void 0:r.body,...a}=e;return n?Jg.createPortal(u.createElement(xa.div,Pr({},a,{ref:s})),n):null}),I3=globalThis!=null&&globalThis.document?u.useLayoutEffect:()=>{};function aae(e,s){return u.useReducer((r,n)=>{const a=s[r][n];return a??r},e)}const Yv=e=>{const{present:s,children:r}=e,n=iae(s),a=typeof r=="function"?r({present:n.isPresent}):u.Children.only(r),i=Gf(n.ref,a.ref);return typeof r=="function"||n.isPresent?u.cloneElement(a,{ref:i}):null};Yv.displayName="Presence";function iae(e){const[s,r]=u.useState(),n=u.useRef({}),a=u.useRef(e),i=u.useRef("none"),o=e?"mounted":"unmounted",[l,c]=aae(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=Lp(n.current);i.current=l==="mounted"?d:"none"},[l]),I3(()=>{const d=n.current,m=a.current;if(m!==e){const f=i.current,p=Lp(d);e?c("MOUNT"):p==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(m&&f!==p?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),I3(()=>{if(s){const d=h=>{const p=Lp(n.current).includes(h.animationName);h.target===s&&p&&yn.flushSync(()=>c("ANIMATION_END"))},m=h=>{h.target===s&&(i.current=Lp(n.current))};return s.addEventListener("animationstart",m),s.addEventListener("animationcancel",d),s.addEventListener("animationend",d),()=>{s.removeEventListener("animationstart",m),s.removeEventListener("animationcancel",d),s.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[s,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{d&&(n.current=getComputedStyle(d)),r(d)},[])}}function Lp(e){return(e==null?void 0:e.animationName)||"none"}let j0=0;function oae(){u.useEffect(()=>{var e,s;const r=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",(e=r[0])!==null&&e!==void 0?e:F3()),document.body.insertAdjacentElement("beforeend",(s=r[1])!==null&&s!==void 0?s:F3()),j0++,()=>{j0===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(n=>n.remove()),j0--}},[])}function F3(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",e}var rR=I6(),w0=function(){},Kv=u.forwardRef(function(e,s){var r=u.useRef(null),n=u.useState({onScrollCapture:w0,onWheelCapture:w0,onTouchMoveCapture:w0}),a=n[0],i=n[1],o=e.forwardProps,l=e.children,c=e.className,d=e.removeScrollBar,m=e.enabled,h=e.shards,f=e.sideCar,p=e.noIsolation,x=e.inert,g=e.allowPinchZoom,b=e.as,w=b===void 0?"div":b,j=Xw(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),y=f,v=O6([r,s]),N=Fr(Fr({},j),a);return u.createElement(u.Fragment,null,m&&u.createElement(y,{sideCar:rR,removeScrollBar:d,shards:h,noIsolation:p,inert:x,setCallbacks:i,allowPinchZoom:!!g,lockRef:r}),o?u.cloneElement(u.Children.only(l),Fr(Fr({},N),{ref:v})):u.createElement(w,Fr({},N,{className:c,ref:v}),l))});Kv.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Kv.classNames={fullWidth:Wm,zeroRight:Hm};var r1=!1;if(typeof window<"u")try{var Bp=Object.defineProperty({},"passive",{get:function(){return r1=!0,!0}});window.addEventListener("test",Bp,Bp),window.removeEventListener("test",Bp,Bp)}catch{r1=!1}var Qc=r1?{passive:!1}:!1,lae=function(e){return e.tagName==="TEXTAREA"},nR=function(e,s){var r=window.getComputedStyle(e);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!lae(e)&&r[s]==="visible")},cae=function(e){return nR(e,"overflowY")},dae=function(e){return nR(e,"overflowX")},L3=function(e,s){var r=s;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var n=aR(e,r);if(n){var a=iR(e,r),i=a[1],o=a[2];if(i>o)return!0}r=r.parentNode}while(r&&r!==document.body);return!1}
vendor: 4,701 bytes, lines 762-765
762,uae=function(e){var s=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[s,r,n]},mae=function(e){var s=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[s,r,n]},aR=function(e,s){return e==="v"?cae(s):dae(s)},iR=function(e,s){return e==="v"?uae(s):mae(s)},hae=function(e,s){return e==="h"&&s==="rtl"?-1:1},fae=function(e,s,r,n,a){var i=hae(e,window.getComputedStyle(s).direction),o=i*n,l=r.target,c=s.contains(l),d=!1,m=o>0,h=0,f=0;do{var p=iR(e,l),x=p[0],g=p[1],b=p[2],w=g-b-i*x;(x||w)&&aR(e,l)&&(h+=w,f+=x),l=l.parentNode}while(!c&&l!==document.body||c&&(s.contains(l)||s===l));return(m&&(h===0||!a)||!m&&(f===0||!a))&&(d=!0),d},zp=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},B3=function(e){return[e.deltaX,e.deltaY]},z3=function(e){return e&&"current"in e?e.current:e},pae=function(e,s){return e[0]===s[0]&&e[1]===s[1]},xae=function(e){return` 763 .block-interactivity-`.concat(e,` {pointer-events: none;} 764 .allow-interactivity-`).concat(e,` {pointer-events: all;} 765`)},gae=0,Xc=[];function vae(e){var s=u.useRef([]),r=u.useRef([0,0]),n=u.useRef(),a=u.useState(gae++)[0],i=u.useState(function(){return Zw()})[0],o=u.useRef(e);u.useEffect(function(){o.current=e},[e]),u.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var g=M6([e.lockRef.current],(e.shards||[]).map(z3),!0).filter(Boolean);return g.forEach(function(b){return b.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),g.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=u.useCallback(function(g,b){if("touches"in g&&g.touches.length===2)return!o.current.allowPinchZoom;var w=zp(g),j=r.current,y="deltaX"in g?g.deltaX:j[0]-w[0],v="deltaY"in g?g.deltaY:j[1]-w[1],N,S=g.target,k=Math.abs(y)>Math.abs(v)?"h":"v";if("touches"in g&&k==="h"&&S.type==="range")return!1;var $=L3(k,S);if(!$)return!0;if($?N=k:(N=k==="v"?"h":"v",$=L3(k,S)),!$)return!1;if(!n.current&&"changedTouches"in g&&(y||v)&&(n.current=N),!N)return!0;var R=n.current||N;return fae(R,b,g,R==="h"?y:v,!0)},[]),c=u.useCallback(function(g){var b=g;if(!(!Xc.length||Xc[Xc.length-1]!==i)){var w="deltaY"in b?B3(b):zp(b),j=s.current.filter(function(N){return N.name===b.type&&N.target===b.target&&pae(N.delta,w)})[0];if(j&&j.should){b.cancelable&&b.preventDefault();return}if(!j){var y=(o.current.shards||[]).map(z3).filter(Boolean).filter(function(N){return N.contains(b.target)}),v=y.length>0?l(b,y[0]):!o.current.noIsolation;v&&b.cancelable&&b.preventDefault()}}},[]),d=u.useCallback(function(g,b,w,j){var y={name:g,delta:b,target:w,should:j};s.current.push(y),setTimeout(function(){s.current=s.current.filter(function(v){return v!==y})},1)},[]),m=u.useCallback(function(g){r.current=zp(g),n.current=void 0},[]),h=u.useCallback(function(g){d(g.type,B3(g),g.target,l(g,e.lockRef.current))},[]),f=u.useCallback(function(g){d(g.type,zp(g),g.target,l(g,e.lockRef.current))},[]);u.useEffect(function(){return Xc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",c,Qc),document.addEventListener("touchmove",c,Qc),document.addEventListener("touchstart",m,Qc),function(){Xc=Xc.filter(function(g){return g!==i}),document.removeEventListener("wheel",c,Qc),document.removeEventListener("touchmove",c,Qc),document.removeEventListener("touchstart",m,Qc)}},[]);var p=e.removeScrollBar,x=e.inert;return u.createElement(u.Fragment,null,x?u.createElement(i,{styles:xae(a)}):null,p?u.createElement(z6,{gapMode:"margin"}):null)}const yae=L6(rR,vae);var oR=u.forwardRef(function(e,s){return u.createElement(Kv,Fr({},e,{ref:s,sideCar:yae}))});oR.classNames=Kv.classNames;const lR=u.forwardRef((e,s)=>{const{children:r,...n}=e,a=u.Children.toArray(r),i=a.find(jae);if(i){const o=i.props.children,l=a.map(c=>c===i?u.Children.count(o)>1?u.Children.only(null):u.isValidElement(o)?o.props.children:null:c);return u.createElement(n1,Pr({},n,{ref:s}),u.isValidElement(o)?u.cloneElement(o,void 0,l):null)}return u.createElement(n1,Pr({},n,{ref:s}),r)});lR.displayName="Slot";const n1=u.forwardRef((e,s)=>{const{children:r,...n}=e;return u.isValidElement(r)?u.cloneElement(r,{...wae(n,r.props),ref:s?Z9(s,r.ref):r.ref}):u.Children.count(r)>1?u.Children.only(null):null});n1.displayName="SlotClone";const bae=({children:e})=>u.createElement(u.Fragment,null,e);function jae(e){return u.isValidElement(e)&&e.type===bae}function wae(e,s){const r={...s};for(const n in s){const a=e[n],i=s[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{i(...l),a(...l)}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}
765:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}const cR="Dialog",[dR,Efe]=Pne(cR),[Nae,Ic]=dR(cR),_ae=e=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:i,modal:o=!0}=e,l=u.useRef(null),c=u.useRef(null),[d=!1,m]=Mne({prop:n,defaultProp:a,onChange:i});return u.createElement(Nae,{scope:s,triggerRef:l,contentRef:c,contentId:v0(),titleId:v0(),descriptionId:v0(),open:d,onOpenChange:m,onOpenToggle:u.useCallback(()=>m(h=>!h),[m]),modal:o},r)},uR="DialogPortal",[Sae,mR]=dR(uR,{forceMount:void 0}),Cae=e=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=e,i=Ic(uR,s);return u.createElement(Sae,{scope:s,forceMount:r},u.Children.map(n,o=>u.createElement(Yv,{present:r||i.open},u.createElement(nae,{asChild:!0,container:a},o))))},a1="DialogOverlay",kae=u.forwardRef((e,s)=>{const r=mR(a1,e.__scopeDialog),{forceMount:n=r.forceMount,...a}=e,i=Ic(a1,e.__scopeDialog);return i.modal?u.createElement(Yv,{present:n||i.open},u.createElement($ae,Pr({},a,{ref:s}))):null}),$ae=u.forwardRef((e,s)=>{const{__scopeDialog:r,...n}=e,a=Ic(a1,r);return u.createElement(oR,{as:lR,allowPinchZoom:!0,shards:[a.contentRef]},u.createElement(xa.div,Pr({"data-state":fR(a.open)},n,{ref:s,style:{pointerEvents:"auto",...n.style}})))}),Xh="DialogContent",Eae=u.forwardRef((e,s)=>{const r=mR(Xh,e.__scopeDialog),{forceMount:n=r.forceMount,...a}=e,i=Ic(Xh,e.__scopeDialog);return u.createElement(Yv,{present:n||i.open},i.modal?u.createElement(Pae,Pr({},a,{ref:s})):u.createElement(Aae,Pr({},a,{ref:s})))}),Pae=u.forwardRef((e,s)=>{const r=Ic(Xh,e.__scopeDialog),n=u.useRef(null),a=Gf(s,r.contentRef,n);return u.useEffect(()=>{const i=n.current;if(i)return Df(i)},[]),u.createElement(hR,Pr({},e,{ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Dd(e.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=r.triggerRef.current)===null||o===void 0||o.focus()}),onPointerDownOutside:Dd(e.onPointerDownOutside,i=>{const o=i.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&i.preventDefault()}),onFocusOutside:Dd(e.onFocusOutside,i=>i.preventDefault())}))}),Aae=u.forwardRef((e,s)=>{const r=Ic(Xh,e.__scopeDialog),n=u.useRef(!1),a=u.useRef(!1);return u.createElement(hR,Pr({},e,{ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o;if((o=e.onCloseAutoFocus)===null||o===void 0||o.call(e,i),!i.defaultPrevented){var l;n.current||(l=r.triggerRef.current)===null||l===void 0||l.focus(),i.preventDefault()}n.current=!1,a.current=!1},onInteractOutside:i=>{var o,l;(o=e.onInteractOutside)===null||o===void 0||o.call(e,i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=i.target;((l=r.triggerRef.current)===null||l===void 0?void 0:l.contains(c))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}}))}),hR=u.forwardRef((e,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=e,l=Ic(Xh,r),c=u.useRef(null),d=Gf(s,c);return oae(),u.createElement(u.Fragment,null,u.createElement(Xne,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:i},u.createElement(Yne,Pr({role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":fR(l.open)},o,{ref:d,onDismiss:()=>l.onOpenChange(!1)}))),!1)});function fR(e){return e?"open":"closed"}const Tae=_ae,Dae=Cae,Rae=kae,Mae=Eae;var gm='[cmdk-group=""]',N0='[cmdk-group-items=""]',Oae='[cmdk-group-heading=""]',RN='[cmdk-item=""]',U3=`${RN}:not([aria-disabled="true"])`,i1="cmdk-item-select",Il="data-value",Iae=(e,s,r)=>$ne(e,s,r),pR=u.createContext(void 0),Yf=()=>u.useContext(pR),xR=u.createContext(void 0),MN=()=>u.useContext(xR),gR=u.createContext(void 0),vR=u.forwardRef((e,s)=>{let r=rd(()=>{var U,G;return{search:"",value:(G=(U=e.value)!=null?U:e.defaultValue)!=null?G:"",filtered:{count:0,items:new Map,groups:new Set}}}),n=rd(()=>new Set),a=rd(()=>new Map),i=rd(()=>new Map),o=rd(()=>new Set),l=yR(e),{label:c,children:d,value:m,onValueChange:h,filter:f,shouldFilter:p,loop:x,disablePointerSelection:g=!1,vimBindings:b=!0,...w}=e,j=u.useId(),y=u.useId(),v=u.useId(),N=u.useRef(null),S=Yae();wc(()=>
vendor: 9,498 bytes, line 765
765{if(m!==void 0){let U=m.trim();r.current.value=U,k.emit()}},[m]),wc(()=>{S(6,B)},[]);let k=u.useMemo(()=>({subscribe:U=>(o.current.add(U),()=>o.current.delete(U)),snapshot:()=>r.current,setState:(U,G,E)=>{var z,Z,M;if(!Object.is(r.current[U],G)){if(r.current[U]=G,U==="search")P(),A(),S(1,T);else if(U==="value"&&(E||S(5,B),((z=l.current)==null?void 0:z.value)!==void 0)){let F=G??"";(M=(Z=l.current).onValueChange)==null||M.call(Z,F);return}k.emit()}},emit:()=>{o.current.forEach(U=>U())}}),[]),$=u.useMemo(()=>({value:(U,G,E)=>{var z;G!==((z=i.current.get(U))==null?void 0:z.value)&&(i.current.set(U,{value:G,keywords:E}),r.current.filtered.items.set(U,R(G,E)),S(2,()=>{A(),k.emit()}))},item:(U,G)=>(n.current.add(U),G&&(a.current.has(G)?a.current.get(G).add(U):a.current.set(G,new Set([U]))),S(3,()=>{P(),A(),r.current.value||T(),k.emit()}),()=>{i.current.delete(U),n.current.delete(U),r.current.filtered.items.delete(U);let E=Y();S(4,()=>{P(),(E==null?void 0:E.getAttribute("id"))===U&&T(),k.emit()})}),group:U=>(a.current.has(U)||a.current.set(U,new Set),()=>{i.current.delete(U),a.current.delete(U)}),filter:()=>l.current.shouldFilter,label:c||e["aria-label"],disablePointerSelection:g,listId:j,inputId:v,labelId:y,listInnerRef:N}),[]);function R(U,G){var E,z;let Z=(z=(E=l.current)==null?void 0:E.filter)!=null?z:Iae;return U?Z(U,r.current.search,G):0}function A(){if(!r.current.search||l.current.shouldFilter===!1)return;let U=r.current.filtered.items,G=[];r.current.filtered.groups.forEach(z=>{let Z=a.current.get(z),M=0;Z.forEach(F=>{let ee=U.get(F);M=Math.max(ee,M)}),G.push([z,M])});let E=N.current;I().sort((z,Z)=>{var M,F;let ee=z.getAttribute("id"),se=Z.getAttribute("id");return((M=U.get(se))!=null?M:0)-((F=U.get(ee))!=null?F:0)}).forEach(z=>{let Z=z.closest(N0);Z?Z.appendChild(z.parentElement===Z?z:z.closest(`${N0} > *`)):E.appendChild(z.parentElement===E?z:z.closest(`${N0} > *`))}),G.sort((z,Z)=>Z[1]-z[1]).forEach(z=>{let Z=N.current.querySelector(`${gm}[${Il}="${encodeURIComponent(z[0])}"]`);Z==null||Z.parentElement.appendChild(Z)})}function T(){let U=I().find(E=>E.getAttribute("aria-disabled")!=="true"),G=U==null?void 0:U.getAttribute(Il);k.setState("value",G||void 0)}function P(){var U,G,E,z;if(!r.current.search||l.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Z=0;for(let M of n.current){let F=(G=(U=i.current.get(M))==null?void 0:U.value)!=null?G:"",ee=(z=(E=i.current.get(M))==null?void 0:E.keywords)!=null?z:[],se=R(F,ee);r.current.filtered.items.set(M,se),se>0&&Z++}for(let[M,F]of a.current)for(let ee of F)if(r.current.filtered.items.get(ee)>0){r.current.filtered.groups.add(M);break}r.current.filtered.count=Z}function B(){var U,G,E;let z=Y();z&&(((U=z.parentElement)==null?void 0:U.firstChild)===z&&((E=(G=z.closest(gm))==null?void 0:G.querySelector(Oae))==null||E.scrollIntoView({block:"nearest"})),z.scrollIntoView({block:"nearest"}))}function Y(){var U;return(U=N.current)==null?void 0:U.querySelector(`${RN}[aria-selected="true"]`)}function I(){var U;return Array.from((U=N.current)==null?void 0:U.querySelectorAll(U3))}function C(U){let G=I()[U];G&&k.setState("value",G.getAttribute(Il))}function L(U){var G;let E=Y(),z=I(),Z=z.findIndex(F=>F===E),M=z[Z+U];(G=l.current)!=null&&G.loop&&(M=Z+U<0?z[z.length-1]:Z+U===z.length?z[0]:z[Z+U]),M&&k.setState("value",M.getAttribute(Il))}function D(U){let G=Y(),E=G==null?void 0:G.closest(gm),z;for(;E&&!z;)E=U>0?Wae(E,gm):Gae(E,gm),z=E==null?void 0:E.querySelector(U3);z?k.setState("value",z.getAttribute(Il)):L(U)}let _=()=>C(I().length-1),H=U=>{U.preventDefault(),U.metaKey?_():U.altKey?D(1):L(1)},O=U=>{U.preventDefault(),U.metaKey?C(0):U.altKey?D(-1):L(-1)};return u.createElement(xa.div,{ref:s,tabIndex:-1,...w,"cmdk-root":"",onKeyDown:U=>{var G;if((G=w.onKeyDown)==null||G.call(w,U),!U.defaultPrevented)switch(U.key){case"n":case"j":{b&&U.ctrlKey&&H(U);break}case"ArrowDown":{H(U);break}case"p":case"k":{b&&U.ctrlKey&&O(U);break}case"ArrowUp":{O(U);break}case"Home":{U.preventDefault(),C(0);break}case"End":{U.preventDefault(),_();break}case"Enter":if(!U.nativeEvent.isComposing&&U.keyCode!==229){U.preventDefault();let E=Y();if(E){let z=new Event(i1);E.dispatchEvent(z)}}}}},u.createElement("label",{"cmdk-label":"",htmlFor:$.inputId,id:$.labelId,style:Qae},c),Qv(e,U=>u.createElement(xR.Provider,{value:k},u.createElement(pR.Provider,{value:$},U))))}),Fae=u.forwardRef((e,s)=>{var r,n;let a=u.useId(),i=u.useRef(null),o=u.useContext(gR),l=Yf(),c=yR(e),d=(n=(r=c.current)==null?void 0:r.forceMount)!=null?n:o==null?void 0:o.forceMount;wc(()=>{if(!d)return l.item(a,o==null?void 0:o.id)},[d]);let m=bR(a,i,[e.value,e.children,i],e.keywords),h=MN(),f=Nc(S=>S.value&&S.value===m.current),p=Nc(S=>d||l.filter()===!1?!0:S.search?S.filtered.items.get(a)>0:!0);u.useEffect(()=>{let S=i.current;if(!(!S||e.disabled))return S.addEventListener(i1,x),()=>S.removeEventListener(i1,x)},[p,e.onSelect,e.disabled]);function x(){var S,k;g(),(k=(S=c.current).onSelect)==null||k.call(S,m.current)}function g(){h.setState("value",m.current,!0)}if(!p)return null;let{disabled:b,value:w,onSelect:j,forceMount:y,keywords:v,...N}=e;return u.createElement(xa.div,{ref:Zh([i,s]),...N,id:a,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!f,"data-disabled":!!b,"data-selected":!!f,onPointerMove:b||l.disablePointerSelection?void 0:g,onClick:b?void 0:x},e.children)}),Lae=u.forwardRef((e,s)=>{let{heading:r,children:n,forceMount:a,...i}=e,o=u.useId(),l=u.useRef(null),c=u.useRef(null),d=u.useId(),m=Yf(),h=Nc(p=>a||m.filter()===!1?!0:p.search?p.filtered.groups.has(o):!0);wc(()=>m.group(o),[]),bR(o,l,[e.value,e.heading,c]);let f=u.useMemo(()=>({id:o,forceMount:a}),[a]);return u.createElement(xa.div,{ref:Zh([l,s]),...i,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},r&&u.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},r),Qv(e,p=>u.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?d:void 0},u.createElement(gR.Provider,{value:f},p))))}),Bae=u.forwardRef((e,s)=>{let{alwaysRender:r,...n}=e,a=u.useRef(null),i=Nc(o=>!o.search);return!r&&!i?null:u.createElement(xa.div,{ref:Zh([a,s]),...n,"cmdk-separator":"",role:"separator"})}),zae=u.forwardRef((e,s)=>{let{onValueChange:r,...n}=e,a=e.value!=null,i=MN(),o=Nc(m=>m.search),l=Nc(m=>m.value),c=Yf(),d=u.useMemo(()=>{var m;let h=(m=c.listInnerRef.current)==null?void 0:m.querySelector(`${RN}[${Il}="${encodeURIComponent(l)}"]`);return h==null?void 0:h.getAttribute("id")},[]);return u.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),u.createElement(xa.input,{ref:s,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":d,id:c.inputId,type:"text",value:a?e.value:o,onChange:m=>{a||i.setState("search",m.target.value),r==null||r(m.target.value)}})}),Uae=u.forwardRef((e,s)=>{let{children:r,label:n="Suggestions",...a}=e,i=u.useRef(null),o=u.useRef(null),l=Yf();return u.useEffect(()=>{if(o.current&&i.current){let c=o.current,d=i.current,m,h=new ResizeObserver(()=>{m=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return h.observe(c),()=>{cancelAnimationFrame(m),h.unobserve(c)}}},[]),u.createElement(xa.div,{ref:Zh([i,s]),...a,"cmdk-list":"",role:"listbox","aria-label":n,id:l.listId},Qv(e,c=>u.createElement("div",{ref:Zh([o,l.listInnerRef]),"cmdk-list-sizer":""},c)))}),Vae=u.forwardRef((e,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:i,container:o,...l}=e;return u.createElement(Tae,{open:r,onOpenChange:n},u.createElement(Dae,{container:o},u.createElement(Rae,{"cmdk-overlay":"",className:a}),u.createElement(Mae,{"aria-label":e.label,"cmdk-dialog":"",className:i},u.createElement(vR,{ref:s,...l}))))}),qae=u.forwardRef((e,s)=>Nc(r=>r.filtered.count===0)?u.createElement(xa.div,{ref:s,...e,"cmdk-empty":"",role:"presentation"}):null),Hae=u.forwardRef((e,s)=>{let{progress:r,children:n,label:a="Loading...",...i}=e;return u.createElement(xa.div,{ref:s,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Qv(e,o=>u.createElement("div",{"aria-hidden":!0},o)))}),En=Object.assign(vR,{List:Uae,Item:Fae,Input:zae,Group:Lae,Separator:Bae,Dialog:Vae,Empty:qae,Loading:Hae});function Wae(e,s){let r=e.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function Gae(e,s){let r=e.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function yR(e){let s=u.useRef(e);return wc(()=>{s.current=e}),s}var wc=typeof window>"u"?u.useEffect:u.useLayoutEffect;function rd(e){let s=u.useRef();return s.current===void 0&&(s.current=e()),s}function Zh(e){return s=>{e.forEach(r=>{typeof r=="function"?r(s):r!=null&&(r.current=s)})}}function Nc(e){let s=MN(),r=()=>e(s.snapshot());return u.useSyncExternalStore(s.subscribe,r,r)}function bR(e,s,r,n=[]){let a=u.useRef(),i=Yf();return wc(()=>{var o;let l=(()=>{var d;for(let m of r){if(typeof m=="string")return m.trim();if(typeof m=="object"&&"current"in m)return m.current?(d=m.current.textContent)==null?void 0:d.trim():a.current}})(),c=n.map(d=>d.trim());i.value(e,l,c),(o=s.current)==null||o.setAttribute(Il,l),a.current=l}),a}var Yae=()=>{let[e,s]=u.useState(),r=rd(()=>new Map);return wc(()=>{r.current.forEach(n=>
765n()),r.current=new Map},[e]),(n,a)=>{r.current.set(n,a),s({})}};function Kae(e){let s=e.type;return typeof s=="function"?s(e.props):"render"in s?s.render(e.props):e}function Qv({asChild:e,children:s},r){return e&&u.isValidElement(s)?u.cloneElement(Kae(s),{ref:s.ref},r(s.props.children)):r(s)}var Qae={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const _c=u.forwardRef(({className:e,...s},r)=>t.jsx(En,{ref:r,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...s}));_c.displayName=En.displayName;const xu=u.forwardRef(({className:e,...s},r)=>t.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[t.jsx(Ur,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),t.jsx(En.Input,{ref:r,className:oe("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...s})]}));xu.displayName=En.Input.displayName;const Sc=u.forwardRef(({className:e,...s},r)=>t.jsx(En.List,{ref:r,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...s}));Sc.displayName=En.List.displayName;const Cc=u.forwardRef((e,s)=>t.jsx(En.Empty,{ref:s,className:"py-6 text-center text-sm",...e}));Cc.displayName=En.Empty.displayName;const kc=u.forwardRef(({className:e,...s},r)=>t.jsx(En.Group,{ref:r,className:oe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...s}));kc.displayName=En.Group.displayName;const Xae=u.forwardRef(({className:e,...s},r)=>t.jsx(En.Separator,{ref:r,className:oe("-mx-1 h-px bg-border",e),...s}));
765Xae.displayName=En.Separator.displayName;const ii=u.forwardRef(({className:e,...s},r)=>t.jsx(En.Item,{ref:r,className:oe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...s}));ii.displayName=En.Item.displayName;const V3=200;function Zae({options:e,value:s,lockedItems:r=[],extraSelected:n=[],max:a,disabled:i,onChange:o}){const[l,c]=u.useState(!1),[d,m]=u.useState(""),h=u.useMemo(()=>new Set(r.map(j=>j.id)),[r]),f=u.useMemo(()=>{const j=new Map;return e.forEach(y=>j.set(y.id,y.term)),n.forEach(y=>j.set(y.id,y.term)),j},[e,n]),p=u.useMemo(()=>e.filter(j=>!h.has(j.id)),[e,h]),x=typeof a=="number"&&s.length>a,g=typeof a=="number"&&s.length>=a,b=u.useMemo(()=>{const j=d.trim().toLowerCase(),y=j?p.filter(k=>k.term.toLowerCase().includes(j)):p,v=new Set(s),N=y.filter(k=>v.has(k.id)),S=y.filter(k=>!v.has(k.id));return{list:[...N,...S].slice(0,V3),total:y.length}},[d,p,s]),w=j=>{if(s.includes(j))o(s.filter(y=>y!==j));else{if(g)return;o([...s,j])}};return t.jsxs("div",{className:"space-y-2",children:[t.jsxs(Cn,{open:l,onOpenChange:c,children:[t.jsx(kn,{asChild:!0,children:t.jsxs(q,{type:"button",variant:"outline",role:"combobox",disabled:i,className:"w-full justify-between h-auto min-h-10 py-2",children:[t.jsxs("div",{className:"flex flex-wrap gap-1.5 text-left",children:[r.map(j=>t.jsxs(XE,{children:[t.jsx(ZE,{asChild:!0,children:t.jsxs(we,{variant:"outline",className:"gap-1 font-normal border-border bg-muted text-muted-foreground whitespace-normal",children:[t.jsx(Cu,{className:"h-3 w-3 opacity-60"}),j.term]})}),t.jsx(Uw,{children:j.reason})]},`locked-${j.id}`)),s.map(j=>t.jsxs(we,{variant:"outline",className:"gap-1 font-normal border-primary/40 bg-primary/10 text-foreground whitespace-normal",children:[f.get(j)||"Keyword",t.jsx("span",{role:"button",tabIndex:-1,"aria-label":`Remove ${f.get(j)||"keyword"}`,onClick:y=>{y.stopPropagation(),o(s.filter(v=>v!==j))}
765,className:"rounded-full hover:bg-foreground/10",children:t.jsx(Es,{className:"h-3 w-3"})})]},j)),r.length===0&&s.length===0&&t.jsx("span",{className:"text-muted-foreground font-normal",children:"Select keywordsâ¦"})]}),t.jsx(yh,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t.jsx(en,{className:"p-0 min-w-[320px] w-auto",align:"end",children:t.jsxs(_c,{shouldFilter:!1,children:[t.jsx(xu,{placeholder:"Search keywordsâ¦",value:d,onValueChange:m}),t.jsxs(Sc,{className:"max-h-[320px]",children:[t.jsx(Cc,{children:"No keywords found."}),t.jsx(kc,{children:b.list.map(j=>{const y=s.includes(j.id);return t.jsxs(ii,{value:j.id,disabled:!y&&g,onSelect:()=>w(j.id),className:oe("items-start gap-2",!y&&g&&"opacity-50 pointer-events-none"),children:[t.jsx(Bs,{className:oe("h-4 w-4 mt-0.5",y?"opacity-100":"opacity-0")}),t.jsx("span",{className:"whitespace-normal break-words",title:j.term,children:j.term})]},j.id)})}),b.total>V3&&t.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground border-t",children:"Keep typing to narrow results"})]}),t.jsxs("div",{className:"flex items-center justify-between border-t px-3 py-2 text-xs text-muted-foreground",children:[t.jsx("span",{children:typeof a=="number"?x?`You're over the limit of ${a}. Remove one to make changes`:`${s.length} of ${a} used`:`${s.length} selected`}),g&&!x&&t.jsx("span",{children:"Remove one to add another"})]})]})})]}),x&&t.jsxs("p",{className:"text-xs text-destructive",children:["You're over the limit of ",a,". Remove one to make changes"]})]})}async function Jae(){const e=[];for(let r=0;r<20;r++){const{data:n,error:a}=await W.from("keywords").select("id, term").eq("is_selectable",!0).order("term").range(r*1e3,r*1e3+1e3-1);if(a||!n||(e.push(...n.map(i=>({id:i.id,term:i.term}))),n.length<1e3))break}return e}function jR({businessId:e,mode:s}){var k;const{toast:r}=rt(),[n,a]=u.useState([]),[i,o]=u.useState([]),[l,c]=u.useState([]),[d,m]=u.useState(!1),[h,f]=u.useState(!1),p=s==="admin",x=s==="admin"||s==="owner-verified",g=u.useCallback(async()=>{if(!e){a([]),c([]);return}m(!0);const{data:$,error:R}=await W.rpc("get_listing_keywords",{_business_id:e});if(!R&&$){const A=$.map(T=>({keyword_id:T.out_keyword_id,term:T.out_term,source:T.out_source,editable:T.out_editable,is_selectable:T.out_is_selectable,owner_limit:T.out_owner_limit,owner_count:T.out_owner_count}));a(A),c(A.filter(T=>T.editable).map(T=>T.keyword_id))}m(!1)},[e]);u.useEffect(()=>{g()},[g]),u.useEffect(()=>{x&&Jae().then(o)},[x]);const b=((k=n[0])==null?void 0:k.owner_limit)??2,w=u.useMemo(()=>n.filter($=>!$.editable).map($=>({id:$.keyword_id,term:$.term,reason:$.source==="crm"&&p||p?"From Mirola â edit keywords in the CRM":"Set by Discover Magazines"})),[n,p]),j=u.useMemo(()=>n.filter($=>$.editable&&!$.is_selectable).map($=>({id:$.keyword_id,term:$.term})),[n]),y=u.useMemo(()=>n.filter($=>$.editable).map($=>$.keyword_id),[n]),v=u.useMemo(()=>{const $=[...y].sort().join(","),R=[...l].sort().join(",");return $!==R},[y,l]),N=!p&&l.length>b,S=async()=>{if(!e)return;f(!0);const{error:$}=await W.rpc("set_listing_keywords",{_business_id:e,_keyword_ids:l});if(f(!1),$){r({title:"Keywords not saved",description:$.message,variant:"destructive"});return}r({title:"Keywords saved"}),await g()};return e?x?t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Keywords"}),d?t.jsx(it,{className:"h-4 w-4 animate-spin text-muted-foreground"}):t.jsx(Zae,{options:i,value:l,lockedItems:w,extraSelected:j,max:p?void 0:b,onChange:c}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:p?"Keywords power directory search. Keywords from Mirola are managed in the CRM.":`Pick up to ${b} extra keywords that describe what you do. Keywords set by Discover don't count towards this.`}),t.jsxs(q,{type:"button",size:"sm",variant:"secondary",onClick:S,disabled:h||!v||N,children:[h&&t.jsx(it,{className:"h-4 w-4 animate-spin mr-1"}),"Save keywords"]})]})]}):t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Keywords"}),t.jsxs("div",{className:"flex flex-wrap gap-1.5 min-h-[2rem]",children:[d&&t.jsx(it,{className:"h-4 w-4 animate-spin text-muted-foreground"}),!d&&n.length===0&&t.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No keywords yet"}),n.map($=>t.jsxs(we,{variant:"outline",className:"gap-1 font-normal border-border bg-muted text-muted-foreground",children:[t.jsx(Cu,{className:"h-3 w-3 opacity-60"}),$.term]},$.keyword_id))]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Claim and verify this listing to add your own keywords."})]}):t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Keywords"}),t.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-3 rounded-md",children:"Save the listing first to add keywords."})]})}const q3={...n9,image:""},eie=()=>{const{user:e,loading:s}=Ar(),[r,n]=u.useState(!0),[a,i]=u.useState(!1),[o,l]=u.useState([]),[c,d]=u.useState(null),[m,h]=u.useState([]),[f,p]=u.useState(null),[x,g]=u.useState([]),[b,w]=u.useState(null),[j,y]=u.useState(null),[v,N]=u.useState(null),[S,k]=u.useState([]);u.useState(null);const[$,R]=u.useState(null),[A,T]=u.useState(!1),[P,B]=u.useState("bookings"),[Y,I]=u.useState(!1),[C,L]=u.useState(!1),[D,_]=u.useState(0),[H,O]=u.useState(!1),[U,G]=u.useState("none"),[E,z]=u.useState(!0),[Z,M]=u.useState(null),[F,ee]=u.useState(!1),se=u.useRef(null),le=u.useRef(!1),X=u.useRef(!1),ye=u.useRef(!1),Ce=o.length>0,ke=ds(),fe=Va(),{toast:Ee}=rt(),{data:K}
765=hN(),[te,Q]=u.useState({name:"",description:"",email:"",phone:"",website:"",address_line1:"",address_line2:"",city:"",postcode:""}),[ae,me]=u.useState({...q3}),[pe,be]=u.useState(null),[ce,ie]=u.useState(null);u.useEffect(()=>{!s&&!e&&ke("/auth")},[e,s,ke]),u.useEffect(()=>{e&&!s&&n(!1)},[e,s]),u.useEffect(()=>{localStorage.getItem("returningBogofCustomer")==="true"&&(Ee({title:"Welcome back!",description:"We've saved your interest in the 3+ Subscription Package. Since you've used this offer before, our team will contact you within 24 hours with exclusive returning customer rates.",duration:8e3}),localStorage.removeItem("returningBogofCustomer"))},[Ee]);const je=async()=>{if(!e)return;const{data:he}=await W.from("businesses").select(` 766 *, 767 business_categories ( 768 name 769 ) 770 `).eq("owner_id",e.id).order("created_at",{ascending:!1});he&&l(he)},Re=async()=>{if(!e)return;const{data:he}=await W.from("events").select("*").eq("user_id",e.id).order("date",{ascending:!0});he&&h(he)},Ae=async()=>{if(!e)return;const{data:he}=await W.from("quotes").select("*").eq("user_id",e.id).order("created_at",{ascending:!1});he&&g(he),X.current=!0},Ue=async()=>{if(!e)return;const{data:he}=await W.from("bookings").select("*").eq("user_id",e.id).order("created_at",{ascending:!1});he&&k(he),ye.current=!0},Ve=async()=>{if(!e)return;const{count:he}=await W.from("vouchers").select("*",{count:"exact",head:!0}).eq("user_id",e.id).eq("is_active",!0);_(he||0)},lt=async()=>{if(e)try{const{data:he,error:$e}=await W.rpc("get_effective_advertiser_status",{_user_id:e.id});if($e)throw $e;const Ge=he||"none";(Ge==="active"||Ge==="lapsed"||Ge==="none")&&G(Ge)}catch(he){console.error("Failed to load advertiser status",he)}},J=async()=>{if(!e)return;const{data:he}=await W.from("profiles").select("is_first_login").eq("user_id",e.id).single();he!=null&&he.is_first_login?(O(!0),await W.from("profiles").update({is_first_login:!1}).eq("user_id",e.id)):O(!1)};u.useEffect(()=>{if(e){je(),Re(),Ae(),Ue(),Ve(),J(),lt();const $e=new URLSearchParams(window.location.search).get("tab");$e&&["quotes","bookings","vouchers","create-booking","terms","listings","create","events","create-event","artwork","schedule","magazines"].includes($e)&&(B($e),le.current=!0);const Ge=localStorage.getItem("newUserFromCalculator"),Pt=localStorage.getItem("justSavedQuote"),_s=localStorage.getItem("justCreatedBooking"),ln=localStorage.getItem("showVoucherNotification");(Ge==="true"||Pt==="true")&&(B("quotes"),le.current=!0,localStorage.removeItem("newUserFromCalculator"),localStorage.removeItem("justSavedQuote"),Ge==="true"&&setTimeout(()=>{Ee({title:"Welcome to Your Dashboard!",description:"Your quote has been saved below. You can create business listings and events here too.",duration:5e3})},2e3)),_s==="true"&&(B("bookings"),le.current=!0,localStorage.removeItem("justCreatedBooking"),setTimeout(()=>{Ve()},1e3)),ln==="true"&&(B("bookings"),localStorage.removeItem("showVoucherNotification"),setTimeout(()=>{Ee({title:"Bonus Voucher Earned! ð",description:"You've received a 10% leafleting service voucher! Check your booking below to redeem it.",duration:8e3}),Ve()},1500))}},[e,fe.pathname]),u.useEffect(()=>{(async()=>{if(!e)return;const $e=localStorage.getItem("pendingQuote");if($e)try{const Ge=JSON.parse($e),{normaliseFinalTotal:Pt}=await xc(async()=>{const{normaliseFinalTotal:Ni}=await Promise.resolve().then(()=>x3);return{normaliseFinalTotal:Ni}},void 0),_s={...Ge,user_id:e.id,final_total:Pt({pricingModel:Ge==null?void 0:Ge.pricing_model,monthlyPrice:Ge==null?void 0:Ge.monthly_price,fallbackFinalTotal:Ge==null?void 0:Ge.final_total})},{error:ln}=await W.from("quotes").insert(_s);if(ln)throw ln;Ee({title:"Quote saved",description:"We saved your quote to your dashboard."}),localStorage.removeItem("pendingQuote"),await Ae(),le.current=!0,B("quotes"),localStorage.getItem("newUserFromCalculator")==="true"&&(localStorage.removeItem("newUserFromCalculator"),setTimeout(()=>{I(!0)},1500))}catch(Ge){console.error("Pending quote save failed",Ge)}})()},[e]),u.useEffect(()=>{if(le.current||!e||!X.current||!ye.current||new URLSearchParams(window.location.search).get("tab"))return;const $e=localStorage.getItem("newUserFromCalculator"),Ge=localStorage.getItem("justSavedQuote"),Pt=localStorage.getItem("justCreatedBooking"),_s=localStorage.getItem("pendingQuote");$e||Ge||Pt||_s||(S.length>0?(B("bookings"),le.current=!0):x.length>0?(B("quotes"),le.current=!0):Ce&&!c?(B("listings"),le.current=!0):(B("create-booking"),le.current=!0))},[e,x,S,Ce,c]),u.useEffect(()=>{se.current&&se.current.scrollTo(0,0),window.scrollTo(0,0)},[P]);const Ne=(he,$e)=>{Q(Ge=>({...Ge,[he]:$e}))},gt=(he,$e)=>{me(Ge=>({...Ge,[he]:$e}))},He=async he=>{if(he.preventDefault(),!!e){i(!0);try{if(!c)throw new Error("New listings are added by the Discover team from the CRM. Claim an existing listing from the directory to manage it here.");{const{error:$e}=await W.from("businesses").update(te).eq("id",c.id);if($e)throw $e;Ee({title:"Success!",description:"Your business listing has been updated successfully."}),d(null),B("listings")}
770Q({name:"",description:"",email:"",phone:"",website:"",address_line1:"",address_line2:"",city:"",postcode:""}),je()}catch($e){Ee({title:"Error",description:$e.message,variant:"destructive"})}finally{i(!1)}}},Te=he=>{d(he),Q({name:he.name||"",description:he.description||"",email:he.email||"",phone:he.phone||"",website:he.website||"",address_line1:he.address_line1||"",address_line2:he.address_line2||"",city:he.city||"",postcode:he.postcode||""}),B("create")},De=()=>{d(null),Q({name:"",description:"",email:"",phone:"",website:"",address_line1:"",address_line2:"",city:"",postcode:""})},Le=async he=>{try{const $e=he.name.split(".").pop(),Pt=`public/${`${Date.now()}-${Math.random().toString(36).substring(2)}.${$e}`}`,{error:_s}=await W.storage.from("event-images").upload(Pt,he);if(_s)throw _s;const{data:{publicUrl:ln}}=W.storage.from("event-images").getPublicUrl(Pt);return ln}catch($e){return console.error("Error uploading image:",$e),null}},We=he=>{if(!he){be(null),ie(null),gt("image","");return}if(he.size>5*1024*1024){Ee({title:"File too large",description:"Please select an image under 5MB",variant:"destructive"});return}be(he);const $e=new FileReader;$e.onloadend=()=>ie($e.result),$e.readAsDataURL(he)},Ke=()=>{me({...q3}),be(null),ie(null)},st=async he=>{if(he.preventDefault(),!!e){i(!0);try{let $e=ae.image;if(pe){const Pt=await Le(pe);Pt?$e=Pt:Ee({title:"Image upload failed",description:"Event will be saved without a new image",variant:"destructive"})}const Ge={...ae,image:$e};if(f){const{error:Pt}=await W.from("events").update(Ge).eq("id",f.id);if(Pt)throw Pt;Ee({title:"Success!",description:"Your event has been updated successfully."}),p(null),B("events")}else{const{data:Pt,error:_s}=await W.from("events").insert([{...Ge,user_id:e.id}]).select().single();if(_s)throw _s;W.functions.invoke("send-event-notification",{body:{event_id:Pt.id,slug:Pt.slug,title:ae.title,date:ae.date,time:ae.time,location:ae.location,area:ae.area,category:ae.category,type:ae.type,organizer:ae.organizer||void 0,excerpt:ae.excerpt||void 0}}).catch(ln=>console.error("Failed to send event notification:",ln)),Ee({title:"Success!",description:"Your event has been created successfully."})}Ke(),Re()}catch($e){Ee({title:"Error",description:$e.message,variant:"destructive"})}finally{i(!1)}}},dt=he=>{p(he),me({title:he.title||"",date:he.date||"",date_end:he.date_end||"",time:he.time||"",end_time:he.end_time||"",location:he.location||"",area:he.area||"",postcode:he.postcode||"",organizer:he.organizer||"",category:he.category||"",type:he.type||"",excerpt:he.excerpt||"",full_description:he.full_description||"",ticket_url:he.ticket_url||"",contact_email:he.contact_email||"",contact_phone:he.contact_phone||"",website_url:he.website_url||"",image:he.image||""}),be(null),ie(null),B("create-event")},tt=async he=>{if(confirm("Are you sure you want to delete this event?"))try{const{error:$e}=await W.from("events").delete().eq("id",he);if($e)throw $e;Ee({title:"Success!",description:"Event deleted successfully."}),Re()}catch($e){Ee({title:"Error",description:$e.message,variant:"destructive"})}},Jt=async he=>{y(he);try{const{error:$e}=await W.from("quotes").delete().eq("id",he);if($e)throw $e;Ee({title:"Deleted",description:"Quote deleted successfully."}),await Ae(),N(null)}catch($e){Ee({title:"Error",description:$e.message,variant:"destructive"})}finally{y(null)}},us=he=>{N(he)},St=he=>{M(he),ee(!0)},fr=async he=>{if(e){i(!0);try{const{normaliseFinalTotal:$e}=await xc(async()=>{const{normaliseFinalTotal:cn}=await Promise.resolve().then(()=>x3);return{normaliseFinalTotal:cn}},void 0),Ge=$e({pricingModel:he.pricing_model,monthlyPrice:he.monthly_price,fallbackFinalTotal:he.final_total}),Pt={user_id:e.id,contact_name:he.contact_name,email:he.email,company:he.company,phone:he.phone,title:he.title,pricing_model:he.pricing_model,ad_size_id:he.ad_size_id,duration_id:he.duration_id,selected_area_ids:he.selected_area_ids||[],bogof_paid_area_ids:he.bogof_paid_area_ids||[],bogof_free_area_ids:he.bogof_free_area_ids||[],monthly_price:he.monthly_price,subtotal:he.subtotal,final_total:Ge,duration_multiplier:he.duration_multiplier,total_circulation:he.total_circulation,volume_discount_percent:he.volume_discount_percent,duration_discount_percent:he.duration_discount_percent,pricing_breakdown:he.pricing_breakdown,selections:he.selections,status:"pending",notes:he.notes,webhook_payload:{},terms_viewed_at:new Date().toISOString(),terms_accepted_at:new Date().toISOString()},{error:_s}=await W.from("bookings").insert([Pt]);if(_s)throw _s;const{error:ln}=await W.from("quotes").delete().eq("id",he.id);if(ln)throw ln;Ee({title:"Booking Confirmed!",description:"Your terms have been accepted. Set up your payment plan to start your campaign."}),ee(!1),M(null),await Promise.all([Ae(),Ue()]),B("bookings")}catch($e){Ee({title:"Error",description:$e.message||"Failed to create booking",variant:"destructive"})}finally{i(!1)}}};if(r)return t.jsx("div",{className:"min-h-screen flex items-center justify-center",children:t.jsx("div",{children:"Loading..."})});const Yn=()=>t.jsxs(xe,{children:[t.jsxs(Me,{children:[t.jsx(Oe,{children:"Edit Business Listing"}),c&&t.jsx("div",{className:"flex gap-2",children:t.jsx(q,{type:"button",variant:"outline",onClick:De,size:"sm",children:"Cancel Edit"})})]}),t.jsx(ge,{children:t.jsxs("form",{onSubmit:He,className:"space-y-6",children:[t.jsx("div",{className:"grid grid-cols-1 gap-4",children:t.jsxs("div",{children:[t.jsx("label",{htmlFor:"name",className:"block text-sm font-medium mb-1",children:"Business N
770ame *"}),t.jsx(re,{id:"name",value:te.name,onChange:he=>Ne("name",he.target.value),required:!0,placeholder:"Enter your business name"})]})}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"description",className:"block text-sm font-medium mb-1",children:"About"}),t.jsx(ms,{id:"description",value:te.description,onChange:he=>Ne("description",he.target.value),placeholder:"Describe your business...",rows:4})]}),c&&t.jsx(jR,{businessId:c.id,mode:c.is_verified?"owner-verified":"owner-readonly"}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"email",className:"block text-sm font-medium mb-1",children:"Email"}),t.jsx(re,{id:"email",type:"email",value:te.email,onChange:he=>Ne("email",he.target.value),placeholder:"[email protected]"})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"phone",className:"block text-sm font-medium mb-1",children:"Phone"}),t.jsx(re,{id:"phone",value:te.phone,onChange:he=>Ne("phone",he.target.value),placeholder:"01234 567890"})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"website",className:"block text-sm font-medium mb-1",children:"Website"}),t.jsx(re,{id:"website",value:te.website,onChange:he=>Ne("website",he.target.value),placeholder:"https://www.yourbusiness.com"})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"text-lg font-medium",children:"Address"}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"address_line1",className:"block text-sm font-medium mb-1",children:"Address Line 1"}),t.jsx(re,{id:"address_line1",value:te.address_line1,onChange:he=>Ne("address_line1",he.target.value),placeholder:"123 High Street"})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"address_line2",className:"block text-sm font-medium mb-1",children:"Address Line 2"}),t.jsx(re,{id:"address_line2",value:te.address_line2,onChange:he=>Ne("address_line2",he.target.value),placeholder:"Suite 100"})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"city",className:"block text-sm font-medium mb-1",children:"City"}),t.jsx(re,{id:"city",value:te.city,onChange:he=>Ne("city",he.target.value),placeholder:"London"})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"postcode",className:"block text-sm font-medium mb-1",children:"Postcode"}),t.jsx(re,{id:"postcode",value:te.postcode,onChange:he=>Ne("postcode",he.target.value),placeholder:"SW1A 1AA"})]})]})]}),t.jsx(q,{type:"submit",className:"w-full",disabled:a||!te.name,children:a?"Updating Listing...":"Update Business Listing"})]})})]}),Ds=()=>t.jsxs(xe,{children:[t.jsxs(Me,{children:[t.jsx(Oe,{children:"Your Business Listings"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Listings come from the Discover directory. To manage one here, claim it from its public listing page."})]}),t.jsx(ge,{children:o.length===0?t.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[t.jsx("p",{children:"You don't manage any business listings yet."}),t.jsxs("p",{className:"mt-2",children:["Find your business in the"," ",t.jsx(hs,{to:"/business-directory",className:"text-community-purple underline",children:"business directory"})," ","and claim the listing to manage it here."]})]}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Business Name"}),t.jsx(ue,{children:"Category"}),t.jsx(ue,{children:"Location"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:o.map(he=>{var $e;return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:he.name}),t.jsx(de,{children:(($e=he.business_categories)==null?void 0:$e.name)||"No category"}),t.jsx(de,{children:he.city?`${he.city}${he.postcode?", "+he.postcode:""}`:"No location"}),t.jsx(de,{children:t.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${he.is_active?"bg-success/10 text-success":"bg-destructive/10 text-destructive"}`,children:he.is_active?"Active":"Inactive"})}),t.jsx(de,{children:t.jsxs(q,{variant:"outline",size:"sm",onClick:()=>Te(he),className:"flex items-center gap-2",children:[t.jsx(Jr,{size:14}),"Edit"]})})]},he.id)})})]})})})]}),rr=()=>t.jsxs(xe,{children:[t.jsxs(Me,{children:[t.jsx(Oe,{children:f?"Edit Event":"Create New Event"}),f&&t.jsx("div",{className:"flex gap-2",children:t.jsx(q,{type:"button",variant:"outline",onClick:()=>{p(null),Ke()},size:"sm",children:"Cancel Edit"})})]}),t.jsx(ge,{children:t.jsxs("form",{onSubmit:st,className:"space-y-6",children:[t.jsx(r9,{formData:ae,onCh
770ange:gt,imagePreview:ce,existingImageUrl:ae.image||null,onImageChange:We,disabled:a}),t.jsx(q,{type:"submit",className:"w-full",disabled:a||!ae.title||!ae.organizer||!ae.date||!ae.time||!ae.location||!ae.area||!ae.category||!ae.type,children:a?f?"Updating Event...":"Creating Event...":f?"Update Event":"Create Event"})]})})]}),Nr=()=>t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{children:"Your Events"})}),t.jsx(ge,{children:m.length===0?t.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[t.jsx("p",{children:"You haven't created any events yet."}),t.jsx("p",{className:"mt-2",children:'Click on "Create Event" to get started.'})]}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Event Title"}),t.jsx(ue,{children:"Date & Time"}),t.jsx(ue,{children:"Location"}),t.jsx(ue,{children:"Type"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:m.map(he=>t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:he.title}),t.jsxs(de,{children:[he.date&&new Date(he.date).toLocaleDateString(),he.time&&` at ${he.time}`]}),t.jsxs(de,{children:[he.location,he.area&&`, ${he.area}`]}),t.jsx(de,{children:t.jsx("span",{className:"capitalize",children:he.type||"Not specified"})}),t.jsx(de,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(q,{variant:"outline",size:"sm",onClick:()=>dt(he),className:"flex items-center gap-1",children:[t.jsx(Jr,{size:12}),"Edit"]}),t.jsxs(q,{variant:"destructive",size:"sm",onClick:()=>tt(he.id),className:"flex items-center gap-1",children:[t.jsx(cs,{size:12}),"Delete"]})]})})]},he.id))})]})})})]}),Tr=()=>{const he=$e=>$e.status==="draft"||$e.status==="bogof_return_interest"?t.jsx(we,{variant:"outline",children:"Saved Quote"}):$e.status==="active"||$e.status==="approved"?t.jsx(we,{variant:"default",className:"bg-green-100 text-green-800 border-green-200",children:"Active"}):t.jsx(we,{variant:"secondary",children:$e.status});return t.jsx(xe,{className:"p-6",children:t.jsxs(ig,{open:E,onOpenChange:z,children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Your Saved Quotes"}),t.jsx(og,{asChild:!0,children:t.jsx(q,{variant:"ghost",size:"sm",children:E?t.jsx(rE,{className:"h-4 w-4"}):t.jsx(Ma,{className:"h-4 w-4"})})})]}),t.jsx(lg,{children:t.jsx("div",{className:"border rounded-lg overflow-hidden",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-muted/50",children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left p-4 font-semibold",children:"Date Created"}),t.jsx("th",{className:"text-left p-4 font-semibold",children:"Campaign Type"}),t.jsx("th",{className:"text-left p-4 font-semibold",children:"Ad Size"}),t.jsx("th",{className:"text-left p-4 font-semibold",children:"Cost (+VAT)"}),t.jsx("th",{className:"text-right p-4 font-semibold",children:"Actions"})]})}),t.jsx("tbody",{children:x.map($e=>{var Ge;return t.jsxs("tr",{className:"border-t hover:bg-muted/30 transition-colors",children:[t.jsx("td",{className:"p-4",children:Dt(new Date($e.created_at),"dd/MM/yyyy")}),t.jsx("td",{className:"p-4",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{children:$e.pricing_model==="bogof"?"3+ Subscription Package for New Advertisers":$e.pricing_model==="fixed"||$e.pricing_model==="fixed_term"?"Pay As You Go":$e.pricing_model==="leafleting"?"Leaflet Distribution":$e.pricing_model}),he($e)]})}),t.jsx("td",{className:"p-4",children:(()=>{const Pt=K==null?void 0:K.find(_s=>_s.id===$e.ad_size_id);return Pt?`${Pt.name}`:"â"})()}),t.jsx("td",{className:"p-4",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("span",{className:"font-semibold",children:["£",((Ge=$e.pricing_model==="bogof"?$e.monthly_price:$e.final_total)==null?void 0:Ge.toFixed(2))||"0.00"]}),t.jsx("span",{className:"text-xs text-muted-foreground",children:$e.pricing_model==="bogof"?"per month":"campaign total"})]})}),t.jsx("td",{className:"p-4",children:t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsxs(q,{variant:"outline",size:"sm",onClick:()=>w($e),children:[t.jsx(tr,{className:"h-4 w-4 mr-1"}),"View"]}
770),t.jsx(q,{variant:"destructive",size:"sm",onClick:()=>us($e),disabled:j===$e.id,children:t.jsx(cs,{className:"h-4 w-4"})})]})})]},$e.id)})})]})})})]})})},Et=()=>{var he,$e,Ge;return t.jsxs("div",{className:"space-y-6",children:[Tr(),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Latest Quote"}),t.jsx(_re,{quote:x[0]||null,onView:w,onDelete:us,onBookNow:St,isDeleting:j===((he=x[0])==null?void 0:he.id)})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Your ROI Calculator"}),t.jsx(Sre,{totalCirculation:(($e=x[0])==null?void 0:$e.total_circulation)||5e4,totalInvestment:((Ge=x[0])==null?void 0:Ge.final_total)||1e3})]})]})},as=()=>(S.filter(he=>!he.payment_status||he.payment_status==="pending"),t.jsx("div",{className:"space-y-6",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{children:"Your Bookings"})}),t.jsx(ge,{children:S.length===0?t.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[t.jsx("p",{children:"You don't have any bookings yet."}),t.jsx("p",{className:"mt-2",children:"Book an advertising campaign to see it here!"})]}):t.jsx("div",{className:"grid gap-4",children:S.map(he=>t.jsx(Lre,{booking:he,onViewDetails:$e=>{R($e),T(!0)},onNavigateToVouchers:()=>B("vouchers")},he.id))})})]})})),Ct=()=>t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{children:"Profile Settings"})}),t.jsxs(ge,{className:"space-y-6",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"profile-email",children:"Email"}),t.jsx(re,{id:"profile-email",type:"email",value:(e==null?void 0:e.email)||"",disabled:!0,className:"bg-muted"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"profile-id",children:"User ID"}),t.jsx(re,{id:"profile-id",value:(e==null?void 0:e.id)||"",disabled:!0,className:"bg-muted text-xs"})]})]}),t.jsxs("div",{className:"pt-4 border-t",children:[t.jsx("h4",{className:"font-medium mb-3",children:"Account Actions"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(q,{variant:"outline",className:"w-full justify-start",onClick:()=>L(!0),children:"Change Password"}),t.jsx(q,{variant:"outline",className:"w-full justify-start",children:"Update Email Preferences"}),t.jsx(q,{variant:"outline",className:"w-full justify-start text-destructive hover:text-destructive",children:"Delete Account"})]})]})]})]});return t.jsxs(SN,{children:[t.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 via-white to-green-50 flex w-full",children:[t.jsx(Hre,{activeTab:P,setActiveTab:B,businessCount:o.length,eventCount:m.length,quoteCount:x.length,bookingCount:S.length,voucherCount:D,editingBusiness:c,editingEvent:f,advertiserStatus:U}),t.jsxs(i9,{className:"flex-1 min-w-0",children:[t.jsx(Qre,{user:e,onProfileClick:()=>B("profile")}),t.jsx("div",{ref:se,className:"flex-1 overflow-auto",children:t.jsxs("div",{className:"max-w-7xl mx-auto p-6 space-y-6",children:[t.jsx(Nre,{user:e,quotes:x,bookings:S,isFirstLogin:H,onBookNowClick:()=>B("bookings")}),t.jsx(one,{status:U}),P==="create-booking"&&e&&t.jsx(Xre,{user:e,onBookingCreated:()=>{Ue(),B("bookings")},onQuoteSaved:()=>{Ae(),B("quotes")},onBookNowWithTerms:he=>{Ae(),St(he)}}),P==="create"&&Yn(),P==="listings"&&Ds(),P==="create-event"&&rr(),P==="events"&&Nr(),P==="quotes"&&Et(),P==="bookings"&&as(),P==="vouchers"&&e&&t.jsx(qre,{user:e}),P==="artwork"&&t.jsx(rne,{}),P==="schedule"&&t.jsx(ane,{}),P==="magazines"&&t.jsx(ine,{lapsed:U==="lapsed"}),P==="terms"&&t.jsx(L9,{}),P==="profile"&&Ct()]})})]})]}),t.jsxs("div",{className:"hidden",children:[t.jsx(gs,{}),t.jsx(vs,{})]}),t.jsx(bt,{open:!!b,onOpenChange:()=>w(null),children:t.jsxs(xt,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",onCloseAutoFocus:he=>he.preventDefault(),onOpenAutoFocus:he=>he.preventDefault(),children:[t.jsxs(jt,{children:[t.jsx(wt,{children:"Quote Details"}),t.jsxs(ys,{children:["Created on ",b&&new Date(b.created_at).toLocaleDateString()]})]}),b&&t.jsx(bre,{quote:b})]})}),t.jsx(Cre,{open:!!v,onClose:()=>N(null),onConfirm:()=>v&&Jt(v.id),quote:v,isDeleting:j===(v==null?void 0:v.id)}),t.jsx(jre,{open:Y,onClose:()=>I(!1)}),t.jsx(wre,{open:C,onClose:()=>L(!1)}),t.jsx(Vre,{booking:$,open:A,onOpenChange:T}),t.jsx(tne,{quote:Z,open:F,onOpenChange:ee,onConfirm:fr,isSubmitting:a})]})};function tie(e,s=300){const[r,n]=u.useState(e);return u.useEffect(()=>{const a=setTimeout(()=>{n(e)},s);return()=>{clearTimeout(a)}},[e,s]),r}const ON=()=>{const e=Xs();
770return{invalidateAll:()=>{e.invalidateQueries({queryKey:["pricing"]}),e.invalidateQueries({queryKey:["areas"]}),e.invalidateQueries({queryKey:["adSizes"]}),e.invalidateQueries({queryKey:["durations"]}),e.invalidateQueries({queryKey:["volumeDiscounts"]})},invalidateSpecific:n=>{e.invalidateQueries({queryKey:[n]}),e.invalidateQueries({queryKey:["pricing"]})}}},sie=()=>{Xs();const{toast:e}=rt(),{invalidateSpecific:s}=ON();return os({mutationFn:async({adSizeId:r,fixedPricing:n,subscriptionPricing:a})=>{const i={};n!==void 0&&(i.fixed_pricing_per_issue=n),a!==void 0&&(i.subscription_pricing_per_issue=a);const{error:o}=await W.from("ad_sizes").update(i).eq("id",r);if(o)throw o;return{adSizeId:r,...i}},onSuccess:()=>{s("adSizes"),e({title:"Success",description:"Pricing updated successfully."})},onError:r=>{console.error("Error updating pricing:",r),e({title:"Error",description:r.message||"Failed to update pricing.",variant:"destructive"})}})};var vt=function(){return vt=Object.assign||function(s){for(var r,n=1,a=arguments.length;n<a;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(s[i]=r[i])}return s},vt.apply(this,arguments)};function rie(e,s){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&s.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)s.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r}function wR(e,s,r){for(var n=0,a=s.length,i;n<a;n++)(i||!(n in s))&&(i||(i=Array.prototype.slice.call(s,0,n)),i[n]=s[n]);return e.concat(i||Array.prototype.slice.call(s))}function Kf(e){return e.mode==="multiple"}function Qf(e){return e.mode==="range"}function Xv(e){return e.mode==="single"}var nie={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};function aie(e,s){return Dt(e,"LLLL y",s)}function iie(e,s){return Dt(e,"d",s)}function oie(e,s){return Dt(e,"LLLL",s)}function lie(e){return"".concat(e)}function cie(e,s){return Dt(e,"cccccc",s)}function die(e,s){return Dt(e,"yyyy",s)}var uie=Object.freeze({__proto__:null,formatCaption:aie,formatDay:iie,formatMonthCaption:oie,formatWeekNumber:lie,formatWeekdayName:cie,formatYearCaption:die}),mie=function(e,s,r){return Dt(e,"do MMMM (EEEE)",r)},hie=function(){return"Month: "},fie=function(){return"Go to next month"},pie=function(){return"Go to previous month"},xie=function(e,s){return Dt(e,"cccc",s)},gie=function(e){return"Week n. ".concat(e)},vie=function(){return"Year: "},yie=Object.freeze({__proto__:null,labelDay:mie,labelMonthDropdown:hie,labelNext:fie,labelPrevious:pie,labelWeekNumber:gie,labelWeekday:xie,labelYearDropdown:vie});function bie(){var e="buttons",s=nie,r=Mv,n={},a={},i=1,o={},l=new Date;return{captionLayout:e,classNames:s,formatters:uie,labels:yie,locale:r,modifiersClassNames:n,modifiers:a,numberOfMonths:i,styles:o,today:l,mode:"default"}}function jie(e){var s=e.fromYear,r=e.toYear,n=e.fromMonth,a=e.toMonth,i=e.fromDate,o=e.toDate;return n?i=jr(n):s&&(i=new Date(s,0,1)),a?o=du(a):r&&(o=new Date(r,11,31)),{fromDate:i?lu(i):void 0,toDate:o?lu(o):void 0}}var NR=u.createContext(void 0);function wie(e){var s,r=e.initialProps,n=bie(),a=jie(r),i=a.fromDate,o=a.toDate,l=(s=r.captionLayout)!==null&&s!==void 0?s:n.captionLayout;l!=="buttons"&&(!i||!o)&&(l="buttons");var c;(Xv(r)||Kf(r)||Qf(r))&&(c=r.onSelect);var d=vt(vt(vt({},n),r),{captionLayout:l,classNames:vt(vt({},n.classNames),r.classNames),components:vt({},r.components),formatters:vt(vt({},n.formatters),r.formatters),fromDate:i,labels:vt(vt({},n.labels),r.labels),mode:r.mode||n.mode,modifiers:vt(vt({},n.modifiers),r.modifiers),modifiersClassNames:vt(vt({},n.modifiersClassNames),r.modifiersClassNames),onSelect:c,styles:vt(vt({},n.styles),r.styles),toDate:o});return t.jsx(NR.Provider,{value:d,children:e.children})}function Ns(){var e=u.useContext(NR);if(!e)throw new Error("useDayPicker must be used within a DayPickerProvider.");return e}function _R(e){var s=Ns(),r=s.locale,n=s.classNames,a=s.styles,i=s.formatters.formatCaption;return t.jsx("div",{className:n.caption_label,style:a.caption_label,"aria-live":"polite",role:"presentation",id:e.id,children:i(e.displayMonth,{locale:r})})}function Nie(e){return t.jsx("svg",vt({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},e,{children:t.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.7
77078175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function SR(e){var s,r,n=e.onChange,a=e.value,i=e.children,o=e.caption,l=e.className,c=e.style,d=Ns(),m=(r=(s=d.components)===null||s===void 0?void 0:s.IconDropdown)!==null&&r!==void 0?r:Nie;return t.jsxs("div",{className:l,style:c,children:[t.jsx("span",{className:d.classNames.vhidden,children:e["aria-label"]}),t.jsx("select",{name:e.name,"aria-label":e["aria-label"],className:d.classNames.dropdown,style:d.styles.dropdown,value:a,onChange:n,children:i}),t.jsxs("div",{className:d.classNames.caption_label,style:d.styles.caption_label,"aria-hidden":"true",children:[o,t.jsx(m,{className:d.classNames.dropdown_icon,style:d.styles.dropdown_icon})]})]})}function _ie(e){var s,r=Ns(),n=r.fromDate,a=r.toDate,i=r.styles,o=r.locale,l=r.formatters.formatMonthCaption,c=r.classNames,d=r.components,m=r.labels.labelMonthDropdown;if(!n)return t.jsx(t.Fragment,{});if(!a)return t.jsx(t.Fragment,{});var h=[];if(VQ(n,a))for(var f=jr(n),p=n.getMonth();p<=a.getMonth();p++)h.push(a0(f,p));else for(var f=jr(new Date),p=0;p<=11;p++)h.push(a0(f,p));var x=function(b){var w=Number(b.target.value),j=a0(jr(e.displayMonth),w);e.onChange(j)},g=(s=d==null?void 0:d.Dropdown)!==null&&s!==void 0?s:SR;return t.jsx(g,{name:"months","aria-label":m(),className:c.dropdown_month,style:i.dropdown_month,onChange:x,value:e.displayMonth.getMonth(),caption:l(e.displayMonth,{locale:o}),children:h.map(function(b){return t.jsx("option",{value:b.getMonth(),children:l(b,{locale:o})},b.getMonth())})})}function Sie(e){var s,r=e.displayMonth,n=Ns(),a=n.fromDate,i=n.toDate,o=n.locale,l=n.styles,c=n.classNames,d=n.components,m=n.formatters.formatYearCaption,h=n.labels.labelYearDropdown,f=[];if(!a)return t.jsx(t.Fragment,{});if(!i)return t.jsx(t.Fragment,{});for(var p=a.getFullYear(),x=i.getFullYear(),g=p;g<=x;g++)f.push(HS(iA(new Date),g));var b=function(j){var y=HS(jr(r),Number(j.target.value));e.onChange(y)},w=(s=d==null?void 0:d.Dropdown)!==null&&s!==void 0?s:SR;return t.jsx(w,{name:"years","aria-label":h(),className:c.dropdown_year,style:l.dropdown_year,onChange:b,value:r.getFullYear(),caption:m(r,{locale:o}),children:f.map(function(j){return t.jsx("option",{value:j.getFullYear(),children:m(j,{locale:o})},j.getFullYear())})})}function Cie(e,s){var r=u.useState(e),n=r[0],a=r[1],i=s===void 0?n:s;return[i,a]}function kie(e){var s=e.month,r=e.defaultMonth,n=e.today,a=s||r||n||new Date,i=e.toDate,o=e.fromDate,l=e.numberOfMonths,c=l===void 0?1:l;if(i&&cu(i,a)<0){var d=-1*(c-1);a=Cr(i,d)}return o&&cu(a,o)<0&&(a=o),jr(a)}function $ie(){var e=Ns(),s=kie(e),r=Cie(s,e.month),n=r[0],a=r[1],i=function(o){var l;if(!e.disableNavigation){var c=jr(o);a(c),(l=e.onMonthChange)===null||l===void 0||l.call(e,c)}};return[n,i]}function Eie(e,s){for(var r=s.reverseMonths,n=s.numberOfMonths,a=jr(e),i=jr(Cr(a,n)),o=cu(i,a),l=[],c=0;c<o;c++){var d=Cr(a,c);l.push(d)}return r&&(l=l.reverse()),l}function Pie(e,s){if(!s.disableNavigation){var r=s.toDate,n=s.pagedNavigation,a=s.numberOfMonths,i=a===void 0?1:a,o=n?i:1,l=jr(e);if(!r)return Cr(l,o);var c=cu(r,e);if(!(c<i))return Cr(l,o)}}function Aie(e,s){if(!s.disableNavigation){var r=s.fromDate,n=s.pagedNavigation,a=s.numberOfMonths,i=a===void 0?1:a,o=n?i:1,l=jr(e);if(!r)return Cr(l,-o);var c=cu(l,r);if(!(c<=0))return Cr(l,-o)}}var CR=u.createContext(void 0);function Tie(e){var s=Ns(),r=$ie(),n=r[0],a=r[1],i=Eie(n,s),o=Pie(n,s),l=Aie(n,s),c=function(h){return i.some(function(f){return Ph(h,f)})},d=function(h,f){c(h)||(f&&uA(h,f)?a(Cr(h,1+s.numberOfMonths*-1)):a(h))},m={currentMonth:n,displayMonths:i,goToMonth:a,goToDate:d,previousMonth:l,nextMonth:o,isDateDisplayed:c};return t.jsx(CR.Provider,{value:m,children:e.children})}function Xf(){var e=u.useContext(CR);if(!e)throw new Error("useNavigation must be used within a NavigationProvider");return e}function H3(e){var s,r=Ns(),n=r.classNames,a=r.styles,i=r.components,o=Xf().goToMonth,l=function(m){o(Cr(m,e.displayIndex?-e.dis
770playIndex:0))},c=(s=i==null?void 0:i.CaptionLabel)!==null&&s!==void 0?s:_R,d=t.jsx(c,{id:e.id,displayMonth:e.displayMonth});return t.jsxs("div",{className:n.caption_dropdowns,style:a.caption_dropdowns,children:[t.jsx("div",{className:n.vhidden,children:d}),t.jsx(_ie,{onChange:l,displayMonth:e.displayMonth}),t.jsx(Sie,{onChange:l,displayMonth:e.displayMonth})]})}function Die(e){return t.jsx("svg",vt({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:t.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function Rie(e){return t.jsx("svg",vt({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:t.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var Cg=u.forwardRef(function(e,s){var r=Ns(),n=r.classNames,a=r.styles,i=[n.button_reset,n.button];e.className&&i.push(e.className);var o=i.join(" "),l=vt(vt({},a.button_reset),a.button);return e.style&&Object.assign(l,e.style),t.jsx("button",vt({},e,{ref:s,type:"button",className:o,style:l}))});function Mie(e){var s,r,n=Ns(),a=n.dir,i=n.locale,o=n.classNames,l=n.styles,c=n.labels,d=c.labelPrevious,m=c.labelNext,h=n.components;if(!e.nextMonth&&!e.previousMonth)return t.jsx(t.Fragment,{});var f=d(e.previousMonth,{locale:i}),p=[o.nav_button,o.nav_button_previous].join(" "),x=m(e.nextMonth,{locale:i}),g=[o.nav_button,o.nav_button_next].join(" "),b=(s=h==null?void 0:h.IconRight)!==null&&s!==void 0?s:Rie,w=(r=h==null?void 0:h.IconLeft)!==null&&r!==void 0?r:Die;return t.jsxs("div",{className:o.nav,style:l.nav,children:[!e.hidePrevious&&t.jsx(Cg,{name:"previous-month","aria-label":f,className:p,style:l.nav_button_previous,disabled:!e.previousMonth,onClick:e.onPreviousClick,children:a==="rtl"?t.jsx(b,{className:o.nav_icon,style:l.nav_icon}):t.jsx(w,{className:o.nav_icon,style:l.nav_icon})}),!e.hideNext&&t.jsx(Cg,{name:"next-month","aria-label":x,className:g,style:l.nav_button_next,disabled:!e.nextMonth,onClick:e.onNextClick,children:a==="rtl"?t.jsx(w,{className:o.nav_icon,style:l.nav_icon}):t.jsx(b,{className:o.nav_icon,style:l.nav_icon})})]})}function W3(e){var s=Ns().numberOfMonths,r=Xf(),n=r.previousMonth,a=r.nextMonth,i=r.goToMonth,o=r.displayMonths,l=o.findIndex(function(x){return Ph(e.displayMonth,x)}),c=l===0,d=l===o.length-1,m=s>1&&(c||!d),h=s>1&&(d||!c),f=function(){n&&i(n)},p=function(){a&&i(a)};return t.jsx(Mie,{displayMonth:e.displayMonth,hideNext:m,hidePrevious:h,nextMonth:a,previousMonth:n,onPreviousClick:f,onNextClick:p})}function Oie(e){var s,r=Ns(),n=r.classNames,a=r.disableNavigation,i=r.styles,o=r.captionLayout,l=r.components,c=(s=l==null?void 0:l.CaptionLabel)!==null&&s!==void 0?s:_R,d;return a?d=t.jsx(c,{id:e.id,displayMonth:e.displayMonth}):o==="dropdown"?d=t.jsx(H3,{displayMonth:e.displayMonth,id:e.id}):o==="dropdown-buttons"?d=t.jsxs(t.Fragment,{children:[t.jsx(H3,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),t.jsx(W3,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}):d=t.jsxs(t.Fragment,{children:[t.jsx(c,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),t.jsx(W3,{displayMonth:e.displayMonth,id:e.id})]}),t.jsx("div",{className:n.caption,style:i.caption,children:d})}function Iie(e){var s=Ns(),r=s.footer,n=s.styles,a=s.classNames.tfoot;return r?t.jsx("tfoot",{className:a,style:n.tfoot,children:t.jsx("tr",{children:t.jsx("td",{colSpan:8,children:r})})}):t.jsx(t.Fragment,{})}function Fie(e,s,r){for(var n=r?Ki(new Date):$n(new Date,{locale:e,weekStartsOn:s}),a=[],i=0;i<7;i++){var o=Sr(n,i);a.push(o)}return a}function Lie(){var e=Ns(),s=e.classNames,r=e.styles,n=e.showWeekNumber,a=e.locale,i=e.weekStartsOn,o=e.ISOWeek,l=e.formatters.formatWeekdayName,c=e.labels.labelWeekday,d=Fie(a,i,o);return t.jsxs("tr",{style:r.head_row,className:s.head_row,children:[n&&t.jsx("td",{style:r.head_cell,className:s.head_cell}),d.map(function(m,h){return t.jsx("th",{scope:"col",className:s.head_cell,style:r.head_cell,"aria-label":c(m,{locale:a}),children:l(m,{locale:a})},h)})]})}function Bie(){var e,s=Ns(),r=s.classNames,n=s.styles,a=s.components,i=(e=a==null?void 0:a.HeadRow)!==null&&e!==void 0?e:Lie;return t.jsx("thead",{style:n.head,className:r.head,children:t.jsx(i,{})})}function zie(e){var s=Ns(),r=s.locale,n=s.formatters.formatDay;return t.jsx(t.Fragment,{children:n(e.date,{locale:r})})}var IN=u.createContext(void 0);function Uie(e){if(!Kf(e.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return t.jsx(IN.Provider,{value:s,children:e.children})}return t.jsx(Vie,{initialProps:e.initialProps,children:e.children})}function Vie(e){var s=e.initialProps,r=e.children,n=s.selected,a=s.min,i=s.max,o=function(d,m,h){var f,p;
770(f=s.onDayClick)===null||f===void 0||f.call(s,d,m,h);var x=!!(m.selected&&a&&(n==null?void 0:n.length)===a);if(!x){var g=!!(!m.selected&&i&&(n==null?void 0:n.length)===i);if(!g){var b=n?wR([],n):[];if(m.selected){var w=b.findIndex(function(j){return jn(d,j)});b.splice(w,1)}else b.push(d);(p=s.onSelect)===null||p===void 0||p.call(s,b,d,m,h)}}},l={disabled:[]};n&&l.disabled.push(function(d){var m=i&&n.length>i-1,h=n.some(function(f){return jn(f,d)});return!!(m&&!h)});var c={selected:n,onDayClick:o,modifiers:l};return t.jsx(IN.Provider,{value:c,children:r})}function FN(){var e=u.useContext(IN);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}function qie(e,s){var r=s||{},n=r.from,a=r.to;return n&&a?jn(a,e)&&jn(n,e)?void 0:jn(a,e)?{from:a,to:void 0}:jn(n,e)?void 0:Pj(n,e)?{from:e,to:a}:{from:n,to:e}:a?Pj(e,a)?{from:a,to:e}:{from:e,to:a}:n?uA(e,n)?{from:e,to:n}:{from:n,to:e}:{from:e,to:void 0}}var LN=u.createContext(void 0);function Hie(e){if(!Qf(e.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return t.jsx(LN.Provider,{value:s,children:e.children})}return t.jsx(Wie,{initialProps:e.initialProps,children:e.children})}function Wie(e){var s=e.initialProps,r=e.children,n=s.selected,a=n||{},i=a.from,o=a.to,l=s.min,c=s.max,d=function(p,x,g){var b,w;(b=s.onDayClick)===null||b===void 0||b.call(s,p,x,g);var j=qie(p,n);(w=s.onSelect)===null||w===void 0||w.call(s,j,p,x,g)},m={range_start:[],range_end:[],range_middle:[],disabled:[]};if(i?(m.range_start=[i],o?(m.range_end=[o],jn(i,o)||(m.range_middle=[{after:i,before:o}])):m.range_end=[i]):o&&(m.range_start=[o],m.range_end=[o]),l&&(i&&!o&&m.disabled.push({after:n0(i,l-1),before:Sr(i,l-1)}),i&&o&&m.disabled.push({after:i,before:Sr(i,l-1)}),!i&&o&&m.disabled.push({after:n0(o,l-1),before:Sr(o,l-1)})),c){if(i&&!o&&(m.disabled.push({before:Sr(i,-c+1)}),m.disabled.push({after:Sr(i,c-1)})),i&&o){var h=ni(o,i)+1,f=c-h;m.disabled.push({before:n0(i,f)}),m.disabled.push({after:Sr(o,f)})}!i&&o&&(m.disabled.push({before:Sr(o,-c+1)}),m.disabled.push({after:Sr(o,c-1)}))}return t.jsx(LN.Provider,{value:{selected:n,onDayClick:d,modifiers:m},children:r})}function BN(){var e=u.useContext(LN);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function xx(e){return Array.isArray(e)?wR([],e):e!==void 0?[e]:[]}function Gie(e){var s={};return Object.entries(e).forEach(function(r){var n=r[0],a=r[1];s[n]=xx(a)}),s}var Ba;(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"})(Ba||(Ba={}));var Yie=Ba.Selected,Ci=Ba.Disabled,Kie=Ba.Hidden,Qie=Ba.Today,_0=Ba.RangeEnd,S0=Ba.RangeMiddle,C0=Ba.RangeStart,Xie=Ba.Outside;function Zie(e,s,r){var n,a=(n={},n[Yie]=xx(e.selected),n[Ci]=xx(e.disabled),n[Kie]=xx(e.hidden),n[Qie]=[e.today],n[_0]=[],n[S0]=[],n[C0]=[],n[Xie]=[],n);return e.fromDate&&a[Ci].push({before:e.fromDate}),e.toDate&&a[Ci].push({after:e.toDate}),Kf(e)?a[Ci]=a[Ci].concat(s.modifiers[Ci]):Qf(e)&&(a[Ci]=a[Ci].concat(r.modifiers[Ci]),a[C0]=r.modifiers[C0],a[S0]=r.modifiers[S0],a[_0]=r.modifiers[_0]),a}var kR=u.createContext(void 0);function Jie(e){var s=Ns(),r=FN(),n=BN(),a=Zie(s,r,n),i=Gie(s.modifiers),o=vt(vt({},a),i);return t.jsx(kR.Provider,{value:o,children:e.children})}function $R(){var e=u.useContext(kR);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function eoe(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function toe(e){return!!(e&&typeof e=="object"&&"from"in e)}function soe(e){return!!(e&&typeof e=="object"&&"after"in e)}function roe(e){return!!(e&&typeof e=="object"&&"before"in e)}function noe(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function aoe(e,s){var r,n=s.from,a=s.to;if(n&&a){var i=ni(a,n)<0;i&&(r=[a,n],n=r[0],a=r[1]);var o=ni(e,n)>=0&&ni(a,e)>=0;return o}return a?jn(a,e):n?jn(n,e):!1}function ioe(e){return I2(e)}function ooe(e){return Array.isArray(e)&&e.every(I2)}function loe(e,s){return s.some(function(r){if(typeof r=="boolean")return r;if(ioe(r))return jn(e,r);if(ooe(r))return r.includes(e);if(toe(r))return aoe(e,r);if(noe(r))return r.dayOfWeek.includes(e.getDay());if(eoe(r)){var n=ni(r.before,e),a=ni(r.after,e),i=n>0,o=a<0,l=Pj(r.before,r.after);return l?o&&i:i||o}return soe(r)?ni(e,r.after)>0:roe(r)?ni(r.before,e)>0:typeof r=="function"?r(e):!1})}function zN(e,s,r){var n=Object.keys(s).reduce(function(i,o){var l=s[o];return loe(e,l)&&i.push(o),i},[]),a={};
770return n.forEach(function(i){return a[i]=!0}),r&&!Ph(e,r)&&(a.outside=!0),a}function coe(e,s){for(var r=jr(e[0]),n=du(e[e.length-1]),a,i,o=r;o<=n;){var l=zN(o,s),c=!l.disabled&&!l.hidden;if(!c){o=Sr(o,1);continue}if(l.selected)return o;l.today&&!i&&(i=o),a||(a=o),o=Sr(o,1)}return i||a}var doe=365;function ER(e,s){var r=s.moveBy,n=s.direction,a=s.context,i=s.modifiers,o=s.retry,l=o===void 0?{count:0,lastFocused:e}:o,c=a.weekStartsOn,d=a.fromDate,m=a.toDate,h=a.locale,f={day:Sr,week:kj,month:Cr,year:FY,startOfWeek:function(b){return a.ISOWeek?Ki(b):$n(b,{locale:h,weekStartsOn:c})},endOfWeek:function(b){return a.ISOWeek?oA(b):Rv(b,{locale:h,weekStartsOn:c})}},p=f[r](e,n==="after"?1:-1);n==="before"&&d?p=LY([d,p]):n==="after"&&m&&(p=BY([m,p]));var x=!0;if(i){var g=zN(p,i);x=!g.disabled&&!g.hidden}return x?p:l.count>doe?l.lastFocused:ER(p,{moveBy:r,direction:n,context:a,modifiers:i,retry:vt(vt({},l),{count:l.count+1})})}var PR=u.createContext(void 0);function uoe(e){var s=Xf(),r=$R(),n=u.useState(),a=n[0],i=n[1],o=u.useState(),l=o[0],c=o[1],d=coe(s.displayMonths,r),m=a??(l&&s.isDateDisplayed(l))?l:d,h=function(){c(a),i(void 0)},f=function(b){i(b)},p=Ns(),x=function(b,w){if(a){var j=ER(a,{moveBy:b,direction:w,context:p,modifiers:r});jn(a,j)||(s.goToDate(j,a),f(j))}},g={focusedDay:a,focusTarget:m,blur:h,focus:f,focusDayAfter:function(){return x("day","after")},focusDayBefore:function(){return x("day","before")},focusWeekAfter:function(){return x("week","after")},focusWeekBefore:function(){return x("week","before")},focusMonthBefore:function(){return x("month","before")},focusMonthAfter:function(){return x("month","after")},focusYearBefore:function(){return x("year","before")},focusYearAfter:function(){return x("year","after")},focusStartOfWeek:function(){return x("startOfWeek","before")},focusEndOfWeek:function(){return x("endOfWeek","after")}};return t.jsx(PR.Provider,{value:g,children:e.children})}function UN(){var e=u.useContext(PR);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}function moe(e,s){var r=$R(),n=zN(e,r,s);return n}var VN=u.createContext(void 0);function hoe(e){if(!Xv(e.initialProps)){var s={selected:void 0};return t.jsx(VN.Provider,{value:s,children:e.children})}return t.jsx(foe,{initialProps:e.initialProps,children:e.children})}function foe(e){var s=e.initialProps,r=e.children,n=function(i,o,l){var c,d,m;if((c=s.onDayClick)===null||c===void 0||c.call(s,i,o,l),o.selected&&!s.required){(d=s.onSelect)===null||d===void 0||d.call(s,void 0,i,o,l);return}(m=s.onSelect)===null||m===void 0||m.call(s,i,i,o,l)},a={selected:s.selected,onDayClick:n};return t.jsx(VN.Provider,{value:a,children:r})}function AR(){var e=u.useContext(VN);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function poe(e,s){var r=Ns(),n=AR(),a=FN(),i=BN(),o=UN(),l=o.focusDayAfter,c=o.focusDayBefore,d=o.focusWeekAfter,m=o.focusWeekBefore,h=o.blur,f=o.focus,p=o.focusMonthBefore,x=o.focusMonthAfter,g=o.focusYearBefore,b=o.focusYearAfter,w=o.focusStartOfWeek,j=o.focusEndOfWeek,y=function(L){var D,_,H,O;Xv(r)?(D=n.onDayClick)===null||D===void 0||D.call(n,e,s,L):Kf(r)?(_=a.onDayClick)===null||_===void 0||_.call(a,e,s,L):Qf(r)?(H=i.onDayClick)===null||H===void 0||H.call(i,e,s,L):(O=r.onDayClick)===null||O===void 0||O.call(r,e,s,L)},v=function(L){var D;f(e),(D=r.onDayFocus)===null||D===void 0||D.call(r,e,s,L)},N=function(L){var D;h(),(D=r.onDayBlur)===null||D===void 0||D.call(r,e,s,L)},S=function(L){var D;(D=r.onDayMouseEnter)===null||D===void 0||D.call(r,e,s,L)},k=function(L){var D;(D=r.onDayMouseLeave)===null||D===void 0||D.call(r,e,s,L)},$=function(L){var D;(D=r.onDayPointerEnter)===null||D===void 0||D.call(r,e,s,L)},R=function(L){var D;(D=r.onDayPointerLeave)===null||D===void 0||D.call(r,e,s,L)},A=function(L){var D;(D=r.onDayTouchCancel)===null||D===void 0||D.call(r,e,s,L)},T=function(L){var D;(D=r.onDayTouchEnd)===null||D===void 0||D.call(r,e,s,L)},P=function(L){var D;(D=r.onDayTouchMove)===null||D===void 0||D.call(r,e,s,L)},B=function(L){var D;(D=r.onDayTouchStart)===null||D===void 0||D.call(r,e,s,L)},Y=function(L){var D;(D=r.onDayKeyUp)===null||D===void 0||D.call(r,e,s,L)},I=function(L){var D;switch(L.key){case"ArrowLeft":L.preventDefault(),L.stopPropagation(),r.dir==="rtl"?l(
770):c();break;case"ArrowRight":L.preventDefault(),L.stopPropagation(),r.dir==="rtl"?c():l();break;case"ArrowDown":L.preventDefault(),L.stopPropagation(),d();break;case"ArrowUp":L.preventDefault(),L.stopPropagation(),m();break;case"PageUp":L.preventDefault(),L.stopPropagation(),L.shiftKey?g():p();break;case"PageDown":L.preventDefault(),L.stopPropagation(),L.shiftKey?b():x();break;case"Home":L.preventDefault(),L.stopPropagation(),w();break;case"End":L.preventDefault(),L.stopPropagation(),j();break}(D=r.onDayKeyDown)===null||D===void 0||D.call(r,e,s,L)},C={onClick:y,onFocus:v,onBlur:N,onKeyDown:I,onKeyUp:Y,onMouseEnter:S,onMouseLeave:k,onPointerEnter:$,onPointerLeave:R,onTouchCancel:A,onTouchEnd:T,onTouchMove:P,onTouchStart:B};return C}function xoe(){var e=Ns(),s=AR(),r=FN(),n=BN(),a=Xv(e)?s.selected:Kf(e)?r.selected:Qf(e)?n.selected:void 0;return a}function goe(e){return Object.values(Ba).includes(e)}function voe(e,s){var r=[e.classNames.day];return Object.keys(s).forEach(function(n){var a=e.modifiersClassNames[n];if(a)r.push(a);else if(goe(n)){var i=e.classNames["day_".concat(n)];i&&r.push(i)}}),r}function yoe(e,s){var r=vt({},e.styles.day);return Object.keys(s).forEach(function(n){var a;r=vt(vt({},r),(a=e.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function boe(e,s,r){var n,a,i,o=Ns(),l=UN(),c=moe(e,s),d=poe(e,c),m=xoe(),h=!!(o.onDayCl
770ick||o.mode!=="default");u.useEffect(function(){var S;c.outside||l.focusedDay&&h&&jn(l.focusedDay,e)&&((S=r.current)===null||S===void 0||S.focus())},[l.focusedDay,e,r,h,c.outside]);var f=voe(o,c).join(" "),p=yoe(o,c),x=!!(c.outside&&!o.showOutsideDays||c.hidden),g=(i=(a=o.components)===null||a===void 0?void 0:a.DayContent)!==null&&i!==void 0?i:zie,b=t.jsx(g,{date:e,displayMonth:s,activeModifiers:c}),w={style:p,className:f,children:b,role:"gridcell"},j=l.focusTarget&&jn(l.focusTarget,e)&&!c.outside,y=l.focusedDay&&jn(l.focusedDay,e),v=vt(vt(vt({},w),(n={disabled:c.disabled,role:"gridcell"},n["aria-selected"]=c.selected,n.tabIndex=y||j?0:-1,n)),d),N={isButton:h,isHidden:x,activeModifiers:c,selectedDays:m,buttonProps:v,divProps:w};return N}function joe(e){var s=u.useRef(null),r=boe(e.date,e.displayMonth,s);return r.isHidden?t.jsx("div",{role:"gridcell"}):r.isButton?t.jsx(Cg,vt({name:"day",ref:s},r.buttonProps)):t.jsx("div",vt({},r.divProps))}function woe(e){var s=e.number,r=e.dates,n=Ns(),a=n.onWeekNumberClick,i=n.styles,o=n.classNames,l=n.locale,c=n.labels.labelWeekNumber,d=n.formatters.formatWeekNumber,m=d(Number(s),{locale:l});if(!a)return t.jsx("span",{className:o.weeknumber,style:i.weeknumber,children:m});var h=c(Number(s),{locale:l}),f=function(p){a(s,r,p)};return t.jsx(Cg,{name:"week-number","aria-label":h,className:o.weeknumber,style:i.weeknumber,onClick:f,children:m})}function Noe(e){var s,r,n=Ns(),a=n.styles,i=n.classNames,o=n.showWeekNumber,l=n.components,c=(s=l==null?void 0:l.Day)!==null&&s!==void 0?s:joe,d=(r=l==null?void 0:l.WeekNumber)!==null&&r!==void 0?r:woe,m;return o&&(m=t.jsx("td",{className:i.cell,style:a.cell,children:t.jsx(d,{number:e.weekNumber,dates:e.dates})})),t.jsxs("tr",{className:i.row,style:a.row,children:[m,e.dates.map(function(h){return t.jsx("td",{className:i.cell,style:a.cell,role:"presentation",children:t.jsx(c,{displayMonth:e.displayMonth,date:h})},WK(h))})]})}function G3(e,s,r){for(var n=r!=null&&r.ISOWeek?oA(s):Rv(s,r),a=r!=null&&r.ISOWeek?Ki(e):$n(e,r),i=ni(n,a),o=[],l=0;l<=i;l++)o.push(Sr(a,l));var c=o.reduce(function(d,m){var h=r!=null&&r.ISOWeek?F2(m):B2(m,r),f=d.find(function(p){return p.weekNumber===h});return f?(f.dates.push(m),d):(d.push({weekNumber:h,dates:[m]}),d)},[]);return c}function _oe(e,s){var r=G3(jr(e),du(e),s);
770if(s!=null&&s.useFixedWeeks){var n=YK(e,s);if(n<6){var a=r[r.length-1],i=a.dates[a.dates.length-1],o=kj(i,6-n),l=G3(kj(i,1),o,s);r.push.apply(r,l)}}return r}function Soe(e){var s,r,n,a=Ns(),i=a.locale,o=a.classNames,l=a.styles,c=a.hideHead,d=a.fixedWeeks,m=a.components,h=a.weekStartsOn,f=a.firstWeekContainsDate,p=a.ISOWeek,x=_oe(e.displayMonth,{useFixedWeeks:!!d,ISOWeek:p,locale:i,weekStartsOn:h,firstWeekContainsDate:f}),g=(s=m==null?void 0:m.Head)!==null&&s!==void 0?s:Bie,b=(r=m==null?void 0:m.Row)!==null&&r!==void 0?r:Noe,w=(n=m==null?void 0:m.Footer)!==null&&n!==void 0?n:Iie;return t.jsxs("table",{id:e.id,className:o.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!c&&t.jsx(g,{}),t.jsx("tbody",{className:o.tbody,style:l.tbody,children:x.map(function(j){return t.jsx(b,{displayMonth:e.displayMonth,dates:j.dates,weekNumber:j.weekNumber},j.weekNumber)})}),t.jsx(w,{displayMonth:e.displayMonth})]})}function Coe(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var koe=Coe()?u.useLayoutEffect:u.useEffect,k0=!1,$oe=0;function Y3(){return"react-day-picker-".concat(++$oe)}function Eoe(e){var s,r=e??(k0?Y3():null),n=u.useState(r),a=n[0],i=n[1];return koe(function(){a===null&&i(Y3())},[]),u.useEffect(function(){k0===!1&&(k0=!0)},[]),(s=e??a)!==null&&s!==void 0?s:void 0}function Poe(e){var s,r,n=Ns(),a=n.dir,i=n.classNames,o=n.styles,l=n.components,c=Xf().displayMonths,d=Eoe(n.id?"".concat(n.id,"-").concat(e.displayIndex):void 0),m=n.id?"".concat(n.id,"-grid-").concat(e.displayIndex):void 0,h=[i.month],f=o.month,p=e.displayIndex===0,x=e.displayIndex===c.length-1,g=!p&&!x;a==="rtl"&&(s=[p,x],x=s[0],p=s[1]),p&&(h.push(i.caption_start),f=vt(vt({},f),o.caption_start)),x&&(h.push(i.caption_end),f=vt(vt({},f),o.caption_end)),g&&(h.push(i.caption_between),f=vt(vt({},f),o.caption_between));var b=(r=l==null?void 0:l.Caption)!==null&&r!==void 0?r:Oie;return t.jsxs("div",{className:h.join(" "),style:f,children:[t.jsx(b,{id:d,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),t.jsx(Soe,{id:m,"aria-labelledby":d,displayMonth:e.displayMonth})]},e.displayIndex)}function Aoe(e){var s=Ns(),r=s.classNames,n=s.styles;return t.jsx("div",{className:r.months,style:n.months,children:e.children})}function Toe(e){var s,r,n=e.initialProps,a=Ns(),i=UN(),o=Xf(),l=u.useState(!1),c=l[0],d=l[1];u.useEffect(function(){a.initialFocus&&i.focusTarget&&(c||(i.focus(i.focusTarget),d(!0)))},[a.initialFocus,c,i.focus,i.focusTarget,i]);var m=[a.classNames.root,a.className];a.numberOfMonths>1&&m.push(a.classNames.multiple_months),a.showWeekNumber&&m.push(a.classNames.with_weeknumber);var h=vt(vt({},a.styles.root),a.style),f=Object.keys(n).filter(function(x){return x.startsWith("data-")}).reduce(function(x,g){var b;return vt(vt({},x),(b={},b[g]=n[g],b))},{}),p=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:Aoe;return t.jsx("div",vt({className:m.join(" "),style:h,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},f,{children:t.jsx(p,{children:o.displayMonths.map(function(x,g){return t.jsx(Poe,{displayIndex:g,displayMonth:x},g)})})}))}function Doe(e){var s=e.children,r=rie(e,["children"]);return t.jsx(wie,{initialProps:r,children:t.jsx(Tie,{children:t.jsx(hoe,{initialProps:r,children:t.jsx(Uie,{initialProps:r,children:t.jsx(Hie,{initialProps:r,children:t.jsx(Jie,{children:t.jsx(uoe,{children:s})})})})})})})}function Roe(e){return t.jsx(Doe,vt({},e,{children:t.jsx(Toe,{initialProps:e})}))}function nc({className:e,classNames:s,showOutsideDays:r=!0,...n}){return t.jsx(Roe,{showOutsideDays:r,className:oe("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:oe(kh({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:oe(kh({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...s},components:{IconLeft:({...a})=>t.jsx(su,{className:"h-4 w-4"}),IconRight:({...a})=>t.jsx(Ac,{className:"h-4 w-4"})},...n})}
770nc.displayName="Calendar";const Moe=[{id:"area1",name:"SOUTHAMPTON CITY",postcodes:"SO15 SO16 SO17",townsVillages:"Chilworth, Upper Shirley, Rownhams, Bassett, Highfield",circulation:1e4,pricingMultipliers:{"eighth-page":1,"quarter-page":1,"half-page":1,"full-page":1,"double-page":1,"loose-insert":.85,"business-card":.4}},{id:"area2",name:"CHANDLER'S FORD",postcodes:"SO53 SO52",townsVillages:"Chandler's Ford, North Baddesley",circulation:11300,pricingMultipliers:{"eighth-page":1,"quarter-page":1,"half-page":1,"full-page":1,"double-page":1,"loose-insert":.85,"business-card":.4}},{id:"area3",name:"EASTLEIGH & VILLAGES",postcodes:"SO50",townsVillages:"Fair Oak, Bishopstoke, Horton Heath, Allbrook, Boyatt Wood, Eastleigh",circulation:12500,pricingMultipliers:{"eighth-page":.85,"quarter-page":.85,"half-page":.85,"full-page":.85,"double-page":.85,"loose-insert":.75,"business-card":.35}},{id:"area4",name:"HEDGE END & BOTLEY",postcodes:"SO30",townsVillages:"Hedge End, West End, Botley",circulation:9400,pricingMultipliers:{"eighth-page":.95,"quarter-page":.95,"half-page":.95,"full-page":.95,"double-page":.95,"loose-insert":.8,"business-card":.38}},{id:"area5",name:"LOCKS HEATH & VILLAGES",postcodes:"SO31",townsVillages:"Locks Heath, Warsash, Swanwick, Bursledon, Hamble, Netley",circulation:12e3,pricingMultipliers:{"eighth-page":.95,"quarter-page":.95,"half-page":.95,"full-page":.95,"double-page":.95,"loose-insert":.8,"business-card":.38}},{id:"area6",name:"FAREHAM & VILLAGES",postcodes:"PO13 PO14 PO15",townsVillages:"Fareham, Titchfield, Stubbington, Lee on Solent, Hill Head",circulation:12100,pricingMultipliers:{"eighth-page":1.05,"quarter-page":1.05,"half-page":1.05,"full-page":1.05,"double-page":1.05,"loose-insert":.9,"business-card":.42}},{id:"area7",name:"MEON VALLEY",postcodes:"SO32 PO17",townsVillages:"Wickham, Bishop's Waltham",circulation:12400,pricingMultipliers:{"eighth-page":1.05,"quarter-page":1.05,"half-page":1.05,"full-page":1.05,"double-page":1.05,"loose-insert":.9,"business-card":.42}},{id:"area8",name:"WINCHESTER & VILLAGES",postcodes:"SO21 SO22 SO23",townsVillages:"Winchester, Otterbourne, Colden Common, Hursley, Crawley, South Wonston, Littleton, Sparsholt",circulation:12e3,pricingMultipliers:{"eighth-page":1,"quarter-page":1,"half-page":1,"full-page":1,"double-page":1,"loose-insert":.85,"business-card":.4}},{id:"area9",name:"ROMSEY & N BADDESLEY",postcodes:"SO51 SO20",townsVillages:"Romsey, Stockbridge, The Wellows, Braishfield, Ampfield, Kings Somborne",circulation:8600,pricingMultipliers:{"eighth-page":1.15,"quarter-page":1.15,"half-page":1.15,"full-page":1.15,"double-page":1.15,"loose-insert":.95,"business-card":.45}},{id:"area10",name:"TOTTON",postcodes:"SO40 SO45",townsVillages:"Totton, Marchwood, Hythe, Dibden, Dibden Purlieu, Holbury, Blackfield",circulation:7e3,pricingMultipliers:{"eighth-page":1.05,"quarter-page":1.05,"half-page":1.05,"full-page":1.05,"double-page":1.05,"loose-insert":.9,"business-card":.42}},{id:"area11",name:"NEW FOREST & WATERSIDE",postcodes:"SO41 SO42 SO43 BH24 4",townsVillages:"Lymington, Brockenhurst, Lyndhurst, New Milton, Beaulieu",circulation:10640,pricingMultipliers:{"eighth-page":1,"quarter-page":1,"half-page":1,"full-page":1,"double-page":1,"loose-insert":.85,"business-card":.4}},{id:"area12",name:"SHOLING, PEARTREE, ITCHEN, WOOLSTON",postcodes:"PO9 PO10 PO11 PO12",townsVillages:"Havant, Waterlooville, Emsworth, Cosham, Drayton, Denmead",circulation:7e3,pricingMultipliers:{"eighth-page":1.15,"quarter-page":1.15,"half-page":1.15,"full-page":1.15,"double-page":1.15,"loose-insert":.95,"business-card":.45}},{id:"area13",name:"SOUTHAMPTON EAST",postcodes:"PO6 PO7 PO8",townsVillages:"Cosham, Drayton, Farlington, Widley, Purbrook",circulation:9200,pricingMultipliers:{"eighth-page":1.1,"quarter-page":1.1,"half-page":1.1,"full-page":1.1,"double-page":1.1,"loose-insert":.92,"business-card":.43}},{id:"area14",name:"TEST VALLEY & STOCKBRIDGE",postcodes:"PO1 PO2 PO3 PO4 PO5",townsVillages:"Portsmouth, Southsea, Eastney, Milton, Fratton",circulation:8e3,pricingMultipliers:{"eighth-page":1.2,"quarter-page":1.2,"half-page":1.2,"full-page":1.2,"double-page":1.2,"loose-insert":1,"business-card":.48}}],Ooe=[{id:"full-page",label:"Full Page",description:"132 x 190",dimensions:"132 x 190",areaPricing:{perMonth:[298,582,858,1128,1390,1646,1896,2140,2384,2620,2854,3088,3322,3550],perArea:[298,284,276,270,262,256,250,244,240,236,234,234,234,228]}},{id:"two-thirds-page",label:"2/3 Page",description:"132 x 125.33",dimensions:"132 x 125.33",areaPricing:{perMonth:[226,429,628,820,997,1166,1324,1483,1641,1799,1957,2115,2274,2432],perArea:[226,203,199,192,177,169,158,159,158,158,158,158,159,158]}},{id:"half-page",label:"1/2 Page",description:"132 x 93",dimensions:"132 x 93",areaPricing:{perMonth:[180,342,500,653,794,929,1055,1181,1307,1433,1559,1685,1811,1937],perArea:[180,162,158,153,141,135,126,126,126,126,126,126,126,126]}},{id:"one-third-page",label:"1/3 Page",description:"132 x 60.66",dimensions:"132 x 60.66",areaPricing:{perMonth:[174,331,484,632,767,898,1020,1141,1263,1385,1507,1629,1750,1872],perArea:[174,157,153,148,135,131,122,121,122,122,122,122,121,122]}},{id:"quarter-page",label:"1/4 Page",description:"64 x 93",dimensions:"64 x 93",areaPricing:{perMonth:[112,213,311,407,494,578,656,735,813,892,970,1048,1127,1205],perArea:[112,101,98,96,87,84,78,79,78,79,78,78,79,78]}},{id:"sixth-page",label:"1/6 Page",description:"64 x 60.66",dimensions:"64 x 60.66",areaPricing:{perMonth:[73,128,181,232,281,325,362,398,435,471,508,545,581,618],perArea:[73,55,53,51,49,44,37,36,37,36,37,37,36,37]}},{id:"eighth-page",label:"1/8 Page",description:"64 x 45.5",dimensions:"64 x 45.5",areaPricing:{perMonth:[54,95,134,172,209,242,269,296,324,351,378,405,432,460],perArea:[54,41,39,38,37,33,27,27,28,27,27,27,27,28]}}],K3=(e,s)=>{if(e.includes("-")){const r=e.split("-"),n=parseInt(r[1],10);return`${["January","February","March","April","May","June","July","August","September","October","November","December"][n-1]} ${s}`}else return`${e} ${s}`},Ioe=({onStatsUpdate:e})=>{const[s,r]=u.useState([]),[n,a]=u.useState(!0),[i,o]=u.useState(!1),[l,c]=u.useState(null),[d,m]=u.useState(""),[h,f]=u.useState("all"),[p,x]=u.useState("name"),[g,b]=u.useState("asc"),[w,j]=u.useState([]),[y,v]=u.useState({name:"",postcodes:"",circulation:0,base_price_multiplier:1,quarter_page_multiplier:1,half_page_multiplier:1,full_page_multiplier:1,is_active:!0,sort_order:0,schedule:[]}),{toast:N}=rt(),S=["January","February","March","April","May","June","July","August","September","October","November","December"],k=[2024,2025,2026],$=(_,H)=>{const O=S.indexOf(H),U=new Date(_,O,15),G=new Date(_,O,20),E=new Date(_,O,25),z={year:_,month:H,copyDeadline:Dt(U,"dd.MM.yyyy"),printDeadline:Dt(G,"dd.MM.yyyy"),deliveryDate:Dt(E,"dd.MM.yyyy")},Z=[...y.schedule,z].sort((M,F)=>M.year!==F.year?M.year-F.year:S.indexOf(M.month)-S.indexOf(F.month));v(M=>({...M,schedule:Z}))},R=(_,H)=>{const O=y.schedule.filter(U=>!(U.year===_&&U.month===H));v(U=>({...U,schedule:O}))},A=()=>{const _=y.schedule.map(O=>`${O.year}-${O.month}`),H=[];
770return k.forEach(O=>{S.forEach(U=>{const G=`${O}-${U}`;_.includes(G)||H.push({year:O,month:U,label:`${U} ${O}`})})}),H};u.useEffect(()=>{P(),T()},[]);const T=async()=>{try{const{data:_}=await W.from("pricing_areas").select("id").limit(1);if(_&&_.length===0){const H=Moe.map((U,G)=>({name:U.name,postcodes:U.postcodes.split(" ").filter(E=>E.trim()),circulation:U.circulation,base_price_multiplier:U.pricingMultipliers["quarter-page"]||1,quarter_page_multiplier:U.pricingMultipliers["quarter-page"]||1,half_page_multiplier:U.pricingMultipliers["half-page"]||1,full_page_multiplier:U.pricingMultipliers["full-page"]||1,is_active:!0,sort_order:G+1})),{error:O}=await W.from("pricing_areas").insert(H);O?console.error("Error initializing default locations:",O):(N({title:"Default Locations Imported",description:`Successfully imported ${H.length} default locations.`}),P())}}catch(_){console.error("Error initializing default locations:",_)}},P=async()=>{try{const{data:_,error:H}=await W.from("pricing_areas").select("*").order("sort_order",{ascending:!0});if(H)throw H;const O=(_||[]).map(U=>({...U,schedule:Array.isArray(U.schedule)?U.schedule:[]}));r(O),e()}catch(_){console.error("Error loading locations:",_),N({title:"Error",description:"Failed to load locations.",variant:"destructive"})}finally{a(!1)}},B=()=>{v({name:"",postcodes:"",circulation:0,base_price_multiplier:1,quarter_page_multiplier:1,half_page_multiplier:1,full_page_multiplier:1,is_active:!0,sort_order:s.length+1,schedule:[]}),c(null)},Y=_=>{_?(c(_),v({name:_.name,postcodes:_.postcodes.join(" "),circulation:_.circulation,base_price_multiplier:_.base_price_multiplier,quarter_page_multiplier:_.quarter_page_multiplier,half_page_multiplier:_.half_page_multiplier,full_page_multiplier:_.full_page_multiplier,is_active:_.is_active,sort_order:_.sort_order,schedule:_.schedule||[]})):B(),o(!0)},I=async()=>{try{const _={...y,postcodes:y.postcodes.split(" ").filter(O=>O.trim()),circulation:Number(y.circulation),base_price_multiplier:Number(y.base_price_multiplier),quarter_page_multiplier:Number(y.quarter_page_multiplier),half_page_multiplier:Number(y.half_page_multiplier),full_page_multiplier:Number(y.full_page_multiplier),sort_order:Number(y.sort_order),schedule:y.schedule};let H;if(l){const{error:O}=await W.from("pricing_areas").update(_).eq("id",l.id);H=O}else{const{error:O}=await W.from("pricing_areas").insert([_]);H=O}if(H)throw H;N({title:"Success",description:`Location ${l?"updated":"created"} successfully.`}),o(!1),B(),P()}catch(_){console.error("Error saving location:",_),N({title:"Error",description:_.message||"Failed to save location.",variant:"destructive"})}},C=async _=>{try{const{error:H}=await W.from("pricing_areas").delete().eq("id",_);if(H)throw H;N({title:"Success",description:"Location deleted successfully."}),P()}catch(H){console.error("Error deleting location:",H),N({title:"Error",description:H.message||"Failed to delete location.",variant:"destructive"})}},L=async _=>{if(w.length!==0)try{const{error:H}=await W.from("pricing_areas").update({is_active:_}).in("id",w);if(H)throw H;N({title:"Success",description:`${w.length} locations ${_?"activated":"deactivated"} successfully.`}),j([]),P()}catch(H){console.error("Error updating locations:",H),N({title:"Error",description:H.message||"Failed to update locations.",variant:"destructive"})}},D=s.filter(_=>{const H=_.name.toLowerCase().includes(d.toLowerCase())||_.postcodes.some(U=>U.toLowerCase().includes(d.toLowerCase())),O=h==="all"||h==="active"&&_.is_active||h==="inactive"&&!_.is_active;return H&&O}).sort((_,H)=>{let O,U;switch(p){case"name":O=_.name,U=H.name;break;case"circulation":O=_.circulation,U=H.circulation;break;case"created_at":O=new Date(_.created_at),U=new Date(H.created_at);break;default:O=_.name,U=H.name}return g==="asc"?O<U?-1:O>U?1:0:O>U?-1:O<U?1:0});return n?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("div",{className:"text-center",children:"Loading locations..."})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-between items-start sm:items-center",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-xl font-heading font-bold text-community-navy flex items-center gap-2",children:[t.jsx(_t,{className:"h-5 w-5"}),"Locations Management"]}),t.jsx("p",{className:"text-sm text-gray-600 mt-1",children:"Manage advertising distribution areas and their pricing multipliers"})]}),t.jsxs("div",{className:"flex gap-2",children:[w.length>0&&t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(q,{size:"sm",variant:"outline",onClick:()=>L(!0),children:[t.jsx(xs,{className:"h-4 w-4 mr-1"}),"Activate (",w.length,")"]}),t.jsxs(q,{size:"sm",variant:"outline",onClick:()=>L(!1),children:[t.jsx(Nf,{className:"h-4 w-4 mr-1"}),"Deactivate (",w.length,")"]})]}),t.jsxs(bt,{open:i,onOpenChange:o,children:[t.jsx(Sn,{asChild:!0,children:t.jsxs(q,{onClick:()=>Y(),children:[t.jsx(Xt,{className:"h-4 w-4 mr-1"}),"Add Location"]})}),t.jsxs(xt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[t.jsx(jt,{children:t.jsx(wt,{children:l?"Edit Location":"Add New Location"})}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"name",children:"Location Name *"}),t.jsx(re,{id:"name",value:y.name,onChange:_=>v(H=>({...H,name:_.target.value})),placeholder:"e.g., SOUTHAMPTON CITY"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"postcodes",children:"Postcodes *"}),t.jsx(re,{id:"postcodes",value:y.postcodes,onChange:_=>v(H=>({...H,postcodes:_.target.value})),placeholder:"e.g., SO15 SO16 SO17"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"circulation",children:"Circulation *"}),t.jsx(re,{id:"circulation",type:"number",value:y.circulation,onChange:_=>v(H=>({...H,circulation:parseInt(_.target.value)||0})),placeholder:"10000"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"sort_order",children:"Sort Order"}),t.jsx(re,{id:"sort_order",type:"number",value:y.sort_order,onChange:_=>v(H=>({...H,sort_order:parseInt(_.target.value)||0}))})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{children:"Pricing Multipliers"}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"quarter_page_multiplier",className:"text-sm",children:"Quarter Page"}),t.jsx(re,{id:"quarter_page_multiplier",type:"number",step:"0.01",value:y.quarter_page_multiplier,onCh
770ange:_=>v(H=>({...H,quarter_page_multiplier:parseFloat(_.target.value)||1}))})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"half_page_multiplier",className:"text-sm",children:"Half Page"}),t.jsx(re,{id:"half_page_multiplier",type:"number",step:"0.01",value:y.half_page_multiplier,onChange:_=>v(H=>({...H,half_page_multiplier:parseFloat(_.target.value)||1}))})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"full_page_multiplier",className:"text-sm",children:"Full Page"}),t.jsx(re,{id:"full_page_multiplier",type:"number",step:"0.01",value:y.full_page_multiplier,onChange:_=>v(H=>({...H,full_page_multiplier:parseFloat(_.target.value)||1}))})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"base_price_multiplier",className:"text-sm",children:"Base Multiplier"}),t.jsx(re,{id:"base_price_multiplier",type:"number",step:"0.01",value:y.base_price_multiplier,onChange:_=>v(H=>({...H,base_price_multiplier:parseFloat(_.target.value)||1}))})]})]})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(kt,{id:"is_active",checked:y.is_active,onCheckedChange:_=>v(H=>({...H,is_active:_}))}),t.jsx(V,{htmlFor:"is_active",children:"Active"})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(V,{className:"text-base font-medium",children:"Monthly Schedule"}),t.jsxs(we,{variant:"outline",className:"text-xs",children:[y.schedule.length," months configured"]})]}),t.jsxs("div",{className:"space-y-3 max-h-96 overflow-y-auto border rounded-md p-4 bg-muted/20",children:[y.schedule.map((_,H)=>{const O=(z,Z,M)=>{if(z)try{if(z.includes(".")){const ee=V2(z,"dd.MM.yyyy",new Date);return isNaN(ee.getTime())?void 0:ee}const F=z.match(/\d+/);if(F){const ee=S.indexOf(M);if(ee===-1)return;const se=parseInt(F[0]),le=new Date(Z,ee,se);return isNaN(le.getTime())?void 0:le}return}catch{return}},U=O(_.copyDeadline,_.year,_.month),G=O(_.printDeadline,_.year,_.month),E=O(_.deliveryDate,_.year,_.month);return t.jsxs("div",{className:"bg-background rounded-lg border p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h4",{className:"text-sm font-semibold text-foreground",children:K3(_.month,_.year)}),t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>R(_.year,_.month),className:"h-8 w-8 p-0 hover:bg-destructive/10 hover:text-destructive",title:`Remove ${K3(_.month,_.year)}`,children:t.jsx(Es,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(V,{className:"text-xs font-medium text-muted-foreground",children:"Copy Deadline"}),t.jsxs(Cn,{children:[t.jsx(kn,{asChild:!0,children:t.jsxs(q,{variant:"outline",className:oe("w-full justify-start text-left font-normal text-sm h-9",!U&&"text-muted-foreground"),children:[t.jsx(It,{className:"mr-2 h-3.5 w-3.5"}),U?Dt(U,"dd.MM.yyyy"):"Pick date"]})}),t.jsx(en,{className:"w-auto p-0",align:"start",children:t.jsx(nc,{mode:"single",selected:U,onSelect:z=>{const Z=[...y.schedule];Z[H]={..._,copyDeadline:z?Dt(z,"dd.MM.yyyy"):""},v(M=>({...M,schedule:Z}))},initialFocus:!0,className:"pointer-events-auto"})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(V,{className:"text-xs font-medium text-muted-foreground",children:"Print Deadline"}),t.jsxs(Cn,{children:[t.jsx(kn,{asChild:!0,children:t.jsxs(q,{variant:"outline",className:oe("w-full justify-start text-left font-normal text-sm h-9",!G&&"text-muted-foreground"),children:[t.jsx(It,{className:"mr-2 h-3.5 w-3.5"}),G?Dt(G,"dd.MM.yyyy"):"Pick date"]})}),t.jsx(en,{className:"w-auto p-0",align:"start",children:t.jsx(nc,{mode:"single",selected:G,onSelect:z=>{const Z=[...y.schedule];Z[H]={..._,printDeadline:z?Dt(z,"dd.MM.yyyy"):""},v(M=>({...M,schedule:Z}))},initialFocus:!0,className:"pointer-events-auto"})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(V,{className:"text-xs font-medium text-muted-foreground",children:"Week Commencing"}),t.jsxs(Cn,{children:[t.jsx(kn,{asChild:!0,children:t.jsxs(q,{variant:"outline",className:oe("w-full justify-start text-left font-normal text-sm h-9",!E&&"text-muted-foreground"),children:[t.jsx(It,{className:"mr-2 h-3.5 w-3.5"}),E?Dt(E,"dd.MM.yyyy"):"Pick date"]})}),t.jsx(en,{className:"w-auto p-0",align:"start",children:t.jsx(nc,{mode:"single",selected:E,onSelect:z=>{const Z=[...y.schedule];Z[H]={..._,deliveryDate:z?Dt(z,"dd.MM.yyyy"):""},v(M=>({...M,schedule:Z}))},initialFocus:!0,className:"pointer-events-auto"})})]})]})]})]},`${_.year}-${_.month}`)}),y.schedule.length===0&&t.jsx("div",{className:"text-center py-4 text-gray-500 text-sm",children:"No dates configured. Add year-month combinations below."})]}),A().length>0&&t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsxs(ht,{onValueChange:_=>{const[H,O]=_.split("-");$(parseInt(H),O)},children:[t.jsxs(ut,{className:"w-48",children:[t.jsx(Xt,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"Add Date"})]}),t.jsx(mt,{children:A().map(_=>t.jsx(Pe,{value:`${_.year}-${_.month}`,children:_.label},`${_.year}-${_.month}`))})]}),t.jsxs("span",{className:"text-xs text-gray-500",children:[A().length," dates available"]})]}),A().length===0&&t.jsx("div",{className:"text-xs text-green-600 bg-green-50 p-2 rounded",children:"All available year-month combinations have been added to the schedule."})]}),t.jsxs("div",{className:"flex gap-2 pt-4",children:[t.jsxs(q,{onClick:I,className:"flex-1",children:[l?"Upd
770ate":"Create"," Location"]}),t.jsx(q,{variant:"outline",onClick:()=>o(!1),className:"flex-1",children:"Cancel"})]})]})]})]})]})]}),t.jsx(xe,{children:t.jsx(ge,{className:"p-4",children:t.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[t.jsx("div",{className:"flex-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),t.jsx(re,{placeholder:"Search locations or postcodes...",value:d,onChange:_=>m(_.target.value),className:"pl-10"})]})}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(ht,{value:h,onValueChange:f,children:[t.jsxs(ut,{className:"w-32",children:[t.jsx(mc,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Status"}),t.jsx(Pe,{value:"active",children:"Active"}),t.jsx(Pe,{value:"inactive",children:"Inactive"})]})]}),t.jsxs(ht,{value:p,onValueChange:x,children:[t.jsxs(ut,{className:"w-40",children:[t.jsx(YF,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"name",children:"Sort by Name"}),t.jsx(Pe,{value:"circulation",children:"Sort by Circulation"}),t.jsx(Pe,{value:"created_at",children:"Sort by Date"})]})]}),t.jsx(q,{variant:"outline",size:"sm",onClick:()=>b(g==="asc"?"desc":"asc"),children:g==="asc"?"â":"â"})]})]})})}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center justify-between",children:[t.jsxs("span",{children:["Locations (",D.length,")"]}),D.length>0&&t.jsxs(we,{variant:"outline",children:["Total Circulation: ",D.reduce((_,H)=>_+H.circulation,0).toLocaleString()]})]})}),t.jsx(ge,{children:D.length===0?t.jsxs("div",{className:"text-center py-8 text-gray-500",children:[t.jsx(_t,{className:"h-12 w-12 mx-auto mb-4 text-gray-300"}),t.jsx("p",{children:"No locations found."})]}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{className:"w-12",children:t.jsx("input",{type:"checkbox",checked:w.length===D.length,onChange:_=>{_.target.checked?j(D.map(H=>H.id)):j([])},className:"rounded"})}),t.jsx(ue,{children:"Name"}),t.jsx(ue,{children:"Postcodes"}),t.jsx(ue,{children:"Circulation"}),t.jsx(ue,{children:"Multipliers"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Date Added"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:D.map(_=>t.jsxs(Xe,{children:[t.jsx(de,{children:t.jsx("input",{type:"checkbox",checked:w.includes(_.id),onChange:H=>{H.target.checked?j(O=>[...O,_.id]):j(O=>O.filter(U=>U!==_.id))},className:"rounded"})}),t.jsx(de,{className:"font-medium",children:_.name}),t.jsx(de,{children:t.jsxs("div",{className:"flex flex-wrap gap-1",children:[_.postcodes.slice(0,3).map(H=>t.jsx(we,{variant:"outline",className:"text-xs",children:H},H)),_.postcodes.length>3&&t.jsxs(we,{variant:"outline",className:"text-xs",children:["+",_.postcodes.length-3]})]})}),t.jsx(de,{children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ua,{className:"h-4 w-4 text-gray-400"}),_.circulation.toLocaleString()]})}),t.jsx(de,{children:t.jsxs("div",{className:"text-xs space-y-1",children:[t.jsxs("div",{children:["1/4: ",_.quarter_page_multiplier,"x"]}),t.jsxs("div",{children:["1/2: ",_.half_page_multiplier,"x"]}),t.jsxs("div",{children:["Full: ",_.full_page_multiplier,"x"]})]})}),t.jsx(de,{children:t.jsx(we,{variant:_.is_active?"default":"secondary",className:_.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800",children:_.is_active?"Active":"Inactive"})}),t.jsx(de,{children:new Date(_.created_at).toLocaleDateString()}),t.jsx(de,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(q,{variant:"outline",size:"sm",onClick:()=>Y(_),children:t.jsx(Jr,{className:"h-4 w-4"})}),t.jsxs(ia,{children:[t.jsx(Li,{asChild:!0,children:t.jsx(q,{variant:"destructive",size:"sm",children:t.jsx(cs,{className:"h-4 w-4"})})}),t.jsxs(Fn,{children:[t.jsxs(Ln,{children:[t.jsx(zn,{children:"Delete Location"}),t.jsxs(Un,{children:['Are you sure you want to delete "',_.name,'"? This action cannot be undone.']})]}),t.jsxs(Bn,{children:[t.jsx(oa,{children:"Cancel"}),t.jsx(Vn,{onClick:()=>C(_.id),className:"bg-red-600 hover:bg-red-700",children:"Delete"})]})]})]})]})})]},_.id))})]})})})]})]})},Foe=({onStatsUpdate:e})=>{var P,B,Y;const[s,r]=u.useState([]),[n,a]=u.useState(!0),[i,o]=u.useState(!1),[l,c]=u.useState(null),[d,m]=u.useState({name:"",dimensions:"",base_price_per_area:0,base_price_per_month:0,design_fee:95,design_fee_subscription:45,fixed_pricing_per_issue:{},subscription_pricing_per_issue:{},available_for:["fixed","subscription"],is_active:!0,sort_order:0}),[h,f]=u.useState({percentage:0,type:"increase"}),{toast:p}=rt(),x=sie(),{invalidateSpecific:g}=ON(),[b,w]=u.useState({});u.useEffect(()=>{y(),j()},[]);const j=async()=>{try{const{data:I}=await W.from("ad_sizes").select("id").limit(1);if(I&&I.length===0){const C=Ooe.map((D,_)=>({name:D.label,dimensions:D.dimensions,base_price_per_area:D.areaPricing.perArea[0],base_price_per_month:D.areaPricing.perMonth[0],is_active:!0,sort_order:_+1})),{error:L}=await W.from("ad_sizes").insert(C);L?console.error("Error initializing default ad sizes:",L):(p({title:"Default Ad Sizes Imported",description:`Successfully imported ${C.length} default ad sizes.`}),y())}}catch(I){console.error("Error initializing default ad sizes:",I)}},y=async()=>{try{const{data:I,error:C}=await W.from("ad_sizes").select("*").order("sort_order",{ascending:!0});if(C)throw C;const L=(I||[]).map(D=>({...D,fixed_pricing_per_issue:typeof D.fixed_pricing_per_issue=="string"?JSON.parse(D.fixed_pricing_per_issue||"{}"):D.fixed_pricing_per_issue||{},subscription_pricing_per_issue:typeof D.subscription_pricing_per_issue=="string"?JSON.parse(D.subscription_pricing_per_issue||"{}"):D.subscription_pricing_per_issue||{},available_for:Array.isArray(D.available_for)?D.available_for:typeof D.available_for=="string"?JSON.parse(D.available_for||'["fixed", "subscription"]'):["fixed","subscription"]}));r(L),e&&e()}catch(I){console.error("Error loading ad sizes:",I),p({title:"Error",description:"Failed to load ad sizes.",variant:"destructive"})}finally{a(!1)}},v=()=>{m({name:"",dimensions:"",base_price_per_area:0,base_price_per_month:0,design_fee:95,design_fee_subscription:45,fixed_pricing_per_issue:{},subscription_pricing_per_issue:{},available_for:["fixed","subscription"],is_active:!0,sort_order:s.length+1}),c(null)},N=I=>{I?(c(I),m({name:I.name,dimensions:I.dimensions,base_price_per_area:I.base_price_per_area,base_price_per_month:I.base_price_per_month,design_fee:I.design_fee||95,design_fee_subscription:I.design_fee_subscription||45,fixed_pricing_per_issue:I.fixed_pricing_per_issue||{},subscription_pricing_per_issue:I.subscription_pricing_per_issue||{},available_for:I.available_for||["fixed","subscription"],is_active:I.is_active,sort_order:I.sort_order})):v(),o(!0)},S=async()=>{try{if(!d.name||!d.dimensions){p({title:"Validation Error",description:"Name and dimensions are required.",variant:"destructive"});return}if(d.base_price_per_area<=0&&d.base_price_per_month<=0){p({title:"Validation Error",description:"At least one base price (fixed or subscription) must be greater than 0.",variant:"destructive"});return}const I={...d,base_price_per_area:Number(d.base_price_per_area),base_price_per_month:Number(d.base_price_per_month),sort_order:Number(d.sort_order)};let C;if(l){const{error:L}=await W.from("ad_sizes").update(I).eq("id",l.id);C=L}else{const{error:L}=await W.from("ad_sizes").insert([I]);C=L}if(C)throw C;p({title:"Success",description:`Ad size ${l?"updated":"created"} successfully. ${l?"":"Configure area-count pricing in Issue-Based Pricing section."}`}),o(!1),v(),await y(),g("adSizes")}catch(I){console.error("Error saving ad size:",I),p({title:"Error",description:I.message||"Failed to save ad size.",variant:"destructive"})}},k=async I=>{try{const{error:C}=await W.from("ad_sizes").delete().eq("id",I);if(C)throw C;p({title:"Success",description:"Ad size deleted successfully."}),await y(),g("adSizes")}catch(C){console.error("Error deleting ad size:",C),p({title:"Error",description:C.message||"Failed to delete ad size.",variant:"destructive"})}},$=async()=>
770{if(h.percentage!==0)try{const I=h.type==="increase"?1+h.percentage/100:1-h.percentage/100,C=s.map(L=>({id:L.id,base_price_per_area:Math.round(L.base_price_per_area*I*100)/100,base_price_per_month:Math.round(L.base_price_per_month*I*100)/100}));for(const L of C){const{error:D}=await W.from("ad_sizes").update({base_price_per_area:L.base_price_per_area,base_price_per_month:L.base_price_per_month}).eq("id",L.id);if(D)throw D}p({title:"Success",description:`All prices ${h.type}d by ${h.percentage}% successfully.`}),f({percentage:0,type:"increase"}),await y(),g("adSizes")}catch(I){console.error("Error adjusting prices:",I),p({title:"Error",description:I.message||"Failed to adjust prices.",variant:"destructive"})}},R=()=>{const I=`data:text/csv;charset=utf-8,Name,Dimensions,Fixed Price,Subscription Price,Status 771`+s.map(D=>`"${D.name}","${D.dimensions}",${D.base_price_per_area},${D.base_price_per_month},${D.is_active?"Active":"Inactive"}`).join(` 772`),C=encodeURI(I),L=document.createElement("a");L.setAttribute("href",C),L.setAttribute("download","ad-sizes-pricing.csv"),document.body.appendChild(L),L.click(),document.body.removeChild(L)},A=(I,C,L)=>{const D=s.find(H=>H.id===I);if(!D)return;const _={...D,[C]:L};r(H=>H.map(O=>O.id===I?_:O)),w(H=>({...H,[I]:_}))},T=async I=>{try{const C=b[I]||s.find(L=>L.id===I);if(!C)return;await x.mutateAsync({adSizeId:I,fixedPricing:C.fixed_pricing_per_issue,subscriptionPricing:C.subscription_pricing_per_issue}),w(L=>{const D={...L};return delete D[I],D}),await y()}catch{}};return n?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("div",{className:"text-center",children:"Loading ad sizes..."})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-between items-start sm:items-center",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-xl font-heading font-bold text-community-navy flex items-center gap-2",children:[t.jsx(Sd,{className:"h-5 w-5"}),"Ad Sizes & Pricing Management"]}),t.jsx("p",{className:"text-sm text-gray-600 mt-1",children:"Manage advertisement sizes and their pricing structure"})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(q,{variant:"outline",size:"sm",onClick:R,children:[t.jsx(ei,{className:"h-4 w-4 mr-1"}),"Export CSV"]}),t.jsxs(bt,{open:i,onOpenChange:o,children:[t.jsx(Sn,{asChild:!0,children:t.jsxs(q,{onClick:()=>N(),children:[t.jsx(Xt,{className:"h-4 w-4 mr-1"}),"Add Ad Size"]})}),t.jsxs(xt,{className:"max-w-lg",children:[t.jsx(jt,{children:t.jsx(wt,{children:l?"Edit Ad Size":"Add New Ad Size"})}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"name",children:"Ad Size Name *"}),t.jsx(re,{id:"name",value:d.name,onChange:I=>m(C=>({...C,name:I.target.value})),placeholder:"e.g., Full Page"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"dimensions",children:"Dimensions *"}),t.jsx(re,{id:"dimensions",value:d.dimensions,onChange:I=>m(C=>({...C,dimensions:I.target.value})),placeholder:"e.g., 132 x 190"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"base_price_per_area",children:"Fixed Price (£)"}),t.jsx(re,{id:"base_price_per_area",type:"number",step:"0.01",value:d.base_price_per_area,onChange:I=>m(C=>({...C,base_price_per_area:parseFloat(I.target.value)||0}))})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"base_price_per_month",children:"Subscription Price (£)"}),t.jsx(re,{id:"base_price_per_month",type:"number",step:"0.01",value:d.base_price_per_month,onChange:I=>m(C=>({...C,base_price_per_month:parseFloat(I.target.value)||0}))})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"design_fee",children:"Fixed Design Fee (£ + VAT)"}),t.jsx(re,{id:"design_fee",type:"number",step:"0.01",value:d.design_fee||0,onChange:I=>m(C=>({...C,design_fee:parseFloat(I.target.value)||0})),placeholder:"e.g., 95.00"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Design fee for Fixed Term bookings"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"design_fee_subscription",children:"3+ Subscription Design Fee (£ + VAT)"}),t.jsx(re,{id:"design_fee_subscription",type:"number",step:"0.01",value:d.design_fee_subscription||0,onChange:I=>m(C=>({...C,design_fee_subscription:parseFloat(I.target.value)||0})),placeholder:"e.g., 45.00"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Design fee for 3+ Subscription bookings"})]})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"sort_order",children:"Sort Order"}),t.jsx(re,{id:"sort_order",type:"number",value:d.sort_order,onChange:I=>m(C=>({...C,sort_order:parseInt(I.target.value)||0}))})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(V,{children:"Available For"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("input",{type:"checkbox",id:"fixed_available",checked:d.available_for.includes("fixed"),onChange:I=>{I.target.checked?m(C=>({...C,available_for:[...C.available_for.filter(L=>L!=="fixed"),"fixed"]})):m(C=>({...C,available_for:C.available_for.filter(L=>L!=="fixed")}))},className:"rounded"}),t.jsx(V,{htmlFor:"fixed_available",className:"text-sm font-normal",children:"Fixed Pricing"})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("input",{type:"checkbox",id:"subscription_available",checked:d.available_for.includes("subscription"),onChange:I=>{I.target.checked?m(C=>({...C,available_for:[...C.available_for.filter(L=>L!=="subscription"),"subscription"]})):m(C=>({...C,available_for:C.available_for.filter(L=>L!=="subscription")}))},className:"rounded"}),t.jsx(V,{htmlFor:"subscription_available",className:"text-sm font-normal",children:"Subscription Pricing"})]})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which pricing types this ad size should be available for"})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(kt,{id:"is_active",checked:d.is_active,onCheckedChange:I=>m(C=>({...C,is_active:I}
772))}),t.jsx(V,{htmlFor:"is_active",children:"Active"})]}),t.jsxs("div",{className:"flex gap-2 pt-4",children:[t.jsxs(q,{onClick:S,className:"flex-1",children:[l?"Update":"Create"," Ad Size"]}),t.jsx(q,{variant:"outline",onClick:()=>o(!1),className:"flex-1",children:"Cancel"})]})]})]})]})]})]}),t.jsxs(ha,{defaultValue:"current",className:"space-y-6",children:[t.jsxs(Hn,{children:[t.jsx(Rt,{value:"current",children:"Current Ad Sizes"}),t.jsx(Rt,{value:"issues",children:"Issue-Based Pricing"}),t.jsx(Rt,{value:"bulk",children:"Bulk Price Tools"}),t.jsx(Rt,{value:"import",children:"Import/Export"})]}),t.jsx(Mt,{value:"current",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center justify-between",children:[t.jsxs("span",{children:["Ad Sizes (",s.length,")"]}),t.jsxs(we,{variant:"outline",children:["Avg Fixed: £",s.length>0?Math.round(s.reduce((I,C)=>I+C.base_price_per_area,0)/s.length):0]})]})}),t.jsx(ge,{children:s.length===0?t.jsxs("div",{className:"text-center py-8 text-gray-500",children:[t.jsx(Sd,{className:"h-12 w-12 mx-auto mb-4 text-gray-300"}),t.jsx("p",{children:"No ad sizes found."})]}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Name"}),t.jsx(ue,{children:"Dimensions"}),t.jsx(ue,{children:"Fixed Price"}),t.jsx(ue,{children:"Subscription Price"}),t.jsx(ue,{children:"Available For"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Order"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:s.map(I=>{var C,L;return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:I.name}),t.jsx(de,{children:I.dimensions}),t.jsxs(de,{children:["£",I.base_price_per_area.toFixed(2)]}),t.jsxs(de,{children:["£",I.base_price_per_month.toFixed(2)]}),t.jsx(de,{children:t.jsxs("div",{className:"flex gap-1",children:[((C=I.available_for)==null?void 0:C.includes("fixed"))&&t.jsx(we,{variant:"outline",className:"text-xs",children:"Fixed"}),((L=I.available_for)==null?void 0:L.includes("subscription"))&&t.jsx(we,{variant:"outline",className:"text-xs",children:"Subscription"})]})}),t.jsx(de,{children:t.jsx(we,{variant:I.is_active?"default":"secondary",className:I.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800",children:I.is_active?"Active":"Inactive"})}),t.jsx(de,{children:I.sort_order}),t.jsx(de,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(q,{variant:"outline",size:"sm",onClick:()=>N(I),children:t.jsx(Jr,{className:"h-4 w-4"})}),t.jsxs(ia,{children:[t.jsx(Li,{asChild:!0,children:t.jsx(q,{variant:"destructive",size:"sm",children:t.jsx(cs,{className:"h-4 w-4"})})}),t.jsxs(Fn,{children:[t.jsxs(Ln,{children:[t.jsx(zn,{children:"Delete Ad Size"}),t.jsxs(Un,{children:['Are you sure you want to delete "',I.name,'"? This action cannot be undone.']})]}),t.jsxs(Bn,{children:[t.jsx(oa,{children:"Cancel"}),t.jsx(Vn,{onClick:()=>k(I.id),className:"bg-red-600 hover:bg-red-700",children:"Delete"})]})]})]})]})})]},I.id)})})]})})})]})}),t.jsx(Mt,{value:"issues",children:t.jsxs(xe,{children:[t.jsxs(Me,{children:[t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(Sd,{className:"h-5 w-5"}),"Issue-Based Pricing Management"]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure pricing for each ad size based on number of issues. Click to expand each section."})]}),t.jsx(ge,{children:t.jsx(Ru,{type:"single",collapsible:!0,className:"w-full",children:s.map(I=>t.jsxs(ti,{value:I.id,className:"border rounded-lg mb-4 last:mb-0",children:[t.jsx(si,{className:"px-6 py-4 hover:no-underline bg-muted/50 rounded-t-lg data-[state=open]:rounded-b-none",children:t.jsxs("div",{className:"flex items-center justify-between w-full",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"font-semibold text-lg",children:I.name}),t.jsx(we,{variant:"outline",className:"bg-background",children:I.dimensions})]}),t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsxs("span",{children:["Fixed: £",I.base_price_per_area.toFixed(2)]}),t.jsx("span",{children:"â¢"}),t.jsxs("span",{children:["Subscription: £",I.base_price_per_month.toFixed(2)]})]})]})}),t.jsxs(ri,{className:"px-6 pb-6 pt-2 bg-background rounded-b-lg",children:[t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs("h3",{className:"text-lg font-semibold text-community-navy flex items-center gap-2",children:["Fixed Rates",t.jsx(we,{variant:"secondary",className:"text-xs",children:"One-time booking"})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{className:"text-sm",children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{className:"w-20",children:"Issues"}),t.jsx(ue,{children:"Per Issue (£)"})]})}),t.jsx(Wt,{children:Array.from({length:14},(C,L)=>L+1).map(C=>{var D;const L=((D=I.fixed_pricing_per_issue)==null?void 0:D[C.toString()])||0;return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:C}),t.jsx(de,{children:t.jsx(re,{type:"number",step:"0.01",value:L,onChange:_=>{const H=parseFloat(_.target.value)||0,O={...I.fixed_pricing_per_issue,[C.toString()]:H};A(I.id,"fixed_pricing_per_issue",O)},className:"w-full h-8"})})]},`fixed-${C}`)})})]})})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("h3",{className:"text-lg font-semibold text-community-navy flex items-center gap-2",children:["Subscription Rates",t.jsx(we,{variant:"secondary",className:"text-xs",children:"Monthly subscription"})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{className:"text-sm",children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{className:"w-20",children:"Issues"}),t.jsx(ue,{children:"Per Issue (£)"})]})}),t.jsx(Wt,{children:Array.from({length:14},(C,L)=>L+1).map(C=>{var D;const L=((D=I.subscription_pricing_per_issue)==null?void 0:D[C.toString()])||0;return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:C}),t.jsx(de,{children:t.jsx(re,{type:"number",step:"0.01",value:L,onChange:_=>{const H=parseFloat(_.target.value)||0,O={...I.subscription_pricing_per_issue,[C.toString()]:H};A(I.id,"subscription_pricing_per_issue",O)},className:"w-full h-8"})})]},`subscription-${C}`)})})]})})]})]}),t.jsx("div",{className:"mt-6 pt-4 border-t",children:t.jsxs(q,{onClick:()=>T(I.id),className:"w-full",variant:b[I.id]?"default":"outline",children:[b[I.id]?"Save Changes":"No Changes"," - ",I.name," Pricing"]})})]})]},I.id))})})]})}),t.jsx(Mt,{value:"bulk",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(lL,{className:"h-5 w-5"}),"Bulk Price Adjustment"]})}),t.jsxs(ge,{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-gray-600",children:"Apply percentage increases or decreases to all ad size prices at once."}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"adjustment_type",children:"Adjustment Type"}
772),t.jsxs("select",{id:"adjustment_type",className:"w-full p-2 border rounded-md",value:h.type,onChange:I=>f(C=>({...C,type:I.target.value})),children:[t.jsx("option",{value:"increase",children:"Increase"}),t.jsx("option",{value:"decrease",children:"Decrease"})]})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"adjustment_percentage",children:"Percentage (%)"}),t.jsx(re,{id:"adjustment_percentage",type:"number",step:"0.1",value:h.percentage,onChange:I=>f(C=>({...C,percentage:parseFloat(I.target.value)||0})),placeholder:"e.g., 5.0"})]}),t.jsx("div",{className:"flex items-end",children:t.jsxs(q,{onClick:$,disabled:h.percentage===0,className:"w-full",children:["Apply ",h.type==="increase"?"Increase":"Decrease"]})})]}),h.percentage>0&&t.jsx("div",{className:"p-4 bg-blue-50 rounded-lg",children:t.jsxs("p",{className:"text-sm text-blue-800",children:[t.jsx("strong",{children:"Preview:"})," All prices will be ",h.type,"d by ",h.percentage,"%.",s.length>0&&t.jsxs("span",{children:[" ","For example, £",(B=(P=s[0])==null?void 0:P.base_price_per_area)==null?void 0:B.toFixed(2)," will become £",(((Y=s[0])==null?void 0:Y.base_price_per_area)*(h.type==="increase"?1+h.percentage/100:1-h.percentage/100)).toFixed(2),"."]})]})})]})]})}),t.jsx(Mt,{value:"import",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(sn,{className:"h-5 w-5"}),"Import/Export Tools"]})}),t.jsx(ge,{className:"space-y-4",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"font-medium",children:"Export Current Pricing"}),t.jsx("p",{className:"text-sm text-gray-600",children:"Download current ad sizes and pricing as CSV for backup or analysis."}),t.jsxs(q,{variant:"outline",onClick:R,className:"w-full",children:[t.jsx(ei,{className:"h-4 w-4 mr-2"}),"Export to CSV"]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"font-medium",children:"Import from Excel Data"}),t.jsx("p",{className:"text-sm text-gray-600",children:"Reset to default pricing from the uploaded Excel sheet."}),t.jsxs(q,{variant:"outline",onClick:()=>{p({title:"Feature Coming Soon",description:"Excel import functionality will be available in the next update."})},className:"w-full",children:[t.jsx(sn,{className:"h-4 w-4 mr-2"}),"Import from Excel"]})]})]})})]})})]})]})},Q3=()=>({code:"",description:"",discount_type:"percentage",discount_value:"",free_item_text:"",applies_to_subscription:!0,applies_to_fixed_term:!0,applies_to_leaflets:!0,single_use_per_email:!1,valid_from:null,valid_until:null,is_active:!0}),Loe={percentage:"Percentage",fixed_amount:"Fixed amount",free_item:"Free item"};function Boe(e){return e.valid_until&&new Date(e.valid_until)<new Date?"expired":e.is_active?"active":"inactive"}function zoe(e){return e.discount_type==="percentage"?`${e.discount_value??0}%`:e.discount_type==="fixed_amount"?`£${Number(e.discount_value??0).toFixed(2)}`:e.free_item_text||"â"}function Uoe(e){const s=e.valid_from?Dt(new Date(e.valid_from),"d MMM yyyy"):"â",r=e.valid_until?Dt(new Date(e.valid_until),"d MMM yyyy"):"â";return`${s} â ${r}`}function Voe(){const{toast:e}=rt(),[s,r]=u.useState([]),[n,a]=u.useState(!0),[i,o]=u.useState(!1),[l,c]=u.useState(null),[d,m]=u.useState(Q3()),[h,f]=u.useState(!1),[p,x]=u.useState(null),g=async()=>{a(!0);const{data:v,error:N}=await W.from("discount_codes").select("*").order("created_at",{ascending:!1});N?e({title:"Error",description:N.message,variant:"destructive"}):r(v||[]),a(!1)};u.useEffect(()=>{g()},[]);const b=()=>{c(null),m(Q3()),o(!0)},w=v=>{c(v),m({code:v.code,description:v.description??"",discount_type:v.discount_type,discount_value:v.discount_value!=null?String(v.discount_value):"",free_item_text:v.free_item_text??"",applies_to_subscription:v.applies_to_subscription,applies_to_fixed_term:v.applies_to_fixed_term,applies_to_leaflets:v.applies_to_leaflets,single_use_per_email:v.single_use_per_email,valid_from:v.valid_from?new Date(v.valid_from):null,valid_until:v.valid_until?new Date(v.valid_until):null,is_active:v.is_active}),o(!0)},j=async()=>{const v=d.code.trim().toUpperCase();if(!v){e({title:"Code is required",variant:"destructive"});return}if(d.discount_type==="free_item"&&!d.free_item_text.trim()){e({title:"Free item text is required",variant:"destructive"});return}if(d.discount_type!=="free_item"){const k=Number(d.discount_value);if(!d.discount_value||Number.isNaN(k)||k<0){e({title:"Enter a valid value",variant:"destructive"});return}if(d.discount_type==="percentage"&&k>100){e({title:"Percentage must be 0â100",variant:"destructive"});return}}if(!d.applies_to_subscription&&!d.applies_to_fixed_term&&!d.applies_to_leaflets){e({title:"Select at least one product",variant:"destructive"});return}const N={code:v,description:d.description.trim()||null,discount_type:d.discount_type,discount_value:d.discount_type==="free_item"?
7720:Number(d.discount_value),free_item_text:d.discount_type==="free_item"?d.free_item_text.trim():null,applies_to_subscription:d.applies_to_subscription,applies_to_fixed_term:d.applies_to_fixed_term,applies_to_leaflets:d.applies_to_leaflets,single_use_per_email:d.single_use_per_email,valid_from:d.valid_from?d.valid_from.toISOString():null,valid_until:d.valid_until?d.valid_until.toISOString():null,is_active:d.is_active};f(!0);const{error:S}=l?await W.from("discount_codes").update(N).eq("id",l.id):await W.from("discount_codes").insert(N);if(f(!1),S){e({title:"Save failed",description:S.message,variant:"destructive"});return}e({title:l?"Discount code updated":"Discount code created"}),o(!1),g()},y=async()=>{if(!p)return;const{error:v}=await W.from("discount_codes").delete().eq("id",p.id);v?e({title:"Delete failed",description:v.message,variant:"destructive"}):(e({title:"Discount code deleted"}),g()),x(null)};return t.jsxs(xe,{children:[t.jsxs(Me,{className:"flex flex-row items-center justify-between",children:[t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(Pw,{className:"h-5 w-5"}),"Discount Codes"]}),t.jsxs(q,{onClick:b,size:"sm",children:[t.jsx(Xt,{className:"h-4 w-4 mr-2"}),"New discount code"]})]}),t.jsx(ge,{children:n?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):s.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No discount codes yet."}):t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Code"}),t.jsx(ue,{children:"Type"}),t.jsx(ue,{children:"Value"}),t.jsx(ue,{children:"Validity"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{className:"text-right",children:"Actions"})]})}),t.jsx(Wt,{children:s.map(v=>{const N=Boe(v);return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-mono font-semibold",children:v.code}),t.jsx(de,{children:t.jsx(we,{variant:"outline",children:Loe[v.discount_type]})}),t.jsx(de,{children:zoe(v)}),t.jsx(de,{className:"text-sm",children:Uoe(v)}),t.jsx(de,{children:t.jsx(we,{variant:N==="active"?"default":N==="expired"?"destructive":"secondary",children:N==="active"?"Active":N==="expired"?"Expired":"Inactive"})}),t.jsxs(de,{className:"text-right",children:[t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>w(v),children:t.jsx(Jr,{className:"h-4 w-4"})}),t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>x(v),children:t.jsx(cs,{className:"h-4 w-4"})})]})]},v.id)})})]})}),t.jsx(bt,{open:i,onOpenChange:o,children:t.jsxs(xt,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[t.jsx(jt,{children:t.jsx(wt,{children:l?"Edit discount code":"New discount code"})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"code",children:"Code"}),t.jsx(re,{id:"code",value:d.code,onChange:v=>m({...d,code:v.target.value.toUpperCase()}),placeholder:"SUMMER25",className:"font-mono"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"description",children:"Description"}),t.jsx(ms,{id:"description",value:d.description,onChange:v=>m({...d,description:v.target.value}),rows:2})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Deal type"}),t.jsxs(ht,{value:d.discount_type,onValueChange:v=>m({...d,discount_type:v}),children:[t.jsx(ut,{children:t.jsx(ft,{})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"percentage",children:"Percentage"}),t.jsx(Pe,{value:"fixed_amount",children:"Fixed amount"}),t.jsx(Pe,{value:"free_item",children:"Free item"})]})]})]}),d.discount_type!=="free_item"&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs(V,{htmlFor:"value",children:["Value ",d.discount_type==="percentage"?"(%)":"(£)"]}),t.jsx(re,{id:"value",type:"number",min:0,max:d.discount_type==="percentage"?100:void 0,step:d.discount_type==="percentage"?1:.01,value:d.discount_value,onChange:v=>m({...d,discount_value:v.target.value})})]})]}),d.discount_type==="free_item"&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"free_item_text",children:"Free item text"}),t.jsx(re,{id:"free_item_text",value:d.free_item_text,onChange:v=>m({...d,free_item_text:v.target.value}),placeholder:"Free 1/8 page upgrade"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Applies to"}),t.jsx("div",{className:"flex flex-col gap-2",children:[["applies_to_subscription","3+ Subscription"],["applies_to_fixed_term","Fixed-term (Pay As You Go)"],["applies_to_leaflets","Leaflet Distribution"]].map(([v,N])=>t.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[t.jsx(Kt,{checked:d[v],onCheckedChange:S=>m({...d,[v]:!!S})}),N]},v))})]}),t.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"single_use",children:"Single use per email"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Each email may redeem once."})]}),t.jsx(kt,{id:"single_use",checked:d.single_use_per_email,onCheckedChange:v=>m({...d,single_use_per_email:v})})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsx(X3,{label:"Valid from",value:d.valid_from,onChange:v=>m({...d,valid_from:v})}
772),t.jsx(X3,{label:"Valid until",value:d.valid_until,onChange:v=>m({...d,valid_until:v})})]}),t.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3",children:[t.jsx(V,{htmlFor:"active",children:"Active"}),t.jsx(kt,{id:"active",checked:d.is_active,onCheckedChange:v=>m({...d,is_active:v})})]})]}),t.jsxs(ma,{children:[t.jsx(q,{variant:"outline",onClick:()=>o(!1),disabled:h,children:"Cancel"}),t.jsx(q,{onClick:j,disabled:h,children:h?"Savingâ¦":l?"Save changes":"Create code"})]})]})}),t.jsx(ia,{open:!!p,onOpenChange:v=>!v&&x(null),children:t.jsxs(Fn,{children:[t.jsxs(Ln,{children:[t.jsx(zn,{children:"Delete discount code?"}),t.jsx(Un,{children:p?`Code "${p.code}" will be permanently removed.`:""})]}),t.jsxs(Bn,{children:[t.jsx(oa,{children:"Cancel"}),t.jsx(Vn,{onClick:y,children:"Delete"})]})]})})]})}function X3({label:e,value:s,onChange:r}){return t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:e}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(Cn,{children:[t.jsx(kn,{asChild:!0,children:t.jsxs(q,{variant:"outline",className:oe("flex-1 justify-start text-left font-normal",!s&&"text-muted-foreground"),children:[t.jsx(It,{className:"mr-2 h-4 w-4"}),s?Dt(s,"PPP"):"Pick a date"]})}),t.jsx(en,{className:"w-auto p-0",align:"start",children:t.jsx(nc,{mode:"single",selected:s??void 0,onSelect:n=>r(n??null),initialFocus:!0,className:oe("p-3 pointer-events-auto")})})]}),s&&t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>r(null),children:"Clear"})]})]})}const qoe={percentage:"Percentage",fixed_amount:"Fixed amount",free_item:"Free item"};function Hoe(e){return e.valid_until&&new Date(e.valid_until)<new Date?"expired":e.is_active?"active":"inactive"}function Z3(e){return`£${Number(e??0).toFixed(2)}`}function Woe(){const{toast:e}=rt(),[s,r]=u.useState([]),[n,a]=u.useState(!0);return u.useEffect(()=>{(async()=>{a(!0);const{data:i,error:o}=await W.from("discount_code_report").select("*").order("times_used",{ascending:!1});o?e({title:"Error",description:o.message,variant:"destructive"}):r(i||[]),a(!1)})()},[e]),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(wf,{className:"h-5 w-5"}),"Discount Codes Reporting"]})}),t.jsx(ge,{children:n?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):s.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No data yet."}):t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Code"}),t.jsx(ue,{children:"Type"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{className:"text-right",children:"Times Used"}),t.jsx(ue,{className:"text-right",children:"Total Booking Value (£)"}),t.jsx(ue,{className:"text-right",children:"Total Discount Given (£)"}),t.jsx(ue,{children:"Last Used"})]})}),t.jsx(Wt,{children:s.map(i=>{const o=Hoe(i);return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-mono font-semibold",children:i.code??"â"}),t.jsx(de,{children:t.jsx(we,{variant:"outline",children:i.discount_type?qoe[i.discount_type]??i.discount_type:"â"})}),t.jsx(de,{children:t.jsx(we,{variant:o==="active"?"default":o==="expired"?"destructive":"secondary",children:o==="active"?"Active":o==="expired"?"Expired":"Inactive"})}),t.jsx(de,{className:"text-right",children:i.times_used??0}),t.jsx(de,{className:"text-right",children:Z3(i.total_booking_value)}),t.jsx(de,{className:"text-right",children:Z3(i.total_discount_given)}),t.jsx(de,{className:"text-sm",children:i.last_used_at?Dt(new Date(i.last_used_at),"d MMM yyyy"):"â"})]},i.id??i.code??Math.random().toString())})})]})})]})}const Goe=({onStatsUpdate:e})=>{const[s,r]=u.useState([]),[n,a]=u.useState([]),[i,o]=u.useState([]),[l,c]=u.useState(!0),[d,m]=u.useState("durations"),[h,f]=u.useState(!1),[p,x]=u.useState(!1),[g,b]=u.useState(!1),[w,j]=u.useState(null),[y,v]=u.useState(null),[N,S]=u.useState(null),[k,$]=u.useState({name:"",duration_type:"subscription",duration_value:6,discount_percentage:0,is_active:!0,sort_order:0}),[R,A]=u.useState({min_areas:1,max_areas:5,discount_percentage:5,is_active:!0}),[T,P]=u.useState({option_type:"",display_name:"",description:"",discount_percentage:0,minimum_payments:6,additional_fee_percentage:0,is_active:!0,sort_order:0}),{toast:B}=rt();u.useEffect(()=>{Y()},[]);const Y=async()=>{try{const[M,F,ee]=await Promise.all([W.from("pricing_durations").select("*").order("sort_order"),W.from("volume_discounts").select("*").order("min_areas"),W.from("payment_options").select("*").order("sort_order")]);r(M.data||[]),a(F.data||[]),o(ee.data||[]),e()}catch(M){console.error("Error loading data:",M),B({title:"Error",description:"Failed to load subscription settings.",variant:"destructive"})}finally{c(!1)}},I=()=>{$({name:"",duration_type:"subscription",duration_value:6,discount_percentage:0,is_active:!0,sort_order:s.length+1}),j(null)},C=M=>{M?(j(M),$({name:M.name,duration_type:M.duration_type,duration_value:M.duration_value,discount_percentage:M.discount_percentage,is_active:M.is_active,sort_order:M.sort_order})):I(),f(!0)},L=async()=>{try{let M;if(w){const{error:F}=await W.from("pricing_durations").update(k).eq("id",w.id);M=F}else{const{error:F}=await W.from("pricing_durations").insert([k]);M=F}if(M)throw M;B({title:"Success",description:`Duration ${w?"updated":"created"} successfully.`}),f(!1),I(),Y()}catch(M){B({title:"Error",description:M.message||"Failed to save duration.",variant:"destructive"})}},D=async M=>{try{const{error:F}=await W.from("pricing_durations").delete().eq("id",M);if(F)throw F;B({title:"Success",description:"Duration deleted successfully."}),Y()}catch(F){B({title:"Error",description:F.message||"Failed to delete duration.",variant:"destructive"})}},_=()=>{A({min_areas:1,max_areas:5,discount_percentage:5,is_active:!0}),v(null)},H=M=>{M?(v(M),A({min_areas:M.min_areas,max_areas:M.max_areas||0,discount_percentage:M.discount_percentage,is_active:M.is_active})):_(),x(!0)},O=async()=>{try{let M;if(y){const{error:F}=await W.from("volume_discounts").update(R).eq("id",y.id);M=F}else{const{error:F}=await W.from("volume_discounts").insert([R]);M=F}if(M)throw M;B({title:"Success",description:`Volume discount ${y?"updated":"created"} successfully.`}),x(!1),_(),Y()}catch(M){B({title:"Error",description:M.message||"Failed to save volume discount.",variant:"destructive"})}},U=async M=>{try{const{error:F}=await W.from("volume_discounts").delete().eq("id",M);if(F)throw F;B({title:"Success",description:"Volume discount deleted successfully."}),Y()}catch(F){B({title:"Error",description:F.message||"Failed to delete volume discount.",variant:"destructive"})}},G=()=>{P({option_type:"",display_name:"",description:"",discount_percentage:0,minimum_payments:6,additional_fee_percentage:0,is_active:!0,sort_order:i.length+1}),S(null)},E=M=>{M?(S(M),P({option_type:M.option_type,display_name:M.display_name,description:M.description||"",discount_percentage:M.discount_percentage,minimum_payments:M.minimum_payments||6,additional_fee_percentage:M.additional_fee_percentage,is_active:M.is_active,sort_order:M.sort_order})):G(),b(!0)},z=async()=>{try{let M;if(N){const{error:F}=await W.from("payment_options").update(T).eq("id",N.id);M=F}else{const{error:F}=await W.from("payment_options").insert([T]);M=F}if(M)throw M;B({title:"Success",description:`Payment option ${N?"updated":"created"} successfully.`}),b(!1),G(),Y()}catch(M){B({title:"Error",description:M.message||"Failed to save payment option.",variant:"destructive"})}},Z=async M=>{try{const{error:F}=await W.from("payment_options").delete().eq("id",M);if(F)throw F;B({title:"Success",description:"Payment option deleted successfully."}),Y()}catch(F){B({title:"Error",description:F.message||"Failed to delete payment option.",variant:"destructive"})}};return l?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("div",{className:"text-center",children:"Loading subscription settings..."})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"flex flex-col sm:flex-row gap-4 justify-between items-start sm:items-center",children:t.jsxs("div",{children:[t.jsxs("h2",{className:"text-xl font-heading font-bold text-community-navy flex items-center gap-2",children:[t.jsx(ws,{className:"h-5 w-5"}),"Subscription Settings Management"]}),t.jsx("p",{className:"text-sm text-gray-600 mt-1",children:"Manage subscription durations, volume discounts, payment options, discount codes, and reporting"})]})}),t.jsxs(ha,{value:d,onValueChange:m,children:[t.jsxs(Hn,{className:"grid w-full grid-cols-5",children:[t.jsxs(Rt,{value:"durations",className:"flex items-center gap-2",children:[t.jsx(ws,{className:"h-4 w-4"}),"Durations"]}),t.jsxs(Rt,{value:"volume",className:"flex items-center gap-2",children:[t.jsx(rv,{className:"h-4 w-4"}),"Volume Discounts"]}),t.jsxs(Rt,{value:"payment",className:"flex items-center gap-2",children:[t.jsx(ci,{className:"h-4 w-4"}),"Payment Options"]}),t.jsxs(Rt,{value:"discountCodes",className:"flex items-center gap-2",children:[t.jsx(Pw,{className:"h-4 w-4"}),"Discount Codes"]}),t.jsxs(Rt,{value:"discountReporting",className:"flex items-center gap-2",children:[t.jsx(wf,{className:"h-4 w-4"}),"Reporting"]})]}),t.jsx(Mt,{value:"durations",className:"space-y-4",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center justify-between",children:[t.jsxs("span",{children:["Subscription Durations (",s.length,")"]}),t.jsxs(bt,{open:h,onOpenChange:f,children:[t.jsx(Sn,{asChild:!0,children:t.jsxs(q,{onClick:()=>C(),children:[t.jsx(Xt,{className:"h-4 w-4 mr-1"}),"Add Duration"]})}),t.jsxs(xt,{children:[t.jsx(jt,{children:t.jsx(wt,{children:w?"Edit Duration":"Add New Duration"})}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"duration_name",children:"Duration Name *"}),t.jsx(re,{id:"duration_name",value:k.name,onChange:M=>$(F=>({...F,name:M.target.value})),placeholder:"e.g., 6 Months"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"duration_type",children:"Type"}),t.jsxs("select",{id:"duration_type",className:"w-full p-2 border rounded-md",value:k.duration_type,onCh
772ange:M=>$(F=>({...F,duration_type:M.target.value})),children:[t.jsx("option",{value:"fixed",children:"Fixed (Issues)"}),t.jsx("option",{value:"subscription",children:"Subscription (Months)"})]})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"duration_value",children:"Value"}),t.jsx(re,{id:"duration_value",type:"number",value:k.duration_value,onChange:M=>$(F=>({...F,duration_value:parseInt(M.target.value)||0}))})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"duration_discount",children:"Discount (%)"}),t.jsx(re,{id:"duration_discount",type:"number",step:"0.1",value:k.discount_percentage,onChange:M=>$(F=>({...F,discount_percentage:parseFloat(M.target.value)||0}))})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"duration_sort",children:"Sort Order"}),t.jsx(re,{id:"duration_sort",type:"number",value:k.sort_order,onChange:M=>$(F=>({...F,sort_order:parseInt(M.target.value)||0}))})]})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(kt,{id:"duration_active",checked:k.is_active,onCheckedChange:M=>$(F=>({...F,is_active:M}))}),t.jsx(V,{htmlFor:"duration_active",children:"Active"})]}),t.jsxs("div",{className:"flex gap-2 pt-4",children:[t.jsxs(q,{onClick:L,className:"flex-1",children:[w?"Update":"Create"," Duration"]}),t.jsx(q,{variant:"outline",onClick:()=>f(!1),className:"flex-1",children:"Cancel"})]})]})]})]})]})}),t.jsx(ge,{children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Name"}),t.jsx(ue,{children:"Type"}),t.jsx(ue,{children:"Value"}),t.jsx(ue,{children:"Discount"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:s.map(M=>t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:M.name}),t.jsx(de,{children:t.jsx(we,{variant:"outline",children:M.duration_type==="subscription"?"Subscription":"Fixed"})}),t.jsxs(de,{children:[M.duration_value," ",M.duration_type==="subscription"?"months":"issues"]}),t.jsxs(de,{children:[M.discount_percentage,"%"]}),t.jsx(de,{children:t.jsx(we,{variant:M.is_active?"default":"secondary",className:M.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800",children:M.is_active?"Active":"Inactive"})}),t.jsx(de,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(q,{variant:"outline",size:"sm",onClick:()=>C(M),children:t.jsx(Jr,{className:"h-4 w-4"})}),t.jsxs(ia,{children:[t.jsx(Li,{asChild:!0,children:t.jsx(q,{variant:"destructive",size:"sm",children:t.jsx(cs,{className:"h-4 w-4"})})}),t.jsxs(Fn,{children:[t.jsxs(Ln,{children:[t.jsx(zn,{children:"Delete Duration"}),t.jsxs(Un,{children:['Are you sure you want to delete "',M.name,'"? This action cannot be undone.']})]}),t.jsxs(Bn,{children:[t.jsx(oa,{children:"Cancel"}),t.jsx(Vn,{onClick:()=>D(M.id),className:"bg-red-600 hover:bg-red-700",children:"Delete"})]})]})]})]})})]},M.id))})]})})]})}),t.jsx(Mt,{value:"volume",className:"space-y-4",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center justify-between",children:[t.jsxs("span",{children:["Volume Discounts (",n.length,")"]}),t.jsxs(bt,{open:p,onOpenChange:x,children:[t.jsx(Sn,{asChild:!0,children:t.jsxs(q,{onClick:()=>H(),children:[t.jsx(Xt,{className:"h-4 w-4 mr-1"}),"Add Volume Discount"]})}),t.jsxs(xt,{children:[t.jsx(jt,{children:t.jsx(wt,{children:y?"Edit Volume Discount":"Add New Volume Discount"})}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"min_areas",children:"Min Areas"}),t.jsx(re,{id:"min_areas",type:"number",value:R.min_areas,onChange:M=>A(F=>({...F,min_areas:parseInt(M.target.value)||0}))})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"max_areas",children:"Max Areas"}),t.jsx(re,{id:"max_areas",type:"number",value:R.max_areas,onChange:M=>A(F=>({...F,max_areas:parseInt(M.target.value)||0}))})]})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"volume_discount",children:"Discount (%)"}),t.jsx(re,{id:"volume_discount",type:"number",step:"0.1",value:R.discount_percentage,onChange:M=>A(F=>({...F,discount_percentage:parseFloat(M.target.value)||0}))})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(kt,{id:"volume_active",checked:R.is_active,onCheckedChange:M=>A(F=>({...F,is_active:M}))}),t.jsx(V,{htmlFor:"volume_active",children:"Active"})]}),t.jsxs("div",{className:"flex gap-2 pt-4",children:[t.jsxs(q,{onClick:O,className:"flex-1",children:[y?"Update":"Create"," Volume Discount"]}),t.jsx(q,{variant:"outline",onClick:()=>x(!1),className:"flex-1",children:"Cancel"})]})]})]})]})]})}),t.jsx(ge,{children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Area Range"}),t.jsx(ue,{children:"Discount"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:n.map(M=>t.jsxs(Xe,{children:[t.jsxs(de,{className:"font-medium",children:[M.min_areas," - ",M.max_areas||"â"," areas"]}),t.jsxs(de,{children:[M.discount_percentage,"%"]}),t.jsx(de,{children:t.jsx(we,{variant:M.is_active?"default":"secondary",className:M.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800",children:M.is_active?"Active":"Inactive"})}),t.jsx(de,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(q,{variant:"outline",size:"sm",onClick:()=>H(M),children:t.jsx(Jr,{className:"h-4 w-4"})}),t.jsxs(ia,{children:[t.jsx(Li,{asChild:!0,children:t.jsx(q,{variant:"destructive",size:"sm",children:t.jsx(cs,{className:"h-4 w-4"})})}),t.jsxs(Fn,{children:[t.jsxs(Ln,{children:[t.jsx(zn,{children:"Delete Volume Discount"}),t.jsx(Un,{children:"Are you sure you want to delete this volume discount? This action cannot be undone."})]}),t.jsxs(Bn,{children:[t.jsx(oa,{children:"Cancel"}),t.jsx(Vn,{onClick:()=>U(M.id),className:"bg-red-600 hover:bg-red-700",children:"Delete"})]})]})]})]})})]},M.id))})]})})]})}),t.jsx(Mt,{value:"payment",className:"space-y-4",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center justify-between",children:[t.jsxs("span",{children:["Payment Options (",i.length,")"]}),t.jsxs(bt,{open:g,onOpenChange:b,children:[t.jsx(Sn,{asChild:!0,children:t.jsxs(q,{onClick:()=>E(),children:[t.jsx(Xt,{className:"h-4 w-4 mr-1"}),"Add Payment Option"]})}),t.jsxs(xt,{className:"max-w-lg",children:[t.jsx(jt,{children:t.jsx(wt,{children:N?"Edit Payment Option":"Add New Payment Option"})}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"option_type",children:"Option Type *"}
772),t.jsx(re,{id:"option_type",value:T.option_type,onChange:M=>P(F=>({...F,option_type:M.target.value})),placeholder:"e.g., 6_months_full, 12_months_full, monthly"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"display_name",children:"Display Name *"}),t.jsx(re,{id:"display_name",value:T.display_name,onChange:M=>P(F=>({...F,display_name:M.target.value})),placeholder:"e.g., Pay in full for 6 months"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"description",children:"Description"}),t.jsx(re,{id:"description",value:T.description,onChange:M=>P(F=>({...F,description:M.target.value})),placeholder:"Optional description"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"discount_percentage",children:"Discount (%)"}),t.jsx(re,{id:"discount_percentage",type:"number",step:"0.1",value:T.discount_percentage,onChange:M=>P(F=>({...F,discount_percentage:parseFloat(M.target.value)||0}))})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"additional_fee_percentage",children:"Additional Fee (%)"}),t.jsx(re,{id:"additional_fee_percentage",type:"number",step:"0.1",value:T.additional_fee_percentage,onChange:M=>P(F=>({...F,additional_fee_percentage:parseFloat(M.target.value)||0}))})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"minimum_payments",children:"Minimum Payments"}),t.jsx(re,{id:"minimum_payments",type:"number",value:T.minimum_payments||"",onChange:M=>P(F=>({...F,minimum_payments:M.target.value?parseInt(M.target.value):0})),placeholder:"Leave empty if not applicable"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"sort_order",children:"Sort Order"}),t.jsx(re,{id:"sort_order",type:"number",value:T.sort_order,onChange:M=>P(F=>({...F,sort_order:parseInt(M.target.value)||0}))})]})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(kt,{id:"payment_active",checked:T.is_active,onCheckedChange:M=>P(F=>({...F,is_active:M}))}),t.jsx(V,{htmlFor:"payment_active",children:"Active"})]}),t.jsxs("div",{className:"flex gap-2 pt-4",children:[t.jsxs(q,{onClick:z,className:"flex-1",children:[N?"Update":"Create"," Payment Option"]}),t.jsx(q,{variant:"outline",onClick:()=>b(!1),className:"flex-1",children:"Cancel"})]})]})]})]})]})}),t.jsx(ge,{children:i.length===0?t.jsxs("div",{className:"text-center py-8 text-gray-500",children:[t.jsx(ci,{className:"h-12 w-12 mx-auto mb-4 text-gray-300"}),t.jsx("p",{children:"No payment options found."})]}):t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Display Name"}),t.jsx(ue,{children:"Type"}),t.jsx(ue,{children:"Discount"}),t.jsx(ue,{children:"Min Payments"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:i.map(M=>t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:M.display_name}),t.jsx(de,{children:t.jsx(we,{variant:"outline",children:M.option_type})}),t.jsx(de,{children:M.discount_percentage>0?`${M.discount_percentage}%`:M.additional_fee_percentage>0?`+${M.additional_fee_percentage}%`:M.additional_fee_percentage<0?`${M.additional_fee_percentage}%`:"None"}),t.jsx(de,{children:M.minimum_payments||"N/A"}),t.jsx(de,{children:t.jsx(we,{variant:M.is_active?"default":"secondary",className:M.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800",children:M.is_active?"Active":"Inactive"})}),t.jsx(de,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(q,{variant:"outline",size:"sm",onClick:()=>E(M),children:t.jsx(Jr,{className:"h-4 w-4"})}),t.jsxs(ia,{children:[t.jsx(Li,{asChild:!0,children:t.jsx(q,{variant:"destructive",size:"sm",children:t.jsx(cs,{className:"h-4 w-4"})})}),t.jsxs(Fn,{children:[t.jsxs(Ln,{children:[t.jsx(zn,{children:"Delete Payment Option"}),t.jsxs(Un,{children:['Are you sure you want to delete "',M.display_name,'"? This action cannot be undone.']})]}),t.jsxs(Bn,{children:[t.jsx(oa,{children:"Cancel"}),t.jsx(Vn,{onClick:()=>Z(M.id),className:"bg-red-600 hover:bg-red-700",children:"Delete"})]})]})]})]})})]},M.id))})]})})]})}),t.jsx(Mt,{value:"discountCodes",className:"space-y-4",children:t.jsx(Voe,{})}),t.jsx(Mt,{value:"discountReporting",className:"space-y-4",children:t.jsx(Woe,{})})]})]})},Zc=["January","February","March","April","May","June","July","August","September","October","November","December"],Yoe=[2025,2026,2027],Koe=({onStatsUpdate:e})=>{const[s,r]=u.useState("areas"),[n,a]=u.useState(null),[i,o]=u.useState(null),[l,c]=u.useState(!1),[d,m]=u.useState(!1),[h,f]=u.useState(!1),[p,x]=u.useState([]),{toast:g}=rt();Xs();const{data:b=[],isLoading:w,isError:j,refetch:y}=qf(),{data:v=[],isLoading:N,isError:S,refetch:k}=Hf(),$=b||[],R=v||[],A=w||N,T=j||S;u.useEffect(()=>{x(n?n.schedule||[]:[])},[n]);const P=(O,U)=>{const G=Zc.indexOf(U),E=new Date(O,G,15),z=new Date(O,G,25),Z={year:O,month:U,copyDeadline:Dt(E,"dd.MM.yyyy"),deliveryDate:Dt(z,"dd.MM.yyyy")},M=[...p,Z].sort((F,ee)=>F.year!==ee.year?F.year-ee.year:Zc.indexOf(F.month)-Zc.indexOf(ee.month));x(M)},B=(O,U)=>{const G=p.filter(E=>!(E.year===O&&E.month===U));x(G)},Y=()=>{const O=p.map(G=>`${G.year}-${G.month}`),U=[];return Yoe.forEach(G=>{Zc.forEach(E=>{const z=`${G}-${E}`;O.includes(z)||U.push({year:G,month:E,label:`${E} ${G}`})})}),U},I=(O,U)=>{if(O.includes("-")){const G=O.split("-"),E=parseInt(G[1],10);return`${Zc[E-1]} ${U}`}return`${O} ${U}`},C=async O=>{O.preventDefault(),f(!0);const U=new FormData(O.currentTarget);try{const G={area_number:parseInt(U.get("area_number")),name:U.get("name"),postcodes:U.get("postcodes"),bimonthly_circulation:parseInt(U.get("bimonthly_circulation"))||0,price_with_vat:parseFloat(U.get("price_with_vat"))||0,is_active:U.get("is_active")==="on"||U.get("is_active")==="true",schedule:p};if(n){const{error:E}=await W.from("leaflet_areas").update({...G,schedule:p}).eq("id",n.id);if(E)throw E;g({title:"Area updated successfully"})}else{const{error:E}=await W.from("leaflet_areas").insert([{...G,schedule:p}]);if(E)throw E;g({title:"Area created successfully"})}c(!1),a(null),x([]),y(),e==null||e()}catch(G){console.error("Error saving area:",G),g({title:"Error saving area",description:"Please try again",variant:"destructive"})}finally{f(!1)}},L=async O=>{f(!0);try{const{error:U}=await W.from("leaflet_areas").delete().eq("id",O.id);if(U)throw U;g({title:"Area deleted successfully"}),y(),e==null||e()}catch(U){console.error("Error deleting area:",U),g({title:"Error deleting area",description:"Please try again",variant:"destructive"})}finally{f(!1)}},D=async O=>{O.preventDefault(),f(!0);const U=new FormData(O.currentTarget);try{const G={name:U.get("name"),description:U.get("description"),months:parseInt(U.get("months")),issues:parseInt(U.get("issues")),is_active:U.get("is_active")==="on"||U.get("is_active")==="true"};if(i){const{error:E}=await W.from("leaflet_campaign_durations").update(G).eq("id",i.id);if(E)throw E;g({title:"Duration updated successfully"})}else{const{error:E}=await W.from("leaflet_campaign_durations").insert([G]);if(E)throw E;g({title:"Duration created successfully"})}m(!1),o(null),k()}catch(G){console.error("Error saving duration:",G),g({title:"Error saving duration",description:"Please try again",variant:"destructive"})}finally{f(!1)}},_=async O=>{f(!0);try{const{error:U}=await W.from("leaflet_campaign_durations").delete().eq("id",O.id);if(U)throw U;g({title:"Duration deleted successfully"}),k()}catch(U){console.error("Error deleting duration:",U),g({title:"Error deleting duration",description:"Please try again",variant:"destructive"})}finally{f(!1)}},H=(O,U,G)=>{if(O)try{if(O.includes(".")){const z=V2(O,"dd.MM.yyyy",new Date);return isNaN(z.getTime())?void 0:z}const E=O.match(/\d+/);if(E){const z=Zc.indexOf(G);if(z===-1)return;const Z=parseInt(E[0]),M=new Date(U,z,Z);return isNaN(M.getTime())?void 0:M}return}catch{return}};return A?t.jsxs("div",{className:"flex items-center justify-center py-8",children:[t.jsx(it,{className:"h-6 w-6 animate-spin mr-2"}),"Loading leafleting data..."]}):T?t.jsxs("div",{className:"text-center py-8",children:[t.jsx(Hs,{className:"h-12 w-12 mx-auto mb-4 text-destructive"}),t.jsx("p",{className:"text-lg font-medium text-destructive mb-2",children:"Error Loading Data"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load leafleting management data."})]}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-heading font-bold text-community-navy",children:"Leafleting Service Management"}),t.jsx("p",{className:"text-gray-600 mt-1",children:"Manage distribution areas and campaign settings"})]})}),t.jsxs(ha,{value:s,onValueChange:r,children:[t.jsxs(Hn,{className:"grid w-full grid-cols-2",children:[t.jsxs(Rt,{value:"areas",className:"flex items-center gap-2",children:[t.jsx(_t,{className:"h-4 w-4"}),"Distribution Areas (",$.length,")"]}),t.jsxs(Rt,{value:"settings",className:"flex items-center gap-2",children:[t.jsx(It,{className:"h-4 w-4"}),"Campaign Settings (",R.length,")"]})]}),t.jsx(Mt,{value:"areas",className:"mt-6",children:t.jsxs(xe,{children:[t.jsxs(Me,{className:"flex flex-row items-center justify-between",children:[t.jsx(Oe,{children:"Distribution Areas"}),t.jsxs(bt,{open:l,onOpenChange:O=>{c(O),O||(a(null),x([]))},children:[t.jsx(Sn,{asChild:!0,children:t.jsxs(q,{onClick:()=>{a(null),x([]),c(!0)},className:"flex items-center gap-2",children:[t.jsx(Xt,{className:"h-4 w-4"}),"Add Area"]})}),t.jsx(xt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:t.jsxs("form",{onSubmit:C,children:[t.jsxs(jt,{children:[t.jsx(wt,{children:n?"Edit Area":"Add New Area"}),t.jsx(ys,{children:"Configure the distribution area details, pricing, and schedule."})]}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"area_number",children:"Area Number"}),t.jsx(re,{id:"area_number",name:"area_number",type:"number",defaultValue:(n==null?void 0:n.area_number)||"",required:!0})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"name",children:"Area Name"}),t.jsx(re,{id:"name",name:"name",defaultValue:(n==null?void 0:n.name)||"",required:!0})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"postcodes",children:"Postcodes"}),t.jsx(ms,{id:"postcodes",name:"postcodes",placeholder:"Enter postcodes separated by commas",defaultValue:(n==null?void 0:n.postcodes)||"",required:!0})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"bimonthly_circulation",children:"Circulation (Bi-monthly)"}),t.jsx(re,{id:"bimonthly_circulation",name:"bimonthly_circulation",type:"number",defaultValue:(n==null?void 0:n.bimonthly_circulation)||""})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"price_with_vat",children:"Price (with VAT)"}),t.jsx(re,{id:"price_with_vat",name:"price_with_vat",type:"number",step:"0.01",defaultValue:(n==null?void 0:n.price_with_vat)||""})]})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(kt,{id:"is_active",name:"is_active",value:"true",defaultChecked:(n==null?void 0:n.is_active)??!0}),t.jsx(V,{htmlFor:"is_active",children:"Active"})]}),t.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(V,{className:"text-base font-medium",children:"Monthly Schedule"}),t.jsxs(we,{variant:"outline",className:"text-xs",children:[p.length," months configured"]})]}),t.jsxs("div",{className:"space-y-3 max-h-96 overflow-y-auto border rounded-md p-4 bg-muted/20",children:[p.map((O,U)=>{const G=H(O.copyDeadline,O.year,O.month),E=H(O.deliveryDate,O.year,O.month);return t.jsxs("div",{className:"bg-background rounded-lg border p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h4",{className:"text-sm font-semibold text-foreground",children:I(O.month,O.year)}),t.jsx(q,{type:"button",variant:"ghost",size:"sm",onClick:()=>B(O.year,O.month),className:"h-8 w-8 p-0 hover:bg-destructive/10 hover:text-destructive",title:`Remove ${I(O.month,O.year)}`,children:t.jsx(Es,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(V,{className:"text-xs font-medium text-muted-foreground",children:"Leaflets req'd by"}),t.jsxs(Cn,{children:[t.jsx(kn,{asChild:!0,children:t.jsxs(q,{type:"button",variant:"outline",className:oe("w-full justify-start text-left font-normal text-sm h-9",!G&&"text-muted-foreground"),children:[t.jsx(It,{className:"mr-2 h-3.5 w-3.5"}),G?Dt(G,"dd.MM.yyyy"):"Pick date"]})}),t.jsx(en,{className:"w-auto p-0",align:"start",children:t.jsx(nc,{mode:"single",selected:G,onSelect:z=>{const Z=[...p];Z[U]={...O,copyDeadline:z?Dt(z,"dd.MM.yyyy"):""},x(Z)},initialFocus:!0,className:"pointer-events-auto"})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(V,{className:"text-xs font-medium text-muted-foreground",children:"w/c delivery"}),t.jsxs(Cn,{children:[t.jsx(kn,{asChild:!0,children:t.jsxs(q,{type:"button",variant:"outline",className:oe("w-full justify-start text-left font-normal text-sm h-9",!E&&"text-muted-foreground"),children:[t.jsx(It,{className:"mr-2 h-3.5 w-3.5"}),E?Dt(E,"dd.MM.yyyy"):"Pick date"]})}),t.jsx(en,{className:"w-auto p-0",align:"start",children:t.jsx(nc,{mode:"single",selected:E,onSelect:z=>{const Z=[...p];Z[U]={...O,deliveryDate:z?Dt(z,"dd.MM.yyyy"):""},x(Z)},initialFocus:!0,className:"pointer-events-auto"})})]})]})]})]},`${O.year}-${O.month}`)}),p.length===0&&t.jsx("div",{className:"text-center py-4 text-gray-500 text-sm",children:"No dates configured. Add year-month combinations below."})]}),Y().length>0&&t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsxs(ht,{onValueChange:O=>
772{const[U,G]=O.split("-");P(parseInt(U),G)},children:[t.jsxs(ut,{className:"w-48",children:[t.jsx(Xt,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"Add Date"})]}),t.jsx(mt,{children:Y().map(O=>t.jsx(Pe,{value:`${O.year}-${O.month}`,children:O.label},`${O.year}-${O.month}`))})]}),t.jsxs("span",{className:"text-xs text-gray-500",children:[Y().length," dates available"]})]}),Y().length===0&&t.jsx("div",{className:"text-xs text-green-600 bg-green-50 p-2 rounded",children:"All available year-month combinations have been added to the schedule."})]})]}),t.jsxs(ma,{children:[t.jsx(q,{type:"button",variant:"outline",onClick:()=>{c(!1),a(null),x([])},children:"Cancel"}),t.jsx(q,{type:"submit",disabled:h,children:h?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):n?"Update Area":"Create Area"})]})]})})]})]}),t.jsx(ge,{children:$.length===0?t.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No distribution areas configured yet."}):t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Area #"}),t.jsx(ue,{children:"Name"}),t.jsx(ue,{children:"Postcodes"}),t.jsx(ue,{children:"Circulation"}),t.jsx(ue,{children:"Price (VAT inc.)"}),t.jsx(ue,{children:"Schedule"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:$.map(O=>{var U,G;return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:O.area_number}),t.jsx(de,{children:O.name}),t.jsx(de,{children:t.jsx("div",{className:"max-w-32 truncate",title:O.postcodes,children:O.postcodes})}),t.jsx(de,{children:((U=O.bimonthly_circulation)==null?void 0:U.toLocaleString())||"N/A"}),t.jsxs(de,{children:["£",O.price_with_vat]}),t.jsx(de,{children:t.jsxs(we,{variant:"outline",className:"text-xs",children:[((G=O.schedule)==null?void 0:G.length)||0," months"]})}),t.jsx(de,{children:t.jsx(we,{variant:O.is_active?"default":"secondary",children:O.is_active?"Active":"Inactive"})}),t.jsx(de,{children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(q,{variant:"outline",size:"sm",onClick:()=>{a(O),x(O.schedule||[]),c(!0)},children:t.jsx(Jr,{className:"h-4 w-4"})}),t.jsxs(ia,{children:[t.jsx(Li,{asChild:!0,children:t.jsx(q,{variant:"outline",size:"sm",children:t.jsx(cs,{className:"h-4 w-4"})})}),t.jsxs(Fn,{children:[t.jsxs(Ln,{children:[t.jsx(zn,{children:"Delete Area"}),t.jsxs(Un,{children:['Are you sure you want to delete "',O.name,'"? This action cannot be undone.']})]}),t.jsxs(Bn,{children:[t.jsx(oa,{children:"Cancel"}),t.jsx(Vn,{onClick:()=>L(O),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})]},O.id)})})]})})]})}),t.jsx(Mt,{value:"settings",className:"mt-6",children:t.jsxs(xe,{children:[t.jsxs(Me,{className:"flex flex-row items-center justify-between",children:[t.jsx(Oe,{children:"Campaign Duration Settings"}),t.jsxs(bt,{open:d,onOpenChange:m,children:[t.jsx(Sn,{asChild:!0,children:t.jsxs(q,{onClick:()=>{o(null),m(!0)},className:"flex items-center gap-2",children:[t.jsx(Xt,{className:"h-4 w-4"}),"Add Duration"]})}),t.jsx(xt,{className:"max-w-md",children:t.jsxs("form",{onSubmit:D,children:[t.jsxs(jt,{children:[t.jsx(wt,{children:i?"Edit Duration":"Add New Duration"}),t.jsx(ys,{children:"Configure the campaign duration options."})]}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"duration_name",children:"Duration Name"}),t.jsx(re,{id:"duration_name",name:"name",placeholder:"e.g., 6 Months",defaultValue:(i==null?void 0:i.name)||"",required:!0})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"duration_description",children:"Description"}),t.jsx(ms,{id:"duration_description",name:"description",placeholder:"Brief description",defaultValue:(i==null?void 0:i.description)||""})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"months",children:"Months"}),t.jsx(re,{id:"months",name:"months",type:"number",defaultValue:(i==null?void 0:i.months)||"",required:!0})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"issues",children:"Issues"}),t.jsx(re,{id:"issues",name:"issues",type:"number",defaultValue:(i==null?void 0:i.issues)||"",required:!0})]})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(kt,{id:"duration_is_active",name:"is_active",value:"true",defaultChecked:(i==null?void 0:i.is_active)??!0}),t.jsx(V,{htmlFor:"duration_is_active",children:"Active"})]})]}),t.jsxs(ma,{children:[t.jsx(q,{type:"button",variant:"outline",onClick:()=>m(!1),children:"Cancel"}),t.jsx(q,{type:"submit",disabled:h,children:h?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):i?"Update Duration":"Create Duration"})]})]})})]})]}),t.jsx(ge,{children:R.length===0?t.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No campaign durations configured yet."}):t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Duration"}),t.jsx(ue,{children:"Description"}),t.jsx(ue,{children:"Months"}),t.jsx(ue,{children:"Issues"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:R.map(O=>t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:O.name}),t.jsx(de,{children:O.description||"-"}),t.jsx(de,{children:O.months}),t.jsx(de,{children:O.issues}),t.jsx(de,{children:t.jsx(we,{variant:O.is_active?"default":"secondary",children:O.is_active?"Active":"Inactive"})}),t.jsx(de,{children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(q,{variant:"outline",size:"sm",onClick:()=>{o(O),m(!0)},children:t.jsx(Jr,{className:"h-4 w-4"})}),t.jsxs(ia,{children:[t.jsx(Li,{asChild:!0,children:t.jsx(q,{variant:"outline",size:"sm",children:t.jsx(cs,{className:"h-4 w-4"})})}),t.jsxs(Fn,{children:[t.jsxs(Ln,{children:[t.jsx(zn,{children:"Delete Duration"}),t.jsxs(Un,{children:['Are you sure you want to delete "',O.name,'"? This action cannot be undone.']})]}),t.jsxs(Bn,{children:[t.jsx(oa,{children:"Cancel"}),t.jsx(Vn,{onClick:()=>_(O),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})]},O.id))})]})})]})})]})]})};function Qoe(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return u.useMemo(()=>n=>
772{s.forEach(a=>a(n))},s)}const Zv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ku(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function qN(e){return"nodeType"in e}function Pn(e){var s,r;return e?Ku(e)?e:qN(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function HN(e){const{Document:s}=Pn(e);return e instanceof s}function Zf(e){return Ku(e)?!1:e instanceof Pn(e).HTMLElement}function TR(e){return e instanceof Pn(e).SVGElement}function Qu(e){return e?Ku(e)?e.document:qN(e)?HN(e)?e:Zf(e)||TR(e)?e.ownerDocument:document:document:document}const yi=Zv?u.useLayoutEffect:u.useEffect;function WN(e){const s=u.useRef(e);return yi(()=>{s.current=e}),u.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return s.current==null?void 0:s.current(...n)},[])}function Xoe(){const e=u.useRef(null),s=u.useCallback((n,a)=>{e.current=setInterval(n,a)},[]),r=u.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function Jh(e,s){s===void 0&&(s=[e]);const r=u.useRef(e);return yi(()=>{r.current!==e&&(r.current=e)},s),r}function Jf(e,s){const r=u.useRef();return u.useMemo(()=>{const n=e(r.current);return r.current=n,n},[...s])}function kg(e){const s=WN(e),r=u.useRef(null),n=u.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function o1(e){const s=u.useRef();return u.useEffect(()=>{s.current=e},[e]),s.current}let $0={};function ep(e,s){return u.useMemo(()=>{if(s)return s;const r=$0[e]==null?0:$0[e]+1;return $0[e]=r,e+"-"+r},[e,s])}function DR(e){return function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];return n.reduce((i,o)=>{const l=Object.entries(o);for(const[c,d]of l){const m=i[c];m!=null&&(i[c]=m+e*d)}return i},{...s})}}const Rd=DR(1),ef=DR(-1);function Zoe(e){return"clientX"in e&&"clientY"in e}function GN(e){if(!e)return!1;const{KeyboardEvent:s}=Pn(e.target);return s&&e instanceof s}function Joe(e){if(!e)return!1;const{TouchEvent:s}=Pn(e.target);return s&&e instanceof s}function l1(e){if(Joe(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return Zoe(e)?{x:e.clientX,y:e.clientY}:null}const $c=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[$c.Translate.toString(e),$c.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:n}=e;return s+" "+r+"ms "+n}}}),J3="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function ele(e){return e.matches(J3)?e:e.querySelector(J3)}const tle={display:"none"};function sle(e){let{id:s,value:r}=e;return ve.createElement("div",{id:s,style:tle},r)}function rle(e){let{id:s,announcement:r,ariaLiveType:n="assertive"}=e;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ve.createElement("div",{id:s,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function nle(){const[e,s]=u.useState("");return{announce:u.useCallback(n=>{n!=null&&s(n)},[]),announcement:e}}const RR=u.createContext(null);function ale(e){const s=u.useContext(RR);u.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function ile(){const[e]=u.useState(()=>new Set),s=u.useCallback(n=>(e.add(n),()=>e.delete(n)),[e]);return[u.useCallback(n=>{let{type:a,event:i}=n;e.forEach(o=>{var l;return(l=o[a])==null?void 0:l.call(o,i)})},[e]),s]}const ole={draggable:` 773 To pick up a draggable item, press the space bar. 774 While dragging, use the arrow keys to move the item. 775 Press space again to drop the item in its new position, or press escape to cancel. 776 `},lle={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function cle(e){let{announcements:s=lle,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=ole}=e;const{announce:i,announcement:o}=nle(),l=ep("DndLiveRegion"),[c,d]=u.useState(!1);if(u.useEffect(()=>{d(!0)},[]),ale(u.useMemo(()=>({onDragStart(h){let{active:f}=h;i(s.onDragStart({active:f}))},onDragMove(h){let{active:f,over:p}=h;s.onDragMove&&i(s.onDragMove({active:f,over:p}))},onDragOver(h){let{active:f,over:p}=h;i(s.onDragOver({active:f,over:p}))},onDragEnd(h){let{active:f,over:p}=h;i(s.onDragEnd({active:f,over:p}))},onDragCancel(h){let{active:f,over:p}=h;i(s.onDragCancel({active:f,over:p}))}}),[i,s])),!c)return null;const m=ve.createElement(ve.Fragment,null,ve.createElement(sle,{id:n,value:a.draggable}),ve.createElement(rle,{id:l,announcement:o}));return r?yn.createPortal(m,r):m}var cr;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(cr||(cr={}));function $g(){}function tf(e,s){return u.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function YN(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return u.useMemo(()=>[...s].filter(n=>n!=null),[...s])}const za=Object.freeze({x:0,y:0});function MR(e,s){return Math.sqrt(Math.pow(e.x-s.x,2)+Math.pow(e.y-s.y,2))}function OR(e,s){let{data:{value:r}}=e,{data:{value:n}}=s;return r-n}function dle(e,s){let{data:{value:r}}=e,{data:{value:n}}=s;return n-r}function eC(e){let{left:s,top:r,height:n,width:a}=e;return[{x:s,y:r},{x:s+a,y:r},{x:s,y:r+n},{x:s+a,y:r+n}]}function IR(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function tC(e,s,r){return s===void 0&&(s=e.left),r===void 0&&(r=e.top),{x:s+e.width*.5,y:r+e.height*.5}}const KN=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=e;const a=tC(s,s.left,s.top),i=[];for(const o of n){const{id:l}=o,c=r.get(l);if(c){const d=MR(tC(c),a);i.push({id:l,data:{droppableContainer:o,value:d}})}}return i.sort(OR)},ule=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=e;const a=eC(s),i=[];for(const o of n){const{id:l}=o,c=r.get(l);if(c){const d=eC(c),m=a.reduce((f,p,x)=>f+MR(d[x],p),0),h=Number((m/4).toFixed(4));i.push({id:l,data:{droppableContainer:o,value:h}})}}return i.sort(OR)};function mle(e,s){const r=Math.max(s.top,e.top),n=Math.max(s.left,e.left),a=Math.min(s.left+s.width,e.left+e.width),i=Math.min(s.top+s.height,e.top+e.height),o=a-n,l=i-r;if(n<a&&r<i){const c=s.width*s.height,d=e.width*e.height,m=o*l,h=m/(c+d-m);return Number(h.toFixed(4))}return 0}const hle=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=e;const a=[];for(const i of n){const{id:o}=i,l=r.get(o);if(l){const c=mle(l,s);c>0&&a.push({id:o,data:{droppableContainer:i,value:c}})}}return a.sort(dle)};function fle(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function FR(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:za}function ple(e){return function(r){for(var n=arguments.length,a=new Array(n>1?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];return a.reduce((o,l)=>
776({...o,top:o.top+e*l.y,bottom:o.bottom+e*l.y,left:o.left+e*l.x,right:o.right+e*l.x}),{...r})}}const xle=ple(1);function gle(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function vle(e,s,r){const n=gle(s);if(!n)return e;const{scaleX:a,scaleY:i,x:o,y:l}=n,c=e.left-o-(1-a)*parseFloat(r),d=e.top-l-(1-i)*parseFloat(r.slice(r.indexOf(" ")+1)),m=a?e.width/a:e.width,h=i?e.height/i:e.height;return{width:m,height:h,top:d,right:c+m,bottom:d+h,left:c}}const yle={ignoreTransform:!1};function Xu(e,s){s===void 0&&(s=yle);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:d,transformOrigin:m}=Pn(e).getComputedStyle(e);d&&(r=vle(r,d,m))}const{top:n,left:a,width:i,height:o,bottom:l,right:c}=r;return{top:n,left:a,width:i,height:o,bottom:l,right:c}}function sC(e){return Xu(e,{ignoreTransform:!0})}function ble(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function jle(e,s){return s===void 0&&(s=Pn(e).getComputedStyle(e)),s.position==="fixed"}function wle(e,s){s===void 0&&(s=Pn(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const i=s[a];return typeof i=="string"?r.test(i):!1})}function Jv(e,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(HN(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!Zf(a)||TR(a)||r.includes(a))return r;const i=Pn(e).getComputedStyle(a);return a!==e&&wle(a,i)&&r.push(a),jle(a,i)?r:n(a.parentNode)}return e?n(e):r}function LR(e){const[s]=Jv(e,1);return s??null}function E0(e){return!Zv||!e?null:Ku(e)?e:qN(e)?HN(e)||e===Qu(e).scrollingElement?window:Zf(e)?e:null:null}function BR(e){return Ku(e)?e.scrollX:e.scrollLeft}function zR(e){return Ku(e)?e.scrollY:e.scrollTop}function c1(e){return{x:BR(e),y:zR(e)}}var vr;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(vr||(vr={}));function UR(e){return!Zv||!e?!1:e===document.scrollingElement}function VR(e){const s={x:0,y:0},r=UR(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},n={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},a=e.scrollTop<=s.y,i=e.scrollLeft<=s.x,o=e.scrollTop>=n.y,l=e.scrollLeft>=n.x;return{isTop:a,isLeft:i,isBottom:o,isRight:l,maxScroll:n,minScroll:s}}const Nle={x:.2,y:.2};function _le(e,s,r,n,a){let{top:i,left:o,right:l,bottom:c}=r;n===void 0&&(n=10),a===void 0&&(a=Nle);const{isTop:d,isBottom:m,isLeft:h,isRight:f}=VR(e),p={x:0,y:0},x={x:0,y:0},g={height:s.height*a.y,width:s.width*a.x};return!d&&i<=s.top+g.height?(p.y=vr.Backward,x.y=n*Math.abs((s.top+g.height-i)/g.height)):!m&&c>=s.bottom-g.height&&(p.y=vr.Forward,x.y=n*Math.abs((s.bottom-g.height-c)/g.height)),!f&&l>=s.right-g.width?(p.x=vr.Forward,x.x=n*Math.abs((s.right-g.width-l)/g.width)):!h&&o<=s.left+g.width&&(p.x=vr.Backward,x.x=n*Math.abs((s.left+g.width-o)/g.width)),{direction:p,speed:x}}function Sle(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:o}=window;return{top:0,left:0,right:i,bottom:o,width:i,height:o}}const{top:s,left:r,right:n,bottom:a}=e.getBoundingClientRect();return{top:s,left:r,right:n,bottom:a,width:e.clientWidth,height:e.clientHeight}}function qR(e){return e.reduce((s,r)=>Rd(s,c1(r)),za)}function Cle(e){return e.reduce((s,r)=>s+BR(r),0)}function kle(e){return e.reduce((s,r)=>s+zR(r),0)}function $le(e,s){if(s===void 0&&(s=Xu),!e)return;const{top:r,left:n,bottom:a,right:i}=s(e);LR(e)&&(a<=0||i<=0||r>=window.innerHeight||n>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Ele=[["x",["left","right"],Cle],["y",["top","bottom"],kle]];class QN{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=Jv(r),a=qR(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[i,o,l]of Ele)for(const c of o)Object.defineProperty(this,c,{get:()=>{const d=l(n),m=a[i]-d;return this.rect[c]+m},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Qm{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>
776{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=s}add(s,r,n){var a;(a=this.target)==null||a.addEventListener(s,r,n),this.listeners.push([s,r,n])}}function Ple(e){const{EventTarget:s}=Pn(e);return e instanceof s?e:Qu(e)}function P0(e,s){const r=Math.abs(e.x),n=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+n**2)>s:"x"in s&&"y"in s?r>s.x&&n>s.y:"x"in s?r>s.x:"y"in s?n>s.y:!1}var Jn;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Jn||(Jn={}));function rC(e){e.preventDefault()}function Ale(e){e.stopPropagation()}var Vt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Vt||(Vt={}));const HR={start:[Vt.Space,Vt.Enter],cancel:[Vt.Esc],end:[Vt.Space,Vt.Enter,Vt.Tab]},Tle=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case Vt.Right:return{...r,x:r.x+25};case Vt.Left:return{...r,x:r.x-25};case Vt.Down:return{...r,y:r.y+25};case Vt.Up:return{...r,y:r.y-25}}};class ey{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new Qm(Qu(r)),this.windowListeners=new Qm(Pn(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Jn.Resize,this.handleCancel),this.windowListeners.add(Jn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Jn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&$le(n),r(za)}handleKeyDown(s){if(GN(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:i=HR,coordinateGetter:o=Tle,scrollBehavior:l="smooth"}=a,{code:c}=s;if(i.end.includes(c)){this.handleEnd(s);return}if(i.cancel.includes(c)){this.handleCancel(s);return}const{collisionRect:d}=n.current,m=d?{x:d.left,y:d.top}:za;this.referenceCoordinates||(this.referenceCoordinates=m);const h=o(s,{active:r,context:n.current,currentCoordinates:m});if(h){const f=ef(h,m),p={x:0,y:0},{scrollableAncestors:x}=n.current;for(const g of x){const b=s.code,{isTop:w,isRight:j,isLeft:y,isBottom:v,maxScroll:N,minScroll:S}=VR(g),k=Sle(g),$={x:Math.min(b===Vt.Right?k.right-k.width/2:k.right,Math.max(b===Vt.Right?k.left:k.left+k.width/2,h.x)),y:Math.min(b===Vt.Down?k.bottom-k.height/2:k.bottom,Math.max(b===Vt.Down?k.top:k.top+k.height/2,h.y))},R=b===Vt.Right&&!j||b===Vt.Left&&!y,A=b===Vt.Down&&!v||b===Vt.Up&&!w;if(R&&$.x!==h.x){const T=g.scrollLeft+f.x,P=b===Vt.Right&&T<=N.x||b===Vt.Left&&T>=S.x;if(P&&!f.y){g.scrollTo({left:T,behavior:l});return}P?p.x=g.scrollLeft-T:p.x=b===Vt.Right?g.scrollLeft-N.x:g.scrollLeft-S.x,p.x&&g.scrollBy({left:-p.x,behavior:l});break}else if(A&&$.y!==h.y){const T=g.scrollTop+f.y,P=b===Vt.Down&&T<=N.y||b===Vt.Up&&T>=S.y;if(P&&!f.x){g.scrollTo({top:T,behavior:l});return}P?p.y=g.scrollTop-T:p.y=b===Vt.Down?g.scrollTop-N.y:g.scrollTop-S.y,p.y&&g.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(s,Rd(ef(h,this.referenceCoordinates),p))}}}handleMove(s,r){const{onMove:n}=this.props;s.preventDefault(),n(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}ey.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:n=HR,onActivation:a}=s,{active:i}=r;const{code:o}=e.nativeEvent;if(n.start.includes(o)){const l=i.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),a==null||a({event:e.nativeEvent}),!0)}return!1}}];function nC(e){return!!(e&&"distance"in e)}function aC(e){return!!(e&&"delay"in e)}class XN{constructor(s,r,n){var a;n===void 0&&(n=Ple(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:i}=s,{target:o}=i;this.props=s,this.events=r,this.document=Qu(o),this.documentListeners=new Qm(this.document),this.listeners=new Qm(n),this.windowListeners=new Qm(Pn(o)),this.initialCoordinates=(a=l1(i))!=null?a:za,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Jn.Resize,this.handleCancel),this.windowListeners.add(Jn.DragStart,rC),this.windowListeners.add(Jn.VisibilityChange,this.handleCancel),this.windowListeners.add(Jn.ContextMenu,rC),this.documentListeners.add(Jn.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(aC(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(nC(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:n,onPending:a}=this.props;a(n,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(Jn.Click,Ale,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Jn.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:n,initialCoordinates:a,props:i}=this,{onMove:o,options:{activationConstraint:l}}=i;if(!a)return;const c=(r=l1(s))!=null?r:za,d=ef(a,c);if(!n&&l){if(nC(l)){if(l.tolerance!=null&&P0(d,l.tolerance))return this.handleCancel();if(P0(d,l.distance))return this.handleStart()}if(aC(l)&&P0(d,l.tolerance))return this.handleCancel();this.handlePending(l,d);return}s.cancelable&&s.preventDefault(),o(c)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===Vt.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const Dle={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class tp extends XN{constructor(s){const{event:r}=s,n=Qu(r.target);super(s,Dle,n)}}
776tp.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:n}=s;return!r.isPrimary||r.button!==0?!1:(n==null||n({event:r}),!0)}}];const Rle={move:{name:"mousemove"},end:{name:"mouseup"}};var d1;(function(e){e[e.RightClick=2]="RightClick"})(d1||(d1={}));class Mle extends XN{constructor(s){super(s,Rle,Qu(s.event.target))}}Mle.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:n}=s;return r.button===d1.RightClick?!1:(n==null||n({event:r}),!0)}}];const A0={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Ole extends XN{constructor(s){super(s,A0)}static setup(){return window.addEventListener(A0.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(A0.move.name,s)};function s(){}}}Ole.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:n}=s;const{touches:a}=r;return a.length>1?!1:(n==null||n({event:r}),!0)}}];var Xm;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Xm||(Xm={}));var Eg;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Eg||(Eg={}));function Ile(e){let{acceleration:s,activator:r=Xm.Pointer,canScroll:n,draggingRect:a,enabled:i,interval:o=5,order:l=Eg.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:m,delta:h,threshold:f}=e;const p=Lle({delta:h,disabled:!i}),[x,g]=Xoe(),b=u.useRef({x:0,y:0}),w=u.useRef({x:0,y:0}),j=u.useMemo(()=>{switch(r){case Xm.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Xm.DraggableRect:return a}},[r,a,c]),y=u.useRef(null),v=u.useCallback(()=>{const S=y.current;if(!S)return;const k=b.current.x*w.current.x,$=b.current.y*w.current.y;S.scrollBy(k,$)},[]),N=u.useMemo(()=>l===Eg.TreeOrder?[...d].reverse():d,[l,d]);u.useEffect(()=>{if(!i||!d.length||!j){g();return}for(const S of N){if((n==null?void 0:n(S))===!1)continue;const k=d.indexOf(S),$=m[k];if(!$)continue;const{direction:R,speed:A}=_le(S,$,j,s,f);for(const T of["x","y"])p[T][R[T]]||(A[T]=0,R[T]=0);if(A.x>0||A.y>0){g(),y.current=S,x(v,o),b.current=A,w.current=R;return}}b.current={x:0,y:0},w.current={x:0,y:0},g()},[s,v,n,g,i,o,JSON.stringify(j),JSON.stringify(p),x,d,N,m,JSON.stringify(f)])}const Fle={x:{[vr.Backward]:!1,[vr.Forward]:!1},y:{[vr.Backward]:!1,[vr.Forward]:!1}};function Lle(e){let{delta:s,disabled:r}=e;const n=o1(s);return Jf(a=>{if(r||!n||!a)return Fle;const i={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[vr.Backward]:a.x[vr.Backward]||i.x===-1,[vr.Forward]:a.x[vr.Forward]||i.x===1},y:{[vr.Backward]:a.y[vr.Backward]||i.y===-1,[vr.Forward]:a.y[vr.Forward]||i.y===1}}},[r,s,n])}function Ble(e,s){const r=s!=null?e.get(s):void 0,n=r?r.node.current:null;return Jf(a=>{var i;return s==null?null:(i=n??a)!=null?i:null},[n,s])}function zle(e,s){return u.useMemo(()=>e.reduce((r,n)=>{const{sensor:a}=n,i=a.activators.map(o=>({eventName:o.eventName,handler:s(o.handler,n)}));return[...r,...i]},[]),[e,s])}var sf;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(sf||(sf={}));var u1;(function(e){e.Optimized="optimized"})(u1||(u1={}));const iC=new Map;function Ule(e,s){let{dragging:r,dependencies:n,config:a}=s;const[i,o]=u.useState(null),{frequency:l,measure:c,strategy:d}=a,m=u.useRef(e),h=b(),f=Jh(h),p=u.useCallback(function(w){w===void 0&&(w=[]),!f.current&&o(j=>j===null?w:j.concat(w.filter(y=>!j.includes(y))))},[f]),x=u.useRef(null),g=Jf(w=>{if(h&&!r)return iC;if(!w||w===iC||m.current!==e||i!=null){const j=new Map;for(let y of e){if(!y)continue;if(i&&i.length>0&&!i.includes(y.id)&&y.rect.current){j.set(y.id,y.rect.current);continue}const v=y.node.current,N=v?new QN(c(v),v):null;y.rect.current=N,N&&j.set(y.id,N)}return j}return w},[e,i,r,h,c]);return u.useEffect(()=>{m.current=e},[e]),u.useEffect(()=>{h||p()},[r,h]),u.useEffect(()=>{i&&i.length>0&&o(null)},[JSON.stringify(i)]),u.useEffect(()=>{h||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{p(),x.current=null},l))},[l,h,p,...n]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:i!=null};function b(){switch(d){case sf.Always:return!1;case sf.BeforeDragging:return r;default:return!r}}}function WR(e,s){return Jf(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function Vle(e,s){return WR(e,s)}function qle(e){let{callback:s,disabled:r}=e;const n=WN(s),a=u.useMemo(()=>
776{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(n)},[n,r]);return u.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function ty(e){let{callback:s,disabled:r}=e;const n=WN(s),a=u.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(n)},[r]);return u.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function Hle(e){return new QN(Xu(e),e)}function oC(e,s,r){s===void 0&&(s=Hle);const[n,a]=u.useState(null);function i(){a(c=>{if(!e)return null;if(e.isConnected===!1){var d;return(d=c??r)!=null?d:null}const m=s(e);return JSON.stringify(c)===JSON.stringify(m)?c:m})}const o=qle({callback(c){if(e)for(const d of c){const{type:m,target:h}=d;if(m==="childList"&&h instanceof HTMLElement&&h.contains(e)){i();break}}}}),l=ty({callback:i});return yi(()=>{i(),e?(l==null||l.observe(e),o==null||o.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),o==null||o.disconnect())},[e]),n}function Wle(e){const s=WR(e);return FR(e,s)}const lC=[];function Gle(e){const s=u.useRef(e),r=Jf(n=>e?n&&n!==lC&&e&&s.current&&e.parentNode===s.current.parentNode?n:Jv(e):lC,[e]);return u.useEffect(()=>{s.current=e},[e]),r}function Yle(e){const[s,r]=u.useState(null),n=u.useRef(e),a=u.useCallback(i=>{const o=E0(i.target);o&&r(l=>l?(l.set(o,c1(o)),new Map(l)):null)},[]);return u.useEffect(()=>{const i=n.current;if(e!==i){o(i);const l=e.map(c=>{const d=E0(c);return d?(d.addEventListener("scroll",a,{passive:!0}),[d,c1(d)]):null}).filter(c=>c!=null);r(l.length?new Map(l):null),n.current=e}return()=>{o(e),o(i)};function o(l){l.forEach(c=>{const d=E0(c);d==null||d.removeEventListener("scroll",a)})}},[a,e]),u.useMemo(()=>e.length?s?Array.from(s.values()).reduce((i,o)=>Rd(i,o),za):qR(e):za,[e,s])}function cC(e,s){s===void 0&&(s=[]);const r=u.useRef(null);return u.useEffect(()=>{r.current=null},s),u.useEffect(()=>{const n=e!==za;n&&!r.current&&(r.current=e),!n&&r.current&&(r.current=null)},[e]),r.current?ef(e,r.current):za}function Kle(e){u.useEffect(()=>{if(!Zv)return;const s=e.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of s)r==null||r()}},e.map(s=>{let{sensor:r}=s;return r}))}function Qle(e,s){return u.useMemo(()=>e.reduce((r,n)=>{let{eventName:a,handler:i}=n;return r[a]=o=>{i(o,s)},r},{}),[e,s])}function GR(e){return u.useMemo(()=>e?ble(e):null,[e])}const dC=[];function Xle(e,s){s===void 0&&(s=Xu);const[r]=e,n=GR(r?Pn(r):null),[a,i]=u.useState(dC);function o(){i(()=>e.length?e.map(c=>UR(c)?n:new QN(s(c),c)):dC)}const l=ty({callback:o});return yi(()=>{l==null||l.disconnect(),o(),e.forEach(c=>l==null?void 0:l.observe(c))},[e]),a}function Zle(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return Zf(s)?s:e}function Jle(e){let{measure:s}=e;const[r,n]=u.useState(null),a=u.useCallback(d=>{for(const{target:m}of d)if(Zf(m)){n(h=>{const f=s(m);return h?{...h,width:f.width,height:f.height}:f});break}},[s]),i=ty({callback:a}),o=u.useCallback(d=>{const m=Zle(d);i==null||i.disconnect(),m&&(i==null||i.observe(m)),n(m?s(m):null)},[s,i]),[l,c]=kg(o);return u.useMemo(()=>({nodeRef:l,rect:r,setRef:c}),[r,l,c])}const ece=[{sensor:tp,options:{}},{sensor:ey,options:{}}],tce={current:{}},gx={draggable:{measure:sC},droppable:{measure:sC,strategy:sf.WhileDragging,frequency:u1.Optimized},dragOverlay:{measure:Xu}};class Zm extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,n;return(r=(n=this.get(s))==null?void 0:n.node.current)!=null?r:void 0}}const sce={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Zm,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:$g},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:gx,measureDroppableContainers:$g,windowRect:null,measuringScheduled:!1},rce={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:$g,draggableNodes:new Map,over:null,measureDroppableContainers:$g},sy=u.createContext(rce),YR=u.createContext(sce);function nce(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Zm}}}function ace(e,s){switch(s.type){case cr.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case cr.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case cr.DragEnd:case cr.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case cr.RegisterDroppable:{const{element:r}=s,{id:n}
776=r,a=new Zm(e.droppable.containers);return a.set(n,r),{...e,droppable:{...e.droppable,containers:a}}}case cr.SetDroppableDisabled:{const{id:r,key:n,disabled:a}=s,i=e.droppable.containers.get(r);if(!i||n!==i.key)return e;const o=new Zm(e.droppable.containers);return o.set(r,{...i,disabled:a}),{...e,droppable:{...e.droppable,containers:o}}}case cr.UnregisterDroppable:{const{id:r,key:n}=s,a=e.droppable.containers.get(r);if(!a||n!==a.key)return e;const i=new Zm(e.droppable.containers);return i.delete(r),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function ice(e){let{disabled:s}=e;const{active:r,activatorEvent:n,draggableNodes:a}=u.useContext(sy),i=o1(n),o=o1(r==null?void 0:r.id);return u.useEffect(()=>{if(!s&&!n&&i&&o!=null){if(!GN(i)||document.activeElement===i.target)return;const l=a.get(o);if(!l)return;const{activatorNode:c,node:d}=l;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const m of[c.current,d.current]){if(!m)continue;const h=ele(m);if(h){h.focus();break}}})}},[n,s,a,o,i]),null}function oce(e,s){let{transform:r,...n}=s;return e!=null&&e.length?e.reduce((a,i)=>i({transform:a,...n}),r):r}function lce(e){return u.useMemo(()=>({draggable:{...gx.draggable,...e==null?void 0:e.draggable},droppable:{...gx.droppable,...e==null?void 0:e.droppable},dragOverlay:{...gx.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function cce(e){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=e;const i=u.useRef(!1),{x:o,y:l}=typeof a=="boolean"?{x:a,y:a}:a;yi(()=>{if(!o&&!l||!s){i.current=!1;return}if(i.current||!n)return;const d=s==null?void 0:s.node.current;if(!d||d.isConnected===!1)return;const m=r(d),h=FR(m,n);if(o||(h.x=0),l||(h.y=0),i.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const f=LR(d);f&&f.scrollBy({top:h.y,left:h.x})}},[s,o,l,n,r])}const KR=u.createContext({...za,scaleX:1,scaleY:1});var bo;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(bo||(bo={}));const ZN=u.memo(function(s){var r,n,a,i;let{id:o,accessibility:l,autoScroll:c=!0,children:d,sensors:m=ece,collisionDetection:h=hle,measuring:f,modifiers:p,...x}=s;const g=u.useReducer(ace,void 0,nce),[b,w]=g,[j,y]=ile(),[v,N]=u.useState(bo.Uninitialized),S=v===bo.Initialized,{draggable:{active:k,nodes:$,translate:R},droppable:{containers:A}}=b,T=k!=null?$.get(k):null,P=u.useRef({initial:null,translated:null}),B=u.useMemo(()=>{var st;return k!=null?{id:k,data:(st=T==null?void 0:T.data)!=null?st:tce,rect:P}:null},[k,T]),Y=u.useRef(null),[I,C]=u.useState(null),[L,D]=u.useState(null),_=Jh(x,Object.values(x)),H=ep("DndDescribedBy",o),O=u.useMemo(()=>A.getEnabled(),[A]),U=lce(f),{droppableRects:G,measureDroppableContainers:E,measuringScheduled:z}=Ule(O,{dragging:S,dependencies:[R.x,R.y],config:U.droppable}),Z=Ble($,k),M=u.useMemo(()=>L?l1(L):null,[L]),F=Ke(),ee=Vle(Z,U.draggable.measure);cce({activeNode:k!=null?$.get(k):null,config:F.layoutShiftCompensation,initialRect:ee,measure:U.draggable.measure});const se=oC(Z,U.draggable.measure,ee),le=oC(Z?Z.parentElement:null),X=u.useRef({activatorEvent:null,active:null,activeNode:Z,collisionRect:null,collisions:null,droppableRects:G,draggableNodes:$,draggingNode:null,draggingNodeRect:null,droppableContainers:A,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ye=A.getNodeFor((r=X.current.over)==null?void 0:r.id),Ce=Jle({measure:U.dragOverlay.measure}),ke=(n=Ce.nodeRef.current)!=null?n:Z,fe=S?(a=Ce.rect)!=null?a:se:null,Ee=!!(Ce.nodeRef.current&&Ce.rect),K=Wle(Ee?null:se),te=GR(ke?Pn(ke):null),Q=Gle(S?ye??Z:null),ae=Xle(Q),me=oce(p,{transform:{x:R.x-K.x,y:R.y-K.y,scaleX:1,scaleY:1},activatorEvent:L,active:B,activeNodeRect:se,containerNodeRect:le,draggingNodeRect:fe,over:X.current.over,overlayNodeRect:Ce.rect,scrollableAncestors:Q,scrollableAncestorRects:ae,windowRect:te}),pe=M?Rd(M,R):null,be=Yle(Q),ce=cC(be),ie=cC(be,[se]),je=Rd(me,ce),Re=fe?xle(fe,me):null,Ae=B&&Re?h({active:B,collisionRect:Re,droppableRects:G,droppableContainers:O,pointerCoordinates:pe}):null,Ue=IR(Ae,"id"),[Ve,lt]=u.useState(null),J=Ee?me:Rd(me,ie),Ne=fle(J,(i=Ve==null?void 0:Ve.rect)!=null?i:null,se),gt=u.useRef(null),He=u.useCallback((st,dt)=>{let{sensor:tt,options:Jt}=dt;if(Y.current==null)return;const us=$.get(Y.current);if(!us)return;const St=st.nativeEvent,fr=new tt({active:Y.current,activeNode:us,event:St,options:Jt,context:X,onAbort(
776Ds){if(!$.get(Ds))return;const{onDragAbort:Nr}=_.current,Tr={id:Ds};Nr==null||Nr(Tr),j({type:"onDragAbort",event:Tr})},onPending(Ds,rr,Nr,Tr){if(!$.get(Ds))return;const{onDragPending:as}=_.current,Ct={id:Ds,constraint:rr,initialCoordinates:Nr,offset:Tr};as==null||as(Ct),j({type:"onDragPending",event:Ct})},onStart(Ds){const rr=Y.current;if(rr==null)return;const Nr=$.get(rr);if(!Nr)return;const{onDragStart:Tr}=_.current,Et={activatorEvent:St,active:{id:rr,data:Nr.data,rect:P}};yn.unstable_batchedUpdates(()=>{Tr==null||Tr(Et),N(bo.Initializing),w({type:cr.DragStart,initialCoordinates:Ds,active:rr}),j({type:"onDragStart",event:Et}),C(gt.current),D(St)})},onMove(Ds){w({type:cr.DragMove,coordinates:Ds})},onEnd:Yn(cr.DragEnd),onCancel:Yn(cr.DragCancel)});gt.current=fr;function Yn(Ds){return async function(){const{active:Nr,collisions:Tr,over:Et,scrollAdjustedTranslate:as}=X.current;let Ct=null;if(Nr&&as){const{cancelDrop:he}=_.current;Ct={activatorEvent:St,active:Nr,collisions:Tr,delta:as,over:Et},Ds===cr.DragEnd&&typeof he=="function"&&await Promise.resolve(he(Ct))&&(Ds=cr.DragCancel)}Y.current=null,yn.unstable_batchedUpdates(()=>{w({type:Ds}),N(bo.Uninitialized),lt(null),C(null),D(null),gt.current=null;const he=Ds===cr.DragEnd?"onDragEnd":"onDragCancel";if(Ct){const $e=_.current[he];$e==null||$e(Ct),j({type:he,event:Ct})}})}}},[$]),Te=u.useCallback((st,dt)=>(tt,Jt)=>{const us=tt.nativeEvent,St=$.get(Jt);if(Y.current!==null||!St||us.dndKit||us.defaultPrevented)return;const fr={active:St};st(tt,dt.options,fr)===!0&&(us.dndKit={capturedBy:dt.sensor},Y.current=Jt,He(tt,dt))},[$,He]),De=zle(m,Te);Kle(m),yi(()=>{se&&v===bo.Initializing&&N(bo.Initialized)},[se,v]),u.useEffect(()=>{const{onDragMove:st}=_.current,{active:dt,activatorEvent:tt,collisions:Jt,over:us}=X.current;if(!dt||!tt)return;const St={active:dt,activatorEvent:tt,collisions:Jt,delta:{x:je.x,y:je.y},over:us};yn.unstable_batchedUpdates(()=>{st==null||st(St),j({type:"onDragMove",event:St})})},[je.x,je.y]),u.useEffect(()=>{const{active:st,activatorEvent:dt,collisions:tt,droppableContainers:Jt,scrollAdjustedTranslate:us}=X.current;if(!st||Y.current==null||!dt||!us)return;const{onDragOver:St}=_.current,fr=Jt.get(Ue),Yn=fr&&fr.rect.current?{id:fr.id,rect:fr.rect.current,data:fr.data,disabled:fr.disabled}:null,Ds={active:st,activatorEvent:dt,collisions:tt,delta:{x:us.x,y:us.y},over:Yn};yn.unstable_batchedUpdates(()=>{lt(Yn),St==null||St(Ds),j({type:"onDragOver",event:Ds})})},[Ue]),yi(()=>{X.current={activatorEvent:L,active:B,activeNode:Z,collisionRect:Re,collisions:Ae,droppableRects:G,draggableNodes:$,draggingNode:ke,draggingNodeRect:fe,droppableContainers:A,over:Ve,scrollableAncestors:Q,scrollAdjustedTranslate:je},P.current={initial:fe,translated:Re}},[B,Z,Ae,Re,$,ke,fe,G,A,Ve,Q,je]),Ile({...F,delta:R,draggingRect:Re,pointerCoordinates:pe,scrollableAncestors:Q,scrollableAncestorRects:ae});const Le=u.useMemo(()=>({active:B,activeNode:Z,activeNodeRect:se,activatorEvent:L,collisions:Ae,containerNodeRect:le,dragOverlay:Ce,draggableNodes:$,droppableContainers:A,droppableRects:G,over:Ve,measureDroppableContainers:E,scrollableAncestors:Q,scrollableAncestorRects:ae,measuringConfiguration:U,measuringScheduled:z,windowRect:te}),[B,Z,se,L,Ae,le,Ce,$,A,G,Ve,E,Q,ae,U,z,te]),We=u.useMemo(()=>({activatorEvent:L,activators:De,active:B,activeNodeRect:se,ariaDescribedById:{draggable:H},dispatch:w,draggableNodes:$,over:Ve,measureDroppableContainers:E}),[L,De,B,se,w,H,$,Ve,E]);return ve.createElement(RR.Provider,{value:y},ve.createElement(sy.Provider,{value:We},ve.createElement(YR.Provider,{value:Le},ve.createElement(KR.Provider,{value:Ne},d)),ve.createElement(ice,{disabled:(l==null?void 0:l.restoreFocus)===!1})),ve.createElement(cle,{...l,hiddenTextDescribedById:H}));function Ke(){const st=(I==null?void 0:I.autoScrollEnabled)===!1,dt=typeof c=="object"?c.enabled===!1:c===!1,tt=S&&!st&&!dt;return typeof c=="object"?{...c,enabled:tt}:{enabled:tt}}}),dce=u.createContext(null),uC="button",uce="Draggable";function mce(e){let{id:s,data:r,disabled:n=!1,attributes:a}=e;const i=ep(uce),{activators:o,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:m,draggableNodes:h,over:f}=u.useContext(sy),{role:p=uC,roleDescription:x="draggable",tabIndex:g=0}=a??{},b=(c==null?void 0:c.id)===s,w=u.useContext(b?KR:dce),[j,y]=kg(),[v,N]=kg(),S=Qle(o,s),k=Jh(r);yi(()=>(h.set(s,{id:s,key:i,node:j,activatorNode:v,data:k}),()=>{const R=h.get(s);R&&R.key===i&&h.delete(s)}),[h,s]);const $=u.useMemo(()=>({role:p,tabIndex:g,"aria-disabled":n,"aria-pressed":b&&p===uC?!0:void 0,"aria-roledescription":x,"aria-describedby":m.draggable}),[n,p,g,b,x,m.draggable]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:$,isDragging:b,listeners:n?void 0:S,node:j,over:f,setNodeRef:y,setActivatorNodeRef:N,transform:w}}function hce(){return u.useContext(YR)}const fce="Droppable",pce={timeout:25};function xce(e){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=e;const i=ep(fce),{active:o,dispatch:l,over:c,measureDroppableContainers:d}=u.useContext(sy),m=u.useRef({disabled:r}),h=u.useRef(!1),f=u.useRef(null),p=u.useRef(null),{disabled:x,updateMeasurementsFor:g,timeout:b}={...pce,...a},w=Jh(g??n),j=u.useCallback(()=>
776{if(!h.current){h.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{d(Array.isArray(w.current)?w.current:[w.current]),p.current=null},b)},[b]),y=ty({callback:j,disabled:x||!o}),v=u.useCallback(($,R)=>{y&&(R&&(y.unobserve(R),h.current=!1),$&&y.observe($))},[y]),[N,S]=kg(v),k=Jh(s);return u.useEffect(()=>{!y||!N.current||(y.disconnect(),h.current=!1,y.observe(N.current))},[N,y]),u.useEffect(()=>(l({type:cr.RegisterDroppable,element:{id:n,key:i,disabled:r,node:N,rect:f,data:k}}),()=>l({type:cr.UnregisterDroppable,key:i,id:n})),[n]),u.useEffect(()=>{r!==m.current.disabled&&(l({type:cr.SetDroppableDisabled,id:n,key:i,disabled:r}),m.current.disabled=r)},[n,i,r,l]),{active:o,rect:f,isOver:(c==null?void 0:c.id)===n,node:N,over:c,setNodeRef:S}}function sp(e,s,r){const n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function gce(e,s){return e.reduce((r,n,a)=>{const i=s.get(n);return i&&(r[a]=i),r},Array(e.length))}function Up(e){return e!==null&&e>=0}function vce(e,s){if(e===s)return!0;if(e.length!==s.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==s[r])return!1;return!0}function yce(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const QR=e=>{let{rects:s,activeIndex:r,overIndex:n,index:a}=e;const i=sp(s,n,r),o=s[a],l=i[a];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},Vp={scaleX:1,scaleY:1},JN=e=>{var s;let{activeIndex:r,activeNodeRect:n,index:a,rects:i,overIndex:o}=e;const l=(s=i[r])!=null?s:n;if(!l)return null;if(a===r){const d=i[o];return d?{x:0,y:r<o?d.top+d.height-(l.top+l.height):d.top-l.top,...Vp}:null}const c=bce(i,a,r);return a>r&&a<=o?{x:0,y:-l.height-c,...Vp}:a<r&&a>=o?{x:0,y:l.height+c,...Vp}:{x:0,y:0,...Vp}};function bce(e,s,r){const n=e[s],a=e[s-1],i=e[s+1];return n?r<s?a?n.top-(a.top+a.height):i?i.top-(n.top+n.height):0:i?i.top-(n.top+n.height):a?n.top-(a.top+a.height):0:0}const XR="Sortable",ZR=ve.createContext({activeIndex:-1,containerId:XR,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:QR,disabled:{draggable:!1,droppable:!1}});function e_(e){let{children:s,id:r,items:n,strategy:a=QR,disabled:i=!1}=e;const{active:o,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:m}=hce(),h=ep(XR,r),f=l.rect!==null,p=u.useMemo(()=>n.map(S=>typeof S=="object"&&"id"in S?S.id:S),[n]),x=o!=null,g=o?p.indexOf(o.id):-1,b=d?p.indexOf(d.id):-1,w=u.useRef(p),j=!vce(p,w.current),y=b!==-1&&g===-1||j,v=yce(i);yi(()=>{j&&x&&m(p)},[j,p,x,m]),u.useEffect(()=>{w.current=p},[p]);const N=u.useMemo(()=>({activeIndex:g,containerId:h,disabled:v,disableTransforms:y,items:p,overIndex:b,useDragOverlay:f,sortedRects:gce(p,c),strategy:a}),[g,h,v.draggable,v.droppable,y,p,b,c,f,a]);return ve.createElement(ZR.Provider,{value:N},s)}const jce=e=>{let{id:s,items:r,activeIndex:n,overIndex:a}=e;return sp(r,n,a).indexOf(s)},wce=e=>{let{containerId:s,isSorting:r,wasDragging:n,index:a,items:i,newIndex:o,previousItems:l,previousContainerId:c,transition:d}=e;return!d||!n||l!==i&&a===o?!1:r?!0:o!==a&&s===c},Nce={duration:200,easing:"ease"},JR="transform",_ce=$c.Transition.toString({property:JR,duration:0,easing:"linear"}),Sce={roleDescription:"sortable"};function Cce(e){let{disabled:s,index:r,node:n,rect:a}=e;const[i,o]=u.useState(null),l=u.useRef(r);return yi(()=>{if(!s&&r!==l.current&&n.current){const c=a.current;if(c){const d=Xu(n.current,{ignoreTransform:!0}),m={x:c.left-d.left,y:c.top-d.top,scaleX:c.width/d.width,scaleY:c.height/d.height};(m.x||m.y)&&o(m)}}r!==l.current&&(l.current=r)},[s,r,n,a]),u.useEffect(()=>{i&&o(null)},[i]),i}function t_(e){let{animateLayoutChanges:s=wce,attributes:r,disabled:n,data:a,getNewIndex:i=jce,id:o,strategy:l,resizeObserverConfig:c,transition:d=Nce}=e;const{items:m,containerId:h,activeIndex:f,disabled:p,disableTransforms:x,sortedRects:g,overIndex:b,useDragOverlay:w,strategy:j}=u.useContext(ZR),y=kce(n,p),v=m.indexOf(o),N=u.useMemo(()=>({sortable:{containerId:h,index:v,items:m},...a}),[h,a,v,m]),S=u.useMemo(()=>m.slice(m.indexOf(o)),[m,o]),{rect:k,node:$,isOver:R,setNodeRef:A}=xce({id:o,data:N,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:T,activatorEvent:P,activeNodeRect:B,attributes:Y,setNodeRef:I,listeners:C,isDragging:L,over:D,setActivatorNodeRef:_,transform:H}=mce({id:o,data:N,attributes:{...Sce,...r},disabled:y.draggable}),O=Qoe(A,I),U=!!T,G=U&&!x&&Up(f)&&Up(b),E=!w&&L,z=E&&G?H:null,M=G?z??(l??j)({rects:g,activeNodeRect:B,activeIndex:f,overIndex:b,index:v}):null,F=Up(f)&&Up(b)?i({id:o,items:m,activeIndex:f,overIndex:b}):v,ee=T==null?void 0:T.id,se=u.useRef({activeId:ee,items:m,newIndex:F,containerId:h}),le=m!==se.current.items,X=s({active:T,containerId:h,isDragging:L,isSorting:U,id:o,index:v,items:m,newIndex:se.current.newIndex,previousItems:se.current.items,previousContainerId:se.current.containerId,transition:d,wasDragging:se.current.activeId!=null}),ye=Cce({disabled:!X,index:v,node:$,rect:k});return u.useEffect(()=>{U&&se.current.newIndex!==F&&(se.current.newIndex=F),h!==se.current.containerId&&(se.current.containerId=h),m!==se.current.items&&(se.current.items=m)},[U,F,h,m]),u.useEffect(()=>{if(ee===se.current.activeId)return;if(ee!=null&&se.current.activeId==null){se.current.activeId=ee;return}const ke=setTimeout(()=>{se.current.activeId=ee},50);return()=>clearTimeout(ke)},[ee]),{active:T,activeIndex:f,attributes:Y,data:N,rect:k,index:v,newIndex:F,items:m,isOver:R,isSorting:U,isDragging:L,listeners:C,node:$,overIndex:b,over:D,setNodeRef:O,setActivatorNodeRef:_,setDroppableNodeRef:A,setDraggableNodeRef:I,transform:ye??M,transition:Ce()};
776function Ce(){if(ye||le&&se.current.newIndex===v)return _ce;if(!(E&&!GN(P)||!d)&&(U||X))return $c.Transition.toString({...d,property:JR})}}function kce(e,s){var r,n;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e==null?void 0:e.draggable)!=null?r:s.draggable,droppable:(n=e==null?void 0:e.droppable)!=null?n:s.droppable}}function Pg(e){if(!e)return!1;const s=e.data.current;return!!(s&&"sortable"in s&&typeof s.sortable=="object"&&"containerId"in s.sortable&&"items"in s.sortable&&"index"in s.sortable)}const $ce=[Vt.Down,Vt.Right,Vt.Up,Vt.Left],e7=(e,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:i,over:o,scrollableAncestors:l}}=s;if($ce.includes(e.code)){if(e.preventDefault(),!r||!n)return;const c=[];i.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const f=a.get(h.id);if(f)switch(e.code){case Vt.Down:n.top<f.top&&c.push(h);break;case Vt.Up:n.top>f.top&&c.push(h);break;case Vt.Left:n.left>f.left&&c.push(h);break;case Vt.Right:n.left<f.left&&c.push(h);break}});const d=ule({active:r,collisionRect:n,droppableRects:a,droppableContainers:c,pointerCoordinates:null});let m=IR(d,"id");if(m===(o==null?void 0:o.id)&&d.length>1&&(m=d[1].id),m!=null){const h=i.get(r.id),f=i.get(m),p=f?a.get(f.id):null,x=f==null?void 0:f.node.current;if(x&&p&&h&&f){const b=Jv(x).some((S,k)=>l[k]!==S),w=t7(h,f),j=Ece(h,f),y=b||!w?{x:0,y:0}:{x:j?n.width-p.width:0,y:j?n.height-p.height:0},v={x:p.left,y:p.top};return y.x&&y.y?v:ef(v,y)}}}};function t7(e,s){return!Pg(e)||!Pg(s)?!1:e.data.current.sortable.containerId===s.data.current.sortable.containerId}function Ece(e,s){return!Pg(e)||!Pg(s)||!t7(e,s)?!1:e.data.current.sortable.index<s.data.current.sortable.index}const Pce=({id:e,feature:s,index:r,updateFeature:n,removeFeature:a})=>{const{attributes:i,listeners:o,setNodeRef:l,transform:c,transition:d,isDragging:m}=t_({id:e}),h={transform:$c.Transform.toString(c),transition:d,opacity:m?.5:1};return t.jsxs("div",{ref:l,style:h,className:"flex items-start gap-2 p-3 border rounded-lg bg-background",children:[t.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground mt-2.5",...i,...o,children:t.jsx(Su,{className:"h-4 w-4"})}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(re,{className:"flex-1",placeholder:"Feature label",value:s.label,onChange:f=>n(r,"label",f.target.value)}),t.jsxs(ht,{value:s.value===!0?"included":s.value===!1?"not_included":"custom",onValueChange:f=>{f==="included"?n(r,"value",!0):f==="not_included"?n(r,"value",!1):n(r,"value","")},children:[t.jsx(ut,{className:"w-[160px]",children:t.jsx(ft,{})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"included",children:"â Included"}),t.jsx(Pe,{value:"not_included",children:"â Not included"}),t.jsx(Pe,{value:"custom",children:"Custom text"})]})]}),typeof s.value=="string"&&t.jsx(re,{className:"w-[140px]",placeholder:"e.g. From £99",value:s.value,onChange:f=>n(r,"value",f.target.value)}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(kt,{checked:s.highlight,onCheckedChange:f=>n(r,"highlight",f)}),t.jsx(V,{className:"text-xs",children:"Highlight"})]}),t.jsx(q,{type:"button",variant:"ghost",size:"sm",onClick:()=>a(r),children:t.jsx(Es,{className:"h-4 w-4"})})]}),t.jsx(re,{className:"text-xs",placeholder:"Subtext (optional) â e.g. additional detail shown below the feature",value:s.subtext||"",onChange:f=>n(r,"subtext",f.target.value)})]})]})},Ace=()=>{var T,P;const{data:e,isLoading:s}=cD(!0),r=Xee(),n=Zee(),a=Jee();rt();const[i,o]=u.useState(!1),[l,c]=u.useState(!1),[d,m]=u.useState(null),[h,f]=u.useState(!1),[p,x]=u.useState({package_id:"",title:"",subtitle:"",description:"",icon:"Target",badge_text:"",badge_variant:"default",cta_text:"SELECT",is_popular:!1,is_active:!0,sort_order:0,features:[]}),g=YN(tf(tp,{activationConstraint:{distance:5}})),b=(p.features||[]).map((B,Y)=>`feature-${Y}`),w=u.useCallback(B=>{const{active:Y,over:I}=B;if(!I||Y.id===I.id||!p.features)return;const C=b.indexOf(Y.id),L=b.indexOf(I.id);x(D=>({...D,features:sp(D.features||[],C,L)}))},[p.features,b]),j=B=>{m(B),x(B),f(!1),o(!0)},y=()=>{m(null),x({package_id:"",title:"",subtitle:"",description:"",icon:"Target",badge_text:"",badge_variant:"default",cta_text:"SELECT",is_popular:!1,is_active:!0,sort_order:e?e.length+1:1,features:[]}),f(!0),o(!0)},v=B=>{m(B),c(!0)},N=()=>{d&&(a.mutate(d.id),c(!1))},S=()=>{h?n.mutate(p):d&&r.mutate({...p,id:d.id}),o(!1)},k=()=>{x({...p,features:[...p.features||[],{label:"",value:"",highlight:!1,subtext:""}]})},$=(B,Y,I)=>{const C=[...p.features||[]];C[B]={...C[B],[Y]:I},x({...p,features:C})},R=B=>{const Y=[...p.features||[]];Y.splice(B,1),x({...p,features:Y})};if(s)return t.jsx("div",{children:"Loading..."});const A=Mj(p.icon||"Target");return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold",children:"Product Packages"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage the pricing options shown to customers on Step 1"})]}),t.jsxs(q,{onClick:y,children:[t.jsx(Xt,{className:"h-4 w-4 mr-2"}),"Create Package"]})]}),t.jsx(xe,{children:t.jsx(ge,{className:"p-0",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{className:"w-12"}),t.jsx(ue,{children:"Title"}),t.jsx(ue,{children:"Package ID"}),t.jsx(ue,{children:"Badge"}),t.jsx(ue,{children:"Popular"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Sort"}),t.jsx(ue,{className:"text-right",children:"Actions"})]})}),t.jsx(Wt,{children:e==null?void 0:e.map(B=>{const Y=Mj(B.icon);return t.jsxs(Xe,{children:[t.jsx(de,{children:t.jsx(Su,{className:"h-4 w-4 text-muted-foreground"})}),t.jsx(de,{children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Y,{className:"h-4 w-4"}),t.jsx("span",{className:"font-medium",children:B.title})]})}),t.jsx(de,{children:t.jsx("code",{className:"text-xs bg-muted px-2 py-1 rounded",children:B.package_id})}),t.jsx(de,{children:B.badge_text&&t.jsx(we,{variant:B.badge_variant,children:B.badge_text})}),t.jsx(de,{children:B.is_popular&&t.jsx(we,{children:"Popular"})}),t.jsx(de,{children:t.jsx(we,{variant:B.is_active?"default":"secondary",children:B.is_active?"Active":"Inactive"})}),t.jsx(de,{children:B.sort_order}),t.jsx(de,{className:"text-right",children:t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>j(B),children:t.jsx(Jr,{className:"h-4 w-4"})}),t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>v(B),children:t.jsx(cs,{className:"h-4 w-4"})})]})})]},B.id)})})]})})}),t.jsx(bt,{open:i,onOpenChange:o,children:t.jsxs(xt,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[t.jsxs(jt,{children:[t.jsxs(wt,{children:[h?"Create":"Edit"," Product Package"]}),t.jsxs(ys,{children:[h?"Create a new":"Edit the"," product package display settings"]})]}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Package ID"}),t.jsx(re,{value:p.package_id,onChange:B=>x({...p,package_id:B.target.value}),placeholder:"fixed, bogof, leafleting",disabled:!h}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Must match backend pricing logic (fixed/bogof/leafleting)"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Icon"}),t.jsxs(ht,{value:p.icon,onValueChange:B=>x({...p,icon:B}),children:[t.jsx(ut,{children:t.jsx(ft,{})}),t.jsx(mt,{children:XX.map(B=>t.jsx(Pe,{value:B,children:t.jsx("div",{className:"flex items-center gap-2",children:B})},B))})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Title"}),t.jsx(re,{value:p.title,onChange:B=>x({...p,title:B.target.value}),placeholder:"Fixed Term"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Subtitle"}),t.jsx(re,{value:p.subtitle,onChange:B=>x({...p,subtitle:B.target.value}),placeholder:"Predictable reach at a fixed term"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Description"}),t.jsx(ms,{value:p.description,onChange:B=>x({...p,description:B.target.value}),placeholder:"Perfect for time-sensitive campaigns..."})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Badge Text (optional)"}),t.jsx(re,{value:p.badge_text||"",onChange:B=>x({...p,badge_text:B.target.value}),placeholder:"Star Buy"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Badge Variant"}),t.jsxs(ht,{value:p.badge_variant,onValueChange:B=>x({...p,badge_variant:B}),children:[t.jsx(ut,{children:t.jsx(ft,{})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"default",children:"Default"}),t.jsx(Pe,{value:"secondary",children:"Secondary"}),t.jsx(Pe,{value:"destructive",children:"Destructive"}),t.jsx(Pe,{value:"outline",children:"Outline"})]})]})]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"CTA Button Text"}),t.jsx(re,{value:p.cta_text,onChange:B=>x({...p,cta_text:B.target.value})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Sort Order"}),t.jsx(re,{type:"number",value:p.sort_order,onChange:B=>x({...p,sort_order:parseInt(B.target.value)})})]}),t.jsxs("div",{className:"space-y-4 pt-6",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(kt,{checked:p.is_popular,onCheckedChange:B=>x({...p,is_popular:B})}),t.jsx(V,{children:"Popular"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(kt,{checked:p.is_active,onCheckedChange:B=>x({...p,is_active:B})}),t.jsx(V,{children:"Active"})]})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(V,{children:"Features"}),t.jsxs(q,{type:"button",variant:"outline",size:"sm",onClick:k,children:[t.jsx(Xt,{className:"h-4 w-4 mr-2"}),"Add Feature"]})]}),t.jsx(ZN,{sensors:g,collisionDetection:KN,onDragEnd:w,children:t.jsx(e_,{items:b,strategy:JN,children:t.jsx("div",{className:"space-y-2",children:(T=p.features)==null?void 0:T.map((B,Y)=>t.jsx(Pce,{id:`feature-${Y}`,feature:B,index:Y,updateFeature:$,removeFeature:R},`feature-${Y}`))})})})]}),t.jsxs(xe,{className:"border-2",children:[t.jsx(Me,{children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(A,{className:"h-8 w-8 text-primary"}),t.jsxs("div",{children:[t.jsx(Oe,{className:"text-xl",children:p.title||"Title"}),t.jsx(Er,{children:p.subtitle||"Subtitle"})]})]}),p.badge_text&&t.jsx(we,{variant:p.badge_variant,children:p.badge_text})]})}),t.jsxs(ge,{children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:p.description||"De
776scription"}),t.jsx(q,{className:"w-full mb-4",children:p.cta_text}),t.jsx("div",{className:"space-y-1",children:(P=p.features)==null?void 0:P.map((B,Y)=>t.jsxs("div",{className:"text-sm",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:B.highlight?"font-medium":"",children:B.label}),t.jsx("span",{className:B.highlight?"text-primary font-medium":"text-muted-foreground",children:typeof B.value=="boolean"?B.value?"â":"â":B.value})]}),B.subtext&&t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:B.subtext})]},Y))})]})]})]}),t.jsxs(ma,{children:[t.jsx(q,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),t.jsx(q,{onClick:S,children:h?"Create":"Save Changes"})]})]})}),t.jsx(ia,{open:l,onOpenChange:c,children:t.jsxs(Fn,{children:[t.jsxs(Ln,{children:[t.jsx(zn,{children:"Delete Product Package?"}),t.jsx(Un,{children:"This will hide the package from customers. You can reactivate it later by editing it."})]}),t.jsxs(Bn,{children:[t.jsx(oa,{children:"Cancel"}),t.jsx(Vn,{onClick:N,children:"Delete"})]})]})})]})},Tce=()=>{const[e,s]=u.useState("locations"),[r,n]=u.useState({totalLocations:0,activeLocations:0,totalAdSizes:0,activeAdSizes:0,subscriptionDurations:0,volumeDiscounts:0});rt();const{invalidateAll:a}=ON(),i=async()=>{try{a(),n({totalLocations:14,activeLocations:14,totalAdSizes:7,activeAdSizes:7,subscriptionDurations:2,volumeDiscounts:4})}catch(l){console.error("Error loading stats:",l)}};u.useEffect(()=>{i()},[]);const o=[{title:"Active Locations",value:`${r.activeLocations}/${r.totalLocations}`,icon:_t,color:"text-blue-600"},{title:"Ad Sizes",value:r.activeAdSizes,icon:Sd,color:"text-green-600"},{title:"Subscriptions",value:r.subscriptionDurations,icon:ws,color:"text-purple-600"},{title:"Volume Tiers",value:r.volumeDiscounts,icon:sc,color:"text-orange-600"}];return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsxs("h1",{className:"text-3xl font-heading font-bold text-community-navy flex items-center gap-2",children:[t.jsx(sc,{className:"h-8 w-8 text-community-green"}),"Cost Calculator Management"]}),t.jsx("p",{className:"text-gray-600 mt-1",children:"Manage advertising locations, pricing, and subscription settings"})]}),t.jsxs(we,{variant:"outline",className:"text-sm",children:["Last Updated: ",new Date().toLocaleDateString()]})]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:o.map((l,c)=>t.jsx(xe,{children:t.jsx(ge,{className:"p-6",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx(l.icon,{className:`h-8 w-8 ${l.color}`}),t.jsxs("div",{className:"ml-4",children:[t.jsx("p",{className:"text-sm font-medium text-gray-600",children:l.title}),t.jsx("p",{className:"text-2xl font-bold text-gray-900",children:l.value})]})]})})},c))}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(sc,{className:"h-5 w-5"}),"Calculator Management Console"]})}),t.jsx(ge,{children:t.jsxs(ha,{value:e,onValueChange:s,children:[t.jsxs(Hn,{className:"grid w-full grid-cols-5",children:[t.jsxs(Rt,{value:"locations",className:"flex items-center gap-2",children:[t.jsx(_t,{className:"h-4 w-4"}),"Locations"]}),t.jsxs(Rt,{value:"adSizes",className:"flex items-center gap-2",children:[t.jsx(Sd,{className:"h-4 w-4"}),"Ad Sizes & Pricing"]}),t.jsxs(Rt,{value:"subscriptions",className:"flex items-center gap-2",children:[t.jsx(ws,{className:"h-4 w-4"}),"Subscription Settings"]}),t.jsxs(Rt,{value:"leaflets",className:"flex items-center gap-2",children:[t.jsx(ir,{className:"h-4 w-4"}),"Leaflets"]}),t.jsxs(Rt,{value:"products",className:"flex items-center gap-2",children:[t.jsx(_f,{className:"h-4 w-4"}),"Product Designer"]})]}),t.jsx(Mt,{value:"locations",className:"mt-6",children:t.jsx(Ioe,{onStatsUpdate:i})}),t.jsx(Mt,{value:"adSizes",className:"mt-6",children:t.jsx(Foe,{onStatsUpdate:i})}),t.jsx(Mt,{value:"subscriptions",className:"mt-6",children:t.jsx(Goe,{onStatsUpdate:i})}),t.jsx(Mt,{value:"leaflets",className:"mt-6",children:t.jsx(Koe,{onStatsUpdate:i})}),t.jsx(Mt,{value:"products",className:"mt-6",children:t.jsx(Ace,{})})]})})]})]})},Dce=()=>{const[e,s]=u.useState([]),[r,n]=u.useState(!0),[a,i]=u.useState(!1),[o,l]=u.useState(null),[c,d]=u.useState({title:"",message:"",alert_type:"premium_slot",is_active:!0,priority:0,badge_text:"",badge_color:"red",expires_at:""}),{toast:m}=rt(),h=[{value:"red",label:"Red",class:"bg-red-600"},{value:"orange",label:"Orange",class:"bg-orange-600"},{value:"yellow",label:"Yellow",class:"bg-yellow-600"},{value:"green",label:"Green",class:"bg-green-600"},{value:"blue",label:"Blue",class:"bg-blue-600"},{value:"purple",label:"Purple",class:"bg-purple-600"}],f=async()=>{try{n(!0);const{data:y,error:v}=await W.from("alerts").select("*").order("priority",{ascending:!0});if(v)throw v;s((y||[]).map(N=>({...N,alert_type:N.alert_type})))}catch(y){console.error("Error loading alerts:",y),m({title:"Error",description:"Failed to load alerts",variant:"destructive"})}finally{n(!1)}};u.useEffect(()=>{f()},[]);const p=()=>{d({title:"",message:"",alert_type:"premium_slot",is_active:!0,priority:0,badge_text:"",badge_color:"red",expires_at:""}),l(null)},x=()=>{p(),i(!0)},g=y=>{l(y),d({title:y.title,message:y.message,alert_type:y.alert_type,is_active:y.is_active,priority:y.priority,badge_text:y.badge_text||"",badge_color:y.badge_color,expires_at:y.expires_at?new Date(y.expires_at).toISOString().split("T")[0]:""}),i(!0)},b=async()=>{try{const y={...c,expires_at:c.expires_at?new Date(c.expires_at).toISOString():null,badge_text:c.badge_text||null};let v;if(o?{error:v}
776=await W.from("alerts").update(y).eq("id",o.id):{error:v}=await W.from("alerts").insert([y]),v)throw v;m({title:"Success",description:`Alert ${o?"updated":"created"} successfully`}),i(!1),p(),f()}catch(y){console.error("Error saving alert:",y),m({title:"Error",description:"Failed to save alert",variant:"destructive"})}},w=async y=>{if(confirm("Are you sure you want to delete this alert?"))try{const{error:v}=await W.from("alerts").delete().eq("id",y);if(v)throw v;m({title:"Success",description:"Alert deleted successfully"}),f()}catch(v){console.error("Error deleting alert:",v),m({title:"Error",description:"Failed to delete alert",variant:"destructive"})}},j=async(y,v)=>{try{const{error:N}=await W.from("alerts").update({is_active:!v}).eq("id",y);if(N)throw N;m({title:"Success",description:`Alert ${v?"deactivated":"activated"}`}),f()}catch(N){console.error("Error updating alert:",N),m({title:"Error",description:"Failed to update alert",variant:"destructive"})}};return r?t.jsx("div",{className:"flex items-center justify-center p-8",children:"Loading..."}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold",children:"Alerts Management"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage deadline alerts and premium slot notifications"})]}),t.jsxs(q,{onClick:x,children:[t.jsx(Xt,{className:"h-4 w-4 mr-2"}),"Create Alert"]})]}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{children:"Active Alerts"})}),t.jsx(ge,{children:e.length===0?t.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[t.jsx(mi,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground/50"}),t.jsx("p",{children:"No alerts configured yet."})]}):t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Title"}),t.jsx(ue,{children:"Type"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Priority"}),t.jsx(ue,{children:"Badge"}),t.jsx(ue,{children:"Expires"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:e.map(y=>{var v;return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:y.title}),t.jsx(de,{children:t.jsx(we,{variant:y.alert_type==="deadline"?"destructive":"default",children:y.alert_type==="deadline"?"Deadline":"Premium Slot"})}),t.jsx(de,{children:t.jsx(we,{variant:y.is_active?"default":"secondary",children:y.is_active?"Active":"Inactive"})}),t.jsx(de,{children:y.priority}),t.jsx(de,{children:y.badge_text&&t.jsx(we,{className:`${(v=h.find(N=>N.value===y.badge_color))==null?void 0:v.class} text-white`,children:y.badge_text})}),t.jsx(de,{children:y.expires_at?new Date(y.expires_at).toLocaleDateString():"Never"}),t.jsx(de,{children:t.jsxs("div",{className:"flex space-x-2",children:[t.jsx(q,{variant:"outline",size:"sm",onClick:()=>g(y),children:t.jsx(oL,{className:"h-3 w-3"})}),t.jsx(q,{variant:y.is_active?"secondary":"default",size:"sm",onClick:()=>j(y.id,y.is_active),children:y.is_active?"Deactivate":"Activate"}),t.jsx(q,{variant:"destructive",size:"sm",onClick:()=>w(y.id),children:t.jsx(cs,{className:"h-3 w-3"})})]})})]},y.id)})})]})})]}),t.jsx(bt,{open:a,onOpenChange:i,children:t.jsxs(xt,{className:"max-w-2xl",children:[t.jsx(jt,{children:t.jsx(wt,{children:o?"Edit Alert":"Create New Alert"})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"title",children:"Title"}),t.jsx(re,{id:"title",value:c.title,onChange:y=>d({...c,title:y.target.value}),placeholder:"e.g., DEADLINE ALERT!"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"alert_type",children:"Alert Type"}),t.jsxs(ht,{value:c.alert_type,onValueChange:y=>d({...c,alert_type:y}),children:[t.jsx(ut,{children:t.jsx(ft,{})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"deadline",children:"Deadline Alert"}),t.jsx(Pe,{value:"premium_slot",children:"Premium Slot Alert"})]})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"message",children:"Message"}),t.jsx(ms,{id:"message",value:c.message,onChange:y=>
776d({...c,message:y.target.value}),placeholder:"Enter the alert message...",rows:3})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"priority",children:"Priority"}),t.jsx(re,{id:"priority",type:"number",value:c.priority,onChange:y=>d({...c,priority:parseInt(y.target.value)||0})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"badge_text",children:"Badge Text"}),t.jsx(re,{id:"badge_text",value:c.badge_text,onChange:y=>d({...c,badge_text:y.target.value}),placeholder:"e.g., Urgent"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"badge_color",children:"Badge Color"}),t.jsxs(ht,{value:c.badge_color,onValueChange:y=>d({...c,badge_color:y}),children:[t.jsx(ut,{children:t.jsx(ft,{})}),t.jsx(mt,{children:h.map(y=>t.jsx(Pe,{value:y.value,children:t.jsxs("div",{className:"flex items-center",children:[t.jsx("div",{className:`w-3 h-3 rounded-full ${y.class} mr-2`}),y.label]})},y.value))})]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"expires_at",children:"Expiry Date (Optional)"}),t.jsx(re,{id:"expires_at",type:"date",value:c.expires_at,onChange:y=>d({...c,expires_at:y.target.value})})]}),t.jsxs("div",{className:"flex items-center space-x-2 pt-6",children:[t.jsx(kt,{checked:c.is_active,onCheckedChange:y=>d({...c,is_active:y})}),t.jsx(V,{children:"Active"})]})]}),t.jsxs("div",{className:"flex justify-end space-x-2",children:[t.jsx(q,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),t.jsxs(q,{onClick:b,children:[o?"Update":"Create"," Alert"]})]})]})]})})]})};function Rce(){const{toast:e}=rt(),s=Xs(),{data:r,isLoading:n,error:a}=Lt({queryKey:["ad-preview-images"],queryFn:async()=>{const{data:m,error:h}=await W.from("ad_preview_images").select(` 777 *, 778 ad_sizes ( 779 id, 780 name, 781 dimensions 782 ) 783 `).order("sort_order",{ascending:!0});if(h)throw h;return m}}),i=os({mutationFn:async({file:m,adSizeId:h,imageName:f})=>{const p=Date.now();m.name.split(".").pop();const x=`${h}/${p}-${m.name}`,{error:g}=await W.storage.from("ad-preview-images").upload(x,m);if(g)throw g;W.storage.from("ad-preview-images").getPublicUrl(x);const{data:b,error:w}=await W.from("ad_preview_images").insert({ad_size_id:h,image_url:x,image_name:f,is_active:!0}).select().single();if(w)throw w;return b},onSuccess:()=>{s.invalidateQueries({queryKey:["ad-preview-images"]}),e({title:"Success",description:"Preview image uploaded successfully"})},onError:m=>{e({title:"Error",description:m.message||"Failed to upload image",variant:"destructive"})}}),o=os({mutationFn:async m=>{const{error:h}=await W.storage.from("ad-preview-images").remove([m.image_url]);if(h)throw h;const{error:f}=await W.from("ad_preview_images").delete().eq("id",m.id);if(f)throw f},onSuccess:()=>{s.invalidateQueries({queryKey:["ad-preview-images"]}),e({title:"Success",description:"Preview image deleted successfully"})},onError:m=>{e({title:"Error",description:m.message||"Failed to delete image",variant:"destructive"})}}),l=os({mutationFn:async({id:m,isActive:h})=>{const{error:f}=await W.from("ad_preview_images").update({is_active:h}).eq("id",m);if(f)throw f},onSuccess:()=>{s.invalidateQueries({queryKey:["ad-preview-images"]}),e({title:"Success",description:"Status updated successfully"})},onError:m=>{e({title:"Error",description:m.message||"Failed to update status",variant:"destructive"})}}),c=m=>r==null?void 0:r.find(h=>h.ad_size_id===m&&h.is_active),d=m=>{const{data:{publicUrl:h}}=W.storage.from("ad-preview-images").getPublicUrl(m);return h};return{previewImages:r,isLoading:n,error:a,uploadImage:i.mutate,isUploading:i.isPending,deleteImage:o.mutate,isDeleting:o.isPending,toggleActive:l.mutate,getPreviewImageForSize:c,getPublicUrl:d}}function Mce(){var Y;const{toast:e}=rt(),{adSizes:s,isLoading:r}=ji(),{previewImages:n,isLoading:a,uploadImage:i,isUploading:o,deleteImage:l,isDeleting:c,getPublicUrl:d}=Rce(),[m,h]=u.useState(null),[f,p]=u.useState(null),[x,g]=u.useState(""),[b,w]=u.useState(!1),[j,y]=u.useState(!1),[v,N]=u.useState(""),S=u.useRef(null),k=I=>{var L;const C=(L=I.target.files)==null?void 0:L[0];if(C){if(!C.type.startsWith("image/")){e({title:"Invalid File",description:"Please select an image file (JPG, PNG, WebP)",variant:"destructive"});return}if(C.size>5*1024*1024){e({title:"File Too Large",description:"Please select an image under 5MB",variant:"destructive"});return}p(C),g(URL.createObjectURL(C))}},$=I=>{h(I),p(null),g(""),w(!0)},R=()=>
783{if(!f||!m){e({title:"Missing Information",description:"Please select an image file",variant:"destructive"});return}const I=`${m.name||"Preview"} - ${f.name}`;i({file:f,adSizeId:m.id,imageName:I},{onSuccess:()=>{p(null),g(""),h(null),w(!1),S.current&&(S.current.value="")}})},A=()=>{w(!1),p(null),g(""),h(null),S.current&&(S.current.value="")},T=I=>{confirm("Are you sure you want to delete this preview image?")&&l(I)},P=I=>{N(d(I)),y(!0)},B=I=>n==null?void 0:n.find(C=>C.ad_size_id===I&&C.is_active);return r||a?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx(it,{className:"h-8 w-8 animate-spin text-primary"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Ad Preview Image Management"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage custom advertisement images for each ad size shown in the Magazine Preview section."})]}),t.jsxs(xe,{children:[t.jsxs(Me,{children:[t.jsx(Oe,{children:"Preview Images by Ad Size"}),t.jsx(Er,{children:"Click the edit button to upload or replace preview images for each ad size"})]}),t.jsxs(ge,{children:[t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Ad Size"}),t.jsx(ue,{children:"Dimensions"}),t.jsx(ue,{children:"Image Name"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Preview"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:s==null?void 0:s.filter(I=>I.is_active).map(I=>{const C=B(I.id);return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:I.name}),t.jsx(de,{children:I.dimensions}),t.jsx(de,{children:C?t.jsx("span",{className:"text-sm",children:C.image_name}):t.jsx("span",{className:"text-sm text-muted-foreground",children:"No image"})}),t.jsx(de,{children:C?t.jsx(we,{variant:"default",children:"Active"}):t.jsx(we,{variant:"secondary",children:"No Image"})}),t.jsx(de,{children:C?t.jsxs(q,{variant:"ghost",size:"sm",onClick:()=>P(C.image_url),children:[t.jsx(tr,{className:"h-4 w-4 mr-1"}),"View"]}
783):t.jsx("span",{className:"text-sm text-muted-foreground",children:"-"})}),t.jsx(de,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(q,{variant:"outline",size:"sm",onClick:()=>$(I),children:[t.jsx(ra,{className:"h-4 w-4 mr-1"}),C?"Edit":"Upload"]}),C&&t.jsx(q,{variant:"destructive",size:"sm",onClick:()=>T(C),disabled:c,children:c?t.jsx(it,{className:"h-4 w-4 animate-spin"}):t.jsx(cs,{className:"h-4 w-4"})})]})})]},I.id)})})]}),(!s||s.length===0)&&t.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[t.jsx(pi,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),t.jsx("p",{children:"No ad sizes found"})]})]})]}),t.jsx(bt,{open:b,onOpenChange:A,children:t.jsxs(xt,{className:"max-w-2xl",children:[t.jsxs(jt,{children:[t.jsxs(wt,{children:[B(m==null?void 0:m.id)?"Edit":"Upload"," Preview Image - ",m==null?void 0:m.name]}),t.jsxs(ys,{children:[m==null?void 0:m.dimensions," - Upload a high-quality image to preview in the Magazine Preview section"]})]}),t.jsxs("div",{className:"space-y-4 mt-4",children:[t.jsxs(ss,{children:[t.jsx(Hs,{className:"h-4 w-4"}),t.jsx(rs,{children:"Maximum file size: 5MB. Supported formats: JPG, PNG, WebP"})]}),B(m==null?void 0:m.id)&&!f&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium",children:"Current Image"}),t.jsx("div",{className:"border rounded-lg p-4 bg-muted/50",children:t.jsx("img",{src:d((Y=B(m==null?void 0:m.id))==null?void 0:Y.image_url),alt:"Current preview",className:"max-h-64 mx-auto object-contain"})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium",children:B(m==null?void 0:m.id)?"Replace with New Image":"Select Image File"}),t.jsx(re,{ref:S,type:"file",accept:"image/*",onChange:k,className:"cursor-pointer"})]}),x&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium",children:"New Image Preview"}),t.jsx("div",{className:"border rounded-lg p-4 bg-muted/50",children:t.jsx("img",{src:x,alt:"New preview",className:"max-h-64 mx-auto object-contain"})})]}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx(q,{variant:"outline",onClick:A,disabled:o,children:"Cancel"}),t.jsx(q,{onClick:R,disabled:!f||o,children:o?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"mr-2 h-4 w-4 animate-spin"}),"Uploading..."]}):t.jsxs(t.Fragment,{children:[t.jsx(sn,{className:"mr-2 h-4 w-4"}),B(m==null?void 0:m.id)?"Replace Image":"Upload Image"]})})]})]})]})}),t.jsx(bt,{open:j,onOpenChange:y,children:t.jsxs(xt,{className:"max-w-4xl",children:[t.jsx(jt,{children:t.jsx(wt,{children:"Preview Image"})}),t.jsx("div",{className:"mt-4",children:t.jsx("img",{src:v,alt:"Full preview",className:"w-full h-auto rounded-lg"})})]})})]})}const Oce=({edition:e,onEdit:s,onDelete:r,onToggleActive:n})=>{const{attributes:a,listeners:i,setNodeRef:o,transform:l,transition:c,isDragging:d}=t_({id:e.id}),m={transform:$c.Transform.toString(l),transition:c,opacity:d?.5:1,backgroundColor:d?"hsl(var(--muted))":void 0};return t.jsxs(Xe,{ref:o,style:m,children:[t.jsx(de,{children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",className:"cursor-grab active:cursor-grabbing touch-none p-1 hover:bg-muted rounded",...a,...i,children:t.jsx(Su,{className:"h-4 w-4 text-muted-foreground"})}),t.jsx("span",{children:e.sort_order})]})}),t.jsx(de,{children:t.jsx("div",{className:"w-16 h-20 rounded overflow-hidden bg-muted",children:t.jsx("img",{src:e.image_url,alt:e.alt_text||e.title,className:"w-full h-full object-cover"})})}),t.jsx(de,{className:"font-medium",children:e.title}),t.jsx(de,{children:e.content_type==="front_cover"?t.jsxs(we,{variant:"default",className:"gap-1",children:[t.jsx(gl,{className:"h-3 w-3"}),"Front Cover"]}):t.jsxs(we,{variant:"secondary",className:"gap-1",children:[t.jsx(Dc,{className:"h-3 w-3"}),"Online Content"]})}),t.jsx(de,{children:e.issue_month||"-"}),t.jsx(de,{children:e.link_url?t.jsxs("a",{href:e.link_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-primary hover:underline",children:[t.jsx(_u,{className:"h-3 w-3"}),"Link"]}):t.jsx("span",{className:"text-muted-foreground",children:"-"})}),t.jsx(de,{children:t.jsx(kt,{checked:e.is_active,onCheckedChange:h=>n(e.id,h)})}),t.jsx(de,{className:"text-right",children:t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(q,{variant:"outline",size:"sm",onClick:()=>s(e),children:t.jsx(ra,{className:"h-4 w-4"})}),t.jsx(q,{variant:"destructive",size:"sm",onClick:()=>r(e.id),children:t.jsx(cs,{className:"h-4 w-4"})})]})})]})},Ice=()=>{const{data:e,isLoading:s}=Fv(!0),{createEdition:r,updateEdition:n,deleteEdition:a,toggleActive:i,updateSortOrder:o}=IX(),{uploadCoverImage:l,isUploading:c}=FX(),[d,m]=u.useState(!1),[h,f]=u.useState(null),[p,x]=u.useState({title:"",image_url:"",alt_text:"",link_url:"",issue_month:"",sort_order:0,is_active:!0,content_type:"front_cover"}),[g,b]=u.useState(null),[w,j]=u.useState(null),[y,v]=u.useState(!1),N=u.useRef(null),S=YN(tf(tp),tf(ey,{coordinateGetter:e7})),k=()=>{x({title:"",image_url:"",alt_text:"",link_url:"",issue_month:"",sort_order:e!=null&&e.length?e.length+1:1,is_active:!0,content_type:"front_cover"}),f(null),b(null),j(null)},$=_=>{_?(f(_),x({title:_.title,image_url:_.image_url,alt_text:_.alt_text||"",link_url:_.link_url||"",issue_month:_.issue_month||"",sort_order:_.sort_order,is_active:_.is_active,content_type:_.content_type||"front_cover"}),j(_.image_url)):k(),m(!0)},R=u.useCallback(_=>{if(!["image/jpeg","image/png","image/webp"].includes(_.type)){alert("Please upload a JPG, PNG, or WebP image.");return}if(_.size>5242880){alert("File size must be less than 5MB.");return}b(_);const U=URL.createObjectURL(_);j(U)},[]),A=_=>{_.preventDefault(),v(!0)},T=_=>{_.preventDefault(),v(!1)},P=_=>{_.preventDefault(),v(!1);const H=_.dataTransfer.files[0];H&&R(H)},B=_=>{var O;const H=(O=_.target.files)==null?void 0:O[0];H&&R(H)},Y=()=>{b(null),j((h==null?void 0:h.image_url)||null),N.current&&(N.current.value="")},I=async()=>{let _=p.image_url;if(g){const H=await l(g);if(!H)return;_=H}h?await n.mutateAsync({id:h.id,...p,image_url:_,alt_text:p.alt_text||null,link_url:p.link_url||null,issue_month:p.issue_month||null}):await r.mutateAsync({...p,image_url:_,alt_text:p.alt_text||null,link_url:p.link_url||null,issue_month:p.issue_month||null}),m(!1),k()},C=async _=>{confirm("Are you sure you want to delete this edition?")&&await a.mutateAsync(_)},L=_=>{const{active:H,over:O}=_;
783if(O&&H.id!==O.id&&e){const U=e.findIndex(Z=>Z.id===H.id),G=e.findIndex(Z=>Z.id===O.id),z=sp(e,U,G).map((Z,M)=>({id:Z.id,sort_order:M+1}));o.mutate(z)}},D=p.title&&(g||p.image_url);return s?t.jsxs("div",{className:"space-y-6",children:[t.jsx(Is,{className:"h-8 w-64"}),t.jsx(Is,{className:"h-96 w-full"})]}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Magazine Editions"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage the magazine covers displayed on the homepage carousel. Drag to reorder."})]}),t.jsxs(bt,{open:d,onOpenChange:_=>{m(_),_||k()},children:[t.jsx(Sn,{asChild:!0,children:t.jsxs(q,{onClick:()=>$(),children:[t.jsx(Xt,{className:"h-4 w-4 mr-2"}),"Add Edition"]})}),t.jsxs(xt,{className:"max-w-lg max-h-[90vh] flex flex-col",children:[t.jsx(jt,{className:"flex-shrink-0",children:t.jsx(wt,{children:h?"Edit Edition":"Add New Edition"})}),t.jsxs("div",{className:"space-y-4 overflow-y-auto flex-1 pr-2",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"title",children:"Edition Title"}),t.jsx(re,{id:"title",value:p.title,onChange:_=>x({...p,title:_.target.value}),placeholder:"e.g., WINCHESTER & SURROUNDS"})]}),t.jsxs("div",{children:[t.jsx(V,{children:"Cover Image"}),t.jsxs("div",{className:`mt-2 border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${y?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50"}`,onDragOver:A,onDragLeave:T,onDrop:P,onClick:()=>{var _;return(_=N.current)==null?void 0:_.click()},children:[t.jsx("input",{ref:N,type:"file",accept:"image/jpeg,image/png,image/webp",className:"hidden",onChange:B}),w?t.jsxs("div",{className:"relative inline-block",children:[t.jsx("img",{src:w,alt:"Preview",className:"max-h-40 rounded-lg mx-auto"}),g&&t.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),Y()},className:"absolute -top-2 -right-2 bg-destructive text-destructive-foreground rounded-full p-1 hover:bg-destructive/90",children:t.jsx(Es,{className:"h-4 w-4"})}),t.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:g?g.name:"Current image"})]}):t.jsxs("div",{className:"space-y-2",children:[t.jsx(sn,{className:"h-10 w-10 mx-auto text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Drag & drop an image here, or click to browse"}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:"JPG, PNG, or WebP ⢠Max 5MB"})]})]})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"issue_month",children:"Issue Month"}),t.jsx(re,{id:"issue_month",value:p.issue_month,onChange:_=>x({...p,issue_month:_.target.value}),placeholder:"e.g., January 2025"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"alt_text",children:"Alt Text (Accessibility)"}),t.jsx(re,{id:"alt_text",value:p.alt_text,onChange:_=>x({...p,alt_text:_.target.value}),placeholder:"Discover Magazine - Winchester Edition"})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"link_url",children:"Link URL (Optional)"}),t.jsx(re,{id:"link_url",value:p.link_url,onChange:_=>x({...p,link_url:_.target.value}),placeholder:"https://..."})]}),t.jsxs("div",{children:[t.jsx(V,{className:"mb-3 block",children:"Display Location"}),t.jsxs(Da,{value:p.content_type,onValueChange:_=>x({...p,content_type:_}),className:"grid grid-cols-1 gap-3",children:[t.jsxs("div",{className:"flex items-start space-x-3 p-3 border rounded-lg hover:bg-muted/50 cursor-pointer",children:[t.jsx(Ir,{value:"front_cover",id:"front_cover",className:"mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsxs(V,{htmlFor:"front_cover",className:"flex items-center gap-2 cursor-pointer font-medium",children:[t.jsx(gl,{className:"h-4 w-4 text-primary"}),"Front Cover (Homepage)"]}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Displays in the hero carousel on the homepage"})]})]}),t.jsxs("div",{className:"flex items-start space-x-3 p-3 border rounded-lg hover:bg-muted/50 cursor-pointer",children:[t.jsx(Ir,{value:"online_content",id:"online_content",className:"mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsxs(V,{htmlFor:"online_content",className:"flex items-center gap-2 cursor-pointer font-medium",children:[t.jsx(Dc,{className:"h-4 w-4 text-secondary-foreground"}),"Online Content (Advertising Page)"]}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Displays in the Online Edition box on the advertising page"})]})]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"sort_order",children:"Sort Order"}),t.jsx(re,{id:"sort_order",type:"number",value:p.sort_order,onChange:_=>x({...p,sort_order:parseInt(_.target.value)||0})})]}),t.jsxs("div",{className:"flex items-center space-x-2 pt-6",children:[t.jsx(kt,{id:"is_active",checked:p.is_active,onCheckedChange:_=>x({...p,is_active:_})}),t.jsx(V,{htmlFor:"is_active",children:"Active"})]})]})]}),t.jsxs(ma,{className:"flex-shrink-0",children:[t.jsx(q,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),t.jsx(q,{onClick:I,disabled:!D||c||r.isPending||n.isPending,children:c?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):h?"Update":"Create"})]})]})]})]}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{children:["Current Editions (",(e==null?void 0:e.length)||0,")"]})}),t.jsx(ge,{children:e!=null&&e.length?t.jsx("div",{className:"overflow-x-auto",children:t.jsx(ZN,{sensors:S,collisionDetection:KN,onDragEnd:L,children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{className:"w-12",children:"Order"}),t.jsx(ue,{className:"w-24",children:"Preview"}),t.jsx(ue,{children:"Title"}),t.jsx(ue,{children:"Type"}),t.jsx(ue,{children:"Issue Month"}),t.jsx(ue,{children:"Link"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{className:"text-right",children:"Actions"})]})}),t.jsx(Wt,{children:t.jsx(e_,{items:e.map(_=>_.id),strategy:JN,children:e.map(_=>t.jsx(Oce,{edition:_,onEdit:$,onDelete:C,onToggleActive:(H,O)=>
783i.mutate({id:H,is_active:O})},_.id))})})]})})}):t.jsx("div",{className:"text-center py-8 text-muted-foreground",children:t.jsx("p",{children:"No editions found. Add your first edition above."})})})]})]})},Fce=(e,s)=>{const r=s==null?void 0:s.find(n=>n.name===e);return(r==null?void 0:r.color_class)||"bg-gray-100 text-gray-800"},Lce=["image/jpeg","image/png","image/webp"],Bce=5*1024*1024;function zce(){const{data:e,isLoading:s}=iD(!0),{data:r,isLoading:n}=Bee(),{createCompetition:a,updateCompetition:i,deleteCompetition:o,toggleActive:l}=Fee(),c=zee(),[d,m]=u.useState(!1),[h,f]=u.useState(!1),[p,x]=u.useState(null),[g,b]=u.useState(!1),[w,j]=u.useState(null),[y,v]=u.useState(!1),[N,S]=u.useState(!1),[k,$]=u.useState(!1),[R,A]=u.useState(""),[T,P]=u.useState(""),[B,Y]=u.useState({title:"",description:"",prize:"",category:"Other",image_url:"",end_date:"",is_active:!0}),I=()=>{Y({title:"",description:"",prize:"",category:"Other",image_url:"",end_date:"",is_active:!0}),x(null)},C=F=>{F?(x(F),Y({title:F.title,description:F.description,prize:F.prize,category:F.category,image_url:F.image_url||"",end_date:F.end_date.split("T")[0],is_active:F.is_active})):I(),m(!0)},L=async F=>{if(!Lce.includes(F.type))return ks.error("Invalid file type. Please upload JPG, PNG, or WebP."),null;if(F.size>Bce)return ks.error("File too large. Maximum size is 5MB."),null;v(!0);try{const ee=F.name.split(".").pop(),le=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ee}`,{error:X}=await W.storage.from("competition-images").upload(le,F);if(X)throw X;const{data:{publicUrl:ye}}=W.storage.from("competition-images").getPublicUrl(le);return ye}catch(ee){return console.error("Upload error:",ee),ks.error("Failed to upload image"),null}finally{v(!1)}},D=async F=>{const ee=await L(F);ee&&Y({...B,image_url:ee})},_=u.useCallback(async F=>{F.preventDefault(),S(!1);const ee=F.dataTransfer.files[0];ee&&await D(ee)},[B]),H=u.useCallback(F=>{F.preventDefault(),S(!0)},[]),O=u.useCallback(F=>{F.preventDefault(),S(!1)},[]),U=async F=>{var se;const ee=(se=F.target.files)==null?void 0:se[0];ee&&await D(ee)},G=()=>{Y({...B,image_url:""})},E=async()=>{const F={...B,end_date:new Date(B.end_date).toISOString(),image_url:B.image_url||null};p?await i.mutateAsync({id:p.id,...F}):await a.mutateAsync(F),m(!1),I()},z=async()=>{w&&(await o.mutateAsync(w.id),b(!1),j(null))},Z=(e==null?void 0:e.filter(F=>F.is_active&&!Aj(new Date(F.end_date))))||[],M=(e==null?void 0:e.reduce((F,ee)=>F+ee.entry_count,0))||0;return s?t.jsx("div",{className:"p-6",children:"Loading competitions..."}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[t.jsxs(xe,{children:[t.jsxs(Me,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(Oe,{className:"text-sm font-medium",children:"Total Competitions"}),t.jsx(hi,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(ge,{children:t.jsx("div",{className:"text-2xl font-bold",children:(e==null?void 0:e.length)||0})})]}),t.jsxs(xe,{children:[t.jsxs(Me,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(Oe,{className:"text-sm font-medium",children:"Active Competitions"}),t.jsx(yr,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(ge,{children:t.jsx("div",{className:"text-2xl font-bold",children:Z.length})})]}),t.jsxs(xe,{children:[t.jsxs(Me,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(Oe,{className:"text-sm font-medium",children:"Total Entries"}),t.jsx(ua,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(ge,{children:t.jsx("div",{className:"text-2xl font-bold",children:M})})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Competitions"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage competitions and view entries"})]}),t.jsxs(q,{onClick:()=>C(),children:[t.jsx(Xt,{className:"h-4 w-4 mr-2"}),"Add Competition"]})]}),t.jsx(xe,{children:t.jsx(ge,{className:"p-0",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{className:"w-[80px]",children:"Image"}),t.jsx(ue,{children:"Title"}),t.jsx(ue,{children:"Category"}),t.jsx(ue,{children:"Prize"}),t.jsx(ue,{children:"End Date"}),t.jsx(ue,{className:"text-center",children:"Entries"}),t.jsx(ue,{className:"text-center",children:"Active"}),t.jsx(ue,{className:"text-right",children:"Actions"})]})}),t.jsxs(Wt,{children:[e==null?void 0:e.map(F=>{const ee=Aj(new Date(F.end_date));return t.jsxs(Xe,{className:ee?"opacity-60":"",children:[t.jsx(de,{children:F.image_url?t.jsx("img",{src:F.image_url,alt:F.title,className:"h-12 w-12 rounded object-cover"}):t.jsx("div",{className:"h-12 w-12 rounded bg-muted flex items-center justify-center",children:t.jsx(hi,{className:"h-5 w-5 text-muted-foreground"})})}),t.jsx(de,{className:"font-medium",children:F.title}),t.jsx(de,{children:t.jsx(we,{variant:"secondary",className:Fce(F.category,r),children:F.category})}),t.jsx(de,{children:F.prize}),t.jsx(de,{children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-sm",children:Dt(new Date(F.end_date),"MMM d, yyyy")}),t.jsx("span",{className:`text-xs ${ee?"text-destructive":"text-muted-foreground"}`,children:ee?"Ended":UK(new Date(F.end_date),{addSuffix:!0})})]})}),t.jsx(de,{className:"text-center",children:t.jsxs(q,{variant:"ghost",size:"sm",onClick:()=>{x(F),f(!0)},children:[t.jsx(ua,{className:"h-4 w-4 mr-1"}),F.entry_count]})}),t.jsx(de,{className:"text-center",children:t.jsx(kt,{checked:F.is_active,onCheckedChange:se=>l.mutate({id:F.id,is_active:se})})}),t.jsx(de,{className:"text-right",children:t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(q,{variant:"ghost",size:"icon",onClick:()=>C(F),children:t.jsx(ra,{className:"h-4 w-4"})}),t.jsx(q,{variant:"ghost",size:"icon",onClick:()=>{j(F),b(!0)},children:t.jsx(cs,{className:"h-4 w-4 text-destructive"})})]})})]},F.id)}),(!e||e.length===0)&&t.jsx(Xe,{children:t.jsx(de,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:'No competitions yet. Click "Add Competition" to create one.'})})]})]})})}),t.jsx(bt,{open:d,onOpenChange:m,children:t.jsxs(xt,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[t.jsxs(jt,{children:[t.jsx(wt,{children:p?"Edit Competition":"Add Competition"}),t.jsx(ys,{children:p?"Update the competition details below.":"Fill in the details to create a new competition."})]}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"title",children:"Title *"}),t.jsx(re,{id:"title",value:B.title,onChange:F=>Y({...B,title:F.target.value}),placeholder:"Win a Weekend Getaway"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"description",children:"Description *"}
783),t.jsx(ms,{id:"description",value:B.description,onChange:F=>Y({...B,description:F.target.value}),placeholder:"Enter to win an amazing prize...",rows:3})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"prize",children:"Prize *"}),t.jsx(re,{id:"prize",value:B.prize,onChange:F=>Y({...B,prize:F.target.value}),placeholder:"£500 Voucher"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"category",children:"Category *"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(ht,{value:B.category,onValueChange:F=>Y({...B,category:F}),children:[t.jsx(ut,{className:"flex-1",children:t.jsx(ft,{placeholder:"Select a category"})}),t.jsx(mt,{children:r==null?void 0:r.map(F=>t.jsx(Pe,{value:F.name,children:F.label},F.id))})]}),t.jsxs(Cn,{open:k,onOpenChange:$,children:[t.jsx(kn,{asChild:!0,children:t.jsx(q,{variant:"outline",size:"icon",type:"button",children:t.jsx(Xt,{className:"h-4 w-4"})})}),t.jsx(en,{className:"w-80",align:"end",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h4",{className:"font-medium leading-none",children:"Add New Category"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Create a custom category for competitions."})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"new-category-name",children:"Category Name"}),t.jsx(re,{id:"new-category-name",placeholder:"e.g., Sports",value:R,onChange:F=>A(F.target.value)})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"new-category-label",children:"Display Label"}),t.jsx(re,{id:"new-category-label",placeholder:"e.g., Sports & Fitness",value:T,onChange:F=>P(F.target.value)})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(q,{variant:"outline",size:"sm",onClick:()=>{$(!1),A(""),P("")},children:"Cancel"}),t.jsx(q,{size:"sm",disabled:!R||!T||c.isPending,onClick:async()=>{await c.mutateAsync({name:R,label:T}),Y({...B,category:R}),$(!1),A(""),P("")},children:c.isPending?t.jsx(it,{className:"h-4 w-4 animate-spin"}):"Add"})]})]})})]})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Competition Image"}),B.image_url?t.jsxs("div",{className:"relative",children:[t.jsx("img",{src:B.image_url,alt:"Competition preview",className:"w-full h-40 object-cover rounded-lg border"}),t.jsx(q,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-8 w-8",onClick:G,children:t.jsx(Es,{className:"h-4 w-4"})})]}):t.jsxs("div",{onDrop:_,onDragOver:H,onDragLeave:O,className:` 784 relative border-2 border-dashed rounded-lg p-8 text-center transition-colors cursor-pointer 785 ${N?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50"} 786 ${y?"pointer-events-none opacity-60":""} 787 `,children:[t.jsx("input",{type:"file",accept:"image/jpeg,image/png,image/webp",onChange:U,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",disabled:y}),t.jsx("div",{className:"flex flex-col items-center gap-2",children:y?t.jsxs(t.Fragment,{children:[t.jsx(it,{className:"h-10 w-10 text-muted-foreground animate-spin"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}):t.jsxs(t.Fragment,{children:[t.jsx(sn,{className:"h-10 w-10 text-muted-foreground"}),t.jsx("p",{className:"text-sm font-medium",children:"Drop image here or click to browse"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"JPG, PNG, or WebP (max 5MB)"})]})})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"end_date",children:"End Date *"}),t.jsx(re,{id:"end_date",type:"date",value:B.end_date,onChange:F=>Y({...B,end_date:F.target.value})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Status"}),t.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[t.jsx(kt,{checked:B.is_active,onCheckedChange:F=>Y({...B,is_active:F})}),t.jsx(V,{className:"font-normal",children:B.is_active?"Active":"Inactive"})]})]})]})]}),t.jsxs(ma,{children:[t.jsx(q,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),t.jsx(q,{onClick:E,disabled:!B.title||!B.description||!B.prize||!B.end_date||y,children:p?"Save Changes":"Create Competition"})]})]})}),t.jsx(bt,{open:g,onOpenChange:b,children:t.jsxs(xt,{children:[t.jsxs(jt,{children:[t.jsx(wt,{children:"Delete Competition"}),t.jsxs(ys,{children:['Are you sure you want to delete "',w==null?void 0:w.title,'"? This action cannot be undone and will also delete all entries.']})]}),t.jsxs(ma,{children:[t.jsx(q,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),t.jsx(q,{variant:"destructive",onClick:z,children:"Delete"})]})]})}),p&&t.jsx(Uce,{competition:p,open:h,onOpenChange:f})]})}function Uce({competition:e,open:s,onOpenChange:r}){const{data:n,isLoading:a}=Iee(e.id);return t.jsx(bt,{open:s,onOpenChange:r,children:t.jsxs(xt,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[t.jsxs(jt,{children:[t.jsxs(wt,{children:['Entries for "',e.title,'"']}),t.jsxs(ys,{children:[(n==null?void 0:n.length)||0," total entries"]})]}),t.jsx("div",{className:"flex-1 overflow-auto",children:a?t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"Loading entr
787ies..."}):n&&n.length>0?t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Name"}),t.jsx(ue,{children:"Email"}),t.jsx(ue,{children:"Phone"}),t.jsx(ue,{children:"Date"})]})}),t.jsx(Wt,{children:n.map(i=>t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:i.name}),t.jsx(de,{children:i.email}),t.jsx(de,{children:i.phone||"-"}),t.jsx(de,{children:Dt(new Date(i.created_at),"MMM d, yyyy HH:mm")})]},i.id))})]}):t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"No entries yet for this competition."})})]})})}function Vce(e,s=[]){let r=[];function n(i,o){const l=u.createContext(o),c=r.length;r=[...r,o];function d(h){const{scope:f,children:p,...x}=h,g=(f==null?void 0:f[e][c])||l,b=u.useMemo(()=>x,Object.values(x));return t.jsx(g.Provider,{value:b,children:p})}function m(h,f){const p=(f==null?void 0:f[e][c])||l,x=u.useContext(p);if(x)return x;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return d.displayName=i+"Provider",[d,m]}const a=()=>{const i=r.map(o=>u.createContext(o));return function(l){const c=(l==null?void 0:l[e])||i;return u.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[n,qce(a,...s)]}function qce(...e){const s=e[0];if(e.length===1)return s;const r=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=n.reduce((l,{useScope:c,scopeName:d})=>{const h=c(i)[`__scope${d}`];return{...l,...h}},{});return u.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return r.scopeName=s.scopeName,r}var s_="Progress",r_=100,[Hce,Pfe]=Vce(s_),[Wce,Gce]=Hce(s_),s7=u.forwardRef((e,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:i=Yce,...o}=e;(a||a===0)&&!mC(a)&&console.error(Kce(`${a}`,"Progress"));const l=mC(a)?a:r_;n!==null&&!hC(n,l)&&console.error(Qce(`${n}`,"Progress"));const c=hC(n,l)?n:null,d=Ag(c)?i(c,l):void 0;return t.jsx(Wce,{scope:r,value:c,max:l,children:t.jsx(ze.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":Ag(c)?c:void 0,"aria-valuetext":d,role:"progressbar","data-state":a7(c,l),"data-value":c??void 0,"data-max":l,...o,ref:s})})});s7.displayName=s_;var r7="ProgressIndicator",n7=u.forwardRef((e,s)=>{const{__scopeProgress:r,...n}=e,a=Gce(r7,r);return t.jsx(ze.div,{"data-state":a7(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});n7.displayName=r7;function Yce(e,s){return`${Math.round(e/s*100)}%`}function a7(e,s){return e==null?"indeterminate":e===s?"complete":"loading"}function Ag(e){return typeof e=="number"}function mC(e){return Ag(e)&&!isNaN(e)&&e>0}function hC(e,s){return Ag(e)&&!isNaN(e)&&e<=s&&e>=0}function Kce(e,s){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${r_}\`.`}function Qce(e,s){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${s}\`. The \`value\` prop must be: 788 - a positive number 789 - less than the value passed to \`max\` (or ${r_} if no \`max\` prop is set) 790 - \`null\` or \`undefined\` if the progress is indeterminate. 791 792Defaulting to \`null\`.`}var i7=s7,Xce=n7;const n_=u.forwardRef(({className:e,value:s,...r},n)=>t.jsx(i7,{ref:n,className:oe("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...r,children:t.jsx(Xce,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));n_.displayName=i7.displayName;const Zce={description:"Description",phone:"Phone",email:"Email",website:"Website",logo_url:"Logo",facebook_url:"Facebook",instagram_url:"Instagram",twitter_url:"Twitter",linkedin_url:"LinkedIn"};function Jce(){const[e,s]=u.useState([]),[r,n]=u.useState(!0),[a,i]=u.useState(null),{toast:o}=rt(),l=async()=>{n(!0);const{data:d,error:m}=await W.from("business_import_conflicts").select("id, business_id, field_name, crm_value, current_value, created_at, businesses(name)").eq("status","pending").order("created_at",{ascending:!1});m?o({title:"Could not load conflicts",description:m.message,variant:"destructive"}):s(d||[]),n(!1)};u.useEffect(()=>{l()},[]);const c=async(d,m)=>{var h;i(d.id);try{const{data:f}=await W.auth.getUser();if(m){const{error:x}=await W.from("businesses").update({[d.field_name]:d.crm_value}).eq("id",d.business_id);if(x)throw x}const{error:p}=await W.from("business_import_conflicts").update({status:m?"accepted":"dismissed",resolved_at:new Date().toISOString(),resolved_by:((h=f.user)==null?void 0:h.id)??null}).eq("id",d.id);if(p)throw p;s(x=>x.filter(g=>g.id!==d.id)),o({title:m?"CRM value applied":"Conflict dismissed",description:m?"The listing now shows the CRM value.":"The listing was left as the owner has it."})}catch(f){o({title:"Could not save",description:f.message,variant:"destructive"})}finally{i(null)}};return t.jsxs(xe,{children:[t.jsxs(Me,{className:"flex flex-row items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx(Oe,{children:"Owner field conflicts"}),t.jsx(Er,{children:"Fields the CRM wants to change but a business owner maintains. Accept to use the CRM value, or dismiss to leave the listing alone."})]}),t.jsxs(q,{variant:"ghost",size:"sm",onClick:l,disabled:r,children:[t.jsx(kw,{className:"h-4 w-4 mr-2"}),"Refresh"]})]}),t.jsx(ge,{children:r?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):e.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No conflicts waiting for review."}):t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Business"}),t.jsx(ue,{children:"Field"}),t.jsx(ue,{children:"Current (owner)"}),t.jsx(ue,{children:"CRM value"}),t.jsx(ue,{className:"text-right",children:"Action"})]})}),t.jsx(Wt,{children:e.map(d=>{var m;return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:((m=d.businesses)==null?void 0:m.name)||"â"}),t.jsx(de,{children:t.jsx(we,{variant:"secondary",children:Zce[d.field_name]||d.field_name})}),t.jsx(de,{className:"max-w-[220px] truncate text-muted-foreground",title:d.current_value||"",children:d.current_value||"â"}),t.jsx(de,{className:"max-w-[220px] truncate",title:d.crm_value||"Import wants to clear this field",children:d.crm_value?d.crm_value:t.jsx("span",{className:"text-amber-600",children:"Import wants to clear this field"})}),t.jsxs(de,{className:"text-right whitespace-nowrap",children:[t.jsxs(q,{size:"sm",variant:"outline",className:"mr-2",disabled:a===d.id,onClick:()=>c(d,!0),children:[t.jsx(Bs,{className:"h-4 w-4 mr-1"})," Accept"]}),t.jsxs(q,{size:"sm",variant:"ghost",disabled:a===d.id,onClick:()=>c(d,!1),children:[t.jsx(Es,{className:"h-4 w-4 mr-1"})," Dismiss"]})]})]},d.id)})})]})})]})}function fC(e){const s=[];let r="",n=!1;for(let a=0;a<e.length;a++){const i=e[a];i==='"'?n&&e[a+1]==='"'?(r+='"',a++):n=!n:i===","&&!n?(s.push(r),r=""):r+=i}return s.push(r),s}const ede=["crm company id","company id","crm id","record id","mirola company id"];function tde(e){const s=[];let r="",n=!1;for(let l=0;l<e.length;l++){const c=e[l];c==='"'&&(n=!n),(c===` 793`||c==="\r")&&!n?(r.trim()&&s.push(r),r="",c==="\r"&&e[l+1]===` 794`&&l++):r+=c}if(r.trim()&&s.push(r),s.length===0)throw new Error("CSV file is empty");const i=fC(s[0]).map(l=>l.trim().replace(/^"|"$/g,"").toLowerCase()).findIndex(l=>ede.includes(l));if(i===-1)throw new Error('No "Company ID" column found in this file');const o=[];for(let l=1;l<s.length;l++){const c=(fC(s[l])[i]??"").trim().replace(/^"|"$/g,"");c&&o.push(c)}return Array.from(new Set(o))}function sde(){const[e,s]=u.useState([]),[r,n]=u.useState(""),[a,i]=u.useState(null),[o,l]=u.useState(null),[c,d]=u.useState(!1),m=u.useRef(null),{toast:h}=rt(),f=()=>{s([]),n(""),i(null),l(null),m.current&&(m.current.value="")},p=async y=>{var N;const v=(N=y.target.files)==null?void 0:N[0];if(v)try{const S=tde(await v.text());s(S),n(""),i(null),l(null),h({title:"File loaded",description:`${S.length} Company IDs found.`})}catch(S){h({title:"Could not read file",description:S.message,variant:"destructive"})}},x=()=>r.trim()?Array.from(new Set(r.split(/\r?\n/).map(y=>
794y.trim()).filter(Boolean))):e,g=async(y,v=!1)=>{const N=x();if(N.length===0)return h({title:"Nothing to process",description:"Upload a CSV or paste Company IDs first.",variant:"destructive"}),null;const{data:S,error:k}=await W.functions.invoke("import-directory-csv",{body:{mode:y,crmIds:N,force:v}});if(k)throw new Error(k.message);if(S!=null&&S.error&&!(S!=null&&S.blocked))throw new Error(S.error);return S},b=async()=>{d(!0),l(null);try{const y=await g("featured-preview");y&&i(y)}catch(y){h({title:"Preview failed",description:y.message,variant:"destructive"})}finally{d(!1)}},w=async y=>{d(!0);try{const v=await g("featured-apply",y);if(!v)return;if(v.blocked){h({title:"Blocked by safety guard",description:v.error,variant:"destructive"});return}l({featured:v.featured,unfeatured:v.unfeatured}),i(null),h({title:"Featured advertisers updated",description:`${v.featured} featured, ${v.unfeatured} unfeatured.`})}catch(v){h({title:"Update failed",description:v.message,variant:"destructive"})}finally{d(!1)}},j=x().length;return t.jsxs(xe,{children:[t.jsxs(Me,{children:[t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(mr,{className:"h-5 w-5"})," Set featured advertisers"]}),t.jsx(Er,{children:"Upload the CRM export filtered to Current Advertiser, or paste Company IDs one per line. The list is the complete set â anyone not on it stops being featured."})]}),t.jsxs(ge,{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("input",{ref:m,type:"file",accept:".csv",onChange:p,className:"hidden",id:"featured-csv"}),t.jsxs(q,{variant:"outline",onClick:()=>{var y;return(y=m.current)==null?void 0:y.click()},disabled:c,children:[t.jsx(Gx,{className:"h-4 w-4 mr-2"})," Choose CSV file"]}),t.jsx(q,{onClick:b,disabled:c||j===0,children:c?"Workingâ¦":"Preview changes"}),(j>0||a||o)&&t.jsxs(q,{variant:"ghost",onClick:f,disabled:c,children:[t.jsx(cs,{className:"h-4 w-4 mr-2"})," Clear"]}),j>0&&t.jsxs("span",{className:"text-sm text-muted-foreground",children:[j," Company IDs ready"]})]}),t.jsx(ms,{value:r,onChange:y=>{n(y.target.value),i(null),l(null)},placeholder:"Or paste Company IDs here, one per line",rows:4,disabled:c}),a&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[t.jsx(vm,{label:"Will become featured",value:a.willFeature}),t.jsx(vm,{label:"Already featured",value:a.alreadyFeatured}),t.jsx(vm,{label:"Will stop being featured",value:a.willUnfeature}),t.jsx(vm,{label:"Matched but switched off",value:a.inactiveCount}),t.jsx(vm,{label:"No match in directory",value:a.unmatchedCount})]}),a.exceedsThreshold&&t.jsxs(ss,{variant:"destructive",children:[t.jsx(lx,{className:"h-4 w-4"}),t.jsxs(Sa,{children:["This would unfeature ",a.percentUnfeatured,"% of currently featured listings"]}),t.jsxs(rs,{children:["That is above the ",a.thresholdPercent,"% safety threshold. Check the file is complete before overriding â a truncated file would empty the Featured tier."]})]}),a.unfeatureList.length>0&&t.jsx(T0,{title:"Will stop being featured",headers:["Name","Company ID"],rows:a.unfeatureList.map(y=>[y.name,y.crmId]),total:a.willUnfeature}),a.inactiveMatches.length>0&&t.jsx(T0,{title:"In the directory but switched off â cannot be featured",headers:["Name","Company ID"],rows:a.inactiveMatches.map(y=>[y.name,y.crmId]),total:a.inactiveCount}),a.unmatched.length>0&&t.jsx(T0,{title:"No match at all â never imported, most likely no in-scope area",headers:["Company ID"],rows:a.unmatched.map(y=>[y]),total:a.unmatchedCount}),t.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[t.jsx(q,{onClick:()=>w(a.exceedsThreshold),disabled:c,variant:a.exceedsThreshold?"destructive":"default",children:a.exceedsThreshold?"Apply anyway (override)":"Confirm and apply"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"Only the featured flag changes. Nothing else is touched."})]})]}),o&&t.jsxs(ss,{children:[t.jsx(xs,{className:"h-4 w-4"}),t.jsx(Sa,{children:"Featured tier updated"}),t.jsxs(rs,{children:[o.featured," newly featured, ",o.unfeatured," removed from the Featured tier."]})]}
794),!a&&!o&&j>0&&t.jsxs(ss,{children:[t.jsx(mi,{className:"h-4 w-4"}),t.jsx(Sa,{children:"Nothing written yet"}),t.jsx(rs,{children:"Run the preview and confirm before anything changes."})]})]})]})}function vm({label:e,value:s}){return t.jsxs("div",{className:"rounded-lg border p-3",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:e}),t.jsx("div",{className:"text-2xl font-semibold",children:s.toLocaleString()})]})}function T0({title:e,headers:s,rows:r,total:n}){return t.jsxs("div",{children:[t.jsxs("h4",{className:"font-medium mb-2",children:[e," ",t.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",n,")"]})]}),t.jsx("div",{className:"max-h-72 overflow-auto rounded-md border",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsx(Xe,{children:s.map(a=>t.jsx(ue,{children:a},a))})}),t.jsx(Wt,{children:r.map((a,i)=>t.jsx(Xe,{children:a.map((o,l)=>t.jsx(de,{className:"text-sm",children:o},l))},i))})]})}),n>r.length&&t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Showing first ",r.length," of ",n,"."]})]})}function o7(e,s){switch(e){case"applied":case"forced":{const r=s??0;return`${r.toLocaleString()} listing${r===1?"":"s"} switched off${e==="forced"?" (safety limit overridden)":""}`}case"skipped_volume":return"Listings not in the file were left switched on (above the 20% safety limit)";case"skipped_not_requested":return"Listings not in the file were left switched on (not requested)";case"skipped_incomplete":return"Import incomplete â no listings were switched off";case"failed_error":return"The switch-off check failed â no listings were switched off";default:return"Listings not in the file were left switched on"}}const pC=()=>({complete:0,failed:0,inserted:0,updated:0,rejected:0,removedSkipped:0,hasCounts:!1});function rde(){const[e,s]=u.useState([]),[r,n]=u.useState({}),[a,i]=u.useState(!0),o=async()=>{i(!0);const{data:l}=await W.from("business_import_runs").select("import_run_id, created_at, completed_at, total_rows, total_batches, status, deactivation_status, deactivated_count").order("created_at",{ascending:!1}).limit(10),c=l??[];if(s(c),c.length>0){const{data:d}=await W.from("business_import_batches").select("import_run_id, status, inserted_count, updated_count, rejected_count, removed_skipped_count").in("import_run_id",c.map(h=>h.import_run_id)),m={};for(const h of d??[]){const f=m[h.import_run_id]??pC();h.status==="complete"?(f.complete+=1,(h.inserted_count!==null||h.updated_count!==null)&&(f.hasCounts=!0),f.inserted+=h.inserted_count??0,f.updated+=h.updated_count??0,f.rejected+=h.rejected_count??0,f.removedSkipped+=h.removed_skipped_count??0):h.status==="failed"&&(f.failed+=1),m[h.import_run_id]=f}n(m)}else n({});i(!1)};return u.useEffect(()=>{o()},[]),t.jsxs(xe,{children:[t.jsxs(Me,{className:"flex flex-row items-center justify-between space-y-0",children:[t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(eL,{className:"h-5 w-5"})," Recent imports"]}),t.jsxs(q,{size:"sm",variant:"ghost",onClick:o,disabled:a,children:[t.jsx(kw,{className:`h-4 w-4 mr-2 ${a?"animate-spin":""}`}),"Refresh"]})]}),t.jsxs(ge,{children:[e.length===0&&!a&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"No imports yet."}),t.jsx("div",{className:"space-y-3",children:e.map(l=>{const c=r[l.import_run_id]??pC(),d=l.total_batches>0&&c.complete>=l.total_batches&&c.failed===0,m=l.status==="pending"&&c.complete===0,h=d||l.status==="complete";return t.jsxs("div",{className:"rounded-lg border p-3 space-y-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:new Date(l.created_at).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}),m?t.jsx(we,{variant:"outline",children:"Validated, not run"}):h?t.jsx(we,{variant:"secondary",children:"Finished"}):l.status==="failed"?t.jsx(we,{variant:"destructive",children:"Incomplete"}):t.jsx(we,{variant:"outline",children:"In progress"})]}),m?t.jsxs("p",{className:"text-sm text-muted-foreground",children:[l.total_rows.toLocaleStr
794ing()," rows checked. Nothing was written."]}):t.jsxs(t.Fragment,{children:[c.hasCounts?t.jsxs("p",{className:"text-sm text-muted-foreground",children:[l.total_rows.toLocaleString()," rows in the file ·"," ",(c.inserted+c.updated).toLocaleString()," imported"," ",t.jsxs("span",{className:"text-xs",children:["(",c.inserted.toLocaleString()," added, ",c.updated.toLocaleString()," updated)"]})," ","·"," ",c.rejected>0?t.jsxs("span",{className:"font-semibold text-destructive",children:[c.rejected.toLocaleString()," rejected"]}):t.jsx(t.Fragment,{children:"0 rejected"}),c.removedSkipped>0&&t.jsxs(t.Fragment,{children:[" · ",c.removedSkipped.toLocaleString()," skipped (Removed in CRM)"]})," ","· ",c.failed," failed ",c.failed===1?"batch":"batches"]}):t.jsxs("p",{className:"text-sm text-muted-foreground",children:[l.total_rows.toLocaleString()," rows in the file · counts not recorded ·"," ",c.failed," failed ",c.failed===1?"batch":"batches"]}),t.jsx("p",{className:"text-sm",children:o7(l.deactivation_status,l.deactivated_count)})]})]},l.import_run_id)})})]})]})}const nde=["CRM Company ID","Business Name","Email","Phone Number","Website","Address Line 1","Address Line 2","City","Postal Code","Logo URL","Checkatrade URL","Toggle Ltd","Toggle Mobile","Toggle Commercial only","Toggle Family Run","Toggle Owner Run","Toggle National","Toggle Regional","Toggle Local","Directory keywords","Directory keywords","Directory keywords","Directory keywords","Directory keywords","Tags"],ade=[["CRM-1001","Example Plumbing Ltd","[email protected]","023 8000 0000","www.exampleplumbing.co.uk","1 High Street","","Southampton","SO15 1AA","","www.checkatrade.com/trades/exampleplumbing","Y","Y","","","","","","Y","plumber","heating","gas","","","area 5; area 13; ltd; mobile"],["CRM-1002","Example Garden Care","[email protected]","023 8000 0001","www.examplegardens.co.uk","2 Park Road","","Eastleigh","SO50 4AA","","","","","Y","Y","","","Y","","gardener","landscaping","","","","area 9; commercial only; family run"]],ide=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e;function m1(e,s){const r=s.map(i=>i.map(o=>ide(o??"")).join(",")).join(`\r 795`),n=URL.createObjectURL(new Blob([r],{type:"text/csv;charset=utf-8;"})),a=document.createElement("a");a.href=n,a.download=e,a.click(),URL.revokeObjectURL(n)}function ode(){m1("directory-import-template.csv",[nde,...ade])}const uo=500;function lde(e,s){return e===s?e:e==="none"?s:s==="none"?e:"both"}function xC(e){const s=[];let r="",n=!1;for(let a=0;a<e.length;a++){const i=e[a];i==='"'?n&&e[a+1]==='"'?(r+='"',a++):n=!n:i===","&&!n?(s.push(r),r=""):r+=i}return s.push(r),s}function cde(e){const s=[];let r="",n=!1;for(let c=0;c<e.length;c++){const d=e[c];d==='"'&&(n=!n),(d===` 796`||d==="\r")&&!n?(r.trim()&&s.push(r),r="",d==="\r"&&e[c+1]===` 797`&&c++):r+=d}if(r.trim()&&s.push(r),s.length===0)throw new Error("CSV file is empty");const a=xC(s[0]).map(c=>c.trim().replace(/^"|"$/g,"")),i=new Map,o=a.map(c=>{const d=(i.get(c)??0)+1;return i.set(c,d),d===1?c:`${c} ${d}`}),l=[];for(let c=1;c<s.length;c++){const d=xC(s[c]),m={};o.forEach((h,f)=>{m[h]=(d[f]??"").trim().replace(/^"|"$/g,"")}),l.push(m)}return{headers:a,rows:l}}function dde(){var B,Y;const[e,s]=u.useState(null),[r,n]=u.useState(null),[a,i]=u.useState(null),[o,l]=u.useState("idle"),[c,d]=u.useState(0),[m,h]=u.useState(!1),[f,p]=u.useState(!1),[x,g]=u.useState(!1),b=u.useRef(null),{toast:w}=rt(),j=()=>{s(null),n(null),i(null),d(0),b.current&&(b.current.value="")},y=async I=>{var L;const C=(L=I.target.files)==null?void 0:L[0];if(C)try{const D=cde(await C.text());s(D),n(null),i(null),w({title:"CSV loaded",description:`${D.rows.length.toLocaleString()} rows ready to validate.`})}catch(D){w({title:"Could not read file",description:D.message,variant:"destructive"})}},v=async()=>{if(!e)return;l("validating"),d(0),i(null);const I=Math.ceil(e.rows.length/uo),C={importRunId:"",toInsert:0,toUpdate:0,rejected:[],partiallyResolved:[],suppressedSkipped:[],removedSkipped:[],noKeywords:[],newKeywords:[],conflicts:[],keywordColumnCount:0,toggleColumns:{recognised:[],unknown:[]},toggleMode:"untouched",toggleSource:"none",toggleChanges:0,checkatradeDetected:!1,phoneSki
797pped:0,phoneSkippedExamples:[],phoneCleared:0,blankCellsKept:0,deactivationPreview:null};try{for(let L=0;L<I;L++){const D=e.rows.slice(L*uo,(L+1)*uo),{data:_,error:H}=await W.functions.invoke("import-directory-csv",{body:{mode:"validate",rows:D,batchIndex:L,rowOffset:L*uo,totalBatches:I,totalRows:e.rows.length,importRunId:C.importRunId||void 0,isFinal:L===I-1}});if(H)throw new Error(H.message);if(_!=null&&_.error)throw new Error(_.error);C.importRunId=_.importRunId,C.toInsert+=_.toInsert,C.toUpdate+=_.toUpdate,C.rejected.push(..._.rejected),C.partiallyResolved.push(..._.partiallyResolved),C.suppressedSkipped.push(..._.suppressedSkipped),C.removedSkipped.push(..._.removedSkipped??[]),C.noKeywords.push(..._.noKeywords),C.conflicts.push(..._.conflicts);for(const O of _.newKeywords)C.newKeywords.includes(O)||C.newKeywords.push(O);_.deactivationPreview&&(C.deactivationPreview=_.deactivationPreview),C.keywordColumnCount=Math.max(C.keywordColumnCount,_.keywordColumnCount??0),C.toggleColumns=_.toggleColumns??C.toggleColumns,C.toggleMode=_.toggleMode==="declarative"?"declarative":C.toggleMode,C.toggleSource=lde(C.toggleSource,_.toggleSource??"none"),C.toggleChanges+=_.toggleChanges??0,C.checkatradeDetected=C.checkatradeDetected||!!_.checkatradeDetected,C.phoneSkipped+=_.phoneSkipped??0,C.phoneCleared+=_.phoneCleared??0,C.blankCellsKept+=_.blankCellsKept??0;for(const O of _.phoneSkippedExamples??[])C.phoneSkippedExamples.length<20&&C.phoneSkippedExamples.push(O);d(Math.round((L+1)/I*100))}n({...C}),w({title:"Validation complete",description:"Nothing has been written yet. Review the report below."})}catch(L){w({title:"Validation failed",description:L.message,variant:"destructive"})}finally{l("idle")}},N=async(I,C)=>{const{data:L,error:D}=await W.functions.invoke("import-directory-csv",{body:{mode:"deactivate",importRunId:I,forceDeactivate:C}});if(D)throw new Error(D.message);if(L!=null&&L.error)throw new Error(L.error);return L},S=async()=>{if(!e||!r)return;l("importing"),d(0);const I=Math.ceil(e.rows.length/uo),C={inserted:0,updated:0,rejected:0,suppressedSkipped:0,removedSkipped:0,conflictsRecorded:0,errors:[],deactivation:null};try{for(let L=0;L<I;L++){const D=e.rows.slice(L*uo,(L+1)*uo),{data:_,error:H}=await W.functions.invoke("import-directory-csv",{body:{mode:"commit",rows:D,batchIndex:L,rowOffset:L*uo,totalBatches:I,importRunId:r.importRunId}});H?C.errors.push(`Batch ${L+1}: ${H.message}`):(_==null?void 0:_.success)===!1?C.errors.push(`Batch ${L+1}: ${_.error}`):_&&(C.inserted+=_.inserted,C.updated+=_.updated,C.rejected+=_.rejected,C.suppressedSkipped+=_.suppressedSkipped,C.removedSkipped+=_.removedSkipped??0,C.conflictsRecorded+=_.conflictsRecorded),d(Math.round((L+1)/I*100))}f&&(C.deactivation=await N(r.importRunId,!1)),i({...C}),w({title:"Import complete",description:`${C.inserted} added, ${C.updated} updated.`})}catch(L){i({...C}),w({title:"Import failed",description:L.message,variant:"destructive"})}finally{l("idle")}},k=async()=>{if(r){h(!0);try{const I=await N(r.importRunId,!0);i(C=>C&&{...C,deactivation:I}),w({title:"Deactivation applied",description:I.message})}catch(I){w({title:"Deactivation failed",description:I.message,variant:"destructive"})}finally{h(!1)}}},$=async I=>{if(r){h(!0);try{const C=await N(r.importRunId,I);i(L=>L?{...L,deactivation:C}:{inserted:0,updated:0,rejected:0,suppressedSkipped:0,removedSkipped:0,conflictsRecorded:0,errors:[],deactivation:C}),w({title:"Deactivation sweep",description:C.message})}catch(C){w({title:"Deactivation failed",description:C.message,variant:"destructive"})}finally{h(!1)}}},R=async()=>{var I;if(r){g(!0);try{const{data:C,error:L}=await W.functions.invoke("import-directory-csv",{body:{mode:"deactivate-preview-list",importRunId:r.importRunId}});if(L)throw new Error(L.message);if(C!=null&&C.error)throw new Error(C.error);const D=C.targets??[],_=((I=r.deactivationPreview)==null?void 0:I.wouldDeactivate)??D.length;if(D.length!==_)throw new Error(`The list came back with ${D.length} listing${D.length===1?"":"s"} but the check found ${_}. Nothing was downloaded â please run the check again.`);m1("directory-would-be-deactivated.csv",[["Business name","Slug","CRM company ID","Areas","Phone","Website","Last updated"],...D.map(H=>[H.name??"",H.slug??"",H.crm_company_id??"",(H.areas??[]).join(" "),H.phone??"",H.website??"",H.last_updated??""])])}catch(C){w({title:"Could not build the list",description:C.message,variant:"destructive"})}finally{g(!1)}}},A=()=>{r&&m1("directory-rejected-rows.csv",[["Row","Name","Reason"],...r.rejected.map(I=>[String(I.row),I.name??"",I.reason??""])])},T=o!=="idle",P=r==null?void 0:r.deactivationPreview;return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Directory Import"}),t.jsx("p",{className:"text-muted-foreground",children:"Import the CRM export into the business directory. Validation runs first and writes nothing â you confirm before anything changes."})]}),t.jsxs(xe,{children:[t.jsxs(Me,{children:[t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(sn,{className:"h-5 w-5"}
797)," Upload CRM export"]}),t.jsx(Er,{children:"CSV only. Every row needs a CRM company ID and at least one in-scope area (1-14)."})]}),t.jsxs(ge,{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("input",{ref:b,type:"file",accept:".csv",onChange:y,className:"hidden",id:"directory-csv"}),t.jsxs(q,{variant:"outline",onClick:()=>{var I;return(I=b.current)==null?void 0:I.click()},disabled:T,children:[t.jsx(Gx,{className:"h-4 w-4 mr-2"})," Choose CSV file"]}),t.jsx(q,{onClick:v,disabled:!e||T,children:o==="validating"?"Validatingâ¦":"Validate"}),t.jsxs(q,{variant:"ghost",onClick:ode,disabled:T,children:[t.jsx(ei,{className:"h-4 w-4 mr-2"})," Download template CSV"]}),e&&t.jsxs(q,{variant:"ghost",onClick:j,disabled:T,children:[t.jsx(cs,{className:"h-4 w-4 mr-2"})," Clear"]})]}),e&&t.jsxs(ss,{children:[t.jsx(Gx,{className:"h-4 w-4"}),t.jsx(Sa,{children:"File ready"}),t.jsxs(rs,{children:[e.rows.length.toLocaleString()," rows, ",e.headers.length," columns."]})]}),T&&t.jsx(n_,{value:c})]})]}),r&&t.jsxs(xe,{children:[t.jsxs(Me,{children:[t.jsx(Oe,{children:"Validation report"}),t.jsx(Er,{children:"Nothing has been written yet."})]}),t.jsxs(ge,{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[t.jsx(pr,{label:"To add",value:r.toInsert}),t.jsx(pr,{label:"To update",value:r.toUpdate}),t.jsx(pr,{label:"Rejected",value:r.rejected.length,tone:r.rejected.length?"warn":void 0}),t.jsx(pr,{label:"Suppressed, skipped",value:r.suppressedSkipped.length}),t.jsx(pr,{label:"Skipped â marked Removed in CRM",value:r.removedSkipped.length,tone:r.removedSkipped.length?"warn":void 0}),t.jsx(pr,{label:"Partially resolved areas",value:r.partiallyResolved.length}),t.jsx(pr,{label:"No keywords",value:r.noKeywords.length,tone:r.noKeywords.length?"warn":void 0}),t.jsx(pr,{label:"New keyword terms",value:r.newKeywords.length}),t.jsx(pr,{label:"Owner field conflicts",value:r.conflicts.length}),t.jsx(pr,{label:"Toggles changing",value:r.toggleChanges}),t.jsx(pr,{label:"Phone numbers being cleared ([clear])",value:r.phoneCleared}),t.jsx(pr,{label:"Phone numbers left alone (unreadable)",value:r.phoneSkipped,tone:r.phoneSkipped?"warn":void 0}),t.jsx(pr,{label:"Blank cells ignored â existing website values kept",value:r.blankCellsKept})]}),t.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[t.jsx("p",{className:"font-medium text-sm",children:"Blank cells"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["A blank cell in the file leaves the value already on the website alone â the website often holds descriptions, logos, addresses and social links the CRM does not. To remove a value, type"," ",t.jsx("code",{children:"[clear]"})," in that cell."]})]}),t.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[t.jsx("p",{className:"font-medium text-sm",children:"Detected columns"}),t.jsxs("p",{className:`text-sm ${r.keywordColumnCount===0?"text-amber-600":"text-muted-foreground"}`,children:["Keyword columns: ",r.keywordColumnCount,r.keywordColumnCount===0&&" â no keyword column found in this file"]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Toggle columns:"," ",r.toggleColumns.recognised.length===0?"none":r.toggleColumns.recognised.map(I=>`${I.header} â ${I.label}`).join(", ")]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Toggles read from:"," ",r.toggleSource==="tags"?"the Tags column":r.toggleSource==="columns"?"the Toggle columns":r.toggleSource==="both"?"the Tags column and the Toggle columns (combined)":"nothing in this file"]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Checkatrade links: ",r.checkatradeDetected?"found and will be imported":"none in this file"]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:r.toggleMode==="declarative"?"Toggles will be set from this file (blank or absent = off).":"No toggles in this file â existing toggles left unchanged."}),r.toggleColumns.unknown.length>0&&t.jsxs(ss,{children:[t.jsx(mi,{className:"h-4 w-4"}),t.jsx(Sa,{children:"Unrecognised toggle columns"}),t.jsx(rs,{children:r.toggleColumns.unknown.map(I=>`Column '${I}' not recognised and will be ignored`).join(". ")})]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.toggleChanges.toLocaleStr
797ing()," listings will have toggles changed."]})]}),t.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[t.jsx("p",{className:"font-medium text-sm",children:"Phone numbers"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.phoneCleared.toLocaleString()," listings have ",t.jsx("code",{children:"[clear]"})," in the phone cell, so the number will be removed from the website. ",r.phoneSkipped.toLocaleString()," numbers could not be read and will be left exactly as they are. An empty phone cell changes nothing."]}),r.phoneSkippedExamples.length>0&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["e.g. ",r.phoneSkippedExamples.slice(0,5).map(I=>`row ${I.row} ${I.name}`).join(", "),"â¦"]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"On listings with an owner, a phone change â including a removal â is saved as a conflict for review instead of being applied, so those numbers will not disappear until you approve them."})]}),r.noKeywords.length>0&&t.jsxs(ss,{children:[t.jsx(mi,{className:"h-4 w-4"}),t.jsxs(Sa,{children:[r.noKeywords.length," listings have no keywords"]}),t.jsx(rs,{children:"They will still import, but will not surface in keyword searches."})]}),P&&t.jsxs(ss,{variant:P.exceedsThreshold?"destructive":void 0,children:[t.jsx(lx,{className:"h-4 w-4"}),t.jsxs(Sa,{children:[P.wouldDeactivate.toLocaleString()," of ",P.activeCount.toLocaleString()," active listings are missing from this file (",P.percent,"%)"]}),t.jsxs(rs,{className:"space-y-2",children:[t.jsx("p",{children:P.exceedsThreshold?`That is above the ${P.thresholdPercent}% safety limit, so switching them off is blocked unless you override it.`:"Switching them off is optional â tick the box below if you want that to happen."}),P.sample.length>0&&t.jsxs("p",{className:"text-xs opacity-80",children:["e.g. ",P.sample.slice(0,5).join(", "),"â¦"]}),t.jsxs(q,{size:"sm",variant:"outline",onClick:R,disabled:x,children:[t.jsx(ei,{className:"h-4 w-4 mr-2"}),x?"Preparingâ¦":"Download the full list"]})]})]}),r.rejected.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(D0,{title:"Rejected rows",rows:r.rejected.slice(0,100).map(I=>[String(I.row),I.name,I.reason]),headers:["Row","Name","Reason"],total:r.rejected.length}),t.jsxs(q,{size:"sm",variant:"outline",onClick:A,children:[t.jsx(ei,{className:"h-4 w-4 mr-2"})," Download rejected rows"]})]}),r.partiallyResolved.length>0&&t.jsx(D0,{title:"Partially resolved areas",rows:r.partiallyResolved.slice(0,100).map(I=>[String(I.row),I.name,`Kept ${I.kept.join(", ")}`,`Discarded ${I.discarded.join("; ")}`]),headers:["Row","Name","Kept","Discarded"],total:r.partiallyResolved.length}),r.removedSkipped.length>0&&t.jsx(D0,{title:"Skipped â marked Removed in CRM",rows:r.removedSkipped.slice(0,100).map(I=>[String(I.row),I.name]),headers:["Row","Name"],total:r.removedSkipped.length}),t.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[t.jsxs("label",{className:"flex items-start gap-3 text-sm",children:[t.jsx("input",{type:"checkbox",className:"mt-1 h-4 w-4",checked:f,onChange:I=>p(I.target.checked),disabled:T}),t.jsxs("span",{children:["Also switch off listings that are missing from this file",P?` (${P.wouldDeactivate.toLocaleString()} listings)`:"",".",t.jsxs("span",{className:"block text-xs text-muted-foreground",children:["Off by default. The ",(P==null?void 0:P.thresholdPercent)??20,"% safety limit still applies, so an unusually large sweep is blocked and offered as a separate override."]})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(q,{onClick:S,disabled:T,children:o==="importing"?"Importingâ¦":"Confirm import"}),t.jsx(q,{variant:"outline",onClick:()=>$(!1),disabled:T||m,children:m?"Workingâ¦":"Run the sweep on its own"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"This writes to the directory. Suppressed listings are never touched."})]})]})]})]}),a&&t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(xs,{className:"h-5 w-5 text-primary"})," Import result"]})}),t.jsxs(ge,{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[t.jsx(pr,{label:"Added",value:a.inserted}),t.jsx(pr,{label:"Updated",value:a.updated}),t.jsx(pr,{label:"Rejected",value:a.rejected}),t.jsx(pr,{label:"Skipped â marked Removed in CRM",value:a.removedSkipped}),t.jsx(pr,{label:"Conflicts recorded",value:a.conflictsRecorded})]}),a.errors.length>0&&t.jsxs(ss,{variant:"destructive",children:[t.jsx(mi,{className:"h-4 w-4"}),t.jsxs(Sa,{children:[a.errors.length," batches failed"]}),t.jsx(rs,{children:t.jsx("ul",{className:"list-disc pl-4 text-xs",children:a.errors.slice(0,10).map(I=>t.jsx("li",{children:I},I))})})]}),a.deactivation&&t.jsxs(ss,{variant:a.deactivation.outcome.startsWith("skipped")?"destructive":void 0,children:[t.jsx(lx,{className:"h-4 w-4"}),t.jsxs(Sa,{children:[a.deactivation.outcome==="skipped_incomplete"&&"Import incomplete, deactivation skipped",a.deactivation.outcome==="skipped_volume"&&"Deactivation skipped â above safety threshold",a.deactivation.outcome==="applied"&&"Deactivation applied",a.deactivation.outcome==="forced"&&"Deactivation applied (override)"]}),t.jsxs(rs,{className:"space-y-2",children:[t.jsx("p",{children:a.deactivation.message}),a.deactivation.outcome==="skipped_incomplete"&&t.jsxs("p",{className:"text-xs",children:[(B=a.deactivation.failedBatches)!=null&&B.length?`Failed batches: ${a.deactivation.failedBatches.map(I=>I+1).join(", ")}. `:"",(Y=a.deactivation.missingBatches)!=null&&Y.length?`Missing batches: ${a.deactivation.missingBatches.map(I=>I+1).join(", ")}.`:""]}),a.deactivation.outcome==="skipped_volume"&&t.jsx(q,{size:"sm",variant:"outline",onClick:k,disabled:m,children:m?"Deactivatingâ¦":"Deactivate anyway"})]})]}),!a.deactivation&&t.jsxs(ss,{children:[t.jsx(lx,{className:"h-4 w-4"}),t.jsx(Sa,{children:"Nothing was switched off"}),t.jsxs(rs,{className:"space-y-2",children:[t.jsxs("p",{children:[o7("skipped_not_requested"),". You can switch them off now, or leave them."]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsxs(q,{size:"sm",variant:"outline",onClick:R,disabled:x,children:[t.jsx(ei,{className:"h-4 w-4 mr-2"}),x?"Preparingâ¦":"Download the list"]}),t.jsx(q,{size:"sm",variant:"outline",onClick:()=>$(!1),disabled:m,children:m?"Workingâ¦":"Switch them off"})]})]})]})]})]}),t.jsx(rde,{}),t.jsx(sde,{}),t.jsx(Jce,{})]})}function pr({label:e,value:s,tone:r}){return t.jsxs("div",{className:"rounded-lg border p-3",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:e}),t.jsxs("div",{className:"text-2xl font-semibold",children:[s.toLocaleStr
797ing(),r==="warn"&&s>0&&t.jsx(we,{variant:"secondary",className:"ml-2 align-middle",children:"review"})]})]})}function D0({title:e,headers:s,rows:r,total:n}){return t.jsxs("div",{children:[t.jsxs("h4",{className:"font-medium mb-2",children:[e," ",t.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",n,")"]})]}),t.jsx("div",{className:"max-h-72 overflow-auto rounded-md border",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsx(Xe,{children:s.map(a=>t.jsx(ue,{children:a},a))})}),t.jsx(Wt,{children:r.map((a,i)=>t.jsx(Xe,{children:a.map((o,l)=>t.jsx(de,{className:"text-sm",children:o},l))},i))})]})}),n>r.length&&t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Showing first ",r.length," of ",n,"."]})]})}function ude(){const[e,s]=u.useState([]),[r,n]=u.useState(!0),{toast:a}=rt(),i=async(f=!1)=>{try{n(!0);let p=W.from("events").select("*").order("date",{ascending:!0});f&&(p=p.eq("is_published",!0));const{data:x,error:g}=await p;if(g)throw g;const b=(x||[]).map(w=>({...w,links:Array.isArray(w.links)?w.links:[]}));s(b)}catch(p){console.error("Error fetching events:",p),a({title:"Error",description:"Failed to load events",variant:"destructive"})}finally{n(!1)}},o=async f=>{try{const p={...f,links:f.links||[]},{data:x,error:g}=await W.from("events").insert([p]).select().single();if(g)throw g;return a({title:"Success",description:"Event created successfully"}),x}catch(p){return console.error("Error creating event:",p),a({title:"Error",description:p.message||"Failed to create event",variant:"destructive"}),null}},l=async(f,p)=>{try{const x={...p,updated_at:new Date().toISOString()},{data:g,error:b}=await W.from("events").update(x).eq("id",f).select().single();if(b)throw b;return a({title:"Success",description:"Event updated successfully"}),g}catch(x){return console.error("Error updating event:",x),a({title:"Error",description:x.message||"Failed to update event",variant:"destructive"}),null}},c=async f=>{try{const{error:p}=await W.from("events").delete().eq("id",f);if(p)throw p;return a({title:"Success",description:"Event deleted successfully"}),!0}catch(p){return console.error("Error deleting event:",p),a({title:"Error",description:p.message||"Failed to delete event",variant:"destructive"}),!1}},d=async(f,p)=>l(f,{is_published:!p}),m=async(f,p)=>l(f,{featured:!p}),h=async f=>{try{const p=f.map(b=>({...b,links:b.links||[],is_published:b.is_published??!1,featured:b.featured??!1})),{data:x,error:g}=await W.from("events").insert(p).select();if(g)throw g;return a({title:"Success",description:`${x.length} events imported successfully`}),x}catch(p){return console.error("Error bulk creating events:",p),a({title:"Error",description:p.message||"Failed to import events",variant:"destructive"}),null}};return u.useEffect(()=>{i()},[]),{events:e,loading:r,fetchEvents:i,createEvent:o,updateEvent:l,deleteEvent:c,togglePublished:d,toggleFeatured:m,bulkCreateEvents:h}}function mde(){const{events:e,loading:s,fetchEvents:r,createEvent:n,updateEvent:a,deleteEvent:i,togglePublished:o,toggleFeatured:l,bulkCreateEvents:c}=ude(),{items:d,loading:m,create:h,update:f,remove:p,moveUp:x,moveDown:g,fetch:b}=t9(!1),{items:w,loading:j,create:y,update:v,remove:N,moveUp:S,moveDown:k,fetch:$}=s9(!1),{toast:R}=rt(),A=u.useRef(null),[T,P]=u.useState(!1),[B,Y]=u.useState(null),[I,C]=u.useState("all"),[L,D]=u.useState(""),[_,H]=u.useState(""),[O,U]=u.useState(null),[G,E]=u.useState({title:"",description:"",excerpt:"",full_description:"",date:"",date_end:"",time:"",end_time:"",location:"",area:"",postcode:"",category:"",type:"",image:"",organizer:"",links:[],ticket_url:"",contact_email:"",contact_phone:"",website_url:"",facebook_url:"",instagram_url:"",twitter_url:"",linkedin_url:"",tiktok_url:"",youtube_url:"",is_published:!1,featured:!1}),[z,Z]=u.useState([]),[M,F]=u.useState(""),[ee,se]=u.useState(""),[le,X]=u.useState([]),[ye,Ce]=u.useState(!1),[ke,fe]=u.useState(!1),Ee=e.filter(J=>!J.is_published&&(J.user_id||J.contact_email));e.filter(J=>J.is_published||!J.user_id&&!J.contact_email);const K=async J=>{await a(J.id,{is_published:!0}
797)&&(R({title:"Event Approved",description:`"${J.title}" has been published.`}),r())},te=async J=>{confirm(`Are you sure you want to reject and delete "${J.title}"? This cannot be undone.`)&&await i(J.id)&&(R({title:"Event Rejected",description:"The submission has been removed."}),r())},Q=J=>{me(J),E(Ne=>({...Ne,is_published:!0}))},ae=()=>{E({title:"",description:"",excerpt:"",full_description:"",date:"",date_end:"",time:"",end_time:"",location:"",area:"",postcode:"",category:"",type:"",image:"",organizer:"",links:[],ticket_url:"",contact_email:"",contact_phone:"",website_url:"",facebook_url:"",instagram_url:"",twitter_url:"",linkedin_url:"",tiktok_url:"",youtube_url:"",is_published:!1,featured:!1}),Z([]),Y(null)},me=J=>{Y(J),E({title:J.title,description:J.description||"",excerpt:J.excerpt||"",full_description:J.full_description||"",date:J.date,date_end:J.date_end||"",time:J.time,end_time:J.end_time||"",location:J.location,area:J.area,postcode:J.postcode||"",category:J.category,type:J.type,image:J.image||"",organizer:J.organizer||"",ticket_url:J.ticket_url||"",contact_email:J.contact_email||"",contact_phone:J.contact_phone||"",website_url:J.website_url||"",facebook_url:J.facebook_url||"",instagram_url:J.instagram_url||"",twitter_url:J.twitter_url||"",linkedin_url:J.linkedin_url||"",tiktok_url:J.tiktok_url||"",youtube_url:J.youtube_url||"",is_published:J.is_published,featured:J.featured}),Z(J.links||[]),P(!0)},pe=async J=>{J.preventDefault();const Ne={...G,links:z};B?await a(B.id,Ne)&&(P(!1),ae(),r()):await n(Ne)&&(P(!1),ae(),r())},be=async J=>{confirm("Are you sure you want to delete this event?")&&await i(J)&&r()},ce=()=>{M&&ee&&(Z([...z,{label:M,url:ee}]),F(""),se(""))},ie=J=>{Z(z.filter((Ne,gt)=>gt!==J))},je=async J=>{var gt;const Ne=(gt=J.target.files)==null?void 0:gt[0];if(Ne){fe(!0);try{const He=Ne.name.split(".").pop(),De=`events/${`${Date.now()}.${He}`}`,{error:Le}=await W.storage.from("event-images").upload(De,Ne);if(Le)throw Le;const{data:{publicUrl:We}}=W.storage.from("event-images").getPublicUrl(De);E(Ke=>({...Ke,image:We})),R({title:"Image uploaded successfully"})}catch(He){R({title:"Error",description:He.message||"Failed to upload image",variant:"destructive"})}finally{fe(!1)}}},Re=()=>{const Te=`\uFEFFtitle,date,date_end,time,end_time,location,area,postcode,category,type,excerpt,description,organizer,ticket_url,contact_email,contact_phone 798"NOTE: Phone numbers must keep leading zeros. Format the contact_phone column as Text in your spreadsheet before entering numbers. The template uses =""01234..."" formula to preserve zeros.","","","","","","","","","","","","","","","" 799"Summer Festival","2025-07-15","2025-07-17","10:00","18:00","Central Park","Downtown","AB12 3CD","Community","Festival","Join us for 3 days of fun!","Full description here...","Local Council","https://tickets.example.com","[email protected]","=""01234567890""" 800"One Day Concert","2025-08-20","","19:00","23:00","Music Hall","City Center","CD45 6EF","Music","Concert","An evening of live music","Full description...","Music Promotions","","[email protected]",""`,De=new Blob([Te],{type:"text/csv;charset=utf-8"}),Le=window.URL.createObjectURL(De),We=document.createElement("a");We.href=Le,We.download="events_template.csv",We.click(),window.URL.revokeObjectURL(Le)},Ae=J=>{var He;const Ne=(He=J.target.files)==null?void 0:He[0];if(!Ne)return;const gt=new FileReader;gt.onload=Te=>{var st,dt;const Le=((st=Te.target)==null?void 0:st.result).split(` 801`).filter(tt=>tt.trim()),We=Le[0].split(",").map(tt=>tt.trim().replace(/"/g,"")),Ke=[];for(let tt=1;tt<Le.length;tt++){const us=(Le[tt].match(/(".*?"|[^",\s]+)(?=\s*,|\s*$)/g)||[]).map(fr=>fr.replace(/^"|"$/g,"").trim()),St={};We.forEach((fr,Yn)=>{St[fr]=us[Yn]||""}),St.title&&St.date&&St.time&&St.location&&St.area&&St.category&&St.type&&Ke.push({title:St.title,date:St.date,date_end:St.date_end||void 0,time:St.time,end_time:St.end_time||void 0,location:St.location,area:St.area,postcode:St.postcode||void 0,category:St.category,type:St.type,excerpt:St.excerpt||void 0,description:St.description||void 0,organizer:St.organizer||void 0,ticket_url:St.ticket_url||void 0,contact_email:St.contact_email||void 0,contact_phone:((dt=St.contact_phone)==null?void 0:dt.replace(/^="?|"$/g,"").trim())||void 0,is_published:!1,featured:!1,links:[]})}X(Ke),Ce(!0)},gt.readAsText(Ne),A.current&&(A.current.value="")},Ue=async()=>{await c(le)&&(Ce(!1),X([]),r())},Ve={total:e.length,published:e.filter(J=>J.is_published).length,upcoming:e.filter(J=>new Date(J.date)>=new Date).length,featured:e.filter(J=>J.featured).length,pending:Ee.length},lt=J=>new Date(J).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"});return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Events Management"}),t.jsx("p",{className:"text-muted-foreground",children:"Create and manage community events."})]}
801),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(xe,{children:t.jsx(ge,{className:"p-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(It,{className:"h-8 w-8 text-primary"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Events"}),t.jsx("p",{className:"text-2xl font-bold",children:Ve.total})]})]})})}),t.jsx(xe,{children:t.jsx(ge,{className:"p-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(tr,{className:"h-8 w-8 text-green-600"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Published"}),t.jsx("p",{className:"text-2xl font-bold",children:Ve.published})]})]})})}),t.jsx(xe,{children:t.jsx(ge,{className:"p-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(It,{className:"h-8 w-8 text-blue-600"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Upcoming"}),t.jsx("p",{className:"text-2xl font-bold",children:Ve.upcoming})]})]})})}),t.jsx(xe,{children:t.jsx(ge,{className:"p-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(mr,{className:"h-8 w-8 text-yellow-500"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Featured"}),t.jsx("p",{className:"text-2xl font-bold",children:Ve.featured})]})]})})}),t.jsx(xe,{className:`cursor-pointer transition-colors ${Ve.pending>0?"border-amber-500 bg-amber-50 dark:bg-amber-950/20":""}`,onClick:()=>Ve.pending>0&&C("submissions"),children:t.jsx(ge,{className:"p-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(z4,{className:`h-8 w-8 ${Ve.pending>0?"text-amber-600":"text-muted-foreground"}`}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Pending Approval"}),t.jsx("p",{className:"text-2xl font-bold",children:Ve.pending})]})]})})})]}),t.jsx(xe,{children:t.jsx(ge,{className:"p-4",children:t.jsxs("div",{className:"flex flex-wrap gap-3",children:[t.jsxs(bt,{open:T,onOpenChange:J=>{P(J),J||ae()},children:[t.jsx(Sn,{asChild:!0,children:t.jsxs(q,{onClick:()=>ae(),children:[t.jsx(Xt,{className:"h-4 w-4 mr-2"}),"Add Event"]})}),t.jsxs(xt,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[t.jsx(jt,{children:t.jsx(wt,{children:B?"Edit Event":"Add New Event"})}),t.jsxs("form",{onSubmit:pe,className:"space-y-6",children:[t.jsxs(ha,{defaultValue:"basic",className:"w-full",children:[t.jsxs(Hn,{className:"grid w-full grid-cols-3",children:[t.jsx(Rt,{value:"basic",children:"Basic Info"}),t.jsx(Rt,{value:"details",children:"Details"}),t.jsx(Rt,{value:"links",children:"Links & Contact"})]}),t.jsx(Mt,{value:"basic",className:"space-y-4 mt-4",children:t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"col-span-2",children:[t.jsx(V,{htmlFor:"title",children:"Event Title *"}),t.jsx(re,{id:"title",value:G.title,onChange:J=>E(Ne=>({...Ne,title:J.target.value})),required:!0})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"date",children:"Start Date *"}),t.jsx(re,{id:"date",type:"date",value:G.date,onChange:J=>E(Ne=>({...Ne,date:J.target.value})),required:!0})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"date_end",children:"End Date (for multi-day)"}),t.jsx(re,{id:"date_end",type:"date",value:G.date_end,onChange:J=>E(Ne=>({...Ne,date_end:J.target.value})),min:G.date}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Leave blank for single-day events"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"time",children:"Start Time *"}),t.jsx(re,{id:"time",type:"time",value:G.time,onChange:J=>E(Ne=>({...Ne,time:J.target.value})),required:!0})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"end_time",children:"End Time"}),t.jsx(re,{id:"end_time",type:"time",value:G.end_time,onChange:J=>E(Ne=>({...Ne,end_time:J.target.value}))})]})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"category",children:"Category *"}),t.jsxs(ht,{value:G.category,onValueChange:J=>E(Ne=>({...Ne,category:J})),children:[t.jsx(ut,{children:t.jsx(ft,{placeholder:"Select category"})}),t.jsx(mt,{children:d.filter(J=>J.is_active).map(J=>t.jsx(Pe,{value:J.name,children:J.name},J.id))})]})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"type",children:"Event Type *"}),t.jsxs(ht,{value:G.type,onValueChange:J=>E(Ne=>({...Ne,type:J})),children:[t.jsx(ut,{children:t.jsx(ft,{placeholder:"Select type"})}),t.jsx(mt,{children:w.filter(J=>J.is_active).map(J=>t.jsx(Pe,{value:J.name,children:J.name},J.id))})]})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"location",children:"Location *"}),t.jsx(re,{id:"location",value:G.location,onChange:J=>E(Ne=>({...Ne,location:J.target.value})),placeholder:"Venue name or address",required:!0})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"area",children:"Area *"}),t.jsx(re,{id:"area",value:G.area,onChange:J=>E(Ne=>({...Ne,area:J.target.value})),placeholder:"Town or district",required:!0})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"postcode",children:"Postcode"}),t.jsx(re,{id:"postcode",value:G.postcode,onChange:J=>E(Ne=>({...Ne,postcode:J.target.value}))})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"organizer",children:"Organizer"}),t.jsx(re,{id:"organizer",value:G.organizer,onChange:J=>E(Ne=>({...Ne,organizer:J.target.value}))})]})]})}
801),t.jsxs(Mt,{value:"details",className:"space-y-4 mt-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"excerpt",children:"Excerpt (Short description for cards)"}),t.jsx(ms,{id:"excerpt",value:G.excerpt,onChange:J=>E(Ne=>({...Ne,excerpt:J.target.value})),placeholder:"Brief description (150 characters recommended)",rows:2})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"full_description",children:"Full Description"}),t.jsx(ms,{id:"full_description",value:G.full_description,onChange:J=>E(Ne=>({...Ne,full_description:J.target.value})),placeholder:"Detailed event description...",rows:6})]}),t.jsxs("div",{children:[t.jsx(V,{children:"Event Image"}),t.jsxs("div",{className:"flex gap-4 items-start",children:[G.image&&t.jsx("img",{src:G.image,alt:"Event preview",className:"w-32 h-24 object-cover rounded-md"}),t.jsxs("div",{className:"flex-1",children:[t.jsx(re,{type:"file",accept:"image/*",onChange:je,disabled:ke}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ke?"Uploading...":"Upload an image for the event"})]})]})]}),t.jsxs("div",{className:"flex gap-6",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(kt,{id:"is_published",checked:G.is_published,onCheckedChange:J=>E(Ne=>({...Ne,is_published:J}))}),t.jsx(V,{htmlFor:"is_published",children:"Published"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(kt,{id:"featured",checked:G.featured,onCheckedChange:J=>E(Ne=>({...Ne,featured:J}))}),t.jsx(V,{htmlFor:"featured",children:"Featured"})]})]})]}),t.jsxs(Mt,{value:"links",className:"space-y-4 mt-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"ticket_url",children:"Ticket/Booking URL"}),t.jsx(re,{id:"ticket_url",type:"url",value:G.ticket_url,onChange:J=>E(Ne=>({...Ne,ticket_url:J.target.value})),placeholder:"https://tickets.example.com"})]}),t.jsxs("div",{children:[t.jsxs(V,{htmlFor:"website_url",className:"flex items-center gap-1",children:[t.jsx(Tc,{className:"h-3 w-3"})," Website URL"]}),t.jsx(re,{id:"website_url",type:"url",value:G.website_url,onChange:J=>E(Ne=>({...Ne,website_url:J.target.value})),placeholder:"https://www.example.com"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"contact_email",children:"Contact Email"}),t.jsx(re,{id:"contact_email",type:"email",value:G.contact_email,onChange:J=>E(Ne=>({...Ne,contact_email:J.target.value}))})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"contact_phone",children:"Contact Phone"}),t.jsx(re,{id:"contact_phone",type:"tel",value:G.contact_phone,onChange:J=>E(Ne=>({...Ne,contact_phone:J.target.value}))})]})]}),t.jsx(fs,{}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("h4",{className:"text-sm font-semibold flex items-center gap-2",children:[t.jsx(Ew,{className:"h-4 w-4"})," Social Media Links"]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsxs(V,{htmlFor:"facebook_url",className:"flex items-center gap-1",children:[t.jsx(aE,{className:"h-3 w-3"})," Facebook"]}),t.jsx(re,{id:"facebook_url",type:"url",value:G.facebook_url,onChange:J=>E(Ne=>({...Ne,facebook_url:J.target.value})),placeholder:"https://facebook.com/..."})]}),t.jsxs("div",{children:[t.jsxs(V,{htmlFor:"instagram_url",className:"flex items-center gap-1",children:[t.jsx(lE,{className:"h-3 w-3"})," Instagram"]}),t.jsx(re,{id:"instagram_url",type:"url",value:G.instagram_url,onChange:J=>E(Ne=>({...Ne,instagram_url:J.target.value})),placeholder:"https://instagram.com/..."})]}),t.jsxs("div",{children:[t.jsxs(V,{htmlFor:"twitter_url",className:"flex items-center gap-1",children:[t.jsx(pL,{className:"h-3 w-3"})," Twitter / X"]}),t.jsx(re,{id:"twitter_url",type:"url",value:G.twitter_url,onChange:J=>E(Ne=>({...Ne,twitter_url:J.target.value})),placeholder:"https://twitter.com/..."})]}),t.jsxs("div",{children:[t.jsxs(V,{htmlFor:"linkedin_url",className:"flex items-center gap-1",children:[t.jsx(cE,{className:"h-3 w-3"})," LinkedIn"]}),t.jsx(re,{id:"linkedin_url",type:"url",value:G.linkedin_url,onChange:J=>E(Ne=>({...Ne,linkedin_url:J.target.value})),placeholder:"https://linkedin.com/..."})]}),t.jsxs("div",{children:[t.jsxs(V,{htmlFor:"tiktok_url",className:"flex items-center gap-1",children:[t.jsx("svg",{className:"h-3 w-3",viewBox:"0 0 24 24",fill:"
801currentColor",children:t.jsx("path",{d:"M19.59 6.69a4.83 4.83 0 01-3.77-4.25V2h-3.45v13.67a2.89 2.89 0 01-5.2 1.74 2.89 2.89 0 012.31-4.64 2.93 2.93 0 01.88.13V9.4a6.84 6.84 0 00-1-.05A6.33 6.33 0 005 20.1a6.34 6.34 0 0010.86-4.43v-7a8.16 8.16 0 004.77 1.52v-3.4a4.85 4.85 0 01-1-.1z"})})," TikTok"]}),t.jsx(re,{id:"tiktok_url",type:"url",value:G.tiktok_url,onChange:J=>E(Ne=>({...Ne,tiktok_url:J.target.value})),placeholder:"https://tiktok.com/@..."})]}),t.jsxs("div",{children:[t.jsxs(V,{htmlFor:"youtube_url",className:"flex items-center gap-1",children:[t.jsx(hE,{className:"h-3 w-3"})," YouTube"]}),t.jsx(re,{id:"youtube_url",type:"url",value:G.youtube_url,onChange:J=>E(Ne=>({...Ne,youtube_url:J.target.value})),placeholder:"https://youtube.com/..."})]})]})]}),t.jsx(fs,{}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Additional Links"}),z.map((J,Ne)=>t.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted rounded-md",children:[t.jsx(Sw,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"font-medium",children:J.label}),t.jsx("span",{className:"text-sm text-muted-foreground truncate flex-1",children:J.url}),t.jsx(q,{type:"button",variant:"ghost",size:"sm",onClick:()=>ie(Ne),children:t.jsx(Es,{className:"h-4 w-4"})})]},Ne)),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(re,{placeholder:"Label (e.g., Menu, Flyer)",value:M,onChange:J=>F(J.target.value)}),t.jsx(re,{placeholder:"URL",value:ee,onChange:J=>se(J.target.value)}),t.jsx(q,{type:"button",variant:"outline",onClick:ce,children:t.jsx(Xt,{className:"h-4 w-4"})})]})]})]})]}),t.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[t.jsx(q,{type:"button",variant:"outline",onClick:()=>P(!1),children:"Cancel"}),t.jsx(q,{type:"submit",children:B?"Update Event":"Create Event"})]})]})]})]}),t.jsxs(q,{variant:"outline",onClick:Re,children:[t.jsx(ei,{className:"h-4 w-4 mr-2"}),"Download Template"]}),t.jsxs("div",{children:[t.jsx("input",{ref:A,type:"file",accept:".csv",onChange:Ae,className:"hidden",id:"csv-upload"}),t.jsxs(q,{variant:"outline",onClick:()=>{var J;return(J=A.current)==null?void 0:J.click()},children:[t.jsx(sn,{className:"h-4 w-4 mr-2"}),"Import CSV"]})]})]})})}),t.jsx(bt,{open:ye,onOpenChange:Ce,children:t.jsxs(xt,{className:"max-w-4xl max-h-[80vh] overflow-y-auto",children:[t.jsx(jt,{children:t.jsxs(wt,{children:["Preview CSV Import (",le.length," events)"]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Title"}),t.jsx(ue,{children:"Date"}),t.jsx(ue,{children:"Time"}),t.jsx(ue,{children:"Location"}),t.jsx(ue,{children:"Category"})]})}),t.jsx(Wt,{children:le.map((J,Ne)=>t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:J.title}),t.jsx(de,{children:J.date}),t.jsxs(de,{children:[J.time,J.end_time&&` - ${J.end_time}`]}),t.jsxs(de,{children:[J.location,", ",J.area]}),t.jsx(de,{children:J.category})]},Ne))})]})}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(q,{variant:"outline",onClick:()=>Ce(!1),children:"Cancel"}),t.jsxs(q,{onClick:Ue,children:["Import ",le.length," Events"]})]})]})}),t.jsxs(ha,{value:I,onValueChange:J=>C(J),children:[t.jsxs(Hn,{className:"mb-4",children:[t.jsx(Rt,{value:"all",children:"All Events"}),t.jsxs(Rt,{value:"submissions",className:"relative",children:["Pending Submissions",Ve.pending>0&&t.jsx("span",{className:"ml-2 inline-flex items-center justify-center w-5 h-5 text-xs font-bold text-primary-foreground bg-primary rounded-full",children:Ve.pending})]}),t.jsx(Rt,{value:"taxonomies",children:"Categories & Types"})]}),t.jsx(Mt,{value:"all",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{children:"All Events"})}),t.jsx(ge,{children:s?t.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading events..."}):e.length===0?t.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[t.jsx(It,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),t.jsx("p",{children:"No events found. Create your first event!"})]}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Event"}),t.jsx(ue,{children:"Date & Time"}),t.jsx(ue,{children:"Location"}),t.jsx(ue,{children:"Category"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:e.map(J=>t.jsxs(Xe,{children:[t.jsx(de,{children:t.jsxs("div",{className:"flex items-center gap-3",children:[J.image&&t.jsx("img",{src:J.image,alt:J.title,className:"w-12 h-12 object-cover rounded"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:J.title}),t.jsx("p",{className:"text-sm text-muted-foreground truncate max-w-[200px]",children:J.excerpt||J.description||"No description"})]})]})}),t.jsx(de,{children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(It,{className:"h-4 w-4 text-muted-foreground"}),t.jsxs("div",{children:[t.jsx("p",{children:lt(J.date)}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[J.time,J.end_time&&` - ${J.end_time}`]})]})]})}),t.jsx(de,{children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_t,{className:"h-4 w-4 text-muted-foreground"}),t.jsxs("div",{children:[t.jsx("p",{children:J.location}),t.jsx("p",{className:"text-sm text-muted-foreground",children:J.area})]})]})}),t.jsx(de,{children:t.jsx(we,{variant:"outline",children:J.category})}),t.jsx(de,{children:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(we,{variant:J.is_published?"default":"secondary",children:J.is_published?"Published":"Draft"}),J.featured&&t.jsx(we,{variant:"outline",className:"border-yellow-500 text-yellow-600",children:"Featured"}),!J.is_published&&(J.user_id||J.contact_email)&&t.jsx(we,{variant:"outline",className:"border-amber-500 text-amber-600",children:"User Submission"})]})}),t.jsx(de,{children:t.jsxs("div",{className:"flex gap-1",children:[t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>me(J),children:t.jsx(ra,{className:"h-4 w-4"})}),t.jsx(q,{variant:"ghost",size:"sm",onClick:async()=>{await o(J.id,J.is_published),r()},children:J.is_published?t.jsx(di,{className:"h-4 w-4"}):t.jsx(tr,{className:"h-4 w-4"})}),t.jsx(q,{variant:"ghost",size:"sm",onClick:async()=>{await l(J.id,J.featured),r()},children:J.featured?t.jsx(mE,{className:"h-4 w-4"}):t.jsx(mr,{className:"h-4 w-4"})}),t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>be(J.id),children:t.jsx(cs,{className:"h-4 w-4 text-destructive"})})]})})]},J.id))})]})})})]})}),t.jsx(Mt,{value:"submissions",children:t.jsxs(xe,{children:[t.jsxs(Me,{children:[t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(z4,{className:"h-5 w-5 text-amber-600"}),"Pending Event Submissions"]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Review and approve events submitted by users. These events will not appear publicly until approved."})]}),t.jsx(ge,{children:s?t.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading submissions..."}):Ee.length===0?t.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[t.jsx(xs,{className:"h-12 w-12 mx-auto mb-4 text-green-500 opacity-70"}),t.jsx("p",{className:"text-lg font-medium",children:"All caught up!"}),t.jsx("p",{className:"text-sm",children:"No pending submissions to review."})]}):t.jsx("div",{className:"space-y-4",children:Ee.map(J=>t.jsx("div",{className:"border rounded-lg p-4 bg-card hover:border-amber-300 transition-colors",children:t.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[J.image&&t.jsx("img",{src:J.image,alt:J.title,className:"w-full lg:w-32 h-32 object-cover rounded-lg"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-4",children:t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-lg",children:J.title}),t.jsxs("div",{className:"flex flex-wrap gap-2 mt-1",children:[t.jsxs(we,{variant:"outline",className:"border-amber-500 text-amber-600",children:[t.jsx(ws,{className:"h-3 w-3 mr-1"}),"Pending Review"]}),t.jsx(we,{variant:"outline",children:J.category}),t.jsx(we,{variant:"secondary",children:J.type})]})]})}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx(It,{className:"h-4 w-4"}),t.jsxs("span",{children:[lt(J.date)," at ",J.time,J.end_time&&` - ${J.end_time}`]})]}),t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx(_t,{className:"h-4 w-4"}),t.jsxs("span",{children:[J.location,", ",J.area]})]}),J.organizer&&t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx("span",{className:"font-medium",children:"Organizer:"}),t.jsx("span",{children:J.organizer})]}),J.contact_email&&t.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx(ar,{className:"h-4 w-4"}),t.jsx("a",{href:`mailto:${J.contact_email}`,className:"text-primary hover:underline",children:J.contact_email})]})]}),(J.excerpt||J.description)&&t.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:J.excerpt||J.description}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:["Submitted: ",new Date(J.created_at).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})]})]}),t.jsxs("div",{className:"flex lg:flex-col gap-2 lg:min-w-[140px]",children:[t.jsxs(q,{onClick:()=>K(J),className:"flex-1 bg-green-600 hover:bg-green-700",children:[t.jsx(xs,{className:"h-4 w-4 mr-2"}),"Approve"]}),t.jsxs(q,{variant:"outline",onClick:()=>Q(J),className:"flex-1",children:[t.jsx(ra,{className:"h-4 w-4 mr-2"}),"Edit & Approve"]}),t.jsxs(q,{variant:"outline",onClick:()=>te(J),className:"flex-1 text-destructive hover:bg-destructive hover:text-destructive-foreground",children:[t.jsx(Nf,{className:"h-4 w-4 mr-2"}),"Reject"]}),J.ticket_url&&t.jsxs(q,{variant:"ghost",size:"sm",onClick:()=>window.open(J.ticket_url,"_blank"),children:[t.jsx(_u,{className:"h-4 w-4 mr-2"}),"View Link"]})]})]})},J.id))})})]})}),t.jsx(Mt,{value:"taxonomies",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-lg",children:"Event Categories"})}),t.jsxs(ge,{className:"space-y-4",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(re,{placeholder:"New category name",value:L,onChange:J=>D(J.target.value),onKeyDown:J=>{J.key==="Enter"&&L.trim()&&(J.preventDefault(),h(L.trim()),D(""))}}),t.jsx(q,{onClick:async()=>{L.trim()&&(await h(L.trim()),D(""))},size:"sm",children:t.jsx(Xt,{className:"h-4 w-4"})})]}),m?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):t.jsx("div",{className:"space-y-2",children:d.map((J,Ne)=>t.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md",children:[(O==null?void 0:O.id)===J.id?t.jsx(re,{value:O.name,onChange:gt=>U({...O,name:gt.target.value}),onKeyDown:async gt=>{gt.key==="Enter"&&(await f(J.id,{name:O.name}
801),U(null)),gt.key==="Escape"&&U(null)},onBlur:async()=>{await f(J.id,{name:O.name}),U(null)},autoFocus:!0,className:"h-8"}):t.jsx("span",{className:`flex-1 text-sm cursor-pointer ${J.is_active?"":"line-through text-muted-foreground"}`,onDoubleClick:()=>U({id:J.id,name:J.name}),children:J.name}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(kt,{checked:J.is_active,onCheckedChange:gt=>f(J.id,{is_active:gt})}),t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>x(Ne),disabled:Ne===0,children:"â"}),t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>g(Ne),disabled:Ne===d.length-1,children:"â"}),t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>U({id:J.id,name:J.name}),children:t.jsx(ra,{className:"h-3 w-3"})}),t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{confirm(`Delete "${J.name}"?`)&&p(J.id)},children:t.jsx(cs,{className:"h-3 w-3 text-destructive"})})]})]},J.id))})]})]}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-lg",children:"Event Types"})}),t.jsxs(ge,{className:"space-y-4",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(re,{placeholder:"New type name",value:_,onChange:J=>H(J.target.value),onKeyDown:J=>{J.key==="Enter"&&_.trim()&&(J.preventDefault(),y(_.trim()),H(""))}}),t.jsx(q,{onClick:async()=>{_.trim()&&(await y(_.trim()),H(""))},size:"sm",children:t.jsx(Xt,{className:"h-4 w-4"})})]}),j?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):t.jsx("div",{className:"space-y-2",children:w.map((J,Ne)=>t.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md",children:[(O==null?void 0:O.id)===J.id?t.jsx(re,{value:O.name,onChange:gt=>U({...O,name:gt.target.value}),onKeyDown:async gt=>{gt.key==="Enter"&&(await v(J.id,{name:O.name}),U(null)),gt.key==="Escape"&&U(null)},onBlur:async()=>{await v(J.id,{name:O.name}),U(null)},autoFocus:!0,className:"h-8"}):t.jsx("span",{className:`flex-1 text-sm cursor-pointer ${J.is_active?"":"line-through text-muted-foreground"}`,onDoubleClick:()=>U({id:J.id,name:J.name}),children:J.name}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(kt,{checked:J.is_active,onCheckedChange:gt=>v(J.id,{is_active:gt})}),t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>S(Ne),disabled:Ne===0,children:"â"}),t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>k(Ne),disabled:Ne===w.length-1,children:"â"}),t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>U({id:J.id,name:J.name}),children:t.jsx(ra,{className:"h-3 w-3"})}),t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{confirm(`Delete "${J.name}"?`)&&N(J.id)},children:t.jsx(cs,{className:"h-3 w-3 text-destructive"})})]})]},J.id))})]})]})]})})]})]})}function hde(e,s){return u.useReducer((r,n)=>s[r][n]??r,e)}var a_="ScrollArea",[l7,Afe]=hr(a_),[fde,ga]=l7(a_),c7=u.forwardRef((e,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:i=600,...o}=e,[l,c]=u.useState(null),[d,m]=u.useState(null),[h,f]=u.useState(null),[p,x]=u.useState(null),[g,b]=u.useState(null),[w,j]=u.useState(0),[y,v]=u.useState(0),[N,S]=u.useState(!1),[k,$]=u.useState(!1),R=at(s,T=>c(T)),A=to(a);return t.jsx(fde,{scope:r,type:n,dir:A,scrollHideDelay:i,scrollArea:l,viewport:d,onViewportChange:m,content:h,onContentChange:f,scrollbarX:p,onScrollbarXChange:x,scrollbarXEnabled:N,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:b,scrollbarYEnabled:k,onScrollbarYEnabledChange:$,onCornerWidthChange:j,onCornerHeightChange:v,children:t.jsx(ze.div,{dir:A,...o,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});c7.displayName=a_;var d7="ScrollAreaViewport",u7=u.forwardRef((e,s)=>{const{__scopeScrollArea:r,children:n,asChild:a,nonce:i,...o}=e,l=ga(d7,r),c=u.useRef(null),d=at(s,c,l.onViewportChange);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:` 802[data-radix-scroll-area-viewport] { 803 scrollbar-width: none; 804 -ms-overflow-style: none; 805 -webkit-overflow-scrolling: touch; 806} 807[data-radix-scroll-area-viewport]::-webkit-scrollbar {
808 display: none; 809} 810:where([data-radix-scroll-area-viewport]) { 811 display: flex; 812 flex-direction: column; 813 align-items: stretch; 814} 815:where([data-radix-scroll-area-content]) { 816 flex-grow: 1; 817} 818`},nonce:i}),t.jsx(ze.div,{"data-radix-scroll-area-viewport":"",...o,asChild:a,ref:d,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:_de({asChild:a,children:n},m=>t.jsx("div",{"data-radix-scroll-area-content":"",ref:l.onContentChange,style:{minWidth:l.scrollbarXEnabled?"fit-content":void 0},children:m}))})]})});u7.displayName=d7;var wi="ScrollAreaScrollbar",i_=u.forwardRef((e,s)=>{const{forceMount:r,...n}=e,a=ga(wi,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=a,l=e.orientation==="horizontal";return u.useEffect(()=>(l?i(!0):o(!0),()=>{l?i(!1):o(!1)}),[l,i,o]),a.type==="hover"?t.jsx(pde,{...n,ref:s,forceMount:r}):a.type==="scroll"?t.jsx(xde,{...n,ref:s,forceMount:r}):a.type==="auto"?t.jsx(m7,{...n,ref:s,forceMount:r}):a.type==="always"?t.jsx(o_,{...n,ref:s}):null});i_.displayName=wi;var pde=u.forwardRef((e,s)=>{const{forceMount:r,...n}=e,a=ga(wi,e.__scopeScrollArea),[i,o]=u.useState(!1);return u.useEffect(()=>{const l=a.scrollArea;let c=0;if(l){const d=()=>{window.clearTimeout(c),o(!0)},m=()=>{c=window.setTimeout(()=>o(!1),a.scrollHideDelay)};return l.addEventListener("pointerenter",d),l.addEventListener("pointerleave",m),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",d),l.removeEventListener("pointerleave",m)}}},[a.scrollArea,a.scrollHideDelay]),t.jsx(Ts,{present:r||i,children:t.jsx(m7,{"data-state":i?"visible":"hidden",...n,ref:s})})}),xde=u.forwardRef((e,s)=>{const{forceMount:r,...n}=e,a=ga(wi,e.__scopeScrollArea),i=e.orientation==="horizontal",o=ny(()=>c("SCROLL_END"),100),[l,c]=hde("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 u.useEffect(()=>{if(l==="idle"){const d=window.setTimeout(()=>c("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(d)}},[l,a.scrollHideDelay,c]),u.useEffect(()=>{const d=a.viewport,m=i?"scrollLeft":"scrollTop";if(d){let h=d[m];const f=()=>{const p=d[m];h!==p&&(c("SCROLL"),o()),h=p};return d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[a.viewport,i,c,o]),t.jsx(Ts,{present:r||l!=="hidden",children:t.jsx(o_,{"data-state":l==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Se(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Se(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),m7=u.forwardRef((e,s)=>{const r=ga(wi,e.__scopeScrollArea),{forceMount:n,...a}=e,[i,o]=u.useState(!1),l=e.orientation==="horizontal",c=ny(()=>{if(r.viewport){const d=r.viewport.offsetWidth<r.viewport.scrollWidth,m=r.viewport.offsetHeight<r.viewport.scrollHeight;o(l?d:m)}},10);return gu(r.viewport,c),gu(r.content,c),t.jsx(Ts,{present:n||i,children:t.jsx(o_,{"data-state":i?"visible":"hidden",...a,ref:s})})}),o_=u.forwardRef((e,s)=>{const{orientation:r="vertical",...n}=e,a=ga(wi,e.__scopeScrollArea),i=u.useRef(null),o=u.useRef(0),[l,c]=u.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=g7(l.viewport,l.content),m={...n,sizes:l,onSizesChange:c,hasThumb:d>0&&d<1,onThumbChange:f=>i.current=f,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:f=>o.current=f};function h(f,p){return wde(f,o.current,l,p)}return r==="horizontal"?t.jsx(gde,{...m,ref:s,onThumbPositionChange:()=>{if(a.viewport&&i.current){const f=a.viewport.scrollLeft,p=gC(f,l,a.dir);i.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:f=>{a.viewport&&(a.viewport.scrollLeft=f)},onDragScroll:f=>{a.viewport&&(a.viewport.scrollLeft=h(f,a.dir))}}):r==="vertical"?t.jsx(vde,{...m,ref:s,onThumbPositionChange:()=>{if(a.viewport&&i.current){const f=a.viewport.scrollTop,p=gC(f,l);i.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:f=>{a.viewport&&(a.viewport.scrollTop=f)},onDragScroll:f=>{a.viewport&&(a.viewport.scrollTop=h(f))}}):null}),gde=u.forwardRef((e,s)=>{const{sizes:r,onSizesChange:n,...a}=e,i=ga(wi,e.__scopeScrollArea),[o,l]=u.useState(),c=u.useRef(null),d=at(s,c,i.onScrollbarXChange);return u.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),t.jsx(f7,{"data-orientation":"horizontal",...a,ref:d,sizes:r,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ry(r)+"px",...e.style},onThumbPointerDown:m=>e.onThumbPointerDown(m.x),onDragScroll:m=>e.onDragScroll(m.x),onWheelScroll:(m,h)=>
vendor: 4,123 bytes, line 818
818{if(i.viewport){const f=i.viewport.scrollLeft+m.deltaX;e.onWheelScroll(f),y7(f,h)&&m.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&n({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Dg(o.paddingLeft),paddingEnd:Dg(o.paddingRight)}})}})}),vde=u.forwardRef((e,s)=>{const{sizes:r,onSizesChange:n,...a}=e,i=ga(wi,e.__scopeScrollArea),[o,l]=u.useState(),c=u.useRef(null),d=at(s,c,i.onScrollbarYChange);return u.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),t.jsx(f7,{"data-orientation":"vertical",...a,ref:d,sizes:r,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ry(r)+"px",...e.style},onThumbPointerDown:m=>e.onThumbPointerDown(m.y),onDragScroll:m=>e.onDragScroll(m.y),onWheelScroll:(m,h)=>{if(i.viewport){const f=i.viewport.scrollTop+m.deltaY;e.onWheelScroll(f),y7(f,h)&&m.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&n({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Dg(o.paddingTop),paddingEnd:Dg(o.paddingBottom)}})}})}),[yde,h7]=l7(wi),f7=u.forwardRef((e,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:m,onResize:h,...f}=e,p=ga(wi,r),[x,g]=u.useState(null),b=at(s,R=>g(R)),w=u.useRef(null),j=u.useRef(""),y=p.viewport,v=n.content-n.viewport,N=Qt(m),S=Qt(c),k=ny(h,10);function $(R){if(w.current){const A=R.clientX-w.current.left,T=R.clientY-w.current.top;d({x:A,y:T})}}return u.useEffect(()=>{const R=A=>{const T=A.target;(x==null?void 0:x.contains(T))&&N(A,v)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[y,x,v,N]),u.useEffect(S,[n,S]),gu(x,k),gu(p.content,k),t.jsx(yde,{scope:r,scrollbar:x,hasThumb:a,onThumbChange:Qt(i),onThumbPointerUp:Qt(o),onThumbPositionChange:S,onThumbPointerDown:Qt(l),children:t.jsx(ze.div,{...f,ref:b,style:{position:"absolute",...f.style},onPointerDown:Se(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),w.current=x.getBoundingClientRect(),j.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),$(R))}),onPointerMove:Se(e.onPointerMove,$),onPointerUp:Se(e.onPointerUp,R=>{const A=R.target;A.hasPointerCapture(R.pointerId)&&A.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=j.current,p.viewport&&(p.viewport.style.scrollBehavior=""),w.current=null})})})}),Tg="ScrollAreaThumb",p7=u.forwardRef((e,s)=>{const{forceMount:r,...n}=e,a=h7(Tg,e.__scopeScrollArea);return t.jsx(Ts,{present:r||a.hasThumb,children:t.jsx(bde,{ref:s,...n})})}),bde=u.forwardRef((e,s)=>{const{__scopeScrollArea:r,style:n,...a}=e,i=ga(Tg,r),o=h7(Tg,r),{onThumbPositionChange:l}=o,c=at(s,h=>o.onThumbChange(h)),d=u.useRef(),m=ny(()=>{d.current&&(d.current(),d.current=void 0)},100);return u.useEffect(()=>{const h=i.viewport;if(h){const f=()=>{if(m(),!d.current){const p=Nde(h,l);d.current=p,l()}};return l(),h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)}},[i.viewport,m,l]),t.jsx(ze.div,{"data-state":o.hasThumb?"visible":"hidden",...a,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Se(e.onPointerDownCapture,h=>{const p=h.target.getBoundingClientRect(),x=h.clientX-p.left,g=h.clientY-p.top;o.onThumbPointerDown({x,y:g})}),onPointerUp:Se(e.onPointerUp,o.onThumbPointerUp)})});p7.displayName=Tg;var l_="ScrollAreaCorner",x7=u.forwardRef((e,s)=>{const r=ga(l_,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?t.jsx(jde,{...e,ref:s}):null});x7.displayName=l_;var jde=u.forwardRef((e,s)=>{const{__scopeScrollArea:r,...n}=e,a=ga(l_,r),[i,o]=u.useState(0),[l,c]=u.useState(0),d=!!(i&&l);return gu(a.scrollbarX,()=>{var h;const m=((h=a.scrollbarX)==null?void 0:h.offsetHeight)||0;
818a.onCornerHeightChange(m),c(m)}),gu(a.scrollbarY,()=>{var h;const m=((h=a.scrollbarY)==null?void 0:h.offsetWidth)||0;a.onCornerWidthChange(m),o(m)}),d?t.jsx(ze.div,{...n,ref:s,style:{width:i,height:l,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Dg(e){return e?parseInt(e,10):0}function g7(e,s){const r=e/s;return isNaN(r)?0:r}function ry(e){const s=g7(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*s;return Math.max(n,18)}function wde(e,s,r,n="ltr"){const a=ry(r),i=a/2,o=s||i,l=a-o,c=r.scrollbar.paddingStart+o,d=r.scrollbar.size-r.scrollbar.paddingEnd-l,m=r.content-r.viewport,h=n==="ltr"?[0,m]:[m*-1,0];return v7([c,d],h)(e)}function gC(e,s,r="ltr"){const n=ry(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,i=s.scrollbar.size-a,o=s.content-s.viewport,l=i-n,c=r==="ltr"?[0,o]:[o*-1,0],d=Rh(e,c);return v7([0,o],[0,l])(d)}function v7(e,s){return r=>{if(e[0]===e[1]||s[0]===s[1])return s[0];const n=(s[1]-s[0])/(e[1]-e[0]);return s[0]+n*(r-e[0])}}function y7(e,s){return e>0&&e<s}var Nde=(e,s=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return function a(){const i={left:e.scrollLeft,top:e.scrollTop},o=r.left!==i.left,l=r.top!==i.top;(o||l)&&s(),r=i,n=window.requestAnimationFrame(a)}(),()=>window.cancelAnimationFrame(n)};function ny(e,s){const r=Qt(e),n=u.useRef(0);return u.useEffect(()=>()=>window.clearTimeout(n.current),[]),u.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function gu(e,s){const r=Qt(s);qs(()=>{let n=0;if(e){const a=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return a.observe(e),()=>{window.cancelAnimationFrame(n),a.unobserve(e)}}},[e,r])}function _de(e,s){const{asChild:r,children:n}=e;if(!r)return typeof s=="function"?s(n):s;const a=u.Children.only(n);return u.cloneElement(a,{children:typeof s=="function"?s(a.props.children):s})}var b7=c7,Sde=u7,Cde=x7;const rp=u.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(b7,{ref:n,className:oe("relative overflow-hidden",e),...r,children:[t.jsx(Sde,{className:"h-full w-full rounded-[inherit]",children:s}),t.jsx(j7,{}),t.jsx(Cde,{})]}));rp.displayName=b7.displayName;const j7=u.forwardRef(({className:e,orientation:s="vertical",...r},n)=>t.jsx(i_,{ref:n,orientation:s,className:oe("flex touch-none select-none transition-colors",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...r,children:t.jsx(p7,{className:"relative flex-1 rounded-full bg-border"})}));j7.displayName=i_.displayName;function kde(){const[e,s]=u.useState([]),[r,n]=u.useState(!0),{toast:a}=rt(),i=async(f=!1)=>{try{n(!0);let p=W.from("stories").select("*").order("created_at",{ascending:!1});f&&(p=p.eq("is_published",!0));const{data:x,error:g}=await p;if(g)throw g;s(x||[])}catch(p){console.error("Error fetching stories:",p),a({title:"Error",description:"Failed to load stories",variant:"destructive"})}finally{n(!1)}},o=async f=>{try{const{data:{user:p}}=await W.auth.getUser(),x={...f,author_id:p==null?void 0:p.id},{data:g,error:b}=await W.from("stories").insert([x]).select().single();if(b)throw b;return a({title:"Success",description:"Story created successfully"}),g}catch(p){return console.error("Error creating story:",p),a({title:"Error",description:p.message||"Failed to create story",variant:"destructive"}),null}},l=async(f,p)=>{try{const x={...p,updated_at:new Date().toISOString()},{data:g,error:b}=await W.from("stories").update(x).eq("id",f).select().single();if(b)throw b;return a({title:"Success",description:"Story updated successfully"}),g}catch(x){return console.error("Error updating story:",x),a({title:"Error",description:x.message||"Failed to update story",variant:"destructive"}),null}},c=async f=>{try{const{error:p}=await W.from("stories").delete().eq("id",f);if(p)throw p;return a({title:"Success",description:"Story deleted successfully"}),!0}catch(p){return console.error("Error deleting story:",p),a({title:"Error",description:p.message||"Failed to delete story",variant:"destructive"}),!1}},d=async(f,p)=>(p||new Date().toISOString(),l(f,{is_published:!p})),m=async(f,p)=>l(f,{featured:!p}),h=async f=>{try{const{data:{user:p}}=await W.auth.getUser(),x=f.map(w=>({...w,author_id:p==null?void 0:p.id,is_published:w.is_published??!1,featured:w.featured??
818!1})),{data:g,error:b}=await W.from("stories").insert(x).select();if(b)throw b;return a({title:"Success",description:`${g.length} stories imported successfully`}),g}catch(p){return console.error("Error bulk creating stories:",p),a({title:"Error",description:p.message||"Failed to import stories",variant:"destructive"}),null}};return u.useEffect(()=>{i()},[]),{stories:e,loading:r,fetchStories:i,createStory:o,updateStory:l,deleteStory:c,togglePublished:d,toggleFeatured:m,bulkCreateStories:h}}const w7=["Community","Business","Events","Education","Transport","People","Health","Environment","Arts & Culture","Sports","Other"],N7=e=>e.replace(/^Area\s+\d+\s*-\s*/i,"").trim();function _7(){const[e,s]=u.useState([]),[r,n]=u.useState(!0);return u.useEffect(()=>{(async()=>{try{const{data:i,error:o}=await W.from("pricing_areas").select("id, name").eq("is_active",!0).order("sort_order",{ascending:!0});if(o)throw o;const l=(i||[]).map(c=>({id:c.id,name:c.name,cleanName:N7(c.name)}));s(l)}catch(i){console.error("Error fetching areas:",i)}finally{n(!1)}})()},[]),{areas:e,loading:r}}function $de(){const{stories:e,loading:s,fetchStories:r,createStory:n,updateStory:a,deleteStory:i,togglePublished:o,toggleFeatured:l,bulkCreateStories:c}=kde(),{areas:d}=_7(),{toast:m}=rt(),h=u.useRef(null),[f,p]=u.useState(!1),[x,g]=u.useState(null),[b,w]=u.useState({title:"",excerpt:"",content:"",category:"",area:"",featured_image_url:"",author_name:"",author_phone:"",is_published:!1,featured:!1}),[j,y]=u.useState([]),[v,N]=u.useState(!1),[S,k]=u.useState([]),[$,R]=u.useState(!1),[A,T]=u.useState(!1),P=z=>{N(z),z?(y([]),w(Z=>({...Z,area:"All Areas"}))):w(Z=>({...Z,area:""}))},B=(z,Z)=>{if(v)return;let M;Z?M=[...j,z]:M=j.filter(F=>F!==z),y(M),w(F=>({...F,area:M.join(", ")}))},Y=()=>{w({title:"",excerpt:"",content:"",category:"",area:"",featured_image_url:"",author_name:"",author_phone:"",is_published:!1,featured:!1}),y([]),N(!1),g(null)},I=()=>{Y(),p(!0)},C=z=>{g(z);const Z=z.area==="All Areas",M=Z?[]:z.area.split(",").map(F=>F.trim()).filter(Boolean);N(Z),y(M),w({title:z.title,excerpt:z.excerpt||"",content:z.content,category:z.category,area:z.area,featured_image_url:z.featured_image_url||"",author_name:z.author_name||"",author_phone:z.author_phone||"",is_published:z.is_published,featured:z.featured}),p(!0)},L=async z=>{z.preventDefault(),x?await a(x.id,b)&&(p(!1),Y(),r()):await n(b)&&(p(!1),Y(),r())},D=async z=>{confirm("Are you sure you want to delete this story?")&&await i(z)&&r()},_=async z=>{var M;const Z=(M=z.target.files)==null?void 0:M[0];if(Z){T(!0);try{const F=Z.name.split(".").pop(),se=`stories/${`${Date.now()}.${F}`}`,{error:le}=await W.storage.from("story-images").upload(se,Z);if(le)throw le;const{data:{publicUrl:X}}=W.storage.from("story-images").getPublicUrl(se);w(ye=>({...ye,featured_image_url:X})),m({title:"Image uploaded successfully"})}catch(F){m({title:"Error",description:F.message||"Failed to upload image",variant:"destructive"})}finally{T(!1)}}},H=()=>{const M=`title,excerpt,content,category,area,author_name 819"New Community Garden Opens","Local residents celebrate the opening...","Full article content here...","Community","FAREHAM & SURROUNDS","Emma Thompson"`,F=new Blob([M],{type:"text/csv"}),ee=window.URL.createObjectURL(F),se=document.createElement("a");se.href=ee,se.download="stories_template.csv",se.click(),window.URL.revokeObjectURL(ee)},O=z=>{var F;const Z=(F=z.target.files)==null?void 0:F[0];if(!Z)return;const M=new FileReader;M.onload=ee=>{var Ce;const le=((Ce=ee.target)==null?void 0:Ce.result).split(` 820`).filter(ke=>ke.trim()),X=le[0].split(",").map(ke=>ke.trim().replace(/"/g,"")),ye=[];for(let ke=1;ke<le.length;ke++){const Ee=(le[ke].match(/(".*?"|[^",\s]+)(?=\s*,|\s*$)/g)||[]).map(te=>te.replace(/^"|"$/g,"").trim()),K={};
820X.forEach((te,Q)=>{K[te]=Ee[Q]||""}),K.title&&K.content&&K.category&&K.area&&ye.push({title:K.title,excerpt:K.excerpt||"",content:K.content,category:K.category,area:K.area,author_name:K.author_name||"",is_published:!1,featured:!1})}k(ye),R(!0)},M.readAsText(Z),h.current&&(h.current.value="")},U=async()=>{await c(S)&&(R(!1),k([]),r())},G={total:e.length,published:e.filter(z=>z.is_published).length,draft:e.filter(z=>!z.is_published).length,featured:e.filter(z=>z.featured).length},E=z=>new Date(z).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"});return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Stories Management"}),t.jsx("p",{className:"text-muted-foreground",children:"Create and manage community stories and news."})]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[t.jsx(xe,{children:t.jsx(ge,{className:"p-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ir,{className:"h-8 w-8 text-primary"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Stories"}),t.jsx("p",{className:"text-2xl font-bold",children:G.total})]})]})})}),t.jsx(xe,{children:t.jsx(ge,{className:"p-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(tr,{className:"h-8 w-8 text-green-600"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Published"}),t.jsx("p",{className:"text-2xl font-bold",children:G.published})]})]})})}),t.jsx(xe,{children:t.jsx(ge,{className:"p-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(di,{className:"h-8 w-8 text-gray-500"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Draft"}),t.jsx("p",{className:"text-2xl font-bold",children:G.draft})]})]})})}),t.jsx(xe,{children:t.jsx(ge,{className:"p-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(mr,{className:"h-8 w-8 text-yellow-500"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Featured"}),t.jsx("p",{className:"text-2xl font-bold",children:G.featured})]})]})})})]}),t.jsx(xe,{children:t.jsx(ge,{className:"p-4",children:t.jsxs("div",{className:"flex flex-wrap gap-3",children:[t.jsxs(bt,{open:f,onOpenChange:z=>{p(z),z||Y()},children:[t.jsxs(q,{onClick:I,children:[t.jsx(Xt,{className:"h-4 w-4 mr-2"}),"Add Story"]}),t.jsxs(xt,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[t.jsx(jt,{children:t.jsx(wt,{children:x?"Edit Story":"Add New Story"})}),t.jsxs("form",{onSubmit:L,className:"space-y-6",children:[t.jsxs(ha,{defaultValue:"basic",className:"w-full",children:[t.jsxs(Hn,{className:"grid w-full grid-cols-3",children:[t.jsx(Rt,{value:"basic",children:"Basic Info"}),t.jsx(Rt,{value:"content",children:"Content"}),t.jsx(Rt,{value:"media",children:"Media"})]}),t.jsxs(Mt,{value:"basic",className:"space-y-4 mt-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"title",children:"Story Title *"}),t.jsx(re,{id:"title",value:b.title,onChange:z=>w(Z=>({...Z,title:z.target.value})),required:!0})]}),t.jsxs("div",{children:[t.jsx(V,{htmlFor:"excerpt",children:"Excerpt (Short description for cards)"}),t.jsx(ms,{id:"excerpt",value:b.excerpt,onChange:z=>w(Z=>({...Z,excerpt:z.target.value})),placeholder:"Brief description (150 characters recommended)",rows:2})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"category",children:"Category *"}),t.jsxs(ht,{value:b.category,onValueChange:z=>w(Z=>({...Z,category:z})),children:[t.jsx(ut,{children:t.jsx(ft,{placeholder:"Select category"})}),t.jsx(mt,{children:w7.map(z=>t.jsx(Pe,{value:z,children:z},z))})]})]}),t.jsxs("div",{children:[t.jsx(V,{children:"Area(s) *"}),t.jsxs("div",{className:"border rounded-md p-3 space-y-3 bg-background",children:[t.jsxs("div",{className:"flex items-center space-x-2 pb-2 border-b",children:[t.jsx(Kt,{id:"all-areas",checked:v,onCheckedChange:z=>P(z)}),t.jsxs("label",{htmlFor:"all-areas",className:"text-sm font-medium cursor-pointer",children:["All Areas (",d.length," editions)"]})]}),t.jsx(rp,{className:"h-48",children:t.jsx("div",{className:"space-y-2",children:d.map(z=>t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(Kt,{id:`area-${z.id}`,checked:v||j.includes(z.name),disabled:v,onCheckedChange:Z=>B(z.name,Z)}),t.jsx("label",{htmlFor:`area-${z.id}`,className:oe("text-sm cursor-pointer",v&&"text-muted-foreground"),children:z.cleanName})]},z.id))})}),t.jsx("div",{className:"text-xs text-muted-foreground pt-2 border-t",children:v?`Story will appear in all ${d.length}
820 editions`:j.length>0?`Selected: ${j.length} area(s)`:"Please select at least one area"})]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"author_name",children:"Author Name"}),t.jsx(re,{id:"author_name",value:b.author_name,onChange:z=>w(Z=>({...Z,author_name:z.target.value}))})]}),t.jsxs("div",{children:[t.jsxs(V,{htmlFor:"author_phone",className:"flex items-center gap-2",children:[t.jsx(zr,{className:"h-4 w-4"}),"Contact Phone"]}),t.jsx(re,{id:"author_phone",type:"tel",value:b.author_phone,onChange:z=>w(Z=>({...Z,author_phone:z.target.value})),placeholder:"07700 900000"})]})]})]}),t.jsxs(Mt,{value:"content",className:"space-y-4 mt-4",children:[t.jsxs("div",{children:[t.jsx(V,{htmlFor:"content",children:"Full Content *"}),t.jsx(ms,{id:"content",value:b.content,onChange:z=>w(Z=>({...Z,content:z.target.value})),placeholder:"Write the full story content here...",rows:12,required:!0})]}),t.jsxs("div",{className:"flex gap-6",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(kt,{id:"is_published",checked:b.is_published,onCheckedChange:z=>w(Z=>({...Z,is_published:z}))}),t.jsx(V,{htmlFor:"is_published",children:"Published"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(kt,{id:"featured",checked:b.featured,onCheckedChange:z=>w(Z=>({...Z,featured:z}))}),t.jsx(V,{htmlFor:"featured",children:"Featured"})]})]})]}),t.jsx(Mt,{value:"media",className:"space-y-4 mt-4",children:t.jsxs("div",{children:[t.jsx(V,{children:"Featured Image"}),t.jsxs("div",{className:"flex gap-4 items-start",children:[b.featured_image_url&&t.jsx("img",{src:b.featured_image_url,alt:"Story preview",className:"w-32 h-24 object-cover rounded-md"}),t.jsxs("div",{className:"flex-1",children:[t.jsx(re,{type:"file",accept:"image/*",onChange:_,disabled:A}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:A?"Uploading...":"Upload an image for the story"})]})]})]})})]}),t.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[t.jsx(q,{type:"button",variant:"outline",onClick:()=>p(!1),children:"Cancel"}),t.jsx(q,{type:"submit",children:x?"Update Story":"Create Story"})]})]})]})]}),t.jsxs(q,{variant:"outline",onClick:H,children:[t.jsx(ei,{className:"h-4 w-4 mr-2"}),"Download Template"]}),t.jsxs("div",{children:[t.jsx("input",{ref:h,type:"file",accept:".csv",onChange:O,className:"hidden",id:"csv-upload-stories"}),t.jsxs(q,{variant:"outline",onClick:()=>{var z;return(z=h.current)==null?void 0:z.click()},children:[t.jsx(sn,{className:"h-4 w-4 mr-2"}),"Import CSV"]})]})]})})}),t.jsx(bt,{open:$,onOpenChange:R,children:t.jsxs(xt,{className:"max-w-4xl max-h-[80vh] overflow-y-auto",children:[t.jsx(jt,{children:t.jsxs(wt,{children:["Preview CSV Import (",S.length," stories)"]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Title"}),t.jsx(ue,{children:"Category"}),t.jsx(ue,{children:"Area"}),t.jsx(ue,{children:"Author"})]})}),t.jsx(Wt,{children:S.map((z,Z)=>t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:z.title}),t.jsx(de,{children:z.category}),t.jsx(de,{children:z.area}),t.jsx(de,{children:z.author_name||"-"})]},Z))})]})}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(q,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),t.jsxs(q,{onClick:U,children:["Import ",S.length," Stories"]})]})]})}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{children:"All Stories"})}),t.jsx(ge,{children:s?t.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading stories..."}):e.length===0?t.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[t.jsx(ir,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),t.jsx("p",{children:"No stories found. Create your first story!"})]}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Story"}),t.jsx(ue,{children:"Category"}),t.jsx(ue,{children:"Area"}),t.jsx(ue,{children:"Author"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Featured"}),t.jsx(ue,{children:"Created"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:e.map(z=>t.jsxs(Xe,{children:[t.jsx(de,{children:t.jsxs("div",{className:"flex items-center gap-3",children:[z.featured_image_url&&t.jsx("img",{src:z.featured_image_url,alt:z.title,className:"w-12 h-8 object-cover rounded"}),t.jsxs("div",{className:"max-w-xs",children:[t.jsx("p",{className:"font-medium truncate",children:z.title}),z.excerpt&&t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:z.excerpt})]})]})}),t.jsx(de,{children:t.jsx(we,{variant:"outline",children:z.category})}),t.jsx(de,{children:t.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[t.jsx(_t,{className:"h-3 w-3"}),t.jsx("span",{className:"truncate max-w-32",children:z.area})]})}),t.jsx(de,{children:z.author_name||"-"}),t.jsx(de,{children:t.jsx(q,{variant:"ghost",size:"sm",onClick:async()=>{await o(z.id,z.is_published),r()},children:z.is_published?t.jsx(tr,{className:"h-4 w-4 text-green-600"}):t.jsx(di,{className:"h-4 w-4 text-gray-400"})})}),t.jsx(de,{children:t.jsx(q,{variant:"ghost",size:"sm",onClick:async()=>{await l(z.id,z.featured),r()},children:z.featured?t.jsx(mr,{className:"h-4 w-4 text-yellow-500 fill-yellow-500"}):t.jsx(mE,{className:"h-4 w-4 text-gray-400"})})}),t.jsx(de,{className:"text-sm text-muted-foreground",children:E(z.created_at)}),t.jsx(de,{children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>C(z),children:t.jsx(ra,{className:"h-4 w-4"})}),t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>D(z.id),children:t.jsx(cs,{className:"h-4 w-4 text-destructive"})})]})})]},z.id))})]})})})]})]})}const Ede=[{title:"Dashboard",icon:wf,section:"overview"}
820,{title:"Businesses",icon:Xr,section:"businesses"},{title:"Business Accreditations",icon:sv,section:"accreditations"},{title:"Business Keywords",icon:fL,section:"keywords"},{title:"Claim Requests",icon:KF,section:"claim-requests"},{title:"Clients",icon:ua,section:"users"},{title:"Stories",icon:ir,section:"stories"},{title:"Events",icon:It,section:"events"},{title:"Alerts",icon:mi,section:"alerts"},{title:"Cost Calculator",icon:sc,section:"calculator"},{title:"Ad Preview Images",icon:pi,section:"ad-preview-images"},{title:"Magazine Editions",icon:tu,section:"magazine-editions"},{title:"Featured Advertisers",icon:mr,section:"featured-advertisers"},{title:"Competitions",icon:hi,section:"competitions"},{title:"Directory Import",icon:sn,section:"csv-import"},{title:"Email Templates",icon:ar,section:"email-templates"},{title:"Artwork",icon:Wi,section:"artwork"},{title:"Media Library",icon:iE,section:"media-library"}];function Pde({activeSection:e,onSectionChange:s}){const{state:r}=Yu(),n=r==="collapsed";return t.jsx(CN,{className:n?"w-16":"w-64",collapsible:"icon",children:t.jsxs($N,{className:"bg-card border-r",children:[t.jsx("div",{className:"p-4 border-b",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Oa,{className:"h-6 w-6 text-primary"}),!n&&t.jsxs("div",{children:[t.jsx("h2",{className:"font-semibold text-sm",children:"Admin Panel"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Management Dashboard"})]})]})}),t.jsx(gd,{children:t.jsx(vd,{children:t.jsx(ql,{children:Ede.map(a=>t.jsx("div",{children:t.jsx(Lo,{children:t.jsx(Bo,{asChild:!0,isActive:e===a.section,className:"cursor-pointer",children:t.jsx("button",{onClick:()=>s(a.section),className:"flex items-center justify-between w-full text-left",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(a.icon,{className:"h-4 w-4 flex-shrink-0"}),!n&&t.jsx("span",{className:"text-sm",children:a.title})]})})})})},a.section))})})}),t.jsx("div",{className:"mt-auto p-4 border-t",children:t.jsxs(ql,{children:[t.jsx(Lo,{children:t.jsx(Bo,{asChild:!0,children:t.jsxs(eV,{to:"/",className:"flex items-center gap-3 w-full text-left text-muted-foreground hover:text-foreground",children:[t.jsx(gl,{className:"h-4 w-4 flex-shrink-0"}),!n&&t.jsx("span",{className:"text-sm",children:"Back to Website"})]})})}),t.jsx(Lo,{children:t.jsx(Bo,{asChild:!0,children:t.jsxs("button",{className:"flex items-center gap-3 w-full text-left text-muted-foreground hover:text-foreground",children:[t.jsx($w,{className:"h-4 w-4 flex-shrink-0"}),!n&&t.jsx("span",{className:"text-sm",children:"Settings"})]})})})]})})]})})}function Rg({value:e,onUpload:s,onClear:r,label:n="Upload Image",aspectRatio:a="auto",maxSizeMB:i=5,disabled:o=!1,className:l}){const[c,d]=u.useState(!1),[m,h]=u.useState(!1),[f,p]=u.useState(null),[x,g]=u.useState(null),b=f||e,w=b&&b!==x?b:void 0,j=A=>["image/jpeg","image/png","image/gif","image/webp"].includes(A.type)?A.size>i*1024*1024?`File size must be less than ${i}MB`:null:"Please upload a valid image file (JPG, PNG, GIF, or WebP)",y=u.useCallback(async A=>{const T=j(A);if(T){alert(T);return}const P=URL.createObjectURL(A);p(P),h(!0);try{const B=await s(A);p(null)}catch(B){p(null),console.error("Upload failed:",B)}finally{h(!1),URL.revokeObjectURL(P)}},[s,i]),v=u.useCallback(A=>{A.preventDefault(),o||d(!0)},[o]),N=u.useCallback(A=>{A.preventDefault(),d(!1)},[]),S=u.useCallback(A=>{if(A.preventDefault(),d(!1),o)return;const T=A.dataTransfer.files[0];T&&y(T)},[o,y]),k=()=>{if(o||m)return;const A=document.createElement("input");A.type="file",A.accept="image/jpeg,image/png,image/gif,image/webp",A.onchange=T=>{var B;const P=(B=T.target.files)==null?void 0:B[0];P&&y(P)},A.click()},$=A=>{A.stopPropagation(),p(null),r==null||r()},R=a==="square"?"aspect-square":a==="landscape"?"aspect-video":"min-h-[120px]";return t.jsxs("div",{className:oe("space-y-2",l),children:[n&&t.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:n}),t.jsx("div",{onClick:k,onDragOver:v,onDragLeave:N,onDrop:S,className:oe("relative border-2 border-dashed rounded-lg transition-colors cursor-pointer overflow-hidden",R,c&&"border-primary bg-primary/5",!c&&!w&&"border-muted-foreground
820/25 hover:border-muted-foreground/50",w&&"border-transparent",o&&"opacity-50 cursor-not-allowed",m&&"pointer-events-none"),children:w?t.jsxs("div",{className:"relative w-full h-full",children:[t.jsx("img",{src:w,alt:"Preview",className:"w-full h-full object-cover",onError:()=>g(w)}),!m&&r&&t.jsx("button",{type:"button",onClick:$,className:"absolute top-2 right-2 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90",children:t.jsx(Es,{className:"h-4 w-4"})}),m&&t.jsx("div",{className:"absolute inset-0 bg-background/50 flex items-center justify-center",children:t.jsx(it,{className:"h-8 w-8 animate-spin text-primary"})})]}):t.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 text-muted-foreground p-4",children:m?t.jsx(it,{className:"h-8 w-8 animate-spin"}):b?t.jsxs(t.Fragment,{children:[t.jsx(pi,{className:"h-8 w-8"}),t.jsx("span",{className:"text-sm text-center",children:"Existing image could not be loaded"}),t.jsx("span",{className:"text-xs text-center",children:"Click or drop a file to replace it"})]}):t.jsxs(t.Fragment,{children:[t.jsx(sn,{className:"h-8 w-8"}),t.jsx("span",{className:"text-sm text-center",children:"Drag & drop or click to upload"}),t.jsxs("span",{className:"text-xs",children:["Max ",i,"MB (JPG, PNG, GIF, WebP)"]})]})})})]})}function c_(){const[e,s]=u.useState(!1),{toast:r}=rt();return{uploadImage:async(i,o,l)=>{s(!0);try{const c=i.name.split(".").pop(),d=Math.random().toString(36).slice(2,8),m=`${o}/${l}-${Date.now()}-${d}.${c}`,{error:h}=await W.storage.from("business-images").upload(m,i,{cacheControl:"3600",upsert:l==="logo"||l==="featured"});if(h)throw h;const{data:f}=W.storage.from("business-images").getPublicUrl(m);return f.publicUrl}catch(c){return console.error("Upload error:",c),r({title:"Upload failed",description:c.message||"Failed to upload image",variant:"destructive"}),null}finally{s(!1)}},deleteImage:async i=>{try{const o="/business-images/",l=i.indexOf(o);if(l===-1)return!1;const c=i.slice(l+o.length),{error:d}=await W.storage.from("business-images").remove([c]);if(d)throw d;return!0}catch(o){return console.error("Delete error:",o),r({title:"Delete failed",description:o.message||"Failed to delete image",variant:"destructive"}),!1}},isUploading:e}}const Ade="image/jpeg,image/png,image/webp,image/gif",Tde=5*1024*1024;function Dde({businessId:e,images:s,onChange:r,disabled:n,maxImages:a=12}){const{uploadImage:i,deleteImage:o,isUploading:l}=c_(),{toast:c}=rt(),d=u.useRef(null),[m,h]=u.useState(null),f=Math.max(0,a-s.length),p=f>0&&!n,x=async y=>{if(!y||!y.length)return;const v=Array.from(y).slice(0,f),N=[];for(const S of v){if(S.size>Tde){c({title:"File too large",description:`${S.name} exceeds 5MB.`,variant:"destructive"});continue}const k=await i(S,e,"gallery");k&&N.push(k)}N.length&&r([...s,...N]),d.current&&(d.current.value="")},g=async y=>{const v=s[y],N=s.filter((S,k)=>k!==y);r(N),v&&await o(v)},b=y=>h(y),w=y=>y.preventDefault(),j=y=>{if(m===null||m===y)return;const v=[...s],[N]=v.splice(m,1);v.splice(y,0,N),r(v),h(null)};return t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.length," of ",a," images. Drag to reorder."]})}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:[s.map((y,v)=>t.jsxs("div",{draggable:!n,onDragStart:()=>b(v),onDragOver:w,onDrop:()=>j(v),className:`group relative aspect-[4/3] rounded-xl overflow-hidden bg-muted border ${m===v?"opacity-50":""}`,children:[t.jsx("img",{src:y,alt:`Gallery ${v+1}`,className:"w-full h-full object-cover"}),t.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors"}),t.jsx("button",{type:"button",onClick:()=>g(v),disabled:n,className:"absolute top-2 right-2 h-7 w-7 rounded-full bg-background/90 text-foreground flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-destructive hover:text-destructive-foreground","aria-label":"Remove image",children:t.jsx(Es,{className:"h-4 w-4"})}),t.jsx("div",{className:"absolute top-2 left-2 h-7 w-7 rounded-full bg-background/90 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-move",children:t.jsx(Su,{className:"h-4 w-4 text-muted-foreground"})})]},y+v)),p&&t.jsxs("button",{type:"button",onClick:()=>{var y;return(y=d.current)==null?void 0:y.click()},disabled:l,className:"aspect-[4/3] rounded-xl bg-muted/40 border border-dashed flex flex-col items-center justify-center text-muted-foreground hover:bg-muted hover:text-foreground transition disabled:opacity-50",children:[l?t.jsx(it,{className:"h-6 w-6 mb-1 animate-spin"}):t.jsx(Xt,{className:"h-6 w-6 mb-1"}),t.jsx("span",{className:"text-sm font-medium",children:l?"Uploadingâ¦":"Add photo"}),t.jsx("span",{className:"text-xs",children:"Max 5MB (JPG, PNG, WebP)"})]}),s.length===0&&!p&&t.jsxs("div",{className:"aspect-[4/3] rounded-xl bg-muted/40 border flex flex-col items-center justify-center text-muted-foreground",children:[t.jsx(pi,{className:"h-6 w-6 mb-1"}),t.jsx("span",{className:"text-sm",children:"No images"})]})]}),t.jsx("input",{ref:d,type:"file",accept:Ade,multiple:!0,className:"hidden",onChange:y=>x(y.target.files)})]})}function Rde(e){return Array.isArray(e)?e.map((s,r)=>({accreditation_id:String((s==null?void 0:s.accreditation_id)??""),sort_order:Number.isFinite(s==null?void 0:s.sort_order)?Number(s.sort_order):r,link_url:typeof(s==null?void 0:s.link_url)=="str
820ing"&&s.link_url.trim()?s.link_url.trim():null})).filter(s=>s.accreditation_id).sort((s,r)=>s.sort_order-r.sort_order):[]}function Mde({items:e,onChange:s,disabled:r}){const[n,a]=u.useState([]),[i,o]=u.useState(!0),[l,c]=u.useState(""),[d,m]=u.useState(null);u.useEffect(()=>{let y=!1;return(async()=>{const{data:v}=await W.rpc("get_accreditation_library");y||(a(v||[]),o(!1))})(),()=>{y=!0}},[]);const h=u.useMemo(()=>new Map(n.map(y=>[y.id,y])),[n]),f=u.useMemo(()=>new Set(e.map(y=>y.accreditation_id)),[e]),p=u.useMemo(()=>{const y=l.trim().toLowerCase();return y?n.filter(v=>v.name.toLowerCase().includes(y)):n},[n,l]),x=y=>y.map((v,N)=>({...v,sort_order:N})),g=(y,v)=>{if(v){if(f.has(y))return;s(x([...e,{accreditation_id:y,sort_order:e.length,link_url:null}]))}else s(x(e.filter(N=>N.accreditation_id!==y)))},b=(y,v)=>{s(e.map(N=>N.accreditation_id===y?{...N,link_url:v||null}:N))},w=y=>{if(d===null||d===y)return;const v=[...e],[N]=v.splice(d,1);v.splice(y,0,N),s(x(v)),m(null)},j=e.map(y=>({ref:y,entry:h.get(y.accreditation_id)})).filter(y=>y.entry);return i?t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(it,{className:"h-4 w-4 animate-spin"})," Loading accreditationsâ¦"]}):t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose from the shared accreditation library. Drag the selected logos to reorder them on the listing."}),j.length>0&&t.jsx("div",{className:"space-y-2",children:j.map((y,v)=>{const N=y.entry.requires_business_link;return t.jsxs("div",{draggable:!r,onDragStart:()=>m(v),onDragOver:S=>S.preventDefault(),onDrop:()=>w(v),className:`rounded-lg border bg-card p-2 ${d===v?"opacity-50":""}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Su,{className:"h-3.5 w-3.5 text-muted-foreground cursor-move flex-shrink-0"}),t.jsx("img",{src:y.entry.image_url,alt:y.entry.name,className:"h-8 w-8 object-contain flex-shrink-0"}),t.jsx("span",{className:"text-xs flex-1 truncate",children:y.entry.name}),t.jsx("button",{type:"button",disabled:r,onClick:()=>g(y.ref.accreditation_id,!1),"aria-label":`Remove ${y.entry.name}`,className:"h-5 w-5 rounded-full flex items-center justify-center text-muted-foreground hover:bg-destructive hover:text-destructive-foreground flex-shrink-0",children:t.jsx(Es,{className:"h-3 w-3"})})]}),t.jsxs("div",{className:"mt-2 pl-6 space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Sw,{className:"h-3 w-3 text-muted-foreground"}),t.jsx(re,{value:y.ref.link_url??"",disabled:r,onChange:S=>b(y.ref.accreditation_id,S.target.value),onBlur:S=>b(y.ref.accreditation_id,S.target.value.trim()),placeholder:N?`This business's ${y.entry.name} page URL`:y.entry.link_url||"Link (optional)",className:"h-8 text-xs"})]}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:N&&!y.ref.link_url?"Add this businessâs own profile URL for this badge.":y.ref.link_url?"Using this listingâs own link.":y.entry.link_url?`Leave blank to use the shared link (${y.entry.link_url}).`:"No link set â the logo will show without a link."})]})]},y.ref.accreditation_id)})}),t.jsxs("div",{className:"relative",children:[t.jsx(Ur,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),t.jsx(re,{value:l,onChange:y=>c(y.target.value),placeholder:"Search accreditations",className:"pl-8",disabled:r})]}),t.jsx(rp,{className:"h-[600px] rounded-lg border",children:t.jsxs("div",{className:"p-2 space-y-1",children:[p.length===0&&t.jsx("p",{className:"text-sm text-muted-foreground p-2",children:"No accreditations in the library yet."}),p.map(y=>t.jsxs("label",{className:"flex items-center gap-3 rounded-md px-2 py-1.5 hover:bg-accent cursor-pointer",children:[t.jsx(Kt,{checked:f.has(y.id),disabled:r,onCheckedChange:v=>g(y.id,v===!0)}),t.jsx("img",{src:y.image_url,alt:y.name,className:"h-8 w-8 object-contain flex-shrink-0"}),t.jsx("span",{className:"text-sm truncate",children:y.name}),y.requires_business_link&&t.jsx("span",{className:"ml-auto flex-shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground border rounded px-1.5 py-0.5",children:"Needs own link"})]},y.id))]})})]})}const S7=["monday","tuesday","wednesday","thursday","friday","saturday","
820sunday"];function Ode(e){const s={};if(!e||typeof e!="object")return s;for(const r of S7){const n=e[r];if(n){if(typeof n=="object"){s[r]={open:n.open||"",close:n.close||"",closed:!!n.closed};continue}if(typeof n=="string"){const a=n.trim();if(!a||/^closed$/i.test(a)){s[r]={closed:!0};continue}const i=a.match(/(\d{1,2}:?\d{0,2})\s*[-âto]+\s*(\d{1,2}:?\d{0,2})/i);if(i){const o=l=>{const c=l.includes(":")?l:l.length<=2?`${l}:00`:`${l.slice(0,-2)}:${l.slice(-2)}`,[d,m="00"]=c.split(":");return`${d.padStart(2,"0")}:${m.padStart(2,"0")}`};s[r]={open:o(i[1]),close:o(i[2]),closed:!1}}}}}return s}function Ide({value:e,onChange:s}){const r=u.useMemo(()=>Ode(e),[e]),n=(i,o)=>{const l={...r,[i]:{...r[i]||{},...o}};s(l)},a=()=>{const i=r.monday;if(!i)return;const o={...r};["tuesday","wednesday","thursday","friday"].forEach(l=>{o[l]={...i}}),s(o)};return t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"flex justify-end",children:t.jsxs(q,{type:"button",variant:"ghost",size:"sm",onClick:a,children:[t.jsx(Wx,{className:"h-3.5 w-3.5 mr-1"})," Copy Mon to TueâFri"]})}),t.jsx("div",{className:"space-y-2",children:S7.map(i=>{const o=r[i]||{},l=!!o.closed;return t.jsxs("div",{className:"grid grid-cols-[110px_auto_1fr_auto_1fr] items-center gap-2 py-1.5 border-b last:border-0",children:[t.jsx(V,{className:"capitalize text-sm",children:i}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(kt,{checked:!l,onCheckedChange:c=>n(i,{closed:!c}),"aria-label":`${i} open`}),t.jsx("span",{className:"text-xs text-muted-foreground w-12",children:l?"Closed":"Open"})]}),t.jsx(re,{type:"time",value:o.open||"",disabled:l,onChange:c=>n(i,{open:c.target.value}),className:"h-9"}),t.jsx("span",{className:"text-muted-foreground text-sm px-1",children:"to"}),t.jsx(re,{type:"time",value:o.close||"",disabled:l,onChange:c=>n(i,{close:c.target.value}),className:"h-9"})]},i)})})]})}function Fde({businessId:e}){const{toast:s}=rt(),[r,n]=u.useState([]),[a,i]=u.useState([]),[o,l]=u.useState(!1),[c,d]=u.useState(!1);u.useEffect(()=>{(async()=>{const{data:x}=await W.from("directory_areas").select("area_code, internal_name").eq("is_active",!0).order("sort_order");x&&n(x)})()},[]);const m=u.useCallback(async()=>{if(!e){i([]);return}l(!0);const{data:p}=await W.from("business_areas").select("area_code").eq("business_id",e);i((p||[]).map(x=>x.area_code)),l(!1)},[e]);u.useEffect(()=>{m()},[m]);const h=async(p,x)=>{if(!e)return;const g=a;i(x?[...a,p]:a.filter(w=>w!==p));const{error:b}=x?await W.from("business_areas").insert({business_id:e,area_code:p}):await W.from("business_areas").delete().eq("business_id",e).eq("area_code",p);b&&(i(g),s({title:"Could not update areas",description:b.message,variant:"destructive"}))};if(!e)return t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Area"}),t.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-3 rounded-md",children:"Save the listing first to assign areas."})]});const f=r.filter(p=>a.includes(p.area_code));return t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Area"}),t.jsxs(Cn,{open:c,onOpenChange:d,children:[t.jsx(kn,{asChild:!0,children:t.jsxs(q,{type:"button",variant:"outline",className:"w-full justify-between font-normal",children:[t.jsx("span",{className:"truncate",children:o?"Loadingâ¦":f.length===0?"Select areas":`${f.length} area${f.length===1?"":"s"} selected`}),o?t.jsx(it,{className:"h-4 w-4 animate-spin opacity-50"}):t.jsx(yh,{className:"h-4 w-4 opacity-50"})]})}),t.jsx(en,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:t.jsx(rp,{className:"max-h-64",children:t.jsx("div",{className:"p-2 space-y-1",children:r.map(p=>t.jsxs("label",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-accent cursor-pointer",children:[t.jsx(Kt,{checked:a.includes(p.area_code),onCheckedChange:x=>h(p.area_code,x===!0)}),t.jsx("span",{children:p.internal_name})]},p.area_code))})})})]}),f.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:f.map(p=>t.jsx(we,{variant:"secondary",className:"font-normal",children:p.internal_name},p.area_code))}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Internal only â the public listing shows town and postcode, never an area name or number."})]})}function Lde({business:e,onClose:s,onSave:r}){var Y,I;const{toast:n}=rt(),[a,i]=u.useState(!1),{uploadImage:o,isUploading:l}=c_(),[c,d]=u.useState((e==null?void 0:e.id)||null),[m,h]=u.useState([]),[f,p]=u.useState(!1),[x,g]=u.useState("basics"),b=!(e!=null&&e.id),w=C=>(C||"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),j=async(C,L,D)=>{const _=w(C)||"business",H=w(L),{data:O}=await W.from("businesses").select("id, slug").or(`slug.eq.${_},slug.like.${_}-%`),U=new Set((O||[]).filter(E=>!D||E.id!==D).map(E=>
820E.slug).filter(Boolean));if(!U.has(_))return _;if(H){const E=`${_}-${H}`;if(!U.has(E))return E;let z=2;for(;U.has(`${E}-${z}`);)z++;return`${E}-${z}`}let G=2;for(;U.has(`${_}-${G}`);)G++;return`${_}-${G}`},[y,v]=u.useState({name:(e==null?void 0:e.name)||"",description:(e==null?void 0:e.description)||"",email:(e==null?void 0:e.email)||"",phone:(e==null?void 0:e.phone)||"",mobile:(e==null?void 0:e.mobile)||"",website:(e==null?void 0:e.website)||"",address_line1:(e==null?void 0:e.address_line1)||"",address_line2:(e==null?void 0:e.address_line2)||"",city:(e==null?void 0:e.city)||"",postcode:(e==null?void 0:e.postcode)||"",logo_url:(e==null?void 0:e.logo_url)||"",featured_image_url:(e==null?void 0:e.featured_image_url)||"",images:(e==null?void 0:e.images)||[],accreditations:Rde(e==null?void 0:e.accreditations),is_active:(e==null?void 0:e.is_active)??!0,is_verified:(e==null?void 0:e.is_verified)??!1,featured:(e==null?void 0:e.featured)??!1,advertises_in_discover:(e==null?void 0:e.advertises_in_discover)??!1,operating_tags:(e==null?void 0:e.operating_tags)||[],owner_id:(e==null?void 0:e.owner_id)||"",facebook_url:(e==null?void 0:e.facebook_url)||"",instagram_url:(e==null?void 0:e.instagram_url)||"",twitter_url:(e==null?void 0:e.twitter_url)||"",linkedin_url:(e==null?void 0:e.linkedin_url)||"",tiktok_url:(e==null?void 0:e.tiktok_url)||"",youtube_url:(e==null?void 0:e.youtube_url)||"",checkatrade_url:(e==null?void 0:e.checkatrade_url)||"",opening_hours:(e==null?void 0:e.opening_hours)||{}});u.useEffect(()=>{(async()=>{const{data:L,error:D}=await W.rpc("get_users_for_owner_assignment");!D&&L&&h(L)})()},[]);const N=(C,L)=>{v(D=>({...D,[C]:L}))},S=w(y.name||"")||"business",k=async C=>{const L=c||(e==null?void 0:e.id);if(!L)return n({title:"Save First",description:"Please save the business first before uploading images.",variant:"destructive"}),null;const D=await o(C,L,"logo");return D&&N("logo_url",D),D},$=async C=>{const L=c||(e==null?void 0:e.id);if(!L)return n({title:"Save First",description:"Please save the business first before uploading images.",variant:"destructive"}),null;const D=await o(C,L,"featured");return D&&N("featured_image_url",D),D},R=async C=>{C.preventDefault(),i(!0);try{const L={...y,owner_id:y.owner_id||null};if(b&&!c){const D=await j(y.name,y.city,null),{data:_,error:H}=await W.from("businesses").insert({...L,slug:D}).select().single();if(H)throw H;d(_.id),n({title:"Business Created",description:"Business created successfully. You can now upload images."})}else{const D=c||(e==null?void 0:e.id);let _=L;const H=(e==null?void 0:e.name)!==y.name,O=(e==null?void 0:e.city)!==y.city;if(!(e!=null&&e.slug)||H||O){const G=await j(y.name,y.city,D);_={...L,slug:G}}const{error:U}=await W.from("businesses").update(_).eq("id",D);if(U)throw U;n({title:"Success",description:"Business updated successfully."}),r()}}catch(L){n({title:"Error",description:L.message,variant:"destructive"})}finally{i(!1)}},A=[y.facebook_url,y.instagram_url,y.twitter_url,y.linkedin_url,y.tiktok_url,y.youtube_url,y.checkatrade_url].filter(C=>!!(C||"").trim()).length,T=(y.logo_url?1:0)+(y.featured_image_url?1:0)+(((Y=y.images)==null?void 0:Y.length)||0)+(((I=y.accreditations)==null?void 0:I.length)||0),P=C=>{var L;if(!((L=y.name)!=null&&L.trim())){C.preventDefault(),g("basics"),n({title:"Business name required",description:"Add a business name on the Basics tab before saving.",variant:"destructive"});return}R(C)},B=({count:C})=>C>0?t.jsx("span",{className:"ml-1.5 rounded-full bg-muted px-1.5 text-[10px] leading-4 text-muted-foreground",children:C}):null;return t.jsxs("div",{className:"flex flex-col h-full max-h-[80vh]",children:[t.jsxs(jt,{className:"pb-4",children:[t.jsxs(wt,{className:"flex items-center gap-2",children:[t.jsx(Xr,{className:"h-5 w-5"}),b&&!c?"Add New Business":`Edit Business: ${y.name||(e==null?void 0:e.name)}`]}),t.jsx(ys,{children:b&&!c?"Fill in the business details below. Save to enable image uploads.":"Update all business information. Changes are saved immediately."})]}),t.jsx("form",{onSubmit:P,className:"flex flex-col flex-1 min-h-0",children:t.jsxs(ha,{value:x,onValueChange:g,className:"flex flex-col flex-1 min-h-0",children:[t.jsx("div",{className:"overflow-x-auto pb-2",children:t.jsxs(Hn,{className:"inline-flex w-auto",children:[t.jsxs(Rt,{value:"basics",children:[t.jsx(Xr,{className:"h-3.5 w-3.5 mr-1.5"})," Basics"]}),t.jsxs(Rt,{value:"contact",children:[t.jsx(zr,{className:"h-3.5 w-3.5 mr-1.5"})," Contact"]}),t.jsxs(Rt,{value:"location",children:[t.jsx(_t,{className:"h-3.5 w-3.5 mr-1.5"})," Location"]}),t.jsxs(Rt,{value:"media",children:[t.jsx(pi,{className:"h-3.5 w-3.5 mr-1.5"})," Media",t.jsx(B,{count:T})]}),t.jsxs(Rt,{value:"hours",children:[t.jsx(ws,{className:"h-3.5 w-3.5 mr-1.5"})," Hours"]}),t.jsxs(Rt,{value:"social",children:[t.jsx(Ew,{className:"h-3.5 w-3.5 mr-1.5"})," Social",t.jsx(B,{count:A})]}),t.jsxs(Rt,{value:"settings",children:[t.jsx($w,{className:"h-3.5 w-3.5 mr-1.5"})," Settings"]})]})}),t.jsx(rp,{className:"flex-1 pr-4",children:t.jsxs("div",{className:"py-2",children:[t.jsxs(Mt,{value:"basics",className:"space-y-4 mt
820-0",children:[t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"name",children:"Business Name *"}),t.jsx(re,{id:"name",value:y.name,onChange:C=>N("name",C.target.value),required:!0}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["URL: /business/",S]})]})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"description",children:"About"}),t.jsx(ms,{id:"description",value:y.description,onChange:C=>N("description",C.target.value),rows:3})]}),t.jsx(jR,{businessId:c||(e==null?void 0:e.id)||null,mode:"admin"})]}),t.jsxs(Mt,{value:"contact",className:"space-y-4 mt-0",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"email",children:"Email"}),t.jsx(re,{id:"email",type:"email",value:y.email,onChange:C=>N("email",C.target.value)})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"mobile",children:"Mobile"}),t.jsx(re,{id:"mobile",value:y.mobile,onChange:C=>N("mobile",C.target.value)})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"phone",children:"Phone"}),t.jsx(re,{id:"phone",value:y.phone,onChange:C=>N("phone",C.target.value)})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"website",children:"Website"}),t.jsx(re,{id:"website",value:y.website,onChange:C=>N("website",C.target.value),placeholder:"https://"})]})]}),t.jsxs(Mt,{value:"location",className:"space-y-4 mt-0",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"address_line1",children:"Address Line 1"}),t.jsx(re,{id:"address_line1",value:y.address_line1,onChange:C=>N("address_line1",C.target.value)})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"address_line2",children:"Address Line 2"}),t.jsx(re,{id:"address_line2",value:y.address_line2,onChange:C=>N("address_line2",C.target.value)})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"city",children:"City"}),t.jsx(re,{id:"city",value:y.city,onChange:C=>N("city",C.target.value)})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"postcode",children:"Postcode"}),t.jsx(re,{id:"postcode",value:y.postcode,onChange:C=>N("postcode",C.target.value)})]})]}),t.jsx(Fde,{businessId:c||(e==null?void 0:e.id)||null})]}),t.jsxs(Mt,{value:"media",className:"space-y-4 mt-0",children:[b&&!c?t.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-3 rounded-md",children:"Save the business first to enable image uploads."}):t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx(Rg,{label:"Logo",value:y.logo_url,onUpload:k,onClear:()=>N("logo_url",""),aspectRatio:"square",disabled:l}),t.jsx(Rg,{label:"Featured Image",value:y.featured_image_url,onUpload:$,onClear:()=>N("featured_image_url",""),aspectRatio:"landscape",disabled:l})]}),!(b&&!c)&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Gallery"}),t.jsx(Dde,{businessId:c||(e==null?void 0:e.id),images:y.images,onChange:C=>N("images",C),disabled:l})]}),!(b&&!c)&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Accreditations"}),t.jsx(Mde,{items:y.accreditations,onChange:C=>N("accreditations",C),disabled:l})]})]}),t.jsx(Mt,{value:"hours",className:"space-y-4 mt-0",children:t.jsx(Ide,{value:y.opening_hours,onChange:C=>N("opening_hours",C)})}),t.jsx(Mt,{value:"social",className:"space-y-4 mt-0",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"facebook_url",children:"Facebook"}),t.jsx(re,{id:"facebook_url",value:y.facebook_url,onChange:C=>N("facebook_url",C.target.value),placeholder:"https://facebook.com/yourbusiness"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"instagram_url",children:"Instagram"}),t.jsx(re,{id:"instagram_url",value:y.instagram_url,onChange:C=>N("instagram_url",C.target.value),placeholder:"https://instagram.com/yourbusiness"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"twitter_url",children:"Twitter / X"}),t.jsx(re,{id:"twitter_url",value:y.twitter_url,onChange:C=>N("twitter_url",C.target.value),placeholder:"https://x.com/yourbusiness"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"linkedin_url",children:"LinkedIn"}),t.jsx(re,{id:"linkedin_url",value:y.linkedin_url,onChange:C=>N("linkedin_url",C.target.value),placeholder:"https://linkedin.com/company/yourbusiness"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"tiktok_url",children:"TikTok"}),t.jsx(re,{id:"tiktok_url",value:y.tiktok_url,onChange:C=>N("tiktok_url",C.target.value),placeholder:"https://tiktok.com/@yourbusiness"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"youtube_url",children:"YouTube"}),t.jsx(re,{id:"youtube_url",value:y.youtube_url,onChange:C=>N("youtube_url",C.target.value),placeholder:"https://youtube.com/@yourbusiness"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"checkatrade_url",children:"Checkatrade"}),t.jsx(re,{id:"checkatrade_url",value:y.checkatrade_url,onChange:C=>N("checkatrade_url",C.target.value),placeholder:"https://www.checkatrade.com/trades/yourbusiness"})]})]})}
820),t.jsxs(Mt,{value:"settings",className:"space-y-4 mt-0",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(V,{htmlFor:"is_active",children:"Active"}),t.jsx(kt,{id:"is_active",checked:y.is_active,onCheckedChange:C=>N("is_active",C)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(V,{htmlFor:"is_verified",children:"Verified"}),t.jsx(kt,{id:"is_verified",checked:y.is_verified,onCheckedChange:C=>N("is_verified",C)})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(V,{htmlFor:"featured",children:"Featured"}),t.jsx(kt,{id:"featured",checked:y.featured,onCheckedChange:C=>N("featured",C)})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Featured advertisers are normally set in bulk from the Directory Import tab. That tool is declarative â the next run will overwrite anything changed here."})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(V,{htmlFor:"advertises_in_discover",children:"Advertises in Discover"}),t.jsx(kt,{id:"advertises_in_discover",checked:y.advertises_in_discover,onCheckedChange:C=>N("advertises_in_discover",C)})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Business Tags"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown as bubbles on the listing card. Toggles and keywords are normally set in bulk from the Directory Import tab â that tool is declarative, so the next import will overwrite anything changed here."}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-x-6 gap-y-3 pt-1",children:eN.map(C=>t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(V,{htmlFor:`tag_${C.value}`,children:C.label}),t.jsx(kt,{id:`tag_${C.value}`,checked:y.operating_tags.includes(C.value),onCheckedChange:L=>N("operating_tags",L?[...y.operating_tags,C.value]:y.operating_tags.filter(D=>D!==C.value))})]},C.value))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Listing Owner"}),(()=>{const C=m.find(D=>D.user_id===y.owner_id),L=C?`${C.display_name||C.email||"Unnamed user"}${C.email?` · ${C.email}`:""}`:"No owner (unclaimed)";return t.jsxs(Cn,{open:f,onOpenChange:p,children:[t.jsx(kn,{asChild:!0,children:t.jsxs(q,{type:"button",variant:"outline",role:"combobox","aria-expanded":f,className:"w-full justify-between font-normal",children:[t.jsx("span",{className:"truncate text-left",children:L}),t.jsx(yh,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t.jsx(en,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:t.jsxs(_c,{filter:(D,_)=>_?D.toLowerCase().includes(_.toLowerCase())?1:0:1,children:[t.jsx(xu,{placeholder:"Search by name, company, or emailâ¦"}),t.jsxs(Sc,{children:[t.jsx(Cc,{children:"No users found."}),t.jsxs(kc,{children:[t.jsxs(ii,{value:"no-owner-unclaimed",onSelect:()=>{N("owner_id",""),p(!1)},children:[t.jsx(Bs,{className:oe("mr-2 h-4 w-4",y.owner_id?"opacity-0":"opacity-100")}),"No owner (unclaimed)"]}),m.map(D=>{const _=[D.display_name,D.email,D.company,D.user_id].filter(Boolean).join(" ");return t.jsxs(ii,{value:_,onSelect:()=>{N("owner_id",D.user_id),p(!1)},children:[t.jsx(Bs,{className:oe("mr-2 h-4 w-4",y.owner_id===D.user_id?"opacity-100":"opacity-0")}),t.jsxs("div",{className:"flex flex-col min-w-0",children:[t.jsx("span",{className:"truncate",children:D.display_name||D.email||"Unnamed user"}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:[D.email,D.company].filter(Boolean).join(" · ")})]})]},D.user_id)})]})]})]})})]})})(),t.jsx("p",{className:"text-xs text-muted-foreground",children:'Leave as "No owner (unclaimed)" if no business owner has been assigned yet. Assigning a user lets them edit this listing from their dashboard.'})]})]})]})}),t.jsxs("div",{className:"flex gap-2 pt-4 border-t bg-background",children:[t.jsx(q,{type:"submit",disabled:a||l,className:"flex-1",children:a?"Saving...":b&&!c?"Create Business":"Save Changes"}),c&&b&&t.jsx(q,{type:"button",variant:"secondary",onClick:r,children:"Done"}),t.jsx(q,{type:"button",variant:"outline",onClick:s,children:"Cancel"})]})]})})]})}function Bde(){var x;const{toast:e}=rt(),[s,r]=u.useState([]),[n,a]=u.useState(!0),[i,o]=u.useState(null),[l,c]=u.useState(""),[d,m]=u.useState(!1),h=async()=>{a(!0);const{data:g,error:b}=await W.from("business_removal_requests").select("*, business:businesses(name)").order("created_at",{ascending:!1});b?e({title:"Error",description:b.message,variant:"destructive"}):r(g||[]),a(!1)};u.useEffect(()=>{h()},[]);const f=async(g,b)=>{m(!0);try{const{error:w}=g==="approve"?await W.rpc("approve_business_removal",{_request_id:b.id}):await W.rpc("reject_business_removal",{_request_id:b.id,_reason:l||null});if(w)throw w;g==="approve"&&W.functions.invoke("send-directory-notification",{body:{type:"removal_approved_customer",removal_request_id:b.id}}).catch(()=>{}),e({title:g==="approve"?"Listing removed":"Request rejected",description:g==="approve"?"The listing is now hidden and suppressed, so the CRM import will not reinstate it.":"The listing was left untouched."}),o(null),c(""),h()}catch(w){e({title:"Action failed",description:w.message,variant:"destructive"})}finally{m(!1)}},p=g=>g==="pending"?t.jsxs(we,{variant:"secondary",className:"bg-yellow-100 text-yellow-800",children:[t.jsx(ws,{className:"h-3 w-3 mr-1"})," Pending"]}):g==="approved"?t.jsxs(we,{variant:"secondary",className:"bg-green-100 text-green-800",children:[t.jsx(Bs,{className:"h-3 w-3 mr-1"})," Removed"]}):t.jsxs(we,{variant:"secondary",className:"bg-red-100 text-red-800",children:[t.jsx(Es,{className:"h-3 w-3 mr-1"})," Rejected"]});return t.jsxs("div",{className:"space-y-4",children:[t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(cs,{className:"h-5 w-5"})," Removal Requests"]})}),t.jsx(ge,{children:n?t.jsx("div",{className:"text-center py-8",children:"Loading..."}):s.length===0?t.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[t.jsx(Hs,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),t.jsx("p",{children:"No removal requests yet."})]}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Business"}),t.jsx(ue,{children:"Requester"}),t.jsx(ue,{children:"Relationship"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Date"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:s.map(g=>{var b;return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:((b=g.business)==null?void 0:b.name)||"Unknown listing"}),t.jsxs(de,{children:[t.jsx("div",{children:g.requester_name}),t.jsx("div",{className:"text-xs text-muted-foreground",children:g.requester_email})]}),t.jsx(de,{children:g.relationship||"-"}),t.jsx(de,{children:p(g.status)}),t.jsx(de,{children:Dt(new Date(g.created_at),"dd MMM yyyy")}),t.jsx(de,{children:t.jsxs(q,{variant:"outline",size:"sm",onClick:()=>{o(g),c(g.admin_notes||"")},children:[t.jsx(tr,{className:"h-4 w-4 mr-1"})," Review"]})})]},g.id)})})]})})})]}),t.jsx(bt,{open:!!i,onOpenChange:()=>o(null),children:t.jsxs(xt,{className:"max-w-lg",children:[t.jsxs(jt,{children:[t.jsx(wt,{children:"Review Removal Request"}),t.jsx(ys,{children:"Approving hides the listing and suppresses it, so the CRM import will not bring it back."})]}),i&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx(V,{className:"text-muted-foreground",children:"Business"}),t.jsx("p",{className:"font-medium",children:(x=i.business)==null?void 0:x.name})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-muted-foreground",children:"Requester"}),t.jsx("p",{className:"font-medium",children:i.requester_name}),t.jsx("p",{className:"text-xs text-muted-foreground",children:i.requester_email})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-muted-foreground",children:"Relationship"}),t.jsx("p",{className:"font-medium",children:i.relationship||"-"})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-muted-foreground",children:"Status"}),t.jsx("p",{children:p(i.status)})]})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-muted-foreground",children:"Reason given"}),t.jsx("p",{className:"text-sm mt-1 p-2 bg-muted rounded whitespace-pre-line",children:i.reason})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"removal_admin_notes",children:"Admin notes"}
820),t.jsx(ms,{id:"removal_admin_notes",value:l,onChange:g=>c(g.target.value),rows:3,placeholder:"Used as the reason when rejecting (optional)"})]}),i.status==="pending"?t.jsxs("div",{className:"flex gap-2 pt-2",children:[t.jsxs(q,{onClick:()=>f("approve",i),disabled:d,className:"flex-1 bg-green-600 hover:bg-green-700",children:[t.jsx(Bs,{className:"h-4 w-4 mr-1"})," Approve removal"]}),t.jsxs(q,{variant:"destructive",onClick:()=>f("reject",i),disabled:d,className:"flex-1",children:[t.jsx(Es,{className:"h-4 w-4 mr-1"})," Reject"]})]}):t.jsxs("div",{className:"pt-2 text-center text-muted-foreground text-sm",children:["This request has already been ",i.status==="approved"?"approved":"rejected",".",i.reviewed_at&&t.jsxs("p",{className:"text-xs mt-1",children:["Reviewed on ",Dt(new Date(i.reviewed_at),"dd MMM yyyy HH:mm")]}),i.admin_notes&&t.jsxs("p",{className:"text-xs mt-1",children:["Notes: ",i.admin_notes]})]})]})]})})]})}function zde(){var b,w,j,y;const{toast:e}=rt(),[s,r]=u.useState([]),[n,a]=u.useState(!0),[i,o]=u.useState(null),[l,c]=u.useState(""),[d,m]=u.useState(!1);u.useEffect(()=>{h()},[]);const h=async()=>{a(!0);try{const{data:v,error:N}=await W.from("business_claim_requests").select(` 821 *, 822 business:businesses(name, email, phone) 823 `).order("created_at",{ascending:!1});if(N)throw N;const S=[...new Set((v||[]).map(R=>
823R.user_id))],{data:k}=await W.from("profiles").select("user_id, display_name").in("user_id",S),$=(v||[]).map(R=>({...R,profile:(k==null?void 0:k.find(A=>A.user_id===R.user_id))||null}));r($)}catch(v){console.error("Error loading claim requests:",v),e({title:"Error",description:"Failed to load claim requests",variant:"destructive"})}finally{a(!1)}},f=async v=>{m(!0);try{const{error:N}=await W.rpc("approve_business_claim",{_claim_id:v.id});if(N)throw N;l&&await W.from("business_claim_requests").update({admin_notes:l}).eq("id",v.id),W.functions.invoke("send-directory-notification",{body:{type:"claim_approved_customer",claim_id:v.id}}).catch(()=>{}),e({title:"Claim Approved",description:"The claimant now owns this listing and it is marked as verified."}),o(null),c(""),h()}catch(N){e({title:"Approval failed",description:N.message,variant:"destructive"})}finally{m(!1)}},p=async v=>{m(!0);try{const{error:N}=await W.rpc("reject_business_claim",{_claim_id:v.id,_reason:l||null});if(N)throw N;W.functions.invoke("send-directory-notification",{body:{type:"claim_rejected_customer",claim_id:v.id}}).catch(()=>{}),e({title:"Claim Rejected",description:"The claim request has been rejected."}),o(null),c(""),h()}catch(N){e({title:"Rejection failed",description:N.message,variant:"destructive"})}finally{m(!1)}},x=v=>{switch(v){case"pending":return t.jsxs(we,{variant:"secondary",className:"bg-yellow-100 text-yellow-800",children:[t.jsx(ws,{className:"h-3 w-3 mr-1"})," Pending"]});case"approved":return t.jsxs(we,{variant:"secondary",className:"bg-green-100 text-green-800",children:[t.jsx(Bs,{className:"h-3 w-3 mr-1"})," Approved"]});case"rejected":return t.jsxs(we,{variant:"secondary",className:"bg-red-100 text-red-800",children:[t.jsx(Es,{className:"h-3 w-3 mr-1"})," Rejected"]});default:return t.jsx(we,{variant:"outline",children:v})}},g=s.filter(v=>v.status==="pending").length;return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Directory Review Queue"}),t.jsxs("p",{className:"text-muted-foreground",children:["Review ownership claims and listing removal requests.",g>0&&t.jsxs(we,{variant:"destructive",className:"ml-2",children:[g," pending claims"]})]})]}),t.jsxs(ha,{defaultValue:"claims",className:"space-y-4",children:[t.jsxs(Hn,{children:[t.jsx(Rt,{value:"claims",children:"Claims"}),t.jsx(Rt,{value:"removals",children:"Removals"})]}),t.jsx(Mt,{value:"claims",children:t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(Xr,{className:"h-5 w-5"}),"Claim Requests"]})}),t.jsx(ge,{children:n?t.jsx("div",{className:"text-center py-8",children:"Loading..."}):s.length===0?t.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[t.jsx(Hs,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),t.jsx("p",{children:"No claim requests found."})]}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Business"}),t.jsx(ue,{children:"Claimant"}),t.jsx(ue,{children:"Verification"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Date"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:s.map(v=>{var N,S;return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:((N=v.business)==null?void 0:N.name)||"Unknown Business"}),t.jsx(de,{children:((S=v.profile)==null?void 0:S.display_name)||v.user_id.slice(0,8)+"..."}),t.jsx(de,{children:v.verification_method||"-"}),t.jsx(de,{children:x(v.status)}),t.jsx(de,{children:Dt(new Date(v.created_at),"dd MMM yyyy")}),t.jsx(de,{children:t.jsxs(q,{variant:"outline",size:"sm",onClick:()=>{o(v),c(v.admin_notes||"")},children:[t.jsx(tr,{className:"h-4 w-4 mr-1"}),"Review"]})})]},v.id)})})]})})})]})}),t.jsx(Mt,{value:"removals",children:t.jsx(Bde,{})})]}),t.jsx(bt,{open:!!i,onOpenChange:()=>o(null),children:t.jsxs(xt,{className:"max-w-lg",children:[t.jsxs(jt,{children:[t.jsx(wt,{children:"Review Claim Request"}),t.jsx(ys,{children:"Review the claim details and approve or reject the request."})]}),i&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx(V,{className:"text-muted-foreground",children:"Business"}),t.jsx("p",{className:"font-medium",children:(b=i.business)==null?void 0:b.name})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-muted-foreground",children:"Claimant"}),t.jsx("p",{className:"font-medium",children:((w=i.profile)==null?void 0:w.display_name)||"Unknown"})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-muted-foreground",children:"Business Email"}),t.jsx("p",{className:"font-medium",children:((j=i.business)==null?void 0:j.email)||"-"})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-muted-foreground",children:"Business Phone"}),t.jsx("p",{className:"font-medium",children:((y=i.business)==null?void 0:y.phone)||"-"})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-muted-foreground",children:"Verification Method"}),t.jsx("p",{className:"font-medium",children:i.verification_method||"-"})]}),t.jsxs("div",{children:[t.jsx(V,{className:"text-muted-foreground",children:"Status"}),t.jsx("p",{children:x(i.status)})]})]}),i.verification_notes&&t.jsxs("div",{children:[t.jsx(V,{className:"text-muted-foreground",children:"Claimant's Notes"}),t.jsx("p",{className:"text-sm mt-1 p-2 bg-muted rounded",children:i.verification_notes})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"admin_notes",children:"Admin Notes"}
823),t.jsx(ms,{id:"admin_notes",value:l,onChange:v=>c(v.target.value),placeholder:"Add notes about this claim (optional)",rows:3})]}),i.status==="pending"?t.jsxs("div",{className:"flex gap-2 pt-4",children:[t.jsxs(q,{onClick:()=>f(i),disabled:d,className:"flex-1 bg-green-600 hover:bg-green-700",children:[t.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Approve"]}),t.jsxs(q,{variant:"destructive",onClick:()=>p(i),disabled:d,className:"flex-1",children:[t.jsx(Es,{className:"h-4 w-4 mr-1"}),"Reject"]})]}):t.jsxs("div",{className:"pt-4 text-center text-muted-foreground",children:["This claim has already been ",i.status,".",i.reviewed_at&&t.jsxs("p",{className:"text-xs mt-1",children:["Reviewed on ",Dt(new Date(i.reviewed_at),"dd MMM yyyy HH:mm")]})]})]})]})})]})}const Ude=({advertiser:e,onEdit:s,onDelete:r,onToggleActive:n})=>{const{attributes:a,listeners:i,setNodeRef:o,transform:l,transition:c,isDragging:d}=t_({id:e.id}),m={transform:$c.Transform.toString(l),transition:c,opacity:d?.5:1};return t.jsxs(Xe,{ref:o,style:m,children:[t.jsx(de,{children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{...a,...i,className:"cursor-grab hover:bg-muted p-1 rounded",children:t.jsx(Su,{className:"h-4 w-4 text-muted-foreground"})}),t.jsx("span",{className:"text-muted-foreground",children:e.sort_order})]})}),t.jsx(de,{children:t.jsx("img",{src:e.image_url,alt:e.name,className:"h-12 w-20 object-contain rounded bg-muted"})}),t.jsx(de,{className:"font-medium",children:e.name}),t.jsx(de,{children:e.businesses?t.jsxs(hs,{to:`/business/${e.business_id}`,className:"text-primary hover:underline inline-flex items-center gap-1",children:[e.businesses.name,t.jsx(_u,{className:"h-3 w-3"})]}):t.jsx("span",{className:"text-muted-foreground italic",children:"Not linked"})}),t.jsx(de,{children:t.jsx(kt,{checked:e.is_active,onCheckedChange:h=>n(e.id,h)})}),t.jsx(de,{children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(q,{variant:"ghost",size:"icon",onClick:()=>s(e),children:t.jsx(ra,{className:"h-4 w-4"})}),t.jsx(q,{variant:"ghost",size:"icon",onClick:()=>r(e),children:t.jsx(cs,{className:"h-4 w-4 text-destructive"})})]})})]})},Vde=()=>{var L,D;const{data:e,isLoading:s}=SA(!0),{createAdvertiser:r,updateAdvertiser:n,deleteAdvertiser:a,toggleActive:i,updateSortOrder:o,isCreating:l,isUpdating:c}=TX(),[d,m]=u.useState(!1),[h,f]=u.useState(!1),[p,x]=u.useState(!1),[g,b]=u.useState(null),[w,j]=u.useState(!1),[y,v]=u.useState({name:"",image_url:"",business_id:null,is_active:!0}),{data:N}=Lt({queryKey:["businesses-for-linking"],queryFn:async()=>{const{data:_,error:H}=await W.rpc("get_public_businesses",{limit_count:1e3,offset_count:0});if(H)throw H;return _}}),S=YN(tf(tp),tf(ey,{coordinateGetter:e7})),k=_=>{const{active:H,over:O}=_;if(!O||H.id===O.id||!e)return;const U=e.findIndex(Z=>Z.id===H.id),G=e.findIndex(Z=>Z.id===O.id),z=sp(e,U,G).map((Z,M)=>({id:Z.id,sort_order:M+1}));o(z)},$=u.useCallback(async _=>{try{const H=_.name.split(".").pop(),U=`featured-advertisers/${`featured-${Date.now()}.${H}`}`,{error:G}=await W.storage.from("business-images").upload(U,_);if(G)throw G;const{data:{publicUrl:E}}=W.storage.from("business-images").getPublicUrl(U);return v(z=>({...z,image_url:E})),E}catch(H){return console.error("Error uploading image:",H),null}},[]),R=()=>{v({name:"",image_url:"",business_id:null,is_active:!0})},A=()=>{R(),m(!0)},T=_=>{b(_),v({name:_.name,image_url:_.image_url,business_id:_.business_id,is_active:_.is_active}),f(!0)},P=_=>{b(_),x(!0)},B=(_,H)=>{i({id:_,is_active:H})},Y=()=>{const _=(e==null?void 0:e.reduce((H,O)=>
823Math.max(H,O.sort_order),0))||0;r({...y,sort_order:_+1}),m(!1),R()},I=()=>{g&&(n({id:g.id,...y}),f(!1),b(null),R())},C=()=>{g&&(a(g.id),x(!1),b(null))};return s?t.jsxs(xe,{children:[t.jsxs(Me,{children:[t.jsx(Is,{className:"h-8 w-64"}),t.jsx(Is,{className:"h-4 w-96"})]}),t.jsx(ge,{children:t.jsx(Is,{className:"h-64 w-full"})})]}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(mr,{className:"h-5 w-5"}),"Featured Advertisers"]}),t.jsx(Er,{children:"Manage the advertisers displayed on the homepage carousel. Drag to reorder."})]}),t.jsxs(q,{onClick:A,children:[t.jsx(Xt,{className:"h-4 w-4 mr-2"}),"Add Advertiser"]})]})}),t.jsx(ge,{children:e&&e.length>0?t.jsx(ZN,{sensors:S,collisionDetection:KN,onDragEnd:k,children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{className:"w-20",children:"Order"}),t.jsx(ue,{className:"w-24",children:"Image"}),t.jsx(ue,{children:"Name"}),t.jsx(ue,{children:"Linked Business"}),t.jsx(ue,{className:"w-20",children:"Active"}),t.jsx(ue,{className:"w-24",children:"Actions"})]})}),t.jsx(Wt,{children:t.jsx(e_,{items:e.map(_=>_.id),strategy:JN,children:e.map(_=>t.jsx(Ude,{advertiser:_,onEdit:T,onDelete:P,onToggleActive:B},_.id))})})]})}):t.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[t.jsx(mr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),t.jsx("p",{children:"No featured advertisers yet."}),t.jsx("p",{className:"text-sm",children:'Click "Add Advertiser" to get started.'})]})})]}),t.jsx(bt,{open:d,onOpenChange:m,children:t.jsxs(xt,{className:"max-w-lg max-h-[90vh] flex flex-col",children:[t.jsxs(jt,{children:[t.jsx(wt,{children:"Add Featured Advertiser"}),t.jsx(ys,{children:"Add a new advertiser to the homepage carousel."})]}),t.jsxs("div",{className:"space-y-4 overflow-y-auto flex-1 pr-2",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"name",children:"Advertiser Name *"}),t.jsx(re,{id:"name",value:y.name,onChange:_=>v(H=>({...H,name:_.target.value})),placeholder:"e.g., DJ Summers Plumbing & Heating"})]}),t.jsx("div",{className:"space-y-2",children:t.jsx(Rg,{label:"Artwork Image *",value:y.image_url,onUpload:$,onClear:()=>v(_=>({..._,image_url:""})),aspectRatio:"landscape",maxSizeMB:5})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Link to Business Directory"}),t.jsxs(Cn,{open:w,onOpenChange:j,children:[t.jsx(kn,{asChild:!0,children:t.jsxs(q,{variant:"outline",role:"combobox","aria-expanded":w,className:"w-full justify-between font-normal",children:[y.business_id?((L=N==null?void 0:N.find(_=>_.id===y.business_id))==null?void 0:L.name)||"Select a business...":"No business linked",t.jsx(yh,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t.jsx(en,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:t.jsxs(_c,{children:[t.jsx(xu,{placeholder:"Search businesses..."}),t.jsxs(Sc,{children:[t.jsx(Cc,{children:"No business found."}),t.jsxs(kc,{children:[t.jsxs(ii,{value:"none",onSelect:()=>{v(_=>({..._,business_id:null})),j(!1)},children:[t.jsx(Bs,{className:oe("mr-2 h-4 w-4",y.business_id?"opacity-0":"opacity-100")}),"No business linked"]}),N==null?void 0:N.map(_=>t.jsxs(ii,{value:_.name,onSelect:()=>{v(H=>({...H,business_id:_.id})),j(!1)},children:[t.jsx(Bs,{className:oe("mr-2 h-4 w-4",y.business_id===_.id?"opacity-100":"opacity-0")}),_.name]},_.id))]})]})]})})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"When linked, clicking the advertiser on the homepage will navigate to their directory listing."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(kt,{id:"active",checked:y.is_active,onCheckedChange:_=>v(H=>({...H,is_active:_}))}),t.jsx(V,{htmlFor:"active",children:"Active (visible on homepage)"})]})]}),t.jsxs(ma,{children:[t.jsx(q,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),t.jsx(q,{onClick:Y,disabled:!y.name||!y.image_url||l,children:l?"Creating...":"Create Advertiser"})]})]})}),t.jsx(bt,{open:h,onOpenChange:f,children:t.jsxs(xt,{className:"max-w-lg max-h-[90vh] flex flex-col",children:[t.jsxs(jt,{children:[t.jsx(wt,{children:"Edit Featured Advert
823iser"}),t.jsx(ys,{children:"Update the advertiser details."})]}),t.jsxs("div",{className:"space-y-4 overflow-y-auto flex-1 pr-2",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"edit-name",children:"Advertiser Name *"}),t.jsx(re,{id:"edit-name",value:y.name,onChange:_=>v(H=>({...H,name:_.target.value})),placeholder:"e.g., DJ Summers Plumbing & Heating"})]}),t.jsx("div",{className:"space-y-2",children:t.jsx(Rg,{label:"Artwork Image *",value:y.image_url,onUpload:$,onClear:()=>v(_=>({..._,image_url:""})),aspectRatio:"landscape",maxSizeMB:5})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{children:"Link to Business Directory"}),t.jsxs(Cn,{open:w,onOpenChange:j,children:[t.jsx(kn,{asChild:!0,children:t.jsxs(q,{variant:"outline",role:"combobox","aria-expanded":w,className:"w-full justify-between font-normal",children:[y.business_id?((D=N==null?void 0:N.find(_=>_.id===y.business_id))==null?void 0:D.name)||"Select a business...":"No business linked",t.jsx(yh,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t.jsx(en,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:t.jsxs(_c,{children:[t.jsx(xu,{placeholder:"Search businesses..."}),t.jsxs(Sc,{children:[t.jsx(Cc,{children:"No business found."}),t.jsxs(kc,{children:[t.jsxs(ii,{value:"none",onSelect:()=>{v(_=>({..._,business_id:null})),j(!1)},children:[t.jsx(Bs,{className:oe("mr-2 h-4 w-4",y.business_id?"opacity-0":"opacity-100")}),"No business linked"]}),N==null?void 0:N.map(_=>t.jsxs(ii,{value:_.name,onSelect:()=>{v(H=>({...H,business_id:_.id})),j(!1)},children:[t.jsx(Bs,{className:oe("mr-2 h-4 w-4",y.business_id===_.id?"opacity-100":"opacity-0")}),_.name]},_.id))]})]})]})})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"When linked, clicking the advertiser on the homepage will navigate to their directory listing."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(kt,{id:"edit-active",checked:y.is_active,onCheckedChange:_=>v(H=>({...H,is_active:_}))}),t.jsx(V,{htmlFor:"edit-active",children:"Active (visible on homepage)"})]})]}),t.jsxs(ma,{children:[t.jsx(q,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),t.jsx(q,{onClick:I,disabled:!y.name||!y.image_url||c,children:c?"Updating...":"Update Advertiser"})]})]})}),t.jsx(ia,{open:p,onOpenChange:x,children:t.jsxs(Fn,{children:[t.jsxs(Ln,{children:[t.jsx(zn,{children:"Delete Featured Advertiser"}),t.jsxs(Un,{children:['Are you sure you want to delete "',g==null?void 0:g.name,'"? This action cannot be undone.']})]}),t.jsxs(Bn,{children:[t.jsx(oa,{children:"Cancel"}),t.jsx(Vn,{onClick:C,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})},qde={customer_name:"John Smith",business_name:"Smith & Co Ltd",package_type:"Pay As You Go",ad_size:"Half Page",duration:"6 months",circulation:"25,000",total_cost:"£540.00",monthly_price:"£90.00",duration_discount:"10%",dashboard_url:"https://example.com/dashboard",type_label:"Booking",model_label:"Pay As You Go",email:"[email protected]",phone:"023 9298 9314",company:"Smith & Co Ltd",details_table:'<table style="width:100%;"><tr><td>Package</td><td>Pay As You Go</td></tr></table>',admin_url:"https://example.com/admin",paid_areas:"Fareham, Gosport",free_areas:"Portchester",total_circulation:"15,000",leaflet_size:"A5",number_of_areas:"3",distribution_start:"March 2025",number_of_leaflets:"11,300",deposit_amount:"£127.00",remaining_amount:"£381.00",payment_terms:"25% deposit to secure your slot, 75% balance due 10 days before distribution",business_slug:"smith-and-co-ltd",claimant_email:"[email protected]",verification_method:"I have access to the business email",verification_notes:"I am the owner and use the listed email address.",admin_notes:"We could not match the email address to the listing.",admin_notes_block:"<p><strong>Reason:</strong> We could not match the email address to the listing.</p>",requester_name:"Jane Doe",requester_email:"[email protected]",relationship:"Former owner",reason:"The business closed in 2024 and the listing is out of date."};function Hde(e,s){let r=e;for(const n of s){const a=new RegExp(`\\{\\{${n}\\}\\}`,"g");r=r.replace(a,qde[n]||`[${n}]`)}return r}function Wde(){const[e,s]=u.useState(null),[r,n]=u.useState(""),[a,i]=u.useState(""),{toast:o}=rt(),l=Xs(),{data:c=[],isLoading:d}=Lt({queryKey:["email-templates"],queryFn:async()=>{const{data:p,error:x}=await W.from("email_templates").select("*").order("created_at");if(x)throw x;return p||[]}}),m=os({mutationFn:async({id:p,subject:x,html_body:g})=>{const{error:b}=await W.from("email_templates").update({subject:x,html_body:g}).eq("id",p);if(b)throw b},onSuccess:()=>{o({title:"Saved",description:"Email template updated successfully."}
823),l.invalidateQueries({queryKey:["email-templates"]}),s(null)},onError:p=>{o({title:"Error",description:p.message,variant:"destructive"})}}),h=p=>{s(p),n(p.subject),i(p.html_body)},f=()=>{e&&m.mutate({id:e.id,subject:r,html_body:a})};if(e){const p=Hde(a,e.available_variables);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(q,{variant:"ghost",size:"icon",onClick:()=>s(null),children:t.jsx(Hi,{className:"h-4 w-4"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-bold",children:e.display_name}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Editing email template"})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(q,{variant:"outline",onClick:()=>s(null),children:[t.jsx(Es,{className:"h-4 w-4 mr-2"})," Cancel"]}),t.jsxs(q,{onClick:f,disabled:m.isPending,children:[t.jsx(uL,{className:"h-4 w-4 mr-2"})," ",m.isPending?"Saving...":"Save"]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium",children:"Subject Line"}),t.jsx(re,{value:r,onChange:x=>n(x.target.value)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Variables:"}),e.available_variables.map(x=>t.jsx(we,{variant:"secondary",className:"cursor-pointer font-mono text-xs",onClick:()=>{i(g=>g+`{{${x}}}`)},children:`{{${x}}}`},x))]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",style:{minHeight:"500px"},children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[t.jsx(QF,{className:"h-4 w-4"})," HTML Editor"]}),t.jsx("textarea",{value:a,onChange:x=>i(x.target.value),className:"w-full h-[500px] rounded-md border border-input bg-zinc-950 text-green-400 font-mono text-xs p-4 resize-none focus:outline-none focus:ring-2 focus:ring-ring",spellCheck:!1})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[t.jsx(tr,{className:"h-4 w-4"})," Live Preview"]}),t.jsx("div",{className:"w-full h-[500px] rounded-md border border-input bg-white overflow-auto p-4",dangerouslySetInnerHTML:{__html:p}})]})]})]})}return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Email Templates"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage email templates used for booking confirmations, quotes, and welcome emails."})]}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(ar,{className:"h-5 w-5"})," Templates"]})}),t.jsx(ge,{children:d?t.jsx("p",{className:"text-center py-8 text-muted-foreground",children:"Loading templates..."}):c.length===0?t.jsx("p",{className:"text-center py-8 text-muted-foreground",children:"No templates found. Run the database seed to create default templates."}):t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Template"}),t.jsx(ue,{children:"Subject"}),t.jsx(ue,{children:"Last Updated"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:c.map(p=>t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:p.display_name}),t.jsx(de,{className:"max-w-[300px] truncate text-muted-foreground",children:p.subject}),t.jsx(de,{className:"text-muted-foreground",children:Dt(new Date(p.updated_at),"dd MMM yyyy HH:mm")}),t.jsx(de,{children:t.jsx(q,{size:"sm",variant:"outline",onClick:()=>h(p),children:"Edit"})})]},p.id))})]})})]})]})}const Gde=["business-images","event-images","story-images","magazine-covers","ad-preview-images","competition-images"];function h1(e,s){if(e.startsWith("/"))return e;const r=s?{download:s}:void 0;for(const n of Gde)if(e.startsWith(`${n}/`))return W.storage.from(n).getPublicUrl(e.slice(n.length+1),r).data.publicUrl;return W.storage.from("media-library").getPublicUrl(e,r).data.publicUrl}function Yde(e){return e?e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:"Unknown size"}function R0(e){return e.replace(/\.[^.]+$/,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"file"}
823const vC=["image/jpeg","image/png","image/gif","image/webp","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],yC=20,bC={"business-images":"Business Images","event-images":"Event Images","story-images":"Story Images","magazine-covers":"Magazine Covers","ad-preview-images":"Ad Previews","competition-images":"Competition Images"},Kde=[{path:"/lovable-uploads/discover-logo.png",name:"Discover Logo",folder:"Logos"},{path:"/lovable-uploads/discover-logo-2.png",name:"Discover Logo 2",folder:"Logos"}];function jC(e){return e.startsWith("image/")?t.jsx(pi,{className:"h-8 w-8 text-primary"}):e.includes("pdf")?t.jsx(ir,{className:"h-8 w-8 text-destructive"}):e.includes("sheet")||e.includes("excel")?t.jsx(Gx,{className:"h-8 w-8 text-green-600"}):t.jsx(ZF,{className:"h-8 w-8 text-muted-foreground"})}function wC(e){return e?e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:"Unknown"}function NC(e){var n;const s=(n=e.split(".").pop())==null?void 0:n.toLowerCase();return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}[s||""]||"application/octet-stream"}function Qde(){const{toast:e}=rt(),s=Xs(),[r,n]=u.useState(""),[a,i]=u.useState("all"),[o,l]=u.useState("grid"),[c,d]=u.useState(!1),[m,h]=u.useState(!1),[f,p]=u.useState(null),[x,g]=u.useState(""),[b,w]=u.useState(""),[j,y]=u.useState(""),[v,N]=u.useState(""),[S,k]=u.useState(!1),[$,R]=u.useState(""),[A,T]=u.useState(""),[P,B]=u.useState(!1),[Y,I]=u.useState(0),[C,L]=u.useState(""),{data:D=[],isLoading:_}=Lt({queryKey:["media-library",r,a],queryFn:async()=>{let X=W.from("media_library").select("*").order("created_at",{ascending:!1});r.trim()&&(X=X.or(`file_name.ilike.%${r}%,file_type.ilike.%${r}%,alt_text.ilike.%${r}%`)),a&&a!=="all"&&(a==="uncategorised"?X=X.is("folder",null):X=X.eq("folder",a));const{data:ye,error:Ce}=await X;if(Ce)throw Ce;return ye||[]}}),{data:H=[]}=Lt({queryKey:["media-library-folders"],queryFn:async()=>{const{data:X,error:ye}=await W.from("media_library").select("folder");if(ye)throw ye;return X||[]}}),O=Array.from(new Set(H.map(X=>
823X.folder).filter(Boolean))).sort(),U=os({mutationFn:async X=>{if(!X.file_path.startsWith("/")){const{error:Ce}=await W.storage.from("media-library").remove([X.file_path]);Ce&&console.warn("Storage delete warning:",Ce)}const{error:ye}=await W.from("media_library").delete().eq("id",X.id);if(ye)throw ye},onSuccess:()=>{e({title:"File deleted"}),s.invalidateQueries({queryKey:["media-library"]})},onError:X=>{e({title:"Error",description:X.message,variant:"destructive"})}}),G=os({mutationFn:async({id:X,alt_text:ye,caption:Ce,folder:ke})=>{let fe=R0(v||(f==null?void 0:f.file_name)||"file");const{data:Ee}=await W.from("media_library").select("id, slug").like("slug",`${fe}%`),K=new Set((Ee||[]).filter(Q=>Q.id!==X).map(Q=>Q.slug));if(K.has(fe)){let Q=2;for(;K.has(`${fe}-${Q}`);)Q++;fe=`${fe}-${Q}`}const{error:te}=await W.from("media_library").update({alt_text:ye,caption:Ce,folder:ke||null,slug:fe,is_public:S,public_title:$||null,public_description:A||null}).eq("id",X);if(te)throw te;N(fe)},onSuccess:()=>{e({title:"File updated"}),p(null),s.invalidateQueries({queryKey:["media-library"]})},onError:X=>{e({title:"Error",description:X.message,variant:"destructive"})}}),E=u.useCallback(async()=>{var Ce;B(!0),I(0);let X=0,ye=0;try{const{data:{user:ke}}=await W.auth.getUser(),fe=Object.keys(bC),Ee=fe.length+1;let K=0;const{data:te}=await W.from("media_library").select("file_path"),Q=new Set((te||[]).map(ae=>ae.file_path));for(const ae of fe){K++,L(`Scanning ${ae}â¦`),I(Math.round(K/Ee*100));try{const{data:me,error:pe}=await W.storage.from(ae).list("",{limit:1e3});if(pe){console.warn(`Could not list ${ae}:`,pe);continue}for(const be of me||[]){if(!be.name||be.id===null)continue;const ce=`${ae}/${be.name}`;if(Q.has(ce)){ye++;continue}const{error:ie}=await W.from("media_library").insert({file_name:be.name,file_path:ce,file_type:NC(be.name),file_size:((Ce=be.metadata)==null?void 0:Ce.size)||null,uploaded_by:(ke==null?void 0:ke.id)||null,folder:bC[ae]});ie?console.warn("Insert error:",ie):(X++,Q.add(ce))}}catch(me){console.warn(`Error scanning ${ae}:`,me)}}K++,L("Registering static assetsâ¦"),I(Math.round(K/Ee*100));for(const ae of Kde){if(Q.has(ae.path)){ye++;continue}const{error:me}=await W.from("media_library").insert({file_name:ae.name,file_path:ae.path,file_type:NC(ae.path),file_size:null,uploaded_by:(ke==null?void 0:ke.id)||null,folder:ae.folder,alt_text:ae.name});me||(X++,Q.add(ae.path))}e({title:"Backfill complete",description:`Imported ${X} file(s), skipped ${ye} duplicate(s).`}),s.invalidateQueries({queryKey:["media-library"]})}catch(ke){e({title:"Backfill failed",description:ke.message,variant:"destructive"})}finally{B(!1),L(""),I(0)}},[e,s]),z=u.useCallback(async X=>{const ye=Array.from(X),Ce=ye.filter(ke=>!vC.includes(ke.type)||ke.size>yC*1024*1024);if(Ce.length){e({title:"Invalid files",description:`${Ce.map(ke=>ke.name).join(", ")} â unsupported type or too large`,variant:"destructive"});return}d(!0);try{const{data:{user:ke}}=await W.auth.getUser();for(const fe of ye){const Ee=fe.name.split(".").pop(),K=`${Date.now()}-${Math.random().toString(36).slice(2)}.${Ee}`,{error:te}=await W.storage.from("media-library").upload(K,fe);if(te)throw te;const{error:Q}=await W.from("media_library").insert({file_name:fe.name,file_path:K,file_type:fe.type,file_size:fe.size,uploaded_by:(ke==null?void 0:ke.id)||null});if(Q)throw Q}e({title:`${ye.length} file(s) uploaded`}),s.invalidateQueries({queryKey:["media-library"]})}catch(ke){e({title:"Upload failed",description:ke.message,variant:"destructive"})}finally{d(!1)}},[e,s]),Z=X=>h1(X),M=X=>{const ye=Z(X);navigator.clipboard.writeText(ye),e({title:"URL copied to clipboard"})},F=X=>{if(!X.slug||!X.is_public){e({title:"No public page yet",description:'Open Edit, turn on "Show on a public download page" and save.'}),le(X);return}navigator.clipboard.writeText(`${window.location.origin}/files/${X.slug}`),e({title:"Page link copied"})},ee=u.useCallback(X=>{X.preventDefault(),h(!1),X.dataTransfer.files.length&&z(X.dataTransfer.files)},[z]),se=()=>{const X=document.createElement("input");X.type="file",X.multiple=!0,X.accept=vC.join(","),X.onchange=ye=>{const Ce=ye.target.files;
823Ce!=null&&Ce.length&&z(Ce)},X.click()},le=X=>{p(X),g(X.alt_text||""),w(X.caption||""),y(X.folder||""),N(X.slug||R0(X.file_name)),k(!!X.is_public),R(X.public_title||""),T(X.public_description||"")};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Media Library"}),t.jsx("p",{className:"text-muted-foreground",children:"Upload, manage, and organise all your media files."})]}),t.jsxs(q,{variant:"outline",onClick:E,disabled:P,children:[P?t.jsx(it,{className:"h-4 w-4 animate-spin mr-2"}):t.jsx(JF,{className:"h-4 w-4 mr-2"}),"Backfill from Storage"]})]}),P&&t.jsx(xe,{children:t.jsxs(ge,{className:"py-4 space-y-2",children:[t.jsx("p",{className:"text-sm font-medium",children:C}),t.jsx(n_,{value:Y})]})}),t.jsx("div",{onDragOver:X=>{X.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:ee,onClick:se,className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${m?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-muted-foreground/50"}`,children:c?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(it,{className:"h-8 w-8 animate-spin text-primary"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploadingâ¦"})]}):t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(sn,{className:"h-8 w-8 text-muted-foreground"}),t.jsx("p",{className:"font-medium",children:"Drag & drop files here or click to browse"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Images (JPG, PNG, GIF, WebP), PDF, Word, Excel â max ",yC,"MB"]})]})}),t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[t.jsxs("div",{className:"relative flex-1 max-w-sm",children:[t.jsx(Ur,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(re,{placeholder:"Search filesâ¦",value:r,onChange:X=>n(X.target.value),className:"pl-10"})]}),t.jsxs(ht,{value:a,onValueChange:i,children:[t.jsxs(ut,{className:"w-[180px]",children:[t.jsx(iE,{className:"h-4 w-4 mr-2"}),t.jsx(ft,{placeholder:"All folders"})]}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All folders"}),t.jsx(Pe,{value:"uncategorised",children:"Uncategorised"}),O.map(X=>t.jsx(Pe,{value:X,children:X},X))]})]}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx(q,{variant:o==="grid"?"default":"outline",size:"icon",onClick:()=>l("grid"),children:t.jsx(oE,{className:"h-4 w-4"})}),t.jsx(q,{variant:o==="list"?"default":"outline",size:"icon",onClick:()=>l("list"),children:t.jsx(Kb,{className:"h-4 w-4"})})]}),t.jsxs(we,{variant:"secondary",children:[D.length," file",D.length!==1?"s":""]})]}),_?t.jsx("div",{className:"flex justify-center py-12",children:t.jsx(it,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):D.length===0?t.jsx(xe,{children:t.jsx(ge,{className:"py-12 text-center text-muted-foreground",children:"No files found. Upload your first file above."})}):o==="grid"?t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4",children:D.map(X=>t.jsxs(xe,{className:"overflow-hidden group relative",children:[t.jsx("div",{className:"aspect-square bg-muted flex items-center justify-center overflow-hidden",children:X.file_type.startsWith("image/")?t.jsx("img",{src:Z(X.file_path),alt:X.alt_text||X.file_name,className:"w-full h-full object-cover",loading:"lazy"}):jC(X.file_type)}),t.jsxs(ge,{className:"p-2",children:[t.jsx("p",{className:"text-xs font-medium truncate",title:X.file_name,children:X.file_name}),t.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:wC(X.file_size)}),X.is_public&&t.jsx(we,{className:"text-[10px] px-1 py-0 h-4",children:"Public page"}),X.folder&&t.jsx(we,{variant:"outline",className:"text-[10px] px-1 py-0 h-4",children:X.folder})]})]}),t.jsxs("div",{className:"absolute inset-0 bg-background/80 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",children:[t.jsx(q,{size:"icon",variant:"outline",onClick:()=>F(X),title:"Copy page link",children:t.jsx(U4,{className:"h-4 w-4"})}),t.jsx(q,{size:"icon",variant:"outline",onClick:()=>M(X.file_path),title:"Copy URL",children:t.jsx(Wx,{className:"h-4 w-4"})}),t.jsx(q,{size:"icon",variant:"outline",onClick:()=>le(X),title:"Edit metadata",children:t.jsx(Jr,{className:"h-4 w-4"})}),t.jsx(q,{size:"icon",variant:"destructive",onClick:()=>U.mutate(X),title:"Delete",children:t.jsx(cs,{className:"h-4 w-4"})})]})]},X.id))}):t.jsx(xe,{children:t.jsx(ge,{className:"p-0",children:t.jsx("div",{className:"divide-y",children:D.map(X=>t.jsxs("div",{className:"flex items-center gap-4 p-3 hover:bg-muted/50",children:[t.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center overflow-hidden flex-shrink-0",children:X.file_type.startsWith("image/")?t.jsx("img",{src:Z(X.file_path),alt:"",className:"w-full h-full object-cover",loading:"lazy"}):jC(X.file_type)}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:X.file_name}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("p",{className:"text-xs text-muted-foreground",children:[wC(X.file_size)," ⢠",Dt(new Date(X.created_at),"dd MMM yyyy")]}),X.is_public&&t.jsx(we,{className:"text-[10px] px-1 py-0 h-4",children:"Public page"}),X.folder&&t.jsx(we,{variant:"outline",className:"text-[10px] px-1 py-0 h-4",children:X.folder})]})]}),t.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[t.jsx(q,{size:"icon",variant:"ghost",onClick:()=>M(X.file_path),title:"Copy URL",children:t.jsx(Wx,{className:"h-4 w-4"})}),t.jsx(q,{size:"icon",variant:"ghost",onClick:()=>F(X),title:"Copy page link",children:t.jsx(U4,{className:"h-4 w-4"})}),t.jsx(q,{size:"icon",variant:"ghost",onClick:()=>le(X),children:t.jsx(Jr,{className:"h-4 w-4"})}),t.jsx(q,{size:"icon",variant:"ghost",onClick:()=>U.mutate(X),children:t.jsx(cs,{className:"h-4 w-4 text-destructive"})})]})]},X.id))})})}),t.jsx(bt,{open:!!f,onOpenChange:X=>!X&&p(null),children:t.jsxs(xt,{children:[t.jsx(jt,{children:t.jsx(wt,{children:"Edit File Metadata"})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx(V,{children:"File Name"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:f==null?void 0:f.file_name})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"alt_text",children:"Alt Text"}),t.jsx(re,{id:"alt_text",value:x,onChange:X=>g(X.target.value),placeholder:"Describe the imageâ¦"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"caption",children:"Caption"}),t.jsx(re,{id:"caption",value:b,onChange:X=>w(X.target.value),placeholder:"Optional captionâ¦"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"folder",children:"Folder"}),t.jsx(re,{id:"folder",value:j,onChange:X=>y(X.target.value),placeholder:"e.g. Logos, Magazine Coversâ¦",list:"folder-suggestions"}),t.jsx("datalist",{id:"folder-suggestions",children:O.map(X=>t.jsx("option",{value:X},X))})]}),t.jsxs("div",{className:"space-y-3 rounded-md border p-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(V,{htmlFor:"is_public",children:"Show on a public download page"}),t.jsx(kt,{id:"is_public",checked:S,onCheckedChange:k})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"slug",children:"Page link name"}
823),t.jsx(re,{id:"slug",value:v,onChange:X=>N(X.target.value)}),t.jsxs("p",{className:"text-xs text-muted-foreground break-all",children:[window.location.origin,"/files/",R0(v||"file")]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"public_title",children:"Title"}),t.jsx(re,{id:"public_title",value:$,onChange:X=>R(X.target.value),placeholder:f==null?void 0:f.file_name})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"public_description",children:"Description"}),t.jsx(ms,{id:"public_description",value:A,onChange:X=>T(X.target.value),rows:3})]})]}),t.jsxs("div",{className:"flex gap-2 pt-2",children:[t.jsxs(q,{className:"flex-1",onClick:()=>f&&G.mutate({id:f.id,alt_text:x,caption:b,folder:j}),disabled:G.isPending,children:[G.isPending?t.jsx(it,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save"]}),t.jsx(q,{variant:"outline",onClick:()=>p(null),children:"Cancel"})]})]})]})})]})}const Xde="image/jpeg,image/png,image/webp,image/svg+xml",Zde=5*1024*1024;function Jde(){const{toast:e}=rt(),{uploadImage:s,deleteImage:r,isUploading:n}=c_(),a=u.useRef(null),[i,o]=u.useState([]),[l,c]=u.useState(!0),d=u.useCallback(async()=>{c(!0);const{data:p,error:x}=await W.from("accreditations").select("id, name, image_url, link_url, is_active, sort_order, requires_business_link").order("sort_order").order("name");x&&e({title:"Could not load accreditations",description:x.message,variant:"destructive"}),o(p||[]),c(!1)},[e]);u.useEffect(()=>{d()},[d]);const m=async p=>{if(!(p!=null&&p.length))return;let x=0;for(const g of Array.from(p)){if(g.size>Zde){e({title:"File too large",description:`${g.name} exceeds 5MB.`,variant:"destructive"});continue}const b=await s(g,"library","accreditation");if(!b)continue;const w=g.name.replace(/\.[^.]+$/,"").replace(/[-_]+/g," "),{error:j}=await W.from("accreditations").insert({name:w,image_url:b,sort_order:i.length+x});if(j){e({title:"Could not save accreditation",description:j.message,variant:"destructive"});continue}x+=1}a.current&&(a.current.value=""),x&&d()},h=async(p,x)=>{o(b=>b.map(w=>w.id===p.id?{...w,...x}:w));const{error:g}=await W.from("accreditations").update(x).eq("id",p.id);g&&(e({title:"Could not update",description:g.message,variant:"destructive"}),d())},f=async p=>{if(!confirm(`Delete "${p.name}"? It will be removed from every listing that uses it.`))return;const{error:x}=await W.from("accreditations").delete().eq("id",p.id);if(x){e({title:"Could not delete",description:x.message,variant:"destructive"});return}await r(p.image_url),o(g=>g.filter(b=>b.id!==p.id))};return t.jsxs(xe,{children:[t.jsxs(Me,{children:[t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(sv,{className:"h-5 w-5"})," Accreditations Library"]}),t.jsx(Er,{children:"Upload each accreditation or certificate logo once here. Listings then select from this library, so the same image is never stored twice."})]}),t.jsxs(ge,{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs(q,{type:"button",onClick:()=>{var p;return(p=a.current)==null?void 0:p.click()},disabled:n,children:[n?t.jsx(it,{className:"h-4 w-4 mr-2 animate-spin"}):t.jsx(Xt,{className:"h-4 w-4 mr-2"}),n?"Uploadingâ¦":"Add accreditation"]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Max 5MB (JPG, PNG, WebP, SVG)"}),t.jsx("input",{ref:a,type:"file",accept:Xde,multiple:!0,className:"hidden",onChange:p=>m(p.target.files)})]}),l?t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(it,{className:"h-4 w-4 animate-spin"})," Loadingâ¦"]}):i.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No accreditations yet."}):t.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:i.map(p=>t.jsxs("div",{className:"rounded-xl border bg-card p-3 flex gap-3 items-start",children:[t.jsx("div",{className:"h-16 w-16 rounded-lg bg-muted/40 border flex items-center justify-center p-1.5 flex-shrink-0",children:t.jsx("img",{src:p.image_url,alt:p.name,className:"max-h-full max-w-full object-contain"})}),t.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[t.jsx(re,{value:p.name,onChange:x=>o(g=>g.map(b=>b.id===p.id?{...b,name:x.target.value}:b)),onBlur:x=>h(p,{name:x.target.value}),placeholder:"Accreditation name"}),t.jsx(re,{value:p.link_url||"",onChange:x=>o(g=>g.map(b=>b.id===p.id?{...b,link_url:x.target.value}:b)),onBlur:x=>h(p,{link_url:x.target.value.trim()||null}),placeholder:"Link (optional)"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(kt,{id:`acc-active-${p.id}`,checked:p.is_active,onCheckedChange:x=>h(p,{is_active:x})}),t.jsx(V,{htmlFor:`acc-active-${p.id}`,className:"text-xs font-normal",children:"Available to listings"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(kt,{id:`acc-biz-link-${p.id}`,checked:p.requires_business_link,onCheckedChange:x=>h(p,{requires_business_link:x})}),t.jsx(V,{htmlFor:`acc-biz-link-${p.id}
823`,className:"text-xs font-normal",children:"Business-specific link (each listing adds its own profile URL)"})]})]}),t.jsx(q,{type:"button",variant:"ghost",size:"icon",onClick:()=>f(p),"aria-label":"Delete",children:t.jsx(cs,{className:"h-4 w-4"})})]},p.id))})]})]})}const eue=/^[\p{L}\p{N} &'/-]+$/u;function tue(){const{toast:e}=rt(),[s,r]=u.useState([]),[n,a]=u.useState(!0),[i,o]=u.useState(""),[l,c]=u.useState("all"),[d,m]=u.useState(""),[h,f]=u.useState(!1),[p,x]=u.useState(2),[g,b]=u.useState(!1),w=u.useCallback(async()=>{a(!0);const k=[];for(let $=0;$<20;$++){const{data:R,error:A}=await W.from("keywords").select("id, term, normalised_term, is_selectable, business_keywords(count)").order("term").range($*1e3,$*1e3+999);if(A||!R||(k.push(...R),R.length<1e3))break}r(k.map($=>{var R,A;return{id:$.id,term:$.term,normalised_term:$.normalised_term,is_selectable:!!$.is_selectable,usage:((A=(R=$.business_keywords)==null?void 0:R[0])==null?void 0:A.count)??0}})),a(!1)},[]),j=u.useCallback(async()=>{const{data:k}=await W.from("site_settings").select("setting_value").eq("setting_key","owner_keyword_limit").maybeSingle(),$=k==null?void 0:k.setting_value,R=typeof $=="number"?$:parseInt(String($??"").replace(/"/g,""),10);Number.isNaN(R)||x(R)},[]);u.useEffect(()=>{w(),j()},[w,j]);const y=u.useMemo(()=>{const k=i.trim().toLowerCase();return s.filter($=>k&&!$.normalised_term.includes(k)?!1:l==="selectable"?$.is_selectable:l==="not-selectable"?!$.is_selectable:l==="unused"?$.usage===0:!0)},[s,i,l]),v=async(k,$)=>{r(A=>A.map(T=>T.id===k.id?{...T,is_selectable:$}:T));const{error:R}=await W.from("keywords").update({is_selectable:$}).eq("id",k.id);R&&(r(A=>A.map(T=>T.id===k.id?{...T,is_selectable:!$}:T)),e({title:"Could not update keyword",description:R.message,variant:"destructive"}))},N=async()=>{const k=d.trim().replace(/\s+/g," ");if(k.length<2||k.length>40){e({title:"Keywords must be between 2 and 40 characters",variant:"destructive"});return}if(!eue.test(k)){e({title:"Keywords can only contain letters, numbers, spaces, hyphens, slashes, apostrophes and ampersands",variant:"destructive"});return}f(!0);const $=k.toLowerCase(),R=s.find(T=>T.normalised_term===$);if(R){await v(R,!0),f(!1),m(""),e({title:"Keyword already existed â now selectable"});return}const{error:A}=await W.from("keywords").insert({term:k,normalised_term:$,is_selectable:!0});if(f(!1),A){e({title:"Could not add keyword",description:A.message,variant:"destructive"});return}m(""),e({title:"Keyword added"}),await w()},S=async()=>{const k=Math.max(0,Math.min(20,Math.round(p||0)));b(!0);const{error:$}=await W.from("site_settings").update({setting_value:k}).eq("setting_key","owner_keyword_limit");if(b(!1),$){e({title:"Could not save limit",description:$.message,variant:"destructive"});return}x(k),e({title:"Owner keyword limit saved"})};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold",children:"Business Keywords"}),t.jsx("p",{className:"text-muted-foreground",children:"The approved keyword list used across the directory."})]}),t.jsxs(ss,{children:[t.jsx(hc,{className:"h-4 w-4"}),t.jsx(rs,{children:"The keyword list should match Mirola. New keywords from the CRM import are added automatically."})]}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-lg",children:"Owner keyword allowance"})}),t.jsxs(ge,{className:"flex items-end gap-3",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(V,{htmlFor:"owner-keyword-limit",children:"Keywords a verified owner can add"}),t.jsx(re,{id:"owner-keyword-limit",type:"number",min:0,max:20,value:p,onChange:k=>x(parseInt(k.target.value,10)||0),className:"w-28"})]}),t.jsxs(q,{onClick:S,disabled:g,children:[g&&t.jsx(it,{className:"h-4 w-4 animate-spin mr-1"}),"Save"]})]})]}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-lg",children:"Keyword list"})}),t.jsxs(ge,{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-[200px] space-y-1",children:[t.jsx(V,{htmlFor:"keyword-search",children:"Search"}),t.jsx(re,{id:"keyword-search",value:i,onChange:k=>o(k.target.value),placeholder:"Search keywordsâ¦"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(V,{children:"Filter"}),t.jsxs(ht,{value:l,onValueChange:k=>c(k),children:[t.jsx(ut,{className:"w-48",children:t.jsx(ft,{})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All"}),t.jsx(Pe,{value:"selectable",children:"Selectable"}),t.jsx(Pe,{value:"not-selectable",children:"Not selectable"}),t.jsx(Pe,{value:"unused",children:"Unused"})]})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(V,{htmlFor:"new-keyword",children:"Add keyword"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(re,{id:"new-keyword",value:d,onChange:k=>m(k.target.value),maxLength:40,placeholder:"e.g. painter/decorators",onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),N())}}),t.jsx(q,{onClick:N,disabled:h,children:h?t.jsx(it,{className:"h-4 w-4 animate-spin"}):t.jsx(Xt,{className:"h-4 w-4"})})]})]})]}),n?t.jsx("div",{className:"flex justify-center py-10",children:t.jsx(it,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:[y.length," of ",s.length," keywords"]}),t.jsx("div",{className:"border rounded-md max-h-[600px] overflow-auto",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Keyword"}),t.jsx(ue,{className:"w-32",children:"Listings"}),t.jsx(ue,{className:"w-32",children:"Selectable"})]})}),t.jsx(Wt,{children:y.slice(0,500).map(k=>t.jsxs(Xe,{children:[t.jsx(de,{children:k.term}),t.jsx(de,{children:k.usage}),t.jsx(de,{children:t.jsx(kt,{checked:k.is_selectable,onCheckedChange:$=>v(k,$)})})]},k.id))})]})}),y.length>500&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Showing the first 500 â use search to narrow the list."})]})]})]})]})}const sue=()=>{const{toast:e}=rt(),s=Xs(),[r,n]=u.useState("all"),[a,i]=u.useState(!1),[o,l]=u.useState(null),[c,d]=u.useState(""),[m,h]=u.useState(!1),{data:f=[],isLoading:p}=Lt({queryKey:["admin-artwork",r],queryFn:async()=>{let A=W.from("booking_artwork").select("*").order("uploaded_at",{ascending:!1});r!=="all"&&(A=A.eq("status",r));const{data:T,error:P}=await A;if(P)throw P;return T}}),x=[...new Set(f.map(A=>A.booking_id))],{data:g=[]}=Lt({queryKey:["admin-artwork-bookings",x],queryFn:async()=>
823{if(x.length===0)return[];const{data:A,error:T}=await W.from("bookings").select("id, contact_name, company, email, ad_size_id, payment_status").in("id",x);if(T)throw T;return A},enabled:x.length>0}),b=[...new Set(g.map(A=>A.ad_size_id).filter(Boolean))],{data:w=[]}=Lt({queryKey:["admin-artwork-adsizes",b],queryFn:async()=>{if(b.length===0)return[];const{data:A,error:T}=await W.from("ad_sizes").select("id, name, dimensions").in("id",b);if(T)throw T;return A},enabled:b.length>0}),j=A=>g.find(T=>T.id===A),y=A=>w.find(T=>T.id===A),v=A=>{if(!A)return"";if(!A.includes("http"))return A;const T="/booking-artwork/",P=A.indexOf(T);return P===-1?A:A.substring(P+T.length)},N=async A=>{const T=v(A);if(!T)return null;const{data:P,error:B}=await W.storage.from("booking-artwork").createSignedUrl(T,3600);return B?(e({title:"Error",description:"Could not generate file link.",variant:"destructive"}),null):(P==null?void 0:P.signedUrl)??null},S=async A=>{if(o){h(!0);try{const{data:{user:T}}=await W.auth.getUser(),{error:P}=await W.from("booking_artwork").update({status:A,admin_notes:c||null,reviewed_by:T==null?void 0:T.id,reviewed_at:new Date().toISOString()}).eq("id",o.id);if(P)throw P;e({title:"Success",description:`Artwork ${A}.`}),i(!1),l(null),d(""),s.invalidateQueries({queryKey:["admin-artwork"]})}catch(T){e({title:"Error",description:T.message,variant:"destructive"})}finally{h(!1)}}},k=async(A,T)=>{try{const P=await N(A);if(!P)return;const Y=await(await fetch(P)).blob(),I=window.URL.createObjectURL(Y),C=document.createElement("a");C.href=I,C.download=T,document.body.appendChild(C),C.click(),document.body.removeChild(C),window.URL.revokeObjectURL(I)}catch{const P=await N(A);P&&window.open(P,"_blank")}},$=async A=>{const T=await N(A);T&&window.open(T,"_blank","noopener,noreferrer")},R=A=>{switch(A){case"approved":return t.jsx(we,{className:"bg-green-100 text-green-800",children:"Approved"});case"rejected":return t.jsx(we,{className:"bg-red-100 text-red-800",children:"Rejected"});default:return t.jsx(we,{className:"bg-yellow-100 text-yellow-800",children:"Pending"})}};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold",children:"Artwork Submissions"}),t.jsx("p",{className:"text-muted-foreground",children:"Review and manage uploaded artwork from advertisers."})]}),t.jsxs(ht,{value:r,onValueChange:n,children:[t.jsx(ut,{className:"w-[150px]",children:t.jsx(ft,{})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All"}),t.jsx(Pe,{value:"pending",children:"Pending"}),t.jsx(Pe,{value:"approved",children:"Approved"}),t.jsx(Pe,{value:"rejected",children:"Rejected"})]})]})]}),t.jsx(xe,{children:t.jsx(ge,{className:"p-0",children:p?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx(it,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):f.length===0?t.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[t.jsx(Wi,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}),t.jsx("p",{children:"No artwork submissions found."})]}):t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"User"}),t.jsx(ue,{children:"Company"}),t.jsx(ue,{children:"Ad Size"}),t.jsx(ue,{children:"Payment Ref"}),t.jsx(ue,{children:"Message"}),t.jsx(ue,{children:"Uploaded"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:f.map(A=>{var B;const T=j(A.booking_id),P=T?y(T.ad_size_id):null;return t.jsxs(Xe,{children:[t.jsxs(de,{className:"font-medium",children:[(T==null?void 0:T.contact_name)||"Unknown",t.jsx("br",{}),t.jsx("span",{className:"text-xs text-muted-foreground",children:T==null?void 0:T.email})]}),t.jsx(de,{children:(T==null?void 0:T.company)||"-"}),t.jsx(de,{children:P?`${P.name} (${P.dimensions})`:"-"}),t.jsxs(de,{children:[t.jsxs("span",{className:"font-mono text-xs",children:["REF-",(B=A.booking_id)==null?void 0:B.substring(0,8).toUpperCase()]}),(T==null?void 0:T.payment_status)&&t.jsx(we,{className:`ml-2 text-xs ${T.payment_status==="paid"||T.payment_status==="confirmed"?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:T.payment_status})]}),t.jsx(de,{className:"max-w-[200px]",children:A.notes?t.jsx("p",{className:"text-sm text-muted-foreground",children:A.notes}):t.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No message"})}),t.jsx(de,{className:"text-sm",children:new Date(A.uploaded_at).toLocaleDateString("en-GB")}),t.jsx(de,{children:R(A.status)}),t.jsx(de,{children:t.jsxs("div",{className:"flex gap-1",children:[A.status==="pending"&&t.jsx(t.Fragment,{children:t.jsxs(q,{size:"sm",variant:"outline",className:"text-green-600",onClick:()=>{l(A),d(""),i(!0)},children:[t.jsx(xs,{className:"h-3 w-3 mr-1"}),"Review"]})}),t.jsxs(q,{size:"sm",variant:"outline",onClick:()=>k(A.file_url,A.file_name),children:[t.jsx(ei,{className:"h-3 w-3 mr-1"}),"Download"]}),t.jsx(q,{size:"sm",variant:"ghost",onClick:()=>$(A.file_url),children:t.jsx(tr,{className:"h-3 w-3"})})]})})]},A.id)})})]})})}),t.jsx(bt,{open:a,onOpenChange:i,children:t.jsxs(xt,{children:[t.jsx(jt,{children:t.jsx(wt,{children:"Review Artwork"})}),o&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"bg-muted p-3 rounded-lg",children:[t.jsx("p",{className:"text-sm font-medium",children:o.file_name}),t.jsx("button",{type:"button",onClick:()=>$(o.file_url),className:"text-sm text-primary hover:underline",children:"View / Download File"})]}),o.notes&&t.jsxs("div",{children:[t.jsx(V,{children:"User Notes"}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:o.notes})]}),t.jsxs("div",{children:[t.jsx(V,{children:"Admin Notes (optional)"}),t.jsx(ms,{value:c,onChange:A=>d(A.target.value),placeholder:"Feedback for the user...",rows:3,className:"mt-1"})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(q,{onClick:()=>S("approved"),disabled:m,className:"flex-1 bg-green-600 hover:bg-green-700",children:[m?t.jsx(it,{className:"h-4 w-4 animate-spin mr-2"}):t.jsx(xs,{className:"h-4 w-4 mr-2"}),"Approve"]}),t.jsxs(q,{onClick:()=>S("rejected"),disabled:m,variant:"destructive",className:"flex-1",children:[m?t.jsx(it,{className:"h-4 w-4 animate-spin mr-2"}):t.jsx(Nf,{className:"h-4 w-4 mr-2"}),"Reject"]})]})]})]})})]})};
823function qp(e){return e==null?"â":`£${Number(e).toLocaleString("en-GB",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function Jc(e){if(!e)return"â";try{return new Date(e).toLocaleString("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return"â"}}function rue(e){return e==="active"?"bg-green-100 text-green-800 hover:bg-green-100":e==="lapsed"?"bg-amber-100 text-amber-800 hover:bg-amber-100":"bg-muted text-muted-foreground hover:bg-muted"}const nue={form_fill:ir,quote_created:XF,booking_created:uE,payment_confirmed:ci,terms_accepted:bh,email:ar};function ym({values:e}){const s=e??[];return s.length===0?t.jsx("span",{className:"text-muted-foreground",children:"â"}):t.jsx("div",{className:"flex flex-wrap gap-1",children:s.map((r,n)=>t.jsx("span",{className:"px-2 py-0.5 rounded-full bg-muted text-xs",children:r},`${r}-${n}`))})}function M0({pricing_model:e,duration:s}){const r=e??"â";if(!s)return t.jsx("span",{className:"font-medium capitalize",children:r});const n=s.type==="subscription"?"Subscription":s.type?"Fixed term":null;return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-medium capitalize",children:r}),s.name&&t.jsxs("span",{className:"text-muted-foreground",children:["· ",s.name]}),n&&t.jsx(we,{variant:"secondary",className:"text-[10px]",children:n})]})}function es({label:e,children:s}){return t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-0.5",children:e}),t.jsx("div",{className:"text-sm",children:s})]})}function aue({email:e,open:s,onOpenChange:r}){const[n,a]=u.useState(null),[i,o]=u.useState(!1),[l,c]=u.useState(null),d=u.useCallback(async()=>{if(!e)return;o(!0),c(null);const{data:j,error:y}=await W.rpc("admin_get_client",{p_email:e});y?(console.error(y),c(y.message||"Failed to load client"),a(null)):a(j),o(!1)},[e]);u.useEffect(()=>{s&&e&&d(),s||(a(null),c(null))},[s,e,d]);const m=(n==null?void 0:n.contact)??null,h=(n==null?void 0:n.account)??null,f=(n==null?void 0:n.bookings)??[],p=(n==null?void 0:n.quotes)??[],x=(n==null?void 0:n.quote_requests)??[],g=(n==null?void 0:n.payments)??[],b=(n==null?void 0:n.activity)??[],w=(h==null?void 0:h.effective_advertiser_status)??"none";return t.jsx(i2,{open:s,onOpenChange:r,children:t.jsxs($v,{side:"right",className:"w-full sm:max-w-2xl overflow-y-auto",children:[t.jsxs(o2,{children:[t.jsx(l2,{children:(m==null?void 0:m.display_name)||(m==null?void 0:m.email)||e||"Client dossier"}),t.jsx(dP,{children:"Read-only view of the client's journey."})]}),i&&t.jsxs("div",{className:"space-y-4 mt-6",children:[t.jsx(Is,{className:"h-20 w-full"}),t.jsx(Is,{className:"h-32 w-full"}),t.jsx(Is,{className:"h-32 w-full"})]}),l&&!i&&t.jsxs("div",{className:"mt-6 border border-destructive/40 bg-destructive/5 text-destructive rounded-md p-4 flex items-start gap-3",children:[t.jsx(Hs,{className:"h-5 w-5 shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium",children:"Could not load client"}),t.jsx("div",{className:"text-sm opacity-90",children:l}),t.jsx(q,{variant:"outline",size:"sm",className:"mt-3",onClick:d,children:"Retry"})]})]}),!i&&!l&&n&&t.jsxs("div",{className:"mt-6 space-y-6",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(we,{className:`capitalize ${rue(w)}`,children:w}),(m==null?void 0:m.company)&&t.jsx("span",{className:"text-sm text-muted-foreground",children:m.company})]}),t.jsxs("div",{className:"flex flex-wrap gap-x-6 gap-y-1 text-sm",children:[(m==null?void 0:m.email)&&t.jsx("a",{href:`mailto:${m.email}`,className:"text-primary hover:underline",children:m.email}
823),(m==null?void 0:m.phone)&&t.jsx("a",{href:`tel:${m.phone}`,className:"text-primary hover:underline",children:m.phone})]}),h&&t.jsx(xe,{children:t.jsxs(ge,{className:"grid grid-cols-2 gap-3 pt-4 text-sm",children:[t.jsx(es,{label:"Status setting",children:t.jsx("span",{className:"capitalize",children:h.advertiser_status_setting??"auto"})}),t.jsx(es,{label:"Effective",children:t.jsx("span",{className:"capitalize",children:h.effective_advertiser_status??"none"})}),t.jsx(es,{label:"Agency",children:h.agency_name??"â"}),t.jsx(es,{label:"Agency discount",children:h.agency_discount_percent!=null?`${h.agency_discount_percent}%`:"â"}),t.jsx(es,{label:"Discount type",children:h.discount_type??"â"})]})})]}),t.jsx(fs,{}),t.jsxs("section",{className:"space-y-3",children:[t.jsxs("h3",{className:"font-semibold",children:["Bookings (",f.length,")"]}),f.length===0&&t.jsx("div",{className:"text-sm text-muted-foreground",children:"No bookings yet."}),f.map(j=>{const y=j.confirmed===!0;return t.jsxs(xe,{children:[t.jsxs("div",{className:`px-4 py-2 text-xs font-semibold uppercase tracking-wide flex items-center justify-between rounded-t-lg ${y?"bg-green-100 text-green-800":"bg-amber-100 text-amber-800"}`,children:[t.jsx("span",{children:y?"Payment confirmed":"Awaiting payment"}),j.payment_status&&t.jsx("span",{className:"font-normal capitalize opacity-80",children:j.payment_status})]}),t.jsxs(ge,{className:"grid grid-cols-2 gap-3 pt-4",children:[t.jsx(es,{label:"Plan",children:t.jsx(M0,{pricing_model:j.pricing_model,duration:j.duration})}),t.jsx(es,{label:"Ad size",children:j.ad_size??"â"}),t.jsx("div",{className:"col-span-2",children:t.jsx(es,{label:"Locations",children:t.jsx(ym,{values:j.locations})})}),j.pricing_model==="bogof"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"col-span-2",children:t.jsx(es,{label:"Paid areas",children:t.jsx(ym,{values:j.bogof_paid})})}),t.jsx("div",{className:"col-span-2",children:t.jsx(es,{label:"Free areas",children:t.jsx(ym,{values:j.bogof_free})})})]}),t.jsx(es,{label:"Starting issue",children:j.starting_issue??"â"}),t.jsx(es,{label:"Total",children:qp(j.final_total)}),j.discount_code&&t.jsx(es,{label:"Discount code",children:j.discount_code}),t.jsx(es,{label:"T&Cs",children:j.terms_accepted_at?t.jsxs("span",{className:"text-green-700",children:["Accepted ",Jc(j.terms_accepted_at)]}):t.jsx("span",{className:"text-red-700",children:"Not accepted"})}),t.jsx(es,{label:"Status",children:t.jsx("span",{className:"capitalize",children:j.status??"â"})}),j.invoice_number&&t.jsx(es,{label:"Invoice",children:j.invoice_number})]})]},j.id)})]}),t.jsx(fs,{}),t.jsxs("section",{className:"space-y-3",children:[t.jsxs("h3",{className:"font-semibold",children:["Quotes (",p.length,") & form-fills (",x.length,")"]}),p.length===0&&x.length===0&&t.jsx("div",{className:"text-sm text-muted-foreground",children:"No quotes."}),p.map(j=>t.jsx(xe,{className:"bg-muted/40",children:t.jsxs(ge,{className:"grid grid-cols-2 gap-3 pt-4 text-sm",children:[t.jsxs("div",{className:"col-span-2 text-[11px] uppercase tracking-wide text-muted-foreground",children:["Quote · ",Jc(j.created_at)]}),t.jsx(es,{label:"Plan",children:t.jsx(M0,{pricing_model:j.pricing_model,duration:j.duration})}),t.jsx(es,{label:"Ad size",children:j.ad_size??"â"}),t.jsx("div",{className:"col-span-2",children:t.jsx(es,{label:"Locations",children:t.jsx(ym,{values:j.locations})})}),t.jsx(es,{label:"Starting issue",children:j.starting_issue??"â"}),t.jsx(es,{label:"Total",children:qp(j.final_total)}),j.discount_code&&t.jsx(es,{label:"Discount code",children:j.discount_code}),j.terms_viewed_at&&t.jsx(es,{label:"T&Cs viewed",children:Jc(j.terms_viewed_at)}),t.jsx(es,{label:"Status",children:t.jsx("span",{className:"capitalize",children:j.status??"â"})})]})},`q-${j.id}`)),x.map(j=>t.jsx(xe,{className:"bg-muted/40",children:t.jsxs(ge,{className:"grid grid-cols-2 gap-3 pt-4 text-sm",children:[t.jsxs("div",{className:"col-span-2 text-[11px] uppercase tracking-wide text-muted-foreground",children:["Form fill · ",Jc(j.created_at)]}),t.jsx(es,{label:"Plan",children:t.jsx(M0,{pricing_model:j.pricing_model,duration:j.duration})}),t.jsx(es,{label:"Ad size",children:j.ad_size??"â"}),t.jsx("div",{className:"col-span-2",children:t.jsx(es,{label:"Locations",children:t.jsx(ym,{values:j.locations})})}),t.jsx(es,{label:"Starting issue",children:j.starting_issue??"â"}),t.jsx(es,{label:"Total",children:qp(j.final_total)}),t.jsx(es,{label:"Status",children:t.jsx("span",{className:"capitalize",children:j.status??"â"})})]})},`r-${j.id}`))]}),t.jsx(fs,{}),t.jsxs("section",{className:"space-y-3",children:[t.jsxs("h3",{className:"font-semibold",children:["Payments (",g.length,")"]}),g.length===0?t.jsx("div",{className:"text-sm text-muted-foreground",children:"No payments."}):t.jsx("div",{className:"border rounded-md overflow-hidden",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/50 text-xs uppercase tracking-wide text-muted-foreground",children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left px-3 py-2",children:"Source"}),t.jsx("th",{className:"text-left px-3 py-2",children:"Kind"}),t.jsx("th",{className:"text-left px-3 py-2",children:"Status"}),t.jsx("th",{className:"text-right px-3 py-2",children:"Amount"}),t.jsx("th",{className:"text-left px-3 py-2",children:"Date"})]})}),t.jsx("tbody",{children:g.map((j,y)=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2 capitalize",children:j.source??"â"}),t.jsx("td",{className:"px-3 py-2 capitalize",children:j.kind??"â"}),t.jsx("td",{className:"px-3 py-2 capitalize",children:j.status??"â"}),t.jsx("td",{className:"px-3 py-2 text-right font-medium",children:qp(j.amount)}),t.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:Jc(j.date)})]},y))})]})})]}),t.jsx(fs,{}),t.jsxs("section",{className:"space-y-3",children:[t.jsxs("h3",{className:"font-semibold",children:["Activity (",b.length,")"]}),b.length===0?t.jsx("div",{className:"text-sm text-muted-foreground",children:"No activity."}):t.jsx("ol",{className:"space-y-2",children:[...b].reverse().map((j,y)=>{const v=nue[j.type]??ir;return t.jsxs("li",{className:"flex items-start gap-3 border rounded-md px-3 py-2",children:[t.jsx(v,{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"text-sm flex items-center gap-2 flex-wrap",children:[t.jsx("span",{children:j.label}),j.type==="email"&&j.status&&t.jsx(we,{variant:"outline",className:"text-[10px] capitalize",children:j.status})]}),t.jsx("div",{className:"text-xs text-muted-foreground",children:Jc(j.at)})]})]},y)})})]})]})]})})}const _C={fixed:"Fixed",bogof:"BOGOF",leafleting:"Leafleting",subscription:"Subscription"},iue=["active","lapsed","none"];
823function oue(e){return`£${Number(e??0).toLocaleString("en-GB",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function lue(e){if(!e)return"â";try{return new Date(e).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})}catch{return"â"}}function cue(e){return e==="active"?"bg-green-100 text-green-800":e==="lapsed"?"bg-amber-100 text-amber-800":"bg-muted text-muted-foreground"}function Hp({label:e,options:s,selected:r,onChange:n,formatOption:a}){const i=o=>{n(r.includes(o)?r.filter(l=>l!==o):[...r,o])};return t.jsxs(Cn,{children:[t.jsx(kn,{asChild:!0,children:t.jsxs(q,{variant:"outline",size:"sm",className:"h-9 justify-between gap-2 min-w-[140px]",children:[t.jsxs("span",{className:"truncate",children:[e,r.length>0&&t.jsxs("span",{className:"ml-1 text-muted-foreground",children:["(",r.length,")"]})]}),t.jsx(Ma,{className:"h-3 w-3 opacity-60"})]})}),t.jsx(en,{align:"start",className:"w-64 p-0",children:t.jsxs(_c,{children:[t.jsx(xu,{placeholder:`Filter ${e.toLowerCase()}â¦`}),t.jsxs(Sc,{children:[t.jsx(Cc,{children:"No options"}),t.jsx(kc,{children:s.map(o=>{const l=r.includes(o);return t.jsx(ii,{onSelect:()=>i(o),children:t.jsxs("div",{className:"flex items-center gap-2 w-full",children:[t.jsx("div",{className:`h-4 w-4 rounded border flex items-center justify-center ${l?"bg-primary border-primary text-primary-foreground":"border-input"}`,children:l&&t.jsx(Bs,{className:"h-3 w-3"})}),t.jsx("span",{className:"flex-1 truncate",children:a?a(o):o})]})},o)})})]})]})})]})}function due({accountByEmail:e,effectiveAdvertiserStatuses:s,onOpenCreateUser:r,onUpdateRole:n,onUpdateAdvertiserStatus:a,onEdit:i,onSetPassword:o,onDelete:l,refreshSignal:c,onAfterMutation:d}){const[m,h]=u.useState([]),[f,p]=u.useState(!0),{toast:x}=rt(),[g,b]=u.useState(""),[w,j]=u.useState([]),[y,v]=u.useState([]),[N,S]=u.useState([]),[k,$]=u.useState([]),[R,A]=u.useState(!1),[T,P]=u.useState(!1),[B,Y]=u.useState(!1),[I,C]=u.useState(null),[L,D]=u.useState(!1),_=F=>{C(F),D(!0)},H=async()=>{p(!0);const{data:F,error:ee}=await W.rpc("admin_list_clients");ee?(console.error(ee),x({title:"Error",description:"Failed to load clients",variant:"destructive"}),h([])):h(F??[]),p(!1)};u.useEffect(()=>{H()},[c]);const O=u.useMemo(()=>{const F=new Set;return m.forEach(ee=>(ee.ad_sizes_used??[]).forEach(se=>se&&F.add(se))),[...F].sort()},[m]),U=u.useMemo(()=>{const F=new Set;return m.forEach(ee=>(ee.locations_used??[]).forEach(se=>se&&F.add(se))),[...F].sort()},[m]),G=u.useMemo(()=>{const F=new Set;return m.forEach(ee=>(ee.plan_types_used??[]).forEach(se=>se&&F.add(se))),[...F].filter(ee=>_C[ee]).sort()},[m]),E=u.useMemo(()=>{const F=g.trim().toLowerCase();return m.filter(ee=>!(F&&!`${ee.display_name??""} ${ee.company??""} ${ee.email??""}`.toLowerCase().includes(F)||w.length&&!w.includes(ee.effective_advertiser_status??"none")||y.length&&!(ee.ad_sizes_used??[]).some(se=>y.includes(se))||N.length&&!(ee.locations_used??[]).some(se=>N.includes(se))||k.length&&!(ee.plan_types_used??[]).some(se=>k.includes(se))||R&&!ee.has_confirmed_payment||T&&!ee.has_accepted_terms||B&&!ee.has_used_discount))},[m,g,w,y,N,k,R,T,B]),z=()=>{b(""),j([]),v([]),S([]),$([]),A(!1),P(!1),Y(!1)},Z=!!g||w.length>0||y.length>0||N.length>0||k.length>0||R||T||B,M=async F=>{await F(),d(),await H()};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Clients"}),t.jsx("p",{className:"text-muted-foreground",children:"Every client who has interacted with the site â accounts, quotes and cost-calculator enquiries â in one directory."})]}),t.jsxs(q,{onClick:r,children:[t.jsx(Aw,{className:"h-4 w-4 mr-2"})," Create User"]})]}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{children:"Client Directory"})}),t.jsxs(ge,{children:[t.jsx("div",{className:"sticky top-0 z-10 -mx-6 px-6 py-3 bg-background border-b mb-4",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(re,{placeholder:"Search name, company or emailâ¦",value:g,onChange:F=>b(F.target.value),className:"h-9 max-w-xs"}),t.jsx(Hp,{label:"Status",options:iue,selected:w,onChange:j,formatOption:F=>F.charAt(0).toUpperCase()+F.slice(1)}),t.jsx(Hp,{label:"Advert Size",options:O,selected:y,onChange:v}),t.jsx(Hp,{label:"Location",options:U,selected:N,onChange:S}),t.jsx(Hp,{label:"Plan Type",options:G,selected:k,onChange:$,formatOption:F=>_C[F]??F}),t.jsxs("label",{className:"flex items-center gap-2 text-sm ml-2",children:[t.jsx(kt,{checked:R,onCheckedChange:A}),"Confirmed Payment"]}),t.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[t.jsx(kt,{checked:T,onCheckedChange:P}),"Accepted T&Cs"]}),t.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[t.jsx(kt,{checked:B,onCheckedChange:Y}),"Used Discount"]}),Z&&t.jsxs(q,{variant:"ghost",size:"sm",onClick:z,className:"h-9",children:[t.jsx(Es,{className:"h-3 w-3 mr-1"})," Clear"]}),t.jsxs("div",{className:"ml-auto text-sm text-muted-foreground",children:["Showing ",E.length," of ",m.length," clients"]})]})}),f?t.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[t.jsx(it,{className:"h-4 w-4 animate-spin mr-2"})," Loading clientsâ¦"]}):E.length===0?t.jsx("div",{className:"text-center py-12 text-muted-foreground",children:m.length===0?"N
823o clients found.":"No clients match the current filters."}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Name"}),t.jsx(ue,{children:"Company"}),t.jsx(ue,{children:"Email"}),t.jsx(ue,{children:"Advertiser Status"}),t.jsx(ue,{className:"text-right",children:"Quotes"}),t.jsx(ue,{className:"text-right",children:"Bookings"}),t.jsx(ue,{className:"text-right",children:"Confirmed Spend"}),t.jsx(ue,{children:"Last Activity"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:E.map(F=>{const ee=e.get(F.email),se=F.has_account&&!!ee,le=ee&&s[ee.user_id]||F.effective_advertiser_status||"none",X=ee!=null&&ee.user_roles&&ee.user_roles.length>0?ee.user_roles[0].role:"user";return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium",children:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("button",{onClick:()=>_(F.email),className:"text-left text-primary hover:underline",children:F.display_name||"â"}),!se&&t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"No account"})]})}),t.jsx(de,{children:F.company||"â"}),t.jsx(de,{className:"text-sm",children:F.email}),t.jsx(de,{children:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs w-fit capitalize ${cue(le)}`,children:le}),se&&ee&&t.jsxs(ht,{value:ee.advertiser_status||"auto",onValueChange:ye=>M(()=>a(ee,ye)),children:[t.jsx(ut,{className:"w-[110px] h-7 text-xs",children:t.jsx(ft,{})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"auto",children:"Auto"}),t.jsx(Pe,{value:"active",children:"Active"}),t.jsx(Pe,{value:"lapsed",children:"Lapsed"}),t.jsx(Pe,{value:"none",children:"None"})]})]})]})}),t.jsxs(de,{className:"text-right",children:[t.jsx("div",{className:"font-medium",children:(F.quote_requests_count??0)+(F.quotes_count??0)}),(F.quote_requests_count??0)>0&&t.jsxs("div",{className:"text-xs text-muted-foreground",children:[F.quote_requests_count," request",F.quote_requests_count===1?"":"s"]})]}),t.jsxs(de,{className:"text-right",children:[t.jsx("div",{className:"font-medium",children:F.bookings_count??0}),(F.paid_bookings_count??0)>0&&t.jsxs("div",{className:"text-xs text-muted-foreground",children:[F.paid_bookings_count," paid"]})]}),t.jsx(de,{className:"text-right font-medium",children:oue(F.total_confirmed_spend)}),t.jsx(de,{className:"text-sm text-muted-foreground",children:lue(F.last_activity_at)}),t.jsx(de,{children:se&&ee?t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsxs(ht,{value:X,onValueChange:ye=>M(()=>n(ee,ye)),children:[t.jsx(ut,{className:"w-[90px] h-8 text-xs",children:t.jsx(ft,{})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"user",children:"User"}),t.jsx(Pe,{value:"admin",children:"Admin"})]})]}),t.jsx(q,{variant:"outline",size:"sm",onClick:()=>i(ee),children:t.jsx(Jr,{className:"h-3 w-3"})}),t.jsx(q,{variant:"outline",size:"sm",onClick:()=>o(ee),children:t.jsx(tL,{className:"h-3 w-3"})}),t.jsxs(ia,{children:[t.jsx(Li,{asChild:!0,children:t.jsx(q,{variant:"destructive",size:"sm",children:t.jsx(cs,{className:"h-3 w-3"})})}),t.jsxs(Fn,{children:[t.jsxs(Ln,{children:[t.jsx(zn,{children:"Delete User Account"}),t.jsxs(Un,{children:["This will permanently delete the account for"," ",t.jsx("strong",{children:ee.display_name||F.email}),". All their bookings, quotes, and data will be removed."]})]}),t.jsxs(Bn,{children:[t.jsx(oa,{children:"Cancel"}),t.jsx(Vn,{onClick:()=>M(()=>l(ee)),children:"Delete User"})]})]})]})]}):t.jsx("span",{className:"text-xs text-muted-foreground",children:"â"})})]},F.email)})})]})})]})]}),t.jsx(aue,{email:I,open:L,onOpenChange:D})]})}const uue=()=>{const[e,s]=u.useState(null),[r,n]=u.useState(!0),[a,i]=u.useState(!1),[o,l]=u.useState([]),[c,d]=u.useState(0),[m,h]=u.useState([]),[f,p]=u.useState({}),[x,g]=u.useState({}),[b,w]=u.useState([]),[j,y]=u.useState("overview");u.useState(!1);const[v,N]=u.useState(!1),[S,k]=u.useState(null),[$,R]=u.useState(null),[A,T]=u.useState(!1),[P,B]=u.useState(""),[Y,I]=u.useState(!1),C=tie(P,300),[L,D]=u.useState(0),_=25,[H,O]=u.useState(!1),[U,G]=u.useState(null),[E,z]=u.useState(""),[Z,M]=u.useState(!1),[F,ee]=u.useState(!1);u.useState("");const[se,le]=u.useState(0),X=()=>le(He=>He+1),ye=u.useMemo(()=>{const He=new Map;return m.forEach(Te=>{const De=(f[Te.user_id]||"").trim().toLowerCase();De&&He.set(De,Te)}),He},[m,f]),[Ce,ke]=u.useState(!1),[fe,Ee]=u.useState({email:"",password:"",displayName:""}),[K,te]=u.useState(!1);u.useState({title:"",content:"",excerpt:"",category:"",area:"",featured_image_url:"",author_name:""});const Q=ds(),{toast:ae}=rt();u.useEffect(()=>{(async()=>{const{data:{session:Te}}=await W.auth.getSession();if(!Te){Q("/auth");return}s(Te.user);const{data:De}=await W.from("user_roles").select("role").eq("user_id",Te.user.id).eq("role","admin").single();if(!De){ae({title:"Access Denied",description:"You don't have admin privileges to access this page.",variant:"destructive"}),Q("/");return}i(!0),n(!1)})()},[Q,ae]);const{data:me=[],isLoading:pe}=Lt({queryKey:["business-suggestions",C],queryFn:async()=>
823{if(!C||C.length<2)return[];const{data:He}=await W.from("businesses").select(` 824 id, 825 name, 826 city, 827 postcode, 828 business_categories (name) 829 `).or(`name.ilike.%${C}%,email.ilike.%${C}%,postcode.ilike.%${C}%,city.ilike.%${C}%`).order("name").limit(20);return He||[]},enabled:a&&C.length>=2}),be=async()=>{const{count:He}=await W.from("businesses").select("*",{count:"exact",head:!0});d(He||0);let Te=W.from("businesses").select(` 830 *, 831 business_categories ( 832 name 833 ) 834 `).order("created_at",{ascending:!1}).range(L*_,(L+1)*_-1);P.trim()&&(Te=Te.or(`name.ilike.%${P}%,email.ilike.%${P}%,postcode.ilike.%${P}%,city.ilike.%${P}%`));const{data:De}=await Te;De&&l(De)},ce=async()=>{try{const{data:He,error:Te}=await W.from("profiles").select("*").order("created_at",{ascending:!1});if(Te)throw Te;const{data:De,error:Le}=await W.from("user_roles").select("user_id, role, created_at");Le&&console.error("Error loading user roles:",Le);const We=(He||[]).map(Ke=>({...Ke,user_roles:(De||[]).filter(st=>st.user_id===Ke.user_id)}));h(We);try{const Ke=(He||[]).map(async tt=>{const{data:Jt,error:us}=await W.rpc("get_effective_advertiser_status",{_user_id:tt.user_id});return us?[tt.user_id,"none"]:[tt.user_id,Jt||"none"]}),st=await Promise.all(Ke),dt={};st.forEach(([tt,Jt])=>{dt[tt]=Jt}),g(dt)}catch(Ke){console.error("Failed to fetch advertiser statuses:",Ke)}try{const{data:{session:Ke}}=await W.auth.getSession();if(Ke){const{data:st,error:dt}=await W.functions.invoke("admin-manage-user",{body:{action:"list_users_with_email",user_id:"all"}});!dt&&(st!=null&&st.emailMap)&&p(st.emailMap)}}catch(Ke){console.error("Failed to fetch user emails:",Ke)}}catch(He){console.error("Error loading users:",He),ae({title:"Error",description:"Failed to load users",variant:"destructive"})}},ie=async(He,Te,De)=>{ee(!0);try{const{data:Le,error:We}=await W.functions.invoke("admin-manage-user",{body:{action:He,user_id:Te,...De}});if(We)throw We;if(Le!=null&&Le.error)throw new Error(Le.error);return Le}finally{ee(!1)}},je=async He=>{try{await ie("delete_user",He.user_id),ae({title:"Success",description:"User deleted successfully."}),ce(),X()}catch(Te){ae({title:"Error",description:Te.message,variant:"destructive"})}},Re=async()=>{if(!(!U||!E))try{const He=f[U.user_id];await ie("set_password",U.user_id,{password:E,send_email:Z,user_email:He});const Te=Z&&He?` Email sent to ${He}.`:"";ae({title:"Success",description:`Password updated successfully.${Te}`}),O(!1),z(""),M(!1),G(null)}catch(He){ae({title:"Error",description:He.message,variant:"destructive"})}},Ae=async(He,Te)=>{try{await ie("update_role",He.user_id,{role:Te}),ae({title:"Success",description:`Role updated to ${Te}.`}),ce(),X()}catch(De){ae({title:"Error",description:De.message,variant:"destructive"})}},Ue=async(He,Te)=>{try{const{error:De}=await W.from("profiles").update({advertiser_status:Te}).eq("user_id",He.user_id);if(De)throw De;ae({title:"Success",description:`Advertiser status set to ${Te}.`}),ce(),X()}catch(De){ae({title:"Error",description:De.message,variant:"destructive"})}},Ve=async()=>{if(!(!fe.email||!fe.password)){ee(!0);try{const{data:He,error:Te}=await W.functions.invoke("admin-manage-user",{body:{action:"create_user",user_id:"new",email:fe.email,password:fe.password,display_name:fe.displayName||void 0,send_email:K}});if(Te)throw Te;if(He!=null&&He.error)throw new Error(He.error);const De=K?` Credentials sent to ${fe.email}.`:"";ae({title:"Success",description:`User created successfully.${De}`}),ke(!1),Ee({email:"",password:"",displayName:""}),te(!1),ce(),X()}catch(He){ae({title:"Error",description:He.message,variant:"destructive"})}finally{ee(!1)}}},lt=async()=>{const{data:He}=await W.from("stories").select("*").order("created_at",{ascending:!1});He&&w(He)};if(u.useEffect(()=>{a&&(be(),ce(),X(),lt())},[a]),u.useEffect(()=>{a&&be()},[L]),r)return t.jsx("div",{className:"min-h-screen flex items-center justify-center",children:t.jsx("div",{children:"Loading..."})});if(!a)return null;const J=()=>{switch(j){case"overview":return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Dashboard Overview"}),t.jsx("p",{className:"text-muted-foreground",children:"Welcome to the admin dashboard. Manage all aspects of your platform from here."})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[t.jsx(xe,{children:t.jsx(ge,{className:"p-6",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx(Xr,{className:"h-8 w-8 text-primary"}),t.jsxs("div",{className:"ml-4",children:[t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Total Businesses"}),t.jsx("p",{className:"text-2xl font-bold",children:o.length})]})]})})}),t.jsx(xe,{children:t.jsx(ge,{className:"p-6",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx(ua,{className:"h-8 w-8 text-primary"}),t.jsxs("div",{className:"ml-4",children:[t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Total Users"}),t.jsx("p",{className:"text-2xl font-bold",children:m.length})]})]})})}),t.jsx(xe,{children:t.jsx(ge,{className:"p-6",children:t.jsxs("div",{className:"flex items-center",children:[t.jsx(ir,{className:"h-8 w-8 text-primary"}),t.jsxs("div",{className:"ml-4",children:[t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Total Stories"}),t.jsx("p",{className:"text-2xl font-bold",children:b.length})]})]})})})]})]});case"businesses":const He=Math.ceil(c/_);return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Business Management"}),t.jsxs("p",{className:"text-muted-foreground",children:["Manage business listings. Total: ",c.toLocaleStr
834ing()," businesses"]})]}),t.jsxs("div",{className:"flex gap-4 flex-wrap items-center",children:[t.jsxs(Cn,{open:Y,onOpenChange:I,children:[t.jsx(kn,{asChild:!0,children:t.jsxs("div",{className:"relative flex-1 max-w-md",children:[t.jsx(Ur,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none z-10"}),t.jsx(re,{placeholder:"Type to search businesses...",value:P,onChange:Te=>{B(Te.target.value),D(0),Te.target.value.length>=2&&I(!0)},onFocus:()=>{P.length>=2&&I(!0)},className:"pl-10 pr-10"}),P&&t.jsx(q,{variant:"ghost",size:"icon",className:"absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7",onClick:Te=>{Te.stopPropagation(),B(""),D(0),I(!1),be()},children:t.jsx(Es,{className:"h-4 w-4"})})]})}),t.jsx(en,{className:"w-[400px] p-0",align:"start",onOpenAutoFocus:Te=>Te.preventDefault(),children:t.jsx(_c,{shouldFilter:!1,children:t.jsx(Sc,{children:pe?t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(it,{className:"h-4 w-4 animate-spin text-muted-foreground"}),t.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Searching..."})]}):me.length===0?t.jsx(Cc,{children:C.length<2?"Type at least 2 characters to search...":"No businesses found."}):t.jsx(kc,{heading:`${me.length} result${me.length===1?"":"s"}`,children:me.map(Te=>{var De;return t.jsxs(ii,{value:Te.name,onSelect:()=>{B(Te.name),I(!1),D(0),be()},className:"flex items-center justify-between py-3 cursor-pointer",children:[t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"font-medium",children:Te.name}),t.jsx("span",{className:"text-xs text-muted-foreground",children:[Te.city,Te.postcode].filter(Boolean).join(" ⢠")||"No location"})]}),((De=Te.business_categories)==null?void 0:De.name)&&t.jsx(we,{variant:"secondary",className:"text-xs ml-2",children:Te.business_categories.name})]},Te.id)})})})})})]}),t.jsxs(q,{onClick:be,children:[t.jsx(Ur,{className:"h-4 w-4 mr-2"})," Search"]}),t.jsxs(q,{onClick:()=>{R(null),T(!0)},children:[t.jsx(Xt,{className:"h-4 w-4 mr-2"})," Add Business"]})]}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{children:"Business Listings"})}),t.jsx(ge,{children:o.length===0?t.jsx("div",{className:"text-center py-8 text-muted-foreground",children:t.jsx("p",{children:"No businesses found."})}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(qt,{children:[t.jsx(Ht,{children:t.jsxs(Xe,{children:[t.jsx(ue,{children:"Business Name"}),t.jsx(ue,{children:"Category"}),t.jsx(ue,{children:"Location"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Actions"})]})}),t.jsx(Wt,{children:o.map(Te=>{var De;return t.jsxs(Xe,{children:[t.jsx(de,{className:"font-medium cursor-pointer hover:text-primary",onClick:()=>{R(Te),T(!0)},children:Te.name}),t.jsx(de,{children:((De=Te.business_categories)==null?void 0:De.name)||"-"}),t.jsx(de,{children:Te.city||Te.postcode||"-"}),t.jsx(de,{children:t.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${Te.is_active?"bg-green-100 text-green-800":"bg-red-100 text-red-800"}`,children:Te.is_active?"Active":"Inactive"})}),t.jsx(de,{children:t.jsxs(q,{size:"sm",variant:"outline",onClick:()=>{R(Te),T(!0)},children:[t.jsx(Jr,{className:"h-4 w-4 mr-1"})," Edit"]})})]},Te.id)})})]})}),t.jsxs("div",{className:"flex items-center justify-between mt-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",L+1," of ",He||1]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(q,{variant:"outline",size:"sm",disabled:L===0,onClick:()=>D(Te=>Te-1),children:[t.jsx(su,{className:"h-4 w-4"})," Previous"]}),t.jsxs(q,{variant:"outline",size:"sm",disabled:L>=He-1,onClick:()=>D(Te=>Te+1),children:["Next ",t.jsx(Ac,{className:"h-4 w-4"})]})]})]})]})})]}),t.jsx(bt,{open:A,onOpenChange:T,children:t.jsx(xt,{className:"max-w-3xl max-h-[90vh]",children:t.jsx(Lde,{business:$,onClose:()=>T(!1),onSave:()=>{T(!1),be()}})})})]});case"claim-requests":return t.jsx(zde,{});case"users":return t.jsxs("div",{className:"space-y-6",children:[t.jsx(due,{accountByEmail:ye,effectiveAdvertiserStatuses:x,onOpenCreateUser:()=>{Ee({email:"",password:"",displayName:""}),te(!1),ke(!0)},onUpdateRole:Ae,onUpdateAdvertiserStatus:Ue,onEdit:Te=>{k(Te),N(!0)},onSetPassword:Te=>{G(Te),z(""),M(!1),O(!0)},onDelete:je,refreshSignal:se,onAfterMutation:X}),t.jsx(bt,{open:H,onOpenChange:O,children:t.jsxs(xt,{className:"max-w-sm",children:[t.jsxs(jt,{children:[t.jsx(wt,{children:"Set User Password"}),t.jsxs(ys,{children:["Set a new password for ",(U==null?void 0:U.display_name)||f[U==null?void 0:U.user_id]||"this user","."]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"new-password",children:"New Password"}),t.jsx(re,{id:"new-password",type:"password",value:E,onChange:Te=>z(Te.target.value),placeholder:"Minimum 6 characters",minLength:6})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(Kt,{id:"send-password-email",checked:Z,onCheckedChange:Te=>M(Te===!0)}),t.jsx(V,{htmlFor:"send-password-email",className:"text-sm font-normal cursor-pointer",children:"Send password to user via email"})]}),Z&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["An email will be sent to ",f[U==null?void 0:U.user_id]||"the user"," with their new password."]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(q,{onClick:Re,disabled:E.length<6||F,className:"flex-1",children:[F?t.jsx(it,{className:"h-4 w-4 animate-spin mr-2"}):null,"Set Password"]}),t.jsx(q,{variant:"outline",onClick:()=>O(!1),children:"Cancel"})]})]})]})}),t.jsx(bt,{open:Ce,onOpenChange:ke,children:t.jsxs(xt,{className:"max-w-sm",children:[t.jsxs(jt,{children:[t.jsx(wt,{children:"Create New User"}),t.jsx(ys,{children:"Create a new user account. The user will be able to log in immediately."})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"create-email",children:"Email"}),t.jsx(re,{id:"create-email",type:"email",value:fe.email,onChange:Te=>Ee(De=>({...De,email:Te.target.value})),placeholder:"[email protected]"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"create-display-name",children:"Display Name (optional)"}),t.jsx(re,{id:"create-display-name",value:fe.displayName,onChange:Te=>Ee(De=>({...De,displayName:Te.target.value})),placeholder:"John Smith"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"create-password",children:"Password"}),t.jsx(re,{id:"create-password",type:"password",value:fe.password,onChange:Te=>Ee(De=>({...De,password:Te.target.value})),placeholder:"Minimum 6 characters",minLength:6})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(Kt,{id:"send-create-email",checked:K,onCheckedChange:Te=>te(Te===!0)}),t.jsx(V,{htmlFor:"send-create-email",className:"text-sm font-normal cursor-pointer",children:"Send credentials to user via email"})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(q,{onClick:Ve,disabled:!fe.email||fe.password.length<6||F,className:"flex-1",children:[F?t.jsx(it,{className:"h-4 w-4 animate-spin mr-2"}):t.jsx(Aw,{className:"h-4 w-4 mr-2"}),"Create User"]}),t.jsx(q,{variant:"outline",onClick:()=>ke(!1),children:"Cancel"})]})]})]})})]});case"stories":return t.jsx($de,{});case"calculator":return t.jsx(Tce,{});case"alerts":return t.jsx(Dce,{});case"ad-preview-images":return t.jsx(Mce,{});case"magazine-editions":return t.jsx(Ice,{});case"featured-advertisers":return t.jsx(Vde,{});case"competitions":return t.jsx(zce,{});case"csv-import":return t.jsx(dde,{});case"events":return t.jsx(mde,{});case"email-templates":return t.jsx(Wde,{});case"artwork":return t.jsx(sue,{});case"accreditations":return t.jsx(Jde,{});case"keywords":return t.jsx(tue,{});case"media-library":return t.jsx(Qde,{});default:return t.jsx("div",{children:"Section not found"})}},Ne=async(He,Te)=>{const{data:De,error:Le}=await W.from("profiles").update(Te).eq("user_id",He).select();Le?(console.error("Database error:",Le),ae({title:"Error",description:Le.message,variant:"destructive"})):(ae({title:"Success",description:"User agency information updated successfully."}),N(!1),k(null),ce(),X())},gt=He=>{if(He.preventDefault(),!S)return;const Te=new FormData(He.target),De=Te.get("discount_type"),Le={discount_type:De,is_agency_member:De==="agency",agency_discount_percent:parseFloat(Te.get("agency_discount_percent"))||0,agency_name:Te.get("agency_name")||"",company:Te.get("company")||""};Ne(S.user_id,Le)};return t.jsx(SN,{children:t.jsxs("div",{className:"min-h-screen flex w-full",children:[t.jsx(Pde,{activeSection:j,onSectionChange:y}),t.jsxs("div",{className:"flex-1 flex flex-col",children:[t.jsx("header",{className:"border-b bg-background px-6 py-4",children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(kN,{}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold",children:"Admin Dashboard"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage your platform with ease"})]})]})}),t.jsx("main",{className:"flex-1 p-6 bg-muted/10",children:J()})]}),t.jsx(bt,{open:v,onOpenChange:N,children:t.jsxs(xt,{className:"max-w-md",children:[t.jsx(jt,{children:t.jsx(wt,{children:"Edit User Agency Information"})}),t.jsxs("form",{onSubmit:gt,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs(V,{children:["User: ",(S==null?void 0:S.display_name)||"Unknown"]}),t.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:S==null?void 0:S.user_id})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"discount_type",children:"User Status"}),t.jsxs(ht,{name:"discount_type",defaultValue:(S==null?void 0:S.discount_type)||"none",children:[t.jsx(ut,{children:t.jsx(ft,{})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"none",children:"Regular User"}),t.jsx(Pe,{value:"agency",children:"Agency Member"}),t.jsx(Pe,{value:"charity",children:"Charity"}),t.jsx(Pe,{value:"discretionary",children:"Discretionary"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"company",children:"Company Name"}),t.jsx(re,{name:"company",defaultValue:(S==null?void 0:S.company)||"",placeholder:"Enter company name"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"agency_name",children:"Agency Name"}),t.jsx(re,{name:"agency_name",defaultValue:(S==null?void 0:S.agency_name)||"",placeholder:"Enter agency name (optional)"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"agency_discount_percent",children:"Discount Percentage"}),t.jsx(re,{name:"agency_discount_percent",type:"number",min:"0",max:"100",step:"0.01",defaultValue:(S==null?void 0:S.agency_discount_percent)||0,placeholder:"0"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter percentage (0-100). Only applies when user has a discount status."})]}),t.jsxs("div",{className:"flex gap-2 pt-4",children:[t.jsx(q,{type:"submit",className:"flex-1",children:"Update User"}),t.jsx(q,{type:"button",variant:"outline",onClick:()=>{N(!1),k(null)},children:"Cancel"})]})]})]})})]})})};var mue=u.forwardRef(({as:e="div",...s},r)=>t.jsx(e,{...s,ref:r}));const hue="https://challenges.cloudflare.com/turnstile/v0/api.js",fue="cf-turnstile-script",C7="onloadTurnstileCallback",k7=e=>!!document.getElementById(e),pue=({render:e="explicit",onLoadCallbackName:s=C7,scriptOptions:{nonce:r="",defer:n=!0,async:a=!0,id:i="",appendTo:o,onError:l,crossOrigin:c=""}={}})=>{let d=i||"cf-turnstile-script";if(k7(d))return;let m=document.createElement("script");m.id=d,m.src=`${hue}?onload=${s}&render=${e}`,!document.querySelector(`script[src="${m.src}"]`)&&(m.defer=!!n,m.async=!!a,r&&(m.nonce=r),c&&(m.crossOrigin=c),l&&(m.onerror=l,delete window[s]),(o==="body"?document.body:document.getElementsByTagName("head")[0]).appendChild(m))},Cl={normal:{width:300,height:65},compact:{width:150,height:140},invisible:{width:0,height:0,overflow:"hidden"},flexible:{minWidth:300,width:"100%",height:65},interactionOnly:{width:"fit-content",height:"auto",display:"flex"}};function xue(e){if(e!=="invisible"&&e!=="interactionOnly")return e}function gue(e=fue){let[s,r]=u.useState(!1);return u.useEffect(()=>{let n=()=>{k7(e)&&r(!0)},a=new MutationObserver(n);return a.observe(document,{childList:!0,subtree:!0}),n(),()=>{a.disconnect()}},[e]),s}let Jm="unloaded",$7;const vue=new Promise((e,s)=>{$7={resolve:e,reject:s},Jm==="ready"&&e(void 0)}),SC=(e=C7)=>(Jm==="unloaded"&&(Jm="loading",window[e]=()=>{$7.resolve(),Jm="ready",delete window[e]}),vue),E7=u.forwardRef((e,s)=>{let{scriptOptions:r,options:n={},siteKey:a,onWidgetLoad:i,onSuccess:o,onExpire:l,onError:c,onBeforeInteractive:d,onAfterInteractive:m,onUnsupported:h,onTimeout:f,onLoadScript:p,id:x,style:g,as:b="div",injectScript:w=!0,rerenderOnCallbackChange:j=!1,...y}=e,v=n.size,N=u.useCallback(()=>v===void 0?{}:n.execution==="execute"?Cl.invisible:n.appearance==="interaction-only"?Cl.interactionOnly:Cl[v],[n.execution,v,n.appearance]),[S,k]=u.useState(N()),$=u.useRef(null),[R,A]=u.useState(!1),T=u.useRef(void 0),P=u.useRef(!1),B=x||"cf-turnstile",Y=u.useRef({onSuccess:o,onError:c,onExpire:l,onBeforeInteractive:d,onAfterInteractive:m,onUnsupported:h,onTimeout:f});u.useEffect(()=>{j||(Y.current={onSuccess:o,onError:c,onExpire:l,onBeforeInteractive:d,onAfterInteractive:m,onUnsupported:h,onTimeout:f})});let I=(r==null?void 0:r.id)||"cf-turnstile-script",C=gue(I),L=(r==null?void 0:r.onLoadCallbackName)||"onloadTurnstileCallback",D=n.appearance||"always",_=u.useMemo(()=>({sitekey:a,action:n.action,cData:n.cData,theme:n.theme||"auto",language:n.language||"auto",tabindex:n.tabIndex,"response-field":n.responseField,"response-field-name":n.responseFieldName,size:xue(v),retry:n.retry||"auto","retry-interval":n.retryInterval||8e3,"refresh-expired":n.refreshExpired||"auto","refresh-timeout":n.refreshTimeout||"auto",execution:n.execution||"render",appearance:n.appearance||"always","feedback-enabled":n.feedbackEnabled??!0,callback:O=>{var U,G;P.current=!0,j?o==null||o(O):(G=(U=Y.current).onSuccess)==null||G.call(U,O)},"error-callback":j?c:(...O)=>{var U,G;return(G=(U=Y.current).onError)==null?void 0:G.call(U,...O)},"expired-callback":j?l:(...O)=>{var U,G;return(G=(U=Y.current).onExpire)==null?void 0:G.call(U,...O)},"before-interactive-callback":j?d:(...O)=>{var U,G;return(G=(U=Y.current).onBeforeInteractive)==null?void 0:G.call(U,...O)},"after-interactive-callback":j?m:(...O)=>{var U,G;return(G=(U=Y.current).onAfterInteractive)==null?void 0:G.call(U,...O)},"unsupported-callback":j?h:(...O)=>{var U,G;return(G=(U=Y.current).onUnsupported)==null?void 0:G.call(U,...O)},"timeout-callback":j?f:(...O)=>{var U,G;return(G=(U=Y.current).onTimeout)==null?void 0:G.call(U,...O)}}),[n.action,n.appearance,n.cData,n.execution,n.language,n.refreshExpired,n.responseField,n.responseFieldName,n.retry,n.retryInterval,n.tabIndex,n.theme,n.feedbackEnabled,n.refreshTimeout,a,v,j,j?o:null,j?c:null,j?l:null,j?d:null,j?m:null,j?h:null,j?f:null]),H=u.useCallback(()=>typeof window<"u"&&!!window.turnstile,[]);return u.useEffect(function(){w&&!R&&(SC(L),pue({onLoadCallbackName:L,scriptOptions:{...r,id:I}}))},[w,R,r,I,L]),u.useEffect(function(){Jm!=="ready"&&SC(L).then(()=>A(!0)).catch(console.error)},[L]),u.useEffect(function(){if(!$.current||!R)return;let O=!1;return(async()=>O||!$.current||(T.current=window.turnstile.render($.current,_),T.current&&(i==null||i(T.current))))(),()=>{O=!0,T.current&&(window.turnstile.remove(T.current),P.current=!1)}},[B,R,_]),u.useImperativeHandle(s,()=>{let{turnstile:O}=window;return{getResponse(){if(!(O!=null&&O.getResponse)||!T.current||!H()){console.warn("Turnstile has not been loaded");return}return O.getResponse(T.current)},async getResponsePromise(U=3e4,G=100){return new Promise((E,z)=>{let Z,M=async()=>
834{if(P.current&&window.turnstile&&T.current)try{let F=window.turnstile.getResponse(T.current);return Z&&clearTimeout(Z),F?E(F):z(Error("No response received"))}catch(F){return Z&&clearTimeout(Z),console.warn("Failed to get response",F),z(Error("Failed to get response"))}Z||(Z=setTimeout(()=>{Z&&clearTimeout(Z),z(Error("Timeout"))},U)),await new Promise(F=>setTimeout(F,G)),await M()};M()})},reset(){if(!(O!=null&&O.reset)||!T.current||!H()){console.warn("Turnstile has not been loaded");return}n.execution==="execute"&&k(Cl.invisible);try{P.current=!1,O.reset(T.current)}catch(U){console.warn(`Failed to reset Turnstile widget ${T.current}`,U)}},remove(){if(!(O!=null&&O.remove)||!T.current||!H()){console.warn("Turnstile has not been loaded");return}k(Cl.invisible),P.current=!1,O.remove(T.current),T.current=null},render(){if(!(O!=null&&O.render)||!$.current||!H()||T.current){console.warn("Turnstile has not been loaded or container not found");return}let U=O.render($.current,_);return T.current=U,T.current&&(i==null||i(T.current)),n.execution!=="execute"&&k(v?Cl[v]:{}),U},execute(){if(n.execution!=="execute"){console.warn('Execution mode is not set to "execute"');return}if(!(O!=null&&O.execute)||!$.current||!T.current||!H()){console.warn("Turnstile has not been loaded or container not found");return}O.execute($.current,_),k(v?Cl[v]:{})},isExpired(){return!(O!=null&&O.isExpired)||!T.current||!H()?(console.warn("Turnstile has not been loaded"),!1):O.isExpired(T.current)}}},[T,n.execution,v,_,$,H,R,i]),u.useEffect(()=>{if(R||!C)return;if(window.turnstile){A(!0);return}let O=setInterval(()=>{window.turnstile&&(A(!0),clearInterval(O))},50);return()=>{clearInterval(O)}},[R,C]),u.useEffect(()=>{k(N())},[n.execution,v,D]),u.useEffect(()=>{!C||typeof p!="function"||p()},[C]),t.jsx(mue,{ref:$,as:b,id:B,style:{...S,...g},...y})});E7.displayName="Turnstile";const yue=()=>{const{isAdmin:e}=Ar(),[s,r]=u.useState(!1),[n,a]=u.useState(n9),[i,o]=u.useState(null),[l,c]=u.useState(null),[d,m]=u.useState(!1),[h,f]=u.useState(!1),p=ds(),{toast:x}=rt(),[g,b]=u.useState(null),[w,j]=u.useState(null),[y,v]=u.useState(""),N=u.useRef(Date.now()),S=u.useRef(null);u.useEffect(()=>{e||(N.current=Date.now(),(async()=>{try{const{data:T,error:P}=await W.functions.invoke("submit-event",{method:"GET"});if(P)throw P;T!=null&&T.siteKey&&b(T.siteKey)}catch{try{const Y=await(await fetch("https://qajegkbvbpekdggtrupv.supabase.co/functions/v1/submit-event",{headers:{apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InFhamVna2J2YnBla2RnZ3RydXB2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDkxMjM1NjEsImV4cCI6MjA2NDY5OTU2MX0.pYwQldpBjowrqBL_rwyBipOU5SkEAytfJLBzmLPGuBQ"}})).json();Y!=null&&Y.siteKey&&b(Y.siteKey)}catch(P){console.error("Failed to load Turnstile config:",P)}}})())},[e]);const k=(T,P)=>{a(B=>({...B,[T]:P}))},$=T=>{if(!T){o(null),c(null);return}if(T.size>5*1024*1024){x({title:"File too large",description:"Please select an image under 5MB",variant:"destructive"});return}o(T);const P=new FileReader;P.onloadend=()=>c(P.result),P.readAsDataURL(T)},R=async T=>{try{const P=T.name.split(".").pop(),Y=`public/${`${Date.now()}-${Math.random().toString(36).substring(2)}.${P}`}`,{error:I}=await W.storage.from("event-images").upload(Y,T);if(I)throw I;const{data:{publicUrl:C}}=W.storage.from("event-images").getPublicUrl(Y);return C}catch(P){return console.error("Error uploading image:",P),null}},A=async T=>{var P;if(T.preventDefault(),!n.title||!n.date||!n.time||!n.location||!n.area||!n.category||!n.type||!n.organizer){x({title:"Missing required fields",description:"Please fill in all required fields marked with *",variant:"destructive"});return}if(s&&!n.contact_email){x({title:"Organiser email required",description:"Please enter the organiser's email address so we can send them login details.",variant:"destructive"});return}m(!0);try{const{data:{user:B}}=await W.auth.getUser();let Y=null;if(i&&(Y=await R(i),Y||x({title:"Image upload failed",description:"Your event will be submitted without an image",variant:"destructive"})),!e){if(!w){x({title:"Please complete the captcha",description:"We use a quick check to keep spam out.",variant:"destructive"}),m(!1);return}const{data:O,error:U}=await W.functions.invoke("submit-event",{body:{title:n.title,organizer:n.organizer,date:n.date,date_end:n.date_end||null,time:n.time,end_time:n.end_time||null,location:n.location,area:n.area,postcode:n.postcode||null,category:n.category,type:n.type,excerpt:n.excerpt||null,full_description:n.full_description||null,ticket_url:n.ticket_url||null,contact_email:n.contact_email||null,contact_phone:n.contact_phone||null,website_url:n.website_url||null,image:Y,turnstileToken:w,honeypot:y,formLoadedAt:N.current}});if(U||O&&O.error){const G=(O==null?void 0:O.error)||(U==null?void 0:U.message)||"There was an error submitting your event.";x({title:"Submission failed",description:G,variant:"destructive"}),(P=S.current)==null||P.reset(),j(null),m(!1);return}f(!0),x({title:"Event Submitted!",description:"Your event has been submitted for review. It will appear once approved by an admin."}),m(!1);return}let I=null,C=null,L=!1;
834if(s&&n.contact_email){const O=crypto.randomUUID().slice(0,12),{data:U,error:G}=await W.functions.invoke("admin-manage-user",{body:{action:"create_user",email:n.contact_email,password:O,display_name:n.organizer||n.contact_email.split("@")[0],phone:n.contact_phone||void 0,allow_existing_user:!0,send_email:!1}});G?(console.error("Error creating organiser account:",G),x({title:"Account creation failed",description:"Could not create organiser account. The event will be submitted without linking.",variant:"destructive"})):U&&(I=U.user_id,L=U.is_existing_user===!0,L||(C=O))}const D={title:n.title,description:n.excerpt||null,excerpt:n.excerpt||null,full_description:n.full_description||null,date:n.date,date_end:n.date_end||null,time:n.time,end_time:n.end_time||null,location:n.location,area:n.area,postcode:n.postcode||null,category:n.category,type:n.type,organizer:n.organizer,contact_email:n.contact_email||null,contact_phone:n.contact_phone||null,ticket_url:n.ticket_url||null,website_url:n.website_url||null,image:Y,is_published:!1,featured:!1,links:[],user_id:s&&I?I:(B==null?void 0:B.id)||null},{data:_,error:H}=await W.from("events").insert([D]).select().single();if(H)throw H;W.functions.invoke("send-event-notification",{body:{event_id:_.id,slug:_.slug,title:n.title,date:n.date,time:n.time,location:n.location,area:n.area,category:n.category,type:n.type,organizer:n.organizer||void 0,contact_email:n.contact_email||void 0,contact_phone:n.contact_phone||void 0,excerpt:n.excerpt||void 0}}).catch(O=>console.error("Failed to send event notification:",O)),s&&n.contact_email&&I&&W.functions.invoke("send-event-organiser-login",{body:{email:n.contact_email,password:C,is_existing_user:L,event_id:_.id,slug:_.slug,event_title:n.title,organiser_name:n.organizer||void 0}}).catch(O=>console.error("Failed to send organiser login email:",O)),f(!0),x({title:"Event Submitted!",description:s?"Event submitted and organiser has been emailed with their login details.":"Your event has been submitted for review. It will appear once approved by an admin."})}catch(B){console.error("Error submitting event:",B),x({title:"Error",description:B.message||"There was an error submitting your event. Please try again.",variant:"destructive"})}finally{m(!1)}};return h?t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx(gs,{}),t.jsx("main",{className:"py-16",children:t.jsx("div",{className:"max-w-2xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsx(xe,{className:"text-center",children:t.jsxs(ge,{className:"pt-12 pb-8",children:[t.jsx("div",{className:"w-20 h-20 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6",children:t.jsx(xs,{className:"h-10 w-10 text-green-600"})}),t.jsx("h2",{className:"text-2xl font-heading font-bold mb-4",children:"Event Submitted Successfully!"}),t.jsx("p",{className:"text-muted-foreground mb-8 max-w-md mx-auto",children:"Thank you for submitting your event. Our team will review it and once approved, it will be visible on the What's On page."}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[t.jsx(q,{onClick:()=>p("/whats-on"),children:"View What's On"}),t.jsx(q,{variant:"outline",onClick:()=>{f(!1),a({title:"",organizer:"",date:"",date_end:"",time:"",end_time:"",location:"",area:"",postcode:"",category:"",type:"",excerpt:"",full_description:"",ticket_url:"",contact_email:"",contact_phone:"",website_url:""}),o(null),c(null)},children:"Submit Another Event"})]})]})})})}),t.jsx(vs,{})]}):t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx(gs,{}),t.jsx("main",{className:"py-12",children:t.jsxs("div",{className:"max-w-3xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("h1",{className:"text-3xl lg:text-4xl font-heading font-bold mb-4",children:"Add Your Event"}),t.jsx("p",{className:"text-lg text-muted-foreground font-body max-w-2xl mx-auto",children:"Share your local event with the community. Once submitted, your event will be reviewed and published by our team."})]}),t.jsxs(xe,{children:[t.jsxs(Me,{children:[t.jsx(Oe,{children:"Event Details"}),t.jsx(Er,{children:"Fields marked with * are required"})]}),t.jsx(ge,{children:t.jsxs("form",{onSubmit:A,className:"space-y-8",children:[e&&t.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(bh,{className:"h-5 w-5 text-amber-600"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-amber-900",children:"Filling in on behalf of an organiser"}),t.jsx("p",{className:"text-sm text-amber-700",children:"The organiser will receive an email with login details to manage their event"})]})]}),t.jsx(kt,{checked:s,onCheckedChange:r,disabled:d})]}),s&&t.jsx("div",{className:"mt-3 pt-3 border-t border-amber-200",children:t.jsxs("p",{className:"text-sm text-amber-700",children:[t.jsx("strong",{children:"Note:"})," The organiser's contact email (below) will be used as their login email. They'll receive credentials and a link to the dashboard where they can upload an image and verify details."]})})]}),t.jsx(r9,{formData:n,onChange:k,imagePreview:l,onImageChange:$,disabled:d,showInfoBanner:!0,isOnBehalf:s}),t.jsxs("div",{"aria-hidden":"true",style:{position:"absolute",left:"-10000px",top:"auto",width:"1px",height:"1px",overflow:"hidden"},children:[t.jsx("label",{htmlFor:"website_homepage",children:"Website (leave blank)"}),t.jsx("input",{id:"website_homepage",name:"website_homepage",type:"text",tabIndex:-1,autoComplete:"off",value:y,onChange:T=>v(T.target.value)})]}),!e&&g&&t.jsx("div",{className:"flex justify-center",children:t.jsx(E7,{ref:S,siteKey:g,onSuccess:T=>j(T),onExpire:()=>j(null),onError:()=>j(null),options:{theme:"light"}})}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 pt-4",children:[t.jsx(q,{type:"button",variant:"outline",onClick:()=>p("/whats-on"),className:"sm:flex-1",disabled:d,children:"Cancel"}),t.jsx(q,{type:"submit",className:"sm:flex-1",disabled:d||!e&&!w,children:d?"Submitting...":"Submit Event for Review"})]})]})})]})]})}),t.jsx(vs,{})]})},bue="https://qajegkbvbpekdggtrupv.supabase.co/functions/v1",jue=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,wue=()=>{const{slug:e}=xv(),s=ds(),{toast:r}=rt(),[n,a]=u.useState(null),[i,o]=u.useState([]),[l,c]=u.useState(!0);u.useEffect(()=>{(async()=>
834{if(e)try{const b=jue.test(e);let w=W.from("events").select("*").eq("is_published",!0);const{data:j,error:y}=b?await w.eq("id",e).maybeSingle():await w.eq("slug",e).maybeSingle();if(y)throw y;if(!j)throw new Error("Event not found");if(b&&j.slug&&j.slug!==e){s(`/events/${j.slug}`,{replace:!0});return}const v={...j,links:Array.isArray(j.links)?j.links:[]};a(v);const{data:N}=await W.from("events").select("*").eq("is_published",!0).eq("category",j.category).neq("id",j.id).gte("date",new Date().toISOString().split("T")[0]).order("date",{ascending:!0}).limit(3);N&&o(N.map(S=>({...S,links:Array.isArray(S.links)?S.links:[]})))}catch(b){console.error("Error fetching event:",b),r({title:"Error",description:"Event not found",variant:"destructive"}),s("/whats-on")}finally{c(!1)}})()},[e,s,r]);const d=g=>new Date(g).toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long",year:"numeric"}),m=(g,b)=>{const w=new Date(g),j=new Date(b);return w.getMonth()===j.getMonth()&&w.getFullYear()===j.getFullYear()?`${w.getDate()} - ${j.getDate()} ${w.toLocaleDateString("en-GB",{month:"long",year:"numeric"})}`:`${w.toLocaleDateString("en-GB",{day:"numeric",month:"long"})} - ${j.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})}`},h=(n==null?void 0:n.date_end)&&n.date_end!==n.date,f=g=>{const[b,w]=g.split(":"),j=parseInt(b),y=j>=12?"PM":"AM";return`${j%12||12}:${w} ${y}`},p=async()=>{const g=n!=null&&n.slug?`${bue}/event-og?slug=${encodeURIComponent(n.slug)}`:window.location.href;if(navigator.share)try{await navigator.share({title:n==null?void 0:n.title,text:(n==null?void 0:n.excerpt)||(n==null?void 0:n.description)||"",url:g})}
834catch{console.log("Share cancelled")}else await navigator.clipboard.writeText(g),r({title:"Link copied",description:"Shareable event link copied to clipboard"})},x=()=>{if(!n)return"";const g=new Date(`${n.date}T${n.time}`),b=n.end_time?new Date(`${n.date}T${n.end_time}`):new Date(g.getTime()+2*60*60*1e3),w=y=>y.toISOString().replace(/[-:]/g,"").split(".")[0]+"Z";return`https://calendar.google.com/calendar/render?action=TEMPLATE&text=${encodeURIComponent(n.title)}&dates=${w(g)}/${w(b)}&location=${encodeURIComponent(n.location)}&details=${encodeURIComponent(n.excerpt||n.description||"")}`};return l?t.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[t.jsx(gs,{}),t.jsx("main",{className:"flex-1",children:t.jsxs("div",{className:"container mx-auto px-4 py-8",children:[t.jsx(Is,{className:"h-8 w-32 mb-6"}),t.jsx(Is,{className:"h-64 w-full rounded-xl mb-6"}),t.jsx(Is,{className:"h-10 w-3/4 mb-4"}),t.jsx(Is,{className:"h-6 w-1/2 mb-8"}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(Is,{className:"h-4 w-full"}),t.jsx(Is,{className:"h-4 w-full"}),t.jsx(Is,{className:"h-4 w-3/4"})]})]})}),t.jsx(vs,{})]}):n?t.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[t.jsx(gs,{}),t.jsxs("main",{className:"flex-1",children:[t.jsx("div",{className:"relative",children:n.image?t.jsxs("div",{className:"h-64 md:h-96 w-full",children:[t.jsx("img",{src:n.image,alt:n.title,className:"w-full h-full object-cover"}),t.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-background via-background/50 to-transparent"})]}):t.jsx("div",{className:"h-32 md:h-48 bg-gradient-to-r from-primary/20 to-primary/10"})}),t.jsxs("div",{className:"container mx-auto px-4 -mt-20 relative z-10",children:[t.jsxs(q,{variant:"ghost",onClick:()=>s("/whats-on"),className:"mb-4 bg-background/80 backdrop-blur-sm hover:bg-background",children:[t.jsx(Hi,{className:"h-4 w-4 mr-2"}),"Back to Events"]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[t.jsx(xe,{className:"shadow-lg",children:t.jsxs(ge,{className:"p-6 md:p-8",children:[t.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[t.jsx(we,{children:n.category}),t.jsx(we,{variant:"outline",children:n.type}),n.featured&&t.jsxs(we,{variant:"secondary",className:"bg-yellow-100 text-yellow-800",children:[t.jsx(mr,{className:"h-3 w-3 mr-1 fill-current"}),"Featured"]})]}),t.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-4",children:n.title}),t.jsxs("div",{className:"flex flex-wrap gap-4 mb-6 text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(It,{className:"h-5 w-5 text-primary"}),t.jsx("span",{children:h?m(n.date,n.date_end):d(n.date)})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ws,{className:"h-5 w-5 text-primary"}),t.jsxs("span",{children:[f(n.time),n.end_time&&` - ${f(n.end_time)}`]})]})]}),t.jsxs("div",{className:"flex items-start gap-2 mb-6 text-muted-foreground",children:[t.jsx(_t,{className:"h-5 w-5 text-primary mt-0.5"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-foreground",children:n.location}),t.jsxs("p",{children:[n.area,n.postcode&&`, ${n.postcode}`]})]})]}),t.jsx("div",{className:"prose prose-sm max-w-none",children:n.full_description?t.jsx("div",{className:"whitespace-pre-wrap",children:n.full_description}):n.description?t.jsx("div",{className:"whitespace-pre-wrap",children:n.description}):n.excerpt?t.jsx("p",{children:n.excerpt}):t.jsx("p",{className:"text-muted-foreground italic",children:"No description available."})})]})}),i.length>0&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("h2",{className:"text-xl font-semibold",children:["More ",n.category," Events"]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:i.map(g=>t.jsx(hs,{to:`/events/${g.slug||g.id}`,className:"group",children:t.jsxs(xe,{className:"overflow-hidden h-full transition-shadow hover:shadow-md",children:[g.image&&t.jsx("div",{className:"h-32 overflow-hidden",children:t.jsx("img",{src:g.image,alt:g.title,className:"w-full h-full object-cover transition-transform group-hover:scale-105"})}),t.jsxs(ge,{className:"p-4",children:[t.jsx("p",{className:"font-medium line-clamp-2 group-hover:text-primary transition-colors",children:g.title}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:new Date(g.date).toLocaleDateString("en-GB",{day:"numeric",month:"short"})})]})]})},g.id))})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(xe,{children:t.jsxs(ge,{className:"p-4 space-y-3",children:[n.ticket_url&&t.jsx(q,{className:"w-full",asChild:!0,children:t.jsxs("a",{href:n.ticket_url,target:"_blank",rel:"noopener noreferrer",children:[t.jsx(Pw,{className:"h-4 w-4 mr-2"}),"Book Tickets"]})}),t.jsx(q,{variant:"outline",className:"w-full",asChild:!0,children:t.jsxs("a",{href:x(),target:"_blank",rel:"noopener noreferrer",children:[t.jsx(It,{className:"h-4 w-4 mr-2"}),"Add to Calendar"]})}),t.jsxs(q,{variant:"outline",className:"w-full",onClick:p,children:[t.jsx(Ew,{className:"h-4 w-4 mr-2"}),"Share Event"]})]})}),(n.organizer||n.contact_email||n.contact_phone)&&t.jsx(xe,{children:t.jsxs(ge,{className:"p-4 space-y-3",children:[t.jsx("h3",{className:"font-semibold",children:"Contact Information"}),n.organizer&&t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx(bn,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{children:n.organizer})]}),n.contact_email&&t.jsxs("a",{href:`mailto:${n.contact_email}`,className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[t.jsx(ar,{className:"h-4 w-4"}),t.jsx("span",{children:n.contact_email})]}),n.contact_phone&&t.jsxs("a",{href:`tel:${n.contact_phone}`,className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[t.jsx(zr,{className:"h-4 w-4"}),t.jsx("span",{children:n.contact_phone})]})]})}),n.links&&n.links.length>0&&t.jsx(xe,{children:t.jsxs(ge,{className:"p-4 space-y-3",children:[t.jsx("h3",{className:"font-semibold",children:"Links"}),n.links.map((g,b)=>t.jsxs("a",{href:g.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[t.jsx(_u,{className:"h-4 w-4"}),t.jsx("span",{children:g.label})]},b))]})})]})]})]}),t.jsx("div",{className:"h-16"})]}),t.jsx(vs,{})]}):null},Nue=()=>{const{id:e}=xv(),s=ds(),[r,n]=u.useState(null),[a,i]=u.useState(!0),[o,l]=u.useState(!1);u.useEffect(()=>{(async()=>
834{if(!e){l(!0),i(!1);return}try{const{data:h,error:f}=await W.from("stories").select("*").eq("id",e).eq("is_published",!0).single();f||!h?l(!0):n(h)}catch(h){console.error("Error fetching story:",h),l(!0)}finally{i(!1)}})()},[e]);const c=m=>new Date(m).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"}),d=m=>{const h=m.split(/\s+/).length;return`${Math.ceil(h/200)} min read`};return a?t.jsxs("div",{className:"min-h-screen",children:[t.jsx(gs,{}),t.jsx("main",{className:"py-16",children:t.jsx("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"animate-pulse space-y-4",children:[t.jsx("div",{className:"h-8 bg-gray-200 rounded w-1/4"}),t.jsx("div",{className:"h-12 bg-gray-200 rounded w-3/4"}),t.jsx("div",{className:"aspect-video bg-gray-200 rounded-lg"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-4 bg-gray-200 rounded w-full"}),t.jsx("div",{className:"h-4 bg-gray-200 rounded w-full"}),t.jsx("div",{className:"h-4 bg-gray-200 rounded w-3/4"})]})]})})}),t.jsx(vs,{})]}):o||!r?t.jsxs("div",{className:"min-h-screen",children:[t.jsx(gs,{}),t.jsx("main",{className:"py-16",children:t.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 text-center",children:[t.jsx("h1",{className:"text-2xl font-heading font-bold text-community-navy mb-4",children:"Story Not Found"}),t.jsx("p",{className:"text-gray-600 mb-6",children:"The story you're looking for doesn't exist or has been removed."}),t.jsxs(q,{onClick:()=>s("/stories"),className:"bg-community-navy hover:bg-slate-700",children:[t.jsx(Hi,{className:"w-4 h-4 mr-2"}),"Back to Stories"]})]})}),t.jsx(vs,{})]}):t.jsxs("div",{className:"min-h-screen",children:[t.jsx(gs,{}),t.jsx("main",{className:"py-16",children:t.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs(q,{onClick:()=>s("/stories"),variant:"ghost",className:"mb-8 text-community-navy hover:bg-gray-100",children:[t.jsx(Hi,{className:"w-4 h-4 mr-2"}),"Back to Stories"]}),t.jsxs("article",{children:[t.jsxs("div",{className:"mb-8",children:[t.jsxs("div",{className:"flex items-center gap-4 mb-4 flex-wrap",children:[t.jsxs("span",{className:"inline-flex items-center px-3 py-1 bg-community-green text-white text-sm font-medium rounded-full",children:[t.jsx(fc,{className:"w-3 h-3 mr-1"}),r.category]}),t.jsxs("span",{className:"inline-flex items-center px-3 py-1 bg-community-navy text-white text-sm font-medium rounded-full",children:[t.jsx(_t,{className:"w-3 h-3 mr-1"}),r.area]}),t.jsxs("span",{className:"flex items-center text-gray-500 text-sm",children:[t.jsx(It,{className:"w-4 h-4 mr-1"}),c(r.published_at||r.created_at)]}),t.jsx("span",{className:"text-gray-500 text-sm",children:d(r.content)})]}),t.jsx("h1",{className:"text-4xl lg:text-5xl font-heading font-bold text-community-navy mb-4",children:r.title}),r.excerpt&&t.jsx("p",{className:"text-xl text-gray-600 font-body mb-6",children:r.excerpt}),r.author_name&&t.jsxs("p",{className:"flex items-center text-sm text-gray-500",children:[t.jsx(bn,{className:"w-4 h-4 mr-1"}),"By ",r.author_name]})]}),r.featured_image_url&&t.jsx("div",{className:"aspect-video bg-gray-200 rounded-lg overflow-hidden mb-8",children:t.jsx("img",{src:r.featured_image_url,alt:r.title,className:"w-full h-full object-cover"})}),t.jsx("div",{className:"prose prose-lg max-w-none font-body",style:{whiteSpace:"pre-wrap"},children:r.content})]}),t.jsx("div",{className:"mt-12 pt-8 border-t border-gray-200",children:t.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-heading font-semibold text-community-navy mb-2",children:"Share this story"}),t.jsx("p",{className:"text-gray-600",children:"Help spread the word about community news"})]}),t.jsx(q,{onClick:()=>s("/stories"),className:"bg-community-navy hover:bg-slate-700",children:"Read More Stories"})]})})]})}),t.jsx(vs,{})]})},_ue=()=>{const e=ds(),[s,r]=u.useState(""),[n,a]=u.useState("all"),[i,o]=u.useState("all"),[l,c]=u.useState("newest"),[d,m]=u.useState([]),[h,f]=u.useState(!0),{areas:p}=_7();u.useEffect(()=>{(async()=>{try{f(!0);const{data:w,error:j}=await W.from("stories").select("id, title, excerpt, featured_image_url, created_at, category, area").eq("is_published",!0).order("created_at",{ascending:l==="oldest"});if(j)throw j;m(w||[])}catch(w){console.error("Error fetching stories:",w)}finally{f(!1)}})()},[l]);const x=d.filter(b=>{var v;const w=b.title.toLowerCase().includes(s.toLowerCase())||(((v=b.excerpt)==null?void 0:v.toLowerCase().includes(s.toLowerCase()))??!1),j=n==="all"||b.category===n,y=i==="all"||b.area===i;return w&&j&&y}),g=b=>new Date(b).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"});return t.jsxs("div",{className:"min-h-screen",children:[t.jsx(gs,{}),t.jsxs("main",{className:"pt-16",children:[t.jsx("section",{className:"bg-community-navy text-white py-16",children:t.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h1",{className:"text-4xl lg:text-5xl font-heading font-bold mb-4",children:"Stories Archive"}),t.jsx("p",{className:"text-xl text-gray-300 font-body max-w-2xl mx-auto",children:"Browse through all our community stories and find what interests you most"})]})})}),t.jsx("section",{className:"bg-gray-50 py-8",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"flex flex-col md:flex-row gap-4 items-center",children:[t.jsxs("div",{className:"relative flex-1 max-w-md",children:[t.jsx(Ur,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),t.jsx(re,{placeholder:"Search stories...",value:s,onChange:b=>r(b.target.value),className:"pl-10"})]}),t.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(mc,{className:"h-4 w-4 text-gray-600"}),t.jsx("span",{className:"text-sm font-medium text-gray-600",children:"Filter by:"})]}),t.jsxs(ht,{value:n,onValueChange:a,children:[t.jsx(ut,{className:"w-48",children:t.jsx(ft,{placeholder:"Select category"})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Categories"}),w7.map(b=>t.jsx(Pe,{value:b,children:b},b))]})]}),t.jsxs(ht,{value:i,onValueChange:o,children:[t.jsx(ut,{className:"w-64",children:t.jsx(ft,{placeholder:"Select area"})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"all",children:"All Areas"}),p.map(b=>t.jsx(Pe,{value:b.name,children:b.cleanName},b.id))]})]}),t.jsxs(ht,{value:l,onValueChange:c,children:[t.jsx(ut,{className:"w-32",children:t.jsx(ft,{placeholder:"Sort by"})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"newest",children:"Newest"}),t.jsx(Pe,{value:"oldest",children:"Oldest"})]})]})]})]}),t.jsx("div",{className:"mt-4",children:t.jsxs("p",{className:"text-gray-600 text-sm",children:["Showing ",x.length," of ",d.length," stories"]})})]})}),t.jsx("section",{className:"py-16 bg-white",children:t.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:h?t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8",children:[1,2,3,4,5,6].map(b=>t.jsxs("div",{className:"animate-pulse",children:[t.jsx("div",{className:"aspect-video bg-gray-200 rounded-lg"}),t.jsxs("div",{className:"p-4 space-y-2",children:[t.jsx("div",{className:"h-4 bg-gray-200 rounded w-1/4"}),t.jsx("div",{className:"h-6 bg-gray-200 rounded w-3/4"}),t.jsx("div",{className:"h-4 bg-gray-200 rounded w-full"})]})]},b))}):x.length===0?t.jsxs("div",{className:"text-center py-12",children:[t.jsx("p",{className:"text-xl text-gray-600 font-body",children:"No stories found matching your criteria."}),t.jsx(q,{variant:"outline",onClick:()=>{r(""),a("all"),o("all")},className:"mt-4",children:"Clear Filters"})]}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8",children:x.map(b=>t.jsxs(xe,{className:"group hover:shadow-lg transition-shadow duration-300",children:[t.jsx("div",{className:"aspect-video bg-gray-200 rounded-t-lg overflow-hidden",children:t.jsx("img",{src:b.featured_image_url||"/placeholder.svg",alt:b.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"})}),t.jsxs(Me,{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:[t.jsx("span",{className:"px-3 py-1 bg-community-green text-white text-xs font-medium rounded-full",children:b.category}),t.jsx("span",{className:"px-3 py-1 bg-community-navy text-white text-xs font-medium rounded-full",children:N7(b.area)}),t.jsx("span",{className:"text-gray-500 text-sm",children:g(b.created_at)})]}),t.jsx(Oe,{className:"text-xl font-heading text-community-navy group-hover:text-community-green transition-colors",children:b.title})]}),t.jsxs(ge,{children:[t.jsx("p",{className:"text-gray-600 font-body mb-4",children:b.excerpt}),t.jsx(q,{variant:"outline",size:"sm",className:"text-community-green border-community-green hover:bg-community-green hover:text-white",onClick:()=>e(`/story/${b.id}`),children:"Read More"})]})]},b.id))})})})]}),t.jsx(vs,{})]})};function Sue({businessId:e,businessName:s,ownerId:r,triggerClassName:n,triggerLabel:a,triggerIcon:i,hideWhenPending:o}){const{toast:l}=rt(),[c,d]=u.useState(!1),[m,h]=u.useState(!1),[f,p]=u.useState(null),[x,g]=u.useState(null),[b,w]=u.useState(!0),[j,y]=u.useState({verification_method:"",verification_notes:""});if(u.useEffect(()=>{(async()=>{var R,A;const{data:{session:$}}=await W.auth.getSession();if(p(((R=$==null?void 0:$.user)==null?void 0:R.id)||null),(A=$==null?void 0:$.user)!=null&&A.id){const{data:T}=await W.from("business_claim_requests").select("*").eq("business_id",e).eq("user_id",$.user.id).order("created_at",{ascending:!1}).limit(1).maybeSingle();g(T)}w(!1)})()},[e]),r)return o?t.jsxs(hs,{to:"/contact",className:"inline-flex items-center gap-1.5 text-xs text-white/70 hover:text-white underline underline-offset-2 transition-colors",children:[t.jsx(bh,{className:"h-3.5 w-3.5"}),"This listing is managed by its owner â contact us"]}):t.jsxs("div",{className:"p-4 border rounded-lg bg-muted/50",children:[t.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[t.jsx(bh,{className:"h-4 w-4 mr-1 text-muted-foreground"}),"This listing is managed by its owner"]}),t.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["If you believe this listing was claimed in error,"," ",t.jsx(hs,{to:"/contact",className:"underline underline-offset-2",children:"contact our team"}),"."]})]});if(b)return null;if(!f)return t.jsx(hs,{to:"/auth",children:n?t.jsxs("button",{type:"button",className:n,children:[i??t.jsx(Xr,{className:"h-3.5 w-3.5"}),a??"Sign in to claim"]}):t.jsxs(q,{variant:"outline",className:"w-full",children:[t.jsx(Xr,{className:"h-4 w-4 mr-2"}),"Sign in to claim this business"]})});
834const v=x==null?void 0:x.status;if(v==="pending"||v==="approved")return o?t.jsx("span",{className:"inline-flex items-center gap-1.5 bg-white/15 text-white/80 border border-white/25 text-xs font-medium px-4 py-2 rounded-lg cursor-not-allowed",children:v==="pending"?t.jsxs(t.Fragment,{children:[t.jsx(ws,{className:"h-3.5 w-3.5"})," Your claim is under review"]}):t.jsxs(t.Fragment,{children:[t.jsx(xs,{className:"h-3.5 w-3.5"})," Your claim has been approved"]})}):t.jsxs("div",{className:"p-4 border rounded-lg bg-muted/50",children:[t.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[v==="pending"?t.jsx(ws,{className:"h-4 w-4 mr-1 text-yellow-600"}):t.jsx(xs,{className:"h-4 w-4 mr-1 text-green-600"}),v==="pending"?"Your claim is under review":"Your claim has been approved"]}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:v==="pending"?"Your claim is being reviewed by our team.":"Visit your dashboard to manage this business."})]});const S=async k=>{if(k.preventDefault(),!!f){h(!0);try{const{data:$,error:R}=await W.from("business_claim_requests").insert({business_id:e,user_id:f,verification_method:j.verification_method||null,verification_notes:j.verification_notes||null}).select("id").single();if(R)throw R;$!=null&&$.id&&W.functions.invoke("send-directory-notification",{body:{type:"claim_submitted_admin",claim_id:$.id}}).catch(()=>{}),l({title:"Claim Submitted",description:"Your claim request has been submitted for review. We'll notify you once it's processed."}),d(!1),g({status:"pending"})}catch($){l({title:"Error",description:$.message,variant:"destructive"})}finally{h(!1)}}};return t.jsxs("div",{className:"space-y-1.5",children:[v==="rejected"&&t.jsxs("p",{className:o?"flex items-center gap-1.5 text-[11px] text-white/70":"flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx(Hs,{className:"h-3.5 w-3.5"}),"Your previous claim was rejected â you can apply again with more evidence."]}),t.jsxs(bt,{open:c,onOpenChange:d,children:[t.jsx(Sn,{asChild:!0,children:n?t.jsxs("button",{type:"button",className:n,children:[i??t.jsx(Xr,{className:"h-3.5 w-3.5"}),a??"Claim This Business"]}):t.jsxs(q,{variant:"outline",className:"w-full",children:[t.jsx(Xr,{className:"h-4 w-4 mr-2"}),"Claim This Business"]})}),t.jsxs(xt,{children:[t.jsxs(jt,{children:[t.jsx(wt,{children:"Claim Business Ownership"}),t.jsxs(ys,{children:['Submit a claim to take ownership of "',s,'". Our team will review your request.']})]}),t.jsxs("form",{onSubmit:S,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"verification_method",children:"How can we verify you own this business?"}),t.jsxs(ht,{value:j.verification_method,onValueChange:k=>y($=>({...$,verification_method:k})),children:[t.jsx(ut,{children:t.jsx(ft,{placeholder:"Select verification method"})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"email",children:"I have access to the business email"}),t.jsx(Pe,{value:"phone",children:"I can receive calls at the business phone"}),t.jsx(Pe,{value:"document",children:"I can provide business documents"}),t.jsx(Pe,{value:"other",children:"Other"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"verification_notes",children:"Additional Information"}),t.jsx(ms,{id:"verification_notes",value:j.verification_notes,onChange:k=>y($=>({...$,verification_notes:k.target.value})),placeholder:"Tell us more about your connection to this business...",rows:3})]}),t.jsxs("div",{className:"flex gap-2 pt-4",children:[t.jsx(q,{type:"submit",disabled:m,className:"flex-1",children:m?"Submitting...":"Submit Claim"}),t.jsx(q,{type:"button",variant:"outline",onClick:()=>d(!1),children:"Cancel"})]})]})]})]})]})}function Cue({businessId:e,businessName:s,open:r,onOpenChange:n}){const{toast:a}=rt(),[i,o]=u.useState(!1),[l,c]=u.useState(!1),[d,m]=u.useState({name:"",email:"",relationship:"",reason:""}),h=async p=>{p.preventDefault(),o(!0);try{const{error:x}=await W.rpc("submit_business_removal_request",{_business_id:e,_name:d.name,_email:d.email,_relationship:d.relationship||null,_reason:d.reason});if(x)throw x;W.functions.invoke("send-directory-notification",{body:{type:"removal_submitted_admin",business_id:e,requester_email:d.email}}
834).catch(()=>{}),c(!0)}catch(x){a({title:"Could not send your request",description:x.message,variant:"destructive"})}finally{o(!1)}},f=p=>{n(p),p||(c(!1),m({name:"",email:"",relationship:"",reason:""}))};return t.jsx(bt,{open:r,onOpenChange:f,children:t.jsxs(xt,{children:[t.jsxs(jt,{children:[t.jsx(wt,{children:"Request removal of this listing"}),t.jsxs(ys,{children:['Tell us why "',s,'" should be taken off the Discover directory. You do not need an account.']})]}),l?t.jsxs("div",{className:"py-4 text-center space-y-3",children:[t.jsx(As,{className:"h-10 w-10 text-community-green mx-auto"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Thank you â your request has been sent to our team. We review removal requests within a few working days and will email you at the address you gave us."}),t.jsx(q,{onClick:()=>f(!1),className:"w-full",children:"Close"})]}):t.jsxs("form",{onSubmit:h,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"removal_name",children:"Your name"}),t.jsx(re,{id:"removal_name",required:!0,maxLength:120,value:d.name,onChange:p=>m(x=>({...x,name:p.target.value}))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"removal_email",children:"Your email"}),t.jsx(re,{id:"removal_email",type:"email",required:!0,maxLength:255,value:d.email,onChange:p=>m(x=>({...x,email:p.target.value}))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"removal_relationship",children:"Your relationship to the business"}),t.jsxs(ht,{value:d.relationship,onValueChange:p=>m(x=>({...x,relationship:p})),children:[t.jsx(ut,{id:"removal_relationship",children:t.jsx(ft,{placeholder:"Select an option"})}),t.jsxs(mt,{children:[t.jsx(Pe,{value:"owner",children:"I own the business"}),t.jsx(Pe,{value:"employee",children:"I work for the business"}),t.jsx(Pe,{value:"representative",children:"I represent the business"}),t.jsx(Pe,{value:"closed",children:"The business has closed"}),t.jsx(Pe,{value:"other",children:"Other"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(V,{htmlFor:"removal_reason",children:"Why should we remove it?"}),t.jsx(ms,{id:"removal_reason",required:!0,rows:4,maxLength:2e3,value:d.reason,onChange:p=>m(x=>({...x,reason:p.target.value})),placeholder:"For example: the business has closed, or we never asked to be listed."})]}),t.jsxs("div",{className:"flex gap-2 pt-2",children:[t.jsx(q,{type:"submit",disabled:i,className:"flex-1",children:i?"Sending...":"Send request"}),t.jsx(q,{type:"button",variant:"outline",onClick:()=>f(!1),children:"Cancel"})]})]})]})})}const kue
vendor: 12,668 bytes, line 834
834={version:4,country_calling_codes:{1:["US","AG","AI","AS","BB","BM","BS","CA","DM","DO","GD","GU","JM","KN","KY","LC","MP","MS","PR","SX","TC","TT","VC","VG","VI"],7:["RU","KZ"],20:["EG"],27:["ZA"],30:["GR"],31:["NL"],32:["BE"],33:["FR"],34:["ES"],36:["HU"],39:["IT","VA"],40:["RO"],41:["CH"],43:["AT"],44:["GB","GG","IM","JE"],45:["DK"],46:["SE"],47:["NO","SJ"],48:["PL"],49:["DE"],51:["PE"],52:["MX"],53:["CU"],54:["AR"],55:["BR"],56:["CL"],57:["CO"],58:["VE"],60:["MY"],61:["AU","CC","CX"],62:["ID"],63:["PH"],64:["NZ"],65:["SG"],66:["TH"],81:["JP"],82:["KR"],84:["VN"],86:["CN"],90:["TR"],91:["IN"],92:["PK"],93:["AF"],94:["LK"],95:["MM"],98:["IR"],211:["SS"],212:["MA","EH"],213:["DZ"],216:["TN"],218:["LY"],220:["GM"],221:["SN"],222:["MR"],223:["ML"],224:["GN"],225:["CI"],226:["BF"],227:["NE"],228:["TG"],229:["BJ"],230:["MU"],231:["LR"],232:["SL"],233:["GH"],234:["NG"],235:["TD"],236:["CF"],237:["CM"],238:["CV"],239:["ST"],240:["GQ"],241:["GA"],242:["CG"],243:["CD"],244:["AO"],245:["GW"],246:["IO"],247:["AC"],248:["SC"],249:["SD"],250:["RW"],251:["ET"],252:["SO"],253:["DJ"],254:["KE"],255:["TZ"],256:["UG"],257:["BI"],258:["MZ"],260:["ZM"],261:["MG"],262:["RE","YT"],263:["ZW"],264:["NA"],265:["MW"],266:["LS"],267:["BW"],268:["SZ"],269:["KM"],290:["SH","TA"],291:["ER"],297:["AW"],298:["FO"],299:["GL"],350:["GI"],351:["PT"],352:["LU"],353:["IE"],354:["IS"],355:["AL"],356:["MT"],357:["CY"],358:["FI","AX"],359:["BG"],370:["LT"],371:["LV"],372:["EE"],373:["MD"],374:["AM"],375:["BY"],376:["AD"],377:["MC"],378:["SM"],380:["UA"],381:["RS"],382:["ME"],383:["XK"],385:["HR"],386:["SI"],387:["BA"],389:["MK"],420:["CZ"],421:["SK"],423:["LI"],500:["FK"],501:["BZ"],502:["GT"],503:["SV"],504:["HN"],505:["NI"],506:["CR"],507:["PA"],508:["PM"],509:["HT"],590:["GP","BL","MF"],591:["BO"],592:["GY"],593:["EC"],594:["GF"],595:["PY"],596:["MQ"],597:["SR"],598:["UY"],599:["CW","BQ"],670:["TL"],672:["NF"],673:["BN"],674:["NR"],675:["PG"],676:["TO"],677:["SB"],678:["VU"],679:["FJ"],680:["PW"],681:["WF"],682:["CK"],683:["NU"],685:["WS"],686:["KI"],687:["NC"],688:["TV"],689:["PF"],690:["TK"],691:["FM"],692:["MH"],850:["KP"],852:["HK"],853:["MO"],855:["KH"],856:["LA"],880:["BD"],886:["TW"],960:["MV"],961:["LB"],962:["JO"],963:["SY"],964:["IQ"],965:["KW"],966:["SA"],967:["YE"],968:["OM"],970:["PS"],971:["AE"],972:["IL"],973:["BH"],974:["QA"],975:["BT"],976:["MN"],977:["NP"],992:["TJ"],993:["TM"],994:["AZ"],995:["GE"],996:["KG"],998:["UZ"]},countries:{AC:["247","00","(?:[01589]\\d|[2-467])\\d{4}",[5,6]],AD:["376","00","(?:1|6\\d)\\d{7}|[135-9]\\d{5}",[6,8,9],[["(\\d{3})(\\d{3})","$1 $2",["[135-9]"]],["(\\d{4})(\\d{4})","$1 $2",["1"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]]],AE:["971","00","(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}",[5,6,7,8,9,10,11,12],[["(\\d{3})(\\d{2,9})","$1 $2",["60|8"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[236]|[479][2-8]"],"0$1"],["(\\d{3})(\\d)(\\d{5})","$1 $2 $3",["[479]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"]],"0"],AF:["93","00","[2-7]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"]],"0"],AG:["1","011","(?:268|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([457]\\d{6})$|1","268$1",0,"268"],AI:["1","011","(?:264|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2457]\\d{6})$|1","264$1",0,"264"],AL:["355","00","(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}",[6,7,8,9],[["(\\d{3})(\\d{3,4})","$1 $2",["80|9"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2358][2-5]|4"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["[23578]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["6"],"0$1"]],"0"],AM:["374","00","(?:[1-489]\\d|55|60|77)\\d{6}",[8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[89]0"],"0 $1"],["(\\d{3})(\\d{5})","$1 $2",["2|3[12]"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["1|47"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[3-9]"],"0$1"]],"0"],AO:["244","00","[29]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[29]"]]]],AR:["54","00","(?:11|[89]\\d\\d)\\d{8}|[2368]\\d{9}",[10,11],[["(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])","2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8]))|2(?:2[24-9]|3[1-59]|47)","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5[56][46]|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|58|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|54(?:4|5[13-7]|6[89])|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:454|85[56])[46]|3(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["[23]"],"0$1",1],["(\\d)(\\d{4})(\\d{2})(\\d{4})","$2 15-$3-$4",["9(?:2[2-469]|3[3-578])","9(?:2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9]))","9(?:2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8])))|92(?:2[24-9]|3[1-59]|47)","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5(?:[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|5(?:4(?:4|5[13-7]|6[89])|[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",0,"$1 $2 $3-$4"],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 15-$3-$4",["91"],"0$1",0,"$1 $2 $3-$4"],["(\\d{3})(\\d{3})(\\d{5})","$1-$2-$3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 15-$3-$4",["9"],"0$1",0,"$1 $2 $3-$4"]],"0",0,"0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?","9$1"],AS:["1","011","(?:[58]\\d\\d|684|900)\\d{7}",[10],0,"1",0,"([267]\\d{6})$|1","684$1",0,"684"],AT:["43","00","1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}",[4,5,6,7,8,9,10,11,12,13],[["(\\d)(\\d{3,12})","$1 $2",["1(?:11|[2-9])"],"0$1"],["(\\d{3})(\\d{2})","$1 $2",["517"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["5[079]"],"0$1"],["(\\d{3})(\\d{3,10})","$1 $2",["(?:31|4)6|51|6(?:48|5[0-3579]|[6-9])|7(?:20|32|8)|[89]","(?:31|4)6|51|6(?:485|5[0-3579]|[6-9])|7(?:20|32|8)|[89]"],"0$1"],["(\\d{4})(\\d{3,9})","$1 $2",["[2-467]|5[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["5"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,7})","$1 $2 $3",["5"],"0$1"]],"0"],AU:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{7}(?:\\d(?:\\d{2})?)?|8[0-24-9]\\d{7})|[2-478]\\d{8}|1\\d{4,7}",[5,6,7,8,9,10,12],[["(\\d{2})(\\d{3,4})","$1 $2",["16"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,4})","$1 $2 $3",["16"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["14|4"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[2378]"],"(0$1)"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:30|[89])"]]],"0",0,"(183[12])|0",0,0,0,[["(?:(?:241|349)0\\d\\d|8(?:51(?:0(?:0[03-9]|[12479]\\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\\d|7[89]|9[0-4])|[34]\\d\\d)|91(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79]))))\\d{3}|(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|3(?:[0-3589]\\d|4[0-578]|6[1-9]|7[0-35-9])|7(?:[013-57-9]\\d|2[0-8])|8(?:55|6[0-8]|[78]\\d|9[02-9]))\\d{6}",[9]],["4(?:79[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,["163\\d{2,6}",[5,6,7,8,9]],["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],AW:["297","00","(?:[25-79]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[25-9]"]]]],AX:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}",[5,6,7,8,9,10,11,12],0,"0",0,0,0,0,"18",0,"00"],AZ:["994","00","365\\d{6}|(?:[124579]\\d|60|88)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[28]|2|365|46","1[28]|2|365[45]|46","1[28]|2|365(?:4|5[02])|46"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-9]"],"0$1"]],"0"],BA:["387","00","6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-3]|[7-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]|6[56]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6"],"0$1"]],"0"],BB:["1","011","(?:246|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","246$1",0,"246"],BD:["880","00","[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{4,6})","$1-$2",["31[5-8]|[459]1"],"0$1"],["(\\d{3})(\\d{3,7})","$1-$2",["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:[15]|28|4[14])|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"],"0$1"],["(\\d{4})(\\d{3,6})","$1-$2",["[13-9]|2[23]"],"0$1"],["(\\d)(\\d{7,8})","$1-$2",["2"],"0$1"]],"0"],BE:["32","00","4\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[239]|4[23]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[15-8]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4"],"0$1"]],"0"],BF:["226","00","[024-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[024-7]"]]]],BG:["359","00","00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",[6,7,8,9,12],[["(\\d)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["43[1-6]|70[1-9]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:70|8)0"],"0$1"],["(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[1-7]|7"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[48]|9[08]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"]],"0"],BH:["973","00","[136-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[13679]|8[02-4679]"]]]],BI:["257","00","(?:[267]\\d|31)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2367]"]]]],BJ:["229","00","(?:01\\d|8)\\d{7}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["0"]]]],BL:["590","00","7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["(?:59(?:0(?:2[7-9]|3[3-7]|5[12]|87)|87\\d)|80[6-9]\\d\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],["8[129]\\d{7}"],0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\d{4}"]]],BM:["1","011","(?:441|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","441$1",0,"441"],BN:["673","00","[2-578]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-578]"]]]],BO:["591","00(?:1\\d)?","(?:[2-7]\\d\\d|8001)\\d{5}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[23]|4[46]|50"]],["(\\d{8})","$1",["[5-7]"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["8"]]],"0",0,"0(1\\d)?"],BQ:["599","00","(?:[34]1|7\\d)\\d{5}",[7],0,0,0,0,0,0,"[347]"],BR:["55","00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","[1-467]\\d{9,10}
vendor: 13,185 bytes, line 834
834|55[0-46-9]\\d{8}|[34]\\d{7}|55\\d{7,8}|(?:5[0-46-9]|[89]\\d)\\d{7,9}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37|86)","300|4(?:0(?:0|20)|370|864)"]],["(\\d{3})(\\d{2,3})(\\d{4})","$1 $2 $3",["(?:[358]|90)0"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"],"($1)"],["(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[16][1-9]|[2-57-9]"],"($1)"]],"0",0,"(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2"],BS:["1","011","(?:242|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([3-8]\\d{6})$|1","242$1",0,"242"],BT:["975","00","[178]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-6]|7[246]|8[2-4]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|[78]"]]]],BW:["267","00","(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}",[7,8,10],[["(\\d{2})(\\d{5})","$1 $2",["90"]],["(\\d{3})(\\d{4})","$1 $2",["[24-6]|3[15-9]"]],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37]"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["8"]]]],BY:["375","810","(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3})","$1 $2",["800"],"8 $1"],["(\\d{3})(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"],["(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:[56]|7[467])|2[1-3]"],"8 0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-4]"],"8 0$1"],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["[89]"],"8 $1"]],"8",0,"0|80?",0,0,0,0,"8~10"],BZ:["501","00","(?:0800\\d|[2-8])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],["(\\d)(\\d{3})(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]]],CA:["1","011","[2-9]\\d{9}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|5[07]|63)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|7[39])|9(?:0[25]|42))[2-9]\\d{6}",[10]],["",[10]],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",[10]],["900[2-9]\\d{6}",[10]],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:2[125-9]|3[23]|44|66|77|88)|6(?:22|33))[2-9]\\d{6}",[10]],0,["310\\d{4}",[7]],0,["600[2-9]\\d{6}",[10]]]],CC:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:79[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CD:["243","00","(?:(?:[189]|5\\d)\\d|2)\\d{7}|[1-68]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["5"],"0$1"]],"0"],CF:["236","00","8776\\d{4}|(?:[27]\\d|61)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-8]"]]]],CG:["242","00","222\\d{6}|(?:0\\d|80)\\d{7}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]]]],CH:["41","00","8\\d{11}|[2-9]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]|81"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["8"],"0$1"]],"0"],CI:["225","00","[02]\\d{9}",[10],[["(\\d{2})(\\d{2})(\\d)(\\d{5})","$1 $2 $3 $4",["2"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3 $4",["0"]]]],CK:["682","00","[2-578]\\d{4}",[5],[["(\\d{2})(\\d{3})","$1 $2",["[2-578]"]]]],CL:["56","(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0","12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}",[9,10,11],[["(\\d{5})(\\d{4})","$1 $2",["219","2196"],"($1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["60|809"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["44"]],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[1-36]"],"($1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9(?:10|[2-9])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-8]|[1-9])"],"($1)"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{3})(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"]]]],CM:["237","00","[26]\\d{8}|88\\d{6,7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["88"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]|88"]]]],CN:["86","00|1(?:[12]\\d|79)\\d\\d00","(?:(?:1[03-689]|2\\d)\\d\\d|6)\\d{8}|1\\d{10}|[126]\\d{6}(?:\\d(?:\\d{2})?)?|86\\d{5,6}|(?:[3-579]\\d|8[0-57-9])\\d{5,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]","(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123"],"0$1"],["(\\d{3})(\\d{5,6})","$1 $2",["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]","(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]","85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])","85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["(?:4|80)0"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|2(?:[02-57-9]|1[1-9])","10|2(?:[02-57-9]|1[1-9])","10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"],"0$1",1],["(\\d{3})(\\d{7,8})","$1 $2",["9"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[3-578]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-9]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[12]"],"0$1",1]],"0",0,"(1(?:[12]\\d|79)\\d\\d)|0",0,0,0,0,"00"],CO:["57","00(?:4(?:[14]4|56)|[579])","(?:46|60\\d\\d)\\d{6}|(?:1\\d|[39])\\d{9}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["46"]],["(\\d{3})(\\d{7})","$1 $2",["6|90"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|9[14]"]],["(\\d)(\\d{3})(\\d{7})","$1-$2-$3",["1"],"0$1",0,"$1 $2 $3"]],"0",0,"0([3579]|4(?:[14]4|56))?"],CR:["506","00","(?:8\\d|90)\\d{8}|(?:[24-8]\\d{3}|3005)\\d{4}",[8,10],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[3-9]"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]"]]],0,0,"(19(?:0[0-2468]|1[09]|20|66|77|99))"],CU:["53","119","(?:[2-7]|8\\d\\d)\\d{7}|[2-47]\\d{6}|[34]\\d{5}",[6,7,8,10],[["(\\d{2})(\\d{4,6})","$1 $2",["2[1-4]|[34]"],"(0$1)"],["(\\d)(\\d{6,7})","$1 $2",["7"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["[56]"],"0$1"],["(\\d{3})(\\d{7})","$1 $2",["8"],"0$1"]],"0"],CV:["238","0","(?:[2-59]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2-589]"]]]],CW:["599","00","(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[3467]"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["9[4-8]"]]],0,0,0,0,0,"[69]"],CX:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\\d|7(?:0[01]|1[0-2])|958))\\d{3}",[9]],["4(?:79[01]|83[0-36-9]|95[0-3])\\d{5}|4(?:[0-36]\\d|4[047-9]|[58][0-24-9]|7[02-8]|9[0-47-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CY:["357","00","(?:[279]\\d|[58]0)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[257-9]"]]]],CZ:["420","00","(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",[9,10,11,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["96"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]]],DE:["49","00","[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}",[4,5,6,7,8,9,10,11,12,13,14,15],[["(\\d{2})(\\d{3,13})","$1 $2",["3[02]|40|[68]9"],"0$1"],["(\\d{3})(\\d{3,12})","$1 $2",["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1","2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"],"0$1"],["(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]","[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["138"],"0$1"],["(\\d{5})(\\d{2,10})","$1 $2",["3"],"0$1"],["(\\d{3})(\\d{5,11})","$1 $2",["181"],"0$1"],["(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["1(?:3|80)|9"],"0$1"],["(\\d{3})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],["(\\d{3})(\\d{7,12})","$1 $2",["8"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["18[68]"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["15[1279]"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["15[03568]","15(?:[0568]|3[13])"],"0$1"],["(\\d{3})(\\d{8})","$1 $2",["18"],"0$1"],["(\\d{3})(\\d{2})(\\d{7,8})","$1 $2 $3",["1(?:6[023]|7)"],"0$1"],["(\\d{4})(\\d{2})(\\d{7})","$1 $2 $3",["15[279]"],"0$1"],["(\\d{3})(\\d{2})(\\d{8}
vendor: 33,463 bytes, line 834
834)","$1 $2 $3",["15"],"0$1"]],"0"],DJ:["253","00","(?:2\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[27]"]]]],DK:["45","00","[2-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-9]"]]]],DM:["1","011","(?:[58]\\d\\d|767|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","767$1",0,"767"],DO:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,0,0,0,"8001|8[024]9"],DZ:["213","00","(?:[1-4]|[5-79]\\d|80)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-8]"],"0$1"]],"0"],EC:["593","00","1\\d{9,10}|(?:[2-7]|9\\d)\\d{7}",[8,9,10,11],[["(\\d)(\\d{3})(\\d{4})","$1 $2-$3",["[2-7]"],"(0$1)",0,"$1-$2-$3"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{3})(\\d{3,4})","$1 $2 $3",["1"]]],"0"],EE:["372","00","8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]|88","[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]|88"]],["(\\d{4})(\\d{3,4})","$1 $2",["[45]|8(?:00|[1-49])","[45]|8(?:00[1-9]|[1-49])"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],EG:["20","00","[189]\\d{8,9}|[24-6]\\d{8}|[135]\\d{7}",[8,9,10],[["(\\d)(\\d{7,8})","$1 $2",["[23]"],"0$1"],["(\\d{2})(\\d{6,7})","$1 $2",["1[35]|[4-6]|8[2468]|9[235-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{8})","$1 $2",["1"],"0$1"]],"0"],EH:["212","00","[5-8]\\d{8}",[9],0,"0",0,0,0,0,0,[["528[89]\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[016-8]\\d|2[0-8]|3[01]|5[0-5]))\\d{6}"],["80[0-7]\\d{6}"],["89\\d{7}"],0,0,0,0,["(?:592(?:4[0-2]|93)|80[89]\\d\\d)\\d{4}"]]],ER:["291","00","[178]\\d{6}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[178]"],"0$1"]],"0"],ES:["34","00","(?:400|[5-9]\\d\\d)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]00"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[4-9]"]]]],ET:["251","00","(?:11|[2-57-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-57-9]"],"0$1"]],"0"],FI:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",[5,6,7,8,9,10,11,12],[["(\\d{5})","$1",["20[2-59]"],"0$1"],["(\\d{3})(\\d{3,7})","$1 $2",["(?:[1-3]0|[68])0|70[07-9]"],"0$1"],["(\\d{2})(\\d{4,8})","$1 $2",["[14]|2[09]|50|7[135]"],"0$1"],["(\\d{2})(\\d{6,10})","$1 $2",["7"],"0$1"],["(\\d)(\\d{4,9})","$1 $2",["(?:19|[2568])[1-8]|3(?:0[1-9]|[1-9])|9"],"0$1"]],"0",0,0,0,0,"1[03-79]|[2-9]",0,"00"],FJ:["679","0(?:0|52)","45\\d{5}|(?:0800\\d|[235-9])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1 $2",["[235-9]|45"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]]],0,0,0,0,0,0,0,"00"],FK:["500","00","[2-7]\\d{4}",[5]],FM:["691","00","(?:[39]\\d\\d|820)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[389]"]]]],FO:["298","00","[2-9]\\d{5}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[2-9]"]]],0,0,"(10(?:01|[12]0|88))"],FR:["33","00","[1-9]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1"]],"0"],GA:["241","00","(?:[067]\\d|11)\\d{6}|[2-7]\\d{6}",[7,8],[["(\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["11|[67]"],"0$1"]],0,0,"0(11\\d{6}|60\\d{6}|61\\d{6}|6[256]\\d{6}|7[467]\\d{6})","$1"],GB:["44","00","[1-357-9]\\d{9}|[18]\\d{8}|8\\d{6}",[7,9,10],[["(\\d{3})(\\d{4})","$1 $2",["800","8001","80011","800111","8001111"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["845","8454","84546","845464"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["800"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["1(?:38|5[23]|69|76|94)","1(?:(?:38|69)7|5(?:24|39)|768|946)","1(?:3873|5(?:242|39[4-6])|(?:697|768)[347]|9467)"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["1(?:[2-69][02-9]|[78])"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[25]|7(?:0|6[02-9])","[25]|7(?:0|6(?:[03-9]|2[356]))"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[1389]"],"0$1"]],"0",0,"0|180020",0,0,0,[["(?:1(?:1(?:3(?:[0-58]\\d\\d|73[0-5])|4(?:(?:[0-5]\\d|70)\\d|69[7-9])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|5[01]))\\d)|(?:2(?:(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)\\d|1(?:[0-7]\\d|8[0-3]))|(?:3(?:0\\d|1[0-8]|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[137]\\d|[28][02-57-9]|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|[16]\\d|2[024-9]|3[015689]|4[02-9]|5[03-9]|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|1\\d|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0-24578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|[18]\\d|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|9[2-57]))\\d)\\d)|2(?:0[013478]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{3})\\d{4}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[3-5])))|3(?:6(?:38[2-5]|47[23])|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[1-3]))|5(?:2(?:4(?:3[2-79]|6\\d)|76\\d)|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[5-7]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|9(?:55[0-4]|77[23]))|7(?:26(?:6[13-9]|7[0-7])|(?:442|688)\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|843[2-58])|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}",[9,10]],["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[2-49]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]],0," x"],GD:["1","011","(?:473|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","473$1",0,"473"],GE:["995","00","(?:[3-57]\\d\\d|800)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["32"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[57]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"]],"0"],GF:["594","00","(?:694\\d|7093)\\d{5}|(?:59|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]|80[6-9]|9[47]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[89]"],"0$1"]],"0"],GG:["44","00","(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?",[7,9,10],0,"0",0,"([25-9]\\d{5})$|0|180020","1481$1",0,0,[["1481[25-9]\\d{5}",[10]],["7(?:(?:781|839)\\d|911[17])\\d{5}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[0-3]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]]],GH:["233","00","[235]\\d{8}|800\\d{5,6}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2358]"],"0$1"]],"0"],GI:["350","00","(?:[25]\\d|60)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["2"]]]],GL:["299","00","(?:19|[2-689]\\d|70)\\d{4}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["19|[2-9]"]]]],GM:["220","00","[48]\\d{8}|[2-9]\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["[235-9]|4(?:[0-35]|4[16-9])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[48]"]]]],GN:["224","00","722\\d{6}|(?:3|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]]],GP:["590","00","7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|80[6-9]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["(?:59(?:0(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1-9]|5[3-579]|[68][0-689]|7[08]|9\\d)|87\\d)|80[6-9]\\d\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],["8[129]\\d{7}"],0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\d{4}"]]],GQ:["240","00","222\\d{6}|(?:3\\d|55|[89]0)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],["(\\d{3})(\\d{6})","$1 $2",["[89]"]]]],GR:["30","00","5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",[10,11,12],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],["(\\d{4})(\\d{6})","$1 $2",["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2689]"]],["(\\d{3})(\\d{3,4})(\\d{5})","$1 $2 $3",["8"]]]],GT:["502","00","80\\d{6}|(?:1\\d{3}|[2-7])\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1 $2",["[2-8]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],GU:["1","011","(?:[58]\\d\\d|671|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","671$1",0,"671"],GW:["245","00","[49]\\d{8}|4\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["40"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"]]]],GY:["592","001","(?:[2-8]\\d{3}|9008)\\d{3}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],HK:["852","00(?:30|5[09]|[126-9]?)","8[0-46-9]\\d{6,7}|9\\d{4,7}|(?:[2-7]|9\\d{3})\\d{7}",[5,6,7,8,9,11],[["(\\d{3})(\\d{2,5})","$1 $2",["900","9003"]],["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[1-4]|9(?:0[1-9]|[1-8])"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{3})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]],0,0,0,0,0,0,0,"00"],HN:["504","00","8\\d{10}|[237-9]\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1-$2",["[237-9]"]]]],HR:["385","00","[2-69]\\d{8}|80\\d{5,7}|[1-79]\\d{7}|6\\d{6}",[7,8,9],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["6[01]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{4})(\\d{3})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6|7[245]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-57]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],"0"],HT:["509","00","[2-589]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[2-589]"]]]],HU:["36","00","[235-7]\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27][2-9]|3[2-7]|4[24-9]|5[2-79]|6|8[2-57-9]|9[2-69]"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"06 $1"]],"06"],ID:["62","00[89]","00[1-9]\\d{9,14}|(?:[1-36]|8\\d{5})\\d{6}|00\\d{9}|[1-9]\\d{8,10}|[2-9]\\d{7}",[7,8,9,10,11,12,13,14,15,16,17],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["15"]],["(\\d{2})(\\d{5,9})","$1 $2",["2[124]|[36]1"],"(0$1)"],["(\\d{3})(\\d{5,7})","$1 $2",["800"],"0$1"],["(\\d{3})(\\d{5,8})","$1 $2",["[2-79]"],"(0$1)"],["(\\d{3})(\\d{3,4})(\\d{3})","$1-$2-$3",["8[1-35-9]"],"0$1"],["(\\d{3})(\\d{6,8})","$1 $2",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["804"],"0$1"],["(\\d{3})(\\d)(\\d{3})(\\d{3})","$1 $2 $3 $4",["80"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1-$2-$3",["8"],"0$1"]],"0"],IE:["353","00","(?:1\\d|[2569])\\d{6,8}|4\\d{6,9}|7\\d{8}|8\\d{8,9}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["2[24-9]|47|58|6[237-9]|9[35-9]"],"(0$1)"],["(\\d{3})(\\d{5})","$1 $2",["[45]0"],"(0$1)"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["1"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2569]|4[1-69]|7[14]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["81"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[78]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["4"],"(0$1)"],["(\\d{2})(\\d)(\\d{3})(\\d{4})","$1 $2 $3 $4",["8"],"0$1"]],"0"],IL:["972","0(?:0|1(?:05|[2-9]))","1\\d{6}(?:\\d{3,5})?|[57]\\d{8}|[1-489]\\d{7}",[7,8,9,10,11,12],[["(\\d{4})(\\d{3})","$1-$2",["125"]],["(\\d{4})(\\d{2})(\\d{2})","$1-$2-$3",["121"]],["(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[2-489]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1-$2-$3",["12"]],["(\\d{4})(\\d{6})","$1-$2",["159"]],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3-$4",["1[7-9]"]],["(\\d{3})(\\d{1,2})(\\d{3})(\\d{4})","$1-$2 $3-$4",["15"]]],"0"],IM:["44","00","1624\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([25-8]\\d{5})$|0|180020","1624$1",0,"74576|(?:16|7[56])24"],IN:["91","00","(?:000800|[2-9]\\d\\d)\\d{7}|1\\d{7,12}",[8,9,10,11,12,13],[["(\\d{8})","$1",["5(?:0|2[23]|3[03]|[67]1|88)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|888)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|8888)"],0,1],["(\\d{4})(\\d{4,5})","$1 $2",["180","1800"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["140"],0,1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["11|2[02]|33|4[04]|79[1-6]|80[2-46]","11|2[02]|33|4[04]|79[1-6]|80(?:[2-4]|6[0-589])","11|2[02]|33|4[04]|79(?:[124-6]|3(?:[02-9]|1[0-24-9]))|80(?:[2-4]|6[0-589])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:2[0-249]|3[0-25]|4[145]|[68]|7[1257])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|5[12]|[78]1)|6(?:12|[2-4]1|5[17]|6[13]|80)|7(?:12|3[134]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67)[14]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|674|7(?:(?:3[34]|5[15])[2-6]|61[346]|88[0-8])|8(?:70[2-6]|84[235-7]|91[3-7])|(?:1(?:29|60|8[06])|261|552|6(?:12|[2-47]1|5[17]|6[13]|80)|7(?:12|31)|8(?:16|2[014]|3[126]|6[136]|7[78]|83))[2-7]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|6(?:12(?:[2-6]|7[0-8])|74[2-7])|7(?:3171|5[15][2-6]|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|8(?:16|2[014]|3[126]|6[136]|7[78]|83)(?:[2-6]|7[19])|(?:1(?:29|60|8[06])|261|552|6(?:[2-4]1|5[17]|6[13]|7(?:1|4[0189])|80)|7(?:12|88[01]))[2-7]"],"0$1",1],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2[2457-9]|3[2-5]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1[013-9]|3[129]|5[29]|6[02-5]|70)|807","1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2(?:[2457]|84|95)|3(?:[2-4]|55)|4[235-7]|5[2-689]|6[24578]|7(?:[23569]|8[0-57-9])|8[1-6])|7(?:1(?:[013-8]|9[6-9])|3(?:17|2[0-49]|9[2-57])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4|5[0-367])|70[13-7])|807[19]","1(?:[2-479]|5(?:[0236-9]|5[013-9]))|[2-5]|6(?:2(?:84|95)|355|8(?:28[235-7]|3))|73179|807(?:1|9[1-3])|(?:1552|6(?:(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578])\\d|7(?:[23569]\\d|8[0-57-9])|8(?:[14-6]\\d|2[0-79]))|7(?:1(?:[013-8]\\d|9[6-9])|3(?:2[0-49]|9[2-57])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4\\d|5[0-367])|70[13-7]))[2-7]"],"0$1",1],["(\\d{5})(\\d{5})","$1 $2",["16|[6-9]"],"0$1",1],["(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["18[06]","18[06]0"],0,1],["(\\d{4})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["18"],0,1]],"0"],IO:["246","00","3\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["3"]]]],IQ:["964","00","(?:1|7\\d\\d)\\d{7}|[2-6]\\d{7,8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-6]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],IR:["98","00","[1-9]\\d{9}|(?:[1-8]\\d\\d|9)\\d{3,4}",[4,5,6,7,10],[["(\\d{4,5})","$1",["96"],"0$1"],["(\\d{2})(\\d{4,5})","$1 $2",["(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])[12689]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[1-8]"],"0$1"]],"0"],IS:["354","00|1(?:0(?:01|[12]0)|100)","(?:38\\d|[4-9])\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["[4-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["3"]]],0,0,0,0,0,0,0,"00"],IT:["39","00","0\\d{5,11}|1\\d{8,10}|3(?:[0-8]\\d{7,10}|9\\d{7,8})|(?:43|55|70)\\d{8}|8\\d{5}(?:\\d{2,4})?",[6,7,8,9,10,11,12],[["(\\d{2})(\\d{4,6})","$1 $2",["0[26]"]],["(\\d{3})(\\d{3,6})","$1 $2",["0[13-57-9][0159]|8(?:03|4[17]|9[2-5])","0[13-57-9][0159]|8(?:03|4[17]|9(?:2|3[04]|[45][0-4]))"]],["(\\d{4})(\\d{2,6})","$1 $2",["0(?:[13-579][2-46-8]|8[236-8])"]],["(\\d{4})(\\d{4})","$1 $2",["894"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[26]|5"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["1(?:44|[679])|[378]|43"]],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[13-57-9][0159]|14"]],["(\\d{2})(\\d{4})(\\d{5})","$1 $2 $3",["0[26]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[03]"]]],0,0,0,0,0,0,[["0(?:669[0-79]\\d{1,6}|831\\d{2,8})|0(?:1(?:[0159]\\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|2\\d\\d|3(?:[0159]\\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|6(?:[0-57-9]\\d|6[0-8])|7(?:[0159]\\d|2[12]|3[1-7]|4[2-46]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\\d|2[3-578]|3[2356]|[6-8][1-5])|9(?:[0159]\\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\\d{2,7}"],["3[2-9]\\d{7,8}|(?:31|43)\\d{8}",[9,10]],["80(?:0\\d{3}|3)\\d{3}",[6,9]],["(?:0878\\d{3}|89(?:2\\d|3[04]|4(?:[0-4]|[5-9]\\d\\d)|5[0-4]))\\d\\d|(?:1(?:44|6[346])|89(?:38|5[5-9]|9))\\d{6}",[6,8,9,10]],["1(?:78\\d|99)\\d{6}",[9,10]],["3[2-8]\\d{9,10}",[11,12]],0,0,["55\\d{8}",[10]],["84(?:[08]\\d{3}|[17])\\d{3}",[6,9]]]],JE:["44","00","1534\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([0-24-8]\\d{5})$|0|180020","1534$1",0,0,[["1534[0-24-8]\\d{5}"],["7(?:(?:(?:50|82)9|937)\\d|7(?:00[378]|97\\d))\\d{5}"],["80(?:07(?:35|81)|8901)\\d{4}"],["(?:8(?:4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|90(?:066[59]|1810|71(?:07|55)))\\d{4}"],["701511\\d{4}"],0,["(?:3(?:0(?:07(?:35|81)|8901)|3\\d{4}|4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|55\\d{4})\\d{4}"],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}"],["56\\d{8}"]]],JM:["1","011","(?:[58]\\d\\d|658|900)\\d{7}",[10],0,"1",0,0,0,0,"658|876"],JO:["962","00","(?:(?:[2689]|7\\d)\\d|32|427|53)\\d{6}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2356]|87"],"(0$1)"],["(\\d{3})(\\d{5,6})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["70"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[47]"],"0$1"]],"0"],JP:["81","010","00[1-9]\\d{6,14}|[25-9]\\d{9}|(?:00|[1-9]\\d\\d)\\d{6}",[8,9,10,11,12,13,14,15,16,17],[["(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1"],["(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|499|5(?:76|97)|746|8(?:3[89]|47|51)|9(?:80|9[16])","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:76|97)9|7468|8(?:3(?:8[7-9]|96)|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:769|979[2-69])|7468|8(?:3(?:8[7-9]|96[2457-9])|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["3|4(?:2[09]|7[01])|6[1-9]","3|4(?:2(?:0|9[02-69])|7(?:0[019]|1))|6[1-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1(?:1|5[45]|77|88|9[69])|2(?:2[1-37]|3[0-269]|4[59]|5|6[24]|7[1-358]|8[1369]|9[0-38])|4(?:[28][1-9]|3[0-57]|[45]|6[248]|7[2-579]|9[29])|5(?:2|3[0459]|4[0-369]|5[29]|8[02389]|9[0-389])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9[2-6])|8(?:2[124589]|3[26-9]|49|51|6|7[0-468]|8[68]|9[019])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9[1-489])","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2(?:[127]|3[014-9])|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9[19])|62|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|8[1-9]|9[29])|5(?:2|3(?:[045]|9[0-8])|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0-2469])|3(?:[29]|60)|49|51|6(?:[0-24]|36|5[0-3589]|7[23]|9[01459])|7[0-468]|8[68])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3[34]|4[0178]))|(?:264|837)[016-9]|2(?:57|93)[015-9]|(?:25[0468]|422|838)[01]|(?:47[59]|59[89]|8(?:6[68]|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3(?:[045]|9(?:[0-58]|6[4-9]|7[0-35689]))|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0169])|3(?:[29]|60|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[2-57-9]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|7(?:2[2-468]|3[78])|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:8294|96)[1-3]|2(?:57|93)[015-9]|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|8292|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]"],"0$1"],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["[14]|[289][2-9]|5[3-9]|7[2-4679]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[25-9]"],"0$1"]],"0",0,"(000[2569]\\d{4,6})$|(?:(?:003768)0?)|0","$1"],KE:["254","000","(?:[17]\\d\\d|900)\\d{6}|(?:2|80)0\\d{6,7}|[4-6]\\d{6,8}",[7,8,9,10],[["(\\d{2})(\\d{5,7})","$1 $2",["[24-6]"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[17]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0"],KG:["996","00","8\\d{9}|[235-9]\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["3(?:1[346]|[24-79])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-79]|88"],"0$1"],["(\\d{3})(\\d{3})(\\d)(\\d{2,3})","$1 $2 $3 $4",["8"],"0$1"]],"0"],KH:["855","00[14-9]","1\\d{9}|[1-9]\\d{7,8}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],KI:["686","00","(?:[37]\\d|6[0-79])\\d{6}|(?:[2-48]\\d|50)\\d{3}",[5,8],0,"0"],KM:["269","00","[3478]\\d{6}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[3478]"]]]],KN:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","869$1",0,"869"],KP:["850","00|99","85\\d{6}|(?:19\\d|[2-7])\\d{7}",[8,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"]],"0"],KR:["82","00(?:[125689]|3(?:[46]5|91)|7(?:00|27|3|55|6[126]))","00[1-9]\\d{8,11}|(?:[12]|5\\d{3})\\d{7}|[13-6]\\d{9}|(?:[1-6]\\d|80)\\d{7}|[3-6]\\d{4,5}|(?:00|7)0\\d{8}",[5,6,8,9,10,11,12,13,14],[["(\\d{2})(\\d{3,4})","$1-$2",["(?:3[1-3]|[46][1-4]|5[1-5])1"],"0$1"],["(\\d{4})(\\d{4})","$1-$2",["1"]],["(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[36]0|8"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["[1346]|5[1-5]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{2})(\\d{5})(\\d{4})","$1-$2-$3",["5"],"0$1"]],"0",0,"0(8(?:[1-46-8]|5\\d\\d))?"],KW:["965","00","18\\d{5}|(?:[2569]\\d|41)\\d{6}",[7,8],[["(\\d{4})(\\d{3,4})","$1 $2",["[169]|2(?:[235]|4[1-35-9])|52"]],["(\\d{3})(\\d{5})","$1 $2",["[245]"]]]],KY:["1","011","(?:345|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","345$1",0,"345"],KZ:["7","810","8\\d{13}|[78]\\d{9}",[10,14],0,"8",0,0,0,0,"7",0,"8~10"],LA:["856","00","[23]\\d{9}|3\\d{8}|(?:[235-8]\\d|41)\\d{6}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2[13]|3[14]|[4-8]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["3"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[23]"],"0$1"]],"0"],LB:["961","00","[27-9]\\d{7}|[13-9]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[13-69]|7(?:[2-57]|62|8[0-6]|9[04-9])|8[02-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27-9]"]]],"0"],LC:["1","011","(?:[58]\\d\\d|758|900)\\d{7}",[10],0,"1",0,"([2-8]\\d{6})$|1","758$1",0,"758"],LI:["423","00","[68]\\d{8}|(?:[2378]\\d|90)\\d{5}",[7,9],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2379]|8(?:0[09]|7)","[2379]|8(?:0(?:02|9)|7)"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["69"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]],"0",0,"(1001)|0"],LK:["94","00","[1-9]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[1-689]"],"0$1"]],"0"],LR:["231","00","(?:[2457]\\d|33|88)\\d{7}|(?:2\\d|[4-6])\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["4[67]|[56]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-578]"],"0$1"]],"0"],LS:["266","00","(?:[256]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2568]"]]]],LT:["370","00","(?:[3469]\\d|52|[78]0)\\d{6}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["52[0-7]"],"(0-$1)",1],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"0 $1",1],["(\\d{2})(\\d{6})","$1 $2",["37|4(?:[15]|6[1-8])"],"(0-$1)",1],["(\\d{3})(\\d{5})","$1 $2",["[3-6]"],"(0-$1)",1]],"0",0,"[08]"],LU:["352","00","35[013-9]\\d{4,8}|6\\d{8}|35\\d{2,4}|(?:[2457-9]\\d|3[0-46-9])\\d{2,9}",[4,5,6,7,8,9,10,11],[["(\\d{2})(\\d{3})","$1 $2",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["20[2-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4",["20"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,5})","$1 $2 $3 $4",["[3-57]|8[13-9]|9(?:0[89]|[2-579])|(?:2|80)[2-9]"]],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["80[01]|90[015]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["20"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4 $5",["20"]]],0,0,"(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)"],LV:["371","00","(?:[268]\\d|78|90)\\d{6}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2679]|8[01]"]]]],LY:["218","00","[2-9]\\d{8}",[9],[["(\\d{2})(\\d{7})","$1-$2",["[2-9]"],"0$1"]],"0"],MA:["212","00","[5-8]\\d{8}",[9],[["(\\d{4})(\\d{5})","$1-$2",["892"],"0$1"],["(\\d{2})(\\d{7})","$1-$2",["8(?:0[0-7]|9)"],"0$1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[5-8]"],"0$1"]],"0",0,0,0,0,"[5-8]"],MC:["377","00","(?:[3489]|[67]\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["4"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[389]"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[67]"],"0$1"]],"0"],MD:["373","00","(?:[235-7]\\d|[89]0)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["22|3"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[25-7]"],"0$1"]],"0"],ME:["382","00","(?:20|[3-79]\\d)\\d{6}|80\\d{6,7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"0$1"]],"0"],MF:["590","00","7090\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["(?:59(?:0(?:0[079]|[14]3|[27][79]|3[03-7]|5[0-268]|87)|87\\d)|80[6-9]\\d\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5]))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],["8[129]\\d{7}"],0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\d{4}"]]],MG:["261","00","[23]\\d{8}",[9],[["(\\d{2})(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,"([24-9]\\d{6})$|0","20$1"],MH:["692","011","329\\d{4}|(?:[256]\\d|45)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1-$2",["[2-6]"]]],"1"],MK:["389","00","[2-578]\\d{7}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2|34[47]|4(?:[37]7|5[47]|64)"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],"0"],ML:["223","00","[24-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-9]"]]]],MM:["95","00","1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}",[6,7,8,9,10],[["(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["4(?:[2-46]|5[3-5])|5|6(?:[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-5]|(?:60|86)[23]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|452|678|86","[12]|452|6788|86"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[4-7]|8[1-35]"],"0$1"],["(\\d)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92"],"0$1"],["(\\d)(\\d{5})(\\d{4})","$1 $2 $3",["9"],"0$1"]],"0"],MN:["976","001","[12]\\d{7,9}|[5-9]\\d{7}",[8,9,10],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["11|2[16]"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[5-9]"]],["(\\d{3})(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["[12](?:27|3[2-8]|4[2-68]|5[1-4689])","[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["[12]"],"0$1"]],"0"],MO:["853","00","0800\\d{3}|(?:28|[68]\\d)\\d{6}",[7,8],[["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{4})(\\d{4})","$1 $2",["[268]"]]]],MP:["1","011","[58]\\d{9}|(?:67|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","670$1",0,"670"],MQ:["596","00","7091\\d{5}|(?:[56]9|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|8(?:0[6-9]|[36])"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],MR:["222","00","(?:[2-4]\\d\\d|800)\\d{5}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-48]"]]]],MS:["1","011","(?:[58]\\d\\d|664|900)\\d{7}",[10],0,"1",0,"([34]\\d{6})$|1","664$1",0,"664"],MT:["356","00","3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2357-9]"]]]],MU:["230","0(?:0|[24-7]0|3[03])","(?:[57]|8\\d\\d)\\d{7}|[2-468]\\d{6}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[2-46]|8[013]"]],["(\\d{4})(\\d{4})","$1 $2",["[57]"]],["(\\d{5})(\\d{5})","$1 $2",["8"]]],0,0,0,0,0,0,0,"020"],MV:["960","0(?:0|19)","(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}",[7,10],[["(\\d{3})(\\d{4})","$1-$2",["[34679]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,0,"00"],MW:["265","00","(?:[1289]\\d|31|77)\\d{7}|1\\d{6}",[7,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[2-9]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-37-9]"],"0$1"]],"0"],MX:["52","0[09]","[2-9]\\d{9}",[10],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|5[56]|81"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2-9]"]]],0,0,0,0,0,0,0,"00"],MY:["60","00","1\\d{8,9}|(?:3\\d|[4-9])\\d{7}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["[4-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1-$2 $3",["1(?:[02469]|[378][1-9]|53)|8","1(?:[02469]|[37][1-9]|53|8(?:[1-46-9]|5[7-9]))|8"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2 $3",["3"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3-$4",["1(?:[367]|80)"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2 $3",["15"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2 $3",["1"],"0$1"]],"0"],MZ:["258","00","(?:2|8\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2|8[2-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],NA:["264","00","[68]\\d{7,8}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["87"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],NC:["687","00","(?:050|[2-57-9]\\d\\d)\\d{3}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1.$2.$3",["[02-57-9]"]]]],NE:["227","00","[027-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["08"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[089]|2[013]|7[0467]"]]]],NF:["672","00","[13]\\d{5}",[6],[["(\\d{2})(\\d{4})","$1 $2",["1[0-3]"]],["(\\d)(\\d{5})","$1 $2",["[13]"]]],0,0,"([0-258]\\d{4})$","3$1"],NG:["234","009","(?:20|9\\d)\\d{8}|[78]\\d{9,13}",[10,11,12,13,14],[["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["20[129]"],"0$1"],["(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]"],"0$1"],["(\\d{3})(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]"],"0$1"]],"0"],NI:["505","00","(?:1800|[25-8]\\d{3})\\d{4}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[125-8]"]]]],NL:["31","00","(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}",[5,6,7,8,9,10,11],[["(\\d{3})(\\d{4,7})","$1 $2",["[89]0"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["66"],"0$1"],["(\\d)(\\d{8})","$1 $2",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-578]|91"],"0$1"],["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3",["9"],"0$1"]],"0"],NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]"],NP:["977","00","(?:1\\d|9)\\d{9}|[1-9]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],["(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-59]|[67][2-6])"],"0$1"],["(\\d{3})(\\d{7})","$1-$2",["9"]]],"0"],NR:["674","00","(?:222|444|(?:55|8\\d)\\d|666|777|999)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[24-9]"]]]],NU:["683","00","(?:[4-7]|888\\d)\\d{3}",[4,7],[["(\\d{3})(\\d{4})","$1 $2",["8"]]]],NZ:["64","0(?:0|161)","[1289]\\d{9}|50\\d{5}
vendor: 23,715 bytes, line 834
834(?:\\d{2,3})?|[27-9]\\d{7,8}|(?:[34]\\d|6[0-35-9])\\d{6}|8\\d{4,6}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,8})","$1 $2",["8[1-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["50[036-8]|8|90","50(?:[0367]|88)|8|90"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["24|[346]|7[2-57-9]|9[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:10|74)|[589]"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["1|2[028]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,5})","$1 $2 $3",["2(?:[169]|7[0-35-9])|7"],"0$1"]],"0",0,0,0,0,0,0,"00"],OM:["968","00","(?:1505|[279]\\d{3}|500)\\d{4}|800\\d{5,6}",[7,8,9],[["(\\d{3})(\\d{4,6})","$1 $2",["[58]"]],["(\\d{2})(\\d{6})","$1 $2",["2"]],["(\\d{4})(\\d{4})","$1 $2",["[179]"]]]],PA:["507","00","(?:00800|8\\d{3})\\d{6}|[68]\\d{7}|[1-57-9]\\d{6}",[7,8,10,11],[["(\\d{3})(\\d{4})","$1-$2",["[1-57-9]"]],["(\\d{4})(\\d{4})","$1-$2",["[68]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]]],PE:["51","00|19(?:1[124]|77|90)00","(?:[14-8]|9\\d)\\d{7}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["80"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["1"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[4-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"]]],"0",0,0,0,0,0,0,"00"," Anexo "],PF:["689","00","4\\d{5}(?:\\d{2})?|8\\d{7,8}",[6,8,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["44"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4|8[7-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],PG:["675","00|140[1-3]","(?:180|[78]\\d{3})\\d{4}|(?:[2-589]\\d|64)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["18|[2-69]|85[02-46-9]"]],["(\\d{4})(\\d{4})","$1 $2",["[78]"]]],0,0,0,0,0,0,0,"00"],PH:["63","00","(?:[2-7]|9\\d)\\d{8}|2\\d{5}|(?:1800|8)\\d{7,9}",[6,8,9,10,11,12,13],[["(\\d)(\\d{5})","$1 $2",["2"],"(0$1)"],["(\\d{4})(\\d{4,6})","$1 $2",["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|544|88[245]|(?:52|64|86)2","3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"],"(0$1)"],["(\\d{5})(\\d{4})","$1 $2",["346|4(?:27|9[35])|883","3469|4(?:279|9(?:30|56))|8834"],"(0$1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|8[2-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{4})(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1"]]],"0"],PK:["92","00","122\\d{6}|[24-8]\\d{10,11}|9(?:[013-9]\\d{8,10}|2(?:[01]\\d\\d|2(?:[06-8]\\d|1[01]))\\d{7})|(?:[2-8]\\d{3}|92(?:[0-7]\\d|8[1-9]))\\d{6}|[24-9]\\d{8}|[89]\\d{7}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,7})","$1 $2 $3",["[89]0"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["1"]],["(\\d{3})(\\d{6,7})","$1 $2",["2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8])","9(?:2[3-8]|98)|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:22|3[27-9]|4[2-6]|6[3569]|9[25-7]))[2-9]"],"(0$1)"],["(\\d{2})(\\d{7,8})","$1 $2",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"],"(0$1)"],["(\\d{5})(\\d{5})","$1 $2",["58"],"(0$1)"],["(\\d{3})(\\d{7})","$1 $2",["3"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[24-9]"],"(0$1)"]],"0"],PL:["48","00","(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}",[6,7,8,9,10],[["(\\d{5})","$1",["19"]],["(\\d{3})(\\d{3})","$1 $2",["11|20|64"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["30|(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])1","30|(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])19"]],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["64"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["21|39|45|5[0137]|6[0469]|7[02389]|8(?:0[14]|8)"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[2-8]|[2-7]|8[1-79]|9[145]"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["8"]]]],PM:["508","00","[78]\\d{8}|[2-9]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],PR:["1","011","(?:[589]\\d\\d|787)\\d{7}",[10],0,"1",0,0,0,0,"787|939"],PS:["970","00","[2489]2\\d{6}|(?:1\\d|5)\\d{8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2489]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["5"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],PT:["351","00","1693\\d{5}|(?:[26-9]\\d|30)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["2[12]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["16|[236-9]"]]]],PW:["680","01[12]","(?:[24-8]\\d\\d|345|900)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],PY:["595","00","[36-8]\\d{5,8}|4\\d{6,8}|59\\d{6}|9\\d{5,10}|(?:2\\d|5[0-8])\\d{6,7}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3,6})","$1 $2",["[2-9]0"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["3[289]|4[246-8]|61|7[1-3]|8[1-36]"],"(0$1)"],["(\\d{3})(\\d{4,5})","$1 $2",["2[279]|3[13-5]|4[359]|5|6(?:[34]|7[1-46-8])|7[46-8]|85"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2[14-68]|3[26-9]|4[1246-8]|6(?:1|75)|7[1-35]|8[1-36]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["87"]],["(\\d{3})(\\d{6})","$1 $2",["9(?:[5-79]|8[1-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["9"]]],"0"],QA:["974","00","800\\d{4}|(?:2|800)\\d{6}|(?:0080|[3-7])\\d{7}",[7,8,9,11],[["(\\d{3})(\\d{4})","$1 $2",["2[136]|8"]],["(\\d{4})(\\d{4})","$1 $2",["[3-7]"]]]],RE:["262","00","709\\d{6}|(?:26|[689]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"],"0$1"]],"0",0,0,0,0,0,[["2631[0-6]\\d{4}|26(?:2\\d|30|88)\\d{5}"],["(?:69(?:2\\d\\d|3(?:[06][0-6]|1[0-3]|2[0-2]|3[0-39]|4\\d|5[0-5]|7[0-37]|8[0-8]|9[0-479]))|7092[0-3])\\d{4}"],["80\\d{7}"],["89[1-37-9]\\d{6}"],0,0,0,0,["9(?:399[0-3]|479[0-6]|76(?:2[278]|3[0-37]))\\d{4}"],["8(?:1[019]|2[0156]|84|90)\\d{6}"]]],RO:["40","00","(?:[236-8]\\d|90)\\d{7}|[23]\\d{5}",[6,9],[["(\\d{3})(\\d{3})","$1 $2",["2[3-6]","2[3-6]\\d9"],"0$1"],["(\\d{2})(\\d{4})","$1 $2",["219|31"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23]1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[236-9]"],"0$1"]],"0",0,0,0,0,0,0,0," int "],RS:["381","00","38[02-9]\\d{6,9}|6\\d{7,9}|90\\d{4,8}|38\\d{5,6}|(?:7\\d\\d|800)\\d{3,9}|(?:[12]\\d|3[0-79])\\d{5,10}",[6,7,8,9,10,11,12],[["(\\d{3})(\\d{3,9})","$1 $2",["(?:2[389]|39)0|[7-9]"],"0$1"],["(\\d{2})(\\d{5,10})","$1 $2",["[1-36]"],"0$1"]],"0"],RU:["7","810","8\\d{13}|[347-9]\\d{9}",[10,14],[["(\\d{4})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-8]|2[1-9])","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:1[23]|[2-9]2))","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:13[03-69]|62[013-9]))|72[1-57-9]2"],"8 ($1)",1],["(\\d{5})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-68]|2[1-9])","7(?:1(?:[06][3-6]|[18]|2[35]|[3-5][3-5])|2(?:[13][3-5]|[24-689]|7[457]))","7(?:1(?:0(?:[356]|4[023])|[18]|2(?:3[013-9]|5)|3[45]|43[013-79]|5(?:3[1-8]|4[1-7]|5)|6(?:3[0-35-9]|[4-6]))|2(?:1(?:3[178]|[45])|[24-689]|3[35]|7[457]))|7(?:14|23)4[0-8]|71(?:33|45)[1-79]"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[349]|8(?:[02-7]|1[1-8])"],"8 ($1)",1],["(\\d{4})(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3 $4",["8"],"8 ($1)"]],"8",0,0,0,0,"[3489]",0,"8~10"],RW:["250","00","(?:06|[27]\\d\\d|[89]00)\\d{6}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"]],"0"],SA:["966","00","(?:[15]\\d|800|92)\\d{7}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["9"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]],"0"],SB:["677","0[01]","[6-9]\\d{6}|[1-6]\\d{4}",[5,7],[["(\\d{2})(\\d{5})","$1 $2",["6[89]|7|8[4-9]|9(?:[1-8]|9[0-8])"]]]],SC:["248","010|0[0-2]","(?:[2489]\\d|64)\\d{5}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[246]|9[57]"]]],0,0,0,0,0,0,0,"00"],SD:["249","00","[19]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[19]"],"0$1"]],"0"],SE:["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10,12],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0"],SG:["65","0[0-3]\\d","(?:(?:1\\d|8)\\d\\d|7000)\\d{7}|[3689]\\d{7}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["[369]|8(?:0[1-9]|[1-9])"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]],["(\\d{4})(\\d{4})(\\d{3})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],SH:["290","00","(?:[256]\\d|8)\\d{3}",[4,5],0,0,0,0,0,0,"[256]"],SI:["386","00|10(?:22|66|88|99)","[1-7]\\d{7}|8\\d{4,7}|90\\d{4,6}",[5,6,7,8],[["(\\d{2})(\\d{3,6})","$1 $2",["8[09]|9"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["59|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37][01]|4[013]|51|6"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-57]"],"(0$1)"]],"0",0,0,0,0,0,0,"00"],SJ:["47","00","0\\d{4}|(?:[489]\\d|79)\\d{6}",[5,8],0,0,0,0,0,0,"79"],SK:["421","00","[2-689]\\d{8}|[2-59]\\d{6}|[2-5]\\d{5}",[6,7,9],[["(\\d)(\\d{2})(\\d{3,4})","$1 $2 $3",["21"],"0$1"],["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["[3-5][1-8]1","[3-5][1-8]1[67]"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[689]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[3-5]"],"0$1"]],"0"],SL:["232","00","(?:[237-9]\\d|66)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[236-9]"],"(0$1)"]],"0"],SM:["378","00","(?:0549|[5-7]\\d)\\d{6}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"]],["(\\d{4})(\\d{6})","$1 $2",["0"]]],0,0,"([89]\\d{5})$","0549$1"],SN:["221","00","(?:[378]\\d|93)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[379]"]]]],SO:["252","00","[346-9]\\d{8}|[12679]\\d{7}|[1-5]\\d{6}|[1348]\\d{5}",[6,7,8,9],[["(\\d{2})(\\d{4})","$1 $2",["8[125]"]],["(\\d{6})","$1",["[134]"]],["(\\d)(\\d{6})","$1 $2",["[15]|2[0-79]|3[0-46-8]|4[0-7]"]],["(\\d{2})(\\d{5,7})","$1 $2",["1|28|9[2-9]"]],["(\\d)(\\d{7})","$1 $2",["[267]|904"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[346-9]"]]],"0"],SR:["597","00","(?:[2-5]|[6-9]\\d)\\d{5}",[6,7],[["(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3",["56"]],["(\\d{3})(\\d{3})","$1-$2",["[2-5]"]],["(\\d{3})(\\d{4})","$1-$2",["[6-9]"]]]],SS:["211","00","[19]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[19]"],"0$1"]],"0"],ST:["239","00","(?:22|9\\d)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[29]"]]]],SV:["503","00","[25-7]\\d{7}|(?:80\\d|900)\\d{4}(?:\\d{4})?",[7,8,11],[["(\\d{3})(\\d{4})","$1 $2",["[89]"]],["(\\d{4})(\\d{4})","$1 $2",["[25-7]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]]],SX:["1","011","7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"(5\\d{6})$|1","721$1",0,"721"],SY:["963","00","[1-359]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-4]|5[1-3]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[59]"],"0$1",1]],"0"],SZ:["268","00","0800\\d{4}|(?:[237]\\d|900)\\d{6}",[8,9],[["(\\d{4})(\\d{4})","$1 $2",["[0237]"]],["(\\d{5})(\\d{4})","$1 $2",["9"]]]],TA:["290","00","8\\d{3}",[4],0,0,0,0,0,0,"8"],TC:["1","011","(?:[58]\\d\\d|649|900)\\d{7}",[10],0,"1",0,"([2-479]\\d{6})$|1","649$1",0,"649"],TD:["235","00|16","(?:22|[3689]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[236-9]"]]],0,0,0,0,0,0,0,"00"],TG:["228","00","[279]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[279]"]]]],TH:["66","00[1-9]","(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}",[8,9,10,13],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],TJ:["992","810","(?:[0-57-9]\\d|66)\\d{7}",[9],[["(\\d{6})(\\d)(\\d{2})","$1 $2 $3",["331","3317"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["44[02-479]|[34]7"]],["(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["3(?:[1245]|3[12])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["\\d"]]],0,0,0,0,0,0,0,"8~10"],TK:["690","00","[2-47]\\d{3,6}",[4,5,6,7]],TL:["670","00","7\\d{7}|(?:[2-47]\\d|[89]0)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[2-489]|70"]],["(\\d{4})(\\d{4})","$1 $2",["7"]]]],TM:["993","810","[1-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["12"],"(8 $1)"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-5]"],"(8 $1)"],["(\\d{2})(\\d{6})","$1 $2",["[67]"],"8 $1"]],"8",0,0,0,0,0,0,"8~10"],TN:["216","00","[2-57-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-57-9]"]]]],TO:["676","00","(?:0800|(?:[5-8]\\d\\d|999)\\d)\\d{3}|[2-8]\\d{4}",[5,7],[["(\\d{2})(\\d{3})","$1-$2",["[2-4]|50|6[09]|7[0-24-69]|8[05]"]],["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[5-9]"]]]],TR:["90","00","4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",[7,10,12,13],[["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["512|8[01589]|90"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24][1-8]|3[1-9]"],"(0$1)",1],["(\\d{3})(\\d{3})(\\d{6,7})","$1 $2 $3",["80"],"0$1",1]],"0"],TT:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-46-8]\\d{6})$|1","868$1",0,"868"],TV:["688","00","(?:2|7\\d\\d|90)\\d{4}",[5,6,7],[["(\\d{2})(\\d{3})","$1 $2",["2"]],["(\\d{2})(\\d{4})","$1 $2",["90"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],TW:["886","0(?:0[25-79]|19)","[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}",[7,8,9,10,11],[["(\\d{2})(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["826"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["83"],"0$1"],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["82"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[25]0|37|49|8[09]"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-478])|7[1-9]","[23568]|4(?:0[2-48]|[1-478])|(?:400|7)[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,5})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,0,0,"#"],TZ:["255","00[056]","(?:[25-8]\\d|41|90)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["5"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"]],"0"],UA:["380","00","[89]\\d{9}|[3-9]\\d{8}",[9,10],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]","6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6[0135689]|7[4-6])|6(?:[12][3-7]|[459])","3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6(?:[015689]|3[02389])|7[4-6])|6(?:[12][3-7]|[459])"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|89|9[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,0,"0~0"],UG:["256","00[057]","800\\d{6}|(?:[29]0|[347]\\d)\\d{7}",[9],[["(\\d{4})(\\d{5})","$1 $2",["202","2024","20240"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["20[0-35-7]|4(?:6[45]|[7-9])|[7-9]","20(?:[0135-7]|2[5-9])|4(?:6[45]|[7-9])|[7-9]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[2-4]"],"0$1"]],"0"],US:["1","011","[2-9]\\d{9}|3\\d{6}",[10],[["(\\d{3})(\\d{4})","$1-$2",["310"],0,1],["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],0,1,"$1-$2-$3"]],"1",0,0,0,0,0,[["(?:472[2-47-9]|983[2-57-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[02469]|8[13])|3(?:0[1-57-9]|1[02-9]|2[013-79]|3[0-24679]|4[167]|5[0-3]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-269])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-2478]|4[0378]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-3589]|8[04-69]))[2-9]\\d{6}"],[""],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}"],["900[2-9]\\d{6}"],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|5(?:00|2[125-9]|3[23]|44|66|77|88)[2-9]\\d{6}"]]],UY:["598","0(?:0|1[3-9]\\d)","0004\\d{2,9}|[1249]\\d{7}|2\\d{3,4}|(?:[49]\\d|80)\\d{5}",[4,5,6,7,8,9,10,11,12,13],[["(\\d{4,5})","$1",["21"]],["(\\d{3})(\\d{3,4})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[49]0|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[124]"]],["(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3 $4",["0"]]],"0",0,0,0,0,0,0,"00"," int. "],UZ:["998","00","(?:20|33|[5-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-9]"]]]],VA:["39","00","0\\d{5,10}|3[0-8]\\d{7,10}|55\\d{8}|8\\d{5}(?:\\d{2,4})?|(?:1\\d|39)\\d{7,8}",[6,7,8,9,10,11,12],0,0,0,0,0,0,"06698"],VC:["1","011","(?:[58]\\d\\d|784|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","784$1",0,"784"],VE:["58","00","[68]00\\d{7}|(?:[24]\\d|[59]0)\\d{8}",[10],[["(\\d{3})(\\d{7})","$1-$2",["[24-689]"],"0$1"]],"0"],VG:["1","011","(?:284|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-578]\\d{6})$|1","284$1",0,"284"],VI:["1","011","[58]\\d{9}|(?:34|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","340$1",0,"340"],VN:["84","00","[12]\\d{9}|[135-9]\\d{8}|[16]\\d{6,7}|7\\d{6}",[7,8,9,10],[["(\\d{4})(\\d{4,6})","$1 $2",["1(?:2[02]|[89])"],0,1],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[26]|6"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[357-9]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["2[48]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["2"],"0$1",1]],"0"],VU:["678","00","[57-9]\\d{6}|(?:[238]\\d|48)\\d{3}",[5,7],[["(\\d{3})(\\d{4})","$1 $2",["[57-9]"]]]],WF:["681","00","(?:40|72|8\\d{4})\\d{4}|[89]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[47-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],WS:["685","0","(?:[2-6]|8\\d{5})\\d{4}|[78]\\d{6}|[68]\\d{5}",[5,6,7,10],[["(\\d{5})","$1",["[2-5]|6[1-9]"]],["(\\d{3})(\\d{3,7})","$1 $2",["[68]"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],XK:["383","00","2\\d{7,8}|3\\d{7,11}|(?:4\\d\\d|[89]00)\\d{5}",[8,9,10,11,12],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2|39"],"0$1"],["(\\d{2})(\\d{7,10})","$1 $2",["3"],"0$1"]],"0"],YE:["967","00","(?:1|7\\d)\\d{7}|[1-7]\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-6]|7(?:[24-6]|8[0-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1"]],"0"],YT:["262","00","(?:639\\d|7093)\\d{5}|(?:26|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["26(?:89\\d|9(?:0[0-467]|15|5[0-4]|6\\d|[78]0))\\d{4}"],["(?:639(?:0[0-79]|1[019]|[267]\\d|3[09]|40|5[05-9]|9[04-79])|7093[5-7])\\d{4}"],["80\\d{7}"],0,0,0,0,0,["9(?:(?:39|47)8[01]|769\\d)\\d{4}"]]],ZA:["27","00","[1-79]\\d{8}|8\\d{4,9}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,4})","$1 $2",["8[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["8[1-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["860"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],ZM:["260","00","800\\d{6}|(?:21|[579]\\d|63)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[28]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[579]"],"0$1"]],"0"],ZW:["263","00","(?:13|8\\d{4})\\d{5}|[235-8]\\d{8}|[2-689]\\d{6}",[7,9,10],[["(\\d{2})(\\d{3,5})","$1 $2",["1|2(?:0[0-36-9]|29|58)|67[0-46-9]|(?:55|68)[0-69]"],"0$1"],["(\\d{3})(\\d{3,5})","$1 $2",["2(?:0[45]|[27]|48)|37|675|(?:55|68)[78]"],"0$1"],["(\\d)(\\d{3})(\\d{2,4})","$1 $2 $3",["[49]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["80"],"0$1"],["(\\d{4})(\\d{3,5})","$1 $2",["548"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["29[013-9]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[256]|39|8[13-59]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["3"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["8"],"0$1"]],"0"]},nonGeographic:{800:["800",0,"(?:00|[1-9]\\d)\\d{6}",[8],[["(\\d{4})(\\d{4})","$1 $2",["\\d"]]],0,0,0,0,0,0,[0,0,["(?:00|[1-9]\\d)\\d{6}"]]],808:["808",0,"[1-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[1-9]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,0,["[1-9]\\d{7}"]]],870:["870",0,"7\\d{11}|[235-7]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-7]"]]],0,0,0,0,0,0,[0,["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"],0,0,0,0,0,0,["2\\d{8}",[9]]]],878:["878",0,"10\\d{10}",[12],[["(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3",["1"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["10\\d{10}"]]],881:["881",0,"6\\d{9}|[0-36-9]\\d{8}",[9,10],[["(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[0-37-9]"]],["(\\d)(\\d{3})(\\d{5,6})","$1 $2 $3",["6"]]],0,0,0,0,0,0,[0,["6\\d{9}|[0-36-9]\\d{8}"]]],882:["882",0,"[13]\\d{6}(?:\\d{2,5})?|[19]\\d{7}|(?:[25]\\d\\d|4)\\d{7}(?:\\d{2})?",[7,8,9,10,11,12],[["(\\d{2})(\\d{5})","$1 $2",["16|342"]],["(\\d{2})(\\d{6})","$1 $2",["49"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["1[36]|9"]],["(\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["3[23]"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["16"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|23|3(?:[15]|4[57])|4|5[12]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["34"]],["(\\d{2})(\\d{4,5})(\\d{5})","$1 $2 $3",["[1-35]"]]],0,0,0,0,0,0,[0,["342\\d{4}|(?:337|49)\\d{6}|(?:3(?:2|47|7\\d{3})|5(?:0\\d{3}|2[0-2]))\\d{7}",[7,8,9,10,12]],0,0,0,["348[57]\\d{7}",[11]],0,0,["1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15-8]|9[0689])\\d{4}|6\\d{5,10})|(?:345\\d|9[89])\\d{6}|(?:10|2(?:3|85\\d)|3(?:[15]|[69]\\d\\d)|4[15-8]|51)\\d{8}"]]],883:["883",0,"(?:[1-4]\\d|51)\\d{6,10}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,8})","$1 $2 $3",["[14]|2[24-689]|3[02-689]|51[24-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["510"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["21"]],["(\\d{4})(\\d{4})(\\d{4})","$1 $2 $3",["51[13]"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[235]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["(?:2(?:00\\d\\d|10)|(?:370[1-9]|51\\d0)\\d)\\d{7}|51(?:00\\d{5}|[24-9]0\\d{4,7})|(?:1[0-79]|2[24-689]|3[02-689]|4[0-4])0\\d{5,9}"]]],888:["888",0,"\\d{11}",[11],[["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3"]],0,0,0,0,0,0,[0,0,0,0,0,0,["\\d{11}"]]],979:["979",0,"[1359]\\d{8}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[1359]"]]],0,0,0,0,0,0,[0,0,0,["[1359]\\d{8}"]]]}};function
vendor: 13,273 bytes, lines 834-835
834$ue(e,s){var r=Array.prototype.slice.call(s);return r.push(kue),e.apply(this,r)}function CC(e,s){e=e.split("-"),s=s.split("-");for(var r=e[0].split("."),n=s[0].split("."),a=0;a<3;a++){var i=Number(r[a]),o=Number(n[a]);if(i>o)return 1;if(o>i)return-1;if(!isNaN(i)&&isNaN(o))return 1;if(isNaN(i)&&!isNaN(o))return-1}return e[1]&&s[1]?e[1]>s[1]?1:e[1]<s[1]?-1:0:!e[1]&&s[1]?1:e[1]&&!s[1]?-1:0}var Eue={}.constructor;function Md(e){return e!=null&&e.constructor===Eue}var Pue=/^\d+$/;function Aue(e){return Pue.test(e)}function vu(e){"@babel/helpers - typeof";return vu=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},vu(e)}function ay(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function Tue(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Due(n.key),n)}}function iy(e,s,r){return s&&Tue(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function Due(e){var s=Rue(e,"string");return vu(s)=="symbol"?s:s+""}function Rue(e,s){if(vu(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(vu(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var Mue="1.2.0",Oue="1.7.35",kC=" ext. ",qr=function(){function e(s){ay(this,e),P7(s),this.metadata=s,T7.call(this,s)}return iy(e,[{key:"getCountries",value:function(){return Object.keys(this.metadata.countries).filter(function(r){return r!=="001"})}},{key:"getCountryMetadata",value:function(r){return this.metadata.countries[r]}},{key:"nonGeographic",value:function(){if(!(this.v1||this.v2||this.v3))return this.metadata.nonGeographic||this.metadata.nonGeographical}},{key:"hasCountry",value:function(r){return this.getCountryMetadata(r)!==void 0}},{key:"hasCallingCode",value:function(r){if(this.getCountryCodesForCallingCode(r))return!0;if(this.nonGeographic()){if(this.nonGeographic()[r])return!0}else{var n=this.countryCallingCodes()[r];if(n&&n.length===1&&n[0]==="001")return!0}}},{key:"isNonGeographicCallingCode",value:function(r){return this.nonGeographic()?!!this.nonGeographic()[r]:!this.getCountryCodesForCallingCode(r)}},{key:"country",value:function(r){return this.selectNumberingPlan(r)}},{key:"selectNumberingPlan",value:function(r,n){var a,i;if(r&&(Aue(r)?i=r:a=r),n&&(i=n),a&&a!=="001"){var o=this.getCountryMetadata(a);if(!o)throw new Error("Unknown country: ".concat(a));this.numberingPlan=new $C(o,this)}else if(i){if(!this.hasCallingCode(i))throw new Error("Unknown calling code: ".concat(i));this.numberingPlan=new $C(this.getNumberingPlanMetadata(i),this)}else this.numberingPlan=void 0;return this}},{key:"getCountryCodesForCallingCode",value:function(r){var n=this.countryCallingCodes()[r];if(n)return n.length===1&&n[0].length===3?void 0:n}},{key:"getCountryCodeForCallingCode",value:function(r){var n=this.getCountryCodesForCallingCode(r);if(n)return n[0]}},{key:"getNumberingPlanMetadata",value:function(r){var n=this.getCountryCodeForCallingCode(r);if(n)return this.getCountryMetadata(n);if(this.nonGeographic()){var a=this.nonGeographic()[r];if(a)return a}else{var i=this.countryCallingCodes()[r];if(i&&i.length===1&&i[0]==="001")return this.metadata.countries["001"]}}},{key:"countryCallingCode",value:function(){return this.numberingPlan.callingCode()}},{key:"IDDPrefix",value:function(){return this.numberingPlan.IDDPrefix()}},{key:"defaultIDDPrefix",value:function(){return this.numberingPlan.defaultIDDPrefix()}},{key:"nationalNumberPattern",value:function(){return this.numberingPlan.nationalNumberPattern()}},{key:"possibleLengths",value:function(){return this.numberingPlan.possibleLengths()}},{key:"formats",value:function(){return this.numberingPlan.formats()}},{key:"nationalPrefixForParsing",value:function(){return this.numberingPlan.nationalPrefixForParsing()}},{key:"nationalPrefixTransformRule",value:function(){return this.numberingPlan.nationalPrefixTransformRule()}},{key:"leadingDigits",value:function(){return this.numberingPlan.leadingDigits()}},{key:"hasTypes",value:function(){return this.numberingPlan.hasTypes()}},{key:"type",value:function(r){return this.numberingPlan.type(r)}},{key:"ext",value:function(){return this.numberingPlan.ext()}},{key:"countryCallingCodes",value:function(){return this.v1?this.metadata.country_phone_code_to_countries:this.metadata.country_calling_codes}},{key:"chooseCountryByCountryCallingCode",value:function(r){return this.selectNumberingPlan(r)}},{key:"hasSelectedNumberingPlan",value:function(){return this.numberingPlan!==void 0}}])}(),$C=function(){function e(s,r){ay(this,e),this.globalMetadataObject=r,this.metadata=s,T7.call(this,r.metadata)}return iy(e,[{key:"callingCode",value:function(){return this.metadata[0]}},{key:"_getDefaultCountryMetadataForThisCallingCode",value:function(){return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode())}},{key:"getDefaultCountryMetadataForRegion",value:function(){return this._getDefaultCountryMetadataForThisCallingCode()}},{key:"IDDPrefix",value:function(){if(!(this.v1||this.v2))return this.metadata[1]}},{key:"defaultIDDPrefix",value:function(){if(!(this.v1||this.v2))return this.metadata[12]}},{key:"nationalNumberPattern",value:function(){return this.v1||this.v2?this.metadata[1]:this.metadata[2]}},{key:"possibleLengths",value:function(){if(!this.v1)return this.metadata[this.v2?2:3]}},{key:"_getFormats",value:function(r){return r[this.v1?2:this.v2?3:4]}},{key:"formats",value:function(){var r=this,n=this._getFormats(this.metadata)||this._getFormats(this._getDefaultCountryMetadataForThisCallingCode())||[];return n.map(function(a){return new Iue(a,r)})}},{key:"nationalPrefix",value:function(){return this.metadata[this.v1?3:this.v2?4:5]}},{key:"_getNationalPrefixFormattingRule",value:function(r){return r[this.v1?4:this.v2?5:6]}},{key:"nationalPrefixFormattingRule",value:function(){return this._getNationalPrefixFormattingRule(this.metadata)||this._getNationalPrefixFormattingRule(this._getDefaultCountryMetadataForThisCallingCode())}},{key:"_nationalPrefixForParsing",value:function(){return this.metadata[this.v1?5:this.v2?6:7]}},{key:"nationalPrefixForParsing",value:function(){return this._nationalPrefixForParsing()||this.nationalPrefix()}},{key:"nationalPrefixTransformRule",value:function(){return this.metadata[this.v1?6:this.v2?7:8]}},{key:"_getNationalPrefixIsOptionalWhenFormatting",value:function(){return!!this.metadata[this.v1?7:this.v2?8:9]}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata)||this._getNationalPrefixIsOptionalWhenFormatting(this._getDefaultCountryMetadataForThisCallingCode())}},{key:"leadingDigits",value:function(){return this.metadata[this.v1?8:this.v2?9:10]}},{key:"types",value:function(){return this.metadata[this.v1?9:this.v2?10:11]}},{key:"hasTypes",value:function(){return this.types()&&this.types().length===0?!1:!!this.types()}},{key:"type",value:function(r){if(this.hasTypes()&&EC(this.types(),r))return new Lue(EC(this.types(),r),this)}},{key:"ext",value:function(){return this.v1||this.v2?kC:this.metadata[13]||kC}}])}(),Iue=function(){function e(s,r){ay(this,e),this._format=s,this.metadata=r}return iy(e,[{key:"pattern",value:function(){return this._format[0]}},{key:"format",value:function(){return this._format[1]}},{key:"leadingDigitsPatterns",value:function(){return this._format[2]||[]}},{key:"nationalPrefixFormattingRule",value:function(){return this._format[3]||this.metadata.nationalPrefixFormattingRule()}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return!!this._format[4]||this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"nationalPrefixIsMandatoryWhenFormattingInNationalFormat",value:function(){return this.usesNationalPrefix()&&!this.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"usesNationalPrefix",value:function(){return!!(this.nationalPrefixFormattingRule()&&!Fue.test(this.nationalPrefixFormattingRule()))}},{key:"internationalFormat",value:function(){return this._format[5]||this.format()}}])}(),Fue=/^\(?\$1\)?$/,Lue=function(){function e(s,r){ay(this,e),this.type=s,this.metadata=r}return iy(e,[{key:"pattern",value:function(){return this.metadata.v1?this.type:this.type[0]}},{key:"possibleLengths",value:function(){if(!this.metadata.v1)return this.type[1]||this.metadata.possibleLengths()}}])}();function EC(e,s){switch(s){case"FIXED_LINE":return e[0];case"MOBILE":return e[1];case"TOLL_FREE":return e[2];case"PREMIUM_RATE":return e[3];case"PERSONAL_NUMBER":return e[4];case"VOICEMAIL":return e[5];case"UAN":return e[6];case"PAGER":return e[7];case"VOIP":return e[8];case"SHARED_COST":return e[9]}}function P7(e){if(!e)throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");if(!Md(e)||!Md(e.countries))throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(Md(e)?"an object of shape: { "+Object.keys(e).join(", ")+" }":"a "+Bue(e)+": "+e,"."))}var Bue=function(s){return vu(s)};function A7(e,s){var r=new qr(s);if(r.hasCountry(e))return r.selectNumberingPlan(e).countryCallingCode();throw new Error("Unknown country: ".concat(e))}function zue(e,s){return s.countries.hasOwnProperty(e)}function T7(e){var s=e.version;typeof s=="number"?(this.v1=s===1,this.v2=s===2,this.v3=s===3,this.v4=s===4):s?CC(s,Mue)===-1?this.v2=!0:CC(s,Oue)===-1?this.v3=!0:this.v4=!0:this.v1=!0}function d_(e,s,r){return Uue(e,void 0,s,r)}function Uue(e,s,r,n){r&&(n=new qr(n.metadata),n.selectNumberingPlan(r));var a=n.type(s),i=a&&a.possibleLengths()||n.possibleLengths();if(!i)return"IS_POSSIBLE";var o=e.length,l=i[0];return l===o?"IS_POSSIBLE":l>o?"TOO_SHORT":i[i.length-1]<o?"TOO_LONG":i.indexOf(o,1)>=0?"IS_POSSIBLE":"INVALID_LENGTH"}function Vue(e,s,r){s===void 0&&(s={});var n=new qr(r);if(s.v2){if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");n.selectNumberingPlan(e.country||e.countryCallingCode)}else{if(!e.phone)return!1;if(e.country){if(!n.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));n.selectNumberingPlan(e.country)}else{if(!e.countryCallingCode)throw new Error("Invalid phone number object passed");n.selectNumberingPlan(e.countryCallingCode)}}if(n.possibleLengths())return D7(e.phone||e.nationalNumber,n);if(e.countryCallingCode&&n.isNonGeographicCallingCode(e.countryCallingCode))return!0;throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.')}function D7(e,s){switch(d_(e,void 0,s)){case"IS_POSSIBLE":return!0;default:return!1}}function Xi(e,s){return e=e||"",new RegExp("^(?:"+s+")$").test(e)}function que(e,s){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=Hue(e))||s){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. 835In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hue(e,s){if(e){if(typeof e=="string")return PC(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?PC(e,s):void 0}}function PC(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=Array(s);r<s;r++)n[r]=e[r];return n}var Wue=["MOBILE","PREMIUM_RATE","TOLL_FREE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL"];function u_(e,s,r){if(s=s||{},!(!e.country&&!e.countryCallingCode)){var n=new qr(r);n.selectNumberingPlan(e.country||e.countryCallingCode);var a=s.v2?e.nationalNumber:e.phone;if(Xi(a,n.nationalNumberPattern())){if(O0(a,"FIXED_LINE",n))return n.type("MOBILE")&&n.type("MOBILE").pattern()===""||!n.type("MOBILE")||O0(a,"MOBILE",n)?"FIXED_LINE_OR_MOBILE":"FIXED_LINE";for(var i=que(Wue),o;!(o=i()).done;){var l=o.value;if(O0(a,l,n))return l}}}}function O0(e,s,r){var n=r.type(s);return!n||!n.pattern()||n.possibleLengths()&&n.possibleLengths().indexOf(e.length)<0?!1:Xi(e,n.pattern())}function Gue(e,s,r){s=s||{};var n=new qr(r);if(n.selectNumberingPlan(e.country||e.countryCallingCode),n.hasTypes())return u_(e,s,n.metadata)!==void 0;var a=s.v2?e.nationalNumber:e.phone;return Xi(a,n.nationalNumberPattern())}var Yue=/^[A-Z]{2}$/;function Kue(e){return Yue.test(e)}function Que(e,s){var r,n,a=new qr(s);return Kue(e)?(r=e,a.selectNumberingPlan(r),n=a.countryCallingCode()):n=e,{country:r,callingCode:n}}function Xue(e,s,r){var n=new qr(r),a=n.getCountryCodesForCallingCode(e);return a?a.filter(function(i){return Zue(s,i,r)}):[]}function Zue(e,s,r){var n=new qr(r);return n.selectNumberingPlan(s),n.numberingPlan.possibleLengths().indexOf(e.length)>=0}var m_=2,Jue=17,eme=3,Ua="0-9ï¼-ï¼Ù -Ù©Û°-Û¹",tme="-â-ââã¼ï¼",sme="ï¼/",rme="ï¼.",nme="  Ââ
835â ã",ame="()ï¼ï¼ï¼»ï¼½\\[\\]",ime="~ââ¼ï½",Mg="".concat(tme).concat(sme).concat(rme).concat(nme).concat(ame).concat(ime),h_="+ï¼",ome=new RegExp("(["+Ua+"])");function lme(e,s,r,n){if(s){var a=new qr(n);a.selectNumberingPlan(s||r);var i=new RegExp(a.IDDPrefix());if(e.search(i)===0){e=e.slice(e.match(i)[0].length);var o=e.match(ome);if(!(o&&o[1]!=null&&o[1].length>0&&o[1]==="0"))return e}}}function cme(e,s){if(e&&s.numberingPlan.nationalPrefixForParsing()){var r=new RegExp("^(?:"+s.numberingPlan.nationalPrefixForParsing()+")"),n=r.exec(e);if(n){var a,i,o=n.length-1,l=o>0&&n[o];if(s.nationalPrefixTransformRule()&&l)a=e.replace(r,s.nationalPrefixTransformRule()),o>1&&(i=n[1]);else{var c=n[0];a=e.slice(c.length),l&&(i=n[1])}var d;if(l){var m=e.indexOf(n[1]),h=e.slice(0,m);h===s.numberingPlan.nationalPrefix()&&(d=s.numberingPlan.nationalPrefix())}else d=n[0];return{nationalNumber:a,nationalPrefix:d,carrierCode:i}}}return{nationalNumber:e}}function dme(e,s){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=ume(e))||s){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. 836In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ume(e,s){if(e){if(typeof e=="string")return AC(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?AC(e,s):void 0}}function AC(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=Array(s);r<s;r++)n[r]=e[r];return n}function mme(e,s,r){for(var n=new qr(r),a=dme(s),i;!(i=a()).done;){var o=i.value;if(n.selectNumberingPlan(o),n.leadingDigits()){if(e&&e.search(n.leadingDigits())===0)return o}else if(u_({phone:e,country:o},void 0,n.metadata))return o}}function R7(e,s){var r=s.nationalNumber,n=s.metadata,a=n.getCountryCodesForCallingCode(e);if(a)return a.length===1?a[0]:mme(r,a,n.metadata)}function f1(e,s,r){var n=cme(e,r),a=n.carrierCode,i=n.nationalNumber;if(i!==e){if(!hme(e,i,r))return{nationalNumber:e};if(r.numberingPlan.possibleLengths()&&(s||(s=R7(r.numberingPlan.callingCode(),{nationalNumber:i,metadata:r})),!fme(i,s,r)))return{nationalNumber:e}}return{nationalNumber:i,carrierCode:a}}function hme(e,s,r){return!(Xi(e,r.nationalNumberPattern())&&!Xi(s,r.nationalNumberPattern()))}function fme(e,s,r){switch(d_(e,s,r)){case"TOO_SHORT":case"INVALID_LENGTH":return!1;default:return!0}}function pme(e,s,r,n,a){if(!(r||n))return{number:e};var i=r?A7(r,a):n;if(e.indexOf(i)===0){var o=new qr(a);o.selectNumberingPlan(r||n);var l=e.slice(i.length),c=f1(l,void 0,o),d=c.nationalNumber,m=f1(e,void 0,o),h=m.nationalNumber;if(!Xi(h,o.nationalNumberPattern())&&Xi(d,o.nationalNumberPattern())||d_(h,void 0,o)==="TOO_LONG")return{countryCallingCode:i,number:l}}return{number:e}}function M7(e,s,r,n,a){if(!e)return{};var i;if(e[0]!=="+"){var o=lme(e,r,n,a);if(o&&o!==e)i=!0,e="+"+o;else{if(r||n){var l=pme(e,s,r,n,a),c=l.countryCallingCode,d=l.number;if(c)return{countryCallingCodeSource:"FROM_NUMBER_WITHOUT_PLUS_SIGN",countryCallingCode:c,number:d}}return{number:e}}}if(e[1]==="0")return{};for(var m=new qr(a),h=2;h-1<=eme&&h<=e.length;){var f=e.slice(1,h);if(m.hasCallingCode(f))return m.selectNumberingPlan(f),{countryCallingCodeSource:i?"FROM_NUMBER_WITH_IDD":"FROM_NUMBER_WITH_PLUS_SIGN",countryCallingCode:f,number:e.slice(h)};h++}return{}}function xme(e){return e.replace(new RegExp("[".concat(Mg,"]+"),"g")," ").trim()}var gme=/(\$\d)/;function vme(e,s,r){var n=r.useInternationalFormat,a=r.withNationalPrefix,i=e.replace(new RegExp(s.pattern()),n?s.internationalFormat():a&&s.nationalPrefixFormattingRule()?s.format().replace(gme,s.nationalPrefixFormattingRule()):s.format());return n?xme(i):i}var yme=/^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;function bme(e,s,r){var n=new qr(r);if(n.selectNumberingPlan(e||s),n.defaultIDDPrefix())return n.defaultIDDPrefix();if(yme.test(n.IDDPrefix()))return n.IDDPrefix()}var jme=";ext=",ed=function(s){return"([".concat(Ua,"]{1,").concat(s,"})")};function O7(e){var s="20",r="15",n="9",a="6",i="[  \\t,]*",o="[:\\.ï¼]?[  \\t,-]*",l="#?",c="(?:e?xt(?:ensi(?:oÌ?|ó))?n?|ï½ ?ï½ï½ï½?|доб|anexo)",d="(?:[xï½#ï¼~ï½]|int|ï½ï½ï½)",m="[- ]+",h="[  \\t]*",f="(?:,{2}|;)",p=jme+ed(s),x=i+c+o+ed(s)+l,g=i+d+o+ed(n)+l,b=m+ed(a)+"#",w=h+f+o+ed(r)+l,j=h+"(?:,)+"+o+ed(n)+l;return p+"|"+x+"|"+g+"|"+b+"|"+w+"|"+j}var wme="["+Ua+"]{"+m_+"}",Nme="["+h_+"]{0,1}(?:["+Mg+"]*["+Ua+"]){3,}["+Mg+Ua+"]*",_me=new RegExp("^["+h_+"]{0,1}(?:["+Mg+"]*["+Ua+"]){1,2}$","i"),Sme=Nme+"(?:"+O7()+")?",Cme=new RegExp("^"+wme+"$|^"+Sme+"$","i");function kme(e){return e.length>=m_&&Cme.test(e)}function $me(e){return _me.test(e)}function Eme(e){var s=e.number,r=e.ext;if(!s)return"";if(s[0]!=="+")throw new Error('"formatRFC3966()" expects "number" to be in E.164 format.');return"tel:".concat(s).concat(r?";ext="+r:"")}var TC={formatExtension:function(s,r,n){return"".concat(s).concat(n.ext()).concat(r)}};function Pme(e,s,r,n){r?r=Dme({},TC,r):r=TC;var a=new qr(n);if(e.country&&e.country!=="001"){if(!a.hasCountry(e.country))throw new Error("Unknown country: ".concat(e.country));a.selectNumberingPlan(e.country)}else if(e.countryCallingCode)a.selectNumberingPlan(e.countryCallingCode);else return e.phone||"";var i=a.countryCallingCode(),o=r.v2?e.nationalNumber:e.phone,l;switch(s){case"NATIONAL":return o?(l=Og(o,e.carrierCode,"NATIONAL",a,r),I0(l,e.ext,a,r.formatExtension)):"";case"INTERNATIONAL":return o?(l=Og(o,null,"INTERNATIONAL",a,r),l="+".concat(i," ").concat(l),I0(l,e.ext,a,r.formatExtension)):"+".concat(i);
vendor: 12,576 bytes, lines 836-837
836case"E.164":return"+".concat(i).concat(o);case"RFC3966":return Eme({number:"+".concat(i).concat(o),ext:e.ext});case"IDD":if(!r.fromCountry)return;var c=Tme(o,e.carrierCode,i,r.fromCountry,a);return c?I0(c,e.ext,a,r.formatExtension):void 0;default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(s,'"'))}}function Og(e,s,r,n,a){var i=Ame(n.formats(),e);return i?vme(e,i,{useInternationalFormat:r==="INTERNATIONAL",withNationalPrefix:!(i.nationalPrefixIsOptionalWhenFormattingInNationalFormat()&&a&&a.nationalPrefix===!1),carrierCode:s,metadata:n}):e}function Ame(e,s){return Rme(e,function(r){if(r.leadingDigitsPatterns().length>0){var n=r.leadingDigitsPatterns()[r.leadingDigitsPatterns().length-1];if(s.search(n)!==0)return!1}return Xi(s,r.pattern())})}function I0(e,s,r,n){return s?n(e,s,r):e}function Tme(e,s,r,n,a){var i=A7(n,a.metadata);if(i===r){var o=Og(e,s,"NATIONAL",a);return r==="1"?r+" "+o:o}var l=bme(n,void 0,a.metadata);if(l)return"".concat(l," ").concat(r," ").concat(Og(e,null,"INTERNATIONAL",a))}function Dme(){for(var e=1,s=arguments.length,r=new Array(s),n=0;n<s;n++)r[n]=arguments[n];for(;e<r.length;){if(r[e])for(var a in r[e])r[0][a]=r[e][a];e++}return r[0]}function Rme(e,s){for(var r=0;r<e.length;){if(s(e[r]))return e[r];r++}}function rf(e){"@babel/helpers - typeof";return rf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},rf(e)}function DC(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function RC(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?DC(Object(r),!0).forEach(function(n){Mme(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):DC(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Mme(e,s,r){return(s=I7(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Ome(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function Ime(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,I7(n.key),n)}}function Fme(e,s,r){return s&&Ime(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function I7(e){var s=Lme(e,"string");return rf(s)=="symbol"?s:s+""}function Lme(e,s){if(rf(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s||"default");if(rf(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}var Bme=function(){function e(s,r,n){if(Ome(this,e),!s)throw new TypeError("First argument is required");if(typeof s!="string")throw new TypeError("First argument must be a string");if(s[0]==="+"&&!r)throw new TypeError("`metadata` argument not passed");if(Md(r)&&Md(r.countries)){n=r;var a=s;if(!zme.test(a))throw new Error('Invalid `number` argument passed: must consist of a "+" followed by digits');var i=M7(a,void 0,void 0,void 0,n),o=i.countryCallingCode,l=i.number;if(r=l,s=o,!r)throw new Error("Invalid `number` argument passed: too short")}if(!r)throw new TypeError("`nationalNumber` argument is required");if(typeof r!="string")throw new TypeError("`nationalNumber` argument must be a string");P7(n);var c=Que(s,n),d=c.country,m=c.callingCode;this.country=d,this.countryCallingCode=m,this.nationalNumber=r,this.number="+"+this.countryCallingCode+this.nationalNumber,this.getMetadata=function(){return n}}return Fme(e,[{key:"setExt",value:function(r){this.ext=r}},{key:"getPossibleCountries",value:function(){return this.country?[this.country]:Xue(this.countryCallingCode,this.nationalNumber,this.getMetadata())}},{key:"isPossible",value:function(){return Vue(this,{v2:!0},this.getMetadata())}},{key:"isValid",value:function(){return Gue(this,{v2:!0},this.getMetadata())}},{key:"isNonGeographic",value:function(){var r=new qr(this.getMetadata());return r.isNonGeographicCallingCode(this.countryCallingCode)}},{key:"isEqual",value:function(r){return this.number===r.number&&this.ext===r.ext}},{key:"getType",value:function(){return u_(this,{v2:!0},this.getMetadata())}},{key:"format",value:function(r,n){return Pme(this,r,n?RC(RC({},n),{},{v2:!0}):{v2:!0},this.getMetadata())}},{key:"formatNational",value:function(r){return this.format("NATIONAL",r)}},{key:"formatInternational",value:function(r){return this.format("INTERNATIONAL",r)}},{key:"getURI",value:function(r){return this.format("RFC3966",r)}}])}(),zme=/^\+\d+$/;function p1(e){"@babel/helpers - typeof";return p1=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},p1(e)}function Ume(e,s,r){return Object.defineProperty(e,"prototype",{writable:!1}),e}function Vme(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function qme(e,s,r){return s=af(s),Hme(e,f_()?Reflect.construct(s,r||[],af(e).constructor):s.apply(e,r))}function Hme(e,s){if(s&&(p1(s)=="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wme(e)}function Wme(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Gme(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&nf(e,s)}function x1(e){var s=typeof Map=="function"?new Map:void 0;return x1=function(n){if(n===null||!Kme(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(s!==void 0){if(s.has(n))return s.get(n);s.set(n,a)}function a(){return Yme(n,arguments,af(this).constructor)}return a.prototype=Object.create(n.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),nf(a,n)},x1(e)}function Yme(e,s,r){if(f_())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,s);var a=new(e.bind.apply(e,n));return r&&nf(a,r.prototype),a}function f_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(f_=function(){return!!e})()}function Kme(e){try{return Function.toString.call(e).indexOf("[native code]")!==-1}catch{return typeof e=="function"}}function nf(e,s){return nf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},nf(e,s)}function af(e){return af=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},af(e)}var Ti=function(e){function s(r){var n;return Vme(this,s),n=qme(this,s,[r]),Object.setPrototypeOf(n,s.prototype),n.name=n.constructor.name,n}return Gme(s,e),Ume(s)}(x1(Error)),MC=new RegExp("(?:"+O7()+")$","i");function Qme(e){var s=e.search(MC);if(s<0)return{};for(var r=e.slice(0,s),n=e.match(MC),a=1;a<n.length;){if(n[a])return{number:r,ext:n[a]};a++}}var Xme={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","ï¼":"0","ï¼":"1","ï¼":"2","ï¼":"3","ï¼":"4","ï¼":"5","ï¼":"6","ï¼":"7","ï¼":"8","ï¼":"9","Ù ":"0","Ù¡":"1","Ù¢":"2","Ù£":"3","Ù¤":"4","Ù¥":"5","Ù¦":"6","Ù§":"7","Ù¨":"8","Ù©":"9","Û°":"0","Û±":"1","Û²":"2","Û³":"3","Û´":"4","Ûµ":"5","Û¶":"6","Û·":"7","Û¸":"8","Û¹":"9"};function Zme(e){return Xme[e]}function Jme(e,s){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=ehe(e))||s){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. 837In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ehe(e,s){if(e){if(typeof e=="string")return OC(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?OC(e,s):void 0}}function OC(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=Array(s);r<s;r++)n[r]=e[r];return n}function IC(e){for(var s="",r=Jme(e.split("")),n;!(n=r()).done;){var a=n.value;s+=the(a,s)||""}return s}function the(e,s,r){return e==="+"?s?void 0:"+":Zme(e)}var F7="+",she="[\\-\\.\\(\\)]?",FC="(["+Ua+"]|"+she+")",rhe="^\\"+F7+FC+"*["+Ua+"]"+FC+"*$",nhe=new RegExp(rhe,"g"),g1=Ua,ahe="["+g1+"]+((\\-)*["+g1+"])*",ihe="a-zA-Z",ohe="["+ihe+"]+((\\-)*["+g1+"])*",lhe="^("+ahe+"\\.)*"+ohe+"\\.?$",che=new RegExp(lhe,"g"),LC="tel:",v1=";phone-context=",dhe=";isub=";function uhe(e){var s=e.indexOf(v1);if(s<0)return null;var r=s+v1.length;if(r>=e.length)return"";var n=e.indexOf(";",r);return n>=0?e.substring(r,n):e.substring(r)}function mhe(e){return e===null?!0:e.length===0?!1:nhe.test(e)||che.test(e)}function hhe(e,s){var r=s.extractFormattedPhoneNumber,n=uhe(e);if(!mhe(n))throw new Ti("NOT_A_NUMBER");var a;if(n===null)a=r(e)||"";else{a="",n.charAt(0)===F7&&(a+=n);var i=e.indexOf(LC),o;i>=0?o=i+LC.length:o=0;var l=e.indexOf(v1);a+=e.substring(o,l)}var c=a.indexOf(dhe);if(c>0&&(a=a.substring(0,c)),a!=="")return a}var fhe=250,phe=new RegExp("["+h_+Ua+"]"),xhe=new RegExp("[^"+Ua+"#]+$");function ghe(e,s,r){s=s||{};var n=new qr(r);if(s.defaultCountry&&!n.hasCountry(s.defaultCountry))throw s.v2?new Ti("INVALID_COUNTRY"):new Error("Unknown country: ".concat(s.defaultCountry));var a=yhe(e,s.v2,s.extract),i=a.number,o=a.ext,l=a.error;if(!i){if(s.v2)throw l==="TOO_SHORT"?new Ti("TOO_SHORT"):new Ti("NOT_A_NUMBER");return{}}var c=jhe(i,s.defaultCountry,s.defaultCallingCode,n),d=c.country,m=c.nationalNumber,h=c.countryCallingCode,f=c.countryCallingCodeSource,p=c.carrierCode;if(!n.hasSelectedNumberingPlan()){if(s.v2)throw new Ti("INVALID_COUNTRY");return{}}if(!m||m.length<m_){if(s.v2)throw new Ti("TOO_SHORT");return{}}if(m.length>Jue){if(s.v2)throw new Ti("TOO_LONG");return{}}if(s.v2){var x=new Bme(h,m,n.metadata);return d&&(x.country=d),p&&(x.carrierCode=p),o&&(x.ext=o),x.__countryCallingCodeSource=f,x}var g=(s.extended?n.hasSelectedNumberingPlan():d)?Xi(m,n.nationalNumberPattern()):!1;return s.extended?{country:d,countryCallingCode:h,carrierCode:p,valid:g,possible:g?!0:!!(s.extended===!0&&n.possibleLengths()&&D7(m,n)),phone:m,ext:o}:g?bhe(d,m,o):{}}function vhe(e,s,r){if(e){if(e.length>fhe){if(r)throw new Ti("TOO_LONG");return}if(s===!1)return e;var n=e.search(phe);if(!(n<0))return e.slice(n).replace(xhe,"")}}function yhe(e,s,r){var n=hhe(e,{extractFormattedPhoneNumber:function(o){return vhe(o,r,s)}});if(!n)return{};if(!kme(n))return $me(n)?{error:"TOO_SHORT"}:{};var a=Qme(n);return a.ext?a:{number:n}}function bhe(e,s,r){var n={country:e,phone:s};return r&&(n.ext=r),n}function jhe(e,s,r,n){var a=M7(IC(e),void 0,s,r,n.metadata),i=a.countryCallingCodeSource,o=a.countryCallingCode,l=a.number,c;if(o)n.selectNumberingPlan(o);else if(l&&(s||r))s?(c=s,n.selectNumberingPlan(s),o=n.numberingPlan.callingCode()):(n.selectNumberingPlan(r),o=r);else return{};if(!l)return{countryCallingCodeSource:i,countryCallingCode:o};var d=f1(IC(l),void 0,n),m=d.nationalNumber,h=d.carrierCode,f=R7(o,{nationalNumber:m,metadata:n});return f&&(c=f,f==="001"||n.selectNumberingPlan(c)),{country:c,countryCallingCode:o,countryCallingCodeSource:i,nationalNumber:m,carrierCode:h}}function of(e){"@babel/helpers - typeof";return of=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},of(e)}function BC(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function zC(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?BC(Object(r),!0).forEach(function(n){whe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):BC(Object(r)).forEac
837h(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function whe(e,s,r){return(s=Nhe(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Nhe(e){var s=_he(e,"string");return of(s)=="symbol"?s:s+""}function _he(e,s){if(of(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s||"default");if(of(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function She(e,s,r){return ghe(e,zC(zC({},s),{},{v2:!0}),r)}function lf(e){"@babel/helpers - typeof";return lf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},lf(e)}function UC(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Che(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?UC(Object(r),!0).forEach(function(n){khe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):UC(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function khe(e,s,r){return(s=$he(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function $he(e){var s=Ehe(e,"string");return lf(s)=="symbol"?s:s+""}function Ehe(e,s){if(lf(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s||"default");if(lf(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function Phe(e,s){return Rhe(e)||Dhe(e,s)||The(e,s)||Ahe()}function Ahe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 838In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function The(e,s){if(e){if(typeof e=="string")return VC(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?VC(e,s):void 0}}function VC(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=Array(s);r<s;r++)n[r]=e[r];return n}function Dhe(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,s!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==s);c=!0);}catch(m){d=!0,a=m}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function Rhe(e){if(Array.isArray(e))return e}function Mhe(e){var s=Array.prototype.slice.call(e),r=Phe(s,4),n=r[0],a=r[1],i=r[2],o=r[3],l,c,d;if(typeof n=="string")l=n;else throw new TypeError("A text for parsing must be a string.");if(!a||typeof a=="string")o?(c=i,d=o):(c=void 0,d=i),a&&(c=Che({defaultCountry:a},c));else if(Md(a))i?(c=a,d=i):d=a;else throw new Error("Invalid second argument: ".concat(a));return{text:l,options:c,metadata:d}}function cf(e){"@babel/helpers - typeof";return cf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},cf(e)}function qC(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function HC(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?qC(Object(r),!0).forEach(function(n){Ohe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):qC(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Ohe(e,s,r){return(s=Ihe(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Ihe(e){var s=Fhe(e,"string");return cf(s)=="symbol"?s:s+""}function Fhe(e,s){if(cf(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s||"default");if(cf(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function Lhe(e,s,r){s&&s.defaultCountry&&!zue(s.defaultCountry,r)&&(s=HC(HC({},s),{},{defaultCountry:void 0}));try{return She(e,s,r)}catch(n){if(!(n instanceof Ti))throw n}}function Bhe(){var e=Mhe(arguments),s=e.text,r=e.options,n=e.metadata;return Lhe(s,r,n)}function L7(){return $ue(Bhe,arguments)}function B7(e){return/^[0+]/.test(e)}function Wp(e){if(!e)return"";const s=String(e).trim();if(!s)return"";try{if(B7(s)){const r=L7(s,"GB");if(r&&r.isValid())return r.country==="GB"?r.formatNational():r.formatInternational()}}catch{}return s}function y1(e){if(!e)return null;const s=String(e).trim();if(!s)return null;try{if(B7(s)){const r=L7(s,"GB");if(r&&r.isValid())return`tel:${r.number}`}}catch{}return null}function zhe({business:e}){const[s,r]=u.useState(!1),n=sZ(e),a=n?`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(n)}`:null,i=e.website?e.website.startsWith("http")?e.website:`https://${e.website}`:null,o=e.phone?y1(e.phone):null;return t.jsxs("section",{className:"relative overflow-hidden bg-community-teal text-white",children:[t.jsx("div",{className:"pointer-events-none absolute inset-0",style:{background:"radial-gradient(ellipse 50% 100% at 100% 50%, hsl(330 75% 40% / 0.18) 0%, transparent 60%)"}}),t.jsxs("div",{className:"relative max-w-6xl mx-auto px-4 md:px-8 py-8 md:py-10 flex flex-col md:flex-row gap-5 md:gap-6 items-start md:items-center",children:[t.jsx(J2,{business:e,size:160,className:"bg-white/15 border-white/25 rounded-2xl"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[e.is_verified?t.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[10px] font-medium uppercase tracking-wider bg-white/20 text-white border border-white/35",children:[t.jsx(As,{className:"h-3 w-3"})," Verified"]}):t.jsx("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[10px] font-medium uppercase tracking-wider bg-white/10 text-white/70 border border-white/20",children:"Unverified"}),e.advertises_in_discover&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[10px] font-medium uppercase tracking-wider bg-community-purple/15 text-white border border-white/25",children:[t.jsx(ui,{className:"h-3 w-3"})," Advertises in Discover"]})]}),t.jsx("h1",{className:"font-heading text-3xl md:text-4xl leading-tight tracking-tight text-white",children:e.name}),n&&t.jsx("p",{className:"mt-1 text-sm md:text-base text-white/70 font-light",children:n}),t.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[o&&t.jsxs("a",{href:o,className:"inline-flex items-center gap-1.5 bg-community-purple hover:bg-community-purple/90 text-white text-xs font-medium px-4 py-2 rounded-lg transition-colors",children:[t.jsx(zr,{className:"h-3.5 w-3.5"})," Call"]}),i&&t.jsxs("a",{href:i,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 bg-white/15 hover:bg-white/25 text-white border border-white/25 text-xs font-medium px-4 py-2 rounded-lg transition-colors",children:[t.jsx(Tc,{className:"h-3.5 w-3.5"})," Website"]}),e.email&&t.jsxs("a",{href:`mailto:${e.email}`,className:"inline-flex items-center gap-1.5 bg-white/15 hover:bg-white/25 text-white border border-white/25 text-xs font-medium px-4 py-2 rounded-lg transition-colors",children:[t.jsx(ar,{className:"h-3.5 w-3.5"})," Email"]}),a&&t.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 bg-white/15 hover:bg-white/25 text-white border border-white/25 text-xs font-medium px-4 py-2 rounded-lg transition-colors",children:[t.jsx(_t,{className:"h-3.5 w-3.5"})," Directions"]}
838),!e.is_verified&&t.jsx(Sue,{businessId:e.id,businessName:e.name,ownerId:e.owner_id??null,hideWhenPending:!0,triggerLabel:"Is this your business? Claim this listing",triggerIcon:t.jsx(bh,{className:"h-3.5 w-3.5"}),triggerClassName:"inline-flex items-center gap-1.5 bg-white text-community-teal hover:bg-white/90 text-xs font-medium px-4 py-2 rounded-lg transition-colors border border-white"})]}),!e.is_verified&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>r(!0),className:"mt-3 text-[11px] text-white/60 hover:text-white/90 underline underline-offset-2 transition-colors",children:"Request removal of this listing"}),t.jsx(Cue,{businessId:e.id,businessName:e.name,open:s,onOpenChange:r})]})]})]})]})}function Uhe({ownerName:e,ownerRole:s,ownerPhotoUrl:r,ownerQuote:n}){return!e&&!n&&!r?null:t.jsxs("div",{className:"bg-card border border-community-teal/25 rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-[1px] text-muted-foreground mb-4",children:[t.jsx(bn,{className:"h-3.5 w-3.5 text-community-teal"})," Meet the owner"]}),t.jsxs("div",{className:"flex gap-4 items-start",children:[t.jsx("div",{className:"w-[72px] h-[72px] rounded-full bg-community-teal/10 overflow-hidden flex items-center justify-center flex-shrink-0 border border-community-teal/25",children:r?t.jsx("img",{src:r,alt:e||"Owner",className:"w-full h-full object-cover"}):t.jsx(bn,{className:"h-7 w-7 text-community-teal",strokeWidth:1.5})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[e&&t.jsx("div",{className:"font-medium text-sm",children:e}),s&&t.jsx("div",{className:"text-xs text-muted-foreground mb-2.5",children:s}),n&&t.jsxs("blockquote",{className:"border-l-2 border-community-purple pl-3",children:[t.jsx("span",{className:"font-heading text-3xl leading-none text-community-purple block mb-1.5",children:"â"}),t.jsx("p",{className:"font-heading italic text-sm text-foreground/85 leading-relaxed",children:n})]})]})]})]})}const WC=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];function Vhe(e){if(!e)return"Closed";if(typeof e=="string")return e;if(typeof e=="object"){if(e.closed)return"Closed";if(e.open&&e.close)return`${e.open} â ${e.close}`}return"Closed"}function qhe({openingHours:e}){if(!e)return null;const s=WC[(new Date().getDay()+6)%7],r=tZ(e);return t.jsxs("div",{className:"bg-card border border-community-teal/25 rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-[1px] text-muted-foreground mb-3",children:[t.jsx(ws,{className:"h-3.5 w-3.5 text-community-teal"})," Opening hours"]}),t.jsx("div",{className:"text-sm",children:WC.map(n=>{const a=n===s;return t.jsxs("div",{className:`flex justify-between py-1.5 border-b border-community-teal/15 last:border-0 ${a?"font-medium text-foreground":""}`,children:[t.jsx("span",{className:"capitalize text-muted-foreground",children:n}),t.jsxs("span",{className:"text-foreground/80",children:[Vhe(e[n]),a&&r&&t.jsx("span",{className:"ml-2 text-community-teal font-medium",children:"· Open now"})]})]},n)})})]})}function Hhe({business:e}){const s=e.website?e.website.startsWith("http")?e.website:`https://${e.website}`:null,r=s?(()=>{try{return new URL(s).hostname.replace(/^www\./,"")}catch{return e.website||""}})():null,n=e.mobile?y1(e.mobile):null,a=e.phone?y1(e.phone):null,i=[...e.mobile?[{key:"mobile",icon:mL,on:!0,node:n?t.jsx("a",{href:n,className:"text-community-purple hover:underline",children:Wp(e.mobile)}):t.jsx("span",{className:"text-foreground/85",children:Wp(e.mobile)})}]:[],{key:"phone",icon:zr,on:!!e.phone,node:e.phone?a?t.jsx("a",{href:a,className:"text-community-purple hover:underline",children:Wp(e.phone)}):t.jsx("span",{className:"text-foreground/85",children:Wp(e.phone)}):t.jsx("span",{className:"text-muted-foreground/70 italic",children:"No phone listed"})},{key:"web",icon:Tc,on:!!s,node:s?t.jsx("a",{href:s,target:"_blank",rel:"noreferrer",className:"text-community-purple hover:underline truncate",children:r}
838):t.jsx("span",{className:"text-muted-foreground/70 italic",children:"No website"})},{key:"email",icon:ar,on:!!e.email,node:e.email?t.jsx("a",{href:`mailto:${e.email}`,className:"text-community-purple hover:underline truncate",children:e.email}):t.jsx("span",{className:"text-muted-foreground/70 italic",children:"No email listed"})},{key:"address",icon:_t,on:!!(e.address_line1||e.city),node:e.address_line1||e.city?t.jsxs("span",{className:"text-foreground/85",children:[e.address_line1&&t.jsx("span",{className:"block",children:e.address_line1}),e.address_line2&&t.jsx("span",{className:"block",children:e.address_line2}),t.jsx("span",{className:"block",children:[e.city,e.postcode].filter(Boolean).join(", ")})]}):t.jsx("span",{className:"text-muted-foreground/70 italic",children:"No address"})}],o=zA(e);return t.jsxs("div",{className:"bg-card border border-community-teal/25 rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-[1px] text-muted-foreground mb-3",children:[t.jsx(hc,{className:"h-3.5 w-3.5 text-community-teal"})," Details"]}),t.jsx("div",{className:"text-sm",children:i.map(({key:l,icon:c,node:d,on:m})=>t.jsxs("div",{className:"flex items-start gap-2.5 py-2 border-b border-community-teal/15 last:border-0",children:[t.jsx(c,{className:`h-4 w-4 mt-0.5 flex-shrink-0 ${m?"text-community-teal":"text-muted-foreground/40"}`}),t.jsx("div",{className:"min-w-0 flex-1 leading-snug",children:d})]},l))}),t.jsx(tN,{tags:e.operating_tags,className:"mt-4"}),o.length>0&&t.jsx(UA,{business:e,className:"mt-4 pt-3 border-t border-community-teal/15"})]})}function Whe({accreditations:e,className:s=""}){const r=(Array.isArray(e)?e:[]).filter(n=>n&&typeof n.url=="string"&&n.url).sort((n,a)=>(n.sort_order??0)-(a.sort_order??0));return r.length===0?null:t.jsx("section",{className:s,children:t.jsxs("div",{className:"bg-card border border-community-teal/25 rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-[1px] text-muted-foreground mb-3",children:[t.jsx(sv,{className:"h-3.5 w-3.5 text-community-teal"})," Accreditations"]}),t.jsx("div",{className:"flex flex-wrap gap-2.5",children:r.map((n,a)=>{const i=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"h-16 w-full flex items-center justify-center",children:t.jsx("img",{src:n.url,alt:n.title||"Accreditation",loading:"lazy",className:"max-h-16 max-w-full w-auto h-auto object-contain"})}),n.title&&t.jsx("figcaption",{className:"text-[11px] text-muted-foreground text-center leading-snug line-clamp-2",children:n.title})]}),o="w-[120px] bg-card border border-community-teal/25 rounded-[10px] p-3 flex flex-col items-center gap-2";return n.link_url?t.jsx("a",{href:n.link_url,target:"_blank",rel:"noopener noreferrer",className:`${o} hover:border-community-teal/60 transition-colors`,children:t.jsx("figure",{className:"contents",children:i})},(n.accreditation_id||n.url)+a):t.jsx("figure",{className:o,children:i},(n.accreditation_id||n.url)+a)})})]})})}const Ghe=()=>{const e=CZ(),{slug:s}=xv(),[r,n]=u.useState(null),[a,i]=u.useState(!0),{user:o,isAdmin:l}=Ar();u.useEffect(()=>{s&&c()},[s]);const c=async()=>{const{data:x,error:g}=await W.rpc("get_business_detail_by_slug_v2",{business_slug:s});if(g)console.error("Error fetching business:",g),n(null);else if(x&&x.length>0){const b=x[0],w={...b,postcode:b.postcode_out??"",business_categories:b.business_categories||{name:"",icon:""}};n(w)}else n(null);i(!1)};if(a)return t.jsxs("div",{className:"min-h-screen",children:[t.jsx(gs,{}),t.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:t.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-community-green"})}),t.jsx(vs,{})]});if(!r)return t.jsxs("div",{className:"min-h-screen",children:[t.jsx(gs,{}),t.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-16 text-center",children:[t.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Business Not Found"}),t.jsx("p",{className:"text-gray-600 mb-8",children:"The business you're looking for doesn't exist or has been removed."}),t.jsx(hs,{to:e,children:t.jsxs(q,{className:"bg-community-green hover:bg-green-600",children:[t.jsx(Hi,{className:"h-4 w-4 mr-2"}),"Back to Directory"]})})]}),t.jsx(vs,{})]});
838const d=[r.featured_image_url,...r.images||[]].filter(Boolean),h=!!o&&o.id===r.owner_id||l,f=h?6:Math.max(3,d.length),p=Array.from({length:Math.max(f,d.length)},(x,g)=>d[g]??null);return t.jsxs("div",{className:"min-h-screen bg-[hsl(180_20%_97%)]",children:[t.jsx(gs,{}),t.jsx("div",{className:"bg-background border-b border-community-teal/15 text-xs text-muted-foreground",children:t.jsxs("div",{className:"max-w-6xl mx-auto px-4 md:px-8 py-3 flex items-center gap-1.5",children:[t.jsx(hs,{to:e,className:"text-community-purple hover:underline",children:"Directory"}),t.jsx(Ac,{className:"h-3 w-3"}),t.jsx("span",{className:"truncate",children:r.name})]})}),t.jsx(zhe,{business:r}),t.jsxs("main",{className:"max-w-6xl mx-auto px-4 md:px-8 py-6 md:py-8",children:[t.jsx("div",{className:"relative",children:t.jsx("div",{children:t.jsxs("div",{className:"grid lg:grid-cols-3 gap-4 lg:gap-[18px]",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-[14px]",children:[r.description&&t.jsxs("div",{className:"bg-card border border-community-teal/25 rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-[1px] text-muted-foreground mb-3",children:[t.jsx(hc,{className:"h-3.5 w-3.5 text-community-teal"})," About"]}),t.jsx("p",{className:"text-[13px] text-foreground/75 leading-[1.7] whitespace-pre-line",children:r.description})]}),t.jsx("section",{children:t.jsxs("div",{className:"bg-card border border-community-teal/25 rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-[1px] text-muted-foreground mb-3",children:[t.jsx(pi,{className:"h-3.5 w-3.5 text-community-teal"})," Gallery"]}),t.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2.5",children:p.map((x,g)=>x?t.jsx("div",{className:"aspect-[4/3] rounded-[10px] overflow-hidden bg-card border border-community-teal/25",children:t.jsx("img",{src:x,alt:`${r.name} ${g+1}`,className:"w-full h-full object-cover"})},g):h?t.jsxs("button",{type:"button",className:"aspect-[4/3] rounded-[10px] bg-card border border-dashed border-community-teal/40 flex flex-col items-center justify-center gap-1.5 text-community-teal/70 hover:border-community-teal/70 transition-colors",children:[t.jsx(Xt,{className:"h-5 w-5"}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Add photo"})]},g):t.jsxs("div",{className:"aspect-[4/3] rounded-[10px] bg-card border border-community-teal/25 flex flex-col items-center justify-center gap-1.5 text-community-teal/40",children:[t.jsx(pi,{className:"h-6 w-6"}),t.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["Photo ",g+1]})]},g))})]})}),t.jsx(Whe,{accreditations:r.accreditations}),t.jsx(Uhe,{ownerName:r.owner_name,ownerRole:r.owner_role,ownerPhotoUrl:r.owner_photo_url,ownerQuote:r.owner_quote})]}),t.jsxs("div",{className:"space-y-[14px]",children:[t.jsx(Hhe,{business:r}),t.jsx(qhe,{openingHours:r.opening_hours})]})]})})}),t.jsxs(hs,{to:e,className:"inline-flex items-center text-community-purple hover:underline mt-8 text-sm",children:[t.jsx(Hi,{className:"h-4 w-4 mr-2"})," Back to Directory"]})]}),t.jsx(vs,{})]})},Yhe=()=>{const e=ds(),s=[{icon:t.jsx(tr,{className:"h-8 w-8 text-community-green"}),title:"Discover Local Content",description:"Browse community news, local events, business listings, and exciting competitions all in one place."},{icon:t.jsx(Sf,{className:"h-8 w-8 text-community-green"}),title:"Letterbox Delivery",description:"Our magazine is delivered directly to 142,000 homes across SO & PO postcodes through our trusted distribution network."},{icon:t.jsx(_t,{className:"h-8 w-8 text-community-green"}),title:"14 Coverage Areas",description:"We cover 14 distinct areas across South Hampshire, ensuring relevant local content for each community."},{icon:t.jsx(ua,{className:"h-8 w-8 text-community-green"}),title:"Community Engagement",description:"Connect with local businesses, attend community events, and participate in competitions to win amazing prizes."}],r=[{category:"General",questions:[{question:"What is Discover Magazine?",answer:"Discover Magazine is a community publication that covers local news, events, business directory, and competitions across South Hampshire. We deliver to 142,000 homes across SO & PO postcodes."},{question:"How often is the magazine published?",answer:"The magazine follows a regular publication schedule with deadlines for submissions. The next deadline is 14th May 2025. Check our advertising section for current deadlines."},{question:"Which areas do you cover?",answer:"We cover 14 areas across South Hampshire including Winchester & Surrounds, Itchen Valley, Meon Valley & Whiteley, New Forest & Waterside, Southampton West & Totton, Test Valley & Romsey, Winchester & Alresford, and Chandler's Ford & Eastleigh."},{question:"How can I get a copy of the magazine?",answer:"The magazine is delivered free to homes in our coverage areas. If you live in an SO or PO postcode area, you should receive it through your letterbox."}]},{category:"Events & Submissions",questions:[{question:"How do I submit an event?",answer:"You can submit events through our 'Submit an Event' form on the homepage or through the What's On section. You'll need to register for an account to submit events."},{question:"How do I submit a story or news article?",answer:"Use our 'Submit a Story' button on the homepage or contact us through the Contact page. Our editorial team will review all submissions."},{question:"Is there a deadline for event submissions?",answer:"Yes, events need to be submitted before our publication deadlines to appear in the next issue. Check the advertising section for current deadlines."},{question:"Can I submit photos with my story?",answer:"Yes, we encourage photos to accompany stories and events. You can upload images through our submission forms."}]},{category:"Business Directory",questions:[{question:"How do I add my business to the directory?",answer:"Register for an account and use the Business Directory section to create your listing. You can add details like contact information, description, and category."},{question:"Is there a cost to list my business?",answer:"Basic business directory listings are free. We also offer featured listings and advertising packages for enhanced visibility."},{question:"Can I edit my business listing?",answer:"Yes, once you've created an account and added your business, you can edit your listing details anytime through your dashboard."},{question:"How many businesses can I list?",answer:"Currently, you can list one business per account. Contact us if you need to list multiple businesses."}]},{category:"Advertising",questions:[{question:"What advertising options are available?",answer:"We offer various advertising packages including different ad sizes, areas, and duration options. Use our cost calculator to explore pricing for your needs."},{question:"How do I calculate advertising costs?",answer:"Use our interactive cost c
838alculator in the Advertising section. You can select ad size, areas, duration, and see pricing instantly."},{question:"What is the BOGOF (3 + Repeat) package?",answer:"The BOGOF package allows you to book 3 issues and receive additional benefits including a 10% voucher for our leafleting service, available in your dashboard."},{question:"When is the next advertising deadline?",answer:"The next deadline is 14th May 2025. Don't miss out - contact us to secure your advertising space."},{question:"Do you offer leafleting services?",answer:"Yes, we offer leafleting services in addition to magazine advertising. Contact us for pricing and coverage areas."}]},{category:"Account & Technical",questions:[{question:"Why do I need to create an account?",answer:"An account allows you to submit events, manage business listings, save advertising quotes, track bookings, and access special offers like vouchers."},{question:"I forgot my password, how do I reset it?",answer:"Use the password reset option on the login page. You'll receive an email with instructions to reset your password."},{question:"Can I delete my account?",answer:"Yes, you can delete your account through your Profile Settings in the dashboard. Note that this action cannot be undone."},{question:"How do I use my vouchers?",answer:"Vouchers earned from qualifying bookings appear in your dashboard. Contact us to redeem vouchers for leafleting services."}]},{category:"Distribution",questions:[{question:"How can I become a distributor?",answer:"Apply through our 'Apply to Distribute' section. We'll review your application and contact you about available territories."},{question:"What are the requirements to be a distributor?",answer:"Distributors need to be reliable, have their own transport, and be able to deliver magazines on schedule. Specific requirements are outlined in the application form."},{question:"Which areas need distributors?",answer:"Available distribution areas change regularly. Check the 'Apply to Distribute' section for current opportunities."}]}];return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx(gs,{}),t.jsxs("main",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[t.jsxs("div",{className:"text-center mb-12",children:[t.jsxs("div",{className:"inline-flex items-center gap-2 bg-primary/10 rounded-full px-4 py-2 mb-4",children:[t.jsx(Hx,{className:"h-5 w-5 text-primary"}),t.jsx("span",{className:"text-primary font-medium",children:"Support Center"})]}),t.jsx("h1",{className:"text-4xl md:text-5xl font-heading font-bold text-foreground mb-4",children:"How Can We Help You?"}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-2xl mx-auto",children:"Find answers to common questions and learn how Discover Magazine works"})]}),t.jsxs(xe,{className:"mb-12",children:[t.jsx(Me,{children:t.jsxs(Oe,{className:"flex items-center gap-2",children:[t.jsx(ar,{className:"h-5 w-5"}),"Need More Help?"]})}),t.jsx(ge,{children:t.jsxs("div",{className:"grid md:grid-cols-3 gap-4",children:[t.jsxs(q,{variant:"outline",className:"h-auto p-4 flex flex-col items-center gap-2",onClick:()=>e("/contact"),children:[t.jsx(ar,{className:"h-8 w-8 text-primary"}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"font-medium",children:"Contact Us"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Send us a message"})]})]}),t.jsxs(q,{variant:"outline",className:"h-auto p-4 flex flex-col items-center gap-2",onClick:()=>e("/advertising"),children:[t.jsx(Xo,{className:"h-8 w-8 text-primary"}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"font-medium",children:"Advertising"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Get advertising info"})]})]}),t.jsxs(q,{variant:"outline",className:"h-auto p-4 flex flex-col items-center gap-2",onClick:()=>window.open("mailto:[email protected]"),children:[t.jsx(zr,{className:"h-8 w-8 text-primary"}),t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"font-medium",children:"Email Support"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"[email protected]"})]})]})]})})]}),t.jsxs("section",{className:"mb-12",children:[t.jsx("h2",{className:"text-3xl font-heading font-bold text-foreground mb-8 text-center",children:"How Discover Magazine Works"}),t.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:s.map((n,a)=>t.jsx(xe,{className:"text-center",children:t.jsxs(ge,{className:"p-6",children:[t.jsx("div",{className:"flex justify-center mb-4",children:n.icon}),t.jsx("h3",{className:"text-lg font-semibold mb-2",children:n.title}),t.jsx("p",{className:"text-muted-foreground text-sm",children:n.description})]})},a))}),t.jsx(xe,{className:"bg-gradient-to-r from-primary/5 to-community-green/5 border-primary/20",children:t.jsx(ge,{className:"p-8",children:t.jsxs("div",{className:"grid md:grid-cols-2 gap-8 items-center",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-2xl font-bold mb-4",children:"About Our Publication"}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(we,{variant:"secondary",className:"bg-community-green/10 text-community-green",children:[t.jsx(_t,{className:"h-3 w-3 mr-1"}),"Coverage"]}),t.jsx("span",{className:"text-sm",children:"142,000 homes across SO & PO postcodes"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(we,{variant:"secondary",className:"bg-community-green/10 text-community-green",children:[t.jsx(qx,{className:"h-3 w-3 mr-1"}),"Areas"]}),t.jsx("span",{className:"text-sm",children:"14 distinct areas across South Hampshire"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(we,{variant:"secondary",className:"bg-community-green/10 text-community-green",children:[t.jsx(ws,{className:"h-3 w-3 mr-1"}),"Delivery"]}),t.jsx("span",{className:"text-sm",children:"Regular letterbox delivery schedule"})]})]})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-lg font-semibold mb-3",children:"What We Feature"}),t.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(ir,{className:"h-4 w-4 text-community-green"}
838),"Local community news and stories"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(It,{className:"h-4 w-4 text-community-green"}),"Upcoming events and activities"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(qx,{className:"h-4 w-4 text-community-green"}),"Local business directory"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(yr,{className:"h-4 w-4 text-community-green"}),"Competitions with great prizes"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(Xo,{className:"h-4 w-4 text-community-green"}),"Business advertising opportunities"]})]})]})]})})})]}),t.jsx("div",{className:"my-16",children:t.jsx(fs,{})}),t.jsxs("section",{className:"bg-gradient-to-br from-muted/20 to-muted/10 rounded-2xl p-8 md:p-12",children:[t.jsxs("div",{className:"text-center mb-12",children:[t.jsxs("div",{className:"inline-flex items-center gap-2 bg-primary/10 rounded-full px-4 py-2 mb-4",children:[t.jsx(Hx,{className:"h-5 w-5 text-primary"}),t.jsx("span",{className:"text-primary font-medium",children:"FAQ"})]}),t.jsx("h2",{className:"text-3xl font-heading font-bold text-foreground mb-4",children:"Frequently Asked Questions"}),t.jsx("p",{className:"text-muted-foreground max-w-2xl mx-auto",children:"Find quick answers to the most common questions about Discover Magazine"})]}),r.map((n,a)=>t.jsxs(xe,{className:"mb-6",children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-xl text-primary",children:n.category})}),t.jsx(ge,{children:t.jsx(Ru,{type:"single",collapsible:!0,className:"w-full",children:n.questions.map((i,o)=>t.jsxs(ti,{value:`${a}-${o}`,children:[t.jsx(si,{className:"text-left hover:text-primary",children:i.question}),t.jsx(ri,{className:"text-muted-foreground pt-2",children:i.answer})]},o))})})]},a))]}),t.jsx(xe,{className:"mt-12 bg-gradient-to-r from-community-green/5 to-primary/5 border-community-green/20",children:t.jsxs(ge,{className:"p-8 text-center",children:[t.jsx("h3",{className:"text-2xl font-bold mb-4",children:"Still Have Questions?"}),t.jsx("p",{className:"text-muted-foreground mb-6 max-w-2xl mx-auto",children:"Our team is here to help! Whether you need assistance with advertising, submissions, or general inquiries, we're just a message away."}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[t.jsxs(q,{size:"lg",onClick:()=>e("/contact"),className:"bg-community-green hover:bg-community-green/90",children:[t.jsx(ar,{className:"h-5 w-5 mr-2"}),"Contact Us"]}),t.jsxs(q,{variant:"outline",size:"lg",onClick:()=>e("/advertising"),children:[t.jsx(Xo,{className:"h-5 w-5 mr-2"}),"Advertising Enquiry"]})]})]})})]}),t.jsx(vs,{})]})},Khe=()=>{const[e]=Hw(),s=ds(),{toast:r}=rt(),[n,a]=u.useState("loading"),[i,o]=u.useState("Setting up your payment...");return u.useEffect(()=>{(async()=>{const c=e.get("booking_id"),d=e.get("redirect_flow_id"),m=e.get("stripe_success"),h=e.get("stripe_session_id");if(!c){a("error"),o("No booking ID found");return}try{if(m==="true"||h){await W.from("bookings").update({payment_status:"payment_pending",status:"submitted"}).eq("id",c),a("success"),o("Payment received! Redirecting to your dashboard..."),r({title:"Payment Successful",description:"Your card payment has been processed successfully."}),setTimeout(()=>{s("/dashboard?tab=artwork")},2e3);return}if(d){const{data:f,error:p}=await W.from("bookings").select("*").eq("id",c).single();if(p||!f)throw new Error("Booking not found");const x=f.selections,g=x==null?void 0:x.payment_option_id;if(!g)throw new Error("Payment option not found");const{data:b,error:w}=await W.from("payment_options").select("*").eq("option_type",g).single();if(w||!b)throw new Error("Payment option not found");const{data:j,error:y}=await W.functions.invoke("complete-gocardless-redirect",{body:{redirectFlowId:d,bookingId:c}});if(y||!j)throw new Error("Failed to complete redirect flow");const v=j.mandateId,N=j.customerId;await W.from("gocardless_mandates").insert({user_id:f.user_id,booking_id:c,gocardless_mandate_id:v,gocardless_customer_id:N,status:"pending_submission",scheme:"bacs"}),await W.from("bookings").update({gocardless_mandate_id:v,payment_status:"mandate_created"}).eq("id",c);const S=b.option_type==="monthly",k=S?f.monthly_price||0:f.final_total,{error:$}=await W.functions.invoke("create-gocardless-payment",{body:{bookingId:c,mandateId:v,paymentType:S?"subscription":"one-off",amount:k,paymentOptionId:b.id}});if($)throw $;if(await W.from("bookings").update({payment_status:"payment_pending",status:"submitted"}).eq("id",c),f.pricing_model==="bogof"){console.log("Generating voucher for BOGOF booking after payment setup...");try{const{data:R,error:A}=await W.rpc("generate_voucher_code");if(!A&&R){const T=new Date;T.setMonth(T.getMonth()+6),await W.from("vouchers").insert({user_id:f.user_id,voucher_code:R,voucher_type:"percentage",discount_value:10,service_type:"leafleting",description:"10% discount on leafleting services - Earned from 3+ Subscription Package booking",expires_at:T.toISOString(),created_from_booking_id:c})}}catch(R){console.error("Error creating voucher:",R)}}a("success"),o("Payment setup complete! Redirecting to your dashboard..."),f.pricing_model==="bogof"&&localStorage.setItem("showVoucherNotification","true"),r({title:"Payment Setup Complete",description:"Your Direct Debit has been set up successfully."}),setTimeout(()=>{s("/dashboard?tab=artwork")},2e3)}else a("error"),o("No payment redirect found. Please initiate payment from your booking details.")}catch(f){console.error("Error setting up payment:",f),a("error"),o(f.message||"Failed to set up payment"),r({title:"Payment Setup Failed",description:"There was an error setting up your payment. Please contact support.",variant:"destructive"})}})()},[e,s,r]),t.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background",children:t.jsxs(xe,{className:"w-full max-w-md",children:[t.jsxs(Me,{className:"text-center",children:[t.jsx(Oe,{children:"Payment Setup"}),t.jsxs(Er,{children:[n==="loading"&&"Please wait while we set up your payment...",n==="success"&&"Your payment has been set up successfully!",n==="error"&&"There was an error setting up your payment"]})]}),t.jsxs(ge,{className:"flex flex-col items-center gap-4",children:[n==="loading"&&t.jsx(it,{className:"h-12 w-12 animate-spin text-primary"}),n==="success"&&t.jsx(xs,{className:"h-12 w-12 text-green-500"}),n==="error"&&t.jsx(Nf,{className:"h-12 w-12 text-destructive"}),t.jsx("p",{className:"text-center text-muted-foreground",children:i}),n==="error"&&t.jsxs("div",{className:"flex gap-2 mt-4",children:[t.jsx(q,{onClick:()=>s("/dashboard"),variant:"outline",children:"Go to Dashboard"}),t.jsx(q,{onClick:()=>window.location.reload(),children:"Try Again"})]})]})]})})},Qhe=()=>{const[e,s]=u.useState(""),[r,n]=u.useState(""),[a,i]=u.useState(!1),[o,l]=u.useState(!1),[c,d]=u.useState(!1),[m,h]=u.useState(!1),[f,p]=u.useState(!1),[x,g]=u.useState(!0),[b,w]=u.useState(5),j=ds(),{toast:y}=rt();u.useEffect(()=>{(async()=>{try{const{data:{session:S}}=await W.auth.getSession();if(S){window.history.replaceState({},"",window.location.pathname),p(!0),g(!1);return}const $=new URLSearchParams(window.location.search).get("code");if($){console.log("Found PKCE code, exchanging for session...");const{error:P}=await W.auth.exchangeCodeForSession($);
838if(P){console.error("Error exchanging code for session:",P),p(!1),g(!1);return}else{window.history.replaceState({},"",window.location.pathname),p(!0),g(!1);return}}const R=new URLSearchParams(window.location.hash.substring(1)),A=R.get("access_token");if(R.get("type")==="recovery"&&A){const{error:P}=await W.auth.setSession({access_token:A,refresh_token:R.get("refresh_token")||""});P?(console.error("Error setting recovery session:",P),p(!1)):(window.history.replaceState({},"",window.location.pathname),p(!0))}else p(!1)}catch(S){console.error("Error checking session:",S),p(!1)}finally{g(!1)}})()},[]),u.useEffect(()=>{if(m&&b>0){const N=setTimeout(()=>{w(b-1)},1e3);return()=>clearTimeout(N)}else m&&b===0&&j("/dashboard")},[m,b,j]);const v=async N=>{if(N.preventDefault(),e!==r){y({title:"Passwords don't match",description:"Please make sure both passwords are the same.",variant:"destructive"});return}if(e.length<6){y({title:"Password too short",description:"Password must be at least 6 characters long.",variant:"destructive"});return}i(!0);try{const{error:S}=await W.auth.updateUser({password:e});S?(console.error("Error updating password:",S),y({title:"Error",description:S.message,variant:"destructive"})):(h(!0),y({title:"Password Updated",description:"Your password has been successfully changed."}))}catch(S){console.error("Unexpected error:",S),y({title:"Error",description:"An unexpected error occurred. Please try again.",variant:"destructive"})}finally{i(!1)}};return x?t.jsxs("div",{className:"min-h-screen",children:[t.jsx(gs,{}),t.jsx("main",{className:"py-16 bg-gray-50",children:t.jsx("div",{className:"max-w-md mx-auto px-4",children:t.jsx(xe,{children:t.jsxs(ge,{className:"py-12 text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-community-green mx-auto mb-4"}),t.jsx("p",{className:"text-muted-foreground",children:"Verifying your reset link..."})]})})})}),t.jsx(vs,{})]}):f?m?t.jsxs("div",{className:"min-h-screen",children:[t.jsx(gs,{}),t.jsx("main",{className:"py-16 bg-gray-50",children:t.jsx("div",{className:"max-w-md mx-auto px-4",children:t.jsx(xe,{children:t.jsxs(ge,{className:"py-12 text-center",children:[t.jsx(xs,{className:"h-16 w-16 text-community-green mx-auto mb-4"}),t.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Password Updated!"}),t.jsxs("p",{className:"text-muted-foreground mb-6",children:["Your password has been successfully changed. Redirecting to your dashboard in ",b," seconds..."]}),t.jsx(q,{onClick:()=>j("/dashboard"),className:"bg-community-green hover:bg-green-600",children:"Go to Dashboard Now"})]})})})}),t.jsx(vs,{})]}):t.jsxs("div",{className:"min-h-screen",children:[t.jsx(gs,{}),t.jsx("main",{className:"py-16 bg-gray-50",children:t.jsxs("div",{className:"max-w-md mx-auto px-4",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx(Cu,{className:"h-12 w-12 text-community-green mx-auto mb-4"}),t.jsx("h1",{className:"text-3xl font-heading font-bold mb-4",children:"Set New Password"}),t.jsx("p",{className:"text-gray-600",children:"Enter your new password below. Make sure it's at least 6 characters long."})]}),t.jsxs(xe,{children:[t.jsx(Me,{children:t.jsx(Oe,{className:"text-center",children:"Create New Password"})}),t.jsx(ge,{children:t.jsxs("form",{onSubmit:v,className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"password",className:"block text-sm font-medium mb-1",children:"New Password"}),t.jsxs("div",{className:"relative",children:[t.jsx(re,{id:"password",type:o?"text":"password",value:e,onChange:N=>s(N.target.value),required:!0,placeholder:"Enter new password",minLength:6,disabled:a,className:"pr-10"}),t.jsx("button",{type:"button",onClick:()=>l(!o),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:o?t.jsx(di,{className:"h-4 w-4"}):t.jsx(tr,{className:"h-4 w-4"})})]})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium mb-1",children:"Confirm Password"}),t.jsxs("div",{className:"relative",children:[t.jsx(re,{id:"confirm-password",type:c?"text":"password",value:r,onChange:N=>n(N.target.value),required:!0,placeholder:"Confirm new password",minLength:6,disabled:a,className:"pr-10"}),t.jsx("button",{type:"button",onClick:()=>d(!c),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:c?t.jsx(di,{className:"h-4 w-4"}):t.jsx(tr,{className:"h-4 w-4"})})]})]}),e&&r&&e!==r&&t.jsx("p",{className:"text-sm text-red-500",children:"Passwords do not match"}),t.jsx(q,{type:"submit",className:"w-full bg-community-green hover:bg-green-600",disabled:a||e!==r||e.length<6,children:a?"Updating Password...":"Update Password"})]})})]})]})}),t.jsx(vs,{})]}):t.jsxs("div",{className:"min-h-screen",children:[t.jsx(gs,{}),t.jsx("main",{className:"py-16 bg-gray-50",children:t.jsx("div",{className:"max-w-md mx-auto px-4",children:t.jsxs(xe,{children:[t.jsxs(Me,{className:"text-center",children:[t.jsx(Oe,{className:"text-red-600",children:"Invalid Reset Link"}
838),t.jsx(Er,{children:"This password reset link is invalid or has expired."})]}),t.jsx(ge,{className:"text-center",children:t.jsx(q,{onClick:()=>j("/auth"),className:"bg-community-green hover:bg-green-600",children:"Back to Sign In"})})]})})}),t.jsx(vs,{})]})},Xhe=({children:e})=>{const{user:s,loading:r}=Ar(),n=ds();return u.useEffect(()=>{!r&&!s&&n("/auth")},[s,r,n]),r?t.jsx("div",{className:"min-h-screen flex items-center justify-center",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-community-green mx-auto mb-4"}),t.jsx("p",{className:"text-gray-600",children:"Checking authentication..."})]})}):s?t.jsx(t.Fragment,{children:e}):null},z7=()=>{const e=Va();return u.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",e.pathname)},[e.pathname]),t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h1",{className:"text-4xl font-bold mb-4",children:"404"}),t.jsx("p",{className:"text-xl text-gray-600 mb-4",children:"Oops! Page not found"}),t.jsx("a",{href:"/",className:"text-blue-500 hover:text-blue-700 underline",children:"Return to Home"})]})})},F0=({children:e})=>{const{isAdmin:s,loading:r}=Ar();return r?t.jsx("div",{className:"min-h-screen flex items-center justify-center",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-community-green mx-auto mb-4"}),t.jsx("p",{className:"text-gray-600",children:"Loading..."})]})}):s?t.jsx(t.Fragment,{children:e}):t.jsx(z7,{})},Zhe=()=>{const{pathname:e}=Va();return u.useEffect(()=>{window.scrollTo(0,0)},[e]),null},Jhe=()=>{var d;const{slug:e}=xv(),[s,r]=u.useState(null),[n,a]=u.useState(!0);u.useEffect(()=>{const m=document.createElement("meta");return m.name="robots",m.content="noindex",document.head.appendChild(m),()=>{m.remove()}},[]),u.useEffect(()=>{(async()=>{a(!0);const{data:m}=await W.rpc("get_public_media_file",{_slug:e}),h=Array.isArray(m)?m[0]:null;r(h||null),a(!1),h&&(document.title=`${h.public_title||h.file_name} | Discover Magazines`)})()},[e]);const i=s?h1(s.file_path):"",o=s?h1(s.file_path,s.file_name):"",l=s==null?void 0:s.file_type.includes("pdf"),c=s==null?void 0:s.file_type.startsWith("image/");return t.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[t.jsx(gs,{}),t.jsx("main",{className:"flex-1 container mx-auto px-4 py-10 max-w-5xl",children:n?t.jsx("div",{className:"flex justify-center py-24",children:t.jsx(it,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):s?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex flex-col md:flex-row md:items-end md:justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold",children:s.public_title||s.file_name}),s.public_description&&t.jsx("p",{className:"text-muted-foreground mt-2 whitespace-pre-line",children:s.public_description}),t.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:[(d=s.file_name.split(".").pop())==null?void 0:d.toUpperCase()," ⢠",Yde(s.file_size)]})]}),t.jsx(q,{asChild:!0,size:"lg",children:t.jsxs("a",{href:o,download:s.file_name,children:[t.jsx(ei,{className:"h-4 w-4 mr-2"}),"Download file"]})})]}),l?t.jsx("iframe",{src:i,title:s.file_name,className:"w-full h-[80vh] rounded-lg border bg-muted"}):c?t.jsx("img",{src:i,alt:s.public_title||s.file_name,className:"max-w-full rounded-lg border mx-auto"}):t.jsxs("div",{className:"rounded-lg border bg-muted p-12 text-center",children:[t.jsx(ir,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),t.jsx("p",{className:"text-muted-foreground",children:"Preview isn't available for this file type â use Download file to open it."})]})]}):t.jsxs("div",{className:"text-center py-24",children:[t.jsx("h1",{className:"text-3xl font-bold mb-3",children:"File not available"}),t.jsx("p",{className:"text-muted-foreground mb-6",children:"This file has been removed or the link is incorrect."}),t.jsx(q,{asChild:!0,variant:"outline",children:t.jsx(hs,{to:"/",children:"Back to home"})})]})}),t.jsx(vs,{})]})},efe=()=>t.jsxs(QE,{children:[t.jsx(ZL,{}),t.jsx(kB,{}),t.jsx(XU,{children:t.jsxs(bH,{children:[t.jsx(Zhe,{}),t.jsxs(UU,{children:[t.jsx(Rs,{path:"/",element:t.jsx(BX,{})}),t.jsx(Rs,{path:"/whats-on",element:t.jsx(F0,{children:t.jsx(rJ,{})})}),t.jsx(Rs,{path:"/whats-on/archive",element:t.jsx(F0,{children:t.jsx(nJ,{})})}),t.jsx(Rs,{path:"/events/:slug",element:t.jsx(F0,{children:t.jsx(wue,{})})}),t.jsx(Rs,{path:"/competitions",element:t.jsx(Wee,{})}),t.jsx(Rs,{path:"/advertising",element:t.jsx(use,{})}),t.jsx(Rs,{path:"/apply-to-distribute",element:t.jsx(mse,{})}),t.jsx(Rs,{path:"/contact",element:t.jsx(Gse,{})}),t.jsx(Rs,{path:"/support",element:t.jsx(Yhe,{})}),t.jsx(Rs,{path:"/business-directory",element:t.jsx(kZ,{})}),t.jsx(Rs,{path:"/business/:slug",element:t.jsx(Ghe,{})}),t.jsx(Rs,{path:"/stories",element:t.jsx(_ue,{})}),t.jsx(Rs,{path:"/story/:id",element:t.jsx(Nue,{})}),t.jsx(Rs,{path:"/files/:slug",element:t.jsx(Jhe,{})}),t.jsx(Rs,{path:"/auth",element:t.jsx(Yse,{})}),t.jsx(Rs,{path:"/reset-password",element:t.jsx(Qhe,{})}),t.jsx(Rs,{path:"/dashboard",element:t.jsx(eie,{})}),t.jsx(Rs,{path:"/admin",element:t.jsx(uue,{})}),t.jsx(Rs,{path:"/add-event",element:t.jsx(Xhe,{children:t.jsx(yue,{})})}),t.jsx(Rs,{path:"/payment-setup",element:t.jsx(Khe,{})}),t.jsx(Rs,{path:"/calendars-with-sidebar-2-2",element:t.jsx(BU,{to:"/advertising",replace:!0})}),t.jsx(Rs,{path:"*",element:t.jsx(z7,{})})]})]})})]});window.addEventListener("unhandledrejection",e=>{console.error("[Diagnostics] Unhandled promise rejection:",e.reason)});window.addEventListener("error",e=>{const s=e;console.error("[Diagnostics] Uncaught error:",s.error||s.message)});x$(document.getElementById("root")).render(t.jsx(XI,{children:t.jsx(efe,{})}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.