coupdoeil 1.0.0.pre.alpha.9 → 1.0.0.pre.alpha.10
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/coupdoeil.js +71 -47
- data/app/assets/javascripts/coupdoeil.min.js +1 -1
- data/app/assets/javascripts/coupdoeil.min.js.map +1 -1
- data/app/javascript/coupdoeil/elements/coupdoeil_element.js +15 -3
- data/app/javascript/coupdoeil/events/onclick.js +6 -6
- data/app/javascript/coupdoeil/events/onmouseover.js +8 -8
- data/app/javascript/coupdoeil/hovercard/closing.js +17 -2
- data/app/javascript/coupdoeil/hovercard/config.js +11 -11
- data/app/javascript/coupdoeil/hovercard/opening.js +11 -14
- data/app/javascript/coupdoeil/hovercard/optionsParser.js +22 -14
- data/app/models/coupdoeil/hovercard/option/opening_delay.rb +19 -0
- data/app/models/coupdoeil/hovercard/options_set.rb +1 -0
- data/app/models/coupdoeil/hovercard/view_context_delegation.rb +2 -1
- data/app/models/coupdoeil/hovercard.rb +3 -1
- data/lib/coupdoeil/version.rb +1 -1
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31a80413c45fa17fca365233b208858a7b96b997247b3372f5da4cf935591390
|
4
|
+
data.tar.gz: 94b982b21c026b42b28c35394b75332ba49d4fe04330f88ccf801a827c76bdd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6015ff94c49867a6683c7bbf7b240a24ce5e1a747f9bd8a428ae9b2d83b8146447e40504ec1c39eeca51237b0c52768b9ab4983eab920e1c604a11dc4b05ec3
|
7
|
+
data.tar.gz: 4b684ca29211664aa12e57c07f45d207a8914c6cc6dcf9776d07e0e1c22d2fb7031ad56961432fc3b9cc335ff1bd2e9536e581f63fffd9630e3d4a04f0153ac0
|
@@ -20,11 +20,11 @@ const HOVERCARD_SELECTOR = `.${HOVERCARD_CLASS_NAME}`;
|
|
20
20
|
|
21
21
|
const HOVERCARD_CLOSE_BTN_SELECTOR = "[data-hovercard-close]";
|
22
22
|
|
23
|
-
const
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
const CLOSING_DELAY_MS = 75;
|
24
|
+
|
25
|
+
const FETCH_DELAY_MS = 100;
|
26
|
+
|
27
|
+
const OPENING_DELAY_MS = 200;
|
28
28
|
|
29
29
|
const OPTIONS = {
|
30
30
|
animation: {
|
@@ -33,21 +33,24 @@ const OPTIONS = {
|
|
33
33
|
cache: {
|
34
34
|
getter: getCache
|
35
35
|
},
|
36
|
+
loading: {
|
37
|
+
getter: getLoading
|
38
|
+
},
|
36
39
|
offset: {
|
37
40
|
getter: getOffset
|
38
41
|
},
|
42
|
+
openingDelay: {
|
43
|
+
getter: getOpeningDelay
|
44
|
+
},
|
39
45
|
placement: {
|
40
46
|
getter: getPlacement
|
41
47
|
},
|
42
|
-
loading: {
|
43
|
-
getter: getLoading
|
44
|
-
},
|
45
48
|
trigger: {
|
46
49
|
getter: getTrigger$1
|
47
50
|
}
|
48
51
|
};
|
49
52
|
|
50
|
-
const ORDERED_OPTIONS = [ "trigger", "loading", "cache", "animation", "placement", "offset" ];
|
53
|
+
const ORDERED_OPTIONS = [ "trigger", "loading", "cache", "openingDelay", "animation", "placement", "offset" ];
|
51
54
|
|
52
55
|
const TRIGGERS = [ "hover", "click" ];
|
53
56
|
|
@@ -69,7 +72,7 @@ function parseCSSSize(value) {
|
|
69
72
|
}
|
70
73
|
|
71
74
|
function getOffset(optionsInt) {
|
72
|
-
const offsetBits = Number(BigInt(optionsInt) >> BigInt(
|
75
|
+
const offsetBits = Number(BigInt(optionsInt) >> BigInt(24));
|
73
76
|
if (offsetBits === 0) return 0;
|
74
77
|
const isNegative = (offsetBits & 1) === 1;
|
75
78
|
const isREM = (offsetBits & 2) === 2;
|
@@ -80,7 +83,7 @@ function getOffset(optionsInt) {
|
|
80
83
|
}
|
81
84
|
|
82
85
|
function getPlacement(optionsInt) {
|
83
|
-
const placementBits = optionsInt >>
|
86
|
+
const placementBits = optionsInt >> 8 & 65535;
|
84
87
|
let shift = 0;
|
85
88
|
let lastPlacement = null;
|
86
89
|
const placements = [];
|
@@ -93,7 +96,11 @@ function getPlacement(optionsInt) {
|
|
93
96
|
}
|
94
97
|
|
95
98
|
function getAnimation(optionsInt) {
|
96
|
-
return ANIMATIONS[
|
99
|
+
return ANIMATIONS[optionsInt >> 5 & 7];
|
100
|
+
}
|
101
|
+
|
102
|
+
function getOpeningDelay(optionsInt) {
|
103
|
+
return (optionsInt >> 4 & 1) === 1;
|
97
104
|
}
|
98
105
|
|
99
106
|
function getCache(optionsInt) {
|
@@ -111,9 +118,10 @@ function getTrigger$1(optionsInt) {
|
|
111
118
|
const HovercardOptions = {
|
112
119
|
animation: undefined,
|
113
120
|
cache: undefined,
|
121
|
+
loading: undefined,
|
114
122
|
offset: undefined,
|
123
|
+
openingDelay: undefined,
|
115
124
|
placement: undefined,
|
116
|
-
loading: undefined,
|
117
125
|
trigger: undefined
|
118
126
|
};
|
119
127
|
|
@@ -1963,7 +1971,7 @@ function closeLater(controller) {
|
|
1963
1971
|
cancelOpenCloseActions(controller);
|
1964
1972
|
controller.closingRequest = setTimeout((() => {
|
1965
1973
|
closeNow(controller);
|
1966
|
-
}),
|
1974
|
+
}), CLOSING_DELAY_MS);
|
1967
1975
|
}
|
1968
1976
|
|
1969
1977
|
function closeChildrenNow(controller) {
|
@@ -1994,19 +2002,24 @@ function clearAll() {
|
|
1994
2002
|
}
|
1995
2003
|
}
|
1996
2004
|
|
1997
|
-
function
|
2005
|
+
function closeTriggeredOnHoverLater() {
|
1998
2006
|
for (const coupdoeilElement of CURRENT_HOVERCARDS_BY_ID.values()) {
|
1999
2007
|
if (triggeredOnHover(coupdoeilElement.hovercardController)) {
|
2000
|
-
|
2008
|
+
closeLater(coupdoeilElement.hovercardController);
|
2001
2009
|
removeFromCurrents(coupdoeilElement);
|
2002
2010
|
}
|
2003
2011
|
}
|
2004
2012
|
}
|
2005
2013
|
|
2006
|
-
function
|
2014
|
+
function closeTriggeredOnHoverNowUnlessAncestor(controller) {
|
2015
|
+
let topMostParent = controller;
|
2016
|
+
while (topMostParent.parent) {
|
2017
|
+
topMostParent = topMostParent.parent;
|
2018
|
+
}
|
2019
|
+
const idToSkip = topMostParent.coupdoeilElement.uniqueId;
|
2007
2020
|
for (const coupdoeilElement of CURRENT_HOVERCARDS_BY_ID.values()) {
|
2008
|
-
if (triggeredOnHover(coupdoeilElement.hovercardController)) {
|
2009
|
-
|
2021
|
+
if (coupdoeilElement.uniqueId !== idToSkip && triggeredOnHover(coupdoeilElement.hovercardController)) {
|
2022
|
+
closeNow(coupdoeilElement.hovercardController);
|
2010
2023
|
removeFromCurrents(coupdoeilElement);
|
2011
2024
|
}
|
2012
2025
|
}
|
@@ -2054,7 +2067,7 @@ async function loadHovercardContentHTML(controller, options, delayOptions) {
|
|
2054
2067
|
}));
|
2055
2068
|
}
|
2056
2069
|
|
2057
|
-
async function openHovercard(controller, {parent: parent}) {
|
2070
|
+
async function openHovercard(controller, {parent: parent, beforeDisplay: beforeDisplay}) {
|
2058
2071
|
if (controller.isOpen) {
|
2059
2072
|
return cancelCloseRequest(controller);
|
2060
2073
|
}
|
@@ -2062,18 +2075,18 @@ async function openHovercard(controller, {parent: parent}) {
|
|
2062
2075
|
controller.parent = parent;
|
2063
2076
|
parent.children.add(controller);
|
2064
2077
|
}
|
2065
|
-
const delays = getDelayOptionsForController(controller);
|
2066
2078
|
const options = extractOptionsFromElement(controller.coupdoeilElement);
|
2079
|
+
const delays = getDelayOptionsForController(controller, options);
|
2067
2080
|
const openingDelay = new Promise((resolve => setTimeout(resolve, delays.opening)));
|
2068
2081
|
const fetchDelay = loadHovercardContentHTML(controller, options, delays);
|
2069
2082
|
await Promise.all([ fetchDelay, openingDelay ]);
|
2070
2083
|
const parentIsClosedOrClosing = controller.parent && (controller.parent.isClosed || controller.parent.closingRequest);
|
2071
2084
|
if (controller.coupdoeilElement.openingHovercard && !parentIsClosedOrClosing) {
|
2072
|
-
await display(controller, options);
|
2085
|
+
await display(controller, options, beforeDisplay);
|
2073
2086
|
}
|
2074
2087
|
}
|
2075
2088
|
|
2076
|
-
async function display(controller, options) {
|
2089
|
+
async function display(controller, options, beforeDisplay) {
|
2077
2090
|
if (controller.isOpen) return;
|
2078
2091
|
cancelCloseRequest(controller);
|
2079
2092
|
controller.card = buildHovercardElement(controller, options);
|
@@ -2086,6 +2099,9 @@ async function display(controller, options) {
|
|
2086
2099
|
controller.card.classList.add("hidden");
|
2087
2100
|
controller.card.style.removeProperty("visibility");
|
2088
2101
|
executeNextFrameIfStillOpening(controller, (async () => {
|
2102
|
+
if (beforeDisplay) {
|
2103
|
+
beforeDisplay(controller);
|
2104
|
+
}
|
2089
2105
|
addToCurrents(controller.coupdoeilElement);
|
2090
2106
|
delete controller.coupdoeilElement.openingHovercard;
|
2091
2107
|
controller.coupdoeilElement.dataset.hovercardOpen = true;
|
@@ -2104,20 +2120,16 @@ function executeNextFrameIfStillOpening(controller, callback) {
|
|
2104
2120
|
}));
|
2105
2121
|
}
|
2106
2122
|
|
2107
|
-
function getDelayOptionsForController(controller) {
|
2108
|
-
if (triggeredOnClick(controller)) {
|
2123
|
+
function getDelayOptionsForController(controller, options) {
|
2124
|
+
if (options.openingDelay === false || triggeredOnClick(controller)) {
|
2109
2125
|
return {
|
2110
2126
|
fetch: 0,
|
2111
2127
|
opening: 0
|
2112
2128
|
};
|
2113
2129
|
}
|
2114
|
-
let fetchDelay;
|
2115
|
-
{
|
2116
|
-
fetchDelay = defaultConfig.openingDelay / 2;
|
2117
|
-
}
|
2118
2130
|
return {
|
2119
|
-
fetch:
|
2120
|
-
opening:
|
2131
|
+
fetch: FETCH_DELAY_MS,
|
2132
|
+
opening: OPENING_DELAY_MS
|
2121
2133
|
};
|
2122
2134
|
}
|
2123
2135
|
|
@@ -2145,18 +2157,29 @@ class CoupdoeilElement extends HTMLElement {
|
|
2145
2157
|
this.uniqueId = generateUniqueId();
|
2146
2158
|
this.hovercardController = new HovercardController(this);
|
2147
2159
|
}
|
2148
|
-
openHovercard() {
|
2149
|
-
if (this.openingHovercard || this.hovercardController.isOpen) return;
|
2160
|
+
openHovercard(triggerElement = null, callbacks) {
|
2161
|
+
if (this.openingHovercard || this.hovercardController.isOpen || this.disabled || triggerElement === this) return;
|
2150
2162
|
this.openingHovercard = true;
|
2151
2163
|
const parent = this.closest(HOVERCARD_SELECTOR)?.controller;
|
2152
2164
|
addToCurrents(this);
|
2153
2165
|
return openHovercard(this.hovercardController, {
|
2154
|
-
parent: parent
|
2166
|
+
parent: parent,
|
2167
|
+
...callbacks
|
2155
2168
|
});
|
2156
2169
|
}
|
2157
2170
|
closeHovercard() {
|
2158
2171
|
closeNow(this.hovercardController);
|
2159
2172
|
}
|
2173
|
+
get disabled() {
|
2174
|
+
return !!this.getAttribute("disabled");
|
2175
|
+
}
|
2176
|
+
set disabled(disabled) {
|
2177
|
+
if (disabled) {
|
2178
|
+
this.setAttribute("disabled", true);
|
2179
|
+
} else {
|
2180
|
+
this.removeAttribute("disabled");
|
2181
|
+
}
|
2182
|
+
}
|
2160
2183
|
}
|
2161
2184
|
|
2162
2185
|
function isElementCloseHovercardButton(element) {
|
@@ -2171,9 +2194,9 @@ const coupdoeilOnClickEvent = ({target: clickedElement}) => {
|
|
2171
2194
|
const coupdoeilElement = clickedElement.closest("coup-doeil");
|
2172
2195
|
const hovercardElement = clickedElement.closest(HOVERCARD_SELECTOR);
|
2173
2196
|
if (coupdoeilElement && hovercardElement) {
|
2174
|
-
handleClickedCoupdoeilWithinHovercard(coupdoeilElement);
|
2197
|
+
handleClickedCoupdoeilWithinHovercard(coupdoeilElement, hovercardElement, clickedElement);
|
2175
2198
|
} else if (coupdoeilElement) {
|
2176
|
-
handleClickedCoupdoeilOutsideHovercard(coupdoeilElement);
|
2199
|
+
handleClickedCoupdoeilOutsideHovercard(coupdoeilElement, clickedElement);
|
2177
2200
|
} else if (hovercardElement) {
|
2178
2201
|
handleClickOutsideCoupdoeilButWithinHovercard(hovercardElement, clickedElement);
|
2179
2202
|
} else {
|
@@ -2181,24 +2204,24 @@ const coupdoeilOnClickEvent = ({target: clickedElement}) => {
|
|
2181
2204
|
}
|
2182
2205
|
};
|
2183
2206
|
|
2184
|
-
function handleClickedCoupdoeilWithinHovercard(coupdoeilElement, _hovercardElement) {
|
2207
|
+
function handleClickedCoupdoeilWithinHovercard(coupdoeilElement, _hovercardElement, clickedElement) {
|
2185
2208
|
const hovercard = coupdoeilElement.hovercardController;
|
2186
2209
|
if (noTriggeredOnClick(hovercard)) return;
|
2187
2210
|
if (hovercard.isOpen) {
|
2188
2211
|
closeNow(hovercard);
|
2189
2212
|
} else {
|
2190
|
-
coupdoeilElement.openHovercard();
|
2213
|
+
coupdoeilElement.openHovercard(clickedElement);
|
2191
2214
|
}
|
2192
2215
|
}
|
2193
2216
|
|
2194
|
-
function handleClickedCoupdoeilOutsideHovercard(coupdoeilElement) {
|
2217
|
+
function handleClickedCoupdoeilOutsideHovercard(coupdoeilElement, clickedElement) {
|
2195
2218
|
const hovercard = coupdoeilElement.hovercardController;
|
2196
2219
|
if (noTriggeredOnClick(hovercard)) return;
|
2197
2220
|
if (hovercard.isOpen) {
|
2198
2221
|
closeNow(hovercard);
|
2199
2222
|
} else {
|
2200
2223
|
closeAllNow();
|
2201
|
-
coupdoeilElement.openHovercard();
|
2224
|
+
coupdoeilElement.openHovercard(clickedElement);
|
2202
2225
|
}
|
2203
2226
|
}
|
2204
2227
|
|
@@ -2219,9 +2242,9 @@ const onMouseOver = ({target: hoveredElement}) => {
|
|
2219
2242
|
const coupdoeilElement = hoveredElement.closest("coup-doeil");
|
2220
2243
|
const hovercardElement = hoveredElement.closest(HOVERCARD_SELECTOR);
|
2221
2244
|
if (coupdoeilElement && hovercardElement) {
|
2222
|
-
handleMouseOverCoupdoeilWithinHovercard(coupdoeilElement, hovercardElement);
|
2245
|
+
handleMouseOverCoupdoeilWithinHovercard(coupdoeilElement, hovercardElement, hoveredElement);
|
2223
2246
|
} else if (coupdoeilElement) {
|
2224
|
-
handleMouseOverCoupdoeilOutsideHovercard(coupdoeilElement);
|
2247
|
+
handleMouseOverCoupdoeilOutsideHovercard(coupdoeilElement, hoveredElement);
|
2225
2248
|
} else if (hovercardElement) {
|
2226
2249
|
handleOverOutsideCoupdoeilButWithinHovercard(hovercardElement);
|
2227
2250
|
} else {
|
@@ -2229,7 +2252,7 @@ const onMouseOver = ({target: hoveredElement}) => {
|
|
2229
2252
|
}
|
2230
2253
|
};
|
2231
2254
|
|
2232
|
-
function handleMouseOverCoupdoeilWithinHovercard(coupdoeilElement, hovercardElement) {
|
2255
|
+
function handleMouseOverCoupdoeilWithinHovercard(coupdoeilElement, hovercardElement, hoveredElement) {
|
2233
2256
|
const childHovercard = coupdoeilElement.hovercardController;
|
2234
2257
|
const parentHovercard = hovercardElement.controller;
|
2235
2258
|
if (notTriggeredOnHover(childHovercard)) return;
|
@@ -2237,16 +2260,17 @@ function handleMouseOverCoupdoeilWithinHovercard(coupdoeilElement, hovercardElem
|
|
2237
2260
|
closeChildrenNow(childHovercard);
|
2238
2261
|
} else {
|
2239
2262
|
closeChildrenNow(parentHovercard);
|
2240
|
-
coupdoeilElement.openHovercard();
|
2263
|
+
coupdoeilElement.openHovercard(hoveredElement);
|
2241
2264
|
}
|
2242
2265
|
}
|
2243
2266
|
|
2244
|
-
function handleMouseOverCoupdoeilOutsideHovercard(coupdoeilElement) {
|
2267
|
+
function handleMouseOverCoupdoeilOutsideHovercard(coupdoeilElement, hoveredElement) {
|
2245
2268
|
const hovercard = coupdoeilElement.hovercardController;
|
2246
2269
|
if (notTriggeredOnHover(hovercard)) return;
|
2247
2270
|
if (hovercard.isClosed) {
|
2248
|
-
|
2249
|
-
|
2271
|
+
coupdoeilElement.openHovercard(hoveredElement, {
|
2272
|
+
beforeDisplay: closeTriggeredOnHoverNowUnlessAncestor
|
2273
|
+
});
|
2250
2274
|
} else if (hovercard.closingRequest) {
|
2251
2275
|
cancelCloseRequest(hovercard);
|
2252
2276
|
addToCurrents(coupdoeilElement);
|
@@ -1,2 +1,2 @@
|
|
1
|
-
class t{constructor(t){this.coupdoeilElement=t,this.card=null,this.children=new Set,this.parent=null,this.closingRequest=null}get isOpen(){return!!this.coupdoeilElement.dataset.hovercardOpen}get isClosed(){return!this.isOpen}}const e="coupdoeil--hovercard",n=`.${e}`,o=150,r=200,i={animation:{getter:function(t){return a[(56&t)>>4]}},cache:{getter:function(t){return!(8&~t)}},offset:{getter:function(t){const e=Number(BigInt(t)>>BigInt(23));if(0===e)return 0;return function(t){if("number"==typeof t)return t;if(/^(-?\d+\.?\d+)px$/.test(t))return parseFloat(t);if(/^(-?\d*\.?\d+)rem$/.test(t))return parseFloat(t)*parseFloat(getComputedStyle(document.documentElement).fontSize);return 0}(`${1&~e?"":"-"}${e>>13}.${e>>2&2047}${2&~e?"px":"rem"}`)}},placement:{getter:function(t){const e=t>>7&65535;let n=0,o=null;const r=[];for(;"auto"!==o&&n<16;)o=s[e>>n&15],r.push(o),n+=4;return r}},loading:{getter:function(t){return u[t>>1&3]}},trigger:{getter:function(t){return l[1&t]}}},c=["trigger","loading","cache","animation","placement","offset"],l=["hover","click"],a=[!1,"slide-in","fade-in","slide-out","custom"],s=["auto","top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"],u=["async","preload","lazy"];const f={animation:void 0,cache:void 0,offset:void 0,placement:void 0,loading:void 0,trigger:void 0};function d(t){const e=t.getAttribute("hc");return parseInt(e,36)}function p(t){return t.coupdoeilElement.getAttribute("hc-type")}function m(t){return t.coupdoeilElement.getAttribute("hc-params")}function h(t){return function(t,e){const n=t.hovercardController.optionsInt||=d(t);return i[e].getter(n)}(t.coupdoeilElement,"trigger")}function g(t){return"click"!==h(t)}function y(t){return"hover"===h(t)}function v(t){return"hover"!==h(t)}function w(t){return t.coupdoeilElement.querySelector(".hovercard-content")}const x=new Map;function b(t){return w(t)?t.coupdoeilElement.uniqueId:p(t)+m(t)}function E(t){return x.get(b(t))}function C(){x.clear()}const L=["top","right","bottom","left"],T=["start","end"],R=L.reduce(((t,e)=>t.concat(e,e+"-"+T[0],e+"-"+T[1])),[]),O=Math.min,H=Math.max,P=Math.round,A=t=>({x:t,y:t}),S={left:"right",right:"left",bottom:"top",top:"bottom"},$={start:"end",end:"start"};function D(t,e,n){return H(t,O(e,n))}function q(t,e){return"function"==typeof t?t(e):t}function k(t){return t.split("-")[0]}function F(t){return t.split("-")[1]}function W(t){return"x"===t?"y":"x"}function M(t){return"y"===t?"height":"width"}function B(t){return["top","bottom"].includes(k(t))?"y":"x"}function V(t){return W(B(t))}function I(t,e,n){void 0===n&&(n=!1);const o=F(t),r=V(t),i=M(r);let c="x"===r?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[i]>e.floating[i]&&(c=j(c)),[c,j(c)]}function N(t){return t.replace(/start|end/g,(t=>$[t]))}function j(t){return t.replace(/left|right|bottom|top/g,(t=>S[t]))}function z(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function _(t){const{x:e,y:n,width:o,height:r}=t;return{width:o,height:r,top:n,left:e,right:e+o,bottom:n+r,x:e,y:n}}function U(t,e,n){let{reference:o,floating:r}=t;const i=B(e),c=V(e),l=M(c),a=k(e),s="y"===i,u=o.x+o.width/2-r.width/2,f=o.y+o.height/2-r.height/2,d=o[l]/2-r[l]/2;let p;switch(a){case"top":p={x:u,y:o.y-r.height};break;case"bottom":p={x:u,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:f};break;case"left":p={x:o.x-r.width,y:f};break;default:p={x:o.x,y:o.y}}switch(F(e)){case"start":p[c]-=d*(n&&s?-1:1);break;case"end":p[c]+=d*(n&&s?-1:1)}return p}async function X(t,e){var n;void 0===e&&(e={});const{x:o,y:r,platform:i,rects:c,elements:l,strategy:a}=t,{boundary:s="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:d=!1,padding:p=0}=q(e,t),m=z(p),h=l[d?"floating"===f?"reference":"floating":f],g=_(await i.getClippingRect({element:null==(n=await(null==i.isElement?void 0:i.isElement(h)))||n?h:h.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(l.floating)),boundary:s,rootBoundary:u,strategy:a})),y="floating"===f?{x:o,y:r,width:c.floating.width,height:c.floating.height}:c.reference,v=await(null==i.getOffsetParent?void 0:i.getOffsetParent(l.floating)),w=await(null==i.isElement?void 0:i.isElement(v))&&await(null==i.getScale?void 0:i.getScale(v))||{x:1,y:1},x=_(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:v,strategy:a}):y);return{top:(g.top-x.top+m.top)/w.y,bottom:(x.bottom-g.bottom+m.bottom)/w.y,left:(g.left-x.left+m.left)/w.x,right:(x.right-g.right+m.right)/w.x}}function Y(){return"undefined"!=typeof window}function J(t){return Q(t)?(t.nodeName||"").toLowerCase():"#document"}function G(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function K(t){var e;return null==(e=(Q(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function Q(t){return!!Y()&&(t instanceof Node||t instanceof G(t).Node)}function Z(t){return!!Y()&&(t instanceof Element||t instanceof G(t).Element)}function tt(t){return!!Y()&&(t instanceof HTMLElement||t instanceof G(t).HTMLElement)}function et(t){return!(!Y()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof G(t).ShadowRoot)}function nt(t){const{overflow:e,overflowX:n,overflowY:o,display:r}=at(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(r)}function ot(t){return["table","td","th"].includes(J(t))}function rt(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function it(t){const e=ct(),n=Z(t)?at(t):t;return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function ct(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function lt(t){return["html","body","#document"].includes(J(t))}function at(t){return G(t).getComputedStyle(t)}function st(t){return Z(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ut(t){if("html"===J(t))return t;const e=t.assignedSlot||t.parentNode||et(t)&&t.host||K(t);return et(e)?e.host:e}function ft(t){const e=ut(t);return lt(e)?t.ownerDocument?t.ownerDocument.body:t.body:tt(e)&&nt(e)?e:ft(e)}function dt(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const r=ft(t),i=r===(null==(o=t.ownerDocument)?void 0:o.body),c=G(r);if(i){const t=pt(c);return e.concat(c,c.visualViewport||[],nt(r)?r:[],t&&n?dt(t):[])}return e.concat(r,dt(r,[],n))}function pt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function mt(t){const e=at(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=tt(t),i=r?t.offsetWidth:n,c=r?t.offsetHeight:o,l=P(n)!==i||P(o)!==c;return l&&(n=i,o=c),{width:n,height:o,$:l}}function ht(t){return Z(t)?t:t.contextElement}function gt(t){const e=ht(t);if(!tt(e))return A(1);const n=e.getBoundingClientRect(),{width:o,height:r,$:i}=mt(e);let c=(i?P(n.width):n.width)/o,l=(i?P(n.height):n.height)/r;return c&&Number.isFinite(c)||(c=1),l&&Number.isFinite(l)||(l=1),{x:c,y:l}}const yt=A(0);function vt(t){const e=G(t);return ct()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:yt}function wt(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const r=t.getBoundingClientRect(),i=ht(t);let c=A(1);e&&(o?Z(o)&&(c=gt(o)):c=gt(t));const l=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==G(t))&&e}(i,n,o)?vt(i):A(0);let a=(r.left+l.x)/c.x,s=(r.top+l.y)/c.y,u=r.width/c.x,f=r.height/c.y;if(i){const t=G(i),e=o&&Z(o)?G(o):o;let n=t,r=pt(n);for(;r&&o&&e!==n;){const t=gt(r),e=r.getBoundingClientRect(),o=at(r),i=e.left+(r.clientLeft+parseFloat(o.paddingLeft))*t.x,c=e.top+(r.clientTop+parseFloat(o.paddingTop))*t.y;a*=t.x,s*=t.y,u*=t.x,f*=t.y,a+=i,s+=c,n=G(r),r=pt(n)}}return _({width:u,height:f,x:a,y:s})}function xt(t,e){const n=st(t).scrollLeft;return e?e.left+n:wt(K(t)).left+n}function bt(t,e,n){void 0===n&&(n=!1);const o=t.getBoundingClientRect();return{x:o.left+e.scrollLeft-(n?0:xt(t,o)),y:o.top+e.scrollTop}}function Et(t,e,n){let o;if("viewport"===e)o=function(t,e){const n=G(t),o=K(t),r=n.visualViewport;let i=o.clientWidth,c=o.clientHeight,l=0,a=0;if(r){i=r.width,c=r.height;const t=ct();(!t||t&&"fixed"===e)&&(l=r.offsetLeft,a=r.offsetTop)}return{width:i,height:c,x:l,y:a}}(t,n);else if("document"===e)o=function(t){const e=K(t),n=st(t),o=t.ownerDocument.body,r=H(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),i=H(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let c=-n.scrollLeft+xt(t);const l=-n.scrollTop;return"rtl"===at(o).direction&&(c+=H(e.clientWidth,o.clientWidth)-r),{width:r,height:i,x:c,y:l}}(K(t));else if(Z(e))o=function(t,e){const n=wt(t,!0,"fixed"===e),o=n.top+t.clientTop,r=n.left+t.clientLeft,i=tt(t)?gt(t):A(1);return{width:t.clientWidth*i.x,height:t.clientHeight*i.y,x:r*i.x,y:o*i.y}}(e,n);else{const n=vt(t);o={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return _(o)}function Ct(t,e){const n=ut(t);return!(n===e||!Z(n)||lt(n))&&("fixed"===at(n).position||Ct(n,e))}function Lt(t,e,n){const o=tt(e),r=K(e),i="fixed"===n,c=wt(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const a=A(0);if(o||!o&&!i)if(("body"!==J(e)||nt(r))&&(l=st(e)),o){const t=wt(e,!0,i,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else r&&(a.x=xt(r));const s=!r||o||i?A(0):bt(r,l);return{x:c.left+l.scrollLeft-a.x-s.x,y:c.top+l.scrollTop-a.y-s.y,width:c.width,height:c.height}}function Tt(t){return"static"===at(t).position}function Rt(t,e){if(!tt(t)||"fixed"===at(t).position)return null;if(e)return e(t);let n=t.offsetParent;return K(t)===n&&(n=n.ownerDocument.body),n}function Ot(t,e){const n=G(t);if(rt(t))return n;if(!tt(t)){let e=ut(t);for(;e&&!lt(e);){if(Z(e)&&!Tt(e))return e;e=ut(e)}return n}let o=Rt(t,e);for(;o&&ot(o)&&Tt(o);)o=Rt(o,e);return o&<(o)&&Tt(o)&&!it(o)?n:o||function(t){let e=ut(t);for(;tt(e)&&!lt(e);){if(it(e))return e;if(rt(e))return null;e=ut(e)}return null}(t)||n}const Ht={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:r}=t;const i="fixed"===r,c=K(o),l=!!e&&rt(e.floating);if(o===c||l&&i)return n;let a={scrollLeft:0,scrollTop:0},s=A(1);const u=A(0),f=tt(o);if((f||!f&&!i)&&(("body"!==J(o)||nt(c))&&(a=st(o)),tt(o))){const t=wt(o);s=gt(o),u.x=t.x+o.clientLeft,u.y=t.y+o.clientTop}const d=!c||f||i?A(0):bt(c,a,!0);return{width:n.width*s.x,height:n.height*s.y,x:n.x*s.x-a.scrollLeft*s.x+u.x+d.x,y:n.y*s.y-a.scrollTop*s.y+u.y+d.y}},getDocumentElement:K,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:o,strategy:r}=t;const i=[..."clippingAncestors"===n?rt(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=dt(t,[],!1).filter((t=>Z(t)&&"body"!==J(t))),r=null;const i="fixed"===at(t).position;let c=i?ut(t):t;for(;Z(c)&&!lt(c);){const e=at(c),n=it(c);n||"fixed"!==e.position||(r=null),(i?!n&&!r:!n&&"static"===e.position&&r&&["absolute","fixed"].includes(r.position)||nt(c)&&!n&&Ct(t,c))?o=o.filter((t=>t!==c)):r=e,c=ut(c)}return e.set(t,o),o}(e,this._c):[].concat(n),o],c=i[0],l=i.reduce(((t,n)=>{const o=Et(e,n,r);return t.top=H(o.top,t.top),t.right=O(o.right,t.right),t.bottom=O(o.bottom,t.bottom),t.left=H(o.left,t.left),t}),Et(e,c,r));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}},getOffsetParent:Ot,getElementRects:async function(t){const e=this.getOffsetParent||Ot,n=this.getDimensions,o=await n(t.floating);return{reference:Lt(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=mt(t);return{width:e,height:n}},getScale:gt,isElement:Z,isRTL:function(t){return"rtl"===at(t).direction}},Pt=X,At=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:r,y:i,placement:c,middlewareData:l}=e,a=await async function(t,e){const{placement:n,platform:o,elements:r}=t,i=await(null==o.isRTL?void 0:o.isRTL(r.floating)),c=k(n),l=F(n),a="y"===B(n),s=["left","top"].includes(c)?-1:1,u=i&&a?-1:1,f=q(e,t);let{mainAxis:d,crossAxis:p,alignmentAxis:m}="number"==typeof f?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&"number"==typeof m&&(p="end"===l?-1*m:m),a?{x:p*u,y:d*s}:{x:d*s,y:p*u}}(e,t);return c===(null==(n=l.offset)?void 0:n.placement)&&null!=(o=l.arrow)&&o.alignmentOffset?{}:{x:r+a.x,y:i+a.y,data:{...a,placement:c}}}}},St=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,o,r;const{rects:i,middlewareData:c,placement:l,platform:a,elements:s}=e,{crossAxis:u=!1,alignment:f,allowedPlacements:d=R,autoAlignment:p=!0,...m}=q(t,e),h=void 0!==f||d===R?function(t,e,n){return(t?[...n.filter((e=>F(e)===t)),...n.filter((e=>F(e)!==t))]:n.filter((t=>k(t)===t))).filter((n=>!t||F(n)===t||!!e&&N(n)!==n))}(f||null,p,d):d,g=await X(e,m),y=(null==(n=c.autoPlacement)?void 0:n.index)||0,v=h[y];if(null==v)return{};const w=I(v,i,await(null==a.isRTL?void 0:a.isRTL(s.floating)));if(l!==v)return{reset:{placement:h[0]}};const x=[g[k(v)],g[w[0]],g[w[1]]],b=[...(null==(o=c.autoPlacement)?void 0:o.overflows)||[],{placement:v,overflows:x}],E=h[y+1];if(E)return{data:{index:y+1,overflows:b},reset:{placement:E}};const C=b.map((t=>{const e=F(t.placement);return[t.placement,e&&u?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),L=(null==(r=C.filter((t=>t[2].slice(0,F(t[0])?2:3).every((t=>t<=0))))[0])?void 0:r[0])||C[0][0];return L!==l?{data:{index:y+1,overflows:b},reset:{placement:L}}:{}}}},$t=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:o,placement:r,rects:i,platform:c,elements:l,middlewareData:a}=e,{element:s,padding:u=0}=q(t,e)||{};if(null==s)return{};const f=z(u),d={x:n,y:o},p=V(r),m=M(p),h=await c.getDimensions(s),g="y"===p,y=g?"top":"left",v=g?"bottom":"right",w=g?"clientHeight":"clientWidth",x=i.reference[m]+i.reference[p]-d[p]-i.floating[m],b=d[p]-i.reference[p],E=await(null==c.getOffsetParent?void 0:c.getOffsetParent(s));let C=E?E[w]:0;C&&await(null==c.isElement?void 0:c.isElement(E))||(C=l.floating[w]||i.floating[m]);const L=x/2-b/2,T=C/2-h[m]/2-1,R=O(f[y],T),H=O(f[v],T),P=R,A=C-h[m]-H,S=C/2-h[m]/2+L,$=D(P,S,A),k=!a.arrow&&null!=F(r)&&S!==$&&i.reference[m]/2-(S<P?R:H)-h[m]/2<0,W=k?S<P?S-P:S-A:0;return{[p]:d[p]+W,data:{[p]:$,centerOffset:S-$-W,...k&&{alignmentOffset:W}},reset:k}}}),Dt=(t,e,n)=>{const o=new Map,r={platform:Ht,...n},i={...r.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:c}=n,l=i.filter(Boolean),a=await(null==c.isRTL?void 0:c.isRTL(e));let s=await c.getElementRects({reference:t,floating:e,strategy:r}),{x:u,y:f}=U(s,o,a),d=o,p={},m=0;for(let n=0;n<l.length;n++){const{name:i,fn:h}=l[n],{x:g,y:y,data:v,reset:w}=await h({x:u,y:f,initialPlacement:o,placement:d,strategy:r,middlewareData:p,rects:s,platform:c,elements:{reference:t,floating:e}});u=null!=g?g:u,f=null!=y?y:f,p={...p,[i]:{...p[i],...v}},w&&m<=50&&(m++,"object"==typeof w&&(w.placement&&(d=w.placement),w.rects&&(s=!0===w.rects?await c.getElementRects({reference:t,floating:e,strategy:r}):w.rects),({x:u,y:f}=U(s,d,a))),n=-1)}return{x:u,y:f,placement:d,strategy:r,middlewareData:p}})(t,e,{...r,platform:i})};async function qt(t,e,n){let{placement:o,offset:r}=n;const i=o[0],c=e.querySelector("[data-hovercard-arrow]"),l=[kt(o)];if(c){r+=c.clientWidth,l.push($t({element:c}))}l.push(At(r));const a=await Dt(t,e,{placement:i,middleware:l}),{x:s,y:u,placement:f}=a;c&&function(t,e){const n=t.clientWidth,{placement:o,middlewareData:{arrow:r}}=e,i=o.split("-")[0],c=Ft[i],{x:l,y:a}=r,{borderWidth:s}=getComputedStyle(t.parentElement);Object.assign(t.style,{left:null!=l?`${l}px`:"",top:null!=a?`${a}px`:"",[c]:`calc(${-n}px + ${s})`})}(c,a),e.dataset.placement=f,Object.assign(e.style,{left:`${s}px`,top:`${u}px`})}const kt=t=>{let e=0;return{name:"autoPlacement",async fn(n){if("auto"===n.placement)return St().fn(n);const{top:o,bottom:r,left:i,right:c}=await Pt(n),l=o>0||r>0||i>0||c>0;return"auto"!==t[e]&&l?(e++,{reset:{placement:t[e]||"auto"}}):l?St().fn(n):{}}}},Ft={right:"left",left:"right",top:"bottom",bottom:"top"};async function Wt(t,e,n){const o=e.dataset,r=n?`${n}-${t}`:t;let i=`transition${t.charAt(0).toUpperCase()+t.slice(1)}`;const c=o[i]?o[i].split(" "):[r],l=o[`${i}Start`]?o[`${i}Start`].split(" "):[`${r}-start`],a=o[`${i}End`]?o[`${i}End`].split(" "):[`${r}-end`];Mt(e,c),Mt(e,l),await new Promise((t=>{requestAnimationFrame((()=>{requestAnimationFrame(t)}))})),Bt(e,l),Mt(e,a),await function(t){return new Promise((e=>{const n=getComputedStyle(t).transitionDuration.split(",")[0],o=1e3*Number(n.replace("s",""));setTimeout((()=>{e()}),o)}))}(e),Bt(e,a),Bt(e,c)}function Mt(t,e){t.classList.add(...e)}function Bt(t,e){t.classList.remove(...e)}const Vt=new Map;function It(t){Vt.set(t.uniqueId,t)}function Nt(t){Vt.delete(t.uniqueId)}function jt(t){!function(t){delete t.coupdoeilElement.openingHovercard}(t),zt(t)}function zt(t){clearTimeout(t.closingRequest),t.closingRequest=null,It(t.coupdoeilElement)}function _t(t,e=!0){t.closing||t.isClosed&&!t.coupdoeilElement.openingHovercard||(t.closing=!0,jt(t),t.children.forEach((t=>{_t(t)})),function(t){t.parent&&(t.parent.children.delete(t),t.parent=null)}(t),e&&t.card&&t.card.dataset.animation?async function(t){await async function(t,e=null){await Wt("leave",t,e),t.classList.add("hidden")}(t.card,"hovercard"),Ut(t)}(t):Ut(t))}function Ut(t){t.card&&(t.card.remove(),t.card=null),delete t.closing,delete t.coupdoeilElement.dataset.hovercardOpen}function Xt(t){jt(t),t.closingRequest=setTimeout((()=>{_t(t)}),o)}function Yt(t){t.children.forEach((t=>{_t(t)}))}function Jt(){for(const t of Vt.values())_t(t.hovercardController),Nt(t)}function Gt(){for(const t of Vt.values())clearHovercard(t.hovercardController),Nt(t)}async function Kt(t,e,n){return new Promise((o=>{setTimeout((async()=>{if(t.coupdoeilElement.openingHovercard){if(!1===e.cache||e.cache&&!E(t)){let n;n="preload"===e.loading?w(t).innerHTML:await function(t){const e=p(t),n=m(t),o=document.querySelector("meta[name=csrf-token]").content,r={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({params:n,action_name:e,authenticity_token:o})};return fetch("/coupdoeil/hovercard",r).then((t=>{if(t.status>=400)throw"error while fetching hovercard content";return t.text()}))}(t),function(t,e){x.set(b(t),e)}(t,n)}o()}}),n.fetch)}))}async function Qt(t,{parent:n}){if(t.isOpen)return zt(t);n&&(t.parent=n,n.children.add(t));const o=function(t){if(function(t){return"click"===h(t)}(t))return{fetch:0,opening:0};let e;return e=r/2,{fetch:e,opening:r}}(t),l=function(t){const e=t.hovercardController.optionsInt||=d(t),n=Object.create(f);for(const t of c)n[t]=i[t].getter(e);return n}(t.coupdoeilElement),a=new Promise((t=>setTimeout(t,o.opening))),s=Kt(t,l,o);await Promise.all([s,a]);const u=t.parent&&(t.parent.isClosed||t.parent.closingRequest);t.coupdoeilElement.openingHovercard&&!u&&await async function(t,n){if(t.isOpen)return;zt(t),t.card=function(t,n){const o=document.createElement("div");return o.setAttribute("role","dialog"),o.classList.add(e),o.style.cssText="position: absolute; left: 0; top: 0;",o.innerHTML=E(t),o.controller=t,o.dataset.placement=n.placement,o.style.visibility="hidden",o}(t,n),document.body.appendChild(t.card),n.animation&&(t.card.dataset.animation=n.animation);Zt(t,(async()=>{await qt(t.coupdoeilElement,t.card,n),t.card.classList.add("hidden"),t.card.style.removeProperty("visibility"),Zt(t,(async()=>{It(t.coupdoeilElement),delete t.coupdoeilElement.openingHovercard,t.coupdoeilElement.dataset.hovercardOpen=!0,await async function(t,e=null){t.classList.remove("hidden"),await Wt("enter",t,e)}(t.card,"hovercard")}))}))}(t,l)}function Zt(t,e){requestAnimationFrame((()=>{t.coupdoeilElement.openingHovercard?e.call():function(t){_t(t,!1)}(t)}))}class te extends HTMLElement{constructor(){super(),this.uniqueId=function(){const t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}(),this.hovercardController=new t(this)}openHovercard(){if(this.openingHovercard||this.hovercardController.isOpen)return;this.openingHovercard=!0;const t=this.closest(n)?.controller;return It(this),Qt(this.hovercardController,{parent:t})}closeHovercard(){_t(this.hovercardController)}}function ee(){return Vt.size>0}const ne=({target:t})=>{const e=t.closest("coup-doeil"),o=t.closest(n);e&&o?function(t){const e=t.hovercardController;if(g(e))return;e.isOpen?_t(e):t.openHovercard()}(e):e?function(t){const e=t.hovercardController;if(g(e))return;e.isOpen?_t(e):(Jt(),t.openHovercard())}(e):o?function(t,e){const n=t.controller;o=e,o.closest("[data-hovercard-close]")||o.dataset.hasOwnProperty("hovercardClose")?_t(n):n.children.size>0&&Yt(n);var o}(o,t):Jt()};const oe=({target:t})=>{const e=t.closest("coup-doeil"),o=t.closest(n);e&&o?function(t,e){const n=t.hovercardController,o=e.controller;if(v(n))return;n.isOpen?Yt(n):(Yt(o),t.openHovercard())}(e,o):e?function(t){const e=t.hovercardController;if(v(e))return;e.isClosed?(!function(){for(const t of Vt.values())y(t.hovercardController)&&(_t(t.hovercardController),Nt(t))}(),t.openHovercard()):e.closingRequest&&(zt(e),It(t))}(e):o?function(t){const e=t.controller;e.closingRequest?(zt(e),It(e.coupdoeilElement)):e.children.size>0&&e.children.forEach((t=>{y(t)&&Xt(t)}))}(o):ee()&&function(){for(const t of Vt.values())y(t.hovercardController)&&(Xt(t.hovercardController),Nt(t))}()};document.addEventListener("DOMContentLoaded",(()=>{C(),document.addEventListener("click",ne),document.documentElement.addEventListener("mouseover",oe,{passive:!0}),window.Turbo&&(document.addEventListener("turbo:before-cache",(t=>{Gt()})),document.addEventListener("turbo:load",(t=>{Gt(),C()})))})),void 0===customElements.get("coup-doeil")&&customElements.define("coup-doeil",te);
|
1
|
+
class t{constructor(t){this.coupdoeilElement=t,this.card=null,this.children=new Set,this.parent=null,this.closingRequest=null}get isOpen(){return!!this.coupdoeilElement.dataset.hovercardOpen}get isClosed(){return!this.isOpen}}const e="coupdoeil--hovercard",n=`.${e}`,o={animation:{getter:function(t){return c[t>>5&7]}},cache:{getter:function(t){return!(8&~t)}},loading:{getter:function(t){return a[t>>1&3]}},offset:{getter:function(t){const e=Number(BigInt(t)>>BigInt(24));if(0===e)return 0;return function(t){if("number"==typeof t)return t;if(/^(-?\d+\.?\d+)px$/.test(t))return parseFloat(t);if(/^(-?\d*\.?\d+)rem$/.test(t))return parseFloat(t)*parseFloat(getComputedStyle(document.documentElement).fontSize);return 0}(`${1&~e?"":"-"}${e>>13}.${e>>2&2047}${2&~e?"px":"rem"}`)}},openingDelay:{getter:function(t){return 1==(t>>4&1)}},placement:{getter:function(t){const e=t>>8&65535;let n=0,o=null;const r=[];for(;"auto"!==o&&n<16;)o=l[e>>n&15],r.push(o),n+=4;return r}},trigger:{getter:function(t){return i[1&t]}}},r=["trigger","loading","cache","openingDelay","animation","placement","offset"],i=["hover","click"],c=[!1,"slide-in","fade-in","slide-out","custom"],l=["auto","top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"],a=["async","preload","lazy"];const s={animation:void 0,cache:void 0,loading:void 0,offset:void 0,openingDelay:void 0,placement:void 0,trigger:void 0};function u(t){const e=t.getAttribute("hc");return parseInt(e,36)}function f(t){return t.coupdoeilElement.getAttribute("hc-type")}function d(t){return t.coupdoeilElement.getAttribute("hc-params")}function p(t){return function(t,e){const n=t.hovercardController.optionsInt||=u(t);return o[e].getter(n)}(t.coupdoeilElement,"trigger")}function m(t){return"click"!==p(t)}function h(t){return"hover"===p(t)}function g(t){return"hover"!==p(t)}function y(t){return t.coupdoeilElement.querySelector(".hovercard-content")}const v=new Map;function w(t){return y(t)?t.coupdoeilElement.uniqueId:f(t)+d(t)}function x(t){return v.get(w(t))}function b(){v.clear()}const E=["top","right","bottom","left"],C=["start","end"],L=E.reduce(((t,e)=>t.concat(e,e+"-"+C[0],e+"-"+C[1])),[]),T=Math.min,R=Math.max,O=Math.round,A=t=>({x:t,y:t}),H={left:"right",right:"left",bottom:"top",top:"bottom"},D={start:"end",end:"start"};function P(t,e,n){return R(t,T(e,n))}function S(t,e){return"function"==typeof t?t(e):t}function $(t){return t.split("-")[0]}function q(t){return t.split("-")[1]}function k(t){return"x"===t?"y":"x"}function F(t){return"y"===t?"height":"width"}function W(t){return["top","bottom"].includes($(t))?"y":"x"}function M(t){return k(W(t))}function B(t,e,n){void 0===n&&(n=!1);const o=q(t),r=M(t),i=F(r);let c="x"===r?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[i]>e.floating[i]&&(c=V(c)),[c,V(c)]}function I(t){return t.replace(/start|end/g,(t=>D[t]))}function V(t){return t.replace(/left|right|bottom|top/g,(t=>H[t]))}function N(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function j(t){const{x:e,y:n,width:o,height:r}=t;return{width:o,height:r,top:n,left:e,right:e+o,bottom:n+r,x:e,y:n}}function z(t,e,n){let{reference:o,floating:r}=t;const i=W(e),c=M(e),l=F(c),a=$(e),s="y"===i,u=o.x+o.width/2-r.width/2,f=o.y+o.height/2-r.height/2,d=o[l]/2-r[l]/2;let p;switch(a){case"top":p={x:u,y:o.y-r.height};break;case"bottom":p={x:u,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:f};break;case"left":p={x:o.x-r.width,y:f};break;default:p={x:o.x,y:o.y}}switch(q(e)){case"start":p[c]-=d*(n&&s?-1:1);break;case"end":p[c]+=d*(n&&s?-1:1)}return p}async function _(t,e){var n;void 0===e&&(e={});const{x:o,y:r,platform:i,rects:c,elements:l,strategy:a}=t,{boundary:s="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:d=!1,padding:p=0}=S(e,t),m=N(p),h=l[d?"floating"===f?"reference":"floating":f],g=j(await i.getClippingRect({element:null==(n=await(null==i.isElement?void 0:i.isElement(h)))||n?h:h.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(l.floating)),boundary:s,rootBoundary:u,strategy:a})),y="floating"===f?{x:o,y:r,width:c.floating.width,height:c.floating.height}:c.reference,v=await(null==i.getOffsetParent?void 0:i.getOffsetParent(l.floating)),w=await(null==i.isElement?void 0:i.isElement(v))&&await(null==i.getScale?void 0:i.getScale(v))||{x:1,y:1},x=j(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:v,strategy:a}):y);return{top:(g.top-x.top+m.top)/w.y,bottom:(x.bottom-g.bottom+m.bottom)/w.y,left:(g.left-x.left+m.left)/w.x,right:(x.right-g.right+m.right)/w.x}}function U(){return"undefined"!=typeof window}function X(t){return G(t)?(t.nodeName||"").toLowerCase():"#document"}function Y(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function J(t){var e;return null==(e=(G(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function G(t){return!!U()&&(t instanceof Node||t instanceof Y(t).Node)}function K(t){return!!U()&&(t instanceof Element||t instanceof Y(t).Element)}function Q(t){return!!U()&&(t instanceof HTMLElement||t instanceof Y(t).HTMLElement)}function Z(t){return!(!U()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof Y(t).ShadowRoot)}function tt(t){const{overflow:e,overflowX:n,overflowY:o,display:r}=ct(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(r)}function et(t){return["table","td","th"].includes(X(t))}function nt(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function ot(t){const e=rt(),n=K(t)?ct(t):t;return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some((t=>(n.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(n.contain||"").includes(t)))}function rt(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function it(t){return["html","body","#document"].includes(X(t))}function ct(t){return Y(t).getComputedStyle(t)}function lt(t){return K(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function at(t){if("html"===X(t))return t;const e=t.assignedSlot||t.parentNode||Z(t)&&t.host||J(t);return Z(e)?e.host:e}function st(t){const e=at(t);return it(e)?t.ownerDocument?t.ownerDocument.body:t.body:Q(e)&&tt(e)?e:st(e)}function ut(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const r=st(t),i=r===(null==(o=t.ownerDocument)?void 0:o.body),c=Y(r);if(i){const t=ft(c);return e.concat(c,c.visualViewport||[],tt(r)?r:[],t&&n?ut(t):[])}return e.concat(r,ut(r,[],n))}function ft(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function dt(t){const e=ct(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=Q(t),i=r?t.offsetWidth:n,c=r?t.offsetHeight:o,l=O(n)!==i||O(o)!==c;return l&&(n=i,o=c),{width:n,height:o,$:l}}function pt(t){return K(t)?t:t.contextElement}function mt(t){const e=pt(t);if(!Q(e))return A(1);const n=e.getBoundingClientRect(),{width:o,height:r,$:i}=dt(e);let c=(i?O(n.width):n.width)/o,l=(i?O(n.height):n.height)/r;return c&&Number.isFinite(c)||(c=1),l&&Number.isFinite(l)||(l=1),{x:c,y:l}}const ht=A(0);function gt(t){const e=Y(t);return rt()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:ht}function yt(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const r=t.getBoundingClientRect(),i=pt(t);let c=A(1);e&&(o?K(o)&&(c=mt(o)):c=mt(t));const l=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==Y(t))&&e}(i,n,o)?gt(i):A(0);let a=(r.left+l.x)/c.x,s=(r.top+l.y)/c.y,u=r.width/c.x,f=r.height/c.y;if(i){const t=Y(i),e=o&&K(o)?Y(o):o;let n=t,r=ft(n);for(;r&&o&&e!==n;){const t=mt(r),e=r.getBoundingClientRect(),o=ct(r),i=e.left+(r.clientLeft+parseFloat(o.paddingLeft))*t.x,c=e.top+(r.clientTop+parseFloat(o.paddingTop))*t.y;a*=t.x,s*=t.y,u*=t.x,f*=t.y,a+=i,s+=c,n=Y(r),r=ft(n)}}return j({width:u,height:f,x:a,y:s})}function vt(t,e){const n=lt(t).scrollLeft;return e?e.left+n:yt(J(t)).left+n}function wt(t,e,n){void 0===n&&(n=!1);const o=t.getBoundingClientRect();return{x:o.left+e.scrollLeft-(n?0:vt(t,o)),y:o.top+e.scrollTop}}function xt(t,e,n){let o;if("viewport"===e)o=function(t,e){const n=Y(t),o=J(t),r=n.visualViewport;let i=o.clientWidth,c=o.clientHeight,l=0,a=0;if(r){i=r.width,c=r.height;const t=rt();(!t||t&&"fixed"===e)&&(l=r.offsetLeft,a=r.offsetTop)}return{width:i,height:c,x:l,y:a}}(t,n);else if("document"===e)o=function(t){const e=J(t),n=lt(t),o=t.ownerDocument.body,r=R(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),i=R(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let c=-n.scrollLeft+vt(t);const l=-n.scrollTop;return"rtl"===ct(o).direction&&(c+=R(e.clientWidth,o.clientWidth)-r),{width:r,height:i,x:c,y:l}}(J(t));else if(K(e))o=function(t,e){const n=yt(t,!0,"fixed"===e),o=n.top+t.clientTop,r=n.left+t.clientLeft,i=Q(t)?mt(t):A(1);return{width:t.clientWidth*i.x,height:t.clientHeight*i.y,x:r*i.x,y:o*i.y}}(e,n);else{const n=gt(t);o={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return j(o)}function bt(t,e){const n=at(t);return!(n===e||!K(n)||it(n))&&("fixed"===ct(n).position||bt(n,e))}function Et(t,e,n){const o=Q(e),r=J(e),i="fixed"===n,c=yt(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const a=A(0);if(o||!o&&!i)if(("body"!==X(e)||tt(r))&&(l=lt(e)),o){const t=yt(e,!0,i,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else r&&(a.x=vt(r));const s=!r||o||i?A(0):wt(r,l);return{x:c.left+l.scrollLeft-a.x-s.x,y:c.top+l.scrollTop-a.y-s.y,width:c.width,height:c.height}}function Ct(t){return"static"===ct(t).position}function Lt(t,e){if(!Q(t)||"fixed"===ct(t).position)return null;if(e)return e(t);let n=t.offsetParent;return J(t)===n&&(n=n.ownerDocument.body),n}function Tt(t,e){const n=Y(t);if(nt(t))return n;if(!Q(t)){let e=at(t);for(;e&&!it(e);){if(K(e)&&!Ct(e))return e;e=at(e)}return n}let o=Lt(t,e);for(;o&&et(o)&&Ct(o);)o=Lt(o,e);return o&&it(o)&&Ct(o)&&!ot(o)?n:o||function(t){let e=at(t);for(;Q(e)&&!it(e);){if(ot(e))return e;if(nt(e))return null;e=at(e)}return null}(t)||n}const Rt={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:r}=t;const i="fixed"===r,c=J(o),l=!!e&&nt(e.floating);if(o===c||l&&i)return n;let a={scrollLeft:0,scrollTop:0},s=A(1);const u=A(0),f=Q(o);if((f||!f&&!i)&&(("body"!==X(o)||tt(c))&&(a=lt(o)),Q(o))){const t=yt(o);s=mt(o),u.x=t.x+o.clientLeft,u.y=t.y+o.clientTop}const d=!c||f||i?A(0):wt(c,a,!0);return{width:n.width*s.x,height:n.height*s.y,x:n.x*s.x-a.scrollLeft*s.x+u.x+d.x,y:n.y*s.y-a.scrollTop*s.y+u.y+d.y}},getDocumentElement:J,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:o,strategy:r}=t;const i=[..."clippingAncestors"===n?nt(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=ut(t,[],!1).filter((t=>K(t)&&"body"!==X(t))),r=null;const i="fixed"===ct(t).position;let c=i?at(t):t;for(;K(c)&&!it(c);){const e=ct(c),n=ot(c);n||"fixed"!==e.position||(r=null),(i?!n&&!r:!n&&"static"===e.position&&r&&["absolute","fixed"].includes(r.position)||tt(c)&&!n&&bt(t,c))?o=o.filter((t=>t!==c)):r=e,c=at(c)}return e.set(t,o),o}(e,this._c):[].concat(n),o],c=i[0],l=i.reduce(((t,n)=>{const o=xt(e,n,r);return t.top=R(o.top,t.top),t.right=T(o.right,t.right),t.bottom=T(o.bottom,t.bottom),t.left=R(o.left,t.left),t}),xt(e,c,r));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}},getOffsetParent:Tt,getElementRects:async function(t){const e=this.getOffsetParent||Tt,n=this.getDimensions,o=await n(t.floating);return{reference:Et(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=dt(t);return{width:e,height:n}},getScale:mt,isElement:K,isRTL:function(t){return"rtl"===ct(t).direction}},Ot=_,At=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:r,y:i,placement:c,middlewareData:l}=e,a=await async function(t,e){const{placement:n,platform:o,elements:r}=t,i=await(null==o.isRTL?void 0:o.isRTL(r.floating)),c=$(n),l=q(n),a="y"===W(n),s=["left","top"].includes(c)?-1:1,u=i&&a?-1:1,f=S(e,t);let{mainAxis:d,crossAxis:p,alignmentAxis:m}="number"==typeof f?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&"number"==typeof m&&(p="end"===l?-1*m:m),a?{x:p*u,y:d*s}:{x:d*s,y:p*u}}(e,t);return c===(null==(n=l.offset)?void 0:n.placement)&&null!=(o=l.arrow)&&o.alignmentOffset?{}:{x:r+a.x,y:i+a.y,data:{...a,placement:c}}}}},Ht=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,o,r;const{rects:i,middlewareData:c,placement:l,platform:a,elements:s}=e,{crossAxis:u=!1,alignment:f,allowedPlacements:d=L,autoAlignment:p=!0,...m}=S(t,e),h=void 0!==f||d===L?function(t,e,n){return(t?[...n.filter((e=>q(e)===t)),...n.filter((e=>q(e)!==t))]:n.filter((t=>$(t)===t))).filter((n=>!t||q(n)===t||!!e&&I(n)!==n))}(f||null,p,d):d,g=await _(e,m),y=(null==(n=c.autoPlacement)?void 0:n.index)||0,v=h[y];if(null==v)return{};const w=B(v,i,await(null==a.isRTL?void 0:a.isRTL(s.floating)));if(l!==v)return{reset:{placement:h[0]}};const x=[g[$(v)],g[w[0]],g[w[1]]],b=[...(null==(o=c.autoPlacement)?void 0:o.overflows)||[],{placement:v,overflows:x}],E=h[y+1];if(E)return{data:{index:y+1,overflows:b},reset:{placement:E}};const C=b.map((t=>{const e=q(t.placement);return[t.placement,e&&u?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),T=(null==(r=C.filter((t=>t[2].slice(0,q(t[0])?2:3).every((t=>t<=0))))[0])?void 0:r[0])||C[0][0];return T!==l?{data:{index:y+1,overflows:b},reset:{placement:T}}:{}}}},Dt=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:o,placement:r,rects:i,platform:c,elements:l,middlewareData:a}=e,{element:s,padding:u=0}=S(t,e)||{};if(null==s)return{};const f=N(u),d={x:n,y:o},p=M(r),m=F(p),h=await c.getDimensions(s),g="y"===p,y=g?"top":"left",v=g?"bottom":"right",w=g?"clientHeight":"clientWidth",x=i.reference[m]+i.reference[p]-d[p]-i.floating[m],b=d[p]-i.reference[p],E=await(null==c.getOffsetParent?void 0:c.getOffsetParent(s));let C=E?E[w]:0;C&&await(null==c.isElement?void 0:c.isElement(E))||(C=l.floating[w]||i.floating[m]);const L=x/2-b/2,R=C/2-h[m]/2-1,O=T(f[y],R),A=T(f[v],R),H=O,D=C-h[m]-A,$=C/2-h[m]/2+L,k=P(H,$,D),W=!a.arrow&&null!=q(r)&&$!==k&&i.reference[m]/2-($<H?O:A)-h[m]/2<0,B=W?$<H?$-H:$-D:0;return{[p]:d[p]+B,data:{[p]:k,centerOffset:$-k-B,...W&&{alignmentOffset:B}},reset:W}}}),Pt=(t,e,n)=>{const o=new Map,r={platform:Rt,...n},i={...r.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:c}=n,l=i.filter(Boolean),a=await(null==c.isRTL?void 0:c.isRTL(e));let s=await c.getElementRects({reference:t,floating:e,strategy:r}),{x:u,y:f}=z(s,o,a),d=o,p={},m=0;for(let n=0;n<l.length;n++){const{name:i,fn:h}=l[n],{x:g,y:y,data:v,reset:w}=await h({x:u,y:f,initialPlacement:o,placement:d,strategy:r,middlewareData:p,rects:s,platform:c,elements:{reference:t,floating:e}});u=null!=g?g:u,f=null!=y?y:f,p={...p,[i]:{...p[i],...v}},w&&m<=50&&(m++,"object"==typeof w&&(w.placement&&(d=w.placement),w.rects&&(s=!0===w.rects?await c.getElementRects({reference:t,floating:e,strategy:r}):w.rects),({x:u,y:f}=z(s,d,a))),n=-1)}return{x:u,y:f,placement:d,strategy:r,middlewareData:p}})(t,e,{...r,platform:i})};async function St(t,e,n){let{placement:o,offset:r}=n;const i=o[0],c=e.querySelector("[data-hovercard-arrow]"),l=[$t(o)];if(c){r+=c.clientWidth,l.push(Dt({element:c}))}l.push(At(r));const a=await Pt(t,e,{placement:i,middleware:l}),{x:s,y:u,placement:f}=a;c&&function(t,e){const n=t.clientWidth,{placement:o,middlewareData:{arrow:r}}=e,i=o.split("-")[0],c=qt[i],{x:l,y:a}=r,{borderWidth:s}=getComputedStyle(t.parentElement);Object.assign(t.style,{left:null!=l?`${l}px`:"",top:null!=a?`${a}px`:"",[c]:`calc(${-n}px + ${s})`})}(c,a),e.dataset.placement=f,Object.assign(e.style,{left:`${s}px`,top:`${u}px`})}const $t=t=>{let e=0;return{name:"autoPlacement",async fn(n){if("auto"===n.placement)return Ht().fn(n);const{top:o,bottom:r,left:i,right:c}=await Ot(n),l=o>0||r>0||i>0||c>0;return"auto"!==t[e]&&l?(e++,{reset:{placement:t[e]||"auto"}}):l?Ht().fn(n):{}}}},qt={right:"left",left:"right",top:"bottom",bottom:"top"};async function kt(t,e,n){const o=e.dataset,r=n?`${n}-${t}`:t;let i=`transition${t.charAt(0).toUpperCase()+t.slice(1)}`;const c=o[i]?o[i].split(" "):[r],l=o[`${i}Start`]?o[`${i}Start`].split(" "):[`${r}-start`],a=o[`${i}End`]?o[`${i}End`].split(" "):[`${r}-end`];Ft(e,c),Ft(e,l),await new Promise((t=>{requestAnimationFrame((()=>{requestAnimationFrame(t)}))})),Wt(e,l),Ft(e,a),await function(t){return new Promise((e=>{const n=getComputedStyle(t).transitionDuration.split(",")[0],o=1e3*Number(n.replace("s",""));setTimeout((()=>{e()}),o)}))}(e),Wt(e,a),Wt(e,c)}function Ft(t,e){t.classList.add(...e)}function Wt(t,e){t.classList.remove(...e)}const Mt=new Map;function Bt(t){Mt.set(t.uniqueId,t)}function It(t){Mt.delete(t.uniqueId)}function Vt(t){!function(t){delete t.coupdoeilElement.openingHovercard}(t),Nt(t)}function Nt(t){clearTimeout(t.closingRequest),t.closingRequest=null,Bt(t.coupdoeilElement)}function jt(t,e=!0){t.closing||t.isClosed&&!t.coupdoeilElement.openingHovercard||(t.closing=!0,Vt(t),t.children.forEach((t=>{jt(t)})),function(t){t.parent&&(t.parent.children.delete(t),t.parent=null)}(t),e&&t.card&&t.card.dataset.animation?async function(t){await async function(t,e=null){await kt("leave",t,e),t.classList.add("hidden")}(t.card,"hovercard"),zt(t)}(t):zt(t))}function zt(t){t.card&&(t.card.remove(),t.card=null),delete t.closing,delete t.coupdoeilElement.dataset.hovercardOpen}function _t(t){Vt(t),t.closingRequest=setTimeout((()=>{jt(t)}),75)}function Ut(t){t.children.forEach((t=>{jt(t)}))}function Xt(){for(const t of Mt.values())jt(t.hovercardController),It(t)}function Yt(){for(const t of Mt.values())clearHovercard(t.hovercardController),It(t)}function Jt(t){let e=t;for(;e.parent;)e=e.parent;const n=e.coupdoeilElement.uniqueId;for(const t of Mt.values())t.uniqueId!==n&&h(t.hovercardController)&&(jt(t.hovercardController),It(t))}async function Gt(t,e,n){return new Promise((o=>{setTimeout((async()=>{if(t.coupdoeilElement.openingHovercard){if(!1===e.cache||e.cache&&!x(t)){let n;n="preload"===e.loading?y(t).innerHTML:await function(t){const e=f(t),n=d(t),o=document.querySelector("meta[name=csrf-token]").content,r={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({params:n,action_name:e,authenticity_token:o})};return fetch("/coupdoeil/hovercard",r).then((t=>{if(t.status>=400)throw"error while fetching hovercard content";return t.text()}))}(t),function(t,e){v.set(w(t),e)}(t,n)}o()}}),n.fetch)}))}async function Kt(t,{parent:n,beforeDisplay:i}){if(t.isOpen)return Nt(t);n&&(t.parent=n,n.children.add(t));const c=function(t){const e=t.hovercardController.optionsInt||=u(t),n=Object.create(s);for(const t of r)n[t]=o[t].getter(e);return n}(t.coupdoeilElement),l=function(t,e){if(!1===e.openingDelay||function(t){return"click"===p(t)}(t))return{fetch:0,opening:0};return{fetch:100,opening:200}}(t,c),a=new Promise((t=>setTimeout(t,l.opening))),f=Gt(t,c,l);await Promise.all([f,a]);const d=t.parent&&(t.parent.isClosed||t.parent.closingRequest);t.coupdoeilElement.openingHovercard&&!d&&await async function(t,n,o){if(t.isOpen)return;Nt(t),t.card=function(t,n){const o=document.createElement("div");return o.setAttribute("role","dialog"),o.classList.add(e),o.style.cssText="position: absolute; left: 0; top: 0;",o.innerHTML=x(t),o.controller=t,o.dataset.placement=n.placement,o.style.visibility="hidden",o}(t,n),document.body.appendChild(t.card),n.animation&&(t.card.dataset.animation=n.animation);Qt(t,(async()=>{await St(t.coupdoeilElement,t.card,n),t.card.classList.add("hidden"),t.card.style.removeProperty("visibility"),Qt(t,(async()=>{o&&o(t),Bt(t.coupdoeilElement),delete t.coupdoeilElement.openingHovercard,t.coupdoeilElement.dataset.hovercardOpen=!0,await async function(t,e=null){t.classList.remove("hidden"),await kt("enter",t,e)}(t.card,"hovercard")}))}))}(t,c,i)}function Qt(t,e){requestAnimationFrame((()=>{t.coupdoeilElement.openingHovercard?e.call():function(t){jt(t,!1)}(t)}))}class Zt extends HTMLElement{constructor(){super(),this.uniqueId=function(){const t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}(),this.hovercardController=new t(this)}openHovercard(t=null,e){if(this.openingHovercard||this.hovercardController.isOpen||this.disabled||t===this)return;this.openingHovercard=!0;const o=this.closest(n)?.controller;return Bt(this),Kt(this.hovercardController,{parent:o,...e})}closeHovercard(){jt(this.hovercardController)}get disabled(){return!!this.getAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",!0):this.removeAttribute("disabled")}}function te(){return Mt.size>0}const ee=({target:t})=>{const e=t.closest("coup-doeil"),o=t.closest(n);e&&o?function(t,e,n){const o=t.hovercardController;if(m(o))return;o.isOpen?jt(o):t.openHovercard(n)}(e,0,t):e?function(t,e){const n=t.hovercardController;if(m(n))return;n.isOpen?jt(n):(Xt(),t.openHovercard(e))}(e,t):o?function(t,e){const n=t.controller;o=e,o.closest("[data-hovercard-close]")||o.dataset.hasOwnProperty("hovercardClose")?jt(n):n.children.size>0&&Ut(n);var o}(o,t):Xt()};const ne=({target:t})=>{const e=t.closest("coup-doeil"),o=t.closest(n);e&&o?function(t,e,n){const o=t.hovercardController,r=e.controller;if(g(o))return;o.isOpen?Ut(o):(Ut(r),t.openHovercard(n))}(e,o,t):e?function(t,e){const n=t.hovercardController;if(g(n))return;n.isClosed?t.openHovercard(e,{beforeDisplay:Jt}):n.closingRequest&&(Nt(n),Bt(t))}(e,t):o?function(t){const e=t.controller;e.closingRequest?(Nt(e),Bt(e.coupdoeilElement)):e.children.size>0&&e.children.forEach((t=>{h(t)&&_t(t)}))}(o):te()&&function(){for(const t of Mt.values())h(t.hovercardController)&&(_t(t.hovercardController),It(t))}()};document.addEventListener("DOMContentLoaded",(()=>{b(),document.addEventListener("click",ee),document.documentElement.addEventListener("mouseover",ne,{passive:!0}),window.Turbo&&(document.addEventListener("turbo:before-cache",(t=>{Yt()})),document.addEventListener("turbo:load",(t=>{Yt(),b()})))})),void 0===customElements.get("coup-doeil")&&customElements.define("coup-doeil",Zt);
|
2
2
|
//# sourceMappingURL=coupdoeil.min.js.map
|