@copart/ops-tool-kit 1.13.0-beta.30 → 1.13.0-beta.32

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.
@@ -49,7 +49,7 @@ var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
49
49
  var ReactRouterDOM__namespace = /*#__PURE__*/_interopNamespace(ReactRouterDOM);
50
50
 
51
51
  const name$1 = "@copart/ops-tool-kit";
52
- const version$3 = "1.13.0-beta.30";
52
+ const version$3 = "1.13.0-beta.32";
53
53
  const main$1 = "dist/ops-tool-kit.js";
54
54
  const style = "dist/ops-tool-kit.css";
55
55
  const files = [
@@ -2847,266 +2847,6 @@ var createOpsStorage = function createOpsStorage() {
2847
2847
  var storage$2 = createOpsStorage();
2848
2848
  global.storage = storage$2;
2849
2849
 
2850
- var DEFAULT_BREADCRUMBS_CONTEXT = {
2851
- error: 'You tried to use Breadcrumbs outside of its context.'
2852
- };
2853
-
2854
- var css_248z$r = ".utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Breadcrumbs {\n /* height: 36px;\n background: #3c4656; */\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--crumbs {\n display: flex;\n}\n\n#notCrumbs {\n height: 100%;\n margin-right: 12px;\n display: flex;\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb {\n cursor: pointer;\n height: 100%;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 16px;\n font-weight: 300;\n letter-spacing: 0;\n /* transition: all 0.2s; */\n position: relative;\n top: -2px;\n color: rgba(255, 255, 255, 0.8);\n grid-gap: 6px;\n gap: 6px;\n margin-left: 5px;\n opacity: 1;\n}\n\n@-webkit-keyframes utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--fadeIn {\n 0% {\n opacity: 0;\n -webkit-transform: translateX(-6px);\n transform: translateX(-6px);\n /* transform: scale(0.9); */\n }\n 100% {\n opacity: 1;\n -webkit-transform: translateX(0px);\n transform: translateX(0px);\n /* transform: scale(1); */\n }\n}\n\n@keyframes utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--fadeIn {\n 0% {\n opacity: 0;\n -webkit-transform: translateX(-6px);\n transform: translateX(-6px);\n /* transform: scale(0.9); */\n }\n 100% {\n opacity: 1;\n -webkit-transform: translateX(0px);\n transform: translateX(0px);\n /* transform: scale(1); */\n }\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb {\n -webkit-animation-name: utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--fadeIn;\n animation-name: utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--fadeIn;\n -webkit-animation-duration: 0.2s;\n animation-duration: 0.2s;\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb::before {\n content: '\\f054';\n color: rgba(255, 255, 255, 0.4);\n display: inline-block;\n font-family: 'Font Awesome 6 Pro';\n font-size: 16px;\n margin: 0 6px;\n position: relative;\n top: 2px;\n}\n\n/* .Crumb:first-of-type {\n margin-left: 12px;\n font-weight: 400;\n} */\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb:hover {\n /* background: rgba(0, 0, 0, 0.15); */\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb:not(:last-of-type):not(:hover) {\n /* opacity: 0.75; */\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb:last-of-type {\n font-weight: 700;\n opacity: 1;\n color: rgba(255, 255, 255, 1);\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb:last-of-type::before {\n font-weight: 300;\n /* opacity: 0.8; */\n}\n\n/* .crumbSpacer {} */\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--crumbs {\n /* margin: 10px; */\n flex-grow: 2;\n font-size: 14px;\n cursor: pointer;\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--notCrumbs {\n height: 100%;\n display: flex;\n margin-right: 0px !important;\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--entityIndicator {\n height: 100%;\n display: flex;\n margin-right: 0px !important;\n}";
2855
- styleInject(css_248z$r);
2856
-
2857
- var Context = createContext(DEFAULT_BREADCRUMBS_CONTEXT);
2858
- var withBreadcrumbs = function withBreadcrumbs(Comp) {
2859
- return /*#__PURE__*/function (_React$Component) {
2860
- function _class() {
2861
- _classCallCheck$3(this, _class);
2862
- return _callSuper(this, _class, arguments);
2863
- }
2864
- _inherits$2(_class, _React$Component);
2865
- return _createClass$2(_class, [{
2866
- key: "render",
2867
- value: function render() {
2868
- var _this = this;
2869
- return /*#__PURE__*/React__namespace.createElement(Context.Consumer, null, function (breadcrumbs) {
2870
- return /*#__PURE__*/React__namespace.createElement(Comp, _extends$1({}, _this.props, {
2871
- breadcrumbs: breadcrumbs
2872
- }));
2873
- });
2874
- }
2875
- }]);
2876
- }(React__namespace.Component);
2877
- };
2878
- var Breadcrumbs = withBreadcrumbs(index$1.purist(function (props) {
2879
- var _props$appTile, _props$appTile3;
2880
- return /*#__PURE__*/React__namespace.createElement("div", {
2881
- className: "utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Breadcrumbs"
2882
- }, /*#__PURE__*/React__namespace.createElement("div", {
2883
- className: "utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--crumbs"
2884
- }, props !== null && props !== void 0 && (_props$appTile = props.appTile) !== null && _props$appTile !== void 0 && _props$appTile.title ? /*#__PURE__*/React__namespace.createElement("a", {
2885
- onClick: function onClick() {
2886
- var _props$appTile2;
2887
- var isEmbedded = window.location.pathname.includes('embedded');
2888
- props.history.push(isEmbedded && (_props$appTile2 = props.appTile) !== null && _props$appTile2 !== void 0 && _props$appTile2.path ? props.appTile.path : '/');
2889
- },
2890
- className: "utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb"
2891
- }, props === null || props === void 0 ? void 0 : (_props$appTile3 = props.appTile) === null || _props$appTile3 === void 0 ? void 0 : _props$appTile3.title) : null, props.breadcrumbs.crumbs.map(function (crumb, idx) {
2892
- return /*#__PURE__*/React__namespace.createElement("a", {
2893
- onClick: function onClick() {
2894
- return props.history.push(crumb.to);
2895
- },
2896
- className: "utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb",
2897
- key: crumb.crumbId != null ? crumb.crumbId : idx
2898
- }, crumb.children);
2899
- }, this)), /*#__PURE__*/React__namespace.createElement("div", {
2900
- id: "notCrumbs",
2901
- className: "utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--notCrumbs"
2902
- }), /*#__PURE__*/React__namespace.createElement("div", {
2903
- id: "entityIndicator",
2904
- className: "utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--entityIndicator"
2905
- }));
2906
- }));
2907
-
2908
- var url = '_~getRandomVcryp0123456789bfhijklqsuvwxzABCDEFGHIJKLMNOPQSTUWXYZ';
2909
- function random(size) {
2910
- var result = [];
2911
- while (0 < size--) {
2912
- result.push(Math.floor(Math.random() * 256));
2913
- }
2914
- return result;
2915
- }
2916
- var nonSecure = function (size) {
2917
- size = size || 21;
2918
- var id = '';
2919
- var bytes = random(size);
2920
- while (0 < size--) {
2921
- id += url[bytes[size] & 63];
2922
- }
2923
- return id;
2924
- };
2925
-
2926
- var BreadcrumbsProvider = /*#__PURE__*/function (_React$Component) {
2927
- function BreadcrumbsProvider(props) {
2928
- var _this;
2929
- _classCallCheck$3(this, BreadcrumbsProvider);
2930
- _this = _callSuper(this, BreadcrumbsProvider, [props]);
2931
- _defineProperty$2(_this, "crumbIds", new Set());
2932
- _this.state = function () {
2933
- var self = _this;
2934
- return {
2935
- crumbs: [],
2936
- addCrumb: function addCrumb(props, crumbId, oldId) {
2937
- var newCrumb = _objectSpread2(_objectSpread2({}, props), {}, {
2938
- crumbId: crumbId
2939
- });
2940
- self.setState(function (state) {
2941
- return {
2942
- crumbs: oldId ? state.crumbs.map(function (crumb) {
2943
- return crumb.crumbId === oldId ? newCrumb : crumb;
2944
- }) : [].concat(_toConsumableArray(state.crumbs), [newCrumb])
2945
- };
2946
- });
2947
- },
2948
- removeCrumb: function removeCrumb(crumbId) {
2949
- // Filter out the specific crumb by its crumbId.
2950
- self.setState(function (state) {
2951
- return {
2952
- crumbs: state.crumbs.filter(function (crumb) {
2953
- return crumb.crumbId !== crumbId;
2954
- })
2955
- };
2956
- });
2957
- }
2958
- };
2959
- }();
2960
- return _this;
2961
- }
2962
- _inherits$2(BreadcrumbsProvider, _React$Component);
2963
- return _createClass$2(BreadcrumbsProvider, [{
2964
- key: "render",
2965
- value: function render() {
2966
- return /*#__PURE__*/React__namespace.createElement(Context.Provider, {
2967
- value: this.state
2968
- }, this.props.children);
2969
- }
2970
- }]);
2971
- }(React__namespace.Component);
2972
-
2973
- var _class;
2974
- var _excluded$6 = ["breadcrumbs"];
2975
- var getCrumbProps = function getCrumbProps(props) {
2976
- props.breadcrumbs;
2977
- var crumbProps = _objectWithoutProperties(props, _excluded$6);
2978
- return crumbProps;
2979
- };
2980
-
2981
- // Flatten children to a comparable text label. Children may be a React element
2982
- // (e.g. <span onClick>Label</span>) whose internal fiber refs (`_owner`) are
2983
- // circular, so it must never be passed to JSON.stringify.
2984
- var _crumbLabel = function crumbLabel(children) {
2985
- if (children == null) return '';
2986
- if (typeof children === 'string' || typeof children === 'number') return String(children);
2987
- if (Array.isArray(children)) return children.map(_crumbLabel).join('');
2988
- if (React__namespace.isValidElement(children) && children.props && children.props.children != null) {
2989
- return _crumbLabel(children.props.children);
2990
- }
2991
- return '';
2992
- };
2993
-
2994
- // Safe replacement for the old JSON.stringify diff, which threw
2995
- // "Converting circular structure to JSON" whenever children was a React element.
2996
- var crumbPropsChanged = function crumbPropsChanged(oldProps, newProps) {
2997
- var keys = new Set([].concat(_toConsumableArray(Object.keys(oldProps)), _toConsumableArray(Object.keys(newProps))));
2998
- var _iterator = _createForOfIteratorHelper(keys),
2999
- _step;
3000
- try {
3001
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
3002
- var key = _step.value;
3003
- if (key === 'children') {
3004
- if (_crumbLabel(oldProps.children) !== _crumbLabel(newProps.children)) return true;
3005
- } else if (oldProps[key] !== newProps[key]) {
3006
- return true;
3007
- }
3008
- }
3009
- } catch (err) {
3010
- _iterator.e(err);
3011
- } finally {
3012
- _iterator.f();
3013
- }
3014
- return false;
3015
- };
3016
- var Crumb$1 = withBreadcrumbs(_class = /*#__PURE__*/function (_React$Component) {
3017
- function Crumb() {
3018
- var _this;
3019
- _classCallCheck$3(this, Crumb);
3020
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3021
- args[_key] = arguments[_key];
3022
- }
3023
- _this = _callSuper(this, Crumb, [].concat(args));
3024
- _defineProperty$2(_this, "crumbId", nonSecure());
3025
- return _this;
3026
- }
3027
- _inherits$2(Crumb, _React$Component);
3028
- return _createClass$2(Crumb, [{
3029
- key: "componentDidMount",
3030
- value: function componentDidMount() {
3031
- var crumbProps = getCrumbProps(this.props);
3032
- this.props.breadcrumbs.addCrumb(crumbProps, this.crumbId);
3033
- }
3034
- }, {
3035
- key: "shouldComponentUpdate",
3036
- value: function shouldComponentUpdate(nextProps) {
3037
- var oldProps = getCrumbProps(this.props);
3038
- var newProps = getCrumbProps(nextProps);
3039
- return crumbPropsChanged(oldProps, newProps);
3040
- }
3041
- }, {
3042
- key: "componentDidUpdate",
3043
- value: function componentDidUpdate() {
3044
- var oldId = this.crumbId;
3045
- this.crumbId = nonSecure();
3046
- var crumbProps = getCrumbProps(this.props);
3047
- this.props.breadcrumbs.addCrumb(crumbProps, this.crumbId, oldId);
3048
- }
3049
- }, {
3050
- key: "componentWillUnmount",
3051
- value: function componentWillUnmount() {
3052
- this.props.breadcrumbs.removeCrumb(this.crumbId);
3053
- }
3054
- }, {
3055
- key: "render",
3056
- value: function render() {
3057
- return null;
3058
- }
3059
- }]);
3060
- }(React__namespace.Component)) || _class;
3061
- Crumb$1.defaultProps = {
3062
- breadcrumbs: {
3063
- addCrumb: function addCrumb() {},
3064
- removeCrumb: function removeCrumb() {},
3065
- crumbs: []
3066
- }
3067
- };
3068
-
3069
- /**
3070
- * Copyright (c) 2013-present, Facebook, Inc.
3071
- *
3072
- * This source code is licensed under the MIT license found in the
3073
- * LICENSE file in the root directory of this source tree.
3074
- */
3075
-
3076
- /**
3077
- * Use invariant() to assert state which your program assumes to be true.
3078
- *
3079
- * Provide sprintf-style format (only %s is supported) and arguments
3080
- * to provide information about what broke and what you were
3081
- * expecting.
3082
- *
3083
- * The invariant message will be stripped in production, but the invariant
3084
- * will remain to ensure logic does not differ in production.
3085
- */
3086
- var invariant = function (condition, format, a, b, c, d, e, f) {
3087
- if (process.env.NODE_ENV !== 'production') {
3088
- if (format === undefined) {
3089
- throw new Error('invariant requires an error message argument');
3090
- }
3091
- }
3092
- if (!condition) {
3093
- var error;
3094
- if (format === undefined) {
3095
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
3096
- } else {
3097
- var args = [a, b, c, d, e, f];
3098
- var argIndex = 0;
3099
- error = new Error(format.replace(/%s/g, function () {
3100
- return args[argIndex++];
3101
- }));
3102
- error.name = 'Invariant Violation';
3103
- }
3104
- error.framesToPop = 1; // we don't care about invariant's own frame
3105
- throw error;
3106
- }
3107
- };
3108
- var browser$2 = invariant;
3109
-
3110
2850
  var bind$4 = function bind(fn, thisArg) {
3111
2851
  return function wrap() {
3112
2852
  var args = new Array(arguments.length);
@@ -4294,6 +4034,24 @@ axios_1.default = _default;
4294
4034
 
4295
4035
  var axios = axios_1;
4296
4036
 
4037
+ var url = '_~getRandomVcryp0123456789bfhijklqsuvwxzABCDEFGHIJKLMNOPQSTUWXYZ';
4038
+ function random(size) {
4039
+ var result = [];
4040
+ while (0 < size--) {
4041
+ result.push(Math.floor(Math.random() * 256));
4042
+ }
4043
+ return result;
4044
+ }
4045
+ var nonSecure = function (size) {
4046
+ size = size || 21;
4047
+ var id = '';
4048
+ var bytes = random(size);
4049
+ while (0 < size--) {
4050
+ id += url[bytes[size] & 63];
4051
+ }
4052
+ return id;
4053
+ };
4054
+
4297
4055
  var __assign$8 = undefined && undefined.__assign || function () {
4298
4056
  __assign$8 = Object.assign || function (t) {
4299
4057
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -5282,16 +5040,6 @@ fetcher$1.interceptors.response.use(function (response) {
5282
5040
  };
5283
5041
  }());
5284
5042
 
5285
- Object.defineProperty(fetcher$1, 'extend', {
5286
- enumerable: false,
5287
- value: function value(name, fn) {
5288
- var INVALID_NAMES = ['defaults', 'delete', 'put', 'post', 'get', 'head', 'interceptors', 'options', 'patch', 'request'];
5289
- var INVALID_NAME_WARNING = "The name of the method used (\"".concat(name, "\") to extend fetcher is invalid.");
5290
- !!INVALID_NAMES.includes(name) ? process.env.NODE_ENV !== "production" ? browser$2(false, INVALID_NAME_WARNING) : browser$2(false) : void 0;
5291
- fetcher$1[name] = fn;
5292
- }
5293
- });
5294
-
5295
5043
  var DEFAULT_USER_RULES$1 = {
5296
5044
  allow: [],
5297
5045
  deny: []
@@ -5360,14 +5108,39 @@ var getConfig = /*#__PURE__*/function () {
5360
5108
  return _ref.apply(this, arguments);
5361
5109
  };
5362
5110
  }();
5111
+
5112
+ // Does this pathname sit under an iframe app's mount path?
5113
+ // Works for BOTH legacy Angular apps at "/embedded/<app>" and new React apps at
5114
+ // their own root path "/<app>" — matches by the tile's configured path, never by
5115
+ // a hard-coded "/embedded" URL substring (which root-mounted apps do not have).
5116
+ var pathIsUnderTile = function pathIsUnderTile(tile, pathname) {
5117
+ return typeof tile.path === 'string' && (pathname === tile.path || pathname.startsWith("".concat(tile.path, "/")));
5118
+ };
5119
+
5120
+ // Canonical matcher: the embedded (iframe) tile that owns a given pathname, or
5121
+ // null. Longest path wins so a deeper mount path is preferred. Single source of
5122
+ // truth reused by app-frame chrome (see utilities.isEmbeddedRoute) so "which
5123
+ // embedded app am I on" is decided exactly one way across the toolkit.
5124
+ var getEmbeddedTileForPath = function getEmbeddedTileForPath() {
5125
+ var tiles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
5126
+ var pathname = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location.pathname;
5127
+ return tiles.filter(function (tile) {
5128
+ return tile.appName === 'embedded' && pathIsUnderTile(tile, pathname);
5129
+ }).sort(function (a, b) {
5130
+ return b.path.length - a.path.length;
5131
+ })[0] || null;
5132
+ };
5363
5133
  var tileFilter = function tileFilter(tile) {
5364
5134
  var _window$toolkitEnv;
5365
- var appName = (_window$toolkitEnv = window.toolkitEnv) !== null && _window$toolkitEnv !== void 0 && _window$toolkitEnv.APP_NAME ? window.toolkitEnv.APP_NAME : process.env.APP_NAME;
5366
- if (window.location.pathname.includes('embedded')) {
5367
- appName = window.location.pathname;
5135
+ var pathname = window.location.pathname;
5136
+ // Iframe apps are matched by mount path (prefix), not by APP_NAME — shell-side
5137
+ // the APP_NAME is the shell's, not the embedded app's.
5138
+ if (tile.appName === 'embedded') {
5139
+ return pathIsUnderTile(tile, pathname);
5368
5140
  }
5141
+ var appName = (_window$toolkitEnv = window.toolkitEnv) !== null && _window$toolkitEnv !== void 0 && _window$toolkitEnv.APP_NAME ? window.toolkitEnv.APP_NAME : process.env.APP_NAME;
5369
5142
  if (tile.appName) {
5370
- return tile.appName === 'embedded' ? tile.path === appName : tile.appName === appName;
5143
+ return tile.appName === appName;
5371
5144
  } else {
5372
5145
  return tile.path === "/".concat(appName);
5373
5146
  }
@@ -5399,7 +5172,7 @@ var getAppTileData = /*#__PURE__*/function () {
5399
5172
  return getConfig(coreConfigUri);
5400
5173
  case 1:
5401
5174
  config = _context2.v;
5402
- storage.setLocalItem('opsportal-core:config', config);
5175
+ storage$2.setLocalItem('opsportal-core:config', config);
5403
5176
  return _context2.a(2, findAppData(config.tiles, config.tileOverrides));
5404
5177
  }
5405
5178
  }, _callee2);
@@ -5409,6 +5182,317 @@ var getAppTileData = /*#__PURE__*/function () {
5409
5182
  };
5410
5183
  }();
5411
5184
 
5185
+ var getRouteName = function getRouteName() {
5186
+ return window.location.pathname.split('/').splice(1)[0];
5187
+ };
5188
+
5189
+ // True when the current URL is an iframe-embedded app — legacy "/embedded/<app>"
5190
+ // OR a new root-mounted React app at "/<app>". Decided from config (tiles with
5191
+ // appName === 'embedded'), NOT from a "/embedded" URL substring, so root-mounted
5192
+ // apps get identical chrome/behaviour. Single predicate reused across app-frame.
5193
+ var isEmbeddedRoute = function isEmbeddedRoute() {
5194
+ var pathname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.pathname;
5195
+ var coreAppConfig = storage$2.getLocalItem('opsportal-core:config') || {};
5196
+ return Boolean(getEmbeddedTileForPath(coreAppConfig.tiles || [], pathname));
5197
+ };
5198
+ var regexCountry = /\.co\.([a-z]{2})/;
5199
+ var regexCobaltCountry = /\.copart\.([a-z]{2})/;
5200
+ var isLogoutRoute = ['logout'].includes(getRouteName());
5201
+ var isAuthRoute = ['login', 'logout', ''].includes(getRouteName());
5202
+ var isCoreRoute = ['settings', 'home', 'webChat', 'embedded', ''].includes(getRouteName());
5203
+ var getDomain = function getDomain(url) {
5204
+ var country = url.match(regexCountry);
5205
+ var countryCode = (country && country.length > 1 && country[1] || 'US').toUpperCase();
5206
+ if (countryCode === 'UK') {
5207
+ return 'copart.co.uk';
5208
+ } else {
5209
+ var matchedCountry = url.match(regexCobaltCountry);
5210
+ var matchedCountryCode = matchedCountry.length > 1 ? matchedCountry[1].toLowerCase() : ['.copart.co', 'co'];
5211
+ if (matchedCountryCode === 'de') {
5212
+ return 'copart.de';
5213
+ } else if (matchedCountryCode === 'es') {
5214
+ return 'copart.es';
5215
+ } else return 'copart.com';
5216
+ }
5217
+ };
5218
+ var dateDiffInDays = function dateDiffInDays(date1, date2) {
5219
+ var diffInMilliseconds = Math.abs(date2 - date1);
5220
+ var millisecondsPerDay = 24 * 60 * 60 * 1000;
5221
+ return Math.floor(diffInMilliseconds / millisecondsPerDay);
5222
+ };
5223
+ var isChrome = function isChrome() {
5224
+ var userAgent = window.navigator.userAgent;
5225
+ var isChromium = userAgent.indexOf('Chrome/') > -1;
5226
+ var isEdge = userAgent.indexOf('Edg/') > -1;
5227
+ return isChromium && !isEdge;
5228
+ };
5229
+ var isUserStatusHidden = function isUserStatusHidden() {
5230
+ var _window$toolkitEnv, _storage$coreConfig2, _storage$coreConfig3;
5231
+ var isCoreApp = isEmbeddedRoute() ? false : (_window$toolkitEnv = window.toolkitEnv) !== null && _window$toolkitEnv !== void 0 && _window$toolkitEnv.IS_CORE_APP ? window.toolkitEnv.IS_CORE_APP : process.env.IS_CORE_APP;
5232
+ if (isCoreApp) {
5233
+ var _storage$coreConfig;
5234
+ return ((_storage$coreConfig = storage$2.coreConfig) === null || _storage$coreConfig === void 0 ? void 0 : _storage$coreConfig.hideUserStatus) || false;
5235
+ }
5236
+ if ((_storage$coreConfig2 = storage$2.coreConfig) !== null && _storage$coreConfig2 !== void 0 && _storage$coreConfig2.checkUserStatusByApp) {
5237
+ var coreAppConfig = storage$2.getLocalItem('opsportal-core:config') || {};
5238
+ var appData = findAppData(coreAppConfig.tiles || [], coreAppConfig.tileOverrides || []);
5239
+ return (appData === null || appData === void 0 ? void 0 : appData.showUserStatus) !== true;
5240
+ }
5241
+ return ((_storage$coreConfig3 = storage$2.coreConfig) === null || _storage$coreConfig3 === void 0 ? void 0 : _storage$coreConfig3.hideUserStatus) || false;
5242
+ };
5243
+
5244
+ var DEFAULT_BREADCRUMBS_CONTEXT = {
5245
+ error: 'You tried to use Breadcrumbs outside of its context.'
5246
+ };
5247
+
5248
+ var css_248z$r = ".utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Breadcrumbs {\n /* height: 36px;\n background: #3c4656; */\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--crumbs {\n display: flex;\n}\n\n#notCrumbs {\n height: 100%;\n margin-right: 12px;\n display: flex;\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb {\n cursor: pointer;\n height: 100%;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 16px;\n font-weight: 300;\n letter-spacing: 0;\n /* transition: all 0.2s; */\n position: relative;\n top: -2px;\n color: rgba(255, 255, 255, 0.8);\n grid-gap: 6px;\n gap: 6px;\n margin-left: 5px;\n opacity: 1;\n}\n\n@-webkit-keyframes utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--fadeIn {\n 0% {\n opacity: 0;\n -webkit-transform: translateX(-6px);\n transform: translateX(-6px);\n /* transform: scale(0.9); */\n }\n 100% {\n opacity: 1;\n -webkit-transform: translateX(0px);\n transform: translateX(0px);\n /* transform: scale(1); */\n }\n}\n\n@keyframes utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--fadeIn {\n 0% {\n opacity: 0;\n -webkit-transform: translateX(-6px);\n transform: translateX(-6px);\n /* transform: scale(0.9); */\n }\n 100% {\n opacity: 1;\n -webkit-transform: translateX(0px);\n transform: translateX(0px);\n /* transform: scale(1); */\n }\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb {\n -webkit-animation-name: utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--fadeIn;\n animation-name: utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--fadeIn;\n -webkit-animation-duration: 0.2s;\n animation-duration: 0.2s;\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb::before {\n content: '\\f054';\n color: rgba(255, 255, 255, 0.4);\n display: inline-block;\n font-family: 'Font Awesome 6 Pro';\n font-size: 16px;\n margin: 0 6px;\n position: relative;\n top: 2px;\n}\n\n/* .Crumb:first-of-type {\n margin-left: 12px;\n font-weight: 400;\n} */\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb:hover {\n /* background: rgba(0, 0, 0, 0.15); */\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb:not(:last-of-type):not(:hover) {\n /* opacity: 0.75; */\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb:last-of-type {\n font-weight: 700;\n opacity: 1;\n color: rgba(255, 255, 255, 1);\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb:last-of-type::before {\n font-weight: 300;\n /* opacity: 0.8; */\n}\n\n/* .crumbSpacer {} */\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--crumbs {\n /* margin: 10px; */\n flex-grow: 2;\n font-size: 14px;\n cursor: pointer;\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--notCrumbs {\n height: 100%;\n display: flex;\n margin-right: 0px !important;\n}\n\n.utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--entityIndicator {\n height: 100%;\n display: flex;\n margin-right: 0px !important;\n}";
5249
+ styleInject(css_248z$r);
5250
+
5251
+ var Context = createContext(DEFAULT_BREADCRUMBS_CONTEXT);
5252
+ var withBreadcrumbs = function withBreadcrumbs(Comp) {
5253
+ return /*#__PURE__*/function (_React$Component) {
5254
+ function _class() {
5255
+ _classCallCheck$3(this, _class);
5256
+ return _callSuper(this, _class, arguments);
5257
+ }
5258
+ _inherits$2(_class, _React$Component);
5259
+ return _createClass$2(_class, [{
5260
+ key: "render",
5261
+ value: function render() {
5262
+ var _this = this;
5263
+ return /*#__PURE__*/React__namespace.createElement(Context.Consumer, null, function (breadcrumbs) {
5264
+ return /*#__PURE__*/React__namespace.createElement(Comp, _extends$1({}, _this.props, {
5265
+ breadcrumbs: breadcrumbs
5266
+ }));
5267
+ });
5268
+ }
5269
+ }]);
5270
+ }(React__namespace.Component);
5271
+ };
5272
+ var Breadcrumbs = withBreadcrumbs(index$1.purist(function (props) {
5273
+ var _props$appTile, _props$appTile3;
5274
+ return /*#__PURE__*/React__namespace.createElement("div", {
5275
+ className: "utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Breadcrumbs"
5276
+ }, /*#__PURE__*/React__namespace.createElement("div", {
5277
+ className: "utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--crumbs"
5278
+ }, props !== null && props !== void 0 && (_props$appTile = props.appTile) !== null && _props$appTile !== void 0 && _props$appTile.title ? /*#__PURE__*/React__namespace.createElement("a", {
5279
+ onClick: function onClick() {
5280
+ var _props$appTile2;
5281
+ var isEmbedded = isEmbeddedRoute();
5282
+ props.history.push(isEmbedded && (_props$appTile2 = props.appTile) !== null && _props$appTile2 !== void 0 && _props$appTile2.path ? props.appTile.path : '/');
5283
+ },
5284
+ className: "utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb"
5285
+ }, props === null || props === void 0 ? void 0 : (_props$appTile3 = props.appTile) === null || _props$appTile3 === void 0 ? void 0 : _props$appTile3.title) : null, props.breadcrumbs.crumbs.map(function (crumb, idx) {
5286
+ return /*#__PURE__*/React__namespace.createElement("a", {
5287
+ onClick: function onClick() {
5288
+ return props.history.push(crumb.to);
5289
+ },
5290
+ className: "utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--Crumb",
5291
+ key: crumb.crumbId != null ? crumb.crumbId : idx
5292
+ }, crumb.children);
5293
+ }, this)), /*#__PURE__*/React__namespace.createElement("div", {
5294
+ id: "notCrumbs",
5295
+ className: "utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--notCrumbs"
5296
+ }), /*#__PURE__*/React__namespace.createElement("div", {
5297
+ id: "entityIndicator",
5298
+ className: "utilities_ops-app-frame_Breadcrumbs_styles_Breadcrumbs--entityIndicator"
5299
+ }));
5300
+ }));
5301
+
5302
+ var BreadcrumbsProvider = /*#__PURE__*/function (_React$Component) {
5303
+ function BreadcrumbsProvider(props) {
5304
+ var _this;
5305
+ _classCallCheck$3(this, BreadcrumbsProvider);
5306
+ _this = _callSuper(this, BreadcrumbsProvider, [props]);
5307
+ _defineProperty$2(_this, "crumbIds", new Set());
5308
+ _this.state = function () {
5309
+ var self = _this;
5310
+ return {
5311
+ crumbs: [],
5312
+ addCrumb: function addCrumb(props, crumbId, oldId) {
5313
+ var newCrumb = _objectSpread2(_objectSpread2({}, props), {}, {
5314
+ crumbId: crumbId
5315
+ });
5316
+ self.setState(function (state) {
5317
+ return {
5318
+ crumbs: oldId ? state.crumbs.map(function (crumb) {
5319
+ return crumb.crumbId === oldId ? newCrumb : crumb;
5320
+ }) : [].concat(_toConsumableArray(state.crumbs), [newCrumb])
5321
+ };
5322
+ });
5323
+ },
5324
+ removeCrumb: function removeCrumb(crumbId) {
5325
+ // Filter out the specific crumb by its crumbId.
5326
+ self.setState(function (state) {
5327
+ return {
5328
+ crumbs: state.crumbs.filter(function (crumb) {
5329
+ return crumb.crumbId !== crumbId;
5330
+ })
5331
+ };
5332
+ });
5333
+ }
5334
+ };
5335
+ }();
5336
+ return _this;
5337
+ }
5338
+ _inherits$2(BreadcrumbsProvider, _React$Component);
5339
+ return _createClass$2(BreadcrumbsProvider, [{
5340
+ key: "render",
5341
+ value: function render() {
5342
+ return /*#__PURE__*/React__namespace.createElement(Context.Provider, {
5343
+ value: this.state
5344
+ }, this.props.children);
5345
+ }
5346
+ }]);
5347
+ }(React__namespace.Component);
5348
+
5349
+ var _class;
5350
+ var _excluded$6 = ["breadcrumbs"];
5351
+ var getCrumbProps = function getCrumbProps(props) {
5352
+ props.breadcrumbs;
5353
+ var crumbProps = _objectWithoutProperties(props, _excluded$6);
5354
+ return crumbProps;
5355
+ };
5356
+
5357
+ // Flatten children to a comparable text label. Children may be a React element
5358
+ // (e.g. <span onClick>Label</span>) whose internal fiber refs (`_owner`) are
5359
+ // circular, so it must never be passed to JSON.stringify.
5360
+ var _crumbLabel = function crumbLabel(children) {
5361
+ if (children == null) return '';
5362
+ if (typeof children === 'string' || typeof children === 'number') return String(children);
5363
+ if (Array.isArray(children)) return children.map(_crumbLabel).join('');
5364
+ if (React__namespace.isValidElement(children) && children.props && children.props.children != null) {
5365
+ return _crumbLabel(children.props.children);
5366
+ }
5367
+ return '';
5368
+ };
5369
+
5370
+ // Safe replacement for the old JSON.stringify diff, which threw
5371
+ // "Converting circular structure to JSON" whenever children was a React element.
5372
+ var crumbPropsChanged = function crumbPropsChanged(oldProps, newProps) {
5373
+ var keys = new Set([].concat(_toConsumableArray(Object.keys(oldProps)), _toConsumableArray(Object.keys(newProps))));
5374
+ var _iterator = _createForOfIteratorHelper(keys),
5375
+ _step;
5376
+ try {
5377
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
5378
+ var key = _step.value;
5379
+ if (key === 'children') {
5380
+ if (_crumbLabel(oldProps.children) !== _crumbLabel(newProps.children)) return true;
5381
+ } else if (oldProps[key] !== newProps[key]) {
5382
+ return true;
5383
+ }
5384
+ }
5385
+ } catch (err) {
5386
+ _iterator.e(err);
5387
+ } finally {
5388
+ _iterator.f();
5389
+ }
5390
+ return false;
5391
+ };
5392
+ var Crumb$1 = withBreadcrumbs(_class = /*#__PURE__*/function (_React$Component) {
5393
+ function Crumb() {
5394
+ var _this;
5395
+ _classCallCheck$3(this, Crumb);
5396
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5397
+ args[_key] = arguments[_key];
5398
+ }
5399
+ _this = _callSuper(this, Crumb, [].concat(args));
5400
+ _defineProperty$2(_this, "crumbId", nonSecure());
5401
+ return _this;
5402
+ }
5403
+ _inherits$2(Crumb, _React$Component);
5404
+ return _createClass$2(Crumb, [{
5405
+ key: "componentDidMount",
5406
+ value: function componentDidMount() {
5407
+ var crumbProps = getCrumbProps(this.props);
5408
+ this.props.breadcrumbs.addCrumb(crumbProps, this.crumbId);
5409
+ }
5410
+ }, {
5411
+ key: "shouldComponentUpdate",
5412
+ value: function shouldComponentUpdate(nextProps) {
5413
+ var oldProps = getCrumbProps(this.props);
5414
+ var newProps = getCrumbProps(nextProps);
5415
+ return crumbPropsChanged(oldProps, newProps);
5416
+ }
5417
+ }, {
5418
+ key: "componentDidUpdate",
5419
+ value: function componentDidUpdate() {
5420
+ var oldId = this.crumbId;
5421
+ this.crumbId = nonSecure();
5422
+ var crumbProps = getCrumbProps(this.props);
5423
+ this.props.breadcrumbs.addCrumb(crumbProps, this.crumbId, oldId);
5424
+ }
5425
+ }, {
5426
+ key: "componentWillUnmount",
5427
+ value: function componentWillUnmount() {
5428
+ this.props.breadcrumbs.removeCrumb(this.crumbId);
5429
+ }
5430
+ }, {
5431
+ key: "render",
5432
+ value: function render() {
5433
+ return null;
5434
+ }
5435
+ }]);
5436
+ }(React__namespace.Component)) || _class;
5437
+ Crumb$1.defaultProps = {
5438
+ breadcrumbs: {
5439
+ addCrumb: function addCrumb() {},
5440
+ removeCrumb: function removeCrumb() {},
5441
+ crumbs: []
5442
+ }
5443
+ };
5444
+
5445
+ /**
5446
+ * Copyright (c) 2013-present, Facebook, Inc.
5447
+ *
5448
+ * This source code is licensed under the MIT license found in the
5449
+ * LICENSE file in the root directory of this source tree.
5450
+ */
5451
+
5452
+ /**
5453
+ * Use invariant() to assert state which your program assumes to be true.
5454
+ *
5455
+ * Provide sprintf-style format (only %s is supported) and arguments
5456
+ * to provide information about what broke and what you were
5457
+ * expecting.
5458
+ *
5459
+ * The invariant message will be stripped in production, but the invariant
5460
+ * will remain to ensure logic does not differ in production.
5461
+ */
5462
+ var invariant = function (condition, format, a, b, c, d, e, f) {
5463
+ if (process.env.NODE_ENV !== 'production') {
5464
+ if (format === undefined) {
5465
+ throw new Error('invariant requires an error message argument');
5466
+ }
5467
+ }
5468
+ if (!condition) {
5469
+ var error;
5470
+ if (format === undefined) {
5471
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
5472
+ } else {
5473
+ var args = [a, b, c, d, e, f];
5474
+ var argIndex = 0;
5475
+ error = new Error(format.replace(/%s/g, function () {
5476
+ return args[argIndex++];
5477
+ }));
5478
+ error.name = 'Invariant Violation';
5479
+ }
5480
+ error.framesToPop = 1; // we don't care about invariant's own frame
5481
+ throw error;
5482
+ }
5483
+ };
5484
+ var browser$2 = invariant;
5485
+
5486
+ Object.defineProperty(fetcher$1, 'extend', {
5487
+ enumerable: false,
5488
+ value: function value(name, fn) {
5489
+ var INVALID_NAMES = ['defaults', 'delete', 'put', 'post', 'get', 'head', 'interceptors', 'options', 'patch', 'request'];
5490
+ var INVALID_NAME_WARNING = "The name of the method used (\"".concat(name, "\") to extend fetcher is invalid.");
5491
+ !!INVALID_NAMES.includes(name) ? process.env.NODE_ENV !== "production" ? browser$2(false, INVALID_NAME_WARNING) : browser$2(false) : void 0;
5492
+ fetcher$1[name] = fn;
5493
+ }
5494
+ });
5495
+
5412
5496
  var MEA_COUNTRIES = ['ARE', 'BHR', 'OMN'];
