@cpra/mp-ui 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cpra-mp-ui.js +25 -9
- package/dist/cpra-mp-ui.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/cpra-mp-ui.js
CHANGED
|
@@ -382,12 +382,25 @@ class ip {
|
|
|
382
382
|
dtype;
|
|
383
383
|
model;
|
|
384
384
|
subroutine;
|
|
385
|
+
// `unit` describes the values as stored; the display_* fields describe how they are
|
|
386
|
+
// shown, which differs when a variable is stored in a finer unit than it is read in.
|
|
387
|
+
// `display_scale_factor` is the divisor taking a stored value to a displayed one, and no
|
|
388
|
+
// variable currently sets it — storage and display units are the same throughout. The
|
|
389
|
+
// API already applies all three to everything it renders (chart specs, map legends), so
|
|
390
|
+
// these are only for a client that formats raw dataset values itself.
|
|
385
391
|
unit;
|
|
392
|
+
display_unit;
|
|
393
|
+
display_scale_factor;
|
|
394
|
+
display_number_format;
|
|
395
|
+
// Decimal places the API has already rounded this variable's values to in a CSV
|
|
396
|
+
// response, reported so a client can tell a rounded download from a full-precision one.
|
|
397
|
+
// Nothing to apply: the other formats carry the stored value, and formatting a value for
|
|
398
|
+
// display is `display_number_format`'s job.
|
|
399
|
+
float_precision;
|
|
386
400
|
legend;
|
|
387
401
|
geographic_units;
|
|
388
402
|
time_units;
|
|
389
403
|
required_dimensions;
|
|
390
|
-
number_format;
|
|
391
404
|
difference_legend_limit;
|
|
392
405
|
structure;
|
|
393
406
|
constructor({
|
|
@@ -397,14 +410,17 @@ class ip {
|
|
|
397
410
|
model: o,
|
|
398
411
|
subroutine: a,
|
|
399
412
|
unit: s,
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
413
|
+
display_unit: i,
|
|
414
|
+
display_scale_factor: c,
|
|
415
|
+
display_number_format: l,
|
|
416
|
+
float_precision: u,
|
|
417
|
+
legend: d,
|
|
418
|
+
geographic_units: m,
|
|
419
|
+
time_units: h,
|
|
420
|
+
required_dimensions: g,
|
|
421
|
+
difference_legend_limit: f
|
|
422
|
+
}, p) {
|
|
423
|
+
this.name = t, this.label = n, this.dtype = r, this.model = o, this.subroutine = a, this.unit = s, this.display_unit = i, this.display_scale_factor = c, this.display_number_format = l, this.float_precision = u, this.legend = d, this.geographic_units = m, this.time_units = h, this.required_dimensions = g, this.difference_legend_limit = f, this.structure = p;
|
|
408
424
|
}
|
|
409
425
|
}
|
|
410
426
|
class sp {
|
package/dist/cpra-mp-ui.umd.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(K,J){typeof exports=="object"&&typeof module<"u"?J(exports,require("jotai"),require("jotai/utils"),require("react"),require("jotai-effect"),require("react/jsx-runtime"),require("vega-embed"),require("maplibre-gl"),require("react-dom"),require("jotai-scope")):typeof define=="function"&&define.amd?define(["exports","jotai","jotai/utils","react","jotai-effect","react/jsx-runtime","vega-embed","maplibre-gl","react-dom","jotai-scope"],J):(K=typeof globalThis<"u"?globalThis:K||self,J(K.CpraMpUi={},K.Jotai,K.JotaiUtils,K.React,K.JotaiEffect,K.jsxRuntime,K.VegaEmbed,K.MapLibreGl,K.ReactDOM,K.JotaiScope))})(this,(function(K,J,Ot,A,Rt,y,$f,tr,bo,Jf){"use strict";function Pi(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const v=Pi(A),Oi=Pi(bo);class yn extends Error{}yn.prototype.name="InvalidTokenError";function jf(e){return decodeURIComponent(atob(e).replace(/(.)/g,(t,n)=>{let r=n.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}function Uf(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return jf(t)}catch{return atob(t)}}function Qf(e,t){if(typeof e!="string")throw new yn("Invalid token specified: must be a string");t||(t={});const n=t.header===!0?0:1,r=e.split(".")[n];if(typeof r!="string")throw new yn(`Invalid token specified: missing part #${n+1}`);let o;try{o=Uf(r)}catch(a){throw new yn(`Invalid token specified: invalid base64 for part #${n+1} (${a.message})`)}try{return JSON.parse(o)}catch(a){throw new yn(`Invalid token specified: invalid json for part #${n+1} (${a.message})`)}}const Di=e=>({...e,tags:e.tags.filter(t=>!t.name.startsWith("meta_type:"))}),Ni=e=>{const t={...e};return"markdown_description"in t&&(t.markdown_content=t.markdown_description,delete t.markdown_description),t},Lt="https://api.mpdp.coastal.la.gov/v1",qf="https://mpdp.coastal.la.gov",Kf="https://api.mpdp.coastal.la.gov/tiles",ep="https://api.mpdp.coastal.la.gov/v1/management",Ti=["ff0000","0aefff","ffd300","be0aff","0aff99","580aff","deff0a","ff8700","a1ff0a","147df5"],tp=["Red","Cyan","Yellow","Purple","Teal","Indigo","Lime","Orange","Green","Blue"],np=[{value:"type:qaqc_high",label:"Type: QA/QC (High Concern)"},{value:"type:qaqc_moderate",label:"Type: QA/QC (Moderate Concern)"},{value:"type:qaqc_low",label:"Type: QA/QC (Low Concern)"},{value:"type:narrative",label:"Type: Narrative"},{value:"impact:project",label:"Impact: Project"},{value:"impact:fwoa",label:"Impact: FWOA"},{value:"theme:stg",label:"Theme: Water Levels and Inundation"},{value:"theme:sal",label:"Theme: Salinities and Estuarine Gradient"},{value:"theme:lnd",label:"Theme: Land Change"},{value:"theme:veg",label:"Theme: Vegetation Coverage and Habitat Diversity"},{value:"theme:sed",label:"Theme: Sedimentation Patterns"},{value:"theme:hs",label:"Theme: Habitat Suitabilities"},{value:"theme:wave",label:"Theme: Wave Generation Conditions"},{value:"story:comp",label:"Storyline: Compartments Scale"},{value:"story:basin",label:"Storyline: Basin Scale"},{value:"story:coast",label:"Storyline: Coastwide Scale"},{value:"story:ad",label:"Storyline: Annual/Decadal Trends"},{value:"story:dms",label:"Storyline: Daily/Monthly/Seasonal Trends"},{value:"story:time",label:"Storyline: Changes Over Time"},{value:"story:scenario",label:"Storyline: Changes Across Scenarios"}];async function nr(e,{body:t=null,headers:n={},method:r="GET"}={}){const o=await fetch(e,{body:t?JSON.stringify(t):null,headers:{...n,accept:"application/json"},method:r});if(o.status<200||o.status>299)return{error:{status:o.status}};try{return await o.json()}catch(a){return{error:{message:a}}}}async function rp(e,{signal:t}={signal:null}){const n=await fetch(e,{headers:{accept:"application/x-ndjson"},signal:t});if(n.status<200||n.status>299)return console.error(`Received status ${n.status} while loading ${e}`),[];try{return(await n.text()).split(`
|
|
2
|
-
`).filter(r=>r.length>0).map(r=>JSON.parse(r))}catch(r){return console.error(`Error while loading ${e}: ${r}`),[]}}function Cn(e,t="name"){const n={};for(let r of e)n[r[t]]=r;return n}function op(e,t=1,n=null){const r=[];for(let o of e)if(Array.isArray(o)){let[a,s]=o;if(typeof o[0]=="number")for(;a<=s;)r.push(a),a+=t;else{let[i,c]=[a,s].map(l=>new Date(`${l}T00:00:00`));for(;i<=c;)(n===null||i.getDate()===n)&&r.push(new Date(i.valueOf()).toISOString().split("T")[0]),i.setDate(i.getDate()+t)}}else r.push(o);return r}function Fi(e,t){const n={};for(let r in e){let o=1,a=null;r.startsWith("calendar_")&&(t.time_unit=="decadal"&&(o=10),t.time_unit=="monthly"&&(a=1)),n[r]=op(e[r],o,a)}return n}function Gi(e,t=null){const n={};for(let r of e)for(let o in r)if(!t||t.includes(o)){const a=r[o];if(o in n)for(let s of a)n[o].includes(s)||n[o].push(s);else n[o]=a}return n}function _i(e,t,n=null,r=[]){const o=[];for(let a of e){let s=0;for(let i of t[a.name]||[])if(o.push([a.name,i]),s++,n&&!r.includes(a.name)&&s===n)break}return o}function wn(e){return e.length?`?${e.map(([t,n])=>`${t}=${encodeURIComponent(n.toString())}`).join("&")}`:""}function ap(e){return new Promise(t=>setTimeout(t,e))}const ip=(e,t)=>`#${e.replace(/../g,n=>`0${Math.min(255,Math.max(0,parseInt(n,16)+t)).toString(16)}`.substr(-2))}`,Wi=(e,{adjustment:t,count:n}={})=>ip(Ti.slice(0,n)[e]||"000000",t||0),Bi=([e,t])=>[e,t].map(n=>parseFloat(n.toFixed(5))),sp=e=>{const t=e.split("-").map(n=>parseInt(n));return new Date(t[0],t[1]-1,t[2])};function cp(e){return(e||"").replace(/\w\S*/g,t=>t.charAt(0).toUpperCase()+t.substring(1).toLowerCase())}function vo(e,t){if(!t)return e;const n=r=>{const o=(t||[]).indexOf(r);return o===-1?9999:o};e.sort((r,o)=>n(r)-n(o))}function Ht(e,t=""){return t==="calendar_day"?`'${e}'::date`:typeof e=="number"?e:`'${e}'`}const Vi=e=>e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1_$2").toLowerCase(),yo=()=>new URLSearchParams(window.location.hash.replace(/^#/,"")),Ri=e=>{e.sort();let t=e.toString();return e.has("map")&&(t=t.replace(/(^|&)map=[^&]+/,`$1map=${e.get("map")}`)),t?`#${t}`:""},rr=[],Li=e=>{const t=rr.flatMap(n=>n.fromHash?[[n.atom,n.fromHash(e)]]:[]);Ot.useHydrateAtoms(t)},Hi=(e,{include:t,exclude:n}={})=>{const r=new URLSearchParams;for(const o of rr)o.updateHash&&o.updateHash(r,e(o.atom));if(t)for(const o of r.keys())t.includes(o)||r.delete(o);if(n)for(const o of n)r.delete(o);return r.sort(),Ri(r)},lp=e=>{const t=Hi(e);t!==Ri(yo())&&window.history.pushState(window.history.state,"",t)},up=Rt.atomEffect((e,t)=>{const n=()=>{const r=yo();for(const o of rr)o.fromHash&&t(o.atom,o.fromHash(r))};return window.addEventListener("hashchange",n,!1),()=>window.removeEventListener("hashchange",n)}),dp=Rt.atomEffect(e=>lp(e)),Xi=(e,t)=>{const{key:n}=t;zi.push(n);const r=t.encoder||(i=>typeof i=="string"?i:JSON.stringify(i)),o=t.decoder||(i=>{try{return JSON.parse(i)}catch(c){if(c instanceof SyntaxError)return i;throw c}});return[i=>i.has(n)?o(i.get(n)):e,(i,c)=>{!t.includeDefault&&r(c)===r(e)?i.delete(n):i.set(n,r(c))}]},zi=[],Re=(e,t)=>{let n,r;"key"in t?[n,r]=Xi(e,t):(n=t.fromHash,r=t.updateHash);const o=J.atom(e);return rr.push({atom:o,fromHash:n,updateHash:r}),o},fp=e=>{const t={},n={};for(const a of Object.keys(e)){const[s,i]=Xi(e[a],{key:Vi(a)});t[a]=s,n[a]=i}return Re(e,{fromHash:a=>{const s={};for(const i of Object.keys(e))s[i]=t[i](a);return s},updateHash:(a,s)=>{for(const i of Object.keys(e))n[i](a,s[i])}})},yt=e=>Array.isArray(e),pp=e=>yt(e)?`(${e.join(", ")})`:`${e}`;class Ye{geographies;constructor(t=[]){this.geographies=t}get length(){return this.geographies.length}add(t){return new Ye([...this.geographies.filter(yt),t])}editable(){return this.geographies.every(yt)?this:new Ye(this.geographies.filter(yt))}remove(t){const n=[...this.geographies];return n.splice(t,1),new Ye(n)}replace(t,n){const r=[...this.geographies];return r[t]=n,new Ye(r)}rotate(t){const n=t==0?this.geographies:[...this.geographies.slice(t),...this.geographies.slice(0,t)];return new Ye(n)}}class mp{value;label;constructor({value:t,label:n}){this.value=t,this.label=n}}class hp{name;label;type;dtype;required;null;values;minValue;maxValue;isFilter;filterType;constructor({name:t,label:n,type:r,dtype:o,required:a,null:s,values:i,min_value:c,max_value:l}){this.name=t,this.label=n,this.type=r,this.dtype=o,this.required=a,this.null=s,this.values=i?i.map(u=>new mp(u)):null,this.minValue=c,this.maxValue=l,this.isFilter=!["dataset","metadata"].includes(r),this.filterType=this.isFilter?t.startsWith("calendar_")?"time":"select":null}}class gp{name;label;dtype;model;subroutine;unit;legend;geographic_units;time_units;required_dimensions;number_format;difference_legend_limit;structure;constructor({name:t,label:n,dtype:r,model:o,subroutine:a,unit:s,legend:i,geographic_units:c,time_units:l,required_dimensions:u,number_format:d,difference_legend_limit:p},h){this.name=t,this.label=n,this.dtype=r,this.model=o,this.subroutine=a,this.unit=s,this.legend=i,this.geographic_units=c,this.time_units=l,this.required_dimensions=u,this.number_format=d,this.difference_legend_limit=p,this.structure=h}}class bp{name;label;grid_type;crs;geographies;bounds;height;width;constructor({name:t,label:n,grid_type:r,crs:o,geographies:a,bounds:s,height:i,width:c}){this.name=t,this.label=n,this.grid_type=r,this.crs=o,this.geographies=a,this.bounds=s,this.height=i,this.width=c}isRaster(){return this.grid_type==="raster"}isVector(){return this.grid_type==="vector"}getTileUrl(){return this.isVector()?`${Kf}/${this.name}`:null}getGeographyUrl(t){const n=[["geography",t.flat().join(",")],["to_grid",this.name]];return`${Lt}/grids/wgs84/crosswalk.ndjson${wn(n)}`}}class vp{label;color;upper_bound;constructor({label:t,color:n,upper_bound:r}){this.label=t,this.color=n,this.upper_bound=r}}class yp{name;break_points;constructor({name:t,break_points:n}){this.name=t,this.break_points=n.map(r=>new vp(r))}}class Cp{variable;grid;time_unit;constructor({variable:t,grid:n,time_unit:r}){this.variable=t,this.grid=n,this.time_unit=r}getBaseUrl(){return`${Lt}/datasets/${this.variable.name}/${this.grid.name}/${this.time_unit}`}getDataUrl(t,n){return`${this.getBaseUrl()}/data.${n}${wn(t)}`}getTileUrl(t){return this.grid.getTileUrl()||`${this.getBaseUrl()}/data/{z}/{x}/{y}.png${wn(t)}`}getTimeColumn(){return["annual","decadal"].includes(this.time_unit)?"calendar_year":"calendar_day"}}class wp{name;label;type;max_geographies;variables;constructor({name:t,label:n,type:r,max_geographies:o,variables:a}){this.name=t,this.label=n,this.type=r,this.max_geographies=o,this.variables=a}getSpecUrl(t,n,r=[]){const o=[...t.getQueryParams({...n,includeTimeDimension:!n.geographies,maxGeographies:this.max_geographies}),...r];return`${this.type==="dataset"?`${t.dataset.getBaseUrl()}/visualization`:`${Lt}/visualizations`}/${this.name}.json${wn(o)}`}}class Ip{datasets;dimensions;dimensionsMap;variables;variablesMap;grids;gridsMap;legends;legendsMap;visualizations;visualizationsMap;constructor(t,n,r,o,a,s){this.dimensions=n.map(i=>new hp(i)),this.dimensionsMap=Cn(this.dimensions),this.grids=o.map(i=>new bp(i)),this.gridsMap=Cn(this.grids),this.legends=a.map(i=>new yp(i)),this.legendsMap=Cn(this.legends),this.visualizations=s.map(i=>new wp(i)),this.visualizationsMap=Cn(this.visualizations),this.variables=r.map(i=>new gp({...i,legend:i.legend?this.legendsMap[i.legend]:this.legendsMap.default,required_dimensions:i.required_dimensions?i.required_dimensions.map(c=>this.dimensionsMap[c]):[]},this)),this.variablesMap=Cn(this.variables),this.datasets=t.map(i=>{const c=this.variablesMap[i.variable],l=this.gridsMap[i.grid];return c?l?new Cp({variable:c,grid:l,time_unit:i.time_unit}):console.warn(`Ignoring dataset with invalid grid: ${i.grid}`):console.warn(`Ignoring dataset with invalid variable: ${i.variable}`)}).filter(i=>i!==void 0).sort((i,c)=>i.variable.label<c.variable.label?-1:1)}getRequiredDimensions(t,n=!1,r=!1){return this.dimensions.filter(o=>{if(!n&&o.type==="dataset"||!r&&o.type==="metadata")return!1;for(let a of t){let s=this.variablesMap[a.variable.name];if(o.required||(s.required_dimensions||[]).includes(o)||["daily","monthly"].includes(a.time_unit)&&o.name==="calendar_day"||["annual","decadal"].includes(a.time_unit)&&o.name==="calendar_year")return!0}return!1})}getDataLabel(t,n){const{dataset:r,response:o}=t,{results:a}=o,s=[cp(r.time_unit)],i=[];for(const c of this.getRequiredDimensions([r])){const l=(c.values?a[c.name].map(u=>c.values.find(d=>d.value==u)?.label):a[c.name]).join(", ");c.name=="aggregate_type"?s.push(l):i.push(`${c.label} ${l}`)}return s.push(r.variable.label),n&&n.length>0&&i.push(`${r.grid.label} ${n.map(pp).join(", ")}`),`${s.join(" ")}: ${i.join(", ")}`}}async function xp(){const e=rp(`${Lt}/datasets.ndjson`),t=["dimensions","variables","grids","legends","visualizations"].map(n=>nr(`${Lt}/${n}.json`));return new Ip(...await Promise.all([e,...t]))}class Sp{dataset;filters;structure;requestPath;response;constructor(t,n,r){this.dataset=t,this.filters=n,this.structure=r,this.requestPath=this.getRequestPath(),this.response=null}async execute(){this.response=await nr(this.requestPath);for(const t of Object.keys(this.response.results))vo(this.response.results[t],this.filters[t])}equals(t){return this.requestPath===t.requestPath}getRequestPath(){const{variable:t,grid:n,time_unit:r}=this.dataset,o=this.structure.getRequiredDimensions([this.dataset]),a=wn(_i(o,this.filters));return`${Lt}/datasets/${t.name}/${n.name}/${r}/catalog.json${a}`}getQueryParams({analysis:t,geographies:n,includeTimeDimension:r,maxGeographies:o,maxValues:a,unpivot:s}={analysis:null,geographies:null,includeTimeDimension:!0,maxGeographies:null,maxValues:null,unpivot:!1}){const i=this.structure.getRequiredDimensions([this.dataset]),c={};for(const p of i)(p.filterType!=="time"||r)&&(c[p.name]=this.response.results[p.name]);const l=c.model_group_id||[],u=[];t?.dimension&&u.push(t.dimension),t?.operation==="concatenate"&&l.length===2&&u.push("model_group_id");const d=_i(i,c,a,u);if(t){const{operation:p,dimension:h}=t;if(h){let g=i.map(({name:m})=>m).filter(m=>m!==h);const f=[...this.response.results[h]];if(f.sort((m,b)=>m<b?-1:1),p.startsWith("subtract-")){if(f&&f.length===2){const m=f[p.endsWith("asc")?1:0];d.push(["negate",`${h}=${Ht(m,h)}`]),d.push(["group_by",g]),d.push(["group_aggregate","sum"])}}else if(p==="concatenate"){const m=f;l.sort();const b=l.length===2;d.push([b?"multiply100":"multiply10",`${h}=${Ht(m[0],h)}`]),b&&(d.push(["multiply10",`model_group_id=${Ht(l[0])} and ${h}=${Ht(m[1],h)}`]),d.push(["where",`not (model_group_id=${Ht(l[1])} and ${h}=${Ht(m[0],h)})`]),g=g.filter(I=>I!=="model_group_id")),d.push(["group_by",g]),d.push(["group_aggregate","sum"])}}}return n&&d.push(["geography",o?n.slice(0,o):n]),s&&d.push(["unpivot","true"]),d}getTimeIncrement(){return{annual:"Year",daily:"Day",decadal:"Decade",month:"Month"}[this.dataset.time_unit]}getDataDownloadUrl({analysis:t,format:n,geographies:r,includeTimeDimension:o,unpivot:a}){return this.dataset.getDataUrl(this.getQueryParams({analysis:t,geographies:r,includeTimeDimension:o,unpivot:a}),n)}getMapStyleUrl({analysis:t,mapOptions:n,extraParams:r=[]}){return this.structure.visualizationsMap.map.getSpecUrl(this,{analysis:t,includeTimeDimension:!0},[...Object.keys(n).map(o=>[Vi(o),n[o]]),...r])}getModelGroup(){return(this?.response.results?.model_group_id||[-1])[0]}getVisualizationUrl({visualizationType:t,selectedGeographies:n,analysis:r}){return t&&n&&n.length?this.structure.visualizationsMap[t].getSpecUrl(this,{analysis:r.dimension?.startsWith("calendar_")?null:r,geographies:n}):null}getYear(){const t=this.response?.results,n=t?.calendar_day;if(n)return parseInt(n[0].substr(0,4));const r=t?.calendar_year;return r?r[0]:0}}class Ap{datasets;filters;structure;queries;combinedFilters;combinedChoices;activeDimensions;constructor(t,n,r){this.datasets=t,this.filters=n,this.reconcileFilters(),this.structure=r,this.queries=t.map(o=>new Sp(o,this.filters,r)),this.combinedFilters=null,this.combinedChoices=null,this.activeDimensions=[]}equals(t){return this.queries.length===t.queries.length&&this.queries.every((n,r)=>n.equals(t.queries[r]))}async executeAll(){await Promise.all(this.queries.map(n=>n.execute()));const t=this.structure.dimensions.filter(n=>n.isFilter).map(n=>n.name);this.combinedFilters=Gi(this.queries.map(({dataset:n,response:r})=>Fi(r.results,n)),t);for(let n of Object.keys(this.combinedFilters))vo(this.combinedFilters[n],this.filters[n]);this.combinedChoices=Gi(this.queries.map(({dataset:n,response:r})=>Fi(r.choices,n)),t),this.activeDimensions=this.structure.dimensions.filter(n=>n.name in this.combinedChoices)}getMapCatalogQuery(){return this.queries[0]}getTimeDimension(){return this.activeDimensions.filter(t=>t.filterType==="time")[0]}getTimeChoices(){const t=this.getTimeDimension();return this.combinedChoices[t.name]}reconcileFilters(){const t=this.filters,n=this.datasets[0].getTimeColumn(),r=this.datasets[0].time_unit,o={...t};"calendar_day"in t&&!("calendar_year"in t)&&n==="calendar_year"?(o.calendar_year=t.calendar_day.map(a=>{let s=parseInt(a.substr(0,4));return r==="decadal"&&(s=Math.round(s/10)*10),s}),delete o.calendar_day,this.filters=o):"calendar_year"in t&&!("calendar_day"in t)&&n==="calendar_day"&&(o.calendar_day=t.calendar_year.map(a=>`${a}-01-01`),delete o.calendar_year,this.filters=o)}}const Xt=J.createStore(),Yi=e=>Ot.atomWithStorage(e,null,void 0,{getOnInit:!0}),or=Yi("access_token"),Co=Yi("refresh_token"),ar=J.atom(async()=>await xp()),Zi=Re("data",{key:"activity"}),Mp=Re(null,{key:"issue"}),$i=[{variable:"sal",grid:"hydro_compartment_v001",time_unit:"annual"}],In=Re($i,{fromHash:e=>{const t=e.getAll("variable")||[],n=e.getAll("grid")||[],r=e.getAll("time_unit")||[],o=t.map((a,s)=>({variable:a,grid:n[s],time_unit:r[s]}));return o.length?o:$i}}),xn=Re({},{fromHash:e=>{const t=new Set(e.keys()),n={};for(const r of t)zi.includes(r)||(n[r]=e.getAll(r));return n}}),ir=J.atom([]),Sn=J.atom(null),lt=Re(new Promise(()=>{}),{updateHash:(e,t)=>{if("datasets"in t)for(const{variable:n,grid:r,time_unit:o}of t.datasets)e.append("variable",n.name),e.append("grid",r.name),e.append("time_unit",o);if("combinedFilters"in t)for(const n of Object.keys(t.combinedFilters))for(const r of t.combinedFilters[n])e.append(n,r)}}),Ji=()=>{const e=A.useRef(void 0);if(!e.current){let t;const n=new Promise(r=>t=r);e.current={promise:n,resolve:t}}Ot.useHydrateAtoms(new Map([[lt,e.current.promise],[Sn,{resolve:e.current.resolve}]]))},ut=Re({operation:"single",dimension:null},{key:"analysis",encoder:({operation:e,dimension:t})=>{let n=e;return t&&(n+=`:${t}`),n},decoder:e=>{const t=e.split(":");return{operation:t[0],dimension:t[1]||null}}}),ji=J.atom(null,(e,t,n,{updateGeographies:r}={updateGeographies:!0})=>{const o=e(In),a=n.map(i=>({variable:i.variable.name,grid:i.grid.name,time_unit:i.time_unit})),s=e(ut);t(In,a),r&&o[0].grid!==a[0].grid&&t(zt,e(zt).filter(yt)),s.operation==="concatenate"&&a[0].variable!=="lnd_type"&&t(ut,{operation:"single",dimension:null})}),wo=Re([8,29.75,-91.5],{key:"map",encoder:e=>e.map(t=>t.toFixed(2)).join("/"),decoder:e=>e.split("/").map(t=>parseFloat(t)),includeDefault:!0}),zt=Re([],{key:"geography",encoder:e=>e.map(t=>t.toString()).join(","),decoder:e=>{const t=e.split(",");if(e.includes(".")){const n=[];for(let r=0;r<t.length;r+=2)n.push(t.slice(r,r+2).map(o=>parseFloat(o)));return n}return t.map(n=>parseInt(n))}}),sr=J.atom(10),Io=fp({showGridLabels:!1,showGridLines:!0,showProjects:!0,showWater:!1}),xo=Re(null,{key:"start_date"}),So=Re(null,{key:"end_date"}),cr=Re("time-series-line",{key:"visualization"});J.atom(new Date().getTime());const Ao=J.atom(!1),Ep=J.atom([]);J.atom(async e=>{const t=await e(ar),n=[...np];if(t)for(const r of t.dimensions)r.values&&n.push(...r.values.map(o=>({value:`${r.name}:${o.value}`.toLowerCase(),label:`${r.label}: ${o.label||o.value}`})));return n.sort((r,o)=>r.label<o.label?-1:1),n});const Mo=J.atom(async e=>{const t=await e(ar),n=e(cr);return t.visualizationsMap[n]}),Ui=J.atom(null,(e,t,n,r,o=!0)=>{const a=e(xn);o&&vo(r,a[n]);const s={...a,[n]:r};n==="calendar_day"&&"calendar_year"in s&&delete s.calendar_year,n==="calendar_year"&&"calendar_day"in s&&delete s.calendar_day,t(xn,s)}),Ze=async(e,t,{accessToken:n=null,body:r=null,method:o="GET"}={})=>{const a=await nr(`${ep}${t}`,{body:r,headers:{authorization:`Bearer ${n??e(or)}`,"content-type":"application/json"},method:o});if(a.error&&a.error.status===401){if(!n&&await kp(e))return await Ze(e,t,{accessToken:n,body:r,method:o});Xt.set(or,null),Xt.set(Co,null)}return a},kp=async e=>{const t=Xt.get(Co);if(!t)return!1;const n=await Ze(e,"/login/refresh",{accessToken:t});return n.error?!1:(Xt.set(or,n.accessToken),!0)},Eo=Ot.atomWithRefresh(async e=>{const t=await Ze(e,"/users/current_user");return t.error?null:t});J.atom(async e=>(await e(Eo))?.clickupId?(await Ze(e,"/users/")).sort((r,o)=>r.fullName<o.fullName?-1:1):[]),J.atom(async e=>{const t=await Ze(e,"/statuses/");return t.error?[]:t}),Ot.atomWithRefresh(async e=>{const t=e(Ep),n=new URLSearchParams;if(t)for(const o of t)n.append("tags",o.value);return(await Ze(e,`/tasks/?${n}`)).map(Di)});const lr=Ot.atomWithReset(new Promise(()=>{}));J.atom(null,async(e,t,n)=>await Ze(e,"/tasks/",{body:Ni(n),method:"POST"})),J.atom(null,async(e,t,{taskId:n,comment:r})=>await Ze(e,`/tasks/${n}/comments`,{body:r,method:"POST"})),J.atom(null,async(e,t,{commentId:n,commentUpdates:r})=>await Ze(e,`/comments/${n}`,{body:r,method:"PUT"})),J.atom(null,async(e,t,n)=>{const r=e(lr);return await Ze(e,`/tasks/${r.id}`,{body:Ni(n),method:"PUT"})}),J.atom(null,async(e,t,{search:n,navigate:r,status:o})=>{const a=new URLSearchParams(n),s=l=>{t(o.description,l),t(o.heading,"Login error"),t(o.status,"error")};if(!a.has("access_token")||!a.has("refresh_token"))return s("Required token parameters are missing.");const i=a.get("access_token"),c=a.get("refresh_token");try{Qf(i)}catch(l){return s(l)}t(or,i),t(Co,c),r("/")}),J.atom(null,(e,t,{search:n,navigate:r})=>{new URLSearchParams(n).get("status")==="success"&&t(Eo),r("/")});const ko=J.atom(null,(e,t,n)=>{t(lt,n);const r=e(Sn);r&&(r.resolve(n),t(Sn,null)),t(ir,n.queries[0].response.results[n.getTimeDimension().name]);const o=e(ut),a=n.getTimeDimension().name;o.dimension&&["calendar_day","calendar_year"].includes(o.dimension)&&o.dimension!==a&&t(ut,{...o,dimension:a})}),ur=(e,t)=>Ot.atomWithStorage(e,t,void 0,{getOnInit:!0});ur("chart-image-format","png"),ur("geometry-data-format","zip"),ur("tabular-data-format","csv"),ur("tabular-data-shape","long");const Qi=J.atom(e=>{const t=Hi(e,{exclude:["activity","issue"]});return`${qf}${t}`}),Pp=Rt.atomEffect((e,t)=>{const n=e(In),r=e(xn);n.length&&(async()=>{const o=await e(ar),a=new Set(n.map(c=>`${c.variable}|${c.grid}|${c.time_unit}`)),s=new Ap(o.datasets.filter(c=>a.has(`${c.variable.name}|${c.grid.name}|${c.time_unit}`)),r,o),i=e(lt);"equals"in i&&i.equals(s)||(await s.executeAll(),t(ko,s))})()}),Op=Rt.atomEffect((e,t)=>{const n=e(Mo);(async()=>{const r=await n;t(sr,r.max_geographies)})()});Rt.observe((e,t)=>{const n=e(Mp);n==="new"?t(lr,{assignees:[],tags:[],markdown_description:"",name:""}):n&&(t(lr,new Promise(()=>{})),(async()=>{const r=await Ze(e,`/tasks/${n}?getComments=true`);t(lr,Di(r))})())},Xt),Rt.atomEffect((e,t)=>{const n=e(Zi),r=e(Eo);(async()=>{const o=await r;n!=="data"&&!o&&t(Zi,"data")})()});function qi(e,t){let n;return(...r)=>{window.clearTimeout(n),n=window.setTimeout(()=>e(...r),t)}}function Dp({debounce:e,scroll:t,polyfill:n,offsetSize:r}={debounce:0,scroll:!1,offsetSize:!1}){const o=n||(typeof window>"u"?class{}:window.ResizeObserver);if(!o)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[a,s]=A.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),i=A.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:a,orientationHandler:null}),c=e?typeof e=="number"?e:e.scroll:null,l=e?typeof e=="number"?e:e.resize:null,u=A.useRef(!1);A.useEffect(()=>(u.current=!0,()=>{u.current=!1}));const[d,p,h]=A.useMemo(()=>{const b=()=>{if(!i.current.element)return;const{left:I,top:w,width:x,height:C,bottom:S,right:M,x:E,y:O}=i.current.element.getBoundingClientRect(),P={left:I,top:w,width:x,height:C,bottom:S,right:M,x:E,y:O};i.current.element instanceof HTMLElement&&r&&(P.height=i.current.element.offsetHeight,P.width=i.current.element.offsetWidth),Object.freeze(P),u.current&&!Gp(i.current.lastBounds,P)&&s(i.current.lastBounds=P)};return[b,l?qi(b,l):b,c?qi(b,c):b]},[s,r,c,l]);function g(){i.current.scrollContainers&&(i.current.scrollContainers.forEach(b=>b.removeEventListener("scroll",h,!0)),i.current.scrollContainers=null),i.current.resizeObserver&&(i.current.resizeObserver.disconnect(),i.current.resizeObserver=null),i.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",i.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",i.current.orientationHandler))}function f(){i.current.element&&(i.current.resizeObserver=new o(h),i.current.resizeObserver.observe(i.current.element),t&&i.current.scrollContainers&&i.current.scrollContainers.forEach(b=>b.addEventListener("scroll",h,{capture:!0,passive:!0})),i.current.orientationHandler=()=>{h()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",i.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",i.current.orientationHandler))}const m=b=>{!b||b===i.current.element||(g(),i.current.element=b,i.current.scrollContainers=Ki(b),f())};return Tp(h,!!t),Np(p),A.useEffect(()=>{g(),f()},[t,h,p]),A.useEffect(()=>g,[]),[m,a,d]}function Np(e){A.useEffect(()=>{const t=e;return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[e])}function Tp(e,t){A.useEffect(()=>{if(t){const n=e;return window.addEventListener("scroll",n,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",n,!0)}}},[e,t])}function Ki(e){const t=[];if(!e||e===document.body)return t;const{overflow:n,overflowX:r,overflowY:o}=window.getComputedStyle(e);return[n,r,o].some(a=>a==="auto"||a==="scroll")&&t.push(e),[...t,...Ki(e.parentElement)]}const Fp=["x","y","top","bottom","left","right","width","height"],Gp=(e,t)=>Fp.every(n=>e[n]===t[n]);function _p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var es,ts;function Wp(){return ts||(ts=1,es=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,o,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[o]))return!1;for(o=r;o--!==0;){var s=a[o];if(!e(t[s],n[s]))return!1}return!0}return t!==t&&n!==n}),es}var Bp=Wp();const Vp=_p(Bp);function ns(e){const[t,n]=A.useState(null),{ref:r,spec:o,onEmbed:a,onError:s,options:i={}}=e;return Rp(()=>{let c=!1,l=null;return(async()=>{if(!(!r.current||c))try{if(l=await $f(r.current,o,i),c){l.finalize();return}n(l),a?.(l)}catch(u){console.error(`[react-vega] Error creating view: ${u}`),s?.(u)}})(),()=>{c=!0,l?.finalize()}},[o,i]),t}function Rp(e,t){const n=A.useRef(null),r=A.useRef(0);(!n.current||!Vp(t,n.current))&&(r.current+=1),n.current=t,A.useEffect(e,[r.current])}const Lp=A.forwardRef((e,t)=>{const{spec:n,options:r,onEmbed:o,onError:a,...s}=e,i=A.useRef(null);return A.useImperativeHandle(t,()=>{if(!i.current)throw new Error("VegaEmbed: ref is not attached to a div element");return i.current},[]),ns({ref:i,spec:n,onEmbed:o,onError:a,options:r}),y.jsx("div",{ref:i,...s})});Lp.displayName="VegaEmbed";const Yt="#fff",rs="#888",Hp={background:"#333",view:{stroke:rs},title:{color:Yt,subtitleColor:Yt},style:{"guide-label":{fill:Yt},"guide-title":{fill:Yt}},axis:{domainColor:Yt,gridColor:rs,tickColor:Yt}},Dt="#4572a7",Xp={background:"#fff",arc:{fill:Dt},area:{fill:Dt},line:{stroke:Dt,strokeWidth:2},path:{stroke:Dt},rect:{fill:Dt},shape:{stroke:Dt},symbol:{fill:Dt,strokeWidth:1.5,size:50},axis:{bandPosition:.5,grid:!0,gridColor:"#000000",gridOpacity:1,gridWidth:.5,labelPadding:10,tickSize:5,tickWidth:.5},axisBand:{grid:!1,tickExtra:!0},legend:{labelBaseline:"middle",labelFontSize:11,symbolSize:50,symbolType:"square"},range:{category:["#4572a7","#aa4643","#8aa453","#71598e","#4598ae","#d98445","#94aace","#d09393","#b9cc98","#a99cbc"]}},Po='IBM Plex Sans,system-ui,-apple-system,BlinkMacSystemFont,".sfnstext-regular",sans-serif',zp='IBM Plex Sans Condensed, system-ui, -apple-system, BlinkMacSystemFont, ".SFNSText-Regular", sans-serif',Oo=400,dr={textPrimary:{g90:"#f4f4f4",g100:"#f4f4f4",white:"#161616",g10:"#161616"},textSecondary:{g90:"#c6c6c6",g100:"#c6c6c6",white:"#525252",g10:"#525252"},layerAccent01:{white:"#e0e0e0",g10:"#e0e0e0",g90:"#525252",g100:"#393939"},gridBg:{white:"#ffffff",g10:"#ffffff",g90:"#161616",g100:"#161616"}},Yp=["#8a3ffc","#33b1ff","#007d79","#ff7eb6","#fa4d56","#fff1f1","#6fdc8c","#4589ff","#d12771","#d2a106","#08bdba","#bae6ff","#ba4e00","#d4bbff"],Zp=["#6929c4","#1192e8","#005d5d","#9f1853","#fa4d56","#570408","#198038","#002d9c","#ee538b","#b28600","#009d9a","#012749","#8a3800","#a56eff"];function fr({theme:e,background:t}){const n=["white","g10"].includes(e)?"light":"dark",r=dr.gridBg[e],o=dr.textPrimary[e],a=dr.textSecondary[e],s=n==="dark"?Yp:Zp,i=n==="dark"?"#d4bbff":"#6929c4";return{background:t,arc:{fill:i},area:{fill:i},path:{stroke:i},rect:{fill:i},shape:{stroke:i},symbol:{stroke:i},circle:{fill:i},view:{fill:r,stroke:r},group:{fill:r},title:{color:o,anchor:"start",dy:-15,fontSize:16,font:Po,fontWeight:600},axis:{labelColor:a,labelFontSize:12,labelFont:zp,labelFontWeight:Oo,titleColor:o,titleFontWeight:600,titleFontSize:12,grid:!0,gridColor:dr.layerAccent01[e],labelAngle:0},axisX:{titlePadding:10},axisY:{titlePadding:2.5},style:{"guide-label":{font:Po,fill:a,fontWeight:Oo},"guide-title":{font:Po,fill:a,fontWeight:Oo}},range:{category:s,diverging:["#750e13","#a2191f","#da1e28","#fa4d56","#ff8389","#ffb3b8","#ffd7d9","#fff1f1","#e5f6ff","#bae6ff","#82cfff","#33b1ff","#1192e8","#0072c3","#00539a","#003a6d"],heatmap:["#f6f2ff","#e8daff","#d4bbff","#be95ff","#a56eff","#8a3ffc","#6929c4","#491d8b","#31135e","#1c0f30"]}}}fr({theme:"white",background:"#ffffff"}),fr({theme:"g10",background:"#f4f4f4"}),fr({theme:"g90",background:"#262626"}),fr({theme:"g100",background:"#161616"});const os=A.memo(function({actions:t=!1,children:n,className:r="",endDate:o,id:a="default",setEndDate:s,setStartDate:i,spec:c,startDate:l,padding:u=16,style:d={},theme:p="light"}){const[h,{height:g,width:f}]=Dp(),m=!!(g&&f),b=A.useRef(null),[I,w]=A.useState(typeof c=="string"?null:c),x={...Hp,background:"transparent"},C={...Xp,background:"transparent"},S=A.useRef(null),M=ns({ref:S,spec:I,options:{mode:"vega-lite",actions:t,config:p==="dark"?x:C,padding:u}});return A.useEffect(()=>{if(typeof c=="string"){if(g&&f){const E=async()=>{let O=`${c}${c.includes("?")?"":"?"}&height=${Math.floor(g)}&width=${Math.floor(f)}`;l&&(O+=`&start_date=${l}`),o&&(O+=`&end_date=${o}`);const P=await nr(O);w(P)};I||b.current?(w(null),b.current&&clearTimeout(b.current),b.current=setTimeout(E,250)):E()}}else w(c)},[c,m]),A.useEffect(()=>{let E=!1;const O=async P=>{if(f&&Number.isFinite(f)&&P.width(f),!g||!Number.isFinite(g)){await P.runAsync();return}let W=!0;try{P.signal("concat_0_height")}catch{W=!1}if(!W){P.height(g),await P.runAsync();return}if(await P.runAsync(),!E)for(let N=0;N<2;N++){const T=S.current?.querySelector("svg");if(!T)break;const G=T.getBoundingClientRect().height-g;if(Math.abs(G)<=1)break;const F=P.signal("concat_0_height");if(P.signal("concat_0_height",Math.max(F-G,40)),await P.runAsync(),E)return}};return M?.view&&O(M.view),()=>{E=!0}},[M,f,g]),A.useEffect(()=>{const E={date_range:(P,W)=>{const N=Object.keys(W)[0];if(!N)return;const[T,D]=W[N].map(G=>new Date(G).toISOString().split("T")[0]);i&&i(T),s&&s(D)}},O={date_range:()=>{i&&i(null),s&&s(null)}};for(const P of Object.keys(E))I&&!I?.params?.find(({name:W})=>P===W)&&(delete E[P],P in O&&O[P]());for(const P of Object.keys(E))M?.view.addSignalListener(P,E[P]);return()=>{for(const P of Object.keys(E))M?.view.removeSignalListener(P,E[P])}},[M]),A.useEffect(()=>{if(S.current){const E=O=>{O.detail.id===a&&(async()=>{const P=await M?.view.toImageURL(O.detail.type);if(P){const W=document.createElement("a");W.setAttribute("href",P),W.setAttribute("target","_blank"),W.setAttribute("download",O.detail.filename),W.dispatchEvent(new MouseEvent("click"))}})()};return window.addEventListener("chartDownload",E),()=>{window.removeEventListener("chartDownload",E)}}},[M,a]),y.jsxs("div",{style:{height:"100%",position:"relative",width:"100%",...d},ref:h,children:[n,I?y.jsx("div",{style:{height:`${g}px`,overflow:"hidden",position:"absolute",width:`${f}px`},className:r,ref:S}):null]})},(e,t)=>Object.keys(e).filter(n=>n!=="children"&&!n.toLowerCase().includes("date")).every(n=>e[n]===t[n])),pr=new Map,mr=(e,t)=>`${e.name}:${t.join(",")}`,$p=async(e,t)=>{const n=e.getGeographyUrl(t),r=await fetch(n,{headers:{accept:"application/x-ndjson"}});if(!r.ok)throw new Error(`Received status ${r.status} while loading ${n}`);const o=new Map;return(await r.text()).split(`
|
|
2
|
+
`).filter(r=>r.length>0).map(r=>JSON.parse(r))}catch(r){return console.error(`Error while loading ${e}: ${r}`),[]}}function Cn(e,t="name"){const n={};for(let r of e)n[r[t]]=r;return n}function op(e,t=1,n=null){const r=[];for(let o of e)if(Array.isArray(o)){let[a,s]=o;if(typeof o[0]=="number")for(;a<=s;)r.push(a),a+=t;else{let[i,c]=[a,s].map(l=>new Date(`${l}T00:00:00`));for(;i<=c;)(n===null||i.getDate()===n)&&r.push(new Date(i.valueOf()).toISOString().split("T")[0]),i.setDate(i.getDate()+t)}}else r.push(o);return r}function Fi(e,t){const n={};for(let r in e){let o=1,a=null;r.startsWith("calendar_")&&(t.time_unit=="decadal"&&(o=10),t.time_unit=="monthly"&&(a=1)),n[r]=op(e[r],o,a)}return n}function Gi(e,t=null){const n={};for(let r of e)for(let o in r)if(!t||t.includes(o)){const a=r[o];if(o in n)for(let s of a)n[o].includes(s)||n[o].push(s);else n[o]=a}return n}function _i(e,t,n=null,r=[]){const o=[];for(let a of e){let s=0;for(let i of t[a.name]||[])if(o.push([a.name,i]),s++,n&&!r.includes(a.name)&&s===n)break}return o}function wn(e){return e.length?`?${e.map(([t,n])=>`${t}=${encodeURIComponent(n.toString())}`).join("&")}`:""}function ap(e){return new Promise(t=>setTimeout(t,e))}const ip=(e,t)=>`#${e.replace(/../g,n=>`0${Math.min(255,Math.max(0,parseInt(n,16)+t)).toString(16)}`.substr(-2))}`,Wi=(e,{adjustment:t,count:n}={})=>ip(Ti.slice(0,n)[e]||"000000",t||0),Bi=([e,t])=>[e,t].map(n=>parseFloat(n.toFixed(5))),sp=e=>{const t=e.split("-").map(n=>parseInt(n));return new Date(t[0],t[1]-1,t[2])};function cp(e){return(e||"").replace(/\w\S*/g,t=>t.charAt(0).toUpperCase()+t.substring(1).toLowerCase())}function vo(e,t){if(!t)return e;const n=r=>{const o=(t||[]).indexOf(r);return o===-1?9999:o};e.sort((r,o)=>n(r)-n(o))}function Ht(e,t=""){return t==="calendar_day"?`'${e}'::date`:typeof e=="number"?e:`'${e}'`}const Vi=e=>e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1_$2").toLowerCase(),yo=()=>new URLSearchParams(window.location.hash.replace(/^#/,"")),Ri=e=>{e.sort();let t=e.toString();return e.has("map")&&(t=t.replace(/(^|&)map=[^&]+/,`$1map=${e.get("map")}`)),t?`#${t}`:""},rr=[],Li=e=>{const t=rr.flatMap(n=>n.fromHash?[[n.atom,n.fromHash(e)]]:[]);Ot.useHydrateAtoms(t)},Hi=(e,{include:t,exclude:n}={})=>{const r=new URLSearchParams;for(const o of rr)o.updateHash&&o.updateHash(r,e(o.atom));if(t)for(const o of r.keys())t.includes(o)||r.delete(o);if(n)for(const o of n)r.delete(o);return r.sort(),Ri(r)},lp=e=>{const t=Hi(e);t!==Ri(yo())&&window.history.pushState(window.history.state,"",t)},up=Rt.atomEffect((e,t)=>{const n=()=>{const r=yo();for(const o of rr)o.fromHash&&t(o.atom,o.fromHash(r))};return window.addEventListener("hashchange",n,!1),()=>window.removeEventListener("hashchange",n)}),dp=Rt.atomEffect(e=>lp(e)),Xi=(e,t)=>{const{key:n}=t;zi.push(n);const r=t.encoder||(i=>typeof i=="string"?i:JSON.stringify(i)),o=t.decoder||(i=>{try{return JSON.parse(i)}catch(c){if(c instanceof SyntaxError)return i;throw c}});return[i=>i.has(n)?o(i.get(n)):e,(i,c)=>{!t.includeDefault&&r(c)===r(e)?i.delete(n):i.set(n,r(c))}]},zi=[],Re=(e,t)=>{let n,r;"key"in t?[n,r]=Xi(e,t):(n=t.fromHash,r=t.updateHash);const o=J.atom(e);return rr.push({atom:o,fromHash:n,updateHash:r}),o},fp=e=>{const t={},n={};for(const a of Object.keys(e)){const[s,i]=Xi(e[a],{key:Vi(a)});t[a]=s,n[a]=i}return Re(e,{fromHash:a=>{const s={};for(const i of Object.keys(e))s[i]=t[i](a);return s},updateHash:(a,s)=>{for(const i of Object.keys(e))n[i](a,s[i])}})},yt=e=>Array.isArray(e),pp=e=>yt(e)?`(${e.join(", ")})`:`${e}`;class Ye{geographies;constructor(t=[]){this.geographies=t}get length(){return this.geographies.length}add(t){return new Ye([...this.geographies.filter(yt),t])}editable(){return this.geographies.every(yt)?this:new Ye(this.geographies.filter(yt))}remove(t){const n=[...this.geographies];return n.splice(t,1),new Ye(n)}replace(t,n){const r=[...this.geographies];return r[t]=n,new Ye(r)}rotate(t){const n=t==0?this.geographies:[...this.geographies.slice(t),...this.geographies.slice(0,t)];return new Ye(n)}}class mp{value;label;constructor({value:t,label:n}){this.value=t,this.label=n}}class hp{name;label;type;dtype;required;null;values;minValue;maxValue;isFilter;filterType;constructor({name:t,label:n,type:r,dtype:o,required:a,null:s,values:i,min_value:c,max_value:l}){this.name=t,this.label=n,this.type=r,this.dtype=o,this.required=a,this.null=s,this.values=i?i.map(u=>new mp(u)):null,this.minValue=c,this.maxValue=l,this.isFilter=!["dataset","metadata"].includes(r),this.filterType=this.isFilter?t.startsWith("calendar_")?"time":"select":null}}class gp{name;label;dtype;model;subroutine;unit;display_unit;display_scale_factor;display_number_format;float_precision;legend;geographic_units;time_units;required_dimensions;difference_legend_limit;structure;constructor({name:t,label:n,dtype:r,model:o,subroutine:a,unit:s,display_unit:i,display_scale_factor:c,display_number_format:l,float_precision:u,legend:d,geographic_units:p,time_units:h,required_dimensions:g,difference_legend_limit:f},m){this.name=t,this.label=n,this.dtype=r,this.model=o,this.subroutine=a,this.unit=s,this.display_unit=i,this.display_scale_factor=c,this.display_number_format=l,this.float_precision=u,this.legend=d,this.geographic_units=p,this.time_units=h,this.required_dimensions=g,this.difference_legend_limit=f,this.structure=m}}class bp{name;label;grid_type;crs;geographies;bounds;height;width;constructor({name:t,label:n,grid_type:r,crs:o,geographies:a,bounds:s,height:i,width:c}){this.name=t,this.label=n,this.grid_type=r,this.crs=o,this.geographies=a,this.bounds=s,this.height=i,this.width=c}isRaster(){return this.grid_type==="raster"}isVector(){return this.grid_type==="vector"}getTileUrl(){return this.isVector()?`${Kf}/${this.name}`:null}getGeographyUrl(t){const n=[["geography",t.flat().join(",")],["to_grid",this.name]];return`${Lt}/grids/wgs84/crosswalk.ndjson${wn(n)}`}}class vp{label;color;upper_bound;constructor({label:t,color:n,upper_bound:r}){this.label=t,this.color=n,this.upper_bound=r}}class yp{name;break_points;constructor({name:t,break_points:n}){this.name=t,this.break_points=n.map(r=>new vp(r))}}class Cp{variable;grid;time_unit;constructor({variable:t,grid:n,time_unit:r}){this.variable=t,this.grid=n,this.time_unit=r}getBaseUrl(){return`${Lt}/datasets/${this.variable.name}/${this.grid.name}/${this.time_unit}`}getDataUrl(t,n){return`${this.getBaseUrl()}/data.${n}${wn(t)}`}getTileUrl(t){return this.grid.getTileUrl()||`${this.getBaseUrl()}/data/{z}/{x}/{y}.png${wn(t)}`}getTimeColumn(){return["annual","decadal"].includes(this.time_unit)?"calendar_year":"calendar_day"}}class wp{name;label;type;max_geographies;variables;constructor({name:t,label:n,type:r,max_geographies:o,variables:a}){this.name=t,this.label=n,this.type=r,this.max_geographies=o,this.variables=a}getSpecUrl(t,n,r=[]){const o=[...t.getQueryParams({...n,includeTimeDimension:!n.geographies,maxGeographies:this.max_geographies}),...r];return`${this.type==="dataset"?`${t.dataset.getBaseUrl()}/visualization`:`${Lt}/visualizations`}/${this.name}.json${wn(o)}`}}class Ip{datasets;dimensions;dimensionsMap;variables;variablesMap;grids;gridsMap;legends;legendsMap;visualizations;visualizationsMap;constructor(t,n,r,o,a,s){this.dimensions=n.map(i=>new hp(i)),this.dimensionsMap=Cn(this.dimensions),this.grids=o.map(i=>new bp(i)),this.gridsMap=Cn(this.grids),this.legends=a.map(i=>new yp(i)),this.legendsMap=Cn(this.legends),this.visualizations=s.map(i=>new wp(i)),this.visualizationsMap=Cn(this.visualizations),this.variables=r.map(i=>new gp({...i,legend:i.legend?this.legendsMap[i.legend]:this.legendsMap.default,required_dimensions:i.required_dimensions?i.required_dimensions.map(c=>this.dimensionsMap[c]):[]},this)),this.variablesMap=Cn(this.variables),this.datasets=t.map(i=>{const c=this.variablesMap[i.variable],l=this.gridsMap[i.grid];return c?l?new Cp({variable:c,grid:l,time_unit:i.time_unit}):console.warn(`Ignoring dataset with invalid grid: ${i.grid}`):console.warn(`Ignoring dataset with invalid variable: ${i.variable}`)}).filter(i=>i!==void 0).sort((i,c)=>i.variable.label<c.variable.label?-1:1)}getRequiredDimensions(t,n=!1,r=!1){return this.dimensions.filter(o=>{if(!n&&o.type==="dataset"||!r&&o.type==="metadata")return!1;for(let a of t){let s=this.variablesMap[a.variable.name];if(o.required||(s.required_dimensions||[]).includes(o)||["daily","monthly"].includes(a.time_unit)&&o.name==="calendar_day"||["annual","decadal"].includes(a.time_unit)&&o.name==="calendar_year")return!0}return!1})}getDataLabel(t,n){const{dataset:r,response:o}=t,{results:a}=o,s=[cp(r.time_unit)],i=[];for(const c of this.getRequiredDimensions([r])){const l=(c.values?a[c.name].map(u=>c.values.find(d=>d.value==u)?.label):a[c.name]).join(", ");c.name=="aggregate_type"?s.push(l):i.push(`${c.label} ${l}`)}return s.push(r.variable.label),n&&n.length>0&&i.push(`${r.grid.label} ${n.map(pp).join(", ")}`),`${s.join(" ")}: ${i.join(", ")}`}}async function xp(){const e=rp(`${Lt}/datasets.ndjson`),t=["dimensions","variables","grids","legends","visualizations"].map(n=>nr(`${Lt}/${n}.json`));return new Ip(...await Promise.all([e,...t]))}class Sp{dataset;filters;structure;requestPath;response;constructor(t,n,r){this.dataset=t,this.filters=n,this.structure=r,this.requestPath=this.getRequestPath(),this.response=null}async execute(){this.response=await nr(this.requestPath);for(const t of Object.keys(this.response.results))vo(this.response.results[t],this.filters[t])}equals(t){return this.requestPath===t.requestPath}getRequestPath(){const{variable:t,grid:n,time_unit:r}=this.dataset,o=this.structure.getRequiredDimensions([this.dataset]),a=wn(_i(o,this.filters));return`${Lt}/datasets/${t.name}/${n.name}/${r}/catalog.json${a}`}getQueryParams({analysis:t,geographies:n,includeTimeDimension:r,maxGeographies:o,maxValues:a,unpivot:s}={analysis:null,geographies:null,includeTimeDimension:!0,maxGeographies:null,maxValues:null,unpivot:!1}){const i=this.structure.getRequiredDimensions([this.dataset]),c={};for(const p of i)(p.filterType!=="time"||r)&&(c[p.name]=this.response.results[p.name]);const l=c.model_group_id||[],u=[];t?.dimension&&u.push(t.dimension),t?.operation==="concatenate"&&l.length===2&&u.push("model_group_id");const d=_i(i,c,a,u);if(t){const{operation:p,dimension:h}=t;if(h){let g=i.map(({name:m})=>m).filter(m=>m!==h);const f=[...this.response.results[h]];if(f.sort((m,b)=>m<b?-1:1),p.startsWith("subtract-")){if(f&&f.length===2){const m=f[p.endsWith("asc")?1:0];d.push(["negate",`${h}=${Ht(m,h)}`]),d.push(["group_by",g]),d.push(["group_aggregate","sum"])}}else if(p==="concatenate"){const m=f;l.sort();const b=l.length===2;d.push([b?"multiply100":"multiply10",`${h}=${Ht(m[0],h)}`]),b&&(d.push(["multiply10",`model_group_id=${Ht(l[0])} and ${h}=${Ht(m[1],h)}`]),d.push(["where",`not (model_group_id=${Ht(l[1])} and ${h}=${Ht(m[0],h)})`]),g=g.filter(I=>I!=="model_group_id")),d.push(["group_by",g]),d.push(["group_aggregate","sum"])}}}return n&&d.push(["geography",o?n.slice(0,o):n]),s&&d.push(["unpivot","true"]),d}getTimeIncrement(){return{annual:"Year",daily:"Day",decadal:"Decade",month:"Month"}[this.dataset.time_unit]}getDataDownloadUrl({analysis:t,format:n,geographies:r,includeTimeDimension:o,unpivot:a}){return this.dataset.getDataUrl(this.getQueryParams({analysis:t,geographies:r,includeTimeDimension:o,unpivot:a}),n)}getMapStyleUrl({analysis:t,mapOptions:n,extraParams:r=[]}){return this.structure.visualizationsMap.map.getSpecUrl(this,{analysis:t,includeTimeDimension:!0},[...Object.keys(n).map(o=>[Vi(o),n[o]]),...r])}getModelGroup(){return(this?.response.results?.model_group_id||[-1])[0]}getVisualizationUrl({visualizationType:t,selectedGeographies:n,analysis:r}){return t&&n&&n.length?this.structure.visualizationsMap[t].getSpecUrl(this,{analysis:r.dimension?.startsWith("calendar_")?null:r,geographies:n}):null}getYear(){const t=this.response?.results,n=t?.calendar_day;if(n)return parseInt(n[0].substr(0,4));const r=t?.calendar_year;return r?r[0]:0}}class Ap{datasets;filters;structure;queries;combinedFilters;combinedChoices;activeDimensions;constructor(t,n,r){this.datasets=t,this.filters=n,this.reconcileFilters(),this.structure=r,this.queries=t.map(o=>new Sp(o,this.filters,r)),this.combinedFilters=null,this.combinedChoices=null,this.activeDimensions=[]}equals(t){return this.queries.length===t.queries.length&&this.queries.every((n,r)=>n.equals(t.queries[r]))}async executeAll(){await Promise.all(this.queries.map(n=>n.execute()));const t=this.structure.dimensions.filter(n=>n.isFilter).map(n=>n.name);this.combinedFilters=Gi(this.queries.map(({dataset:n,response:r})=>Fi(r.results,n)),t);for(let n of Object.keys(this.combinedFilters))vo(this.combinedFilters[n],this.filters[n]);this.combinedChoices=Gi(this.queries.map(({dataset:n,response:r})=>Fi(r.choices,n)),t),this.activeDimensions=this.structure.dimensions.filter(n=>n.name in this.combinedChoices)}getMapCatalogQuery(){return this.queries[0]}getTimeDimension(){return this.activeDimensions.filter(t=>t.filterType==="time")[0]}getTimeChoices(){const t=this.getTimeDimension();return this.combinedChoices[t.name]}reconcileFilters(){const t=this.filters,n=this.datasets[0].getTimeColumn(),r=this.datasets[0].time_unit,o={...t};"calendar_day"in t&&!("calendar_year"in t)&&n==="calendar_year"?(o.calendar_year=t.calendar_day.map(a=>{let s=parseInt(a.substr(0,4));return r==="decadal"&&(s=Math.round(s/10)*10),s}),delete o.calendar_day,this.filters=o):"calendar_year"in t&&!("calendar_day"in t)&&n==="calendar_day"&&(o.calendar_day=t.calendar_year.map(a=>`${a}-01-01`),delete o.calendar_year,this.filters=o)}}const Xt=J.createStore(),Yi=e=>Ot.atomWithStorage(e,null,void 0,{getOnInit:!0}),or=Yi("access_token"),Co=Yi("refresh_token"),ar=J.atom(async()=>await xp()),Zi=Re("data",{key:"activity"}),Mp=Re(null,{key:"issue"}),$i=[{variable:"sal",grid:"hydro_compartment_v001",time_unit:"annual"}],In=Re($i,{fromHash:e=>{const t=e.getAll("variable")||[],n=e.getAll("grid")||[],r=e.getAll("time_unit")||[],o=t.map((a,s)=>({variable:a,grid:n[s],time_unit:r[s]}));return o.length?o:$i}}),xn=Re({},{fromHash:e=>{const t=new Set(e.keys()),n={};for(const r of t)zi.includes(r)||(n[r]=e.getAll(r));return n}}),ir=J.atom([]),Sn=J.atom(null),lt=Re(new Promise(()=>{}),{updateHash:(e,t)=>{if("datasets"in t)for(const{variable:n,grid:r,time_unit:o}of t.datasets)e.append("variable",n.name),e.append("grid",r.name),e.append("time_unit",o);if("combinedFilters"in t)for(const n of Object.keys(t.combinedFilters))for(const r of t.combinedFilters[n])e.append(n,r)}}),Ji=()=>{const e=A.useRef(void 0);if(!e.current){let t;const n=new Promise(r=>t=r);e.current={promise:n,resolve:t}}Ot.useHydrateAtoms(new Map([[lt,e.current.promise],[Sn,{resolve:e.current.resolve}]]))},ut=Re({operation:"single",dimension:null},{key:"analysis",encoder:({operation:e,dimension:t})=>{let n=e;return t&&(n+=`:${t}`),n},decoder:e=>{const t=e.split(":");return{operation:t[0],dimension:t[1]||null}}}),ji=J.atom(null,(e,t,n,{updateGeographies:r}={updateGeographies:!0})=>{const o=e(In),a=n.map(i=>({variable:i.variable.name,grid:i.grid.name,time_unit:i.time_unit})),s=e(ut);t(In,a),r&&o[0].grid!==a[0].grid&&t(zt,e(zt).filter(yt)),s.operation==="concatenate"&&a[0].variable!=="lnd_type"&&t(ut,{operation:"single",dimension:null})}),wo=Re([8,29.75,-91.5],{key:"map",encoder:e=>e.map(t=>t.toFixed(2)).join("/"),decoder:e=>e.split("/").map(t=>parseFloat(t)),includeDefault:!0}),zt=Re([],{key:"geography",encoder:e=>e.map(t=>t.toString()).join(","),decoder:e=>{const t=e.split(",");if(e.includes(".")){const n=[];for(let r=0;r<t.length;r+=2)n.push(t.slice(r,r+2).map(o=>parseFloat(o)));return n}return t.map(n=>parseInt(n))}}),sr=J.atom(10),Io=fp({showGridLabels:!1,showGridLines:!0,showProjects:!0,showWater:!1}),xo=Re(null,{key:"start_date"}),So=Re(null,{key:"end_date"}),cr=Re("time-series-line",{key:"visualization"});J.atom(new Date().getTime());const Ao=J.atom(!1),Ep=J.atom([]);J.atom(async e=>{const t=await e(ar),n=[...np];if(t)for(const r of t.dimensions)r.values&&n.push(...r.values.map(o=>({value:`${r.name}:${o.value}`.toLowerCase(),label:`${r.label}: ${o.label||o.value}`})));return n.sort((r,o)=>r.label<o.label?-1:1),n});const Mo=J.atom(async e=>{const t=await e(ar),n=e(cr);return t.visualizationsMap[n]}),Ui=J.atom(null,(e,t,n,r,o=!0)=>{const a=e(xn);o&&vo(r,a[n]);const s={...a,[n]:r};n==="calendar_day"&&"calendar_year"in s&&delete s.calendar_year,n==="calendar_year"&&"calendar_day"in s&&delete s.calendar_day,t(xn,s)}),Ze=async(e,t,{accessToken:n=null,body:r=null,method:o="GET"}={})=>{const a=await nr(`${ep}${t}`,{body:r,headers:{authorization:`Bearer ${n??e(or)}`,"content-type":"application/json"},method:o});if(a.error&&a.error.status===401){if(!n&&await kp(e))return await Ze(e,t,{accessToken:n,body:r,method:o});Xt.set(or,null),Xt.set(Co,null)}return a},kp=async e=>{const t=Xt.get(Co);if(!t)return!1;const n=await Ze(e,"/login/refresh",{accessToken:t});return n.error?!1:(Xt.set(or,n.accessToken),!0)},Eo=Ot.atomWithRefresh(async e=>{const t=await Ze(e,"/users/current_user");return t.error?null:t});J.atom(async e=>(await e(Eo))?.clickupId?(await Ze(e,"/users/")).sort((r,o)=>r.fullName<o.fullName?-1:1):[]),J.atom(async e=>{const t=await Ze(e,"/statuses/");return t.error?[]:t}),Ot.atomWithRefresh(async e=>{const t=e(Ep),n=new URLSearchParams;if(t)for(const o of t)n.append("tags",o.value);return(await Ze(e,`/tasks/?${n}`)).map(Di)});const lr=Ot.atomWithReset(new Promise(()=>{}));J.atom(null,async(e,t,n)=>await Ze(e,"/tasks/",{body:Ni(n),method:"POST"})),J.atom(null,async(e,t,{taskId:n,comment:r})=>await Ze(e,`/tasks/${n}/comments`,{body:r,method:"POST"})),J.atom(null,async(e,t,{commentId:n,commentUpdates:r})=>await Ze(e,`/comments/${n}`,{body:r,method:"PUT"})),J.atom(null,async(e,t,n)=>{const r=e(lr);return await Ze(e,`/tasks/${r.id}`,{body:Ni(n),method:"PUT"})}),J.atom(null,async(e,t,{search:n,navigate:r,status:o})=>{const a=new URLSearchParams(n),s=l=>{t(o.description,l),t(o.heading,"Login error"),t(o.status,"error")};if(!a.has("access_token")||!a.has("refresh_token"))return s("Required token parameters are missing.");const i=a.get("access_token"),c=a.get("refresh_token");try{Qf(i)}catch(l){return s(l)}t(or,i),t(Co,c),r("/")}),J.atom(null,(e,t,{search:n,navigate:r})=>{new URLSearchParams(n).get("status")==="success"&&t(Eo),r("/")});const ko=J.atom(null,(e,t,n)=>{t(lt,n);const r=e(Sn);r&&(r.resolve(n),t(Sn,null)),t(ir,n.queries[0].response.results[n.getTimeDimension().name]);const o=e(ut),a=n.getTimeDimension().name;o.dimension&&["calendar_day","calendar_year"].includes(o.dimension)&&o.dimension!==a&&t(ut,{...o,dimension:a})}),ur=(e,t)=>Ot.atomWithStorage(e,t,void 0,{getOnInit:!0});ur("chart-image-format","png"),ur("geometry-data-format","zip"),ur("tabular-data-format","csv"),ur("tabular-data-shape","long");const Qi=J.atom(e=>{const t=Hi(e,{exclude:["activity","issue"]});return`${qf}${t}`}),Pp=Rt.atomEffect((e,t)=>{const n=e(In),r=e(xn);n.length&&(async()=>{const o=await e(ar),a=new Set(n.map(c=>`${c.variable}|${c.grid}|${c.time_unit}`)),s=new Ap(o.datasets.filter(c=>a.has(`${c.variable.name}|${c.grid.name}|${c.time_unit}`)),r,o),i=e(lt);"equals"in i&&i.equals(s)||(await s.executeAll(),t(ko,s))})()}),Op=Rt.atomEffect((e,t)=>{const n=e(Mo);(async()=>{const r=await n;t(sr,r.max_geographies)})()});Rt.observe((e,t)=>{const n=e(Mp);n==="new"?t(lr,{assignees:[],tags:[],markdown_description:"",name:""}):n&&(t(lr,new Promise(()=>{})),(async()=>{const r=await Ze(e,`/tasks/${n}?getComments=true`);t(lr,Di(r))})())},Xt),Rt.atomEffect((e,t)=>{const n=e(Zi),r=e(Eo);(async()=>{const o=await r;n!=="data"&&!o&&t(Zi,"data")})()});function qi(e,t){let n;return(...r)=>{window.clearTimeout(n),n=window.setTimeout(()=>e(...r),t)}}function Dp({debounce:e,scroll:t,polyfill:n,offsetSize:r}={debounce:0,scroll:!1,offsetSize:!1}){const o=n||(typeof window>"u"?class{}:window.ResizeObserver);if(!o)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[a,s]=A.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),i=A.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:a,orientationHandler:null}),c=e?typeof e=="number"?e:e.scroll:null,l=e?typeof e=="number"?e:e.resize:null,u=A.useRef(!1);A.useEffect(()=>(u.current=!0,()=>{u.current=!1}));const[d,p,h]=A.useMemo(()=>{const b=()=>{if(!i.current.element)return;const{left:I,top:w,width:x,height:C,bottom:S,right:M,x:E,y:O}=i.current.element.getBoundingClientRect(),P={left:I,top:w,width:x,height:C,bottom:S,right:M,x:E,y:O};i.current.element instanceof HTMLElement&&r&&(P.height=i.current.element.offsetHeight,P.width=i.current.element.offsetWidth),Object.freeze(P),u.current&&!Gp(i.current.lastBounds,P)&&s(i.current.lastBounds=P)};return[b,l?qi(b,l):b,c?qi(b,c):b]},[s,r,c,l]);function g(){i.current.scrollContainers&&(i.current.scrollContainers.forEach(b=>b.removeEventListener("scroll",h,!0)),i.current.scrollContainers=null),i.current.resizeObserver&&(i.current.resizeObserver.disconnect(),i.current.resizeObserver=null),i.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",i.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",i.current.orientationHandler))}function f(){i.current.element&&(i.current.resizeObserver=new o(h),i.current.resizeObserver.observe(i.current.element),t&&i.current.scrollContainers&&i.current.scrollContainers.forEach(b=>b.addEventListener("scroll",h,{capture:!0,passive:!0})),i.current.orientationHandler=()=>{h()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",i.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",i.current.orientationHandler))}const m=b=>{!b||b===i.current.element||(g(),i.current.element=b,i.current.scrollContainers=Ki(b),f())};return Tp(h,!!t),Np(p),A.useEffect(()=>{g(),f()},[t,h,p]),A.useEffect(()=>g,[]),[m,a,d]}function Np(e){A.useEffect(()=>{const t=e;return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[e])}function Tp(e,t){A.useEffect(()=>{if(t){const n=e;return window.addEventListener("scroll",n,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",n,!0)}}},[e,t])}function Ki(e){const t=[];if(!e||e===document.body)return t;const{overflow:n,overflowX:r,overflowY:o}=window.getComputedStyle(e);return[n,r,o].some(a=>a==="auto"||a==="scroll")&&t.push(e),[...t,...Ki(e.parentElement)]}const Fp=["x","y","top","bottom","left","right","width","height"],Gp=(e,t)=>Fp.every(n=>e[n]===t[n]);function _p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var es,ts;function Wp(){return ts||(ts=1,es=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,o,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[o]))return!1;for(o=r;o--!==0;){var s=a[o];if(!e(t[s],n[s]))return!1}return!0}return t!==t&&n!==n}),es}var Bp=Wp();const Vp=_p(Bp);function ns(e){const[t,n]=A.useState(null),{ref:r,spec:o,onEmbed:a,onError:s,options:i={}}=e;return Rp(()=>{let c=!1,l=null;return(async()=>{if(!(!r.current||c))try{if(l=await $f(r.current,o,i),c){l.finalize();return}n(l),a?.(l)}catch(u){console.error(`[react-vega] Error creating view: ${u}`),s?.(u)}})(),()=>{c=!0,l?.finalize()}},[o,i]),t}function Rp(e,t){const n=A.useRef(null),r=A.useRef(0);(!n.current||!Vp(t,n.current))&&(r.current+=1),n.current=t,A.useEffect(e,[r.current])}const Lp=A.forwardRef((e,t)=>{const{spec:n,options:r,onEmbed:o,onError:a,...s}=e,i=A.useRef(null);return A.useImperativeHandle(t,()=>{if(!i.current)throw new Error("VegaEmbed: ref is not attached to a div element");return i.current},[]),ns({ref:i,spec:n,onEmbed:o,onError:a,options:r}),y.jsx("div",{ref:i,...s})});Lp.displayName="VegaEmbed";const Yt="#fff",rs="#888",Hp={background:"#333",view:{stroke:rs},title:{color:Yt,subtitleColor:Yt},style:{"guide-label":{fill:Yt},"guide-title":{fill:Yt}},axis:{domainColor:Yt,gridColor:rs,tickColor:Yt}},Dt="#4572a7",Xp={background:"#fff",arc:{fill:Dt},area:{fill:Dt},line:{stroke:Dt,strokeWidth:2},path:{stroke:Dt},rect:{fill:Dt},shape:{stroke:Dt},symbol:{fill:Dt,strokeWidth:1.5,size:50},axis:{bandPosition:.5,grid:!0,gridColor:"#000000",gridOpacity:1,gridWidth:.5,labelPadding:10,tickSize:5,tickWidth:.5},axisBand:{grid:!1,tickExtra:!0},legend:{labelBaseline:"middle",labelFontSize:11,symbolSize:50,symbolType:"square"},range:{category:["#4572a7","#aa4643","#8aa453","#71598e","#4598ae","#d98445","#94aace","#d09393","#b9cc98","#a99cbc"]}},Po='IBM Plex Sans,system-ui,-apple-system,BlinkMacSystemFont,".sfnstext-regular",sans-serif',zp='IBM Plex Sans Condensed, system-ui, -apple-system, BlinkMacSystemFont, ".SFNSText-Regular", sans-serif',Oo=400,dr={textPrimary:{g90:"#f4f4f4",g100:"#f4f4f4",white:"#161616",g10:"#161616"},textSecondary:{g90:"#c6c6c6",g100:"#c6c6c6",white:"#525252",g10:"#525252"},layerAccent01:{white:"#e0e0e0",g10:"#e0e0e0",g90:"#525252",g100:"#393939"},gridBg:{white:"#ffffff",g10:"#ffffff",g90:"#161616",g100:"#161616"}},Yp=["#8a3ffc","#33b1ff","#007d79","#ff7eb6","#fa4d56","#fff1f1","#6fdc8c","#4589ff","#d12771","#d2a106","#08bdba","#bae6ff","#ba4e00","#d4bbff"],Zp=["#6929c4","#1192e8","#005d5d","#9f1853","#fa4d56","#570408","#198038","#002d9c","#ee538b","#b28600","#009d9a","#012749","#8a3800","#a56eff"];function fr({theme:e,background:t}){const n=["white","g10"].includes(e)?"light":"dark",r=dr.gridBg[e],o=dr.textPrimary[e],a=dr.textSecondary[e],s=n==="dark"?Yp:Zp,i=n==="dark"?"#d4bbff":"#6929c4";return{background:t,arc:{fill:i},area:{fill:i},path:{stroke:i},rect:{fill:i},shape:{stroke:i},symbol:{stroke:i},circle:{fill:i},view:{fill:r,stroke:r},group:{fill:r},title:{color:o,anchor:"start",dy:-15,fontSize:16,font:Po,fontWeight:600},axis:{labelColor:a,labelFontSize:12,labelFont:zp,labelFontWeight:Oo,titleColor:o,titleFontWeight:600,titleFontSize:12,grid:!0,gridColor:dr.layerAccent01[e],labelAngle:0},axisX:{titlePadding:10},axisY:{titlePadding:2.5},style:{"guide-label":{font:Po,fill:a,fontWeight:Oo},"guide-title":{font:Po,fill:a,fontWeight:Oo}},range:{category:s,diverging:["#750e13","#a2191f","#da1e28","#fa4d56","#ff8389","#ffb3b8","#ffd7d9","#fff1f1","#e5f6ff","#bae6ff","#82cfff","#33b1ff","#1192e8","#0072c3","#00539a","#003a6d"],heatmap:["#f6f2ff","#e8daff","#d4bbff","#be95ff","#a56eff","#8a3ffc","#6929c4","#491d8b","#31135e","#1c0f30"]}}}fr({theme:"white",background:"#ffffff"}),fr({theme:"g10",background:"#f4f4f4"}),fr({theme:"g90",background:"#262626"}),fr({theme:"g100",background:"#161616"});const os=A.memo(function({actions:t=!1,children:n,className:r="",endDate:o,id:a="default",setEndDate:s,setStartDate:i,spec:c,startDate:l,padding:u=16,style:d={},theme:p="light"}){const[h,{height:g,width:f}]=Dp(),m=!!(g&&f),b=A.useRef(null),[I,w]=A.useState(typeof c=="string"?null:c),x={...Hp,background:"transparent"},C={...Xp,background:"transparent"},S=A.useRef(null),M=ns({ref:S,spec:I,options:{mode:"vega-lite",actions:t,config:p==="dark"?x:C,padding:u}});return A.useEffect(()=>{if(typeof c=="string"){if(g&&f){const E=async()=>{let O=`${c}${c.includes("?")?"":"?"}&height=${Math.floor(g)}&width=${Math.floor(f)}`;l&&(O+=`&start_date=${l}`),o&&(O+=`&end_date=${o}`);const P=await nr(O);w(P)};I||b.current?(w(null),b.current&&clearTimeout(b.current),b.current=setTimeout(E,250)):E()}}else w(c)},[c,m]),A.useEffect(()=>{let E=!1;const O=async P=>{if(f&&Number.isFinite(f)&&P.width(f),!g||!Number.isFinite(g)){await P.runAsync();return}let W=!0;try{P.signal("concat_0_height")}catch{W=!1}if(!W){P.height(g),await P.runAsync();return}if(await P.runAsync(),!E)for(let N=0;N<2;N++){const T=S.current?.querySelector("svg");if(!T)break;const G=T.getBoundingClientRect().height-g;if(Math.abs(G)<=1)break;const F=P.signal("concat_0_height");if(P.signal("concat_0_height",Math.max(F-G,40)),await P.runAsync(),E)return}};return M?.view&&O(M.view),()=>{E=!0}},[M,f,g]),A.useEffect(()=>{const E={date_range:(P,W)=>{const N=Object.keys(W)[0];if(!N)return;const[T,D]=W[N].map(G=>new Date(G).toISOString().split("T")[0]);i&&i(T),s&&s(D)}},O={date_range:()=>{i&&i(null),s&&s(null)}};for(const P of Object.keys(E))I&&!I?.params?.find(({name:W})=>P===W)&&(delete E[P],P in O&&O[P]());for(const P of Object.keys(E))M?.view.addSignalListener(P,E[P]);return()=>{for(const P of Object.keys(E))M?.view.removeSignalListener(P,E[P])}},[M]),A.useEffect(()=>{if(S.current){const E=O=>{O.detail.id===a&&(async()=>{const P=await M?.view.toImageURL(O.detail.type);if(P){const W=document.createElement("a");W.setAttribute("href",P),W.setAttribute("target","_blank"),W.setAttribute("download",O.detail.filename),W.dispatchEvent(new MouseEvent("click"))}})()};return window.addEventListener("chartDownload",E),()=>{window.removeEventListener("chartDownload",E)}}},[M,a]),y.jsxs("div",{style:{height:"100%",position:"relative",width:"100%",...d},ref:h,children:[n,I?y.jsx("div",{style:{height:`${g}px`,overflow:"hidden",position:"absolute",width:`${f}px`},className:r,ref:S}):null]})},(e,t)=>Object.keys(e).filter(n=>n!=="children"&&!n.toLowerCase().includes("date")).every(n=>e[n]===t[n])),pr=new Map,mr=(e,t)=>`${e.name}:${t.join(",")}`,$p=async(e,t)=>{const n=e.getGeographyUrl(t),r=await fetch(n,{headers:{accept:"application/x-ndjson"}});if(!r.ok)throw new Error(`Received status ${r.status} while loading ${n}`);const o=new Map;return(await r.text()).split(`
|
|
3
3
|
`).filter(a=>a.length>0).forEach(a=>{const s=JSON.parse(a);o.set(`${s.src_lng},${s.src_lat}`,s.dst_id)}),t.map(a=>o.get(a.join(",")))},Jp=(e,t)=>{const n=[],r=new Set;if(t.forEach(o=>{if(!yt(o))return;const a=mr(e,o);pr.has(a)||r.has(a)||(r.add(a),n.push(o))}),n.length){const o=$p(e,n).catch(a=>(n.forEach(s=>pr.delete(mr(e,s))),console.error(a),n.map(()=>{})));n.forEach((a,s)=>pr.set(mr(e,a),o.then(i=>i[s])))}return Promise.all(t.map(o=>yt(o)?pr.get(mr(e,o)):o))};function jp(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function hr(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Up(e){return e=hr(Math.abs(e)),e?e[1]:NaN}function Qp(e,t){return function(n,r){for(var o=n.length,a=[],s=0,i=e[0],c=0;o>0&&i>0&&(c+i+1>r&&(i=Math.max(1,r-c)),a.push(n.substring(o-=i,o+i)),!((c+=i+1)>r));)i=e[s=(s+1)%e.length];return a.reverse().join(t)}}function qp(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var Kp=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Do(e){if(!(t=Kp.exec(e)))throw new Error("invalid format: "+e);var t;return new No({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Do.prototype=No.prototype;function No(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}No.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function em(e){e:for(var t=e.length,n=1,r=-1,o;n<t;++n)switch(e[n]){case".":r=o=n;break;case"0":r===0&&(r=n),o=n;break;default:if(!+e[n])break e;r>0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(o+1):e}var gr;function tm(e,t){var n=hr(e,t);if(!n)return gr=void 0,e.toPrecision(t);var r=n[0],o=n[1],a=o-(gr=Math.max(-8,Math.min(8,Math.floor(o/3)))*3)+1,s=r.length;return a===s?r:a>s?r+new Array(a-s+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+hr(e,Math.max(0,t+a-1))[0]}function as(e,t){var n=hr(e,t);if(!n)return e+"";var r=n[0],o=n[1];return o<0?"0."+new Array(-o).join("0")+r:r.length>o+1?r.slice(0,o+1)+"."+r.slice(o+1):r+new Array(o-r.length+2).join("0")}const is={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:jp,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>as(e*100,t),r:as,s:tm,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function ss(e){return e}var cs=Array.prototype.map,ls=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function nm(e){var t=e.grouping===void 0||e.thousands===void 0?ss:Qp(cs.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",o=e.decimal===void 0?".":e.decimal+"",a=e.numerals===void 0?ss:qp(cs.call(e.numerals,String)),s=e.percent===void 0?"%":e.percent+"",i=e.minus===void 0?"−":e.minus+"",c=e.nan===void 0?"NaN":e.nan+"";function l(d,p){d=Do(d);var h=d.fill,g=d.align,f=d.sign,m=d.symbol,b=d.zero,I=d.width,w=d.comma,x=d.precision,C=d.trim,S=d.type;S==="n"?(w=!0,S="g"):is[S]||(x===void 0&&(x=12),C=!0,S="g"),(b||h==="0"&&g==="=")&&(b=!0,h="0",g="=");var M=(p&&p.prefix!==void 0?p.prefix:"")+(m==="$"?n:m==="#"&&/[boxX]/.test(S)?"0"+S.toLowerCase():""),E=(m==="$"?r:/[%p]/.test(S)?s:"")+(p&&p.suffix!==void 0?p.suffix:""),O=is[S],P=/[defgprs%]/.test(S);x=x===void 0?6:/[gprs]/.test(S)?Math.max(1,Math.min(21,x)):Math.max(0,Math.min(20,x));function W(N){var T=M,D=E,G,F,B;if(S==="c")D=O(N)+D,N="";else{N=+N;var k=N<0||1/N<0;if(N=isNaN(N)?c:O(Math.abs(N),x),C&&(N=em(N)),k&&+N==0&&f!=="+"&&(k=!1),T=(k?f==="("?f:i:f==="-"||f==="("?"":f)+T,D=(S==="s"&&!isNaN(N)&&gr!==void 0?ls[8+gr/3]:"")+D+(k&&f==="("?")":""),P){for(G=-1,F=N.length;++G<F;)if(B=N.charCodeAt(G),48>B||B>57){D=(B===46?o+N.slice(G+1):N.slice(G))+D,N=N.slice(0,G);break}}}w&&!b&&(N=t(N,1/0));var _=T.length+N.length+D.length,X=_<I?new Array(I-_+1).join(h):"";switch(w&&b&&(N=t(X+N,X.length?I-D.length:1/0),X=""),g){case"<":N=T+N+D+X;break;case"=":N=T+X+N+D;break;case"^":N=X.slice(0,_=X.length>>1)+T+N+D+X.slice(_);break;default:N=X+T+N+D;break}return a(N)}return W.toString=function(){return d+""},W}function u(d,p){var h=Math.max(-8,Math.min(8,Math.floor(Up(p)/3)))*3,g=Math.pow(10,-h),f=l((d=Do(d),d.type="f",d),{suffix:ls[8+h/3]});return function(m){return f(g*m)}}return{format:l,formatPrefix:u}}var br,us;rm({thousands:",",grouping:[3],currency:["$",""]});function rm(e){return br=nm(e),us=br.format,br.formatPrefix,br}class om{_container;_map;getDefaultPosition(){return"bottom-left"}onAdd(t){return this._map=t,this.addEventHandlers(),this._container=document.createElement("div"),this._container.className="maplibregl-ctrl maplibregl-ctrl-group cpra-map-legend",this._container}onRemove(){this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=void 0}addEventHandlers(){if(this._map){const t=()=>this.updateLegend();this._map.on("load",t),this._map.on("styledata",t)}}updateLegend(){if(this._map&&this._container){const t=this._map.getGlobalState()?.legend;if(this.clearContainer(),t)for(const n of t.entries){const r=document.createElement("div");if(r.className="entry",n.title){const o=document.createElement("h2");if(o.className="title",o.innerText=n.title,n.subtitle){const a=document.createElement("span");a.className="subtitle",a.innerText=`(${n.subtitle})`,o.innerText+=" ",o.append(a)}r.append(o)}n.type==="discrete"?this.addDiscreteSteps(r,n.steps):n.type==="continuous"&&this.addContinuousSteps(r,n),this._container.append(r)}}}addContinuousSteps(t,n){const{numberFormat:r,steps:o}=n;if(o.length<2)return;const a=o[0].value,i=o[o.length-1].value-a,c=o.map(g=>({...g,pct:(g.value-a)*100/i})),l=document.createElement("div");l.className="continuous-steps";const u=document.createElement("div");u.className="continuous-symbol";const d=c.map(g=>`${g.color} ${g.pct}%`).join(", ");u.style.backgroundImage=`linear-gradient(to right, ${d})`,l.append(u);const p=document.createElement("div");p.className="continuous-ticks";const h=us(r);for(const g of c){const f=document.createElement("div");f.className="tick",f.style.left=`${g.pct}%`;const m=document.createElement("span");m.className="label",m.style.left=`-${g.pct}%`,m.innerText=g.value===0?"0":h(g.value),f.append(m),p.append(f)}l.append(p),t.append(l)}addDiscreteSteps(t,n){const r=new Set;for(const o of n){if(r.has(o.label))continue;r.add(o.label);const a=document.createElement("div");a.className="discrete-step";const s=document.createElement("div");s.className="discrete-symbol",s.style.backgroundColor=o.color;const i=document.createElement("span");i.className="discrete-label",i.innerText=o.label,a.append(s,i),t.append(a)}}clearContainer(){this._container&&(this._container.innerHTML="")}}function U(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function Ct(e,t=[]){let n=[];function r(a,s){const i=v.createContext(s),c=n.length;n=[...n,s];const l=d=>{const{scope:p,children:h,...g}=d,f=p?.[e]?.[c]||i,m=v.useMemo(()=>g,Object.values(g));return y.jsx(f.Provider,{value:m,children:h})};l.displayName=a+"Provider";function u(d,p){const h=p?.[e]?.[c]||i,g=v.useContext(h);if(g)return g;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${a}\``)}return[l,u]}const o=()=>{const a=n.map(s=>v.createContext(s));return function(i){const c=i?.[e]||a;return v.useMemo(()=>({[`__scope${e}`]:{...i,[e]:c}}),[i,c])}};return o.scopeName=e,[r,am(o,...t)]}function am(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const s=r.reduce((i,{useScope:c,scopeName:l})=>{const d=c(a)[`__scope${l}`];return{...i,...d}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function ds(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function vr(...e){return t=>{let n=!1;const r=e.map(o=>{const a=ds(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():ds(e[o],null)}}}}function ye(...e){return v.useCallback(vr(...e),e)}function Zt(e){const t=sm(e),n=v.forwardRef((r,o)=>{const{children:a,...s}=r,i=v.Children.toArray(a),c=i.find(lm);if(c){const l=c.props.children,u=i.map(d=>d===c?v.Children.count(l)>1?v.Children.only(null):v.isValidElement(l)?l.props.children:null:d);return y.jsx(t,{...s,ref:o,children:v.isValidElement(l)?v.cloneElement(l,void 0,u):null})}return y.jsx(t,{...s,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}var im=Zt("Slot");function sm(e){const t=v.forwardRef((n,r)=>{const{children:o,...a}=n;if(v.isValidElement(o)){const s=dm(o),i=um(a,o.props);return o.type!==v.Fragment&&(i.ref=r?vr(r,s):s),v.cloneElement(o,i)}return v.Children.count(o)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var cm=Symbol("radix.slottable");function lm(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===cm}function um(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...i)=>{const c=a(...i);return o(...i),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function dm(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var fm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],be=fm.reduce((e,t)=>{const n=Zt(`Primitive.${t}`),r=v.forwardRef((o,a)=>{const{asChild:s,...i}=o,c=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(c,{...i,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function fs(e,t){e&&Oi.flushSync(()=>e.dispatchEvent(t))}function To(e){const t=e+"CollectionProvider",[n,r]=Ct(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=f=>{const{scope:m,children:b}=f,I=A.useRef(null),w=A.useRef(new Map).current;return y.jsx(o,{scope:m,itemMap:w,collectionRef:I,children:b})};s.displayName=t;const i=e+"CollectionSlot",c=Zt(i),l=A.forwardRef((f,m)=>{const{scope:b,children:I}=f,w=a(i,b),x=ye(m,w.collectionRef);return y.jsx(c,{ref:x,children:I})});l.displayName=i;const u=e+"CollectionItemSlot",d="data-radix-collection-item",p=Zt(u),h=A.forwardRef((f,m)=>{const{scope:b,children:I,...w}=f,x=A.useRef(null),C=ye(m,x),S=a(u,b);return A.useEffect(()=>(S.itemMap.set(x,{ref:x,...w}),()=>{S.itemMap.delete(x)})),y.jsx(p,{[d]:"",ref:C,children:I})});h.displayName=u;function g(f){const m=a(e+"CollectionConsumer",f);return A.useCallback(()=>{const I=m.collectionRef.current;if(!I)return[];const w=Array.from(I.querySelectorAll(`[${d}]`));return Array.from(m.itemMap.values()).sort((S,M)=>w.indexOf(S.ref.current)-w.indexOf(M.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:s,Slot:l,ItemSlot:h},g,r]}var pm=v.createContext(void 0);function Fo(e){const t=v.useContext(pm);return e||t||"ltr"}function $e(e){const t=v.useRef(e);return v.useEffect(()=>{t.current=e}),v.useMemo(()=>(...n)=>t.current?.(...n),[])}function mm(e,t=globalThis?.document){const n=$e(e);v.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var hm="DismissableLayer",Go="dismissableLayer.update",gm="dismissableLayer.pointerDownOutside",bm="dismissableLayer.focusOutside",ps,ms=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_o=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:s,onDismiss:i,...c}=e,l=v.useContext(ms),[u,d]=v.useState(null),p=u?.ownerDocument??globalThis?.document,[,h]=v.useState({}),g=ye(t,M=>d(M)),f=Array.from(l.layers),[m]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),b=f.indexOf(m),I=u?f.indexOf(u):-1,w=l.layersWithOutsidePointerEventsDisabled.size>0,x=I>=b,C=Cm(M=>{const E=M.target,O=[...l.branches].some(P=>P.contains(E));!x||O||(o?.(M),s?.(M),M.defaultPrevented||i?.())},p),S=wm(M=>{const E=M.target;[...l.branches].some(P=>P.contains(E))||(a?.(M),s?.(M),M.defaultPrevented||i?.())},p);return mm(M=>{I===l.layers.size-1&&(r?.(M),!M.defaultPrevented&&i&&(M.preventDefault(),i()))},p),v.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(ps=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),hs(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=ps)}},[u,p,n,l]),v.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),hs())},[u,l]),v.useEffect(()=>{const M=()=>h({});return document.addEventListener(Go,M),()=>document.removeEventListener(Go,M)},[]),y.jsx(be.div,{...c,ref:g,style:{pointerEvents:w?x?"auto":"none":void 0,...e.style},onFocusCapture:U(e.onFocusCapture,S.onFocusCapture),onBlurCapture:U(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:U(e.onPointerDownCapture,C.onPointerDownCapture)})});_o.displayName=hm;var vm="DismissableLayerBranch",ym=v.forwardRef((e,t)=>{const n=v.useContext(ms),r=v.useRef(null),o=ye(t,r);return v.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),y.jsx(be.div,{...e,ref:o})});ym.displayName=vm;function Cm(e,t=globalThis?.document){const n=$e(e),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const a=i=>{if(i.target&&!r.current){let c=function(){gs(gm,n,l,{discrete:!0})};const l={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function wm(e,t=globalThis?.document){const n=$e(e),r=v.useRef(!1);return v.useEffect(()=>{const o=a=>{a.target&&!r.current&&gs(bm,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function hs(){const e=new CustomEvent(Go);document.dispatchEvent(e)}function gs(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?fs(o,a):o.dispatchEvent(a)}var Wo=0;function bs(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??vs()),document.body.insertAdjacentElement("beforeend",e[1]??vs()),Wo++,()=>{Wo===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Wo--}},[])}function vs(){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 Bo="focusScope.autoFocusOnMount",Vo="focusScope.autoFocusOnUnmount",ys={bubbles:!1,cancelable:!0},Im="FocusScope",Ro=v.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...s}=e,[i,c]=v.useState(null),l=$e(o),u=$e(a),d=v.useRef(null),p=ye(t,f=>c(f)),h=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let f=function(w){if(h.paused||!i)return;const x=w.target;i.contains(x)?d.current=x:wt(d.current,{select:!0})},m=function(w){if(h.paused||!i)return;const x=w.relatedTarget;x!==null&&(i.contains(x)||wt(d.current,{select:!0}))},b=function(w){if(document.activeElement===document.body)for(const C of w)C.removedNodes.length>0&&wt(i)};document.addEventListener("focusin",f),document.addEventListener("focusout",m);const I=new MutationObserver(b);return i&&I.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",f),document.removeEventListener("focusout",m),I.disconnect()}}},[r,i,h.paused]),v.useEffect(()=>{if(i){Is.add(h);const f=document.activeElement;if(!i.contains(f)){const b=new CustomEvent(Bo,ys);i.addEventListener(Bo,l),i.dispatchEvent(b),b.defaultPrevented||(xm(km(Cs(i)),{select:!0}),document.activeElement===f&&wt(i))}return()=>{i.removeEventListener(Bo,l),setTimeout(()=>{const b=new CustomEvent(Vo,ys);i.addEventListener(Vo,u),i.dispatchEvent(b),b.defaultPrevented||wt(f??document.body,{select:!0}),i.removeEventListener(Vo,u),Is.remove(h)},0)}}},[i,l,u,h]);const g=v.useCallback(f=>{if(!n&&!r||h.paused)return;const m=f.key==="Tab"&&!f.altKey&&!f.ctrlKey&&!f.metaKey,b=document.activeElement;if(m&&b){const I=f.currentTarget,[w,x]=Sm(I);w&&x?!f.shiftKey&&b===x?(f.preventDefault(),n&&wt(w,{select:!0})):f.shiftKey&&b===w&&(f.preventDefault(),n&&wt(x,{select:!0})):b===I&&f.preventDefault()}},[n,r,h.paused]);return y.jsx(be.div,{tabIndex:-1,...s,ref:p,onKeyDown:g})});Ro.displayName=Im;function xm(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(wt(r,{select:t}),document.activeElement!==n)return}function Sm(e){const t=Cs(e),n=ws(t,e),r=ws(t.reverse(),e);return[n,r]}function Cs(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ws(e,t){for(const n of e)if(!Am(n,{upTo:t}))return n}function Am(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Mm(e){return e instanceof HTMLInputElement&&"select"in e}function wt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Mm(e)&&t&&e.select()}}var Is=Em();function Em(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=xs(e,t),e.unshift(t)},remove(t){e=xs(e,t),e[0]?.resume()}}}function xs(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function km(e){return e.filter(t=>t.tagName!=="A")}var It=globalThis?.document?v.useLayoutEffect:()=>{},Pm=v[" useId ".trim().toString()]||(()=>{}),Om=0;function $t(e){const[t,n]=v.useState(Pm());return It(()=>{n(r=>r??String(Om++))},[e]),e||(t?`radix-${t}`:"")}const Dm=["top","right","bottom","left"],xt=Math.min,Fe=Math.max,yr=Math.round,Cr=Math.floor,qe=e=>({x:e,y:e}),Nm={left:"right",right:"left",bottom:"top",top:"bottom"},Tm={start:"end",end:"start"};function Lo(e,t,n){return Fe(e,xt(t,n))}function dt(e,t){return typeof e=="function"?e(t):e}function ft(e){return e.split("-")[0]}function Jt(e){return e.split("-")[1]}function Ho(e){return e==="x"?"y":"x"}function Xo(e){return e==="y"?"height":"width"}const Fm=new Set(["top","bottom"]);function Ke(e){return Fm.has(ft(e))?"y":"x"}function zo(e){return Ho(Ke(e))}function Gm(e,t,n){n===void 0&&(n=!1);const r=Jt(e),o=zo(e),a=Xo(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(s=wr(s)),[s,wr(s)]}function _m(e){const t=wr(e);return[Yo(e),t,Yo(t)]}function Yo(e){return e.replace(/start|end/g,t=>Tm[t])}const Ss=["left","right"],As=["right","left"],Wm=["top","bottom"],Bm=["bottom","top"];function Vm(e,t,n){switch(e){case"top":case"bottom":return n?t?As:Ss:t?Ss:As;case"left":case"right":return t?Wm:Bm;default:return[]}}function Rm(e,t,n,r){const o=Jt(e);let a=Vm(ft(e),n==="start",r);return o&&(a=a.map(s=>s+"-"+o),t&&(a=a.concat(a.map(Yo)))),a}function wr(e){return e.replace(/left|right|bottom|top/g,t=>Nm[t])}function Lm(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ms(e){return typeof e!="number"?Lm(e):{top:e,right:e,bottom:e,left:e}}function Ir(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Es(e,t,n){let{reference:r,floating:o}=e;const a=Ke(t),s=zo(t),i=Xo(s),c=ft(t),l=a==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,p=r[i]/2-o[i]/2;let h;switch(c){case"top":h={x:u,y:r.y-o.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-o.width,y:d};break;default:h={x:r.x,y:r.y}}switch(Jt(t)){case"start":h[s]-=p*(n&&l?-1:1);break;case"end":h[s]+=p*(n&&l?-1:1);break}return h}const Hm=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:s}=n,i=a.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(t));let l=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=Es(l,r,c),p=r,h={},g=0;for(let f=0;f<i.length;f++){const{name:m,fn:b}=i[f],{x:I,y:w,data:x,reset:C}=await b({x:u,y:d,initialPlacement:r,placement:p,strategy:o,middlewareData:h,rects:l,platform:s,elements:{reference:e,floating:t}});u=I??u,d=w??d,h={...h,[m]:{...h[m],...x}},C&&g<=50&&(g++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(l=C.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:u,y:d}=Es(l,p,c)),f=-1)}return{x:u,y:d,placement:p,strategy:o,middlewareData:h}};async function An(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:a,rects:s,elements:i,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:p=!1,padding:h=0}=dt(t,e),g=Ms(h),m=i[p?d==="floating"?"reference":"floating":d],b=Ir(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(m)))==null||n?m:m.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(i.floating)),boundary:l,rootBoundary:u,strategy:c})),I=d==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(i.floating)),x=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},C=Ir(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:I,offsetParent:w,strategy:c}):I);return{top:(b.top-C.top+g.top)/x.y,bottom:(C.bottom-b.bottom+g.bottom)/x.y,left:(b.left-C.left+g.left)/x.x,right:(C.right-b.right+g.right)/x.x}}const Xm=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:a,platform:s,elements:i,middlewareData:c}=t,{element:l,padding:u=0}=dt(e,t)||{};if(l==null)return{};const d=Ms(u),p={x:n,y:r},h=zo(o),g=Xo(h),f=await s.getDimensions(l),m=h==="y",b=m?"top":"left",I=m?"bottom":"right",w=m?"clientHeight":"clientWidth",x=a.reference[g]+a.reference[h]-p[h]-a.floating[g],C=p[h]-a.reference[h],S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l));let M=S?S[w]:0;(!M||!await(s.isElement==null?void 0:s.isElement(S)))&&(M=i.floating[w]||a.floating[g]);const E=x/2-C/2,O=M/2-f[g]/2-1,P=xt(d[b],O),W=xt(d[I],O),N=P,T=M-f[g]-W,D=M/2-f[g]/2+E,G=Lo(N,D,T),F=!c.arrow&&Jt(o)!=null&&D!==G&&a.reference[g]/2-(D<N?P:W)-f[g]/2<0,B=F?D<N?D-N:D-T:0;return{[h]:p[h]+B,data:{[h]:G,centerOffset:D-G-B,...F&&{alignmentOffset:B}},reset:F}}}),zm=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:a,rects:s,initialPlacement:i,platform:c,elements:l}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:f=!0,...m}=dt(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const b=ft(o),I=Ke(i),w=ft(i)===i,x=await(c.isRTL==null?void 0:c.isRTL(l.floating)),C=p||(w||!f?[wr(i)]:_m(i)),S=g!=="none";!p&&S&&C.push(...Rm(i,f,g,x));const M=[i,...C],E=await An(t,m),O=[];let P=((r=a.flip)==null?void 0:r.overflows)||[];if(u&&O.push(E[b]),d){const D=Gm(o,s,x);O.push(E[D[0]],E[D[1]])}if(P=[...P,{placement:o,overflows:O}],!O.every(D=>D<=0)){var W,N;const D=(((W=a.flip)==null?void 0:W.index)||0)+1,G=M[D];if(G&&(!(d==="alignment"?I!==Ke(G):!1)||P.every(k=>Ke(k.placement)===I?k.overflows[0]>0:!0)))return{data:{index:D,overflows:P},reset:{placement:G}};let F=(N=P.filter(B=>B.overflows[0]<=0).sort((B,k)=>B.overflows[1]-k.overflows[1])[0])==null?void 0:N.placement;if(!F)switch(h){case"bestFit":{var T;const B=(T=P.filter(k=>{if(S){const _=Ke(k.placement);return _===I||_==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(_=>_>0).reduce((_,X)=>_+X,0)]).sort((k,_)=>k[1]-_[1])[0])==null?void 0:T[0];B&&(F=B);break}case"initialPlacement":F=i;break}if(o!==F)return{reset:{placement:F}}}return{}}}};function ks(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ps(e){return Dm.some(t=>e[t]>=0)}const Ym=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=dt(e,t);switch(r){case"referenceHidden":{const a=await An(t,{...o,elementContext:"reference"}),s=ks(a,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:Ps(s)}}}case"escaped":{const a=await An(t,{...o,altBoundary:!0}),s=ks(a,n.floating);return{data:{escapedOffsets:s,escaped:Ps(s)}}}default:return{}}}}},Os=new Set(["left","top"]);async function Zm(e,t){const{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=ft(n),i=Jt(n),c=Ke(n)==="y",l=Os.has(s)?-1:1,u=a&&c?-1:1,d=dt(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return i&&typeof g=="number"&&(h=i==="end"?g*-1:g),c?{x:h*u,y:p*l}:{x:p*l,y:h*u}}const $m=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:a,placement:s,middlewareData:i}=t,c=await Zm(t,e);return s===((n=i.offset)==null?void 0:n.placement)&&(r=i.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:a+c.y,data:{...c,placement:s}}}}},Jm=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:a=!0,crossAxis:s=!1,limiter:i={fn:m=>{let{x:b,y:I}=m;return{x:b,y:I}}},...c}=dt(e,t),l={x:n,y:r},u=await An(t,c),d=Ke(ft(o)),p=Ho(d);let h=l[p],g=l[d];if(a){const m=p==="y"?"top":"left",b=p==="y"?"bottom":"right",I=h+u[m],w=h-u[b];h=Lo(I,h,w)}if(s){const m=d==="y"?"top":"left",b=d==="y"?"bottom":"right",I=g+u[m],w=g-u[b];g=Lo(I,g,w)}const f=i.fn({...t,[p]:h,[d]:g});return{...f,data:{x:f.x-n,y:f.y-r,enabled:{[p]:a,[d]:s}}}}}},jm=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:a,middlewareData:s}=t,{offset:i=0,mainAxis:c=!0,crossAxis:l=!0}=dt(e,t),u={x:n,y:r},d=Ke(o),p=Ho(d);let h=u[p],g=u[d];const f=dt(i,t),m=typeof f=="number"?{mainAxis:f,crossAxis:0}:{mainAxis:0,crossAxis:0,...f};if(c){const w=p==="y"?"height":"width",x=a.reference[p]-a.floating[w]+m.mainAxis,C=a.reference[p]+a.reference[w]-m.mainAxis;h<x?h=x:h>C&&(h=C)}if(l){var b,I;const w=p==="y"?"width":"height",x=Os.has(ft(o)),C=a.reference[d]-a.floating[w]+(x&&((b=s.offset)==null?void 0:b[d])||0)+(x?0:m.crossAxis),S=a.reference[d]+a.reference[w]+(x?0:((I=s.offset)==null?void 0:I[d])||0)-(x?m.crossAxis:0);g<C?g=C:g>S&&(g=S)}return{[p]:h,[d]:g}}}},Um=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:a,platform:s,elements:i}=t,{apply:c=()=>{},...l}=dt(e,t),u=await An(t,l),d=ft(o),p=Jt(o),h=Ke(o)==="y",{width:g,height:f}=a.floating;let m,b;d==="top"||d==="bottom"?(m=d,b=p===(await(s.isRTL==null?void 0:s.isRTL(i.floating))?"start":"end")?"left":"right"):(b=d,m=p==="end"?"top":"bottom");const I=f-u.top-u.bottom,w=g-u.left-u.right,x=xt(f-u[m],I),C=xt(g-u[b],w),S=!t.middlewareData.shift;let M=x,E=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(E=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(M=I),S&&!p){const P=Fe(u.left,0),W=Fe(u.right,0),N=Fe(u.top,0),T=Fe(u.bottom,0);h?E=g-2*(P!==0||W!==0?P+W:Fe(u.left,u.right)):M=f-2*(N!==0||T!==0?N+T:Fe(u.top,u.bottom))}await c({...t,availableWidth:E,availableHeight:M});const O=await s.getDimensions(i.floating);return g!==O.width||f!==O.height?{reset:{rects:!0}}:{}}}};function xr(){return typeof window<"u"}function jt(e){return Ds(e)?(e.nodeName||"").toLowerCase():"#document"}function Ge(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function et(e){var t;return(t=(Ds(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ds(e){return xr()?e instanceof Node||e instanceof Ge(e).Node:!1}function Je(e){return xr()?e instanceof Element||e instanceof Ge(e).Element:!1}function tt(e){return xr()?e instanceof HTMLElement||e instanceof Ge(e).HTMLElement:!1}function Ns(e){return!xr()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ge(e).ShadowRoot}const Qm=new Set(["inline","contents"]);function Mn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=je(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Qm.has(o)}const qm=new Set(["table","td","th"]);function Km(e){return qm.has(jt(e))}const eh=[":popover-open",":modal"];function Sr(e){return eh.some(t=>{try{return e.matches(t)}catch{return!1}})}const th=["transform","translate","scale","rotate","perspective"],nh=["transform","translate","scale","rotate","perspective","filter"],rh=["paint","layout","strict","content"];function Zo(e){const t=$o(),n=Je(e)?je(e):e;return th.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||nh.some(r=>(n.willChange||"").includes(r))||rh.some(r=>(n.contain||"").includes(r))}function oh(e){let t=St(e);for(;tt(t)&&!Ut(t);){if(Zo(t))return t;if(Sr(t))return null;t=St(t)}return null}function $o(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ah=new Set(["html","body","#document"]);function Ut(e){return ah.has(jt(e))}function je(e){return Ge(e).getComputedStyle(e)}function Ar(e){return Je(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function St(e){if(jt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ns(e)&&e.host||et(e);return Ns(t)?t.host:t}function Ts(e){const t=St(e);return Ut(t)?e.ownerDocument?e.ownerDocument.body:e.body:tt(t)&&Mn(t)?t:Ts(t)}function En(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ts(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),s=Ge(o);if(a){const i=Jo(s);return t.concat(s,s.visualViewport||[],Mn(o)?o:[],i&&n?En(i):[])}return t.concat(o,En(o,[],n))}function Jo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Fs(e){const t=je(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=tt(e),a=o?e.offsetWidth:n,s=o?e.offsetHeight:r,i=yr(n)!==a||yr(r)!==s;return i&&(n=a,r=s),{width:n,height:r,$:i}}function jo(e){return Je(e)?e:e.contextElement}function Qt(e){const t=jo(e);if(!tt(t))return qe(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:a}=Fs(t);let s=(a?yr(n.width):n.width)/r,i=(a?yr(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!i||!Number.isFinite(i))&&(i=1),{x:s,y:i}}const ih=qe(0);function Gs(e){const t=Ge(e);return!$o()||!t.visualViewport?ih:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function sh(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ge(e)?!1:t}function Nt(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=jo(e);let s=qe(1);t&&(r?Je(r)&&(s=Qt(r)):s=Qt(e));const i=sh(a,n,r)?Gs(a):qe(0);let c=(o.left+i.x)/s.x,l=(o.top+i.y)/s.y,u=o.width/s.x,d=o.height/s.y;if(a){const p=Ge(a),h=r&&Je(r)?Ge(r):r;let g=p,f=Jo(g);for(;f&&r&&h!==g;){const m=Qt(f),b=f.getBoundingClientRect(),I=je(f),w=b.left+(f.clientLeft+parseFloat(I.paddingLeft))*m.x,x=b.top+(f.clientTop+parseFloat(I.paddingTop))*m.y;c*=m.x,l*=m.y,u*=m.x,d*=m.y,c+=w,l+=x,g=Ge(f),f=Jo(g)}}return Ir({width:u,height:d,x:c,y:l})}function Uo(e,t){const n=Ar(e).scrollLeft;return t?t.left+n:Nt(et(e)).left+n}function _s(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:Uo(e,r)),a=r.top+t.scrollTop;return{x:o,y:a}}function ch(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const a=o==="fixed",s=et(r),i=t?Sr(t.floating):!1;if(r===s||i&&a)return n;let c={scrollLeft:0,scrollTop:0},l=qe(1);const u=qe(0),d=tt(r);if((d||!d&&!a)&&((jt(r)!=="body"||Mn(s))&&(c=Ar(r)),tt(r))){const h=Nt(r);l=Qt(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const p=s&&!d&&!a?_s(s,c,!0):qe(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+p.x,y:n.y*l.y-c.scrollTop*l.y+u.y+p.y}}function lh(e){return Array.from(e.getClientRects())}function uh(e){const t=et(e),n=Ar(e),r=e.ownerDocument.body,o=Fe(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Fe(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+Uo(e);const i=-n.scrollTop;return je(r).direction==="rtl"&&(s+=Fe(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:s,y:i}}function dh(e,t){const n=Ge(e),r=et(e),o=n.visualViewport;let a=r.clientWidth,s=r.clientHeight,i=0,c=0;if(o){a=o.width,s=o.height;const l=$o();(!l||l&&t==="fixed")&&(i=o.offsetLeft,c=o.offsetTop)}return{width:a,height:s,x:i,y:c}}const fh=new Set(["absolute","fixed"]);function ph(e,t){const n=Nt(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=tt(e)?Qt(e):qe(1),s=e.clientWidth*a.x,i=e.clientHeight*a.y,c=o*a.x,l=r*a.y;return{width:s,height:i,x:c,y:l}}function Ws(e,t,n){let r;if(t==="viewport")r=dh(e,n);else if(t==="document")r=uh(et(e));else if(Je(t))r=ph(t,n);else{const o=Gs(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ir(r)}function Bs(e,t){const n=St(e);return n===t||!Je(n)||Ut(n)?!1:je(n).position==="fixed"||Bs(n,t)}function mh(e,t){const n=t.get(e);if(n)return n;let r=En(e,[],!1).filter(i=>Je(i)&&jt(i)!=="body"),o=null;const a=je(e).position==="fixed";let s=a?St(e):e;for(;Je(s)&&!Ut(s);){const i=je(s),c=Zo(s);!c&&i.position==="fixed"&&(o=null),(a?!c&&!o:!c&&i.position==="static"&&!!o&&fh.has(o.position)||Mn(s)&&!c&&Bs(e,s))?r=r.filter(u=>u!==s):o=i,s=St(s)}return t.set(e,r),r}function hh(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?Sr(t)?[]:mh(t,this._c):[].concat(n),r],i=s[0],c=s.reduce((l,u)=>{const d=Ws(t,u,o);return l.top=Fe(d.top,l.top),l.right=xt(d.right,l.right),l.bottom=xt(d.bottom,l.bottom),l.left=Fe(d.left,l.left),l},Ws(t,i,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function gh(e){const{width:t,height:n}=Fs(e);return{width:t,height:n}}function bh(e,t,n){const r=tt(t),o=et(t),a=n==="fixed",s=Nt(e,!0,a,t);let i={scrollLeft:0,scrollTop:0};const c=qe(0);function l(){c.x=Uo(o)}if(r||!r&&!a)if((jt(t)!=="body"||Mn(o))&&(i=Ar(t)),r){const h=Nt(t,!0,a,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else o&&l();a&&!r&&o&&l();const u=o&&!r&&!a?_s(o,i):qe(0),d=s.left+i.scrollLeft-c.x-u.x,p=s.top+i.scrollTop-c.y-u.y;return{x:d,y:p,width:s.width,height:s.height}}function Qo(e){return je(e).position==="static"}function Vs(e,t){if(!tt(e)||je(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return et(e)===n&&(n=n.ownerDocument.body),n}function Rs(e,t){const n=Ge(e);if(Sr(e))return n;if(!tt(e)){let o=St(e);for(;o&&!Ut(o);){if(Je(o)&&!Qo(o))return o;o=St(o)}return n}let r=Vs(e,t);for(;r&&Km(r)&&Qo(r);)r=Vs(r,t);return r&&Ut(r)&&Qo(r)&&!Zo(r)?n:r||oh(e)||n}const vh=async function(e){const t=this.getOffsetParent||Rs,n=this.getDimensions,r=await n(e.floating);return{reference:bh(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function yh(e){return je(e).direction==="rtl"}const Ch={convertOffsetParentRelativeRectToViewportRelativeRect:ch,getDocumentElement:et,getClippingRect:hh,getOffsetParent:Rs,getElementRects:vh,getClientRects:lh,getDimensions:gh,getScale:Qt,isElement:Je,isRTL:yh};function Ls(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function wh(e,t){let n=null,r;const o=et(e);function a(){var i;clearTimeout(r),(i=n)==null||i.disconnect(),n=null}function s(i,c){i===void 0&&(i=!1),c===void 0&&(c=1),a();const l=e.getBoundingClientRect(),{left:u,top:d,width:p,height:h}=l;if(i||t(),!p||!h)return;const g=Cr(d),f=Cr(o.clientWidth-(u+p)),m=Cr(o.clientHeight-(d+h)),b=Cr(u),w={rootMargin:-g+"px "+-f+"px "+-m+"px "+-b+"px",threshold:Fe(0,xt(1,c))||1};let x=!0;function C(S){const M=S[0].intersectionRatio;if(M!==c){if(!x)return s();M?s(!1,M):r=setTimeout(()=>{s(!1,1e-7)},1e3)}M===1&&!Ls(l,e.getBoundingClientRect())&&s(),x=!1}try{n=new IntersectionObserver(C,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,w)}n.observe(e)}return s(!0),a}function Hs(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,l=jo(e),u=o||a?[...l?En(l):[],...En(t)]:[];u.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),a&&b.addEventListener("resize",n)});const d=l&&i?wh(l,n):null;let p=-1,h=null;s&&(h=new ResizeObserver(b=>{let[I]=b;I&&I.target===l&&h&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=h)==null||w.observe(t)})),n()}),l&&!c&&h.observe(l),h.observe(t));let g,f=c?Nt(e):null;c&&m();function m(){const b=Nt(e);f&&!Ls(f,b)&&n(),f=b,g=requestAnimationFrame(m)}return n(),()=>{var b;u.forEach(I=>{o&&I.removeEventListener("scroll",n),a&&I.removeEventListener("resize",n)}),d?.(),(b=h)==null||b.disconnect(),h=null,c&&cancelAnimationFrame(g)}}const Ih=$m,xh=Jm,Sh=zm,Ah=Um,Mh=Ym,Xs=Xm,Eh=jm,kh=(e,t,n)=>{const r=new Map,o={platform:Ch,...n},a={...o.platform,_c:r};return Hm(e,t,{...o,platform:a})};var Ph=typeof document<"u",Oh=function(){},Mr=Ph?A.useLayoutEffect:Oh;function Er(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Er(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const a=o[r];if(!(a==="_owner"&&e.$$typeof)&&!Er(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function zs(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ys(e,t){const n=zs(e);return Math.round(t*n)/n}function qo(e){const t=v.useRef(e);return Mr(()=>{t.current=e}),t}function Dh(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:s}={},transform:i=!0,whileElementsMounted:c,open:l}=e,[u,d]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=v.useState(r);Er(p,r)||h(r);const[g,f]=v.useState(null),[m,b]=v.useState(null),I=v.useCallback(k=>{k!==S.current&&(S.current=k,f(k))},[]),w=v.useCallback(k=>{k!==M.current&&(M.current=k,b(k))},[]),x=a||g,C=s||m,S=v.useRef(null),M=v.useRef(null),E=v.useRef(u),O=c!=null,P=qo(c),W=qo(o),N=qo(l),T=v.useCallback(()=>{if(!S.current||!M.current)return;const k={placement:t,strategy:n,middleware:p};W.current&&(k.platform=W.current),kh(S.current,M.current,k).then(_=>{const X={..._,isPositioned:N.current!==!1};D.current&&!Er(E.current,X)&&(E.current=X,Oi.flushSync(()=>{d(X)}))})},[p,t,n,W,N]);Mr(()=>{l===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,d(k=>({...k,isPositioned:!1})))},[l]);const D=v.useRef(!1);Mr(()=>(D.current=!0,()=>{D.current=!1}),[]),Mr(()=>{if(x&&(S.current=x),C&&(M.current=C),x&&C){if(P.current)return P.current(x,C,T);T()}},[x,C,T,P,O]);const G=v.useMemo(()=>({reference:S,floating:M,setReference:I,setFloating:w}),[I,w]),F=v.useMemo(()=>({reference:x,floating:C}),[x,C]),B=v.useMemo(()=>{const k={position:n,left:0,top:0};if(!F.floating)return k;const _=Ys(F.floating,u.x),X=Ys(F.floating,u.y);return i?{...k,transform:"translate("+_+"px, "+X+"px)",...zs(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:_,top:X}},[n,i,F.floating,u.x,u.y]);return v.useMemo(()=>({...u,update:T,refs:G,elements:F,floatingStyles:B}),[u,T,G,F,B])}const Nh=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Xs({element:r.current,padding:o}).fn(n):{}:r?Xs({element:r,padding:o}).fn(n):{}}}},Th=(e,t)=>({...Ih(e),options:[e,t]}),Fh=(e,t)=>({...xh(e),options:[e,t]}),Gh=(e,t)=>({...Eh(e),options:[e,t]}),_h=(e,t)=>({...Sh(e),options:[e,t]}),Wh=(e,t)=>({...Ah(e),options:[e,t]}),Bh=(e,t)=>({...Mh(e),options:[e,t]}),Vh=(e,t)=>({...Nh(e),options:[e,t]});var Rh="Arrow",Zs=v.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...a}=e;return y.jsx(be.svg,{...a,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:y.jsx("polygon",{points:"0,0 30,0 15,10"})})});Zs.displayName=Rh;var Lh=Zs;function $s(e){const[t,n]=v.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let s,i;if("borderBoxSize"in a){const c=a.borderBoxSize,l=Array.isArray(c)?c[0]:c;s=l.inlineSize,i=l.blockSize}else s=e.offsetWidth,i=e.offsetHeight;n({width:s,height:i})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Ko="Popper",[Js,kr]=Ct(Ko),[Hh,js]=Js(Ko),Us=e=>{const{__scopePopper:t,children:n}=e,[r,o]=v.useState(null);return y.jsx(Hh,{scope:t,anchor:r,onAnchorChange:o,children:n})};Us.displayName=Ko;var Qs="PopperAnchor",qs=v.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=js(Qs,n),s=v.useRef(null),i=ye(t,s),c=v.useRef(null);return v.useEffect(()=>{const l=c.current;c.current=r?.current||s.current,l!==c.current&&a.onAnchorChange(c.current)}),r?null:y.jsx(be.div,{...o,ref:i})});qs.displayName=Qs;var ea="PopperContent",[Xh,zh]=Js(ea),Ks=v.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:s=0,arrowPadding:i=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:p=!1,updatePositionStrategy:h="optimized",onPlaced:g,...f}=e,m=js(ea,n),[b,I]=v.useState(null),w=ye(t,$=>I($)),[x,C]=v.useState(null),S=$s(x),M=S?.width??0,E=S?.height??0,O=r+(a!=="center"?"-"+a:""),P=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},W=Array.isArray(l)?l:[l],N=W.length>0,T={padding:P,boundary:W.filter(Zh),altBoundary:N},{refs:D,floatingStyles:G,placement:F,isPositioned:B,middlewareData:k}=Dh({strategy:"fixed",placement:O,whileElementsMounted:(...$)=>Hs(...$,{animationFrame:h==="always"}),elements:{reference:m.anchor},middleware:[Th({mainAxis:o+E,alignmentAxis:s}),c&&Fh({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?Gh():void 0,...T}),c&&_h({...T}),Wh({...T,apply:({elements:$,rects:we,availableWidth:Oe,availableHeight:Ne})=>{const{width:Xe,height:R}=we.reference,ze=$.floating.style;ze.setProperty("--radix-popper-available-width",`${Oe}px`),ze.setProperty("--radix-popper-available-height",`${Ne}px`),ze.setProperty("--radix-popper-anchor-width",`${Xe}px`),ze.setProperty("--radix-popper-anchor-height",`${R}px`)}}),x&&Vh({element:x,padding:i}),$h({arrowWidth:M,arrowHeight:E}),p&&Bh({strategy:"referenceHidden",...T})]}),[_,X]=nc(F),ie=$e(g);It(()=>{B&&ie?.()},[B,ie]);const oe=k.arrow?.x,q=k.arrow?.y,ee=k.arrow?.centerOffset!==0,[he,ge]=v.useState();return It(()=>{b&&ge(window.getComputedStyle(b).zIndex)},[b]),y.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:B?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:he,"--radix-popper-transform-origin":[k.transformOrigin?.x,k.transformOrigin?.y].join(" "),...k.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:y.jsx(Xh,{scope:n,placedSide:_,onArrowChange:C,arrowX:oe,arrowY:q,shouldHideArrow:ee,children:y.jsx(be.div,{"data-side":_,"data-align":X,...f,ref:w,style:{...f.style,animation:B?void 0:"none"}})})})});Ks.displayName=ea;var ec="PopperArrow",Yh={top:"bottom",right:"left",bottom:"top",left:"right"},tc=v.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=zh(ec,r),s=Yh[a.placedSide];return y.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:y.jsx(Lh,{...o,ref:n,style:{...o.style,display:"block"}})})});tc.displayName=ec;function Zh(e){return e!==null}var $h=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,s=o.arrow?.centerOffset!==0,i=s?0:e.arrowWidth,c=s?0:e.arrowHeight,[l,u]=nc(n),d={start:"0%",center:"50%",end:"100%"}[u],p=(o.arrow?.x??0)+i/2,h=(o.arrow?.y??0)+c/2;let g="",f="";return l==="bottom"?(g=s?d:`${p}px`,f=`${-c}px`):l==="top"?(g=s?d:`${p}px`,f=`${r.floating.height+c}px`):l==="right"?(g=`${-c}px`,f=s?d:`${h}px`):l==="left"&&(g=`${r.floating.width+c}px`,f=s?d:`${h}px`),{data:{x:g,y:f}}}});function nc(e){const[t,n="center"]=e.split("-");return[t,n]}var ta=Us,na=qs,rc=Ks,oc=tc,Jh="Portal",ra=v.forwardRef((e,t)=>{const{container:n,...r}=e,[o,a]=v.useState(!1);It(()=>a(!0),[]);const s=n||o&&globalThis?.document?.body;return s?bo.createPortal(y.jsx(be.div,{...r,ref:t}),s):null});ra.displayName=Jh;function jh(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var Tt=e=>{const{present:t,children:n}=e,r=Uh(t),o=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),a=ye(r.ref,Qh(o));return typeof n=="function"||r.isPresent?v.cloneElement(o,{ref:a}):null};Tt.displayName="Presence";function Uh(e){const[t,n]=v.useState(),r=v.useRef(null),o=v.useRef(e),a=v.useRef("none"),s=e?"mounted":"unmounted",[i,c]=jh(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const l=Pr(r.current);a.current=i==="mounted"?l:"none"},[i]),It(()=>{const l=r.current,u=o.current;if(u!==e){const p=a.current,h=Pr(l);e?c("MOUNT"):h==="none"||l?.display==="none"?c("UNMOUNT"):c(u&&p!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),It(()=>{if(t){let l;const u=t.ownerDocument.defaultView??window,d=h=>{const f=Pr(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&f&&(c("ANIMATION_END"),!o.current)){const m=t.style.animationFillMode;t.style.animationFillMode="forwards",l=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=m)})}},p=h=>{h.target===t&&(a.current=Pr(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(l),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:v.useCallback(l=>{r.current=l?getComputedStyle(l):null,n(l)},[])}}function Pr(e){return e?.animationName||"none"}function Qh(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var qh=v[" useInsertionEffect ".trim().toString()]||It;function kn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,s]=Kh({defaultProp:t,onChange:n}),i=e!==void 0,c=i?e:o;{const u=v.useRef(e!==void 0);v.useEffect(()=>{const d=u.current;d!==i&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=i},[i,r])}const l=v.useCallback(u=>{if(i){const d=eg(u)?u(e):u;d!==e&&s.current?.(d)}else a(u)},[i,e,a,s]);return[c,l]}function Kh({defaultProp:e,onChange:t}){const[n,r]=v.useState(e),o=v.useRef(n),a=v.useRef(t);return qh(()=>{a.current=t},[t]),v.useEffect(()=>{o.current!==n&&(a.current?.(n),o.current=n)},[n,o]),[n,r,a]}function eg(e){return typeof e=="function"}var oa="rovingFocusGroup.onEntryFocus",tg={bubbles:!1,cancelable:!0},Pn="RovingFocusGroup",[aa,ac,ng]=To(Pn),[rg,ic]=Ct(Pn,[ng]),[og,ag]=rg(Pn),sc=v.forwardRef((e,t)=>y.jsx(aa.Provider,{scope:e.__scopeRovingFocusGroup,children:y.jsx(aa.Slot,{scope:e.__scopeRovingFocusGroup,children:y.jsx(ig,{...e,ref:t})})}));sc.displayName=Pn;var ig=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:a,currentTabStopId:s,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,p=v.useRef(null),h=ye(t,p),g=Fo(a),[f,m]=kn({prop:s,defaultProp:i??null,onChange:c,caller:Pn}),[b,I]=v.useState(!1),w=$e(l),x=ac(n),C=v.useRef(!1),[S,M]=v.useState(0);return v.useEffect(()=>{const E=p.current;if(E)return E.addEventListener(oa,w),()=>E.removeEventListener(oa,w)},[w]),y.jsx(og,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:f,onItemFocus:v.useCallback(E=>m(E),[m]),onItemShiftTab:v.useCallback(()=>I(!0),[]),onFocusableItemAdd:v.useCallback(()=>M(E=>E+1),[]),onFocusableItemRemove:v.useCallback(()=>M(E=>E-1),[]),children:y.jsx(be.div,{tabIndex:b||S===0?-1:0,"data-orientation":r,...d,ref:h,style:{outline:"none",...e.style},onMouseDown:U(e.onMouseDown,()=>{C.current=!0}),onFocus:U(e.onFocus,E=>{const O=!C.current;if(E.target===E.currentTarget&&O&&!b){const P=new CustomEvent(oa,tg);if(E.currentTarget.dispatchEvent(P),!P.defaultPrevented){const W=x().filter(F=>F.focusable),N=W.find(F=>F.active),T=W.find(F=>F.id===f),G=[N,T,...W].filter(Boolean).map(F=>F.ref.current);uc(G,u)}}C.current=!1}),onBlur:U(e.onBlur,()=>I(!1))})})}),cc="RovingFocusGroupItem",lc=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:a,children:s,...i}=e,c=$t(),l=a||c,u=ag(cc,n),d=u.currentTabStopId===l,p=ac(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:f}=u;return v.useEffect(()=>{if(r)return h(),()=>g()},[r,h,g]),y.jsx(aa.ItemSlot,{scope:n,id:l,focusable:r,active:o,children:y.jsx(be.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...i,ref:t,onMouseDown:U(e.onMouseDown,m=>{r?u.onItemFocus(l):m.preventDefault()}),onFocus:U(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:U(e.onKeyDown,m=>{if(m.key==="Tab"&&m.shiftKey){u.onItemShiftTab();return}if(m.target!==m.currentTarget)return;const b=lg(m,u.orientation,u.dir);if(b!==void 0){if(m.metaKey||m.ctrlKey||m.altKey||m.shiftKey)return;m.preventDefault();let w=p().filter(x=>x.focusable).map(x=>x.ref.current);if(b==="last")w.reverse();else if(b==="prev"||b==="next"){b==="prev"&&w.reverse();const x=w.indexOf(m.currentTarget);w=u.loop?ug(w,x+1):w.slice(x+1)}setTimeout(()=>uc(w))}}),children:typeof s=="function"?s({isCurrentTabStop:d,hasTabStop:f!=null}):s})})});lc.displayName=cc;var sg={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cg(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function lg(e,t,n){const r=cg(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return sg[r]}function uc(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ug(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var dg=sc,fg=lc,pg=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},qt=new WeakMap,Or=new WeakMap,Dr={},ia=0,dc=function(e){return e&&(e.host||dc(e.parentNode))},mg=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=dc(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},hg=function(e,t,n,r){var o=mg(t,Array.isArray(e)?e:[e]);Dr[n]||(Dr[n]=new WeakMap);var a=Dr[n],s=[],i=new Set,c=new Set(o),l=function(d){!d||i.has(d)||(i.add(d),l(d.parentNode))};o.forEach(l);var u=function(d){!d||c.has(d)||Array.prototype.forEach.call(d.children,function(p){if(i.has(p))u(p);else try{var h=p.getAttribute(r),g=h!==null&&h!=="false",f=(qt.get(p)||0)+1,m=(a.get(p)||0)+1;qt.set(p,f),a.set(p,m),s.push(p),f===1&&g&&Or.set(p,!0),m===1&&p.setAttribute(n,"true"),g||p.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",p,b)}})};return u(t),i.clear(),ia++,function(){s.forEach(function(d){var p=qt.get(d)-1,h=a.get(d)-1;qt.set(d,p),a.set(d,h),p||(Or.has(d)||d.removeAttribute(r),Or.delete(d)),h||d.removeAttribute(n)}),ia--,ia||(qt=new WeakMap,qt=new WeakMap,Or=new WeakMap,Dr={})}},fc=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=pg(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),hg(r,o,n,"aria-hidden")):function(){return null}},nt=function(){return nt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},nt.apply(this,arguments)};function pc(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function gg(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Nr="right-scroll-bar-position",Tr="width-before-scroll-bar",bg="with-scroll-bars-hidden",vg="--removed-body-scroll-bar-size";function sa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function yg(e,t){var n=A.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Cg=typeof window<"u"?v.useLayoutEffect:v.useEffect,mc=new WeakMap;function wg(e,t){var n=yg(null,function(r){return e.forEach(function(o){return sa(o,r)})});return Cg(function(){var r=mc.get(n);if(r){var o=new Set(r),a=new Set(e),s=n.current;o.forEach(function(i){a.has(i)||sa(i,null)}),a.forEach(function(i){o.has(i)||sa(i,s)})}mc.set(n,e)},[e]),n}function Ig(e){return e}function xg(e,t){t===void 0&&(t=Ig);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var s=t(a,r);return n.push(s),function(){n=n.filter(function(i){return i!==s})}},assignSyncMedium:function(a){for(r=!0;n.length;){var s=n;n=[],s.forEach(a)}n={push:function(i){return a(i)},filter:function(){return n}}},assignMedium:function(a){r=!0;var s=[];if(n.length){var i=n;n=[],i.forEach(a),s=n}var c=function(){var u=s;s=[],u.forEach(a)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(u){s.push(u),l()},filter:function(u){return s=s.filter(u),n}}}};return o}function Sg(e){e===void 0&&(e={});var t=xg(null);return t.options=nt({async:!0,ssr:!1},e),t}var hc=function(e){var t=e.sideCar,n=pc(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return v.createElement(r,nt({},n))};hc.isSideCarExport=!0;function Ag(e,t){return e.useMedium(t),hc}var gc=Sg(),ca=function(){},Fr=v.forwardRef(function(e,t){var n=v.useRef(null),r=v.useState({onScrollCapture:ca,onWheelCapture:ca,onTouchMoveCapture:ca}),o=r[0],a=r[1],s=e.forwardProps,i=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,p=e.sideCar,h=e.noRelative,g=e.noIsolation,f=e.inert,m=e.allowPinchZoom,b=e.as,I=b===void 0?"div":b,w=e.gapMode,x=pc(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=p,S=wg([n,t]),M=nt(nt({},x),o);return v.createElement(v.Fragment,null,u&&v.createElement(C,{sideCar:gc,removeScrollBar:l,shards:d,noRelative:h,noIsolation:g,inert:f,setCallbacks:a,allowPinchZoom:!!m,lockRef:n,gapMode:w}),s?v.cloneElement(v.Children.only(i),nt(nt({},M),{ref:S})):v.createElement(I,nt({},M,{className:c,ref:S}),i))});Fr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Fr.classNames={fullWidth:Tr,zeroRight:Nr};var Mg=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Eg(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Mg();return t&&e.setAttribute("nonce",t),e}function kg(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Pg(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Og=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Eg())&&(kg(t,n),Pg(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Dg=function(){var e=Og();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},bc=function(){var e=Dg(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Ng={left:0,top:0,right:0,gap:0},la=function(e){return parseInt(e||"",10)||0},Tg=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[la(n),la(r),la(o)]},Fg=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ng;var t=Tg(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Gg=bc(),Kt="data-scroll-locked",_g=function(e,t,n,r){var o=e.left,a=e.top,s=e.right,i=e.gap;return n===void 0&&(n="margin"),`
|
|
4
4
|
.`.concat(bg,` {
|
|
5
5
|
overflow: hidden `).concat(r,`;
|