@inploi/plugin-job-alerts 0.3.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { createPlugin } from "@inploi/sdk";
1
+ import { endpoint, typed, createPlugin } from "@inploi/sdk";
2
2
  function invariant(condition, message) {
3
3
  if (condition) {
4
4
  return;
@@ -1814,9 +1814,9 @@ function $d3863c46a17e8a28$var$createFocusScopesStack() {
1814
1814
  }
1815
1815
  };
1816
1816
  }
1817
- function $d3863c46a17e8a28$var$arrayRemove(array, item) {
1817
+ function $d3863c46a17e8a28$var$arrayRemove(array2, item) {
1818
1818
  const updatedArray = [
1819
- ...array
1819
+ ...array2
1820
1820
  ];
1821
1821
  const index2 = updatedArray.indexOf(item);
1822
1822
  if (index2 !== -1)
@@ -4117,21 +4117,25 @@ var applyAttributeToOthers = function(originalTarget, parentNode, markerName, co
4117
4117
  if (elementsToKeep.has(node)) {
4118
4118
  deep(node);
4119
4119
  } else {
4120
- var attr = node.getAttribute(controlAttribute);
4121
- var alreadyHidden = attr !== null && attr !== "false";
4122
- var counterValue = (counterMap.get(node) || 0) + 1;
4123
- var markerValue = (markerCounter.get(node) || 0) + 1;
4124
- counterMap.set(node, counterValue);
4125
- markerCounter.set(node, markerValue);
4126
- hiddenNodes.push(node);
4127
- if (counterValue === 1 && alreadyHidden) {
4128
- uncontrolledNodes.set(node, true);
4129
- }
4130
- if (markerValue === 1) {
4131
- node.setAttribute(markerName, "true");
4132
- }
4133
- if (!alreadyHidden) {
4134
- node.setAttribute(controlAttribute, "true");
4120
+ try {
4121
+ var attr = node.getAttribute(controlAttribute);
4122
+ var alreadyHidden = attr !== null && attr !== "false";
4123
+ var counterValue = (counterMap.get(node) || 0) + 1;
4124
+ var markerValue = (markerCounter.get(node) || 0) + 1;
4125
+ counterMap.set(node, counterValue);
4126
+ markerCounter.set(node, markerValue);
4127
+ hiddenNodes.push(node);
4128
+ if (counterValue === 1 && alreadyHidden) {
4129
+ uncontrolledNodes.set(node, true);
4130
+ }
4131
+ if (markerValue === 1) {
4132
+ node.setAttribute(markerName, "true");
4133
+ }
4134
+ if (!alreadyHidden) {
4135
+ node.setAttribute(controlAttribute, "true");
4136
+ }
4137
+ } catch (e2) {
4138
+ console.error("aria-hidden: cannot operate on ", node, e2);
4135
4139
  }
4136
4140
  }
4137
4141
  });
@@ -4175,7 +4179,7 @@ var hideOthers = function(originalTarget, parentNode, markerName) {
4175
4179
  return null;
4176
4180
  };
4177
4181
  }
4178
- targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll("[aria-live]")));
4182
+ targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll("[aria-live], script")));
4179
4183
  return applyAttributeToOthers(targets, activeParentNode, markerName, "aria-hidden");
4180
4184
  };
4181
4185
  var __assign = function() {
@@ -4254,12 +4258,34 @@ function useCallbackRef(initialValue, callback) {
4254
4258
  ref.callback = callback;
4255
4259
  return ref.facade;
4256
4260
  }
4261
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? y$1 : p$2;
4262
+ var currentValues = /* @__PURE__ */ new WeakMap();
4257
4263
  function useMergeRefs(refs, defaultValue) {
4258
- return useCallbackRef(defaultValue || null, function(newValue) {
4264
+ var callbackRef = useCallbackRef(defaultValue || null, function(newValue) {
4259
4265
  return refs.forEach(function(ref) {
4260
4266
  return assignRef(ref, newValue);
4261
4267
  });
4262
4268
  });
4269
+ useIsomorphicLayoutEffect(function() {
4270
+ var oldValue = currentValues.get(callbackRef);
4271
+ if (oldValue) {
4272
+ var prevRefs_1 = new Set(oldValue);
4273
+ var nextRefs_1 = new Set(refs);
4274
+ var current_1 = callbackRef.current;
4275
+ prevRefs_1.forEach(function(ref) {
4276
+ if (!nextRefs_1.has(ref)) {
4277
+ assignRef(ref, null);
4278
+ }
4279
+ });
4280
+ nextRefs_1.forEach(function(ref) {
4281
+ if (!prevRefs_1.has(ref)) {
4282
+ assignRef(ref, current_1);
4283
+ }
4284
+ });
4285
+ }
4286
+ currentValues.set(callbackRef, refs);
4287
+ }, [refs]);
4288
+ return callbackRef;
4263
4289
  }
4264
4290
  function ItoI(a2) {
4265
4291
  return a2;
@@ -4500,19 +4526,38 @@ var getGapWidth = function(gapMode) {
4500
4526
  };
4501
4527
  };
4502
4528
  var Style = styleSingleton();
4529
+ var lockAttribute = "data-scroll-locked";
4503
4530
  var getStyles = function(_a, allowRelative, gapMode, important) {
4504
4531
  var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
4505
4532
  if (gapMode === void 0) {
4506
4533
  gapMode = "margin";
4507
4534
  }
4508
- return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
4535
+ return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
4509
4536
  allowRelative && "position: relative ".concat(important, ";"),
4510
4537
  gapMode === "margin" && "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
4511
4538
  gapMode === "padding" && "padding-right: ".concat(gap, "px ").concat(important, ";")
4512
- ].filter(Boolean).join(""), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
4539
+ ].filter(Boolean).join(""), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
4513
4540
  };
4514
- var RemoveScrollBar = function(props) {
4515
- var noRelative = props.noRelative, noImportant = props.noImportant, _a = props.gapMode, gapMode = _a === void 0 ? "margin" : _a;
4541
+ var getCurrentUseCounter = function() {
4542
+ var counter = parseInt(document.body.getAttribute(lockAttribute) || "0", 10);
4543
+ return isFinite(counter) ? counter : 0;
4544
+ };
4545
+ var useLockAttribute = function() {
4546
+ p$2(function() {
4547
+ document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
4548
+ return function() {
4549
+ var newCounter = getCurrentUseCounter() - 1;
4550
+ if (newCounter <= 0) {
4551
+ document.body.removeAttribute(lockAttribute);
4552
+ } else {
4553
+ document.body.setAttribute(lockAttribute, newCounter.toString());
4554
+ }
4555
+ };
4556
+ }, []);
4557
+ };
4558
+ var RemoveScrollBar = function(_a) {
4559
+ var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? "margin" : _b;
4560
+ useLockAttribute();
4516
4561
  var gap = F$1(function() {
4517
4562
  return getGapWidth(gapMode);
4518
4563
  }, [gapMode]);
@@ -5014,6 +5059,80 @@ function clsx() {
5014
5059
  (e2 = arguments[f2]) && (t2 = r$1(e2)) && (n2 && (n2 += " "), n2 += t2);
5015
5060
  return n2;
5016
5061
  }
5062
+ const JOB_ALERTS_ELEMENT_ID = "inploi-job-alerts";
5063
+ const JOB_ALERTS_SCOPE_ELEMENT_ID = "ija";
5064
+ const FREQUENCIES = ["INSTANTLY", "DAILY", "WEEKLY", "MONTHLY"];
5065
+ var FALLBACK_PLURAL_ORDER = ["other", "few", "many", "two", "one", "zero"];
5066
+ var createTranslateFunction = ({
5067
+ terms,
5068
+ overrides,
5069
+ locale
5070
+ }) => {
5071
+ const cardinalRules = new Intl.PluralRules(locale);
5072
+ function t2(key, options) {
5073
+ const term = (overrides == null ? void 0 : overrides[key]) ?? terms[key];
5074
+ switch (typeof term) {
5075
+ case "string":
5076
+ return term.replace(/{{(\w+)}}/g, (_2, param) => {
5077
+ var _a;
5078
+ return ((_a = options == null ? void 0 : options[param]) == null ? void 0 : _a.toString()) ?? "";
5079
+ });
5080
+ case "object": {
5081
+ if (typeof (options == null ? void 0 : options.count) !== "number")
5082
+ throw new Error(`Missing count for translation key “${key.toString()}”`);
5083
+ let pluralRule = cardinalRules.select(options.count);
5084
+ if (pluralRule in term === false) {
5085
+ const fallbackRule = FALLBACK_PLURAL_ORDER.find((rule) => rule in term);
5086
+ if (!fallbackRule)
5087
+ throw new Error(`Missing plural rule for translation key “${key.toString()}”`);
5088
+ pluralRule = fallbackRule;
5089
+ }
5090
+ return term[pluralRule].replace(/{{(\w+)}}/g, (_2, param) => {
5091
+ var _a;
5092
+ return ((_a = options == null ? void 0 : options[param]) == null ? void 0 : _a.toString()) ?? "";
5093
+ });
5094
+ }
5095
+ default:
5096
+ throw new Error(`Invalid translation value in dictionary for key “${key.toString()}”.`);
5097
+ }
5098
+ }
5099
+ return t2;
5100
+ };
5101
+ var TranslationContext = G$1(null);
5102
+ var createTranslation = (defaultTerms) => {
5103
+ return {
5104
+ TranslationProvider: ({ terms, children, locale }) => {
5105
+ const t2 = F$1(() => {
5106
+ return createTranslateFunction({ locale, terms: defaultTerms, overrides: terms });
5107
+ }, [terms, locale]);
5108
+ return /* @__PURE__ */ o$2(TranslationContext.Provider, { value: { t: t2, locale }, children });
5109
+ },
5110
+ useTranslation: () => {
5111
+ const context = q$1(TranslationContext);
5112
+ if (context === null)
5113
+ throw new Error("Please wrap useTranslation in a TranslationProvider");
5114
+ return { t: context.t, locale: context.locale };
5115
+ },
5116
+ createTFunction: ({
5117
+ overrides,
5118
+ locale
5119
+ }) => createTranslateFunction({ terms: defaultTerms, overrides, locale })
5120
+ };
5121
+ };
5122
+ const { TranslationProvider, useTranslation, createTFunction } = createTranslation({
5123
+ INSTANTLY: "Instantly",
5124
+ DAILY: "Daily",
5125
+ WEEKLY: "Weekly",
5126
+ MONTHLY: "Monthly",
5127
+ email: "Email",
5128
+ email_placeholder: "jane.doe@example.com",
5129
+ name: "Name",
5130
+ name_placeholder: "Jane Doe",
5131
+ save: "Save",
5132
+ save_alert: "Save Alert",
5133
+ frequency: "Frequency",
5134
+ create_alert: "Create Alert"
5135
+ });
5017
5136
  function i() {
5018
5137
  throw new Error("Cycle detected");
5019
5138
  }
@@ -5560,12 +5679,566 @@ function useSignal(n2) {
5560
5679
  return a(n2);
5561
5680
  }, []);
5562
5681
  }
5563
- const store = {
5682
+ const store$1 = {
5564
5683
  config$: a({ headerText: "", label: "" }),
5565
5684
  filters$: a({})
5566
5685
  };
5567
- const JOB_ALERTS_ELEMENT_ID = "inploi-job-alerts";
5568
- const JOB_ALERTS_SCOPE_ELEMENT_ID = "ija";
5686
+ var store;
5687
+ // @__NO_SIDE_EFFECTS__
5688
+ function getGlobalConfig(config2) {
5689
+ return {
5690
+ lang: (config2 == null ? void 0 : config2.lang) ?? (store == null ? void 0 : store.lang),
5691
+ message: config2 == null ? void 0 : config2.message,
5692
+ abortEarly: (config2 == null ? void 0 : config2.abortEarly) ?? (store == null ? void 0 : store.abortEarly),
5693
+ abortPipeEarly: (config2 == null ? void 0 : config2.abortPipeEarly) ?? (store == null ? void 0 : store.abortPipeEarly)
5694
+ };
5695
+ }
5696
+ var store2;
5697
+ // @__NO_SIDE_EFFECTS__
5698
+ function getGlobalMessage(lang) {
5699
+ return store2 == null ? void 0 : store2.get(lang);
5700
+ }
5701
+ var store3;
5702
+ // @__NO_SIDE_EFFECTS__
5703
+ function getSchemaMessage(lang) {
5704
+ return store3 == null ? void 0 : store3.get(lang);
5705
+ }
5706
+ var store4;
5707
+ // @__NO_SIDE_EFFECTS__
5708
+ function getSpecificMessage(reference, lang) {
5709
+ var _a;
5710
+ return (_a = store4 == null ? void 0 : store4.get(reference)) == null ? void 0 : _a.get(lang);
5711
+ }
5712
+ // @__NO_SIDE_EFFECTS__
5713
+ function _stringify(input) {
5714
+ var _a, _b;
5715
+ const type = typeof input;
5716
+ if (type === "string") {
5717
+ return `"${input}"`;
5718
+ }
5719
+ if (type === "number" || type === "bigint" || type === "boolean") {
5720
+ return `${input}`;
5721
+ }
5722
+ if (type === "object" || type === "function") {
5723
+ return (input && ((_b = (_a = Object.getPrototypeOf(input)) == null ? void 0 : _a.constructor) == null ? void 0 : _b.name)) ?? "null";
5724
+ }
5725
+ return type;
5726
+ }
5727
+ function _addIssue(context, label, dataset, config2, other) {
5728
+ const input = other && "input" in other ? other.input : dataset.value;
5729
+ const expected = (other == null ? void 0 : other.expected) ?? context.expects ?? null;
5730
+ const received = (other == null ? void 0 : other.received) ?? /* @__PURE__ */ _stringify(input);
5731
+ const issue = {
5732
+ kind: context.kind,
5733
+ type: context.type,
5734
+ input,
5735
+ expected,
5736
+ received,
5737
+ message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
5738
+ requirement: context.requirement,
5739
+ path: other == null ? void 0 : other.path,
5740
+ issues: other == null ? void 0 : other.issues,
5741
+ lang: config2.lang,
5742
+ abortEarly: config2.abortEarly,
5743
+ abortPipeEarly: config2.abortPipeEarly
5744
+ };
5745
+ const isSchema = context.kind === "schema";
5746
+ const message2 = (other == null ? void 0 : other.message) ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
5747
+ if (message2 !== void 0) {
5748
+ issue.message = typeof message2 === "function" ? (
5749
+ // @ts-expect-error
5750
+ message2(issue)
5751
+ ) : message2;
5752
+ }
5753
+ if (isSchema) {
5754
+ dataset.typed = false;
5755
+ }
5756
+ if (dataset.issues) {
5757
+ dataset.issues.push(issue);
5758
+ } else {
5759
+ dataset.issues = [issue];
5760
+ }
5761
+ }
5762
+ // @__NO_SIDE_EFFECTS__
5763
+ function _getStandardProps(context) {
5764
+ return {
5765
+ version: 1,
5766
+ vendor: "valibot",
5767
+ validate(value2) {
5768
+ return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig());
5769
+ }
5770
+ };
5771
+ }
5772
+ // @__NO_SIDE_EFFECTS__
5773
+ function _isValidObjectKey(object2, key) {
5774
+ return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
5775
+ }
5776
+ // @__NO_SIDE_EFFECTS__
5777
+ function _joinExpects(values2, separator) {
5778
+ const list = [...new Set(values2)];
5779
+ if (list.length > 1) {
5780
+ return `(${list.join(` ${separator} `)})`;
5781
+ }
5782
+ return list[0] ?? "never";
5783
+ }
5784
+ var EMAIL_REGEX = /^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu;
5785
+ // @__NO_SIDE_EFFECTS__
5786
+ function email(message2) {
5787
+ return {
5788
+ kind: "validation",
5789
+ type: "email",
5790
+ reference: email,
5791
+ expects: null,
5792
+ async: false,
5793
+ requirement: EMAIL_REGEX,
5794
+ message: message2,
5795
+ "~run"(dataset, config2) {
5796
+ if (dataset.typed && !this.requirement.test(dataset.value)) {
5797
+ _addIssue(this, "email", dataset, config2);
5798
+ }
5799
+ return dataset;
5800
+ }
5801
+ };
5802
+ }
5803
+ // @__NO_SIDE_EFFECTS__
5804
+ function getFallback(schema, dataset, config2) {
5805
+ return typeof schema.fallback === "function" ? (
5806
+ // @ts-expect-error
5807
+ schema.fallback(dataset, config2)
5808
+ ) : (
5809
+ // @ts-expect-error
5810
+ schema.fallback
5811
+ );
5812
+ }
5813
+ // @__NO_SIDE_EFFECTS__
5814
+ function getDefault(schema, dataset, config2) {
5815
+ return typeof schema.default === "function" ? (
5816
+ // @ts-expect-error
5817
+ schema.default(dataset, config2)
5818
+ ) : (
5819
+ // @ts-expect-error
5820
+ schema.default
5821
+ );
5822
+ }
5823
+ // @__NO_SIDE_EFFECTS__
5824
+ function array(item, message2) {
5825
+ return {
5826
+ kind: "schema",
5827
+ type: "array",
5828
+ reference: array,
5829
+ expects: "Array",
5830
+ async: false,
5831
+ item,
5832
+ message: message2,
5833
+ get "~standard"() {
5834
+ return /* @__PURE__ */ _getStandardProps(this);
5835
+ },
5836
+ "~run"(dataset, config2) {
5837
+ var _a;
5838
+ const input = dataset.value;
5839
+ if (Array.isArray(input)) {
5840
+ dataset.typed = true;
5841
+ dataset.value = [];
5842
+ for (let key = 0; key < input.length; key++) {
5843
+ const value2 = input[key];
5844
+ const itemDataset = this.item["~run"]({ value: value2 }, config2);
5845
+ if (itemDataset.issues) {
5846
+ const pathItem = {
5847
+ type: "array",
5848
+ origin: "value",
5849
+ input,
5850
+ key,
5851
+ value: value2
5852
+ };
5853
+ for (const issue of itemDataset.issues) {
5854
+ if (issue.path) {
5855
+ issue.path.unshift(pathItem);
5856
+ } else {
5857
+ issue.path = [pathItem];
5858
+ }
5859
+ (_a = dataset.issues) == null ? void 0 : _a.push(issue);
5860
+ }
5861
+ if (!dataset.issues) {
5862
+ dataset.issues = itemDataset.issues;
5863
+ }
5864
+ if (config2.abortEarly) {
5865
+ dataset.typed = false;
5866
+ break;
5867
+ }
5868
+ }
5869
+ if (!itemDataset.typed) {
5870
+ dataset.typed = false;
5871
+ }
5872
+ dataset.value.push(itemDataset.value);
5873
+ }
5874
+ } else {
5875
+ _addIssue(this, "type", dataset, config2);
5876
+ }
5877
+ return dataset;
5878
+ }
5879
+ };
5880
+ }
5881
+ // @__NO_SIDE_EFFECTS__
5882
+ function object(entries2, message2) {
5883
+ return {
5884
+ kind: "schema",
5885
+ type: "object",
5886
+ reference: object,
5887
+ expects: "Object",
5888
+ async: false,
5889
+ entries: entries2,
5890
+ message: message2,
5891
+ get "~standard"() {
5892
+ return /* @__PURE__ */ _getStandardProps(this);
5893
+ },
5894
+ "~run"(dataset, config2) {
5895
+ var _a;
5896
+ const input = dataset.value;
5897
+ if (input && typeof input === "object") {
5898
+ dataset.typed = true;
5899
+ dataset.value = {};
5900
+ for (const key in this.entries) {
5901
+ const valueSchema = this.entries[key];
5902
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && // @ts-expect-error
5903
+ valueSchema.default !== void 0) {
5904
+ const value2 = key in input ? (
5905
+ // @ts-expect-error
5906
+ input[key]
5907
+ ) : /* @__PURE__ */ getDefault(valueSchema);
5908
+ const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
5909
+ if (valueDataset.issues) {
5910
+ const pathItem = {
5911
+ type: "object",
5912
+ origin: "value",
5913
+ input,
5914
+ key,
5915
+ value: value2
5916
+ };
5917
+ for (const issue of valueDataset.issues) {
5918
+ if (issue.path) {
5919
+ issue.path.unshift(pathItem);
5920
+ } else {
5921
+ issue.path = [pathItem];
5922
+ }
5923
+ (_a = dataset.issues) == null ? void 0 : _a.push(issue);
5924
+ }
5925
+ if (!dataset.issues) {
5926
+ dataset.issues = valueDataset.issues;
5927
+ }
5928
+ if (config2.abortEarly) {
5929
+ dataset.typed = false;
5930
+ break;
5931
+ }
5932
+ }
5933
+ if (!valueDataset.typed) {
5934
+ dataset.typed = false;
5935
+ }
5936
+ dataset.value[key] = valueDataset.value;
5937
+ } else if (valueSchema.fallback !== void 0) {
5938
+ dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
5939
+ } else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
5940
+ _addIssue(this, "key", dataset, config2, {
5941
+ input: void 0,
5942
+ expected: `"${key}"`,
5943
+ path: [
5944
+ {
5945
+ type: "object",
5946
+ origin: "key",
5947
+ input,
5948
+ key,
5949
+ // @ts-expect-error
5950
+ value: input[key]
5951
+ }
5952
+ ]
5953
+ });
5954
+ if (config2.abortEarly) {
5955
+ break;
5956
+ }
5957
+ }
5958
+ }
5959
+ } else {
5960
+ _addIssue(this, "type", dataset, config2);
5961
+ }
5962
+ return dataset;
5963
+ }
5964
+ };
5965
+ }
5966
+ // @__NO_SIDE_EFFECTS__
5967
+ function optional(wrapped, default_) {
5968
+ return {
5969
+ kind: "schema",
5970
+ type: "optional",
5971
+ reference: optional,
5972
+ expects: `(${wrapped.expects} | undefined)`,
5973
+ async: false,
5974
+ wrapped,
5975
+ default: default_,
5976
+ get "~standard"() {
5977
+ return /* @__PURE__ */ _getStandardProps(this);
5978
+ },
5979
+ "~run"(dataset, config2) {
5980
+ if (dataset.value === void 0) {
5981
+ if (this.default !== void 0) {
5982
+ dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
5983
+ }
5984
+ if (dataset.value === void 0) {
5985
+ dataset.typed = true;
5986
+ return dataset;
5987
+ }
5988
+ }
5989
+ return this.wrapped["~run"](dataset, config2);
5990
+ }
5991
+ };
5992
+ }
5993
+ // @__NO_SIDE_EFFECTS__
5994
+ function picklist(options, message2) {
5995
+ return {
5996
+ kind: "schema",
5997
+ type: "picklist",
5998
+ reference: picklist,
5999
+ expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
6000
+ async: false,
6001
+ options,
6002
+ message: message2,
6003
+ get "~standard"() {
6004
+ return /* @__PURE__ */ _getStandardProps(this);
6005
+ },
6006
+ "~run"(dataset, config2) {
6007
+ if (this.options.includes(dataset.value)) {
6008
+ dataset.typed = true;
6009
+ } else {
6010
+ _addIssue(this, "type", dataset, config2);
6011
+ }
6012
+ return dataset;
6013
+ }
6014
+ };
6015
+ }
6016
+ // @__NO_SIDE_EFFECTS__
6017
+ function record(key, value2, message2) {
6018
+ return {
6019
+ kind: "schema",
6020
+ type: "record",
6021
+ reference: record,
6022
+ expects: "Object",
6023
+ async: false,
6024
+ key,
6025
+ value: value2,
6026
+ message: message2,
6027
+ get "~standard"() {
6028
+ return /* @__PURE__ */ _getStandardProps(this);
6029
+ },
6030
+ "~run"(dataset, config2) {
6031
+ var _a, _b;
6032
+ const input = dataset.value;
6033
+ if (input && typeof input === "object") {
6034
+ dataset.typed = true;
6035
+ dataset.value = {};
6036
+ for (const entryKey in input) {
6037
+ if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
6038
+ const entryValue = input[entryKey];
6039
+ const keyDataset = this.key["~run"]({ value: entryKey }, config2);
6040
+ if (keyDataset.issues) {
6041
+ const pathItem = {
6042
+ type: "object",
6043
+ origin: "key",
6044
+ input,
6045
+ key: entryKey,
6046
+ value: entryValue
6047
+ };
6048
+ for (const issue of keyDataset.issues) {
6049
+ issue.path = [pathItem];
6050
+ (_a = dataset.issues) == null ? void 0 : _a.push(issue);
6051
+ }
6052
+ if (!dataset.issues) {
6053
+ dataset.issues = keyDataset.issues;
6054
+ }
6055
+ if (config2.abortEarly) {
6056
+ dataset.typed = false;
6057
+ break;
6058
+ }
6059
+ }
6060
+ const valueDataset = this.value["~run"](
6061
+ { value: entryValue },
6062
+ config2
6063
+ );
6064
+ if (valueDataset.issues) {
6065
+ const pathItem = {
6066
+ type: "object",
6067
+ origin: "value",
6068
+ input,
6069
+ key: entryKey,
6070
+ value: entryValue
6071
+ };
6072
+ for (const issue of valueDataset.issues) {
6073
+ if (issue.path) {
6074
+ issue.path.unshift(pathItem);
6075
+ } else {
6076
+ issue.path = [pathItem];
6077
+ }
6078
+ (_b = dataset.issues) == null ? void 0 : _b.push(issue);
6079
+ }
6080
+ if (!dataset.issues) {
6081
+ dataset.issues = valueDataset.issues;
6082
+ }
6083
+ if (config2.abortEarly) {
6084
+ dataset.typed = false;
6085
+ break;
6086
+ }
6087
+ }
6088
+ if (!keyDataset.typed || !valueDataset.typed) {
6089
+ dataset.typed = false;
6090
+ }
6091
+ if (keyDataset.typed) {
6092
+ dataset.value[keyDataset.value] = valueDataset.value;
6093
+ }
6094
+ }
6095
+ }
6096
+ } else {
6097
+ _addIssue(this, "type", dataset, config2);
6098
+ }
6099
+ return dataset;
6100
+ }
6101
+ };
6102
+ }
6103
+ // @__NO_SIDE_EFFECTS__
6104
+ function string(message2) {
6105
+ return {
6106
+ kind: "schema",
6107
+ type: "string",
6108
+ reference: string,
6109
+ expects: "string",
6110
+ async: false,
6111
+ message: message2,
6112
+ get "~standard"() {
6113
+ return /* @__PURE__ */ _getStandardProps(this);
6114
+ },
6115
+ "~run"(dataset, config2) {
6116
+ if (typeof dataset.value === "string") {
6117
+ dataset.typed = true;
6118
+ } else {
6119
+ _addIssue(this, "type", dataset, config2);
6120
+ }
6121
+ return dataset;
6122
+ }
6123
+ };
6124
+ }
6125
+ // @__NO_SIDE_EFFECTS__
6126
+ function _subIssues(datasets) {
6127
+ let issues;
6128
+ if (datasets) {
6129
+ for (const dataset of datasets) {
6130
+ if (issues) {
6131
+ issues.push(...dataset.issues);
6132
+ } else {
6133
+ issues = dataset.issues;
6134
+ }
6135
+ }
6136
+ }
6137
+ return issues;
6138
+ }
6139
+ // @__NO_SIDE_EFFECTS__
6140
+ function union(options, message2) {
6141
+ return {
6142
+ kind: "schema",
6143
+ type: "union",
6144
+ reference: union,
6145
+ expects: /* @__PURE__ */ _joinExpects(
6146
+ options.map((option) => option.expects),
6147
+ "|"
6148
+ ),
6149
+ async: false,
6150
+ options,
6151
+ message: message2,
6152
+ get "~standard"() {
6153
+ return /* @__PURE__ */ _getStandardProps(this);
6154
+ },
6155
+ "~run"(dataset, config2) {
6156
+ let validDataset;
6157
+ let typedDatasets;
6158
+ let untypedDatasets;
6159
+ for (const schema of this.options) {
6160
+ const optionDataset = schema["~run"]({ value: dataset.value }, config2);
6161
+ if (optionDataset.typed) {
6162
+ if (optionDataset.issues) {
6163
+ if (typedDatasets) {
6164
+ typedDatasets.push(optionDataset);
6165
+ } else {
6166
+ typedDatasets = [optionDataset];
6167
+ }
6168
+ } else {
6169
+ validDataset = optionDataset;
6170
+ break;
6171
+ }
6172
+ } else {
6173
+ if (untypedDatasets) {
6174
+ untypedDatasets.push(optionDataset);
6175
+ } else {
6176
+ untypedDatasets = [optionDataset];
6177
+ }
6178
+ }
6179
+ }
6180
+ if (validDataset) {
6181
+ return validDataset;
6182
+ }
6183
+ if (typedDatasets) {
6184
+ if (typedDatasets.length === 1) {
6185
+ return typedDatasets[0];
6186
+ }
6187
+ _addIssue(this, "type", dataset, config2, {
6188
+ issues: /* @__PURE__ */ _subIssues(typedDatasets)
6189
+ });
6190
+ dataset.typed = true;
6191
+ } else if ((untypedDatasets == null ? void 0 : untypedDatasets.length) === 1) {
6192
+ return untypedDatasets[0];
6193
+ } else {
6194
+ _addIssue(this, "type", dataset, config2, {
6195
+ issues: /* @__PURE__ */ _subIssues(untypedDatasets)
6196
+ });
6197
+ }
6198
+ return dataset;
6199
+ }
6200
+ };
6201
+ }
6202
+ // @__NO_SIDE_EFFECTS__
6203
+ function pipe(...pipe2) {
6204
+ return {
6205
+ ...pipe2[0],
6206
+ pipe: pipe2,
6207
+ get "~standard"() {
6208
+ return /* @__PURE__ */ _getStandardProps(this);
6209
+ },
6210
+ "~run"(dataset, config2) {
6211
+ for (const item of pipe2) {
6212
+ if (item.kind !== "metadata") {
6213
+ if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
6214
+ dataset.typed = false;
6215
+ break;
6216
+ }
6217
+ if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) {
6218
+ dataset = item["~run"](dataset, config2);
6219
+ }
6220
+ }
6221
+ }
6222
+ return dataset;
6223
+ }
6224
+ };
6225
+ }
6226
+ const saveSearchEndpoint = endpoint({
6227
+ pathname: "/search/save",
6228
+ method: "POST",
6229
+ schema: {
6230
+ response: typed(),
6231
+ body: /* @__PURE__ */ object({
6232
+ contact: /* @__PURE__ */ object({
6233
+ email: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ string(), /* @__PURE__ */ email()),
6234
+ first_name: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
6235
+ last_name: /* @__PURE__ */ optional(/* @__PURE__ */ string())
6236
+ }),
6237
+ alerts: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ string(), /* @__PURE__ */ picklist(FREQUENCIES)),
6238
+ filters: /* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ array(/* @__PURE__ */ string())]))
6239
+ })
6240
+ }
6241
+ });
5569
6242
  var COLOR_SHADES = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
5570
6243
  var OKLCH_PRESETS = {
5571
6244
  light: {
@@ -5776,17 +6449,18 @@ const JobAlertsButton = k(
5776
6449
  children: [
5777
6450
  /* @__PURE__ */ o$2(Icon, { class: "flex-none", name: "bell" }),
5778
6451
  " ",
5779
- /* @__PURE__ */ o$2("span", { class: "min-w-0 truncate text-center", children: store.config$.value.label })
6452
+ /* @__PURE__ */ o$2("span", { class: "min-w-0 truncate text-center", children: store$1.config$.value.label })
5780
6453
  ]
5781
6454
  }
5782
6455
  )
5783
6456
  );
5784
- const PopoverHeader = () => /* @__PURE__ */ o$2("p", { class: "text-neutral-11 px-2 pb-4 pt-1 text-sm", children: store.config$.value.headerText });
6457
+ const PopoverHeader = () => /* @__PURE__ */ o$2("p", { class: "text-neutral-11 px-2 pb-4 pt-1 text-sm", children: store$1.config$.value.headerText });
5785
6458
  function noop() {
5786
6459
  }
5787
- const JobAlerts = ({ theme, apiClient, logger }) => {
6460
+ const JobAlerts = ({ theme, rpcClient, logger }) => {
5788
6461
  const [formState, setFormState] = h("idle");
5789
6462
  const [error, setError] = h();
6463
+ const { t: t2 } = useTranslation();
5790
6464
  return /* @__PURE__ */ o$2("div", { id: "ija", children: /* @__PURE__ */ o$2("div", { class: getThemeVariants(theme).join(" "), children: /* @__PURE__ */ o$2($cb5cc270b50c6fcd$export$be92b6f5f03c0fe9, { children: [
5791
6465
  /* @__PURE__ */ o$2($cb5cc270b50c6fcd$export$41fb9f06171c75f4, { asChild: true, children: /* @__PURE__ */ o$2(JobAlertsButton, {}) }),
5792
6466
  /* @__PURE__ */ o$2($cb5cc270b50c6fcd$export$602eac185826482c, { children: /* @__PURE__ */ o$2("div", { id: "ija", children: /* @__PURE__ */ o$2("div", { class: clsx("absolute isolate z-50", getThemeVariants(theme).join(" ")), children: /* @__PURE__ */ o$2(
@@ -5813,17 +6487,16 @@ const JobAlerts = ({ theme, apiClient, logger }) => {
5813
6487
  await Promise.all([
5814
6488
  // waits for at least 1 second
5815
6489
  new Promise((resolve) => setTimeout(resolve, 1e3)),
5816
- apiClient.fetch("/search/save", {
5817
- method: "POST",
5818
- body: JSON.stringify({
6490
+ rpcClient.request(saveSearchEndpoint, {
6491
+ body: {
5819
6492
  contact: {
5820
6493
  email: (_b = formData.get("email")) == null ? void 0 : _b.toString(),
5821
6494
  first_name: firstName,
5822
6495
  last_name: lastName
5823
6496
  },
5824
6497
  alerts: (_c = formData.get("frequency")) == null ? void 0 : _c.toString(),
5825
- filters: store.filters$.peek()
5826
- })
6498
+ filters: store$1.filters$.peek()
6499
+ }
5827
6500
  })
5828
6501
  ]).then(async () => {
5829
6502
  setFormState("success");
@@ -5839,7 +6512,7 @@ const JobAlerts = ({ theme, apiClient, logger }) => {
5839
6512
  children: [
5840
6513
  /* @__PURE__ */ o$2("div", { children: [
5841
6514
  /* @__PURE__ */ o$2("fieldset", { class: "fieldset relative focus-within:z-10", children: [
5842
- /* @__PURE__ */ o$2("label", { class: "sr-only", htmlFor: "ija-email", children: "Email" }),
6515
+ /* @__PURE__ */ o$2("label", { class: "sr-only", htmlFor: "ija-email", children: t2("email") }),
5843
6516
  /* @__PURE__ */ o$2(
5844
6517
  "input",
5845
6518
  {
@@ -5848,14 +6521,14 @@ const JobAlerts = ({ theme, apiClient, logger }) => {
5848
6521
  class: inputClass,
5849
6522
  disabled: formState === "loading",
5850
6523
  id: "ija-email",
5851
- placeholder: "Email",
6524
+ placeholder: t2("email_placeholder"),
5852
6525
  type: "email",
5853
6526
  required: true
5854
6527
  }
5855
6528
  )
5856
6529
  ] }),
5857
6530
  /* @__PURE__ */ o$2("fieldset", { class: "fieldset relative focus-within:z-10", children: [
5858
- /* @__PURE__ */ o$2("label", { class: "sr-only", htmlFor: "ija-name", children: "Name" }),
6531
+ /* @__PURE__ */ o$2("label", { class: "sr-only", htmlFor: "ija-name", children: t2("name") }),
5859
6532
  /* @__PURE__ */ o$2(
5860
6533
  "input",
5861
6534
  {
@@ -5865,12 +6538,12 @@ const JobAlerts = ({ theme, apiClient, logger }) => {
5865
6538
  autocomplete: "name",
5866
6539
  class: inputClass,
5867
6540
  id: "ija-name",
5868
- placeholder: "Full Name"
6541
+ placeholder: t2("name_placeholder")
5869
6542
  }
5870
6543
  )
5871
6544
  ] }),
5872
6545
  /* @__PURE__ */ o$2("fieldset", { class: "fieldset relative focus-within:z-10", children: [
5873
- /* @__PURE__ */ o$2("label", { class: "sr-only", htmlFor: "ija-frequency", children: "Frequency" }),
6546
+ /* @__PURE__ */ o$2("label", { class: "sr-only", htmlFor: "ija-frequency", children: t2("frequency") }),
5874
6547
  /* @__PURE__ */ o$2(
5875
6548
  "select",
5876
6549
  {
@@ -5879,12 +6552,7 @@ const JobAlerts = ({ theme, apiClient, logger }) => {
5879
6552
  id: "ija-frequency",
5880
6553
  defaultValue: "WEEKLY",
5881
6554
  name: "frequency",
5882
- children: [
5883
- /* @__PURE__ */ o$2("option", { value: "INSTANTLY", children: "Instantly" }),
5884
- /* @__PURE__ */ o$2("option", { value: "DAILY", children: "Daily" }),
5885
- /* @__PURE__ */ o$2("option", { value: "WEEKLY", children: "Weekly" }),
5886
- /* @__PURE__ */ o$2("option", { value: "MONTHLY", children: "Monthly" })
5887
- ]
6555
+ children: FREQUENCIES.map((frequency) => /* @__PURE__ */ o$2("option", { value: frequency, children: t2(frequency) }))
5888
6556
  }
5889
6557
  ),
5890
6558
  /* @__PURE__ */ o$2("div", { class: "text-neutral-10 absolute bottom-0 right-0 top-0 flex items-center p-1", "aria-hidden": true, children: /* @__PURE__ */ o$2(Icon, { name: "chevron-up-down" }) })
@@ -5901,7 +6569,7 @@ const JobAlerts = ({ theme, apiClient, logger }) => {
5901
6569
  {
5902
6570
  "data-state": formState,
5903
6571
  class: "ease-expo-out duration-medium col-span-full row-span-full text-base opacity-0 transition-all data-[state=loading]:-translate-y-full data-[state=success]:translate-y-full data-[state=idle]:opacity-100",
5904
- children: "Create Alert"
6572
+ children: t2("create_alert")
5905
6573
  }
5906
6574
  ),
5907
6575
  /* @__PURE__ */ o$2(
@@ -5961,20 +6629,27 @@ const createJobAlertsDomManager = () => {
5961
6629
  };
5962
6630
  };
5963
6631
  const dom = createJobAlertsDomManager();
5964
- const jobAlertsPlugin = () => createPlugin(({ apiClient, logger, analytics }) => {
6632
+ const jobAlertsPlugin = () => createPlugin(({ rpcClient, logger, analytics }) => {
5965
6633
  let prerendered = false;
5966
6634
  const App = ({ params }) => {
5967
- return y$3(k$3, {}, [
6635
+ return y$3(
6636
+ TranslationProvider,
6637
+ {
6638
+ terms: params.terms,
6639
+ locale: void 0
6640
+ },
5968
6641
  [
5969
- y$3("style", { id: "inploi-job-alerts-styles" }, tailwind),
5970
- y$3("style", { id: "inploi-job-search-theme" }, generateColorThemeCss(params.theme))
5971
- ],
5972
- y$3(IconSpritesheet, { theme: params.theme }),
5973
- y$3(JobAlerts, { theme: params.theme, apiClient, logger, analytics })
5974
- ]);
6642
+ [
6643
+ y$3("style", { id: "inploi-job-alerts-styles" }, tailwind),
6644
+ y$3("style", { id: "inploi-job-search-theme" }, generateColorThemeCss(params.theme))
6645
+ ],
6646
+ y$3(IconSpritesheet, { theme: params.theme }),
6647
+ y$3(JobAlerts, { theme: params.theme, rpcClient, logger, analytics })
6648
+ ]
6649
+ );
5975
6650
  };
5976
- const setFilters = (newFilters) => store.filters$.value = newFilters;
5977
- const setConfig = (newConfig) => store.config$.value = typeof newConfig === "function" ? newConfig(store.config$.peek()) : newConfig;
6651
+ const setFilters = (newFilters) => store$1.filters$.value = newFilters;
6652
+ const setConfig = (newConfig) => store$1.config$.value = typeof newConfig === "function" ? newConfig(store$1.config$.peek()) : newConfig;
5978
6653
  return {
5979
6654
  /** Returns a string with the initial rendering state of the UI.
5980
6655
  * Useful when server-side rendering to avoid CLS.
@@ -5998,7 +6673,8 @@ const jobAlertsPlugin = () => createPlugin(({ apiClient, logger, analytics }) =>
5998
6673
  fn2(y$3(App, { params }), dom.getRenderTargetElement());
5999
6674
  },
6000
6675
  setFilters,
6001
- setConfig
6676
+ setConfig,
6677
+ "~brand": "@inploi/plugin-job-alerts"
6002
6678
  };
6003
6679
  });
6004
6680
  export {