5413
5497
  var getHeaders$1 = function getHeaders() {
5414
5498
  var country = storage.getSessionItem('dashboard', 'selectedCountryA3code');
@@ -9337,56 +9421,6 @@ fetcher$1.getUserScopes = getUserScopes;
9337
9421
  fetcher$1.getCobaltUserFacilities = getCobaltUserFacilities;
9338
9422
  fetcher$1.getCobaltUserRoles = getCobaltUserRoles;
9339
9423
 
9340
- var getRouteName = function getRouteName() {
9341
- return window.location.pathname.split('/').splice(1)[0];
9342
- };
9343
- var regexCountry = /\.co\.([a-z]{2})/;
9344
- var regexCobaltCountry = /\.copart\.([a-z]{2})/;
9345
- var isLogoutRoute = ['logout'].includes(getRouteName());
9346
- var isAuthRoute = ['login', 'logout', ''].includes(getRouteName());
9347
- var isCoreRoute = ['settings', 'home', 'webChat', 'embedded', ''].includes(getRouteName());
9348
- var getDomain = function getDomain(url) {
9349
- var country = url.match(regexCountry);
9350
- var countryCode = (country && country.length > 1 && country[1] || 'US').toUpperCase();
9351
- if (countryCode === 'UK') {
9352
- return 'copart.co.uk';
9353
- } else {
9354
- var matchedCountry = url.match(regexCobaltCountry);
9355
- var matchedCountryCode = matchedCountry.length > 1 ? matchedCountry[1].toLowerCase() : ['.copart.co', 'co'];
9356
- if (matchedCountryCode === 'de') {
9357
- return 'copart.de';
9358
- } else if (matchedCountryCode === 'es') {
9359
- return 'copart.es';
9360
- } else return 'copart.com';
9361
- }
9362
- };
9363
- var dateDiffInDays = function dateDiffInDays(date1, date2) {
9364
- var diffInMilliseconds = Math.abs(date2 - date1);
9365
- var millisecondsPerDay = 24 * 60 * 60 * 1000;
9366
- return Math.floor(diffInMilliseconds / millisecondsPerDay);
9367
- };
9368
- var isChrome = function isChrome() {
9369
- var userAgent = window.navigator.userAgent;
9370
- var isChromium = userAgent.indexOf('Chrome/') > -1;
9371
- var isEdge = userAgent.indexOf('Edg/') > -1;
9372
- return isChromium && !isEdge;
9373
- };
9374
- var isUserStatusHidden = function isUserStatusHidden() {
9375
- var _window$toolkitEnv, _storage$coreConfig2, _storage$coreConfig3;
9376
- var isEmbeddedRoute = window.location.pathname.includes('embedded');
9377
- var isCoreApp = isEmbeddedRoute ? false : (_window$toolkitEnv = window.toolkitEnv) !== null && _window$toolkitEnv !== void 0 && _window$toolkitEnv.IS_CORE_APP ? window.toolkitEnv.IS_CORE_APP : process.env.IS_CORE_APP;
9378
- if (isCoreApp) {
9379
- var _storage$coreConfig;
9380
- return ((_storage$coreConfig = storage$2.coreConfig) === null || _storage$coreConfig === void 0 ? void 0 : _storage$coreConfig.hideUserStatus) || false;
9381
- }
9382
- if ((_storage$coreConfig2 = storage$2.coreConfig) !== null && _storage$coreConfig2 !== void 0 && _storage$coreConfig2.checkUserStatusByApp) {
9383
- var coreAppConfig = storage$2.getLocalItem('opsportal-core:config') || {};
9384
- var appData = findAppData(coreAppConfig.tiles || [], coreAppConfig.tileOverrides || []);
9385
- return (appData === null || appData === void 0 ? void 0 : appData.showUserStatus) !== true;
9386
- }
9387
- return ((_storage$coreConfig3 = storage$2.coreConfig) === null || _storage$coreConfig3 === void 0 ? void 0 : _storage$coreConfig3.hideUserStatus) || false;
9388
- };
9389
-
9390
9424
  var css_248z$q = ".utilities_ops-app-frame_ConfigFetcher_ConfigFetcher--ConfigFetcher {\n}\n\n.utilities_ops-app-frame_ConfigFetcher_ConfigFetcher--spinner {\n margin: 80px 0 40px;\n width: 100%;\n height: 100%;\n}\n\n.utilities_ops-app-frame_ConfigFetcher_ConfigFetcher--spinner * {\n width: 60px;\n height: 60px;\n}\n";
9391
9425
  styleInject(css_248z$q);
9392
9426
 
@@ -21618,7 +21652,7 @@ var _styleModuleImportMap$9 = {
21618
21652
  }
21619
21653
  };
