@overlastic/svelte 0.8.1 → 0.8.7

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.
@@ -4,6 +4,7 @@ var OverlaysSvelte = (() => {
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
8
  var __export = (target, all) => {
8
9
  for (var name in all)
9
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -17,16 +18,35 @@ var OverlaysSvelte = (() => {
17
18
  return to;
18
19
  };
19
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
20
22
 
21
23
  // src/index.ts
22
- var src_exports = {};
23
- __export(src_exports, {
24
+ var index_exports = {};
25
+ __export(index_exports, {
24
26
  Overlay: () => Overlay,
25
27
  defineOverlay: () => defineOverlay,
26
28
  renderOverlay: () => renderOverlay,
27
- useExtendOverlay: () => useExtendOverlay
29
+ useDisclosure: () => useDisclosure
28
30
  });
29
31
 
32
+ // ../@core/src/deferred.ts
33
+ function createDeferred() {
34
+ let confirm, cancel;
35
+ const promise = new Promise((_confirm, _cancel) => {
36
+ confirm = _confirm;
37
+ cancel = _cancel;
38
+ });
39
+ promise.confirm = (v) => {
40
+ confirm(v);
41
+ return promise;
42
+ };
43
+ promise.close = () => {
44
+ confirm();
45
+ };
46
+ promise.cancel = cancel;
47
+ return promise;
48
+ }
49
+
30
50
  // ../@core/src/define/global.ts
31
51
  var UnifiedOverlayProviderID = "unified-overlay";
32
52
  function defineGlobalElement(id = "", root = document.body) {
@@ -56,21 +76,6 @@ var OverlaysSvelte = (() => {
56
76
  return context.spaces[id] || 0;
57
77
  }
58
78
 
59
- // ../@core/src/deferred.ts
60
- function createDeferred() {
61
- let resolve, reject;
62
- const promise = new Promise((_resolve, _reject) => {
63
- resolve = _resolve;
64
- reject = _reject;
65
- });
66
- promise.resolve = (v) => {
67
- resolve(v);
68
- return promise;
69
- };
70
- promise.reject = reject;
71
- return promise;
72
- }
73
-
74
79
  // ../@core/src/events/index.ts
75
80
  function watchClickPosition() {
76
81
  if (typeof window === "undefined" && typeof document === "undefined")
@@ -98,8 +103,8 @@ var OverlaysSvelte = (() => {
98
103
  const deferred = createDeferred();
99
104
  const name = defineName(options3.id, options3.autoIncrement);
100
105
  const index = getIndex(options3.id);
101
- const root = globalContainer ? options3.root : document.body;
102
- const container = defineGlobalElement(name, root);
106
+ const root = options3.root ? options3.root : document.body;
107
+ const container = globalContainer !== false ? defineGlobalElement(name, root) : void 0;
103
108
  mount(instance2, props, Object.assign(options3, {
104
109
  position: context.position,
105
110
  id: name,
@@ -132,63 +137,372 @@ var OverlaysSvelte = (() => {
132
137
 
133
138
  // ../@core/src/utils/util.ts
134
139
  function delay(milliseconds) {
135
- return new Promise((resolve) => setTimeout(resolve, milliseconds));
140
+ return new Promise((confirm) => setTimeout(confirm, milliseconds));
136
141
  }
137
142
 
138
- // src/internal/index.ts
139
- var injectOverlayKey = Symbol("overlays:svelte");
140
- var injectOptionsKey = Symbol("overlays:options");
143
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/runtime/internal/globals.js
144
+ var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : (
145
+ // @ts-ignore Node typings have this
146
+ global
147
+ );
141
148
 
142
- // src/define/constructor.ts
143
- var constructor = createConstructor((Inst, props, options) => {
144
- const { container, deferred, context: _context = /* @__PURE__ */ new Map() } = options;
145
- function vanish() {
146
- app.$destroy();
147
- container.remove();
149
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/runtime/internal/ResizeObserverSingleton.js
150
+ var ResizeObserverSingleton = class _ResizeObserverSingleton {
151
+ /** @param {ResizeObserverOptions} options */
152
+ constructor(options) {
153
+ /**
154
+ * @private
155
+ * @readonly
156
+ * @type {WeakMap<Element, import('./private.js').Listener>}
157
+ */
158
+ __publicField(this, "_listeners", "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0);
159
+ /**
160
+ * @private
161
+ * @type {ResizeObserver}
162
+ */
163
+ __publicField(this, "_observer");
164
+ /** @type {ResizeObserverOptions} */
165
+ __publicField(this, "options");
166
+ this.options = options;
148
167
  }
149
- const context2 = new Map([..._context.entries()]);
150
- context2.set(injectOverlayKey, {
151
- resolve: deferred.resolve,
152
- reject: deferred.reject,
153
- deferred,
154
- visible: false,
155
- vanish
156
- });
157
- const app = new Inst({
158
- target: container,
159
- props,
160
- context: context2
161
- });
162
- });
168
+ /**
169
+ * @param {Element} element
170
+ * @param {import('./private.js').Listener} listener
171
+ * @returns {() => void}
172
+ */
173
+ observe(element2, listener) {
174
+ this._listeners.set(element2, listener);
175
+ this._getObserver().observe(element2, this.options);
176
+ return () => {
177
+ this._listeners.delete(element2);
178
+ this._observer.unobserve(element2);
179
+ };
180
+ }
181
+ /**
182
+ * @private
183
+ */
184
+ _getObserver() {
185
+ var _a;
186
+ return (_a = this._observer) != null ? _a : this._observer = new ResizeObserver((entries) => {
187
+ var _a2;
188
+ for (const entry of entries) {
189
+ _ResizeObserverSingleton.entries.set(entry.target, entry);
190
+ (_a2 = this._listeners.get(entry.target)) == null ? void 0 : _a2(entry);
191
+ }
192
+ });
193
+ }
194
+ };
195
+ ResizeObserverSingleton.entries = "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0;
163
196
 
164
- // src/define/index.ts
165
- var defineOverlay = constructor.define;
166
- var renderOverlay = constructor.render;
197
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/runtime/internal/dom.js
198
+ function insert(target, node, anchor) {
199
+ target.insertBefore(node, anchor || null);
200
+ }
201
+ function detach(node) {
202
+ if (node.parentNode) {
203
+ node.parentNode.removeChild(node);
204
+ }
205
+ }
206
+ function element(name) {
207
+ return document.createElement(name);
208
+ }
209
+ function attr(node, attribute, value) {
210
+ if (value == null) node.removeAttribute(attribute);
211
+ else if (node.getAttribute(attribute) !== value) node.setAttribute(attribute, value);
212
+ }
213
+ function get_custom_elements_slots(element2) {
214
+ const result = {};
215
+ element2.childNodes.forEach(
216
+ /** @param {Element} node */
217
+ (node) => {
218
+ result[node.slot || "default"] = true;
219
+ }
220
+ );
221
+ return result;
222
+ }
223
+
224
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/runtime/internal/lifecycle.js
225
+ var current_component;
226
+ function get_current_component() {
227
+ if (!current_component) throw new Error("Function called outside component initialization");
228
+ return current_component;
229
+ }
230
+ function setContext(key, context2) {
231
+ get_current_component().$$.context.set(key, context2);
232
+ return context2;
233
+ }
234
+ function getContext(key) {
235
+ return get_current_component().$$.context.get(key);
236
+ }
237
+
238
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/shared/boolean_attributes.js
239
+ var _boolean_attributes = (
240
+ /** @type {const} */
241
+ [
242
+ "allowfullscreen",
243
+ "allowpaymentrequest",
244
+ "async",
245
+ "autofocus",
246
+ "autoplay",
247
+ "checked",
248
+ "controls",
249
+ "default",
250
+ "defer",
251
+ "disabled",
252
+ "formnovalidate",
253
+ "hidden",
254
+ "inert",
255
+ "ismap",
256
+ "loop",
257
+ "multiple",
258
+ "muted",
259
+ "nomodule",
260
+ "novalidate",
261
+ "open",
262
+ "playsinline",
263
+ "readonly",
264
+ "required",
265
+ "reversed",
266
+ "selected"
267
+ ]
268
+ );
269
+ var boolean_attributes = /* @__PURE__ */ new Set([..._boolean_attributes]);
270
+
271
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/runtime/internal/Component.js
272
+ var SvelteElement;
273
+ if (typeof HTMLElement === "function") {
274
+ SvelteElement = class extends HTMLElement {
275
+ constructor($$componentCtor, $$slots, use_shadow_dom) {
276
+ super();
277
+ /** The Svelte component constructor */
278
+ __publicField(this, "$$ctor");
279
+ /** Slots */
280
+ __publicField(this, "$$s");
281
+ /** The Svelte component instance */
282
+ __publicField(this, "$$c");
283
+ /** Whether or not the custom element is connected */
284
+ __publicField(this, "$$cn", false);
285
+ /** Component props data */
286
+ __publicField(this, "$$d", {});
287
+ /** `true` if currently in the process of reflecting component props back to attributes */
288
+ __publicField(this, "$$r", false);
289
+ /** @type {Record<string, CustomElementPropDefinition>} Props definition (name, reflected, type etc) */
290
+ __publicField(this, "$$p_d", {});
291
+ /** @type {Record<string, Function[]>} Event listeners */
292
+ __publicField(this, "$$l", {});
293
+ /** @type {Map<Function, Function>} Event listener unsubscribe functions */
294
+ __publicField(this, "$$l_u", /* @__PURE__ */ new Map());
295
+ this.$$ctor = $$componentCtor;
296
+ this.$$s = $$slots;
297
+ if (use_shadow_dom) {
298
+ this.attachShadow({ mode: "open" });
299
+ }
300
+ }
301
+ addEventListener(type, listener, options) {
302
+ this.$$l[type] = this.$$l[type] || [];
303
+ this.$$l[type].push(listener);
304
+ if (this.$$c) {
305
+ const unsub = this.$$c.$on(type, listener);
306
+ this.$$l_u.set(listener, unsub);
307
+ }
308
+ super.addEventListener(type, listener, options);
309
+ }
310
+ removeEventListener(type, listener, options) {
311
+ super.removeEventListener(type, listener, options);
312
+ if (this.$$c) {
313
+ const unsub = this.$$l_u.get(listener);
314
+ if (unsub) {
315
+ unsub();
316
+ this.$$l_u.delete(listener);
317
+ }
318
+ }
319
+ }
320
+ async connectedCallback() {
321
+ this.$$cn = true;
322
+ if (!this.$$c) {
323
+ let create_slot3 = function(name) {
324
+ return () => {
325
+ let node;
326
+ const obj = {
327
+ c: function create() {
328
+ node = element("slot");
329
+ if (name !== "default") {
330
+ attr(node, "name", name);
331
+ }
332
+ },
333
+ /**
334
+ * @param {HTMLElement} target
335
+ * @param {HTMLElement} [anchor]
336
+ */
337
+ m: function mount(target, anchor) {
338
+ insert(target, node, anchor);
339
+ },
340
+ d: function destroy(detaching) {
341
+ if (detaching) {
342
+ detach(node);
343
+ }
344
+ }
345
+ };
346
+ return obj;
347
+ };
348
+ };
349
+ var create_slot2 = create_slot3;
350
+ await Promise.resolve();
351
+ if (!this.$$cn || this.$$c) {
352
+ return;
353
+ }
354
+ const $$slots = {};
355
+ const existing_slots = get_custom_elements_slots(this);
356
+ for (const name of this.$$s) {
357
+ if (name in existing_slots) {
358
+ $$slots[name] = [create_slot3(name)];
359
+ }
360
+ }
361
+ for (const attribute of this.attributes) {
362
+ const name = this.$$g_p(attribute.name);
363
+ if (!(name in this.$$d)) {
364
+ this.$$d[name] = get_custom_element_value(name, attribute.value, this.$$p_d, "toProp");
365
+ }
366
+ }
367
+ for (const key in this.$$p_d) {
368
+ if (!(key in this.$$d) && this[key] !== void 0) {
369
+ this.$$d[key] = this[key];
370
+ delete this[key];
371
+ }
372
+ }
373
+ this.$$c = new this.$$ctor({
374
+ target: this.shadowRoot || this,
375
+ props: {
376
+ ...this.$$d,
377
+ $$slots,
378
+ $$scope: {
379
+ ctx: []
380
+ }
381
+ }
382
+ });
383
+ const reflect_attributes = () => {
384
+ this.$$r = true;
385
+ for (const key in this.$$p_d) {
386
+ this.$$d[key] = this.$$c.$$.ctx[this.$$c.$$.props[key]];
387
+ if (this.$$p_d[key].reflect) {
388
+ const attribute_value = get_custom_element_value(
389
+ key,
390
+ this.$$d[key],
391
+ this.$$p_d,
392
+ "toAttribute"
393
+ );
394
+ if (attribute_value == null) {
395
+ this.removeAttribute(this.$$p_d[key].attribute || key);
396
+ } else {
397
+ this.setAttribute(this.$$p_d[key].attribute || key, attribute_value);
398
+ }
399
+ }
400
+ }
401
+ this.$$r = false;
402
+ };
403
+ this.$$c.$$.after_update.push(reflect_attributes);
404
+ reflect_attributes();
405
+ for (const type in this.$$l) {
406
+ for (const listener of this.$$l[type]) {
407
+ const unsub = this.$$c.$on(type, listener);
408
+ this.$$l_u.set(listener, unsub);
409
+ }
410
+ }
411
+ this.$$l = {};
412
+ }
413
+ }
414
+ // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
415
+ // and setting attributes through setAttribute etc, this is helpful
416
+ attributeChangedCallback(attr2, _oldValue, newValue) {
417
+ var _a;
418
+ if (this.$$r) return;
419
+ attr2 = this.$$g_p(attr2);
420
+ this.$$d[attr2] = get_custom_element_value(attr2, newValue, this.$$p_d, "toProp");
421
+ (_a = this.$$c) == null ? void 0 : _a.$set({ [attr2]: this.$$d[attr2] });
422
+ }
423
+ disconnectedCallback() {
424
+ this.$$cn = false;
425
+ Promise.resolve().then(() => {
426
+ if (!this.$$cn && this.$$c) {
427
+ this.$$c.$destroy();
428
+ this.$$c = void 0;
429
+ }
430
+ });
431
+ }
432
+ $$g_p(attribute_name) {
433
+ return Object.keys(this.$$p_d).find(
434
+ (key) => this.$$p_d[key].attribute === attribute_name || !this.$$p_d[key].attribute && key.toLowerCase() === attribute_name
435
+ ) || attribute_name;
436
+ }
437
+ };
438
+ }
439
+ function get_custom_element_value(prop, value, props_definition, transform) {
440
+ var _a;
441
+ const type = (_a = props_definition[prop]) == null ? void 0 : _a.type;
442
+ value = type === "Boolean" && typeof value !== "boolean" ? value != null : value;
443
+ if (!transform || !props_definition[prop]) {
444
+ return value;
445
+ } else if (transform === "toAttribute") {
446
+ switch (type) {
447
+ case "Object":
448
+ case "Array":
449
+ return value == null ? null : JSON.stringify(value);
450
+ case "Boolean":
451
+ return value ? "" : null;
452
+ case "Number":
453
+ return value == null ? null : value;
454
+ default:
455
+ return value;
456
+ }
457
+ } else {
458
+ switch (type) {
459
+ case "Object":
460
+ case "Array":
461
+ return value && JSON.parse(value);
462
+ case "Boolean":
463
+ return value;
464
+ // conversion already handled above
465
+ case "Number":
466
+ return value != null ? +value : value;
467
+ default:
468
+ return value;
469
+ }
470
+ }
471
+ }
472
+
473
+ // ../../node_modules/.pnpm/svelte@4.2.19/node_modules/svelte/src/runtime/ssr.js
474
+ function onMount2() {
475
+ }
167
476
 
168
- // ../../node_modules/.pnpm/svelte@3.57.0/node_modules/svelte/internal/index.mjs
169
- function noop() {
477
+ // src/components/index.ts
478
+ var __defProp2 = Object.defineProperty;
479
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
480
+ var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? `${key}` : key, value);
481
+ function noop2() {
170
482
  }
171
483
  function assign(tar, src) {
172
- for (const k in src)
173
- tar[k] = src[k];
174
- return tar;
484
+ for (const k in src) tar[k] = src[k];
485
+ return (
486
+ /** @type {T & S} */
487
+ tar
488
+ );
175
489
  }
176
- function run(fn) {
490
+ function run2(fn) {
177
491
  return fn();
178
492
  }
179
- function blank_object() {
493
+ function blank_object2() {
180
494
  return /* @__PURE__ */ Object.create(null);
181
495
  }
182
- function run_all(fns) {
183
- fns.forEach(run);
496
+ function run_all2(fns) {
497
+ fns.forEach(run2);
184
498
  }
185
- function is_function(thing) {
499
+ function is_function2(thing) {
186
500
  return typeof thing === "function";
187
501
  }
188
502
  function safe_not_equal(a, b) {
189
- return a != a ? b == b : a !== b || (a && typeof a === "object" || typeof a === "function");
503
+ return a != a ? b == b : a !== b || a && typeof a === "object" || typeof a === "function";
190
504
  }
191
- function is_empty(obj) {
505
+ function is_empty2(obj) {
192
506
  return Object.keys(obj).length === 0;
193
507
  }
194
508
  function create_slot(definition, ctx, $$scope, fn) {
@@ -201,21 +515,8 @@ var OverlaysSvelte = (() => {
201
515
  return definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx;
202
516
  }
203
517
  function get_slot_changes(definition, $$scope, dirty, fn) {
204
- if (definition[2] && fn) {
205
- const lets = definition[2](fn(dirty));
206
- if ($$scope.dirty === void 0) {
207
- return lets;
208
- }
209
- if (typeof lets === "object") {
210
- const merged = [];
211
- const len = Math.max($$scope.dirty.length, lets.length);
212
- for (let i = 0; i < len; i += 1) {
213
- merged[i] = $$scope.dirty[i] | lets[i];
214
- }
215
- return merged;
216
- }
217
- return $$scope.dirty | lets;
218
- }
518
+ if (definition[2] && fn)
519
+ ;
219
520
  return $$scope.dirty;
220
521
  }
221
522
  function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {
@@ -235,17 +536,10 @@ var OverlaysSvelte = (() => {
235
536
  }
236
537
  return -1;
237
538
  }
238
- var is_hydrating = false;
239
- function start_hydrating() {
240
- is_hydrating = true;
241
- }
242
- function end_hydrating() {
243
- is_hydrating = false;
244
- }
245
- function insert(target, node, anchor) {
539
+ function insert2(target, node, anchor) {
246
540
  target.insertBefore(node, anchor || null);
247
541
  }
248
- function detach(node) {
542
+ function detach2(node) {
249
543
  if (node.parentNode) {
250
544
  node.parentNode.removeChild(node);
251
545
  }
@@ -256,65 +550,52 @@ var OverlaysSvelte = (() => {
256
550
  function empty() {
257
551
  return text("");
258
552
  }
259
- function children(element) {
260
- return Array.from(element.childNodes);
553
+ function children2(element2) {
554
+ return Array.from(element2.childNodes);
261
555
  }
262
- var current_component;
263
- function set_current_component(component) {
264
- current_component = component;
556
+ var current_component2;
557
+ function set_current_component2(component) {
558
+ current_component2 = component;
265
559
  }
266
- function get_current_component() {
267
- if (!current_component)
268
- throw new Error("Function called outside component initialization");
269
- return current_component;
270
- }
271
- function setContext(key, context2) {
272
- get_current_component().$$.context.set(key, context2);
273
- return context2;
274
- }
275
- function getContext(key) {
276
- return get_current_component().$$.context.get(key);
277
- }
278
- var dirty_components = [];
560
+ var dirty_components2 = [];
279
561
  var binding_callbacks = [];
280
562
  var render_callbacks = [];
281
563
  var flush_callbacks = [];
282
564
  var resolved_promise = /* @__PURE__ */ Promise.resolve();
283
565
  var update_scheduled = false;
284
- function schedule_update() {
566
+ function schedule_update2() {
285
567
  if (!update_scheduled) {
286
568
  update_scheduled = true;
287
- resolved_promise.then(flush);
569
+ resolved_promise.then(flush2);
288
570
  }
289
571
  }
290
- function add_render_callback(fn) {
572
+ function add_render_callback2(fn) {
291
573
  render_callbacks.push(fn);
292
574
  }
293
575
  var seen_callbacks = /* @__PURE__ */ new Set();
294
576
  var flushidx = 0;
295
- function flush() {
577
+ function flush2() {
296
578
  if (flushidx !== 0) {
297
579
  return;
298
580
  }
299
- const saved_component = current_component;
581
+ const saved_component = current_component2;
300
582
  do {
301
583
  try {
302
- while (flushidx < dirty_components.length) {
303
- const component = dirty_components[flushidx];
584
+ while (flushidx < dirty_components2.length) {
585
+ const component = dirty_components2[flushidx];
304
586
  flushidx++;
305
- set_current_component(component);
587
+ set_current_component2(component);
306
588
  update(component.$$);
307
589
  }
308
590
  } catch (e) {
309
- dirty_components.length = 0;
591
+ dirty_components2.length = 0;
310
592
  flushidx = 0;
311
593
  throw e;
312
594
  }
313
- set_current_component(null);
314
- dirty_components.length = 0;
595
+ set_current_component2(null);
596
+ dirty_components2.length = 0;
315
597
  flushidx = 0;
316
- while (binding_callbacks.length)
317
- binding_callbacks.pop()();
598
+ while (binding_callbacks.length) binding_callbacks.pop()();
318
599
  for (let i = 0; i < render_callbacks.length; i += 1) {
319
600
  const callback = render_callbacks[i];
320
601
  if (!seen_callbacks.has(callback)) {
@@ -323,34 +604,34 @@ var OverlaysSvelte = (() => {
323
604
  }
324
605
  }
325
606
  render_callbacks.length = 0;
326
- } while (dirty_components.length);
607
+ } while (dirty_components2.length);
327
608
  while (flush_callbacks.length) {
328
609
  flush_callbacks.pop()();
329
610
  }
330
611
  update_scheduled = false;
331
612
  seen_callbacks.clear();
332
- set_current_component(saved_component);
613
+ set_current_component2(saved_component);
333
614
  }
334
615
  function update($$) {
335
616
  if ($$.fragment !== null) {
336
617
  $$.update();
337
- run_all($$.before_update);
618
+ run_all2($$.before_update);
338
619
  const dirty = $$.dirty;
339
620
  $$.dirty = [-1];
340
621
  $$.fragment && $$.fragment.p($$.ctx, dirty);
341
- $$.after_update.forEach(add_render_callback);
622
+ $$.after_update.forEach(add_render_callback2);
342
623
  }
343
624
  }
344
- function flush_render_callbacks(fns) {
625
+ function flush_render_callbacks2(fns) {
345
626
  const filtered = [];
346
627
  const targets = [];
347
- render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c));
628
+ render_callbacks.forEach((c) => !fns.includes(c) ? filtered.push(c) : targets.push(c));
348
629
  targets.forEach((c) => c());
349
630
  render_callbacks = filtered;
350
631
  }
351
632
  var outroing = /* @__PURE__ */ new Set();
352
633
  var outros;
353
- function group_outros() {
634
+ function group_outros2() {
354
635
  outros = {
355
636
  r: 0,
356
637
  c: [],
@@ -358,19 +639,19 @@ var OverlaysSvelte = (() => {
358
639
  // parent group
359
640
  };
360
641
  }
361
- function check_outros() {
642
+ function check_outros2() {
362
643
  if (!outros.r) {
363
- run_all(outros.c);
644
+ run_all2(outros.c);
364
645
  }
365
646
  outros = outros.p;
366
647
  }
367
- function transition_in(block, local) {
648
+ function transition_in2(block, local) {
368
649
  if (block && block.i) {
369
650
  outroing.delete(block);
370
651
  block.i(local);
371
652
  }
372
653
  }
373
- function transition_out(block, local, detach2, callback) {
654
+ function transition_out2(block, local, detach22, callback) {
374
655
  if (block && block.o) {
375
656
  if (outroing.has(block))
376
657
  return;
@@ -378,7 +659,7 @@ var OverlaysSvelte = (() => {
378
659
  outros.c.push(() => {
379
660
  outroing.delete(block);
380
661
  if (callback) {
381
- if (detach2)
662
+ if (detach22)
382
663
  block.d(1);
383
664
  callback();
384
665
  }
@@ -388,57 +669,25 @@ var OverlaysSvelte = (() => {
388
669
  callback();
389
670
  }
390
671
  }
391
- var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : global;
392
- var _boolean_attributes = [
393
- "allowfullscreen",
394
- "allowpaymentrequest",
395
- "async",
396
- "autofocus",
397
- "autoplay",
398
- "checked",
399
- "controls",
400
- "default",
401
- "defer",
402
- "disabled",
403
- "formnovalidate",
404
- "hidden",
405
- "inert",
406
- "ismap",
407
- "itemscope",
408
- "loop",
409
- "multiple",
410
- "muted",
411
- "nomodule",
412
- "novalidate",
413
- "open",
414
- "playsinline",
415
- "readonly",
416
- "required",
417
- "reversed",
418
- "selected"
419
- ];
420
- var boolean_attributes = /* @__PURE__ */ new Set([..._boolean_attributes]);
421
- function mount_component(component, target, anchor, customElement) {
672
+ function mount_component(component, target, anchor) {
422
673
  const { fragment, after_update } = component.$$;
423
674
  fragment && fragment.m(target, anchor);
424
- if (!customElement) {
425
- add_render_callback(() => {
426
- const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
427
- if (component.$$.on_destroy) {
428
- component.$$.on_destroy.push(...new_on_destroy);
429
- } else {
430
- run_all(new_on_destroy);
431
- }
432
- component.$$.on_mount = [];
433
- });
434
- }
435
- after_update.forEach(add_render_callback);
675
+ add_render_callback2(() => {
676
+ const new_on_destroy = component.$$.on_mount.map(run2).filter(is_function2);
677
+ if (component.$$.on_destroy) {
678
+ component.$$.on_destroy.push(...new_on_destroy);
679
+ } else {
680
+ run_all2(new_on_destroy);
681
+ }
682
+ component.$$.on_mount = [];
683
+ });
684
+ after_update.forEach(add_render_callback2);
436
685
  }
437
686
  function destroy_component(component, detaching) {
438
687
  const $$ = component.$$;
439
688
  if ($$.fragment !== null) {
440
- flush_render_callbacks($$.after_update);
441
- run_all($$.on_destroy);
689
+ flush_render_callbacks2($$.after_update);
690
+ run_all2($$.on_destroy);
442
691
  $$.fragment && $$.fragment.d(detaching);
443
692
  $$.on_destroy = $$.fragment = null;
444
693
  $$.ctx = [];
@@ -446,23 +695,23 @@ var OverlaysSvelte = (() => {
446
695
  }
447
696
  function make_dirty(component, i) {
448
697
  if (component.$$.dirty[0] === -1) {
449
- dirty_components.push(component);
450
- schedule_update();
698
+ dirty_components2.push(component);
699
+ schedule_update2();
451
700
  component.$$.dirty.fill(0);
452
701
  }
453
702
  component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
454
703
  }
455
- function init(component, options, instance2, create_fragment2, not_equal, props, append_styles, dirty = [-1]) {
456
- const parent_component = current_component;
457
- set_current_component(component);
704
+ function init(component, options, instance2, create_fragment2, not_equal, props, append_styles = null, dirty = [-1]) {
705
+ const parent_component = current_component2;
706
+ set_current_component2(component);
458
707
  const $$ = component.$$ = {
459
708
  fragment: null,
460
709
  ctx: [],
461
710
  // state
462
711
  props,
463
- update: noop,
712
+ update: noop2,
464
713
  not_equal,
465
- bound: blank_object(),
714
+ bound: blank_object2(),
466
715
  // lifecycle
467
716
  on_mount: [],
468
717
  on_destroy: [],
@@ -471,7 +720,7 @@ var OverlaysSvelte = (() => {
471
720
  after_update: [],
472
721
  context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
473
722
  // everything else
474
- callbacks: blank_object(),
723
+ callbacks: blank_object2(),
475
724
  dirty,
476
725
  skip_bound: false,
477
726
  root: options.target || parent_component.$$.root
@@ -490,78 +739,42 @@ var OverlaysSvelte = (() => {
490
739
  }) : [];
491
740
  $$.update();
492
741
  ready = true;
493
- run_all($$.before_update);
742
+ run_all2($$.before_update);
494
743
  $$.fragment = create_fragment2 ? create_fragment2($$.ctx) : false;
495
744
  if (options.target) {
496
745
  if (options.hydrate) {
497
- start_hydrating();
498
- const nodes = children(options.target);
746
+ const nodes = children2(options.target);
499
747
  $$.fragment && $$.fragment.l(nodes);
500
- nodes.forEach(detach);
748
+ nodes.forEach(detach2);
501
749
  } else {
502
750
  $$.fragment && $$.fragment.c();
503
751
  }
504
752
  if (options.intro)
505
- transition_in(component.$$.fragment);
506
- mount_component(component, options.target, options.anchor, options.customElement);
507
- end_hydrating();
508
- flush();
753
+ transition_in2(component.$$.fragment);
754
+ mount_component(component, options.target, options.anchor);
755
+ flush2();
509
756
  }
510
- set_current_component(parent_component);
757
+ set_current_component2(parent_component);
511
758
  }
512
- var SvelteElement;
513
- if (typeof HTMLElement === "function") {
514
- SvelteElement = class extends HTMLElement {
515
- constructor() {
516
- super();
517
- this.attachShadow({ mode: "open" });
518
- }
519
- connectedCallback() {
520
- const { on_mount } = this.$$;
521
- this.$$.on_disconnect = on_mount.map(run).filter(is_function);
522
- for (const key in this.$$.slotted) {
523
- this.appendChild(this.$$.slotted[key]);
524
- }
525
- }
526
- attributeChangedCallback(attr, _oldValue, newValue) {
527
- this[attr] = newValue;
528
- }
529
- disconnectedCallback() {
530
- run_all(this.$$.on_disconnect);
531
- }
532
- $destroy() {
533
- destroy_component(this, 1);
534
- this.$destroy = noop;
535
- }
536
- $on(type, callback) {
537
- if (!is_function(callback)) {
538
- return noop;
539
- }
540
- const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
541
- callbacks.push(callback);
542
- return () => {
543
- const index = callbacks.indexOf(callback);
544
- if (index !== -1)
545
- callbacks.splice(index, 1);
546
- };
547
- }
548
- $set($$props) {
549
- if (this.$$set && !is_empty($$props)) {
550
- this.$$.skip_bound = true;
551
- this.$$set($$props);
552
- this.$$.skip_bound = false;
553
- }
554
- }
555
- };
556
- }
557
- var SvelteComponent = class {
759
+ var SvelteComponent2 = class {
760
+ constructor() {
761
+ __publicField2(this, "$$");
762
+ __publicField2(this, "$$set");
763
+ }
764
+ /** @returns {void} */
558
765
  $destroy() {
559
766
  destroy_component(this, 1);
560
- this.$destroy = noop;
767
+ this.$destroy = noop2;
561
768
  }
769
+ /**
770
+ * @template {Extract<keyof Events, string>} K
771
+ * @param {K} type
772
+ * @param {((e: Events[K]) => void) | null | undefined} callback
773
+ * @returns {() => void}
774
+ */
562
775
  $on(type, callback) {
563
- if (!is_function(callback)) {
564
- return noop;
776
+ if (!is_function2(callback)) {
777
+ return noop2;
565
778
  }
566
779
  const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
567
780
  callbacks.push(callback);
@@ -571,49 +784,23 @@ var OverlaysSvelte = (() => {
571
784
  callbacks.splice(index, 1);
572
785
  };
573
786
  }
574
- $set($$props) {
575
- if (this.$$set && !is_empty($$props)) {
787
+ /**
788
+ * @param {Partial<Props>} props
789
+ * @returns {void}
790
+ */
791
+ $set(props) {
792
+ if (this.$$set && !is_empty2(props)) {
576
793
  this.$$.skip_bound = true;
577
- this.$$set($$props);
794
+ this.$$set(props);
578
795
  this.$$.skip_bound = false;
579
796
  }
580
797
  }
581
798
  };
582
- var SvelteComponentDev = class extends SvelteComponent {
583
- constructor(options) {
584
- if (!options || !options.target && !options.$$inline) {
585
- throw new Error("'target' is a required option");
586
- }
587
- super();
588
- }
589
- $destroy() {
590
- super.$destroy();
591
- this.$destroy = () => {
592
- console.warn("Component was already destroyed");
593
- };
594
- }
595
- $capture_state() {
596
- }
597
- $inject_state() {
598
- }
599
- };
600
- var SvelteComponentTyped = class extends SvelteComponentDev {
601
- constructor(options) {
602
- super(options);
603
- }
604
- };
605
-
606
- // ../../node_modules/.pnpm/svelte@3.57.0/node_modules/svelte/ssr.mjs
607
- function onMount() {
608
- }
609
-
610
- // src/composable/define.ts
611
- function useExtendOverlay(options = {}) {
612
- setContext(injectOptionsKey, options);
613
- return getContext(injectOverlayKey);
614
- }
615
-
616
- // src/components/index.ts
799
+ var PUBLIC_VERSION = "4";
800
+ if (typeof window !== "undefined")
801
+ (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(PUBLIC_VERSION);
802
+ var injectOverlayKey = Symbol("overlays:svelte");
803
+ var injectOptionsKey = Symbol("overlays:options");
617
804
  function create_if_block(ctx) {
618
805
  let current;
619
806
  const default_slot_template = (
@@ -633,8 +820,9 @@ var OverlaysSvelte = (() => {
633
820
  default_slot.c();
634
821
  },
635
822
  m(target, anchor) {
636
- if (default_slot)
823
+ if (default_slot) {
637
824
  default_slot.m(target, anchor);
825
+ }
638
826
  current = true;
639
827
  },
640
828
  p(ctx2, dirty) {
@@ -664,11 +852,11 @@ var OverlaysSvelte = (() => {
664
852
  i(local) {
665
853
  if (current)
666
854
  return;
667
- transition_in(default_slot, local);
855
+ transition_in2(default_slot, local);
668
856
  current = true;
669
857
  },
670
858
  o(local) {
671
- transition_out(default_slot, local);
859
+ transition_out2(default_slot, local);
672
860
  current = false;
673
861
  },
674
862
  d(detaching) {
@@ -693,7 +881,7 @@ var OverlaysSvelte = (() => {
693
881
  m(target, anchor) {
694
882
  if (if_block)
695
883
  if_block.m(target, anchor);
696
- insert(target, if_block_anchor, anchor);
884
+ insert2(target, if_block_anchor, anchor);
697
885
  current = true;
698
886
  },
699
887
  p(ctx2, [dirty]) {
@@ -703,53 +891,53 @@ var OverlaysSvelte = (() => {
703
891
  ) {
704
892
  if (if_block) {
705
893
  if_block.p(ctx2, dirty);
706
- if (dirty & 1)
707
- transition_in(if_block, 1);
894
+ if (dirty & 1) {
895
+ transition_in2(if_block, 1);
896
+ }
708
897
  } else {
709
898
  if_block = create_if_block(ctx2);
710
899
  if_block.c();
711
- transition_in(if_block, 1);
900
+ transition_in2(if_block, 1);
712
901
  if_block.m(if_block_anchor.parentNode, if_block_anchor);
713
902
  }
714
903
  } else if (if_block) {
715
- group_outros();
716
- transition_out(if_block, 1, 1, () => {
904
+ group_outros2();
905
+ transition_out2(if_block, 1, 1, () => {
717
906
  if_block = null;
718
907
  });
719
- check_outros();
908
+ check_outros2();
720
909
  }
721
910
  },
722
- i() {
911
+ i(local) {
723
912
  if (current)
724
913
  return;
725
- transition_in(if_block);
914
+ transition_in2(if_block);
726
915
  current = true;
727
916
  },
728
- o() {
729
- transition_out(if_block);
917
+ o(local) {
918
+ transition_out2(if_block);
730
919
  current = false;
731
920
  },
732
921
  d(detaching) {
922
+ if (detaching) {
923
+ detach2(if_block_anchor);
924
+ }
733
925
  if (if_block)
734
926
  if_block.d(detaching);
735
- if (detaching)
736
- detach(if_block_anchor);
737
927
  }
738
928
  };
739
929
  }
740
930
  function instance($$self, $$props, $$invalidate) {
741
931
  let { $$slots: slots = {}, $$scope } = $$props;
742
932
  let { visible = false } = $$props;
743
- const { duration = 0, immediate = true } = getContext(injectOptionsKey) || {};
933
+ const { duration = 0 } = getContext(injectOptionsKey) || {};
744
934
  const { deferred, vanish } = getContext(injectOverlayKey);
745
- async function destroy() {
935
+ deferred == null ? void 0 : deferred.finally(async () => {
746
936
  $$invalidate(0, visible = false);
747
937
  await delay(duration);
748
- vanish == null ? void 0 : vanish();
749
- return Promise.resolve();
750
- }
751
- onMount(() => immediate && $$invalidate(0, visible = true));
752
- deferred == null ? void 0 : deferred.then(destroy).catch(destroy);
938
+ vanish();
939
+ });
940
+ onMount2(() => $$invalidate(0, visible = true));
753
941
  $$self.$$set = ($$props2) => {
754
942
  if ("visible" in $$props2)
755
943
  $$invalidate(0, visible = $$props2.visible);
@@ -758,11 +946,48 @@ var OverlaysSvelte = (() => {
758
946
  };
759
947
  return [visible, $$scope, slots];
760
948
  }
761
- var Overlay = class extends SvelteComponentTyped {
949
+ var _Overlay = class extends SvelteComponent2 {
762
950
  constructor(options) {
763
- super(options);
764
- init(this, options, instance, create_fragment, safe_not_equal, { visible: 0 }, noop);
951
+ super();
952
+ init(this, options, instance, create_fragment, safe_not_equal, { visible: 0 });
765
953
  }
766
954
  };
767
- return __toCommonJS(src_exports);
955
+ var Overlay = _Overlay;
956
+
957
+ // src/internal/index.ts
958
+ var injectOverlayKey2 = Symbol("overlays:svelte");
959
+ var injectOptionsKey2 = Symbol("overlays:options");
960
+
961
+ // src/composable/define.ts
962
+ function useDisclosure(options = {}) {
963
+ setContext(injectOptionsKey2, options);
964
+ return getContext(injectOverlayKey2);
965
+ }
966
+
967
+ // src/define/constructor.ts
968
+ var constructor = createConstructor((Inst, props, options) => {
969
+ const { container, deferred, context: _context = /* @__PURE__ */ new Map() } = options;
970
+ function vanish() {
971
+ app.$destroy();
972
+ container.remove();
973
+ }
974
+ const context2 = new Map([..._context.entries()]);
975
+ context2.set(injectOverlayKey2, {
976
+ confirm: deferred.confirm,
977
+ cannel: deferred.cancel,
978
+ deferred,
979
+ visible: false,
980
+ vanish
981
+ });
982
+ const app = new Inst({
983
+ target: container,
984
+ props,
985
+ context: context2
986
+ });
987
+ });
988
+
989
+ // src/define/index.ts
990
+ var defineOverlay = constructor.define;
991
+ var renderOverlay = constructor.render;
992
+ return __toCommonJS(index_exports);
768
993
  })();