1/// <reference path="../../../../../../../global.d.ts" /> 2/// <reference path="../../../../../../../iu.d.ts" /> 3function _array_like_to_array(arr, len) { 4 if (len == null || len > arr.length) len = arr.length; 5 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; 6 return arr2; 7} 8function _array_with_holes(arr) { 9 if (Array.isArray(arr)) return arr; 10} 11function _assert_this_initialized(self) { 12 if (self === void 0) { 13 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 14 } 15 return self; 16} 17function _class_call_check(instance, Constructor) { 18 if (!(instance instanceof Constructor)) { 19 throw new TypeError("Cannot call a class as a function"); 20 } 21} 22function _defineProperties(target, props) { 23 for(var i = 0; i < props.length; i++){ 24 var descriptor = props[i]; 25 descriptor.enumerable = descriptor.enumerable || false; 26 descriptor.configurable = true; 27 if ("value" in descriptor) descriptor.writable = true; 28 Object.defineProperty(target, descriptor.key, descriptor); 29 } 30} 31function _create_class(Constructor, protoProps, staticProps) { 32 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 33 if (staticProps) _defineProperties(Constructor, staticProps); 34 return Constructor; 35} 36function _define_property(obj, key, value) { 37 if (key in obj) { 38 Object.defineProperty(obj, key, { 39 value: value, 40 enumerable: true, 41 configurable: true, 42 writable: true 43 }); 44 } else { 45 obj[key] = value; 46 } 47 return obj; 48} 49function _get_prototype_of(o) { 50 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) { 51 return o.__proto__ || Object.getPrototypeOf(o); 52 }; 53 return _get_prototype_of(o); 54} 55function _inherits(subClass, superClass) { 56 if (typeof superClass !== "function" && superClass !== null) { 57 throw new TypeError("Super expression must either be null or a function"); 58 } 59 subClass.prototype = Object.create(superClass && superClass.prototype, { 60 constructor: { 61 value: subClass, 62 writable: true, 63 configurable: true 64 } 65 }); 66 if (superClass) _set_prototype_of(subClass, superClass); 67} 68function _instanceof(left, right) { 69 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { 70 return !!right[Symbol.hasInstance](left); 71 } else { 72 return left instanceof right; 73 } 74} 75function _iterable_to_array_limit(arr, i) { 76 var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; 77 if (_i == null) return; 78 var _arr = []; 79 var _n = true; 80 var _d = false; 81 var _s, _e; 82 try { 83 for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){ 84 _arr.push(_s.value); 85 if (i && _arr.length === i) break; 86 } 87 } catch (err) { 88 _d = true; 89 _e = err; 90 } finally{ 91 try { 92 if (!_n && _i["return"] != null) _i["return"](); 93 } finally{ 94 if (_d) throw _e; 95 } 96 } 97 return _arr; 98} 99function _non_iterable_rest() { 100 throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 101} 102function _possible_constructor_return(self, call) { 103 if (call && (_type_of(call) === "object" || typeof call === "function")) { 104 return call; 105 } 106 return _assert_this_initialized(self); 107} 108function _set_prototype_of(o, p) { 109 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) { 110 o.__proto__ = p; 111 return o; 112 }; 113 return _set_prototype_of(o, p); 114} 115function _sliced_to_array(arr, i) { 116 return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest(); 117} 118function _type_of(obj) { 119 "@swc/helpers - typeof"; 120 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; 121} 122function _unsupported_iterable_to_array(o, minLen) { 123 if (!o) return; 124 if (typeof o === "string") return _array_like_to_array(o, minLen); 125 var n = Object.prototype.toString.call(o).slice(8, -1); 126 if (n === "Object" && o.constructor) n = o.constructor.name; 127 if (n === "Map" || n === "Set") return Array.from(n); 128 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen); 129} 130function _is_native_reflect_construct() { 131 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
132 if (Reflect.construct.sham) return false; 133 if (typeof Proxy === "function") return true; 134 try { 135 Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})); 136 return true; 137 } catch (e) { 138 return false; 139 } 140} 141function _create_super(Derived) { 142 var hasNativeReflectConstruct = _is_native_reflect_construct(); 143 return function _createSuperInternal() { 144 var Super = _get_prototype_of(Derived), result; 145 if (hasNativeReflectConstruct) { 146 var NewTarget = _get_prototype_of(this).constructor; 147 result = Reflect.construct(Super, arguments, NewTarget); 148 } else { 149 result = Super.apply(this, arguments); 150 } 151 return _possible_constructor_return(this, result); 152 }; 153} 154import { Controller } from "@hotwired/stimulus"; 155var PENDING_APPLICATION_KEY = "speakerFormPendingApplication"; 156var PENDING_APPLICATION_TTL_MS = 15 * 60 * 1000; 157var _class = /*#__PURE__*/ function(Controller) { 158 "use strict"; 159 _inherits(_class, Controller); 160 var _super = _create_super(_class); 161 function _class() { 162 _class_call_check(this, _class); 163 var _this; 164 _this = _super.apply(this, arguments); 165 _define_property(_assert_this_initialized(_this), "clearFieldError", function(event) { 166 var _field_closest; 167 var field = event.target; 168 if (!(field === null || field === void 0 ? void 0 : field.required) || field.value.trim() === "") { 169 return; 170 } 171 (_field_closest = field.closest(".iu-input")) === null || _field_closest === void 0 ? void 0 : _field_closest.classList.remove("iu-input--error"); 172 }); 173 return _this; 174 } 175 _create_class(_class, [ 176 { 177 key: "connect", 178 value: function connect() { 179 var _this_submitButton; 180 (_this_submitButton = this.submitButton) === null || _this_submitButton === void 0 ? void 0 : _this_submitButton.removeAttribute("disabled"); 181 this.element.addEventListener("input", this.clearFieldError); 182 this.resumePendingApplication(); 183 } 184 }, 185 { 186 key: "disconnect", 187 value: function disconnect() { 188 var _this_submitButton; 189 (_this_submitButton = this.submitButton) === null || _this_submitButton === void 0 ? void 0 : _this_submitButton.setAttribute("disabled", ""); 190 this.element.removeEventListener("input", this.clearFieldError); 191 } 192 }, 193 { 194 key: "submit", 195 value: function submit(event) { 196 event.preventDefault(); 197 if (!this.validate()) { 198 return; 199 } 200 if (!this.isAuthenticatedValue) { 201 this.savePendingApplication(); 202 iu.dlg(null, "login"); 203 return; 204 } 205 this.send(); 206 } 207 }, 208 { 209 key: "submitButton", 210 get: function get() { 211 return this.element.querySelector('[type="submit"]'); 212 } 213 }, 214 { 215 key: "send", 216 value: function send() { 217 var _this = this; 218 iu.ajax({ 219 target: this.submitButton 220 }, this.submitUrlValue, "#".concat(this.element.id), function(data) { 221 if (!(data === null || data === void 0 ? void 0 : data.success)) { 222 return; 223 } 224 _this.clear(); 225 iu.ajax(null, _this.successModalUrlValue); 226 }); 227 } 228 }, 229 { 230 key: "clear", 231 value: function clear() { 232 this.element.reset(); 233 this.element.querySelectorAll(".iu-input--error").forEach(function(field) { 234 return field.classList.remove("iu-input--error"); 235 }); 236 } 237 }, 238 { 239 key: "savePendingApplication", 240 value: function savePendingApplication() { 241 var fields = {}; 242 new FormData(this.element).forEach(function(value, name) { 243 if (typeof value === "string") { 244 fields[name] = value; 245 } 246 }); 247 try { 248 window.sessionStorage.setItem(PENDING_APPLICATION_KEY, JSON.stringify({ 249 expiresAt: Date.now() + PENDING_APPLICATION_TTL_MS, 250 fields: fields 251 })); 252 } catch (e) { 253 // пÑиваÑнÑй Ñежим бÑаÑзеÑа: заÑвка пÑоÑÑо не пеÑеживÑÑ Ð²Ñ Ð¾Ð´ 254 } 255 } 256 }, 257 { 258 key: "takePendingApplication", 259 value: function takePendingApplication() { 260 var raw = null; 261 try { 262 raw = window.sessionStorage.getItem(PENDING_APPLICATION_KEY); 263 window.sessionStorage.removeItem(PENDING_APPLICATION_KEY); 264 } catch (e) { 265 return null; 266 } 267 if (raw === null) { 268 return null; 269 } 270 var pending = null; 271 try { 272 var parsed = JSON.parse(raw); 273 pending = typeof (parsed === null || parsed === void 0 ? void 0 : parsed.expiresAt) === "number" && typeof parsed.fields === "object" ? parsed : null; 274 } catch (e) { 275 return null; 276 } 277 if (pending === null || pending.fields === null || pending.expiresAt <= Date.now()) { 278 return null; 279 } 280 return pending.fields; 281 } 282 }, 283 { 284 key: "resumePendingApplication", 285 value: function resumePendingApplication() { 286 var _this = this; 287 if (!this.isAuthenticatedValue) { 288 return; 289 } 290 var fields = this.takePendingApplication(); 291 if (fields === null) { 292 return; 293 }
294 Object.entries(fields).forEach(function(param) { 295 var _param = _sliced_to_array(param, 2), name = _param[0], value = _param[1]; 296 var field = _this.element.elements.namedItem(name); 297 if (_instanceof(field, HTMLInputElement) || _instanceof(field, HTMLTextAreaElement)) { 298 field.value = value; 299 } 300 }); 301 this.element.scrollIntoView({ 302 block: "center" 303 }); 304 if (this.validate()) { 305 this.send(); 306 } 307 } 308 }, 309 { 310 key: "validate", 311 value: function validate() { 312 var fields = this.element.querySelectorAll("[required]"); 313 var isValid = true; 314 fields.forEach(function(field) { 315 var _field_closest; 316 var hasValue = field.value.trim() !== ""; 317 (_field_closest = field.closest(".iu-input")) === null || _field_closest === void 0 ? void 0 : _field_closest.classList.toggle("iu-input--error", !hasValue); 318 if (!hasValue) { 319 isValid = false; 320 } 321 }); 322 return isValid; 323 } 324 } 325 ]); 326 return _class; 327}(Controller); 328_define_property(_class, "values", { 329 isAuthenticated: Boolean, 330 submitUrl: String, 331 successModalUrl: String 332}); 333/* stimulusFetch: 'lazy' */ export { _class as default };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.