21620
21654
  var isEmbeddedPath = function isEmbeddedPath() {
21621
- return typeof window !== 'undefined' && window.location.pathname.startsWith('/embedded');
21655
+ return typeof window !== 'undefined' && isEmbeddedRoute();
21622
21656
  };
21623
21657
  var CopartLogo = function CopartLogo() {
21624
21658
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
@@ -27051,7 +27085,11 @@ var generateAppBarElements = function generateAppBarElements(props, showCallout)
27051
27085
  enableIdeaNote = coreAppConfig.enableIdeaNote,
27052
27086
  enableMiHelp = coreAppConfig.enableMiHelp;
27053
27087
  var showSettingsInAppbar = false;
27054
- if (isCoreRoute) {
27088
+
27089
+ // isCoreRoute is frozen at shell-boot URL and stays true through SPA nav on a
27090
+ // home-booted session; isEmbeddedRoute() adds the same branch for a COLD-LOAD
27091
+ // onto a root-mounted iframe app so cold-load === home-nav.
27092
+ if (isCoreRoute || isEmbeddedRoute()) {
27055
27093
  showSettingsInAppbar = enableNewToolkitFeatures;
27056
27094
  } else if (!isAuthRoute) {
27057
27095
  if (enableNewToolkitFeatures && showSettingsMenuByTileConfig) {
@@ -27695,12 +27733,12 @@ var AppBar$1 = function AppBar(props) {
27695
27733
  return tile.path === "/".concat(appName);
27696
27734
  }
27697
27735
  });
27698
- if (window.location.pathname.includes('embedded')) {
27699
- var tiles = appTiles.filter(function (tile) {
27700
- var currentLocation = window.location.pathname;
27701
- return currentLocation.startsWith(tile.path);
27702
- });
27703
- matchingTiles = [].concat(_toConsumableArray(matchingTiles), _toConsumableArray(tiles));
27736
+ // Also match the iframe app whose mount path owns the current URL — legacy
27737
+ // "/embedded/<app>" or new root-mounted "/<app>". Config-driven (see
27738
+ // getEmbeddedTileForPath), not a "/embedded" URL substring.
27739
+ var embeddedTile = getEmbeddedTileForPath(appTiles, window.location.pathname);
27740
+ if (embeddedTile) {
27741
+ matchingTiles = [].concat(_toConsumableArray(matchingTiles), [embeddedTile]);
27704
27742
  }
27705
27743
  if (matchingTiles.length > 1) {
27706
27744
  var currentLocation = window.location.pathname;
@@ -30689,7 +30727,10 @@ var notificationsSource = pathOr$1([], ['notificationsSource'])(coreAppConfig);
30689
30727
  var enableNewToolkitFeatures = coreAppConfig.enableNewToolkitFeatures;
30690
30728
  var getIdeaNoteEnabledStatus = function getIdeaNoteEnabledStatus(tileData) {
30691
30729
  var coreAppConfig = storage$2.getLocalItem('opsportal-core:config');
30692
- if (isCoreRoute || coreAppConfig.enableIdeaNoteGlobally) {
30730
+ // isCoreRoute is frozen at shell-boot URL; on a home-booted session it stays
30731
+ // true through SPA nav to any iframe app. isEmbeddedRoute() adds the same
30732
+ // branch for a COLD-LOAD onto a root-mounted app so cold-load === home-nav.
30733
+ if (isCoreRoute || isEmbeddedRoute() || coreAppConfig.enableIdeaNoteGlobally) {
30693
30734
  return coreAppConfig.enableIdeaNote;
30694
30735
  } else {
30695
30736
  return tileData.enableIdeaNote;
@@ -30783,9 +30824,10 @@ var AppBar = function AppBar(_ref) {
30783
30824
  var _useErrorNotification = useErrorNotification(),
30784
30825
  showError = _useErrorNotification.showError;
30785
30826
  var tileData = findAppData(coreAppConfig.tiles, coreAppConfig.tileOverrides) || {};
30786
- var mihelpAppPath = isCoreRoute && !window.location.pathname.includes('embedded') ? null : tileData.mihelpAppPath;
30827
+ var isEmbeddedApp = isEmbeddedRoute();
30828
+ var mihelpAppPath = isCoreRoute && !isEmbeddedApp ? null : tileData.mihelpAppPath;
30787
30829
  var isMihelpEnabled;
30788
- if (isCoreRoute && !window.location.pathname.includes('embedded')) {
30830
+ if (isCoreRoute && !isEmbeddedApp) {
30789
30831
  isMihelpEnabled = coreAppConfig.enableMiHelp;
30790
30832
  } else {
30791
30833
  isMihelpEnabled = Boolean(mihelpAppPath);
@@ -31262,7 +31304,11 @@ var AppBar = function AppBar(_ref) {
31262
31304
  document.removeEventListener('visibilitychange', handleVisibilityChange);
31263
31305
  };
31264
31306
  }, [socketClient]);
31265
- var notificationsReloadPathKey = pathname === '/embedded' || pathname && pathname.startsWith('/embedded/') ? pathname : '__non_embedded__';
31307
+
31308
+ // Reset notifications per embedded app switch. Keyed on the pathname for any
31309
+ // iframe app (legacy "/embedded/*" or root-mounted "/<app>"); a single sentinel
31310
+ // otherwise so standalone/core routes share one bucket.
31311
+ var notificationsReloadPathKey = pathname && isEmbeddedRoute(pathname) ? pathname : '__non_embedded__';
31266
31312
  React.useEffect(function () {
31267
31313
  setNotifications([]);
31268
31314
  setListOfAllNotifications([]);
@@ -31653,7 +31699,14 @@ var AuthGuard = /*#__PURE__*/function (_React$PureComponent) {
31653
31699
  // If we got this far, the user must be authenticated, and
31654
31700
  // opsportal-core accepts ALL authenticated users. So if we determine
31655
31701
  // that we are on a opsportal-core route, allow the user in.
31656
- if (!isCoreRoute) {
31702
+ //
31703
+ // isEmbeddedRoute() covers a COLD-LOAD onto an iframe app's own path
31704
+ // (legacy "/embedded/*" is already core via isCoreRoute; new root-mounted
31705
+ // React apps at "/<app>" are not). Passing here makes the shell frame-gate
31706
+ // identical to the home-nav flow, where AuthGuard already passed at "/" boot
31707
+ // and per-iframe access is enforced by IframeComponent.userHasAccess. This
31708
+ // keeps cold-load functionally identical to navigating from Home.
31709
+ if (!(isCoreRoute || isEmbeddedRoute())) {
31657
31710
  _context.n = 2;
31658
31711
  break;
31659
31712
  }
@@ -65377,7 +65430,7 @@ var AppFrame = function AppFrame(props) {
65377
65430
  chatBotAppFunctionId = _ref.chatBotAppFunctionId;
65378
65431
  var isCoreRoute = ['settings', 'home', 'webChat', 'embedded', ''].includes(getRouteName());
65379
65432
  var hasChatBotAccess = userHasChatBotAccess$1(chatBotAppFunctionId);
65380
- var chatBotEnabled = isCoreRoute && !window.location.pathname.includes('embedded') ? enableChatBot && hasChatBotAccess : (tileData === null || tileData === void 0 ? void 0 : tileData.enableChatBot) && hasChatBotAccess;
65433
+ var chatBotEnabled = isCoreRoute && !isEmbeddedRoute() ? enableChatBot && hasChatBotAccess : (tileData === null || tileData === void 0 ? void 0 : tileData.enableChatBot) && hasChatBotAccess;
65381
65434
  setChatBotEnabled(chatBotEnabled);
65382
65435
  chatBotEnabledRef.current = chatBotEnabled;
65383
65436
  };
@@ -69035,6 +69088,7 @@ function isAllowedOrigin(origin) {
69035
69088
  var _excluded$1 = ["signal"];
69036
69089
  var pending = new Map();
69037
69090
  var STORAGE_REQUEST_TIMEOUT_MS = 5000;
69091
+ var LOG_PREFIX = '[iframe-bridge]';
69038
69092
  function requestId() {
69039
69093
  if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
69040
69094
  return crypto.randomUUID();
@@ -69054,47 +69108,365 @@ function requestId() {
69054
69108
  return v.toString(16);
69055
69109
  });
69056
69110
  }
69111
+ function isEmbeddedFrame() {
69112
+ return typeof window !== 'undefined' && window.self !== window.top;
69113
+ }
69057
69114
 
69058
- // The exact origin of the shell that framed us. Learned from the first inbound
69059
- // message that passes validation (origin is copart + came from window.parent),
69115
+ // The exact origin of the shell that framed us. Learned from SHELL_ORIGIN,
69116
+ // optional browser hints, or the first inbound message that passes validation,
69060
69117
  // then pinned. Used as the targetOrigin for every outbound post() so app→shell
69061
69118
  // messages (incl. FETCH_REQUEST bodies) are never broadcast to '*'.
69062
69119
  //
69063
69120
  // If SHELL_ORIGIN is provided at build time we lock to it up front — there is
69064
69121
  // only one shell, so this is the tightest option and closes the "any
69065
69122
  // *.copart.com subdomain" residual entirely. Otherwise we capture-and-lock.
69066
- var trustedParentOrigin = typeof process !== 'undefined' && process.env && process.env.SHELL_ORIGIN || null;
69123
+ //
69124
+ // CRITICAL: handshake MUST NOT depend on ancestorOrigins/referrer. Those are
69125
+ // Chromium-only / often empty. Cross-origin GET_INIT_DATA uses targetOrigin '*'
69126
+ // until the parent is pinned by an inbound LOAD_URI or INIT_DATA (all browsers).
69127
+ var configuredShellOrigin = typeof process !== 'undefined' && process.env && process.env.SHELL_ORIGIN || null;
69128
+ var trustedParentOrigin = configuredShellOrigin || null;
69129
+ var parentOriginWaiters = new Set();
69130
+ function notifyParentOriginWaiters() {
69131
+ if (!trustedParentOrigin || parentOriginWaiters.size === 0) return;
69132
+ var waiters = Array.from(parentOriginWaiters);
69133
+ parentOriginWaiters.clear();
69134
+ waiters.forEach(function (resolve) {
69135
+ return resolve(trustedParentOrigin);
69136
+ });
69137
+ }
69138
+
69139
+ /**
69140
+ * Optional fast-path only. Never required for correctness.
69141
+ * Chromium: ancestorOrigins. Others: document.referrer (often empty).
69142
+ */
69143
+ function tryInferParentOrigin() {
69144
+ if (typeof window === 'undefined') return null;
69145
+ try {
69146
+ var ancestors = window.location && window.location.ancestorOrigins;
69147
+ if (ancestors && ancestors.length > 0) {
69148
+ var origin = ancestors[0];
69149
+ if (isAllowedOrigin(origin)) return origin;
69150
+ }
69151
+ } catch (_) {/* ignore */}
69152
+ try {
69153
+ if (document.referrer) {
69154
+ var _origin = new URL(document.referrer).origin;
69155
+ if (isAllowedOrigin(_origin)) return _origin;
69156
+ }
69157
+ } catch (_) {/* ignore */}
69158
+ return null;
69159
+ }
69160
+ if (!trustedParentOrigin) {
69161
+ var inferred = tryInferParentOrigin();
69162
+ if (inferred) trustedParentOrigin = inferred;
69163
+ }
69164
+
69165
+ /** Snapshot for support logs — no tokens/secrets. */
69166
+ function getHandshakeDiagnostics() {
69167
+ var ancestorOrigin = null;
69168
+ var referrerOrigin = null;
69169
+ try {
69170
+ var ancestors = typeof window !== 'undefined' && window.location && window.location.ancestorOrigins;
69171
+ if (ancestors && ancestors.length > 0) ancestorOrigin = ancestors[0];
69172
+ } catch (_) {/* ignore */}
69173
+ try {
69174
+ if (typeof document !== 'undefined' && document.referrer) {
69175
+ referrerOrigin = new URL(document.referrer).origin;
69176
+ }
69177
+ } catch (_) {/* ignore */}
69178
+ return {
69179
+ inIframe: isEmbeddedFrame(),
69180
+ appOrigin: typeof window !== 'undefined' ? window.location.origin : null,
69181
+ configuredShellOrigin: configuredShellOrigin,
69182
+ pinnedShellOrigin: trustedParentOrigin,
69183
+ inferredAncestorOrigin: ancestorOrigin,
69184
+ inferredReferrerOrigin: referrerOrigin,
69185
+ earlyLoadUri: typeof window !== 'undefined' ? window.__IFRAME_EARLY_LOAD_URI : null,
69186
+ pendingRequestCount: pending.size
69187
+ };
69188
+ }
69189
+
69190
+ /**
69191
+ * Pin the shell origin after validating it is an allowed Copart origin.
69192
+ * Used by early LOAD_URI and by the first trusted inbound message.
69193
+ * Once pinned, a conflicting origin is rejected.
69194
+ */
69195
+ function pinTrustedParentOrigin(origin) {
69196
+ var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'unknown';
69197
+ if (!origin || typeof origin !== 'string') return false;
69198
+ if (configuredShellOrigin) {
69199
+ var ok = origin === configuredShellOrigin;
69200
+ if (!ok) {
69201
+ console.warn("".concat(LOG_PREFIX, " refused pin \u2014 conflicts with SHELL_ORIGIN"), {
69202
+ source: source,
69203
+ attempted: origin,
69204
+ configuredShellOrigin: configuredShellOrigin
69205
+ });
69206
+ }
69207
+ return ok;
69208
+ }
69209
+ if (trustedParentOrigin) {
69210
+ var _ok = origin === trustedParentOrigin;
69211
+ if (!_ok) {
69212
+ console.warn("".concat(LOG_PREFIX, " refused pin \u2014 already pinned to different origin"), {
69213
+ source: source,
69214
+ attempted: origin,
69215
+ pinned: trustedParentOrigin
69216
+ });
69217
+ }
69218
+ return _ok;
69219
+ }
69220
+ if (!isAllowedOrigin(origin)) {
69221
+ console.warn("".concat(LOG_PREFIX, " refused pin \u2014 origin not in allowlist"), {
69222
+ source: source,
69223
+ attempted: origin
69224
+ });
69225
+ return false;
69226
+ }
69227
+ trustedParentOrigin = origin;
69228
+ console.info("".concat(LOG_PREFIX, " pinned shell origin"), {
69229
+ source: source,
69230
+ shellOrigin: origin
69231
+ });
69232
+ notifyParentOriginWaiters();
69233
+ return true;
69234
+ }
69235
+
69236
+ /**
69237
+ * Resolve (and optionally wait for) the pinned shell origin before outbound posts.
69238
+ */
69239
+ function waitForTrustedParentOrigin() {
69240
+ var timeoutMs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4000;
69241
+ if (trustedParentOrigin) return Promise.resolve(trustedParentOrigin);
69242
+ var inferred = tryInferParentOrigin();
69243
+ if (inferred) {
69244
+ pinTrustedParentOrigin(inferred, 'infer');
69245
+ return Promise.resolve(trustedParentOrigin);
69246
+ }
69247
+ return new Promise(function (resolve) {
69248
+ var settled = false;
69249
+ var _waiter = function waiter(origin) {
69250
+ if (settled) return;
69251
+ settled = true;
69252
+ clearTimeout(timer);
69253
+ parentOriginWaiters.delete(_waiter);
69254
+ resolve(origin || null);
69255
+ };
69256
+ parentOriginWaiters.add(_waiter);
69257
+ var timer = setTimeout(function () {
69258
+ parentOriginWaiters.delete(_waiter);
69259
+ if (!settled) {
69260
+ settled = true;
69261
+ resolve(trustedParentOrigin || null);
69262
+ }
69263
+ }, timeoutMs);
69264
+ });
69265
+ }
69067
69266
 
69068
69267
  /**
69069
69268
  * Gate every inbound message. event.origin is set by the browser and cannot be
69070
- * forged by the sender, so a non-copart parent (e.g. a malicious embedder) is
69071
- * rejected here before it can lock the origin or be processed.
69072
- * - must come from our direct parent window (single framer),
69073
- * - must be a copart origin (or the pinned SHELL_ORIGIN if configured),
69074
- * - once an origin is pinned, only that exact origin is accepted thereafter.
69269
+ * forged by the sender.
69075
69270
  */
69076
69271
  function isTrustedMessage(event) {
69077
- if (typeof window !== 'undefined' && event.source !== window.parent) return false;
69272
+ if (typeof window !== 'undefined' && event.source !== window.parent) {
69273
+ return false;
69274
+ }
69078
69275
  if (trustedParentOrigin) {
69079
- // Already pinned (via SHELL_ORIGIN or a prior capture): exact match only.
69080
- return event.origin === trustedParentOrigin;
69276
+ if (event.origin !== trustedParentOrigin) {
69277
+ console.warn("".concat(LOG_PREFIX, " ignored message \u2014 origin mismatch vs pinned shell"), {
69278
+ eventType: event.data && event.data.eventType,
69279
+ from: event.origin,
69280
+ pinned: trustedParentOrigin
69281
+ });
69282
+ return false;
69283
+ }
69284
+ return true;
69285
+ }
69286
+ if (!isAllowedOrigin(event.origin)) {
69287
+ console.warn("".concat(LOG_PREFIX, " ignored message \u2014 origin not allowlisted"), {
69288
+ eventType: event.data && event.data.eventType,
69289
+ from: event.origin
69290
+ });
69291
+ return false;
69081
69292
  }
69082
- if (!isAllowedOrigin(event.origin)) return false;
69083
- // First valid message from a copart parent — pin it.
69084
- trustedParentOrigin = event.origin;
69293
+ // First valid message from a copart parent — pin it (works on all browsers).
69294
+ pinTrustedParentOrigin(event.origin, "inbound:".concat(event.data && event.data.eventType || 'message'));
69085
69295
  return true;
69086
69296
  }
69297
+
69298
+ /**
69299
+ * @param {string} eventType
69300
+ * @param {object} [eventProps]
69301
+ * @param {{ allowWildcardHandshake?: boolean }} [options]
69302
+ * @returns {boolean} whether the browser postMessage was invoked
69303
+ */
69087
69304
  function post(eventType, eventProps) {
69088
- if (typeof window === 'undefined' || !window.parent) return;
69089
- // Never fall back to '*': if we have not yet learned the shell origin, use the
69090
- // '/' sentinel ("deliver only if same-origin as us") so nothing leaks to a
69091
- // malicious framer. In practice an inbound message pins the origin before the
69092
- // app sends anything.
69093
- var targetOrigin = trustedParentOrigin || '/';
69305
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
69306
+ if (typeof window === 'undefined' || !window.parent) return false;
69307
+ var targetOrigin = trustedParentOrigin;
69308
+ if (!targetOrigin) {
69309
+ if (options.allowWildcardHandshake) {
69310
+ // Handshake probe only — no secrets in the payload. Required for
69311
+ // cross-origin embeds on Safari/Firefox where parent origin is unknown
69312
+ // until the first inbound shell message arrives.
69313
+ targetOrigin = '*';
69314
+ } else if (isEmbeddedFrame()) {
69315
+ // NEVER use '/' while framed: it silently drops on subdomain (cross-origin).
69316
+ console.error("".concat(LOG_PREFIX, " blocked post \u2014 shell origin not pinned yet"), {
69317
+ eventType: eventType,
69318
+ diagnostics: getHandshakeDiagnostics()
69319
+ });
69320
+ return false;
69321
+ } else {
69322
+ targetOrigin = '/';
69323
+ }
69324
+ }
69094
69325
  window.parent.postMessage({
69095
69326
  eventType: eventType,
69096
69327
  eventProps: eventProps || {}
69097
69328
  }, targetOrigin);
69329
+ return true;
69330
+ }
69331
+ function delay(ms) {
69332
+ return new Promise(function (resolve) {
69333
+ return setTimeout(resolve, ms);
69334
+ });
69335
+ }
69336
+ function requestInitDataOnce(timeoutMs, allowWildcardHandshake) {
69337
+ return new Promise(function (_resolve) {
69338
+ var id = requestId();
69339
+ var timer = setTimeout(function () {
69340
+ if (pending.has(id)) {
69341
+ pending.delete(id);
69342
+ console.warn("".concat(LOG_PREFIX, " GET_INIT_DATA attempt timed out"), {
69343
+ requestId: id,
69344
+ timeoutMs: timeoutMs,
69345
+ usedWildcard: allowWildcardHandshake,
69346
+ shellOrigin: trustedParentOrigin
69347
+ });
69348
+ _resolve(null);
69349
+ }
69350
+ }, timeoutMs);
69351
+ pending.set(id, {
69352
+ resolve: function resolve(result) {
69353
+ clearTimeout(timer);
69354
+ _resolve(result);
69355
+ },
69356
+ reject: function reject() {
69357
+ clearTimeout(timer);
69358
+ _resolve(null);
69359
+ }
69360
+ });
69361
+ var sent = post(IFRAME_EVENTS.GET_INIT_DATA, {
69362
+ requestId: id
69363
+ }, {
69364
+ allowWildcardHandshake: allowWildcardHandshake
69365
+ });
69366
+ console.info("".concat(LOG_PREFIX, " GET_INIT_DATA sent"), {
69367
+ requestId: id,
69368
+ usedWildcard: allowWildcardHandshake,
69369
+ shellOrigin: trustedParentOrigin,
69370
+ sent: sent
69371
+ });
69372
+ if (!sent) {
69373
+ clearTimeout(timer);
69374
+ pending.delete(id);
69375
+ _resolve(null);
69376
+ }
69377
+ });
69378
+ }
69379
+
69380
+ /**
69381
+ * Fetch bootstrap init data from the shell.
69382
+ * All-browser / cross-origin safe:
69383
+ * - does NOT require ancestorOrigins or referrer
69384
+ * - sends GET_INIT_DATA with '*' until parent origin is pinned
69385
+ * - retries so a request that arrives before the shell listener is attached
69386
+ * is not a permanent failure
69387
+ * - first trusted INIT_DATA / LOAD_URI pins the parent for later secret posts
69388
+ */
69389
+ function getInitData() {
69390
+ return _getInitData.apply(this, arguments);
69391
+ }
69392
+ function _getInitData() {
69393
+ _getInitData = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee() {
69394
+ var timeoutMs,
69395
+ _inferred,
69396
+ attempts,
69397
+ perAttemptTimeout,
69398
+ attempt,
69399
+ allowWildcardHandshake,
69400
+ result,
69401
+ _args = arguments;
69402
+ return _regenerator().w(function (_context) {
69403
+ while (1) switch (_context.n) {
69404
+ case 0:
69405
+ timeoutMs = _args.length > 0 && _args[0] !== undefined ? _args[0] : 5000;
69406
+ // Optional fast-path only — never block the handshake on browser-specific APIs.
69407
+ if (!trustedParentOrigin) {
69408
+ _inferred = tryInferParentOrigin();
69409
+ if (_inferred) pinTrustedParentOrigin(_inferred, 'infer-before-handshake');
69410
+ }
69411
+ console.info("".concat(LOG_PREFIX, " handshake start"), getHandshakeDiagnostics());
69412
+ attempts = 3; // Full window per attempt — shell may await permission fetches on cold load.
69413
+ perAttemptTimeout = Math.max(timeoutMs, 5000);
69414
+ attempt = 1;
69415
+ case 1:
69416
+ if (!(attempt <= attempts)) {
69417
+ _context.n = 5;
69418
+ break;
69419
+ }
69420
+ allowWildcardHandshake = !trustedParentOrigin;
69421
+ console.info("".concat(LOG_PREFIX, " GET_INIT_DATA attempt"), {
69422
+ attempt: attempt,
69423
+ attempts: attempts,
69424
+ allowWildcardHandshake: allowWildcardHandshake,
69425
+ shellOrigin: trustedParentOrigin
69426
+ });
69427
+ _context.n = 2;
69428
+ return requestInitDataOnce(perAttemptTimeout, allowWildcardHandshake);
69429
+ case 2:
69430
+ result = _context.v;
69431
+ if (!result) {
69432
+ _context.n = 3;
69433
+ break;
69434
+ }
69435
+ console.info("".concat(LOG_PREFIX, " handshake success"), {
69436
+ attempt: attempt,
69437
+ shellOrigin: trustedParentOrigin,
69438
+ hasLogin: !!(result && result.login),
69439
+ hasAccessToken: !!(result && result.accessToken)
69440
+ });
69441
+ return _context.a(2, result);
69442
+ case 3:
69443
+ if (!(attempt < attempts)) {
69444
+ _context.n = 4;
69445
+ break;
69446
+ }
69447
+ console.warn("".concat(LOG_PREFIX, " GET_INIT_DATA attempt failed; retrying"), {
69448
+ attempt: attempt,
69449
+ attempts: attempts,
69450
+ shellOrigin: trustedParentOrigin,
69451
+ diagnostics: getHandshakeDiagnostics()
69452
+ });
69453
+ _context.n = 4;
69454
+ return delay(200);
69455
+ case 4:
69456
+ attempt += 1;
69457
+ _context.n = 1;
69458
+ break;
69459
+ case 5:
69460
+ console.error("".concat(LOG_PREFIX, " handshake FAILED \u2014 no INIT_DATA from shell"), {
69461
+ attempts: attempts,
69462
+ perAttemptTimeout: perAttemptTimeout,
69463
+ diagnostics: getHandshakeDiagnostics()
69464
+ });
69465
+ return _context.a(2, null);
69466
+ }
69467
+ }, _callee);
69468
+ }));
69469
+ return _getInitData.apply(this, arguments);
69098
69470
  }
69099
69471
  function handleMessage(event) {
69100
69472
  if (!isTrustedMessage(event)) return;
@@ -69103,7 +69475,18 @@ function handleMessage(event) {
69103
69475
  var _data$eventProps = data.eventProps,
69104
69476
  eventProps = _data$eventProps === void 0 ? {} : _data$eventProps;
69105
69477
  var id = eventProps.requestId;
69106
- if (!id || !pending.has(id)) return;
69478
+ if (!id || !pending.has(id)) {
69479
+ // LOAD_URI / STORAGE_CHANGED etc. are handled by other listeners; only log
69480
+ // orphaned RPC responses which indicate a timeout/retry race.
69481
+ if (data.eventType === IFRAME_EVENTS.INIT_DATA || data.eventType === IFRAME_EVENTS.FETCH_RESPONSE || data.eventType === IFRAME_EVENTS.STORAGE_RESPONSE || data.eventType === IFRAME_EVENTS.ACCESS_RESPONSE) {
69482
+ console.warn("".concat(LOG_PREFIX, " ignored RPC response \u2014 no matching pending request"), {
69483
+ eventType: data.eventType,
69484
+ requestId: id,
69485
+ pendingCount: pending.size
69486
+ });
69487
+ }
69488
+ return;
69489
+ }
69107
69490
  var _pending$get = pending.get(id),
69108
69491
  resolve = _pending$get.resolve,
69109
69492
  reject = _pending$get.reject,
@@ -69124,11 +69507,8 @@ function handleMessage(event) {
69124
69507
  var _eventProps$result;
69125
69508
  var resultData = (_eventProps$result = eventProps.result) === null || _eventProps$result === void 0 ? void 0 : _eventProps$result.data;
69126
69509
  if (pendingResponseType === 'arraybuffer') {
69127
- if (resultData instanceof ArrayBuffer) ; else {
69128
- // Shell returned non-binary for a request that expected arraybuffer.
69129
- // This means Step 2 (shell) has not been deployed yet, or the shell
69130
- // is not forwarding responseType to its own axios call.
69131
- console.warn('[iframe-bridge/transport] FETCH_RESPONSE expected ArrayBuffer but got non-binary — shell may not support responseType yet', {
69510
+ if (!(resultData instanceof ArrayBuffer)) {
69511
+ console.warn("".concat(LOG_PREFIX, " FETCH_RESPONSE expected ArrayBuffer but got non-binary"), {
69132
69512
  requestId: id,
69133
69513
  actualType: _typeof$1(resultData),
69134
69514
  isNull: resultData == null
@@ -69156,25 +69536,20 @@ function sendFetchRequest(payload) {
69156
69536
  var signal = payload.signal,
69157
69537
  restPayload = _objectWithoutProperties(payload, _excluded$1);
69158
69538
  return new Promise(function (resolve, reject) {
69159
- // Reject immediately if the signal is already aborted before we even send
69160
69539
  if (signal !== null && signal !== void 0 && signal.aborted) {
69161
69540
  reject(new DOMException('Request aborted', 'AbortError'));
69162
69541
  return;
69163
69542
  }
69164
69543
  var id = requestId();
69165
- // store responseType so the response handler can detect a binary/non-binary mismatch
69166
69544
  pending.set(id, {
69167
69545
  resolve: resolve,
69168
69546
  reject: reject,
69169
69547
  responseType: payload.responseType
69170
69548
  });
69171
-
69172
- // signal cannot be transferred through postMessage — handle abort locally
69173
69549
  if (signal) {
69174
69550
  var onAbort = function onAbort() {
69175
69551
  if (pending.has(id)) {
69176
69552
  pending.delete(id);
69177
- // Notify the shell so it can cancel its own request if wired up
69178
69553
  post(IFRAME_EVENTS.CANCEL_REQUEST, {
69179
69554
  requestId: id
69180
69555
  });
@@ -69185,103 +69560,87 @@ function sendFetchRequest(payload) {
69185
69560
  once: true
69186
69561
  });
69187
69562
  }
69188
-
69189
- // signal is intentionally excluded from the message — it's a non-serialisable DOM object
69190
- post(IFRAME_EVENTS.FETCH_REQUEST, _objectSpread2(_objectSpread2({}, restPayload), {}, {
69563
+ var sent = post(IFRAME_EVENTS.FETCH_REQUEST, _objectSpread2(_objectSpread2({}, restPayload), {}, {
69191
69564
  requestId: id
69192
69565
  }));
69566
+ if (!sent) {
69567
+ pending.delete(id);
69568
+ reject(new Error('iframe-bridge: FETCH_REQUEST blocked — shell origin not pinned'));
69569
+ }
69193
69570
  });
69194
69571
  }
69195
69572
  function sendStorageGet(payload) {
69196
69573
  var timeoutMs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : STORAGE_REQUEST_TIMEOUT_MS;
69197
- return new Promise(function (_resolve) {
69574
+ return new Promise(function (_resolve2) {
69198
69575
  var id = requestId();
69199
69576
  var timer = setTimeout(function () {
69200
69577
  if (pending.has(id)) {
69201
69578
  pending.delete(id);
69202
- console.warn('[iframe-bridge/transport] STORAGE_GET timed out', {
69579
+ console.warn("".concat(LOG_PREFIX, " STORAGE_GET timed out"), {
69203
69580
  op: payload === null || payload === void 0 ? void 0 : payload.op,
69204
69581
  key: payload === null || payload === void 0 ? void 0 : payload.key,
69205
- timeoutMs: timeoutMs
69582
+ timeoutMs: timeoutMs,
69583
+ shellOrigin: trustedParentOrigin
69206
69584
  });
69207
- _resolve(undefined);
69585
+ _resolve2(undefined);
69208
69586
  }
69209
69587
  }, timeoutMs);
69210
69588
  pending.set(id, {
69211
69589
  resolve: function resolve(result) {
69212
69590
  clearTimeout(timer);
69213
- _resolve(result);
69591
+ _resolve2(result);
69214
69592
  },
69215
69593
  reject: function reject() {
69216
69594
  clearTimeout(timer);
69217
- _resolve(undefined);
69595
+ _resolve2(undefined);
69218
69596
  }
69219
69597
  });
69220
- post(IFRAME_EVENTS.STORAGE_GET, _objectSpread2(_objectSpread2({}, payload), {}, {
69598
+ var sent = post(IFRAME_EVENTS.STORAGE_GET, _objectSpread2(_objectSpread2({}, payload), {}, {
69221
69599
  requestId: id
69222
69600
  }));
69601
+ if (!sent) {
69602
+ clearTimeout(timer);
69603
+ pending.delete(id);
69604
+ _resolve2(undefined);
69605
+ }
69223
69606
  });
69224
69607
  }
69225
69608
  function sendStorageSet(payload) {
69226
69609
  var timeoutMs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : STORAGE_REQUEST_TIMEOUT_MS;
69227
- return new Promise(function (_resolve2) {
69610
+ return new Promise(function (_resolve3) {
69228
69611
  var id = requestId();
69229
69612
  var timer = setTimeout(function () {
69230
69613
  if (pending.has(id)) {
69231
69614
  pending.delete(id);
69232
- console.warn('[iframe-bridge/transport] STORAGE_SET timed out', {
69615
+ console.warn("".concat(LOG_PREFIX, " STORAGE_SET timed out"), {
69233
69616
  op: payload === null || payload === void 0 ? void 0 : payload.op,
69234
69617
  key: payload === null || payload === void 0 ? void 0 : payload.key,
69235
- timeoutMs: timeoutMs
69618
+ timeoutMs: timeoutMs,
69619
+ shellOrigin: trustedParentOrigin
69236
69620
  });
69237
- _resolve2(undefined);
69621
+ _resolve3(undefined);
69238
69622
  }
69239
69623
  }, timeoutMs);
69240
69624
  pending.set(id, {
69241
69625
  resolve: function resolve(result) {
69242
69626
  clearTimeout(timer);
69243
- _resolve2(result);
69627
+ _resolve3(result);
69244
69628
  },
69245
69629
  reject: function reject() {
69246
69630
  clearTimeout(timer);
69247
- _resolve2(undefined);
69631
+ _resolve3(undefined);
69248
69632
  }
69249
69633
  });
69250
- post(IFRAME_EVENTS.STORAGE_SET, _objectSpread2(_objectSpread2({}, payload), {}, {
69634
+ var sent = post(IFRAME_EVENTS.STORAGE_SET, _objectSpread2(_objectSpread2({}, payload), {}, {
69251
69635
  requestId: id
69252
69636
  }));
69637
+ if (!sent) {
69638
+ clearTimeout(timer);
69639
+ pending.delete(id);
69640
+ _resolve3(undefined);
69641
+ }
69253
69642
  });
69254
69643
  }
69255
- function getInitData() {
69256
- return new Promise(function (_resolve4) {
69257
- var id = requestId();
69258
- var timer = setTimeout(function () {
69259
- if (pending.has(id)) {
69260
- pending.delete(id);
69261
- _resolve4(null);
69262
- }
69263
- }, 5000);
69264
- pending.set(id, {
69265
- resolve: function resolve(result) {
69266
- clearTimeout(timer);
69267
- _resolve4(result);
69268
- },
69269
- reject: function reject() {
69270
- clearTimeout(timer);
69271
- _resolve4(null);
69272
- }
69273
- });
69274
- post(IFRAME_EVENTS.GET_INIT_DATA, {
69275
- requestId: id
69276
- });
69277
- });
69278
- }
69279
-
69280
- /**
69281
- * The shell origin we are pinned to (learned from the handshake or SHELL_ORIGIN).
69282
- * Null until the first valid inbound message arrives. Used to build absolute
69283
- * shell URLs (e.g. AppLink opening a shell route in a new tab).
69284
- */
69285
69644
  function getShellOrigin() {
69286
69645
  return trustedParentOrigin;
69287
69646
  }
@@ -69314,11 +69673,6 @@ function postCountsAvailable() {
69314
69673
  /**
69315
69674
  * Push nav badge counts to the shell.
69316
69675
  * @param {Record<string, Record<string, import('../utilities/navCountStatus').NavCountEntry>>} countsByMenu
69317
- * Top-level menu route → sub-route counts. Each value may be:
69318
- * - a plain number (count only, no badge color), or
69319
- * - `{ count, status }` where status is pre-resolved in the iframe (1|2|3).
69320
- * Example:
69321
- * { tasks: { 'open-tasks': { count: 750, status: 2 } }, admin: { 'staged-users': 12 } }
69322
69676
  */
69323
69677
  function postNavCounts(countsByMenu) {
69324
69678
  if (!countsByMenu || _typeof$1(countsByMenu) !== 'object') return;
@@ -69374,6 +69728,9 @@ function extractUriFromFullPath(fullPath) {
69374
69728
  function getInitialUri() {
69375
69729
  if (typeof window !== 'undefined' && window.__IFRAME_EARLY_LOAD_URI != null) {
69376
69730
  var uri = window.__IFRAME_EARLY_LOAD_URI;
69731
+ console.info("".concat(LOG_PREFIX, " getInitialUri from early LOAD_URI"), {
69732
+ uri: uri
69733
+ });
69377
69734
  return Promise.resolve(uri === '' ? '/' : uri);
69378
69735
  }
69379
69736
  return new Promise(function (resolve) {
@@ -69386,6 +69743,9 @@ function getInitialUri() {
69386
69743
  if (_uri == null && event.data.eventProps.fullPath) {
69387
69744
  _uri = extractUriFromFullPath(event.data.eventProps.fullPath);
69388
69745
  }
69746
+ console.info("".concat(LOG_PREFIX, " getInitialUri from LOAD_URI"), {
69747
+ uri: _uri
69748
+ });
69389
69749
  resolve(_uri == null || _uri === '' ? '/' : _uri);
69390
69750
  }
69391
69751
  }
@@ -69393,6 +69753,10 @@ function getInitialUri() {
69393
69753
  var timer = setTimeout(function () {
69394
69754
  window.removeEventListener('message', onMessage);
69395
69755
  var early = typeof window !== 'undefined' && window.__IFRAME_EARLY_LOAD_URI;
69756
+ console.warn("".concat(LOG_PREFIX, " getInitialUri timed out \u2014 defaulting"), {
69757
+ uri: early || '/',
69758
+ diagnostics: getHandshakeDiagnostics()
69759
+ });
69396
69760
  resolve(early || '/');
69397
69761
  }, 3000);
69398
69762
  });
@@ -70657,6 +71021,12 @@ function Crumb(_ref) {
70657
71021
  * catch-all for raw <a>/window.open/forms) use this so they agree on what is
70658
71022
  * "internal" (a shell route), "external" (a foreign site), or something we
70659
71023
  * should leave to the browser.
71024
+ *
71025
+ * Cross-origin note: after handshake, getShellOrigin() is the portal origin
71026
+ * (e.g. https://g2-qa4.copart.com), which may differ from window.location.origin
71027
+ * (the app subdomain). Relative hrefs are resolved against the shell origin so
71028
+ * they route through the portal, not the app host. This does not depend on
71029
+ * ancestorOrigins/referrer — only on the pinned shell origin from handshake.
70660
71030
  */
70661
71031
 
70662
71032
  // Schemes that are not frame navigations we manage — let the browser handle.
@@ -70681,6 +71051,7 @@ function classifyHref(href) {
70681
71051
  };
70682
71052
  var shellOrigin = getShellOrigin();
70683
71053
  var appOrigin = typeof window !== 'undefined' ? window.location.origin : undefined;
71054
+ // Prefer pinned shell origin so relative links are portal routes, not app-subdomain URLs.
70684
71055
  var base = shellOrigin || appOrigin;
70685
71056
  var parsed;
70686
71057
  try {
@@ -70958,6 +71329,9 @@ var iframeFacade = {
70958
71329
  getInitDataForBootstrap: getInitDataForBootstrap,
70959
71330
  sendStorageGet: sendStorageGet,
70960
71331
  getShellOrigin: getShellOrigin,
71332
+ pinTrustedParentOrigin: pinTrustedParentOrigin,
71333
+ waitForTrustedParentOrigin: waitForTrustedParentOrigin,
71334
+ getHandshakeDiagnostics: getHandshakeDiagnostics,
70961
71335
  IFRAME_EVENTS: IFRAME_EVENTS
70962
71336
  }
70963
71337
  };
@@ -70965,6 +71339,8 @@ var iframeFacade = {
70965
71339
  /**
70966
71340
  * Register a synchronous LOAD_URI listener before async bootstrap loads.
70967
71341
  * Call this from the app entry (index.js) before dynamic-importing bootstrap.
71342
+ * Also pins the shell origin so later secret-carrying posts can target the real
71343
+ * parent (all browsers — does not require ancestorOrigins/referrer).
70968
71344
  */
70969
71345
  function registerEarlyLoadUriListener() {
70970
71346
  if (typeof window === 'undefined') return;
@@ -70972,9 +71348,16 @@ function registerEarlyLoadUriListener() {
70972
71348
  window.__IFRAME_EARLY_LOAD_URI_LISTENER_REGISTERED = true;
70973
71349
  window.__IFRAME_EARLY_LOAD_URI = null;
70974
71350
  window.addEventListener('message', function (event) {
71351
+ if (event.source !== window.parent) return;
70975
71352
  if (!isAllowedOrigin(event.origin)) return;
70976
71353
  if (event.data && event.data.eventType === IFRAME_EVENTS.LOAD_URI && event.data.eventProps) {
71354
+ var pinned = pinTrustedParentOrigin(event.origin, 'early-LOAD_URI');
70977
71355
  window.__IFRAME_EARLY_LOAD_URI = event.data.eventProps.uri || '/';
71356
+ console.info('[iframe-bridge] early LOAD_URI received', {
71357
+ uri: window.__IFRAME_EARLY_LOAD_URI,
71358
+ shellOrigin: event.origin,
71359
+ pinned: pinned
71360
+ });
70978
71361
  }
70979
71362
  });
70980
71363
  }
@@ -71125,7 +71508,7 @@ function bootstrapIframeApp(_x3) {
71125
71508
  }
71126
71509
  function _bootstrapIframeApp() {
71127
71510
  _bootstrapIframeApp = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee4(options) {
71128
- var _ref4, _ref4$appName, appName, permissionKeysOption, rootSelector, onInitCache, render, _ref4$standaloneError, standaloneErrorMessage, _ref4$fetchConfigFrom, fetchConfigFromShell, _ref4$configFallbackU, configFallbackUri, validateAppConfig, _ref4$permissionsOnly, permissionsOnlyIfArray, _ref4$autoSendAppEnv, autoSendAppEnv, toolkitEnv, _ref4$mihelpAgentProp, mihelpAgentProps, _ref4$installNavGuard, installNavGuard, rootNode, bridge, fetcher, storage, getInitialUri, getInitData, setInitCache, setExtraLocal, sendStorageGet, setAppName, sendAppEnv, resolveAppAuthName, _yield$Promise$all, _yield$Promise$all2, initialUri, initData, getCachedLocalItem, appAuthName, permissionKeys, tasks, _t;
71511
+ var _ref4, _ref4$appName, appName, permissionKeysOption, rootSelector, onInitCache, render, _ref4$standaloneError, standaloneErrorMessage, _ref4$fetchConfigFrom, fetchConfigFromShell, _ref4$configFallbackU, configFallbackUri, validateAppConfig, _ref4$permissionsOnly, permissionsOnlyIfArray, _ref4$autoSendAppEnv, autoSendAppEnv, toolkitEnv, _ref4$mihelpAgentProp, mihelpAgentProps, _ref4$installNavGuard, installNavGuard, rootNode, bridge, fetcher, storage, getInitialUri, getInitData, setInitCache, setExtraLocal, sendStorageGet, setAppName, sendAppEnv, resolveAppAuthName, getShellOrigin, getHandshakeDiagnostics, _yield$Promise$all, _yield$Promise$all2, initialUri, initData, getCachedLocalItem, appAuthName, permissionKeys, tasks, _t;
71129
71512
  return _regenerator().w(function (_context4) {
71130
71513
  while (1) switch (_context4.p = _context4.n) {
71131
71514
  case 0:
@@ -71160,7 +71543,12 @@ function _bootstrapIframeApp() {
71160
71543
  installNavigationGuard();
71161
71544
  }
71162
71545
  bridge = iframeFacade.bridge, fetcher = iframeFacade.fetcher, storage = iframeFacade.storage;
71163
- getInitialUri = bridge.getInitialUri, getInitData = bridge.getInitData, setInitCache = bridge.setInitCache, setExtraLocal = bridge.setExtraLocal, sendStorageGet = bridge.sendStorageGet, setAppName = bridge.setAppName, sendAppEnv = bridge.sendAppEnv, resolveAppAuthName = bridge.resolveAppAuthName;
71546
+ getInitialUri = bridge.getInitialUri, getInitData = bridge.getInitData, setInitCache = bridge.setInitCache, setExtraLocal = bridge.setExtraLocal, sendStorageGet = bridge.sendStorageGet, setAppName = bridge.setAppName, sendAppEnv = bridge.sendAppEnv, resolveAppAuthName = bridge.resolveAppAuthName, getShellOrigin = bridge.getShellOrigin, getHandshakeDiagnostics = bridge.getHandshakeDiagnostics;
71547
+ console.info('[Iframe] bootstrap start', {
71548
+ appName: appName,
71549
+ appOrigin: typeof window !== 'undefined' ? window.location.origin : null,
71550
+ diagnostics: typeof getHandshakeDiagnostics === 'function' ? getHandshakeDiagnostics() : null
71551
+ });
71164
71552
  _context4.n = 4;
71165
71553
  return Promise.all([getInitialUri(), getInitData()]);
71166
71554
  case 4:
@@ -71178,10 +71566,20 @@ function _bootstrapIframeApp() {
71178
71566
  }
71179
71567
  setInitCache(initData);
71180
71568
  if (onInitCache) onInitCache(initData);
71569
+ console.info('[Iframe] bootstrap ready', {
71570
+ appName: appName,
71571
+ initialUri: initialUri,
71572
+ shellOrigin: typeof getShellOrigin === 'function' ? getShellOrigin() : null
71573
+ });
71181
71574
  _context4.n = 6;
71182
71575
  break;
71183
71576
  case 5:
71184
- console.error('[Iframe] failed to get initData from shell (handshake timeout)');
71577
+ console.error('[Iframe] failed to get initData from shell (handshake timeout)', {
71578
+ appName: appName,
71579
+ initialUri: initialUri,
71580
+ shellOrigin: typeof getShellOrigin === 'function' ? getShellOrigin() : null,
71581
+ diagnostics: typeof getHandshakeDiagnostics === 'function' ? getHandshakeDiagnostics() : null
71582
+ });
71185
71583
  renderStandaloneError(rootNode, 'Failed to connect to the portal. Please refresh.');
71186
71584
  return _context4.a(2);
71187
71585
  case 6: